@mmmbuto/nexuscrew 0.9.75 → 0.9.76

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.
@@ -0,0 +1,169 @@
1
+ (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}})();function ov(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ep={exports:{}},Fl={},tp={exports:{}},qt={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Bw;function FN(){if(Bw)return qt;Bw=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),_=Symbol.iterator;function g(A){return A===null||typeof A!="object"?null:(A=_&&A[_]||A["@@iterator"],typeof A=="function"?A:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,j={};function C(A,U,Q){this.props=A,this.context=U,this.refs=j,this.updater=Q||b}C.prototype.isReactComponent={},C.prototype.setState=function(A,U){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,U,"setState")},C.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function N(){}N.prototype=C.prototype;function E(A,U,Q){this.props=A,this.context=U,this.refs=j,this.updater=Q||b}var O=E.prototype=new N;O.constructor=E,S(O,C.prototype),O.isPureReactComponent=!0;var x=Array.isArray,W=Object.prototype.hasOwnProperty,$={current:null},J={key:!0,ref:!0,__self:!0,__source:!0};function q(A,U,Q){var ae,re={},je=null,te=null;if(U!=null)for(ae in U.ref!==void 0&&(te=U.ref),U.key!==void 0&&(je=""+U.key),U)W.call(U,ae)&&!J.hasOwnProperty(ae)&&(re[ae]=U[ae]);var ne=arguments.length-2;if(ne===1)re.children=Q;else if(1<ne){for(var me=Array(ne),we=0;we<ne;we++)me[we]=arguments[we+2];re.children=me}if(A&&A.defaultProps)for(ae in ne=A.defaultProps,ne)re[ae]===void 0&&(re[ae]=ne[ae]);return{$$typeof:t,type:A,key:je,ref:te,props:re,_owner:$.current}}function V(A,U){return{$$typeof:t,type:A.type,key:U,ref:A.ref,props:A.props,_owner:A._owner}}function ie(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function K(A){var U={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(Q){return U[Q]})}var B=/\/+/g;function I(A,U){return typeof A=="object"&&A!==null&&A.key!=null?K(""+A.key):U.toString(36)}function D(A,U,Q,ae,re){var je=typeof A;(je==="undefined"||je==="boolean")&&(A=null);var te=!1;if(A===null)te=!0;else switch(je){case"string":case"number":te=!0;break;case"object":switch(A.$$typeof){case t:case e:te=!0}}if(te)return te=A,re=re(te),A=ae===""?"."+I(te,0):ae,x(re)?(Q="",A!=null&&(Q=A.replace(B,"$&/")+"/"),D(re,U,Q,"",function(we){return we})):re!=null&&(ie(re)&&(re=V(re,Q+(!re.key||te&&te.key===re.key?"":(""+re.key).replace(B,"$&/")+"/")+A)),U.push(re)),1;if(te=0,ae=ae===""?".":ae+":",x(A))for(var ne=0;ne<A.length;ne++){je=A[ne];var me=ae+I(je,ne);te+=D(je,U,Q,me,re)}else if(me=g(A),typeof me=="function")for(A=me.call(A),ne=0;!(je=A.next()).done;)je=je.value,me=ae+I(je,ne++),te+=D(je,U,Q,me,re);else if(je==="object")throw U=String(A),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.");return te}function T(A,U,Q){if(A==null)return A;var ae=[],re=0;return D(A,ae,"","",function(je){return U.call(Q,je,re++)}),ae}function z(A){if(A._status===-1){var U=A._result;U=U(),U.then(function(Q){(A._status===0||A._status===-1)&&(A._status=1,A._result=Q)},function(Q){(A._status===0||A._status===-1)&&(A._status=2,A._result=Q)}),A._status===-1&&(A._status=0,A._result=U)}if(A._status===1)return A._result.default;throw A._result}var R={current:null},M={transition:null},L={ReactCurrentDispatcher:R,ReactCurrentBatchConfig:M,ReactCurrentOwner:$};function H(){throw Error("act(...) is not supported in production builds of React.")}return qt.Children={map:T,forEach:function(A,U,Q){T(A,function(){U.apply(this,arguments)},Q)},count:function(A){var U=0;return T(A,function(){U++}),U},toArray:function(A){return T(A,function(U){return U})||[]},only:function(A){if(!ie(A))throw Error("React.Children.only expected to receive a single React element child.");return A}},qt.Component=C,qt.Fragment=n,qt.Profiler=i,qt.PureComponent=E,qt.StrictMode=s,qt.Suspense=h,qt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=L,qt.act=H,qt.cloneElement=function(A,U,Q){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var ae=S({},A.props),re=A.key,je=A.ref,te=A._owner;if(U!=null){if(U.ref!==void 0&&(je=U.ref,te=$.current),U.key!==void 0&&(re=""+U.key),A.type&&A.type.defaultProps)var ne=A.type.defaultProps;for(me in U)W.call(U,me)&&!J.hasOwnProperty(me)&&(ae[me]=U[me]===void 0&&ne!==void 0?ne[me]:U[me])}var me=arguments.length-2;if(me===1)ae.children=Q;else if(1<me){ne=Array(me);for(var we=0;we<me;we++)ne[we]=arguments[we+2];ae.children=ne}return{$$typeof:t,type:A.type,key:re,ref:je,props:ae,_owner:te}},qt.createContext=function(A){return A={$$typeof:c,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},A.Provider={$$typeof:l,_context:A},A.Consumer=A},qt.createElement=q,qt.createFactory=function(A){var U=q.bind(null,A);return U.type=A,U},qt.createRef=function(){return{current:null}},qt.forwardRef=function(A){return{$$typeof:u,render:A}},qt.isValidElement=ie,qt.lazy=function(A){return{$$typeof:v,_payload:{_status:-1,_result:A},_init:z}},qt.memo=function(A,U){return{$$typeof:p,type:A,compare:U===void 0?null:U}},qt.startTransition=function(A){var U=M.transition;M.transition={};try{A()}finally{M.transition=U}},qt.unstable_act=H,qt.useCallback=function(A,U){return R.current.useCallback(A,U)},qt.useContext=function(A){return R.current.useContext(A)},qt.useDebugValue=function(){},qt.useDeferredValue=function(A){return R.current.useDeferredValue(A)},qt.useEffect=function(A,U){return R.current.useEffect(A,U)},qt.useId=function(){return R.current.useId()},qt.useImperativeHandle=function(A,U,Q){return R.current.useImperativeHandle(A,U,Q)},qt.useInsertionEffect=function(A,U){return R.current.useInsertionEffect(A,U)},qt.useLayoutEffect=function(A,U){return R.current.useLayoutEffect(A,U)},qt.useMemo=function(A,U){return R.current.useMemo(A,U)},qt.useReducer=function(A,U,Q){return R.current.useReducer(A,U,Q)},qt.useRef=function(A){return R.current.useRef(A)},qt.useState=function(A){return R.current.useState(A)},qt.useSyncExternalStore=function(A,U,Q){return R.current.useSyncExternalStore(A,U,Q)},qt.useTransition=function(){return R.current.useTransition()},qt.version="18.3.1",qt}var $w;function av(){return $w||($w=1,tp.exports=FN()),tp.exports}/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var zw;function HN(){if(zw)return Fl;zw=1;var t=av(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(u,h,p){var v,_={},g=null,b=null;p!==void 0&&(g=""+p),h.key!==void 0&&(g=""+h.key),h.ref!==void 0&&(b=h.ref);for(v in h)s.call(h,v)&&!l.hasOwnProperty(v)&&(_[v]=h[v]);if(u&&u.defaultProps)for(v in h=u.defaultProps,h)_[v]===void 0&&(_[v]=h[v]);return{$$typeof:e,type:u,key:g,ref:b,props:_,_owner:i.current}}return Fl.Fragment=n,Fl.jsx=c,Fl.jsxs=c,Fl}var Fw;function UN(){return Fw||(Fw=1,ep.exports=HN()),ep.exports}var a=UN(),y=av();const WN=ov(y);var Gu={},np={exports:{}},Vs={},sp={exports:{}},ip={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */var Hw;function qN(){return Hw||(Hw=1,(function(t){function e(M,L){var H=M.length;M.push(L);e:for(;0<H;){var A=H-1>>>1,U=M[A];if(0<i(U,L))M[A]=L,M[H]=U,H=A;else break e}}function n(M){return M.length===0?null:M[0]}function s(M){if(M.length===0)return null;var L=M[0],H=M.pop();if(H!==L){M[0]=H;e:for(var A=0,U=M.length,Q=U>>>1;A<Q;){var ae=2*(A+1)-1,re=M[ae],je=ae+1,te=M[je];if(0>i(re,H))je<U&&0>i(te,re)?(M[A]=te,M[je]=H,A=je):(M[A]=re,M[ae]=H,A=ae);else if(je<U&&0>i(te,H))M[A]=te,M[je]=H,A=je;else break e}}return L}function i(M,L){var H=M.sortIndex-L.sortIndex;return H!==0?H:M.id-L.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;t.unstable_now=function(){return l.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var h=[],p=[],v=1,_=null,g=3,b=!1,S=!1,j=!1,C=typeof setTimeout=="function"?setTimeout:null,N=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 O(M){for(var L=n(p);L!==null;){if(L.callback===null)s(p);else if(L.startTime<=M)s(p),L.sortIndex=L.expirationTime,e(h,L);else break;L=n(p)}}function x(M){if(j=!1,O(M),!S)if(n(h)!==null)S=!0,z(W);else{var L=n(p);L!==null&&R(x,L.startTime-M)}}function W(M,L){S=!1,j&&(j=!1,N(q),q=-1),b=!0;var H=g;try{for(O(L),_=n(h);_!==null&&(!(_.expirationTime>L)||M&&!K());){var A=_.callback;if(typeof A=="function"){_.callback=null,g=_.priorityLevel;var U=A(_.expirationTime<=L);L=t.unstable_now(),typeof U=="function"?_.callback=U:_===n(h)&&s(h),O(L)}else s(h);_=n(h)}if(_!==null)var Q=!0;else{var ae=n(p);ae!==null&&R(x,ae.startTime-L),Q=!1}return Q}finally{_=null,g=H,b=!1}}var $=!1,J=null,q=-1,V=5,ie=-1;function K(){return!(t.unstable_now()-ie<V)}function B(){if(J!==null){var M=t.unstable_now();ie=M;var L=!0;try{L=J(!0,M)}finally{L?I():($=!1,J=null)}}else $=!1}var I;if(typeof E=="function")I=function(){E(B)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,T=D.port2;D.port1.onmessage=B,I=function(){T.postMessage(null)}}else I=function(){C(B,0)};function z(M){J=M,$||($=!0,I())}function R(M,L){q=C(function(){M(t.unstable_now())},L)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(M){M.callback=null},t.unstable_continueExecution=function(){S||b||(S=!0,z(W))},t.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):V=0<M?Math.floor(1e3/M):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_getFirstCallbackNode=function(){return n(h)},t.unstable_next=function(M){switch(g){case 1:case 2:case 3:var L=3;break;default:L=g}var H=g;g=L;try{return M()}finally{g=H}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(M,L){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var H=g;g=M;try{return L()}finally{g=H}},t.unstable_scheduleCallback=function(M,L,H){var A=t.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?A+H:A):H=A,M){case 1:var U=-1;break;case 2:U=250;break;case 5:U=1073741823;break;case 4:U=1e4;break;default:U=5e3}return U=H+U,M={id:v++,callback:L,priorityLevel:M,startTime:H,expirationTime:U,sortIndex:-1},H>A?(M.sortIndex=H,e(p,M),n(h)===null&&M===n(p)&&(j?(N(q),q=-1):j=!0,R(x,H-A))):(M.sortIndex=U,e(h,M),S||b||(S=!0,z(W))),M},t.unstable_shouldYield=K,t.unstable_wrapCallback=function(M){var L=g;return function(){var H=g;g=L;try{return M.apply(this,arguments)}finally{g=H}}}})(ip)),ip}var Uw;function KN(){return Uw||(Uw=1,sp.exports=qN()),sp.exports}/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var Ww;function VN(){if(Ww)return Vs;Ww=1;var t=av(),e=KN();function n(r){for(var o="https://reactjs.org/docs/error-decoder.html?invariant="+r,d=1;d<arguments.length;d++)o+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+r+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,i={};function l(r,o){c(r,o),c(r+"Capture",o)}function c(r,o){for(i[r]=o,r=0;r<o.length;r++)s.add(o[r])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,p=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},_={};function g(r){return h.call(_,r)?!0:h.call(v,r)?!1:p.test(r)?_[r]=!0:(v[r]=!0,!1)}function b(r,o,d,m){if(d!==null&&d.type===0)return!1;switch(typeof o){case"function":case"symbol":return!0;case"boolean":return m?!1:d!==null?!d.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function S(r,o,d,m){if(o===null||typeof o>"u"||b(r,o,d,m))return!0;if(m)return!1;if(d!==null)switch(d.type){case 3:return!o;case 4:return o===!1;case 5:return isNaN(o);case 6:return isNaN(o)||1>o}return!1}function j(r,o,d,m,w,k,F){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=m,this.attributeNamespace=w,this.mustUseProperty=d,this.propertyName=r,this.type=o,this.sanitizeURL=k,this.removeEmptyString=F}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){C[r]=new j(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var o=r[0];C[o]=new j(o,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){C[r]=new j(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){C[r]=new j(r,2,!1,r,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){C[r]=new j(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){C[r]=new j(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){C[r]=new j(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){C[r]=new j(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){C[r]=new j(r,5,!1,r.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function E(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var o=r.replace(N,E);C[o]=new j(o,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var o=r.replace(N,E);C[o]=new j(o,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var o=r.replace(N,E);C[o]=new j(o,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){C[r]=new j(r,1,!1,r.toLowerCase(),null,!1,!1)}),C.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){C[r]=new j(r,1,!1,r.toLowerCase(),null,!0,!0)});function O(r,o,d,m){var w=C.hasOwnProperty(o)?C[o]:null;(w!==null?w.type!==0:m||!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(S(o,d,w,m)&&(d=null),m||w===null?g(o)&&(d===null?r.removeAttribute(o):r.setAttribute(o,""+d)):w.mustUseProperty?r[w.propertyName]=d===null?w.type===3?!1:"":d:(o=w.attributeName,m=w.attributeNamespace,d===null?r.removeAttribute(o):(w=w.type,d=w===3||w===4&&d===!0?"":""+d,m?r.setAttributeNS(m,o,d):r.setAttribute(o,d))))}var x=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,W=Symbol.for("react.element"),$=Symbol.for("react.portal"),J=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),V=Symbol.for("react.profiler"),ie=Symbol.for("react.provider"),K=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),R=Symbol.for("react.offscreen"),M=Symbol.iterator;function L(r){return r===null||typeof r!="object"?null:(r=M&&r[M]||r["@@iterator"],typeof r=="function"?r:null)}var H=Object.assign,A;function U(r){if(A===void 0)try{throw Error()}catch(d){var o=d.stack.trim().match(/\n( *(at )?)/);A=o&&o[1]||""}return`
34
+ `+A+r}var Q=!1;function ae(r,o){if(!r||Q)return"";Q=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(o)if(o=function(){throw Error()},Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(Ee){var m=Ee}Reflect.construct(r,[],o)}else{try{o.call()}catch(Ee){m=Ee}r.call(o.prototype)}else{try{throw Error()}catch(Ee){m=Ee}r()}}catch(Ee){if(Ee&&m&&typeof Ee.stack=="string"){for(var w=Ee.stack.split(`
35
+ `),k=m.stack.split(`
36
+ `),F=w.length-1,se=k.length-1;1<=F&&0<=se&&w[F]!==k[se];)se--;for(;1<=F&&0<=se;F--,se--)if(w[F]!==k[se]){if(F!==1||se!==1)do if(F--,se--,0>se||w[F]!==k[se]){var de=`
37
+ `+w[F].replace(" at new "," at ");return r.displayName&&de.includes("<anonymous>")&&(de=de.replace("<anonymous>",r.displayName)),de}while(1<=F&&0<=se);break}}}finally{Q=!1,Error.prepareStackTrace=d}return(r=r?r.displayName||r.name:"")?U(r):""}function re(r){switch(r.tag){case 5:return U(r.type);case 16:return U("Lazy");case 13:return U("Suspense");case 19:return U("SuspenseList");case 0:case 2:case 15:return r=ae(r.type,!1),r;case 11:return r=ae(r.type.render,!1),r;case 1:return r=ae(r.type,!0),r;default:return""}}function je(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case J:return"Fragment";case $:return"Portal";case V:return"Profiler";case q:return"StrictMode";case I:return"Suspense";case D:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case K:return(r.displayName||"Context")+".Consumer";case ie:return(r._context.displayName||"Context")+".Provider";case B:var o=r.render;return r=r.displayName,r||(r=o.displayName||o.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case T:return o=r.displayName||null,o!==null?o:je(r.type)||"Memo";case z:o=r._payload,r=r._init;try{return je(r(o))}catch{}}return null}function te(r){var o=r.type;switch(r.tag){case 24:return"Cache";case 9:return(o.displayName||"Context")+".Consumer";case 10:return(o._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=o.render,r=r.displayName||r.name||"",o.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return o;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return je(o);case 8:return o===q?"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 o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o}return null}function ne(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function me(r){var o=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function we(r){var o=me(r)?"checked":"value",d=Object.getOwnPropertyDescriptor(r.constructor.prototype,o),m=""+r[o];if(!r.hasOwnProperty(o)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var w=d.get,k=d.set;return Object.defineProperty(r,o,{configurable:!0,get:function(){return w.call(this)},set:function(F){m=""+F,k.call(this,F)}}),Object.defineProperty(r,o,{enumerable:d.enumerable}),{getValue:function(){return m},setValue:function(F){m=""+F},stopTracking:function(){r._valueTracker=null,delete r[o]}}}}function Fe(r){r._valueTracker||(r._valueTracker=we(r))}function Ae(r){if(!r)return!1;var o=r._valueTracker;if(!o)return!0;var d=o.getValue(),m="";return r&&(m=me(r)?r.checked?"true":"false":r.value),r=m,r!==d?(o.setValue(r),!0):!1}function He(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function X(r,o){var d=o.checked;return H({},o,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:d??r._wrapperState.initialChecked})}function ce(r,o){var d=o.defaultValue==null?"":o.defaultValue,m=o.checked!=null?o.checked:o.defaultChecked;d=ne(o.value!=null?o.value:d),r._wrapperState={initialChecked:m,initialValue:d,controlled:o.type==="checkbox"||o.type==="radio"?o.checked!=null:o.value!=null}}function Z(r,o){o=o.checked,o!=null&&O(r,"checked",o,!1)}function ge(r,o){Z(r,o);var d=ne(o.value),m=o.type;if(d!=null)m==="number"?(d===0&&r.value===""||r.value!=d)&&(r.value=""+d):r.value!==""+d&&(r.value=""+d);else if(m==="submit"||m==="reset"){r.removeAttribute("value");return}o.hasOwnProperty("value")?he(r,o.type,d):o.hasOwnProperty("defaultValue")&&he(r,o.type,ne(o.defaultValue)),o.checked==null&&o.defaultChecked!=null&&(r.defaultChecked=!!o.defaultChecked)}function Y(r,o,d){if(o.hasOwnProperty("value")||o.hasOwnProperty("defaultValue")){var m=o.type;if(!(m!=="submit"&&m!=="reset"||o.value!==void 0&&o.value!==null))return;o=""+r._wrapperState.initialValue,d||o===r.value||(r.value=o),r.defaultValue=o}d=r.name,d!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,d!==""&&(r.name=d)}function he(r,o,d){(o!=="number"||He(r.ownerDocument)!==r)&&(d==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+d&&(r.defaultValue=""+d))}var Ne=Array.isArray;function Ce(r,o,d,m){if(r=r.options,o){o={};for(var w=0;w<d.length;w++)o["$"+d[w]]=!0;for(d=0;d<r.length;d++)w=o.hasOwnProperty("$"+r[d].value),r[d].selected!==w&&(r[d].selected=w),w&&m&&(r[d].defaultSelected=!0)}else{for(d=""+ne(d),o=null,w=0;w<r.length;w++){if(r[w].value===d){r[w].selected=!0,m&&(r[w].defaultSelected=!0);return}o!==null||r[w].disabled||(o=r[w])}o!==null&&(o.selected=!0)}}function Ve(r,o){if(o.dangerouslySetInnerHTML!=null)throw Error(n(91));return H({},o,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function Ye(r,o){var d=o.value;if(d==null){if(d=o.children,o=o.defaultValue,d!=null){if(o!=null)throw Error(n(92));if(Ne(d)){if(1<d.length)throw Error(n(93));d=d[0]}o=d}o==null&&(o=""),d=o}r._wrapperState={initialValue:ne(d)}}function ht(r,o){var d=ne(o.value),m=ne(o.defaultValue);d!=null&&(d=""+d,d!==r.value&&(r.value=d),o.defaultValue==null&&r.defaultValue!==d&&(r.defaultValue=d)),m!=null&&(r.defaultValue=""+m)}function ze(r){var o=r.textContent;o===r._wrapperState.initialValue&&o!==""&&o!==null&&(r.value=o)}function ve(r){switch(r){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 Oe(r,o){return r==null||r==="http://www.w3.org/1999/xhtml"?ve(o):r==="http://www.w3.org/2000/svg"&&o==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var et,Ue=(function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(o,d,m,w){MSApp.execUnsafeLocalFunction(function(){return r(o,d,m,w)})}:r})(function(r,o){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=o;else{for(et=et||document.createElement("div"),et.innerHTML="<svg>"+o.valueOf().toString()+"</svg>",o=et.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;o.firstChild;)r.appendChild(o.firstChild)}});function st(r,o){if(o){var d=r.firstChild;if(d&&d===r.lastChild&&d.nodeType===3){d.nodeValue=o;return}}r.textContent=o}var ot={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},ee=["Webkit","ms","Moz","O"];Object.keys(ot).forEach(function(r){ee.forEach(function(o){o=o+r.charAt(0).toUpperCase()+r.substring(1),ot[o]=ot[r]})});function P(r,o,d){return o==null||typeof o=="boolean"||o===""?"":d||typeof o!="number"||o===0||ot.hasOwnProperty(r)&&ot[r]?(""+o).trim():o+"px"}function le(r,o){r=r.style;for(var d in o)if(o.hasOwnProperty(d)){var m=d.indexOf("--")===0,w=P(d,o[d],m);d==="float"&&(d="cssFloat"),m?r.setProperty(d,w):r[d]=w}}var _e=H({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 Me(r,o){if(o){if(_e[r]&&(o.children!=null||o.dangerouslySetInnerHTML!=null))throw Error(n(137,r));if(o.dangerouslySetInnerHTML!=null){if(o.children!=null)throw Error(n(60));if(typeof o.dangerouslySetInnerHTML!="object"||!("__html"in o.dangerouslySetInnerHTML))throw Error(n(61))}if(o.style!=null&&typeof o.style!="object")throw Error(n(62))}}function oe(r,o){if(r.indexOf("-")===-1)return typeof o.is=="string";switch(r){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 Be=null;function gt(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Lt=null,Nt=null,kt=null;function Kt(r){if(r=El(r)){if(typeof Lt!="function")throw Error(n(280));var o=r.stateNode;o&&(o=uu(o),Lt(r.stateNode,r.type,o))}}function ft(r){Nt?kt?kt.push(r):kt=[r]:Nt=r}function Vt(){if(Nt){var r=Nt,o=kt;if(kt=Nt=null,Kt(r),o)for(r=0;r<o.length;r++)Kt(o[r])}}function It(r,o){return r(o)}function Xt(){}var Dt=!1;function Cn(r,o,d){if(Dt)return r(o,d);Dt=!0;try{return It(r,o,d)}finally{Dt=!1,(Nt!==null||kt!==null)&&(Xt(),Vt())}}function nn(r,o){var d=r.stateNode;if(d===null)return null;var m=uu(d);if(m===null)return null;d=m[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(m=!m.disabled)||(r=r.type,m=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!m;break e;default:r=!1}if(r)return null;if(d&&typeof d!="function")throw Error(n(231,o,typeof d));return d}var on=!1;if(u)try{var tn={};Object.defineProperty(tn,"passive",{get:function(){on=!0}}),window.addEventListener("test",tn,tn),window.removeEventListener("test",tn,tn)}catch{on=!1}function un(r,o,d,m,w,k,F,se,de){var Ee=Array.prototype.slice.call(arguments,3);try{o.apply(d,Ee)}catch(qe){this.onError(qe)}}var Ht=!1,sn=null,En=!1,Qt=null,an={onError:function(r){Ht=!0,sn=r}};function $s(r,o,d,m,w,k,F,se,de){Ht=!1,sn=null,un.apply(an,arguments)}function Vn(r,o,d,m,w,k,F,se,de){if($s.apply(this,arguments),Ht){if(Ht){var Ee=sn;Ht=!1,sn=null}else throw Error(n(198));En||(En=!0,Qt=Ee)}}function Ut(r){var o=r,d=r;if(r.alternate)for(;o.return;)o=o.return;else{r=o;do o=r,(o.flags&4098)!==0&&(d=o.return),r=o.return;while(r)}return o.tag===3?d:null}function zs(r){if(r.tag===13){var o=r.memoizedState;if(o===null&&(r=r.alternate,r!==null&&(o=r.memoizedState)),o!==null)return o.dehydrated}return null}function ds(r){if(Ut(r)!==r)throw Error(n(188))}function Yn(r){var o=r.alternate;if(!o){if(o=Ut(r),o===null)throw Error(n(188));return o!==r?null:r}for(var d=r,m=o;;){var w=d.return;if(w===null)break;var k=w.alternate;if(k===null){if(m=w.return,m!==null){d=m;continue}break}if(w.child===k.child){for(k=w.child;k;){if(k===d)return ds(w),r;if(k===m)return ds(w),o;k=k.sibling}throw Error(n(188))}if(d.return!==m.return)d=w,m=k;else{for(var F=!1,se=w.child;se;){if(se===d){F=!0,d=w,m=k;break}if(se===m){F=!0,m=w,d=k;break}se=se.sibling}if(!F){for(se=k.child;se;){if(se===d){F=!0,d=k,m=w;break}if(se===m){F=!0,m=k,d=w;break}se=se.sibling}if(!F)throw Error(n(189))}}if(d.alternate!==m)throw Error(n(190))}if(d.tag!==3)throw Error(n(188));return d.stateNode.current===d?r:o}function xt(r){return r=Yn(r),r!==null?ue(r):null}function ue(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var o=ue(r);if(o!==null)return o;r=r.sibling}return null}var Ie=e.unstable_scheduleCallback,Qe=e.unstable_cancelCallback,ct=e.unstable_shouldYield,At=e.unstable_requestPaint,G=e.unstable_now,fe=e.unstable_getCurrentPriorityLevel,Te=e.unstable_ImmediatePriority,Ze=e.unstable_UserBlockingPriority,Pe=e.unstable_NormalPriority,jt=e.unstable_LowPriority,ke=e.unstable_IdlePriority,Le=null,lt=null;function Yt(r){if(lt&&typeof lt.onCommitFiberRoot=="function")try{lt.onCommitFiberRoot(Le,r,void 0,(r.current.flags&128)===128)}catch{}}var De=Math.clz32?Math.clz32:be,Je=Math.log,Pt=Math.LN2;function be(r){return r>>>=0,r===0?32:31-(Je(r)/Pt|0)|0}var Re=64,Ke=4194304;function at(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function wt(r,o){var d=r.pendingLanes;if(d===0)return 0;var m=0,w=r.suspendedLanes,k=r.pingedLanes,F=d&268435455;if(F!==0){var se=F&~w;se!==0?m=at(se):(k&=F,k!==0&&(m=at(k)))}else F=d&~w,F!==0?m=at(F):k!==0&&(m=at(k));if(m===0)return 0;if(o!==0&&o!==m&&(o&w)===0&&(w=m&-m,k=o&-o,w>=k||w===16&&(k&4194240)!==0))return o;if((m&4)!==0&&(m|=d&16),o=r.entangledLanes,o!==0)for(r=r.entanglements,o&=m;0<o;)d=31-De(o),w=1<<d,m|=r[d],o&=~w;return m}function Gn(r,o){switch(r){case 1:case 2:case 4:return o+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 o+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 Fs(r,o){for(var d=r.suspendedLanes,m=r.pingedLanes,w=r.expirationTimes,k=r.pendingLanes;0<k;){var F=31-De(k),se=1<<F,de=w[F];de===-1?((se&d)===0||(se&m)!==0)&&(w[F]=Gn(se,o)):de<=o&&(r.expiredLanes|=se),k&=~se}}function Wt(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function Xn(){var r=Re;return Re<<=1,(Re&4194240)===0&&(Re=64),r}function Ot(r){for(var o=[],d=0;31>d;d++)o.push(r);return o}function ws(r,o,d){r.pendingLanes|=o,o!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,o=31-De(o),r[o]=d}function Di(r,o){var d=r.pendingLanes&~o;r.pendingLanes=o,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=o,r.mutableReadLanes&=o,r.entangledLanes&=o,o=r.entanglements;var m=r.eventTimes;for(r=r.expirationTimes;0<d;){var w=31-De(d),k=1<<w;o[w]=0,m[w]=-1,r[w]=-1,d&=~k}}function ir(r,o){var d=r.entangledLanes|=o;for(r=r.entanglements;d;){var m=31-De(d),w=1<<m;w&o|r[m]&o&&(r[m]|=o),d&=~w}}var Zt=0;function ll(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var cl,ta,Js,ul,dl,na=!1,rr=[],bs=null,Qs=null,bi=null,or=new Map,Mr=new Map,As=[],tu="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 ar(r,o){switch(r){case"focusin":case"focusout":bs=null;break;case"dragenter":case"dragleave":Qs=null;break;case"mouseover":case"mouseout":bi=null;break;case"pointerover":case"pointerout":or.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":Mr.delete(o.pointerId)}}function Ss(r,o,d,m,w,k){return r===null||r.nativeEvent!==k?(r={blockedOn:o,domEventName:d,eventSystemFlags:m,nativeEvent:k,targetContainers:[w]},o!==null&&(o=El(o),o!==null&&ta(o)),r):(r.eventSystemFlags|=m,o=r.targetContainers,w!==null&&o.indexOf(w)===-1&&o.push(w),r)}function hl(r,o,d,m,w){switch(o){case"focusin":return bs=Ss(bs,r,o,d,m,w),!0;case"dragenter":return Qs=Ss(Qs,r,o,d,m,w),!0;case"mouseover":return bi=Ss(bi,r,o,d,m,w),!0;case"pointerover":var k=w.pointerId;return or.set(k,Ss(or.get(k)||null,r,o,d,m,w)),!0;case"gotpointercapture":return k=w.pointerId,Mr.set(k,Ss(Mr.get(k)||null,r,o,d,m,w)),!0}return!1}function fl(r){var o=vo(r.target);if(o!==null){var d=Ut(o);if(d!==null){if(o=d.tag,o===13){if(o=zs(d),o!==null){r.blockedOn=o,dl(r.priority,function(){Js(d)});return}}else if(o===3&&d.stateNode.current.memoizedState.isDehydrated){r.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}r.blockedOn=null}function Jn(r){if(r.blockedOn!==null)return!1;for(var o=r.targetContainers;0<o.length;){var d=oa(r.domEventName,r.eventSystemFlags,o[0],r.nativeEvent);if(d===null){d=r.nativeEvent;var m=new d.constructor(d.type,d);Be=m,d.target.dispatchEvent(m),Be=null}else return o=El(d),o!==null&&ta(o),r.blockedOn=d,!1;o.shift()}return!0}function pl(r,o,d){Jn(r)&&d.delete(o)}function sa(){na=!1,bs!==null&&Jn(bs)&&(bs=null),Qs!==null&&Jn(Qs)&&(Qs=null),bi!==null&&Jn(bi)&&(bi=null),or.forEach(pl),Mr.forEach(pl)}function Si(r,o){r.blockedOn===o&&(r.blockedOn=null,na||(na=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,sa)))}function Oi(r){function o(w){return Si(w,r)}if(0<rr.length){Si(rr[0],r);for(var d=1;d<rr.length;d++){var m=rr[d];m.blockedOn===r&&(m.blockedOn=null)}}for(bs!==null&&Si(bs,r),Qs!==null&&Si(Qs,r),bi!==null&&Si(bi,r),or.forEach(o),Mr.forEach(o),d=0;d<As.length;d++)m=As[d],m.blockedOn===r&&(m.blockedOn=null);for(;0<As.length&&(d=As[0],d.blockedOn===null);)fl(d),d.blockedOn===null&&As.shift()}var lr=x.ReactCurrentBatchConfig,cr=!0;function nu(r,o,d,m){var w=Zt,k=lr.transition;lr.transition=null;try{Zt=1,ra(r,o,d,m)}finally{Zt=w,lr.transition=k}}function ia(r,o,d,m){var w=Zt,k=lr.transition;lr.transition=null;try{Zt=4,ra(r,o,d,m)}finally{Zt=w,lr.transition=k}}function ra(r,o,d,m){if(cr){var w=oa(r,o,d,m);if(w===null)Uh(r,o,m,mo,d),ar(r,m);else if(hl(w,r,o,d,m))m.stopPropagation();else if(ar(r,m),o&4&&-1<tu.indexOf(r)){for(;w!==null;){var k=El(w);if(k!==null&&cl(k),k=oa(r,o,d,m),k===null&&Uh(r,o,m,mo,d),k===w)break;w=k}w!==null&&m.stopPropagation()}else Uh(r,o,m,null,d)}}var mo=null;function oa(r,o,d,m){if(mo=null,r=gt(m),r=vo(r),r!==null)if(o=Ut(r),o===null)r=null;else if(d=o.tag,d===13){if(r=zs(o),r!==null)return r;r=null}else if(d===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;r=null}else o!==r&&(r=null);return mo=r,null}function ml(r){switch(r){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(fe()){case Te:return 1;case Ze:return 4;case Pe:case jt:return 16;case ke:return 536870912;default:return 16}default:return 16}}var xi=null,aa=null,ye=null;function Xe(){if(ye)return ye;var r,o=aa,d=o.length,m,w="value"in xi?xi.value:xi.textContent,k=w.length;for(r=0;r<d&&o[r]===w[r];r++);var F=d-r;for(m=1;m<=F&&o[d-m]===w[k-m];m++);return ye=w.slice(r,1<m?1-m:void 0)}function nt(r){var o=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&o===13&&(r=13)):r=o,r===10&&(r=13),32<=r||r===13?r:0}function pt(){return!0}function Rt(){return!1}function St(r){function o(d,m,w,k,F){this._reactName=d,this._targetInst=w,this.type=m,this.nativeEvent=k,this.target=F,this.currentTarget=null;for(var se in r)r.hasOwnProperty(se)&&(d=r[se],this[se]=d?d(k):k[se]);return this.isDefaultPrevented=(k.defaultPrevented!=null?k.defaultPrevented:k.returnValue===!1)?pt:Rt,this.isPropagationStopped=Rt,this}return H(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=pt)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=pt)},persist:function(){},isPersistent:pt}),o}var Gt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},dn=St(Gt),In=H({},Gt,{view:0,detail:0}),Mn=St(In),xs,ri,go,gl=H({},In,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Mh,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==go&&(go&&r.type==="mousemove"?(xs=r.screenX-go.screenX,ri=r.screenY-go.screenY):ri=xs=0,go=r),xs)},movementY:function(r){return"movementY"in r?r.movementY:ri}}),N_=St(gl),m2=H({},gl,{dataTransfer:0}),g2=St(m2),v2=H({},In,{relatedTarget:0}),Ah=St(v2),_2=H({},Gt,{animationName:0,elapsedTime:0,pseudoElement:0}),y2=St(_2),w2=H({},Gt,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),b2=St(w2),S2=H({},Gt,{data:0}),j_=St(S2),x2={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},k2={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"},C2={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function E2(r){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(r):(r=C2[r])?!!o[r]:!1}function Mh(){return E2}var N2=H({},In,{key:function(r){if(r.key){var o=x2[r.key]||r.key;if(o!=="Unidentified")return o}return r.type==="keypress"?(r=nt(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?k2[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Mh,charCode:function(r){return r.type==="keypress"?nt(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?nt(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),j2=St(N2),L2=H({},gl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),L_=St(L2),R2=H({},In,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Mh}),A2=St(R2),M2=H({},Gt,{propertyName:0,elapsedTime:0,pseudoElement:0}),T2=St(M2),P2=H({},gl,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),I2=St(P2),D2=[9,13,27,32],Th=u&&"CompositionEvent"in window,vl=null;u&&"documentMode"in document&&(vl=document.documentMode);var O2=u&&"TextEvent"in window&&!vl,R_=u&&(!Th||vl&&8<vl&&11>=vl),A_=" ",M_=!1;function T_(r,o){switch(r){case"keyup":return D2.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function P_(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var la=!1;function B2(r,o){switch(r){case"compositionend":return P_(o);case"keypress":return o.which!==32?null:(M_=!0,A_);case"textInput":return r=o.data,r===A_&&M_?null:r;default:return null}}function $2(r,o){if(la)return r==="compositionend"||!Th&&T_(r,o)?(r=Xe(),ye=aa=xi=null,la=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return R_&&o.locale!=="ko"?null:o.data;default:return null}}var z2={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 I_(r){var o=r&&r.nodeName&&r.nodeName.toLowerCase();return o==="input"?!!z2[r.type]:o==="textarea"}function D_(r,o,d,m){ft(m),o=au(o,"onChange"),0<o.length&&(d=new dn("onChange","change",null,d,m),r.push({event:d,listeners:o}))}var _l=null,yl=null;function F2(r){ey(r,0)}function su(r){var o=fa(r);if(Ae(o))return r}function H2(r,o){if(r==="change")return o}var O_=!1;if(u){var Ph;if(u){var Ih="oninput"in document;if(!Ih){var B_=document.createElement("div");B_.setAttribute("oninput","return;"),Ih=typeof B_.oninput=="function"}Ph=Ih}else Ph=!1;O_=Ph&&(!document.documentMode||9<document.documentMode)}function $_(){_l&&(_l.detachEvent("onpropertychange",z_),yl=_l=null)}function z_(r){if(r.propertyName==="value"&&su(yl)){var o=[];D_(o,yl,r,gt(r)),Cn(F2,o)}}function U2(r,o,d){r==="focusin"?($_(),_l=o,yl=d,_l.attachEvent("onpropertychange",z_)):r==="focusout"&&$_()}function W2(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return su(yl)}function q2(r,o){if(r==="click")return su(o)}function K2(r,o){if(r==="input"||r==="change")return su(o)}function V2(r,o){return r===o&&(r!==0||1/r===1/o)||r!==r&&o!==o}var ki=typeof Object.is=="function"?Object.is:V2;function wl(r,o){if(ki(r,o))return!0;if(typeof r!="object"||r===null||typeof o!="object"||o===null)return!1;var d=Object.keys(r),m=Object.keys(o);if(d.length!==m.length)return!1;for(m=0;m<d.length;m++){var w=d[m];if(!h.call(o,w)||!ki(r[w],o[w]))return!1}return!0}function F_(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function H_(r,o){var d=F_(r);r=0;for(var m;d;){if(d.nodeType===3){if(m=r+d.textContent.length,r<=o&&m>=o)return{node:d,offset:o-r};r=m}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=F_(d)}}function U_(r,o){return r&&o?r===o?!0:r&&r.nodeType===3?!1:o&&o.nodeType===3?U_(r,o.parentNode):"contains"in r?r.contains(o):r.compareDocumentPosition?!!(r.compareDocumentPosition(o)&16):!1:!1}function W_(){for(var r=window,o=He();o instanceof r.HTMLIFrameElement;){try{var d=typeof o.contentWindow.location.href=="string"}catch{d=!1}if(d)r=o.contentWindow;else break;o=He(r.document)}return o}function Dh(r){var o=r&&r.nodeName&&r.nodeName.toLowerCase();return o&&(o==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||o==="textarea"||r.contentEditable==="true")}function Y2(r){var o=W_(),d=r.focusedElem,m=r.selectionRange;if(o!==d&&d&&d.ownerDocument&&U_(d.ownerDocument.documentElement,d)){if(m!==null&&Dh(d)){if(o=m.start,r=m.end,r===void 0&&(r=o),"selectionStart"in d)d.selectionStart=o,d.selectionEnd=Math.min(r,d.value.length);else if(r=(o=d.ownerDocument||document)&&o.defaultView||window,r.getSelection){r=r.getSelection();var w=d.textContent.length,k=Math.min(m.start,w);m=m.end===void 0?k:Math.min(m.end,w),!r.extend&&k>m&&(w=m,m=k,k=w),w=H_(d,k);var F=H_(d,m);w&&F&&(r.rangeCount!==1||r.anchorNode!==w.node||r.anchorOffset!==w.offset||r.focusNode!==F.node||r.focusOffset!==F.offset)&&(o=o.createRange(),o.setStart(w.node,w.offset),r.removeAllRanges(),k>m?(r.addRange(o),r.extend(F.node,F.offset)):(o.setEnd(F.node,F.offset),r.addRange(o)))}}for(o=[],r=d;r=r.parentNode;)r.nodeType===1&&o.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof d.focus=="function"&&d.focus(),d=0;d<o.length;d++)r=o[d],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var G2=u&&"documentMode"in document&&11>=document.documentMode,ca=null,Oh=null,bl=null,Bh=!1;function q_(r,o,d){var m=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;Bh||ca==null||ca!==He(m)||(m=ca,"selectionStart"in m&&Dh(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),bl&&wl(bl,m)||(bl=m,m=au(Oh,"onSelect"),0<m.length&&(o=new dn("onSelect","select",null,o,d),r.push({event:o,listeners:m}),o.target=ca)))}function iu(r,o){var d={};return d[r.toLowerCase()]=o.toLowerCase(),d["Webkit"+r]="webkit"+o,d["Moz"+r]="moz"+o,d}var ua={animationend:iu("Animation","AnimationEnd"),animationiteration:iu("Animation","AnimationIteration"),animationstart:iu("Animation","AnimationStart"),transitionend:iu("Transition","TransitionEnd")},$h={},K_={};u&&(K_=document.createElement("div").style,"AnimationEvent"in window||(delete ua.animationend.animation,delete ua.animationiteration.animation,delete ua.animationstart.animation),"TransitionEvent"in window||delete ua.transitionend.transition);function ru(r){if($h[r])return $h[r];if(!ua[r])return r;var o=ua[r],d;for(d in o)if(o.hasOwnProperty(d)&&d in K_)return $h[r]=o[d];return r}var V_=ru("animationend"),Y_=ru("animationiteration"),G_=ru("animationstart"),X_=ru("transitionend"),J_=new Map,Q_="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 Tr(r,o){J_.set(r,o),l(o,[r])}for(var zh=0;zh<Q_.length;zh++){var Fh=Q_[zh],X2=Fh.toLowerCase(),J2=Fh[0].toUpperCase()+Fh.slice(1);Tr(X2,"on"+J2)}Tr(V_,"onAnimationEnd"),Tr(Y_,"onAnimationIteration"),Tr(G_,"onAnimationStart"),Tr("dblclick","onDoubleClick"),Tr("focusin","onFocus"),Tr("focusout","onBlur"),Tr(X_,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Sl="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(" "),Q2=new Set("cancel close invalid load scroll toggle".split(" ").concat(Sl));function Z_(r,o,d){var m=r.type||"unknown-event";r.currentTarget=d,Vn(m,o,void 0,r),r.currentTarget=null}function ey(r,o){o=(o&4)!==0;for(var d=0;d<r.length;d++){var m=r[d],w=m.event;m=m.listeners;e:{var k=void 0;if(o)for(var F=m.length-1;0<=F;F--){var se=m[F],de=se.instance,Ee=se.currentTarget;if(se=se.listener,de!==k&&w.isPropagationStopped())break e;Z_(w,se,Ee),k=de}else for(F=0;F<m.length;F++){if(se=m[F],de=se.instance,Ee=se.currentTarget,se=se.listener,de!==k&&w.isPropagationStopped())break e;Z_(w,se,Ee),k=de}}}if(En)throw r=Qt,En=!1,Qt=null,r}function hn(r,o){var d=o[Gh];d===void 0&&(d=o[Gh]=new Set);var m=r+"__bubble";d.has(m)||(ty(o,r,2,!1),d.add(m))}function Hh(r,o,d){var m=0;o&&(m|=4),ty(d,r,m,o)}var ou="_reactListening"+Math.random().toString(36).slice(2);function xl(r){if(!r[ou]){r[ou]=!0,s.forEach(function(d){d!=="selectionchange"&&(Q2.has(d)||Hh(d,!1,r),Hh(d,!0,r))});var o=r.nodeType===9?r:r.ownerDocument;o===null||o[ou]||(o[ou]=!0,Hh("selectionchange",!1,o))}}function ty(r,o,d,m){switch(ml(o)){case 1:var w=nu;break;case 4:w=ia;break;default:w=ra}d=w.bind(null,o,d,r),w=void 0,!on||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(w=!0),m?w!==void 0?r.addEventListener(o,d,{capture:!0,passive:w}):r.addEventListener(o,d,!0):w!==void 0?r.addEventListener(o,d,{passive:w}):r.addEventListener(o,d,!1)}function Uh(r,o,d,m,w){var k=m;if((o&1)===0&&(o&2)===0&&m!==null)e:for(;;){if(m===null)return;var F=m.tag;if(F===3||F===4){var se=m.stateNode.containerInfo;if(se===w||se.nodeType===8&&se.parentNode===w)break;if(F===4)for(F=m.return;F!==null;){var de=F.tag;if((de===3||de===4)&&(de=F.stateNode.containerInfo,de===w||de.nodeType===8&&de.parentNode===w))return;F=F.return}for(;se!==null;){if(F=vo(se),F===null)return;if(de=F.tag,de===5||de===6){m=k=F;continue e}se=se.parentNode}}m=m.return}Cn(function(){var Ee=k,qe=gt(d),Ge=[];e:{var We=J_.get(r);if(We!==void 0){var dt=dn,vt=r;switch(r){case"keypress":if(nt(d)===0)break e;case"keydown":case"keyup":dt=j2;break;case"focusin":vt="focus",dt=Ah;break;case"focusout":vt="blur",dt=Ah;break;case"beforeblur":case"afterblur":dt=Ah;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":dt=N_;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":dt=g2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":dt=A2;break;case V_:case Y_:case G_:dt=y2;break;case X_:dt=T2;break;case"scroll":dt=Mn;break;case"wheel":dt=I2;break;case"copy":case"cut":case"paste":dt=b2;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":dt=L_}var yt=(o&4)!==0,Tn=!yt&&r==="scroll",Se=yt?We!==null?We+"Capture":null:We;yt=[];for(var pe=Ee,xe;pe!==null;){xe=pe;var tt=xe.stateNode;if(xe.tag===5&&tt!==null&&(xe=tt,Se!==null&&(tt=nn(pe,Se),tt!=null&&yt.push(kl(pe,tt,xe)))),Tn)break;pe=pe.return}0<yt.length&&(We=new dt(We,vt,null,d,qe),Ge.push({event:We,listeners:yt}))}}if((o&7)===0){e:{if(We=r==="mouseover"||r==="pointerover",dt=r==="mouseout"||r==="pointerout",We&&d!==Be&&(vt=d.relatedTarget||d.fromElement)&&(vo(vt)||vt[ur]))break e;if((dt||We)&&(We=qe.window===qe?qe:(We=qe.ownerDocument)?We.defaultView||We.parentWindow:window,dt?(vt=d.relatedTarget||d.toElement,dt=Ee,vt=vt?vo(vt):null,vt!==null&&(Tn=Ut(vt),vt!==Tn||vt.tag!==5&&vt.tag!==6)&&(vt=null)):(dt=null,vt=Ee),dt!==vt)){if(yt=N_,tt="onMouseLeave",Se="onMouseEnter",pe="mouse",(r==="pointerout"||r==="pointerover")&&(yt=L_,tt="onPointerLeave",Se="onPointerEnter",pe="pointer"),Tn=dt==null?We:fa(dt),xe=vt==null?We:fa(vt),We=new yt(tt,pe+"leave",dt,d,qe),We.target=Tn,We.relatedTarget=xe,tt=null,vo(qe)===Ee&&(yt=new yt(Se,pe+"enter",vt,d,qe),yt.target=xe,yt.relatedTarget=Tn,tt=yt),Tn=tt,dt&&vt)t:{for(yt=dt,Se=vt,pe=0,xe=yt;xe;xe=da(xe))pe++;for(xe=0,tt=Se;tt;tt=da(tt))xe++;for(;0<pe-xe;)yt=da(yt),pe--;for(;0<xe-pe;)Se=da(Se),xe--;for(;pe--;){if(yt===Se||Se!==null&&yt===Se.alternate)break t;yt=da(yt),Se=da(Se)}yt=null}else yt=null;dt!==null&&ny(Ge,We,dt,yt,!1),vt!==null&&Tn!==null&&ny(Ge,Tn,vt,yt,!0)}}e:{if(We=Ee?fa(Ee):window,dt=We.nodeName&&We.nodeName.toLowerCase(),dt==="select"||dt==="input"&&We.type==="file")var bt=H2;else if(I_(We))if(O_)bt=K2;else{bt=W2;var Ct=U2}else(dt=We.nodeName)&&dt.toLowerCase()==="input"&&(We.type==="checkbox"||We.type==="radio")&&(bt=q2);if(bt&&(bt=bt(r,Ee))){D_(Ge,bt,d,qe);break e}Ct&&Ct(r,We,Ee),r==="focusout"&&(Ct=We._wrapperState)&&Ct.controlled&&We.type==="number"&&he(We,"number",We.value)}switch(Ct=Ee?fa(Ee):window,r){case"focusin":(I_(Ct)||Ct.contentEditable==="true")&&(ca=Ct,Oh=Ee,bl=null);break;case"focusout":bl=Oh=ca=null;break;case"mousedown":Bh=!0;break;case"contextmenu":case"mouseup":case"dragend":Bh=!1,q_(Ge,d,qe);break;case"selectionchange":if(G2)break;case"keydown":case"keyup":q_(Ge,d,qe)}var Et;if(Th)e:{switch(r){case"compositionstart":var Mt="onCompositionStart";break e;case"compositionend":Mt="onCompositionEnd";break e;case"compositionupdate":Mt="onCompositionUpdate";break e}Mt=void 0}else la?T_(r,d)&&(Mt="onCompositionEnd"):r==="keydown"&&d.keyCode===229&&(Mt="onCompositionStart");Mt&&(R_&&d.locale!=="ko"&&(la||Mt!=="onCompositionStart"?Mt==="onCompositionEnd"&&la&&(Et=Xe()):(xi=qe,aa="value"in xi?xi.value:xi.textContent,la=!0)),Ct=au(Ee,Mt),0<Ct.length&&(Mt=new j_(Mt,r,null,d,qe),Ge.push({event:Mt,listeners:Ct}),Et?Mt.data=Et:(Et=P_(d),Et!==null&&(Mt.data=Et)))),(Et=O2?B2(r,d):$2(r,d))&&(Ee=au(Ee,"onBeforeInput"),0<Ee.length&&(qe=new j_("onBeforeInput","beforeinput",null,d,qe),Ge.push({event:qe,listeners:Ee}),qe.data=Et))}ey(Ge,o)})}function kl(r,o,d){return{instance:r,listener:o,currentTarget:d}}function au(r,o){for(var d=o+"Capture",m=[];r!==null;){var w=r,k=w.stateNode;w.tag===5&&k!==null&&(w=k,k=nn(r,d),k!=null&&m.unshift(kl(r,k,w)),k=nn(r,o),k!=null&&m.push(kl(r,k,w))),r=r.return}return m}function da(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function ny(r,o,d,m,w){for(var k=o._reactName,F=[];d!==null&&d!==m;){var se=d,de=se.alternate,Ee=se.stateNode;if(de!==null&&de===m)break;se.tag===5&&Ee!==null&&(se=Ee,w?(de=nn(d,k),de!=null&&F.unshift(kl(d,de,se))):w||(de=nn(d,k),de!=null&&F.push(kl(d,de,se)))),d=d.return}F.length!==0&&r.push({event:o,listeners:F})}var Z2=/\r\n?/g,eN=/\u0000|\uFFFD/g;function sy(r){return(typeof r=="string"?r:""+r).replace(Z2,`
38
+ `).replace(eN,"")}function lu(r,o,d){if(o=sy(o),sy(r)!==o&&d)throw Error(n(425))}function cu(){}var Wh=null,qh=null;function Kh(r,o){return r==="textarea"||r==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var Vh=typeof setTimeout=="function"?setTimeout:void 0,tN=typeof clearTimeout=="function"?clearTimeout:void 0,iy=typeof Promise=="function"?Promise:void 0,nN=typeof queueMicrotask=="function"?queueMicrotask:typeof iy<"u"?function(r){return iy.resolve(null).then(r).catch(sN)}:Vh;function sN(r){setTimeout(function(){throw r})}function Yh(r,o){var d=o,m=0;do{var w=d.nextSibling;if(r.removeChild(d),w&&w.nodeType===8)if(d=w.data,d==="/$"){if(m===0){r.removeChild(w),Oi(o);return}m--}else d!=="$"&&d!=="$?"&&d!=="$!"||m++;d=w}while(d);Oi(o)}function Pr(r){for(;r!=null;r=r.nextSibling){var o=r.nodeType;if(o===1||o===3)break;if(o===8){if(o=r.data,o==="$"||o==="$!"||o==="$?")break;if(o==="/$")return null}}return r}function ry(r){r=r.previousSibling;for(var o=0;r;){if(r.nodeType===8){var d=r.data;if(d==="$"||d==="$!"||d==="$?"){if(o===0)return r;o--}else d==="/$"&&o++}r=r.previousSibling}return null}var ha=Math.random().toString(36).slice(2),Bi="__reactFiber$"+ha,Cl="__reactProps$"+ha,ur="__reactContainer$"+ha,Gh="__reactEvents$"+ha,iN="__reactListeners$"+ha,rN="__reactHandles$"+ha;function vo(r){var o=r[Bi];if(o)return o;for(var d=r.parentNode;d;){if(o=d[ur]||d[Bi]){if(d=o.alternate,o.child!==null||d!==null&&d.child!==null)for(r=ry(r);r!==null;){if(d=r[Bi])return d;r=ry(r)}return o}r=d,d=r.parentNode}return null}function El(r){return r=r[Bi]||r[ur],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function fa(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(n(33))}function uu(r){return r[Cl]||null}var Xh=[],pa=-1;function Ir(r){return{current:r}}function fn(r){0>pa||(r.current=Xh[pa],Xh[pa]=null,pa--)}function ln(r,o){pa++,Xh[pa]=r.current,r.current=o}var Dr={},ks=Ir(Dr),Hs=Ir(!1),_o=Dr;function ma(r,o){var d=r.type.contextTypes;if(!d)return Dr;var m=r.stateNode;if(m&&m.__reactInternalMemoizedUnmaskedChildContext===o)return m.__reactInternalMemoizedMaskedChildContext;var w={},k;for(k in d)w[k]=o[k];return m&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=o,r.__reactInternalMemoizedMaskedChildContext=w),w}function Us(r){return r=r.childContextTypes,r!=null}function du(){fn(Hs),fn(ks)}function oy(r,o,d){if(ks.current!==Dr)throw Error(n(168));ln(ks,o),ln(Hs,d)}function ay(r,o,d){var m=r.stateNode;if(o=o.childContextTypes,typeof m.getChildContext!="function")return d;m=m.getChildContext();for(var w in m)if(!(w in o))throw Error(n(108,te(r)||"Unknown",w));return H({},d,m)}function hu(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Dr,_o=ks.current,ln(ks,r),ln(Hs,Hs.current),!0}function ly(r,o,d){var m=r.stateNode;if(!m)throw Error(n(169));d?(r=ay(r,o,_o),m.__reactInternalMemoizedMergedChildContext=r,fn(Hs),fn(ks),ln(ks,r)):fn(Hs),ln(Hs,d)}var dr=null,fu=!1,Jh=!1;function cy(r){dr===null?dr=[r]:dr.push(r)}function oN(r){fu=!0,cy(r)}function Or(){if(!Jh&&dr!==null){Jh=!0;var r=0,o=Zt;try{var d=dr;for(Zt=1;r<d.length;r++){var m=d[r];do m=m(!0);while(m!==null)}dr=null,fu=!1}catch(w){throw dr!==null&&(dr=dr.slice(r+1)),Ie(Te,Or),w}finally{Zt=o,Jh=!1}}return null}var ga=[],va=0,pu=null,mu=0,oi=[],ai=0,yo=null,hr=1,fr="";function wo(r,o){ga[va++]=mu,ga[va++]=pu,pu=r,mu=o}function uy(r,o,d){oi[ai++]=hr,oi[ai++]=fr,oi[ai++]=yo,yo=r;var m=hr;r=fr;var w=32-De(m)-1;m&=~(1<<w),d+=1;var k=32-De(o)+w;if(30<k){var F=w-w%5;k=(m&(1<<F)-1).toString(32),m>>=F,w-=F,hr=1<<32-De(o)+w|d<<w|m,fr=k+r}else hr=1<<k|d<<w|m,fr=r}function Qh(r){r.return!==null&&(wo(r,1),uy(r,1,0))}function Zh(r){for(;r===pu;)pu=ga[--va],ga[va]=null,mu=ga[--va],ga[va]=null;for(;r===yo;)yo=oi[--ai],oi[ai]=null,fr=oi[--ai],oi[ai]=null,hr=oi[--ai],oi[ai]=null}var Zs=null,ei=null,vn=!1,Ci=null;function dy(r,o){var d=di(5,null,null,0);d.elementType="DELETED",d.stateNode=o,d.return=r,o=r.deletions,o===null?(r.deletions=[d],r.flags|=16):o.push(d)}function hy(r,o){switch(r.tag){case 5:var d=r.type;return o=o.nodeType!==1||d.toLowerCase()!==o.nodeName.toLowerCase()?null:o,o!==null?(r.stateNode=o,Zs=r,ei=Pr(o.firstChild),!0):!1;case 6:return o=r.pendingProps===""||o.nodeType!==3?null:o,o!==null?(r.stateNode=o,Zs=r,ei=null,!0):!1;case 13:return o=o.nodeType!==8?null:o,o!==null?(d=yo!==null?{id:hr,overflow:fr}:null,r.memoizedState={dehydrated:o,treeContext:d,retryLane:1073741824},d=di(18,null,null,0),d.stateNode=o,d.return=r,r.child=d,Zs=r,ei=null,!0):!1;default:return!1}}function ef(r){return(r.mode&1)!==0&&(r.flags&128)===0}function tf(r){if(vn){var o=ei;if(o){var d=o;if(!hy(r,o)){if(ef(r))throw Error(n(418));o=Pr(d.nextSibling);var m=Zs;o&&hy(r,o)?dy(m,d):(r.flags=r.flags&-4097|2,vn=!1,Zs=r)}}else{if(ef(r))throw Error(n(418));r.flags=r.flags&-4097|2,vn=!1,Zs=r}}}function fy(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;Zs=r}function gu(r){if(r!==Zs)return!1;if(!vn)return fy(r),vn=!0,!1;var o;if((o=r.tag!==3)&&!(o=r.tag!==5)&&(o=r.type,o=o!=="head"&&o!=="body"&&!Kh(r.type,r.memoizedProps)),o&&(o=ei)){if(ef(r))throw py(),Error(n(418));for(;o;)dy(r,o),o=Pr(o.nextSibling)}if(fy(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));e:{for(r=r.nextSibling,o=0;r;){if(r.nodeType===8){var d=r.data;if(d==="/$"){if(o===0){ei=Pr(r.nextSibling);break e}o--}else d!=="$"&&d!=="$!"&&d!=="$?"||o++}r=r.nextSibling}ei=null}}else ei=Zs?Pr(r.stateNode.nextSibling):null;return!0}function py(){for(var r=ei;r;)r=Pr(r.nextSibling)}function _a(){ei=Zs=null,vn=!1}function nf(r){Ci===null?Ci=[r]:Ci.push(r)}var aN=x.ReactCurrentBatchConfig;function Nl(r,o,d){if(r=d.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(d._owner){if(d=d._owner,d){if(d.tag!==1)throw Error(n(309));var m=d.stateNode}if(!m)throw Error(n(147,r));var w=m,k=""+r;return o!==null&&o.ref!==null&&typeof o.ref=="function"&&o.ref._stringRef===k?o.ref:(o=function(F){var se=w.refs;F===null?delete se[k]:se[k]=F},o._stringRef=k,o)}if(typeof r!="string")throw Error(n(284));if(!d._owner)throw Error(n(290,r))}return r}function vu(r,o){throw r=Object.prototype.toString.call(o),Error(n(31,r==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":r))}function my(r){var o=r._init;return o(r._payload)}function gy(r){function o(Se,pe){if(r){var xe=Se.deletions;xe===null?(Se.deletions=[pe],Se.flags|=16):xe.push(pe)}}function d(Se,pe){if(!r)return null;for(;pe!==null;)o(Se,pe),pe=pe.sibling;return null}function m(Se,pe){for(Se=new Map;pe!==null;)pe.key!==null?Se.set(pe.key,pe):Se.set(pe.index,pe),pe=pe.sibling;return Se}function w(Se,pe){return Se=qr(Se,pe),Se.index=0,Se.sibling=null,Se}function k(Se,pe,xe){return Se.index=xe,r?(xe=Se.alternate,xe!==null?(xe=xe.index,xe<pe?(Se.flags|=2,pe):xe):(Se.flags|=2,pe)):(Se.flags|=1048576,pe)}function F(Se){return r&&Se.alternate===null&&(Se.flags|=2),Se}function se(Se,pe,xe,tt){return pe===null||pe.tag!==6?(pe=Yf(xe,Se.mode,tt),pe.return=Se,pe):(pe=w(pe,xe),pe.return=Se,pe)}function de(Se,pe,xe,tt){var bt=xe.type;return bt===J?qe(Se,pe,xe.props.children,tt,xe.key):pe!==null&&(pe.elementType===bt||typeof bt=="object"&&bt!==null&&bt.$$typeof===z&&my(bt)===pe.type)?(tt=w(pe,xe.props),tt.ref=Nl(Se,pe,xe),tt.return=Se,tt):(tt=Fu(xe.type,xe.key,xe.props,null,Se.mode,tt),tt.ref=Nl(Se,pe,xe),tt.return=Se,tt)}function Ee(Se,pe,xe,tt){return pe===null||pe.tag!==4||pe.stateNode.containerInfo!==xe.containerInfo||pe.stateNode.implementation!==xe.implementation?(pe=Gf(xe,Se.mode,tt),pe.return=Se,pe):(pe=w(pe,xe.children||[]),pe.return=Se,pe)}function qe(Se,pe,xe,tt,bt){return pe===null||pe.tag!==7?(pe=jo(xe,Se.mode,tt,bt),pe.return=Se,pe):(pe=w(pe,xe),pe.return=Se,pe)}function Ge(Se,pe,xe){if(typeof pe=="string"&&pe!==""||typeof pe=="number")return pe=Yf(""+pe,Se.mode,xe),pe.return=Se,pe;if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case W:return xe=Fu(pe.type,pe.key,pe.props,null,Se.mode,xe),xe.ref=Nl(Se,null,pe),xe.return=Se,xe;case $:return pe=Gf(pe,Se.mode,xe),pe.return=Se,pe;case z:var tt=pe._init;return Ge(Se,tt(pe._payload),xe)}if(Ne(pe)||L(pe))return pe=jo(pe,Se.mode,xe,null),pe.return=Se,pe;vu(Se,pe)}return null}function We(Se,pe,xe,tt){var bt=pe!==null?pe.key:null;if(typeof xe=="string"&&xe!==""||typeof xe=="number")return bt!==null?null:se(Se,pe,""+xe,tt);if(typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case W:return xe.key===bt?de(Se,pe,xe,tt):null;case $:return xe.key===bt?Ee(Se,pe,xe,tt):null;case z:return bt=xe._init,We(Se,pe,bt(xe._payload),tt)}if(Ne(xe)||L(xe))return bt!==null?null:qe(Se,pe,xe,tt,null);vu(Se,xe)}return null}function dt(Se,pe,xe,tt,bt){if(typeof tt=="string"&&tt!==""||typeof tt=="number")return Se=Se.get(xe)||null,se(pe,Se,""+tt,bt);if(typeof tt=="object"&&tt!==null){switch(tt.$$typeof){case W:return Se=Se.get(tt.key===null?xe:tt.key)||null,de(pe,Se,tt,bt);case $:return Se=Se.get(tt.key===null?xe:tt.key)||null,Ee(pe,Se,tt,bt);case z:var Ct=tt._init;return dt(Se,pe,xe,Ct(tt._payload),bt)}if(Ne(tt)||L(tt))return Se=Se.get(xe)||null,qe(pe,Se,tt,bt,null);vu(pe,tt)}return null}function vt(Se,pe,xe,tt){for(var bt=null,Ct=null,Et=pe,Mt=pe=0,es=null;Et!==null&&Mt<xe.length;Mt++){Et.index>Mt?(es=Et,Et=null):es=Et.sibling;var en=We(Se,Et,xe[Mt],tt);if(en===null){Et===null&&(Et=es);break}r&&Et&&en.alternate===null&&o(Se,Et),pe=k(en,pe,Mt),Ct===null?bt=en:Ct.sibling=en,Ct=en,Et=es}if(Mt===xe.length)return d(Se,Et),vn&&wo(Se,Mt),bt;if(Et===null){for(;Mt<xe.length;Mt++)Et=Ge(Se,xe[Mt],tt),Et!==null&&(pe=k(Et,pe,Mt),Ct===null?bt=Et:Ct.sibling=Et,Ct=Et);return vn&&wo(Se,Mt),bt}for(Et=m(Se,Et);Mt<xe.length;Mt++)es=dt(Et,Se,Mt,xe[Mt],tt),es!==null&&(r&&es.alternate!==null&&Et.delete(es.key===null?Mt:es.key),pe=k(es,pe,Mt),Ct===null?bt=es:Ct.sibling=es,Ct=es);return r&&Et.forEach(function(Kr){return o(Se,Kr)}),vn&&wo(Se,Mt),bt}function yt(Se,pe,xe,tt){var bt=L(xe);if(typeof bt!="function")throw Error(n(150));if(xe=bt.call(xe),xe==null)throw Error(n(151));for(var Ct=bt=null,Et=pe,Mt=pe=0,es=null,en=xe.next();Et!==null&&!en.done;Mt++,en=xe.next()){Et.index>Mt?(es=Et,Et=null):es=Et.sibling;var Kr=We(Se,Et,en.value,tt);if(Kr===null){Et===null&&(Et=es);break}r&&Et&&Kr.alternate===null&&o(Se,Et),pe=k(Kr,pe,Mt),Ct===null?bt=Kr:Ct.sibling=Kr,Ct=Kr,Et=es}if(en.done)return d(Se,Et),vn&&wo(Se,Mt),bt;if(Et===null){for(;!en.done;Mt++,en=xe.next())en=Ge(Se,en.value,tt),en!==null&&(pe=k(en,pe,Mt),Ct===null?bt=en:Ct.sibling=en,Ct=en);return vn&&wo(Se,Mt),bt}for(Et=m(Se,Et);!en.done;Mt++,en=xe.next())en=dt(Et,Se,Mt,en.value,tt),en!==null&&(r&&en.alternate!==null&&Et.delete(en.key===null?Mt:en.key),pe=k(en,pe,Mt),Ct===null?bt=en:Ct.sibling=en,Ct=en);return r&&Et.forEach(function(zN){return o(Se,zN)}),vn&&wo(Se,Mt),bt}function Tn(Se,pe,xe,tt){if(typeof xe=="object"&&xe!==null&&xe.type===J&&xe.key===null&&(xe=xe.props.children),typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case W:e:{for(var bt=xe.key,Ct=pe;Ct!==null;){if(Ct.key===bt){if(bt=xe.type,bt===J){if(Ct.tag===7){d(Se,Ct.sibling),pe=w(Ct,xe.props.children),pe.return=Se,Se=pe;break e}}else if(Ct.elementType===bt||typeof bt=="object"&&bt!==null&&bt.$$typeof===z&&my(bt)===Ct.type){d(Se,Ct.sibling),pe=w(Ct,xe.props),pe.ref=Nl(Se,Ct,xe),pe.return=Se,Se=pe;break e}d(Se,Ct);break}else o(Se,Ct);Ct=Ct.sibling}xe.type===J?(pe=jo(xe.props.children,Se.mode,tt,xe.key),pe.return=Se,Se=pe):(tt=Fu(xe.type,xe.key,xe.props,null,Se.mode,tt),tt.ref=Nl(Se,pe,xe),tt.return=Se,Se=tt)}return F(Se);case $:e:{for(Ct=xe.key;pe!==null;){if(pe.key===Ct)if(pe.tag===4&&pe.stateNode.containerInfo===xe.containerInfo&&pe.stateNode.implementation===xe.implementation){d(Se,pe.sibling),pe=w(pe,xe.children||[]),pe.return=Se,Se=pe;break e}else{d(Se,pe);break}else o(Se,pe);pe=pe.sibling}pe=Gf(xe,Se.mode,tt),pe.return=Se,Se=pe}return F(Se);case z:return Ct=xe._init,Tn(Se,pe,Ct(xe._payload),tt)}if(Ne(xe))return vt(Se,pe,xe,tt);if(L(xe))return yt(Se,pe,xe,tt);vu(Se,xe)}return typeof xe=="string"&&xe!==""||typeof xe=="number"?(xe=""+xe,pe!==null&&pe.tag===6?(d(Se,pe.sibling),pe=w(pe,xe),pe.return=Se,Se=pe):(d(Se,pe),pe=Yf(xe,Se.mode,tt),pe.return=Se,Se=pe),F(Se)):d(Se,pe)}return Tn}var ya=gy(!0),vy=gy(!1),_u=Ir(null),yu=null,wa=null,sf=null;function rf(){sf=wa=yu=null}function of(r){var o=_u.current;fn(_u),r._currentValue=o}function af(r,o,d){for(;r!==null;){var m=r.alternate;if((r.childLanes&o)!==o?(r.childLanes|=o,m!==null&&(m.childLanes|=o)):m!==null&&(m.childLanes&o)!==o&&(m.childLanes|=o),r===d)break;r=r.return}}function ba(r,o){yu=r,sf=wa=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&o)!==0&&(Ws=!0),r.firstContext=null)}function li(r){var o=r._currentValue;if(sf!==r)if(r={context:r,memoizedValue:o,next:null},wa===null){if(yu===null)throw Error(n(308));wa=r,yu.dependencies={lanes:0,firstContext:r}}else wa=wa.next=r;return o}var bo=null;function lf(r){bo===null?bo=[r]:bo.push(r)}function _y(r,o,d,m){var w=o.interleaved;return w===null?(d.next=d,lf(o)):(d.next=w.next,w.next=d),o.interleaved=d,pr(r,m)}function pr(r,o){r.lanes|=o;var d=r.alternate;for(d!==null&&(d.lanes|=o),d=r,r=r.return;r!==null;)r.childLanes|=o,d=r.alternate,d!==null&&(d.childLanes|=o),d=r,r=r.return;return d.tag===3?d.stateNode:null}var Br=!1;function cf(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function yy(r,o){r=r.updateQueue,o.updateQueue===r&&(o.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function mr(r,o){return{eventTime:r,lane:o,tag:0,payload:null,callback:null,next:null}}function $r(r,o,d){var m=r.updateQueue;if(m===null)return null;if(m=m.shared,(Jt&2)!==0){var w=m.pending;return w===null?o.next=o:(o.next=w.next,w.next=o),m.pending=o,pr(r,d)}return w=m.interleaved,w===null?(o.next=o,lf(m)):(o.next=w.next,w.next=o),m.interleaved=o,pr(r,d)}function wu(r,o,d){if(o=o.updateQueue,o!==null&&(o=o.shared,(d&4194240)!==0)){var m=o.lanes;m&=r.pendingLanes,d|=m,o.lanes=d,ir(r,d)}}function wy(r,o){var d=r.updateQueue,m=r.alternate;if(m!==null&&(m=m.updateQueue,d===m)){var w=null,k=null;if(d=d.firstBaseUpdate,d!==null){do{var F={eventTime:d.eventTime,lane:d.lane,tag:d.tag,payload:d.payload,callback:d.callback,next:null};k===null?w=k=F:k=k.next=F,d=d.next}while(d!==null);k===null?w=k=o:k=k.next=o}else w=k=o;d={baseState:m.baseState,firstBaseUpdate:w,lastBaseUpdate:k,shared:m.shared,effects:m.effects},r.updateQueue=d;return}r=d.lastBaseUpdate,r===null?d.firstBaseUpdate=o:r.next=o,d.lastBaseUpdate=o}function bu(r,o,d,m){var w=r.updateQueue;Br=!1;var k=w.firstBaseUpdate,F=w.lastBaseUpdate,se=w.shared.pending;if(se!==null){w.shared.pending=null;var de=se,Ee=de.next;de.next=null,F===null?k=Ee:F.next=Ee,F=de;var qe=r.alternate;qe!==null&&(qe=qe.updateQueue,se=qe.lastBaseUpdate,se!==F&&(se===null?qe.firstBaseUpdate=Ee:se.next=Ee,qe.lastBaseUpdate=de))}if(k!==null){var Ge=w.baseState;F=0,qe=Ee=de=null,se=k;do{var We=se.lane,dt=se.eventTime;if((m&We)===We){qe!==null&&(qe=qe.next={eventTime:dt,lane:0,tag:se.tag,payload:se.payload,callback:se.callback,next:null});e:{var vt=r,yt=se;switch(We=o,dt=d,yt.tag){case 1:if(vt=yt.payload,typeof vt=="function"){Ge=vt.call(dt,Ge,We);break e}Ge=vt;break e;case 3:vt.flags=vt.flags&-65537|128;case 0:if(vt=yt.payload,We=typeof vt=="function"?vt.call(dt,Ge,We):vt,We==null)break e;Ge=H({},Ge,We);break e;case 2:Br=!0}}se.callback!==null&&se.lane!==0&&(r.flags|=64,We=w.effects,We===null?w.effects=[se]:We.push(se))}else dt={eventTime:dt,lane:We,tag:se.tag,payload:se.payload,callback:se.callback,next:null},qe===null?(Ee=qe=dt,de=Ge):qe=qe.next=dt,F|=We;if(se=se.next,se===null){if(se=w.shared.pending,se===null)break;We=se,se=We.next,We.next=null,w.lastBaseUpdate=We,w.shared.pending=null}}while(!0);if(qe===null&&(de=Ge),w.baseState=de,w.firstBaseUpdate=Ee,w.lastBaseUpdate=qe,o=w.shared.interleaved,o!==null){w=o;do F|=w.lane,w=w.next;while(w!==o)}else k===null&&(w.shared.lanes=0);ko|=F,r.lanes=F,r.memoizedState=Ge}}function by(r,o,d){if(r=o.effects,o.effects=null,r!==null)for(o=0;o<r.length;o++){var m=r[o],w=m.callback;if(w!==null){if(m.callback=null,m=d,typeof w!="function")throw Error(n(191,w));w.call(m)}}}var jl={},$i=Ir(jl),Ll=Ir(jl),Rl=Ir(jl);function So(r){if(r===jl)throw Error(n(174));return r}function uf(r,o){switch(ln(Rl,o),ln(Ll,r),ln($i,jl),r=o.nodeType,r){case 9:case 11:o=(o=o.documentElement)?o.namespaceURI:Oe(null,"");break;default:r=r===8?o.parentNode:o,o=r.namespaceURI||null,r=r.tagName,o=Oe(o,r)}fn($i),ln($i,o)}function Sa(){fn($i),fn(Ll),fn(Rl)}function Sy(r){So(Rl.current);var o=So($i.current),d=Oe(o,r.type);o!==d&&(ln(Ll,r),ln($i,d))}function df(r){Ll.current===r&&(fn($i),fn(Ll))}var wn=Ir(0);function Su(r){for(var o=r;o!==null;){if(o.tag===13){var d=o.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||d.data==="$?"||d.data==="$!"))return o}else if(o.tag===19&&o.memoizedProps.revealOrder!==void 0){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===r)break;for(;o.sibling===null;){if(o.return===null||o.return===r)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var hf=[];function ff(){for(var r=0;r<hf.length;r++)hf[r]._workInProgressVersionPrimary=null;hf.length=0}var xu=x.ReactCurrentDispatcher,pf=x.ReactCurrentBatchConfig,xo=0,bn=null,Fn=null,Qn=null,ku=!1,Al=!1,Ml=0,lN=0;function Cs(){throw Error(n(321))}function mf(r,o){if(o===null)return!1;for(var d=0;d<o.length&&d<r.length;d++)if(!ki(r[d],o[d]))return!1;return!0}function gf(r,o,d,m,w,k){if(xo=k,bn=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,xu.current=r===null||r.memoizedState===null?hN:fN,r=d(m,w),Al){k=0;do{if(Al=!1,Ml=0,25<=k)throw Error(n(301));k+=1,Qn=Fn=null,o.updateQueue=null,xu.current=pN,r=d(m,w)}while(Al)}if(xu.current=Nu,o=Fn!==null&&Fn.next!==null,xo=0,Qn=Fn=bn=null,ku=!1,o)throw Error(n(300));return r}function vf(){var r=Ml!==0;return Ml=0,r}function zi(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Qn===null?bn.memoizedState=Qn=r:Qn=Qn.next=r,Qn}function ci(){if(Fn===null){var r=bn.alternate;r=r!==null?r.memoizedState:null}else r=Fn.next;var o=Qn===null?bn.memoizedState:Qn.next;if(o!==null)Qn=o,Fn=r;else{if(r===null)throw Error(n(310));Fn=r,r={memoizedState:Fn.memoizedState,baseState:Fn.baseState,baseQueue:Fn.baseQueue,queue:Fn.queue,next:null},Qn===null?bn.memoizedState=Qn=r:Qn=Qn.next=r}return Qn}function Tl(r,o){return typeof o=="function"?o(r):o}function _f(r){var o=ci(),d=o.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=r;var m=Fn,w=m.baseQueue,k=d.pending;if(k!==null){if(w!==null){var F=w.next;w.next=k.next,k.next=F}m.baseQueue=w=k,d.pending=null}if(w!==null){k=w.next,m=m.baseState;var se=F=null,de=null,Ee=k;do{var qe=Ee.lane;if((xo&qe)===qe)de!==null&&(de=de.next={lane:0,action:Ee.action,hasEagerState:Ee.hasEagerState,eagerState:Ee.eagerState,next:null}),m=Ee.hasEagerState?Ee.eagerState:r(m,Ee.action);else{var Ge={lane:qe,action:Ee.action,hasEagerState:Ee.hasEagerState,eagerState:Ee.eagerState,next:null};de===null?(se=de=Ge,F=m):de=de.next=Ge,bn.lanes|=qe,ko|=qe}Ee=Ee.next}while(Ee!==null&&Ee!==k);de===null?F=m:de.next=se,ki(m,o.memoizedState)||(Ws=!0),o.memoizedState=m,o.baseState=F,o.baseQueue=de,d.lastRenderedState=m}if(r=d.interleaved,r!==null){w=r;do k=w.lane,bn.lanes|=k,ko|=k,w=w.next;while(w!==r)}else w===null&&(d.lanes=0);return[o.memoizedState,d.dispatch]}function yf(r){var o=ci(),d=o.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=r;var m=d.dispatch,w=d.pending,k=o.memoizedState;if(w!==null){d.pending=null;var F=w=w.next;do k=r(k,F.action),F=F.next;while(F!==w);ki(k,o.memoizedState)||(Ws=!0),o.memoizedState=k,o.baseQueue===null&&(o.baseState=k),d.lastRenderedState=k}return[k,m]}function xy(){}function ky(r,o){var d=bn,m=ci(),w=o(),k=!ki(m.memoizedState,w);if(k&&(m.memoizedState=w,Ws=!0),m=m.queue,wf(Ny.bind(null,d,m,r),[r]),m.getSnapshot!==o||k||Qn!==null&&Qn.memoizedState.tag&1){if(d.flags|=2048,Pl(9,Ey.bind(null,d,m,w,o),void 0,null),Zn===null)throw Error(n(349));(xo&30)!==0||Cy(d,o,w)}return w}function Cy(r,o,d){r.flags|=16384,r={getSnapshot:o,value:d},o=bn.updateQueue,o===null?(o={lastEffect:null,stores:null},bn.updateQueue=o,o.stores=[r]):(d=o.stores,d===null?o.stores=[r]:d.push(r))}function Ey(r,o,d,m){o.value=d,o.getSnapshot=m,jy(o)&&Ly(r)}function Ny(r,o,d){return d(function(){jy(o)&&Ly(r)})}function jy(r){var o=r.getSnapshot;r=r.value;try{var d=o();return!ki(r,d)}catch{return!0}}function Ly(r){var o=pr(r,1);o!==null&&Li(o,r,1,-1)}function Ry(r){var o=zi();return typeof r=="function"&&(r=r()),o.memoizedState=o.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Tl,lastRenderedState:r},o.queue=r,r=r.dispatch=dN.bind(null,bn,r),[o.memoizedState,r]}function Pl(r,o,d,m){return r={tag:r,create:o,destroy:d,deps:m,next:null},o=bn.updateQueue,o===null?(o={lastEffect:null,stores:null},bn.updateQueue=o,o.lastEffect=r.next=r):(d=o.lastEffect,d===null?o.lastEffect=r.next=r:(m=d.next,d.next=r,r.next=m,o.lastEffect=r)),r}function Ay(){return ci().memoizedState}function Cu(r,o,d,m){var w=zi();bn.flags|=r,w.memoizedState=Pl(1|o,d,void 0,m===void 0?null:m)}function Eu(r,o,d,m){var w=ci();m=m===void 0?null:m;var k=void 0;if(Fn!==null){var F=Fn.memoizedState;if(k=F.destroy,m!==null&&mf(m,F.deps)){w.memoizedState=Pl(o,d,k,m);return}}bn.flags|=r,w.memoizedState=Pl(1|o,d,k,m)}function My(r,o){return Cu(8390656,8,r,o)}function wf(r,o){return Eu(2048,8,r,o)}function Ty(r,o){return Eu(4,2,r,o)}function Py(r,o){return Eu(4,4,r,o)}function Iy(r,o){if(typeof o=="function")return r=r(),o(r),function(){o(null)};if(o!=null)return r=r(),o.current=r,function(){o.current=null}}function Dy(r,o,d){return d=d!=null?d.concat([r]):null,Eu(4,4,Iy.bind(null,o,r),d)}function bf(){}function Oy(r,o){var d=ci();o=o===void 0?null:o;var m=d.memoizedState;return m!==null&&o!==null&&mf(o,m[1])?m[0]:(d.memoizedState=[r,o],r)}function By(r,o){var d=ci();o=o===void 0?null:o;var m=d.memoizedState;return m!==null&&o!==null&&mf(o,m[1])?m[0]:(r=r(),d.memoizedState=[r,o],r)}function $y(r,o,d){return(xo&21)===0?(r.baseState&&(r.baseState=!1,Ws=!0),r.memoizedState=d):(ki(d,o)||(d=Xn(),bn.lanes|=d,ko|=d,r.baseState=!0),o)}function cN(r,o){var d=Zt;Zt=d!==0&&4>d?d:4,r(!0);var m=pf.transition;pf.transition={};try{r(!1),o()}finally{Zt=d,pf.transition=m}}function zy(){return ci().memoizedState}function uN(r,o,d){var m=Ur(r);if(d={lane:m,action:d,hasEagerState:!1,eagerState:null,next:null},Fy(r))Hy(o,d);else if(d=_y(r,o,d,m),d!==null){var w=Ts();Li(d,r,m,w),Uy(d,o,m)}}function dN(r,o,d){var m=Ur(r),w={lane:m,action:d,hasEagerState:!1,eagerState:null,next:null};if(Fy(r))Hy(o,w);else{var k=r.alternate;if(r.lanes===0&&(k===null||k.lanes===0)&&(k=o.lastRenderedReducer,k!==null))try{var F=o.lastRenderedState,se=k(F,d);if(w.hasEagerState=!0,w.eagerState=se,ki(se,F)){var de=o.interleaved;de===null?(w.next=w,lf(o)):(w.next=de.next,de.next=w),o.interleaved=w;return}}catch{}finally{}d=_y(r,o,w,m),d!==null&&(w=Ts(),Li(d,r,m,w),Uy(d,o,m))}}function Fy(r){var o=r.alternate;return r===bn||o!==null&&o===bn}function Hy(r,o){Al=ku=!0;var d=r.pending;d===null?o.next=o:(o.next=d.next,d.next=o),r.pending=o}function Uy(r,o,d){if((d&4194240)!==0){var m=o.lanes;m&=r.pendingLanes,d|=m,o.lanes=d,ir(r,d)}}var Nu={readContext:li,useCallback:Cs,useContext:Cs,useEffect:Cs,useImperativeHandle:Cs,useInsertionEffect:Cs,useLayoutEffect:Cs,useMemo:Cs,useReducer:Cs,useRef:Cs,useState:Cs,useDebugValue:Cs,useDeferredValue:Cs,useTransition:Cs,useMutableSource:Cs,useSyncExternalStore:Cs,useId:Cs,unstable_isNewReconciler:!1},hN={readContext:li,useCallback:function(r,o){return zi().memoizedState=[r,o===void 0?null:o],r},useContext:li,useEffect:My,useImperativeHandle:function(r,o,d){return d=d!=null?d.concat([r]):null,Cu(4194308,4,Iy.bind(null,o,r),d)},useLayoutEffect:function(r,o){return Cu(4194308,4,r,o)},useInsertionEffect:function(r,o){return Cu(4,2,r,o)},useMemo:function(r,o){var d=zi();return o=o===void 0?null:o,r=r(),d.memoizedState=[r,o],r},useReducer:function(r,o,d){var m=zi();return o=d!==void 0?d(o):o,m.memoizedState=m.baseState=o,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:o},m.queue=r,r=r.dispatch=uN.bind(null,bn,r),[m.memoizedState,r]},useRef:function(r){var o=zi();return r={current:r},o.memoizedState=r},useState:Ry,useDebugValue:bf,useDeferredValue:function(r){return zi().memoizedState=r},useTransition:function(){var r=Ry(!1),o=r[0];return r=cN.bind(null,r[1]),zi().memoizedState=r,[o,r]},useMutableSource:function(){},useSyncExternalStore:function(r,o,d){var m=bn,w=zi();if(vn){if(d===void 0)throw Error(n(407));d=d()}else{if(d=o(),Zn===null)throw Error(n(349));(xo&30)!==0||Cy(m,o,d)}w.memoizedState=d;var k={value:d,getSnapshot:o};return w.queue=k,My(Ny.bind(null,m,k,r),[r]),m.flags|=2048,Pl(9,Ey.bind(null,m,k,d,o),void 0,null),d},useId:function(){var r=zi(),o=Zn.identifierPrefix;if(vn){var d=fr,m=hr;d=(m&~(1<<32-De(m)-1)).toString(32)+d,o=":"+o+"R"+d,d=Ml++,0<d&&(o+="H"+d.toString(32)),o+=":"}else d=lN++,o=":"+o+"r"+d.toString(32)+":";return r.memoizedState=o},unstable_isNewReconciler:!1},fN={readContext:li,useCallback:Oy,useContext:li,useEffect:wf,useImperativeHandle:Dy,useInsertionEffect:Ty,useLayoutEffect:Py,useMemo:By,useReducer:_f,useRef:Ay,useState:function(){return _f(Tl)},useDebugValue:bf,useDeferredValue:function(r){var o=ci();return $y(o,Fn.memoizedState,r)},useTransition:function(){var r=_f(Tl)[0],o=ci().memoizedState;return[r,o]},useMutableSource:xy,useSyncExternalStore:ky,useId:zy,unstable_isNewReconciler:!1},pN={readContext:li,useCallback:Oy,useContext:li,useEffect:wf,useImperativeHandle:Dy,useInsertionEffect:Ty,useLayoutEffect:Py,useMemo:By,useReducer:yf,useRef:Ay,useState:function(){return yf(Tl)},useDebugValue:bf,useDeferredValue:function(r){var o=ci();return Fn===null?o.memoizedState=r:$y(o,Fn.memoizedState,r)},useTransition:function(){var r=yf(Tl)[0],o=ci().memoizedState;return[r,o]},useMutableSource:xy,useSyncExternalStore:ky,useId:zy,unstable_isNewReconciler:!1};function Ei(r,o){if(r&&r.defaultProps){o=H({},o),r=r.defaultProps;for(var d in r)o[d]===void 0&&(o[d]=r[d]);return o}return o}function Sf(r,o,d,m){o=r.memoizedState,d=d(m,o),d=d==null?o:H({},o,d),r.memoizedState=d,r.lanes===0&&(r.updateQueue.baseState=d)}var ju={isMounted:function(r){return(r=r._reactInternals)?Ut(r)===r:!1},enqueueSetState:function(r,o,d){r=r._reactInternals;var m=Ts(),w=Ur(r),k=mr(m,w);k.payload=o,d!=null&&(k.callback=d),o=$r(r,k,w),o!==null&&(Li(o,r,w,m),wu(o,r,w))},enqueueReplaceState:function(r,o,d){r=r._reactInternals;var m=Ts(),w=Ur(r),k=mr(m,w);k.tag=1,k.payload=o,d!=null&&(k.callback=d),o=$r(r,k,w),o!==null&&(Li(o,r,w,m),wu(o,r,w))},enqueueForceUpdate:function(r,o){r=r._reactInternals;var d=Ts(),m=Ur(r),w=mr(d,m);w.tag=2,o!=null&&(w.callback=o),o=$r(r,w,m),o!==null&&(Li(o,r,m,d),wu(o,r,m))}};function Wy(r,o,d,m,w,k,F){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(m,k,F):o.prototype&&o.prototype.isPureReactComponent?!wl(d,m)||!wl(w,k):!0}function qy(r,o,d){var m=!1,w=Dr,k=o.contextType;return typeof k=="object"&&k!==null?k=li(k):(w=Us(o)?_o:ks.current,m=o.contextTypes,k=(m=m!=null)?ma(r,w):Dr),o=new o(d,k),r.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=ju,r.stateNode=o,o._reactInternals=r,m&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=w,r.__reactInternalMemoizedMaskedChildContext=k),o}function Ky(r,o,d,m){r=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(d,m),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(d,m),o.state!==r&&ju.enqueueReplaceState(o,o.state,null)}function xf(r,o,d,m){var w=r.stateNode;w.props=d,w.state=r.memoizedState,w.refs={},cf(r);var k=o.contextType;typeof k=="object"&&k!==null?w.context=li(k):(k=Us(o)?_o:ks.current,w.context=ma(r,k)),w.state=r.memoizedState,k=o.getDerivedStateFromProps,typeof k=="function"&&(Sf(r,o,k,d),w.state=r.memoizedState),typeof o.getDerivedStateFromProps=="function"||typeof w.getSnapshotBeforeUpdate=="function"||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(o=w.state,typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount(),o!==w.state&&ju.enqueueReplaceState(w,w.state,null),bu(r,d,w,m),w.state=r.memoizedState),typeof w.componentDidMount=="function"&&(r.flags|=4194308)}function xa(r,o){try{var d="",m=o;do d+=re(m),m=m.return;while(m);var w=d}catch(k){w=`
39
+ Error generating stack: `+k.message+`
40
+ `+k.stack}return{value:r,source:o,stack:w,digest:null}}function kf(r,o,d){return{value:r,source:null,stack:d??null,digest:o??null}}function Cf(r,o){try{console.error(o.value)}catch(d){setTimeout(function(){throw d})}}var mN=typeof WeakMap=="function"?WeakMap:Map;function Vy(r,o,d){d=mr(-1,d),d.tag=3,d.payload={element:null};var m=o.value;return d.callback=function(){Iu||(Iu=!0,zf=m),Cf(r,o)},d}function Yy(r,o,d){d=mr(-1,d),d.tag=3;var m=r.type.getDerivedStateFromError;if(typeof m=="function"){var w=o.value;d.payload=function(){return m(w)},d.callback=function(){Cf(r,o)}}var k=r.stateNode;return k!==null&&typeof k.componentDidCatch=="function"&&(d.callback=function(){Cf(r,o),typeof m!="function"&&(Fr===null?Fr=new Set([this]):Fr.add(this));var F=o.stack;this.componentDidCatch(o.value,{componentStack:F!==null?F:""})}),d}function Gy(r,o,d){var m=r.pingCache;if(m===null){m=r.pingCache=new mN;var w=new Set;m.set(o,w)}else w=m.get(o),w===void 0&&(w=new Set,m.set(o,w));w.has(d)||(w.add(d),r=LN.bind(null,r,o,d),o.then(r,r))}function Xy(r){do{var o;if((o=r.tag===13)&&(o=r.memoizedState,o=o!==null?o.dehydrated!==null:!0),o)return r;r=r.return}while(r!==null);return null}function Jy(r,o,d,m,w){return(r.mode&1)===0?(r===o?r.flags|=65536:(r.flags|=128,d.flags|=131072,d.flags&=-52805,d.tag===1&&(d.alternate===null?d.tag=17:(o=mr(-1,1),o.tag=2,$r(d,o,1))),d.lanes|=1),r):(r.flags|=65536,r.lanes=w,r)}var gN=x.ReactCurrentOwner,Ws=!1;function Ms(r,o,d,m){o.child=r===null?vy(o,null,d,m):ya(o,r.child,d,m)}function Qy(r,o,d,m,w){d=d.render;var k=o.ref;return ba(o,w),m=gf(r,o,d,m,k,w),d=vf(),r!==null&&!Ws?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~w,gr(r,o,w)):(vn&&d&&Qh(o),o.flags|=1,Ms(r,o,m,w),o.child)}function Zy(r,o,d,m,w){if(r===null){var k=d.type;return typeof k=="function"&&!Vf(k)&&k.defaultProps===void 0&&d.compare===null&&d.defaultProps===void 0?(o.tag=15,o.type=k,ew(r,o,k,m,w)):(r=Fu(d.type,null,m,o,o.mode,w),r.ref=o.ref,r.return=o,o.child=r)}if(k=r.child,(r.lanes&w)===0){var F=k.memoizedProps;if(d=d.compare,d=d!==null?d:wl,d(F,m)&&r.ref===o.ref)return gr(r,o,w)}return o.flags|=1,r=qr(k,m),r.ref=o.ref,r.return=o,o.child=r}function ew(r,o,d,m,w){if(r!==null){var k=r.memoizedProps;if(wl(k,m)&&r.ref===o.ref)if(Ws=!1,o.pendingProps=m=k,(r.lanes&w)!==0)(r.flags&131072)!==0&&(Ws=!0);else return o.lanes=r.lanes,gr(r,o,w)}return Ef(r,o,d,m,w)}function tw(r,o,d){var m=o.pendingProps,w=m.children,k=r!==null?r.memoizedState:null;if(m.mode==="hidden")if((o.mode&1)===0)o.memoizedState={baseLanes:0,cachePool:null,transitions:null},ln(Ca,ti),ti|=d;else{if((d&1073741824)===0)return r=k!==null?k.baseLanes|d:d,o.lanes=o.childLanes=1073741824,o.memoizedState={baseLanes:r,cachePool:null,transitions:null},o.updateQueue=null,ln(Ca,ti),ti|=r,null;o.memoizedState={baseLanes:0,cachePool:null,transitions:null},m=k!==null?k.baseLanes:d,ln(Ca,ti),ti|=m}else k!==null?(m=k.baseLanes|d,o.memoizedState=null):m=d,ln(Ca,ti),ti|=m;return Ms(r,o,w,d),o.child}function nw(r,o){var d=o.ref;(r===null&&d!==null||r!==null&&r.ref!==d)&&(o.flags|=512,o.flags|=2097152)}function Ef(r,o,d,m,w){var k=Us(d)?_o:ks.current;return k=ma(o,k),ba(o,w),d=gf(r,o,d,m,k,w),m=vf(),r!==null&&!Ws?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~w,gr(r,o,w)):(vn&&m&&Qh(o),o.flags|=1,Ms(r,o,d,w),o.child)}function sw(r,o,d,m,w){if(Us(d)){var k=!0;hu(o)}else k=!1;if(ba(o,w),o.stateNode===null)Ru(r,o),qy(o,d,m),xf(o,d,m,w),m=!0;else if(r===null){var F=o.stateNode,se=o.memoizedProps;F.props=se;var de=F.context,Ee=d.contextType;typeof Ee=="object"&&Ee!==null?Ee=li(Ee):(Ee=Us(d)?_o:ks.current,Ee=ma(o,Ee));var qe=d.getDerivedStateFromProps,Ge=typeof qe=="function"||typeof F.getSnapshotBeforeUpdate=="function";Ge||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(se!==m||de!==Ee)&&Ky(o,F,m,Ee),Br=!1;var We=o.memoizedState;F.state=We,bu(o,m,F,w),de=o.memoizedState,se!==m||We!==de||Hs.current||Br?(typeof qe=="function"&&(Sf(o,d,qe,m),de=o.memoizedState),(se=Br||Wy(o,d,se,m,We,de,Ee))?(Ge||typeof F.UNSAFE_componentWillMount!="function"&&typeof F.componentWillMount!="function"||(typeof F.componentWillMount=="function"&&F.componentWillMount(),typeof F.UNSAFE_componentWillMount=="function"&&F.UNSAFE_componentWillMount()),typeof F.componentDidMount=="function"&&(o.flags|=4194308)):(typeof F.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=m,o.memoizedState=de),F.props=m,F.state=de,F.context=Ee,m=se):(typeof F.componentDidMount=="function"&&(o.flags|=4194308),m=!1)}else{F=o.stateNode,yy(r,o),se=o.memoizedProps,Ee=o.type===o.elementType?se:Ei(o.type,se),F.props=Ee,Ge=o.pendingProps,We=F.context,de=d.contextType,typeof de=="object"&&de!==null?de=li(de):(de=Us(d)?_o:ks.current,de=ma(o,de));var dt=d.getDerivedStateFromProps;(qe=typeof dt=="function"||typeof F.getSnapshotBeforeUpdate=="function")||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(se!==Ge||We!==de)&&Ky(o,F,m,de),Br=!1,We=o.memoizedState,F.state=We,bu(o,m,F,w);var vt=o.memoizedState;se!==Ge||We!==vt||Hs.current||Br?(typeof dt=="function"&&(Sf(o,d,dt,m),vt=o.memoizedState),(Ee=Br||Wy(o,d,Ee,m,We,vt,de)||!1)?(qe||typeof F.UNSAFE_componentWillUpdate!="function"&&typeof F.componentWillUpdate!="function"||(typeof F.componentWillUpdate=="function"&&F.componentWillUpdate(m,vt,de),typeof F.UNSAFE_componentWillUpdate=="function"&&F.UNSAFE_componentWillUpdate(m,vt,de)),typeof F.componentDidUpdate=="function"&&(o.flags|=4),typeof F.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof F.componentDidUpdate!="function"||se===r.memoizedProps&&We===r.memoizedState||(o.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||se===r.memoizedProps&&We===r.memoizedState||(o.flags|=1024),o.memoizedProps=m,o.memoizedState=vt),F.props=m,F.state=vt,F.context=de,m=Ee):(typeof F.componentDidUpdate!="function"||se===r.memoizedProps&&We===r.memoizedState||(o.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||se===r.memoizedProps&&We===r.memoizedState||(o.flags|=1024),m=!1)}return Nf(r,o,d,m,k,w)}function Nf(r,o,d,m,w,k){nw(r,o);var F=(o.flags&128)!==0;if(!m&&!F)return w&&ly(o,d,!1),gr(r,o,k);m=o.stateNode,gN.current=o;var se=F&&typeof d.getDerivedStateFromError!="function"?null:m.render();return o.flags|=1,r!==null&&F?(o.child=ya(o,r.child,null,k),o.child=ya(o,null,se,k)):Ms(r,o,se,k),o.memoizedState=m.state,w&&ly(o,d,!0),o.child}function iw(r){var o=r.stateNode;o.pendingContext?oy(r,o.pendingContext,o.pendingContext!==o.context):o.context&&oy(r,o.context,!1),uf(r,o.containerInfo)}function rw(r,o,d,m,w){return _a(),nf(w),o.flags|=256,Ms(r,o,d,m),o.child}var jf={dehydrated:null,treeContext:null,retryLane:0};function Lf(r){return{baseLanes:r,cachePool:null,transitions:null}}function ow(r,o,d){var m=o.pendingProps,w=wn.current,k=!1,F=(o.flags&128)!==0,se;if((se=F)||(se=r!==null&&r.memoizedState===null?!1:(w&2)!==0),se?(k=!0,o.flags&=-129):(r===null||r.memoizedState!==null)&&(w|=1),ln(wn,w&1),r===null)return tf(o),r=o.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((o.mode&1)===0?o.lanes=1:r.data==="$!"?o.lanes=8:o.lanes=1073741824,null):(F=m.children,r=m.fallback,k?(m=o.mode,k=o.child,F={mode:"hidden",children:F},(m&1)===0&&k!==null?(k.childLanes=0,k.pendingProps=F):k=Hu(F,m,0,null),r=jo(r,m,d,null),k.return=o,r.return=o,k.sibling=r,o.child=k,o.child.memoizedState=Lf(d),o.memoizedState=jf,r):Rf(o,F));if(w=r.memoizedState,w!==null&&(se=w.dehydrated,se!==null))return vN(r,o,F,m,se,w,d);if(k){k=m.fallback,F=o.mode,w=r.child,se=w.sibling;var de={mode:"hidden",children:m.children};return(F&1)===0&&o.child!==w?(m=o.child,m.childLanes=0,m.pendingProps=de,o.deletions=null):(m=qr(w,de),m.subtreeFlags=w.subtreeFlags&14680064),se!==null?k=qr(se,k):(k=jo(k,F,d,null),k.flags|=2),k.return=o,m.return=o,m.sibling=k,o.child=m,m=k,k=o.child,F=r.child.memoizedState,F=F===null?Lf(d):{baseLanes:F.baseLanes|d,cachePool:null,transitions:F.transitions},k.memoizedState=F,k.childLanes=r.childLanes&~d,o.memoizedState=jf,m}return k=r.child,r=k.sibling,m=qr(k,{mode:"visible",children:m.children}),(o.mode&1)===0&&(m.lanes=d),m.return=o,m.sibling=null,r!==null&&(d=o.deletions,d===null?(o.deletions=[r],o.flags|=16):d.push(r)),o.child=m,o.memoizedState=null,m}function Rf(r,o){return o=Hu({mode:"visible",children:o},r.mode,0,null),o.return=r,r.child=o}function Lu(r,o,d,m){return m!==null&&nf(m),ya(o,r.child,null,d),r=Rf(o,o.pendingProps.children),r.flags|=2,o.memoizedState=null,r}function vN(r,o,d,m,w,k,F){if(d)return o.flags&256?(o.flags&=-257,m=kf(Error(n(422))),Lu(r,o,F,m)):o.memoizedState!==null?(o.child=r.child,o.flags|=128,null):(k=m.fallback,w=o.mode,m=Hu({mode:"visible",children:m.children},w,0,null),k=jo(k,w,F,null),k.flags|=2,m.return=o,k.return=o,m.sibling=k,o.child=m,(o.mode&1)!==0&&ya(o,r.child,null,F),o.child.memoizedState=Lf(F),o.memoizedState=jf,k);if((o.mode&1)===0)return Lu(r,o,F,null);if(w.data==="$!"){if(m=w.nextSibling&&w.nextSibling.dataset,m)var se=m.dgst;return m=se,k=Error(n(419)),m=kf(k,m,void 0),Lu(r,o,F,m)}if(se=(F&r.childLanes)!==0,Ws||se){if(m=Zn,m!==null){switch(F&-F){case 4:w=2;break;case 16:w=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:w=32;break;case 536870912:w=268435456;break;default:w=0}w=(w&(m.suspendedLanes|F))!==0?0:w,w!==0&&w!==k.retryLane&&(k.retryLane=w,pr(r,w),Li(m,r,w,-1))}return Kf(),m=kf(Error(n(421))),Lu(r,o,F,m)}return w.data==="$?"?(o.flags|=128,o.child=r.child,o=RN.bind(null,r),w._reactRetry=o,null):(r=k.treeContext,ei=Pr(w.nextSibling),Zs=o,vn=!0,Ci=null,r!==null&&(oi[ai++]=hr,oi[ai++]=fr,oi[ai++]=yo,hr=r.id,fr=r.overflow,yo=o),o=Rf(o,m.children),o.flags|=4096,o)}function aw(r,o,d){r.lanes|=o;var m=r.alternate;m!==null&&(m.lanes|=o),af(r.return,o,d)}function Af(r,o,d,m,w){var k=r.memoizedState;k===null?r.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:m,tail:d,tailMode:w}:(k.isBackwards=o,k.rendering=null,k.renderingStartTime=0,k.last=m,k.tail=d,k.tailMode=w)}function lw(r,o,d){var m=o.pendingProps,w=m.revealOrder,k=m.tail;if(Ms(r,o,m.children,d),m=wn.current,(m&2)!==0)m=m&1|2,o.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=o.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&aw(r,d,o);else if(r.tag===19)aw(r,d,o);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===o)break e;for(;r.sibling===null;){if(r.return===null||r.return===o)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}m&=1}if(ln(wn,m),(o.mode&1)===0)o.memoizedState=null;else switch(w){case"forwards":for(d=o.child,w=null;d!==null;)r=d.alternate,r!==null&&Su(r)===null&&(w=d),d=d.sibling;d=w,d===null?(w=o.child,o.child=null):(w=d.sibling,d.sibling=null),Af(o,!1,w,d,k);break;case"backwards":for(d=null,w=o.child,o.child=null;w!==null;){if(r=w.alternate,r!==null&&Su(r)===null){o.child=w;break}r=w.sibling,w.sibling=d,d=w,w=r}Af(o,!0,d,null,k);break;case"together":Af(o,!1,null,null,void 0);break;default:o.memoizedState=null}return o.child}function Ru(r,o){(o.mode&1)===0&&r!==null&&(r.alternate=null,o.alternate=null,o.flags|=2)}function gr(r,o,d){if(r!==null&&(o.dependencies=r.dependencies),ko|=o.lanes,(d&o.childLanes)===0)return null;if(r!==null&&o.child!==r.child)throw Error(n(153));if(o.child!==null){for(r=o.child,d=qr(r,r.pendingProps),o.child=d,d.return=o;r.sibling!==null;)r=r.sibling,d=d.sibling=qr(r,r.pendingProps),d.return=o;d.sibling=null}return o.child}function _N(r,o,d){switch(o.tag){case 3:iw(o),_a();break;case 5:Sy(o);break;case 1:Us(o.type)&&hu(o);break;case 4:uf(o,o.stateNode.containerInfo);break;case 10:var m=o.type._context,w=o.memoizedProps.value;ln(_u,m._currentValue),m._currentValue=w;break;case 13:if(m=o.memoizedState,m!==null)return m.dehydrated!==null?(ln(wn,wn.current&1),o.flags|=128,null):(d&o.child.childLanes)!==0?ow(r,o,d):(ln(wn,wn.current&1),r=gr(r,o,d),r!==null?r.sibling:null);ln(wn,wn.current&1);break;case 19:if(m=(d&o.childLanes)!==0,(r.flags&128)!==0){if(m)return lw(r,o,d);o.flags|=128}if(w=o.memoizedState,w!==null&&(w.rendering=null,w.tail=null,w.lastEffect=null),ln(wn,wn.current),m)break;return null;case 22:case 23:return o.lanes=0,tw(r,o,d)}return gr(r,o,d)}var cw,Mf,uw,dw;cw=function(r,o){for(var d=o.child;d!==null;){if(d.tag===5||d.tag===6)r.appendChild(d.stateNode);else if(d.tag!==4&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===o)break;for(;d.sibling===null;){if(d.return===null||d.return===o)return;d=d.return}d.sibling.return=d.return,d=d.sibling}},Mf=function(){},uw=function(r,o,d,m){var w=r.memoizedProps;if(w!==m){r=o.stateNode,So($i.current);var k=null;switch(d){case"input":w=X(r,w),m=X(r,m),k=[];break;case"select":w=H({},w,{value:void 0}),m=H({},m,{value:void 0}),k=[];break;case"textarea":w=Ve(r,w),m=Ve(r,m),k=[];break;default:typeof w.onClick!="function"&&typeof m.onClick=="function"&&(r.onclick=cu)}Me(d,m);var F;d=null;for(Ee in w)if(!m.hasOwnProperty(Ee)&&w.hasOwnProperty(Ee)&&w[Ee]!=null)if(Ee==="style"){var se=w[Ee];for(F in se)se.hasOwnProperty(F)&&(d||(d={}),d[F]="")}else Ee!=="dangerouslySetInnerHTML"&&Ee!=="children"&&Ee!=="suppressContentEditableWarning"&&Ee!=="suppressHydrationWarning"&&Ee!=="autoFocus"&&(i.hasOwnProperty(Ee)?k||(k=[]):(k=k||[]).push(Ee,null));for(Ee in m){var de=m[Ee];if(se=w!=null?w[Ee]:void 0,m.hasOwnProperty(Ee)&&de!==se&&(de!=null||se!=null))if(Ee==="style")if(se){for(F in se)!se.hasOwnProperty(F)||de&&de.hasOwnProperty(F)||(d||(d={}),d[F]="");for(F in de)de.hasOwnProperty(F)&&se[F]!==de[F]&&(d||(d={}),d[F]=de[F])}else d||(k||(k=[]),k.push(Ee,d)),d=de;else Ee==="dangerouslySetInnerHTML"?(de=de?de.__html:void 0,se=se?se.__html:void 0,de!=null&&se!==de&&(k=k||[]).push(Ee,de)):Ee==="children"?typeof de!="string"&&typeof de!="number"||(k=k||[]).push(Ee,""+de):Ee!=="suppressContentEditableWarning"&&Ee!=="suppressHydrationWarning"&&(i.hasOwnProperty(Ee)?(de!=null&&Ee==="onScroll"&&hn("scroll",r),k||se===de||(k=[])):(k=k||[]).push(Ee,de))}d&&(k=k||[]).push("style",d);var Ee=k;(o.updateQueue=Ee)&&(o.flags|=4)}},dw=function(r,o,d,m){d!==m&&(o.flags|=4)};function Il(r,o){if(!vn)switch(r.tailMode){case"hidden":o=r.tail;for(var d=null;o!==null;)o.alternate!==null&&(d=o),o=o.sibling;d===null?r.tail=null:d.sibling=null;break;case"collapsed":d=r.tail;for(var m=null;d!==null;)d.alternate!==null&&(m=d),d=d.sibling;m===null?o||r.tail===null?r.tail=null:r.tail.sibling=null:m.sibling=null}}function Es(r){var o=r.alternate!==null&&r.alternate.child===r.child,d=0,m=0;if(o)for(var w=r.child;w!==null;)d|=w.lanes|w.childLanes,m|=w.subtreeFlags&14680064,m|=w.flags&14680064,w.return=r,w=w.sibling;else for(w=r.child;w!==null;)d|=w.lanes|w.childLanes,m|=w.subtreeFlags,m|=w.flags,w.return=r,w=w.sibling;return r.subtreeFlags|=m,r.childLanes=d,o}function yN(r,o,d){var m=o.pendingProps;switch(Zh(o),o.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Es(o),null;case 1:return Us(o.type)&&du(),Es(o),null;case 3:return m=o.stateNode,Sa(),fn(Hs),fn(ks),ff(),m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null),(r===null||r.child===null)&&(gu(o)?o.flags|=4:r===null||r.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,Ci!==null&&(Uf(Ci),Ci=null))),Mf(r,o),Es(o),null;case 5:df(o);var w=So(Rl.current);if(d=o.type,r!==null&&o.stateNode!=null)uw(r,o,d,m,w),r.ref!==o.ref&&(o.flags|=512,o.flags|=2097152);else{if(!m){if(o.stateNode===null)throw Error(n(166));return Es(o),null}if(r=So($i.current),gu(o)){m=o.stateNode,d=o.type;var k=o.memoizedProps;switch(m[Bi]=o,m[Cl]=k,r=(o.mode&1)!==0,d){case"dialog":hn("cancel",m),hn("close",m);break;case"iframe":case"object":case"embed":hn("load",m);break;case"video":case"audio":for(w=0;w<Sl.length;w++)hn(Sl[w],m);break;case"source":hn("error",m);break;case"img":case"image":case"link":hn("error",m),hn("load",m);break;case"details":hn("toggle",m);break;case"input":ce(m,k),hn("invalid",m);break;case"select":m._wrapperState={wasMultiple:!!k.multiple},hn("invalid",m);break;case"textarea":Ye(m,k),hn("invalid",m)}Me(d,k),w=null;for(var F in k)if(k.hasOwnProperty(F)){var se=k[F];F==="children"?typeof se=="string"?m.textContent!==se&&(k.suppressHydrationWarning!==!0&&lu(m.textContent,se,r),w=["children",se]):typeof se=="number"&&m.textContent!==""+se&&(k.suppressHydrationWarning!==!0&&lu(m.textContent,se,r),w=["children",""+se]):i.hasOwnProperty(F)&&se!=null&&F==="onScroll"&&hn("scroll",m)}switch(d){case"input":Fe(m),Y(m,k,!0);break;case"textarea":Fe(m),ze(m);break;case"select":case"option":break;default:typeof k.onClick=="function"&&(m.onclick=cu)}m=w,o.updateQueue=m,m!==null&&(o.flags|=4)}else{F=w.nodeType===9?w:w.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=ve(d)),r==="http://www.w3.org/1999/xhtml"?d==="script"?(r=F.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof m.is=="string"?r=F.createElement(d,{is:m.is}):(r=F.createElement(d),d==="select"&&(F=r,m.multiple?F.multiple=!0:m.size&&(F.size=m.size))):r=F.createElementNS(r,d),r[Bi]=o,r[Cl]=m,cw(r,o,!1,!1),o.stateNode=r;e:{switch(F=oe(d,m),d){case"dialog":hn("cancel",r),hn("close",r),w=m;break;case"iframe":case"object":case"embed":hn("load",r),w=m;break;case"video":case"audio":for(w=0;w<Sl.length;w++)hn(Sl[w],r);w=m;break;case"source":hn("error",r),w=m;break;case"img":case"image":case"link":hn("error",r),hn("load",r),w=m;break;case"details":hn("toggle",r),w=m;break;case"input":ce(r,m),w=X(r,m),hn("invalid",r);break;case"option":w=m;break;case"select":r._wrapperState={wasMultiple:!!m.multiple},w=H({},m,{value:void 0}),hn("invalid",r);break;case"textarea":Ye(r,m),w=Ve(r,m),hn("invalid",r);break;default:w=m}Me(d,w),se=w;for(k in se)if(se.hasOwnProperty(k)){var de=se[k];k==="style"?le(r,de):k==="dangerouslySetInnerHTML"?(de=de?de.__html:void 0,de!=null&&Ue(r,de)):k==="children"?typeof de=="string"?(d!=="textarea"||de!=="")&&st(r,de):typeof de=="number"&&st(r,""+de):k!=="suppressContentEditableWarning"&&k!=="suppressHydrationWarning"&&k!=="autoFocus"&&(i.hasOwnProperty(k)?de!=null&&k==="onScroll"&&hn("scroll",r):de!=null&&O(r,k,de,F))}switch(d){case"input":Fe(r),Y(r,m,!1);break;case"textarea":Fe(r),ze(r);break;case"option":m.value!=null&&r.setAttribute("value",""+ne(m.value));break;case"select":r.multiple=!!m.multiple,k=m.value,k!=null?Ce(r,!!m.multiple,k,!1):m.defaultValue!=null&&Ce(r,!!m.multiple,m.defaultValue,!0);break;default:typeof w.onClick=="function"&&(r.onclick=cu)}switch(d){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}}m&&(o.flags|=4)}o.ref!==null&&(o.flags|=512,o.flags|=2097152)}return Es(o),null;case 6:if(r&&o.stateNode!=null)dw(r,o,r.memoizedProps,m);else{if(typeof m!="string"&&o.stateNode===null)throw Error(n(166));if(d=So(Rl.current),So($i.current),gu(o)){if(m=o.stateNode,d=o.memoizedProps,m[Bi]=o,(k=m.nodeValue!==d)&&(r=Zs,r!==null))switch(r.tag){case 3:lu(m.nodeValue,d,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&lu(m.nodeValue,d,(r.mode&1)!==0)}k&&(o.flags|=4)}else m=(d.nodeType===9?d:d.ownerDocument).createTextNode(m),m[Bi]=o,o.stateNode=m}return Es(o),null;case 13:if(fn(wn),m=o.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(vn&&ei!==null&&(o.mode&1)!==0&&(o.flags&128)===0)py(),_a(),o.flags|=98560,k=!1;else if(k=gu(o),m!==null&&m.dehydrated!==null){if(r===null){if(!k)throw Error(n(318));if(k=o.memoizedState,k=k!==null?k.dehydrated:null,!k)throw Error(n(317));k[Bi]=o}else _a(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Es(o),k=!1}else Ci!==null&&(Uf(Ci),Ci=null),k=!0;if(!k)return o.flags&65536?o:null}return(o.flags&128)!==0?(o.lanes=d,o):(m=m!==null,m!==(r!==null&&r.memoizedState!==null)&&m&&(o.child.flags|=8192,(o.mode&1)!==0&&(r===null||(wn.current&1)!==0?Hn===0&&(Hn=3):Kf())),o.updateQueue!==null&&(o.flags|=4),Es(o),null);case 4:return Sa(),Mf(r,o),r===null&&xl(o.stateNode.containerInfo),Es(o),null;case 10:return of(o.type._context),Es(o),null;case 17:return Us(o.type)&&du(),Es(o),null;case 19:if(fn(wn),k=o.memoizedState,k===null)return Es(o),null;if(m=(o.flags&128)!==0,F=k.rendering,F===null)if(m)Il(k,!1);else{if(Hn!==0||r!==null&&(r.flags&128)!==0)for(r=o.child;r!==null;){if(F=Su(r),F!==null){for(o.flags|=128,Il(k,!1),m=F.updateQueue,m!==null&&(o.updateQueue=m,o.flags|=4),o.subtreeFlags=0,m=d,d=o.child;d!==null;)k=d,r=m,k.flags&=14680066,F=k.alternate,F===null?(k.childLanes=0,k.lanes=r,k.child=null,k.subtreeFlags=0,k.memoizedProps=null,k.memoizedState=null,k.updateQueue=null,k.dependencies=null,k.stateNode=null):(k.childLanes=F.childLanes,k.lanes=F.lanes,k.child=F.child,k.subtreeFlags=0,k.deletions=null,k.memoizedProps=F.memoizedProps,k.memoizedState=F.memoizedState,k.updateQueue=F.updateQueue,k.type=F.type,r=F.dependencies,k.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),d=d.sibling;return ln(wn,wn.current&1|2),o.child}r=r.sibling}k.tail!==null&&G()>Ea&&(o.flags|=128,m=!0,Il(k,!1),o.lanes=4194304)}else{if(!m)if(r=Su(F),r!==null){if(o.flags|=128,m=!0,d=r.updateQueue,d!==null&&(o.updateQueue=d,o.flags|=4),Il(k,!0),k.tail===null&&k.tailMode==="hidden"&&!F.alternate&&!vn)return Es(o),null}else 2*G()-k.renderingStartTime>Ea&&d!==1073741824&&(o.flags|=128,m=!0,Il(k,!1),o.lanes=4194304);k.isBackwards?(F.sibling=o.child,o.child=F):(d=k.last,d!==null?d.sibling=F:o.child=F,k.last=F)}return k.tail!==null?(o=k.tail,k.rendering=o,k.tail=o.sibling,k.renderingStartTime=G(),o.sibling=null,d=wn.current,ln(wn,m?d&1|2:d&1),o):(Es(o),null);case 22:case 23:return qf(),m=o.memoizedState!==null,r!==null&&r.memoizedState!==null!==m&&(o.flags|=8192),m&&(o.mode&1)!==0?(ti&1073741824)!==0&&(Es(o),o.subtreeFlags&6&&(o.flags|=8192)):Es(o),null;case 24:return null;case 25:return null}throw Error(n(156,o.tag))}function wN(r,o){switch(Zh(o),o.tag){case 1:return Us(o.type)&&du(),r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 3:return Sa(),fn(Hs),fn(ks),ff(),r=o.flags,(r&65536)!==0&&(r&128)===0?(o.flags=r&-65537|128,o):null;case 5:return df(o),null;case 13:if(fn(wn),r=o.memoizedState,r!==null&&r.dehydrated!==null){if(o.alternate===null)throw Error(n(340));_a()}return r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 19:return fn(wn),null;case 4:return Sa(),null;case 10:return of(o.type._context),null;case 22:case 23:return qf(),null;case 24:return null;default:return null}}var Au=!1,Ns=!1,bN=typeof WeakSet=="function"?WeakSet:Set,mt=null;function ka(r,o){var d=r.ref;if(d!==null)if(typeof d=="function")try{d(null)}catch(m){Nn(r,o,m)}else d.current=null}function Tf(r,o,d){try{d()}catch(m){Nn(r,o,m)}}var hw=!1;function SN(r,o){if(Wh=cr,r=W_(),Dh(r)){if("selectionStart"in r)var d={start:r.selectionStart,end:r.selectionEnd};else e:{d=(d=r.ownerDocument)&&d.defaultView||window;var m=d.getSelection&&d.getSelection();if(m&&m.rangeCount!==0){d=m.anchorNode;var w=m.anchorOffset,k=m.focusNode;m=m.focusOffset;try{d.nodeType,k.nodeType}catch{d=null;break e}var F=0,se=-1,de=-1,Ee=0,qe=0,Ge=r,We=null;t:for(;;){for(var dt;Ge!==d||w!==0&&Ge.nodeType!==3||(se=F+w),Ge!==k||m!==0&&Ge.nodeType!==3||(de=F+m),Ge.nodeType===3&&(F+=Ge.nodeValue.length),(dt=Ge.firstChild)!==null;)We=Ge,Ge=dt;for(;;){if(Ge===r)break t;if(We===d&&++Ee===w&&(se=F),We===k&&++qe===m&&(de=F),(dt=Ge.nextSibling)!==null)break;Ge=We,We=Ge.parentNode}Ge=dt}d=se===-1||de===-1?null:{start:se,end:de}}else d=null}d=d||{start:0,end:0}}else d=null;for(qh={focusedElem:r,selectionRange:d},cr=!1,mt=o;mt!==null;)if(o=mt,r=o.child,(o.subtreeFlags&1028)!==0&&r!==null)r.return=o,mt=r;else for(;mt!==null;){o=mt;try{var vt=o.alternate;if((o.flags&1024)!==0)switch(o.tag){case 0:case 11:case 15:break;case 1:if(vt!==null){var yt=vt.memoizedProps,Tn=vt.memoizedState,Se=o.stateNode,pe=Se.getSnapshotBeforeUpdate(o.elementType===o.type?yt:Ei(o.type,yt),Tn);Se.__reactInternalSnapshotBeforeUpdate=pe}break;case 3:var xe=o.stateNode.containerInfo;xe.nodeType===1?xe.textContent="":xe.nodeType===9&&xe.documentElement&&xe.removeChild(xe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(tt){Nn(o,o.return,tt)}if(r=o.sibling,r!==null){r.return=o.return,mt=r;break}mt=o.return}return vt=hw,hw=!1,vt}function Dl(r,o,d){var m=o.updateQueue;if(m=m!==null?m.lastEffect:null,m!==null){var w=m=m.next;do{if((w.tag&r)===r){var k=w.destroy;w.destroy=void 0,k!==void 0&&Tf(o,d,k)}w=w.next}while(w!==m)}}function Mu(r,o){if(o=o.updateQueue,o=o!==null?o.lastEffect:null,o!==null){var d=o=o.next;do{if((d.tag&r)===r){var m=d.create;d.destroy=m()}d=d.next}while(d!==o)}}function Pf(r){var o=r.ref;if(o!==null){var d=r.stateNode;switch(r.tag){case 5:r=d;break;default:r=d}typeof o=="function"?o(r):o.current=r}}function fw(r){var o=r.alternate;o!==null&&(r.alternate=null,fw(o)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(o=r.stateNode,o!==null&&(delete o[Bi],delete o[Cl],delete o[Gh],delete o[iN],delete o[rN])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function pw(r){return r.tag===5||r.tag===3||r.tag===4}function mw(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||pw(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function If(r,o,d){var m=r.tag;if(m===5||m===6)r=r.stateNode,o?d.nodeType===8?d.parentNode.insertBefore(r,o):d.insertBefore(r,o):(d.nodeType===8?(o=d.parentNode,o.insertBefore(r,d)):(o=d,o.appendChild(r)),d=d._reactRootContainer,d!=null||o.onclick!==null||(o.onclick=cu));else if(m!==4&&(r=r.child,r!==null))for(If(r,o,d),r=r.sibling;r!==null;)If(r,o,d),r=r.sibling}function Df(r,o,d){var m=r.tag;if(m===5||m===6)r=r.stateNode,o?d.insertBefore(r,o):d.appendChild(r);else if(m!==4&&(r=r.child,r!==null))for(Df(r,o,d),r=r.sibling;r!==null;)Df(r,o,d),r=r.sibling}var hs=null,Ni=!1;function zr(r,o,d){for(d=d.child;d!==null;)gw(r,o,d),d=d.sibling}function gw(r,o,d){if(lt&&typeof lt.onCommitFiberUnmount=="function")try{lt.onCommitFiberUnmount(Le,d)}catch{}switch(d.tag){case 5:Ns||ka(d,o);case 6:var m=hs,w=Ni;hs=null,zr(r,o,d),hs=m,Ni=w,hs!==null&&(Ni?(r=hs,d=d.stateNode,r.nodeType===8?r.parentNode.removeChild(d):r.removeChild(d)):hs.removeChild(d.stateNode));break;case 18:hs!==null&&(Ni?(r=hs,d=d.stateNode,r.nodeType===8?Yh(r.parentNode,d):r.nodeType===1&&Yh(r,d),Oi(r)):Yh(hs,d.stateNode));break;case 4:m=hs,w=Ni,hs=d.stateNode.containerInfo,Ni=!0,zr(r,o,d),hs=m,Ni=w;break;case 0:case 11:case 14:case 15:if(!Ns&&(m=d.updateQueue,m!==null&&(m=m.lastEffect,m!==null))){w=m=m.next;do{var k=w,F=k.destroy;k=k.tag,F!==void 0&&((k&2)!==0||(k&4)!==0)&&Tf(d,o,F),w=w.next}while(w!==m)}zr(r,o,d);break;case 1:if(!Ns&&(ka(d,o),m=d.stateNode,typeof m.componentWillUnmount=="function"))try{m.props=d.memoizedProps,m.state=d.memoizedState,m.componentWillUnmount()}catch(se){Nn(d,o,se)}zr(r,o,d);break;case 21:zr(r,o,d);break;case 22:d.mode&1?(Ns=(m=Ns)||d.memoizedState!==null,zr(r,o,d),Ns=m):zr(r,o,d);break;default:zr(r,o,d)}}function vw(r){var o=r.updateQueue;if(o!==null){r.updateQueue=null;var d=r.stateNode;d===null&&(d=r.stateNode=new bN),o.forEach(function(m){var w=AN.bind(null,r,m);d.has(m)||(d.add(m),m.then(w,w))})}}function ji(r,o){var d=o.deletions;if(d!==null)for(var m=0;m<d.length;m++){var w=d[m];try{var k=r,F=o,se=F;e:for(;se!==null;){switch(se.tag){case 5:hs=se.stateNode,Ni=!1;break e;case 3:hs=se.stateNode.containerInfo,Ni=!0;break e;case 4:hs=se.stateNode.containerInfo,Ni=!0;break e}se=se.return}if(hs===null)throw Error(n(160));gw(k,F,w),hs=null,Ni=!1;var de=w.alternate;de!==null&&(de.return=null),w.return=null}catch(Ee){Nn(w,o,Ee)}}if(o.subtreeFlags&12854)for(o=o.child;o!==null;)_w(o,r),o=o.sibling}function _w(r,o){var d=r.alternate,m=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(ji(o,r),Fi(r),m&4){try{Dl(3,r,r.return),Mu(3,r)}catch(yt){Nn(r,r.return,yt)}try{Dl(5,r,r.return)}catch(yt){Nn(r,r.return,yt)}}break;case 1:ji(o,r),Fi(r),m&512&&d!==null&&ka(d,d.return);break;case 5:if(ji(o,r),Fi(r),m&512&&d!==null&&ka(d,d.return),r.flags&32){var w=r.stateNode;try{st(w,"")}catch(yt){Nn(r,r.return,yt)}}if(m&4&&(w=r.stateNode,w!=null)){var k=r.memoizedProps,F=d!==null?d.memoizedProps:k,se=r.type,de=r.updateQueue;if(r.updateQueue=null,de!==null)try{se==="input"&&k.type==="radio"&&k.name!=null&&Z(w,k),oe(se,F);var Ee=oe(se,k);for(F=0;F<de.length;F+=2){var qe=de[F],Ge=de[F+1];qe==="style"?le(w,Ge):qe==="dangerouslySetInnerHTML"?Ue(w,Ge):qe==="children"?st(w,Ge):O(w,qe,Ge,Ee)}switch(se){case"input":ge(w,k);break;case"textarea":ht(w,k);break;case"select":var We=w._wrapperState.wasMultiple;w._wrapperState.wasMultiple=!!k.multiple;var dt=k.value;dt!=null?Ce(w,!!k.multiple,dt,!1):We!==!!k.multiple&&(k.defaultValue!=null?Ce(w,!!k.multiple,k.defaultValue,!0):Ce(w,!!k.multiple,k.multiple?[]:"",!1))}w[Cl]=k}catch(yt){Nn(r,r.return,yt)}}break;case 6:if(ji(o,r),Fi(r),m&4){if(r.stateNode===null)throw Error(n(162));w=r.stateNode,k=r.memoizedProps;try{w.nodeValue=k}catch(yt){Nn(r,r.return,yt)}}break;case 3:if(ji(o,r),Fi(r),m&4&&d!==null&&d.memoizedState.isDehydrated)try{Oi(o.containerInfo)}catch(yt){Nn(r,r.return,yt)}break;case 4:ji(o,r),Fi(r);break;case 13:ji(o,r),Fi(r),w=r.child,w.flags&8192&&(k=w.memoizedState!==null,w.stateNode.isHidden=k,!k||w.alternate!==null&&w.alternate.memoizedState!==null||($f=G())),m&4&&vw(r);break;case 22:if(qe=d!==null&&d.memoizedState!==null,r.mode&1?(Ns=(Ee=Ns)||qe,ji(o,r),Ns=Ee):ji(o,r),Fi(r),m&8192){if(Ee=r.memoizedState!==null,(r.stateNode.isHidden=Ee)&&!qe&&(r.mode&1)!==0)for(mt=r,qe=r.child;qe!==null;){for(Ge=mt=qe;mt!==null;){switch(We=mt,dt=We.child,We.tag){case 0:case 11:case 14:case 15:Dl(4,We,We.return);break;case 1:ka(We,We.return);var vt=We.stateNode;if(typeof vt.componentWillUnmount=="function"){m=We,d=We.return;try{o=m,vt.props=o.memoizedProps,vt.state=o.memoizedState,vt.componentWillUnmount()}catch(yt){Nn(m,d,yt)}}break;case 5:ka(We,We.return);break;case 22:if(We.memoizedState!==null){bw(Ge);continue}}dt!==null?(dt.return=We,mt=dt):bw(Ge)}qe=qe.sibling}e:for(qe=null,Ge=r;;){if(Ge.tag===5){if(qe===null){qe=Ge;try{w=Ge.stateNode,Ee?(k=w.style,typeof k.setProperty=="function"?k.setProperty("display","none","important"):k.display="none"):(se=Ge.stateNode,de=Ge.memoizedProps.style,F=de!=null&&de.hasOwnProperty("display")?de.display:null,se.style.display=P("display",F))}catch(yt){Nn(r,r.return,yt)}}}else if(Ge.tag===6){if(qe===null)try{Ge.stateNode.nodeValue=Ee?"":Ge.memoizedProps}catch(yt){Nn(r,r.return,yt)}}else if((Ge.tag!==22&&Ge.tag!==23||Ge.memoizedState===null||Ge===r)&&Ge.child!==null){Ge.child.return=Ge,Ge=Ge.child;continue}if(Ge===r)break e;for(;Ge.sibling===null;){if(Ge.return===null||Ge.return===r)break e;qe===Ge&&(qe=null),Ge=Ge.return}qe===Ge&&(qe=null),Ge.sibling.return=Ge.return,Ge=Ge.sibling}}break;case 19:ji(o,r),Fi(r),m&4&&vw(r);break;case 21:break;default:ji(o,r),Fi(r)}}function Fi(r){var o=r.flags;if(o&2){try{e:{for(var d=r.return;d!==null;){if(pw(d)){var m=d;break e}d=d.return}throw Error(n(160))}switch(m.tag){case 5:var w=m.stateNode;m.flags&32&&(st(w,""),m.flags&=-33);var k=mw(r);Df(r,k,w);break;case 3:case 4:var F=m.stateNode.containerInfo,se=mw(r);If(r,se,F);break;default:throw Error(n(161))}}catch(de){Nn(r,r.return,de)}r.flags&=-3}o&4096&&(r.flags&=-4097)}function xN(r,o,d){mt=r,yw(r)}function yw(r,o,d){for(var m=(r.mode&1)!==0;mt!==null;){var w=mt,k=w.child;if(w.tag===22&&m){var F=w.memoizedState!==null||Au;if(!F){var se=w.alternate,de=se!==null&&se.memoizedState!==null||Ns;se=Au;var Ee=Ns;if(Au=F,(Ns=de)&&!Ee)for(mt=w;mt!==null;)F=mt,de=F.child,F.tag===22&&F.memoizedState!==null?Sw(w):de!==null?(de.return=F,mt=de):Sw(w);for(;k!==null;)mt=k,yw(k),k=k.sibling;mt=w,Au=se,Ns=Ee}ww(r)}else(w.subtreeFlags&8772)!==0&&k!==null?(k.return=w,mt=k):ww(r)}}function ww(r){for(;mt!==null;){var o=mt;if((o.flags&8772)!==0){var d=o.alternate;try{if((o.flags&8772)!==0)switch(o.tag){case 0:case 11:case 15:Ns||Mu(5,o);break;case 1:var m=o.stateNode;if(o.flags&4&&!Ns)if(d===null)m.componentDidMount();else{var w=o.elementType===o.type?d.memoizedProps:Ei(o.type,d.memoizedProps);m.componentDidUpdate(w,d.memoizedState,m.__reactInternalSnapshotBeforeUpdate)}var k=o.updateQueue;k!==null&&by(o,k,m);break;case 3:var F=o.updateQueue;if(F!==null){if(d=null,o.child!==null)switch(o.child.tag){case 5:d=o.child.stateNode;break;case 1:d=o.child.stateNode}by(o,F,d)}break;case 5:var se=o.stateNode;if(d===null&&o.flags&4){d=se;var de=o.memoizedProps;switch(o.type){case"button":case"input":case"select":case"textarea":de.autoFocus&&d.focus();break;case"img":de.src&&(d.src=de.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(o.memoizedState===null){var Ee=o.alternate;if(Ee!==null){var qe=Ee.memoizedState;if(qe!==null){var Ge=qe.dehydrated;Ge!==null&&Oi(Ge)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Ns||o.flags&512&&Pf(o)}catch(We){Nn(o,o.return,We)}}if(o===r){mt=null;break}if(d=o.sibling,d!==null){d.return=o.return,mt=d;break}mt=o.return}}function bw(r){for(;mt!==null;){var o=mt;if(o===r){mt=null;break}var d=o.sibling;if(d!==null){d.return=o.return,mt=d;break}mt=o.return}}function Sw(r){for(;mt!==null;){var o=mt;try{switch(o.tag){case 0:case 11:case 15:var d=o.return;try{Mu(4,o)}catch(de){Nn(o,d,de)}break;case 1:var m=o.stateNode;if(typeof m.componentDidMount=="function"){var w=o.return;try{m.componentDidMount()}catch(de){Nn(o,w,de)}}var k=o.return;try{Pf(o)}catch(de){Nn(o,k,de)}break;case 5:var F=o.return;try{Pf(o)}catch(de){Nn(o,F,de)}}}catch(de){Nn(o,o.return,de)}if(o===r){mt=null;break}var se=o.sibling;if(se!==null){se.return=o.return,mt=se;break}mt=o.return}}var kN=Math.ceil,Tu=x.ReactCurrentDispatcher,Of=x.ReactCurrentOwner,ui=x.ReactCurrentBatchConfig,Jt=0,Zn=null,Dn=null,fs=0,ti=0,Ca=Ir(0),Hn=0,Ol=null,ko=0,Pu=0,Bf=0,Bl=null,qs=null,$f=0,Ea=1/0,vr=null,Iu=!1,zf=null,Fr=null,Du=!1,Hr=null,Ou=0,$l=0,Ff=null,Bu=-1,$u=0;function Ts(){return(Jt&6)!==0?G():Bu!==-1?Bu:Bu=G()}function Ur(r){return(r.mode&1)===0?1:(Jt&2)!==0&&fs!==0?fs&-fs:aN.transition!==null?($u===0&&($u=Xn()),$u):(r=Zt,r!==0||(r=window.event,r=r===void 0?16:ml(r.type)),r)}function Li(r,o,d,m){if(50<$l)throw $l=0,Ff=null,Error(n(185));ws(r,d,m),((Jt&2)===0||r!==Zn)&&(r===Zn&&((Jt&2)===0&&(Pu|=d),Hn===4&&Wr(r,fs)),Ks(r,m),d===1&&Jt===0&&(o.mode&1)===0&&(Ea=G()+500,fu&&Or()))}function Ks(r,o){var d=r.callbackNode;Fs(r,o);var m=wt(r,r===Zn?fs:0);if(m===0)d!==null&&Qe(d),r.callbackNode=null,r.callbackPriority=0;else if(o=m&-m,r.callbackPriority!==o){if(d!=null&&Qe(d),o===1)r.tag===0?oN(kw.bind(null,r)):cy(kw.bind(null,r)),nN(function(){(Jt&6)===0&&Or()}),d=null;else{switch(ll(m)){case 1:d=Te;break;case 4:d=Ze;break;case 16:d=Pe;break;case 536870912:d=ke;break;default:d=Pe}d=Mw(d,xw.bind(null,r))}r.callbackPriority=o,r.callbackNode=d}}function xw(r,o){if(Bu=-1,$u=0,(Jt&6)!==0)throw Error(n(327));var d=r.callbackNode;if(Na()&&r.callbackNode!==d)return null;var m=wt(r,r===Zn?fs:0);if(m===0)return null;if((m&30)!==0||(m&r.expiredLanes)!==0||o)o=zu(r,m);else{o=m;var w=Jt;Jt|=2;var k=Ew();(Zn!==r||fs!==o)&&(vr=null,Ea=G()+500,Eo(r,o));do try{NN();break}catch(se){Cw(r,se)}while(!0);rf(),Tu.current=k,Jt=w,Dn!==null?o=0:(Zn=null,fs=0,o=Hn)}if(o!==0){if(o===2&&(w=Wt(r),w!==0&&(m=w,o=Hf(r,w))),o===1)throw d=Ol,Eo(r,0),Wr(r,m),Ks(r,G()),d;if(o===6)Wr(r,m);else{if(w=r.current.alternate,(m&30)===0&&!CN(w)&&(o=zu(r,m),o===2&&(k=Wt(r),k!==0&&(m=k,o=Hf(r,k))),o===1))throw d=Ol,Eo(r,0),Wr(r,m),Ks(r,G()),d;switch(r.finishedWork=w,r.finishedLanes=m,o){case 0:case 1:throw Error(n(345));case 2:No(r,qs,vr);break;case 3:if(Wr(r,m),(m&130023424)===m&&(o=$f+500-G(),10<o)){if(wt(r,0)!==0)break;if(w=r.suspendedLanes,(w&m)!==m){Ts(),r.pingedLanes|=r.suspendedLanes&w;break}r.timeoutHandle=Vh(No.bind(null,r,qs,vr),o);break}No(r,qs,vr);break;case 4:if(Wr(r,m),(m&4194240)===m)break;for(o=r.eventTimes,w=-1;0<m;){var F=31-De(m);k=1<<F,F=o[F],F>w&&(w=F),m&=~k}if(m=w,m=G()-m,m=(120>m?120:480>m?480:1080>m?1080:1920>m?1920:3e3>m?3e3:4320>m?4320:1960*kN(m/1960))-m,10<m){r.timeoutHandle=Vh(No.bind(null,r,qs,vr),m);break}No(r,qs,vr);break;case 5:No(r,qs,vr);break;default:throw Error(n(329))}}}return Ks(r,G()),r.callbackNode===d?xw.bind(null,r):null}function Hf(r,o){var d=Bl;return r.current.memoizedState.isDehydrated&&(Eo(r,o).flags|=256),r=zu(r,o),r!==2&&(o=qs,qs=d,o!==null&&Uf(o)),r}function Uf(r){qs===null?qs=r:qs.push.apply(qs,r)}function CN(r){for(var o=r;;){if(o.flags&16384){var d=o.updateQueue;if(d!==null&&(d=d.stores,d!==null))for(var m=0;m<d.length;m++){var w=d[m],k=w.getSnapshot;w=w.value;try{if(!ki(k(),w))return!1}catch{return!1}}}if(d=o.child,o.subtreeFlags&16384&&d!==null)d.return=o,o=d;else{if(o===r)break;for(;o.sibling===null;){if(o.return===null||o.return===r)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function Wr(r,o){for(o&=~Bf,o&=~Pu,r.suspendedLanes|=o,r.pingedLanes&=~o,r=r.expirationTimes;0<o;){var d=31-De(o),m=1<<d;r[d]=-1,o&=~m}}function kw(r){if((Jt&6)!==0)throw Error(n(327));Na();var o=wt(r,0);if((o&1)===0)return Ks(r,G()),null;var d=zu(r,o);if(r.tag!==0&&d===2){var m=Wt(r);m!==0&&(o=m,d=Hf(r,m))}if(d===1)throw d=Ol,Eo(r,0),Wr(r,o),Ks(r,G()),d;if(d===6)throw Error(n(345));return r.finishedWork=r.current.alternate,r.finishedLanes=o,No(r,qs,vr),Ks(r,G()),null}function Wf(r,o){var d=Jt;Jt|=1;try{return r(o)}finally{Jt=d,Jt===0&&(Ea=G()+500,fu&&Or())}}function Co(r){Hr!==null&&Hr.tag===0&&(Jt&6)===0&&Na();var o=Jt;Jt|=1;var d=ui.transition,m=Zt;try{if(ui.transition=null,Zt=1,r)return r()}finally{Zt=m,ui.transition=d,Jt=o,(Jt&6)===0&&Or()}}function qf(){ti=Ca.current,fn(Ca)}function Eo(r,o){r.finishedWork=null,r.finishedLanes=0;var d=r.timeoutHandle;if(d!==-1&&(r.timeoutHandle=-1,tN(d)),Dn!==null)for(d=Dn.return;d!==null;){var m=d;switch(Zh(m),m.tag){case 1:m=m.type.childContextTypes,m!=null&&du();break;case 3:Sa(),fn(Hs),fn(ks),ff();break;case 5:df(m);break;case 4:Sa();break;case 13:fn(wn);break;case 19:fn(wn);break;case 10:of(m.type._context);break;case 22:case 23:qf()}d=d.return}if(Zn=r,Dn=r=qr(r.current,null),fs=ti=o,Hn=0,Ol=null,Bf=Pu=ko=0,qs=Bl=null,bo!==null){for(o=0;o<bo.length;o++)if(d=bo[o],m=d.interleaved,m!==null){d.interleaved=null;var w=m.next,k=d.pending;if(k!==null){var F=k.next;k.next=w,m.next=F}d.pending=m}bo=null}return r}function Cw(r,o){do{var d=Dn;try{if(rf(),xu.current=Nu,ku){for(var m=bn.memoizedState;m!==null;){var w=m.queue;w!==null&&(w.pending=null),m=m.next}ku=!1}if(xo=0,Qn=Fn=bn=null,Al=!1,Ml=0,Of.current=null,d===null||d.return===null){Hn=1,Ol=o,Dn=null;break}e:{var k=r,F=d.return,se=d,de=o;if(o=fs,se.flags|=32768,de!==null&&typeof de=="object"&&typeof de.then=="function"){var Ee=de,qe=se,Ge=qe.tag;if((qe.mode&1)===0&&(Ge===0||Ge===11||Ge===15)){var We=qe.alternate;We?(qe.updateQueue=We.updateQueue,qe.memoizedState=We.memoizedState,qe.lanes=We.lanes):(qe.updateQueue=null,qe.memoizedState=null)}var dt=Xy(F);if(dt!==null){dt.flags&=-257,Jy(dt,F,se,k,o),dt.mode&1&&Gy(k,Ee,o),o=dt,de=Ee;var vt=o.updateQueue;if(vt===null){var yt=new Set;yt.add(de),o.updateQueue=yt}else vt.add(de);break e}else{if((o&1)===0){Gy(k,Ee,o),Kf();break e}de=Error(n(426))}}else if(vn&&se.mode&1){var Tn=Xy(F);if(Tn!==null){(Tn.flags&65536)===0&&(Tn.flags|=256),Jy(Tn,F,se,k,o),nf(xa(de,se));break e}}k=de=xa(de,se),Hn!==4&&(Hn=2),Bl===null?Bl=[k]:Bl.push(k),k=F;do{switch(k.tag){case 3:k.flags|=65536,o&=-o,k.lanes|=o;var Se=Vy(k,de,o);wy(k,Se);break e;case 1:se=de;var pe=k.type,xe=k.stateNode;if((k.flags&128)===0&&(typeof pe.getDerivedStateFromError=="function"||xe!==null&&typeof xe.componentDidCatch=="function"&&(Fr===null||!Fr.has(xe)))){k.flags|=65536,o&=-o,k.lanes|=o;var tt=Yy(k,se,o);wy(k,tt);break e}}k=k.return}while(k!==null)}jw(d)}catch(bt){o=bt,Dn===d&&d!==null&&(Dn=d=d.return);continue}break}while(!0)}function Ew(){var r=Tu.current;return Tu.current=Nu,r===null?Nu:r}function Kf(){(Hn===0||Hn===3||Hn===2)&&(Hn=4),Zn===null||(ko&268435455)===0&&(Pu&268435455)===0||Wr(Zn,fs)}function zu(r,o){var d=Jt;Jt|=2;var m=Ew();(Zn!==r||fs!==o)&&(vr=null,Eo(r,o));do try{EN();break}catch(w){Cw(r,w)}while(!0);if(rf(),Jt=d,Tu.current=m,Dn!==null)throw Error(n(261));return Zn=null,fs=0,Hn}function EN(){for(;Dn!==null;)Nw(Dn)}function NN(){for(;Dn!==null&&!ct();)Nw(Dn)}function Nw(r){var o=Aw(r.alternate,r,ti);r.memoizedProps=r.pendingProps,o===null?jw(r):Dn=o,Of.current=null}function jw(r){var o=r;do{var d=o.alternate;if(r=o.return,(o.flags&32768)===0){if(d=yN(d,o,ti),d!==null){Dn=d;return}}else{if(d=wN(d,o),d!==null){d.flags&=32767,Dn=d;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{Hn=6,Dn=null;return}}if(o=o.sibling,o!==null){Dn=o;return}Dn=o=r}while(o!==null);Hn===0&&(Hn=5)}function No(r,o,d){var m=Zt,w=ui.transition;try{ui.transition=null,Zt=1,jN(r,o,d,m)}finally{ui.transition=w,Zt=m}return null}function jN(r,o,d,m){do Na();while(Hr!==null);if((Jt&6)!==0)throw Error(n(327));d=r.finishedWork;var w=r.finishedLanes;if(d===null)return null;if(r.finishedWork=null,r.finishedLanes=0,d===r.current)throw Error(n(177));r.callbackNode=null,r.callbackPriority=0;var k=d.lanes|d.childLanes;if(Di(r,k),r===Zn&&(Dn=Zn=null,fs=0),(d.subtreeFlags&2064)===0&&(d.flags&2064)===0||Du||(Du=!0,Mw(Pe,function(){return Na(),null})),k=(d.flags&15990)!==0,(d.subtreeFlags&15990)!==0||k){k=ui.transition,ui.transition=null;var F=Zt;Zt=1;var se=Jt;Jt|=4,Of.current=null,SN(r,d),_w(d,r),Y2(qh),cr=!!Wh,qh=Wh=null,r.current=d,xN(d),At(),Jt=se,Zt=F,ui.transition=k}else r.current=d;if(Du&&(Du=!1,Hr=r,Ou=w),k=r.pendingLanes,k===0&&(Fr=null),Yt(d.stateNode),Ks(r,G()),o!==null)for(m=r.onRecoverableError,d=0;d<o.length;d++)w=o[d],m(w.value,{componentStack:w.stack,digest:w.digest});if(Iu)throw Iu=!1,r=zf,zf=null,r;return(Ou&1)!==0&&r.tag!==0&&Na(),k=r.pendingLanes,(k&1)!==0?r===Ff?$l++:($l=0,Ff=r):$l=0,Or(),null}function Na(){if(Hr!==null){var r=ll(Ou),o=ui.transition,d=Zt;try{if(ui.transition=null,Zt=16>r?16:r,Hr===null)var m=!1;else{if(r=Hr,Hr=null,Ou=0,(Jt&6)!==0)throw Error(n(331));var w=Jt;for(Jt|=4,mt=r.current;mt!==null;){var k=mt,F=k.child;if((mt.flags&16)!==0){var se=k.deletions;if(se!==null){for(var de=0;de<se.length;de++){var Ee=se[de];for(mt=Ee;mt!==null;){var qe=mt;switch(qe.tag){case 0:case 11:case 15:Dl(8,qe,k)}var Ge=qe.child;if(Ge!==null)Ge.return=qe,mt=Ge;else for(;mt!==null;){qe=mt;var We=qe.sibling,dt=qe.return;if(fw(qe),qe===Ee){mt=null;break}if(We!==null){We.return=dt,mt=We;break}mt=dt}}}var vt=k.alternate;if(vt!==null){var yt=vt.child;if(yt!==null){vt.child=null;do{var Tn=yt.sibling;yt.sibling=null,yt=Tn}while(yt!==null)}}mt=k}}if((k.subtreeFlags&2064)!==0&&F!==null)F.return=k,mt=F;else e:for(;mt!==null;){if(k=mt,(k.flags&2048)!==0)switch(k.tag){case 0:case 11:case 15:Dl(9,k,k.return)}var Se=k.sibling;if(Se!==null){Se.return=k.return,mt=Se;break e}mt=k.return}}var pe=r.current;for(mt=pe;mt!==null;){F=mt;var xe=F.child;if((F.subtreeFlags&2064)!==0&&xe!==null)xe.return=F,mt=xe;else e:for(F=pe;mt!==null;){if(se=mt,(se.flags&2048)!==0)try{switch(se.tag){case 0:case 11:case 15:Mu(9,se)}}catch(bt){Nn(se,se.return,bt)}if(se===F){mt=null;break e}var tt=se.sibling;if(tt!==null){tt.return=se.return,mt=tt;break e}mt=se.return}}if(Jt=w,Or(),lt&&typeof lt.onPostCommitFiberRoot=="function")try{lt.onPostCommitFiberRoot(Le,r)}catch{}m=!0}return m}finally{Zt=d,ui.transition=o}}return!1}function Lw(r,o,d){o=xa(d,o),o=Vy(r,o,1),r=$r(r,o,1),o=Ts(),r!==null&&(ws(r,1,o),Ks(r,o))}function Nn(r,o,d){if(r.tag===3)Lw(r,r,d);else for(;o!==null;){if(o.tag===3){Lw(o,r,d);break}else if(o.tag===1){var m=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(Fr===null||!Fr.has(m))){r=xa(d,r),r=Yy(o,r,1),o=$r(o,r,1),r=Ts(),o!==null&&(ws(o,1,r),Ks(o,r));break}}o=o.return}}function LN(r,o,d){var m=r.pingCache;m!==null&&m.delete(o),o=Ts(),r.pingedLanes|=r.suspendedLanes&d,Zn===r&&(fs&d)===d&&(Hn===4||Hn===3&&(fs&130023424)===fs&&500>G()-$f?Eo(r,0):Bf|=d),Ks(r,o)}function Rw(r,o){o===0&&((r.mode&1)===0?o=1:(o=Ke,Ke<<=1,(Ke&130023424)===0&&(Ke=4194304)));var d=Ts();r=pr(r,o),r!==null&&(ws(r,o,d),Ks(r,d))}function RN(r){var o=r.memoizedState,d=0;o!==null&&(d=o.retryLane),Rw(r,d)}function AN(r,o){var d=0;switch(r.tag){case 13:var m=r.stateNode,w=r.memoizedState;w!==null&&(d=w.retryLane);break;case 19:m=r.stateNode;break;default:throw Error(n(314))}m!==null&&m.delete(o),Rw(r,d)}var Aw;Aw=function(r,o,d){if(r!==null)if(r.memoizedProps!==o.pendingProps||Hs.current)Ws=!0;else{if((r.lanes&d)===0&&(o.flags&128)===0)return Ws=!1,_N(r,o,d);Ws=(r.flags&131072)!==0}else Ws=!1,vn&&(o.flags&1048576)!==0&&uy(o,mu,o.index);switch(o.lanes=0,o.tag){case 2:var m=o.type;Ru(r,o),r=o.pendingProps;var w=ma(o,ks.current);ba(o,d),w=gf(null,o,m,r,w,d);var k=vf();return o.flags|=1,typeof w=="object"&&w!==null&&typeof w.render=="function"&&w.$$typeof===void 0?(o.tag=1,o.memoizedState=null,o.updateQueue=null,Us(m)?(k=!0,hu(o)):k=!1,o.memoizedState=w.state!==null&&w.state!==void 0?w.state:null,cf(o),w.updater=ju,o.stateNode=w,w._reactInternals=o,xf(o,m,r,d),o=Nf(null,o,m,!0,k,d)):(o.tag=0,vn&&k&&Qh(o),Ms(null,o,w,d),o=o.child),o;case 16:m=o.elementType;e:{switch(Ru(r,o),r=o.pendingProps,w=m._init,m=w(m._payload),o.type=m,w=o.tag=TN(m),r=Ei(m,r),w){case 0:o=Ef(null,o,m,r,d);break e;case 1:o=sw(null,o,m,r,d);break e;case 11:o=Qy(null,o,m,r,d);break e;case 14:o=Zy(null,o,m,Ei(m.type,r),d);break e}throw Error(n(306,m,""))}return o;case 0:return m=o.type,w=o.pendingProps,w=o.elementType===m?w:Ei(m,w),Ef(r,o,m,w,d);case 1:return m=o.type,w=o.pendingProps,w=o.elementType===m?w:Ei(m,w),sw(r,o,m,w,d);case 3:e:{if(iw(o),r===null)throw Error(n(387));m=o.pendingProps,k=o.memoizedState,w=k.element,yy(r,o),bu(o,m,null,d);var F=o.memoizedState;if(m=F.element,k.isDehydrated)if(k={element:m,isDehydrated:!1,cache:F.cache,pendingSuspenseBoundaries:F.pendingSuspenseBoundaries,transitions:F.transitions},o.updateQueue.baseState=k,o.memoizedState=k,o.flags&256){w=xa(Error(n(423)),o),o=rw(r,o,m,d,w);break e}else if(m!==w){w=xa(Error(n(424)),o),o=rw(r,o,m,d,w);break e}else for(ei=Pr(o.stateNode.containerInfo.firstChild),Zs=o,vn=!0,Ci=null,d=vy(o,null,m,d),o.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(_a(),m===w){o=gr(r,o,d);break e}Ms(r,o,m,d)}o=o.child}return o;case 5:return Sy(o),r===null&&tf(o),m=o.type,w=o.pendingProps,k=r!==null?r.memoizedProps:null,F=w.children,Kh(m,w)?F=null:k!==null&&Kh(m,k)&&(o.flags|=32),nw(r,o),Ms(r,o,F,d),o.child;case 6:return r===null&&tf(o),null;case 13:return ow(r,o,d);case 4:return uf(o,o.stateNode.containerInfo),m=o.pendingProps,r===null?o.child=ya(o,null,m,d):Ms(r,o,m,d),o.child;case 11:return m=o.type,w=o.pendingProps,w=o.elementType===m?w:Ei(m,w),Qy(r,o,m,w,d);case 7:return Ms(r,o,o.pendingProps,d),o.child;case 8:return Ms(r,o,o.pendingProps.children,d),o.child;case 12:return Ms(r,o,o.pendingProps.children,d),o.child;case 10:e:{if(m=o.type._context,w=o.pendingProps,k=o.memoizedProps,F=w.value,ln(_u,m._currentValue),m._currentValue=F,k!==null)if(ki(k.value,F)){if(k.children===w.children&&!Hs.current){o=gr(r,o,d);break e}}else for(k=o.child,k!==null&&(k.return=o);k!==null;){var se=k.dependencies;if(se!==null){F=k.child;for(var de=se.firstContext;de!==null;){if(de.context===m){if(k.tag===1){de=mr(-1,d&-d),de.tag=2;var Ee=k.updateQueue;if(Ee!==null){Ee=Ee.shared;var qe=Ee.pending;qe===null?de.next=de:(de.next=qe.next,qe.next=de),Ee.pending=de}}k.lanes|=d,de=k.alternate,de!==null&&(de.lanes|=d),af(k.return,d,o),se.lanes|=d;break}de=de.next}}else if(k.tag===10)F=k.type===o.type?null:k.child;else if(k.tag===18){if(F=k.return,F===null)throw Error(n(341));F.lanes|=d,se=F.alternate,se!==null&&(se.lanes|=d),af(F,d,o),F=k.sibling}else F=k.child;if(F!==null)F.return=k;else for(F=k;F!==null;){if(F===o){F=null;break}if(k=F.sibling,k!==null){k.return=F.return,F=k;break}F=F.return}k=F}Ms(r,o,w.children,d),o=o.child}return o;case 9:return w=o.type,m=o.pendingProps.children,ba(o,d),w=li(w),m=m(w),o.flags|=1,Ms(r,o,m,d),o.child;case 14:return m=o.type,w=Ei(m,o.pendingProps),w=Ei(m.type,w),Zy(r,o,m,w,d);case 15:return ew(r,o,o.type,o.pendingProps,d);case 17:return m=o.type,w=o.pendingProps,w=o.elementType===m?w:Ei(m,w),Ru(r,o),o.tag=1,Us(m)?(r=!0,hu(o)):r=!1,ba(o,d),qy(o,m,w),xf(o,m,w,d),Nf(null,o,m,!0,r,d);case 19:return lw(r,o,d);case 22:return tw(r,o,d)}throw Error(n(156,o.tag))};function Mw(r,o){return Ie(r,o)}function MN(r,o,d,m){this.tag=r,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=m,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function di(r,o,d,m){return new MN(r,o,d,m)}function Vf(r){return r=r.prototype,!(!r||!r.isReactComponent)}function TN(r){if(typeof r=="function")return Vf(r)?1:0;if(r!=null){if(r=r.$$typeof,r===B)return 11;if(r===T)return 14}return 2}function qr(r,o){var d=r.alternate;return d===null?(d=di(r.tag,o,r.key,r.mode),d.elementType=r.elementType,d.type=r.type,d.stateNode=r.stateNode,d.alternate=r,r.alternate=d):(d.pendingProps=o,d.type=r.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=r.flags&14680064,d.childLanes=r.childLanes,d.lanes=r.lanes,d.child=r.child,d.memoizedProps=r.memoizedProps,d.memoizedState=r.memoizedState,d.updateQueue=r.updateQueue,o=r.dependencies,d.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},d.sibling=r.sibling,d.index=r.index,d.ref=r.ref,d}function Fu(r,o,d,m,w,k){var F=2;if(m=r,typeof r=="function")Vf(r)&&(F=1);else if(typeof r=="string")F=5;else e:switch(r){case J:return jo(d.children,w,k,o);case q:F=8,w|=8;break;case V:return r=di(12,d,o,w|2),r.elementType=V,r.lanes=k,r;case I:return r=di(13,d,o,w),r.elementType=I,r.lanes=k,r;case D:return r=di(19,d,o,w),r.elementType=D,r.lanes=k,r;case R:return Hu(d,w,k,o);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case ie:F=10;break e;case K:F=9;break e;case B:F=11;break e;case T:F=14;break e;case z:F=16,m=null;break e}throw Error(n(130,r==null?r:typeof r,""))}return o=di(F,d,o,w),o.elementType=r,o.type=m,o.lanes=k,o}function jo(r,o,d,m){return r=di(7,r,m,o),r.lanes=d,r}function Hu(r,o,d,m){return r=di(22,r,m,o),r.elementType=R,r.lanes=d,r.stateNode={isHidden:!1},r}function Yf(r,o,d){return r=di(6,r,null,o),r.lanes=d,r}function Gf(r,o,d){return o=di(4,r.children!==null?r.children:[],r.key,o),o.lanes=d,o.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},o}function PN(r,o,d,m,w){this.tag=o,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ot(0),this.expirationTimes=Ot(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ot(0),this.identifierPrefix=m,this.onRecoverableError=w,this.mutableSourceEagerHydrationData=null}function Xf(r,o,d,m,w,k,F,se,de){return r=new PN(r,o,d,se,de),o===1?(o=1,k===!0&&(o|=8)):o=0,k=di(3,null,null,o),r.current=k,k.stateNode=r,k.memoizedState={element:m,isDehydrated:d,cache:null,transitions:null,pendingSuspenseBoundaries:null},cf(k),r}function IN(r,o,d){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:m==null?null:""+m,children:r,containerInfo:o,implementation:d}}function Tw(r){if(!r)return Dr;r=r._reactInternals;e:{if(Ut(r)!==r||r.tag!==1)throw Error(n(170));var o=r;do{switch(o.tag){case 3:o=o.stateNode.context;break e;case 1:if(Us(o.type)){o=o.stateNode.__reactInternalMemoizedMergedChildContext;break e}}o=o.return}while(o!==null);throw Error(n(171))}if(r.tag===1){var d=r.type;if(Us(d))return ay(r,d,o)}return o}function Pw(r,o,d,m,w,k,F,se,de){return r=Xf(d,m,!0,r,w,k,F,se,de),r.context=Tw(null),d=r.current,m=Ts(),w=Ur(d),k=mr(m,w),k.callback=o??null,$r(d,k,w),r.current.lanes=w,ws(r,w,m),Ks(r,m),r}function Uu(r,o,d,m){var w=o.current,k=Ts(),F=Ur(w);return d=Tw(d),o.context===null?o.context=d:o.pendingContext=d,o=mr(k,F),o.payload={element:r},m=m===void 0?null:m,m!==null&&(o.callback=m),r=$r(w,o,F),r!==null&&(Li(r,w,F,k),wu(r,w,F)),F}function Wu(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return r.child.stateNode;default:return r.child.stateNode}}function Iw(r,o){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var d=r.retryLane;r.retryLane=d!==0&&d<o?d:o}}function Jf(r,o){Iw(r,o),(r=r.alternate)&&Iw(r,o)}function DN(){return null}var Dw=typeof reportError=="function"?reportError:function(r){console.error(r)};function Qf(r){this._internalRoot=r}qu.prototype.render=Qf.prototype.render=function(r){var o=this._internalRoot;if(o===null)throw Error(n(409));Uu(r,o,null,null)},qu.prototype.unmount=Qf.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var o=r.containerInfo;Co(function(){Uu(null,r,null,null)}),o[ur]=null}};function qu(r){this._internalRoot=r}qu.prototype.unstable_scheduleHydration=function(r){if(r){var o=ul();r={blockedOn:null,target:r,priority:o};for(var d=0;d<As.length&&o!==0&&o<As[d].priority;d++);As.splice(d,0,r),d===0&&fl(r)}};function Zf(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function Ku(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function Ow(){}function ON(r,o,d,m,w){if(w){if(typeof m=="function"){var k=m;m=function(){var Ee=Wu(F);k.call(Ee)}}var F=Pw(o,m,r,0,null,!1,!1,"",Ow);return r._reactRootContainer=F,r[ur]=F.current,xl(r.nodeType===8?r.parentNode:r),Co(),F}for(;w=r.lastChild;)r.removeChild(w);if(typeof m=="function"){var se=m;m=function(){var Ee=Wu(de);se.call(Ee)}}var de=Xf(r,0,!1,null,null,!1,!1,"",Ow);return r._reactRootContainer=de,r[ur]=de.current,xl(r.nodeType===8?r.parentNode:r),Co(function(){Uu(o,de,d,m)}),de}function Vu(r,o,d,m,w){var k=d._reactRootContainer;if(k){var F=k;if(typeof w=="function"){var se=w;w=function(){var de=Wu(F);se.call(de)}}Uu(o,F,r,w)}else F=ON(d,o,r,w,m);return Wu(F)}cl=function(r){switch(r.tag){case 3:var o=r.stateNode;if(o.current.memoizedState.isDehydrated){var d=at(o.pendingLanes);d!==0&&(ir(o,d|1),Ks(o,G()),(Jt&6)===0&&(Ea=G()+500,Or()))}break;case 13:Co(function(){var m=pr(r,1);if(m!==null){var w=Ts();Li(m,r,1,w)}}),Jf(r,1)}},ta=function(r){if(r.tag===13){var o=pr(r,134217728);if(o!==null){var d=Ts();Li(o,r,134217728,d)}Jf(r,134217728)}},Js=function(r){if(r.tag===13){var o=Ur(r),d=pr(r,o);if(d!==null){var m=Ts();Li(d,r,o,m)}Jf(r,o)}},ul=function(){return Zt},dl=function(r,o){var d=Zt;try{return Zt=r,o()}finally{Zt=d}},Lt=function(r,o,d){switch(o){case"input":if(ge(r,d),o=d.name,d.type==="radio"&&o!=null){for(d=r;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll("input[name="+JSON.stringify(""+o)+'][type="radio"]'),o=0;o<d.length;o++){var m=d[o];if(m!==r&&m.form===r.form){var w=uu(m);if(!w)throw Error(n(90));Ae(m),ge(m,w)}}}break;case"textarea":ht(r,d);break;case"select":o=d.value,o!=null&&Ce(r,!!d.multiple,o,!1)}},It=Wf,Xt=Co;var BN={usingClientEntryPoint:!1,Events:[El,fa,uu,ft,Vt,Wf]},zl={findFiberByHostInstance:vo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},$N={bundleType:zl.bundleType,version:zl.version,rendererPackageName:zl.rendererPackageName,rendererConfig:zl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:x.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=xt(r),r===null?null:r.stateNode},findFiberByHostInstance:zl.findFiberByHostInstance||DN,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 Yu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Yu.isDisabled&&Yu.supportsFiber)try{Le=Yu.inject($N),lt=Yu}catch{}}return Vs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=BN,Vs.createPortal=function(r,o){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Zf(o))throw Error(n(200));return IN(r,o,null,d)},Vs.createRoot=function(r,o){if(!Zf(r))throw Error(n(299));var d=!1,m="",w=Dw;return o!=null&&(o.unstable_strictMode===!0&&(d=!0),o.identifierPrefix!==void 0&&(m=o.identifierPrefix),o.onRecoverableError!==void 0&&(w=o.onRecoverableError)),o=Xf(r,1,!1,null,null,d,!1,m,w),r[ur]=o.current,xl(r.nodeType===8?r.parentNode:r),new Qf(o)},Vs.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var o=r._reactInternals;if(o===void 0)throw typeof r.render=="function"?Error(n(188)):(r=Object.keys(r).join(","),Error(n(268,r)));return r=xt(o),r=r===null?null:r.stateNode,r},Vs.flushSync=function(r){return Co(r)},Vs.hydrate=function(r,o,d){if(!Ku(o))throw Error(n(200));return Vu(null,r,o,!0,d)},Vs.hydrateRoot=function(r,o,d){if(!Zf(r))throw Error(n(405));var m=d!=null&&d.hydratedSources||null,w=!1,k="",F=Dw;if(d!=null&&(d.unstable_strictMode===!0&&(w=!0),d.identifierPrefix!==void 0&&(k=d.identifierPrefix),d.onRecoverableError!==void 0&&(F=d.onRecoverableError)),o=Pw(o,null,r,1,d??null,w,!1,k,F),r[ur]=o.current,xl(r),m)for(r=0;r<m.length;r++)d=m[r],w=d._getVersion,w=w(d._source),o.mutableSourceEagerHydrationData==null?o.mutableSourceEagerHydrationData=[d,w]:o.mutableSourceEagerHydrationData.push(d,w);return new qu(o)},Vs.render=function(r,o,d){if(!Ku(o))throw Error(n(200));return Vu(null,r,o,!1,d)},Vs.unmountComponentAtNode=function(r){if(!Ku(r))throw Error(n(40));return r._reactRootContainer?(Co(function(){Vu(null,null,r,!1,function(){r._reactRootContainer=null,r[ur]=null})}),!0):!1},Vs.unstable_batchedUpdates=Wf,Vs.unstable_renderSubtreeIntoContainer=function(r,o,d,m){if(!Ku(d))throw Error(n(200));if(r==null||r._reactInternals===void 0)throw Error(n(38));return Vu(r,o,d,!1,m)},Vs.version="18.3.1-next-f1338f8080-20240426",Vs}var qw;function YN(){if(qw)return np.exports;qw=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),np.exports=VN(),np.exports}var Kw;function GN(){if(Kw)return Gu;Kw=1;var t=YN();return Gu.createRoot=t.createRoot,Gu.hydrateRoot=t.hydrateRoot,Gu}var XN=GN();const JN=ov(XN),km="nc_token",Cm="nc:auth-invalid",Em="nc:token-not-remembered";function QN(t){return typeof t=="string"&&t.startsWith("/api/")&&!t.startsWith("/api/route/")}const kc=(t,e)=>{try{return t()}catch{return e}};function Ux(t={}){return{local:t.local!==void 0?t.local:kc(()=>globalThis.localStorage,null),session:t.session!==void 0?t.session:kc(()=>globalThis.sessionStorage,null)}}const Vw=t=>kc(()=>t?String(t.getItem(km)||"").trim():"","");function ZN(t){const{local:e,session:n}=Ux(t);return Vw(e)||Vw(n)||""}function Wx(t,{remember:e=!0,local:n,session:s}={}){const i=String(t||"").trim();if(!i)return{ok:!1,where:null};const l=Ux({local:n,session:s}),c=e?[["local",l.local,l.session],["session",l.session,l.local]]:[["session",l.session,l.local],["local",l.local,l.session]];for(const[u,h,p]of c)if(h&&kc(()=>(h.setItem(km,i),!0),!1))return kc(()=>{p&&p.removeItem(km)},null),{ok:!0,where:u};return{ok:!1,where:null}}function Yw(t,e,n){if(!(!n||n.status!==401||!QN(t)))try{window.dispatchEvent(new CustomEvent(Cm,{detail:{token:e,path:t}}))}catch{}}const e5=8e3,t5=4e3,qx=8e3;function n5(t){const e=new AbortController,n=setTimeout(()=>e.abort(new DOMException("timeout","TimeoutError")),t);return{signal:e.signal,cancel:()=>clearTimeout(n),controller:e}}function Gw(t,e){return e.redirect!==void 0?e:/^\/(?:api\/route|node)\//.test(String(t))?{...e,redirect:"error"}:e}function qn(t,e,n={}){const s=Number(n.timeoutMs);if(!Number.isFinite(s)||s<=0)return fetch(t,{...Gw(t,n),headers:{...n.headers||{},Authorization:`Bearer ${e}`}}).then(g=>(Yw(t,e,g),g));const{signal:i,cancel:l,controller:c}=n5(s),u=n.signal,h=()=>c.abort(u.reason),p=()=>{l(),u&&u.removeEventListener("abort",h)};if(u){if(u.aborted)return p(),c.abort(u.reason),Promise.reject(u.reason instanceof Error?u.reason:new DOMException("aborted","AbortError"));u.addEventListener("abort",h,{once:!0})}const{timeoutMs:v,..._}=n;return fetch(t,{...Gw(t,_),signal:i,headers:{..._.headers||{},Authorization:`Bearer ${e}`}}).then(g=>(g.__cleanupTimeout=p,Yw(t,e,g),g),g=>{throw p(),g})}const Kx=t=>`nc_seen_${t}`;async function rt(t,e,n={}){const s=await qn(t,e,{method:n.method||"GET",headers:{"content-type":"application/json"},body:n.body?JSON.stringify(n.body):void 0,timeoutMs:n.timeoutMs,signal:n.signal});let i;try{try{i=await s.json()}catch(l){if(l&&(l.name==="AbortError"||l.name==="TimeoutError"))throw l;i={}}}finally{typeof s.__cleanupTimeout=="function"&&s.__cleanupTimeout()}if(!s.ok){const l=new Error(i.error||`HTTP ${s.status}`);throw l.status=s.status,l.data=i,l}return i}const yn=t=>Array.isArray(t)&&t.length?`/api/route/${t.map(encodeURIComponent).join("/")}/_`:"/api",kn=(t,e)=>`${yn(t)}/fleet/${e}`;async function s5(t,e,n,{signal:s}={}){const i=await qn(`${yn(e)}/panel/${encodeURIComponent(n)}/ticket`,t,{method:"POST",signal:s}),l=await i.json().catch(()=>({}));return i.status===200&&l&&typeof l.ticket=="string"?{ok:!0,ticket:l.ticket}:i.status===403&&l&&l.reason==="panel-not-granted"?{ok:!1,cause:"not-granted"}:i.status===403?{ok:!1,cause:"node-refused"}:i.status===404?{ok:!1,cause:"no-panel"}:i.status===401?{ok:!1,cause:"unauthorized"}:{ok:!1,cause:"denied"}}const tl=(t,e,n)=>rt(kn(e,"status"),t,n),lv=6e4,i5=(t,e,n)=>rt(kn(n,"up"),t,{method:"POST",body:e,timeoutMs:lv}),Vx=(t,e,n)=>rt(kn(n,"down"),t,{method:"POST",body:e,timeoutMs:lv}),Yx=(t,e,n)=>rt(kn(n,"boot"),t,{method:"POST",body:e}),oc=(t,e,n)=>rt(kn(n,"restart"),t,{method:"POST",body:{cell:e}}),rh=(t,e)=>rt(kn(e,"definitions"),t),r5=(t,e)=>rt(kn(e,"credentials/status"),t),Xw=(t,e,n,s)=>rt(kn(s,"credentials/set"),t,{method:"POST",body:{envKey:e,value:n}}),o5=(t,e,n)=>rt(kn(n,"credentials/remove"),t,{method:"POST",body:{envKey:e}}),a5=(t,e,n)=>rt(kn(n,"define-engine"),t,{method:"POST",body:{def:e}}),l5=(t,e,n,s,i)=>rt(kn(i,"edit-engine"),t,{method:"POST",body:{id:e,patch:n,envChanges:s}}),c5=(t,e,n)=>rt(kn(n,"remove-engine"),t,{method:"POST",body:{id:e}}),Jw=(t,e,n)=>rt(kn(n,"define-model"),t,{method:"POST",body:{def:e}}),u5=(t,e,n,s,i)=>rt(kn(i,"edit-model"),t,{method:"POST",body:{id:e,engine:n,patch:s}}),d5=(t,e,n,s)=>rt(kn(s,"remove-model"),t,{method:"POST",body:{id:e,engine:n}}),h5=(t,e,n,s)=>rt(kn(s,"model-test"),t,{method:"POST",body:{engine:e,model:n}}),f5=(t,e,n=!1,s)=>rt(`${kn(s,"engine-models")}?engine=${encodeURIComponent(e)}${n?"&refresh=1":""}`,t,{timeoutMs:lv}),p5=(t,e,n)=>rt(kn(n,"define-cell"),t,{method:"POST",body:{def:e}}),Gx=(t,e,n,s)=>rt(kn(s,"edit-cell"),t,{method:"POST",body:{id:e,patch:n}}),Xx=(t,e,n=!1,s)=>rt(kn(s,"remove-cell"),t,{method:"POST",body:{id:e,stop:n}}),m5=(t,e,n)=>rt(kn(n,"import-cell"),t,{method:"POST",body:e}),g5=(t,e,n)=>rt(kn(n,"restore-cells"),t,{method:"POST",body:{cells:e}}),v5=(t,e,n,s,i)=>rt(kn(s,"restore-engines"),t,{method:"POST",body:{engines:e,overwrite:!!n,...Array.isArray(i)&&i.length?{models:i}:{}}}),cv=(t,e,n)=>rt(`${yn(n)}/sessions/${encodeURIComponent(e)}`,t,{method:"DELETE"}),Jx=(t,e,n,s)=>rt(`${yn(s)}/sessions/${encodeURIComponent(e)}/visibility`,t,{method:"PATCH",body:{technical:!!n}}),uv=(t,e,n)=>rt(`${yn(n)}/fs/dirs${e?`?path=${encodeURIComponent(e)}`:""}`,t),Qx=(t,e={})=>rt("/api/settings",t,e),_5=(t,e={})=>rt("/api/nodes",t,e),y5=(t,e={})=>rt("/api/peers",t,e),Zx=(t,e=[],n={})=>rt(`${yn(e)}/vl-nodes`,t,{timeoutMs:t5,...n}),Qw=(t,e,n,s={},i=[])=>rt(`${yn(i)}/vl-nodes/${encodeURIComponent(e)}/commands`,t,{method:"POST",body:{kind:n,args:s}}),w5=(t,e,n=0,s=[])=>rt(`${yn(s)}/vl-nodes/${encodeURIComponent(e)}/events${n?`?after=${encodeURIComponent(n)}`:""}`,t),e1=(t,e={})=>rt("/api/topology",t,e),dv=(t,e,n={})=>rt(`${yn(e)}/sessions`,t,n),qc=(t,e,n={})=>rt(`${yn(e)}/config`,t,n),Zw=(t,e,n={})=>rt(`${yn(e)}/topology`,t,n),Pd=(t,e)=>rt("/api/settings/config",t,{method:"POST",body:e}),b5=t=>rt("/api/settings/ai-desktop",t),t1=(t,e)=>rt("/api/settings/ai-desktop",t,{method:"POST",body:{enabled:e}}),S5=t=>rt("/api/settings/token/rotate",t,{method:"POST"}),x5=(t,e)=>rt("/api/settings/nodes/pair",t,{method:"POST",body:e}),k5=(t,e,n=[])=>rt(`${yn(n)}/settings/peering/invite`,t,{method:"POST",body:e||{}}),n1=(t,e,n)=>rt(`/api/settings/nodes/${encodeURIComponent(e)}/label`,t,{method:"PATCH",body:{label:n}}),C5=(t,e={})=>rt("/api/settings/node-aliases",t,e),E5=(t,e,n)=>rt(`/api/settings/node-aliases/${encodeURIComponent(e)}`,t,{method:"PATCH",body:{alias:n}}),eb=(t,e)=>rt(`/api/settings/node-aliases/${encodeURIComponent(e)}`,t,{method:"DELETE"}),rp=(t,e,n)=>rt(`/api/settings/nodes/${encodeURIComponent(e)}`,t,{method:"PATCH",body:n}),N5=(t,e)=>rt(`/api/settings/nodes/${encodeURIComponent(e)}`,t,{method:"DELETE"}),hv=(t,e,n)=>rt(`/api/settings/nodes/${encodeURIComponent(e)}/${n}`,t,{method:"POST"}),j5=(t,e,n)=>rt(`/api/settings/nodes/${encodeURIComponent(e)}/share`,t,{method:"PATCH",body:{shared:n}}),L5=(t,e,n,s=[])=>rt(`/api/settings/nodes/${encodeURIComponent(e)}/visibility`,t,{method:"PATCH",body:{visibility:n,selected:s}}),R5=t=>rt("/api/settings/audio",t),A5=(t,e)=>rt("/api/settings/audio/consent",t,{method:"PATCH",body:{consent:e}}),M5=t=>rt("/api/settings/audio/test",t,{method:"POST",body:{}}),T5=t=>rt("/api/settings/audio/stop",t,{method:"POST",body:{}}),P5=t=>rt("/api/settings/audio/groups",t),I5=(t,e,n)=>rt(`/api/settings/audio/groups/${encodeURIComponent(e)}`,t,{method:"PUT",body:n}),D5=(t,e)=>rt(`/api/settings/audio/groups/${encodeURIComponent(e)}`,t,{method:"DELETE"}),O5=t=>rt("/api/settings/service/regenerate",t,{method:"POST"}),B5=t=>rt("/api/settings/update/check",t,{method:"POST"}),$5=t=>rt("/api/settings/update/apply",t,{method:"POST"}),oh=(t,e)=>`${yn(t)}/diagnostics/${e}`,z5=(t,e=[])=>rt(oh(e,"status"),t),F5=(t,{after:e=0,limit:n=200}={},s=[])=>rt(`${oh(s,"logs")}?after=${encodeURIComponent(e)}&limit=${encodeURIComponent(n)}`,t),tb=(t,e,n,s=[])=>rt(oh(s,"verbose"),t,{method:"PATCH",body:{enabled:e,durationSeconds:n}}),H5=(t,e=[])=>rt(oh(e,"logs"),t,{method:"DELETE"}),U5=(t,e=!0)=>rt(`/api/asks${e?"?open=1":""}`,t),W5=(t,e,n)=>rt(`/api/asks/${encodeURIComponent(e)}/answer`,t,{method:"POST",body:{text:n}}),q5=(t,e)=>rt(`/api/asks/${encodeURIComponent(e)}`,t,{method:"DELETE"}),K5=(t,{ownerId:e,askId:n,text:s,requestId:i})=>rt("/api/asks-relay",t,{method:"POST",body:{ownerId:e,askId:n,text:s,requestId:i}}),V5=(t,{ownerId:e,askId:n,requestId:s})=>rt("/api/asks-relay",t,{method:"POST",body:{action:"verify",ownerId:e,askId:n,requestId:s}}),Y5=(t,{ownerId:e,askId:n},s={})=>rt(`/api/asks-relay/capability?ownerId=${encodeURIComponent(e)}&askId=${encodeURIComponent(n)}&dismissals=1`,t,{timeoutMs:8e3,...s}),G5=t=>rt("/api/asks-relay/state",t),X5=(t,{ownerId:e,askId:n})=>rt("/api/asks-relay",t,{method:"POST",body:{action:"dismiss",ownerId:e,askId:n}}),J5=(t,{ownerId:e,askId:n})=>rt("/api/asks-relay",t,{method:"POST",body:{action:"dismiss-local",ownerId:e,askId:n}}),Q5=t=>rt("/api/feed-state",t),Z5=(t,{ownerId:e,eventId:n})=>rt("/api/notices-relay",t,{method:"POST",body:{action:"dismiss",ownerId:e,eventId:n}}),ej=(t,{owners:e})=>rt("/api/notices-relay",t,{method:"POST",body:{action:"dismiss-all",owners:e}}),Xu=(t,e=[])=>rt(`${yn(e)}/decks`,t,e.length?{timeoutMs:e5}:{}),nb=(t,e,n=[])=>rt(`${yn(n)}/decks`,t,{method:"POST",body:{name:e}}),Ju=(t,e,n,s,i=[],l)=>rt(`${yn(i)}/decks/${encodeURIComponent(e)}`,t,{method:"PUT",body:{layout:n,expectedRevision:s,...l?{floating:l}:{}}}),tj=(t,e,n,s,i=[],l)=>qn(`${yn(i)}/decks/${encodeURIComponent(e)}`,t,{method:"PUT",keepalive:!0,headers:{"content-type":"application/json"},body:JSON.stringify({layout:n,expectedRevision:s,...l?{floating:l}:{}})}),nj=(t,e,n,s,i=[])=>rt(`${yn(i)}/decks/${encodeURIComponent(e)}`,t,{method:"PATCH",body:{name:n,expectedRevision:s}}),sj=(t,e,n,s=[])=>rt(`${yn(s)}/decks/${encodeURIComponent(e)}`,t,{method:"DELETE",body:{expectedRevision:n}}),ah=(t,e=[],n)=>rt(`${yn(e)}/live-host`,t,n),lh=(t,e,n,s=[])=>rt(`${yn(s)}/live-host/designate`,t,{method:"POST",body:{cellId:e,expectedRevision:n}}),ch=(t,e,n=[])=>rt(`${yn(n)}/live-host/clear`,t,{method:"POST",body:{expectedRevision:e}});function uh(){let t=0,e=!1;return{begin(){return e?null:(e=!0,t+=1,t)},end(n){n===t&&(e=!1)},reset(){t+=1,e=!1},isCurrent(n){return n!==null&&n===t}}}const s1=4e3,sb=3500,io=new Map,i1=()=>typeof document<"u"&&document.visibilityState==="hidden";let ib=!1;function ij(){ib||typeof document>"u"||!document.addEventListener||(ib=!0,document.addEventListener("visibilitychange",()=>{const t=i1();for(const e of io.values())t?e.timer!==null&&(clearInterval(e.timer),e.timer=null):e.timer===null&&(e.timer=setInterval(e.cycle,s1),e.cycle())}))}const fv=(t,e)=>`${t}|${JSON.stringify(e||[])}`;function rj(t){return t&&t.length?`/api/route/${t.map(encodeURIComponent).join("/")}/_`:"/api"}function oj(t,e){const n=uh(),s={token:t,route:e,consumers:new Set,snapshot:null,timer:null},i=async()=>{const l=n.begin();if(l!==null)try{let c=null,u=null;try{c=await(await qn(`${rj(e)}/sessions`,t,{timeoutMs:sb})).json()}catch(v){u=v}let h=null,p=null;try{h=await tl(t,e,{timeoutMs:sb})}catch(v){p=v}if(!n.isCurrent(l))return;s.snapshot={at:Date.now(),sessionsJson:c,sessionsError:u,fs:h,fleetError:p};for(const v of s.consumers)v(s.snapshot)}finally{n.end(l)}};return s.cycle=i,ij(),i1()||(s.timer=setInterval(i,s1)),i(),s}function Cc(t,e,n){const s=fv(t,e);let i=io.get(s);return i||(i=oj(t,e),io.set(s,i)),i.consumers.add(n),i.snapshot&&n(i.snapshot),()=>{const l=io.get(s);l&&(l.consumers.delete(n),l.consumers.size===0&&(l.timer!==null&&clearInterval(l.timer),io.delete(s)))}}function ac(t,e=null){if(e!==null){const s=io.get(fv(e,t));return s?s.snapshot:null}const n=`|${JSON.stringify(t||[])}`;for(const[s,i]of io)if(s.endsWith(n))return i.snapshot;return null}function lc(t,e=null){const n=`|${JSON.stringify(t||[])}`;for(const[s,i]of io)(e!==null?s===fv(e,t):s.endsWith(n))&&i.cycle()}const aj={power:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M12 3v8"}),a.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:a.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:a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),a.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),a.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),a.jsx("path",{d:"M12 18v3"})]}),enter:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),a.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),a.jsx("path",{d:"M22 2 11 13"})]}),trash:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M4 7h16"}),a.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),a.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),a.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:a.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),broadcast:a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor",stroke:"none"}),a.jsx("path",{d:"M7.6 16.4a6.2 6.2 0 0 1 0-8.8"}),a.jsx("path",{d:"M16.4 7.6a6.2 6.2 0 0 1 0 8.8"}),a.jsx("path",{d:"M4.6 19.4a10.6 10.6 0 0 1 0-14.8"}),a.jsx("path",{d:"M19.4 4.6a10.6 10.6 0 0 1 0 14.8"})]}),monitor:a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"3",y:"4",width:"18",height:"12",rx:"2"}),a.jsx("path",{d:"M8 20h8M12 16v4"})]}),refresh:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),a.jsx("polyline",{points:"21 3 21 8 16 8"})]}),boot:a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),a.jsx("path",{d:"M8 21h8M12 17v4M12 12V7"}),a.jsx("polyline",{points:"9 10 12 7 15 10"})]}),upload:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M12 16V5"}),a.jsx("polyline",{points:"8 9 12 5 16 9"}),a.jsx("path",{d:"M5 20h14"})]}),download:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M12 4v10"}),a.jsx("polyline",{points:"8 10 12 14 16 10"}),a.jsx("path",{d:"M5 15v4a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-4"})]}),chevronLeft:a.jsx("polyline",{points:"14 6 8 12 14 18"}),chevronUp:a.jsx("polyline",{points:"6 14 12 8 18 14"}),chevronDown:a.jsx("polyline",{points:"6 10 12 16 18 10"}),history:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),a.jsx("polyline",{points:"3 3 3 8 8 8"}),a.jsx("path",{d:"M12 7v5l3 2"})]}),attach:a.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:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:a.jsxs(a.Fragment,{children:[a.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"}),a.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),a.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),a.jsx("path",{d:"M21 15l-5-5L5 21"})]}),gpu:a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"}),a.jsx("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),a.jsx("path",{d:"M9 3v3M15 3v3M9 18v3M15 18v3M3 9h3M3 15h3M18 9h3M18 15h3"})]}),zoomIn:a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"11",cy:"11",r:"7"}),a.jsx("path",{d:"M21 21l-4.35-4.35"}),a.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"11",cy:"11",r:"7"}),a.jsx("path",{d:"M21 21l-4.35-4.35"}),a.jsx("path",{d:"M8 11h6"})]}),gear:a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"12",cy:"12",r:"3"}),a.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"})]}),splitView:a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"3.5",y:"5.5",width:"17",height:"13",rx:"1.5"}),a.jsx("line",{x1:"14.5",y1:"5.5",x2:"14.5",y2:"18.5"})]}),copy:a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),a.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),more:a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"5",cy:"12",r:"1.6",fill:"currentColor",stroke:"none"}),a.jsx("circle",{cx:"12",cy:"12",r:"1.6",fill:"currentColor",stroke:"none"}),a.jsx("circle",{cx:"19",cy:"12",r:"1.6",fill:"currentColor",stroke:"none"})]}),eye:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M1 12s4-7 11-7 11 7 11 7-4 7-11 7S1 12 1 12Z"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),search:a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"11",cy:"11",r:"7"}),a.jsx("path",{d:"M21 21l-4.35-4.35"})]})};function _t({name:t,size:e=20}){return a.jsx("svg",{className:"nc-icon",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:aj[t]||null})}const pv=["it","en","es"];function lj(){try{const t=typeof navigator<"u"&&navigator.language||"",e=String(t).slice(0,2).toLowerCase();return pv.includes(e)?e:"en"}catch{return"en"}}const yd=lj(),r1="nc_lang",Nm="nc-lang";function o1(){return typeof localStorage<"u"?localStorage:null}const Qu={it:{"update-available":"nuova versione {v} disponibile","update-stale":"interfaccia non allineata: stai eseguendo la v{browser}, il nodo serve la v{ui}. ricarica senza cache; se persiste, riavvia il nodo","reload-no-cache":"ricarica senza cache","update-installed-restart":"versione {v} installata: riavvia il nodo","update-dismiss":"chiudi","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","host-lease-live":"host live: supervisione attiva","host-lease-grace":"host live: supervisione in recupero (grace)","host-lease-expired":"host live: supervisione scaduta","host-lease-none":"host live: mai supervisionata","host-lease-unavailable":"host live: garanzia di supervisione non disponibile su questo nodo","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","node-sessions-unverified":"sessioni non verificate","tile-unverified":"dato non verificato","cell-working":"al lavoro","cell-idle":"in attesa","cell-stopped":"ferma","cell-permission":"attesa permesso","cell-unknown":"non verificato","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","power-starting":"avvio…","power-stopping":"arresto…","fleet-up-slow":"avvio in corso: controlla lo stato","fleet-down-slow":"arresto in corso: controlla lo stato","fleet-up-duplicate":"già in esecuzione",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):","auth-invalid":"Il nodo non accetta più questo token (ruotato o sostituito). Inserisci quello nuovo: le tue preferenze non vengono toccate.","auth-not-remembered":"Il browser non ha permesso di ricordare il token su questo device: dovrai reinserirlo alla prossima apertura.","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande","dual-swap":"scambia le due celle","dual-go-to":"Vai a {cell}","dual-close":"chiudi la seconda cella","dual-focus":"cella col focus","terminal-renderer-webgl":"WebGL","terminal-renderer-dom":"DOM","terminal-renderer-switch":"motore grafico: richiesto {requested}, in uso {effective} — tocca per cambiare (ricarica il terminale)",composer:"composer",panel:"pannello","panel-none":"Nessun pannello configurato per questa cella.","panel-checking":"Apertura del pannello…","panel-not-granted":"Questo nodo non concede il pannello a chi lo chiede: l'accesso va concesso sul nodo che possiede la cella, non riprovando qui.","panel-denied":"Ingresso al pannello rifiutato: il biglietto non è più valido. Riprova: verrà chiesto un biglietto nuovo.","cell-peek":"Sbircia senza cambiare cella","cell-tele-ctx":"contesto","cell-tele-free":"libero","cell-tele-5h":"5h usati","cell-tele-7d":"7g usati","cell-activity":"attività","cell-activity-now":"adesso","cell-peek-preview":"Anteprima","cell-peek-stream":"Flusso","cell-peek-panel":"Pannello","cell-peek-vuoto":"Nessuna anteprima disponibile per questa cella.","panel-node-refused":"Il nodo che possiede la cella rifiuta la richiesta: è in sola lettura, o la sua policy blocca questa operazione. Riprovare qui non cambia l'esito.","panel-unauthorized":"Credenziale non valida per questo nodo: va corretta dove è configurata, non riprovando da qui.","panel-unreachable":"Il pannello non è raggiungibile attraverso questo nodo: riprova tra poco.","panel-frame-loading":"pannello montato: caricamento in corso","panel-frame-error":"Il frame del pannello non si è caricato: il biglietto può essere scaduto (30 s di vita, monouso) o la destinazione è irraggiungibile. Riprova: verrà chiesto un biglietto nuovo.","popup-drag-hint":"trascina per spostare; doppio clic per tornare al centro","popup-resize-hint":"trascina per ridimensionare","panel-timeout":"Il pannello non ha risposto in tempo: servizio lento a partire o sovraccarico. Riprova tra poco.","panel-retry":"Riprova","live-host-indicator":"Live host: {cell} · {mode} · {state}","live-host-indicator-none":"Live host: nessuna cella designata","live-host-remote":"altro nodo","live-host-mode-native":"nativa (thread)","live-host-mode-tmux":"tmux","live-host-mode-unknown":"modalità sconosciuta","live-host-state-none":"nessuna designazione","live-host-state-designated":"designata, thread assente","live-host-state-thread-present":"thread presente ma inattivo","live-host-state-thread-active":"thread attivo","live-host-state-thread-unknown":"stato del thread sconosciuto","live-badge":"Live","live-badge-native":"Live attiva (thread nativo)","live-badge-tmux":"Live attiva in modalità tmux: non riceve messaggi","live-host-designated":"Live host: {cell}","live-host-cleared":"Live host rimosso","live-host-action-use":"Usa come host Live","live-host-action-remove":"Rimuovi host Live","cell-actions-title":"Azioni di {cell}","cell-actions-open":"Azioni cella","cell-actions-live-assign":"Assegna la Live","cell-actions-live-remove":"Togli la Live","cell-actions-pin":"Fissa in cima","cell-actions-unpin":"Togli in cima","cell-actions-boot":"Avvio al boot","cell-actions-watch":"Guarda dal vivo","bar-menu-open":"Altre azioni","bar-menu-keyboard":"Tastiera di scrittura","bar-menu-keyboard-desc":"sotto il terminale","bar-menu-files":"File della cella","bar-menu-files-desc":"inbox · outbox","bar-menu-files-setting-desc":"mostra il tasto nella barra","bar-menu-panel":"Pannello della cella","bar-menu-panel-desc":"solo se la cella ne ha uno","bar-menu-renderer":"Renderer GPU","bar-menu-renderer-desc":"cambiarlo ricarica la pagina","bar-keyboard-button":"Tasto tastiera in barra","bar-keyboard-button-desc":"mostra il tasto della tastiera di scrittura","bar-panel-button":"Tasto AI Desktop in barra","bar-panel-button-desc":"mostra il tasto, se la cella ha un pannello","cell-switcher-group":"Celle {node}","cell-switcher-group-local":"locale","cell-switcher-tap-hint":"Tocca una cella per l'anteprima · tocca di nuovo per aprirla","cell-switcher-two-taps":"2 tocchi = apri","cell-switcher-side-add":"affianca nella doppia vista","cell-switcher-side-remove":"togli dalla doppia vista","cell-switcher-preview-word":"ANTEPRIMA","cell-switcher-preview-readonly":"sola lettura","cell-peek-expand":"Apri la finestra","ai-desktop-title":"Desktop grafico","ai-desktop":"Desktop grafico attivo","ai-desktop-help":"Il container del desktop parte con la spunta e si ferma senza; il tasto del pannello appare solo con il desktop attivo.","ai-desktop-confirm-stop":"Il desktop è in esecuzione: spegnerlo chiude le sessioni aperte nel container. Continuare?","panel-start-desktop":"Avvia il desktop","live-host-stale-revision":"designazione non applicata: lo stato e' cambiato nel frattempo, riprova","live-host-not-local":"quella cella non appartiene a questo nodo","live-host-unavailable":"flotta non disponibile su questo nodo, riprova tra poco","live-host-not-granted":"Questo nodo non concede la designazione della cella ospite Live a chi la chiede: va concessa sul nodo che possiede la cella (nodes live-host <nodo> on), non riprovando qui.","live-host-error":"La designazione della cella ospite Live non è riuscita: riprova tra poco.","host-thread-designated":"cella designata; thread assente","host-thread-present":"thread presente ma inattivo","host-thread-active":"thread attivo","host-thread-unknown":"stato del thread sconosciuto",windows:"{n} finestre","empty-files":"vuota","files-download":"scarica file","files-download-action":"Scarica","files-outbox":"Outbox · {n}","files-inbox":"Inbox · {n}","files-search":"cerca file","files-search-ph":"cerca per nome…","files-no-match":'nessun file contiene "{q}"',"files-actions":"azioni del file","files-sheet-title":"Azioni del file","files-original-name":"nome originale","files-preview":"Anteprima","files-preview-failed":"anteprima non riuscita","files-preview-blocked":"anteprima non disponibile per questo tipo: scaricalo","files-copy-name":"Copia nome completo","files-copied-name":"nome completo copiato","files-delete-ellipsis":"Elimina…","files-delete-confirm":'Eliminare "{name}"?',"files-delete-confirm-help":"Il file viene eliminato definitivamente dalla cartella della cella.","files-today":"Oggi","files-dupes":"{n} copie","files-of":"File di {session}","files-upload":"Carica file","files-upload-failed":"errore caricamento: {e}","files-filter-all":"Tutti","files-filter-docs":"Documenti","files-filter-images":"Immagini","files-open":"Apri","files-detail-none":"Seleziona un file per vederne i dettagli.","files-meta-date":"Data","files-meta-size":"Dimensione","files-meta-folder":"Cartella","files-meta-type":"Tipo","files-footer-count":"{n} file · {size}","files-kbd-enter":"Invio","files-kbd-hint":"↑↓ sposta la selezione · {enter} apre le azioni · / cerca","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-inbox":"Inbox","attach-inbox-done":"{n} file aggiunti all'inbox","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-stale":"aggiornamento in ritardo","deck-stale-badge":"in ritardo","deck-owner-unavailable":"nodo owner non condiviso o non raggiungibile","deck-owner-reconnecting":"riconnessione…","deck-owner-stale":"owner stale (route in cache)","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","tile-detach":"Stacca e fai flottare","tile-reattach":"Rimetti nella griglia","tile-minimize":"Riduci","tile-restore":"Ripristina","grid-resize-cols":"Trascina per ridimensionare le due colonne; doppio clic: metà e metà. Alt: niente aggancio.","grid-resize-rows":"Trascina per ridimensionare le due finestre; doppio clic: metà e metà. Alt: niente aggancio.","device-name-ask-title":"Come si chiama questo dispositivo?","device-name-ask-text":"Il nome non è ricavabile dall’host: serve per mostrarti il nodo Locale e per presentarti ai nuovi nodi.","device-name-save":"Salva nome","device-name-later":"Più tardi","wizard-device-name":"Dai un nome a questo dispositivo (lo vedrai come nodo Locale e i nuovi nodi lo useranno).","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.","pair-authkeys-title":"Riga da sostituire in ~/.ssh/authorized_keys sul peer","pair-authkeys-hint":"Senza questa riga il forward del pannello resta rifiutato: il tunnel sembra attivo e il pannello non risponde.","pair-authkeys-copy":"Copia la riga","pair-authkeys-copied":"Riga copiata","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-stale":"Lettura della flotta non riuscita: l’elenco delle celle potrebbe non essere aggiornato.","reorder-blocked":"Riordino non applicato: la lista è incompleta in questo momento, il tuo ordine è al sicuro.","prefs-journal":"Diario preferenze (ultime 50 scritture)","prefs-journal-empty":"Nessuna modifica registrata finora.","prefs-journal-copy":"Copia diario","prefs-journal-clear":"Svuota diario","prefs-persist":"Storage persistente","prefs-persist-unknown":"non ancora verificato","prefs-before":"prima","prefs-after":"dopo","prefs-visible":"visibili","prefs-backup":"Backup preferenze","prefs-sync":"Copia sul nodo","prefs-conflict":"Le preferenze di questo dispositivo e la copia sul nodo sono diverse. Quale tieni?","prefs-keep-local":"Tieni questo dispositivo","prefs-use-server":"Usa la copia del nodo","prefs-export":"Esporta preferenze","prefs-import":"Importa preferenze","prefs-export-done":"File di preferenze creato (senza token).","prefs-import-done":"Preferenze importate.","prefs-import-confirm":"Sostituire le preferenze di questo dispositivo con quelle del file?","prefs-import-wrong":"Il file non è un file di preferenze NexusCrew.","prefs-import-bad":"Il file di preferenze non è valido: non è stato importato nulla.","prefs-import-storage":"Il browser ha rifiutato la scrittura: nulla è stato importato e le preferenze di questo dispositivo sono intatte.","fleet-off":"Flotta non disponibile: nessuna cella.","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 e non viene mai mostrata né esportata. Se il nodo è remoto, il valore viaggia fino a lui sul canale accoppiato.","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-providers-shell":"shell dell'utente","fleet-credential-source-keys-file":"file chiavi","fleet-credential-source-secure-file":"file secure (precede)","fleet-credential-source-legacy":"file legacy","fleet-credential-source-nexuscrew-store":"store NexusCrew","fleet-credential-source-unreadable":"non verificabile","fleet-credential-source-login":"login del client","fleet-credential-source-none":"nessuna","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: non viene mai riletto dalla rete e non entra in engine o backup. Se il nodo selezionato è remoto, il valore lo raggiunge attraverso il canale accoppiato.","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, ma i suoi strumenti MCP vengono ereditati.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY dal credential layer locale; qwen3.8-max è 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-provider-notice-opencode-native":"OpenCode client nativo: auth delegata al login locale di opencode (i modelli free del gateway rispondono anche senza login). NexusCrew non legge né copia credenziali e non scrive la tua opencode.jsonc; modelli e MCP restano nella configurazione del client.","fleet-model-default":"modello predefinito (opzionale)","fleet-model-required":"modello (obbligatorio)","fleet-models-title":"Modelli","fleet-models-usable":"Puoi usare questi","fleet-models-refresh":"Aggiorna modelli","fleet-models-refreshing":"Aggiorno…","fleet-models-loading":"Cerco i modelli dell’engine…","fleet-models-error":"Aggiornamento modelli non riuscito (rete o nodo): l’editor resta utilizzabile","fleet-models-stale":"Dati non freschi: mostro l’ultima lettura riuscita","fleet-models-unsupported":"Questo engine non espone un elenco modelli","fleet-models-none":"Nessun modello trovato","fleet-models-not-in-api":"non disponibile nelle API","fleet-models-use":"Usa il modello {model}","fleet-models-cap":"Si attivano i modelli che vuoi, entro il tetto di {cap} per engine","fleet-models-field-context":"contesto","fleet-models-field-output":"output","fleet-models-field-tools":"tool","fleet-models-field-vision":"vision","fleet-models-field-reasoning":"reasoning","fleet-models-source-of":"provenienza: {source}","fleet-models-source-user":"utente","fleet-models-source-api":"API","fleet-models-source-public":"catalogo","fleet-models-source-backup":"backup","fleet-models-missing-title":"Dato mancante","fleet-models-missing-why":"Per {model} manca un dato che serve all’engine:","fleet-models-missing-backup":"backup proposto: {value}","fleet-models-missing-user":"Quello che confermi diventa il tuo valore: precedenza più alta, mai riscritto dalla scoperta.","fleet-models-missing-confirm":"Conferma","fleet-models-missing-empty":"Lascia vuoto","fleet-models-missing-open":"Dato mancante per {model}","fleet-models-default-badge":"models.dev · default","fleet-models-make-mine":"Rendilo mio","fleet-models-make-mine-field":"Rendilo mio: {field} di {model}","fleet-models-make-mine-row":"Rendilo mio: {model}","fleet-models-make-mine-title":"Conferma i valori di {model}","fleet-models-make-mine-why":"Quello che confermi diventa una dichiarazione tua: resta sopra al catalogo e non cambia al prossimo aggiornamento.","fleet-models-make-mine-confirm":"Conferma","fleet-models-write-failed":"La scrittura non è riuscita: i valori sono ancora qui.","fleet-models-value-absent":"Lascia vuoto","fleet-models-value-true":"Sì","fleet-models-value-false":"No","fleet-models-auth-missing-key":"L’elenco modelli richiede un’autenticazione: la chiave {key} non è configurata su questo nodo","fleet-models-auth-missing-key-anonymous":"L’elenco modelli richiede un’autenticazione, ma la richiesta di questo engine è anonima: nessuna chiave è configurata.","fleet-models-auth-key-rejected":"La chiave inviata non è stata accettata per l’elenco modelli.","fleet-models-auth-access-denied":"Accesso all’elenco modelli negato: possono essere permessi o policy, non necessariamente la chiave.","fleet-models-auth-credential-unavailable":"La chiave non è leggibile o verificabile su questo nodo: non risulta assente, è indisponibile.","fleet-models-auth-endpoint-unreachable":"Endpoint non raggiungibile (rete o timeout): non è un problema di chiave.","fleet-models-auth-provider-error":"Il provider ha risposto con un errore per l’elenco modelli.","fleet-models-auth-invalid-response":"La risposta del provider per l’elenco modelli non è valida.","fleet-models-auth-anonymous-success":"Elenco modelli ottenuto senza chiave.","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.","cell-prompt":"Prompt di avvio della cella","cell-prompt-help":"Inviato alla cella quando parte: e’ il suo incarico permanente. Vuoto = nessun prompt, la cella parte e basta.","fleet-boot":"avvio automatico","fleet-remote-control":"controllo remoto","cell-mcp":"Strumenti MCP","cell-mcp-all":"tutti","cell-mcp-none":"nessuno","cell-mcp-some":"scelti","cell-mcp-inert":"Per questo client gli strumenti MCP li registra il client nel proprio config, non NexusCrew: la selezione qui non ha effetto.","cell-mcp-help":"«Tutti» è il comportamento di sempre. «Nessuno» è l’unica esclusione CERTA: toglie ogni strumento e non dipende da dove i server sono definiti — è ciò che serve per una cella di cui non ci si fida. Con «scelti» si concede per nome, ma l’elenco copre solo i server che questo nodo sa enumerare: plugin e connettori non compaiono e resterebbero disponibili.","fleet-model-override":"modello alternativo","fleet-ready":"pronto","fleet-not-ready":"non configurato","fleet-engines":"Engine","fleet-cells":"Celle / sessioni cloud","fleet-engine-group-standard":"Standard","fleet-engine-group-other":"Altri","fleet-models":"Modelli dichiarati","fleet-no-models":"Nessun modello dichiarato: si usano quelli del catalogo.","model-editor-engine":"Profilo","model-editor-id":"Id del modello","model-editor-id-help":"L’id esatto che il fornitore si aspetta. Profilo e id non si cambiano dopo: si ritira e si ridichiara.","model-editor-context":"Finestra di contesto (token)","model-editor-max-tokens":"Massimo di token in uscita","model-editor-reasoning":"Supporta il ragionamento esteso","model-editor-tools":"Supporta gli strumenti","model-editor-vision":"Legge le immagini","model-editor-absent":"Lascia vuoto","model-editor-true":"Sì","model-editor-false":"No","model-editor-limit-invalid":"La finestra deve stare fra 1024 e 100000000.","model-test":"Prova sull’API","model-test-running":"Provo…","model-test-ok":"risponde","model-test-unknown-model":"il fornitore non conosce questo id","model-test-auth":"credenziale mancante o rifiutata","model-test-unreachable":"endpoint non raggiungibile","model-test-unverified":"non verificato","model-test-unverified-help":"Non significa che non funzioni: questo fornitore non espone l’elenco dei modelli, quindi la prova non ha potuto dire né sì né no.","model-remove":"Ritira","model-in-use":"in uso","fleet-backup":"backup / ripristino","fleet-backup-help":"Esporta o ripristina selettivamente engine, celle, modelli dichiarati 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-invalid-model":"il backup contiene un modello non valido","fleet-backup-duplicate-model":"il backup contiene modelli 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. Alpha","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-readiness-degraded":"Avviata senza conferma di prontezza: potrebbe non elaborare subito. Verifica nel terminale prima di affidarle un incarico.","fleet-mcp-degraded":"Avviata in degrado, server MCP non pronti:","fleet-vl-prompt-degraded":"Avviata senza il prompt di cella: la versione di vl sul nodo non lo supporta (serve 0.3.1+). La cella lavora senza la sua identità: aggiorna vl prima di affidarle un incarico.","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)","fleet-panel-url":"URL pannello (opzionale)","fleet-panel-url-help":"Endpoint del pannello grafico della cella (es. il noVNC di un container): solo http/https verso un host loopback — il proxy risolve la destinazione sulla macchina che ospita la cella.","fleet-panel-url-invalid":"Il pannello non è un port-forward: chi lo apre sceglie quale cella, mai dove connettersi. L’indirizzo viene risolto sulla macchina che ospita la cella, quindi deve essere raggiungibile lì in loopback — 127.0.0.1, localhost o [::1]. L’indirizzo di un container (es. 172.17.0.2) non lo è.","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-never":"mai controllato","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","peer-cause-assente":"peer non risponde — in attesa che torni (interrogazioni diradate)","peer-cause-nega":"peer nega l'accesso — concedi il permesso sul nodo remoto","peer-cause-rotta":"rotta inesistente sul peer — aggiorna il nodo","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","remote-notices-title":"Notifiche da altri nodi","remote-notices-clear":"Pulisci","remote-notices-dismiss":"scarta questa notifica","remote-notices-dismiss-failed":"scarto non confermato: la notifica resta","remote-notices-clear-failed":"pulizia non confermata: le notifiche restano","ask-dismiss":"Scarta la domanda","ask-dismiss-local":"Scarta su questo nodo","ask-dismiss-local-pending":"Chiusura sul nodo origine in attesa","ask-dismiss-local-blocked":"Scarto solo locale: chiusura remota non autorizzata","ask-dismiss-unconfirmed":"Scarto locale non confermato: la domanda resta visibile.","ask-reply-ph":"scrivi la risposta…","push-enable":"attiva notifiche push","push-disable":"disattiva notifiche push","push-on":"push attive su questo device","push-local-off":"silenzia su questo browser","push-local-on":"riattiva su questo browser","push-local-help":"solo questo browser: la UI e le notifiche dell’owner restano attive","push-local-off-note":"avvisi di sistema spenti su questo browser; la UI resta attiva","push-local-disabled":"gli avvisi push sono spenti su questo browser: riattivali qui","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-preview-voice-error":"La prova vocale è fallita: voce o audio non disponibili. Controlla la voce selezionata e riprova.","notification-speech-preview-timeout":"La prova vocale è fallita: nessuna risposta dal motore vocale. Controlla la voce selezionata 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-verify-failed":"Verifica non riuscita: riprova tra poco.","cell-switcher-select":"seleziona una cella","cell-switcher-open":"apri cella","cell-switcher-show-all":"tutte","cell-switcher-title":"Celle","cell-switcher-filter":"filtro: attive o tutte","cell-switcher-live-strip":"Live su {cell} · {mode}","cell-switcher-show-active":"attive","cell-switcher-close":"chiudi selettore celle","cell-switcher-here":"sei qui","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","selection-changed":"il testo sotto la selezione è cambiato","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.","cell-scope-list-unavailable":"Elenco delle celle non disponibile ora: le concessioni qui sotto restano valide, ma non si può dire se esistono ancora.","feed-owner":"da nodo federato","ask-remote-readonly":"Risposta non concessa per questo nodo: card in sola lettura.","ask-capability-loading":"Verifica del permesso di risposta…","ask-capability-unreachable":"Percorso di risposta non raggiungibile.","ask-capability-unsupported":"Questo nodo non supporta la verifica del permesso di risposta.","ask-remote-no-feed":"Non ricevi gli eventi di questo nodo: attiva la ricezione (nodes edit <peer> --events-receive true).","ask-feed-stale":"Feed di questo nodo non attivo (dati non aggiornati): la card potrebbe essere già chiusa altrove.","ask-dismiss-stale":"Scarta comunque: lo scarto parte via relay diretto, ma finché il feed è fermo la card può non riflettere lo stato reale.","ask-uncertain":"Esito incerto: la risposta potrebbe essere arrivata. Verifica lo stato prima di riprovare.","ask-reconcile":"Risposta bloccata da un invio precedente: riconcilia con il nodo che ha fatto la domanda. Nessun nuovo invio.","ask-verify":"Verifica stato","peer-access":"Ruolo del peer","peer-access-help":"Cosa questo peer può fare su questa installazione. Il nome è derivato dai permessi effettivi: applicare un preset riscrive l’intero vettore in una sola scrittura.","peer-access-current":"Adesso","peer-access-preset":"Preset da applicare","peer-access-preset-none":"scegli un preset","peer-access-matrix":"Cosa cambierebbe","peer-access-apply":"Applica il preset","peer-access-changed-hint":"Le righe evidenziate cambiano con la conferma.","peer-access-unchanged":"Il preset non cambierebbe nulla.","peer-access-conflict":"Questo peer è stato modificato altrove: stato ricaricato, riapplica il preset se serve.","access-label-admin":"amministratore","access-label-user":"utente","access-label-nexushost":"nexushost","access-label-custom":"personalizzato","access-label-unconfigured":"non configurato","access-grant-cellVisibility":"Celle visibili","access-grant-eventsAccess":"Eventi","access-grant-eventsReceive":"Ricezione eventi e notifiche","access-grant-nodeEventsAccess":"Eventi di nodo","access-grant-askReplyAccess":"Risposte alle domande","access-grant-filesReadAccess":"Lettura file","access-grant-liveHostAccess":"Host Live","access-grant-panelAccess":"Pannelli","access-grant-peerOperatorAccess":"Operatore dei peer","access-value-all":"tutte","access-value-selected":"selezionate","access-value-none":"nessuna","access-value-yes":"sì","access-value-no":"no","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","update-stale":"interface out of step: you are running v{browser}, the node is serving v{ui}. reload without cache; if it persists, restart the node","reload-no-cache":"reload without cache","update-installed-restart":"version {v} installed: restart the node","update-dismiss":"close","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","host-lease-live":"live host: supervision active","host-lease-grace":"live host: supervision recovering (grace)","host-lease-expired":"live host: supervision expired","host-lease-none":"live host: never supervised","host-lease-unavailable":"live host: supervision guarantee not available on this node","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","node-sessions-unverified":"sessions not verified","tile-unverified":"data not verified","cell-working":"working","cell-idle":"idle","cell-stopped":"stopped","cell-permission":"permission required","cell-unknown":"unverified","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","power-starting":"starting…","power-stopping":"stopping…","fleet-up-slow":"start still in progress: check the cell state","fleet-down-slow":"stop still in progress: check the cell state","fleet-up-duplicate":"already running",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):","auth-invalid":"The node no longer accepts this token (rotated or replaced). Enter the new one: your preferences are left untouched.","auth-not-remembered":"The browser did not allow remembering the token on this device: you will have to enter it again next time.","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text","dual-swap":"swap the two cells","dual-go-to":"Go to {cell}","dual-close":"close the second cell","dual-focus":"focused cell","terminal-renderer-webgl":"WebGL","terminal-renderer-dom":"DOM","terminal-renderer-switch":"graphics renderer: requested {requested}, in use {effective} — tap to switch (reloads the terminal)",composer:"composer",panel:"panel","panel-none":"No panel configured for this cell.","panel-checking":"Opening panel…","panel-not-granted":"This node does not grant the panel to the requester: access must be granted on the node that owns the cell, not by retrying here.","panel-denied":"Panel entry refused: the ticket is no longer valid. Retry: a new ticket will be requested.","cell-peek":"Peek without switching cell","cell-tele-ctx":"context","cell-tele-free":"free","cell-tele-5h":"5h used","cell-tele-7d":"7d used","cell-activity":"activity","cell-activity-now":"now","cell-peek-preview":"Preview","cell-peek-stream":"Stream","cell-peek-panel":"Panel","cell-peek-vuoto":"No preview available for this cell.","panel-node-refused":"The node that owns the cell refuses the request: it is read-only, or its policy blocks this operation. Retrying here does not change the outcome.","panel-unauthorized":"Invalid credential for this node: fix it where it is configured, not by retrying from here.","panel-unreachable":"The panel is not reachable through this node: retry in a little while.","panel-frame-loading":"panel mounted: loading in progress","panel-frame-error":"The panel frame did not load: the ticket may have expired (30 s lifetime, single-use) or the destination is unreachable. Retry: a fresh ticket will be requested.","popup-drag-hint":"drag to move; double-click to recenter","popup-resize-hint":"drag to resize","panel-timeout":"The panel did not answer in time: service slow to start or overloaded. Retry in a little while.","panel-retry":"Retry","live-host-indicator":"Live host: {cell} · {mode} · {state}","live-host-indicator-none":"Live host: no cell designated","live-host-remote":"other node","live-host-mode-native":"native (thread)","live-host-mode-tmux":"tmux","live-host-mode-unknown":"unknown mode","live-host-state-none":"no designation","live-host-state-designated":"designated, no thread","live-host-state-thread-present":"thread present but idle","live-host-state-thread-active":"thread active","live-host-state-thread-unknown":"thread status unknown","live-badge":"Live","live-badge-native":"Live active (native thread)","live-badge-tmux":"Live active in tmux mode: it does not receive messages","live-host-designated":"Live host: {cell}","live-host-cleared":"Live host removed","live-host-action-use":"Use as Live host","live-host-action-remove":"Remove Live host","cell-actions-title":"Actions for {cell}","cell-actions-open":"Cell actions","cell-actions-live-assign":"Assign Live","cell-actions-live-remove":"Remove Live","cell-actions-pin":"Pin to top","cell-actions-unpin":"Unpin from top","cell-actions-boot":"Boot at startup","cell-actions-watch":"Watch live","bar-menu-open":"More actions","bar-menu-keyboard":"On-screen keyboard","bar-menu-keyboard-desc":"below the terminal","bar-menu-files":"Cell files","bar-menu-files-desc":"inbox · outbox","bar-menu-files-setting-desc":"show the button in the bar","bar-menu-panel":"Cell panel","bar-menu-panel-desc":"only if the cell has one","bar-menu-renderer":"GPU renderer","bar-menu-renderer-desc":"switching reloads the page","bar-keyboard-button":"Keyboard button in the bar","bar-keyboard-button-desc":"show the on-screen keyboard button","bar-panel-button":"AI Desktop button in the bar","bar-panel-button-desc":"show the button if the cell has a panel","cell-switcher-group":"Cells {node}","cell-switcher-group-local":"local","cell-switcher-tap-hint":"Tap a cell for the preview · tap again to open it","cell-switcher-two-taps":"2 taps = open","cell-switcher-side-add":"open side by side","cell-switcher-side-remove":"remove from side by side","cell-switcher-preview-word":"PREVIEW","cell-switcher-preview-readonly":"read only","cell-peek-expand":"Open window","ai-desktop-title":"Graphical desktop","ai-desktop":"Graphical desktop enabled","ai-desktop-help":"The desktop container starts with the switch and stops without it; the panel button appears only while the desktop is running.","ai-desktop-confirm-stop":"The desktop is running: stopping it closes the sessions open in the container. Continue?","panel-start-desktop":"Start the desktop","live-host-stale-revision":"designation not applied: the state changed meanwhile, try again","live-host-not-local":"that cell does not belong to this node","live-host-unavailable":"fleet not available on this node, try again shortly","live-host-not-granted":"This node does not grant the live host cell designation to the requester: it must be granted on the node that owns the cell (nodes live-host <node> on), not by retrying here.","live-host-error":"The live host cell designation failed: retry in a little while.","host-thread-designated":"cell designated; thread absent","host-thread-present":"thread present but idle","host-thread-active":"thread active","host-thread-unknown":"thread status unknown",windows:"{n} windows","empty-files":"empty","files-download":"download file","files-download-action":"Download","files-outbox":"Outbox · {n}","files-inbox":"Inbox · {n}","files-search":"search files","files-search-ph":"search by name…","files-no-match":'no file matches "{q}"',"files-actions":"file actions","files-sheet-title":"File actions","files-original-name":"original name","files-preview":"Preview","files-preview-failed":"preview failed","files-preview-blocked":"preview unavailable for this type: download it","files-copy-name":"Copy full name","files-copied-name":"full name copied","files-delete-ellipsis":"Delete…","files-delete-confirm":'Delete "{name}"?',"files-delete-confirm-help":"The file is permanently deleted from the cell folder.","files-today":"Today","files-dupes":"{n} copies","files-of":"Files of {session}","files-upload":"Upload file","files-upload-failed":"upload error: {e}","files-filter-all":"All","files-filter-docs":"Documents","files-filter-images":"Images","files-open":"Open","files-detail-none":"Select a file to see its details.","files-meta-date":"Date","files-meta-size":"Size","files-meta-folder":"Folder","files-meta-type":"Type","files-footer-count":"{n} files · {size}","files-kbd-enter":"Enter","files-kbd-hint":"↑↓ moves the selection · {enter} opens actions · / searches","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-inbox":"Add Inbox","attach-inbox-done":"{n} file added to the inbox","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-stale":"refresh running late","deck-stale-badge":"running late","deck-owner-unavailable":"owner node is not shared or reachable","deck-owner-reconnecting":"reconnecting…","deck-owner-stale":"stale owner (cached route)","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","tile-detach":"Detach and float","tile-reattach":"Put back in the grid","tile-minimize":"Minimize","tile-restore":"Restore","grid-resize-cols":"Drag to resize the two columns; double click: half and half. Alt: no snapping.","grid-resize-rows":"Drag to resize the two windows; double click: half and half. Alt: no snapping.","visibility-relay":"relay only","device-name-ask-title":"What is this device called?","device-name-ask-text":"The name cannot be derived from the host: it labels your Locale node and introduces you to new nodes.","device-name-save":"Save name","device-name-later":"Later","wizard-device-name":"Name this device (you will see it as your Locale node; new nodes will use it).","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.","pair-authkeys-title":"Line to replace in ~/.ssh/authorized_keys on the peer","pair-authkeys-hint":"Without this line the panel forward stays refused: the tunnel looks up while the panel does not answer.","pair-authkeys-copy":"Copy the line","pair-authkeys-copied":"Line copied","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-stale":"Fleet read failed: the cell list may not be up to date.","reorder-blocked":"Reorder not applied: the list is incomplete right now, your order is safe.","prefs-journal":"Preferences journal (last 50 writes)","prefs-journal-empty":"No changes recorded yet.","prefs-journal-copy":"Copy journal","prefs-journal-clear":"Clear journal","prefs-persist":"Persistent storage","prefs-persist-unknown":"not checked yet","prefs-before":"before","prefs-after":"after","prefs-visible":"visible","prefs-backup":"Preferences backup","prefs-sync":"Copy on the node","prefs-conflict":"This device's preferences and the copy on the node differ. Which one do you keep?","prefs-keep-local":"Keep this device","prefs-use-server":"Use server copy","prefs-export":"Export preferences","prefs-import":"Import preferences","prefs-export-done":"Preferences file created (no token inside).","prefs-import-done":"Preferences imported.","prefs-import-confirm":"Replace this device's preferences with the ones in the file?","prefs-import-wrong":"The file is not a NexusCrew preferences file.","prefs-import-bad":"The preferences file is not valid: nothing was imported.","prefs-import-storage":"The browser refused the write: nothing was imported and this device's preferences are untouched.","fleet-off":"Fleet unavailable: no cells.","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 or exported. If the node is remote, the value travels to it over the paired channel.","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-providers-shell":"user shell","fleet-credential-source-keys-file":"keys file","fleet-credential-source-secure-file":"secure file (wins)","fleet-credential-source-legacy":"legacy file","fleet-credential-source-nexuscrew-store":"NexusCrew store","fleet-credential-source-unreadable":"unreadable","fleet-credential-source-login":"client login","fleet-credential-source-none":"none","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: it is never read back over the network and never enters engines or backups. If the selected node is remote, the value reaches it over the paired channel.","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, but its MCP tools are inherited.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal uses only ALIBABA_CODE_API_KEY from the local credential layer; qwen3.8-max 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-provider-notice-opencode-native":"Native OpenCode client: auth is delegated to the local opencode login (gateway free models answer even without a login). NexusCrew never reads or copies credentials and never writes your opencode.jsonc; models and MCP stay in the client configuration.","fleet-model-default":"default model (optional)","fleet-model-required":"model (required)","fleet-models-title":"Models","fleet-models-usable":"You can use these","fleet-models-refresh":"Update models","fleet-models-refreshing":"Updating…","fleet-models-loading":"Looking up this engine’s models…","fleet-models-error":"Model update failed (network or node): the editor stays usable","fleet-models-stale":"Stale data: showing the last successful fetch","fleet-models-unsupported":"This engine does not expose a model listing","fleet-models-none":"No models found","fleet-models-not-in-api":"not available in the APIs","fleet-models-use":"Use model {model}","fleet-models-cap":"Enable the models you want, within the {cap}-model-per-engine cap","fleet-models-field-context":"context","fleet-models-field-output":"output","fleet-models-field-tools":"tools","fleet-models-field-vision":"vision","fleet-models-field-reasoning":"reasoning","fleet-models-source-of":"source: {source}","fleet-models-source-user":"user","fleet-models-source-api":"API","fleet-models-source-public":"catalog","fleet-models-source-backup":"backup","fleet-models-missing-title":"Missing data","fleet-models-missing-why":"The engine needs a datum for {model} that no source provided:","fleet-models-missing-backup":"proposed backup: {value}","fleet-models-missing-user":"What you confirm becomes your own value: top precedence, never rewritten by discovery.","fleet-models-missing-confirm":"Confirm","fleet-models-missing-empty":"Leave empty","fleet-models-missing-open":"Missing data for {model}","fleet-models-default-badge":"models.dev · default","fleet-models-make-mine":"Make it mine","fleet-models-make-mine-field":"Make it mine: {field} of {model}","fleet-models-make-mine-row":"Make it mine: {model}","fleet-models-make-mine-title":"Confirm the values of {model}","fleet-models-make-mine-why":"What you confirm becomes your own declaration: it stays above the catalog and does not change on the next refresh.","fleet-models-make-mine-confirm":"Confirm","fleet-models-write-failed":"The write did not succeed: the values are still here.","fleet-models-value-absent":"Leave empty","fleet-models-value-true":"Yes","fleet-models-value-false":"No","fleet-models-auth-missing-key":"This model listing requires authentication: the {key} key is not configured on this node","fleet-models-auth-missing-key-anonymous":"This model listing requires authentication, but this engine requests it anonymously: no key is configured.","fleet-models-auth-key-rejected":"The submitted key was not accepted for the model listing.","fleet-models-auth-access-denied":"Access to the model listing was denied: it may be permissions or policy, not necessarily the key.","fleet-models-auth-credential-unavailable":"The key cannot be read or verified on this node: it is not known to be missing — it is unavailable.","fleet-models-auth-endpoint-unreachable":"Endpoint unreachable (network or timeout): this is not a key problem.","fleet-models-auth-provider-error":"The provider answered with an error for the model listing.","fleet-models-auth-invalid-response":"The provider response for the model listing is not valid.","fleet-models-auth-anonymous-success":"Model listing obtained without a key.","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.","cell-prompt":"Cell start-up prompt","cell-prompt-help":"Sent to the cell when it starts: this is its standing brief. Empty means no prompt — the cell just starts.","fleet-boot":"start at boot","fleet-remote-control":"remote control","cell-mcp":"MCP tools","cell-mcp-all":"all","cell-mcp-none":"none","cell-mcp-some":"chosen","cell-mcp-inert":"For this client, MCP tools are registered by the client in its own config, not NexusCrew: the selection here has no effect.","cell-mcp-help":"“All” is the long-standing behaviour. “None” is the only CERTAIN exclusion: it removes every tool and does not depend on where the servers are defined — that is what you want for a cell you do not trust. “Chosen” grants by name, but the list only covers servers this node can enumerate: plugins and connectors do not appear and would stay available.","fleet-model-override":"model override","fleet-ready":"ready","fleet-not-ready":"not configured","fleet-engines":"Engines","fleet-cells":"Cells / cloud sessions","fleet-engine-group-standard":"Standard","fleet-engine-group-other":"Other","fleet-models":"Declared models","fleet-no-models":"No declared model: the built-in catalog is used.","model-editor-engine":"Profile","model-editor-id":"Model id","model-editor-id-help":"The exact id the provider expects. Profile and id cannot be changed later: withdraw and declare again.","model-editor-context":"Context window (tokens)","model-editor-max-tokens":"Max output tokens","model-editor-reasoning":"Supports extended reasoning","model-editor-tools":"Supports tools","model-editor-vision":"Reads images","model-editor-absent":"Leave empty","model-editor-true":"Yes","model-editor-false":"No","model-editor-limit-invalid":"The window must be between 1024 and 100000000.","model-test":"Test against the API","model-test-running":"Testing…","model-test-ok":"responds","model-test-unknown-model":"the provider does not know this id","model-test-auth":"credential missing or refused","model-test-unreachable":"endpoint unreachable","model-test-unverified":"not verified","model-test-unverified-help":"This does not mean it fails: this provider does not expose a model list, so the test could say neither yes nor no.","model-remove":"Withdraw","model-in-use":"in use","fleet-backup":"backup / restore","fleet-backup-help":"Selectively export or restore engines, cells, declared models, 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-invalid-model":"the backup contains an invalid model","fleet-backup-duplicate-model":"the backup contains duplicate models","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. Alpha","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-readiness-degraded":"Started without readiness confirmation: it may not process right away. Check its terminal before assigning work.","fleet-mcp-degraded":"Started degraded, MCP servers not ready:","fleet-vl-prompt-degraded":"Started without its cell prompt: the vl version on this node does not support it (0.3.1+ required). The cell works without its identity: upgrade vl before assigning work.","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)","fleet-panel-url":"Panel URL (optional)","fleet-panel-url-help":"Graphical panel endpoint for the cell (e.g. a container's noVNC): http/https only, toward a loopback host — the proxy resolves the destination on the machine that hosts the cell.","fleet-panel-url-invalid":"The panel is not a port-forward: whoever opens it picks which cell, never where to connect. The address is resolved on the machine that hosts the cell, so it must be reachable there on loopback — 127.0.0.1, localhost, or [::1]. A container's address (e.g. 172.17.0.2) is not.","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-never":"never checked","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","peer-cause-assente":"peer not responding — waiting for it to come back (polls spaced out)","peer-cause-nega":"peer denies access — grant permission on the remote node","peer-cause-rotta":"route no longer exists on the peer — update the node","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","remote-notices-title":"Notifications from other nodes","remote-notices-clear":"Clear","remote-notices-dismiss":"dismiss this notice","remote-notices-dismiss-failed":"dismissal not confirmed: the notice stays","remote-notices-clear-failed":"clear not confirmed: the notices stay","ask-dismiss":"Dismiss question","ask-dismiss-local":"Dismiss on this node","ask-dismiss-local-pending":"Closure on the origin node is pending","ask-dismiss-local-blocked":"Local dismissal only: remote closure is not authorized","ask-dismiss-unconfirmed":"Local dismissal was not confirmed: the question remains visible.","ask-reply-ph":"type your answer…","push-enable":"enable push notifications","push-disable":"disable push notifications","push-on":"push active on this device","push-local-off":"silence on this browser","push-local-on":"re-enable on this browser","push-local-help":"this browser only: the UI and the owner’s own notifications stay on","push-local-off-note":"system alerts off on this browser; the UI stays live","push-local-disabled":"push alerts are off on this browser: re-enable them here","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-preview-voice-error":"The voice test failed: voice or audio unavailable. Check the selected voice and try again.","notification-speech-preview-timeout":"The voice test failed: no response from the speech engine. Check the selected voice 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-verify-failed":"Could not verify: try again shortly.","cell-switcher-select":"select a cell","cell-switcher-open":"open cell","cell-switcher-show-all":"all","cell-switcher-title":"Cells","cell-switcher-filter":"filter: active or all","cell-switcher-live-strip":"Live on {cell} · {mode}","cell-switcher-show-active":"active","cell-switcher-close":"close cell switcher","cell-switcher-here":"you are here","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","selection-changed":"text under the selection changed","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.","cell-scope-list-unavailable":"Cell list unavailable right now: the grants below still hold, but we cannot tell whether they still exist.","feed-owner":"from federated node","ask-remote-readonly":"Reply not granted for this node: card is read-only.","ask-capability-loading":"Checking reply permission…","ask-capability-unreachable":"Reply route is unreachable.","ask-capability-unsupported":"This owner does not support reply capability.","ask-remote-no-feed":"You are not receiving this node’s events: enable receiving (nodes edit <peer> --events-receive true).","ask-feed-stale":"This node’s feed is inactive (stale data): the card may already be closed elsewhere.","ask-dismiss-stale":"Dismiss anyway: the dismissal is forwarded directly to the node, but while the feed is down the card may not reflect the live state.","ask-uncertain":"Uncertain outcome: the answer may have arrived. Verify the status before retrying.","ask-reconcile":"Answer blocked by a previous send: reconcile with the asking node. No blind resend.","ask-verify":"Verify status","peer-access":"Peer role","peer-access-help":"What this peer may do on this installation. The name is derived from the effective grants: applying a preset rewrites the whole vector in one write.","peer-access-current":"Now","peer-access-preset":"Preset to apply","peer-access-preset-none":"pick a preset","peer-access-matrix":"What would change","peer-access-apply":"Apply the preset","peer-access-changed-hint":"The highlighted rows change on confirmation.","peer-access-unchanged":"The preset would change nothing.","peer-access-conflict":"This peer was changed elsewhere: state reloaded, apply the preset again if needed.","access-label-admin":"administrator","access-label-user":"user","access-label-nexushost":"nexushost","access-label-custom":"custom","access-label-unconfigured":"not configured","access-grant-cellVisibility":"Visible cells","access-grant-eventsAccess":"Events","access-grant-eventsReceive":"Receive events and notifications","access-grant-nodeEventsAccess":"Node events","access-grant-askReplyAccess":"Ask replies","access-grant-filesReadAccess":"File reading","access-grant-liveHostAccess":"Live host","access-grant-panelAccess":"Panels","access-grant-peerOperatorAccess":"Peer operator","access-value-all":"all","access-value-selected":"selected","access-value-none":"none","access-value-yes":"yes","access-value-no":"no","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","update-stale":"interfaz desalineada: ejecutas la v{browser}, el nodo sirve la v{ui}. recarga sin caché; si persiste, reinicia el nodo","reload-no-cache":"recargar sin caché","update-installed-restart":"versión {v} instalada: reinicia el nodo","update-dismiss":"cerrar","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","host-lease-live":"host live: supervisión activa","host-lease-grace":"host live: supervisión en recuperación (grace)","host-lease-expired":"host live: supervisión caducada","host-lease-none":"host live: nunca supervisada","host-lease-unavailable":"host live: garantía de supervisión no disponible en este nodo","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","node-sessions-unverified":"sesiones sin verificar","tile-unverified":"dato sin verificar","cell-working":"trabajando","cell-idle":"en espera","cell-stopped":"parada","cell-permission":"esperando permiso","cell-unknown":"sin verificar","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","power-starting":"iniciando…","power-stopping":"deteniendo…","fleet-up-slow":"inicio en curso: comprueba el estado","fleet-down-slow":"parada en curso: comprueba el estado","fleet-up-duplicate":"ya en ejecución",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):","auth-invalid":"El nodo ya no acepta este token (rotado o reemplazado). Introduce el nuevo: tus preferencias no se tocan.","auth-not-remembered":"El navegador no permitió recordar el token en este dispositivo: tendrás que introducirlo de nuevo la próxima vez.","remember-device":"recordar en este dispositivo","zoom-out":"texto más pequeño","zoom-in":"texto más grande","dual-swap":"intercambiar las dos celdas","dual-go-to":"Ir a {cell}","dual-close":"cerrar la segunda celda","dual-focus":"celda con el foco","terminal-renderer-webgl":"WebGL","terminal-renderer-dom":"DOM","terminal-renderer-switch":"motor gráfico: solicitado {requested}, en uso {effective} — toca para cambiar (recarga el terminal)",composer:"composer",panel:"panel","panel-none":"Ningún panel configurado para esta celda.","panel-checking":"Abriendo el panel…","panel-not-granted":"Este nodo no concede el panel a quien lo pide: el acceso se concede en el nodo que posee la celda, no reintentando aquí.","panel-denied":"Entrada al panel rechazada: el billete ya no es válido. Reintenta: se pedirá un billete nuevo.","cell-peek":"Echa un vistazo sin cambiar de celda","cell-tele-ctx":"contexto","cell-tele-free":"libre","cell-tele-5h":"5h usados","cell-tele-7d":"7d usados","cell-activity":"actividad","cell-activity-now":"ahora","cell-peek-preview":"Vista previa","cell-peek-stream":"Flujo","cell-peek-panel":"Panel","cell-peek-vuoto":"No hay vista previa para esta celda.","panel-node-refused":"El nodo que posee la celda rechaza la petición: está en solo lectura, o su política bloquea esta operación. Reintentar aquí no cambia el resultado.","panel-unauthorized":"Credencial no válida para este nodo: se corrige donde está configurada, no reintentando desde aquí.","panel-unreachable":"El panel no es accesible a través de este nodo: reintenta en un momento.","panel-frame-loading":"panel montado: carga en curso","panel-frame-error":"El frame del panel no se ha cargado: el billete puede haber caducado (30 s de vida, monouso) o el destino es inaccesible. Reintenta: se pedirá un billete nuevo.","popup-drag-hint":"arrastra para mover; doble clic para volver al centro","popup-resize-hint":"arrastra para redimensionar","panel-timeout":"El panel no respondió a tiempo: servicio lento en arrancar o sobrecargado. Reintenta en un momento.","panel-retry":"Reintentar","live-host-indicator":"Live host: {cell} · {mode} · {state}","live-host-indicator-none":"Live host: ninguna celda designada","live-host-remote":"otro nodo","live-host-mode-native":"nativa (thread)","live-host-mode-tmux":"tmux","live-host-mode-unknown":"modo desconocido","live-host-state-none":"sin designación","live-host-state-designated":"designada, sin thread","live-host-state-thread-present":"thread presente pero inactivo","live-host-state-thread-active":"thread activo","live-host-state-thread-unknown":"estado del thread desconocido","live-badge":"Live","live-badge-native":"Live activa (thread nativo)","live-badge-tmux":"Live activa en modo tmux: no recibe mensajes","live-host-designated":"Live host: {cell}","live-host-cleared":"Live host quitado","live-host-action-use":"Usar como host Live","live-host-action-remove":"Quitar host Live","cell-actions-title":"Acciones de {cell}","cell-actions-open":"Acciones de celda","cell-actions-live-assign":"Asignar Live","cell-actions-live-remove":"Quitar Live","cell-actions-pin":"Fijar arriba","cell-actions-unpin":"Quitar de arriba","cell-actions-boot":"Arranque al inicio","cell-actions-watch":"Ver en vivo","bar-menu-open":"Más acciones","bar-menu-keyboard":"Teclado en pantalla","bar-menu-keyboard-desc":"bajo el terminal","bar-menu-files":"Archivos de la celda","bar-menu-files-desc":"inbox · outbox","bar-menu-files-setting-desc":"muestra el botón en la barra","bar-menu-panel":"Panel de la celda","bar-menu-panel-desc":"solo si la celda tiene uno","bar-menu-renderer":"Renderer GPU","bar-menu-renderer-desc":"cambiarlo recarga la página","bar-keyboard-button":"Botón de teclado en la barra","bar-keyboard-button-desc":"muestra el botón del teclado en pantalla","bar-panel-button":"Botón de AI Desktop en la barra","bar-panel-button-desc":"muestra el botón si la celda tiene panel","cell-switcher-group":"Celdas {node}","cell-switcher-group-local":"local","cell-switcher-tap-hint":"Toca una celda para la vista previa · toca de nuevo para abrirla","cell-switcher-two-taps":"2 toques = abrir","cell-switcher-side-add":"abrir en paralelo","cell-switcher-side-remove":"quitar de la vista en paralelo","cell-switcher-preview-word":"VISTA PREVIA","cell-switcher-preview-readonly":"solo lectura","cell-peek-expand":"Abrir ventana","ai-desktop-title":"Escritorio gráfico","ai-desktop":"Escritorio gráfico activo","ai-desktop-help":"El contenedor del escritorio arranca con la casilla y se detiene sin ella; el botón del panel aparece solo con el escritorio activo.","ai-desktop-confirm-stop":"El escritorio está en ejecución: detenerlo cierra las sesiones abiertas en el contenedor. ¿Continuar?","panel-start-desktop":"Iniciar el escritorio","live-host-stale-revision":"designación no aplicada: el estado cambió mientras tanto, reintenta","live-host-not-local":"esa celda no pertenece a este nodo","live-host-unavailable":"flota no disponible en este nodo, reintenta en un momento","live-host-not-granted":"Este nodo no concede la designación de celda anfitriona Live a quien la pide: se concede en el nodo que posee la celda (nodes live-host <nodo> on), no reintentando aquí.","live-host-error":"La designación de celda anfitriona Live no funcionó: reintenta en un momento.","host-thread-designated":"celda designada; thread ausente","host-thread-present":"thread presente pero inactivo","host-thread-active":"thread activo","host-thread-unknown":"estado del thread desconocido",windows:"{n} ventanas","empty-files":"vacía","files-download":"descargar archivo","files-download-action":"Descargar","files-outbox":"Outbox · {n}","files-inbox":"Inbox · {n}","files-search":"buscar archivos","files-search-ph":"buscar por nombre…","files-no-match":'ningún archivo contiene "{q}"',"files-actions":"acciones del archivo","files-sheet-title":"Acciones del archivo","files-original-name":"nombre original","files-preview":"Vista previa","files-preview-failed":"vista previa no lograda","files-preview-blocked":"vista previa no disponible para este tipo: descárgalo","files-copy-name":"Copiar nombre completo","files-copied-name":"nombre completo copiado","files-delete-ellipsis":"Eliminar…","files-delete-confirm":'¿Eliminar "{name}"?',"files-delete-confirm-help":"El archivo se elimina definitivamente de la carpeta de la celda.","files-today":"Hoy","files-dupes":"{n} copias","files-of":"Archivos de {session}","files-upload":"Subir archivo","files-upload-failed":"error de subida: {e}","files-filter-all":"Todos","files-filter-docs":"Documentos","files-filter-images":"Imágenes","files-open":"Abrir","files-detail-none":"Selecciona un archivo para ver sus detalles.","files-meta-date":"Fecha","files-meta-size":"Tamaño","files-meta-folder":"Carpeta","files-meta-type":"Tipo","files-footer-count":"{n} archivos · {size}","files-kbd-enter":"Enter","files-kbd-hint":"↑↓ mueve la selección · {enter} abre acciones · / busca","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-inbox":"Inbox","attach-inbox-done":"{n} archivos añadidos a la bandeja","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-stale":"actualización con retraso","deck-stale-badge":"con retraso","deck-owner-unavailable":"el nodo propietario no está compartido o accesible","deck-owner-reconnecting":"reconectando…","deck-owner-stale":"owner stale (ruta en caché)","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.","tile-detach":"Desprender y flotar","tile-reattach":"Volver a la cuadrícula","tile-minimize":"Minimizar","tile-restore":"Restaurar","grid-resize-cols":"Arrastra para redimensionar las dos columnas; doble clic: mitad y mitad. Alt: sin imán.","grid-resize-rows":"Arrastra para redimensionar las dos ventanas; doble clic: mitad y mitad. Alt: sin imán.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","device-name-ask-title":"¿Cómo se llama este dispositivo?","device-name-ask-text":"El nombre no se puede deducir del host: identifica tu nodo Locale y te presenta a los nodos nuevos.","device-name-save":"Guardar nombre","device-name-later":"Más tarde","wizard-device-name":"Ponle nombre a este dispositivo (lo verás como nodo Locale; los nodos nuevos lo usarán).","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.","pair-authkeys-title":"Línea que hay que sustituir en ~/.ssh/authorized_keys del peer","pair-authkeys-hint":"Sin esta línea el reenvío del panel sigue rechazado: el túnel parece activo y el panel no responde.","pair-authkeys-copy":"Copiar la línea","pair-authkeys-copied":"Línea copiada","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-stale":"Fallo de lectura de la flota: la lista de celdas puede no estar actualizada.","reorder-blocked":"Reordenación no aplicada: la lista está incompleta ahora, tu orden está a salvo.","prefs-journal":"Diario de preferencias (últimas 50 escrituras)","prefs-journal-empty":"Aún no hay cambios registrados.","prefs-journal-copy":"Copiar diario","prefs-journal-clear":"Vaciar diario","prefs-persist":"Almacenamiento persistente","prefs-persist-unknown":"sin comprobar","prefs-before":"antes","prefs-after":"después","prefs-visible":"visibles","prefs-backup":"Copia de preferencias","prefs-sync":"Copia en el nodo","prefs-conflict":"Las preferencias de este dispositivo y la copia del nodo difieren. ¿Cuál conservas?","prefs-keep-local":"Conservar este dispositivo","prefs-use-server":"Usar la copia del nodo","prefs-export":"Exportar preferencias","prefs-import":"Importar preferencias","prefs-export-done":"Archivo de preferencias creado (sin token).","prefs-import-done":"Preferencias importadas.","prefs-import-confirm":"¿Reemplazar las preferencias de este dispositivo con las del archivo?","prefs-import-wrong":"El archivo no es un archivo de preferencias de NexusCrew.","prefs-import-bad":"El archivo de preferencias no es válido: no se importó nada.","prefs-import-storage":"El navegador rechazó la escritura: no se importó nada y las preferencias de este dispositivo están intactas.","fleet-off":"Flota no disponible: sin celdas.","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 ni se exporta. Si el nodo es remoto, el valor viaja hasta él por el canal emparejado.","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-providers-shell":"shell del usuario","fleet-credential-source-keys-file":"archivo de claves","fleet-credential-source-secure-file":"archivo secure (prevale)","fleet-credential-source-legacy":"archivo legacy","fleet-credential-source-nexuscrew-store":"almacén NexusCrew","fleet-credential-source-unreadable":"no verificable","fleet-credential-source-login":"login del cliente","fleet-credential-source-none":"ninguna","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: nunca se vuelve a leer desde la red ni entra en motores o copias. Si el nodo seleccionado es remoto, el valor llega a él por el canal emparejado.","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, pero sus herramientas MCP se heredan.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY de la capa local de credenciales; qwen3.8-max 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-provider-notice-opencode-native":"Cliente OpenCode nativo: la autenticación se delega al login local de opencode (los modelos free del gateway responden incluso sin login). NexusCrew no lee ni copia credenciales y no escribe tu opencode.jsonc; modelos y MCP quedan en la configuración del cliente.","fleet-model-default":"modelo predeterminado (opcional)","fleet-model-required":"modelo (obligatorio)","fleet-models-title":"Modelos","fleet-models-usable":"Puedes usar estos","fleet-models-refresh":"Actualizar los modelos","fleet-models-refreshing":"Actualizando…","fleet-models-loading":"Buscando los modelos de este motor…","fleet-models-error":"No se pudieron actualizar los modelos (red o nodo): el editor sigue siendo utilizable","fleet-models-stale":"Datos no actualizados: muestro la última lectura correcta","fleet-models-unsupported":"Este motor no expone una lista de modelos","fleet-models-none":"No se ha encontrado ningún modelo","fleet-models-not-in-api":"no disponible en las API","fleet-models-use":"Usar el modelo {model}","fleet-models-cap":"Se activan los modelos que quieras, dentro del límite de {cap} por motor","fleet-models-field-context":"contexto","fleet-models-field-output":"salida","fleet-models-field-tools":"herramientas","fleet-models-field-vision":"visión","fleet-models-field-reasoning":"razonamiento","fleet-models-source-of":"procedencia: {source}","fleet-models-source-user":"usuario","fleet-models-source-api":"API","fleet-models-source-public":"catálogo","fleet-models-source-backup":"reserva","fleet-models-missing-title":"Falta un dato","fleet-models-missing-why":"A {model} le falta un dato que el motor necesita:","fleet-models-missing-backup":"copia de seguridad propuesta: {value}","fleet-models-missing-user":"Lo que confirmas se convierte en tu valor: prioridad máxima, el descubrimiento nunca lo reescribe.","fleet-models-missing-confirm":"Confirmar","fleet-models-missing-empty":"Dejar vacío","fleet-models-missing-open":"Falta un dato de {model}","fleet-models-default-badge":"models.dev · default","fleet-models-make-mine":"Hazlo mío","fleet-models-make-mine-field":"Hazlo mío: {field} de {model}","fleet-models-make-mine-row":"Hazlo mío: {model}","fleet-models-make-mine-title":"Confirma los valores de {model}","fleet-models-make-mine-why":"Lo que confirmas se convierte en una declaración tuya: queda por encima del catálogo y no cambia en la próxima actualización.","fleet-models-make-mine-confirm":"Confirmar","fleet-models-write-failed":"La escritura no se completó: los valores siguen aquí.","fleet-models-value-absent":"Dejar vacío","fleet-models-value-true":"Sí","fleet-models-value-false":"No","fleet-models-auth-missing-key":"Esta lista de modelos requiere autenticación: la clave {key} no está configurada en este nodo","fleet-models-auth-missing-key-anonymous":"Esta lista de modelos requiere autenticación, pero este motor la pide de forma anónima: no hay clave configurada.","fleet-models-auth-key-rejected":"La clave enviada no fue aceptada para la lista de modelos.","fleet-models-auth-access-denied":"Se denegó el acceso a la lista de modelos: pueden ser permisos o políticas, no necesariamente la clave.","fleet-models-auth-credential-unavailable":"La clave no se puede leer ni verificar en este nodo: no consta que falte, no está disponible.","fleet-models-auth-endpoint-unreachable":"Punto de acceso inalcanzable (red o tiempo de espera): no es un problema de clave.","fleet-models-auth-provider-error":"El proveedor respondió con un error para la lista de modelos.","fleet-models-auth-invalid-response":"La respuesta del proveedor para la lista de modelos no es válida.","fleet-models-auth-anonymous-success":"Lista de modelos obtenida sin clave.","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.","cell-prompt":"Prompt de arranque de la celda","cell-prompt-help":"Se envía a la celda al arrancar: es su encargo permanente. Vacío = sin prompt, la celda solo arranca.","fleet-boot":"inicio automático","fleet-remote-control":"control remoto","cell-mcp":"Herramientas MCP","cell-mcp-all":"todas","cell-mcp-none":"ninguna","cell-mcp-some":"elegidas","cell-mcp-inert":"Para este cliente, las herramientas MCP las registra el cliente en su propia config, no NexusCrew: la selección aquí no tiene efecto.","cell-mcp-help":"«Todas» es el comportamiento de siempre. «Ninguna» es la única exclusión CIERTA: quita toda herramienta y no depende de dónde estén definidos los servidores — es lo que hace falta para una celda en la que no se confía. Con «elegidas» se concede por nombre, pero la lista solo cubre los servidores que este nodo puede enumerar: los plugins y conectores no aparecen y seguirían disponibles.","fleet-model-override":"modelo alternativo","fleet-ready":"listo","fleet-not-ready":"no configurado","fleet-engines":"Motores","fleet-cells":"Celdas / sesiones cloud","fleet-engine-group-standard":"Estándar","fleet-engine-group-other":"Otros","fleet-models":"Modelos declarados","fleet-no-models":"Ningún modelo declarado: se usa el catálogo interno.","model-editor-engine":"Perfil","model-editor-id":"Id del modelo","model-editor-id-help":"El id exacto que espera el proveedor. Perfil e id no se cambian después: se retira y se vuelve a declarar.","model-editor-context":"Ventana de contexto (tokens)","model-editor-max-tokens":"Máximo de tokens de salida","model-editor-reasoning":"Admite razonamiento extendido","model-editor-tools":"Admite herramientas","model-editor-vision":"Lee imágenes","model-editor-absent":"Dejar vacío","model-editor-true":"Sí","model-editor-false":"No","model-editor-limit-invalid":"La ventana debe estar entre 1024 y 100000000.","model-test":"Probar contra la API","model-test-running":"Probando…","model-test-ok":"responde","model-test-unknown-model":"el proveedor no conoce este id","model-test-auth":"credencial ausente o rechazada","model-test-unreachable":"endpoint inalcanzable","model-test-unverified":"no verificado","model-test-unverified-help":"No significa que falle: este proveedor no expone la lista de modelos, así que la prueba no pudo decir ni sí ni no.","model-remove":"Retirar","model-in-use":"en uso","fleet-backup":"copia / restauración","fleet-backup-help":"Exporta o restaura selectivamente motores, celdas, modelos declarados 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-invalid-model":"la copia contiene un modelo no válido","fleet-backup-duplicate-model":"la copia contiene modelos 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-readiness-degraded":"Iniciada sin confirmación de preparación: puede que no procese de inmediato. Revisa su terminal antes de asignarle trabajo.","fleet-mcp-degraded":"Iniciada en degradación, servidores MCP no listos:","fleet-vl-prompt-degraded":"Iniciada sin el prompt de celda: la versión de vl en este nodo no lo admite (se requiere 0.3.1+). La celda trabaja sin su identidad: actualiza vl antes de asignarle trabajo.","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)","fleet-panel-url":"URL del panel (opcional)","fleet-panel-url-help":"Endpoint del panel gráfico de la celda (p. ej. el noVNC de un contenedor): solo http/https hacia un host loopback — el proxy resuelve el destino en la máquina que aloja la celda.","fleet-panel-url-invalid":"El panel no es un port-forward: quien lo abre elige qué celda, nunca dónde conectarse. La dirección se resuelve en la máquina que aloja la celda, así que debe ser alcanzable allí en loopback — 127.0.0.1, localhost o [::1]. La dirección de un contenedor (p. ej. 172.17.0.2) no lo es.","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-never":"nunca comprobado","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","peer-cause-assente":"el peer no responde — esperando a que vuelva (consultas espaciadas)","peer-cause-nega":"el peer deniega el acceso — concede el permiso en el nodo remoto","peer-cause-rotta":"la ruta ya no existe en el peer — actualiza el nodo","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","remote-notices-title":"Notificaciones de otros nodos","remote-notices-clear":"Limpiar","remote-notices-dismiss":"descartar esta notificación","remote-notices-dismiss-failed":"descarte no confirmado: la notificación permanece","remote-notices-clear-failed":"limpieza no confirmada: las notificaciones permanecen","ask-dismiss":"Descartar la pregunta","ask-dismiss-local":"Descartar en este nodo","ask-dismiss-local-pending":"Cierre en el nodo de origen pendiente","ask-dismiss-local-blocked":"Descarte solo local: el cierre remoto no está autorizado","ask-dismiss-unconfirmed":"Descarte local no confirmado: la pregunta sigue visible.","ask-reply-ph":"escribe la respuesta…","push-enable":"activar notificaciones push","push-disable":"desactivar notificaciones push","push-on":"push activas en este dispositivo","push-local-off":"silenciar en este navegador","push-local-on":"reactivar en este navegador","push-local-help":"solo este navegador: la UI y las notificaciones del owner siguen activas","push-local-off-note":"avisos del sistema apagados en este navegador; la UI sigue activa","push-local-disabled":"los avisos push están apagados en este navegador: reactívalos aquí","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-preview-voice-error":"La prueba de voz falló: voz o audio no disponibles. Comprueba la voz seleccionada e inténtalo de nuevo.","notification-speech-preview-timeout":"La prueba de voz falló: sin respuesta del motor de voz. Comprueba la voz seleccionada e inténtalo de nuevo.","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-verify-failed":"No se pudo verificar: inténtalo de nuevo dentro de poco.","cell-switcher-select":"selecciona una celda","cell-switcher-open":"abrir celda","cell-switcher-show-all":"todas","cell-switcher-title":"Celdas","cell-switcher-filter":"filtro: activas o todas","cell-switcher-live-strip":"Live en {cell} · {mode}","cell-switcher-show-active":"activas","cell-switcher-close":"cerrar selector de celdas","cell-switcher-here":"estás aquí","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","selection-changed":"el texto bajo la selección cambió","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.","cell-scope-list-unavailable":"Lista de celdas no disponible ahora: las concesiones de abajo siguen vigentes, pero no se puede saber si aún existen.","feed-owner":"de nodo federado","ask-remote-readonly":"Respuesta no concedida para este nodo: tarjeta en solo lectura.","ask-capability-loading":"Comprobando el permiso de respuesta…","ask-capability-unreachable":"Ruta de respuesta no accesible.","ask-capability-unsupported":"Este nodo no admite la comprobación del permiso de respuesta.","ask-remote-no-feed":"No recibes los eventos de este nodo: activa la recepción (nodes edit <peer> --events-receive true).","ask-feed-stale":"El feed de este nodo está inactivo (datos no actualizados): la tarjeta puede estar ya cerrada en otro sitio.","ask-dismiss-stale":"Descartar igualmente: el descarto se reenvía directamente al nodo, pero con el feed caído la tarjeta puede no reflejar el estado real.","ask-uncertain":"Resultado incierto: la respuesta pudo llegar. Verifica el estado antes de reintentar.","ask-reconcile":"Respuesta bloqueada por un envío previo: reconcilia con el nodo que hizo la pregunta. Ningún reenvío a ciegas.","ask-verify":"Verificar estado","peer-access":"Rol del par","peer-access-help":"Lo que este par puede hacer en esta instalación. El nombre se deriva de los permisos efectivos: aplicar un preajuste reescribe todo el vector en una sola escritura.","peer-access-current":"Ahora","peer-access-preset":"Preajuste a aplicar","peer-access-preset-none":"elige un preajuste","peer-access-matrix":"Qué cambiaría","peer-access-apply":"Aplicar el preajuste","peer-access-changed-hint":"Las filas resaltadas cambian al confirmar.","peer-access-unchanged":"El preajuste no cambiaría nada.","peer-access-conflict":"Este par fue modificado en otro lugar: estado recargado, vuelve a aplicar el preajuste si hace falta.","access-label-admin":"administrador","access-label-user":"usuario","access-label-nexushost":"nexushost","access-label-custom":"personalizado","access-label-unconfigured":"no configurado","access-grant-cellVisibility":"Celdas visibles","access-grant-eventsAccess":"Eventos","access-grant-eventsReceive":"Recepción de eventos y notificaciones","access-grant-nodeEventsAccess":"Eventos de nodo","access-grant-askReplyAccess":"Respuestas a preguntas","access-grant-filesReadAccess":"Lectura de archivos","access-grant-liveHostAccess":"Host Live","access-grant-panelAccess":"Paneles","access-grant-peerOperatorAccess":"Operador de pares","access-value-all":"todas","access-value-selected":"seleccionadas","access-value-none":"ninguna","access-value-yes":"sí","access-value-no":"no","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 Vo(){const t=o1(),e=t?t.getItem(r1):null;return pv.includes(e)?e:yd}function cj(t){const e=o1();if(e)try{e.setItem(r1,t)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(Nm))}function f(t){const e=Vo(),n=Qu[e]||Qu[yd];return Object.prototype.hasOwnProperty.call(n,t)?n[t]:Object.prototype.hasOwnProperty.call(Qu[yd],t)?Qu[yd][t]:t}function uj(t){return typeof window>"u"?()=>{}:(window.addEventListener(Nm,t),()=>window.removeEventListener(Nm,t))}const a1=pv,Ec="none",l1="favorite",c1="designated",u1="thread-present",d1="thread-active",h1="thread-unknown",f1=new Set([c1,u1,d1,h1]);function p1(t){return t==="absent"?c1:t==="present"?u1:t==="active"?d1:h1}function dj(t){return f1.has(t)?`host-thread-${t.replace("thread-","")}`:null}function Id({hostCell:t,threadStatus:e,pins:n=[],item:s}){const i=s&&s.value&&typeof s.value.cell=="string"?s.value.cell:null;return i!=null&&t===i?p1(e):Array.isArray(n)&&s&&n.includes(s.key)?l1:Ec}const hj=Object.freeze(["live","grace","expired","none","unavailable"]);function jm(t,e){return!f1.has(t)||!hj.includes(e)?null:`host-lease-${e}`}const fj="local";function Ls(t){return Array.isArray(t)&&t.length?t.join("/"):fj}function Lm(t){return(t&&t.data&&typeof t.data=="object"?t.data.reason:null)==="live-host-not-granted"?"live-host-not-granted":"live-host-error"}const m1="native",Rm="tmux";function pj(t){return typeof t!="string"||!t?null:t.startsWith("codex-vl")?m1:Rm}function Va({liveHost:t,cells:e=[],localNodeId:n="",ownerId:s=null}={}){const i=t&&typeof t.hostCell=="string"&&t.hostCell?t.hostCell:null,l=i&&(Array.isArray(e)?e:[]).find(u=>u&&u.cell===i)||null,c=l&&typeof l.engine=="string"&&l.engine?l.engine:null;return{hostCell:i,cell:i,known:!!l,engine:c,mode:pj(c),state:i?p1(t&&t.threadStatus):Ec,hostActive:!!(l&&l.active===!0&&l.tmux!==!1),remote:!!(s&&n&&s!==n),lease:t&&(t.hostLease||(t.host&&typeof t.host.lease=="string"?t.host.lease:null))||null}}function mj(t){const e=t&&t.state?t.state:Ec;return{modeKey:t&&t.mode?`live-host-mode-${t.mode}`:null,stateKey:`live-host-state-${e}`}}function mv(t){const e=t&&t.state?t.state:Ec;return e==="thread-active"?"active":e==="thread-present"?"present":e===Ec?"none":e==="thread-unknown"?"unknown":"designated"}function gj(t){return!t||!t.cell||t.remote?null:t.state==="thread-present"||t.state==="thread-active"?m1:t.mode===Rm&&t.hostActive?Rm:null}function g1({view:t}){const e=gj(t);return e?a.jsx("span",{className:"nc-live-badge","data-testid":"live-badge","data-mode":e,title:f(`live-badge-${e}`),children:f("live-badge")}):null}const gv="nc_popup_assetto",vj=320,_j=240,yj=1100,wj=820,rb=48,bj=44;function v1(){return{vw:window.innerWidth||1024,vh:window.innerHeight||768}}function cc(t){const{vw:e,vh:n}=v1(),s=Math.max(vj,Math.min(t.w,e)),i=Math.max(_j,Math.min(t.h,n)),l=Math.max(-(s-rb),Math.min(t.x,e-rb)),c=Math.max(0,Math.min(t.y,Math.max(0,n-bj)));return{x:l,y:c,w:s,h:i}}function ob(){try{const t=window.localStorage.getItem(gv);if(!t)return null;const e=JSON.parse(t);return!e||![e.x,e.y,e.w,e.h].every(n=>typeof n=="number"&&Number.isFinite(n))?null:cc(e)}catch{return null}}function Sj(t){try{window.localStorage.setItem(gv,JSON.stringify(t))}catch{}}function xj(){const[t,e]=y.useState(()=>typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 720px)").matches);return y.useEffect(()=>{if(typeof window.matchMedia!="function")return;const n=window.matchMedia("(max-width: 720px)"),s=i=>e(!!(i&&i.matches));if(typeof n.addEventListener=="function")return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),t}function _1({title:t,subtitle:e,onClose:n,children:s}){const i=y.useRef(null),l=y.useRef(null),c=xj(),[u,h]=y.useState(()=>c?null:ob()),p=y.useRef(null),[v,_]=y.useState(!1),g=y.useCallback(()=>{n&&n()},[n]);y.useEffect(()=>{const N=E=>{E.key==="Escape"&&(E.stopPropagation(),g())};return document.addEventListener("keydown",N,!0),()=>document.removeEventListener("keydown",N,!0)},[g]),y.useEffect(()=>{const N=l.current;N&&typeof N.focus=="function"&&N.focus()},[]);const b=()=>{const{vw:N,vh:E}=v1(),O=Math.min(yj,Math.floor(N*.96)),x=Math.min(wj,Math.floor(E*.92));return cc({x:Math.round((N-O)/2),y:Math.round((E-x)/2),w:O,h:x})},S=N=>E=>{if(c||E.button!==0||E.target&&typeof E.target.closest=="function"&&E.target.closest(".nc-popup-chiudi"))return;E.preventDefault();const O=u||b();p.current={mode:N,startX:E.clientX,startY:E.clientY,base:O},h(O),_(!0)};y.useEffect(()=>{if(!v)return;const N=O=>{const x=p.current;if(!x)return;const W=O.clientX-x.startX,$=O.clientY-x.startY;x.mode==="move"?h(cc({...x.base,x:x.base.x+W,y:x.base.y+$})):h(cc({...x.base,w:x.base.w+W,h:x.base.h+$}))},E=()=>{p.current=null,_(!1),h(O=>(O&&Sj(O),O))};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",E),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",E)}},[v]);const j=()=>{if(!c){p.current=null,_(!1),h(null);try{window.localStorage.removeItem(gv)}catch{}}};y.useEffect(()=>{if(c)return;const N=()=>h(E=>E&&cc(E));return window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[c]),y.useEffect(()=>{c||h(N=>N||ob())},[c]);const C=!!(u&&!c);return a.jsxs("div",{className:"nc-popup-velo",onMouseDown:N=>{N.target===N.currentTarget&&g()},role:"presentation",children:[a.jsxs("div",{className:C?"nc-popup nc-popup-libera":"nc-popup",style:C?{left:u.x,top:u.y,width:u.w,height:u.h}:void 0,ref:i,role:"dialog","aria-modal":"true","aria-label":t||f("panel"),children:[a.jsxs("header",{className:"nc-popup-testa",onMouseDown:S("move"),onDoubleClick:j,title:f("popup-drag-hint"),children:[a.jsxs("span",{className:"nc-popup-titolo",children:[t,e?a.jsx("small",{className:"nc-popup-sub",children:e}):null]}),a.jsx("button",{type:"button",ref:l,className:"nc-popup-chiudi",onClick:g,title:f("close"),"aria-label":f("close"),children:"✕"})]}),a.jsx("div",{className:"nc-popup-corpo",children:s}),!c&&a.jsx("div",{className:"nc-popup-angolo",onMouseDown:S("resize"),title:f("popup-resize-hint"),role:"presentation"})]}),v&&a.jsx("div",{className:"nc-popup-velo-drag",role:"presentation"})]})}function ab(t){const e=t&&t.status;return(t&&t.data&&typeof t.data=="object"?t.data.reason:null)==="live-host-not-granted"?"live-host-not-granted":e===409?"live-host-stale-revision":e===404?"live-host-not-local":e===503?"live-host-unavailable":Lm(t)}async function dh({action:t,cellId:e,route:n=[],token:s,api:i={}}={}){const l=i.getLiveHost||(v=>ah(s,v)),c=i.designateHostCell||((v,_,g)=>lh(s,v,_,g)),u=i.clearHostCell||((v,_)=>ch(s,v,_));let h;try{h=await l(n)}catch(v){return{ok:!1,messageKey:ab(v),error:v}}const p=Number.isInteger(h&&h.revision)?h.revision:0;try{if(t==="remove"){const _=await u(p,n);return{ok:!0,messageKey:"live-host-cleared",hostCell:_&&typeof _.hostCell=="string"?_.hostCell:null,revision:_&&_.revision}}const v=await c(e,p,n);return{ok:!0,messageKey:"live-host-designated",hostCell:v&&typeof v.hostCell=="string"?v.hostCell:e,revision:v&&v.revision}}catch(v){return{ok:!1,messageKey:ab(v),error:v}}}/**
41
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
42
+ * @license MIT
43
+ *
44
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
45
+ * @license MIT
46
+ *
47
+ * Originally forked from (with the author's permission):
48
+ * Fabrice Bellard's javascript vt100 for jslinux:
49
+ * http://bellard.org/jslinux/
50
+ * Copyright (c) 2011 Fabrice Bellard
51
+ */var y1=Object.defineProperty,kj=Object.getOwnPropertyDescriptor,Cj=(t,e)=>{for(var n in e)y1(t,n,{get:e[n],enumerable:!0})},An=(t,e,n,s)=>{for(var i=s>1?void 0:s?kj(e,n):e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(i=(s?c(e,n,i):c(i))||i);return s&&i&&y1(e,n,i),i},ut=(t,e)=>(n,s)=>e(n,s,t),lb="Terminal input",Am={get:()=>lb,set:t=>lb=t},cb="Too much output to announce, navigate to rows manually to read",Mm={get:()=>cb,set:t=>cb=t};function Ej(t){return t.replace(/\r?\n/g,"\r")}function Nj(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function jj(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function Lj(t,e,n,s){if(t.stopPropagation(),t.clipboardData){let i=t.clipboardData.getData("text/plain");w1(i,e,n,s)}}function w1(t,e,n,s){t=Ej(t),t=Nj(t,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(t,!0),e.value=""}function b1(t,e,n){let s=n.getBoundingClientRect(),i=t.clientX-s.left-10,l=t.clientY-s.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${i}px`,e.style.top=`${l}px`,e.style.zIndex="1000",e.focus()}function ub(t,e,n,s,i){b1(t,e,n),i&&s.rightClickSelect(t),e.value=s.selectionText,e.select()}function so(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function hh(t,e=0,n=t.length){let s="";for(let i=e;i<n;++i){let l=t[i];l>65535?(l-=65536,s+=String.fromCharCode((l>>10)+55296)+String.fromCharCode(l%1024+56320)):s+=String.fromCharCode(l)}return s}var Rj=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,n){let s=e.length;if(!s)return 0;let i=0,l=0;if(this._interim){let c=e.charCodeAt(l++);56320<=c&&c<=57343?n[i++]=(this._interim-55296)*1024+c-56320+65536:(n[i++]=this._interim,n[i++]=c),this._interim=0}for(let c=l;c<s;++c){let u=e.charCodeAt(c);if(55296<=u&&u<=56319){if(++c>=s)return this._interim=u,i;let h=e.charCodeAt(c);56320<=h&&h<=57343?n[i++]=(u-55296)*1024+h-56320+65536:(n[i++]=u,n[i++]=h);continue}u!==65279&&(n[i++]=u)}return i}},Aj=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,n){let s=e.length;if(!s)return 0;let i=0,l,c,u,h,p=0,v=0;if(this.interim[0]){let b=!1,S=this.interim[0];S&=(S&224)===192?31:(S&240)===224?15:7;let j=0,C;for(;(C=this.interim[++j]&63)&&j<4;)S<<=6,S|=C;let N=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,E=N-j;for(;v<E;){if(v>=s)return 0;if(C=e[v++],(C&192)!==128){v--,b=!0;break}else this.interim[j++]=C,S<<=6,S|=C&63}b||(N===2?S<128?v--:n[i++]=S:N===3?S<2048||S>=55296&&S<=57343||S===65279||(n[i++]=S):S<65536||S>1114111||(n[i++]=S)),this.interim.fill(0)}let _=s-4,g=v;for(;g<s;){for(;g<_&&!((l=e[g])&128)&&!((c=e[g+1])&128)&&!((u=e[g+2])&128)&&!((h=e[g+3])&128);)n[i++]=l,n[i++]=c,n[i++]=u,n[i++]=h,g+=4;if(l=e[g++],l<128)n[i++]=l;else if((l&224)===192){if(g>=s)return this.interim[0]=l,i;if(c=e[g++],(c&192)!==128){g--;continue}if(p=(l&31)<<6|c&63,p<128){g--;continue}n[i++]=p}else if((l&240)===224){if(g>=s)return this.interim[0]=l,i;if(c=e[g++],(c&192)!==128){g--;continue}if(g>=s)return this.interim[0]=l,this.interim[1]=c,i;if(u=e[g++],(u&192)!==128){g--;continue}if(p=(l&15)<<12|(c&63)<<6|u&63,p<2048||p>=55296&&p<=57343||p===65279)continue;n[i++]=p}else if((l&248)===240){if(g>=s)return this.interim[0]=l,i;if(c=e[g++],(c&192)!==128){g--;continue}if(g>=s)return this.interim[0]=l,this.interim[1]=c,i;if(u=e[g++],(u&192)!==128){g--;continue}if(g>=s)return this.interim[0]=l,this.interim[1]=c,this.interim[2]=u,i;if(h=e[g++],(h&192)!==128){g--;continue}if(p=(l&7)<<18|(c&63)<<12|(u&63)<<6|h&63,p<65536||p>1114111)continue;n[i++]=p}}return i}},S1="",ro=" ",Kc=class x1{constructor(){this.fg=0,this.bg=0,this.extended=new Dd}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new x1;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Dd=class k1{constructor(e=0,n=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new k1(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},wi=class C1 extends Kc{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Dd,this.combinedData=""}static fromCharData(e){let n=new C1;return n.setFromCharData(e),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?so(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let n=!1;if(e[1].length>2)n=!0;else if(e[1].length===2){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let i=e[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(s-55296)*1024+i-56320+65536|e[2]<<22:n=!0}else n=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;n&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},db="di$target",Tm="di$dependencies",op=new Map;function Mj(t){return t[Tm]||[]}function us(t){if(op.has(t))return op.get(t);let e=function(n,s,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Tj(e,n,i)};return e._id=t,op.set(t,e),e}function Tj(t,e,n){e[db]===e?e[Tm].push({id:t,index:n}):(e[Tm]=[{id:t,index:n}],e[db]=e)}var Os=us("BufferService"),E1=us("CoreMouseService"),Qo=us("CoreService"),Pj=us("CharsetService"),vv=us("InstantiationService"),N1=us("LogService"),Bs=us("OptionsService"),j1=us("OscLinkService"),Ij=us("UnicodeService"),Vc=us("DecorationService"),Pm=class{constructor(e,n,s){this._bufferService=e,this._optionsService=n,this._oscLinkService=s}provideLinks(e,n){var _;let s=this._bufferService.buffer.lines.get(e-1);if(!s){n(void 0);return}let i=[],l=this._optionsService.rawOptions.linkHandler,c=new wi,u=s.getTrimmedLength(),h=-1,p=-1,v=!1;for(let g=0;g<u;g++)if(!(p===-1&&!s.hasContent(g))){if(s.loadCell(g,c),c.hasExtendedAttrs()&&c.extended.urlId)if(p===-1){p=g,h=c.extended.urlId;continue}else v=c.extended.urlId!==h;else p!==-1&&(v=!0);if(v||p!==-1&&g===u-1){let b=(_=this._oscLinkService.getLinkData(h))==null?void 0:_.uri;if(b){let S={start:{x:p+1,y:e},end:{x:g+(!v&&g===u-1?1:0),y:e}},j=!1;if(!(l!=null&&l.allowNonHttpProtocols))try{let C=new URL(b);["http:","https:"].includes(C.protocol)||(j=!0)}catch{j=!0}j||i.push({text:b,range:S,activate:(C,N)=>l?l.activate(C,N,S):Dj(C,N),hover:(C,N)=>{var E;return(E=l==null?void 0:l.hover)==null?void 0:E.call(l,C,N,S)},leave:(C,N)=>{var E;return(E=l==null?void 0:l.leave)==null?void 0:E.call(l,C,N,S)}})}v=!1,c.hasExtendedAttrs()&&c.extended.urlId?(p=g,h=c.extended.urlId):(p=-1,h=-1)}}n(i)}};Pm=An([ut(0,Os),ut(1,Bs),ut(2,j1)],Pm);function Dj(t,e){if(confirm(`Do you want to navigate to ${e}?
52
+
53
+ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var fh=us("CharSizeService"),Lr=us("CoreBrowserService"),_v=us("MouseService"),Rr=us("RenderService"),Oj=us("SelectionService"),L1=us("CharacterJoinerService"),nl=us("ThemeService"),R1=us("LinkProviderService"),Bj=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?hb.isErrorNoTelemetry(e)?new hb(e.message+`
54
+
55
+ `+e.stack):new Error(e.message+`
56
+
57
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(n=>{n(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)}},$j=new Bj;function wd(t){zj(t)||$j.onUnexpectedError(t)}var Im="Canceled";function zj(t){return t instanceof Fj?!0:t instanceof Error&&t.name===Im&&t.message===Im}var Fj=class extends Error{constructor(){super(Im),this.name=this.message}};function Hj(t){return new Error(`Illegal argument: ${t}`)}var hb=class Dm extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof Dm)return e;let n=new Dm;return n.message=e.message,n.stack=e.stack,n}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},Om=class A1 extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,A1.prototype)}};function ni(t,e=0){return t[t.length-(1+e)]}var Uj;(t=>{function e(l){return l<0}t.isLessThan=e;function n(l){return l<=0}t.isLessThanOrEqual=n;function s(l){return l>0}t.isGreaterThan=s;function i(l){return l===0}t.isNeitherLessOrGreaterThan=i,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(Uj||(Uj={}));function Wj(t,e){let n=this,s=!1,i;return function(){return s||(s=!0,e||(i=t.apply(n,arguments))),i}}var M1;(t=>{function e(x){return x&&typeof x=="object"&&typeof x[Symbol.iterator]=="function"}t.is=e;let n=Object.freeze([]);function s(){return n}t.empty=s;function*i(x){yield x}t.single=i;function l(x){return e(x)?x:i(x)}t.wrap=l;function c(x){return x||n}t.from=c;function*u(x){for(let W=x.length-1;W>=0;W--)yield x[W]}t.reverse=u;function h(x){return!x||x[Symbol.iterator]().next().done===!0}t.isEmpty=h;function p(x){return x[Symbol.iterator]().next().value}t.first=p;function v(x,W){let $=0;for(let J of x)if(W(J,$++))return!0;return!1}t.some=v;function _(x,W){for(let $ of x)if(W($))return $}t.find=_;function*g(x,W){for(let $ of x)W($)&&(yield $)}t.filter=g;function*b(x,W){let $=0;for(let J of x)yield W(J,$++)}t.map=b;function*S(x,W){let $=0;for(let J of x)yield*W(J,$++)}t.flatMap=S;function*j(...x){for(let W of x)yield*W}t.concat=j;function C(x,W,$){let J=$;for(let q of x)J=W(J,q);return J}t.reduce=C;function*N(x,W,$=x.length){for(W<0&&(W+=x.length),$<0?$+=x.length:$>x.length&&($=x.length);W<$;W++)yield x[W]}t.slice=N;function E(x,W=Number.POSITIVE_INFINITY){let $=[];if(W===0)return[$,x];let J=x[Symbol.iterator]();for(let q=0;q<W;q++){let V=J.next();if(V.done)return[$,t.empty()];$.push(V.value)}return[$,{[Symbol.iterator](){return J}}]}t.consume=E;async function O(x){let W=[];for await(let $ of x)W.push($);return Promise.resolve(W)}t.asyncToArray=O})(M1||(M1={}));function Yo(t){if(M1.is(t)){let e=[];for(let n of t)if(n)try{n.dispose()}catch(s){e.push(s)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function qj(...t){return _n(()=>Yo(t))}function _n(t){return{dispose:Wj(()=>{t()})}}var T1=class P1{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{Yo(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?P1.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(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};T1.DISABLE_DISPOSED_WARNING=!1;var lo=T1,Ft=class{constructor(){this._store=new lo,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)}};Ft.None=Object.freeze({dispose(){}});var Ya=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var n;this._isDisposed||e===this._value||((n=this._value)==null||n.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}},Cr=typeof window=="object"?window:globalThis,Bm=class $m{constructor(e){this.element=e,this.next=$m.Undefined,this.prev=$m.Undefined}};Bm.Undefined=new Bm(void 0);var Sn=Bm,fb=class{constructor(){this._first=Sn.Undefined,this._last=Sn.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Sn.Undefined}clear(){let e=this._first;for(;e!==Sn.Undefined;){let n=e.next;e.prev=Sn.Undefined,e.next=Sn.Undefined,e=n}this._first=Sn.Undefined,this._last=Sn.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,n){let s=new Sn(e);if(this._first===Sn.Undefined)this._first=s,this._last=s;else if(n){let l=this._last;this._last=s,s.prev=l,l.next=s}else{let l=this._first;this._first=s,s.next=l,l.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==Sn.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Sn.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Sn.Undefined&&e.next!==Sn.Undefined){let n=e.prev;n.next=e.next,e.next.prev=n}else e.prev===Sn.Undefined&&e.next===Sn.Undefined?(this._first=Sn.Undefined,this._last=Sn.Undefined):e.next===Sn.Undefined?(this._last=this._last.prev,this._last.next=Sn.Undefined):e.prev===Sn.Undefined&&(this._first=this._first.next,this._first.prev=Sn.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Sn.Undefined;)yield e.element,e=e.next}},Kj=globalThis.performance&&typeof globalThis.performance.now=="function",Vj=class I1{static create(e){return new I1(e)}constructor(e){this._now=Kj&&e===!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}},_s;(t=>{t.None=()=>Ft.None;function e(B,I){return _(B,()=>{},0,void 0,!0,void 0,I)}t.defer=e;function n(B){return(I,D=null,T)=>{let z=!1,R;return R=B(M=>{if(!z)return R?R.dispose():z=!0,I.call(D,M)},null,T),z&&R.dispose(),R}}t.once=n;function s(B,I,D){return p((T,z=null,R)=>B(M=>T.call(z,I(M)),null,R),D)}t.map=s;function i(B,I,D){return p((T,z=null,R)=>B(M=>{I(M),T.call(z,M)},null,R),D)}t.forEach=i;function l(B,I,D){return p((T,z=null,R)=>B(M=>I(M)&&T.call(z,M),null,R),D)}t.filter=l;function c(B){return B}t.signal=c;function u(...B){return(I,D=null,T)=>{let z=qj(...B.map(R=>R(M=>I.call(D,M))));return v(z,T)}}t.any=u;function h(B,I,D,T){let z=D;return s(B,R=>(z=I(z,R),z),T)}t.reduce=h;function p(B,I){let D,T={onWillAddFirstListener(){D=B(z.fire,z)},onDidRemoveLastListener(){D==null||D.dispose()}},z=new it(T);return I==null||I.add(z),z.event}function v(B,I){return I instanceof Array?I.push(B):I&&I.add(B),B}function _(B,I,D=100,T=!1,z=!1,R,M){let L,H,A,U=0,Q,ae={leakWarningThreshold:R,onWillAddFirstListener(){L=B(je=>{U++,H=I(H,je),T&&!A&&(re.fire(H),H=void 0),Q=()=>{let te=H;H=void 0,A=void 0,(!T||U>1)&&re.fire(te),U=0},typeof D=="number"?(clearTimeout(A),A=setTimeout(Q,D)):A===void 0&&(A=0,queueMicrotask(Q))})},onWillRemoveListener(){z&&U>0&&(Q==null||Q())},onDidRemoveLastListener(){Q=void 0,L.dispose()}},re=new it(ae);return M==null||M.add(re),re.event}t.debounce=_;function g(B,I=0,D){return t.debounce(B,(T,z)=>T?(T.push(z),T):[z],I,void 0,!0,void 0,D)}t.accumulate=g;function b(B,I=(T,z)=>T===z,D){let T=!0,z;return l(B,R=>{let M=T||!I(R,z);return T=!1,z=R,M},D)}t.latch=b;function S(B,I,D){return[t.filter(B,I,D),t.filter(B,T=>!I(T),D)]}t.split=S;function j(B,I=!1,D=[],T){let z=D.slice(),R=B(H=>{z?z.push(H):L.fire(H)});T&&T.add(R);let M=()=>{z==null||z.forEach(H=>L.fire(H)),z=null},L=new it({onWillAddFirstListener(){R||(R=B(H=>L.fire(H)),T&&T.add(R))},onDidAddFirstListener(){z&&(I?setTimeout(M):M())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return T&&T.add(L),L.event}t.buffer=j;function C(B,I){return(D,T,z)=>{let R=I(new E);return B(function(M){let L=R.evaluate(M);L!==N&&D.call(T,L)},void 0,z)}}t.chain=C;let N=Symbol("HaltChainable");class E{constructor(){this.steps=[]}map(I){return this.steps.push(I),this}forEach(I){return this.steps.push(D=>(I(D),D)),this}filter(I){return this.steps.push(D=>I(D)?D:N),this}reduce(I,D){let T=D;return this.steps.push(z=>(T=I(T,z),T)),this}latch(I=(D,T)=>D===T){let D=!0,T;return this.steps.push(z=>{let R=D||!I(z,T);return D=!1,T=z,R?z:N}),this}evaluate(I){for(let D of this.steps)if(I=D(I),I===N)break;return I}}function O(B,I,D=T=>T){let T=(...L)=>M.fire(D(...L)),z=()=>B.on(I,T),R=()=>B.removeListener(I,T),M=new it({onWillAddFirstListener:z,onDidRemoveLastListener:R});return M.event}t.fromNodeEventEmitter=O;function x(B,I,D=T=>T){let T=(...L)=>M.fire(D(...L)),z=()=>B.addEventListener(I,T),R=()=>B.removeEventListener(I,T),M=new it({onWillAddFirstListener:z,onDidRemoveLastListener:R});return M.event}t.fromDOMEventEmitter=x;function W(B){return new Promise(I=>n(B)(I))}t.toPromise=W;function $(B){let I=new it;return B.then(D=>{I.fire(D)},()=>{I.fire(void 0)}).finally(()=>{I.dispose()}),I.event}t.fromPromise=$;function J(B,I){return B(D=>I.fire(D))}t.forward=J;function q(B,I,D){return I(D),B(T=>I(T))}t.runAndSubscribe=q;class V{constructor(I,D){this._observable=I,this._counter=0,this._hasChanged=!1;let T={onWillAddFirstListener:()=>{I.addObserver(this)},onDidRemoveLastListener:()=>{I.removeObserver(this)}};this.emitter=new it(T),D&&D.add(this.emitter)}beginUpdate(I){this._counter++}handlePossibleChange(I){}handleChange(I,D){this._hasChanged=!0}endUpdate(I){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ie(B,I){return new V(B,I).emitter.event}t.fromObservable=ie;function K(B){return(I,D,T)=>{let z=0,R=!1,M={beginUpdate(){z++},endUpdate(){z--,z===0&&(B.reportChanges(),R&&(R=!1,I.call(D)))},handlePossibleChange(){},handleChange(){R=!0}};B.addObserver(M),B.reportChanges();let L={dispose(){B.removeObserver(M)}};return T instanceof lo?T.add(L):Array.isArray(T)&&T.push(L),L}}t.fromObservableLight=K})(_s||(_s={}));var zm=class Fm{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${Fm._idPool++}`,Fm.all.add(this)}start(e){this._stopWatch=new Vj,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};zm.all=new Set,zm._idPool=0;var Yj=zm,Gj=-1,D1=class O1{constructor(e,n,s=(O1._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var e;(e=this._stacks)==null||e.clear()}check(e,n){let s=this.threshold;if(s<=0||n<s)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[l,c]=this.getMostFrequentStack(),u=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${c}):`;console.warn(u),console.warn(l);let h=new Qj(u,l);this._errorHandler(h)}return()=>{let l=this._stacks.get(e.value)||0;this._stacks.set(e.value,l-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,n=0;for(let[s,i]of this._stacks)(!e||n<i)&&(e=[s,i],n=i);return e}};D1._idPool=1;var Xj=D1,Jj=class B1{constructor(e){this.value=e}static create(){let e=new Error;return new B1(e.stack??"")}print(){console.warn(this.value.split(`
58
+ `).slice(2).join(`
59
+ `))}},Qj=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},Zj=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},eL=0,ap=class{constructor(e){this.value=e,this.id=eL++}},tL=2,nL,it=class{constructor(t){var e,n,s,i;this._size=0,this._options=t,this._leakageMon=(e=this._options)!=null&&e.leakWarningThreshold?new Xj((t==null?void 0:t.onListenerError)??wd,((n=this._options)==null?void 0:n.leakWarningThreshold)??Gj):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new Yj(this._options._profName):void 0,this._deliveryQueue=(i=this._options)==null?void 0:i.deliveryQueue}dispose(){var t,e,n,s;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(e=this._options)==null?void 0:e.onDidRemoveLastListener)==null||n.call(e),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(t,e,n)=>{var c,u,h,p,v;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let _=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(_);let g=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],b=new Zj(`${_}. HINT: Stack shows most frequent listener (${g[1]}-times)`,g[0]);return(((c=this._options)==null?void 0:c.onListenerError)||wd)(b),Ft.None}if(this._disposed)return Ft.None;e&&(t=t.bind(e));let s=new ap(t),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Jj.create(),i=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof ap?(this._deliveryQueue??(this._deliveryQueue=new sL),this._listeners=[this._listeners,s]):this._listeners.push(s):((h=(u=this._options)==null?void 0:u.onWillAddFirstListener)==null||h.call(u,this),this._listeners=s,(v=(p=this._options)==null?void 0:p.onDidAddFirstListener)==null||v.call(p,this)),this._size++;let l=_n(()=>{i==null||i(),this._removeListener(s)});return n instanceof lo?n.add(l):Array.isArray(n)&&n.push(l),l}),this._event}_removeListener(t){var i,l,c,u;if((l=(i=this._options)==null?void 0:i.onWillRemoveListener)==null||l.call(i,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(u=(c=this._options)==null?void 0:c.onDidRemoveLastListener)==null||u.call(c,this),this._size=0;return}let e=this._listeners,n=e.indexOf(t);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--,e[n]=void 0;let s=this._deliveryQueue.current===this;if(this._size*tL<=e.length){let h=0;for(let p=0;p<e.length;p++)e[p]?e[h++]=e[p]:s&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=h}}_deliver(t,e){var s;if(!t)return;let n=((s=this._options)==null?void 0:s.onListenerError)||wd;if(!n){t.value(e);return}try{t.value(e)}catch(i){n(i)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){var e,n,s,i;if((e=this._deliveryQueue)!=null&&e.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 ap)this._deliver(this._listeners,t);else{let l=this._deliveryQueue;l.enqueue(this,t,this._listeners.length),this._deliverQueue(l)}(i=this._perfMon)==null||i.stop()}hasListeners(){return this._size>0}},sL=class{constructor(){this.i=-1,this.end=0}enqueue(e,n,s){this.i=0,this.end=s,this.current=e,this.value=n}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Hm=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new it,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new it,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,n){if(this.getZoomLevel(n)===e)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),e)}setFullscreen(e,n){if(this.isFullscreen(n)===e)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Hm.INSTANCE=new Hm;var yv=Hm;function iL(t,e,n){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",n)}yv.INSTANCE.onDidChangeZoomLevel;function rL(t){return yv.INSTANCE.getZoomFactor(t)}yv.INSTANCE.onDidChangeFullscreen;var sl=typeof navigator=="object"?navigator.userAgent:"",Um=sl.indexOf("Firefox")>=0,oL=sl.indexOf("AppleWebKit")>=0,wv=sl.indexOf("Chrome")>=0,aL=!wv&&sl.indexOf("Safari")>=0;sl.indexOf("Electron/")>=0;sl.indexOf("Android")>=0;var lp=!1;if(typeof Cr.matchMedia=="function"){let t=Cr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=Cr.matchMedia("(display-mode: fullscreen)");lp=t.matches,iL(Cr,t,({matches:n})=>{lp&&e.matches||(lp=n)})}var $a="en",Wm=!1,qm=!1,bd=!1,$1=!1,Zu,Sd=$a,pb=$a,lL,Ri,Fo=globalThis,gs,Ox;typeof Fo.vscode<"u"&&typeof Fo.vscode.process<"u"?gs=Fo.vscode.process:typeof process<"u"&&typeof((Ox=process==null?void 0:process.versions)==null?void 0:Ox.node)=="string"&&(gs=process);var Bx,cL=typeof((Bx=gs==null?void 0:gs.versions)==null?void 0:Bx.electron)=="string",uL=cL&&(gs==null?void 0:gs.type)==="renderer",$x;if(typeof gs=="object"){Wm=gs.platform==="win32",qm=gs.platform==="darwin",bd=gs.platform==="linux",bd&&gs.env.SNAP&&gs.env.SNAP_REVISION,gs.env.CI||gs.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Zu=$a,Sd=$a;let t=gs.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Zu=e.userLocale,pb=e.osLocale,Sd=e.resolvedLanguage||$a,lL=($x=e.languagePack)==null?void 0:$x.translationsConfigFile}catch{}$1=!0}else typeof navigator=="object"&&!uL?(Ri=navigator.userAgent,Wm=Ri.indexOf("Windows")>=0,qm=Ri.indexOf("Macintosh")>=0,(Ri.indexOf("Macintosh")>=0||Ri.indexOf("iPad")>=0||Ri.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,bd=Ri.indexOf("Linux")>=0,(Ri==null?void 0:Ri.indexOf("Mobi"))>=0,Sd=globalThis._VSCODE_NLS_LANGUAGE||$a,Zu=navigator.language.toLowerCase(),pb=Zu):console.error("Unable to resolve platform.");var z1=Wm,Zi=qm,dL=bd,mb=$1,tr=Ri,Vr=Sd,hL;(t=>{function e(){return Vr}t.value=e;function n(){return Vr.length===2?Vr==="en":Vr.length>=3?Vr[0]==="e"&&Vr[1]==="n"&&Vr[2]==="-":!1}t.isDefaultVariant=n;function s(){return Vr==="en"}t.isDefault=s})(hL||(hL={}));var fL=typeof Fo.postMessage=="function"&&!Fo.importScripts;(()=>{if(fL){let t=[];Fo.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,i=t.length;s<i;s++){let l=t[s];if(l.id===n.data.vscodeScheduleAsyncWork){t.splice(s,1),l.callback();return}}});let e=0;return n=>{let s=++e;t.push({id:s,callback:n}),Fo.postMessage({vscodeScheduleAsyncWork:s},"*")}}return t=>setTimeout(t)})();var pL=!!(tr&&tr.indexOf("Chrome")>=0);tr&&tr.indexOf("Firefox")>=0;!pL&&tr&&tr.indexOf("Safari")>=0;tr&&tr.indexOf("Edg/")>=0;tr&&tr.indexOf("Android")>=0;var ja=typeof navigator=="object"?navigator:{};mb||document.queryCommandSupported&&document.queryCommandSupported("copy")||ja&&ja.clipboard&&ja.clipboard.writeText,mb||ja&&ja.clipboard&&ja.clipboard.readText;var bv=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,n){this._keyCodeToStr[e]=n,this._strToKeyCode[n.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},cp=new bv,gb=new bv,vb=new bv,mL=new Array(230),F1;(t=>{function e(u){return cp.keyCodeToStr(u)}t.toString=e;function n(u){return cp.strToKeyCode(u)}t.fromString=n;function s(u){return gb.keyCodeToStr(u)}t.toUserSettingsUS=s;function i(u){return vb.keyCodeToStr(u)}t.toUserSettingsGeneral=i;function l(u){return gb.strToKeyCode(u)||vb.strToKeyCode(u)}t.fromUserSettings=l;function c(u){if(u>=98&&u<=113)return null;switch(u){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return cp.keyCodeToStr(u)}t.toElectronAccelerator=c})(F1||(F1={}));var gL=class H1{constructor(e,n,s,i,l){this.ctrlKey=e,this.shiftKey=n,this.altKey=s,this.metaKey=i,this.keyCode=l}equals(e){return e instanceof H1&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${e}${n}${s}${i}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new vL([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},vL=class{constructor(t){if(t.length===0)throw Hj("chords");this.chords=t}getHashCode(){let t="";for(let e=0,n=this.chords.length;e<n;e++)e!==0&&(t+=";"),t+=this.chords[e].getHashCode();return t}equals(t){if(t===null||this.chords.length!==t.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(t.chords[e]))return!1;return!0}};function _L(t){if(t.charCode){let n=String.fromCharCode(t.charCode).toUpperCase();return F1.fromString(n)}let e=t.keyCode;if(e===3)return 7;if(Um)switch(e){case 59:return 85;case 60:if(dL)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Zi)return 57;break}else if(oL&&(Zi&&e===93||!Zi&&e===92))return 57;return mL[e]||0}var yL=Zi?256:2048,wL=512,bL=1024,SL=Zi?2048:256,_b=class{constructor(t){var n;this._standardKeyboardEventBrand=!0;let e=t;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=(n=e.getModifierState)==null?void 0:n.call(e,"AltGraph"),this.keyCode=_L(e),this.code=e.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(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode);let e=0;return this.ctrlKey&&(e|=yL),this.altKey&&(e|=wL),this.shiftKey&&(e|=bL),this.metaKey&&(e|=SL),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new gL(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},yb=new WeakMap;function xL(t){if(!t.parent||t.parent===t)return null;try{let e=t.location,n=t.parent.location;if(e.origin!=="null"&&n.origin!=="null"&&e.origin!==n.origin)return null}catch{return null}return t.parent}var kL=class{static getSameOriginWindowChain(t){let e=yb.get(t);if(!e){e=[],yb.set(t,e);let n=t,s;do s=xL(n),s?e.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):e.push({window:new WeakRef(n),iframeElement:null}),n=s;while(n)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let n=0,s=0,i=this.getSameOriginWindowChain(t);for(let l of i){let c=l.window.deref();if(n+=(c==null?void 0:c.scrollY)??0,s+=(c==null?void 0:c.scrollX)??0,c===e||!l.iframeElement)break;let u=l.iframeElement.getBoundingClientRect();n+=u.top,s+=u.left}return{top:n,left:s}}},ed=class{constructor(e,n){this.timestamp=Date.now(),this.browserEvent=n,this.leftButton=n.button===0,this.middleButton=n.button===1,this.rightButton=n.button===2,this.buttons=n.buttons,this.target=n.target,this.detail=n.detail||1,n.type==="dblclick"&&(this.detail=2),this.ctrlKey=n.ctrlKey,this.shiftKey=n.shiftKey,this.altKey=n.altKey,this.metaKey=n.metaKey,typeof n.pageX=="number"?(this.posx=n.pageX,this.posy=n.pageY):(this.posx=n.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=n.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=kL.getPositionOfChildWindowRelativeToAncestorWindow(e,n.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},wb=class{constructor(e,n=0,s=0){var l;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=n;let i=!1;if(wv){let c=navigator.userAgent.match(/Chrome\/(\d+)/);i=(c?parseInt(c[1]):123)<=122}if(e){let c=e,u=e,h=((l=e.view)==null?void 0:l.devicePixelRatio)||1;if(typeof c.wheelDeltaY<"u")i?this.deltaY=c.wheelDeltaY/(120*h):this.deltaY=c.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 p=e;p.deltaMode===p.DOM_DELTA_LINE?Um&&!Zi?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof c.wheelDeltaX<"u")aL&&z1?this.deltaX=-(c.wheelDeltaX/120):i?this.deltaX=c.wheelDeltaX/(120*h):this.deltaX=c.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 p=e;p.deltaMode===p.DOM_DELTA_LINE?Um&&!Zi?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?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()}},U1=Object.freeze(function(t,e){let n=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(n)}}}),CL;(t=>{function e(n){return n===t.None||n===t.Cancelled||n instanceof EL?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:_s.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:U1})})(CL||(CL={}));var EL=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?U1:(this._emitter||(this._emitter=new it),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Sv=class{constructor(e,n){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof n=="number"&&this.setIfNotSet(e,n)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,n){if(this._isDisposed)throw new Om("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},n)}setIfNotSet(e,n){if(this._isDisposed)throw new Om("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},n))}},NL=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,n,s=globalThis){if(this.isDisposed)throw new Om("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},n);this.disposable=_n(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},jL;(t=>{async function e(s){let i,l=await Promise.all(s.map(c=>c.then(u=>u,u=>{i||(i=u)})));if(typeof i<"u")throw i;return l}t.settled=e;function n(s){return new Promise(async(i,l)=>{try{await s(i,l)}catch(c){l(c)}})}t.withAsyncBody=n})(jL||(jL={}));var bb=class fi{static fromArray(e){return new fi(n=>{n.emitMany(e)})}static fromPromise(e){return new fi(async n=>{n.emitMany(await e)})}static fromPromises(e){return new fi(async n=>{await Promise.all(e.map(async s=>n.emitOne(await s)))})}static merge(e){return new fi(async n=>{await Promise.all(e.map(async s=>{for await(let i of s)n.emitOne(i)}))})}constructor(e,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new it,queueMicrotask(async()=>{let s={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(e(s)),this.resolve()}catch(i){this.reject(i)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await _s.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(e,n){return new fi(async s=>{for await(let i of e)s.emitOne(n(i))})}map(e){return fi.map(this,e)}static filter(e,n){return new fi(async s=>{for await(let i of e)n(i)&&s.emitOne(i)})}filter(e){return fi.filter(this,e)}static coalesce(e){return fi.filter(e,n=>!!n)}coalesce(){return fi.coalesce(this)}static async toPromise(e){let n=[];for await(let s of e)n.push(s);return n}toPromise(){return fi.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};bb.EMPTY=bb.fromArray([]);var{getWindow:Qi,getWindowId:LL,onDidRegisterWindow:RL}=(function(){let t=new Map,e={window:Cr,disposables:new lo};t.set(Cr.vscodeWindowId,e);let n=new it,s=new it,i=new it;function l(c,u){return(typeof c=="number"?t.get(c):void 0)??(u?e:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:s.event,registerWindow(c){if(t.has(c.vscodeWindowId))return Ft.None;let u=new lo,h={window:c,disposables:u.add(new lo)};return t.set(c.vscodeWindowId,h),u.add(_n(()=>{t.delete(c.vscodeWindowId),s.fire(c)})),u.add(Tt(c,ss.BEFORE_UNLOAD,()=>{i.fire(c)})),n.fire(h),u},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return t.has(c)},getWindowById:l,getWindow(c){var p;let u=c;if((p=u==null?void 0:u.ownerDocument)!=null&&p.defaultView)return u.ownerDocument.defaultView.window;let h=c;return h!=null&&h.view?h.view.window:Cr},getDocument(c){return Qi(c).document}}})(),AL=class{constructor(e,n,s,i){this._node=e,this._type=n,this._handler=s,this._options=i||!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 Tt(t,e,n,s){return new AL(t,e,n,s)}var Sb=function(t,e,n,s){return Tt(t,e,n,s)},xv,ML=class extends NL{constructor(t){super(),this.defaultTarget=t&&Qi(t)}cancelAndSet(t,e,n){return super.cancelAndSet(t,e,n??this.defaultTarget)}},xb=class{constructor(e,n=0){this._runner=e,this.priority=n,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){wd(e)}}static sort(e,n){return n.priority-e.priority}};(function(){let t=new Map,e=new Map,n=new Map,s=new Map,i=l=>{n.set(l,!1);let c=t.get(l)??[];for(e.set(l,c),t.set(l,[]),s.set(l,!0);c.length>0;)c.sort(xb.sort),c.shift().execute();s.set(l,!1)};xv=(l,c,u=0)=>{let h=LL(l),p=new xb(c,u),v=t.get(h);return v||(v=[],t.set(h,v)),v.push(p),n.get(h)||(n.set(h,!0),l.requestAnimationFrame(()=>i(h))),p}})();function TL(t){let e=t.getBoundingClientRect(),n=Qi(t);return{left:e.left+n.scrollX,top:e.top+n.scrollY,width:e.width,height:e.height}}var ss={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"},PL=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let n=Ys(e);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let n=Ys(e);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(e){let n=Ys(e);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(e){let n=Ys(e);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(e){let n=Ys(e);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(e){let n=Ys(e);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(e){let n=Ys(e);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(e){let n=Ys(e);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let n=Ys(e);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let n=Ys(e);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let n=Ys(e);this._paddingRight!==n&&(this._paddingRight=n,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let n=Ys(e);this._fontSize!==n&&(this._fontSize=n,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let n=Ys(e);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let n=Ys(e);this._letterSpacing!==n&&(this._letterSpacing=n,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,n){this.domNode.classList.toggle(e,n),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,n){this.domNode.setAttribute(e,n)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Ys(t){return typeof t=="number"?`${t}px`:t}function yc(t){return new PL(t)}var W1=class{constructor(){this._hooks=new lo,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,n){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(n)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,n,s,i,l){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=l;let c=e;try{e.setPointerCapture(n),this._hooks.add(_n(()=>{try{e.releasePointerCapture(n)}catch{}}))}catch{c=Qi(e)}this._hooks.add(Tt(c,ss.POINTER_MOVE,u=>{if(u.buttons!==s){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(Tt(c,ss.POINTER_UP,u=>this.stopMonitoring(!0)))}};function IL(t,e,n){let s=null,i=null;if(typeof n.value=="function"?(s="value",i=n.value,i.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",i=n.get),!i)throw new Error("not supported");let l=`$memoize$${e}`;n[s]=function(...c){return this.hasOwnProperty(l)||Object.defineProperty(this,l,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,c)}),this[l]}}var Ki;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(Ki||(Ki={}));var uc=class js extends Ft{constructor(){super(),this.dispatched=!1,this.targets=new fb,this.ignoreTargets=new fb,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(_s.runAndSubscribe(RL,({window:e,disposables:n})=>{n.add(Tt(e.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Tt(e.document,"touchend",s=>this.onTouchEnd(e,s))),n.add(Tt(e.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Cr,disposables:this._store}))}static addTarget(e){if(!js.isTouchDevice())return Ft.None;js.INSTANCE||(js.INSTANCE=new js);let n=js.INSTANCE.targets.push(e);return _n(n)}static ignoreTarget(e){if(!js.isTouchDevice())return Ft.None;js.INSTANCE||(js.INSTANCE=new js);let n=js.INSTANCE.ignoreTargets.push(e);return _n(n)}static isTouchDevice(){return"ontouchstart"in Cr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,i=e.targetTouches.length;s<i;s++){let l=e.targetTouches.item(s);this.activeTouches[l.identifier]={id:l.identifier,initialTarget:l.target,initialTimeStamp:n,initialPageX:l.pageX,initialPageY:l.pageY,rollingTimestamps:[n],rollingPageX:[l.pageX],rollingPageY:[l.pageY]};let c=this.newGestureEvent(Ki.Start,l.target);c.pageX=l.pageX,c.pageY=l.pageY,this.dispatchEvent(c)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,n){let s=Date.now(),i=Object.keys(this.activeTouches).length;for(let l=0,c=n.changedTouches.length;l<c;l++){let u=n.changedTouches.item(l);if(!this.activeTouches.hasOwnProperty(String(u.identifier))){console.warn("move of an UNKNOWN touch",u);continue}let h=this.activeTouches[u.identifier],p=Date.now()-h.initialTimeStamp;if(p<js.HOLD_DELAY&&Math.abs(h.initialPageX-ni(h.rollingPageX))<30&&Math.abs(h.initialPageY-ni(h.rollingPageY))<30){let v=this.newGestureEvent(Ki.Tap,h.initialTarget);v.pageX=ni(h.rollingPageX),v.pageY=ni(h.rollingPageY),this.dispatchEvent(v)}else if(p>=js.HOLD_DELAY&&Math.abs(h.initialPageX-ni(h.rollingPageX))<30&&Math.abs(h.initialPageY-ni(h.rollingPageY))<30){let v=this.newGestureEvent(Ki.Contextmenu,h.initialTarget);v.pageX=ni(h.rollingPageX),v.pageY=ni(h.rollingPageY),this.dispatchEvent(v)}else if(i===1){let v=ni(h.rollingPageX),_=ni(h.rollingPageY),g=ni(h.rollingTimestamps)-h.rollingTimestamps[0],b=v-h.rollingPageX[0],S=_-h.rollingPageY[0],j=[...this.targets].filter(C=>h.initialTarget instanceof Node&&C.contains(h.initialTarget));this.inertia(e,j,s,Math.abs(b)/g,b>0?1:-1,v,Math.abs(S)/g,S>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(Ki.End,h.initialTarget)),delete this.activeTouches[u.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,n){let s=document.createEvent("CustomEvent");return s.initEvent(e,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(e){if(e.type===Ki.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>js.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,e.tapCount=s}else(e.type===Ki.Change||e.type===Ki.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(e.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(e.initialTarget)){let i=0,l=e.initialTarget;for(;l&&l!==s;)i++,l=l.parentElement;n.push([i,s])}n.sort((s,i)=>s[0]-i[0]);for(let[s,i]of n)i.dispatchEvent(e),this.dispatched=!0}}inertia(e,n,s,i,l,c,u,h,p){this.handle=xv(e,()=>{let v=Date.now(),_=v-s,g=0,b=0,S=!0;i+=js.SCROLL_FRICTION*_,u+=js.SCROLL_FRICTION*_,i>0&&(S=!1,g=l*i*_),u>0&&(S=!1,b=h*u*_);let j=this.newGestureEvent(Ki.Change);j.translationX=g,j.translationY=b,n.forEach(C=>C.dispatchEvent(j)),S||this.inertia(e,n,v,i,l,c+g,u,h,p+b)})}onTouchMove(e){let n=Date.now();for(let s=0,i=e.changedTouches.length;s<i;s++){let l=e.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("end of an UNKNOWN touch",l);continue}let c=this.activeTouches[l.identifier],u=this.newGestureEvent(Ki.Change,c.initialTarget);u.translationX=l.pageX-ni(c.rollingPageX),u.translationY=l.pageY-ni(c.rollingPageY),u.pageX=l.pageX,u.pageY=l.pageY,this.dispatchEvent(u),c.rollingPageX.length>3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(l.pageX),c.rollingPageY.push(l.pageY),c.rollingTimestamps.push(n)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};uc.SCROLL_FRICTION=-.005,uc.HOLD_DELAY=700,uc.CLEAR_TAP_COUNT_TIME=400,An([IL],uc,"isTouchDevice",1);var DL=uc,kv=class extends Ft{onclick(e,n){this._register(Tt(e,ss.CLICK,s=>n(new ed(Qi(e),s))))}onmousedown(e,n){this._register(Tt(e,ss.MOUSE_DOWN,s=>n(new ed(Qi(e),s))))}onmouseover(e,n){this._register(Tt(e,ss.MOUSE_OVER,s=>n(new ed(Qi(e),s))))}onmouseleave(e,n){this._register(Tt(e,ss.MOUSE_LEAVE,s=>n(new ed(Qi(e),s))))}onkeydown(e,n){this._register(Tt(e,ss.KEY_DOWN,s=>n(new _b(s))))}onkeyup(e,n){this._register(Tt(e,ss.KEY_UP,s=>n(new _b(s))))}oninput(e,n){this._register(Tt(e,ss.INPUT,n))}onblur(e,n){this._register(Tt(e,ss.BLUR,n))}onfocus(e,n){this._register(Tt(e,ss.FOCUS,n))}onchange(e,n){this._register(Tt(e,ss.CHANGE,n))}ignoreGesture(e){return DL.ignoreTarget(e)}},kb=11,OL=class extends kv{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=kb+"px",this.domNode.style.height=kb+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new W1),this._register(Sb(this.bgDomNode,ss.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(Sb(this.domNode,ss.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new ML),this._pointerdownScheduleRepeatTimer=this._register(new Sv)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Qi(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},BL=class Km{constructor(e,n,s,i,l,c,u){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,i=i|0,l=l|0,c=c|0,u=u|0),this.rawScrollLeft=i,this.rawScrollTop=u,n<0&&(n=0),i+n>s&&(i=s-n),i<0&&(i=0),l<0&&(l=0),u+l>c&&(u=c-l),u<0&&(u=0),this.width=n,this.scrollWidth=s,this.scrollLeft=i,this.height=l,this.scrollHeight=c,this.scrollTop=u}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,n){return new Km(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new Km(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,n){let s=this.width!==e.width,i=this.scrollWidth!==e.scrollWidth,l=this.scrollLeft!==e.scrollLeft,c=this.height!==e.height,u=this.scrollHeight!==e.scrollHeight,h=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:n,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:i,scrollLeftChanged:l,heightChanged:c,scrollHeightChanged:u,scrollTopChanged:h}}},$L=class extends Ft{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new it),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new BL(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){var s;let n=this._state.withScrollDimensions(t,e);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(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let n=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;e?s=new Eb(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(t);this._smoothScrolling=Eb.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 t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let n=this._state;n.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(n,e)))}},Cb=class{constructor(e,n,s){this.scrollLeft=e,this.scrollTop=n,this.isDone=s}};function up(t,e){let n=e-t;return function(s){return t+n*HL(s)}}function zL(t,e,n){return function(s){return s<n?t(s/n):e((s-n)/(1-n))}}var Eb=class Vm{constructor(e,n,s,i){this.from=e,this.to=n,this.duration=i,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(e,n,s){if(Math.abs(e-n)>2.5*s){let i,l;return e<n?(i=e+.75*s,l=n-.75*s):(i=e-.75*s,l=n+.75*s),zL(up(e,i),up(l,n),.33)}return up(e,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let n=(e-this.startTime)/this.duration;if(n<1){let s=this.scrollLeft(n),i=this.scrollTop(n);return new Cb(s,i,!1)}return new Cb(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,n,s){return Vm.start(e,n,s)}static start(e,n,s){s=s+10;let i=Date.now()-10;return new Vm(e,n,i,s)}};function FL(t){return Math.pow(t,3)}function HL(t){return 1-FL(1-t)}var UL=class extends Ft{constructor(e,n,s){super(),this._visibility=e,this._visibleClassName=n,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Sv)}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 n;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(n=this._domNode)==null||n.setClassName(this._invisibleClassName+(e?" fade":"")))}},WL=140,q1=class extends kv{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 UL(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new W1),this._shouldRender=!0,this.domNode=yc(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(Tt(this.domNode.domNode,ss.POINTER_DOWN,n=>this._domNodePointerDown(n)))}_createArrow(e){let n=this._register(new OL(e));this.domNode.domNode.appendChild(n.bgDomNode),this.domNode.domNode.appendChild(n.domNode)}_createSlider(e,n,s,i){this.slider=yc(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(n),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Tt(this.slider.domNode,ss.POINTER_DOWN,l=>{l.button===0&&(l.preventDefault(),this._sliderPointerDown(l))})),this.onclick(this.slider.domNode,l=>{l.leftButton&&l.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let n=this.domNode.domNode.getClientRects()[0].top,s=n+this._scrollbarState.getSliderPosition(),i=n+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),l=this._sliderPointerPosition(e);s<=l&&l<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let n,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")n=e.offsetX,s=e.offsetY;else{let l=TL(this.domNode.domNode);n=e.pageX-l.left,s=e.pageY-l.top}let i=this._pointerDownRelativePosition(n,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let n=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,l=>{let c=this._sliderOrthogonalPointerPosition(l),u=Math.abs(c-s);if(z1&&u>WL){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let h=this._sliderPointerPosition(l)-n;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(h))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let n={};this.writeScrollPosition(n,e),this._scrollable.setScrollPositionNow(n)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},K1=class Ym{constructor(e,n,s,i,l,c){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(e),this._visibleSize=i,this._scrollSize=l,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Ym(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let n=Math.round(e);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(e){let n=Math.round(e);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let n=Math.round(e);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,n,s,i,l){let c=Math.max(0,s-e),u=Math.max(0,c-2*n),h=i>0&&i>s;if(!h)return{computedAvailableSize:Math.round(c),computedIsNeeded:h,computedSliderSize:Math.round(u),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(s*u/i))),v=(u-p)/(i-s),_=l*v;return{computedAvailableSize:Math.round(c),computedIsNeeded:h,computedSliderSize:Math.round(p),computedSliderRatio:v,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let e=Ym._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.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(e){if(!this._computedIsNeeded)return 0;let n=e-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let n=e-this._arrowSize,s=this._scrollPosition;return n<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+e;return Math.round(n/this._computedSliderRatio)}},qL=class extends q1{constructor(e,n,s){let i=e.getScrollDimensions(),l=e.getCurrentScrollPosition();if(super({lazyRender:n.lazyRender,host:s,scrollbarState:new K1(n.horizontalHasArrows?n.arrowSize:0,n.horizontal===2?0:n.horizontalScrollbarSize,n.vertical===2?0:n.verticalScrollbarSize,i.width,i.scrollWidth,l.scrollLeft),visibility:n.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:n.scrollByPage}),n.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((n.horizontalScrollbarSize-n.horizontalSliderSize)/2),0,void 0,n.horizontalSliderSize)}_updateSlider(e,n){this.slider.setWidth(e),this.slider.setLeft(n)}_renderDomNode(e,n){this.domNode.setWidth(e),this.domNode.setHeight(n),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,n){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,n){e.scrollLeft=n}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}},KL=class extends q1{constructor(t,e,n){let s=t.getScrollDimensions(),i=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:n,scrollbarState:new K1(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,s.height,s.scrollHeight,i.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(t,e){this.slider.setHeight(t),this.slider.setTop(e)}_renderDomNode(t,e){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(t.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return e}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,e){t.scrollTop=e}updateOptions(t){this.updateScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},VL=500,Nb=50,YL=class{constructor(e,n,s){this.timestamp=e,this.deltaX=n,this.deltaY=s,this.score=0}},Gm=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,n=0,s=1,i=this._rear;do{let l=i===this._front?e:Math.pow(2,-s);if(e-=l,n+=this._memory[i].score*l,i===this._front)break;i=(this._capacity+i-1)%this._capacity,s++}while(!0);return n<=.5}acceptStandardWheelEvent(e){if(wv){let n=Qi(e.browserEvent),s=rL(n);this.accept(Date.now(),e.deltaX*s,e.deltaY*s)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,n,s){let i=null,l=new YL(e,n,s);this._front===-1&&this._rear===-1?(this._memory[0]=l,this._front=0,this._rear=0):(i=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]=l),l.score=this._computeScore(l,i)}_computeScore(e,n){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(s+=.25),n){let i=Math.abs(e.deltaX),l=Math.abs(e.deltaY),c=Math.abs(n.deltaX),u=Math.abs(n.deltaY),h=Math.max(Math.min(i,c),1),p=Math.max(Math.min(l,u),1),v=Math.max(i,c),_=Math.max(l,u);v%h===0&&_%p===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Gm.INSTANCE=new Gm;var GL=Gm,XL=class extends kv{constructor(t,e,n){super(),this._onScroll=this._register(new it),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new it),this.onWillScroll=this._onWillScroll.event,this._options=QL(e),this._scrollable=n,this._register(this._scrollable.onScroll(i=>{this._onWillScroll.fire(i),this._onDidScroll(i),this._onScroll.fire(i)}));let s={onMouseWheel:i=>this._onMouseWheel(i),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new KL(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new qL(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(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=yc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=yc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=yc(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,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new Sv),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Yo(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,Zi&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new wb(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=Yo(this._mouseWheelToDispose),t)){let e=n=>{this._onMouseWheel(new wb(n))};this._mouseWheelToDispose.push(Tt(this._listenOnDomNode,ss.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){var i;if((i=t.browserEvent)!=null&&i.defaultPrevented)return;let e=GL.INSTANCE;e.acceptStandardWheelEvent(t);let n=!1;if(t.deltaY||t.deltaX){let l=t.deltaY*this._options.mouseWheelScrollSensitivity,c=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+l===0?c=l=0:Math.abs(l)>=Math.abs(c)?c=0:l=0),this._options.flipAxes&&([l,c]=[c,l]);let u=!Zi&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||u)&&!c&&(c=l,l=0),t.browserEvent&&t.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,l=l*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),p={};if(l){let v=Nb*l,_=h.scrollTop-(v<0?Math.floor(v):Math.ceil(v));this._verticalScrollbar.writeScrollPosition(p,_)}if(c){let v=Nb*c,_=h.scrollLeft-(v<0?Math.floor(v):Math.ceil(v));this._horizontalScrollbar.writeScrollPosition(p,_)}p=this._scrollable.validateScrollPosition(p),(h.scrollLeft!==p.scrollLeft||h.scrollTop!==p.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(p):this._scrollable.setScrollPositionNow(p),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||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 t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,n=t.scrollLeft>0,s=n?" left":"",i=e?" top":"",l=n||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${l}${i}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){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(),VL)}},JL=class extends XL{constructor(e,n,s){super(e,n,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function QL(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,Zi&&(e.className+=" mac"),e}var Xm=class extends Ft{constructor(e,n,s,i,l,c,u,h){super(),this._bufferService=s,this._optionsService=u,this._renderService=h,this._onRequestScrollLines=this._register(new it),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new $L({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:v=>xv(i.window,v)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new JL(n,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(l.onProtocolChange(v=>{this._scrollableElement.updateOptions({handleMouseWheel:!(v&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(_s.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(_n(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),n.appendChild(this._styleElement),this._register(_n(()=>this._styleElement.remove())),this._register(_s.runAndSubscribe(c.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${c.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${c.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${c.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
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(v=>this._handleScroll(v)))}scrollLines(e){let n=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:n.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,n){n&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!n,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 n=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=n-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=n,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Xm=An([ut(2,Os),ut(3,Lr),ut(4,E1),ut(5,nl),ut(6,Bs),ut(7,Rr)],Xm);var Jm=class extends Ft{constructor(e,n,s,i,l){super(),this._screenElement=e,this._bufferService=n,this._coreBrowserService=s,this._decorationService=i,this._renderService=l,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(c=>this._removeDecoration(c))),this._register(_n(()=>{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 i;let n=this._coreBrowserService.mainDocument.createElement("div");n.classList.add("xterm-decoration"),n.classList.toggle("xterm-decoration-top-layer",((i=e==null?void 0:e.options)==null?void 0:i.layer)==="top"),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=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(n.style.display="none"),this._refreshXPosition(e,n),n}_refreshStyle(e){let n=e.marker.line-this._bufferService.buffers.active.ydisp;if(n<0||n>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${n*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,n=e.element){if(!n)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?n.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":n.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var n;(n=this._decorationElements.get(e))==null||n.remove(),this._decorationElements.delete(e),e.dispose()}};Jm=An([ut(1,Os),ut(2,Lr),ut(3,Vc),ut(4,Rr)],Jm);var ZL=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 n of this._zones)if(n.color===e.options.overviewRulerOptions.color&&n.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(n,e.marker.line))return;if(this._lineAdjacentToZone(n,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(n,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,n){return n>=e.startBufferLine&&n<=e.endBufferLine}_lineAdjacentToZone(e,n,s){return n>=e.startBufferLine-this._linePadding[s||"full"]&&n<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,n){e.startBufferLine=Math.min(e.startBufferLine,n),e.endBufferLine=Math.max(e.endBufferLine,n)}},Hi={full:0,left:0,center:0,right:0},Yr={full:0,left:0,center:0,right:0},Hl={full:0,left:0,center:0,right:0},Od=class extends Ft{constructor(e,n,s,i,l,c,u,h){var v;super(),this._viewportElement=e,this._screenElement=n,this._bufferService=s,this._decorationService=i,this._renderService=l,this._optionsService=c,this._themeService=u,this._coreBrowserService=h,this._colorZoneStore=new ZL,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(),(v=this._viewportElement.parentElement)==null||v.insertBefore(this._canvas,this._viewportElement),this._register(_n(()=>{var _;return(_=this._canvas)==null?void 0:_.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;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),n=Math.ceil((this._canvas.width-1)/3);Yr.full=this._canvas.width,Yr.left=e,Yr.center=n,Yr.right=e,this._refreshDrawHeightConstants(),Hl.full=1,Hl.left=1,Hl.center=1+Yr.left,Hl.right=1+Yr.left+Yr.center}_refreshDrawHeightConstants(){Hi.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,n=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Hi.left=n,Hi.center=n,Hi.right=n}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Hi.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Hi.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Hi.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Hi.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 n of this._decorationService.decorations)this._colorZoneStore.addDecoration(n);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let n of e)n.position!=="full"&&this._renderColorZone(n);for(let n of e)n.position==="full"&&this._renderColorZone(n);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(Hl[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Hi[e.position||"full"]/2),Yr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Hi[e.position||"full"]))}_queueRefresh(e,n){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=n||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Od=An([ut(2,Os),ut(3,Vc),ut(4,Rr),ut(5,Bs),ut(6,nl),ut(7,Lr)],Od);var $e;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=`
61
+ `,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))($e||($e={}));var xd;(t=>(t.PAD="€",t.HOP="",t.BPH="‚",t.NBH="ƒ",t.IND="„",t.NEL="…",t.SSA="†",t.ESA="‡",t.HTS="ˆ",t.HTJ="‰",t.VTS="Š",t.PLD="‹",t.PLU="Œ",t.RI="",t.SS2="Ž",t.SS3="",t.DCS="",t.PU1="‘",t.PU2="’",t.STS="“",t.CCH="”",t.MW="•",t.SPA="–",t.EPA="—",t.SOS="˜",t.SGCI="™",t.SCI="š",t.CSI="›",t.ST="œ",t.OSC="",t.PM="ž",t.APC="Ÿ"))(xd||(xd={}));var V1;(t=>t.ST=`${$e.ESC}\\`)(V1||(V1={}));var Qm=class{constructor(e,n,s,i,l,c){this._textarea=e,this._compositionView=n,this._bufferService=s,this._optionsService=i,this._coreService=l,this._renderService=c,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let n={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;n.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(n.start,this._compositionPosition.start):s=this._textarea.value.substring(n.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let n=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(n,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let n=this._textarea.value,s=n.replace(e,"");this._dataAlreadySent=s,n.length>e.length?this._coreService.triggerDataEvent(s,!0):n.length<e.length?this._coreService.triggerDataEvent(`${$e.DEL}`,!0):n.length===e.length&&n!==e&&this._coreService.triggerDataEvent(n,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let n=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,l=n*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=l+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let c=this._compositionView.getBoundingClientRect();this._textarea.style.left=l+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Qm=An([ut(2,Os),ut(3,Bs),ut(4,Qo),ut(5,Rr)],Qm);var is=0,rs=0,os=0,Ln=0,jb={css:"#00000000",rgba:0},$n;(t=>{function e(i,l,c,u){return u!==void 0?`#${Lo(i)}${Lo(l)}${Lo(c)}${Lo(u)}`:`#${Lo(i)}${Lo(l)}${Lo(c)}`}t.toCss=e;function n(i,l,c,u=255){return(i<<24|l<<16|c<<8|u)>>>0}t.toRgba=n;function s(i,l,c,u){return{css:t.toCss(i,l,c,u),rgba:t.toRgba(i,l,c,u)}}t.toColor=s})($n||($n={}));var mn;(t=>{function e(h,p){if(Ln=(p.rgba&255)/255,Ln===1)return{css:p.css,rgba:p.rgba};let v=p.rgba>>24&255,_=p.rgba>>16&255,g=p.rgba>>8&255,b=h.rgba>>24&255,S=h.rgba>>16&255,j=h.rgba>>8&255;is=b+Math.round((v-b)*Ln),rs=S+Math.round((_-S)*Ln),os=j+Math.round((g-j)*Ln);let C=$n.toCss(is,rs,os),N=$n.toRgba(is,rs,os);return{css:C,rgba:N}}t.blend=e;function n(h){return(h.rgba&255)===255}t.isOpaque=n;function s(h,p,v){let _=kd.ensureContrastRatio(h.rgba,p.rgba,v);if(_)return $n.toColor(_>>24&255,_>>16&255,_>>8&255)}t.ensureContrastRatio=s;function i(h){let p=(h.rgba|255)>>>0;return[is,rs,os]=kd.toChannels(p),{css:$n.toCss(is,rs,os),rgba:p}}t.opaque=i;function l(h,p){return Ln=Math.round(p*255),[is,rs,os]=kd.toChannels(h.rgba),{css:$n.toCss(is,rs,os,Ln),rgba:$n.toRgba(is,rs,os,Ln)}}t.opacity=l;function c(h,p){return Ln=h.rgba&255,l(h,Ln*p/255)}t.multiplyOpacity=c;function u(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}t.toColorRGB=u})(mn||(mn={}));var xn;(t=>{let e,n;try{let i=document.createElement("canvas");i.width=1,i.height=1;let l=i.getContext("2d",{willReadFrequently:!0});l&&(e=l,e.globalCompositeOperation="copy",n=e.createLinearGradient(0,0,1,1))}catch{}function s(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return is=parseInt(i.slice(1,2).repeat(2),16),rs=parseInt(i.slice(2,3).repeat(2),16),os=parseInt(i.slice(3,4).repeat(2),16),$n.toColor(is,rs,os);case 5:return is=parseInt(i.slice(1,2).repeat(2),16),rs=parseInt(i.slice(2,3).repeat(2),16),os=parseInt(i.slice(3,4).repeat(2),16),Ln=parseInt(i.slice(4,5).repeat(2),16),$n.toColor(is,rs,os,Ln);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let l=i.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(l)return is=parseInt(l[1]),rs=parseInt(l[2]),os=parseInt(l[3]),Ln=Math.round((l[5]===void 0?1:parseFloat(l[5]))*255),$n.toColor(is,rs,os,Ln);if(!e||!n)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=n,e.fillStyle=i,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[is,rs,os,Ln]=e.getImageData(0,0,1,1).data,Ln!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:$n.toRgba(is,rs,os,Ln),css:i}}t.toColor=s})(xn||(xn={}));var Ps;(t=>{function e(s){return n(s>>16&255,s>>8&255,s&255)}t.relativeLuminance=e;function n(s,i,l){let c=s/255,u=i/255,h=l/255,p=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),v=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),_=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return p*.2126+v*.7152+_*.0722}t.relativeLuminance2=n})(Ps||(Ps={}));var kd;(t=>{function e(c,u){if(Ln=(u&255)/255,Ln===1)return u;let h=u>>24&255,p=u>>16&255,v=u>>8&255,_=c>>24&255,g=c>>16&255,b=c>>8&255;return is=_+Math.round((h-_)*Ln),rs=g+Math.round((p-g)*Ln),os=b+Math.round((v-b)*Ln),$n.toRgba(is,rs,os)}t.blend=e;function n(c,u,h){let p=Ps.relativeLuminance(c>>8),v=Ps.relativeLuminance(u>>8);if(_r(p,v)<h){if(v<p){let b=s(c,u,h),S=_r(p,Ps.relativeLuminance(b>>8));if(S<h){let j=i(c,u,h),C=_r(p,Ps.relativeLuminance(j>>8));return S>C?b:j}return b}let _=i(c,u,h),g=_r(p,Ps.relativeLuminance(_>>8));if(g<h){let b=s(c,u,h),S=_r(p,Ps.relativeLuminance(b>>8));return g>S?_:b}return _}}t.ensureContrastRatio=n;function s(c,u,h){let p=c>>24&255,v=c>>16&255,_=c>>8&255,g=u>>24&255,b=u>>16&255,S=u>>8&255,j=_r(Ps.relativeLuminance2(g,b,S),Ps.relativeLuminance2(p,v,_));for(;j<h&&(g>0||b>0||S>0);)g-=Math.max(0,Math.ceil(g*.1)),b-=Math.max(0,Math.ceil(b*.1)),S-=Math.max(0,Math.ceil(S*.1)),j=_r(Ps.relativeLuminance2(g,b,S),Ps.relativeLuminance2(p,v,_));return(g<<24|b<<16|S<<8|255)>>>0}t.reduceLuminance=s;function i(c,u,h){let p=c>>24&255,v=c>>16&255,_=c>>8&255,g=u>>24&255,b=u>>16&255,S=u>>8&255,j=_r(Ps.relativeLuminance2(g,b,S),Ps.relativeLuminance2(p,v,_));for(;j<h&&(g<255||b<255||S<255);)g=Math.min(255,g+Math.ceil((255-g)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),j=_r(Ps.relativeLuminance2(g,b,S),Ps.relativeLuminance2(p,v,_));return(g<<24|b<<16|S<<8|255)>>>0}t.increaseLuminance=i;function l(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}t.toChannels=l})(kd||(kd={}));function Lo(t){let e=t.toString(16);return e.length<2?"0"+e:e}function _r(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var eR=class extends Kc{constructor(e,n,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=n,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Bd=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new wi}register(t){let e={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(e),e.id}deregister(t){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===t)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(t){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(t);if(!e||e.length===0)return[];let n=[],s=e.translateToString(!0),i=0,l=0,c=0,u=e.getFg(0),h=e.getBg(0);for(let p=0;p<e.getTrimmedLength();p++)if(e.loadCell(p,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==u||this._workCell.bg!==h){if(p-i>1){let v=this._getJoinedRanges(s,c,l,e,i);for(let _=0;_<v.length;_++)n.push(v[_])}i=p,c=l,u=this._workCell.fg,h=this._workCell.bg}l+=this._workCell.getChars().length||ro.length}if(this._bufferService.cols-i>1){let p=this._getJoinedRanges(s,c,l,e,i);for(let v=0;v<p.length;v++)n.push(p[v])}return n}_getJoinedRanges(t,e,n,s,i){let l=t.substring(e,n),c=[];try{c=this._characterJoiners[0].handler(l)}catch(u){console.error(u)}for(let u=1;u<this._characterJoiners.length;u++)try{let h=this._characterJoiners[u].handler(l);for(let p=0;p<h.length;p++)Bd._mergeRanges(c,h[p])}catch(h){console.error(h)}return this._stringRangesToCellRanges(c,s,i),c}_stringRangesToCellRanges(t,e,n){let s=0,i=!1,l=0,c=t[s];if(c){for(let u=n;u<this._bufferService.cols;u++){let h=e.getWidth(u),p=e.getString(u).length||ro.length;if(h!==0){if(!i&&c[0]<=l&&(c[0]=u,i=!0),c[1]<=l){if(c[1]=u,c=t[++s],!c)break;c[0]<=l?(c[0]=u,i=!0):i=!1}l+=p}}c&&(c[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let n=!1;for(let s=0;s<t.length;s++){let i=t[s];if(n){if(e[1]<=i[0])return t[s-1][1]=e[1],t;if(e[1]<=i[1])return t[s-1][1]=Math.max(e[1],i[1]),t.splice(s,1),t;t.splice(s,1),s--}else{if(e[1]<=i[0])return t.splice(s,0,e),t;if(e[1]<=i[1])return i[0]=Math.min(e[0],i[0]),t;e[0]<i[1]&&(i[0]=Math.min(e[0],i[0]),n=!0);continue}}return n?t[t.length-1][1]=e[1]:t.push(e),t}};Bd=An([ut(0,Os)],Bd);function tR(t){return 57508<=t&&t<=57558}function nR(t){return 9472<=t&&t<=9631}function sR(t){return tR(t)||nR(t)}function iR(){return{css:{canvas:td(),cell:td()},device:{canvas:td(),cell:td(),char:{width:0,height:0,left:0,top:0}}}}function td(){return{width:0,height:0}}var Zm=class{constructor(e,n,s,i,l,c,u){this._document=e,this._characterJoinerService=n,this._optionsService=s,this._coreBrowserService=i,this._coreService=l,this._decorationService=c,this._themeService=u,this._workCell=new wi,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,n,s){this._selectionStart=e,this._selectionEnd=n,this._columnSelectMode=s}createRow(e,n,s,i,l,c,u,h,p,v,_){let g=[],b=this._characterJoinerService.getJoinedCharacters(n),S=this._themeService.colors,j=e.getNoBgTrimmedLength();s&&j<c+1&&(j=c+1);let C,N=0,E="",O=0,x=0,W=0,$=0,J=!1,q=0,V=!1,ie=0,K=0,B=[],I=v!==-1&&_!==-1;for(let D=0;D<j;D++){e.loadCell(D,this._workCell);let T=this._workCell.getWidth();if(T===0)continue;let z=!1,R=D>=K,M=D,L=this._workCell;if(b.length>0&&D===b[0][0]&&R){let X=b.shift(),ce=this._isCellInSelection(X[0],n);for(O=X[0]+1;O<X[1];O++)R&&(R=ce===this._isCellInSelection(O,n));R&&(R=!s||c<X[0]||c>=X[1]),R?(z=!0,L=new eR(this._workCell,e.translateToString(!0,X[0],X[1]),X[1]-X[0]),M=X[1]-1,T=L.getWidth()):K=X[1]}let H=this._isCellInSelection(D,n),A=s&&D===c,U=I&&D>=v&&D<=_,Q=!1;this._decorationService.forEachDecorationAtCell(D,n,void 0,X=>{Q=!0});let ae=L.getChars()||ro;if(ae===" "&&(L.isUnderline()||L.isOverline())&&(ae=" "),ie=T*h-p.get(ae,L.isBold(),L.isItalic()),!C)C=this._document.createElement("span");else if(N&&(H&&V||!H&&!V&&L.bg===x)&&(H&&V&&S.selectionForeground||L.fg===W)&&L.extended.ext===$&&U===J&&ie===q&&!A&&!z&&!Q&&R){L.isInvisible()?E+=ro:E+=ae,N++;continue}else N&&(C.textContent=E),C=this._document.createElement("span"),N=0,E="";if(x=L.bg,W=L.fg,$=L.extended.ext,J=U,q=ie,V=H,z&&c>=D&&c<=M&&(c=D),!this._coreService.isCursorHidden&&A&&this._coreService.isCursorInitialized){if(B.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&B.push("xterm-cursor-blink"),B.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(l)switch(l){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(L.isBold()&&B.push("xterm-bold"),L.isItalic()&&B.push("xterm-italic"),L.isDim()&&B.push("xterm-dim"),L.isInvisible()?E=ro:E=L.getChars()||ro,L.isUnderline()&&(B.push(`xterm-underline-${L.extended.underlineStyle}`),E===" "&&(E=" "),!L.isUnderlineColorDefault()))if(L.isUnderlineColorRGB())C.style.textDecorationColor=`rgb(${Kc.toColorRGB(L.getUnderlineColor()).join(",")})`;else{let X=L.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&L.isBold()&&X<8&&(X+=8),C.style.textDecorationColor=S.ansi[X].css}L.isOverline()&&(B.push("xterm-overline"),E===" "&&(E=" ")),L.isStrikethrough()&&B.push("xterm-strikethrough"),U&&(C.style.textDecoration="underline");let re=L.getFgColor(),je=L.getFgColorMode(),te=L.getBgColor(),ne=L.getBgColorMode(),me=!!L.isInverse();if(me){let X=re;re=te,te=X;let ce=je;je=ne,ne=ce}let we,Fe,Ae=!1;this._decorationService.forEachDecorationAtCell(D,n,void 0,X=>{X.options.layer!=="top"&&Ae||(X.backgroundColorRGB&&(ne=50331648,te=X.backgroundColorRGB.rgba>>8&16777215,we=X.backgroundColorRGB),X.foregroundColorRGB&&(je=50331648,re=X.foregroundColorRGB.rgba>>8&16777215,Fe=X.foregroundColorRGB),Ae=X.options.layer==="top")}),!Ae&&H&&(we=this._coreBrowserService.isFocused?S.selectionBackgroundOpaque:S.selectionInactiveBackgroundOpaque,te=we.rgba>>8&16777215,ne=50331648,Ae=!0,S.selectionForeground&&(je=50331648,re=S.selectionForeground.rgba>>8&16777215,Fe=S.selectionForeground)),Ae&&B.push("xterm-decoration-top");let He;switch(ne){case 16777216:case 33554432:He=S.ansi[te],B.push(`xterm-bg-${te}`);break;case 50331648:He=$n.toColor(te>>16,te>>8&255,te&255),this._addStyle(C,`background-color:#${Lb((te>>>0).toString(16),"0",6)}`);break;case 0:default:me?(He=S.foreground,B.push("xterm-bg-257")):He=S.background}switch(we||L.isDim()&&(we=mn.multiplyOpacity(He,.5)),je){case 16777216:case 33554432:L.isBold()&&re<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(re+=8),this._applyMinimumContrast(C,He,S.ansi[re],L,we,void 0)||B.push(`xterm-fg-${re}`);break;case 50331648:let X=$n.toColor(re>>16&255,re>>8&255,re&255);this._applyMinimumContrast(C,He,X,L,we,Fe)||this._addStyle(C,`color:#${Lb(re.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(C,He,S.foreground,L,we,Fe)||me&&B.push("xterm-fg-257")}B.length&&(C.className=B.join(" "),B.length=0),!A&&!z&&!Q&&R?N++:C.textContent=E,ie!==this.defaultSpacing&&(C.style.letterSpacing=`${ie}px`),g.push(C),D=M}return C&&N&&(C.textContent=E),g}_applyMinimumContrast(e,n,s,i,l,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||sR(i.getCode()))return!1;let u=this._getContrastCache(i),h;if(!l&&!c&&(h=u.getColor(n.rgba,s.rgba)),h===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);h=mn.ensureContrastRatio(l||n,c||s,p),u.setColor((l||n).rgba,(c||s).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,n){e.setAttribute("style",`${e.getAttribute("style")||""}${n};`)}_isCellInSelection(e,n){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&n>=s[1]&&e<i[0]&&n<=i[1]:e<s[0]&&n>=s[1]&&e>=i[0]&&n<=i[1]:n>s[1]&&n<i[1]||s[1]===i[1]&&n===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&n===i[1]&&e<i[0]||s[1]<i[1]&&n===s[1]&&e>=s[0]}};Zm=An([ut(1,L1),ut(2,Bs),ut(3,Lr),ut(4,Qo),ut(5,Vc),ut(6,nl)],Zm);function Lb(t,e,n){for(;t.length<n;)t=e+t;return t}var rR=class{constructor(e,n){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.style.fontStyle="italic";let c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[s,i,l,c],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(l),this._container.appendChild(c),n.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,n,s,i){e===this._font&&n===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=n,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,n,s){let i=0;if(!n&&!s&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let u=this._measure(e,0);return u>0&&(this._flat[i]=u),u}let l=e;n&&(l+="B"),s&&(l+="I");let c=this._holey.get(l);if(c===void 0){let u=0;n&&(u|=1),s&&(u|=2),c=this._measure(e,u),c>0&&this._holey.set(l,c)}return c}_measure(e,n){let s=this._measureElements[n];return s.textContent=e.repeat(32),s.offsetWidth/32}},oR=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,n,s,i=!1){if(this.selectionStart=n,this.selectionEnd=s,!n||!s||n[0]===s[0]&&n[1]===s[1]){this.clear();return}let l=e.buffers.active.ydisp,c=n[1]-l,u=s[1]-l,h=Math.max(c,0),p=Math.min(u,e.rows-1);if(h>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=c,this.viewportEndRow=u,this.viewportCappedStartRow=h,this.viewportCappedEndRow=p,this.startCol=n[0],this.endCol=s[0]}isCellSelected(e,n,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?n>=this.startCol&&s>=this.viewportCappedStartRow&&n<this.endCol&&s<=this.viewportCappedEndRow:n<this.startCol&&s>=this.viewportCappedStartRow&&n>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&n>=this.startCol&&n<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&n<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&n>=this.startCol):!1}};function aR(){return new oR}var dp="xterm-dom-renderer-owner-",hi="xterm-rows",nd="xterm-fg-",Rb="xterm-bg-",Ul="xterm-focus",sd="xterm-selection",lR=1,eg=class extends Ft{constructor(e,n,s,i,l,c,u,h,p,v,_,g,b,S){super(),this._terminal=e,this._document=n,this._element=s,this._screenElement=i,this._viewportElement=l,this._helperContainer=c,this._linkifier2=u,this._charSizeService=p,this._optionsService=v,this._bufferService=_,this._coreService=g,this._coreBrowserService=b,this._themeService=S,this._terminalClass=lR++,this._rowElements=[],this._selectionRenderModel=aR(),this.onRequestRedraw=this._register(new it).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(hi),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(sd),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=iR(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(j=>this._injectCss(j))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance(Zm,document),this._element.classList.add(dp+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(j=>this._handleLinkHover(j))),this._register(this._linkifier2.onHideLinkUnderline(j=>this._handleLinkLeave(j))),this._register(_n(()=>{this._element.classList.remove(dp+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new rR(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let n=`${this._terminalSelector} .${hi} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=n,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 n=`${this._terminalSelector} .${hi} { 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}`;n+=`${this._terminalSelector} .${hi} .xterm-dim { color: ${mn.multiplyOpacity(e.foreground,.5).css};}`,n+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,l=`blink_block_${this._terminalClass}`;n+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,n+=`@keyframes ${i} { 50% { box-shadow: none; }}`,n+=`@keyframes ${l} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,n+=`${this._terminalSelector} .${hi}.${Ul} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${hi}.${Ul} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${hi}.${Ul} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${l} 1s step-end infinite;}${this._terminalSelector} .${hi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${hi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${hi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${hi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${hi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,n+=`${this._terminalSelector} .${sd} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${sd} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${sd} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,u]of e.ansi.entries())n+=`${this._terminalSelector} .${nd}${c} { color: ${u.css}; }${this._terminalSelector} .${nd}${c}.xterm-dim { color: ${mn.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${Rb}${c} { background-color: ${u.css}; }`;n+=`${this._terminalSelector} .${nd}257 { color: ${mn.opaque(e.background).css}; }${this._terminalSelector} .${nd}257.xterm-dim { color: ${mn.multiplyOpacity(mn.opaque(e.background),.5).css}; }${this._terminalSelector} .${Rb}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=n}_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,n){for(let s=this._rowElements.length;s<=n;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>n;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,n){this._refreshRowElements(e,n),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(Ul),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ul),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,n,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,n,s),this.renderRows(0,this._bufferService.rows-1),!e||!n||(this._selectionRenderModel.update(this._terminal,e,n,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,l=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(s){let p=e[0]>n[0];h.appendChild(this._createSelectionElement(c,p?n[0]:e[0],p?e[0]:n[0],u-c+1))}else{let p=i===c?e[0]:0,v=c===l?n[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(c,p,v));let _=u-c-1;if(h.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,_)),c!==u){let g=l===u?n[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(u,0,g))}}this._selectionContainer.appendChild(h)}_createSelectionElement(e,n,s,i=1){let l=this._document.createElement("div"),c=n*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(s-n);return c+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-c),l.style.height=`${i*this.dimensions.css.cell.height}px`,l.style.top=`${e*this.dimensions.css.cell.height}px`,l.style.left=`${c}px`,l.style.width=`${u}px`,l}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,n){let s=this._bufferService.buffer,i=s.ybase+s.y,l=Math.min(s.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=n;p++){let v=p+s.ydisp,_=this._rowElements[p],g=s.lines.get(v);if(!_||!g)break;_.replaceChildren(...this._rowFactory.createRow(g,v,v===i,u,h,l,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${dp}${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,n,s,i,l,c){s<0&&(e=0),i<0&&(n=0);let u=this._bufferService.rows-1;s=Math.max(Math.min(s,u),0),i=Math.max(Math.min(i,u),0),l=Math.min(l,this._bufferService.cols);let h=this._bufferService.buffer,p=h.ybase+h.y,v=Math.min(h.x,l-1),_=this._optionsService.rawOptions.cursorBlink,g=this._optionsService.rawOptions.cursorStyle,b=this._optionsService.rawOptions.cursorInactiveStyle;for(let S=s;S<=i;++S){let j=S+h.ydisp,C=this._rowElements[S],N=h.lines.get(j);if(!C||!N)break;C.replaceChildren(...this._rowFactory.createRow(N,j,j===p,g,b,v,_,this.dimensions.css.cell.width,this._widthCache,c?S===s?e:0:-1,c?(S===i?n:l)-1:-1))}}};eg=An([ut(7,vv),ut(8,fh),ut(9,Bs),ut(10,Os),ut(11,Qo),ut(12,Lr),ut(13,nl)],eg);var tg=class extends Ft{constructor(e,n,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new it),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new uR(this._optionsService))}catch{this._measureStrategy=this._register(new cR(e,n,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())}};tg=An([ut(2,Bs)],tg);var Y1=class extends Ft{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},cR=class extends Y1{constructor(t,e,n){super(),this._document=t,this._parentElement=e,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}},uR=class extends Y1{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let n=this._ctx.measureText("W");if(!("width"in n&&"fontBoundingBoxAscent"in n&&"fontBoundingBoxDescent"in n))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}},dR=class extends Ft{constructor(e,n,s){super(),this._textarea=e,this._window=n,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new hR(this._window)),this._onDprChange=this._register(new it),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new it),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(_s.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Tt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Tt(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},hR=class extends Ft{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ya),this._onDprChange=this._register(new it),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(_n(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Tt(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)}},fR=class extends Ft{constructor(){super(),this.linkProviders=[],this._register(_n(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function Cv(t,e,n){let s=n.getBoundingClientRect(),i=t.getComputedStyle(n),l=parseInt(i.getPropertyValue("padding-left")),c=parseInt(i.getPropertyValue("padding-top"));return[e.clientX-s.left-l,e.clientY-s.top-c]}function pR(t,e,n,s,i,l,c,u,h){if(!l)return;let p=Cv(t,e,n);if(p)return p[0]=Math.ceil((p[0]+(h?c/2:0))/c),p[1]=Math.ceil(p[1]/u),p[0]=Math.min(Math.max(p[0],1),s+(h?1:0)),p[1]=Math.min(Math.max(p[1],1),i),p}var ng=class{constructor(e,n){this._renderService=e,this._charSizeService=n}getCoords(e,n,s,i,l){return pR(window,e,n,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,l)}getMouseReportCoords(e,n){let s=Cv(window,e,n);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};ng=An([ut(0,Rr),ut(1,fh)],ng);var mR=class{constructor(e,n){this._renderCallback=e,this._coreBrowserService=n,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,n,s){this._rowCount=s,e=e!==void 0?e:0,n=n!==void 0?n: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,n):n,!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),n=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,n),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},G1={};Cj(G1,{getSafariVersion:()=>vR,isChromeOS:()=>Z1,isFirefox:()=>X1,isIpad:()=>_R,isIphone:()=>yR,isLegacyEdge:()=>gR,isLinux:()=>Ev,isMac:()=>$d,isNode:()=>ph,isSafari:()=>J1,isWindows:()=>Q1});var ph=typeof process<"u"&&"title"in process,Yc=ph?"node":navigator.userAgent,Gc=ph?"node":navigator.platform,X1=Yc.includes("Firefox"),gR=Yc.includes("Edge"),J1=/^((?!chrome|android).)*safari/i.test(Yc);function vR(){if(!J1)return 0;let t=Yc.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var $d=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Gc),_R=Gc==="iPad",yR=Gc==="iPhone",Q1=["Windows","Win16","Win32","WinCE"].includes(Gc),Ev=Gc.indexOf("Linux")>=0,Z1=/\bCrOS\b/.test(Yc),ek=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),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(t){this._idleCallback=void 0;let e=0,n=0,s=t.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),n=Math.max(e,n),i=t.timeRemaining(),n*1.5>i){s-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-e))}ms`),this._start();return}s=i}this.clear()}},wR=class extends ek{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let n=performance.now()+e;return{timeRemaining:()=>Math.max(0,n-performance.now())}}},bR=class extends ek{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},zd=!ph&&"requestIdleCallback"in window?bR:wR,SR=class{constructor(){this._queue=new zd}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},sg=class extends Ft{constructor(e,n,s,i,l,c,u,h,p){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=l,this._coreBrowserService=h,this._renderer=this._register(new Ya),this._pausedResizeTask=new SR,this._observerDisposable=this._register(new Ya),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 it),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new it),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new it),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new it),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new mR((v,_)=>this._renderRows(v,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new xR(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(_n(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>{var v;return(v=this._renderer.value)==null?void 0:v.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(c.onDecorationRegistered(()=>this._fullRefresh())),this._register(c.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,n),this._register(this._coreBrowserService.onWindowChange(v=>this._registerIntersectionObserver(v,n)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,n){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(n),this._observerDisposable.value=_n(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,n,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,n);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),n=Math.max(n,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,n,this._rowCount)}_renderRows(e,n){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,n);return}e=Math.min(e,this._rowCount-1),n=Math.min(n,this._rowCount-1),this._renderer.value.renderRows(e,n),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:n}),this._onRender.fire({start:e,end:n}),this._isNextRenderRedrawOnly=!0}}resize(e,n){this._rowCount=n,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(n=>this.refreshRows(n.start,n.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,n;this._renderer.value&&((n=(e=this._renderer.value).clearTextureAtlas)==null||n.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,n){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,n)}):this._renderer.value.handleResize(e,n),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,n,s){var i;this._selectionState.start=e,this._selectionState.end=n,this._selectionState.columnSelectMode=s,(i=this._renderer.value)==null||i.handleSelectionChanged(e,n,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};sg=An([ut(2,Bs),ut(3,fh),ut(4,Qo),ut(5,Vc),ut(6,Os),ut(7,Lr),ut(8,nl)],sg);var xR=class{constructor(t,e,n){this._coreBrowserService=t,this._coreService=e,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,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 t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function kR(t,e,n,s){let i=n.buffer.x,l=n.buffer.y;if(!n.buffer.hasScrollback)return NR(i,l,t,e,n,s)+mh(l,e,n,s)+jR(i,l,t,e,n,s);let c;if(l===e)return c=i>t?"D":"C",jc(Math.abs(i-t),Nc(c,s));c=l>e?"D":"C";let u=Math.abs(l-e),h=ER(l>e?t:i,n)+(u-1)*n.cols+1+CR(l>e?i:t);return jc(h,Nc(c,s))}function CR(t,e){return t-1}function ER(t,e){return e.cols-t}function NR(t,e,n,s,i,l){return mh(e,s,i,l).length===0?"":jc(nk(t,e,t,e-Go(e,i),!1,i).length,Nc("D",l))}function mh(t,e,n,s){let i=t-Go(t,n),l=e-Go(e,n),c=Math.abs(i-l)-LR(t,e,n);return jc(c,Nc(tk(t,e),s))}function jR(t,e,n,s,i,l){let c;mh(e,s,i,l).length>0?c=s-Go(s,i):c=e;let u=s,h=RR(t,e,n,s,i,l);return jc(nk(t,c,n,u,h==="C",i).length,Nc(h,l))}function LR(t,e,n){var c;let s=0,i=t-Go(t,n),l=e-Go(e,n);for(let u=0;u<Math.abs(i-l);u++){let h=tk(t,e)==="A"?-1:1;(c=n.buffer.lines.get(i+h*u))!=null&&c.isWrapped&&s++}return s}function Go(t,e){let n=0,s=e.buffer.lines.get(t),i=s==null?void 0:s.isWrapped;for(;i&&t>=0&&t<e.rows;)n++,s=e.buffer.lines.get(--t),i=s==null?void 0:s.isWrapped;return n}function RR(t,e,n,s,i,l){let c;return mh(n,s,i,l).length>0?c=s-Go(s,i):c=e,t<n&&c<=s||t>=n&&c<s?"C":"D"}function tk(t,e){return t>e?"A":"B"}function nk(t,e,n,s,i,l){let c=t,u=e,h="";for(;(c!==n||u!==s)&&u>=0&&u<l.buffer.lines.length;)c+=i?1:-1,i&&c>l.cols-1?(h+=l.buffer.translateBufferLineToString(u,!1,t,c),c=0,t=0,u++):!i&&c<0&&(h+=l.buffer.translateBufferLineToString(u,!1,0,t+1),c=l.cols-1,t=c,u--);return h+l.buffer.translateBufferLineToString(u,!1,t,c)}function Nc(t,e){let n=e?"O":"[";return $e.ESC+n+t}function jc(t,e){t=Math.floor(t);let n="";for(let s=0;s<t;s++)n+=e;return n}var AR=class{constructor(t){this._bufferService=t,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 t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Ab(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var hp=50,MR=15,TR=50,PR=500,IR=" ",DR=new RegExp(IR,"g"),ig=class extends Ft{constructor(e,n,s,i,l,c,u,h,p){super(),this._element=e,this._screenElement=n,this._linkifier=s,this._bufferService=i,this._coreService=l,this._mouseService=c,this._optionsService=u,this._renderService=h,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new wi,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new it),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new it),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new it),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new it),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=v=>this._handleMouseMove(v),this._mouseUpListener=v=>this._handleMouseUp(v),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(v=>this._handleTrim(v)),this._register(this._bufferService.buffers.onBufferActivate(v=>this._handleBufferActivate(v))),this.enable(),this._model=new AR(this._bufferService),this._activeSelectionMode=0,this._register(_n(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(v=>{v.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,n=this._model.finalSelectionEnd;return!e||!n?!1:e[0]!==n[0]||e[1]!==n[1]}get selectionText(){let e=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;if(!e||!n)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===n[0])return"";let l=e[0]<n[0]?e[0]:n[0],c=e[0]<n[0]?n[0]:e[0];for(let u=e[1];u<=n[1];u++){let h=s.translateBufferLineToString(u,!0,l,c);i.push(h)}}else{let l=e[1]===n[1]?n[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],l));for(let c=e[1]+1;c<=n[1]-1;c++){let u=s.lines.get(c),h=s.translateBufferLineToString(c,!0);u!=null&&u.isWrapped?i[i.length-1]+=h:i.push(h)}if(e[1]!==n[1]){let c=s.lines.get(n[1]),u=s.translateBufferLineToString(n[1],!0,0,n[0]);c&&c.isWrapped?i[i.length-1]+=u:i.push(u)}}return i.map(l=>l.replace(DR," ")).join(Q1?`\r
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())),Ev&&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 n=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!n?!1:this._areCoordsInSelection(n,s,i)}isCellInSelection(e,n){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,n],s,i)}_areCoordsInSelection(e,n,s){return e[1]>n[1]&&e[1]<s[1]||n[1]===s[1]&&e[1]===n[1]&&e[0]>=n[0]&&e[0]<s[0]||n[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||n[1]<s[1]&&e[1]===n[1]&&e[0]>=n[0]}_selectWordAtCursor(e,n){var l,c;let s=(c=(l=this._linkifier.currentLink)==null?void 0:l.link)==null?void 0:c.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=Ab(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,n),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,n){this._model.clearSelection(),e=Math.max(e,0),n=Math.min(n,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,n],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let n=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(n)return n[0]--,n[1]--,n[1]+=this._bufferService.buffer.ydisp,n}_getMouseEventScrollAmount(e){let n=Cv(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return n>=0&&n<=s?0:(n>s&&(n-=s),n=Math.min(Math.max(n,-hp),hp),n/=hp,n/Math.abs(n)+Math.round(n*(MR-1)))}shouldForceSelection(e){return $d?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(),TR)}_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 n=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);n&&n.length!==this._model.selectionStart[0]&&n.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let n=this._getMouseBufferCoords(e);n&&(this._activeSelectionMode=2,this._selectLineAt(n[1]))}shouldColumnSelect(e){return e.altKey&&!($d&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let n=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!n||n[0]!==this._model.selectionEnd[0]||n[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 n=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&n<PR&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=kR(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,n=this._model.finalSelectionEnd,s=!!e&&!!n&&(e[0]!==n[0]||e[1]!==n[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,n,s);return}!e||!n||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||n[0]!==this._oldSelectionEnd[0]||n[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,n,s)}_fireOnSelectionChange(e,n,s){this._oldSelectionStart=e,this._oldSelectionEnd=n,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(n=>this._handleTrim(n))}_convertViewportColToCharacterIndex(e,n){let s=n;for(let i=0;n>=i;i++){let l=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:l>1&&n!==i&&(s+=l-1)}return s}setSelection(e,n,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,n],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,n,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let l=this._bufferService.buffer,c=l.lines.get(e[1]);if(!c)return;let u=l.translateBufferLineToString(e[1],!1),h=this._convertViewportColToCharacterIndex(c,e[0]),p=h,v=e[0]-h,_=0,g=0,b=0,S=0;if(u.charAt(h)===" "){for(;h>0&&u.charAt(h-1)===" ";)h--;for(;p<u.length&&u.charAt(p+1)===" ";)p++}else{let N=e[0],E=e[0];c.getWidth(N)===0&&(_++,N--),c.getWidth(E)===2&&(g++,E++);let O=c.getString(E).length;for(O>1&&(S+=O-1,p+=O-1);N>0&&h>0&&!this._isCharWordSeparator(c.loadCell(N-1,this._workCell));){c.loadCell(N-1,this._workCell);let x=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,N--):x>1&&(b+=x-1,h-=x-1),h--,N--}for(;E<c.length&&p+1<u.length&&!this._isCharWordSeparator(c.loadCell(E+1,this._workCell));){c.loadCell(E+1,this._workCell);let x=this._workCell.getChars().length;this._workCell.getWidth()===2?(g++,E++):x>1&&(S+=x-1,p+=x-1),p++,E++}}p++;let j=h+v-_+b,C=Math.min(this._bufferService.cols,p-h+_+g-b-S);if(!(!n&&u.slice(h,p).trim()==="")){if(s&&j===0&&c.getCodePoint(0)!==32){let N=l.lines.get(e[1]-1);if(N&&c.isWrapped&&N.getCodePoint(this._bufferService.cols-1)!==32){let E=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(E){let O=this._bufferService.cols-E.start;j-=O,C+=O}}}if(i&&j+C===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let N=l.lines.get(e[1]+1);if(N!=null&&N.isWrapped&&N.getCodePoint(0)!==32){let E=this._getWordAt([0,e[1]+1],!1,!1,!0);E&&(C+=E.length)}}return{start:j,length:C}}}_selectWordAt(e,n){let s=this._getWordAt(e,n);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let n=this._getWordAt(e,!0);if(n){let s=e[1];for(;n.start<0;)n.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;n.start+n.length>this._bufferService.cols;)n.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?n.start:n.start+n.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let n=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:n.first},end:{x:this._bufferService.cols-1,y:n.last}};this._model.selectionStart=[0,n.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Ab(s,this._bufferService.cols)}};ig=An([ut(3,Os),ut(4,Qo),ut(5,_v),ut(6,Bs),ut(7,Rr),ut(8,Lr)],ig);var Mb=class{constructor(){this._data={}}set(e,n,s){this._data[e]||(this._data[e]={}),this._data[e][n]=s}get(e,n){return this._data[e]?this._data[e][n]:void 0}clear(){this._data={}}},Tb=class{constructor(){this._color=new Mb,this._css=new Mb}setCss(e,n,s){this._css.set(e,n,s)}getCss(e,n){return this._css.get(e,n)}setColor(e,n,s){this._color.set(e,n,s)}getColor(e,n){return this._color.get(e,n)}clear(){this._color.clear(),this._css.clear()}},Un=Object.freeze((()=>{let t=[xn.toColor("#2e3436"),xn.toColor("#cc0000"),xn.toColor("#4e9a06"),xn.toColor("#c4a000"),xn.toColor("#3465a4"),xn.toColor("#75507b"),xn.toColor("#06989a"),xn.toColor("#d3d7cf"),xn.toColor("#555753"),xn.toColor("#ef2929"),xn.toColor("#8ae234"),xn.toColor("#fce94f"),xn.toColor("#729fcf"),xn.toColor("#ad7fa8"),xn.toColor("#34e2e2"),xn.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=e[n/36%6|0],i=e[n/6%6|0],l=e[n%6];t.push({css:$n.toCss(s,i,l),rgba:$n.toRgba(s,i,l)})}for(let n=0;n<24;n++){let s=8+n*10;t.push({css:$n.toCss(s,s,s),rgba:$n.toRgba(s,s,s)})}return t})()),To=xn.toColor("#ffffff"),dc=xn.toColor("#000000"),Pb=xn.toColor("#ffffff"),Ib=dc,Wl={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},OR=To,rg=class extends Ft{constructor(e){super(),this._optionsService=e,this._contrastCache=new Tb,this._halfContrastCache=new Tb,this._onChangeColors=this._register(new it),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:To,background:dc,cursor:Pb,cursorAccent:Ib,selectionForeground:void 0,selectionBackgroundTransparent:Wl,selectionBackgroundOpaque:mn.blend(dc,Wl),selectionInactiveBackgroundTransparent:Wl,selectionInactiveBackgroundOpaque:mn.blend(dc,Wl),scrollbarSliderBackground:mn.opacity(To,.2),scrollbarSliderHoverBackground:mn.opacity(To,.4),scrollbarSliderActiveBackground:mn.opacity(To,.5),overviewRulerBorder:To,ansi:Un.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 n=this._colors;if(n.foreground=rn(e.foreground,To),n.background=rn(e.background,dc),n.cursor=mn.blend(n.background,rn(e.cursor,Pb)),n.cursorAccent=mn.blend(n.background,rn(e.cursorAccent,Ib)),n.selectionBackgroundTransparent=rn(e.selectionBackground,Wl),n.selectionBackgroundOpaque=mn.blend(n.background,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundTransparent=rn(e.selectionInactiveBackground,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundOpaque=mn.blend(n.background,n.selectionInactiveBackgroundTransparent),n.selectionForeground=e.selectionForeground?rn(e.selectionForeground,jb):void 0,n.selectionForeground===jb&&(n.selectionForeground=void 0),mn.isOpaque(n.selectionBackgroundTransparent)&&(n.selectionBackgroundTransparent=mn.opacity(n.selectionBackgroundTransparent,.3)),mn.isOpaque(n.selectionInactiveBackgroundTransparent)&&(n.selectionInactiveBackgroundTransparent=mn.opacity(n.selectionInactiveBackgroundTransparent,.3)),n.scrollbarSliderBackground=rn(e.scrollbarSliderBackground,mn.opacity(n.foreground,.2)),n.scrollbarSliderHoverBackground=rn(e.scrollbarSliderHoverBackground,mn.opacity(n.foreground,.4)),n.scrollbarSliderActiveBackground=rn(e.scrollbarSliderActiveBackground,mn.opacity(n.foreground,.5)),n.overviewRulerBorder=rn(e.overviewRulerBorder,OR),n.ansi=Un.slice(),n.ansi[0]=rn(e.black,Un[0]),n.ansi[1]=rn(e.red,Un[1]),n.ansi[2]=rn(e.green,Un[2]),n.ansi[3]=rn(e.yellow,Un[3]),n.ansi[4]=rn(e.blue,Un[4]),n.ansi[5]=rn(e.magenta,Un[5]),n.ansi[6]=rn(e.cyan,Un[6]),n.ansi[7]=rn(e.white,Un[7]),n.ansi[8]=rn(e.brightBlack,Un[8]),n.ansi[9]=rn(e.brightRed,Un[9]),n.ansi[10]=rn(e.brightGreen,Un[10]),n.ansi[11]=rn(e.brightYellow,Un[11]),n.ansi[12]=rn(e.brightBlue,Un[12]),n.ansi[13]=rn(e.brightMagenta,Un[13]),n.ansi[14]=rn(e.brightCyan,Un[14]),n.ansi[15]=rn(e.brightWhite,Un[15]),e.extendedAnsi){let s=Math.min(n.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)n.ansi[i+16]=rn(e.extendedAnsi[i],Un[i+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 n=0;n<this._restoreColors.ansi.length;++n)this._colors.ansi[n]=this._restoreColors.ansi[n];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()}}};rg=An([ut(0,Bs)],rg);function rn(t,e){if(t!==void 0)try{return xn.toColor(t)}catch{}return e}var BR=class{constructor(...e){this._entries=new Map;for(let[n,s]of e)this.set(n,s)}set(e,n){let s=this._entries.get(e);return this._entries.set(e,n),s}forEach(e){for(let[n,s]of this._entries.entries())e(n,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},$R=class{constructor(){this._services=new BR,this._services.set(vv,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let n=Mj(t).sort((l,c)=>l.index-c.index),s=[];for(let l of n){let c=this._services.get(l.id);if(!c)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${l.id._id}.`);s.push(c)}let i=n.length>0?n[0].index:e.length;if(e.length!==i)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${i+1} conflicts with ${e.length} static arguments`);return new t(...e,...s)}},zR={trace:0,debug:1,info:2,warn:3,error:4,off:5},FR="xterm.js: ",og=class extends Ft{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=zR[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let n=0;n<e.length;n++)typeof e[n]=="function"&&(e[n]=e[n]())}_log(e,n,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":FR)+n,...s)}trace(e,...n){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,e,n)}debug(e,...n){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,e,n)}info(e,...n){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,e,n)}warn(e,...n){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,e,n)}error(e,...n){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,e,n)}};og=An([ut(0,Bs)],og);var Db=class extends Ft{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new it),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new it),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new it),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 n=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)n[s]=this._array[this._getCyclicIndex(s)];this._array=n,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let n=this._length;n<e;n++)this._array[n]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,n){this._array[this._getCyclicIndex(e)]=n}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,n,...s){if(n){for(let i=e;i<this._length-n;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+n)];this._length-=n,this.onDeleteEmitter.fire({index:e,amount:n})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,n,s){if(!(n<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let l=n-1;l>=0;l--)this.set(e+l+s,this.get(e+l));let i=e+n+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<n;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},$t=3,On=Object.freeze(new Kc),id=0,fp=2,hc=class sk{constructor(e,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*$t);let i=n||wi.fromCharData([0,S1,1,0]);for(let l=0;l<e;++l)this.setCell(l,i);this.length=e}get(e){let n=this._data[e*$t+0],s=n&2097151;return[this._data[e*$t+1],n&2097152?this._combined[e]:s?so(s):"",n>>22,n&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s]}set(e,n){this._data[e*$t+1]=n[0],n[1].length>1?(this._combined[e]=n[1],this._data[e*$t+0]=e|2097152|n[2]<<22):this._data[e*$t+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(e){return this._data[e*$t+0]>>22}hasWidth(e){return this._data[e*$t+0]&12582912}getFg(e){return this._data[e*$t+1]}getBg(e){return this._data[e*$t+2]}hasContent(e){return this._data[e*$t+0]&4194303}getCodePoint(e){let n=this._data[e*$t+0];return n&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n&2097151}isCombined(e){return this._data[e*$t+0]&2097152}getString(e){let n=this._data[e*$t+0];return n&2097152?this._combined[e]:n&2097151?so(n&2097151):""}isProtected(e){return this._data[e*$t+2]&536870912}loadCell(e,n){return id=e*$t,n.content=this._data[id+0],n.fg=this._data[id+1],n.bg=this._data[id+2],n.content&2097152&&(n.combinedData=this._combined[e]),n.bg&268435456&&(n.extended=this._extendedAttrs[e]),n}setCell(e,n){n.content&2097152&&(this._combined[e]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[e]=n.extended),this._data[e*$t+0]=n.content,this._data[e*$t+1]=n.fg,this._data[e*$t+2]=n.bg}setCellFromCodepoint(e,n,s,i){i.bg&268435456&&(this._extendedAttrs[e]=i.extended),this._data[e*$t+0]=n|s<<22,this._data[e*$t+1]=i.fg,this._data[e*$t+2]=i.bg}addCodepointToCell(e,n,s){let i=this._data[e*$t+0];i&2097152?this._combined[e]+=so(n):i&2097151?(this._combined[e]=so(i&2097151)+so(n),i&=-2097152,i|=2097152):i=n|1<<22,s&&(i&=-12582913,i|=s<<22),this._data[e*$t+0]=i}insertCells(e,n,s){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),n<this.length-e){let i=new wi;for(let l=this.length-e-n-1;l>=0;--l)this.setCell(e+n+l,this.loadCell(e+l,i));for(let l=0;l<n;++l)this.setCell(e+l,s)}else for(let i=e;i<this.length;++i)this.setCell(i,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(e,n,s){if(e%=this.length,n<this.length-e){let i=new wi;for(let l=0;l<this.length-e-n;++l)this.setCell(e+l,this.loadCell(e+n+l,i));for(let l=this.length-n;l<this.length;++l)this.setCell(l,s)}else for(let i=e;i<this.length;++i)this.setCell(i,s);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,s)}replaceCells(e,n,s,i=!1){if(i){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,s);e<n&&e<this.length;)this.isProtected(e)||this.setCell(e,s),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,s);e<n&&e<this.length;)this.setCell(e++,s)}resize(e,n){if(e===this.length)return this._data.length*4*fp<this._data.buffer.byteLength;let s=e*$t;if(e>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let i=new Uint32Array(s);i.set(this._data),this._data=i}for(let i=this.length;i<e;++i)this.setCell(i,n)}else{this._data=this._data.subarray(0,s);let i=Object.keys(this._combined);for(let c=0;c<i.length;c++){let u=parseInt(i[c],10);u>=e&&delete this._combined[u]}let l=Object.keys(this._extendedAttrs);for(let c=0;c<l.length;c++){let u=parseInt(l[c],10);u>=e&&delete this._extendedAttrs[u]}}return this.length=e,s*4*fp<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*fp<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,n=!1){if(n){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,e);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,e)}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(let n in e._combined)this._combined[n]=e._combined[n];this._extendedAttrs={};for(let n in e._extendedAttrs)this._extendedAttrs[n]=e._extendedAttrs[n];this.isWrapped=e.isWrapped}clone(){let e=new sk(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let n in this._combined)e._combined[n]=this._combined[n];for(let n in this._extendedAttrs)e._extendedAttrs[n]=this._extendedAttrs[n];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*$t+0]&4194303)return e+(this._data[e*$t+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*$t+0]&4194303||this._data[e*$t+2]&50331648)return e+(this._data[e*$t+0]>>22);return 0}copyCellsFrom(e,n,s,i,l){let c=e._data;if(l)for(let h=i-1;h>=0;h--){for(let p=0;p<$t;p++)this._data[(s+h)*$t+p]=c[(n+h)*$t+p];c[(n+h)*$t+2]&268435456&&(this._extendedAttrs[s+h]=e._extendedAttrs[n+h])}else for(let h=0;h<i;h++){for(let p=0;p<$t;p++)this._data[(s+h)*$t+p]=c[(n+h)*$t+p];c[(n+h)*$t+2]&268435456&&(this._extendedAttrs[s+h]=e._extendedAttrs[n+h])}let u=Object.keys(e._combined);for(let h=0;h<u.length;h++){let p=parseInt(u[h],10);p>=n&&(this._combined[p-n+s]=e._combined[p])}}translateToString(e,n,s,i){n=n??0,s=s??this.length,e&&(s=Math.min(s,this.getTrimmedLength())),i&&(i.length=0);let l="";for(;n<s;){let c=this._data[n*$t+0],u=c&2097151,h=c&2097152?this._combined[n]:u?so(u):ro;if(l+=h,i)for(let p=0;p<h.length;++p)i.push(n);n+=c>>22||1}return i&&i.push(n),l}};function HR(t,e,n,s,i,l){let c=[];for(let u=0;u<t.length-1;u++){let h=u,p=t.get(++h);if(!p.isWrapped)continue;let v=[t.get(u)];for(;h<t.length&&p.isWrapped;)v.push(p),p=t.get(++h);if(!l&&s>=u&&s<h){u+=v.length-1;continue}let _=0,g=Lc(v,_,e),b=1,S=0;for(;b<v.length;){let C=Lc(v,b,e),N=C-S,E=n-g,O=Math.min(N,E);v[_].copyCellsFrom(v[b],S,g,O,!1),g+=O,g===n&&(_++,g=0),S+=O,S===C&&(b++,S=0),g===0&&_!==0&&v[_-1].getWidth(n-1)===2&&(v[_].copyCellsFrom(v[_-1],n-1,g++,1,!1),v[_-1].setCell(n-1,i))}v[_].replaceCells(g,n,i);let j=0;for(let C=v.length-1;C>0&&(C>_||v[C].getTrimmedLength()===0);C--)j++;j>0&&(c.push(u+v.length-j),c.push(j)),u+=v.length-1}return c}function UR(t,e){let n=[],s=0,i=e[s],l=0;for(let c=0;c<t.length;c++)if(i===c){let u=e[++s];t.onDeleteEmitter.fire({index:c-l,amount:u}),c+=u-1,l+=u,i=e[++s]}else n.push(c);return{layout:n,countRemoved:l}}function WR(t,e){let n=[];for(let s=0;s<e.length;s++)n.push(t.get(e[s]));for(let s=0;s<n.length;s++)t.set(s,n[s]);t.length=e.length}function qR(t,e,n){let s=[],i=t.map((h,p)=>Lc(t,p,e)).reduce((h,p)=>h+p),l=0,c=0,u=0;for(;u<i;){if(i-u<n){s.push(i-u);break}l+=n;let h=Lc(t,c,e);l>h&&(l-=h,c++);let p=t[c].getWidth(l-1)===2;p&&l--;let v=p?n-1:n;s.push(v),u+=v}return s}function Lc(t,e,n){if(e===t.length-1)return t[e].getTrimmedLength();let s=!t[e].hasContent(n-1)&&t[e].getWidth(n-1)===1,i=t[e+1].getWidth(0)===2;return s&&i?n-1:n}var ik=class rk{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=rk._nextId++,this._onDispose=this.register(new it),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Yo(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};ik._nextId=1;var KR=ik,Kn={},Po=Kn.B;Kn[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Kn.A={"#":"£"};Kn.B=void 0;Kn[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Kn.C=Kn[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Kn.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Kn.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Kn.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Kn.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Kn.E=Kn[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Kn.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Kn.H=Kn[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Kn["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Ob=4294967295,Bb=class{constructor(t,e,n){this._hasScrollback=t,this._optionsService=e,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=On.clone(),this.savedCharset=Po,this.markers=[],this._nullCell=wi.fromCharData([0,S1,1,0]),this._whitespaceCell=wi.fromCharData([0,ro,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new zd,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Db(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(t){return t?(this._nullCell.fg=t.fg,this._nullCell.bg=t.bg,this._nullCell.extended=t.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Dd),this._nullCell}getWhitespaceCell(t){return t?(this._whitespaceCell.fg=t.fg,this._whitespaceCell.bg=t.bg,this._whitespaceCell.extended=t.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Dd),this._whitespaceCell}getBlankLine(t,e){return new hc(this._bufferService.cols,this.getNullCell(t),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let t=this.ybase+this.y-this.ydisp;return t>=0&&t<this._rows}_getCorrectBufferLength(t){if(!this._hasScrollback)return t;let e=t+this._optionsService.rawOptions.scrollback;return e>Ob?Ob:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=On);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Db(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let n=this.getNullCell(On),s=0,i=this._getCorrectBufferLength(e);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<t)for(let c=0;c<this.lines.length;c++)s+=+this.lines.get(c).resize(t,n);let l=0;if(this._rows<e)for(let c=this._rows;c<e;c++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new hc(t,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+l+1?(this.ybase--,l++,this.ydisp>0&&this.ydisp--):this.lines.push(new hc(t,n)));else for(let c=this._rows;c>e;c--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let c=this.lines.length-i;c>0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=i}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),l&&(this.y+=l),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(t,e),this._cols>t))for(let l=0;l<this.lines.length;l++)s+=+this.lines.get(l).resize(t,n);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let t=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,t=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&t.backend==="conpty"&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,e){this._cols!==t&&(t>this._cols?this._reflowLarger(t,e):this._reflowSmaller(t,e))}_reflowLarger(t,e){let n=this._optionsService.rawOptions.reflowCursorLine,s=HR(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(On),n);if(s.length>0){let i=UR(this.lines,s);WR(this.lines,i.layout),this._reflowLargerAdjustViewport(t,e,i.countRemoved)}}_reflowLargerAdjustViewport(t,e,n){let s=this.getNullCell(On),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new hc(t,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(t,e){let n=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(On),i=[],l=0;for(let c=this.lines.length-1;c>=0;c--){let u=this.lines.get(c);if(!u||!u.isWrapped&&u.getTrimmedLength()<=t)continue;let h=[u];for(;u.isWrapped&&c>0;)u=this.lines.get(--c),h.unshift(u);if(!n){let O=this.ybase+this.y;if(O>=c&&O<c+h.length)continue}let p=h[h.length-1].getTrimmedLength(),v=qR(h,this._cols,t),_=v.length-h.length,g;this.ybase===0&&this.y!==this.lines.length-1?g=Math.max(0,this.y-this.lines.maxLength+_):g=Math.max(0,this.lines.length-this.lines.maxLength+_);let b=[];for(let O=0;O<_;O++){let x=this.getBlankLine(On,!0);b.push(x)}b.length>0&&(i.push({start:c+h.length+l,newLines:b}),l+=b.length),h.push(...b);let S=v.length-1,j=v[S];j===0&&(S--,j=v[S]);let C=h.length-_-1,N=p;for(;C>=0;){let O=Math.min(N,j);if(h[S]===void 0)break;if(h[S].copyCellsFrom(h[C],N-O,j-O,O,!0),j-=O,j===0&&(S--,j=v[S]),N-=O,N===0){C--;let x=Math.max(C,0);N=Lc(h,x,this._cols)}}for(let O=0;O<h.length;O++)v[O]<t&&h[O].setCell(v[O],s);let E=_-g;for(;E-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+l)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+_,this.ybase+e-1)}if(i.length>0){let c=[],u=[];for(let j=0;j<this.lines.length;j++)u.push(this.lines.get(j));let h=this.lines.length,p=h-1,v=0,_=i[v];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+l);let g=0;for(let j=Math.min(this.lines.maxLength-1,h+l-1);j>=0;j--)if(_&&_.start>p+g){for(let C=_.newLines.length-1;C>=0;C--)this.lines.set(j--,_.newLines[C]);j++,c.push({index:p+1,amount:_.newLines.length}),g+=_.newLines.length,_=i[++v]}else this.lines.set(j,u[p--]);let b=0;for(let j=c.length-1;j>=0;j--)c[j].index+=b,this.lines.onInsertEmitter.fire(c[j]),b+=c[j].amount;let S=Math.max(0,h+l-this.lines.maxLength);S>0&&this.lines.onTrimEmitter.fire(S)}}translateBufferLineToString(t,e,n=0,s){let i=this.lines.get(t);return i?i.translateToString(e,n,s):""}getWrappedRangeForLine(t){let e=t,n=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:e,last:n}}setupTabStops(t){for(t!=null?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);t<this._cols;t+=this._optionsService.rawOptions.tabStopWidth)this.tabs[t]=!0}prevStop(t){for(t==null&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(t==null&&(t=this.x);!this.tabs[++t]&&t<this._cols;);return t>=this._cols?this._cols-1:t<0?0:t}clearMarkers(t){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===t&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].dispose();this.markers.length=0,this._isClearing=!1}addMarker(t){let e=new KR(t);return this.markers.push(e),e.register(this.lines.onTrim(n=>{e.line-=n,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(n=>{e.line>=n.index&&(e.line+=n.amount)})),e.register(this.lines.onDelete(n=>{e.line>=n.index&&e.line<n.index+n.amount&&e.dispose(),e.line>n.index&&(e.line-=n.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},VR=class extends Ft{constructor(e,n){super(),this._optionsService=e,this._bufferService=n,this._onBufferActivate=this._register(new it),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 Bb(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Bb(!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,n){this._normal.resize(e,n),this._alt.resize(e,n),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},ok=2,ak=1,ag=class extends Ft{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new it),this.onResize=this._onResize.event,this._onScroll=this._register(new it),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,ok),this.rows=Math.max(t.rawOptions.rows||0,ak),this.buffers=this._register(new VR(t,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(t,e){let n=this.cols!==t,s=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==t.fg||s.getBg(0)!==t.bg)&&(s=n.getBlankLine(t,e),this._cachedBlankLine=s),s.isWrapped=e;let i=n.ybase+n.scrollTop,l=n.ybase+n.scrollBottom;if(n.scrollTop===0){let c=n.lines.isFull;l===n.lines.length-1?c?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(l+1,0,s.clone()),c?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let c=l-i+1;n.lines.shiftElements(i+1,c-1,-1),n.lines.set(l,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(t,e){let n=this.buffer;if(t<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else t+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+t,n.ybase),0),s!==n.ydisp&&(e||this._onScroll.fire(n.ydisp))}};ag=An([ut(0,Bs)],ag);var La={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:$d,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},YR=["normal","bold","100","200","300","400","500","600","700","800","900"],GR=class extends Ft{constructor(e){super(),this._onOptionChange=this._register(new it),this.onOptionChange=this._onOptionChange.event;let n={...La};for(let s in e)if(s in n)try{let i=e[s];n[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=n,this.options={...n},this._setupOptions(),this._register(_n(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,n){return this.onOptionChange(s=>{s===e&&n(this.rawOptions[e])})}onMultipleOptionChange(e,n){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&n()})}_setupOptions(){let e=s=>{if(!(s in La))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},n=(s,i)=>{if(!(s in La))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,n){switch(e){case"cursorStyle":if(n||(n=La[e]),!XR(n))throw new Error(`"${n}" is not a valid value for ${e}`);break;case"wordSeparator":n||(n=La[e]);break;case"fontWeight":case"fontWeightBold":if(typeof n=="number"&&1<=n&&n<=1e3)break;n=YR.includes(n)?n:La[e];break;case"cursorWidth":n=Math.floor(n);case"lineHeight":case"tabStopWidth":if(n<1)throw new Error(`${e} cannot be less than 1, value: ${n}`);break;case"minimumContrastRatio":n=Math.max(1,Math.min(21,Math.round(n*10)/10));break;case"scrollback":if(n=Math.min(n,4294967295),n<0)throw new Error(`${e} cannot be less than 0, value: ${n}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(n<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${n}`);break;case"rows":case"cols":if(!n&&n!==0)throw new Error(`${e} must be numeric, value: ${n}`);break;case"windowsPty":n=n??{};break}return n}};function XR(t){return t==="block"||t==="underline"||t==="bar"}function fc(t,e=5){if(typeof t!="object")return t;let n=Array.isArray(t)?[]:{};for(let s in t)n[s]=e<=1?t[s]:t[s]&&fc(t[s],e-1);return n}var $b=Object.freeze({insertMode:!1}),zb=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),lg=class extends Ft{constructor(e,n,s){super(),this._bufferService=e,this._logService=n,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new it),this.onData=this._onData.event,this._onUserInput=this._register(new it),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new it),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new it),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=fc($b),this.decPrivateModes=fc(zb)}reset(){this.modes=fc($b),this.decPrivateModes=fc(zb)}triggerDataEvent(e,n=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;n&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),n&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.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(n=>n.charCodeAt(0))),this._onBinary.fire(e))}};lg=An([ut(0,Os),ut(1,N1),ut(2,Bs)],lg);var Fb={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>t.button===4||t.action!==1?!1:(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>t.action!==32},DRAG:{events:23,restrict:t=>!(t.action===32&&t.button===3)},ANY:{events:31,restrict:t=>!0}};function pp(t,e){let n=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return t.button===4?(n|=64,n|=t.action):(n|=t.button&3,t.button&4&&(n|=64),t.button&8&&(n|=128),t.action===32?n|=32:t.action===0&&!e&&(n|=3)),n}var mp=String.fromCharCode,Hb={DEFAULT:t=>{let e=[pp(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${mp(e[0])}${mp(e[1])}${mp(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${pp(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${pp(t,!0)};${t.x};${t.y}${e}`}},cg=class extends Ft{constructor(t,e,n){super(),this._bufferService=t,this._coreService=e,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new it),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Fb))this.addProtocol(s,Fb[s]);for(let s of Object.keys(Hb))this.addEncoding(s,Hb[s]);this.reset()}addProtocol(t,e){this._protocols[t]=e}addEncoding(t,e){this._encodings[t]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(t){if(!this._protocols[t])throw new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,e,n){if(t.deltaY===0||t.shiftKey||e===void 0||n===void 0)return 0;let s=e/n,i=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=s+0,Math.abs(t.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(t,e){return e.altKey||e.ctrlKey||e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(t){if(t.col<0||t.col>=this._bufferService.cols||t.row<0||t.row>=this._bufferService.rows||t.button===4&&t.action===32||t.button===3&&t.action!==32||t.button!==4&&(t.action===2||t.action===3)||(t.col++,t.row++,t.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,t,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(t))return!1;let e=this._encodings[this._activeEncoding](t);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(t&1),up:!!(t&2),drag:!!(t&4),move:!!(t&8),wheel:!!(t&16)}}_equalEvents(t,e,n){if(n){if(t.x!==e.x||t.y!==e.y)return!1}else if(t.col!==e.col||t.row!==e.row)return!1;return!(t.button!==e.button||t.action!==e.action||t.ctrl!==e.ctrl||t.alt!==e.alt||t.shift!==e.shift)}};cg=An([ut(0,Os),ut(1,Qo),ut(2,Bs)],cg);var gp=[[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]],JR=[[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]],Wn;function QR(t,e){let n=0,s=e.length-1,i;if(t<e[0][0]||t>e[s][1])return!1;for(;s>=n;)if(i=n+s>>1,t>e[i][1])n=i+1;else if(t<e[i][0])s=i-1;else return!0;return!1}var ZR=class{constructor(){if(this.version="6",!Wn){Wn=new Uint8Array(65536),Wn.fill(1),Wn[0]=0,Wn.fill(0,1,32),Wn.fill(0,127,160),Wn.fill(2,4352,4448),Wn[9001]=2,Wn[9002]=2,Wn.fill(2,11904,42192),Wn[12351]=1,Wn.fill(2,44032,55204),Wn.fill(2,63744,64256),Wn.fill(2,65040,65050),Wn.fill(2,65072,65136),Wn.fill(2,65280,65377),Wn.fill(2,65504,65511);for(let e=0;e<gp.length;++e)Wn.fill(0,gp[e][0],gp[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Wn[e]:QR(e,JR)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,n){let s=this.wcwidth(e),i=s===0&&n!==0;if(i){let l=Oo.extractWidth(n);l===0?i=!1:l>s&&(s=l)}return Oo.createPropertyValue(0,s,i)}},Oo=class Cd{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new it,this.onChange=this._onChange.event;let e=new ZR;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,n,s=!1){return(e&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(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let n=0,s=0,i=e.length;for(let l=0;l<i;++l){let c=e.charCodeAt(l);if(55296<=c&&c<=56319){if(++l>=i)return n+this.wcwidth(c);let p=e.charCodeAt(l);56320<=p&&p<=57343?c=(c-55296)*1024+p-56320+65536:n+=this.wcwidth(p)}let u=this.charProperties(c,s),h=Cd.extractWidth(u);Cd.extractShouldJoin(u)&&(h-=Cd.extractWidth(s)),n+=h,s=u}return n}charProperties(e,n){return this._activeProvider.charProperties(e,n)}},eA=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,n){this._charsets[e]=n,this.glevel===e&&(this.charset=n)}};function Ub(t){var s;let e=(s=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1))==null?void 0:s.get(t.cols-1),n=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);n&&e&&(n.isWrapped=e[3]!==0&&e[3]!==32)}var ql=2147483647,tA=256,lk=class ug{constructor(e=32,n=32){if(this.maxLength=e,this.maxSubParamsLength=n,n>tA)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let n=new ug;if(!e.length)return n;for(let s=Array.isArray(e[0])?1:0;s<e.length;++s){let i=e[s];if(Array.isArray(i))for(let l=0;l<i.length;++l)n.addSubParam(i[l]);else n.addParam(i)}return n}clone(){let e=new ug(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let n=0;n<this.length;++n){e.push(this.params[n]);let s=this._subParamsIdx[n]>>8,i=this._subParamsIdx[n]&255;i-s>0&&e.push(Array.prototype.slice.call(this._subParams,s,i))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>ql?ql:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>ql?ql:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let n=this._subParamsIdx[e]>>8,s=this._subParamsIdx[e]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let e={};for(let n=0;n<this.length;++n){let s=this._subParamsIdx[n]>>8,i=this._subParamsIdx[n]&255;i-s>0&&(e[n]=this._subParams.slice(s,i))}return e}addDigit(e){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,i=s[n-1];s[n-1]=~i?Math.min(i*10+e,ql):e}},Kl=[],nA=class{constructor(){this._state=0,this._active=Kl,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,n){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(n),{dispose:()=>{let i=s.indexOf(n);i!==-1&&s.splice(i,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=Kl}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=Kl,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Kl,!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,n,s){if(!this._active.length)this._handlerFb(this._id,"PUT",hh(e,n,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,n,s)}start(){this.reset(),this._state=1}put(e,n,s){if(this._state!==3){if(this._state===1)for(;n<s;){let i=e[n++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-n>0&&this._put(e,n,s)}}end(e,n=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,i=this._active.length-1,l=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=n,l=this._stack.fallThrough,this._stack.paused=!1),!l&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Kl,this._id=-1,this._state=0}}},si=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,n,s){this._hitLimit||(this._data+=hh(e,n,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let n=!1;if(this._hitLimit)n=!1;else if(e&&(n=this._handler(this._data),n instanceof Promise))return n.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,n}},Vl=[],sA=class{constructor(){this._handlers=Object.create(null),this._active=Vl,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Vl}registerHandler(e,n){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(n),{dispose:()=>{let i=s.indexOf(n);i!==-1&&s.splice(i,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=Vl,this._ident=0}hook(e,n){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Vl,!this._active.length)this._handlerFb(this._ident,"HOOK",n);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(n)}put(e,n,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",hh(e,n,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,n,s)}unhook(e,n=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,l=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=n,l=this._stack.fallThrough,this._stack.paused=!1),!l&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Vl,this._ident=0}},pc=new lk;pc.addParam(0);var Wb=class{constructor(t){this._handler=t,this._data="",this._params=pc,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():pc,this._data="",this._hitLimit=!1}put(t,e,n){this._hitLimit||(this._data+=hh(t,e,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(n=>(this._params=pc,this._data="",this._hitLimit=!1,n));return this._params=pc,this._data="",this._hitLimit=!1,e}},iA=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,n){this.table.fill(e<<4|n)}add(e,n,s,i){this.table[n<<8|e]=s<<4|i}addMany(e,n,s,i){for(let l=0;l<e.length;l++)this.table[n<<8|e[l]]=s<<4|i}},gi=160,rA=(function(){let t=new iA(4095),e=Array.apply(null,Array(256)).map((u,h)=>h),n=(u,h)=>e.slice(u,h),s=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let l=n(0,14),c;t.setDefault(1,0),t.addMany(s,0,2,0);for(c in l)t.addMany([24,26,153,154],c,3,0),t.addMany(n(128,144),c,3,0),t.addMany(n(144,152),c,3,0),t.add(156,c,0,0),t.add(27,c,11,1),t.add(157,c,4,8),t.addMany([152,158,159],c,0,7),t.add(155,c,11,3),t.add(144,c,11,9);return t.addMany(i,0,3,0),t.addMany(i,1,3,1),t.add(127,1,0,1),t.addMany(i,8,0,8),t.addMany(i,3,3,3),t.add(127,3,0,3),t.addMany(i,4,3,4),t.add(127,4,0,4),t.addMany(i,6,3,6),t.addMany(i,5,3,5),t.add(127,5,0,5),t.addMany(i,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(s,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(n(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(s,7,0,7),t.addMany(i,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(n(64,127),3,7,0),t.addMany(n(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(n(48,60),4,8,4),t.addMany(n(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(n(32,64),6,0,6),t.add(127,6,0,6),t.addMany(n(64,127),6,0,0),t.addMany(n(32,48),3,9,5),t.addMany(n(32,48),5,9,5),t.addMany(n(48,64),5,0,6),t.addMany(n(64,127),5,7,0),t.addMany(n(32,48),4,9,5),t.addMany(n(32,48),1,9,2),t.addMany(n(32,48),2,9,2),t.addMany(n(48,127),2,10,0),t.addMany(n(48,80),1,10,0),t.addMany(n(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(n(96,127),1,10,0),t.add(80,1,11,9),t.addMany(i,9,0,9),t.add(127,9,0,9),t.addMany(n(28,32),9,0,9),t.addMany(n(32,48),9,9,12),t.addMany(n(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(i,11,0,11),t.addMany(n(32,128),11,0,11),t.addMany(n(28,32),11,0,11),t.addMany(i,10,0,10),t.add(127,10,0,10),t.addMany(n(28,32),10,0,10),t.addMany(n(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(n(32,48),10,9,12),t.addMany(i,12,0,12),t.add(127,12,0,12),t.addMany(n(28,32),12,0,12),t.addMany(n(32,48),12,9,12),t.addMany(n(48,64),12,0,11),t.addMany(n(64,127),12,12,13),t.addMany(n(64,127),10,12,13),t.addMany(n(64,127),9,12,13),t.addMany(i,13,13,13),t.addMany(s,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(gi,0,2,0),t.add(gi,8,5,8),t.add(gi,6,0,6),t.add(gi,11,0,11),t.add(gi,13,13,13),t})(),oA=class extends Ft{constructor(e=rA){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 lk,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(n,s,i)=>{},this._executeHandlerFb=n=>{},this._csiHandlerFb=(n,s)=>{},this._escHandlerFb=n=>{},this._errorHandlerFb=n=>n,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(_n(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new nA),this._dcsParser=this._register(new sA),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,n=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let l=0;l<e.intermediates.length;++l){let c=e.intermediates.charCodeAt(l);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=c}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(n[0]>i||i>n[1])throw new Error(`final must be in range ${n[0]} .. ${n[1]}`);return s<<=8,s|=i,s}identToString(e){let n=[];for(;e;)n.push(String.fromCharCode(e&255)),e>>=8;return n.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,n){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(n),{dispose:()=>{let l=i.indexOf(n);l!==-1&&i.splice(l,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,n){this._executeHandlers[e.charCodeAt(0)]=n}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,n){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(n),{dispose:()=>{let l=i.indexOf(n);l!==-1&&i.splice(l,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,n){return this._dcsParser.registerHandler(this._identifier(e),n)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,n){return this._oscParser.registerHandler(e,n)}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,n,s,i,l){this._parseStack.state=e,this._parseStack.handlers=n,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=l}parse(e,n,s){let i=0,l=0,c=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let h=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&p>-1){for(;p>=0&&(u=h[p](this._params),u!==!0);p--)if(u instanceof Promise)return this._parseStack.handlerPos=p,u}this._parseStack.handlers=[];break;case 4:if(s===!1&&p>-1){for(;p>=0&&(u=h[p](),u!==!0);p--)if(u instanceof Promise)return this._parseStack.handlerPos=p,u}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(i!==24&&i!==26,s),u)return u;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],u=this._oscParser.end(i!==24&&i!==26,s),u)return u;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let h=c;h<n;++h){switch(i=e[h],l=this._transitions.table[this.currentState<<8|(i<160?i:gi)],l>>4){case 2:for(let b=h+1;;++b){if(b>=n||(i=e[b])<32||i>126&&i<gi){this._printHandler(e,h,b),h=b-1;break}if(++b>=n||(i=e[b])<32||i>126&&i<gi){this._printHandler(e,h,b),h=b-1;break}if(++b>=n||(i=e[b])<32||i>126&&i<gi){this._printHandler(e,h,b),h=b-1;break}if(++b>=n||(i=e[b])<32||i>126&&i<gi){this._printHandler(e,h,b),h=b-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:h,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let p=this._csiHandlers[this._collect<<8|i],v=p?p.length-1:-1;for(;v>=0&&(u=p[v](this._params),u!==!0);v--)if(u instanceof Promise)return this._preserveStack(3,p,v,l,h),u;v<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++h<n&&(i=e[h])>47&&i<60);h--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let _=this._escHandlers[this._collect<<8|i],g=_?_.length-1:-1;for(;g>=0&&(u=_[g](),u!==!0);g--)if(u instanceof Promise)return this._preserveStack(4,_,g,l,h),u;g<0&&this._escHandlerFb(this._collect<<8|i),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|i,this._params);break;case 13:for(let b=h+1;;++b)if(b>=n||(i=e[b])===24||i===26||i===27||i>127&&i<gi){this._dcsParser.put(e,h,b),h=b-1;break}break;case 14:if(u=this._dcsParser.unhook(i!==24&&i!==26),u)return this._preserveStack(6,[],0,l,h),u;i===27&&(l|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let b=h+1;;b++)if(b>=n||(i=e[b])<32||i>127&&i<gi){this._oscParser.put(e,h,b),h=b-1;break}break;case 6:if(u=this._oscParser.end(i!==24&&i!==26),u)return this._preserveStack(5,[],0,l,h),u;i===27&&(l|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=l&15}}},aA=/^([\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})$/,lA=/^[\da-f]+$/;function qb(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let n=aA.exec(e);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(e.indexOf("#")===0&&(e=e.slice(1),lA.exec(e)&&[3,6,9,12].includes(e.length))){let n=e.length/3,s=[0,0,0];for(let i=0;i<3;++i){let l=parseInt(e.slice(n*i,n*i+n),16);s[i]=n===1?l<<4:n===2?l:n===3?l>>4:l>>8}return s}}function vp(t,e){let n=t.toString(16),s=n.length<2?"0"+n:n;switch(e){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function cA(t,e=16){let[n,s,i]=t;return`rgb:${vp(n,e)}/${vp(s,e)}/${vp(i,e)}`}var uA={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Gr=131072,Kb=10;function Vb(t,e){if(t>24)return e.setWinLines||!1;switch(t){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var Yb=5e3,Gb=0,dA=class extends Ft{constructor(t,e,n,s,i,l,c,u,h=new oA){super(),this._bufferService=t,this._charsetService=e,this._coreService=n,this._logService=s,this._optionsService=i,this._oscLinkService=l,this._coreMouseService=c,this._unicodeService=u,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Rj,this._utf8Decoder=new Aj,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=On.clone(),this._eraseAttrDataInternal=On.clone(),this._onRequestBell=this._register(new it),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new it),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new it),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new it),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new it),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new it),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new it),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new it),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new it),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new it),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new it),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new it),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new it),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 dg(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,v)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:v.toArray()})}),this._parser.setEscHandlerFallback(p=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(p)})}),this._parser.setExecuteHandlerFallback(p=>{this._logService.debug("Unknown EXECUTE code: ",{code:p})}),this._parser.setOscHandlerFallback((p,v,_)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:v,data:_})}),this._parser.setDcsHandlerFallback((p,v,_)=>{v==="HOOK"&&(_=_.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:v,payload:_})}),this._parser.setPrintHandler((p,v,_)=>this.print(p,v,_)),this._parser.registerCsiHandler({final:"@"},p=>this.insertChars(p)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},p=>this.scrollLeft(p)),this._parser.registerCsiHandler({final:"A"},p=>this.cursorUp(p)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},p=>this.scrollRight(p)),this._parser.registerCsiHandler({final:"B"},p=>this.cursorDown(p)),this._parser.registerCsiHandler({final:"C"},p=>this.cursorForward(p)),this._parser.registerCsiHandler({final:"D"},p=>this.cursorBackward(p)),this._parser.registerCsiHandler({final:"E"},p=>this.cursorNextLine(p)),this._parser.registerCsiHandler({final:"F"},p=>this.cursorPrecedingLine(p)),this._parser.registerCsiHandler({final:"G"},p=>this.cursorCharAbsolute(p)),this._parser.registerCsiHandler({final:"H"},p=>this.cursorPosition(p)),this._parser.registerCsiHandler({final:"I"},p=>this.cursorForwardTab(p)),this._parser.registerCsiHandler({final:"J"},p=>this.eraseInDisplay(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},p=>this.eraseInDisplay(p,!0)),this._parser.registerCsiHandler({final:"K"},p=>this.eraseInLine(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},p=>this.eraseInLine(p,!0)),this._parser.registerCsiHandler({final:"L"},p=>this.insertLines(p)),this._parser.registerCsiHandler({final:"M"},p=>this.deleteLines(p)),this._parser.registerCsiHandler({final:"P"},p=>this.deleteChars(p)),this._parser.registerCsiHandler({final:"S"},p=>this.scrollUp(p)),this._parser.registerCsiHandler({final:"T"},p=>this.scrollDown(p)),this._parser.registerCsiHandler({final:"X"},p=>this.eraseChars(p)),this._parser.registerCsiHandler({final:"Z"},p=>this.cursorBackwardTab(p)),this._parser.registerCsiHandler({final:"`"},p=>this.charPosAbsolute(p)),this._parser.registerCsiHandler({final:"a"},p=>this.hPositionRelative(p)),this._parser.registerCsiHandler({final:"b"},p=>this.repeatPrecedingCharacter(p)),this._parser.registerCsiHandler({final:"c"},p=>this.sendDeviceAttributesPrimary(p)),this._parser.registerCsiHandler({prefix:">",final:"c"},p=>this.sendDeviceAttributesSecondary(p)),this._parser.registerCsiHandler({final:"d"},p=>this.linePosAbsolute(p)),this._parser.registerCsiHandler({final:"e"},p=>this.vPositionRelative(p)),this._parser.registerCsiHandler({final:"f"},p=>this.hVPosition(p)),this._parser.registerCsiHandler({final:"g"},p=>this.tabClear(p)),this._parser.registerCsiHandler({final:"h"},p=>this.setMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"h"},p=>this.setModePrivate(p)),this._parser.registerCsiHandler({final:"l"},p=>this.resetMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"l"},p=>this.resetModePrivate(p)),this._parser.registerCsiHandler({final:"m"},p=>this.charAttributes(p)),this._parser.registerCsiHandler({final:"n"},p=>this.deviceStatus(p)),this._parser.registerCsiHandler({prefix:"?",final:"n"},p=>this.deviceStatusPrivate(p)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},p=>this.softReset(p)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},p=>this.setCursorStyle(p)),this._parser.registerCsiHandler({final:"r"},p=>this.setScrollRegion(p)),this._parser.registerCsiHandler({final:"s"},p=>this.saveCursor(p)),this._parser.registerCsiHandler({final:"t"},p=>this.windowOptions(p)),this._parser.registerCsiHandler({final:"u"},p=>this.restoreCursor(p)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},p=>this.insertColumns(p)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},p=>this.deleteColumns(p)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},p=>this.selectProtected(p)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},p=>this.requestMode(p,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},p=>this.requestMode(p,!1)),this._parser.setExecuteHandler($e.BEL,()=>this.bell()),this._parser.setExecuteHandler($e.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($e.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($e.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($e.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($e.BS,()=>this.backspace()),this._parser.setExecuteHandler($e.HT,()=>this.tab()),this._parser.setExecuteHandler($e.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($e.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(xd.IND,()=>this.index()),this._parser.setExecuteHandler(xd.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(xd.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new si(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new si(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new si(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new si(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new si(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new si(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new si(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new si(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new si(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new si(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new si(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new si(p=>this.restoreCursorColor(p))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let p in Kn)this._parser.registerEscHandler({intermediates:"(",final:p},()=>this.selectCharset("("+p)),this._parser.registerEscHandler({intermediates:")",final:p},()=>this.selectCharset(")"+p)),this._parser.registerEscHandler({intermediates:"*",final:p},()=>this.selectCharset("*"+p)),this._parser.registerEscHandler({intermediates:"+",final:p},()=>this.selectCharset("+"+p)),this._parser.registerEscHandler({intermediates:"-",final:p},()=>this.selectCharset("-"+p)),this._parser.registerEscHandler({intermediates:".",final:p},()=>this.selectCharset("."+p)),this._parser.registerEscHandler({intermediates:"/",final:p},()=>this.selectCharset("/"+p));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(p=>(this._logService.error("Parsing error: ",p),p)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Wb((p,v)=>this.requestStatusString(p,v)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),Yb))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${Yb} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let n,s=this._activeBuffer.x,i=this._activeBuffer.y,l=0,c=this._parseStack.paused;if(c){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>Gr&&(l=this._parseStack.position+Gr)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,p=>String.fromCharCode(p)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(p=>p.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<Gr&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Gr))),c||this._dirtyRowTracker.clearRange(),t.length>Gr)for(let p=l;p<t.length;p+=Gr){let v=p+Gr<t.length?p+Gr:t.length,_=typeof t=="string"?this._stringDecoder.decode(t.substring(p,v),this._parseBuffer):this._utf8Decoder.decode(t.subarray(p,v),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,_))return this._preserveStack(s,i,_,p),this._logSlowResolvingAsync(n),n}else if(!c){let p=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,p))return this._preserveStack(s,i,p,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let u=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(u,this._bufferService.rows-1)})}print(t,e,n){let s,i,l=this._charsetService.charset,c=this._optionsService.rawOptions.screenReaderMode,u=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,p=this._coreService.modes.insertMode,v=this._curAttrData,_=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-e>0&&_.getWidth(this._activeBuffer.x-1)===2&&_.setCellFromCodepoint(this._activeBuffer.x-1,0,1,v);let g=this._parser.precedingJoinState;for(let b=e;b<n;++b){if(s=t[b],s<127&&l){let N=l[String.fromCharCode(s)];N&&(s=N.charCodeAt(0))}let S=this._unicodeService.charProperties(s,g);i=Oo.extractWidth(S);let j=Oo.extractShouldJoin(S),C=j?Oo.extractWidth(g):0;if(g=S,c&&this._onA11yChar.fire(so(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-C>u){if(h){let N=_,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),_=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),C>0&&_ instanceof hc&&_.copyCellsFrom(N,E,0,C,!1);E<u;)N.setCellFromCodepoint(E++,0,1,v)}else if(this._activeBuffer.x=u-1,i===2)continue}if(j&&this._activeBuffer.x){let N=_.getWidth(this._activeBuffer.x-1)?1:2;_.addCodepointToCell(this._activeBuffer.x-N,s,i);for(let E=i-C;--E>=0;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,v);continue}if(p&&(_.insertCells(this._activeBuffer.x,i-C,this._activeBuffer.getNullCell(v)),_.getWidth(u-1)===2&&_.setCellFromCodepoint(u-1,0,1,v)),_.setCellFromCodepoint(this._activeBuffer.x++,s,i,v),i>0)for(;--i;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,v)}this._parser.precedingJoinState=g,this._activeBuffer.x<u&&n-e>0&&_.getWidth(this._activeBuffer.x)===0&&!_.hasContent(this._activeBuffer.x)&&_.setCellFromCodepoint(this._activeBuffer.x,0,1,v),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,n=>Vb(n.params[0],this._optionsService.rawOptions.windowOptions)?e(n):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new Wb(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new si(e))}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 t;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&&((t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&t.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-t),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(t=this._bufferService.cols-1){this._activeBuffer.x=Math.min(t,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(t,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=t,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+e)}cursorUp(t){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,t.params[0]||1)):this._moveCursor(0,-(t.params[0]||1)),!0}cursorDown(t){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,t.params[0]||1)):this._moveCursor(0,t.params[0]||1),!0}cursorForward(t){return this._moveCursor(t.params[0]||1,0),!0}cursorBackward(t){return this._moveCursor(-(t.params[0]||1),0),!0}cursorNextLine(t){return this.cursorDown(t),this._activeBuffer.x=0,!0}cursorPrecedingLine(t){return this.cursorUp(t),this._activeBuffer.x=0,!0}cursorCharAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(t){return this._setCursor(t.length>=2?(t.params[1]||1)-1:0,(t.params[0]||1)-1),!0}charPosAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(t){return this._moveCursor(t.params[0]||1,0),!0}linePosAbsolute(t){return this._setCursor(this._activeBuffer.x,(t.params[0]||1)-1),!0}vPositionRelative(t){return this._moveCursor(0,t.params[0]||1),!0}hVPosition(t){return this.cursorPosition(t),!0}tabClear(t){let e=t.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let e=t.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,e,n,s=!1,i=!1){let l=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);l.replaceCells(e,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),s&&(l.isWrapped=!1)}_resetBufferLine(t,e=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),n.isWrapped=!1)}eraseInDisplay(t,e=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(t.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,e);n<this._bufferService.rows;n++)this._resetBufferLine(n,e);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,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,e);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,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,0),this._onScroll.fire(0));break}return!0}eraseInLine(t,e=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let e=t.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,i=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;e--;)this._activeBuffer.lines.splice(i-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(t){this._restrictCursor();let e=t.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;e--;)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(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.insertCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.deleteCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(t){let e=t.params[0]||1;for(;e--;)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(t){let e=t.params[0]||1;for(;e--;)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(On));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.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,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.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,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.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,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.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,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(t.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(t){let e=this._parser.precedingJoinState;if(!e)return!0;let n=t.params[0]||1,s=Oo.extractWidth(e),i=this._activeBuffer.x-s,l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),c=new Uint32Array(l.length*n),u=0;for(let p=0;p<l.length;){let v=l.codePointAt(p)||0;c[u++]=v,p+=v>65535?2:1}let h=u;for(let p=1;p<n;++p)c.copyWithin(h,0,u),h+=u;return this.print(c,0,h),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent($e.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent($e.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent($e.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent($e.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent($e.ESC+"[>83;40003;0c")),!0}_is(t){return(this._optionsService.rawOptions.termName+"").indexOf(t)===0}setMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Po),this._charsetService.setgCharset(1,Po),this._charsetService.setgCharset(2,Po),this._charsetService.setgCharset(3,Po);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(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){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(),t.params[e]===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(t,e){(j=>(j[j.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",j[j.SET=1]="SET",j[j.RESET=2]="RESET",j[j.PERMANENTLY_SET=3]="PERMANENTLY_SET",j[j.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:l}=this._coreMouseService,c=this._coreService,{buffers:u,cols:h}=this._bufferService,{active:p,alt:v}=u,_=this._optionsService.rawOptions,g=(j,C)=>(c.triggerDataEvent(`${$e.ESC}[${e?"":"?"}${j};${C}$y`),!0),b=j=>j?1:2,S=t.params[0];return e?S===2?g(S,4):S===4?g(S,b(c.modes.insertMode)):S===12?g(S,3):S===20?g(S,b(_.convertEol)):g(S,0):S===1?g(S,b(s.applicationCursorKeys)):S===3?g(S,_.windowOptions.setWinLines?h===80?2:h===132?1:0:0):S===6?g(S,b(s.origin)):S===7?g(S,b(s.wraparound)):S===8?g(S,3):S===9?g(S,b(i==="X10")):S===12?g(S,b(_.cursorBlink)):S===25?g(S,b(!c.isCursorHidden)):S===45?g(S,b(s.reverseWraparound)):S===66?g(S,b(s.applicationKeypad)):S===67?g(S,4):S===1e3?g(S,b(i==="VT200")):S===1002?g(S,b(i==="DRAG")):S===1003?g(S,b(i==="ANY")):S===1004?g(S,b(s.sendFocus)):S===1005?g(S,4):S===1006?g(S,b(l==="SGR")):S===1015?g(S,4):S===1016?g(S,b(l==="SGR_PIXELS")):S===1048?g(S,1):S===47||S===1047||S===1049?g(S,b(p===v)):S===2004?g(S,b(s.bracketedPasteMode)):S===2026?g(S,b(s.synchronizedOutput)):g(S,0)}_updateAttrColor(t,e,n,s,i){return e===2?(t|=50331648,t&=-16777216,t|=Kc.fromColorRGB([n,s,i])):e===5&&(t&=-50331904,t|=33554432|n&255),t}_extractColor(t,e,n){let s=[0,0,-1,0,0,0],i=0,l=0;do{if(s[l+i]=t.params[e+l],t.hasSubParams(e+l)){let c=t.getSubParams(e+l),u=0;do s[1]===5&&(i=1),s[l+u+1+i]=c[u];while(++u<c.length&&u+l+1+i<s.length);break}if(s[1]===5&&l+i>=2||s[1]===2&&l+i>=5)break;s[1]&&(i=1)}while(++l+e<t.length&&l+i<s.length);for(let c=2;c<s.length;++c)s[c]===-1&&(s[c]=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 l}_processUnderline(t,e){e.extended=e.extended.clone(),(!~t||t>5)&&(t=1),e.extended.underlineStyle=t,e.fg|=268435456,t===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(t){t.fg=On.fg,t.bg=On.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(t.length===1&&t.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=t.length,n,s=this._curAttrData;for(let i=0;i<e;i++)n=t.params[i],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(t.hasSubParams(i)?t.getSubParams(i)[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|=On.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=On.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(t,i,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|=On.fg&16777215,s.bg&=-67108864,s.bg|=On.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${$e.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$e.ESC}[${e};${n}R`);break}return!0}deviceStatusPrivate(t){switch(t.params[0]){case 6:let e=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$e.ESC}[?${e};${n}R`);break}return!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=On.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(t){let e=t.length===0?1:t.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){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=e%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(t){let e=t.params[0]||1,n;return(t.length<2||(n=t.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(t){if(!Vb(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${$e.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Kb&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Kb&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(t){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(t){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(t){return this._windowTitle=t,this._onTitleChange.fire(t),!0}setIconName(t){return this._iconName=t,!0}setOrReportIndexedColor(t){let e=[],n=t.split(";");for(;n.length>1;){let s=n.shift(),i=n.shift();if(/^\d+$/.exec(s)){let l=parseInt(s);if(Xb(l))if(i==="?")e.push({type:0,index:l});else{let c=qb(i);c&&e.push({type:1,index:l,color:c})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(t){let e=t.indexOf(";");if(e===-1)return!0;let n=t.slice(0,e).trim(),s=t.slice(e+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let n=t.split(":"),s,i=n.findIndex(l=>l.startsWith("id="));return i!==-1&&(s=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,e){let n=t.split(";");for(let s=0;s<n.length&&!(e>=this._specialColors.length);++s,++e)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let i=qb(n[s]);i&&this._onColor.fire([{type:1,index:this._specialColors[e],color:i}])}return!0}setOrReportFgColor(t){return this._setOrReportSpecialColor(t,0)}setOrReportBgColor(t){return this._setOrReportSpecialColor(t,1)}setOrReportCursorColor(t){return this._setOrReportSpecialColor(t,2)}restoreIndexedColor(t){if(!t)return this._onColor.fire([{type:2}]),!0;let e=[],n=t.split(";");for(let s=0;s<n.length;++s)if(/^\d+$/.exec(n[s])){let i=parseInt(n[s]);Xb(i)&&e.push({type:2,index:i})}return e.length&&this._onColor.fire(e),!0}restoreFgColor(t){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(t){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(t){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,Po),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(uA[t[0]],Kn[t[1]]||Po),!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 t=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,t,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=On.clone(),this._eraseAttrDataInternal=On.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new wi;t.content=1<<22|69,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e<this._bufferService.rows;++e){let n=this._activeBuffer.ybase+this._activeBuffer.y+e,s=this._activeBuffer.lines.get(n);s&&(s.fill(t),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let n=c=>(this._coreService.triggerDataEvent(`${$e.ESC}${c}${$e.ESC}\\`),!0),s=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(t==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:t==='"p'?'P1$r61;1"p':t==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},dg=class{constructor(t){this._bufferService=t,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(t){t<this.start?this.start=t:t>this.end&&(this.end=t)}markRangeDirty(t,e){t>e&&(Gb=t,t=e,e=Gb),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};dg=An([ut(0,Os)],dg);function Xb(t){return 0<=t&&t<256}var hA=5e7,Jb=12,fA=50,pA=class extends Ft{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 it),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,n){if(n!==void 0&&this._syncCalls>n){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,n){if(this._pendingData>hA)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(n),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(n)}_innerWrite(e=0,n=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],l=this._action(i,n);if(l){let u=h=>performance.now()-s>=Jb?setTimeout(()=>this._innerWrite(0,h)):this._innerWrite(s,h);l.catch(h=>(queueMicrotask(()=>{throw h}),Promise.resolve(!1))).then(u);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=Jb)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>fA&&(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()}},hg=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let n=this._bufferService.buffer;if(e.id===void 0){let h=n.addMarker(n.ybase+n.y),p={data:e,id:this._nextId++,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(p,h)),this._dataByLinkId.set(p.id,p),p.id}let s=e,i=this._getEntryIdKey(s),l=this._entriesWithId.get(i);if(l)return this.addLineToLink(l.id,n.ybase+n.y),l.id;let c=n.addMarker(n.ybase+n.y),u={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(u,c)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,n){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==n)){let i=this._bufferService.buffer.addMarker(n);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){var n;return(n=this._dataByLinkId.get(e))==null?void 0:n.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,n){let s=e.lines.indexOf(n);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};hg=An([ut(0,Os)],hg);var Qb=!1,mA=class extends Ft{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ya),this._onBinary=this._register(new it),this.onBinary=this._onBinary.event,this._onData=this._register(new it),this.onData=this._onData.event,this._onLineFeed=this._register(new it),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new it),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new it),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new it),this._instantiationService=new $R,this.optionsService=this._register(new GR(e)),this._instantiationService.setService(Bs,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(ag)),this._instantiationService.setService(Os,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(og)),this._instantiationService.setService(N1,this._logService),this.coreService=this._register(this._instantiationService.createInstance(lg)),this._instantiationService.setService(Qo,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(cg)),this._instantiationService.setService(E1,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Oo)),this._instantiationService.setService(Ij,this.unicodeService),this._charsetService=this._instantiationService.createInstance(eA),this._instantiationService.setService(Pj,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(hg),this._instantiationService.setService(j1,this._oscLinkService),this._inputHandler=this._register(new dA(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(_s.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(_s.forward(this._bufferService.onResize,this._onResize)),this._register(_s.forward(this.coreService.onData,this._onData)),this._register(_s.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 pA((n,s)=>this._inputHandler.parse(n,s))),this._register(_s.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new it),this._onScroll.event(e=>{var n;(n=this._onScrollApi)==null||n.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 n in e)this.optionsService.options[n]=e[n]}write(e,n){this._writeBuffer.write(e,n)}writeSync(e,n){this._logService.logLevel<=3&&!Qb&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Qb=!0),this._writeBuffer.writeSync(e,n)}input(e,n=!0){this.coreService.triggerDataEvent(e,n)}resize(e,n){isNaN(e)||isNaN(n)||(e=Math.max(e,ok),n=Math.max(n,ak),this._bufferService.resize(e,n))}scroll(e,n=!1){this._bufferService.scroll(e,n)}scrollLines(e,n){this._bufferService.scrollLines(e,n)}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 n=e-this._bufferService.buffer.ydisp;n!==0&&this.scrollLines(n)}registerEscHandler(e,n){return this._inputHandler.registerEscHandler(e,n)}registerDcsHandler(e,n){return this._inputHandler.registerDcsHandler(e,n)}registerCsiHandler(e,n){return this._inputHandler.registerCsiHandler(e,n)}registerOscHandler(e,n){return this._inputHandler.registerOscHandler(e,n)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,n=this.optionsService.rawOptions.windowsPty;n&&n.buildNumber!==void 0&&n.buildNumber!==void 0?e=n.backend==="conpty"&&n.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(Ub.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Ub(this._bufferService),!1))),this._windowsWrappingHeuristics.value=_n(()=>{for(let n of e)n.dispose()})}}},gA={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 vA(t,e,n,s){var c;let i={type:0,cancel:!1,key:void 0},l=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:t.key==="UIKeyInputUpArrow"?e?i.key=$e.ESC+"OA":i.key=$e.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?i.key=$e.ESC+"OD":i.key=$e.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?i.key=$e.ESC+"OC":i.key=$e.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?i.key=$e.ESC+"OB":i.key=$e.ESC+"[B");break;case 8:i.key=t.ctrlKey?"\b":$e.DEL,t.altKey&&(i.key=$e.ESC+i.key);break;case 9:if(t.shiftKey){i.key=$e.ESC+"[Z";break}i.key=$e.HT,i.cancel=!0;break;case 13:i.key=t.altKey?$e.ESC+$e.CR:$e.CR,i.cancel=!0;break;case 27:i.key=$e.ESC,t.altKey&&(i.key=$e.ESC+$e.ESC),i.cancel=!0;break;case 37:if(t.metaKey)break;l?i.key=$e.ESC+"[1;"+(l+1)+"D":e?i.key=$e.ESC+"OD":i.key=$e.ESC+"[D";break;case 39:if(t.metaKey)break;l?i.key=$e.ESC+"[1;"+(l+1)+"C":e?i.key=$e.ESC+"OC":i.key=$e.ESC+"[C";break;case 38:if(t.metaKey)break;l?i.key=$e.ESC+"[1;"+(l+1)+"A":e?i.key=$e.ESC+"OA":i.key=$e.ESC+"[A";break;case 40:if(t.metaKey)break;l?i.key=$e.ESC+"[1;"+(l+1)+"B":e?i.key=$e.ESC+"OB":i.key=$e.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(i.key=$e.ESC+"[2~");break;case 46:l?i.key=$e.ESC+"[3;"+(l+1)+"~":i.key=$e.ESC+"[3~";break;case 36:l?i.key=$e.ESC+"[1;"+(l+1)+"H":e?i.key=$e.ESC+"OH":i.key=$e.ESC+"[H";break;case 35:l?i.key=$e.ESC+"[1;"+(l+1)+"F":e?i.key=$e.ESC+"OF":i.key=$e.ESC+"[F";break;case 33:t.shiftKey?i.type=2:t.ctrlKey?i.key=$e.ESC+"[5;"+(l+1)+"~":i.key=$e.ESC+"[5~";break;case 34:t.shiftKey?i.type=3:t.ctrlKey?i.key=$e.ESC+"[6;"+(l+1)+"~":i.key=$e.ESC+"[6~";break;case 112:l?i.key=$e.ESC+"[1;"+(l+1)+"P":i.key=$e.ESC+"OP";break;case 113:l?i.key=$e.ESC+"[1;"+(l+1)+"Q":i.key=$e.ESC+"OQ";break;case 114:l?i.key=$e.ESC+"[1;"+(l+1)+"R":i.key=$e.ESC+"OR";break;case 115:l?i.key=$e.ESC+"[1;"+(l+1)+"S":i.key=$e.ESC+"OS";break;case 116:l?i.key=$e.ESC+"[15;"+(l+1)+"~":i.key=$e.ESC+"[15~";break;case 117:l?i.key=$e.ESC+"[17;"+(l+1)+"~":i.key=$e.ESC+"[17~";break;case 118:l?i.key=$e.ESC+"[18;"+(l+1)+"~":i.key=$e.ESC+"[18~";break;case 119:l?i.key=$e.ESC+"[19;"+(l+1)+"~":i.key=$e.ESC+"[19~";break;case 120:l?i.key=$e.ESC+"[20;"+(l+1)+"~":i.key=$e.ESC+"[20~";break;case 121:l?i.key=$e.ESC+"[21;"+(l+1)+"~":i.key=$e.ESC+"[21~";break;case 122:l?i.key=$e.ESC+"[23;"+(l+1)+"~":i.key=$e.ESC+"[23~";break;case 123:l?i.key=$e.ESC+"[24;"+(l+1)+"~":i.key=$e.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?i.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?i.key=$e.NUL:t.keyCode>=51&&t.keyCode<=55?i.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?i.key=$e.DEL:t.keyCode===219?i.key=$e.ESC:t.keyCode===220?i.key=$e.FS:t.keyCode===221&&(i.key=$e.GS);else if((!n||s)&&t.altKey&&!t.metaKey){let u=(c=gA[t.keyCode])==null?void 0:c[t.shiftKey?1:0];if(u)i.key=$e.ESC+u;else if(t.keyCode>=65&&t.keyCode<=90){let h=t.ctrlKey?t.keyCode-64:t.keyCode+32,p=String.fromCharCode(h);t.shiftKey&&(p=p.toUpperCase()),i.key=$e.ESC+p}else if(t.keyCode===32)i.key=$e.ESC+(t.ctrlKey?$e.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let h=t.code.slice(3,4);t.shiftKey||(h=h.toLowerCase()),i.key=$e.ESC+h,i.cancel=!0}}else n&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(i.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?i.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(i.key=$e.US),t.key==="@"&&(i.key=$e.NUL));break}return i}var Pn=0,_A=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new zd,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new zd,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((l,c)=>this._getKey(l)-this._getKey(c)),n=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let l=0;l<i.length;l++)s>=this._array.length||this._getKey(e[n])<=this._getKey(this._array[s])?(i[l]=e[n],n++):i[l]=this._array[s++];this._array=i,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 n=this._getKey(e);if(n===void 0||(Pn=this._search(n),Pn===-1)||this._getKey(this._array[Pn])!==n)return!1;do if(this._array[Pn]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Pn),!0;while(++Pn<this._array.length&&this._getKey(this._array[Pn])===n);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((l,c)=>l-c),n=0,s=new Array(this._array.length-e.length),i=0;for(let l=0;l<this._array.length;l++)e[n]===l?n++:s[i++]=this._array[l];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Pn=this._search(e),!(Pn<0||Pn>=this._array.length)&&this._getKey(this._array[Pn])===e))do yield this._array[Pn];while(++Pn<this._array.length&&this._getKey(this._array[Pn])===e)}forEachByKey(e,n){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Pn=this._search(e),!(Pn<0||Pn>=this._array.length)&&this._getKey(this._array[Pn])===e))do n(this._array[Pn]);while(++Pn<this._array.length&&this._getKey(this._array[Pn])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let n=0,s=this._array.length-1;for(;s>=n;){let i=n+s>>1,l=this._getKey(this._array[i]);if(l>e)s=i-1;else if(l<e)n=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return n}},_p=0,Zb=0,yA=class extends Ft{constructor(){super(),this._decorations=new _A(t=>t==null?void 0:t.marker.line),this._onDecorationRegistered=this._register(new it),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new it),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(_n(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new wA(t);if(e){let n=e.marker.onDispose(()=>e.dispose()),s=e.onDispose(()=>{s.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),n.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,e,n){let s=0,i=0;for(let l of this._decorations.getKeyIterator(e))s=l.options.x??0,i=s+(l.options.width??1),t>=s&&t<i&&(!n||(l.options.layer??"bottom")===n)&&(yield l)}forEachDecorationAtCell(t,e,n,s){this._decorations.forEachByKey(e,i=>{_p=i.options.x??0,Zb=_p+(i.options.width??1),t>=_p&&t<Zb&&(!n||(i.options.layer??"bottom")===n)&&s(i)})}},wA=class extends lo{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new it),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new it),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=t.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=xn.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=xn.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},bA=1e3,SA=class{constructor(e,n=bA){this._renderCallback=e,this._debounceThresholdMS=n,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,n,s){this._rowCount=s,e=e!==void 0?e:0,n=n!==void 0?n: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,n):n;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let l=i-this._lastRefreshMs,c=this._debounceThresholdMS-l;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},c)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),n=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,n)}},e0=20,Fd=class extends Ft{constructor(t,e,n,s){super(),this._terminal=t,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let l=0;l<this._terminal.rows;l++)this._rowElements[l]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[l]);if(this._topBoundaryFocusListener=l=>this._handleBoundaryFocus(l,0),this._bottomBoundaryFocusListener=l=>this._handleBoundaryFocus(l,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=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new SA(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(l=>this._handleResize(l.rows))),this._register(this._terminal.onRender(l=>this._refreshRows(l.start,l.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(l=>this._handleChar(l))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
64
+ `))),this._register(this._terminal.onA11yTab(l=>this._handleTab(l))),this._register(this._terminal.onKey(l=>this._handleKey(l.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Tt(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(_n(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<e0+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
65
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===e0+1&&(this._liveRegion.textContent+=Mm.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(t)||this._charsToConsume.push(t)}_refreshRows(t,e){this._liveRegionDebouncer.refresh(t,e,this._terminal.rows)}_renderRows(t,e){let n=this._terminal.buffer,s=n.lines.length.toString();for(let i=t;i<=e;i++){let l=n.lines.get(n.ydisp+i),c=[],u=(l==null?void 0:l.translateToString(!0,void 0,void 0,c))||"",h=(n.ydisp+i+1).toString(),p=this._rowElements[i];p&&(u.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=u,this._rowColumns.set(p,c)),p.setAttribute("aria-posinset",h),p.setAttribute("aria-setsize",s),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let n=t.target,s=this._rowElements[e===0?1:this._rowElements.length-2],i=n.getAttribute("aria-posinset"),l=e===0?"1":`${this._terminal.buffer.lines.length}`;if(i===l||t.relatedTarget!==s)return;let c,u;if(e===0?(c=n,u=this._rowElements.pop(),this._rowContainer.removeChild(u)):(c=this._rowElements.shift(),u=n,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),u.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}_handleSelectionChange(){var u;if(this._rowElements.length===0)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed){this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection();return}if(!t.anchorNode||!t.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:t.anchorNode,offset:t.anchorOffset},n={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===n.node&&e.offset>n.offset)&&([e,n]=[n,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.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:((u=s.textContent)==null?void 0:u.length)??0}),!this._rowContainer.contains(n.node))return;let i=({node:h,offset:p})=>{let v=h instanceof Text?h.parentNode:h,_=parseInt(v==null?void 0:v.getAttribute("aria-posinset"),10)-1;if(isNaN(_))return console.warn("row is invalid. Race condition?"),null;let g=this._rowColumns.get(v);if(!g)return console.warn("columns is null. Race condition?"),null;let b=p<g.length?g[p]:g.slice(-1)[0]+1;return b>=this._terminal.cols&&(++_,b=0),{row:_,column:b}},l=i(e),c=i(n);if(!(!l||!c)){if(l.row>c.row||l.row===c.row&&l.column>=c.column)throw new Error("invalid range");this._terminal.select(l.column,l.row,(c.row-l.row)*this._terminal.cols-l.column+c.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let t=this._coreBrowserService.mainDocument.createElement("div");return t.setAttribute("role","listitem"),t.tabIndex=-1,this._refreshRowDimensions(t),t}_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 t=0;t<this._terminal.rows;t++)this._refreshRowDimensions(this._rowElements[t]),this._alignRowWidth(this._rowElements[t])}}_refreshRowDimensions(t){t.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(t){var i,l;t.style.transform="";let e=t.getBoundingClientRect().width,n=(l=(i=this._rowColumns.get(t))==null?void 0:i.slice(-1))==null?void 0:l[0];if(!n)return;let s=n*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${s/e})`}};Fd=An([ut(1,vv),ut(2,Lr),ut(3,Rr)],Fd);var fg=class extends Ft{constructor(t,e,n,s,i){super(),this._element=t,this._mouseService=e,this._renderService=n,this._bufferService=s,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new it),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new it),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(_n(()=>{var l;Yo(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(l=this._activeProviderReplies)==null||l.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Tt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Tt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Tt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Tt(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let n=t.composedPath();for(let s=0;s<n.length;s++){let i=n[s];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}(!this._lastBufferCell||e.x!==this._lastBufferCell.x||e.y!==this._lastBufferCell.y)&&(this._handleHover(e),this._lastBufferCell=e)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized){this._clearCurrentLink(),this._askForLink(t,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,e){var s,i;(!this._activeProviderReplies||!e)&&((s=this._activeProviderReplies)==null||s.forEach(l=>{l==null||l.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let n=!1;for(let[l,c]of this._linkProviderService.linkProviders.entries())e?(i=this._activeProviderReplies)!=null&&i.get(l)&&(n=this._checkLinkProviderResult(l,t,n)):c.provideLinks(t.y,u=>{var p,v;if(this._isMouseOut)return;let h=u==null?void 0:u.map(_=>({link:_}));(p=this._activeProviderReplies)==null||p.set(l,h),n=this._checkLinkProviderResult(l,t,n),((v=this._activeProviderReplies)==null?void 0:v.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let n=new Set;for(let s=0;s<e.size;s++){let i=e.get(s);if(i)for(let l=0;l<i.length;l++){let c=i[l],u=c.link.range.start.y<t?0:c.link.range.start.x,h=c.link.range.end.y>t?this._bufferService.cols:c.link.range.end.x;for(let p=u;p<=h;p++){if(n.has(p)){i.splice(l--,1);break}n.add(p)}}}}_checkLinkProviderResult(t,e,n){var l;if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(t),i=!1;for(let c=0;c<t;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(i=!0);if(!i&&s){let c=s.find(u=>this._linkAtPosition(u.link,e));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;c<this._activeProviderReplies.size;c++){let u=(l=this._activeProviderReplies.get(c))==null?void 0:l.find(h=>this._linkAtPosition(h.link,e));if(u){n=!0,this._handleNewLink(u);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink&&xA(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){!this._currentLink||!this._lastMouseEvent||(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Yo(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0?!0:t.link.decorations.underline,pointerCursor:t.link.decorations===void 0?!0:t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.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,i,l;(s=this._currentLink)!=null&&s.state&&((l=(i=this._currentLink)==null?void 0:i.state)==null?void 0:l.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.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,i=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(s,i),this._lastMouseEvent)){let l=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);l&&this._askForLink(l,!1)}})))}_linkHover(t,e,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(n,e.text)}_fireUnderlineEvent(t,e){let n=t.range,s=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(t,e,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(n,e.text)}_linkAtPosition(t,e){let n=t.range.start.y*this._bufferService.cols+t.range.start.x,s=t.range.end.y*this._bufferService.cols+t.range.end.x,i=e.y*this._bufferService.cols+e.x;return n<=i&&i<=s}_positionFromMouseEvent(t,e,n){let s=n.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,n,s,i){return{x1:t,y1:e,x2:n,y2:s,cols:this._bufferService.cols,fg:i}}};fg=An([ut(1,_v),ut(2,Rr),ut(3,Os),ut(4,R1)],fg);function xA(t,e){return t.text===e.text&&t.range.start.x===e.range.start.x&&t.range.start.y===e.range.start.y&&t.range.end.x===e.range.end.x&&t.range.end.y===e.range.end.y}var kA=class extends mA{constructor(e={}){super(e),this._linkifier=this._register(new Ya),this.browser=G1,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ya),this._onCursorMove=this._register(new it),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new it),this.onKey=this._onKey.event,this._onRender=this._register(new it),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new it),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new it),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new it),this.onBell=this._onBell.event,this._onFocus=this._register(new it),this._onBlur=this._register(new it),this._onA11yCharEmitter=this._register(new it),this._onA11yTabEmitter=this._register(new it),this._onWillOpen=this._register(new it),this._setup(),this._decorationService=this._instantiationService.createInstance(yA),this._instantiationService.setService(Vc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(fR),this._instantiationService.setService(R1,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Pm)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(n=>this.refresh((n==null?void 0:n.start)??0,(n==null?void 0:n.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(n=>this._reportWindowsOptions(n))),this._register(this._inputHandler.onColor(n=>this._handleColorEvent(n))),this._register(_s.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(_s.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(_s.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(_s.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(n=>this._afterResize(n.cols,n.rows))),this._register(_n(()=>{var n,s;this._customKeyEventHandler=void 0,(s=(n=this.element)==null?void 0:n.parentNode)==null||s.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 n of e){let s,i="";switch(n.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+n.index}switch(n.type){case 0:let l=mn.toColorRGB(s==="ansi"?this._themeService.colors.ansi[n.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${$e.ESC}]${i};${cA(l)}${V1.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(c=>c.ansi[n.index]=$n.toColor(...n.color));else{let c=s;this._themeService.modifyColors(u=>u[c]=$n.toColor(...n.color))}break;case 2:this._themeService.restoreColor(n.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(Fd,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($e.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($e.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,n=this.buffer.lines.get(e);if(!n)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,l=n.getWidth(s),c=this._renderService.dimensions.css.cell.width*l,u=this.buffer.y*this._renderService.dimensions.css.cell.height,h=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=u+"px",this.textarea.style.width=c+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Tt(this.element,"copy",n=>{this.hasSelection()&&jj(n,this._selectionService)}));let e=n=>Lj(n,this.textarea,this.coreService,this.optionsService);this._register(Tt(this.textarea,"paste",e)),this._register(Tt(this.element,"paste",e)),X1?this._register(Tt(this.element,"mousedown",n=>{n.button===2&&ub(n,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Tt(this.element,"contextmenu",n=>{ub(n,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Ev&&this._register(Tt(this.element,"auxclick",n=>{n.button===1&&b1(n,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Tt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Tt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Tt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Tt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Tt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Tt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Tt(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var l;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"),((l=this.element)==null?void 0:l.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 n=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),n.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Tt(this.screenElement,"mousemove",c=>this.updateCursorStyle(c))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),n.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Am.get()),Z1||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(dR,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Lr,this._coreBrowserService),this._register(Tt(this.textarea,"focus",c=>this._handleTextAreaFocus(c))),this._register(Tt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(tg,this._document,this._helperContainer),this._instantiationService.setService(fh,this._charSizeService),this._themeService=this._instantiationService.createInstance(rg),this._instantiationService.setService(nl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Bd),this._instantiationService.setService(L1,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(sg,this.rows,this.screenElement)),this._instantiationService.setService(Rr,this._renderService),this._register(this._renderService.onRenderedViewportChange(c=>this._onRender.fire(c))),this.onResize(c=>this._renderService.resize(c.cols,c.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Qm,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(ng),this._instantiationService.setService(_v,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(fg,this.screenElement));this.element.appendChild(n);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(Xm,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(c=>{super.scrollLines(c,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(ig,this.element,this.screenElement,i)),this._instantiationService.setService(Oj,this._selectionService),this._register(this._selectionService.onRequestScrollLines(c=>this.scrollLines(c.amount,c.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(c=>this._renderService.handleSelectionChanged(c.start,c.end,c.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(c=>{this.textarea.value=c,this.textarea.focus(),this.textarea.select()})),this._register(_s.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var c;this._selectionService.refresh(),(c=this._viewport)==null||c.queueSync()})),this._register(this._instantiationService.createInstance(Jm,this.screenElement)),this._register(Tt(this.element,"mousedown",c=>this._selectionService.handleMouseDown(c))),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(Fd,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",c=>this._handleScreenReaderModeOptionChange(c))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Od,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",c=>{!this._overviewRulerRenderer&&c&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Od,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(eg,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,n=this.element;function s(c){var v,_,g,b,S;let u=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!u)return!1;let h,p;switch(c.overrideType||c.type){case"mousemove":p=32,c.buttons===void 0?(h=3,c.button!==void 0&&(h=c.button<3?c.button:3)):h=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":p=0,h=c.button<3?c.button:3;break;case"mousedown":p=1,h=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let j=c.deltaY;if(j===0||e.coreMouseService.consumeWheelEvent(c,(b=(g=(_=(v=e._renderService)==null?void 0:v.dimensions)==null?void 0:_.device)==null?void 0:g.cell)==null?void 0:b.height,(S=e._coreBrowserService)==null?void 0:S.dpr)===0)return!1;p=j<0?0:1,h=4;break;default:return!1}return p===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:p,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},l={mouseup:c=>(s(c),c.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(c)),wheel:c=>(s(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&s(c)},mousemove:c=>{c.buttons||s(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),c&8?i.mousemove||(n.addEventListener("mousemove",l.mousemove),i.mousemove=l.mousemove):(n.removeEventListener("mousemove",i.mousemove),i.mousemove=null),c&16?i.wheel||(n.addEventListener("wheel",l.wheel,{passive:!1}),i.wheel=l.wheel):(n.removeEventListener("wheel",i.wheel),i.wheel=null),c&2?i.mouseup||(i.mouseup=l.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),c&4?i.mousedrag||(i.mousedrag=l.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Tt(n,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return s(c),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(c)})),this._register(Tt(n,"wheel",c=>{var u,h,p,v,_;if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,(v=(p=(h=(u=e._renderService)==null?void 0:u.dimensions)==null?void 0:h.device)==null?void 0:p.cell)==null?void 0:v.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return this.cancel(c,!0);let g=$e.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(g,!0),this.cancel(c,!0)}}},{passive:!1}))}refresh(e,n){var s;(s=this._renderService)==null||s.refreshRows(e,n)}updateCursorStyle(e){var n;(n=this._selectionService)!=null&&n.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,n){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,n),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 n=e-this._bufferService.buffer.ydisp;n!==0&&this.scrollLines(n)}paste(e){w1(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 n=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),n}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,n,s){this._selectionService.setSelection(e,n,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,n){var s;(s=this._selectionService)==null||s.selectLines(e,n)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let n=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!n&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!n&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=vA(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===$e.ETX||s.key===$e.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,n){let s=e.isMac&&!this.options.macOptionIsMeta&&n.altKey&&!n.ctrlKey&&!n.metaKey||e.isWindows&&n.altKey&&n.ctrlKey&&!n.metaKey||e.isWindows&&n.getModifierState("AltGraph");return n.type==="keypress"?s:s&&(!n.keyCode||n.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(CA(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let n;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)n=e.charCode;else if(e.which===null||e.which===void 0)n=e.keyCode;else if(e.which!==0&&e.charCode!==0)n=e.which;else return!1;return!n||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(n=String.fromCharCode(n),this._onKey.fire({key:n,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n,!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 n=e.data;return this.coreService.triggerDataEvent(n,!0),this.cancel(e),!0}return!1}resize(e,n){if(e===this.cols&&n===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,n)}_afterResize(e,n){var s;(s=this._charSizeService)==null||s.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(On));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var n;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(n=this._selectionService)==null||n.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($e.ESC+"[I"):this.coreService.triggerDataEvent($e.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let n=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$e.ESC}[4;${s};${n}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),l=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$e.ESC}[6;${l};${i}t`);break}}cancel(e,n){if(!(!this.options.cancelEvents&&!n))return e.preventDefault(),e.stopPropagation(),!1}};function CA(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var EA=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,n){let s={instance:n,dispose:n.dispose,isDisposed:!1};this._addons.push(s),n.dispose=()=>this._wrappedAddonDispose(s),n.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let n=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){n=s;break}if(n===-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(n,1)}},NA=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,n){if(!(e<0||e>=this._line.length))return n?(this._line.loadCell(e,n),n):this._line.loadCell(e,new wi)}translateToString(e,n,s){return this._line.translateToString(e,n,s)}},t0=class{constructor(t,e){this._buffer=t,this.type=e}init(t){return this._buffer=t,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(t){let e=this._buffer.lines.get(t);if(e)return new NA(e)}getNullCell(){return new wi}},jA=class extends Ft{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new it),this.onBufferChange=this._onBufferChange.event,this._normal=new t0(this._core.buffers.normal,"normal"),this._alternate=new t0(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)}},LA=class{constructor(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,n=>e(n.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(n,s)=>e(n,s.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}},RA=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}},AA=["cols","rows"],Ui=0,MA=class extends Ft{constructor(t){super(),this._core=this._register(new kA(t)),this._addonManager=this._register(new EA),this._publicOptions={...this._core.options};let e=s=>this._core.options[s],n=(s,i)=>{this._checkReadonlyOptions(s),this._core.options[s]=i};for(let s in this._core.options){let i={get:e.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,i)}}_checkReadonlyOptions(t){if(AA.includes(t))throw new Error(`Option "${t}" 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 LA(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new RA(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 jA(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,synchronizedOutputMode:t.synchronizedOutput,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,n){this._verifyIntegers(t,e,n),this._core.select(t,e,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
66
+ `,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return Am.get()},set promptLabel(t){Am.set(t)},get tooMuchOutput(){return Mm.get()},set tooMuchOutput(t){Mm.set(t)}}}_verifyIntegers(...t){for(Ui of t)if(Ui===1/0||isNaN(Ui)||Ui%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(Ui of t)if(Ui&&(Ui===1/0||isNaN(Ui)||Ui%1!==0||Ui<0))throw new Error("This API only accepts positive integers")}};/**
67
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
68
+ * @license MIT
69
+ *
70
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
71
+ * @license MIT
72
+ *
73
+ * Originally forked from (with the author's permission):
74
+ * Fabrice Bellard's javascript vt100 for jslinux:
75
+ * http://bellard.org/jslinux/
76
+ * Copyright (c) 2011 Fabrice Bellard
77
+ */var TA=2,PA=1,IA=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){var _;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:((_=this._terminal.options.overviewRuler)==null?void 0:_.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),i=Math.max(0,parseInt(n.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),c={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},u=c.top+c.bottom,h=c.right+c.left,p=s-u,v=i-h-e;return{cols:Math.max(TA,Math.floor(v/t.css.cell.width)),rows:Math.max(PA,Math.floor(p/t.css.cell.height))}}};const DA=Object.freeze([[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,12350],[12352,12871],[12880,19903],[19968,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65131],[65281,65376],[65504,65510],[126976,127461],[127488,129791]]),OA=Object.freeze([[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1552,1562],[1611,1631],[1648,1648],[1750,1756],[1759,1764],[1767,1768],[1770,1773],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2275,2307],[2362,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[3134,3136],[3142,3144],[3146,3149],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3790],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[4038,4038],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6155,6157],[6832,6911],[7616,7679],[8203,8207],[8232,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12335],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[66045,66045],[66272,66272],[113824,113827],[119141,119145],[119149,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]]),BA="nc-15.1";function n0(t,e){let n=0,s=t.length-1;for(;n<=s;){const i=n+s>>1,[l,c]=t[i];if(e<l)s=i-1;else if(e>c)n=i+1;else return!0}return!1}function $A(t,e,n){return(t&16777215)<<3|(e&3)<<1|(n?1:0)}function s0(t){const e=Number(t);return!Number.isFinite(e)||e<0||e<32||e>=127&&e<160||n0(OA,e)?0:n0(DA,e)?2:1}function zA(){return{version:BA,wcwidth:s0,charProperties(t,e){let n=s0(t),s=n===0&&e!==0;if(s){const i=e>>1&3;i===0?s=!1:i>n&&(n=i)}return $A(t,n,s)}}}function FA(t){try{const e=t&&t.unicode;if(!e||typeof e.register!="function")return null;const n=zA();return e.versions.includes(n.version)||e.register(n),e.activeVersion=n.version,n}catch{return null}}/**
78
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
79
+ * @license MIT
80
+ *
81
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
82
+ * @license MIT
83
+ *
84
+ * Originally forked from (with the author's permission):
85
+ * Fabrice Bellard's javascript vt100 for jslinux:
86
+ * http://bellard.org/jslinux/
87
+ * Copyright (c) 2011 Fabrice Bellard
88
+ */var HA=(t,e,n,s)=>{for(var i=e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(i=c(i)||i);return i},UA=(t,e)=>(n,s)=>e(n,s,t),WA=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?i0.isErrorNoTelemetry(t)?new i0(t.message+`
89
+
90
+ `+t.stack):new Error(t.message+`
91
+
92
+ `+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},qA=new WA;function yp(t){KA(t)||qA.onUnexpectedError(t)}var pg="Canceled";function KA(t){return t instanceof VA?!0:t instanceof Error&&t.name===pg&&t.message===pg}var VA=class extends Error{constructor(){super(pg),this.name=this.message}},i0=class mg extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof mg)return e;let n=new mg;return n.message=e.message,n.stack=e.stack,n}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},YA;(t=>{function e(l){return l<0}t.isLessThan=e;function n(l){return l<=0}t.isLessThanOrEqual=n;function s(l){return l>0}t.isGreaterThan=s;function i(l){return l===0}t.isNeitherLessOrGreaterThan=i,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(YA||(YA={}));function GA(t,e){let n=this,s=!1,i;return function(){return s||(s=!0,e||(i=t.apply(n,arguments))),i}}var ck;(t=>{function e(x){return x&&typeof x=="object"&&typeof x[Symbol.iterator]=="function"}t.is=e;let n=Object.freeze([]);function s(){return n}t.empty=s;function*i(x){yield x}t.single=i;function l(x){return e(x)?x:i(x)}t.wrap=l;function c(x){return x||n}t.from=c;function*u(x){for(let W=x.length-1;W>=0;W--)yield x[W]}t.reverse=u;function h(x){return!x||x[Symbol.iterator]().next().done===!0}t.isEmpty=h;function p(x){return x[Symbol.iterator]().next().value}t.first=p;function v(x,W){let $=0;for(let J of x)if(W(J,$++))return!0;return!1}t.some=v;function _(x,W){for(let $ of x)if(W($))return $}t.find=_;function*g(x,W){for(let $ of x)W($)&&(yield $)}t.filter=g;function*b(x,W){let $=0;for(let J of x)yield W(J,$++)}t.map=b;function*S(x,W){let $=0;for(let J of x)yield*W(J,$++)}t.flatMap=S;function*j(...x){for(let W of x)yield*W}t.concat=j;function C(x,W,$){let J=$;for(let q of x)J=W(J,q);return J}t.reduce=C;function*N(x,W,$=x.length){for(W<0&&(W+=x.length),$<0?$+=x.length:$>x.length&&($=x.length);W<$;W++)yield x[W]}t.slice=N;function E(x,W=Number.POSITIVE_INFINITY){let $=[];if(W===0)return[$,x];let J=x[Symbol.iterator]();for(let q=0;q<W;q++){let V=J.next();if(V.done)return[$,t.empty()];$.push(V.value)}return[$,{[Symbol.iterator](){return J}}]}t.consume=E;async function O(x){let W=[];for await(let $ of x)W.push($);return Promise.resolve(W)}t.asyncToArray=O})(ck||(ck={}));function uk(t){if(ck.is(t)){let e=[];for(let n of t)if(n)try{n.dispose()}catch(s){e.push(s)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function dk(...t){return Rs(()=>uk(t))}function Rs(t){return{dispose:GA(()=>{t()})}}var hk=class fk{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{uk(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?fk.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(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};hk.DISABLE_DISPOSED_WARNING=!1;var Wa=hk,Pi=class{constructor(){this._store=new Wa,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Pi.None=Object.freeze({dispose(){}});var Yl=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){var e;this._isDisposed||t===this._value||((e=this._value)==null||e.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){var t;this._isDisposed=!0,(t=this._value)==null||t.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},Nv=typeof process<"u"&&"title"in process,gh=Nv?"node":navigator.userAgent,XA=Nv?"node":navigator.platform,JA=gh.includes("Firefox"),QA=gh.includes("Edge"),pk=/^((?!chrome|android).)*safari/i.test(gh);function ZA(){if(!pk)return 0;let t=gh.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}XA.indexOf("Linux")>=0;var eM="",as=0,ls=0,cs=0,Rn=0,pi={css:"#00000000",rgba:0},Ds;(t=>{function e(i,l,c,u){return u!==void 0?`#${Ro(i)}${Ro(l)}${Ro(c)}${Ro(u)}`:`#${Ro(i)}${Ro(l)}${Ro(c)}`}t.toCss=e;function n(i,l,c,u=255){return(i<<24|l<<16|c<<8|u)>>>0}t.toRgba=n;function s(i,l,c,u){return{css:t.toCss(i,l,c,u),rgba:t.toRgba(i,l,c,u)}}t.toColor=s})(Ds||(Ds={}));var mc;(t=>{function e(h,p){if(Rn=(p.rgba&255)/255,Rn===1)return{css:p.css,rgba:p.rgba};let v=p.rgba>>24&255,_=p.rgba>>16&255,g=p.rgba>>8&255,b=h.rgba>>24&255,S=h.rgba>>16&255,j=h.rgba>>8&255;as=b+Math.round((v-b)*Rn),ls=S+Math.round((_-S)*Rn),cs=j+Math.round((g-j)*Rn);let C=Ds.toCss(as,ls,cs),N=Ds.toRgba(as,ls,cs);return{css:C,rgba:N}}t.blend=e;function n(h){return(h.rgba&255)===255}t.isOpaque=n;function s(h,p,v){let _=Ho.ensureContrastRatio(h.rgba,p.rgba,v);if(_)return Ds.toColor(_>>24&255,_>>16&255,_>>8&255)}t.ensureContrastRatio=s;function i(h){let p=(h.rgba|255)>>>0;return[as,ls,cs]=Ho.toChannels(p),{css:Ds.toCss(as,ls,cs),rgba:p}}t.opaque=i;function l(h,p){return Rn=Math.round(p*255),[as,ls,cs]=Ho.toChannels(h.rgba),{css:Ds.toCss(as,ls,cs,Rn),rgba:Ds.toRgba(as,ls,cs,Rn)}}t.opacity=l;function c(h,p){return Rn=h.rgba&255,l(h,Rn*p/255)}t.multiplyOpacity=c;function u(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}t.toColorRGB=u})(mc||(mc={}));var tM;(t=>{let e,n;try{let i=document.createElement("canvas");i.width=1,i.height=1;let l=i.getContext("2d",{willReadFrequently:!0});l&&(e=l,e.globalCompositeOperation="copy",n=e.createLinearGradient(0,0,1,1))}catch{}function s(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return as=parseInt(i.slice(1,2).repeat(2),16),ls=parseInt(i.slice(2,3).repeat(2),16),cs=parseInt(i.slice(3,4).repeat(2),16),Ds.toColor(as,ls,cs);case 5:return as=parseInt(i.slice(1,2).repeat(2),16),ls=parseInt(i.slice(2,3).repeat(2),16),cs=parseInt(i.slice(3,4).repeat(2),16),Rn=parseInt(i.slice(4,5).repeat(2),16),Ds.toColor(as,ls,cs,Rn);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let l=i.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(l)return as=parseInt(l[1]),ls=parseInt(l[2]),cs=parseInt(l[3]),Rn=Math.round((l[5]===void 0?1:parseFloat(l[5]))*255),Ds.toColor(as,ls,cs,Rn);if(!e||!n)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=n,e.fillStyle=i,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[as,ls,cs,Rn]=e.getImageData(0,0,1,1).data,Rn!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ds.toRgba(as,ls,cs,Rn),css:i}}t.toColor=s})(tM||(tM={}));var Is;(t=>{function e(s){return n(s>>16&255,s>>8&255,s&255)}t.relativeLuminance=e;function n(s,i,l){let c=s/255,u=i/255,h=l/255,p=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),v=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),_=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return p*.2126+v*.7152+_*.0722}t.relativeLuminance2=n})(Is||(Is={}));var Ho;(t=>{function e(c,u){if(Rn=(u&255)/255,Rn===1)return u;let h=u>>24&255,p=u>>16&255,v=u>>8&255,_=c>>24&255,g=c>>16&255,b=c>>8&255;return as=_+Math.round((h-_)*Rn),ls=g+Math.round((p-g)*Rn),cs=b+Math.round((v-b)*Rn),Ds.toRgba(as,ls,cs)}t.blend=e;function n(c,u,h){let p=Is.relativeLuminance(c>>8),v=Is.relativeLuminance(u>>8);if(yr(p,v)<h){if(v<p){let b=s(c,u,h),S=yr(p,Is.relativeLuminance(b>>8));if(S<h){let j=i(c,u,h),C=yr(p,Is.relativeLuminance(j>>8));return S>C?b:j}return b}let _=i(c,u,h),g=yr(p,Is.relativeLuminance(_>>8));if(g<h){let b=s(c,u,h),S=yr(p,Is.relativeLuminance(b>>8));return g>S?_:b}return _}}t.ensureContrastRatio=n;function s(c,u,h){let p=c>>24&255,v=c>>16&255,_=c>>8&255,g=u>>24&255,b=u>>16&255,S=u>>8&255,j=yr(Is.relativeLuminance2(g,b,S),Is.relativeLuminance2(p,v,_));for(;j<h&&(g>0||b>0||S>0);)g-=Math.max(0,Math.ceil(g*.1)),b-=Math.max(0,Math.ceil(b*.1)),S-=Math.max(0,Math.ceil(S*.1)),j=yr(Is.relativeLuminance2(g,b,S),Is.relativeLuminance2(p,v,_));return(g<<24|b<<16|S<<8|255)>>>0}t.reduceLuminance=s;function i(c,u,h){let p=c>>24&255,v=c>>16&255,_=c>>8&255,g=u>>24&255,b=u>>16&255,S=u>>8&255,j=yr(Is.relativeLuminance2(g,b,S),Is.relativeLuminance2(p,v,_));for(;j<h&&(g<255||b<255||S<255);)g=Math.min(255,g+Math.ceil((255-g)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),j=yr(Is.relativeLuminance2(g,b,S),Is.relativeLuminance2(p,v,_));return(g<<24|b<<16|S<<8|255)>>>0}t.increaseLuminance=i;function l(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}t.toChannels=l})(Ho||(Ho={}));function Ro(t){let e=t.toString(16);return e.length<2?"0"+e:e}function yr(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}function Bn(t){if(!t)throw new Error("value must not be falsy");return t}function jv(t){return 57508<=t&&t<=57558}function nM(t){return 57520<=t&&t<=57527}function sM(t){return 57344<=t&&t<=63743}function iM(t){return 9472<=t&&t<=9631}function rM(t){return t>=128512&&t<=128591||t>=127744&&t<=128511||t>=128640&&t<=128767||t>=9728&&t<=9983||t>=9984&&t<=10175||t>=65024&&t<=65039||t>=129280&&t<=129535||t>=127462&&t<=127487}function oM(t,e,n,s){return e===1&&n>Math.ceil(s*1.5)&&t!==void 0&&t>255&&!rM(t)&&!jv(t)&&!sM(t)}function mk(t){return jv(t)||iM(t)}function aM(){return{css:{canvas:rd(),cell:rd()},device:{canvas:rd(),cell:rd(),char:{width:0,height:0,left:0,top:0}}}}function rd(){return{width:0,height:0}}function lM(t,e,n=0){return(t-(Math.round(e)*2-n))%(Math.round(e)*2)}var ps=0,ts=0,Wi=!1,wr=!1,od=!1,Gs,wp=0,cM=class{constructor(t,e,n,s,i,l){this._terminal=t,this._optionService=e,this._selectionRenderModel=n,this._decorationService=s,this._coreBrowserService=i,this._themeService=l,this.result={fg:0,bg:0,ext:0}}resolve(t,e,n,s){if(this.result.bg=t.bg,this.result.fg=t.fg,this.result.ext=t.bg&268435456?t.extended.ext:0,ts=0,ps=0,wr=!1,Wi=!1,od=!1,Gs=this._themeService.colors,wp=0,t.getCode()!==0&&t.extended.underlineStyle===4){let i=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));wp=e*s%(Math.round(i)*2)}if(this._decorationService.forEachDecorationAtCell(e,n,"bottom",i=>{i.backgroundColorRGB&&(ts=i.backgroundColorRGB.rgba>>8&16777215,wr=!0),i.foregroundColorRGB&&(ps=i.foregroundColorRGB.rgba>>8&16777215,Wi=!0)}),od=this._selectionRenderModel.isCellSelected(this._terminal,e,n),od){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:ts=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:ts=(this.result.fg&16777215)<<8|255;break;case 0:default:ts=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:ts=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:ts=(this.result.bg&16777215)<<8|255;break}ts=Ho.blend(ts,(this._coreBrowserService.isFocused?Gs.selectionBackgroundOpaque:Gs.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else ts=(this._coreBrowserService.isFocused?Gs.selectionBackgroundOpaque:Gs.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(wr=!0,Gs.selectionForeground&&(ps=Gs.selectionForeground.rgba>>8&16777215,Wi=!0),mk(t.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)ps=(this._coreBrowserService.isFocused?Gs.selectionBackgroundOpaque:Gs.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:ps=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:ps=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:ps=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:ps=(this.result.fg&16777215)<<8|255;break;case 0:default:ps=this._themeService.colors.foreground.rgba}ps=Ho.blend(ps,(this._coreBrowserService.isFocused?Gs.selectionBackgroundOpaque:Gs.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}Wi=!0}}this._decorationService.forEachDecorationAtCell(e,n,"top",i=>{i.backgroundColorRGB&&(ts=i.backgroundColorRGB.rgba>>8&16777215,wr=!0),i.foregroundColorRGB&&(ps=i.foregroundColorRGB.rgba>>8&16777215,Wi=!0)}),wr&&(od?ts=t.bg&-16777216&-134217729|ts|50331648:ts=t.bg&-16777216|ts|50331648),Wi&&(ps=t.fg&-16777216&-67108865|ps|50331648),this.result.fg&67108864&&(wr&&!Wi&&((this.result.bg&50331648)===0?ps=this.result.fg&-134217728|Gs.background.rgba>>8&16777215&16777215|50331648:ps=this.result.fg&-134217728|this.result.bg&67108863,Wi=!0),!wr&&Wi&&((this.result.fg&50331648)===0?ts=this.result.bg&-67108864|Gs.foreground.rgba>>8&16777215&16777215|50331648:ts=this.result.bg&-67108864|this.result.fg&67108863,wr=!0)),Gs=void 0,this.result.bg=wr?ts:this.result.bg,this.result.fg=Wi?ps:this.result.fg,this.result.ext&=536870911,this.result.ext|=wp<<29&3758096384}},uM=.5,gk=JA||QA?"bottom":"ideographic",dM={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},hM={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},fM={"─":{1:"M0,.5 L1,.5"},"━":{3:"M0,.5 L1,.5"},"│":{1:"M.5,0 L.5,1"},"┃":{3:"M.5,0 L.5,1"},"┌":{1:"M0.5,1 L.5,.5 L1,.5"},"┏":{3:"M0.5,1 L.5,.5 L1,.5"},"┐":{1:"M0,.5 L.5,.5 L.5,1"},"┓":{3:"M0,.5 L.5,.5 L.5,1"},"└":{1:"M.5,0 L.5,.5 L1,.5"},"┗":{3:"M.5,0 L.5,.5 L1,.5"},"┘":{1:"M.5,0 L.5,.5 L0,.5"},"┛":{3:"M.5,0 L.5,.5 L0,.5"},"├":{1:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┣":{3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┤":{1:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┫":{3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┬":{1:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┳":{3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┴":{1:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┻":{3:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┼":{1:"M0,.5 L1,.5 M.5,0 L.5,1"},"╋":{3:"M0,.5 L1,.5 M.5,0 L.5,1"},"╴":{1:"M.5,.5 L0,.5"},"╸":{3:"M.5,.5 L0,.5"},"╵":{1:"M.5,.5 L.5,0"},"╹":{3:"M.5,.5 L.5,0"},"╶":{1:"M.5,.5 L1,.5"},"╺":{3:"M.5,.5 L1,.5"},"╷":{1:"M.5,.5 L.5,1"},"╻":{3:"M.5,.5 L.5,1"},"═":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"║":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╒":{1:(t,e)=>`M.5,1 L.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╓":{1:(t,e)=>`M${.5-t},1 L${.5-t},.5 L1,.5 M${.5+t},.5 L${.5+t},1`},"╔":{1:(t,e)=>`M1,${.5-e} L${.5-t},${.5-e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1`},"╕":{1:(t,e)=>`M0,${.5-e} L.5,${.5-e} L.5,1 M0,${.5+e} L.5,${.5+e}`},"╖":{1:(t,e)=>`M${.5+t},1 L${.5+t},.5 L0,.5 M${.5-t},.5 L${.5-t},1`},"╗":{1:(t,e)=>`M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M0,${.5-e} L${.5+t},${.5-e} L${.5+t},1`},"╘":{1:(t,e)=>`M.5,0 L.5,${.5+e} L1,${.5+e} M.5,${.5-e} L1,${.5-e}`},"╙":{1:(t,e)=>`M1,.5 L${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╚":{1:(t,e)=>`M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0 M1,${.5+e} L${.5-t},${.5+e} L${.5-t},0`},"╛":{1:(t,e)=>`M0,${.5+e} L.5,${.5+e} L.5,0 M0,${.5-e} L.5,${.5-e}`},"╜":{1:(t,e)=>`M0,.5 L${.5+t},.5 L${.5+t},0 M${.5-t},.5 L${.5-t},0`},"╝":{1:(t,e)=>`M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M0,${.5+e} L${.5+t},${.5+e} L${.5+t},0`},"╞":{1:(t,e)=>`M.5,0 L.5,1 M.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╟":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1 M${.5+t},.5 L1,.5`},"╠":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╡":{1:(t,e)=>`M.5,0 L.5,1 M0,${.5-e} L.5,${.5-e} M0,${.5+e} L.5,${.5+e}`},"╢":{1:(t,e)=>`M0,.5 L${.5-t},.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╣":{1:(t,e)=>`M${.5+t},0 L${.5+t},1 M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0`},"╤":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e} M.5,${.5+e} L.5,1`},"╥":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},1 M${.5+t},.5 L${.5+t},1`},"╦":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1`},"╧":{1:(t,e)=>`M.5,0 L.5,${.5-e} M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╨":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╩":{1:(t,e)=>`M0,${.5+e} L1,${.5+e} M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╪":{1:(t,e)=>`M.5,0 L.5,1 M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╫":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╬":{1:(t,e)=>`M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1 M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╱":{1:"M1,0 L0,1"},"╲":{1:"M0,0 L1,1"},"╳":{1:"M1,0 L0,1 M0,0 L1,1"},"╼":{1:"M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"╽":{1:"M.5,.5 L.5,0",3:"M.5,.5 L.5,1"},"╾":{1:"M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"╿":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┍":{1:"M.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┎":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┑":{1:"M.5,.5 L.5,1",3:"M.5,.5 L0,.5"},"┒":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┕":{1:"M.5,.5 L.5,0",3:"M.5,.5 L1,.5"},"┖":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┙":{1:"M.5,.5 L.5,0",3:"M.5,.5 L0,.5"},"┚":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,0"},"┝":{1:"M.5,0 L.5,1",3:"M.5,.5 L1,.5"},"┞":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┟":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┠":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1"},"┡":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"┢":{1:"M.5,.5 L.5,0",3:"M0.5,1 L.5,.5 L1,.5"},"┥":{1:"M.5,0 L.5,1",3:"M.5,.5 L0,.5"},"┦":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┧":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┨":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1"},"┩":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L0,.5"},"┪":{1:"M.5,.5 L.5,0",3:"M0,.5 L.5,.5 L.5,1"},"┭":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┮":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┯":{1:"M.5,.5 L.5,1",3:"M0,.5 L1,.5"},"┰":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"┱":{1:"M.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"┲":{1:"M.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"┵":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┶":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┷":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5"},"┸":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,0"},"┹":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"┺":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,.5 L1,.5"},"┽":{1:"M.5,0 L.5,1 M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┾":{1:"M.5,0 L.5,1 M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┿":{1:"M.5,0 L.5,1",3:"M0,.5 L1,.5"},"╀":{1:"M0,.5 L1,.5 M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"╁":{1:"M.5,.5 L.5,0 M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"╂":{1:"M0,.5 L1,.5",3:"M.5,0 L.5,1"},"╃":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"╄":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"╅":{1:"M.5,0 L.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"╆":{1:"M.5,0 L.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"╇":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0 M0,.5 L1,.5"},"╈":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"╉":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"╊":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"╌":{1:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"╍":{3:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"┄":{1:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┅":{3:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┈":{1:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"┉":{3:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"╎":{1:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"╏":{3:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"┆":{1:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┇":{3:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┊":{1:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"┋":{3:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"╭":{1:(t,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,1,.5`},"╮":{1:(t,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,0,.5`},"╯":{1:(t,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,0,.5`},"╰":{1:(t,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,1,.5`}},Rc={"":{d:"M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655",type:0},"":{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0},"":{d:"M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82",type:0},"":{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2},"":{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2},"":{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1},"":{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1},"":{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1},"":{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0},"":{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}};Rc[""]=Rc[""];Rc[""]=Rc[""];function pM(t,e,n,s,i,l,c,u){let h=dM[e];if(h)return mM(t,h,n,s,i,l),!0;let p=hM[e];if(p)return gM(t,p,n,s,i,l),!0;let v=fM[e];if(v)return vM(t,v,n,s,i,l,u),!0;let _=Rc[e];return _?(_M(t,_,n,s,i,l,c,u),!0):!1}function mM(t,e,n,s,i,l){for(let c=0;c<e.length;c++){let u=e[c],h=i/8,p=l/8;t.fillRect(n+u.x*h,s+u.y*p,u.w*h,u.h*p)}}var r0=new Map;function gM(t,e,n,s,i,l){let c=r0.get(e);c||(c=new Map,r0.set(e,c));let u=t.fillStyle;if(typeof u!="string")throw new Error(`Unexpected fillStyle type "${u}"`);let h=c.get(u);if(!h){let p=e[0].length,v=e.length,_=t.canvas.ownerDocument.createElement("canvas");_.width=p,_.height=v;let g=Bn(_.getContext("2d")),b=new ImageData(p,v),S,j,C,N;if(u.startsWith("#"))S=parseInt(u.slice(1,3),16),j=parseInt(u.slice(3,5),16),C=parseInt(u.slice(5,7),16),N=u.length>7&&parseInt(u.slice(7,9),16)||1;else if(u.startsWith("rgba"))[S,j,C,N]=u.substring(5,u.length-1).split(",").map(E=>parseFloat(E));else throw new Error(`Unexpected fillStyle color format "${u}" when drawing pattern glyph`);for(let E=0;E<v;E++)for(let O=0;O<p;O++)b.data[(E*p+O)*4]=S,b.data[(E*p+O)*4+1]=j,b.data[(E*p+O)*4+2]=C,b.data[(E*p+O)*4+3]=e[E][O]*(N*255);g.putImageData(b,0,0),h=Bn(t.createPattern(_,null)),c.set(u,h)}t.fillStyle=h,t.fillRect(n,s,i,l)}function vM(t,e,n,s,i,l,c){t.strokeStyle=t.fillStyle;for(let[u,h]of Object.entries(e)){t.beginPath(),t.lineWidth=c*Number.parseInt(u);let p;if(typeof h=="function"){let v=.15/l*i;p=h(.15,v)}else p=h;for(let v of p.split(" ")){let _=v[0],g=vk[_];if(!g){console.error(`Could not find drawing instructions for "${_}"`);continue}let b=v.substring(1).split(",");!b[0]||!b[1]||g(t,_k(b,i,l,n,s,!0,c))}t.stroke(),t.closePath()}}function _M(t,e,n,s,i,l,c,u){let h=new Path2D;h.rect(n,s,i,l),t.clip(h),t.beginPath();let p=c/12;t.lineWidth=u*p;for(let v of e.d.split(" ")){let _=v[0],g=vk[_];if(!g){console.error(`Could not find drawing instructions for "${_}"`);continue}let b=v.substring(1).split(",");!b[0]||!b[1]||g(t,_k(b,i,l,n,s,!1,u,(e.leftPadding??0)*(p/2),(e.rightPadding??0)*(p/2)))}e.type===1?(t.strokeStyle=t.fillStyle,t.stroke()):t.fill(),t.closePath()}function o0(t,e,n=0){return Math.max(Math.min(t,e),n)}var vk={C:(t,e)=>t.bezierCurveTo(e[0],e[1],e[2],e[3],e[4],e[5]),L:(t,e)=>t.lineTo(e[0],e[1]),M:(t,e)=>t.moveTo(e[0],e[1])};function _k(t,e,n,s,i,l,c,u=0,h=0){let p=t.map(v=>parseFloat(v)||parseInt(v));if(p.length<2)throw new Error("Too few arguments for instruction");for(let v=0;v<p.length;v+=2)p[v]*=e-u*c-h*c,l&&p[v]!==0&&(p[v]=o0(Math.round(p[v]+.5)-.5,e,0)),p[v]+=s+u*c;for(let v=1;v<p.length;v+=2)p[v]*=n,l&&p[v]!==0&&(p[v]=o0(Math.round(p[v]+.5)-.5,n,0)),p[v]+=i;return p}var a0=class{constructor(){this._data={}}set(t,e,n){this._data[t]||(this._data[t]={}),this._data[t][e]=n}get(t,e){return this._data[t]?this._data[t][e]:void 0}clear(){this._data={}}},l0=class{constructor(){this._data=new a0}set(t,e,n,s,i){this._data.get(t,e)||this._data.set(t,e,new a0),this._data.get(t,e).set(n,s,i)}get(t,e,n,s){var i;return(i=this._data.get(t,e))==null?void 0:i.get(n,s)}clear(){this._data.clear()}},yk=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),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(t){this._idleCallback=void 0;let e=0,n=0,s=t.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),n=Math.max(e,n),i=t.timeRemaining(),n*1.5>i){s-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-e))}ms`),this._start();return}s=i}this.clear()}},yM=class extends yk{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},wM=class extends yk{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},bM=!Nv&&"requestIdleCallback"in window?wM:yM,za=class wk{constructor(){this.fg=0,this.bg=0,this.extended=new bk}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new wk;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},bk=class Sk{constructor(e=0,n=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new Sk(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},SM=globalThis.performance&&typeof globalThis.performance.now=="function",xM=class xk{static create(e){return new xk(e)}constructor(e){this._now=SM&&e===!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}},Er;(t=>{t.None=()=>Pi.None;function e(B,I){return _(B,()=>{},0,void 0,!0,void 0,I)}t.defer=e;function n(B){return(I,D=null,T)=>{let z=!1,R;return R=B(M=>{if(!z)return R?R.dispose():z=!0,I.call(D,M)},null,T),z&&R.dispose(),R}}t.once=n;function s(B,I,D){return p((T,z=null,R)=>B(M=>T.call(z,I(M)),null,R),D)}t.map=s;function i(B,I,D){return p((T,z=null,R)=>B(M=>{I(M),T.call(z,M)},null,R),D)}t.forEach=i;function l(B,I,D){return p((T,z=null,R)=>B(M=>I(M)&&T.call(z,M),null,R),D)}t.filter=l;function c(B){return B}t.signal=c;function u(...B){return(I,D=null,T)=>{let z=dk(...B.map(R=>R(M=>I.call(D,M))));return v(z,T)}}t.any=u;function h(B,I,D,T){let z=D;return s(B,R=>(z=I(z,R),z),T)}t.reduce=h;function p(B,I){let D,T={onWillAddFirstListener(){D=B(z.fire,z)},onDidRemoveLastListener(){D==null||D.dispose()}},z=new gn(T);return I==null||I.add(z),z.event}function v(B,I){return I instanceof Array?I.push(B):I&&I.add(B),B}function _(B,I,D=100,T=!1,z=!1,R,M){let L,H,A,U=0,Q,ae={leakWarningThreshold:R,onWillAddFirstListener(){L=B(je=>{U++,H=I(H,je),T&&!A&&(re.fire(H),H=void 0),Q=()=>{let te=H;H=void 0,A=void 0,(!T||U>1)&&re.fire(te),U=0},typeof D=="number"?(clearTimeout(A),A=setTimeout(Q,D)):A===void 0&&(A=0,queueMicrotask(Q))})},onWillRemoveListener(){z&&U>0&&(Q==null||Q())},onDidRemoveLastListener(){Q=void 0,L.dispose()}},re=new gn(ae);return M==null||M.add(re),re.event}t.debounce=_;function g(B,I=0,D){return t.debounce(B,(T,z)=>T?(T.push(z),T):[z],I,void 0,!0,void 0,D)}t.accumulate=g;function b(B,I=(T,z)=>T===z,D){let T=!0,z;return l(B,R=>{let M=T||!I(R,z);return T=!1,z=R,M},D)}t.latch=b;function S(B,I,D){return[t.filter(B,I,D),t.filter(B,T=>!I(T),D)]}t.split=S;function j(B,I=!1,D=[],T){let z=D.slice(),R=B(H=>{z?z.push(H):L.fire(H)});T&&T.add(R);let M=()=>{z==null||z.forEach(H=>L.fire(H)),z=null},L=new gn({onWillAddFirstListener(){R||(R=B(H=>L.fire(H)),T&&T.add(R))},onDidAddFirstListener(){z&&(I?setTimeout(M):M())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return T&&T.add(L),L.event}t.buffer=j;function C(B,I){return(D,T,z)=>{let R=I(new E);return B(function(M){let L=R.evaluate(M);L!==N&&D.call(T,L)},void 0,z)}}t.chain=C;let N=Symbol("HaltChainable");class E{constructor(){this.steps=[]}map(I){return this.steps.push(I),this}forEach(I){return this.steps.push(D=>(I(D),D)),this}filter(I){return this.steps.push(D=>I(D)?D:N),this}reduce(I,D){let T=D;return this.steps.push(z=>(T=I(T,z),T)),this}latch(I=(D,T)=>D===T){let D=!0,T;return this.steps.push(z=>{let R=D||!I(z,T);return D=!1,T=z,R?z:N}),this}evaluate(I){for(let D of this.steps)if(I=D(I),I===N)break;return I}}function O(B,I,D=T=>T){let T=(...L)=>M.fire(D(...L)),z=()=>B.on(I,T),R=()=>B.removeListener(I,T),M=new gn({onWillAddFirstListener:z,onDidRemoveLastListener:R});return M.event}t.fromNodeEventEmitter=O;function x(B,I,D=T=>T){let T=(...L)=>M.fire(D(...L)),z=()=>B.addEventListener(I,T),R=()=>B.removeEventListener(I,T),M=new gn({onWillAddFirstListener:z,onDidRemoveLastListener:R});return M.event}t.fromDOMEventEmitter=x;function W(B){return new Promise(I=>n(B)(I))}t.toPromise=W;function $(B){let I=new gn;return B.then(D=>{I.fire(D)},()=>{I.fire(void 0)}).finally(()=>{I.dispose()}),I.event}t.fromPromise=$;function J(B,I){return B(D=>I.fire(D))}t.forward=J;function q(B,I,D){return I(D),B(T=>I(T))}t.runAndSubscribe=q;class V{constructor(I,D){this._observable=I,this._counter=0,this._hasChanged=!1;let T={onWillAddFirstListener:()=>{I.addObserver(this)},onDidRemoveLastListener:()=>{I.removeObserver(this)}};this.emitter=new gn(T),D&&D.add(this.emitter)}beginUpdate(I){this._counter++}handlePossibleChange(I){}handleChange(I,D){this._hasChanged=!0}endUpdate(I){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ie(B,I){return new V(B,I).emitter.event}t.fromObservable=ie;function K(B){return(I,D,T)=>{let z=0,R=!1,M={beginUpdate(){z++},endUpdate(){z--,z===0&&(B.reportChanges(),R&&(R=!1,I.call(D)))},handlePossibleChange(){},handleChange(){R=!0}};B.addObserver(M),B.reportChanges();let L={dispose(){B.removeObserver(M)}};return T instanceof Wa?T.add(L):Array.isArray(T)&&T.push(L),L}}t.fromObservableLight=K})(Er||(Er={}));var gg=class vg{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${vg._idPool++}`,vg.all.add(this)}start(e){this._stopWatch=new xM,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};gg.all=new Set,gg._idPool=0;var kM=gg,CM=-1,kk=class Ck{constructor(e,n,s=(Ck._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var e;(e=this._stacks)==null||e.clear()}check(e,n){let s=this.threshold;if(s<=0||n<s)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[l,c]=this.getMostFrequentStack(),u=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${c}):`;console.warn(u),console.warn(l);let h=new jM(u,l);this._errorHandler(h)}return()=>{let l=this._stacks.get(e.value)||0;this._stacks.set(e.value,l-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,n=0;for(let[s,i]of this._stacks)(!e||n<i)&&(e=[s,i],n=i);return e}};kk._idPool=1;var EM=kk,NM=class Ek{constructor(e){this.value=e}static create(){let e=new Error;return new Ek(e.stack??"")}print(){console.warn(this.value.split(`
93
+ `).slice(2).join(`
94
+ `))}},jM=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},LM=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},RM=0,bp=class{constructor(t){this.value=t,this.id=RM++}},AM=2,MM,gn=class{constructor(t){var e,n,s,i;this._size=0,this._options=t,this._leakageMon=(e=this._options)!=null&&e.leakWarningThreshold?new EM((t==null?void 0:t.onListenerError)??yp,((n=this._options)==null?void 0:n.leakWarningThreshold)??CM):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new kM(this._options._profName):void 0,this._deliveryQueue=(i=this._options)==null?void 0:i.deliveryQueue}dispose(){var t,e,n,s;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(e=this._options)==null?void 0:e.onDidRemoveLastListener)==null||n.call(e),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(t,e,n)=>{var c,u,h,p,v;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let _=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(_);let g=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],b=new LM(`${_}. HINT: Stack shows most frequent listener (${g[1]}-times)`,g[0]);return(((c=this._options)==null?void 0:c.onListenerError)||yp)(b),Pi.None}if(this._disposed)return Pi.None;e&&(t=t.bind(e));let s=new bp(t),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=NM.create(),i=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof bp?(this._deliveryQueue??(this._deliveryQueue=new TM),this._listeners=[this._listeners,s]):this._listeners.push(s):((h=(u=this._options)==null?void 0:u.onWillAddFirstListener)==null||h.call(u,this),this._listeners=s,(v=(p=this._options)==null?void 0:p.onDidAddFirstListener)==null||v.call(p,this)),this._size++;let l=Rs(()=>{i==null||i(),this._removeListener(s)});return n instanceof Wa?n.add(l):Array.isArray(n)&&n.push(l),l}),this._event}_removeListener(t){var i,l,c,u;if((l=(i=this._options)==null?void 0:i.onWillRemoveListener)==null||l.call(i,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(u=(c=this._options)==null?void 0:c.onDidRemoveLastListener)==null||u.call(c,this),this._size=0;return}let e=this._listeners,n=e.indexOf(t);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--,e[n]=void 0;let s=this._deliveryQueue.current===this;if(this._size*AM<=e.length){let h=0;for(let p=0;p<e.length;p++)e[p]?e[h++]=e[p]:s&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=h}}_deliver(t,e){var s;if(!t)return;let n=((s=this._options)==null?void 0:s.onListenerError)||yp;if(!n){t.value(e);return}try{t.value(e)}catch(i){n(i)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){var e,n,s,i;if((e=this._deliveryQueue)!=null&&e.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 bp)this._deliver(this._listeners,t);else{let l=this._deliveryQueue;l.enqueue(this,t,this._listeners.length),this._deliverQueue(l)}(i=this._perfMon)==null||i.stop()}hasListeners(){return this._size>0}},TM=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,n){this.i=0,this.end=n,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},c0={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},Gl=2,Xl,Zr=class Oa{constructor(e,n,s){this._document=e,this._config=n,this._unicodeService=s,this._didWarmUp=!1,this._cacheMap=new l0,this._cacheMapCombined=new l0,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new za,this._textureSize=512,this._onAddTextureAtlasCanvas=new gn,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new gn,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=Nk(e,this._config.deviceCellWidth*4+Gl*2,this._config.deviceCellHeight+Gl*2),this._tmpCtx=Bn(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let e=new bM;for(let n=33;n<126;n++)e.enqueue(()=>{if(!this._cacheMap.get(n,0,0,0)){let s=this._drawToCache(n,0,0,0,!1,void 0);this._cacheMap.set(n,0,0,0,s)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(Oa.maxAtlasPages&&this._pages.length>=Math.max(4,Oa.maxAtlasPages)){let n=this._pages.filter(p=>p.canvas.width*2<=(Oa.maxTextureSize||4096)).sort((p,v)=>v.canvas.width!==p.canvas.width?v.canvas.width-p.canvas.width:v.percentageUsed-p.percentageUsed),s=-1,i=0;for(let p=0;p<n.length;p++)if(n[p].canvas.width!==i)s=p,i=n[p].canvas.width;else if(p-s===3)break;let l=n.slice(s,s+4),c=l.map(p=>p.glyphs[0].texturePage).sort((p,v)=>p>v?1:-1),u=this.pages.length-l.length,h=this._mergePages(l,u);h.version++;for(let p=c.length-1;p>=0;p--)this._deletePage(c[p]);this.pages.push(h),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(h.canvas)}let e=new Sp(this._document,this._textureSize);return this._pages.push(e),this._activePages.push(e),this._onAddTextureAtlasCanvas.fire(e.canvas),e}_mergePages(e,n){let s=e[0].canvas.width*2,i=new Sp(this._document,s,e);for(let[l,c]of e.entries()){let u=l*c.canvas.width%s,h=Math.floor(l/2)*c.canvas.height;i.ctx.drawImage(c.canvas,u,h);for(let v of c.glyphs)v.texturePage=n,v.sizeClipSpace.x=v.size.x/s,v.sizeClipSpace.y=v.size.y/s,v.texturePosition.x+=u,v.texturePosition.y+=h,v.texturePositionClipSpace.x=v.texturePosition.x/s,v.texturePositionClipSpace.y=v.texturePosition.y/s;this._onRemoveTextureAtlasCanvas.fire(c.canvas);let p=this._activePages.indexOf(c);p!==-1&&this._activePages.splice(p,1)}return i}_deletePage(e){this._pages.splice(e,1);for(let n=e;n<this._pages.length;n++){let s=this._pages[n];for(let i of s.glyphs)i.texturePage--;s.version++}}getRasterizedGlyphCombinedChar(e,n,s,i,l,c){return this._getFromCacheMap(this._cacheMapCombined,e,n,s,i,l,c)}getRasterizedGlyph(e,n,s,i,l,c){return this._getFromCacheMap(this._cacheMap,e,n,s,i,l,c)}_getFromCacheMap(e,n,s,i,l,c,u){return Xl=e.get(n,s,i,l),Xl||(Xl=this._drawToCache(n,s,i,l,c,u),e.set(n,s,i,l,Xl)),Xl}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw new Error("No color found for idx "+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,n,s,i){if(this._config.allowTransparency)return pi;let l;switch(e){case 16777216:case 33554432:l=this._getColorFromAnsiIndex(n);break;case 50331648:let c=za.toColorRGB(n);l=Ds.toColor(c[0],c[1],c[2]);break;case 0:default:s?l=mc.opaque(this._config.colors.foreground):l=this._config.colors.background;break}return this._config.allowTransparency||(l=mc.opaque(l)),l}_getForegroundColor(e,n,s,i,l,c,u,h,p,v){let _=this._getMinimumContrastColor(e,n,s,i,l,c,u,p,h,v);if(_)return _;let g;switch(l){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&p&&c<8&&(c+=8),g=this._getColorFromAnsiIndex(c);break;case 50331648:let b=za.toColorRGB(c);g=Ds.toColor(b[0],b[1],b[2]);break;case 0:default:u?g=this._config.colors.background:g=this._config.colors.foreground}return this._config.allowTransparency&&(g=mc.opaque(g)),h&&(g=mc.multiplyOpacity(g,uM)),g}_resolveBackgroundRgba(e,n,s){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(n).rgba;case 50331648:return n<<8;case 0:default:return s?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,n,s,i){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&i&&n<8&&(n+=8),this._getColorFromAnsiIndex(n).rgba;case 50331648:return n<<8;case 0:default:return s?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,n,s,i,l,c,u,h,p,v){if(this._config.minimumContrastRatio===1||v)return;let _=this._getContrastCache(p),g=_.getColor(e,i);if(g!==void 0)return g||void 0;let b=this._resolveBackgroundRgba(n,s,u),S=this._resolveForegroundRgba(l,c,u,h),j=Ho.ensureContrastRatio(b,S,this._config.minimumContrastRatio/(p?2:1));if(!j){_.setColor(e,i,null);return}let C=Ds.toColor(j>>24&255,j>>16&255,j>>8&255);return _.setColor(e,i,C),C}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(e,n,s,i,l,c){let u=typeof e=="number"?String.fromCharCode(e):e;c&&this._tmpCanvas.parentElement!==c&&(this._tmpCanvas.style.display="none",c.append(this._tmpCanvas));let h=Math.min(this._config.deviceCellWidth*Math.max(u.length,2)+Gl*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<h&&(this._tmpCanvas.width=h);let p=Math.min(this._config.deviceCellHeight+Gl*4,this._textureSize);if(this._tmpCanvas.height<p&&(this._tmpCanvas.height=p),this._tmpCtx.save(),this._workAttributeData.fg=s,this._workAttributeData.bg=n,this._workAttributeData.extended.ext=i,!!this._workAttributeData.isInvisible())return c0;let v=!!this._workAttributeData.isBold(),_=!!this._workAttributeData.isInverse(),g=!!this._workAttributeData.isDim(),b=!!this._workAttributeData.isItalic(),S=!!this._workAttributeData.isUnderline(),j=!!this._workAttributeData.isStrikethrough(),C=!!this._workAttributeData.isOverline(),N=this._workAttributeData.getFgColor(),E=this._workAttributeData.getFgColorMode(),O=this._workAttributeData.getBgColor(),x=this._workAttributeData.getBgColorMode();if(_){let H=N;N=O,O=H;let A=E;E=x,x=A}let W=this._getBackgroundColor(x,O,_,g);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=W.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let $=v?this._config.fontWeightBold:this._config.fontWeight,J=b?"italic":"";this._tmpCtx.font=`${J} ${$} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=gk;let q=u.length===1&&jv(u.charCodeAt(0)),V=u.length===1&&nM(u.charCodeAt(0)),ie=this._getForegroundColor(n,x,O,s,E,N,_,g,v,mk(u.charCodeAt(0)));this._tmpCtx.fillStyle=ie.css;let K=V?0:Gl*2,B=!1;this._config.customGlyphs!==!1&&(B=pM(this._tmpCtx,u,K,K,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let I=!q,D;if(typeof e=="number"?D=this._unicodeService.wcwidth(e):D=this._unicodeService.getStringCellWidth(e),S){this._tmpCtx.save();let H=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),A=H%2===1?.5:0;if(this._tmpCtx.lineWidth=H,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())I=!1,this._tmpCtx.strokeStyle=`rgb(${za.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{I=!1;let te=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&te<8&&(te+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(te).css}this._tmpCtx.beginPath();let U=K,Q=Math.ceil(K+this._config.deviceCharHeight)-A-(l?H*2:0),ae=Q+H,re=Q+H*2,je=this._workAttributeData.getUnderlineVariantOffset();for(let te=0;te<D;te++){this._tmpCtx.save();let ne=U+te*this._config.deviceCellWidth,me=U+(te+1)*this._config.deviceCellWidth,we=ne+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(ne,Q),this._tmpCtx.lineTo(me,Q),this._tmpCtx.moveTo(ne,re),this._tmpCtx.lineTo(me,re);break;case 3:let Fe=H<=1?re:Math.ceil(K+this._config.deviceCharHeight-H/2)-A,Ae=H<=1?Q:Math.ceil(K+this._config.deviceCharHeight+H/2)-A,He=new Path2D;He.rect(ne,Q,this._config.deviceCellWidth,re-Q),this._tmpCtx.clip(He),this._tmpCtx.moveTo(ne-this._config.deviceCellWidth/2,ae),this._tmpCtx.bezierCurveTo(ne-this._config.deviceCellWidth/2,Ae,ne,Ae,ne,ae),this._tmpCtx.bezierCurveTo(ne,Fe,we,Fe,we,ae),this._tmpCtx.bezierCurveTo(we,Ae,me,Ae,me,ae),this._tmpCtx.bezierCurveTo(me,Fe,me+this._config.deviceCellWidth/2,Fe,me+this._config.deviceCellWidth/2,ae);break;case 4:let X=je===0?0:je>=H?H*2-je:H-je;je>=H||X===0?(this._tmpCtx.setLineDash([Math.round(H),Math.round(H)]),this._tmpCtx.moveTo(ne+X,Q),this._tmpCtx.lineTo(me,Q)):(this._tmpCtx.setLineDash([Math.round(H),Math.round(H)]),this._tmpCtx.moveTo(ne,Q),this._tmpCtx.lineTo(ne+X,Q),this._tmpCtx.moveTo(ne+X+H,Q),this._tmpCtx.lineTo(me,Q)),je=lM(me-ne,H,je);break;case 5:let ce=.6,Z=.3,ge=me-ne,Y=Math.floor(ce*ge),he=Math.floor(Z*ge),Ne=ge-Y-he;this._tmpCtx.setLineDash([Y,he,Ne]),this._tmpCtx.moveTo(ne,Q),this._tmpCtx.lineTo(me,Q);break;case 1:default:this._tmpCtx.moveTo(ne,Q),this._tmpCtx.lineTo(me,Q);break}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!B&&this._config.fontSize>=12&&!this._config.allowTransparency&&u!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let te=this._tmpCtx.measureText(u);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in te&&te.actualBoundingBoxDescent>0){this._tmpCtx.save();let ne=new Path2D;ne.rect(U,Q-Math.ceil(H/2),this._config.deviceCellWidth*D,re-Q+Math.ceil(H/2)),this._tmpCtx.clip(ne),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=W.css,this._tmpCtx.strokeText(u,K,K+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(C){let H=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),A=H%2===1?.5:0;this._tmpCtx.lineWidth=H,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(K,K+A),this._tmpCtx.lineTo(K+this._config.deviceCharWidth*D,K+A),this._tmpCtx.stroke()}if(B||this._tmpCtx.fillText(u,K,K+this._config.deviceCharHeight),u==="_"&&!this._config.allowTransparency){let H=xp(this._tmpCtx.getImageData(K,K,this._config.deviceCellWidth,this._config.deviceCellHeight),W,ie,I);if(H)for(let A=1;A<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=W.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(u,K,K+this._config.deviceCharHeight-A),H=xp(this._tmpCtx.getImageData(K,K,this._config.deviceCellWidth,this._config.deviceCellHeight),W,ie,I),!!H);A++);}if(j){let H=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),A=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=H,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(K,K+Math.floor(this._config.deviceCharHeight/2)-A),this._tmpCtx.lineTo(K+this._config.deviceCharWidth*D,K+Math.floor(this._config.deviceCharHeight/2)-A),this._tmpCtx.stroke()}this._tmpCtx.restore();let T=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),z;if(this._config.allowTransparency?z=PM(T):z=xp(T,W,ie,I),z)return c0;let R=this._findGlyphBoundingBox(T,this._workBoundingBox,h,V,B,K),M,L;for(;;){if(this._activePages.length===0){let H=this._createNewPage();M=H,L=H.currentRow,L.height=R.size.y;break}M=this._activePages[this._activePages.length-1],L=M.currentRow;for(let H of this._activePages)R.size.y<=H.currentRow.height&&(M=H,L=H.currentRow);for(let H=this._activePages.length-1;H>=0;H--)for(let A of this._activePages[H].fixedRows)A.height<=L.height&&R.size.y<=A.height&&(M=this._activePages[H],L=A);if(R.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new Sp(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),M=this._overflowSizePage,L=this._overflowSizePage.currentRow,L.x+R.size.x>=M.canvas.width&&(L.x=0,L.y+=L.height,L.height=0);break}if(L.y+R.size.y>=M.canvas.height||L.height>R.size.y+2){let H=!1;if(M.currentRow.y+M.currentRow.height+R.size.y>=M.canvas.height){let A;for(let U of this._activePages)if(U.currentRow.y+U.currentRow.height+R.size.y<U.canvas.height){A=U;break}if(A)M=A;else if(Oa.maxAtlasPages&&this._pages.length>=Oa.maxAtlasPages&&L.y+R.size.y<=M.canvas.height&&L.height>=R.size.y&&L.x+R.size.x<=M.canvas.width)H=!0;else{let U=this._createNewPage();M=U,L=U.currentRow,L.height=R.size.y,H=!0}}H||(M.currentRow.height>0&&M.fixedRows.push(M.currentRow),L={x:0,y:M.currentRow.y+M.currentRow.height,height:R.size.y},M.fixedRows.push(L),M.currentRow={x:0,y:L.y+L.height,height:0})}if(L.x+R.size.x<=M.canvas.width)break;L===M.currentRow?(L.x=0,L.y+=L.height,L.height=0):M.fixedRows.splice(M.fixedRows.indexOf(L),1)}return R.texturePage=this._pages.indexOf(M),R.texturePosition.x=L.x,R.texturePosition.y=L.y,R.texturePositionClipSpace.x=L.x/M.canvas.width,R.texturePositionClipSpace.y=L.y/M.canvas.height,R.sizeClipSpace.x/=M.canvas.width,R.sizeClipSpace.y/=M.canvas.height,L.height=Math.max(L.height,R.size.y),L.x+=R.size.x,M.ctx.putImageData(T,R.texturePosition.x-this._workBoundingBox.left,R.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,R.size.x,R.size.y),M.addGlyph(R),M.version++,R}_findGlyphBoundingBox(e,n,s,i,l,c){n.top=0;let u=i?this._config.deviceCellHeight:this._tmpCanvas.height,h=i?this._config.deviceCellWidth:s,p=!1;for(let v=0;v<u;v++){for(let _=0;_<h;_++){let g=v*this._tmpCanvas.width*4+_*4+3;if(e.data[g]!==0){n.top=v,p=!0;break}}if(p)break}n.left=0,p=!1;for(let v=0;v<c+h;v++){for(let _=0;_<u;_++){let g=_*this._tmpCanvas.width*4+v*4+3;if(e.data[g]!==0){n.left=v,p=!0;break}}if(p)break}n.right=h,p=!1;for(let v=c+h-1;v>=c;v--){for(let _=0;_<u;_++){let g=_*this._tmpCanvas.width*4+v*4+3;if(e.data[g]!==0){n.right=v,p=!0;break}}if(p)break}n.bottom=u,p=!1;for(let v=u-1;v>=0;v--){for(let _=0;_<h;_++){let g=v*this._tmpCanvas.width*4+_*4+3;if(e.data[g]!==0){n.bottom=v,p=!0;break}}if(p)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:n.right-n.left+1,y:n.bottom-n.top+1},sizeClipSpace:{x:n.right-n.left+1,y:n.bottom-n.top+1},offset:{x:-n.left+c+(i||l?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-n.top+c+(i||l?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},Sp=class{constructor(t,e,n){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],n)for(let s of n)this._glyphs.push(...s.glyphs),this._usedPixels+=s._usedPixels;this.canvas=Nk(t,e,e),this.ctx=Bn(this.canvas.getContext("2d",{alpha:!0}))}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(t){this._glyphs.push(t),this._usedPixels+=t.size.x*t.size.y}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version++}};function xp(t,e,n,s){let i=e.rgba>>>24,l=e.rgba>>>16&255,c=e.rgba>>>8&255,u=n.rgba>>>24,h=n.rgba>>>16&255,p=n.rgba>>>8&255,v=Math.floor((Math.abs(i-u)+Math.abs(l-h)+Math.abs(c-p))/12),_=!0;for(let g=0;g<t.data.length;g+=4)t.data[g]===i&&t.data[g+1]===l&&t.data[g+2]===c||s&&Math.abs(t.data[g]-i)+Math.abs(t.data[g+1]-l)+Math.abs(t.data[g+2]-c)<v?t.data[g+3]=0:_=!1;return _}function PM(t){for(let e=0;e<t.data.length;e+=4)if(t.data[e+3]>0)return!1;return!0}function Nk(t,e,n){let s=t.createElement("canvas");return s.width=e,s.height=n,s}function IM(t,e,n,s,i,l,c,u){let h={foreground:l.foreground,background:l.background,cursor:pi,cursorAccent:pi,selectionForeground:pi,selectionBackgroundTransparent:pi,selectionBackgroundOpaque:pi,selectionInactiveBackgroundTransparent:pi,selectionInactiveBackgroundOpaque:pi,overviewRulerBorder:pi,scrollbarSliderBackground:pi,scrollbarSliderHoverBackground:pi,scrollbarSliderActiveBackground:pi,ansi:l.ansi.slice(),contrastCache:l.contrastCache,halfContrastCache:l.halfContrastCache};return{customGlyphs:i.customGlyphs,devicePixelRatio:c,deviceMaxTextureSize:u,letterSpacing:i.letterSpacing,lineHeight:i.lineHeight,deviceCellWidth:t,deviceCellHeight:e,deviceCharWidth:n,deviceCharHeight:s,fontFamily:i.fontFamily,fontSize:i.fontSize,fontWeight:i.fontWeight,fontWeightBold:i.fontWeightBold,allowTransparency:i.allowTransparency,drawBoldTextInBrightColors:i.drawBoldTextInBrightColors,minimumContrastRatio:i.minimumContrastRatio,colors:h}}function u0(t,e){for(let n=0;n<t.colors.ansi.length;n++)if(t.colors.ansi[n].rgba!==e.colors.ansi[n].rgba)return!1;return t.devicePixelRatio===e.devicePixelRatio&&t.customGlyphs===e.customGlyphs&&t.lineHeight===e.lineHeight&&t.letterSpacing===e.letterSpacing&&t.fontFamily===e.fontFamily&&t.fontSize===e.fontSize&&t.fontWeight===e.fontWeight&&t.fontWeightBold===e.fontWeightBold&&t.allowTransparency===e.allowTransparency&&t.deviceCharWidth===e.deviceCharWidth&&t.deviceCharHeight===e.deviceCharHeight&&t.drawBoldTextInBrightColors===e.drawBoldTextInBrightColors&&t.minimumContrastRatio===e.minimumContrastRatio&&t.colors.foreground.rgba===e.colors.foreground.rgba&&t.colors.background.rgba===e.colors.background.rgba}function DM(t){return(t&50331648)===16777216||(t&50331648)===33554432}var vi=[];function jk(t,e,n,s,i,l,c,u,h){let p=IM(s,i,l,c,e,n,u,h);for(let g=0;g<vi.length;g++){let b=vi[g],S=b.ownedBy.indexOf(t);if(S>=0){if(u0(b.config,p))return b.atlas;b.ownedBy.length===1?(b.atlas.dispose(),vi.splice(g,1)):b.ownedBy.splice(S,1);break}}for(let g=0;g<vi.length;g++){let b=vi[g];if(u0(b.config,p))return b.ownedBy.push(t),b.atlas}let v=t._core,_={atlas:new Zr(document,p,v.unicodeService),config:p,ownedBy:[t]};return vi.push(_),_.atlas}function d0(t){for(let e=0;e<vi.length;e++){let n=vi[e].ownedBy.indexOf(t);if(n!==-1){vi[e].ownedBy.length===1?(vi[e].atlas.dispose(),vi.splice(e,1)):vi[e].ownedBy.splice(n,1);break}}}var ad=600,OM=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&this._restartInterval()}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}restartBlinkAnimation(){this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})))}_restartInterval(t=ad){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=ad-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0){this._restartInterval(e);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=ad-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},ad)},t)}pause(){this.isCursorVisible=!0,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function h0(t,e,n){let s=new e.ResizeObserver(i=>{let l=i.find(h=>h.target===t);if(!l)return;if(!("devicePixelContentBoxSize"in l)){s==null||s.disconnect(),s=void 0;return}let c=l.devicePixelContentBoxSize[0].inlineSize,u=l.devicePixelContentBoxSize[0].blockSize;c>0&&u>0&&n(c,u)});try{s.observe(t,{box:["device-pixel-content-box"]})}catch{s.disconnect(),s=void 0}return Rs(()=>s==null?void 0:s.disconnect())}function BM(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}var f0=class Lk extends za{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new bk,this.combinedData=""}static fromCharData(e){let n=new Lk;return n.setFromCharData(e),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?BM(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let n=!1;if(e[1].length>2)n=!0;else if(e[1].length===2){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let i=e[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(s-55296)*1024+i-56320+65536|e[2]<<22:n=!0}else n=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;n&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Rk=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function Ak(t,e,n){let s=Bn(t.createProgram());if(t.attachShader(s,Bn(p0(t,t.VERTEX_SHADER,e))),t.attachShader(s,Bn(p0(t,t.FRAGMENT_SHADER,n))),t.linkProgram(s),t.getProgramParameter(s,t.LINK_STATUS))return s;console.error(t.getProgramInfoLog(s)),t.deleteProgram(s)}function p0(t,e,n){let s=Bn(t.createShader(e));if(t.shaderSource(s,n),t.compileShader(s),t.getShaderParameter(s,t.COMPILE_STATUS))return s;console.error(t.getShaderInfoLog(s)),t.deleteShader(s)}function $M(t,e){let n=Math.min(t.length*2,e),s=new Float32Array(n);for(let i=0;i<t.length;i++)s[i]=t[i];return s}var zM=class{constructor(t){this.texture=t,this.version=-1}},FM=`#version 300 es
95
+ layout (location = 0) in vec2 a_unitquad;
96
+ layout (location = 1) in vec2 a_cellpos;
97
+ layout (location = 2) in vec2 a_offset;
98
+ layout (location = 3) in vec2 a_size;
99
+ layout (location = 4) in float a_texpage;
100
+ layout (location = 5) in vec2 a_texcoord;
101
+ layout (location = 6) in vec2 a_texsize;
102
+
103
+ uniform mat4 u_projection;
104
+ uniform vec2 u_resolution;
105
+
106
+ out vec2 v_texcoord;
107
+ flat out int v_texpage;
108
+
109
+ void main() {
110
+ vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);
111
+ gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
112
+ v_texpage = int(a_texpage);
113
+ v_texcoord = a_texcoord + a_unitquad * a_texsize;
114
+ }`;function HM(t){let e="";for(let n=1;n<t;n++)e+=` else if (v_texpage == ${n}) { outColor = texture(u_texture[${n}], v_texcoord); }`;return`#version 300 es
115
+ precision lowp float;
116
+
117
+ in vec2 v_texcoord;
118
+ flat in int v_texpage;
119
+
120
+ uniform sampler2D u_texture[${t}];
121
+
122
+ out vec4 outColor;
123
+
124
+ void main() {
125
+ if (v_texpage == 0) {
126
+ outColor = texture(u_texture[0], v_texcoord);
127
+ } ${e}
128
+ }`}var eo=11,Ra=eo*Float32Array.BYTES_PER_ELEMENT,UM=2,jn=0,pn,kp=0,Jl=0,WM=class extends Pi{constructor(t,e,n,s){super(),this._terminal=t,this._gl=e,this._dimensions=n,this._optionsService=s,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let i=this._gl;Zr.maxAtlasPages===void 0&&(Zr.maxAtlasPages=Math.min(32,Bn(i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS))),Zr.maxTextureSize=Bn(i.getParameter(i.MAX_TEXTURE_SIZE))),this._program=Bn(Ak(i,FM,HM(Zr.maxAtlasPages))),this._register(Rs(()=>i.deleteProgram(this._program))),this._projectionLocation=Bn(i.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=Bn(i.getUniformLocation(this._program,"u_resolution")),this._textureLocation=Bn(i.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let l=new Float32Array([0,0,1,0,0,1,1,1]),c=i.createBuffer();this._register(Rs(()=>i.deleteBuffer(c))),i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,l,i.STATIC_DRAW),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let u=new Uint8Array([0,1,2,3]),h=i.createBuffer();this._register(Rs(()=>i.deleteBuffer(h))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,h),i.bufferData(i.ELEMENT_ARRAY_BUFFER,u,i.STATIC_DRAW),this._attributesBuffer=Bn(i.createBuffer()),this._register(Rs(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,2,i.FLOAT,!1,Ra,0),i.vertexAttribDivisor(2,1),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,i.FLOAT,!1,Ra,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(3,1),i.enableVertexAttribArray(4),i.vertexAttribPointer(4,1,i.FLOAT,!1,Ra,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(4,1),i.enableVertexAttribArray(5),i.vertexAttribPointer(5,2,i.FLOAT,!1,Ra,5*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(5,1),i.enableVertexAttribArray(6),i.vertexAttribPointer(6,2,i.FLOAT,!1,Ra,7*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(6,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,Ra,9*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.useProgram(this._program);let p=new Int32Array(Zr.maxAtlasPages);for(let v=0;v<Zr.maxAtlasPages;v++)p[v]=v;i.uniform1iv(this._textureLocation,p),i.uniformMatrix4fv(this._projectionLocation,!1,Rk),this._atlasTextures=[];for(let v=0;v<Zr.maxAtlasPages;v++){let _=new zM(Bn(i.createTexture()));this._register(Rs(()=>i.deleteTexture(_.texture))),i.activeTexture(i.TEXTURE0+v),i.bindTexture(i.TEXTURE_2D,_.texture),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[v]=_}i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return this._atlas?this._atlas.beginFrame():!0}updateCell(t,e,n,s,i,l,c,u,h){this._updateCell(this._vertices.attributes,t,e,n,s,i,l,c,u,h)}_updateCell(t,e,n,s,i,l,c,u,h,p){if(jn=(n*this._terminal.cols+e)*eo,s===0||s===void 0){t.fill(0,jn,jn+eo-1-UM);return}this._atlas&&(u&&u.length>1?pn=this._atlas.getRasterizedGlyphCombinedChar(u,i,l,c,!1,this._terminal.element):pn=this._atlas.getRasterizedGlyph(s,i,l,c,!1,this._terminal.element),kp=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),i!==p&&pn.offset.x>kp?(Jl=pn.offset.x-kp,t[jn]=-(pn.offset.x-Jl)+this._dimensions.device.char.left,t[jn+1]=-pn.offset.y+this._dimensions.device.char.top,t[jn+2]=(pn.size.x-Jl)/this._dimensions.device.canvas.width,t[jn+3]=pn.size.y/this._dimensions.device.canvas.height,t[jn+4]=pn.texturePage,t[jn+5]=pn.texturePositionClipSpace.x+Jl/this._atlas.pages[pn.texturePage].canvas.width,t[jn+6]=pn.texturePositionClipSpace.y,t[jn+7]=pn.sizeClipSpace.x-Jl/this._atlas.pages[pn.texturePage].canvas.width,t[jn+8]=pn.sizeClipSpace.y):(t[jn]=-pn.offset.x+this._dimensions.device.char.left,t[jn+1]=-pn.offset.y+this._dimensions.device.char.top,t[jn+2]=pn.size.x/this._dimensions.device.canvas.width,t[jn+3]=pn.size.y/this._dimensions.device.canvas.height,t[jn+4]=pn.texturePage,t[jn+5]=pn.texturePositionClipSpace.x,t[jn+6]=pn.texturePositionClipSpace.y,t[jn+7]=pn.sizeClipSpace.x,t[jn+8]=pn.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&oM(s,h,pn.size.x,this._dimensions.device.cell.width)&&(t[jn+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let t=this._terminal,e=t.cols*t.rows*eo;this._vertices.count!==e?this._vertices.attributes=new Float32Array(e):this._vertices.attributes.fill(0);let n=0;for(;n<this._vertices.attributesBuffers.length;n++)this._vertices.count!==e?this._vertices.attributesBuffers[n]=new Float32Array(e):this._vertices.attributesBuffers[n].fill(0);this._vertices.count=e,n=0;for(let s=0;s<t.rows;s++)for(let i=0;i<t.cols;i++)this._vertices.attributes[n+9]=i/t.cols,this._vertices.attributes[n+10]=s/t.rows,n+=eo}handleResize(){let t=this._gl;t.useProgram(this._program),t.viewport(0,0,t.canvas.width,t.canvas.height),t.uniform2f(this._resolutionLocation,t.canvas.width,t.canvas.height),this.clear()}render(t){if(!this._atlas)return;let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let n=this._vertices.attributesBuffers[this._activeBuffer],s=0;for(let i=0;i<t.lineLengths.length;i++){let l=i*this._terminal.cols*eo,c=this._vertices.attributes.subarray(l,l+t.lineLengths[i]*eo);n.set(c,s),s+=c.length}e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,n.subarray(0,s),e.STREAM_DRAW);for(let i=0;i<this._atlas.pages.length;i++)this._atlas.pages[i].version!==this._atlasTextures[i].version&&this._bindAtlasPageTexture(e,this._atlas,i);e.drawElementsInstanced(e.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,s/eo)}setAtlas(t){this._atlas=t;for(let e of this._atlasTextures)e.version=-1}_bindAtlasPageTexture(t,e,n){t.activeTexture(t.TEXTURE0+n),t.bindTexture(t.TEXTURE_2D,this._atlasTextures[n].texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e.pages[n].canvas),t.generateMipmap(t.TEXTURE_2D),this._atlasTextures[n].version=e.pages[n].version}setDimensions(t){this._dimensions=t}},qM=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(t,e,n,s=!1){if(this.selectionStart=e,this.selectionEnd=n,!e||!n||e[0]===n[0]&&e[1]===n[1]){this.clear();return}let i=t.buffers.active.ydisp,l=e[1]-i,c=n[1]-i,u=Math.max(l,0),h=Math.min(c,t.rows-1);if(u>=t.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=l,this.viewportEndRow=c,this.viewportCappedStartRow=u,this.viewportCappedEndRow=h,this.startCol=e[0],this.endCol=n[0]}isCellSelected(t,e,n){return this.hasSelection?(n-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&n>=this.viewportCappedStartRow&&e<this.endCol&&n<=this.viewportCappedEndRow:e<this.startCol&&n>=this.viewportCappedStartRow&&e>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&e>=this.startCol):!1}};function KM(){return new qM}var Hd=4,Ed=1,Nd=2,Cp=3,VM=2147483648,YM=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=KM()}resize(t,e){let n=t*e*Hd;n!==this.cells.length&&(this.cells=new Uint32Array(n),this.lineLengths=new Uint32Array(e))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},GM=`#version 300 es
129
+ layout (location = 0) in vec2 a_position;
130
+ layout (location = 1) in vec2 a_size;
131
+ layout (location = 2) in vec4 a_color;
132
+ layout (location = 3) in vec2 a_unitquad;
133
+
134
+ uniform mat4 u_projection;
135
+
136
+ out vec4 v_color;
137
+
138
+ void main() {
139
+ vec2 zeroToOne = a_position + (a_unitquad * a_size);
140
+ gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
141
+ v_color = a_color;
142
+ }`,XM=`#version 300 es
143
+ precision lowp float;
144
+
145
+ in vec4 v_color;
146
+
147
+ out vec4 outColor;
148
+
149
+ void main() {
150
+ outColor = v_color;
151
+ }`,Sr=8,Ep=Sr*Float32Array.BYTES_PER_ELEMENT,JM=20*Sr,m0=class{constructor(){this.attributes=new Float32Array(JM),this.count=0}},br=0,g0=0,v0=0,_0=0,y0=0,w0=0,b0=0,QM=class extends Pi{constructor(t,e,n,s){super(),this._terminal=t,this._gl=e,this._dimensions=n,this._themeService=s,this._vertices=new m0,this._verticesCursor=new m0;let i=this._gl;this._program=Bn(Ak(i,GM,XM)),this._register(Rs(()=>i.deleteProgram(this._program))),this._projectionLocation=Bn(i.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let l=new Float32Array([0,0,1,0,0,1,1,1]),c=i.createBuffer();this._register(Rs(()=>i.deleteBuffer(c))),i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,l,i.STATIC_DRAW),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let u=new Uint8Array([0,1,2,3]),h=i.createBuffer();this._register(Rs(()=>i.deleteBuffer(h))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,h),i.bufferData(i.ELEMENT_ARRAY_BUFFER,u,i.STATIC_DRAW),this._attributesBuffer=Bn(i.createBuffer()),this._register(Rs(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,Ep,0),i.vertexAttribDivisor(0,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,Ep,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,Ep,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(2,1),this._updateCachedColors(s.colors),this._register(this._themeService.onChangeColors(p=>{this._updateCachedColors(p),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(t){let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),e.uniformMatrix4fv(this._projectionLocation,!1,Rk),e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,t.attributes,e.DYNAMIC_DRAW),e.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,t.count)}handleResize(){this._updateViewportRectangle()}setDimensions(t){this._dimensions=t}_updateCachedColors(t){this._bgFloat=this._colorToFloat32Array(t.background),this._cursorFloat=this._colorToFloat32Array(t.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(t){let e=this._terminal,n=this._vertices,s=1,i,l,c,u,h,p,v,_,g,b,S;for(i=0;i<e.rows;i++){for(c=-1,u=0,h=0,p=!1,l=0;l<e.cols;l++)v=(i*e.cols+l)*Hd,_=t.cells[v+Ed],g=t.cells[v+Nd],b=!!(g&67108864),(_!==u||g!==h&&(p||b))&&((u!==0||p&&h!==0)&&(S=s++*Sr,this._updateRectangle(n,S,h,u,c,l,i)),c=l,u=_,h=g,p=b);(u!==0||p&&h!==0)&&(S=s++*Sr,this._updateRectangle(n,S,h,u,c,e.cols,i))}n.count=s}updateCursor(t){let e=this._verticesCursor,n=t.cursor;if(!n||n.style==="block"){e.count=0;return}let s,i=0;(n.style==="bar"||n.style==="outline")&&(s=i++*Sr,this._addRectangleFloat(e.attributes,s,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.style==="bar"?n.dpr*n.cursorWidth:n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(n.style==="underline"||n.style==="outline")&&(s=i++*Sr,this._addRectangleFloat(e.attributes,s,n.x*this._dimensions.device.cell.width,(n.y+1)*this._dimensions.device.cell.height-n.dpr,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat)),n.style==="outline"&&(s=i++*Sr,this._addRectangleFloat(e.attributes,s,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat),s=i++*Sr,this._addRectangleFloat(e.attributes,s,(n.x+n.width)*this._dimensions.device.cell.width-n.dpr,n.y*this._dimensions.device.cell.height,n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),e.count=i}_updateRectangle(t,e,n,s,i,l,c){if(n&67108864)switch(n&50331648){case 16777216:case 33554432:br=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:br=(n&16777215)<<8;break;case 0:default:br=this._themeService.colors.foreground.rgba}else switch(s&50331648){case 16777216:case 33554432:br=this._themeService.colors.ansi[s&255].rgba;break;case 50331648:br=(s&16777215)<<8;break;case 0:default:br=this._themeService.colors.background.rgba}t.attributes.length<e+4&&(t.attributes=$M(t.attributes,this._terminal.rows*this._terminal.cols*Sr)),g0=i*this._dimensions.device.cell.width,v0=c*this._dimensions.device.cell.height,_0=(br>>24&255)/255,y0=(br>>16&255)/255,w0=(br>>8&255)/255,b0=1,this._addRectangle(t.attributes,e,g0,v0,(l-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,_0,y0,w0,b0)}_addRectangle(t,e,n,s,i,l,c,u,h,p){t[e]=n/this._dimensions.device.canvas.width,t[e+1]=s/this._dimensions.device.canvas.height,t[e+2]=i/this._dimensions.device.canvas.width,t[e+3]=l/this._dimensions.device.canvas.height,t[e+4]=c,t[e+5]=u,t[e+6]=h,t[e+7]=p}_addRectangleFloat(t,e,n,s,i,l,c){t[e]=n/this._dimensions.device.canvas.width,t[e+1]=s/this._dimensions.device.canvas.height,t[e+2]=i/this._dimensions.device.canvas.width,t[e+3]=l/this._dimensions.device.canvas.height,t[e+4]=c[0],t[e+5]=c[1],t[e+6]=c[2],t[e+7]=c[3]}_colorToFloat32Array(t){return new Float32Array([(t.rgba>>24&255)/255,(t.rgba>>16&255)/255,(t.rgba>>8&255)/255,(t.rgba&255)/255])}},ZM=class extends Pi{constructor(t,e,n,s,i,l,c,u){super(),this._container=e,this._alpha=i,this._coreBrowserService=l,this._optionsService=c,this._themeService=u,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${n}-layer`),this._canvas.style.zIndex=s.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(h=>{this._refreshCharAtlas(t,h),this.reset(t)})),this._register(Rs(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=Bn(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(t){}handleFocus(t){}handleCursorMove(t){}handleGridChanged(t,e,n){}handleSelectionChanged(t,e,n,s=!1){}_setTransparency(t,e){if(e===this._alpha)return;let n=this._canvas;this._alpha=e,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,n),this._refreshCharAtlas(t,this._themeService.colors),this.handleGridChanged(t,0,t.rows-1)}_refreshCharAtlas(t,e){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=jk(t,this._optionsService.rawOptions,e,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(t,e){this._deviceCellWidth=e.device.cell.width,this._deviceCellHeight=e.device.cell.height,this._deviceCharWidth=e.device.char.width,this._deviceCharHeight=e.device.char.height,this._deviceCharLeft=e.device.char.left,this._deviceCharTop=e.device.char.top,this._canvas.width=e.device.canvas.width,this._canvas.height=e.device.canvas.height,this._canvas.style.width=`${e.css.canvas.width}px`,this._canvas.style.height=`${e.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(t,this._themeService.colors)}_fillBottomLineAtCells(t,e,n=1){this._ctx.fillRect(t*this._deviceCellWidth,(e+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,n*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(t,e,n,s){this._alpha?this._ctx.clearRect(t*this._deviceCellWidth,e*this._deviceCellHeight,n*this._deviceCellWidth,s*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(t*this._deviceCellWidth,e*this._deviceCellHeight,n*this._deviceCellWidth,s*this._deviceCellHeight))}_fillCharTrueColor(t,e,n,s){this._ctx.font=this._getFont(t,!1,!1),this._ctx.textBaseline=gk,this._clipCell(n,s,e.getWidth()),this._ctx.fillText(e.getChars(),n*this._deviceCellWidth+this._deviceCharLeft,s*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(t,e,n){this._ctx.beginPath(),this._ctx.rect(t*this._deviceCellWidth,e*this._deviceCellHeight,n*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(t,e,n){let s=e?t.options.fontWeightBold:t.options.fontWeight;return`${n?"italic":""} ${s} ${t.options.fontSize*this._coreBrowserService.dpr}px ${t.options.fontFamily}`}},eT=class extends ZM{constructor(t,e,n,s,i,l,c){super(n,t,"link",e,!0,i,l,c),this._register(s.onShowLinkUnderline(u=>this._handleShowLinkUnderline(u))),this._register(s.onHideLinkUnderline(u=>this._handleHideLinkUnderline(u)))}resize(t,e){super.resize(t,e),this._state=void 0}reset(t){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let t=this._state.y2-this._state.y1-1;t>0&&this._clearCells(0,this._state.y1+1,this._state.cols,t),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(t){if(t.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:t.fg!==void 0&&DM(t.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[t.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,t.y1===t.y2)this._fillBottomLineAtCells(t.x1,t.y1,t.x2-t.x1);else{this._fillBottomLineAtCells(t.x1,t.y1,t.cols-t.x1);for(let e=t.y1+1;e<t.y2;e++)this._fillBottomLineAtCells(0,e,t.cols);this._fillBottomLineAtCells(0,t.y2,t.x2)}this._state=t}_handleHideLinkUnderline(t){this._clearCurrentLink()}},Bo=typeof window=="object"?window:globalThis,_g=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new gn,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new gn,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,n){if(this.getZoomLevel(n)===e)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),e)}setFullscreen(e,n){if(this.isFullscreen(n)===e)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};_g.INSTANCE=new _g;var Mk=_g;function tT(t,e,n){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",n)}Mk.INSTANCE.onDidChangeZoomLevel;Mk.INSTANCE.onDidChangeFullscreen;var il=typeof navigator=="object"?navigator.userAgent:"";il.indexOf("Firefox")>=0;il.indexOf("AppleWebKit")>=0;var nT=il.indexOf("Chrome")>=0;!nT&&il.indexOf("Safari")>=0;il.indexOf("Electron/")>=0;il.indexOf("Android")>=0;var Np=!1;if(typeof Bo.matchMedia=="function"){let t=Bo.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=Bo.matchMedia("(display-mode: fullscreen)");Np=t.matches,tT(Bo,t,({matches:n})=>{Np&&e.matches||(Np=n)})}var Fa="en",jp=!1,Tk=!1,ld,jd=Fa,S0=Fa,sT,Ai,Uo=globalThis,vs,zx;typeof Uo.vscode<"u"&&typeof Uo.vscode.process<"u"?vs=Uo.vscode.process:typeof process<"u"&&typeof((zx=process==null?void 0:process.versions)==null?void 0:zx.node)=="string"&&(vs=process);var Fx,iT=typeof((Fx=vs==null?void 0:vs.versions)==null?void 0:Fx.electron)=="string",rT=iT&&(vs==null?void 0:vs.type)==="renderer",Hx;if(typeof vs=="object"){vs.platform,vs.platform,jp=vs.platform==="linux",jp&&vs.env.SNAP&&vs.env.SNAP_REVISION,vs.env.CI||vs.env.BUILD_ARTIFACTSTAGINGDIRECTORY,ld=Fa,jd=Fa;let t=vs.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);ld=e.userLocale,S0=e.osLocale,jd=e.resolvedLanguage||Fa,sT=(Hx=e.languagePack)==null?void 0:Hx.translationsConfigFile}catch{}Tk=!0}else typeof navigator=="object"&&!rT?(Ai=navigator.userAgent,Ai.indexOf("Windows")>=0,Ai.indexOf("Macintosh")>=0,(Ai.indexOf("Macintosh")>=0||Ai.indexOf("iPad")>=0||Ai.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,jp=Ai.indexOf("Linux")>=0,(Ai==null?void 0:Ai.indexOf("Mobi"))>=0,jd=globalThis._VSCODE_NLS_LANGUAGE||Fa,ld=navigator.language.toLowerCase(),S0=ld):console.error("Unable to resolve platform.");var x0=Tk,nr=Ai,Xr=jd,oT;(t=>{function e(){return Xr}t.value=e;function n(){return Xr.length===2?Xr==="en":Xr.length>=3?Xr[0]==="e"&&Xr[1]==="n"&&Xr[2]==="-":!1}t.isDefaultVariant=n;function s(){return Xr==="en"}t.isDefault=s})(oT||(oT={}));var aT=typeof Uo.postMessage=="function"&&!Uo.importScripts;(()=>{if(aT){let t=[];Uo.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,i=t.length;s<i;s++){let l=t[s];if(l.id===n.data.vscodeScheduleAsyncWork){t.splice(s,1),l.callback();return}}});let e=0;return n=>{let s=++e;t.push({id:s,callback:n}),Uo.postMessage({vscodeScheduleAsyncWork:s},"*")}}return t=>setTimeout(t)})();var lT=!!(nr&&nr.indexOf("Chrome")>=0);nr&&nr.indexOf("Firefox")>=0;!lT&&nr&&nr.indexOf("Safari")>=0;nr&&nr.indexOf("Edg/")>=0;nr&&nr.indexOf("Android")>=0;var Aa=typeof navigator=="object"?navigator:{};x0||document.queryCommandSupported&&document.queryCommandSupported("copy")||Aa&&Aa.clipboard&&Aa.clipboard.writeText,x0||Aa&&Aa.clipboard&&Aa.clipboard.readText;var Lv=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},Lp=new Lv,k0=new Lv,C0=new Lv;new Array(230);var cT;(t=>{function e(u){return Lp.keyCodeToStr(u)}t.toString=e;function n(u){return Lp.strToKeyCode(u)}t.fromString=n;function s(u){return k0.keyCodeToStr(u)}t.toUserSettingsUS=s;function i(u){return C0.keyCodeToStr(u)}t.toUserSettingsGeneral=i;function l(u){return k0.strToKeyCode(u)||C0.strToKeyCode(u)}t.fromUserSettings=l;function c(u){if(u>=98&&u<=113)return null;switch(u){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Lp.keyCodeToStr(u)}t.toElectronAccelerator=c})(cT||(cT={}));var Pk=Object.freeze(function(t,e){let n=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(n)}}}),uT;(t=>{function e(n){return n===t.None||n===t.Cancelled||n instanceof dT?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Er.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Pk})})(uT||(uT={}));var dT=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?Pk:(this._emitter||(this._emitter=new gn),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},hT;(t=>{async function e(s){let i,l=await Promise.all(s.map(c=>c.then(u=>u,u=>{i||(i=u)})));if(typeof i<"u")throw i;return l}t.settled=e;function n(s){return new Promise(async(i,l)=>{try{await s(i,l)}catch(c){l(c)}})}t.withAsyncBody=n})(hT||(hT={}));var E0=class mi{static fromArray(e){return new mi(n=>{n.emitMany(e)})}static fromPromise(e){return new mi(async n=>{n.emitMany(await e)})}static fromPromises(e){return new mi(async n=>{await Promise.all(e.map(async s=>n.emitOne(await s)))})}static merge(e){return new mi(async n=>{await Promise.all(e.map(async s=>{for await(let i of s)n.emitOne(i)}))})}constructor(e,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new gn,queueMicrotask(async()=>{let s={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(e(s)),this.resolve()}catch(i){this.reject(i)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Er.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(e,n){return new mi(async s=>{for await(let i of e)s.emitOne(n(i))})}map(e){return mi.map(this,e)}static filter(e,n){return new mi(async s=>{for await(let i of e)n(i)&&s.emitOne(i)})}filter(e){return mi.filter(this,e)}static coalesce(e){return mi.filter(e,n=>!!n)}coalesce(){return mi.coalesce(this)}static async toPromise(e){let n=[];for await(let s of e)n.push(s);return n}toPromise(){return mi.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};E0.EMPTY=E0.fromArray([]);var{getWindow:fT}=(function(){let t=new Map,e={window:Bo,disposables:new Wa};t.set(Bo.vscodeWindowId,e);let n=new gn,s=new gn,i=new gn;function l(c,u){return(typeof c=="number"?t.get(c):void 0)??(u?e:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:s.event,registerWindow(c){if(t.has(c.vscodeWindowId))return Pi.None;let u=new Wa,h={window:c,disposables:u.add(new Wa)};return t.set(c.vscodeWindowId,h),u.add(Rs(()=>{t.delete(c.vscodeWindowId),s.fire(c)})),u.add(yg(c,mT.BEFORE_UNLOAD,()=>{i.fire(c)})),n.fire(h),u},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return t.has(c)},getWindowById:l,getWindow(c){var p;let u=c;if((p=u==null?void 0:u.ownerDocument)!=null&&p.defaultView)return u.ownerDocument.defaultView.window;let h=c;return h!=null&&h.view?h.view.window:Bo},getDocument(c){return fT(c).document}}})(),pT=class{constructor(t,e,n,s){this._node=t,this._type=e,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 yg(t,e,n,s){return new pT(t,e,n,s)}var mT={BEFORE_UNLOAD:"beforeunload"},gT=class extends Pi{constructor(t,e,n,s,i,l,c,u,h){super(),this._terminal=t,this._characterJoinerService=e,this._charSizeService=n,this._coreBrowserService=s,this._coreService=i,this._decorationService=l,this._optionsService=c,this._themeService=u,this._cursorBlinkStateManager=new Yl,this._charAtlasDisposable=this._register(new Yl),this._observerDisposable=this._register(new Yl),this._model=new YM,this._workCell=new f0,this._workCell2=new f0,this._rectangleRenderer=this._register(new Yl),this._glyphRenderer=this._register(new Yl),this._onChangeTextureAtlas=this._register(new gn),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new gn),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new gn),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new gn),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new gn),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let p={antialias:!1,depth:!1,preserveDrawingBuffer:h};if(this._gl=this._canvas.getContext("webgl2",p),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new cM(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new eT(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,c,this._themeService)],this.dimensions=aM(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(c.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(yg(this._canvas,"webglcontextlost",v=>{console.log("webglcontextlost event received"),v.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(v)},3e3)})),this._register(yg(this._canvas,"webglcontextrestored",v=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,d0(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=h0(this._canvas,this._coreBrowserService.window,(v,_)=>this._setCanvasDevicePixelDimensions(v,_)),this._register(this._coreBrowserService.onWindowChange(v=>{this._observerDisposable.value=h0(this._canvas,v,(_,g)=>this._setCanvasDevicePixelDimensions(_,g))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(Rs(()=>{var v;for(let _ of this._renderLayers)_.dispose();(v=this._canvas.parentElement)==null||v.removeChild(this._canvas),d0(this._terminal)}))}get textureAtlas(){var t;return(t=this._charAtlas)==null?void 0:t.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(t,e){var n,s,i,l;this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let c of this._renderLayers)c.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,(n=this._rectangleRenderer.value)==null||n.setDimensions(this.dimensions),(s=this._rectangleRenderer.value)==null||s.handleResize(),(i=this._glyphRenderer.value)==null||i.setDimensions(this.dimensions),(l=this._glyphRenderer.value)==null||l.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){var t;for(let e of this._renderLayers)e.handleBlur(this._terminal);(t=this._cursorBlinkStateManager.value)==null||t.pause(),this._requestRedrawViewport()}handleFocus(){var t;for(let e of this._renderLayers)e.handleFocus(this._terminal);(t=this._cursorBlinkStateManager.value)==null||t.resume(),this._requestRedrawViewport()}handleSelectionChanged(t,e,n){for(let s of this._renderLayers)s.handleSelectionChanged(this._terminal,t,e,n);this._model.selection.update(this._core,t,e,n),this._requestRedrawViewport()}handleCursorMove(){var t;for(let e of this._renderLayers)e.handleCursorMove(this._terminal);(t=this._cursorBlinkStateManager.value)==null||t.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new QM(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new WM(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){var e;if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let t=jk(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==t&&(this._onChangeTextureAtlas.fire(t.pages[0].canvas),this._charAtlasDisposable.value=dk(Er.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Er.forward(t.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=t,this._charAtlas.warmUp(),(e=this._glyphRenderer.value)==null||e.setAtlas(this._charAtlas)}_clearModel(t){var e;this._model.clear(),t&&((e=this._glyphRenderer.value)==null||e.clear())}clearTextureAtlas(){var t;(t=this._charAtlas)==null||t.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){var t;this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);(t=this._cursorBlinkStateManager.value)==null||t.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(t,e){var n;if(!this._isAttached)if((n=this._core.screenElement)!=null&&n.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let s of this._renderLayers)s.handleGridChanged(this._terminal,t,e);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(t,e),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new OM(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(t,e){let n=this._core,s=this._workCell,i,l,c,u,h,p,v=0,_=!0,g,b,S,j,C,N,E,O,x;t=N0(t,n.rows-1,0),e=N0(e,n.rows-1,0);let W=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??"block",$=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,J=$-n.buffer.ydisp,q=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),V=-1,ie=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let K=!1;for(l=t;l<=e;l++)for(c=l+n.buffer.ydisp,u=n.buffer.lines.get(c),this._model.lineLengths[l]=0,S=$===c,v=0,h=this._characterJoinerService.getJoinedCharacters(c),O=0;O<n.cols;O++){if(i=this._cellColorResolver.result.bg,u.loadCell(O,s),O===0&&(i=this._cellColorResolver.result.bg),p=!1,_=O>=v,g=O,h.length>0&&O===h[0][0]&&_){b=h.shift();let B=this._model.selection.isCellSelected(this._terminal,b[0],c);for(E=b[0]+1;E<b[1];E++)_&&(_=B===this._model.selection.isCellSelected(this._terminal,E,c));_&&(_=!S||q<b[0]||q>=b[1]),_?(p=!0,s=new vT(s,u.translateToString(!0,b[0],b[1]),b[1]-b[0]),g=b[1]-1):v=b[1]}if(j=s.getChars(),C=s.getCode(),E=(l*n.cols+O)*Hd,this._cellColorResolver.resolve(s,O,c,this.dimensions.device.cell.width),ie&&c===$&&(O===q&&(this._model.cursor={x:q,y:J,width:s.getWidth(),style:this._coreBrowserService.isFocused?W:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},V=q+s.getWidth()-1),O>=q&&O<=V&&(this._coreBrowserService.isFocused&&W==="block"||this._coreBrowserService.isFocused===!1&&n.options.cursorInactiveStyle==="block")&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),C!==0&&(this._model.lineLengths[l]=O+1),!(this._model.cells[E]===C&&this._model.cells[E+Ed]===this._cellColorResolver.result.bg&&this._model.cells[E+Nd]===this._cellColorResolver.result.fg&&this._model.cells[E+Cp]===this._cellColorResolver.result.ext)&&(K=!0,j.length>1&&(C|=VM),this._model.cells[E]=C,this._model.cells[E+Ed]=this._cellColorResolver.result.bg,this._model.cells[E+Nd]=this._cellColorResolver.result.fg,this._model.cells[E+Cp]=this._cellColorResolver.result.ext,N=s.getWidth(),this._glyphRenderer.value.updateCell(O,l,C,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,j,N,i),p)){for(s=this._workCell,O++;O<=g;O++)x=(l*n.cols+O)*Hd,this._glyphRenderer.value.updateCell(O,l,0,0,0,0,eM,0,0),this._model.cells[x]=0,this._model.cells[x+Ed]=this._cellColorResolver.result.bg,this._model.cells[x+Nd]=this._cellColorResolver.result.fg,this._model.cells[x+Cp]=this._cellColorResolver.result.ext;O--}}K&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(t,e){this._canvas.width===t&&this._canvas.height===e||(this._canvas.width=t,this._canvas.height=e,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let t=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:t,end:t})}},vT=class extends za{constructor(t,e,n){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=e,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function N0(t,e,n=0){return Math.max(Math.min(t,e),n)}var j0="di$target",L0="di$dependencies",Rp=new Map;function sr(t){if(Rp.has(t))return Rp.get(t);let e=function(n,s,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");_T(e,n,i)};return e._id=t,Rp.set(t,e),e}function _T(t,e,n){e[j0]===e?e[L0].push({id:t,index:n}):(e[L0]=[{id:t,index:n}],e[j0]=e)}sr("BufferService");sr("CoreMouseService");sr("CoreService");sr("CharsetService");sr("InstantiationService");sr("LogService");var yT=sr("OptionsService");sr("OscLinkService");sr("UnicodeService");sr("DecorationService");var wT={trace:0,debug:1,info:2,warn:3,error:4,off:5},bT="xterm.js: ",R0=class extends Pi{constructor(t){super(),this._optionsService=t,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=wT[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let e=0;e<t.length;e++)typeof t[e]=="function"&&(t[e]=t[e]())}_log(t,e,n){this._evalLazyOptionalParams(n),t.call(console,(this._optionsService.options.logger?"":bT)+e,...n)}trace(t,...e){var n;this._logLevel<=0&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.trace.bind(this._optionsService.options.logger))??console.log,t,e)}debug(t,...e){var n;this._logLevel<=1&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.debug.bind(this._optionsService.options.logger))??console.log,t,e)}info(t,...e){var n;this._logLevel<=2&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.info.bind(this._optionsService.options.logger))??console.info,t,e)}warn(t,...e){var n;this._logLevel<=3&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.warn.bind(this._optionsService.options.logger))??console.warn,t,e)}error(t,...e){var n;this._logLevel<=4&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.error.bind(this._optionsService.options.logger))??console.error,t,e)}};R0=HA([UA(0,yT)],R0);var ST=class extends Pi{constructor(t){if(pk&&ZA()<16){let e={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",e))throw new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=t,this._onChangeTextureAtlas=this._register(new gn),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new gn),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new gn),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new gn),this.onContextLoss=this._onContextLoss.event}activate(t){let e=t._core;if(!t.element){this._register(e.onWillOpen(()=>this.activate(t)));return}this._terminal=t;let n=e.coreService,s=e.optionsService,i=e,l=i._renderService,c=i._characterJoinerService,u=i._charSizeService,h=i._coreBrowserService,p=i._decorationService;i._logService;let v=i._themeService;this._renderer=this._register(new gT(t,c,u,h,n,p,s,v,this._preserveDrawingBuffer)),this._register(Er.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Er.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Er.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Er.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),l.setRenderer(this._renderer),this._register(Rs(()=>{if(this._terminal._core._store._isDisposed)return;let _=this._terminal._core._renderService;_.setRenderer(this._terminal._core._createRenderer()),_.handleResize(t.cols,t.rows)}))}get textureAtlas(){var t;return(t=this._renderer)==null?void 0:t.textureAtlas}clearTextureAtlas(){var t;(t=this._renderer)==null||t.clearTextureAtlas()}};const Ik="nc-terminal-renderer",fo="webgl",po="dom";function Dk(t){if(t!==void 0)return t;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Ac(t){const e=Dk(t);try{return e&&e.getItem(Ik)===po?po:fo}catch{return fo}}function Ok(t,e){const n=t===po?po:fo,s=Dk(e);try{s&&s.setItem(Ik,n)}catch{}return n}function xT(t){return t===po?fo:po}function kT(t,{preference:e,createAddon:n,onFallback:s}={}){const i=e||Ac(),l={kind:po,dispose:()=>{}};if(i!==fo||!t||typeof t.loadAddon!="function"||typeof n!="function")return l;let c;try{if(c=n(),!c)return l;t.loadAddon(c)}catch{try{c&&c.dispose()}catch{}return s&&s("unavailable"),l}let u=!1;const h=()=>{if(!u){u=!0;try{c.dispose()}catch{}}};return typeof c.onContextLoss=="function"&&c.onContextLoss(()=>{h(),s&&s("context-loss")}),{kind:fo,dispose:h}}const CT=Object.freeze({retryBaseMs:250,retryMaxMs:5e3,pingMs:5e3,deadMs:1e4,queuedInputBytes:4096,overlayDelayMs:1e3}),ET=(t,e)=>{const n=Number(t);return Number.isFinite(n)&&n>0?n:e};function Bk(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},n={};for(const[s,i]of Object.entries(CT))n[s]=ET(e[s],i);return n}let wg=Bk(null);function NT(t){return wg=Bk(t),{...wg}}function $k(){return{...wg}}function jT(t,e,n=null,s=null){if(!t)return"/ws";let l=`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(e||"")}`;return n&&(l+=`&attachId=${encodeURIComponent(n)}`,s&&(l+=`&attachSession=${encodeURIComponent(s)}`)),l}function LT(t,e,n=null){const s=n===null?typeof sessionStorage<"u"?sessionStorage:null:n;if(!s)return null;const i=`nc-attach:${e||"local"}:${String(t||"")}`;try{const l=s.getItem(i);if(typeof l=="string"&&/^[0-9a-f]{32}$/.test(l))return l;const c=new Uint8Array(16),u=globalThis.crypto;if(!u||typeof u.getRandomValues!="function")return null;u.getRandomValues(c);const h=Array.from(c).map(p=>p.toString(16).padStart(2,"0")).join("");return s.setItem(i,h),h}catch{return null}}function RT({session:t,node:e,token:n,cols:s,rows:i,readonly:l=!1,takeSize:c,focused:u,onData:h,onExit:p,onFiles:v,onSnapshot:_,onLink:g,retryBaseMs:b,retryMaxMs:S,retryStableMs:j=5e3,onRetryScheduled:C,pingMs:N,deadMs:E,queuedInputBytes:O,onQueued:x}){const W=$k(),$=b===void 0?W.retryBaseMs:b,J=S===void 0?W.retryMaxMs:S,q=N===void 0?W.pingMs:N,V=E===void 0?W.deadMs:E,ie=O===void 0?W.queuedInputBytes:O,K=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!K)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const B=location.protocol==="https:"?"wss":"ws",I=LT(t,e),D=`${B}://${location.host}${jT(e,n,I,t)}`;let T=null,z=!1,R=!1,M=null,L=null,H=0,A=null,U=!1,Q=null,ae=0,re=null;const je=Math.max(1,Number(ie)||4096);let te=[],ne=0;const me=()=>{if(typeof x=="function")try{x(ne)}catch{}},we=()=>{if(!T||T.readyState!==1||!te.length)return;const Z=te;te=[],ne=0;for(const ge of Z)try{T.send(ge)}catch{}me()},Fe=()=>{Q&&(clearInterval(Q),Q=null)},Ae=Z=>{Fe(),ae=Date.now();const ge=Math.max(1,Number(q)||5e3),Y=Math.max(1,Number(V)||1e4);Q=setInterval(()=>{if(T!==Z||z||R){Fe();return}if(Date.now()-ae>Y){Fe();try{Z.close(4e3,"liveness timeout")}catch{}return}if(Z.readyState===1)try{Z.send(JSON.stringify({type:"ping",t:Date.now()}))}catch{}},ge),typeof Q.unref=="function"&&Q.unref()};let He=u;const X=()=>{if(z||R||M)return;const Z=Math.min(J,Math.max(0,$)*2**Math.min(H++,5));typeof C=="function"&&C(Z),M=setTimeout(()=>{M=null,ce()},Z)},ce=()=>{if(z||R)return;const Z=new WebSocket(D);T=Z,Z.binaryType="arraybuffer",Z.onopen=()=>{if(T!==Z||z)return;L&&clearTimeout(L);const ge=Number(j),Y=Number.isFinite(ge)?Math.max(0,ge):5e3;L=setTimeout(()=>{L=null,T===Z&&Z.readyState===1&&(H=0)},Y),typeof L.unref=="function"&&L.unref();const he={type:"attach",session:t,token:n,cols:s,rows:i,readonly:l};A&&(he.reconnectToken=A),c!==void 0&&(he.takeSize=c),Z.send(JSON.stringify(he)),He!==void 0&&Z.send(JSON.stringify({type:"focus",on:!!He})),U&&Z.send(JSON.stringify(re===null?{type:"resync"}:{type:"resume",seq:re})),we(),Ae(Z)},Z.onmessage=ge=>{if(!(T!==Z||z))if(ae=Date.now(),typeof ge.data=="string"){let Y;try{Y=JSON.parse(ge.data)}catch{return}if(Y.type==="attached"&&typeof Y.reconnectToken=="string"&&Y.reconnectToken&&(A=Y.reconnectToken),Y.type==="exit"&&(R=!0,p&&p(Y.code)),Y.type==="files"&&v&&v(Y),Y.type==="snapshot"&&_&&_(typeof Y.data=="string"?Y.data:""),Y.type==="link"&&g&&g(Y.state==="live"?"live":"reconnecting"),Y.type==="resync-needed")try{Z.send(JSON.stringify({type:"resync"}))}catch{}}else{let Y=new Uint8Array(ge.data);try{ge.data&&ge.data.byteLength>=4&&(re=new DataView(ge.data).getUint32(0),Y=new Uint8Array(ge.data,4))}catch{}h&&h(Y)}},Z.onerror=()=>{if(T===Z)try{Z.close()}catch{}},Z.onclose=ge=>{Fe(),!(T!==Z||z||R)&&(L&&(clearTimeout(L),L=null),![4401,4403,4404].includes(ge==null?void 0:ge.code)&&(U=!0,g&&g("reconnecting"),X()))}};return ce(),{sendInput:Z=>{const ge=typeof Z=="string"?new TextEncoder().encode(Z):Z;if(T&&T.readyState===1)try{return T.send(ge),!0}catch{try{T.close()}catch{}}return ne+ge.length>je?!1:(te.push(ge),ne+=ge.length,me(),!0)},isReady:()=>!!T&&T.readyState===1,resize:(Z,ge)=>{s=Z,i=ge,(T==null?void 0:T.readyState)===1&&T.send(JSON.stringify({type:"resize",cols:Z,rows:ge}))},action:Z=>{(T==null?void 0:T.readyState)===1&&T.send(JSON.stringify({type:"action",name:Z}))},focus:Z=>{He=Z,(T==null?void 0:T.readyState)===1&&T.send(JSON.stringify({type:"focus",on:!!Z}))},close:()=>{if(z=!0,Fe(),M&&clearTimeout(M),L&&clearTimeout(L),M=null,L=null,T)try{T.close()}catch{}},get raw(){return T}}}const zk=1e3;function AT(t,e,n=zk){if(t==null)return!1;const s=Number(e)-Number(t);return Number.isFinite(s)?s>=Math.max(0,Number(n)||0):!1}function MT(t={},e={}){const n=Number(t.viewportY)||0,s=Number(t.baseY)||0,i=Math.max(0,Number(e.baseY)||0);return n>=s?{atBottom:!0,line:null}:{atBottom:!1,line:Math.min(n,i)}}function TT(t){return t?`\r
152
+ \x1B[2m── riconnesso ──\x1B[0m\r
153
+ `:""}function PT(t,e){var s;if(!t||typeof((s=t.parser)==null?void 0:s.registerCsiHandler)!="function")return;const n=i=>l=>{const c=l&&l[0],u=Array.isArray(c)?c[0]:c,h=Number.isFinite(u)&&u>0?u:0;if(typeof e=="function")try{e(`\x1B[${i}${h};0$y`)}catch{}return!0};t.parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},n("?")),t.parser.registerCsiHandler({intermediates:"$",final:"p"},n(""))}function A0(t,e){try{return t.write(e),!0}catch(n){return console.error("[terminal] output scartato: eccezione del parser",n),!1}}function IT(t,{ctrl:e=!1,alt:n=!1}={}){if(!t||!e&&!n)return t;const s=t.charCodeAt(0);let i=s;return e&&(s>=97&&s<=122?i=s-96:s>=64&&s<=95?i=s-64:s===32&&(i=0)),(n?"\x1B":"")+String.fromCharCode(i)+t.slice(1)}async function Mc(t){const e=String(t||"");if(!e)return!1;try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,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 DT="\r";function OT(t){const e=String(t||"");let n=e.length;for(;n>0;){const s=e.charCodeAt(n-1);if(s===10||s===13)n-=1;else break}return e.slice(0,n)}function BT({isReady:t,paste:e,send:n}){return s=>{if(!s||!t())return!1;try{return e(s)===!1||!t()?!1:n(DT)!==!1}catch{return!1}}}function $T(t){return!t||typeof t!="object"?!1:!!t.shiftKey}function zT(t){return!t||typeof t!="object"||String(t.key||"").toLowerCase()!=="c"?!1:!!(t.metaKey||t.ctrlKey&&t.shiftKey)}function FT(t){return/mac|iphone|ipad/i.test(String(t||""))?"⌘C":"Ctrl+Shift+C"}const HT=450,M0=8;function T0(t,e,n,s){return Math.abs(Number(n)-Number(t))>M0||Math.abs(Number(s)-Number(e))>M0}function UT({range:t,cell:e,cols:n}){const s=Number(n),i=Number(t.start.row)*s+Number(t.start.col),l=Number(t.end.row)*s+Number(t.end.col),c=Number(e.row)*s+Number(e.col),u={start:{row:t.start.row,col:t.start.col},end:{row:t.end.row,col:t.end.col},moved:null};if(c<i)u.start={row:Number(e.row),col:Number(e.col)},u.moved="start";else if(c>l)u.end={row:Number(e.row),col:Number(e.col)},u.moved="end";else{if(c===i||c===l)return u;c-i<=l-c?(u.start={row:Number(e.row),col:Number(e.col)},u.moved="start"):(u.end={row:Number(e.row),col:Number(e.col)},u.moved="end")}return u}function WT(t){const e=t!=="mouse";return{handles:e,magnifier:e}}function qT(t,e){if(!t||!t.start||!t.end)return null;const n=Number(e);if(!Number.isFinite(n)||n<=0)return null;const s=Number(t.start.y)*n+Number(t.start.x),i=Number(t.end.y)*n+Number(t.end.x),l=Math.min(s,i),c=Math.max(l,Math.max(s,i)-1);return{start:{row:Math.floor(l/n),col:l%n},end:{row:Math.floor(c/n),col:c%n}}}function P0(t,e,n){const s=Number(t.row)*Number(n)+Number(t.col),i=Number(e.row)*Number(n)+Number(e.col);return s<=i?{start:{row:t.row,col:t.col},end:{row:e.row,col:e.col}}:{start:{row:e.row,col:e.col},end:{row:t.row,col:t.col}}}function KT({moving:t,fixed:e,which:n,cols:s,maxRow:i}){const l=Number(s);let c=Math.max(0,Math.min(Number(i),Number(t.row))),u=Math.max(0,Math.min(l-1,Number(t.col)));const h=c*l+u,p=Number(e.row)*l+Number(e.col);return n==="start"&&h>p&&(c=Number(e.row),u=Number(e.col)),n==="end"&&h<p&&(c=Number(e.row),u=Number(e.col)),{row:c,col:u}}function Ma({line:t,col:e,side:n,cols:s}){const i=Math.max(0,Math.min(Number(s)-1,Number(e))),l=t&&typeof t.getCell=="function"?t.getCell(i):null;return(l&&typeof l.getWidth=="function"?Number(l.getWidth()):1)!==0?i:n==="end"?Math.min(Number(s)-1,i+1):Math.max(0,i-1)}function I0({line:t,col:e,cols:n}){const s=Math.max(0,Math.min(Number(n)-1,Number(e))),i=u=>{const h=t&&typeof t.getCell=="function"?t.getCell(u):null;return h&&typeof h.getChars=="function"?h.getChars():""};if(i(s)===""||i(s)===" ")return{start:s,end:s};let l=s;for(;l>0;){const u=i(l-1);if(u===""||u===" ")break;l-=1}let c=s;for(;c<Number(n)-1;){const u=i(c+1);if(u===""||u===" ")break;c+=1}return{start:l,end:c}}function VT({startLeft:t,endLeft:e,targetWidth:n=46}){return Math.abs(Number(e)-Number(t))<Number(n)}function YT({anchorLeft:t,anchorTop:e,hostWidth:n,hostHeight:s,bubbleWidth:i,bubbleHeight:l,pinHeight:c=30,margin:u=4,gap:h=8}){const p=Number(i),v=Number(l),_=Number(u),g=Math.max(_,Number(n)-_-p),b=Math.max(_,Math.min(g,Number(t)-Math.round(p/2)));let S=Number(e)-Number(h)-v,j=!1;S<_&&(S=Number(e)+Number(c)+Number(h),j=!0);const C=Math.max(_,Number(s)-_-v);return S>C&&(S=C),{left:b,top:S,flipped:j}}function D0(t,e){const n=Number(e),s=Number(t.start.row)*n+Number(t.start.col),i=Number(t.end.row)*n+Number(t.end.col);return{col:t.start.col,row:t.start.row,length:i-s+1}}const O0=28,GT=50;function XT({range:t,viewportY:e,rows:n,cols:s=0,cellWidth:i,cellHeight:l,screenLeft:c=0,screenTop:u=0}){const h={},p=Number(s)*Number(i);for(const v of["start","end"]){const _=t[v],g=Number(_.row)-Number(e),b=g>=0&&g<Number(n),S=(v==="start"?Number(_.col):Number(_.col)+1)*Number(i),j=v==="start"?S-O0<0:S+O0>p;h[v]={left:Number(c)+S,top:Number(u)+(g+1)*Number(l),visible:b,flip:j}}return h}function JT({visibleRow:t,rows:e}){const n=Number(t);return n<=0?-1:n>=Number(e)-1?1:0}function QT({range:t,side:e,line:n,cols:s}){if(!t||!t.start||!t.end||!n)return null;const i=Math.max(0,Number(s)-1),l=e==="end"?t.end:t.start,c=Number(l.row);let u,h;Number(t.start.row)===Number(t.end.row)?(u=Number(t.start.col),h=Number(t.end.col)):c===Number(t.start.row)?(u=Number(t.start.col),h=i):c===Number(t.end.row)?(u=0,h=Number(t.end.col)):(u=0,h=i),u=Math.max(0,Math.min(i,u)),h=Math.max(u,Math.min(i,h));const p=n.translateToString(!0,0,u);let v=n.translateToString(!1,u,h+1);v.replace(/\s+$/,"")===""&&(v="");const _=n.translateToString(!0,Math.min(i+1,h+1),i+1);return{row:c,before:p,sel:v,after:_}}const Rv="(min-width:1024px) and (pointer:fine)";function ZT(){try{return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(Rv).matches}catch{return!1}}function Av(){const[t,e]=y.useState(ZT);return y.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia(Rv),s=i=>e(i.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),t}const eP=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function Ap(t){return t?t.files&&t.files.length>0||Array.from(t.items||[]).some(e=>e&&e.kind==="file")?!0:Array.from(t.types||[]).includes("Files"):!1}function B0(t){if(!t)return[];const e=Array.from(t.files||[]).filter(Boolean);return e.length?e:Array.from(t.items||[]).filter(n=>n&&n.kind==="file"&&typeof n.getAsFile=="function").map(n=>n.getAsFile()).filter(Boolean)}function tP(t,e=0,n=Date.now()){const s=String((t==null?void 0:t.name)||"").trim();if(s)return s;const i=eP.get(String((t==null?void 0:t.type)||"").toLowerCase())||"bin";return`clipboard-${n}-${e+1}.${i}`}async function Ud({files:t,token:e,session:n,node:s="",paste:i=!0,fetchImpl:l=qn,onProgress:c=()=>{},now:u=Date.now()}={}){const h=Array.from(t||[]).filter(Boolean),p=[],v=[];if(!n||!h.length)return{paths:p,errors:v};const _=yn(s?String(s).split("/"):[]);for(let g=0;g<h.length;g+=1){const b=h[g],S=tP(b,g,u);c({index:g,total:h.length,name:S,state:"uploading"});try{const j=new FormData;j.append("session",n),j.append("paste",i?"true":"false"),j.append("file",b,S);const C=await l(`${_}/files/upload`,e,{method:"POST",body:j}),N=await C.json().catch(()=>({}));if(!C.ok||N.error)throw new Error(N.error||`HTTP ${C.status}`);p.push(N.path),c({index:g,total:h.length,name:S,state:"done",path:N.path})}catch(j){const C=String((j==null?void 0:j.message)||j);v.push({name:S,message:C}),c({index:g,total:h.length,name:S,state:"error",error:C})}}return{paths:p,errors:v}}const nP=420,sP=32;function iP(t){if(!t||typeof t!="object")return!1;const e=String(t.tagName||"").toLowerCase();return e==="textarea"||e==="input"||t.isContentEditable===!0}function bg({documentRef:t,navigatorRef:e}={}){const n=t||(typeof document<"u"?document:null),s=e||(typeof navigator<"u"?navigator:null);let i=!1;try{s!=null&&s.virtualKeyboard&&typeof s.virtualKeyboard.hide=="function"&&(s.virtualKeyboard.hide(),i=!0)}catch{}const l=n&&n.activeElement;let c=!1;if(iP(l)&&typeof l.blur=="function")try{l.blur(),c=!0}catch{}return{blurred:c,apiRequested:i}}function Fk(t,e,n=!1){const s=t&&t.textarea;if(!s)return null;const l=e==="single-tap"||e==="double-tap"&&n?"text":"none";return s.inputMode=l,s.setAttribute("inputmode",l),l}function rP(t,e){if(!t||!t.textarea)return!1;Fk(t,"double-tap",!0);try{t.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 oP(t,e,n){return t==="never"?{open:!1,next:null}:t==="single-tap"?{open:!0,next:null}:!n||!Number.isFinite(n.at)||!Number.isFinite(n.x)||!Number.isFinite(n.y)?{open:!1,next:null}:e&&n.at>=e.at&&n.at-e.at<=nP&&Math.hypot(n.x-e.x,n.y-e.y)<=sP?{open:!0,next:null}:{open:!1,next:n}}const aP=24,$0=80,Hk=8,lP="\x1B[5~",cP="\x1B[6~",uP=64,dP=65;function hP(t,e,n){const s=t==="up"?uP:dP,i=l=>Math.max(1,Math.min(9999,Number.isFinite(l)?Math.round(l):1));return`\x1B[<${s};${i(e)};${i(n)}M`}function fP({alternateScreen:t=!1,readonly:e=!1,mouseTracking:n=!1}={}){return e?"scroll":n?"mouse":t?"page":"scroll"}function pP(t,e){return t==="page"?Number.isFinite(e)&&e>0?Math.max($0,e):$0:Number.isFinite(e)&&e>0?e:aP}function mP({mode:t="scroll",accumulated:e=0,threshold:n=0}={}){const s=pP(t,n);if(!Number.isFinite(e))return{mode:t,up:0,down:0,remainder:0};const i=Math.abs(e);if(i<s)return{mode:t,up:0,down:0,remainder:e};const l=Math.floor(i/s),c=Math.min(l,Hk),u=(e>=0?1:-1)*(i%s);return{mode:t,up:e>0?c:0,down:e<0?c:0,remainder:u}}function gP(t,e=null){const n=[],s=e&&Number.isFinite(e.col)?e.col:1,i=e&&Number.isFinite(e.row)?e.row:1,l=u=>Math.min(Hk,Number.isFinite(u)?Math.max(0,Math.floor(u)):0),c=u=>t.mode==="mouse"?{kind:"input",seq:hP(u,s,i)}:t.mode==="page"?{kind:"input",seq:u==="up"?lP:cP}:{kind:"action",name:u==="up"?"scroll-up":"scroll-down"};for(let u=0;u<l(t.up);u+=1)n.push(c("up"));for(let u=0;u<l(t.down);u+=1)n.push(c("down"));return n}function wc({session:t,node:e,token:n,readonly:s,takeSize:i,focused:l,sendRef:c,composerRef:u,actionRef:h,ctrlRef:p,setCtrlArmed:v,altRef:_,setAltArmed:g,keyboardRef:b,onFiles:S,fontSize:j=13,selectionMode:C=!1,onSelectionModeChange:N,keyboardGesture:E="double-tap",onRendererChange:O}){const x=y.useRef(null),W=y.useRef(null),$=y.useRef(null),J=y.useRef(j);J.current=j;const q=y.useRef(l);q.current=l;const V=y.useRef(C);V.current=C;const ie=y.useRef(E);ie.current=E;const[K,B]=y.useState(""),[I,D]=y.useState(""),[T,z]=y.useState(null),[R,M]=y.useState(null),[L,H]=y.useState(!1),[A,U]=y.useState(0),Q=y.useRef(null),ae=y.useRef(null),[re,je]=y.useState(!1),[te,ne]=y.useState(null),me=y.useRef(null),[we,Fe]=y.useState(null),[Ae,He]=y.useState(0),[X,ce]=y.useState(null),[Z,ge]=y.useState("start"),[Y,he]=y.useState(null),[Ne,Ce]=y.useState(!1),[Ve,Ye]=y.useState(null),[ht,ze]=y.useState(null),ve=y.useRef(null),Oe=y.useRef(null),[et,Ue]=y.useState(!1),st=async()=>{var gt,Lt,Nt,kt;const oe=((Lt=(gt=W.current)==null?void 0:gt.term)==null?void 0:Lt.getSelection())||K;if(!oe){D(f("copy-empty")),setTimeout(()=>D(""),1500);return}const Be=await Mc(oe);D(f(Be?"copied":"copy-manual")),Be&&((kt=(Nt=W.current)==null?void 0:Nt.term)==null||kt.clearSelection(),B(""),je(!1),N==null||N(!1)),setTimeout(()=>D(""),1800)},ot=y.useRef(st);ot.current=st;const ee=y.useRef({startHandleDrag:()=>{}}),P=y.useRef(null);P.current=we,y.useEffect(()=>{const oe=x.current;oe&&(oe.dataset.selectionOrigin=ht||"")},[ht]),y.useEffect(()=>{const oe=W.current;oe&&oe.sock&&oe.sock.focus&&oe.sock.focus(!!l)},[l]),y.useEffect(()=>{const oe=W.current;oe&&(oe.term.options.fontSize=j,oe.fit.fit(),oe.sock.resize(oe.term.cols,oe.term.rows))},[j]),y.useEffect(()=>{var oe,Be;(Be=(oe=W.current)==null?void 0:oe.setKeyboardGesture)==null||Be.call(oe,E)},[E]),y.useEffect(()=>{var Oi,lr,cr,nu,ia,ra,mo,oa,ml,xi,aa;const oe=new MA({cursorBlink:!0,fontSize:J.current,scrollback:1e3,allowProposedApi:!0,theme:{background:"#0a0e0a"}}),Be=new IA;oe.loadAddon(Be),oe.open(x.current),Be.fit(),FA(oe);const gt=kT(oe,{preference:Ac(),createAddon:()=>new ST,onFallback:()=>{O&&O("dom")}});$.current=gt,O&&O(gt.kind);let Lt=!1,Nt=!1;const kt=ye=>Xe=>{for(const nt of Xe){const pt=Array.isArray(nt)?nt[0]:nt;pt===1006&&(Lt=ye),pt===1016&&(Nt=ye)}return!1};(lr=(Oi=oe.parser)==null?void 0:Oi.registerCsiHandler)==null||lr.call(Oi,{prefix:"?",final:"h"},kt(!0)),(nu=(cr=oe.parser)==null?void 0:cr.registerCsiHandler)==null||nu.call(cr,{prefix:"?",final:"l"},kt(!1)),(ra=(ia=oe.parser)==null?void 0:ia.registerEscHandler)==null||ra.call(ia,{final:"c"},()=>(Lt=!1,Nt=!1,!1));let Kt=null;PT(oe,s?null:ye=>Kt&&Kt(ye));const ft=()=>{const ye=Lt&&!Nt&&(oe.modes&&oe.modes.mouseTrackingMode||"none")!=="none",Xe=x.current;return Xe&&(Xe.dataset.mouseTracking=ye?"on":"off"),ye},Vt=new TextDecoder;let It=ie.current==="single-tap",Xt=null;const Dt=()=>{It=ie.current==="single-tap",Fk(oe,ie.current,It)},Cn=ye=>{ie.current=ye,Xt=null,Dt()},nn=()=>ie.current==="never"?!1:(It=!0,rP(oe));b&&(b.current=nn),Dt();const on=oe.textarea,tn=()=>{ie.current==="double-tap"&&Dt()};on==null||on.addEventListener("blur",tn);let un=!1,Ht=0;const sn=()=>{un=!0,Ht=Date.now()+2e3},En=()=>{un=!1};(mo=x.current)==null||mo.addEventListener("paste",sn,!0),(oa=x.current)==null||oa.addEventListener("keydown",En,!0);let Qt;try{Qt=RT({session:t,node:e,token:n,readonly:s,takeSize:i,focused:q.current,onFiles:S,cols:oe.cols,rows:oe.rows,onData:ye=>A0(oe,Vt.decode(ye)),onExit:()=>A0(oe,`\r
154
+ \x1B[33m[sessione finita]\x1B[0m\r
155
+ `),onSnapshot:ye=>{try{const Xe=oe.buffer&&oe.buffer.active,nt=MT({viewportY:Xe?Xe.viewportY:0,baseY:Xe?Xe.baseY:0},{baseY:Xe?Xe.baseY:0});oe.reset(),oe.write(ye),!nt.atBottom&&nt.line!==null&&typeof oe.scrollToLine=="function"&&oe.scrollToLine(nt.line)}catch{}},onQueued:ye=>U(ye),onLink:ye=>{if(ae.current&&(clearTimeout(ae.current),ae.current=null),ye==="live"){const Xe=Q.current!==null&&AT(Q.current,Date.now());if(Q.current=null,H(!1),Xe)try{oe.write(TT(!0))}catch{}return}Q.current===null&&(Q.current=Date.now()),ae.current=setTimeout(()=>{ae.current=null,H(!0)},$k().overlayDelayMs||zk)}}),Kt=ye=>Qt.sendInput(ye)}catch(ye){return oe.write(`\r
156
+ \x1B[31m${ye.message}\x1B[0m\r
157
+ `),b&&(b.current=null),on==null||on.removeEventListener("blur",tn),(ml=x.current)==null||ml.removeEventListener("paste",sn,!0),(xi=x.current)==null||xi.removeEventListener("keydown",En,!0),()=>{var Xe,nt;try{(nt=(Xe=$.current)==null?void 0:Xe.dispose)==null||nt.call(Xe)}catch{}$.current=null,oe.dispose()}}W.current={term:oe,fit:Be,sock:Qt,setKeyboardGesture:Cn};let an=null;const $s=oe.onData(ye=>{if(s){an&&(an.ok=!1);return}const Xe=un&&Date.now()<Ht;En(),!an&&!Xe&&ye.length>=1&&(p&&p.current||_&&_.current)&&(ye=IT(ye,{ctrl:!!(p&&p.current),alt:!!(_&&_.current)}),p&&(p.current=!1),_&&(_.current=!1),v&&v(!1),g&&g(!1));const nt=Qt.sendInput(ye);an&&(an.seen=!0,an.ok=an.ok&&nt)});c&&(c.current=ye=>Qt.sendInput(ye)),h&&(h.current=ye=>Qt.action(ye)),u&&(u.current=BT({isReady:()=>!s&&Qt.isReady(),paste:ye=>{const Xe={seen:!1,ok:!0};an=Xe;try{oe.paste(ye)}catch{Xe.ok=!1}finally{an=null}return Xe.seen&&Xe.ok},send:ye=>Qt.sendInput(ye)}));const Vn=ye=>{ve.current=ye,ze(ye)};let Ut=null;const zs=oe.onSelectionChange(()=>{const ye=oe.getSelection();ye?(B(ye),je(!1)):je(!0);const Xe=qT(oe.getSelectionPosition(),oe.cols),nt=Xe?P0(Xe.start,Xe.end,oe.cols):null;ne(nt),me.current=nt,nt||Vn(null),!nt&&Ut&&Mr();let pt=null;if(nt&&typeof oe.buffer.active.getLine=="function"){const Rt=[];for(let St=nt.start.row;St<=nt.end.row;St++){const Gt=oe.buffer.active.getLine(St);Rt.push(Gt?Gt.translateToString():"")}pt={startRow:nt.start.row,endRow:nt.end.row,lines:Rt}}Oe.current=pt,Ue(!1)}),ds=oe.onRender(ye=>{var Xe;if((Xe=oe.hasSelection)!=null&&Xe.call(oe)){const nt=Oe.current,pt=ye&&ye.start,Rt=ye&&ye.end;if(nt&&Number.isInteger(pt)&&Number.isInteger(Rt)&&typeof oe.buffer.active.getLine=="function"){const St=Number(oe.buffer.active.viewportY)||0,Gt=Math.max(St+pt,nt.startRow),dn=Math.min(St+Rt,nt.endRow);for(let In=Gt;In<=dn;In++){const Mn=oe.buffer.active.getLine(In);if((Mn?Mn.translateToString():"")!==nt.lines[In-nt.startRow]){Ue(!0);break}}}He(St=>St+1)}}),Yn=oe.onScroll(()=>{var ye;(ye=oe.hasSelection)!=null&&ye.call(oe)&&He(Xe=>Xe+1)});oe.attachCustomKeyEventHandler(ye=>(ye.ctrlKey||ye.metaKey)&&ye.key.toLowerCase()==="c"&&oe.getSelection()?(ye.type==="keydown"&&Mc(oe.getSelection()),!1):!0);const xt=x.current;let ue=!1;const Ie=async ye=>{if(!ye.length||ue)return;if(s){z({error:f("settings-readonly")});return}ue=!0,z({current:0,total:ye.length,name:""});const Xe=await Ud({files:ye,token:n,session:t,node:e,paste:!0,onProgress:({index:nt,total:pt,name:Rt,state:St,error:Gt})=>z({current:nt+1,total:pt,name:Rt,...St==="error"?{error:Gt}:{}})});ue=!1,Xe.errors.length?z({error:Xe.errors.map(nt=>`${nt.name}: ${nt.message}`).join(" · ")}):(z({done:!0,total:Xe.paths.length}),setTimeout(()=>z(null),1600))},Qe=ye=>{const Xe=ye.clipboardData;if(!Ap(Xe))return;const nt=B0(Xe);nt.length&&(ye.preventDefault(),ye.stopPropagation(),Ie(nt))},ct=ye=>{Ap(ye.dataTransfer)&&(ye.preventDefault(),ye.stopPropagation())},At=ye=>{Ap(ye.dataTransfer)&&(ye.preventDefault(),ye.stopPropagation(),Ie(B0(ye.dataTransfer)))};xt.addEventListener("paste",Qe,!0),xt.addEventListener("dragenter",ct,!0),xt.addEventListener("dragover",ct,!0),xt.addEventListener("drop",At,!0);const G=24,fe=(ye,Xe)=>{const pt=(xt.querySelector(".xterm-screen")||xt).getBoundingClientRect(),Rt=Math.floor((ye-pt.left)/Math.max(1,pt.width)*oe.cols)+1,St=Math.floor((Xe-pt.top)/Math.max(1,pt.height)*oe.rows)+1;return{col:Math.max(1,Math.min(oe.cols,Rt)),row:Math.max(1,Math.min(oe.rows,St))}},Te=(ye,Xe={mode:null,remainder:0},nt=null,pt=null)=>{const Rt=x.current,St=Rt?Rt.getBoundingClientRect().height:G,Gt=fP({alternateScreen:oe.buffer.active.type==="alternate",readonly:s,mouseTracking:ft()}),dn=Gt==="mouse"?"mouse":nt||Gt,In=Xe.mode===dn?Xe.remainder+ye:ye,Mn=mP({mode:dn,accumulated:In,threshold:dn==="page"?St:G});for(const xs of gP(Mn,pt))xs.kind==="input"?Qt.sendInput(xs.seq):Qt.action(xs.name);return{mode:dn,remainder:Mn.remainder}};let Ze=null,Pe=null,jt=null,ke=null,Le=!1,lt=!1,Yt={mode:null,remainder:0},De=null,Je=null,Pt=null,be=!1;const Re=750;let Ke=0;const at=()=>{Pt&&clearTimeout(Pt),Pt=null},wt=(ye,Xe)=>{const pt=(xt.querySelector(".xterm-screen")||xt).getBoundingClientRect(),Rt=Math.max(0,Math.min(oe.cols-1,Math.floor((ye-pt.left)/Math.max(1,pt.width)*oe.cols))),St=Math.max(0,Math.min(oe.rows-1,Math.floor((Xe-pt.top)/Math.max(1,pt.height)*oe.rows)));return{col:Rt,row:oe.buffer.active.viewportY+St}},Gn=()=>{const nt=(xt.querySelector(".xterm-screen")||xt).getBoundingClientRect().height/Math.max(1,oe.rows),pt=xt.querySelector(".nc-sel-handle"),Rt=pt?pt.getBoundingClientRect().height:0;return-.3*(Rt>0?Rt:nt)},Fs=(ye,Xe)=>wt(ye.clientX,ye.clientY+Xe),Wt=ye=>{const nt=(xt.querySelector(".xterm-screen")||xt).getBoundingClientRect(),pt=xt.getBoundingClientRect(),Rt=nt.width/Math.max(1,oe.cols),St=nt.height/Math.max(1,oe.rows),Gt=Number(oe.buffer.active.viewportY)||0,dn=Math.max(0,Math.min(oe.rows-1,ye.row-Gt));M({left:`${nt.left-pt.left+ye.col*Rt}px`,top:`${nt.top-pt.top+dn*St}px`,width:`${Rt}px`,height:`${St}px`})},Xn=ye=>{if(Ke=Date.now(),Vn("touch"),at(),be=!1,Le=!1,lt||ye.touches.length!==1){lt=!0,Le=!0,Xt=null,M(null),Ze=null,Pe=null,jt=null,ke=null;return}if(V.current){ye.preventDefault(),ye.stopPropagation();const nt=wt(ye.touches[0].clientX,ye.touches[0].clientY),pt=oe.buffer.active.getLine(nt.row),Rt=Ma({line:pt,col:nt.col,side:"start",cols:oe.cols}),St=I0({line:pt,col:Rt,cols:oe.cols});Je={row:nt.row,col:St.start};const Gt={row:nt.row,col:St.end};oe.clearSelection(),Vn("touch"),Ce(!0),ge("end"),oe.select(St.start,nt.row,St.end-St.start+1),Wt(Gt);return}Ze=ye.touches[0].clientY,Pe=ye.touches[0].clientX,jt=Pe,ke=Ze,Yt={mode:null,remainder:0},De=null;const Xe={x:Pe,y:Ze};Pt=setTimeout(()=>{var dn;Pt=null,be=!0,Le=!0,Xt=null,V.current=!0,N==null||N(!0);const nt=wt(Xe.x,Xe.y),pt=oe.buffer.active.getLine(nt.row),Rt=Ma({line:pt,col:nt.col,side:"start",cols:oe.cols}),St=I0({line:pt,col:Rt,cols:oe.cols});Je={row:nt.row,col:St.start};const Gt={row:nt.row,col:St.end};oe.clearSelection(),Vn("touch"),Ce(!0),ge("end"),oe.select(St.start,nt.row,St.end-St.start+1),Wt(Gt);try{(dn=navigator.vibrate)==null||dn.call(navigator,10)}catch{}Ze=null,Pe=null,De=null,Yt={mode:null,remainder:0}},HT)},Ot=ye=>{if(be&&Je&&ye.touches.length===1){ye.preventDefault(),ye.stopPropagation();const pt=wt(ye.touches[0].clientX,ye.touches[0].clientY),Rt=Je.row*oe.cols+Je.col,St=pt.row*oe.cols+pt.col,Gt=Rt<=St?"end":"start",dn=oe.buffer.active.getLine(pt.row),In=Ma({line:dn,col:pt.col,side:Gt,cols:oe.cols}),Mn={row:pt.row,col:In},xs=Mn.row*oe.cols+Mn.col,ri=Rt<=xs?Je:Mn;ge(Gt),oe.select(ri.col,ri.row,Math.abs(xs-Rt)+1),Wt(Mn);return}if(V.current&&Je&&ye.touches.length===1){ye.preventDefault(),ye.stopPropagation();const pt=wt(ye.touches[0].clientX,ye.touches[0].clientY),Rt=Je.row*oe.cols+Je.col,St=pt.row*oe.cols+pt.col,Gt=Rt<=St?"end":"start",dn=oe.buffer.active.getLine(pt.row),In=Ma({line:dn,col:pt.col,side:Gt,cols:oe.cols}),Mn={row:pt.row,col:In},xs=Mn.row*oe.cols+Mn.col,ri=Rt<=xs?Je:Mn;ge(Gt),oe.select(ri.col,ri.row,Math.abs(xs-Rt)+1),Wt(Mn);return}if(Ze===null||ye.touches.length!==1)return;ye.preventDefault(),ye.stopPropagation();const Xe=ye.touches[0];if(T0(jt,ke,Xe.clientX,Xe.clientY)&&(Le=!0,Xt=null,Pt&&at()),De===null&&(Math.abs(Xe.clientY-Ze)>8||Math.abs(Xe.clientX-Pe)>8)&&(De=Math.abs(Xe.clientY-Ze)>Math.abs(Xe.clientX-Pe)),!De)return;const nt=Xe.clientY-Ze;Ze=Xe.clientY,Yt=Te(nt,Yt,"scroll",fe(Xe.clientX,Xe.clientY))},ws=()=>{at(),Ze=null,Pe=null,jt=null,ke=null,Je=null,be=!1,Le=!1,lt=!1,M(null),Ce(!1),Yt={mode:null,remainder:0},Ke=Date.now()},Di=ye=>{if(lt){Xt=null,at(),(!ye.touches||ye.touches.length===0)&&ws();return}const Xe=ye.changedTouches&&ye.changedTouches[0];if(!Le&&!be&&!V.current&&Xe){const nt={at:Date.now(),x:Xe.clientX,y:Xe.clientY},pt=oP(ie.current,Xt,nt);Xt=pt.next,pt.open&&nn()}ws()},ir=()=>{Xt=null,ws()};let Zt={mode:null,remainder:0};const ll=ye=>{ye.preventDefault(),ye.stopPropagation(),Zt=Te(-ye.deltaY,Zt,"scroll",fe(ye.clientX,ye.clientY))};xt.addEventListener("touchstart",Xn,{passive:!1}),xt.addEventListener("touchmove",Ot,{passive:!1,capture:!0}),xt.addEventListener("touchend",Di,{passive:!0}),xt.addEventListener("touchcancel",ir,{passive:!0});const cl=()=>{typeof window.matchMedia=="function"&&window.matchMedia(Rv).matches||!V.current&&ie.current==="double-tap"&&nn()};xt.addEventListener("dblclick",cl);const ta=ye=>{(V.current||be)&&(ye.preventDefault(),ye.stopPropagation())};xt.addEventListener("contextmenu",ta,!0),xt.addEventListener("wheel",ll,{passive:!1,capture:!0});let Js=null;const ul=ye=>{Date.now()-Ke>=Re&&Vn("mouse"),$T(ye)&&(ye.preventDefault(),ye.stopPropagation(),Js={cell:wt(ye.clientX,ye.clientY),clientX:ye.clientX,clientY:ye.clientY,extendFrom:me.current,dragged:!1})},dl=ye=>{var Gt;if(!Js){(Gt=oe.hasSelection)!=null&&Gt.call(oe)&&ft()&&(ye.preventDefault(),ye.stopPropagation());return}if(ye.preventDefault(),ye.stopPropagation(),!Js.dragged&&!T0(Js.clientX,Js.clientY,ye.clientX,ye.clientY))return;Js.dragged=!0;const Xe=Js.cell,nt=wt(ye.clientX,ye.clientY),pt=Xe.row*oe.cols+Xe.col,Rt=nt.row*oe.cols+nt.col,St=pt<=Rt?Xe:nt;oe.select(St.col,St.row,Math.abs(Rt-pt)+1)},na=ye=>{if(!Js)return;ye.stopPropagation();const{cell:Xe,extendFrom:nt,dragged:pt}=Js;if(Js=null,pt||!nt)return;const Rt=UT({range:nt,cell:Xe,cols:oe.cols});if(!Rt.moved)return;const St=Rt[Rt.moved],Gt=oe.buffer.active.getLine(St.row);St.col=Ma({line:Gt,col:St.col,side:Rt.moved,cols:oe.cols});const dn=D0({start:Rt.start,end:Rt.end},oe.cols);oe.select(dn.col,dn.row,dn.length)};xt.addEventListener("mousedown",ul,!0),xt.addEventListener("mousemove",dl,!0),xt.addEventListener("mouseup",na,!0);let rr=null,bs={x:0,y:0,type:"touch"};const Qs=()=>{rr&&(clearInterval(rr),rr=null)},bi=(ye,Xe,nt)=>{if(!Ut||!Ut.fixed)return;const pt=Ut.fixed,Rt=nt==="mouse"?wt(ye,Xe):Fs({clientX:ye,clientY:Xe},Gn()),St=oe.buffer.active.getLine(Rt.row),Gt={row:Rt.row,col:Ma({line:St,col:Rt.col,side:Ut.which,cols:oe.cols})},dn=Math.max(0,Number(oe.buffer.active.baseY||0)+oe.rows-1),In=KT({moving:Gt,fixed:pt,which:Ut.which,cols:oe.cols,maxRow:dn}),Mn=D0(P0(In,pt,oe.cols),oe.cols);oe.select(Mn.col,Mn.row,Mn.length);const xs=Number(oe.buffer.active.viewportY)||0,ri=JT({visibleRow:In.row-xs,rows:oe.rows});Qs(),!(ri===0||oe.buffer.active.type==="alternate")&&(rr=setInterval(()=>{const go=Number(oe.buffer.active.viewportY)||0;if(oe.scrollLines(ri),(Number(oe.buffer.active.viewportY)||0)===go){Qs();return}bi(bs.x-Ut.offsetX,bs.y-Ut.offsetY,bs.type)},130))},or=ye=>{Ut&&(ye.preventDefault(),bs={x:ye.clientX,y:ye.clientY,type:ye.pointerType||bs.type},bi(ye.clientX-Ut.offsetX,ye.clientY-Ut.offsetY,bs.type))},Mr=()=>{Ut=null,Qs(),ce(null),window.removeEventListener("pointermove",or),window.removeEventListener("pointerup",As),window.removeEventListener("pointercancel",As)},As=()=>Mr();ee.current={startHandleDrag:(ye,Xe)=>{if(!oe.getSelectionPosition())return;Xe.preventDefault(),Xe.stopPropagation();const nt=P.current&&P.current[ye],pt=xt.getBoundingClientRect();Ut={which:ye,offsetX:nt?Xe.clientX-(pt.left+nt.left):0,offsetY:nt?Xe.clientY-(pt.top+nt.top):0,fixed:me.current?ye==="start"?me.current.end:me.current.start:null},bs={x:Xe.clientX,y:Xe.clientY,type:Xe.pointerType||"touch"},ce(ye),ge(ye),window.addEventListener("pointermove",or),window.addEventListener("pointerup",As),window.addEventListener("pointercancel",As)}};const tu=ye=>{!zT(ye)||!(W.current&&W.current.term&&W.current.term.getSelection())||(ye.preventDefault(),ye.stopPropagation(),ot.current&&ot.current())};xt.addEventListener("keydown",tu,!0);const ar=()=>{Be.fit(),Qt.resize(oe.cols,oe.rows)};window.addEventListener("resize",ar);const Ss=window.visualViewport;let hl=Ss&&Number(Ss.height);const fl=()=>{const ye=Ss&&Number(Ss.height);It&&ie.current==="double-tap"&&Number.isFinite(hl)&&Number.isFinite(ye)&&ye>hl+80&&Dt(),hl=ye,ar()};Ss&&(Ss.addEventListener("resize",fl),Ss.addEventListener("scroll",ar));const Jn=typeof navigator<"u"?navigator.virtualKeyboard:null,pl=()=>{var ye;It&&ie.current==="double-tap"&&Number(((ye=Jn==null?void 0:Jn.boundingRect)==null?void 0:ye.height)||0)===0&&Dt()};(aa=Jn==null?void 0:Jn.addEventListener)==null||aa.call(Jn,"geometrychange",pl);let sa=null,Si=0;return typeof ResizeObserver<"u"&&(sa=new ResizeObserver(()=>{Si&&cancelAnimationFrame(Si),Si=requestAnimationFrame(ar)}),sa.observe(xt)),()=>{var ye,Xe,nt;W.current=null,b&&(b.current=null),ae.current&&(clearTimeout(ae.current),ae.current=null),c&&(c.current=()=>!1),u&&(u.current=()=>!1),h&&(h.current=()=>!1),$s.dispose(),zs.dispose(),ds.dispose(),Yn.dispose(),Qs(),window.removeEventListener("pointermove",or),window.removeEventListener("pointerup",As),window.removeEventListener("pointercancel",As),ee.current={startHandleDrag:()=>{}},xt.removeEventListener("touchstart",Xn),xt.removeEventListener("touchmove",Ot,{capture:!0}),xt.removeEventListener("touchend",Di),xt.removeEventListener("touchcancel",ir),xt.removeEventListener("dblclick",cl),xt.removeEventListener("contextmenu",ta,!0),at(),xt.removeEventListener("wheel",ll,{capture:!0}),xt.removeEventListener("mousedown",ul,!0),xt.removeEventListener("mousemove",dl,!0),xt.removeEventListener("mouseup",na,!0),xt.removeEventListener("keydown",tu,!0),xt.removeEventListener("paste",Qe,!0),xt.removeEventListener("dragenter",ct,!0),xt.removeEventListener("dragover",ct,!0),xt.removeEventListener("drop",At,!0),window.removeEventListener("resize",ar),Ss&&(Ss.removeEventListener("resize",fl),Ss.removeEventListener("scroll",ar)),(ye=Jn==null?void 0:Jn.removeEventListener)==null||ye.call(Jn,"geometrychange",pl),on==null||on.removeEventListener("blur",tn),(Xe=x.current)==null||Xe.removeEventListener("paste",sn,!0),(nt=x.current)==null||nt.removeEventListener("keydown",En,!0),sa&&sa.disconnect(),Si&&cancelAnimationFrame(Si),Qt.close(),oe.dispose()}},[t,e,n,s,i,c,u,h,p,v,S]),y.useEffect(()=>{const oe=x.current,Be=W.current?W.current.term:null;if(!oe||!Be||!te){Fe(null),he(null),Ye(null);return}const Lt=(oe.querySelector(".xterm-screen")||oe).getBoundingClientRect(),Nt=oe.getBoundingClientRect(),kt=Lt.width/Math.max(1,Be.cols),Kt=Lt.height/Math.max(1,Be.rows),ft=XT({range:te,viewportY:Number(Be.buffer.active.viewportY)||0,rows:Be.rows,cols:Be.cols,cellWidth:kt,cellHeight:Kt,screenLeft:Lt.left-Nt.left,screenTop:Lt.top-Nt.top});Fe(ft);let Vt=null;const It=te[Z==="end"?"end":"start"].row;typeof Be.buffer.active.getLine=="function"&&(Vt=Be.buffer.active.getLine(Number(It)));const Xt=Math.max(16,Math.round(Kt*2)),Dt=Vt?{...QT({range:te,side:Z,line:Vt,cols:Be.cols}),fontSize:Xt}:null;he(Dt);const Cn=X!==null||Ne,nn=ft[Z==="end"?"end":"start"];if(!Cn||!Dt||!nn||!nn.visible){Ye(null);return}const on=(Dt.before+Dt.sel+Dt.after).length,tn=kt*(Xt/Math.max(1,Kt)),un=Math.min(Nt.width-8,Math.round(on*tn)+16),Ht=Math.round(Xt*1.25)+12;Ye(YT({anchorLeft:nn.left,anchorTop:nn.top,hostWidth:Nt.width,hostHeight:Nt.height,bubbleWidth:un,bubbleHeight:Ht}))},[te,Ae,Z,X,Ne]);const le=WT(ht),_e=y.useRef({}),Me=(oe,Be)=>{if(X!==oe)return _e.current[oe]={flip:Be,ts:0},Be;const gt=_e.current[oe]||{flip:Be,ts:0};if(gt.flip===Be)return _e.current[oe]=gt,Be;const Lt=Date.now();return Lt-gt.ts<GT?gt.flip:(_e.current[oe]={flip:Be,ts:Lt},Be)};return a.jsxs("div",{className:`nc-terminal${C?" selecting":""}`,children:[a.jsx("div",{className:"nc-terminal-host",ref:x}),L&&a.jsxs("div",{className:"nc-terminal-link-overlay",children:["riconnessione…",A>0?` (${A} byte in coda)`:""]}),R&&a.jsx("div",{className:"nc-touch-selection-caret",style:R,"aria-hidden":"true"}),te&&we&&le.handles&&["start","end"].map(oe=>we[oe].visible&&a.jsx("div",{className:`nc-sel-handle ${oe}${X===oe?" dragging":""}${Me(oe,we[oe].flip)?" flip":""}${VT({startLeft:we.start.left,endLeft:we.end.left})?" tight":""}`,style:{left:`${we[oe].left}px`,top:`${we[oe].top}px`},onPointerDown:Be=>ee.current.startHandleDrag(oe,Be),"aria-hidden":"true"},`nc-sel-handle-${oe}`)),te&&Y&&le.magnifier&&Ve&&a.jsx("div",{className:`nc-zoom-bubble${Ve.flipped?" flipped":""}`,style:{left:`${Ve.left}px`,top:`${Ve.top}px`},"aria-hidden":"true",children:a.jsxs("pre",{className:"nc-zoom-line",style:{fontSize:`${Y.fontSize}px`},children:[a.jsx("span",{children:Y.before}),a.jsx("span",{className:"nc-zoom-sel",children:Y.sel}),a.jsx("span",{children:Y.after})]})}),T&&a.jsx("div",{className:`nc-upload-state${T.error?" error":""}`,role:"status",children:T.error?T.error:T.done?f("attach-uploaded").replace("{n}",String(T.total||0)):f("attach-upload-progress").replace("{n}",String(T.current||0)).replace("{total}",String(T.total||0))}),(K||C)&&a.jsxs("div",{className:"nc-selection-tools",children:[K?a.jsx("button",{type:"button",onClick:st,children:I||`${f("copy")} · ${FT(typeof navigator<"u"?navigator.userAgent:"")}`}):a.jsx("span",{children:f("select-drag")}),K&&re&&a.jsx("span",{className:"nc-selection-held",children:f("selection-held")}),K&&!re&&et&&a.jsx("span",{className:"nc-selection-changed",children:f("selection-changed")}),a.jsx("button",{type:"button",onClick:()=>{var oe,Be;(Be=(oe=W.current)==null?void 0:oe.term)==null||Be.clearSelection(),B(""),je(!1),N==null||N(!1)},children:f("cancel")}),I===f("copy-manual")&&a.jsx("textarea",{readOnly:!0,value:K,onFocus:oe=>oe.target.select()})]})]})}let Uk=new Set;function vP(t){Uk=new Set(Array.isArray(t)?t.filter(e=>typeof e=="string"):[])}function _P(t){return Array.isArray(t)&&t.some(e=>Uk.has(e))}function Tc(t,e,n){const s=c=>Number.isInteger(c)&&c>0&&c<65536?c:0;if(t==null)return s(n);if(!Array.isArray(t))return 0;if(t.length===0)return s(n);const i=typeof t[0]=="string"?t[0]:null;return i?s((e&&typeof e=="object"?e:{})[i]):0}const yP=6901,wP="allow-scripts allow-forms allow-popups allow-modals allow-downloads allow-pointer-lock";function Mv({cellId:t,panelUrl:e,route:n=[],panelPort:s=0,token:i,title:l,requestTimeoutMs:c=4e3}){const[u,h]=y.useState(t&&i?"requesting":"none"),[p,v]=y.useState(""),_=Array.isArray(n)?n.join("\0"):"",g=y.useMemo(()=>Array.isArray(n)?n:[],[_]),b=_P(g)?wP:null,S=y.useRef(0),j=y.useCallback(async()=>{if(!t||!i||!e){h("none");return}const I=S.current+=1;h("requesting");const D=new AbortController,T=setTimeout(()=>D.abort(),c);try{const z=await s5(i,g,t,{signal:D.signal});if(clearTimeout(T),I!==S.current)return;if(z.ok){let R="/";try{R=new URL(e).pathname||"/"}catch{}const M=s?`http://127.0.0.1:${s}`:yn(g);v(`${M}/panel/${encodeURIComponent(t)}${R}?ticket=${encodeURIComponent(z.ticket)}`),h("ready")}else h(z.cause)}catch(z){if(clearTimeout(T),I!==S.current)return;h(z&&z.name==="AbortError"?"timeout":"unreachable")}},[t,e,g,s,i,c]),C=y.useCallback(()=>{h(I=>I==="ready"?"loaded":I)},[]),N=y.useCallback(()=>{h(I=>I==="ready"||I==="loaded"?"frame-error":I)},[]),E=y.useRef(null),O=y.useCallback(I=>{I&&(E.current=I,I.onload=C,I.onerror=N)},[C,N]);y.useEffect(()=>{j()},[j]);const W=y.useMemo(()=>{try{return Number(new URL(e).port)===yP}catch{return!1}},[e])&&g.length===0,[$,J]=y.useState(!1),[q,V]=y.useState("");y.useEffect(()=>{const I=D=>{const T=E.current;if(!T||!T.contentWindow||D.source!==T.contentWindow)return;let z=null;try{z=new URL(p,window.location.href).origin}catch{return}!z||D.origin!==z||!D.data||D.data.type!=="nc-panel-unreachable"||h(R=>R==="ready"||R==="loaded"?"unreachable":R)};return window.addEventListener("message",I),()=>window.removeEventListener("message",I)},[p]);const ie=y.useCallback(async()=>{if(!i||$)return;J(!0),V("");let I=!1;try{const D=await t1(i,!0);D&&D.ok===!1&&(V(D.error||"comando fallito"),I=!0)}catch(D){V(String(D&&D.message||D)),I=!0}J(!1),I||j()},[i,$,j]),K=(I,D=!0,T=null)=>a.jsxs("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:[a.jsx("span",{children:f(I)}),D&&a.jsxs("span",{className:"nc-cellpanel-actions",children:[T,a.jsx("button",{type:"button",title:f("panel-retry"),onClick:()=>j(),children:f("panel-retry")})]})]}),B=W?a.jsx("button",{type:"button",disabled:$,onClick:ie,children:f("panel-start-desktop")}):null;return u==="none"||u==="no-panel"?K("panel-none",!1):u==="requesting"?a.jsx("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:a.jsx("span",{children:f("panel-checking")})}):u==="not-granted"?K("panel-not-granted",!1):u==="node-refused"?K("panel-node-refused",!1):u==="unauthorized"?K("panel-unauthorized",!1):u==="denied"?K("panel-denied"):u==="timeout"?K("panel-timeout"):u==="unreachable"?a.jsxs("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:[a.jsxs("span",{children:[f("panel-unreachable"),q?` — ${q}`:""]}),a.jsxs("span",{className:"nc-cellpanel-actions",children:[B,a.jsx("button",{type:"button",title:f("panel-retry"),onClick:()=>j(),children:f("panel-retry")})]})]}):u==="frame-error"?K("panel-frame-error",!0,B):a.jsxs(a.Fragment,{children:[u==="ready"&&a.jsx("div",{className:"nc-cellpanel-loading",role:"status",children:f("panel-frame-loading")}),a.jsx("iframe",{ref:O,className:"nc-cellpanel nc-cellpanel-frame","data-frame-state":u,src:p,title:l||f("panel"),allowFullScreen:!0,...b?{sandbox:b}:{}})]})}const bP=1800*1e3;function Sg(t,e,n=Date.now()){const s=Number(e);if(!Number.isFinite(s)||s<=0)return"";const i=n-s;if(i<0||i>bP)return"";if(i<60*1e3)return`${t("cell-activity")} ${t("cell-activity-now")}`;const l=Math.floor(i/6e4);return l<60?`${t("cell-activity")} ${l}m`:`${t("cell-activity")} ${Math.floor(l/60)}h`}function xg(t,e){if(!e||typeof e!="object")return"";const n=[];return Number.isInteger(e.contextFreePct)&&n.push(`${t("cell-tele-ctx")} ${e.contextFreePct}% ${t("cell-tele-free")}`),Number.isInteger(e.tier5hUsedPct)&&n.push(`${t("cell-tele-5h")} ${e.tier5hUsedPct}%`),Number.isInteger(e.tier7dUsedPct)&&n.push(`${t("cell-tele-7d")} ${e.tier7dUsedPct}%`),n.join(" · ")}function Tv({row:t,token:e,panelPort:n=0,liveHost:s=null,onLiveHostApplied:i,source:l,onSourceChange:c,fontSize:u,readOnly:h=!1,chrome:p=!0}){const v=q=>c&&c(q),_=y.useRef(()=>{}),g=y.useRef(()=>!1),b=y.useRef(()=>{}),S=y.useRef(!1),[j,C]=y.useState(!1),[N,E]=y.useState(""),[O,x]=y.useState(!1),W=!!(s&&s.cell&&s.cell===t.cellName),$=async()=>{x(!0);const q=await dh({action:W?"remove":"use",cellId:t.cellName,route:t.route||[],token:e,api:{getLiveHost:V=>ah(e,V),designateHostCell:(V,ie,K)=>lh(e,V,ie,K),clearHostCell:(V,ie)=>ch(e,V,ie)}});x(!1),E(f(q.messageKey).replace("{cell}",q.hostCell||t.cellName)),q.ok&&i&&i({route:t.route||[],hostCell:q.hostCell,revision:q.revision})},J=[["preview",f("cell-peek-preview")],["stream",f("cell-peek-stream")],...t.panelUrl?[["panel",f("cell-peek-panel")]]:[]];return a.jsxs(a.Fragment,{children:[p&&a.jsx("div",{className:"nc-peek-sorgenti",role:"tablist",children:J.map(([q,V])=>a.jsx("button",{type:"button",role:"tab","aria-selected":l===q,className:`nc-peek-sorgente${l===q?" attiva":""}`,onClick:()=>v(q),children:V},q))}),p&&a.jsxs("div",{className:"nc-peek-host",children:[a.jsx("button",{type:"button",className:"nc-peek-host-btn",disabled:O,onClick:$,children:f(W?"live-host-action-remove":"live-host-action-use")}),N&&a.jsx("div",{className:"nc-peek-notice",role:"status",children:N})]}),l==="stream"?a.jsx("div",{className:"nc-peek-stream",children:a.jsx(wc,{session:t.session,node:t.node||void 0,token:e,readonly:h,takeSize:!1,focused:!0,sendRef:_,composerRef:g,actionRef:b,ctrlRef:S,setCtrlArmed:C,fontSize:u},`peek:${t.key}`)}):l==="panel"?a.jsx(Mv,{cellId:t.cellName,panelUrl:t.panelUrl,route:t.route||[],panelPort:n,token:e,title:t.cellName}):a.jsxs(a.Fragment,{children:[a.jsx("pre",{className:"nc-peek-testo",children:t.preview||f("cell-peek-vuoto")}),[Sg(f,t.activity),xg(f,t.telemetry)].filter(Boolean).join(" · ")&&a.jsx("small",{className:"nc-cell-switcher-telemetry",children:[Sg(f,t.activity),xg(f,t.telemetry)].filter(Boolean).join(" · ")})]})]})}function Wk({row:t,token:e,initialSource:n="preview",panelPort:s=0,onClose:i,liveHost:l=null,onLiveHostApplied:c}){const[u,h]=y.useState(n==="panel"&&!t.panelUrl?"preview":n);return a.jsx(_1,{title:t.cellName,subtitle:[t.nodeLabel,t.subtitle].filter(Boolean).join(" · "),onClose:i,children:a.jsx(Tv,{row:t,token:e,panelPort:s,liveHost:l,onLiveHostApplied:c,source:u,onSourceChange:h})})}const Pc="nc_order_journal_v1",SP=50,Mp="__corrupt",xP=200,kP=200,CP=["reason","key","position","source","target","note"],EP=["before","after","visible"],qk=t=>String(t).slice(0,kP),NP=t=>Array.isArray(t)?t.slice(0,xP).map(qk):void 0,vh=t=>{try{return t||globalThis.localStorage}catch{return null}};function jP(t){const e={t:Date.now()};for(const n of CP)t[n]!==void 0&&t[n]!==null&&(e[n]=qk(t[n]));for(const n of EP){const s=NP(t[n]);s&&(e[n]=s)}return e}function Pv(t,e,n){const s=vh(n);if(!s||e===null||e===void 0)return!1;try{if(s.getItem(t+Mp)===e)return!1;s.setItem(t+Mp,e)}catch{return!1}return t!==Pc&&Xi({reason:"corrupt-preserved",key:t,note:`${String(e).length} caratteri conservati in ${t}${Mp}`},s),!0}function kg(t){const e=vh(t);if(!e)return[];let n=null;try{n=e.getItem(Pc)}catch{return[]}if(n===null)return[];try{const s=JSON.parse(n);if(Array.isArray(s))return s}catch{}return Pv(Pc,n,e),[]}function Xi(t,e){const n=vh(e);if(!(!n||!t))try{const s=[...kg(n),jP(t)].slice(-SP);n.setItem(Pc,JSON.stringify(s))}catch{}}function LP(t){const e=vh(t);if(e)try{e.removeItem(Pc)}catch{}}function Ar(t,{parse:e,fallback:n,storage:s}={}){let i=s;try{i=i||globalThis.localStorage}catch{return n()}let l=null;try{l=i.getItem(t)}catch{return n()}if(l==null)return n();try{const c=e(JSON.parse(l));if(c!==void 0)return c}catch{}return Pv(t,l,i),n()}function yi(t,e,{storage:n}={}){let s=n;try{s=s||globalThis.localStorage}catch(i){return i}try{const i=s.getItem(t);if(i!=null)try{JSON.parse(i)}catch{Pv(t,i,s)}return s.setItem(t,JSON.stringify(e)),null}catch(i){return i instanceof Error?i:new Error(String(i))}}const RP=["all","pinned","active","off","technical"],Xo="nc_sidebar_views_v1",Jo="nc_sidebar_order_v1";function Kk(t){return RP.includes(t)?t:"all"}function AP(t,e=[],n="all"){const s=Kk(n);return s==="technical"?t.technical===!0:t.technical===!0?!1:s==="pinned"?e.includes(t.key):s==="active"?!!t.live:s==="off"?!t.live:!0}function MP(t,e,n=[],s=[]){const i=n.indexOf(t.key),l=n.indexOf(e.key),c=i===-1?Number.MAX_SAFE_INTEGER:i,u=l===-1?Number.MAX_SAFE_INTEGER:l,h=s.indexOf(t.key),p=s.indexOf(e.key),v=h===-1?Number.MAX_SAFE_INTEGER:h,_=p===-1?Number.MAX_SAFE_INTEGER:p;return c-u||v-_||+!!e.live-+!!t.live||+!!e.fresh-+!!t.fresh||Number(e.activity||0)-Number(t.activity||0)||String(t.label||"").localeCompare(String(e.label||""))||String(t.key||"").localeCompare(String(e.key||""))}function gc(t=globalThis.localStorage){return Ar(Jo,{storage:t,fallback:()=>({}),parse:e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const n={};for(const[s,i]of Object.entries(e).slice(0,64)){if(typeof s!="string"||!s||s.length>160||!Array.isArray(i))continue;const l=[...new Set(i.filter(c=>typeof c=="string"&&c&&c.length<=256))].slice(0,128);l.length&&(n[s]=l)}return n}})}function Ti(t,e){return Array.isArray(t==null?void 0:t[e])?t[e]:[]}function TP(t,e=globalThis.localStorage){return yi(Jo,t,{storage:e}),t}function PP(t,e,n,s,i=[]){if(typeof e!="string"||!e||n===s)return t;const l=[...new Set(i.filter(g=>typeof g=="string"&&g))];if(!l.includes(n)||!l.includes(s))return t;const c=Ti(t,e),u=[...c,...l.filter(g=>!c.includes(g))],h=u.indexOf(n),p=u.indexOf(s);u.splice(h,1);const v=u.indexOf(s),_=h<p?v+1:v;return u.splice(_,0,n),{...t,[e]:u}}function Ld(t=globalThis.localStorage){return Ar(Xo,{storage:t,fallback:()=>({}),parse:e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0})}function Cg(t,e){var n,s;return{open:((n=t==null?void 0:t[e])==null?void 0:n.open)!==!1,filter:Kk((s=t==null?void 0:t[e])==null?void 0:s.filter)}}function IP(t,e=globalThis.localStorage){return yi(Xo,t,{storage:e}),t}function z0(t,e=""){const n=String(e||"").trim().toLocaleLowerCase();return n?[t.label,t.key,t.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(n):!0}function co(t=[],e=[],n="all",s=[]){return[...t].filter(i=>AP(i,e,n)).sort((i,l)=>MP(i,l,e,s))}function zn(){return[y.useSyncExternalStore(uj,Vo,Vo),cj]}function DP(t){const e=Array.isArray(t)?t:[],n=e.filter(i=>i&&i.standard===!0),s=e.filter(i=>!(i&&i.standard===!0));return{standard:n,others:s}}function _h({engines:t}){const{standard:e,others:n}=DP(t);return a.jsxs(a.Fragment,{children:[e.length>0&&a.jsx("optgroup",{label:f("fleet-engine-group-standard"),children:e.map(s=>a.jsx("option",{value:s.id,children:s.label||s.id},s.id))}),n.length>0&&a.jsx("optgroup",{label:f("fleet-engine-group-other"),children:n.map(s=>a.jsx("option",{value:s.id,children:s.label||s.id},s.id))})]})}function Wd({cell:t,token:e,route:n=[],onConfirm:s,onClose:i}){var z,R;zn();const l=!!(t&&t.active),c=Array.isArray(n)?n.join("/"):"",[u,h]=y.useState([]),[p,v]=y.useState(!1);y.useEffect(()=>{let M=!0;return(async()=>{if(e)try{const L=await tl(e,c?c.split("/"):[]);if(!M)return;if(v(L.provider==="builtin"&&(L.capabilities||[]).includes("edit")),L.provider==="builtin"&&(L.capabilities||[]).includes("definitions")){const H=await rh(e,c?c.split("/"):[]);if(!M)return;const A=new Map((L.engines||[]).map(U=>[U.id,U]));h((H.engines||[]).map(U=>{var Q,ae,re,je,te,ne,me;return{id:U.id,label:U.label||U.id,client:((Q=U.managed)==null?void 0:Q.client)||"",models:[...new Set([...((ae=A.get(U.id))==null?void 0:ae.models)||[],...((re=U.managedInfo)==null?void 0:re.models)||[]])].filter(Boolean),defaultModel:((je=U.managed)==null?void 0:je.model)||((te=U.managedInfo)==null?void 0:te.defaultModel)||"",policyDefault:((ne=U.managed)==null?void 0:ne.permissionPolicy)||((me=U.managed)!=null&&me.client&&U.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{M=!1}},[e,c]);const _=(t==null?void 0:t.engine)||((z=u[0])==null?void 0:z.id)||"",g=M=>(t==null?void 0:t.models)&&t.models[M]||"",b=M=>{const L=(t==null?void 0:t.permissionPolicies)&&t.permissionPolicies[M];if(L==="standard"||L==="unsafe")return L;const H=u.find(A=>A.id===M);return H?H.policyDefault:"standard"},[S,j]=y.useState(_),[C,N]=y.useState((t==null?void 0:t.model)||""),E=(t==null?void 0:t.permissionPolicy)==="standard"||(t==null?void 0:t.permissionPolicy)==="unsafe"?t.permissionPolicy:((R=t==null?void 0:t.permissionPolicies)==null?void 0:R[t==null?void 0:t.engine])||"",[O,x]=y.useState(E),[W,$]=y.useState((t==null?void 0:t.boot)??!0),[J,q]=y.useState(!1),[V,ie]=y.useState(null);y.useEffect(()=>{u.length&&(j(M=>M||_),N(M=>M||g((t==null?void 0:t.engine)||_)||""),x(M=>M==="standard"||M==="unsafe"?M:b((t==null?void 0:t.engine)||_)))},[u.length]);const K=y.useMemo(()=>u.find(M=>M.id===S)||null,[u,S]),B=!!(K&&["claude","codex","codex-vl","agy","kimi"].includes(K.client)),I=(K==null?void 0:K.client)==="shell";function D(M){j(M);const L=u.find(H=>H.id===M);N(g(M)||(L==null?void 0:L.defaultModel)||""),x(b(M))}async function T(M){M.preventDefault(),q(!0),ie(null);try{if(l)await s({action:"down",boot:W});else{const L=O==="standard"||O==="unsafe"?O:(K==null?void 0:K.policyDefault)||"standard";await s({action:"up",...p?{engine:S,model:C||"",...B?{permissionPolicy:L}:(K==null?void 0:K.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:W})}i()}catch(L){ie(String(L&&L.message||L)),q(!1)}}return a.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:i,children:a.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:M=>M.stopPropagation(),onSubmit:T,children:[a.jsxs("div",{className:"nc-sheet-head",children:[a.jsx("b",{children:t==null?void 0:t.cell}),a.jsx("span",{className:"nc-sheet-state",children:f(l?"state-on":"state-off")})]}),l?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"nc-power-config",children:[a.jsx("span",{children:f("engine")}),a.jsx("b",{children:(t==null?void 0:t.engine)||"—"}),(t==null?void 0:t.model)&&a.jsxs("small",{children:[f("model"),": ",t.model]}),a.jsx("small",{children:f("power-on-hint")})]}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:W,onChange:M=>$(M.target.checked)}),f("remove-boot")]})]}):a.jsxs(a.Fragment,{children:[p&&u.length>0?a.jsxs("div",{className:"nc-launch-fields",children:[a.jsxs("label",{className:"nc-field",children:[f("engine"),a.jsx("select",{value:S,onChange:M=>D(M.target.value),children:a.jsx(_h,{engines:u})})]}),!I&&a.jsxs("label",{className:"nc-field",children:[f("model"),a.jsx("input",{value:C,list:"nc-launch-models",placeholder:f("model-default"),onChange:M=>N(M.target.value)}),a.jsx("datalist",{id:"nc-launch-models",children:((K==null?void 0:K.models)||[]).map(M=>a.jsx("option",{value:M},M))})]}),B?a.jsxs("label",{className:"nc-field",children:[f("permissions"),a.jsxs("select",{value:O,onChange:M=>x(M.target.value),children:[a.jsx("option",{value:"standard",children:f("fleet-standard-permissions")}),a.jsx("option",{value:"unsafe",children:f("fleet-unsafe-permissions")})]})]}):a.jsx("small",{className:"nc-note",children:f("fleet-standard-permissions")}),B&&O==="unsafe"&&a.jsx("small",{className:"nc-err",children:f("fleet-unsafe-warning")}),a.jsx("small",{className:"nc-note",children:f(I?"fleet-shell-launch-help":"launch-engine-help")})]}):a.jsxs("div",{className:"nc-power-config",children:[a.jsx("span",{children:f("engine")}),a.jsx("b",{children:(t==null?void 0:t.engine)||"—"}),(t==null?void 0:t.model)&&a.jsxs("small",{children:[f("model"),": ",t.model]}),a.jsx("small",{children:f("launch-unavailable-hint")})]}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:W,onChange:M=>$(M.target.checked)}),f("boot-persist")]})]}),V&&a.jsx("div",{className:"nc-err",children:V}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:i,children:f("cancel")}),a.jsx("button",{type:"submit",className:"nc-btn primary",disabled:J,children:f(J?l?"power-stopping":"power-starting":l?"power-off":"save-and-start")})]})]})})}const F0=/^[a-z0-9-]{1,32}$/;function Ic(t,e){const n=Array.isArray(t)?t:[];return n.length?`${n.map(encodeURIComponent).join("/")}:${e}`:String(e)}function OP(t,e,n){const s={};for(const i of Array.isArray(e)?e:[]){const l=Array.isArray(i==null?void 0:i.route)?i.route:typeof(i==null?void 0:i.name)=="string"?[i.name]:[];if(!l.length)continue;const c=l.join("/"),u=i.status==="up"||i.tunnel&&i.tunnel.status==="up",h=i.status==="passive"||i.tunnel&&i.tunnel.status==="passive";!u&&!h&&i.status!=="pending"&&!i.checking&&(s[c]=t&&t[c]||n)}return s}function Eg(t,e,n,s=!1){return!t||!Array.isArray(t.cells)?[]:t.cells.map(i=>({...i,route:e,key:`${n}:${i.tmuxSession||i.cell}`,...s?{preserved:!0}:{}}))}function Ql(t,e,n){if(!t)return{};const s=Ng(t);return!vc(t,s)||s!=="stale"?{}:{cells:Eg(t,e,n,!0),fleetState:"stale",fleetAvailable:!1,cellsPreserved:!0}}function Ng(t){return(t==null?void 0:t.fleetState)==="stale"?"stale":(t==null?void 0:t.fleetState)==="disabled"?"disabled":(t==null?void 0:t.available)===!0&&Array.isArray(t.cells)?"available":(t==null?void 0:t.available)===!1?"disabled":"stale"}function vc(t,e){return(e==="available"||e==="stale")&&Array.isArray(t==null?void 0:t.cells)}function H0(t,e){const n=t?e&&e.at:e&&e.lastGoodAt;return Number.isFinite(n)?n:null}function U0({nodes:t,topology:e,remote:n,down:s,fleet:i,aliases:l,pendingReads:c,previousGroups:u}={}){var S,j,C,N;const h=[],p=new Set,v=new Set,_=(E,O)=>!!(c&&(c.has(E)||c.has(`${E}#${O}`))),g=(E,O,x)=>Array.isArray(u)?u.find(W=>W.name===O&&W.instanceId===x&&(Array.isArray(W.route)?W.route.join("/"):"")===E):null;function b(E,O){const x=g(E,O.name,O.instanceId),W=_(E,"sessions"),$=_(E,"fleet"),J=(n==null?void 0:n[E])||(W&&x?{sessions:x.sessionsAvailable?x.sessions:void 0,at:x.verifiedAt,lastGoodAt:x.verifiedAt,...x.sessionsAvailable===!1&&x.cause?{cause:x.cause}:{}}:null),q=(i==null?void 0:i[E])||($&&x?{available:x.fleetAvailable,cells:x.cells,fleetState:x.fleetState,capabilities:x.capabilities,engines:x.engines,provider:x.fleetProvider,cellsPreserved:x.cellsPreserved,...x.fleetState==="stale"&&x.cause?{cause:x.cause}:{}}:null);return(W||$)&&(O.checking=!0,O.sessionsPending=W,O.fleetPending=$),{r:J,f:q,previous:x,pending:W||$,rereading:x&&(W||$)&&!(n!=null&&n[E])&&!(i!=null&&i[E])}}for(const E of Array.isArray(t)?t:[]){if(!E||typeof E.name!="string"||!F0.test(E.name)||E.direction==="inbound"&&E.shared!==!0)continue;const O=[E.name],x=E.name;p.add(x);const W=((S=E.tunnel)==null?void 0:S.status)||"unknown",$=W==="up",J={name:E.name,label:E.label||E.name,originalLabel:E.label||E.name,alias:null,route:O,direct:!0,instanceId:E.nodeId||null,shared:E.shared===!0,stale:E.stale===!0,tunnelStatus:W,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:E.health||null,direction:E.direction||"outbound",roles:E.roles||null,rolesKnown:E.rolesKnown===!0};if(E.nodeId&&v.add(E.nodeId),!E.nodeId&&E.paired===!1){h.push({...J,status:"needs-repair",downSince:s&&s[x]||null,...Ql(i&&(i[x]||i[E.name]),O,x)});continue}if(((j=E.health)==null?void 0:j.auth)==="failed"||W==="degraded"&&((C=E.health)==null?void 0:C.status)==="degraded"){h.push({...J,status:"needs-repair",downSince:s&&s[x]||null,...Ql(i&&(i[x]||i[E.name]),O,x)});continue}if(W==="passive"||((N=E.health)==null?void 0:N.status)==="passive"){h.push({...J,status:"passive",downSince:null,...Ql(i&&(i[x]||i[E.name]),O,x)});continue}if(!$){h.push({...J,status:"down",downSince:s&&s[x]||null,...Ql(i&&(i[x]||i[E.name]),O,x)});continue}const{r:q,f:V,previous:ie,pending:K,rereading:B}=b(x,J);if(B){h.push({...ie,checking:!0,sessionsPending:J.sessionsPending,fleetPending:J.fleetPending});continue}const I=!!(q&&!q.error&&Array.isArray(q.sessions)),D=Ng(V),T=D==="available"&&vc(V,D),z=vc(V,D);if(K&&!q&&!V){h.push({...J,status:(ie==null?void 0:ie.status)||"pending",pendingRead:!0,verifiedAt:(ie==null?void 0:ie.verifiedAt)??null});continue}if(!I&&!z){h.push({...J,status:K?(ie==null?void 0:ie.status)||"pending":"unreachable",cause:q&&q.cause||null});continue}const R=(I?q.sessions:[]).filter(H=>H&&typeof H.name=="string"&&H.name).map(H=>({...H,node:x,route:O,key:`${x}:${H.name}`})),M=Eg(V,O,x),L=new Set(M.map(H=>H.tmuxSession).filter(Boolean));h.push({...J,status:"up",sessions:R,cells:M,unmanaged:R.filter(H=>!L.has(H.name)),fleetAvailable:T,fleetState:D,...V!=null&&V.cellsPreserved?{cellsPreserved:!0}:{},...q!=null&&q.cause||V!=null&&V.cause?{cause:(q==null?void 0:q.cause)||(V==null?void 0:V.cause)}:{},capabilities:V&&V.capabilities||[],engines:V&&V.engines||[],fleetProvider:V&&V.provider||null,sessionsAvailable:I,inventoryPartial:!I,verifiedAt:H0(I,q)})}for(const E of Array.isArray(e)?e:[]){if(!E||!Array.isArray(E.route)||E.route.length<1||E.route.some(L=>!F0.test(L)))continue;const O=E.route.join("/");if(p.has(O)||E.instanceId&&v.has(E.instanceId))continue;E.instanceId&&v.add(E.instanceId);const x=E.label||E.route.join(" › "),W=E.instanceId&&l&&typeof l[E.instanceId]=="string"?l[E.instanceId]:null,$={name:E.name,label:W||x,originalLabel:x,alias:W,route:[...E.route],direct:!1,instanceId:E.instanceId||null,shared:!0,stale:E.stale===!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:E.health||null,lastSeen:E.lastSeen||null};if(E.stale){h.push({...$,status:"offline",downSince:s&&s[O]||E.lastSeen||null,...Ql(i&&i[O],E.route,O)});continue}const{r:J,f:q,previous:V,pending:ie,rereading:K}=b(O,$);if(K){h.push({...V,checking:!0,sessionsPending:$.sessionsPending,fleetPending:$.fleetPending});continue}const B=!!(J&&!J.error&&Array.isArray(J.sessions)),I=Ng(q),D=I==="available"&&vc(q,I),T=vc(q,I);if(ie&&!J&&!q){h.push({...$,status:(V==null?void 0:V.status)||"pending",pendingRead:!0,verifiedAt:(V==null?void 0:V.verifiedAt)??null});continue}if(!B&&!T){h.push({...$,status:ie?(V==null?void 0:V.status)||"pending":"unreachable",downSince:s&&s[O]||null,cause:J&&J.cause||null});continue}const z=(B?J.sessions:[]).filter(L=>L&&typeof L.name=="string"&&L.name).map(L=>({...L,node:O,route:E.route,key:`${O}:${L.name}`})),R=Eg(q,E.route,O),M=new Set(R.map(L=>L.tmuxSession).filter(Boolean));h.push({...$,status:"up",sessions:z,cells:R,unmanaged:z.filter(L=>!M.has(L.name)),fleetAvailable:D,fleetState:I,...q!=null&&q.cellsPreserved?{cellsPreserved:!0}:{},...J!=null&&J.cause||q!=null&&q.cause?{cause:(J==null?void 0:J.cause)||(q==null?void 0:q.cause)}:{},capabilities:q&&q.capabilities||[],engines:q&&q.engines||[],fleetProvider:q&&q.provider||null,lastSeen:E.lastSeen||null,sessionsAvailable:B,inventoryPartial:!B,verifiedAt:H0(B,J)})}return h.sort((E,O)=>E.label.localeCompare(O.label))}const jg="nc_route_alias_v1",BP="nexuscrew-roster-preferences",W0="nc_pins",$P=/^[a-f0-9]{16,64}$/;let Iv=new Map;const zP=t=>Array.isArray(t==null?void 0:t.route)&&t.route.length?t.route.join("/"):String((t==null?void 0:t.name)||"");function Tp(t,e=Iv){if(t==="local"||typeof t!="string")return t;const n=e.get(t);return n?`id:${n}`:t}const q0=(t,e,n)=>typeof t=="string"&&t.startsWith(`${e}:`)?`${n}:${t.slice(e.length+1)}`:t,K0=t=>[...new Set(t)];function Pp(t,e){return Ar(t,{storage:e,fallback:()=>({}),parse:n=>n&&typeof n=="object"&&!Array.isArray(n)?n:void 0})}function Ta(t,e=Iv){const n={...t||{}};for(const[s,i]of e)t&&t[`id:${i}`]!==void 0&&(n[s]=t[`id:${i}`]);return n}function FP(t,{storage:e=globalThis.localStorage}={}){const n=new Map,s=new Map;for(const j of Array.isArray(t)?t:[]){const C=String((j==null?void 0:j.instanceId)||""),N=zP(j);if(!($P.test(C)&&N)||n.has(N))continue;n.set(N,C);const E=j.status==="up"&&j.stale!==!0;(!s.has(C)||E&&!s.get(C).up)&&s.set(C,{name:N,up:E})}if(Iv=n,!n.size)return!1;const i=Pp(jg,e);let l=Pp(Jo,e),c=Pp(Xo,e),u=Ar(W0,{storage:e,fallback:()=>[],parse:j=>Array.isArray(j)?j:void 0});const h={...i},p={...l},v={...c};let _=[...u];const g={aliases:!1,orders:!1,views:!1,pins:!1};for(const[j,{name:C}]of s){const N=`id:${j}`,E=typeof i[j]=="string"?i[j]:"",O=E&&E!==C&&(!n.has(E)||n.get(E)===j)?E:"";O&&(_=K0([..._,...u.filter(x=>x.startsWith(`${O}:`)).map(x=>q0(x,O,C))]),g.pins=g.pins||_.length!==u.length);for(const[x,W,$]of[[l,p,"orders"],[c,v,"views"]]){const J=x[N]!==void 0?x[N]:O&&x[O]!==void 0?x[O]:x[C];if(J===void 0)continue;let q=J;$==="orders"&&Array.isArray(q)&&(q=K0(q.map(V=>O?q0(V,O,C):V))),JSON.stringify(W[N])!==JSON.stringify(q)&&(W[N]=q,g[$]=!0)}i[j]!==C&&(h[j]=C,g.aliases=!0),O&&Xi({reason:"route-renamed",key:j,note:`${O} -> ${C}`})}const b=[];g.pins&&b.push(yi(W0,_,{storage:e})),g.orders&&b.push(yi(Jo,p,{storage:e})),g.views&&b.push(yi(Xo,v,{storage:e})),g.aliases&&b.push(yi(jg,h,{storage:e}));const S=Object.values(g).some(Boolean);if(S)try{window.dispatchEvent(new Event(BP))}catch{}return S&&b.every(j=>!j)}const Vk="nc_last_roster_v1",HP=64,UP=["cell","tmuxSession","engine","model","label","boot"],Yk=t=>Ar(Vk,{storage:t,fallback:()=>({}),parse:e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0});function Ga(t,e,n=globalThis.localStorage){if(!t)return;const s={...Yk(n)};!Array.isArray(e)||!e.length?delete s[t]:s[t]={at:Date.now(),cells:e.slice(0,HP).filter(i=>i&&typeof i.cell=="string").map(i=>Object.fromEntries(UP.filter(l=>i[l]!==void 0&&i[l]!==null).map(l=>[l,i[l]])))},yi(Vk,s,{storage:n})}function Dv(t,e=globalThis.localStorage){const n=t?Yk(e)[t]:null;return!n||!Array.isArray(n.cells)?[]:n.cells.map(s=>({...s,tmux:!1,active:!1,preserved:!0,degraded:!1}))}function Gk(t,e={}){if(!t||typeof t!="object")return null;const n=typeof t.nodeId=="string"?t.nodeId:"";if(!n)return null;const s=typeof t.label=="string"&&t.label.trim()||typeof t.cell=="string"&&t.cell.trim()||n,i=Array.isArray(e.route)?[...e.route]:[];return{kind:"vl",nodeId:n,name:n,label:s,cell:t.cell??null,paired:!!t.pairedAt,online:!!t.online,lastSeen:t.lastSeen??null,generation:t.generation??null,version:t.version??null,health:t.health??null,session:t.session??null,capabilities:Array.isArray(t.capabilities)?t.capabilities:[],inflight:t.inflight??null,lastAck:t.lastAck??null,canManage:!!t.canManage,route:i,isLocal:i.length===0,ownerInstanceId:typeof e.instanceId=="string"?e.instanceId:null,ownerLabel:typeof e.label=="string"&&e.label?e.label:null}}function WP(t){var n;const e=[];for(const s of Array.isArray(t)?t:[]){if(!s||s.kind!=="vl"||!s.nodeId)continue;const i=s.online===!0,l=i&&((n=s.session)==null?void 0:n.attached)===!0,c=s.ownerInstanceId||"local";e.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:i?"up":"offline",downSince:i?null:s.lastSeen??null,sessions:l?[{key:`vl:${c}:${s.nodeId}`,name:s.session.profile,attached:!0}]:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:s.health??null,stale:s.stale===!0,fleetState:s.stale===!0?"stale":null,peer:s})}return e}function Xk(t,e){const n=t&&Array.isArray(t.nodes)?t.nodes:[],s=new Set([e]),i=[];for(const l of n){const c=l&&typeof l.instanceId=="string"?l.instanceId:"";if(!c||s.has(c)||l.stale===!0||!Array.isArray(l.route)||l.route.length===0)continue;s.add(c);const u=typeof l.label=="string"&&l.label||typeof l.name=="string"&&l.name||l.route.join(" › ");i.push({instanceId:c,route:[...l.route],label:u})}return i}const qP=/fleet\.json/;function yh({fs:t=null,error:e=null}={}){if(e)return{kind:"stale"};if(!t)return{kind:"stale"};if(t.available===!0)return{kind:"data",cells:t.cells||[],capabilities:t.capabilities||[]};const n=typeof t.reason=="string"?t.reason:"";return typeof t.migrationCode=="string"&&t.migrationCode?{kind:"disabled",reason:n||null}:qP.test(n)?{kind:"stale"}:{kind:"disabled",reason:n||null}}const Jk={baseMs:4e3,capMs:6e4},Qk="peer-assente",Zk="peer-nega",eC="rotta-inesistente";function Ip(t){const e=t&&t.status;return e===403?Zk:e===404?eC:Qk}function KP(t,{baseMs:e,capMs:n}=Jk){return!Number.isFinite(t)||t<1?0:Math.min(e*2**(t-1),n)}function V0(t,e,n){const s=t&&t[e];return!s||!(s.failures>=1)?!0:n>=s.nextAtMs}function Y0(t,e,n,s,i=Jk){const c=(t&&t[e]||{failures:0}).failures+1;return{...t,[e]:{failures:c,cause:n,nextAtMs:s+KP(c,i)}}}function G0(t,e){if(!t||!(e in t))return t;const n={...t};return delete n[e],n}const VP=4e3,Ov=600*1e3,tC="nc-sticky-owners-v1";function YP(){try{const t=localStorage.getItem(tC);if(!t)return null;const e=JSON.parse(t);return!e||!Array.isArray(e.nodes)||!Array.isArray(e.topology)?null:e}catch{return null}}function GP(t){try{localStorage.setItem(tC,JSON.stringify(t))}catch{}}function cd(t,e,n,s,i){if(!e){for(const c of t.values())c.data={...c.data,stale:!0};return t}const l=new Map(n.map(c=>[s(c),c]));for(const[c,u]of t)l.has(c)?(u.data=l.get(c),u.missingSince=null,l.delete(c)):(u.missingSince??(u.missingSince=i),i-u.missingSince>Ov?t.delete(c):u.data={...u.data,stale:!0});for(const[c,u]of l)t.set(c,{data:u,missingSince:null});return t}function nC(t,e=!0,n=0){const[s,i]=y.useState([]),[l,c]=y.useState(null),u=y.useRef([]),h=y.useRef({}),p=y.useRef({}),v=y.useRef({remote:{},fleet:{}}),_=y.useRef(null),g=y.useRef(null),b=y.useRef(new Map),S=y.useRef(new Map),j=y.useRef(new Set),C=y.useRef(uh()),N=y.useRef(null);return y.useEffect(()=>{if(!e||!t){i([]),c(null);return}let E=!0;const O=_.current!==null&&_.current!==t;_.current!==t&&(_.current=t,p.current={},v.current={remote:{},fleet:{}},b.current.clear(),S.current.clear(),j.current.clear(),h.current={},u.current=[],i([]));const x={instanceId:"",nodes:new Map,topology:new Map},W=O?null:YP();if(W){x.instanceId=W.instanceId||"";for(const q of W.nodes)x.nodes.set(q.name,{data:q,missingSince:null});for(const q of W.topology)x.topology.set(q.route.join("/"),{data:q,missingSince:null})}async function $(){const q=C.current,V=Date.now(),ie=q.begin();if(ie===null)return;const K=new AbortController;N.current=K;const B={timeoutMs:qx,signal:K.signal},I=()=>E&&q.isCurrent(ie);let D=[],T=[],z={},R="",M=!1,L=!1,H="pending",A="pending";const U={},Q={},ae=new Set,re=new Set,je=new Set;let te=new Map;const ne=[],me=()=>{te=new Map([...T.filter(ze=>Array.isArray(ze.route)).map(ze=>[ze.route.join("/"),ze.instanceId]),...D.map(ze=>[ze.name,ze.nodeId])].filter(([,ze])=>typeof ze=="string"&&ze))},we=ze=>{const ve=te.get(ze),Oe=ve?Dv(`id:${ve}`):[];return Oe.length?{available:!1,cells:Oe,fleetState:"stale"}:null},Fe=()=>{if(!I()||!R)return!1;const ze=[],ve=Date.now();for(const[st,ot]of S.current){if(ve-ot.at>Ov){S.current.delete(st);continue}const ee=st.slice(3),P=b.current.get(ee);if(ot.ownerInstanceId!=null&&P!==void 0&&P!==ot.ownerInstanceId){S.current.delete(st);continue}const le=j.current.has(st.slice(3)),_e=ot.round!==ie||ot.identityUnknown===!0||le;for(const Me of ot.peers)ze.push({...Me,stale:_e})}const Oe=u.current,et=U0({nodes:D,topology:T,remote:U,fleet:Q,aliases:z,down:h.current,pendingReads:ae,previousGroups:Oe});h.current=OP(h.current,et,Math.floor(Date.now()/1e3));const Ue=[...U0({nodes:D,topology:T,remote:U,fleet:Q,aliases:z,down:h.current,pendingReads:ae,previousGroups:u.current}),...WP(ze)];return FP(Ue),u.current=Ue,c(t),i(Ue),!0};let Ae=[],He=[];const X=()=>{var ze;if(I()&&R){M?cd(x.nodes,!0,Ae,ve=>ve&&ve.name,V):H==="error"&&cd(x.nodes,!1,Ae,ve=>ve&&ve.name,V),L?cd(x.topology,!0,He,ve=>Array.isArray(ve&&ve.route)?ve.route.join("/"):"",V):A==="error"&&cd(x.topology,!1,He,ve=>Array.isArray(ve&&ve.route)?ve.route.join("/"):"",V),D=[...x.nodes.values()].map(ve=>ve.data),T=[...x.topology.values()].map(ve=>ve.data),me();for(const[ve,Oe]of te){const et=b.current.get(ve);et&&et!==Oe&&(delete v.current.remote[ve],delete v.current.fleet[ve],delete p.current[ve],delete p.current[`vl:${ve}`],delete h.current[ve],S.current.delete(`vl:${ve}`)),b.current.set(ve,Oe)}for(const ve of b.current.keys())if(!te.has(ve)){const Oe=S.current.get(`vl:${ve}`);Oe&&(Oe.identityUnknown=!0)}j.current=new Set(T.filter(ve=>!ve.stale&&Array.isArray(ve.route)&&ve.route.length>0&&!te.has(ve.route.join("/"))).map(ve=>ve.route.join("/")));for(const ve of D){if(((ze=ve.tunnel)==null?void 0:ze.status)==="up")continue;const Oe=v.current.fleet[ve.name];Oe&&!Q[ve.name]&&(Q[ve.name]={...Oe,available:!1,fleetState:"stale"})}for(const ve of T){if(!ve.stale||!Array.isArray(ve.route)||!ve.route.length)continue;const Oe=ve.route.join("/"),et=v.current.fleet[Oe];et&&!Q[Oe]&&(Q[Oe]={...et,available:!1,fleetState:"stale"})}(M||L)&&GP({instanceId:x.instanceId,savedAt:V,nodes:[...x.nodes.values()].map(ve=>ve.data),topology:[...x.topology.values()].map(ve=>ve.data)}),Ne(),Fe()}},ce=(ze,ve)=>{I()&&(H=ze?"success":"error",M=ze,Ae=ze?ve:[],X())},Z=(ze,ve)=>{I()&&(A=ze?"success":"error",L=ze,He=ze?ve:[],X())},ge=ze=>{I()&&(R=ze&&typeof ze.instanceId=="string"?ze.instanceId:"",R&&(x.instanceId!==R||g.current!==R)?(x.instanceId!==R&&(x.nodes.clear(),x.topology.clear()),u.current=[],h.current={},p.current={},v.current={remote:{},fleet:{}},b.current.clear(),S.current.clear(),j.current.clear()):R&&(x.instanceId=R),g.current=R||null,x.instanceId=R,X())};function Y(){const ze=[{instanceId:R||null,route:[],label:null},...Xk({nodes:T},R)];for(const ve of ze){const Oe=`${ve.instanceId}:${ve.route.join("/")}`;if(je.has(Oe))continue;je.add(Oe);const et=`vl:${ve.route.join("/")}`;ne.push((async()=>{if(V0(p.current,et,V))try{const Ue=await Zx(t,ve.route,{signal:K.signal});if(!I())return;const st=b.current.get(ve.route.join("/"));if(st!==void 0&&st!==ve.instanceId||j.current.has(ve.route.join("/")))return;p.current=G0(p.current,et);const ot=[];for(const ee of Ue.nodes||[]){const P=Gk(ee,ve);P&&ot.push(P)}S.current.set(et,{peers:ot,ownerInstanceId:ve.instanceId??null,at:V,round:ie}),Fe()}catch(Ue){if(!I())return;const st=b.current.get(ve.route.join("/"));if(st!==void 0&&st!==ve.instanceId||j.current.has(ve.route.join("/")))return;p.current=Y0(p.current,et,Ip(Ue),V)}})())}}async function he(ze){const ve=ze.join("/"),Oe=v.current.remote[ve]||null;if(!V0(p.current,ve,V)){ae.delete(`${ve}#sessions`),ae.delete(`${ve}#fleet`);const st=p.current[ve];U[ve]={error:"unreachable",cause:st&&st.cause||null,lastGoodAt:Oe?Oe.at:null};const ot=v.current.fleet[ve]||we(ve);ot&&(Q[ve]={...ot,available:!1,fleetState:"stale"});return}ae.add(`${ve}#sessions`),ae.add(`${ve}#fleet`);const et=(async()=>{let st=!1;try{const ot=await dv(t,ze,B);if(!I())return;st=!0,U[ve]={...ot,at:V},v.current.remote[ve]={payload:ot,at:V}}catch(ot){if(!I())return;U[ve]={error:"unreachable",cause:Ip(ot),lastGoodAt:Oe?Oe.at:null}}finally{ae.delete(`${ve}#sessions`)}p.current=st?G0(p.current,ve):Y0(p.current,ve,U[ve].cause,V),Fe()})(),Ue=(async()=>{const st=v.current.fleet[ve]||we(ve);try{const ot=await tl(t,ze,B);if(!I())return;const ee=yh({fs:ot});ee.kind==="data"?(Q[ve]={...ot,available:!0,cells:ee.cells,fleetState:"available"},te.get(ve)&&Ga(`id:${te.get(ve)}`,ee.cells)):ee.kind==="disabled"?(Q[ve]={...ot,available:!1,cells:[],fleetState:"disabled"},te.get(ve)&&Ga(`id:${te.get(ve)}`,[])):Q[ve]={...st||{},available:!1,cells:Array.isArray(st==null?void 0:st.cells)?st.cells:[],fleetState:"stale",...ot!=null&&ot.reason?{reason:ot.reason}:{}},v.current.fleet[ve]=Q[ve]}catch(ot){if(!I())return;Q[ve]={...st||{},available:!1,cells:Array.isArray(st==null?void 0:st.cells)?st.cells:[],fleetState:"stale",cause:Ip(ot)},v.current.fleet[ve]=Q[ve]}ae.delete(`${ve}#fleet`),Fe()})();await Promise.allSettled([et,Ue])}function Ne(){var Oe,et;if(!I()||!R)return;Y();const ze=new Set(D.map(Ue=>Ue.name)),ve=Ue=>{const st=Ue.join("/");re.has(st)||(re.add(st),ne.push(he(Ue)))};for(const Ue of D)M&&!Ue.stale&&((Oe=Ue.tunnel)==null?void 0:Oe.status)==="up"&&(Ue.nodeId||Ue.paired!==!1)&&(Ue.direction!=="inbound"||Ue.shared===!0)?ve([Ue.name]):H==="pending"&&!Ue.stale&&((et=Ue.tunnel)==null?void 0:et.status)==="up"&&(ae.add(`${Ue.name}#sessions`),ae.add(`${Ue.name}#fleet`));for(const Ue of T)if(!Ue.stale&&Array.isArray(Ue.route)&&Ue.route.length>0&&!(Ue.route.length===1&&ze.has(Ue.route[0]))){const st=Ue.route.join("/");L?ve(Ue.route):A==="pending"&&(ae.add(`${st}#sessions`),ae.add(`${st}#fleet`))}}const Ce=_5(t,B).then(ze=>{ce(!0,Array.isArray(ze.nodes)?ze.nodes:[])},()=>{ce(!1,[])}),Ve=e1(t,B).then(ze=>{Z(!0,Array.isArray(ze.nodes)?ze.nodes:[])},()=>{Z(!1,[])}),Ye=C5(t,B).then(ze=>{I()&&(z=ze&&typeof ze.aliasesByInstanceId=="object"?ze.aliasesByInstanceId:{},Fe())},()=>{}),ht=qc(t,[],B).then(ze=>{ge(ze)},()=>{});try{await Promise.allSettled([Ce,Ve,Ye,ht]),await Promise.allSettled(ne)}finally{q.isCurrent(ie)&&q.end(ie)}}$();const J=setInterval($,VP);return()=>{E=!1,clearInterval(J),C.current.reset(),N.current&&N.current.abort()}},[t,e,n]),{groups:s,hasLoaded:e&&!!t&&l===t}}function Bv(t,e=!0,n=0){return nC(t,e,n).groups}const X0=52,J0=14;function Yi({position:t,itemKey:e,label:n,onMove:s,onStep:i,canMove:l=()=>!0,scope:c="roster"}){const u=y.useRef(null),h=y.useRef(0),[p,v]=y.useState(!1),_=()=>{var N,E,O,x;const C=u.current;(E=(N=C==null?void 0:C.over)==null?void 0:N.classList)==null||E.remove("nc-roster-over"),(x=(O=C==null?void 0:C.source)==null?void 0:O.classList)==null||x.remove("nc-roster-dragging"),h.current&&cancelAnimationFrame(h.current),h.current=0},g=(C=!1)=>{const N=u.current;if(!N)return;const E=N.target;_(),u.current=null,v(!1);try{N.handle.releasePointerCapture(N.pointerId)}catch{}C&&E&&E!==e&&l(e,E)&&s(e,E)},b=(C,N)=>{var q,V,ie,K,B,I,D,T,z;const E=u.current;if(!E)return;E.x=C,E.y=N;const O=c==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",x=(V=(q=document.elementFromPoint(C,N))==null?void 0:q.closest)==null?void 0:V.call(q,O),W=c==="node"?(ie=x==null?void 0:x.dataset)==null?void 0:ie.nodeOrderKey:(K=x==null?void 0:x.dataset)==null?void 0:K.rosterKey,J=(c==="node"||((B=x==null?void 0:x.dataset)==null?void 0:B.position)===t)&&W&&W!==e&&l(e,W);E.over!==(J?x:null)&&((D=(I=E.over)==null?void 0:I.classList)==null||D.remove("nc-roster-over"),E.over=J?x:null,(z=(T=E.over)==null?void 0:T.classList)==null||z.add("nc-roster-over")),E.target=J?W:null},S=()=>{const C=u.current;if(!C){h.current=0;return}const N=C.container;if(N){const E=N.getBoundingClientRect(),O=C.y<E.top+X0?-J0:C.y>E.bottom-X0?J0:0;O&&(N.scrollTop+=O,b(C.x,C.y))}h.current=requestAnimationFrame(S)};y.useEffect(()=>{const C=E=>{E.key==="Escape"&&u.current&&(E.preventDefault(),g(!1))},N=()=>g(!1);return window.addEventListener("keydown",C),window.addEventListener("blur",N),()=>{window.removeEventListener("keydown",C),window.removeEventListener("blur",N),_(),u.current=null}},[e,t,c]);const j=C=>{var x;if(C.pointerType==="mouse"&&C.button!==0)return;C.preventDefault(),C.stopPropagation(),C.currentTarget.focus({preventScroll:!0});const N=c==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",E=C.currentTarget.closest(N),O=C.currentTarget.closest(".nc-side-scroll, .nc-home-scroll, .nc-cell-switcher-list");u.current={pointerId:C.pointerId,handle:C.currentTarget,source:E,container:O,target:null,over:null,x:C.clientX,y:C.clientY},(x=E==null?void 0:E.classList)==null||x.add("nc-roster-dragging");try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}v(!0),h.current=requestAnimationFrame(S)};return a.jsx("button",{type:"button",className:`nc-roster-handle${p?" active":""}`,"aria-label":`${f("reorder")} ${n}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:f("reorder-help"),onClick:C=>{C.preventDefault(),C.stopPropagation()},onDragStart:C=>C.preventDefault(),onKeyDown:C=>{C.key!=="ArrowUp"&&C.key!=="ArrowDown"||(C.preventDefault(),C.stopPropagation(),i(C.key==="ArrowUp"?-1:1))},onPointerDown:j,onPointerMove:C=>{!u.current||C.pointerId!==u.current.pointerId||(C.preventDefault(),C.stopPropagation(),b(C.clientX,C.clientY))},onPointerUp:C=>{!u.current||C.pointerId!==u.current.pointerId||(C.preventDefault(),C.stopPropagation(),g(!0))},onPointerCancel:()=>g(!1),onLostPointerCapture:()=>{u.current&&g(!1)},children:"↕"})}const sC="nc_pins";function to(){return Ar(sC,{fallback:()=>[],parse:t=>Array.isArray(t)?t:void 0})}function $v(t){return yi(sC,t)}function XP(t,e){const n=t.includes(e)?t.filter(s=>s!==e):[...t,e];return{next:n,error:$v(n)}}function Q0(t,e){if(!Array.isArray(t)||!t.includes(e))return{next:Array.isArray(t)?t:[],error:null};const n=t.filter(s=>s!==e);return{next:n,error:$v(n)}}function JP(t,e,n){if(!t.includes(e)||!t.includes(n)||e===n)return t;const s=[...t],i=s.indexOf(e),l=s.indexOf(n);s.splice(i,1);const c=s.indexOf(n);return s.splice(i<l?c+1:c,0,e),$v(s),s}function QP(t,e,n){const s=t.indexOf(e);return[s===-1?1e9:s,-(n||0)]}function ZP(t,e){return t[0]-e[0]||t[1]-e[1]}const Lg="nexuscrew-roster-preferences",eI=new Set(["nc_pins",Jo,Xo,jg]),Pa=()=>{try{window.dispatchEvent(new Event(Lg))}catch{}},tI=(t,e)=>JSON.stringify(t)===JSON.stringify(e),Dp=t=>e=>tI(e,t)?e:t;function zv(){const[t,e]=y.useState(to),[n,s]=y.useState(Ld),[i,l]=y.useState(gc),[c,u]=y.useState(null),[h,p]=y.useState(null);y.useEffect(()=>{if(!h)return;const O=setTimeout(()=>p(null),8e3);return()=>clearTimeout(O)},[h]),y.useEffect(()=>{const O=x=>{x&&x.type==="storage"&&x.key&&!eI.has(x.key)||(e(Dp(to())),l(Dp(gc())),s(Dp(Ld())))};return window.addEventListener("storage",O),window.addEventListener(Lg,O),()=>{window.removeEventListener("storage",O),window.removeEventListener(Lg,O)}},[]);const v=O=>{const x=to(),W=XP(x,O);e(W.next),Xi({reason:W.error?"pin-write-failed":"pin",key:O,before:x,after:W.next,note:W.error?String(W.error.message||W.error):void 0}),Pa()},_=O=>{const x=to(),W=Q0(x,O);return e(W.next),u(W.error?{key:O,message:W.error.message||String(W.error)}:null),Xi({reason:W.error?"unpin-write-failed":"unpin",key:O,before:x,after:W.next}),Pa(),W.error},g=()=>{if(!c)return;const O=Q0(to(),c.key);e(O.next),u(O.error?{...c,message:O.error.message||String(O.error)}:null),Pa()},b=()=>u(null),S=O=>Cg(Ta(n),O),j=(O,x)=>{const W=Ld(),$=Tp(O),J=IP({...W,[$]:{...Cg(Ta(W),O),...x}});s(J),Pa()},C=(O,x)=>t.includes(O)===t.includes(x);function N(O,x,W,$){var M,L;const J=(M=$.find(H=>H.partial))==null?void 0:M.partial;if(J){p({reason:J,position:O,at:Date.now()}),Xi({reason:"reorder-blocked",position:Tp(O),source:x,target:W,note:J});return}p(null);const q=to(),V=q.includes(x),ie=q.includes(W);if(V!==ie)return;if(V){const H=JP(q,x,W);e(H),Xi({reason:"move-pin",source:x,target:W,before:q,after:H}),Pa();return}const K=gc(),B=Tp(O),I=Ta(K),D=((L=$.find(H=>H.key===x))==null?void 0:L.technical)===!0,T=co($,q,D?"technical":"all",Ti(I,O)).map(H=>H.key),z=PP({...K,[B]:Ti(I,O)},B,x,W,T),R={...K,[B]:z[B]};TP(R),Xi({reason:"move",position:B,source:x,target:W,before:Ti(I,O),after:z[B],visible:T}),l(R),Pa()}function E(O,x,W,$){var D;if($.some(T=>T.partial)){N(O,x,x,$);return}const J=to(),q=Ta(gc()),V=((D=$.find(T=>T.key===x))==null?void 0:D.technical)===!0,ie=J.includes(x),K=co($,J,V?"technical":"all",Ti(q,O)).map(T=>T.key).filter(T=>J.includes(T)===ie),B=K.indexOf(x),I=K[B+W];B>=0&&I&&N(O,x,I,$)}return{pins:t,views:Ta(n),orders:Ta(i),togglePin:v,removePin:_,pinError:c,retryPinPersist:g,clearPinError:b,reorderBlocked:h,viewFor:S,updateView:j,canMoveRoster:C,moveRoster:N,stepRoster:E}}const wh="nc_node_order_v1",nI=/^[a-f0-9]{16,64}$/;function $o(t){if(nI.test(String((t==null?void 0:t.instanceId)||"")))return`id:${t.instanceId}`;const e=Array.isArray(t==null?void 0:t.route)?t.route.filter(n=>typeof n=="string"&&n):[];return e.length?`route:${e.map(encodeURIComponent).join("/")}`:typeof(t==null?void 0:t.name)=="string"&&t.name?`name:${encodeURIComponent(t.name)}`:""}function Rg(t=globalThis.localStorage){return Ar(wh,{storage:t,fallback:()=>[],parse:e=>Array.isArray(e)?[...new Set(e.filter(n=>typeof n=="string"&&n&&n.length<=192))].slice(0,128):void 0})}function sI(t,e=globalThis.localStorage){return yi(wh,t,{storage:e}),t}function Z0(t=[],e=[]){const n=new Map(e.map((s,i)=>[s,i]));return t.map((s,i)=>({group:s,index:i})).sort((s,i)=>{const l=n.has($o(s.group))?n.get($o(s.group)):Number.MAX_SAFE_INTEGER,c=n.has($o(i.group))?n.get($o(i.group)):Number.MAX_SAFE_INTEGER;return l-c||s.index-i.index}).map(({group:s})=>s)}function iI(t,e,n,s=[]){if(!e||!n||e===n)return t;const i=s.map($o).filter(Boolean);if(!i.includes(e)||!i.includes(n))return t;const l=[...t,...i.filter(p=>!t.includes(p))],c=l.indexOf(e),u=l.indexOf(n);l.splice(c,1);const h=l.indexOf(n);return l.splice(c<u?h+1:h,0,e),l}const Ag="nexuscrew-node-preferences";function rI(){try{window.dispatchEvent(new Event(Ag))}catch{}}function bh(){const[t,e]=y.useState(Rg);y.useEffect(()=>{const l=()=>e(Rg());return window.addEventListener("storage",l),window.addEventListener(Ag,l),()=>{window.removeEventListener("storage",l),window.removeEventListener(Ag,l)}},[]);const n=l=>Z0(l,t),s=(l,c,u)=>e(h=>{const p=iI(h,l,c,u);return sI(p),rI(),p});return{order:t,groupsFor:n,moveNode:s,stepNode:(l,c,u)=>{const h=Z0(u,t).map($o),p=h.indexOf(l),v=h[p+c];p>=0&&v&&s(l,v,u)},nodeKey:$o}}function iC({pinError:t,onRetry:e,onDismiss:n}){return t?a.jsxs("div",{className:"nc-pin-error",role:"alert",children:[a.jsx("span",{className:"nc-pin-error-text",children:"★ preferenza non salvata"}),a.jsx("button",{type:"button",className:"nc-pin-error-retry",onClick:e,children:"riprova"}),a.jsx("button",{type:"button",className:"nc-pin-error-close",onClick:n,"aria-label":"chiudi avviso",children:"×"})]}):null}function Sh({item:t,pins:e,hostByRoute:n,route:s}){const i=(n||{})[Ls(s)]||{},l=Id({hostCell:i.hostCell??null,threadStatus:i.threadStatus,pins:e,item:t}),c=dj(l);return{state:l,live:!!c,favorite:l==="favorite",filled:l!=="none",titleKey:c||"pin",action:l===l1?"removePin":"addPin"}}async function Fv({view:t,itemKey:e,togglePin:n,removePin:s}){return t.action==="removePin"?(s(e),{ok:!0}):(n(e),{ok:!0})}function oo({item:t,cellName:e,route:n=[],pins:s=[],hostByRoute:i={}}={}){const l=Sh({item:t,pins:s,hostByRoute:i,route:n}),c=(i||{})[Ls(n)]||{};return{pinned:l.favorite,isLive:!!c.hostCell&&c.hostCell===e}}function Hv({isLive:t,pinned:e,canBoot:n,boot:s,alive:i,handlers:l={}}={}){const c=[];return typeof l.onToggleLive=="function"&&c.push({id:"live",kind:"action",on:!!t,labelKey:t?"cell-actions-live-remove":"cell-actions-live-assign",run:l.onToggleLive}),typeof l.onTogglePin=="function"&&c.push({id:"pin",kind:"action",on:!!e,labelKey:e?"cell-actions-unpin":"cell-actions-pin",run:l.onTogglePin}),n&&typeof l.onToggleBoot=="function"&&c.push({id:"boot",kind:"switch",on:!!s,labelKey:"cell-actions-boot",run:()=>l.onToggleBoot(!s)}),i&&typeof l.onWatchLive=="function"&&c.push({id:"watch",kind:"action",on:!1,labelKey:"cell-actions-watch",run:l.onWatchLive}),c}function rC({items:t=[],busy:e=!1,onRun:n}){return a.jsx("div",{className:"nc-cellactions",role:"menu","aria-busy":e||void 0,children:t.map(s=>{const i=s.descKey?f(s.descKey):s.descText;return a.jsxs("button",{type:"button",role:s.kind==="switch"?"menuitemcheckbox":"menuitem","aria-checked":s.kind==="switch"?s.on?"true":"false":void 0,className:`nc-cellactions-voce${s.on?" on":""}`,disabled:e,"data-cellaction":s.id,onClick:l=>{l.stopPropagation(),n?n(s):s.run()},children:[s.kind==="switch"?a.jsx("span",{className:`nc-cellactions-toggle${s.on?" on":""}`,"aria-hidden":"true"}):null,a.jsxs("span",{className:"nc-cellactions-testo",children:[f(s.labelKey),i?a.jsx("small",{className:"nc-cellactions-desc",children:i}):null]})]},s.id)})})}function oC({aperto:t,refGuscio:e,onClose:n}){y.useEffect(()=>{const s=l=>{e.current&&!e.current.contains(l.target)&&n()},i=l=>{l.key==="Escape"&&n()};return document.addEventListener("pointerdown",s),document.addEventListener("keydown",i),()=>{document.removeEventListener("pointerdown",s),document.removeEventListener("keydown",i)}},[t,e,n])}function aC({anchorRect:t,items:e,busy:n,onClose:s}){const i=y.useRef(null);oC({aperto:!0,refGuscio:i,onClose:s});const l=t?{top:Math.min(t.bottom+6,window.innerHeight-8),left:Math.max(8,Math.min(t.right-210,window.innerWidth-218))}:void 0;return a.jsx("div",{className:"nc-cellactions-popover",style:l,ref:i,"data-testid":"cell-actions-popover",children:a.jsx(rC,{items:e,busy:n,onRun:c=>{c.run(),s()}})})}function Uv({cellName:t,items:e,busy:n,onClose:s}){const i=y.useRef(null);return oC({aperto:!0,refGuscio:i,onClose:s}),a.jsx("div",{className:"nc-cellactions-velo","data-testid":"cell-actions-sheet",children:a.jsxs("div",{className:"nc-cellactions-foglio",role:"dialog","aria-modal":"true","aria-label":f("cell-actions-title").replace("{cell}",t||""),ref:i,children:[a.jsxs("div",{className:"nc-cellactions-testa",children:[a.jsx("span",{className:"nc-cellactions-titolo",children:f("cell-actions-title").replace("{cell}",t||"")}),a.jsx("button",{type:"button",className:"nc-cellactions-chiudi",onClick:s,title:f("close"),"aria-label":f("close"),children:"✕"})]}),a.jsx(rC,{items:e,busy:n,onRun:l=>{l.run(),s()}})]})})}function ao(t,e=Math.floor(Date.now()/1e3)){if(!t)return"";const n=e-t;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 lC(t){const e=t||{};return!(e.sessionsAvailable===!1||typeof e.status=="string"&&e.status!=="up")}function Ji(t){return t.status==="up"&&!lC(t)?f("node-sessions-unverified"):t.status==="passive"?f("node-passive"):t.status==="down"?t.downSince?f("tunnel-down-since").replace("{t}",ao(t.downSince)):f("tunnel-down"):t.status==="unreachable"?t.cause===Zk?f("peer-cause-nega"):t.cause===eC?f("peer-cause-rotta"):t.cause===Qk?f("peer-cause-assente"):f("node-unreachable"):t.status==="offline"?t.lastSeen?f("node-offline-seen").replace("{t}",ao(t.lastSeen)):f("node-offline"):t.status==="needs-repair"?f("node-needs-repair"):""}function cC(t,{passive:e=null}={}){return t?t.status==="passive"?e:t.status==="healthy"?"on":"warn":null}function qd(t){return t&&(t.detail||t.status)||""}const oI="restrict,port-forwarding,permitopen=";function aI(t){const e=t&&typeof t.hint=="string"&&t.hint.trim()||"",n=t&&typeof t.authorizedKeys=="string"&&t.authorizedKeys.trim()||"";if(n){const i=e.indexOf(n);return{note:i>=0?e.slice(0,i).replace(/[:\s]+$/,""):e,line:n}}if(!e)return null;const s=e.indexOf(oI);return s<0?{note:e,line:""}:{note:e.slice(0,s).replace(/[:\s]+$/,""),line:e.slice(s).trim()}}function Kd(t,e,n=globalThis.localStorage){if(!(t!=null&&t.outbox)||t.outbox.count<1)return!1;const s=Number(n.getItem(Kx(e))||0);return t.outbox.latest>s}function Wv(t,e={},{autorevole:n=!0}={}){const s=t||{},i=`${s.engine||""}${s.key?`·${s.key}`:""}`,l=[i,s.model&&s.model!==i?s.model:""].filter(Boolean).join(" · ");if(!s.tmux)return{working:!1,subtitle:String(l||f("cell-off")).trim()};const c=e.attivita&&typeof e.attivita=="object"?e.attivita.stato:null;if(c==="lavora"||c==="attesa"){const u=f(c==="attesa"?"cell-permission":"cell-working"),h=String(e.status||"").trim(),p=!h||/^working(?:\.{3}|…)?$/i.test(h);return{working:!0,stato:c,subtitle:c==="lavora"&&!p?`${u} · ${h}`:u}}if(c==="ferma")return{working:!1,stato:"ferma",subtitle:f("cell-stopped")};if(!n)return{working:!1,stato:"ignoto",subtitle:[f("cell-unknown"),l].filter(Boolean).join(" · ")};if(e.working===!0){const u=String(e.status||"").trim();return{working:!0,stato:"ignoto",subtitle:!u||/^working(?:\.{3}|…)?$/i.test(u)?f("cell-unknown"):`${f("cell-unknown")} · ${u}`}}return e.working===!1?{working:!1,stato:"ignoto",subtitle:f("cell-unknown")}:{working:!1,stato:"ignoto",subtitle:String(e.preview||s.preview||f("cell-on")).trim()}}function uC(t,e){return[...new Set([t.engine,t.model,t.key,e.preview,t.preview,e.status].filter(Boolean).map(String))].join(" ")}function dC({sessionsOk:t=!0,fleetStale:e=!1,cellCount:n=0}={}){return t?e&&!n?"fleet":null:"sessions"}function qv(t,e,n,s=globalThis.localStorage,{autorevole:i=!0,fleetStale:l=!1}={}){const c=dC({sessionsOk:i,fleetStale:l,cellCount:Array.isArray(t)?t.length:0});return hC([...(Array.isArray(t)?t:[]).map(u=>{const h=n.get(u.tmuxSession)||{},p=Ic([],u.tmuxSession),v=Wv(u,h,{autorevole:i});return{type:"cell",value:u,key:p,label:u.cell,live:!!u.tmux,fresh:Kd(h,p,s),activity:h.activity||0,working:v.working,stato:v.stato,subtitle:v.subtitle,searchText:uC(u,h)}}),...(Array.isArray(e)?e:[]).map(u=>{const h=Ic([],u.name);return{type:"session",value:u,key:h,label:u.name,live:!0,technical:u.technical===!0,fresh:Kd(u,h,s),activity:u.activity||0,searchText:`${u.preview||""} ${u.cmd||""}`}})],c)}const hC=(t,e)=>e?t.map(n=>({...n,partial:e})):t;function bc(t,e=globalThis.localStorage){const n=t||{},s=Array.isArray(n.route)?n.route:[],i=lC(n),l=new Map((n.sessions||[]).map(h=>[h.name,h])),c=[...(n.cells||[]).map(h=>{const p=l.get(h.tmuxSession)||{},v=Ic(s,h.tmuxSession||h.cell),_=Wv(h,p,{autorevole:i});return{type:"cell",value:h,key:v,label:h.cell,live:!!h.tmux&&!h.preserved,fresh:Kd(p,v,e),activity:p.activity||h.activity||0,working:_.working,stato:_.stato,subtitle:_.subtitle,searchText:uC(h,p)}}),...(n.unmanaged||[]).map(h=>{const p=Ic(s,h.name);return{type:"session",value:h,key:p,label:h.name,live:!0,technical:h.technical===!0,fresh:Kd(h,p,e),activity:h.activity||0,searchText:`${h.preview||""} ${h.cmd||""}`}})],u=dC({sessionsOk:n.sessionsAvailable!==!1,fleetStale:n.fleetState==="stale",cellCount:(n.cells||[]).length});return{route:s,rawItems:hC(c,u)}}const xh=9,Mg=.2,lI=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,Xa=/^[a-f0-9]{16,64}$/,Tg=t=>lI.test(t)&&new Set(t.split("/")).size===t.split("/").length;function jr(t){if(typeof t=="string"&&t){const e=t.indexOf(":");if(e<0)return{session:t};const n=t.slice(0,e),s=t.slice(e+1);return!Tg(n)||!s?null:{session:s,node:n}}if(t&&typeof t=="object"&&typeof t.session=="string"&&t.session){const e=t.ownerId===void 0?void 0:typeof t.ownerId=="string"&&Xa.test(t.ownerId)?t.ownerId:null;return e===null?null:t.node===void 0||t.node===null||t.node===""?{session:t.session,...e?{ownerId:e}:{}}:typeof t.node=="string"&&Tg(t.node)?{session:t.session,node:t.node,...e?{ownerId:e}:{}}:null}return null}function zt(t){const e=jr(t);return e?e.node?`${e.node}:${e.session}`:e.session:""}const fC=9,pC=24,_i=11,mC=t=>{const e=Number(t);return e>=fC&&e<=pC?e:_i};function uo(){return{columns:[]}}function ys(t){return t.columns.flatMap(e=>e.tiles.map(n=>zt(n)))}function cI(t){const e=[],n=Math.max(0,...t.columns.map(s=>s.tiles.length));for(let s=0;s<n;s+=1)for(const i of t.columns)i.tiles[s]&&e.push(zt(i.tiles[s]));return e}const Ii=t=>({columns:t.columns.map(e=>({width:e.width,tiles:e.tiles.map(n=>({...n}))}))});function Dc(t,e,n,s){const i=jr(e);if(!i||ys(t).includes(zt(i))||ys(t).length>=xh)return t;const l=Ii(t),c={session:i.session,height:1,fontSize:_i,...s||{}};if(i.node&&(c.node=i.node),i.ownerId&&(c.ownerId=i.ownerId),n==="end")return l.columns.push({width:1,tiles:[c]}),l;if(n&&typeof n.col=="number"&&typeof n.row=="number"&&l.columns[n.col])return l.columns[n.col].tiles.splice(n.row,0,c),l;if(n&&typeof n.col=="number"){const u=Math.max(0,Math.min(l.columns.length,n.col));return l.columns.splice(u,0,{width:1,tiles:[c]}),l}return l.columns.push({width:1,tiles:[c]}),l}function gC(t,e){const n=zt(e);if(!n||ys(t).includes(n)||ys(t).length>=xh)return t;const s=ys(t).length+1,i=Math.ceil(Math.sqrt(s));if(t.columns.length>=i){let v=0;for(let _=1;_<t.columns.length;_+=1)t.columns[_].tiles.length<t.columns[v].tiles.length&&(v=_);return Dc(t,e,{col:v,row:t.columns[v].tiles.length})}const l=[...cI(t),n],c=new Map(t.columns.flatMap(v=>v.tiles.map(_=>[zt(_),_]))),u=jr(e),h=t.columns.length?t.columns.reduce((v,_)=>v+(Number(_.width)||1),0)/t.columns.length:1,p=Array.from({length:i},(v,_)=>{var g;return{width:((g=t.columns[_])==null?void 0:g.width)||h,tiles:[]}});return l.forEach((v,_)=>{const g=jr(v);if(!g)return;const b=c.get(v)||(v===n?u:{})||{},S={session:g.session,height:b.height||1,fontSize:b.fontSize||_i};g.node&&(S.node=g.node),b.ownerId&&(S.ownerId=b.ownerId),b.unavailable===!0&&(S.unavailable=!0),b.stale===!0&&(S.stale=!0),p[_%i].tiles.push(S)}),{columns:p.filter(v=>v.tiles.length)}}function vC(t,e){const n=jr(e);if(!n)return t;const s=zt(n);if(!s||ys(t).includes(s)||ys(t).length>=xh)return t;const i=e&&typeof e=="object"?e:{},l={height:Math.max(Mg,Number(i.height)||1),fontSize:mC(i.fontSize),...n.ownerId?{ownerId:n.ownerId}:{}};if(!t.columns.length)return Dc(t,n,null,l);let c=0;for(let u=1;u<t.columns.length;u+=1)t.columns[u].tiles.length<t.columns[c].tiles.length&&(c=u);return Dc(t,n,{col:c,row:t.columns[c].tiles.length},l)}function Oc(t,e){const n=zt(e),s=Ii(t);for(const i of s.columns)i.tiles=i.tiles.filter(l=>zt(l)!==n);return s.columns=s.columns.filter(i=>i.tiles.length>0),s}function uI(t,e,n){const s=zt(e);if(!ys(t).includes(s))return t;const i=t.columns.flatMap(l=>l.tiles).find(l=>zt(l)===s);return Dc(Oc(t,s),s,n,{fontSize:i.fontSize,height:i.height,...i.ownerId?{ownerId:i.ownerId}:{},...i.unavailable===!0?{unavailable:!0}:{},...i.stale===!0?{stale:!0}:{}})}function dI(t,e){if(!(e instanceof Map)||e.size===0)return t;let n=!1;const s=Ii(t);for(const i of s.columns)for(const l of i.tiles){const c=e.get(zt(l));if(!c)continue;const u=jr(c);u&&(l.session=u.session,u.node?l.node=u.node:delete l.node,u.ownerId&&(l.ownerId=u.ownerId),n=!0)}return n?Mi(s):t}const _C=120,yC=60,_c=[1/3,.5,2/3],Pg=16;function wC(t,e,n,s){if(!(e>0))return .5;const i=Math.max(0,Math.min(.5,n/e));let l=t/e;if(l=Math.max(i,Math.min(1-i,l)),s){for(const c of _c)if(Math.abs(l-c)*e<=Pg){l=c;break}}return l}function eS(t,e,n,s,i={}){const l=Ii(t),c=l.columns[e],u=l.columns[e+1];if(!c||!u)return t;const h=l.columns.reduce((g,b)=>g+(Number(b.width)||1),0),p=(Number(c.width)||1)+(Number(u.width)||1),v=(Number(n)||0)*(p/(h||1)),_=i.half===!0?.5:wC(s,v,i.minPx??_C,i.snap!==!1);return c.width=p*_,u.width=p*(1-_),l}function tS(t,e,n,s,i,l={}){const c=Ii(t),u=c.columns[e],h=u&&u.tiles[n],p=u&&u.tiles[n+1];if(!h||!p)return t;const v=u.tiles.reduce((S,j)=>S+(Number(j.height)||1),0),_=(Number(h.height)||1)+(Number(p.height)||1),g=(Number(s)||0)*(_/(v||1)),b=l.half===!0?.5:wC(i,g,l.minPx??yC,l.snap!==!1);return h.height=_*b,p.height=_*(1-b),c}function hI(t,e,n){if(!e||!n||e===n)return t;const s=Ii(t);let i=null,l=null;for(const p of s.columns)for(let v=0;v<p.tiles.length;v+=1){const _=zt(p.tiles[v]);_===e&&!i?i={col:p,i:v}:_===n&&!l&&(l={col:p,i:v})}if(!i||!l)return t;const c=i.col.tiles[i.i],u=l.col.tiles[l.i],h=p=>{const v={...p};return delete v.height,v};return i.col.tiles[i.i]={...h(u),height:c.height},l.col.tiles[l.i]={...h(c),height:u.height},s}const Xc=6,Jc=t=>{let{x:e,y:n,w:s,h:i}=t;return s=Math.max(.05,Math.min(1,Number(s)||.3)),i=Math.max(.05,Math.min(1,Number(i)||.3)),e=Math.max(0,Math.min(1-s,Number(e)||0)),n=Math.max(0,Math.min(1-i,Number(n)||0)),{x:e,y:n,w:s,h:i}};function Kv(t,e){for(const n of t.columns)for(let s=0;s<n.tiles.length;s+=1)if(zt(n.tiles[s])===e)return{tile:n.tiles[s]};return null}function fI(t,e,n){const s=Ii(t),i=zt(e);if(mI(s).length>=Xc)return t;const l=Kv(s,i);return!l||l.tile.float?t:(l.tile.float=Jc(n||{}),s)}function pI(t,e){const n=Ii(t),s=Kv(n,zt(e));return!s||!s.tile.float?t:(delete s.tile.float,n)}function nS(t,e,n){const s=Ii(t),i=Kv(s,zt(e));return!i||!i.tile.float?t:(i.tile.float=Jc(n),s)}function mI(t){return t.columns.flatMap(e=>e.tiles).filter(e=>e.float).map(e=>zt(e))}function Vd(t){const e=[],n=[];for(const s of t.columns){const i=[];for(const l of s.tiles)if(l.float){const c={session:l.session,...l.float,fontSize:l.fontSize};l.node&&(c.node=l.node),l.ownerId&&(c.ownerId=l.ownerId),e.push(c)}else i.push(l);i.length&&n.push({width:s.width,tiles:i})}return{grid:{columns:n},floating:e}}const bC=["x","y","w","h","fontSize"],Ig=(t,e)=>Math.abs((Number(t)||0)-(Number(e)||0))<1e-9,SC=(t,e)=>bC.every(n=>Ig(t[n],e[n]));function gI(t,e,n){if(!t)return n;const s={...n};for(const i of bC)Ig(n[i],t[i])&&!Ig(e[i],t[i])&&(s[i]=e[i]);return{...s,...Jc(s)}}function vI(t,e,n){const s=h=>new Map((Array.isArray(h)?h:[]).map(p=>[zt(p),p]).filter(([p])=>p)),i=s(t),l=s(e),c=s(n),u=[];for(const[h,p]of c)!l.has(h)&&i.has(h)&&SC(p,i.get(h))||u.push(l.has(h)?gI(i.get(h),l.get(h),p):p);for(const[h,p]of l)c.has(h)||i.has(h)||u.push(p);return u.slice(0,Xc)}function _I(t,e,n,s,i){const l=g=>Array.isArray(g.floating)?g.floating:[],c=(g,b)=>l(g).some(S=>zt(S)===b)?"float":ys(g.grid).includes(b)?"grid":"",u=(g,b)=>g.columns.flatMap(S=>S.tiles).find(S=>zt(S)===b),h=new Set([...l(n),...l(s),...l(i)].map(g=>zt(g)).filter(Boolean));let p=t,v=Array.isArray(e)?e:[];const _=(g,b)=>l(g).find(S=>zt(S)===b);for(const g of h){const b=c(i,g),S=c(n,g),C=b!==S||b==="float"&&!SC(_(i,g),_(n,g))?b:c(s,g);if(C!=="grid"&&ys(p).includes(g)&&(p=Oc(p,g)),C!=="float"&&(v=v.filter(N=>zt(N)!==g)),C==="grid"&&!ys(p).includes(g)){const N=u(s.grid,g)||u(i.grid,g)||u(n.grid,g);N&&(p=vC(p,N))}if(C==="float"&&!v.some(N=>zt(N)===g)){const N=[s,i,n].map(E=>l(E).find(O=>zt(O)===g)).find(Boolean);N&&(v=[...v,N])}}return{grid:p,floating:v.slice(0,Xc)}}function yI(t,e){const n=s=>{const{grid:i,floating:l}=Vd(s||uo());return JSON.stringify({g:i.columns.map(c=>[c.width,c.tiles.map(u=>[zt(u),u.ownerId||"",u.height,u.fontSize])]),f:l.map(c=>[zt(c),c.ownerId||"",c.x,c.y,c.w,c.h,c.fontSize])})};return n(t)===n(e)}function Dg(t,e){let n=t;for(const s of Array.isArray(e)?e:[]){const i={session:s.session};s.node&&(i.node=s.node),s.ownerId&&(i.ownerId=s.ownerId);const l=zt(i);if(!l||ys(n).includes(l))continue;const c=Ii(n);c.columns.length||c.columns.push({width:1,tiles:[]});let u=0;for(let p=1;p<c.columns.length;p+=1)c.columns[p].tiles.length<c.columns[u].tiles.length&&(u=p);const h={session:i.session,height:1,fontSize:s.fontSize||_i,float:Jc(s)};i.node&&(h.node=i.node),i.ownerId&&(h.ownerId=i.ownerId),c.columns[u].tiles.push(h),n=c}return n}function wI(t,e,n,s){if(!(t.columns[e]&&t.columns[e].tiles[n]))return t;const l=Ii(t),c=l.columns[e].tiles[n],u=Number(c.fontSize)||_i;return c.fontSize=Math.max(fC,Math.min(pC,u+(Number(s)||0))),l}function bI(t,e,n,s){const i=t.columns[e];if(!i||!i.tiles[n])return null;switch(s){case"left":return{col:e};case"right":return{col:e+1};case"top":return{col:e,row:n};case"bottom":return{col:e,row:n+1};default:return null}}function Mi(t){if(!t||!Array.isArray(t.columns))return uo();const e=t.columns.map(l=>({width:Math.max(Mg,Number(l&&l.width)||1),tiles:(Array.isArray(l&&l.tiles)?l.tiles:[]).filter(c=>c&&typeof c.session=="string"&&c.session).filter(c=>c.node==null||typeof c.node=="string"&&Tg(c.node)).filter(c=>c.ownerId==null||typeof c.ownerId=="string"&&Xa.test(c.ownerId)).map(c=>{const u={session:c.session,height:Math.max(Mg,Number(c.height)||1),fontSize:mC(c.fontSize)};return c.node!=null&&(u.node=c.node),c.ownerId!=null&&(u.ownerId=c.ownerId),c.float&&(u.float=Jc(c.float)),u})})).filter(l=>l.tiles.length>0),n=new Set;let s=0,i=0;for(const l of e)l.tiles=l.tiles.filter(c=>{const u=zt(c);return n.has(u)||(c.float?i>=Xc:s>=xh)?!1:(n.add(u),c.float?i+=1:s+=1,!0)});return{columns:e.filter(l=>l.tiles.length>0)}}function SI(t,e){let n=Mi(t);const s=Mi(e),i=new Map;for(const c of s.columns)for(const u of c.tiles)i.set(zt(u),u);for(const c of n.columns)for(let u=0;u<c.tiles.length;u+=1){const h=zt(c.tiles[u]);i.has(h)&&(c.tiles[u]=i.get(h))}const l=new Map;for(const c of s.columns){const u=c.tiles.map(h=>zt(h)).sort().join("|");l.has(u)||l.set(u,c.width)}for(const c of n.columns){const u=c.tiles.map(p=>zt(p)).sort().join("|"),h=l.get(u);h!=null&&(c.width=h)}for(const[c,u]of i)ys(n).includes(c)||(n=vC(n,u));return n}const xC=/^[a-z0-9-]{1,32}$/,xI=/^[A-Za-z0-9._-]{1,32}$/,kI=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,CI=320;function Og(t){return typeof t=="string"&&xC.test(t)}const EI=64;function Ja(t){if(typeof t!="string")return!1;const e=t.trim();return e.length>0&&e.length<=EI&&!/[\x00-\x1f\x7f]/.test(e)}function ho(t){return String(t??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function kC(t){if(typeof t!="string"||!t||t.length>CI||t.startsWith("-")||/[\0-\x20\x7f]/.test(t))return!1;if(!t.includes("@"))return/^[A-Za-z0-9][A-Za-z0-9._:-]{0,254}$/.test(t);const e=t.indexOf("@");return e<=0||e!==t.lastIndexOf("@")?!1:xI.test(t.slice(0,e))&&kI.test(t.slice(e+1))}function sS(t){if(t===""||t===null||t===void 0)return null;const e=String(t).trim();if(!/^[0-9]{1,5}$/.test(e))return;const n=Number(e);return Number.isInteger(n)&&n>=1&&n<=65535?n:void 0}function NI({name:t,ssh:e,sshPort:n,remotePort:s}={}){const i=typeof t=="string"?t.trim():t,l=typeof e=="string"?e.trim():e;if(!Og(i))return{ok:!1,error:"err-node-name"};if(!kC(l))return{ok:!1,error:"err-ssh"};const c=sS(n);if(c===void 0)return{ok:!1,error:"err-ssh-port"};const u=sS(s);if(u===void 0)return{ok:!1,error:"err-node-port"};const h={name:i,ssh:l};return c!==null&&(h.sshPort=c),u!==null&&(h.remotePort=u),{ok:!0,value:h}}function jI(t,e){if(!t||!e||e<t)return null;const n=Math.floor((e-t)/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 Bg(t,e){const n=!!(t&&t.status==="up"),s=!!(t&&t.status==="passive");return{up:n,...s?{passive:!0}:{},label:n?"tunnel-up":s?"node-passive":"tunnel-down",since:n?jI(t.since,e):null}}const LI=new Set(["v","instanceId","port","label","invite"]),RI=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function AI(t){const e=String(t).replace(/-/g,"+").replace(/_/g,"/"),n=e+"=".repeat((4-e.length%4)%4),s=typeof atob=="function"?atob(n):Buffer.from(n,"base64").toString("binary"),i=Uint8Array.from(s,l=>l.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(i):Buffer.from(i).toString("utf8")}function MI(t){let e="";try{const c=new URL(String(t));e=new URLSearchParams(c.hash.replace(/^#/,"")).get("pair")||""}catch{return{ok:!1}}if(!e)return{ok:!1};let n;try{n=JSON.parse(AI(e))}catch{return{ok:!1}}if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1};const s=n.v===1?LI:n.v===2?RI:null;if(!s)return{ok:!1};for(const c of Object.keys(n))if(!s.has(c))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(n.instanceId)))return{ok:!1};const i=Number(n.port);if(!Number.isInteger(i)||i<1||i>65535)return{ok:!1};if(typeof n.label!="string")return{ok:!1};if(typeof n.invite!="string"||!n.invite)return{ok:!1};const l={ok:!0,version:n.v,label:n.label,invite:n.invite,instanceId:n.instanceId,port:i};if(n.v===2){if(n.name!==void 0){if(typeof n.name!="string"||!xC.test(n.name))return{ok:!1};l.name=n.name}if(n.ssh!==void 0){if(!kC(n.ssh))return{ok:!1};l.ssh=String(n.ssh).trim()}if(n.sshPort!==void 0){const c=Number(n.sshPort);if(!Number.isInteger(c)||c<1||c>65535)return{ok:!1};l.sshPort=c}}return l}function TI(t,e,n=new Set){if(!e||!e.ok)return t;const s={...t},i=(l,c)=>{c==null||c===""||n.has(l)||(s[l]=c)};return i("label",e.label),e.version===2&&(i("name",e.name||(e.ssh?ho(e.label):"")),i("ssh",e.ssh),e.sshPort!==void 0&&i("sshPort",String(e.sshPort))),s}const PI=["KIMI_AUTH_ACTION_REQUIRED","CLIENT_INTERACTION_REQUIRED"],II=["kimi-code-consent-yes","kimi-code-config-custom-api-key","kimi-cli-login","client-terminal-dialog"];function DI(t){const e=t&&typeof t=="object"?t.actionRequired:null;if(e&&typeof e=="object"&&PI.includes(e.code)&&II.includes(e.recovery))return{code:e.code,recovery:e.recovery,text:f(`fleet-recovery-${e.recovery}`)};if(t&&typeof t=="object"&&t.vlPromptDegraded===!0)return{code:"VL_PROMPT_DEGRADED",recovery:null,text:f("fleet-vl-prompt-degraded")};if(t&&typeof t=="object"&&t.readinessDegraded===!0){if(t.mcpDegraded&&typeof t.mcpDegraded=="object"){const n=[...Array.isArray(t.mcpDegraded.failed)?t.mcpDegraded.failed:[],...Array.isArray(t.mcpDegraded.pending)?t.mcpDegraded.pending:[]].filter(s=>typeof s=="string"&&s).slice(0,16);if(n.length)return{code:"READINESS_DEGRADED",recovery:null,text:f("fleet-mcp-degraded")+" "+n.join(", ")}}return{code:"READINESS_DEGRADED",recovery:null,text:f("fleet-readiness-degraded")}}return null}function OI(t,e){if(!t)return null;const n=t.status===502&&t.data&&t.data.cause==="upstream-timeout";return t.name==="TimeoutError"||n?{code:"FLEET_ACTION_TIMEOUT",recovery:null,text:f(e==="down"?"fleet-down-slow":"fleet-up-slow")}:t.status===409&&e==="up"&&t.data&&t.data.code==="SESSION_DUPLICATE"?{code:"FLEET_SESSION_DUPLICATE",recovery:null,text:f("fleet-up-duplicate")}:null}async function Vv({token:t,powerCell:e,payload:n,onNotice:s,fleetApi:i}){const l=i||{fleetUp:i5,fleetDown:Vx},{cell:c}=e,u=Array.isArray(e.route)?e.route:[];try{if(n.action==="up"){const h=await l.fleetUp(t,{cell:c,boot:!!n.boot,...n.engine?{engine:n.engine}:{},...n.model!==void 0?{model:n.model}:{},...n.permissionPolicy?{permissionPolicy:n.permissionPolicy}:{}},u),p=DI(h);p&&s(p.text)}else await l.fleetDown(t,{cell:c,boot:!!n.boot},u);return}catch(h){const p=OI(h,n.action);if(p)return s(p.text),{benign:p.code};throw h}}const BI=1e4;function CC(){const[t,e]=y.useState(null),n=y.useRef(null),s=y.useCallback(i=>{typeof i!="string"||!i||(n.current&&clearTimeout(n.current),e(i),n.current=setTimeout(()=>e(null),BI))},[]);return y.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]),{notice:t,showActionNotice:s}}let $g={sessions:[],cells:[],nodeGroups:[],localNodeId:"",localFresh:!1,refreshedAt:0};function $I(){return $g}function zI(t={}){return $g={sessions:Array.isArray(t.sessions)?t.sessions:[],cells:Array.isArray(t.cells)?t.cells:[],nodeGroups:Array.isArray(t.nodeGroups)?t.nodeGroups:[],localNodeId:typeof t.localNodeId=="string"?t.localNodeId:"",localFresh:t.localFresh===!0,refreshedAt:Number.isFinite(t.refreshedAt)?t.refreshedAt:0},$g}const Ia=(t,e=[])=>`${e.length?e.join("/"):"local"}:${t}`;function FI({onPick:t,token:e,onSettings:n,onOpenVlSession:s,hostByRoute:i={},onDesignateCell:l,onClearHostCell:c,panelPort:u=0,nodePanelPorts:h=null}){const[p,v]=zn(),_=Bv(e),[g,b]=y.useState(null),[S,j]=y.useState(null),[C,N]=y.useState(!0),[E,O]=y.useState(""),[x,W]=y.useState(""),[$,J]=y.useState({bind:"127.0.0.1",port:""}),[q,V]=y.useState(""),[ie,K]=y.useState([]),[B,I]=y.useState([]),[D,T]=y.useState(!1),[z,R]=y.useState(null),[M,L]=y.useState({}),[H,A]=y.useState(new Set),[U,Q]=y.useState(null),{notice:ae,showActionNotice:re}=CC(),[je,te]=y.useState(null),[ne,me]=y.useState(null),[we,Fe]=y.useState(!1),[Ae,He]=y.useState(null),[X,ce]=y.useState(null),[Z,ge]=y.useState("preview"),[Y,he]=y.useState(!1),{pins:Ne,orders:Ce,togglePin:Ve,removePin:Ye,pinError:ht,reorderBlocked:ze,retryPinPersist:ve,clearPinError:Oe,viewFor:et,updateView:Ue,canMoveRoster:st,moveRoster:ot,stepRoster:ee}=zv(),P=ue=>i[Ls(ue)]||{},{groupsFor:le,moveNode:_e,stepNode:Me,nodeKey:oe}=bh(),Be=le(_);y.useEffect(()=>{zI({sessions:g||[],cells:ie,nodeGroups:_,localNodeId:q})},[g,ie,_,q]),y.useEffect(()=>{const ue=new Map;for(const Ie of ie)ue.set(Ia(Ie.cell),!!Ie.boot);for(const Ie of _){const Qe=Ie.route||[Ie.name];for(const ct of Ie.cells||[])ue.set(Ia(ct.cell,Qe),!!ct.boot)}L(Ie=>{let Qe=!1;const ct={...Ie};for(const[At,G]of Object.entries(Ie))ue.has(At)&&ue.get(At)===G&&(delete ct[At],Qe=!0);return Qe?ct:Ie})},[ie,_]);function gt(){lc([],e)}y.useEffect(()=>{const Ie=Cc(e,[],Qe=>{if(!Qe)return;const ct=Qe.sessionsError?null:Qe.sessionsJson;ct&&!ct.error?(j(null),b(ct.sessions||[]),N(!0)):ct?(j(ct.error),b([]),N(!1)):(j(String(Qe.sessionsError)),b([]),N(!1));const At=yh({fs:Qe.fs,error:Qe.fleetError});At.kind==="data"?(Ga("local",At.cells),K(At.cells),I(At.capabilities),T(!1),R(null)):At.kind==="stale"?(K(G=>G.length?G:Dv("local")),T(!0),R(null)):(K([]),Ga("local",[]),I([]),T(!1),R(At.reason||""))});return qn("/api/config",e).then(Qe=>Qe.json()).then(Qe=>{W(Qe.version||""),J({bind:Qe.bind||"127.0.0.1",port:Qe.port||""}),V(Xa.test(String(Qe.instanceId||""))?Qe.instanceId:"")}).catch(()=>{}),Ie},[e]);async function Lt(){if(!$.port)return;const ue=`http://${$.bind}:${$.port}/#token=${e}`;try{await navigator.clipboard.writeText(ue)}catch{}}function Nt(ue,Ie,Qe){const ct=Ia(ue,Ie);L(At=>({...At,[ct]:!!Qe}))}function kt(ue,Ie=[]){const Qe=Ia(ue.cell,Ie);return Object.prototype.hasOwnProperty.call(M,Qe)?M[Qe]:!!ue.boot}async function Kt(ue,Ie,Qe=[],ct){const At=Ia(Ie.cell,Qe),G=typeof ct=="boolean"?ct:!kt(Ie,Qe);Nt(Ie.cell,Qe,G),A(fe=>new Set(fe).add(At));try{await Yx(e,{cell:Ie.cell,enabled:G},Qe),Qe.length||K(fe=>fe.map(Te=>Te.cell===Ie.cell?{...Te,boot:G}:Te))}catch(fe){L(Te=>{const Ze={...Te};return delete Ze[At],Ze}),j(String((fe==null?void 0:fe.message)||fe))}finally{A(fe=>{const Te=new Set(fe);return Te.delete(At),Te})}}const ft=(ue,Ie,Qe)=>({onToggleLive:async()=>{const ct=oo({item:ue,cellName:Ie.cell,route:Qe,pins:Ne,hostByRoute:i});Fe(!0);const At=await dh({action:ct.isLive?"remove":"use",cellId:Ie.cell,route:Qe,token:e});Fe(!1),He({messageKey:At.messageKey,ok:At.ok,cell:At.hostCell||Ie.cell})},onTogglePin:()=>Fv({view:Sh({item:ue,pins:Ne,hostByRoute:i,route:Qe}),itemKey:ue.key,togglePin:Ve,removePin:Ye}),onToggleBoot:ct=>Kt(null,Ie,Qe,ct),onWatchLive:()=>{ge("stream"),ce(ue.key)}});async function Vt(ue){if(!U)return;let Ie=null;try{Ie=await Vv({token:e,powerCell:U,payload:ue,onNotice:re})}catch(Qe){throw re(String(Qe&&Qe.message||Qe)),Qe}if(!Ie){const{cell:Qe}=U,ct=Array.isArray(U.route)?U.route:[];ue.action==="up"?Nt(Qe,ct,!!ue.boot):ue.boot&&Nt(Qe,ct,!1)}gt()}const It=y.useMemo(()=>{if(!U)return null;const ue=(Array.isArray(U.route)?U.route:[]).join("/"),Qe=[...ie,..._.flatMap(ct=>(ct.cells||[]).map(At=>({...At,route:ct.route||[ct.name]})))].find(ct=>ct.cell===U.cell&&(Array.isArray(ct.route)?ct.route.join("/"):"")===ue);return Qe?{...U,active:!!Qe.active}:U},[U,ie,_]);async function Xt(ue,Ie=[]){try{await cv(e,ue,Ie)}catch{return}gt()}async function Dt(ue,Ie,Qe=[]){try{await Jx(e,ue,Ie,Qe)}catch{return}gt()}async function Cn(ue){if(!(!(ue!=null&&ue.direct)||je)){te(ue.name);try{await hv(e,ue.name,ue.tunnelStatus==="up"?"down":"up")}catch{}te(null)}}async function nn(ue){if(!(ue!=null&&ue.direct))return;const Ie=window.prompt(f("rename-node-prompt"),ue.label||ue.name);if(Ie===null)return;const Qe=String(Ie).trim();if(!Ja(Qe)){window.alert(f("rename-node-invalid"));return}try{await n1(e,ue.name,Qe)}catch(ct){window.alert(String((ct==null?void 0:ct.message)||ct))}}const on=y.useMemo(()=>new Map((g||[]).map(ue=>[ue.name,ue])),[g]),tn=y.useMemo(()=>new Set(ie.map(ue=>ue.tmuxSession)),[ie]),un=y.useMemo(()=>(g||[]).filter(ue=>!tn.has(ue.name)),[g,tn]),Ht=y.useMemo(()=>qv(ie,un,on,void 0,{autorevole:C,fleetStale:D}),[ie,un,on,C,D]),sn=y.useMemo(()=>{const ue=new Map;for(const Ie of Ht)Ie.type==="cell"&&ue.set(Ie.key,{item:Ie,route:[],nodeLabel:"",sessions:g||[],cells:ie});for(const Ie of Be){const Qe=Array.isArray(Ie.route)?Ie.route:[];if(!Qe.length||Ie.kind==="vl")continue;const{rawItems:ct}=bc(Ie);for(const At of ct)At.type==="cell"&&ue.set(At.key,{item:At,route:Qe,nodeLabel:Ie.label||Ie.name||"",sessions:Ie.sessions||[],cells:Ie.cells||[]})}return ue},[Ht,Be,g,ie]),En=y.useMemo(()=>{if(!X)return null;const ue=sn.get(X);if(!ue)return null;const Ie=ue.item.value,Qe=(ue.sessions||[]).find(ct=>ct.name===Ie.tmuxSession)||{};return{row:{key:ue.item.key,cellName:Ie.cell,subtitle:ue.item.subtitle||"",nodeLabel:ue.nodeLabel,node:ue.route.length?ue.route.join("/"):"",session:Ie.tmuxSession,route:ue.route,panelUrl:Ie.panelUrl||"",telemetry:Qe.telemetry||null,preview:Qe.preview||Ie.preview||"",activity:Qe.activity||Ie.activity||0},cells:ue.cells||[]}},[X,sn]),Qt=et("local"),an=y.useMemo(()=>co(Ht,Ne,Qt.filter,Ti(Ce,"local")).filter(ue=>z0(ue,E)),[Ht,Ne,Qt.filter,E,Ce]),$s=Be.reduce((ue,Ie)=>ue+(Ie.cells||[]).length+(Ie.unmanaged||[]).filter(Qe=>!Qe.technical).length,0),Vn=co(Ht,Ne,"all",Ti(Ce,"local")).length+$s,Ut=Ht.filter(ue=>ue.live).length+Be.reduce((ue,Ie)=>ue+bc(Ie).rawItems.filter(Qe=>Qe.live).length,0),zs=(g||[]).filter(ue=>ue.attached).length+Be.reduce((ue,Ie)=>ue+(Ie.sessions||[]).filter(Qe=>Qe.attached).length,0),ds=Math.min(zs,Ut),Yn=$.port?`${$.bind}:${$.port}`:$.bind;function xt(ue,Ie=null,Qe=Ht){var jt,ke;const ct=Array.isArray(Ie==null?void 0:Ie.route)?Ie.route:[],At=ct.join("/"),G=At||"local",fe=ct.length?Ie==null?void 0:Ie.instanceId:q,Te=(Le,lt)=>t({session:Le,...At?{node:At}:{},...Xa.test(String(fe||""))?{ownerId:fe}:{},...typeof lt=="string"&&lt?{cellName:lt}:{}}),Ze=st;if(ue.type==="cell"){const Le=ue.value,lt=P(ct),Yt=Id({hostCell:lt.hostCell??null,threadStatus:lt.threadStatus,pins:Ne,item:ue}),De=ct.length?((Ie==null?void 0:Ie.sessions)||[]).find(Wt=>Wt.name===Le.tmuxSession):on.get(Le.tmuxSession),Je=jm(Yt,lt.hostLease??null),Pt=Le.degraded?f("cell-degraded"):ue.subtitle||(Le.tmux?f("cell-idle"):f("cell-off")),be=Je?`${Pt} · ${f(Je)}`:Pt,Re=ct.length===0||((Ie==null?void 0:Ie.capabilities)||[]).includes(Le.active?"down":"up"),Ke=ct.length===0?B.includes("boot"):((Ie==null?void 0:Ie.capabilities)||[]).includes("boot"),at=kt(Le,ct),wt=oo({item:ue,cellName:Le.cell,route:ct,pins:Ne,hostByRoute:i}),Gn=!!ne&&ne.itemKey===ue.key,Fs=`${f("cell-actions-open")}: ${Le.cell}`;return a.jsxs("div",{className:"nc-mcard","data-roster-key":ue.key,"data-position":G,children:[Y&&a.jsx(Yi,{position:G,itemKey:ue.key,label:Le.cell,canMove:Ze,onMove:(Wt,Xn)=>ot(G,Wt,Xn,Qe),onStep:Wt=>ee(G,ue.key,Wt,Qe)}),a.jsxs("button",{className:"nc-mcard-main",onClick:()=>Le.tmux&&Te(Le.tmuxSession,Le.cell),title:be,"aria-label":`${Le.cell}, ${be}`,children:[a.jsx("span",{className:`dot ${Le.degraded?"warn":Le.tmux?`on${ue.working?" working":""}`:""}`}),a.jsxs("span",{className:"nc-mcard-text",children:[a.jsxs("span",{className:"nc-mcard-nome",children:[a.jsx("b",{children:Le.cell}),wt.isLive&&a.jsx("span",{className:"nc-m-live",children:"LIVE"})]}),a.jsx("small",{title:ue.subtitle,children:ue.subtitle})]})]}),ue.activity?a.jsx("span",{className:"nc-rel",children:ao(ue.activity)}):null,ue.fresh&&((jt=De==null?void 0:De.outbox)==null?void 0:jt.count)>0&&a.jsx("span",{className:"nc-badge",title:f("new-files-outbox"),children:De.outbox.count}),a.jsx("button",{type:"button",className:`nc-act cellmenu${Gn?" on":""}`,title:Fs,"aria-label":Fs,"aria-haspopup":"menu","aria-expanded":Gn?"true":"false",onClick:()=>me({itemKey:ue.key,item:ue,cell:Le,route:ct,canBoot:Ke}),children:"⋯"}),Re&&a.jsx("button",{className:`nc-act power${Le.tmux?" on":""}${Le.degraded?" warn":""}`,onClick:()=>Q(ct.length?{...Le,boot:at,route:ct,availableEngines:(Ie==null?void 0:Ie.engines)||[]}:{...Le,boot:at}),title:Le.active?f("power-off"):f("power-on"),"aria-label":`${Le.active?f("power-off"):f("power-on")} ${Le.cell}`,children:a.jsx(_t,{name:"power",size:16})})]},ue.key)}const Pe=ue.value;return a.jsxs("div",{className:"nc-mcard","data-roster-key":ue.key,"data-position":G,children:[a.jsx(Yi,{position:G,itemKey:ue.key,label:Pe.name,canMove:Ze,onMove:(Le,lt)=>ot(G,Le,lt,Qe),onStep:Le=>ee(G,ue.key,Le,Qe)}),a.jsxs("button",{className:"nc-mcard-main",onClick:()=>Te(Pe.name),children:[a.jsx("span",{className:Pe.attached?"dot on":"dot"}),a.jsxs("span",{className:"nc-mcard-text",children:[a.jsx("b",{children:Pe.name}),a.jsx("small",{children:Pe.preview?Pe.preview:Pe.cmd?Pe.cmd:f("windows").replace("{n}",String(Pe.windows||0))})]})]}),ue.activity?a.jsx("span",{className:"nc-rel",children:ao(ue.activity)}):null,ue.fresh&&((ke=Pe.outbox)==null?void 0:ke.count)>0&&a.jsx("span",{className:"nc-badge",title:f("new-files-outbox"),children:Pe.outbox.count}),a.jsx("button",{className:`nc-act pin${Ne.includes(ue.key)?" on":""}`,"aria-label":`${f("pin")} ${Pe.name}`,title:f("pin"),onClick:()=>Ve(ue.key),children:Ne.includes(ue.key)?"★":"☆"}),a.jsx("button",{className:`nc-act technical${Pe.technical?" on":""}`,title:Pe.technical?f("mark-normal"):f("mark-technical"),"aria-label":`${Pe.technical?f("mark-normal"):f("mark-technical")} ${Pe.name}`,onClick:()=>Dt(Pe.name,!Pe.technical,ct),children:"T"}),a.jsx("button",{className:"nc-menu",title:f("terminate"),"aria-label":`${f("terminate")} ${Pe.name}`,onClick:()=>{window.confirm(f("terminate-confirm").replace("{name}",Pe.name))&&Xt(Pe.name,ct)},children:"⋯"})]},ue.key)}return a.jsxs("div",{className:"nc-home",children:[a.jsxs("header",{className:"nc-home-head",children:[a.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",a.jsx("span",{className:"nc-cursor"})]}),a.jsxs("div",{className:"nc-home-sub",children:[f("fleet-tmux")," · ",Ut," ",f("sessions"),ds>0&&` · ${ds} attached`]}),a.jsxs("span",{className:"nc-head-actions",children:[a.jsx("button",{className:`nc-refresh${Y?" on":""}`,onClick:()=>he(ue=>!ue),"aria-pressed":Y,title:f("reorder-help"),"aria-label":f("reorder"),children:"↕"}),a.jsx("button",{className:"nc-refresh",onClick:()=>n("nodes",!1),title:f("settings"),children:a.jsx(_t,{name:"gear",size:18})}),a.jsx("button",{className:"nc-refresh",onClick:gt,title:f("refresh"),children:a.jsx(_t,{name:"refresh",size:18})})]})]}),a.jsxs("main",{className:"nc-home-scroll",children:[a.jsx(HI,{view:Va({liveHost:i[Ls([])],cells:ie}),notice:Ae}),a.jsx(iC,{pinError:ht,onRetry:ve,onDismiss:Oe}),Vn>8&&a.jsx("input",{className:"nc-filter",type:"search",placeholder:f("filter-placeholder"),"aria-label":f("filter-placeholder"),value:E,onChange:ue=>O(ue.target.value)}),S&&a.jsx("div",{className:"nc-err",children:S}),ae&&a.jsx("div",{className:"nc-notice",role:"status",children:ae}),D&&a.jsx("div",{className:"nc-set-hint nc-fleet-stale",role:"status",children:f("fleet-stale")}),ze&&a.jsxs("div",{className:"nc-set-hint nc-reorder-blocked",role:"status",children:[f("reorder-blocked")," (",ze.reason,")"]}),z!==null&&a.jsxs("div",{className:"nc-set-hint nc-fleet-off",role:"status",children:[f("fleet-off"),z?` (${z})`:""]}),a.jsxs("section",{className:"nc-group","data-position":"local",children:[a.jsx(Op,{label:f("position-local"),count:an.length,state:Qt,dotClass:"on",onToggle:()=>Ue("local",{open:!Qt.open}),onFilter:ue=>Ue("local",{filter:ue})}),Qt.open&&an.map(ue=>xt(ue,null,Ht)),Qt.open&&g===null&&a.jsx("div",{className:"nc-empty",children:f("loading-fleet")}),Qt.open&&g!==null&&an.length===0&&!S&&a.jsx("div",{className:"nc-empty",children:E?f("no-match").replace("{q}",E):f("no-sessions-short")})]}),Be.map(ue=>{const Ie=cC(ue.health,{passive:"warn"}),Qe=ue.fleetState==="stale"?f("fleet-stale"):ue.fleetState==="disabled"?f("fleet-off"):"",ct=ue.fleetState==="stale"?"warn":Ie||(ue.status==="up"?"on":ue.status==="passive"?"":"warn"),At=[ue.health?qd(ue.health):Ji(ue),Qe].filter(Boolean).join(" · "),fe=(ue.route&&ue.route.length?ue.route:[ue.name]).join("/"),Te=et(fe);if(ue.kind==="vl")return a.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":fe,"data-node-order-key":oe(ue),children:[a.jsx(Op,{label:ue.label||ue.name,count:ue.sessions.length,state:Te,dotClass:ct,dotTitle:At,detail:Ji(ue),onToggle:()=>Ue(fe,{open:!Te.open}),onFilter:Le=>Ue(fe,{filter:Le})}),ue.status==="up"&&Te.open&&ue.sessions.map(Le=>a.jsx("div",{className:"nc-mcard nc-vl-session-row",children:a.jsxs("button",{className:"nc-mcard-main",onClick:()=>s&&s(ue.peer),"aria-label":`${ue.label||ue.name}: ${Le.name}`,children:[a.jsx("span",{className:"dot on"}),a.jsxs("span",{className:"nc-mcard-text",children:[a.jsx("b",{children:Le.name}),a.jsx("small",{children:f("vl-events-title")})]})]})},Le.key)),ue.status==="up"&&Te.open&&ue.sessions.length===0&&a.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]},`nodo-vl-${fe}-${ue.name}`);const{rawItems:Ze}=bc(ue),Pe=co(Ze,Ne,Te.filter,Ti(Ce,fe)).filter(Le=>z0(Le,E)),jt=ue.direct&&ue.health&&ue.health.managed!==!1?a.jsx("button",{type:"button",className:`nc-act power${ue.tunnelStatus==="up"?" on":""}`,disabled:je===ue.name,title:ue.tunnelStatus==="up"?f("power-off"):f("power-on"),"aria-label":`${ue.tunnelStatus==="up"?f("power-off"):f("power-on")} ${ue.label||ue.name}`,onClick:()=>Cn(ue),children:a.jsx(_t,{name:"power",size:15})}):null,ke=a.jsxs("span",{className:"nc-node-actions",children:[a.jsx(Yi,{scope:"node",position:"nodes",itemKey:oe(ue),label:ue.label||ue.name,onMove:(Le,lt)=>_e(Le,lt,_),onStep:Le=>Me(oe(ue),Le,_)}),ue.direct&&a.jsx("button",{type:"button",className:"nc-node-rename",title:f("rename-node"),"aria-label":`${f("rename-node")} ${ue.label||ue.name}`,onClick:()=>nn(ue),children:"✎"}),jt]});return a.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":fe,"data-node-order-key":oe(ue),children:[a.jsx(Op,{label:ue.label||ue.name,count:Pe.length,state:Te,dotClass:ct,dotTitle:At,detail:ue.status==="up"?[Ji(ue),Qe].filter(Boolean).join(" · "):ue.health&&qd(ue.health)||Ji(ue),onToggle:()=>Ue(fe,{open:!Te.open}),onFilter:Le=>Ue(fe,{filter:Le}),onRename:ue.direct?()=>nn(ue):null,action:ke}),ue.status==="up"&&Te.open&&Pe.map(Le=>xt(Le,ue,Ze)),ue.status==="up"&&Te.open&&Pe.length===0&&a.jsx("div",{className:"nc-empty",children:E?f("no-match").replace("{q}",E):f("no-sessions-short")})]},`nodo-${fe}`)}),a.jsxs("footer",{className:"nc-home-foot",onClick:Lt,title:f("copy-url"),children:[a.jsxs("span",{className:"nc-home-meta",children:[x&&a.jsxs("span",{className:"nc-home-version",children:["v",x]}),a.jsxs("span",{className:"nc-home-endpoint",children:[Yn," · ",f("ssh-only")]})]}),a.jsx("span",{className:"nc-lang",onClick:ue=>ue.stopPropagation(),children:a1.map((ue,Ie)=>a.jsxs("span",{children:[Ie>0&&" · ",a.jsx("button",{className:`nc-lang-btn${p===ue?" on":""}`,onClick:()=>v(ue),title:ue,children:ue.toUpperCase()})]},ue))})]})]}),It&&a.jsx(Wd,{cell:It,token:e,route:Array.isArray(It.route)?It.route:[],onConfirm:Vt,onClose:()=>Q(null)}),En&&a.jsx(Wk,{row:En.row,token:e,initialSource:Z,panelPort:Tc(En.row.route||[],h,u),liveHost:Va({liveHost:i[Ls(En.row.route||[])],cells:En.cells}),onClose:()=>{ce(null),ge("preview")}}),ne&&(()=>{const{item:ue,cell:Ie,route:Qe=[],canBoot:ct}=ne,At=oo({item:ue,cellName:Ie.cell,route:Qe,pins:Ne,hostByRoute:i}),G=Hv({...At,canBoot:ct,boot:kt(Ie,Qe),alive:!!Ie.tmux,handlers:ft(ue,Ie,Qe)});return a.jsx(Uv,{cellName:Ie.cell,items:G,busy:we||H.has(Ia(Ie.cell,Qe)),onClose:()=>me(null)})})()]})}function HI({view:t,notice:e}){const n=!!(t&&t.cell),s=n?f("live-host-indicator").replace("{cell}",t.cell).replace("{mode}",f(t.mode?`live-host-mode-${t.mode}`:"live-host-mode-unknown")).replace("{state}",f(`live-host-state-${t.state||"none"}`)):f("live-host-indicator-none");return a.jsxs("div",{className:"nc-m-live-strip","data-state":t&&t.state?t.state:"none",title:e?`${s} · ${f(e.messageKey)}`:s,children:[a.jsx("span",{className:`nc-m-live-dot ${mv(t||{})}`,"aria-hidden":"true"}),a.jsx("span",{className:"nc-m-live-testo",children:n?t.cell:s}),a.jsx(g1,{view:t}),e&&a.jsx("span",{className:`nc-m-live-notice${e.ok?" ok":" ko"}`,role:"status",children:f(e.messageKey).replace("{cell}",e.cell||t.cell||"")})]})}function Op({label:t,count:e,state:n,dotClass:s="",dotTitle:i="",detail:l="",onToggle:c,onFilter:u,onRename:h=null,action:p=null}){return a.jsxs("div",{className:"nc-mobile-position-head",onContextMenu:h?v=>{v.preventDefault(),h()}:void 0,children:[a.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:c,"aria-expanded":n.open,"aria-label":`${t} · ${f("node-sessions").replace("{n}",String(e))}`,children:[a.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:n.open?"⌄":"›"}),a.jsx("span",{className:`dot ${s}`,title:i}),a.jsxs("span",{className:"nc-mobile-position-copy",children:[a.jsx("b",{children:t}),a.jsx("small",{children:l||f("node-sessions").replace("{n}",String(e))})]})]}),a.jsxs("select",{className:"nc-mobile-position-filter",value:n.filter,"aria-label":`${t} · ${f("filter-placeholder")}`,title:f(`view-${n.filter}`),onChange:v=>u(v.target.value),children:[a.jsx("option",{value:"all",children:f("view-all")}),a.jsx("option",{value:"pinned",children:f("view-pinned")}),a.jsx("option",{value:"active",children:f("view-active")}),a.jsx("option",{value:"off",children:f("view-off")}),a.jsx("option",{value:"technical",children:f("view-technical")})]}),p]})}const iS="",cn="\x1B",UI=[{label:"↑",seq:cn+"[A"},{label:"↓",seq:cn+"[B"},{label:"PGUP",seq:cn+"[5~"},{label:"PGDN",seq:cn+"[6~"}],WI=new Set([cn+"[A",cn+"[B",cn+"[C",cn+"[D",cn+"[5~",cn+"[6~"]),qI=350,KI=55;function VI({send:t,action:e,ctrlArmed:n=!1,onCtrl:s,altArmed:i=!1,onAlt:l,onAltConsume:c,onKeyboard:u,selectionMode:h=!1,onSelectionMode:p,onCellSwitcher:v,cellSwitcherOpen:_=!1,keepKeyboardClosed:g=!0,showEnter:b=!0,keybarLayout:S="full",onKeyboardKeep:j}){const[C,N]=y.useState(!1),[E,O]=y.useState(!1),[x,W]=y.useState(!1),$=S==="compact"&&!x,J=y.useRef({delay:null,interval:null}),q=y.useRef(()=>{}),V=()=>{const A=J.current;A.delay!==null&&clearTimeout(A.delay),A.interval!==null&&clearInterval(A.interval),A.delay=null,A.interval=null};q.current=V,y.useEffect(()=>{const A=()=>{document.visibilityState==="hidden"&&q.current()},U=()=>q.current();return window.addEventListener("blur",U),document.addEventListener("visibilitychange",A),()=>{window.removeEventListener("blur",U),document.removeEventListener("visibilitychange",A),q.current()}},[]),y.useEffect(()=>{S!=="compact"&&W(!1)},[S]);const ie=A=>{i?(t(cn+A),c&&c()):t(A)},K=(A,{keepOpen:U}={})=>{g&&!U&&bg(),U&&j&&j(),A()},B=(A,U={})=>({onPointerDown:Q=>{Q.preventDefault(),K(A,U)},onClick:Q=>{Q.detail===0&&K(A,U)}}),I=(A,U={})=>({onPointerDown:Q=>{Q.preventDefault(),V(),K(A,U),!i&&(J.current.delay=setTimeout(()=>{J.current.delay=null,A(),J.current.interval=setInterval(A,KI)},qI))},onPointerUp:V,onPointerLeave:V,onPointerCancel:V,onLostPointerCapture:V,onTouchCancel:V,onClick:Q=>{Q.detail===0&&K(A,U)}}),D=(A,U,Q)=>a.jsx("button",{type:"button",...WI.has(U)&&!Q?I(()=>ie(U)):B(()=>{ie(U),Q&&Q()}),children:A},A),T=(A,U)=>a.jsx("button",{type:"button",...B(()=>{e(U),O(!1)}),children:A},A),z=v?a.jsx("button",{type:"button","aria-label":f("fleet-cells"),title:f("fleet-cells"),"aria-expanded":_,...B(v),children:"◫"},"cells"):a.jsx("button",{type:"button",...B(()=>{u&&u()}),children:"⌨"},"kbd"),R=b&&a.jsx("button",{type:"button",className:"nc-enter-key","aria-label":"ENTER",title:"ENTER",...B(()=>ie("\r")),children:a.jsx(_t,{name:"enter",size:24})}),M=E&&a.jsxs("div",{className:"nc-keymenu",children:[T("←WIN","prev-window"),T("WIN→","next-window"),T("⬅PANE","pane-left"),T("PANE➡","pane-right"),D("SCROLL",iS+"[",()=>{N(!0),O(!1)}),a.jsx("button",{type:"button",className:h?"armed":"",...B(()=>{p==null||p(!h),O(!1)}),children:"SELECT"}),D("⌃C","",()=>O(!1)),D("DETACH",iS+"d",()=>O(!1))]});if(C)return a.jsxs("div",{className:"nc-keybar copy",children:[a.jsx("span",{className:"tag",children:"copy-mode"}),UI.map(A=>D(A.label,A.seq)),D("ESCI (q)","q",()=>N(!1))]});if($)return a.jsxs("div",{className:"nc-keybar termux",children:[M,a.jsxs("div",{className:`nc-keygrid compact${b?"":" no-enter"}`,children:[a.jsx("div",{className:"nc-keyrows",children:a.jsxs("div",{className:"row",children:[a.jsx("button",{type:"button","aria-label":f("keybar-expand"),title:f("expand"),...B(()=>W(!0)),children:a.jsx(_t,{name:"chevronUp",size:20})},"expand"),z,a.jsx("button",{type:"button",className:E?"armed":"",...B(()=>O(A=>!A)),children:"☰"},"menu"),D("↑",cn+"[A"),D("↓",cn+"[B"),D("←",cn+"[D"),D("→",cn+"[C"),D("PGUP",cn+"[5~"),D("PGDN",cn+"[6~")]})}),R]})]});const L=S==="compact"&&x,H=L&&a.jsx("button",{type:"button",className:"nc-retract-key","aria-label":f("keybar-retract"),title:f("retract"),...B(()=>W(!1)),children:a.jsx(_t,{name:"chevronDown",size:20})});return a.jsxs("div",{className:`nc-keybar termux${L?" expanded":""}`,children:[M,a.jsxs("div",{className:`nc-keygrid${b?"":" no-enter"}${L?" expanded":""}`,children:[H,a.jsxs("div",{className:"nc-keyrows",children:[a.jsxs("div",{className:"row",children:[D("ESC",cn),a.jsx("button",{type:"button",className:E?"armed":"",...B(()=>O(A=>!A)),children:"☰"},"menu"),D("/","/"),D("—","-"),D("HOME",cn+"[H"),D("↑",cn+"[A"),D("END",cn+"[F"),D("PGUP",cn+"[5~")]}),a.jsxs("div",{className:"row",children:[D("⇥"," "),z,a.jsx("button",{type:"button",className:n?"armed":"",...B(()=>{s&&s()},{keepOpen:!0}),children:"CTRL"},"ctrl"),a.jsx("button",{type:"button",className:i?"armed":"",...B(()=>{l&&l()},{keepOpen:!0}),children:"ALT"},"alt"),D("←",cn+"[D"),D("↓",cn+"[B"),D("→",cn+"[C"),D("PGDN",cn+"[6~")]})]}),R]})]})}const EC=/^(\d+-)?(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})_/;function YI(t){return String(t||"").replace(EC,"$1")}const GI=/^\d{4}-\d{2}-\d{2}_/;function Qa(t){const e=String(t||"");let n=YI(e);return n=n.replace(GI,""),n||e}function XI(t){const e=EC.exec(String(t||""));if(!e)return null;const[n,s,i,l,c]=[Number(e[2]),Number(e[3]),Number(e[4]),Number(e[5]),Number(e[6])],u=new Date(n,s-1,i,l,c);return u.getFullYear()!==n||u.getMonth()!==s-1||u.getDate()!==i||u.getHours()!==l||u.getMinutes()!==c?null:u}function Bc(t,e){const n=XI(t);if(n)return n;const s=Number(e);return Number.isFinite(s)&&s>0?new Date(s):new Date(0)}function Sc(t){const e=Number(t)||0;return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.max(1,Math.round(e/1024))} KB`:`${e} B`}function Yd(t){return String(t).padStart(2,"0")}function NC(t){return`${Yd(t.getHours())}:${Yd(t.getMinutes())}`}function jC(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function Wo(t){const e=Qa(t),n=e.lastIndexOf(".");return n<=0||n===e.length-1?"":e.slice(n+1).toUpperCase().slice(0,4)}function LC(t,e,n){const s=NC(t);return jC(t,e)?s:`${new Intl.DateTimeFormat(n||"en",{day:"numeric",month:"short"}).format(t)} ${s}`}function JI(t,e,n,s=""){const i=new Intl.DateTimeFormat(n||"en",{day:"numeric",month:"long"}).format(t);return jC(t,e)&&s?`${s} · ${i}`:i}function RC(t,e){return`${new Intl.DateTimeFormat(e||"en",{day:"numeric",month:"long",year:"numeric"}).format(t)}, ${NC(t)}`}function QI(t){return`${t.getFullYear()}-${Yd(t.getMonth()+1)}-${Yd(t.getDate())}`}const ZI=new Set(["PNG","JPG","JPEG","GIF","WEBP","SVG","PDF","TXT","MD","JSON"]);function eD(t){return ZI.has(Wo(t))}const tD=new Set(["PNG","JPG","JPEG","GIF","WEBP","PDF","TXT","MD","JSON"]);function AC(t){return tD.has(Wo(t))}const nD=new Set(["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","application/pdf","text/plain","text/markdown","application/json"]);function sD(t){const e=String(t||"").split(";")[0].trim().toLowerCase();return nD.has(e)}const iD=new Set(["PNG","JPG","JPEG","GIF","WEBP","SVG","BMP","ICO","AVIF","HEIC"]),rD=new Set(["TXT","MD","JSON","PDF","CSV","LOG","HTML","HTM","XML","YML","YAML","DOC","DOCX","ODT","RTF","XLS","XLSX","PPT","PPTX"]);function oD(t){const e=Wo(t);return iD.has(e)?"image":rD.has(e)?"document":"other"}function MC(t){const e=new Map;for(const n of t||[]){const s=Qa(n&&n.name);e.set(s,(e.get(s)||0)+1)}return e}function TC(t,e,n,s=""){const i=(t||[]).map(u=>({...u,when:Bc(u.name,u.mtime)}));i.sort((u,h)=>h.when-u.when||String(u.name).localeCompare(String(h.name)));const l=[],c=new Map;for(const u of i){const h=QI(u.when);let p=c.get(h);p||(p={key:h,when:u.when,label:JI(u.when,e,n,s),files:[]},c.set(h,p),l.push(p)),p.files.push(u)}return l}function aD({file:t,box:e,session:n,previewable:s=!1,notice:i="",busy:l=!1,onClose:c,onActionStart:u,onDownload:h,onPreview:p,onDelete:v}){const[_,g]=y.useState(!1),[b,S]=y.useState(!1),j=t&&t.name;y.useEffect(()=>{g(!1),S(!1)},[j]),y.useEffect(()=>{const x=W=>{W.key==="Escape"&&c()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[c]);async function C(){u&&u(),S(await Mc(t?t.name:""))}const N=Qa(j),E=Bc(j,t?t.mtime:0),O=Vo();return a.jsx("div",{className:"nc-filesheet-velo","data-testid":"file-actions-sheet",onClick:c,children:a.jsxs("div",{className:"nc-filesheet",role:"dialog","aria-modal":"true","aria-label":f("files-sheet-title"),onClick:x=>x.stopPropagation(),children:[a.jsxs("div",{className:"nc-filesheet-testa",children:[a.jsx("span",{className:"nc-filesheet-titolo",children:f("files-sheet-title")}),a.jsx("button",{type:"button",className:"nc-filesheet-chiudi",onClick:c,title:f("close"),"aria-label":f("close"),children:a.jsx(_t,{name:"x",size:18})})]}),a.jsxs("div",{className:"nc-filesheet-file",children:[a.jsx("span",{className:"nc-filesheet-nome",children:N}),a.jsxs("div",{className:"nc-filesheet-originale",children:[a.jsx("span",{className:"nc-filesheet-label",children:f("files-original-name")}),a.jsx("code",{className:"nc-filesheet-mono",children:j})]}),a.jsxs("small",{className:"nc-filesheet-meta",children:[RC(E,O)," · ",Sc(t?t.size:0)," · ",e==="outbox"?"Outbox":"Inbox"," · ",n]})]}),i&&a.jsx("div",{className:"nc-filesheet-notice",role:"status",children:i}),_?a.jsxs("div",{className:"nc-filesheet-conferma","data-testid":"file-delete-confirm",children:[a.jsx("b",{className:"nc-filesheet-conferma-titolo",children:f("files-delete-confirm").replace("{name}",N)}),a.jsx("small",{className:"nc-filesheet-conferma-aiuto",children:f("files-delete-confirm-help")}),a.jsxs("div",{className:"nc-filesheet-conferma-azioni",children:[a.jsx("button",{type:"button",onClick:()=>g(!1),disabled:l,children:f("cancel")}),a.jsx("button",{type:"button",className:"danger",disabled:l,"data-fileaction":"delete-confirm",onClick:()=>v(t),children:f("delete")})]})]}):a.jsxs("div",{className:"nc-filesheet-azioni",role:"menu",children:[s&&a.jsxs("button",{type:"button",role:"menuitem",disabled:l,"data-fileaction":"preview",onClick:()=>{u&&u(),p(t)},children:[a.jsx(_t,{name:"eye",size:20}),a.jsx("span",{children:f("files-preview")})]}),a.jsxs("button",{type:"button",role:"menuitem",disabled:l,"data-fileaction":"download",onClick:()=>{u&&u(),h(t)},children:[a.jsx(_t,{name:"download",size:20}),a.jsx("span",{children:f("files-download-action")})]}),a.jsxs("button",{type:"button",role:"menuitem",disabled:l,"data-fileaction":"copy",onClick:C,"aria-live":"polite",children:[a.jsx(_t,{name:"copy",size:20}),a.jsx("span",{children:f(b?"files-copied-name":"files-copy-name")})]}),a.jsxs("button",{type:"button",role:"menuitem",className:"danger",disabled:l,"data-fileaction":"delete",onClick:()=>g(!0),children:[a.jsx(_t,{name:"trash",size:20}),a.jsx("span",{children:f("files-delete-ellipsis")})]})]})]})})}const lD=new Set(["TXT","MD","JSON"]),cD=new Set(["PNG","JPG","JPEG","GIF","WEBP","SVG","BMP","ICO","AVIF"]),uD=8e3;function dD({session:t,node:e,token:n,box:s,onBox:i,counts:l,rows:c,visible:u,busy:h,notice:p="",error:v="",onNotice:_,sheetFile:g,onSheet:b,onClose:S,onRefresh:j,fetchBlob:C,onDownload:N,onPreview:E,onDelete:O,query:x,onQuery:W}){const[$,J]=y.useState("all"),[q,V]=y.useState(""),[ie,K]=y.useState(!1),[B,I]=y.useState(!1),[D,T]=y.useState(null),z=y.useRef(null),R=y.useRef(null),M=y.useRef(null),L=Vo(),H=new Date,A=$==="all"?u:u.filter(X=>oD(X.name)===$),U=TC(A,H,L,f("files-today")),Q=MC(A),ae=U.flatMap(X=>X.files),re=q?c.find(X=>X.name===q):null,je=re?re.name:"";y.useEffect(()=>{q&&!c.some(X=>X.name===q)&&V("")},[c,q]),y.useEffect(()=>{K(!1),I(!1)},[je]),y.useEffect(()=>{if(T(null),!je||!eD(je))return;let X=!0,ce="";return(async()=>{const Z=await C(je);if(!X||!Z)return;const ge=Wo(je);if(lD.has(ge)){const Y=await Z.text();X&&T({kind:"text",text:Y.slice(0,uD)})}else cD.has(ge)&&(ce=URL.createObjectURL(Z),X&&T({kind:"img",url:ce}))})(),()=>{X=!1,ce&&URL.revokeObjectURL(ce)}},[je,s,t,e]),y.useEffect(()=>{if(!q)return;const X=R.current?R.current.querySelector('[data-sel="1"]'):null;X&&typeof X.scrollIntoView=="function"&&X.scrollIntoView({block:"nearest"})},[q]),y.useEffect(()=>{const X=ce=>{if(g)return;const Z=ce.target;if(!(Z&&(Z.tagName==="INPUT"||Z.tagName==="TEXTAREA"||Z.tagName==="SELECT"||Z.tagName==="BUTTON"||Z.tagName==="A"||Z.isContentEditable))){if(ce.key==="/"){ce.preventDefault(),z.current&&z.current.focus();return}if(ce.key==="ArrowDown"||ce.key==="ArrowUp"){if(ce.preventDefault(),!ae.length)return;const ge=ae.map(Ne=>Ne.name),Y=q?ge.indexOf(q):-1,he=Y<0?ce.key==="ArrowDown"?0:ge.length-1:Math.min(ge.length-1,Math.max(0,Y+(ce.key==="ArrowDown"?1:-1)));V(ge[he]);return}ce.key==="Enter"&&re&&(ce.preventDefault(),b(re.name))}};return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)});async function te(X){const ce=Array.from(X.target.files||[]);if(X.target.value="",!ce.length)return;const{errors:Z}=await Ud({files:ce,token:n,session:t,node:e,paste:!1});if(Z&&Z.length){const ge=Z[0]||{};_(f("files-upload-failed").replace("{e}",String(ge.message||ge.error||"")))}j()}async function ne(){I(await Mc(re?re.name:""))}const me=re?Qa(re.name):"",we=re?Bc(re.name,re.mtime):null,Fe=x.trim()||f($==="image"?"files-filter-images":"files-filter-docs"),Ae=A.reduce((X,ce)=>X+(Number(ce.size)||0),0),He=e?`${e}:${t}`:t;return a.jsxs(a.Fragment,{children:[a.jsxs("header",{className:"nc-filesd-head",children:[a.jsxs("div",{className:"nc-filesd-titolo",children:[a.jsx("b",{children:f("files-of").replace("{session}",He)}),a.jsxs("span",{className:"nc-filesd-percorso",children:[e?`${e} · `:"","~/NexusFiles/",t,"/",s]})]}),a.jsxs("button",{type:"button",className:"nc-filesd-upload",onClick:()=>M.current&&M.current.click(),children:[a.jsx(_t,{name:"upload",size:16}),a.jsx("span",{children:f("files-upload")})]}),a.jsx("input",{ref:M,type:"file",multiple:!0,className:"nc-filesd-upload-input",tabIndex:-1,"aria-hidden":"true",onChange:te}),a.jsx("button",{type:"button",className:"nc-ntf-x",onClick:S,title:f("close"),"aria-label":f("close"),children:a.jsx(_t,{name:"x",size:16})})]}),a.jsxs("div",{className:"nc-filesd-bar",children:[a.jsxs("nav",{className:"nc-filesd-seg",children:[a.jsx("button",{type:"button",className:s==="outbox"?"on":"",onClick:()=>i("outbox"),children:f("files-outbox").replace("{n}",String(l.outbox))}),a.jsx("button",{type:"button",className:s==="inbox"?"on":"",onClick:()=>i("inbox"),children:f("files-inbox").replace("{n}",String(l.inbox))})]}),a.jsxs("div",{className:"nc-filesd-search",children:[a.jsx(_t,{name:"search",size:16}),a.jsx("input",{ref:z,type:"search",value:x,onChange:X=>W(X.target.value),placeholder:f("files-search-ph"),"aria-label":f("files-search"),enterKeyHint:"search","data-testid":"files-search-input"}),a.jsx("kbd",{className:"nc-filesd-kbd","aria-hidden":"true",children:"/"})]}),a.jsxs("div",{className:"nc-filesd-filtri",children:[a.jsx("button",{type:"button",className:$==="all"?"on":"","aria-pressed":$==="all",onClick:()=>J("all"),children:f("files-filter-all")}),a.jsx("button",{type:"button",className:$==="document"?"on":"","aria-pressed":$==="document",onClick:()=>J("document"),children:f("files-filter-docs")}),a.jsx("button",{type:"button",className:$==="image"?"on":"","aria-pressed":$==="image",onClick:()=>J("image"),children:f("files-filter-images")})]})]}),a.jsxs("div",{className:"nc-filesd-main",children:[a.jsxs("div",{className:"nc-filesd-list",ref:R,children:[U.map(X=>a.jsxs("section",{className:"nc-filesd-daygroup",children:[a.jsx("h3",{className:"nc-filesd-day",children:X.label}),a.jsx("div",{className:"nc-filesd-rows",role:"grid","aria-label":X.label,children:X.files.map(ce=>{const Z=Qa(ce.name),ge=Q.get(Z)||1,Y=ce.name===q;return a.jsxs("div",{role:"row","aria-selected":Y,"data-sel":Y?"1":void 0,className:Y?"nc-filesd-row sel":"nc-filesd-row",onClick:()=>V(ce.name),children:[a.jsx("span",{className:"nc-files-type","aria-hidden":"true",children:Wo(ce.name)||a.jsx(_t,{name:"file",size:18})}),a.jsxs("span",{className:"nc-filesd-name",children:[Z,ge>1&&a.jsxs("span",{className:"nc-files-dup",children:[a.jsx("span",{"aria-hidden":"true",children:`×${ge}`}),a.jsx("span",{className:"nc-sr-only",children:f("files-dupes").replace("{n}",String(ge))})]})]}),a.jsx("span",{className:"nc-filesd-quando",children:LC(Bc(ce.name,ce.mtime),H,L)}),a.jsx("span",{className:"nc-filesd-dim",children:Sc(ce.size)}),a.jsx("span",{className:"nc-filesd-cella",children:a.jsx("button",{type:"button",className:"nc-filesd-dl",onClick:()=>N(ce.name),title:f("files-download"),"aria-label":`${f("files-download")} ${Z}`,children:a.jsx(_t,{name:"download",size:18})})}),a.jsx("span",{className:"nc-filesd-cella",children:a.jsx("button",{type:"button",className:"nc-filesd-more",onClick:()=>b(ce.name),title:f("files-actions"),"aria-label":`${f("files-actions")} ${Z}`,children:a.jsx(_t,{name:"more",size:18})})})]},ce.name)})})]},X.key)),c.length===0&&a.jsx("div",{className:"nc-files-empty",children:f("empty-files")}),c.length>0&&A.length===0&&a.jsx("div",{className:"nc-files-empty",children:f("files-no-match").replace("{q}",Fe)})]}),a.jsx("aside",{className:"nc-filesd-detail",children:re?a.jsxs(a.Fragment,{children:[D&&D.kind==="text"&&a.jsx("pre",{className:"nc-filesd-prev-text","data-testid":"files-detail-text",children:D.text}),D&&D.kind==="img"&&a.jsx("img",{className:"nc-filesd-prev-img","data-testid":"files-detail-img",src:D.url,alt:me}),a.jsx("b",{className:"nc-filesd-nome",children:me}),a.jsxs("div",{className:"nc-filesd-originale",children:[a.jsx("span",{className:"nc-filesd-label",children:f("files-original-name")}),a.jsx("code",{className:"nc-filesd-mono",children:re.name})]}),a.jsxs("dl",{className:"nc-filesd-meta",children:[a.jsxs("div",{children:[a.jsx("dt",{children:f("files-meta-date")}),a.jsx("dd",{children:RC(we,L)})]}),a.jsxs("div",{children:[a.jsx("dt",{children:f("files-meta-size")}),a.jsx("dd",{children:Sc(re.size)})]}),a.jsxs("div",{children:[a.jsx("dt",{children:f("files-meta-folder")}),a.jsxs("dd",{children:[s==="outbox"?"Outbox":"Inbox"," · ",He]})]}),a.jsxs("div",{children:[a.jsx("dt",{children:f("files-meta-type")}),a.jsx("dd",{children:Wo(re.name)||"—"})]})]}),a.jsxs("div",{className:"nc-filesd-azioni",children:[a.jsxs("button",{type:"button",className:"primario",onClick:()=>N(re.name),children:[a.jsx(_t,{name:"download",size:16}),a.jsx("span",{children:f("files-download-action")})]}),AC(re.name)&&a.jsxs("button",{type:"button",onClick:()=>E(re.name),children:[a.jsx(_t,{name:"eye",size:16}),a.jsx("span",{children:f("files-open")})]}),a.jsxs("button",{type:"button",onClick:ne,"aria-live":"polite",children:[a.jsx(_t,{name:"copy",size:16}),a.jsx("span",{children:f(B?"files-copied-name":"files-copy-name")})]}),a.jsxs("button",{type:"button",className:"danger",onClick:()=>K(!0),children:[a.jsx(_t,{name:"trash",size:16}),a.jsx("span",{children:f("files-delete-ellipsis")})]})]}),ie&&a.jsxs("div",{className:"nc-filesd-conferma","data-testid":"files-detail-confirm",children:[a.jsx("b",{className:"nc-filesd-conferma-titolo",children:f("files-delete-confirm").replace("{name}",me)}),a.jsx("small",{className:"nc-filesd-conferma-aiuto",children:f("files-delete-confirm-help")}),a.jsxs("div",{className:"nc-filesd-conferma-azioni",children:[a.jsx("button",{type:"button",onClick:()=>K(!1),disabled:!!h,children:f("cancel")}),a.jsx("button",{type:"button",className:"danger",disabled:!!h,"data-fileaction":"delete-confirm",onClick:()=>O(re.name),children:f("delete")})]})]})]}):a.jsx("div",{className:"nc-filesd-detail-none",children:f("files-detail-none")})})]}),(v||p)&&!g&&a.jsx("div",{className:"nc-busy",role:"status",children:v||p}),a.jsxs("footer",{className:"nc-filesd-foot",children:[a.jsx("span",{children:f("files-footer-count").replace("{n}",String(A.length)).replace("{size}",Sc(Ae))}),a.jsxs("span",{className:"nc-filesd-tasti",title:f("files-kbd-hint").replace("{enter}",f("files-kbd-enter")),children:[a.jsx("kbd",{children:"↑↓"}),a.jsx("kbd",{children:f("files-kbd-enter")}),a.jsx("kbd",{children:"/"})]})]})]})}const hD=6e4;function PC(t,e){const n=URL.createObjectURL(t),s=document.createElement("a");s.href=n,s.download=e,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(n),hD)}const fD=6e4;function zg({session:t,node:e,token:n,filesEvent:s,onClose:i}){zn();const l=e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_`:"/api",c=e?`${e}:${t}`:t,[u,h]=y.useState("outbox"),[p,v]=y.useState({inbox:[],outbox:[]}),[_,g]=y.useState(!1),[b,S]=y.useState(""),[j,C]=y.useState(""),[N,E]=y.useState(""),[O,x]=y.useState(""),W=Av();async function $(){try{const A=await(await qn(`${l}/files?session=${encodeURIComponent(t)}`,n)).json();if(A.error){S(A.error);return}S(""),C(""),v(A);const U=A.outbox[0]?A.outbox[0].mtime:0;localStorage.setItem(Kx(c),String(U))}catch(H){S(String(H))}}y.useEffect(()=>{$()},[t,e]),y.useEffect(()=>{s&&s.session===t&&$()},[s]);async function J(H){try{const A=await qn(`${l}/files/download?session=${encodeURIComponent(t)}&box=${u}&name=${encodeURIComponent(H)}`,n);if(!A.ok){const U=await A.json().catch(()=>({}));return S(U.error?`errore: ${U.error}`:"errore download"),null}return await A.blob()}catch{return S("errore download"),null}}async function q(H){S(""),C(""),g(!0);try{const A=await J(H);if(!A)return;PC(A,H)}catch{S("errore download")}finally{g(!1)}}async function V(H){S(""),C(""),g(!0);try{const A=await J(H);if(!A)return;if(!sD(A.type)){C(f("files-preview-blocked"));return}const U=URL.createObjectURL(A);try{window.open(U,"_blank","noopener")}catch{URL.revokeObjectURL(U),S(f("files-preview-failed"));return}setTimeout(()=>URL.revokeObjectURL(U),fD)}finally{g(!1)}}async function ie(H){S(""),C(""),g(!0);try{const A=await qn(`${l}/files?session=${encodeURIComponent(t)}&box=${u}&name=${encodeURIComponent(H)}`,n,{method:"DELETE"});if(!A.ok){const U=await A.json().catch(()=>({}));S(U.error?`errore: ${U.error}`:"errore delete");return}O===H&&x(""),$()}catch{S("errore delete")}finally{g(!1)}}const K=Vo(),B=new Date,I=p[u]||[],D=N.trim().toLowerCase(),T=D?I.filter(H=>String(H.name||"").toLowerCase().includes(D)):I,z=TC(T,B,K,f("files-today")),R=MC(T),M=O?I.find(H=>H.name===O):null,L=M?a.jsx(aD,{file:M,box:u,session:e?`${e}:${t}`:t,previewable:AC(M.name),notice:b||j,busy:_,onClose:()=>x(""),onActionStart:()=>{S(""),C("")},onDownload:H=>{x(""),q(H.name)},onPreview:H=>V(H.name),onDelete:H=>ie(H.name)}):null;return W?a.jsxs("div",{className:"nc-files nc-files-d",children:[a.jsx(dD,{session:t,node:e,token:n,box:u,onBox:h,counts:{outbox:(p.outbox||[]).length,inbox:(p.inbox||[]).length},rows:I,visible:T,busy:_,notice:j,error:b,onNotice:S,sheetFile:M,onSheet:x,onClose:i,onRefresh:$,fetchBlob:J,onDownload:q,onPreview:V,onDelete:ie,query:N,onQuery:E}),L]}):a.jsxs("div",{className:"nc-files",children:[a.jsxs("header",{children:[a.jsx("b",{children:e?`${e}:${t}`:t}),a.jsx("button",{type:"button",className:"nc-ntf-x",onClick:i,title:f("close"),"aria-label":f("close"),children:a.jsx(_t,{name:"x",size:16})})]}),a.jsxs("nav",{children:[a.jsx("button",{className:u==="outbox"?"on":"",onClick:()=>h("outbox"),children:f("files-outbox").replace("{n}",String((p.outbox||[]).length))}),a.jsx("button",{className:u==="inbox"?"on":"",onClick:()=>h("inbox"),children:f("files-inbox").replace("{n}",String((p.inbox||[]).length))})]}),a.jsxs("div",{className:"nc-files-search",children:[a.jsx(_t,{name:"search",size:16}),a.jsx("input",{type:"search",value:N,onChange:H=>E(H.target.value),placeholder:f("files-search-ph"),"aria-label":f("files-search"),enterKeyHint:"search"})]}),(b||j)&&!M&&a.jsx("div",{className:"nc-busy",role:"status",children:b||j}),a.jsxs("div",{className:"nc-files-list",children:[z.map(H=>a.jsxs("section",{className:"nc-files-daygroup",children:[a.jsx("h3",{className:"nc-files-day",children:H.label}),a.jsx("ul",{children:H.files.map(A=>{const U=Qa(A.name),Q=R.get(U)||1;return a.jsxs("li",{children:[a.jsx("span",{className:"nc-files-type","aria-hidden":"true",children:Wo(A.name)||a.jsx(_t,{name:"file",size:18})}),a.jsxs("span",{className:"nc-files-info",children:[a.jsxs("span",{className:"nc-files-name",children:[U,Q>1&&a.jsxs("span",{className:"nc-files-dup",children:[a.jsx("span",{"aria-hidden":"true",children:`×${Q}`}),a.jsx("span",{className:"nc-sr-only",children:f("files-dupes").replace("{n}",String(Q))})]})]}),a.jsxs("small",{className:"nc-files-meta",children:[LC(Bc(A.name,A.mtime),B,K)," · ",Sc(A.size)]})]}),a.jsx("button",{type:"button",className:"nc-files-dl",onClick:()=>q(A.name),title:f("files-download"),"aria-label":`${f("files-download")} ${U}`,children:a.jsx(_t,{name:"download",size:20})}),a.jsx("button",{type:"button",className:"nc-files-more",onClick:()=>x(A.name),title:f("files-actions"),"aria-label":`${f("files-actions")} ${U}`,children:a.jsx(_t,{name:"more",size:20})})]},A.name)})})]},H.key)),I.length===0&&a.jsx("div",{className:"nc-files-empty",children:f("empty-files")}),I.length>0&&T.length===0&&a.jsx("div",{className:"nc-files-empty",children:f("files-no-match").replace("{q}",N.trim())})]}),L]})}const kh="nc_composer_v1",Fg="nc-composer-reset",pD=50,IC=256*1024,DC=512*1024,mD=768*1024,rS=2*1024*1024,OC=720*60*60*1e3,Hg=1;function BC(t){const e=Number(t);return Number.isFinite(e)&&e>0?e:0}function Yv(t){if(t!==void 0)return t;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Gd(){return{version:Hg,cells:{}}}function $C(t){const e=[];for(const s of Array.isArray(t)?t:[]){const i=typeof s=="string"?s:s&&s.text,l=BC(typeof s=="string"?0:s&&s.at);if(!(typeof i!="string"||!i||i.length>IC)&&!(e.length&&e[e.length-1].text===i)&&(e.push({text:i,at:l}),e.length>=pD))break}let n=0;return e.filter(s=>n+s.text.length>mD?!1:(n+=s.text.length,!0))}function Xd(t){if(!t||typeof t!="object")return null;const e=typeof t.draft=="string"&&t.draft.length<=DC?t.draft:"",n=$C(t.history),s=BC(t.updatedAt),i=t.expanded===!0;return!e&&!n.length&&!i?null:{draft:e,history:n,expanded:i,updatedAt:s}}function gD(t){let e;try{e=typeof t=="string"?JSON.parse(t):t}catch{return Gd()}if(!e||typeof e!="object"||e.version!==Hg||!e.cells||typeof e.cells!="object")return Gd();const n=Object.create(null);for(const[s,i]of Object.entries(e.cells)){if(!s||typeof s!="string"||s.length>512||s==="__proto__"||s==="constructor"||s==="prototype")continue;const l=Xd(i);l&&(n[s]=l)}return{version:Hg,cells:n}}function zC(t){const e=Yv(t);if(!e)return Gd();try{return gD(e.getItem(kh))}catch{return Gd()}}function oS(t){try{return JSON.stringify(t).length}catch{return 1/0}}function vD(t,e,n){for(const[s,i]of Object.entries(t.cells))s!==n&&i.updatedAt>0&&e-i.updatedAt>OC&&delete t.cells[s]}function FC(t,e){return Object.entries(t.cells).filter(([n])=>n!==e).sort((n,s)=>n[1].updatedAt-s[1].updatedAt).map(([n])=>n)}function _D(t,e){for(;oS(t)>rS;){const n=Object.entries(t.cells).filter(([,s])=>s.history.length).sort((s,i)=>s[1].updatedAt-i[1].updatedAt);if(!n.length)break;n[0][1].history.pop()}for(const n of FC(t,e)){if(oS(t)<=rS)break;delete t.cells[n]}}function HC(t,e,n){const s=Yv(t);if(!s)return!1;_D(e,n);const i=()=>(s.setItem(kh,JSON.stringify(e)),!0);try{return i()}catch{for(const c of FC(e,n)){delete e.cells[c];try{return i()}catch{}}return!1}}function Qc(t,e,n,s){const i=zC(e);vD(i,n,t);const l=Xd(i.cells[t])||{draft:"",history:[],expanded:!1,updatedAt:0},c=s({...l,history:[...l.history]}),u=Xd(c);return u?i.cells[t]={...u,updatedAt:n}:delete i.cells[t],{ok:HC(e,i,t),cell:i.cells[t]||{draft:"",history:[],expanded:!1,updatedAt:n}}}function yD({ownerId:t,node:e,session:n}){const s=String(n||"");if(!s)return"";const i=Xa.test(String(t||""))?String(t):e?`route:${String(e)}`:"local";return`${encodeURIComponent(i)}:${encodeURIComponent(s)}`}function Zl(t,e,n=Date.now()){if(!t)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=zC(e),i=Xd(s.cells[t]);return!i||i.updatedAt>0&&n-i.updatedAt>OC?(s.cells[t]&&(delete s.cells[t],HC(e,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...i,history:[...i.history]}}function aS(t,e,n,s=Date.now()){const i=String(e||"");return!t||i.length>DC?!1:Qc(t,n,s,l=>({...l,draft:i})).ok}function lS(t,e,n=Date.now()){return t?Qc(t,e,n,s=>({...s,draft:""})).ok:!1}function wD(t,e,n,s=Date.now()){return t?Qc(t,n,s,i=>({...i,expanded:!!e})).ok:!1}function bD(t,e,n,s=Date.now()){const i=String(e||"");return!t||!i||i.length>IC?!1:Qc(t,n,s,l=>{const c=l.history.filter(u=>u.text!==i);return c.unshift({text:i,at:s}),{...l,history:$C(c)}}).ok}function SD(t,e,n=Date.now()){return t?Qc(t,e,n,s=>({...s,history:[]})).ok:!1}function xD(t){const e=Yv(t);if(!e)return!1;try{return e.removeItem(kh),!0}catch{return!1}}const kD=300;function CD(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function ED({ownerId:t,node:e,session:n,storage:s=CD()}){const i=y.useMemo(()=>yD({ownerId:t,node:e,session:n}),[t,e,n]),l=y.useMemo(()=>Zl(i,s),[]),[c,u]=y.useState(l.draft),[h,p]=y.useState(l.expanded),[v,_]=y.useState(l.history),[g,b]=y.useState(-1),S=y.useRef(i),j=y.useRef(l.draft),C=y.useRef(null),N=y.useRef(l.updatedAt||0),E=y.useRef(l.draft),O=y.useCallback(()=>{C.current&&clearTimeout(C.current),C.current=null},[]),x=y.useCallback(()=>{O(),aS(S.current,j.current,s)},[O,s]),W=y.useCallback(()=>{O(),C.current=setTimeout(()=>{C.current=null,aS(S.current,j.current,s)},kD)},[O,s]),$=y.useCallback(D=>{const T=String(typeof D=="function"?D(j.current):D||"");j.current=T,N.current=Date.now(),E.current=T,b(-1),u(T),W()},[W]),J=y.useCallback((D,T)=>{O(),j.current=D,N.current=Date.now(),u(D),b(T),W()},[O,W]),q=y.useCallback(()=>{if(!v.length)return!1;const D=Math.min(g+1,v.length-1);return g<0&&(E.current=j.current),J(v[D].text,D),!0},[J,v,g]),V=y.useCallback(()=>{if(g<0)return!1;const D=g-1;return J(D<0?E.current:v[D].text,D),!0},[J,v,g]),ie=y.useCallback(D=>{E.current=j.current;const T=v.findIndex(z=>z.text===D);J(String(D||""),T)},[J,v]),K=y.useCallback(()=>{p(D=>{const T=!D;return wD(S.current,T,s),T})},[s]),B=y.useCallback((D,T,z)=>{if(!D)return;if(bD(D,z,s),!(S.current===D)){Zl(D,s).draft===T&&lS(D,s);return}_(Zl(D,s).history),E.current="",b(-1),j.current===T?(O(),j.current="",N.current=Date.now(),u(""),lS(D,s)):W()},[O,W,s]),I=y.useCallback(()=>{SD(S.current,s),_([]),b(-1),E.current=j.current},[s]);return y.useEffect(()=>{if(S.current===i)return;x(),S.current=i;const D=Zl(i,s);j.current=D.draft,N.current=D.updatedAt||0,E.current=D.draft,u(D.draft),p(D.expanded),_(D.history),b(-1)},[i,x,s]),y.useEffect(()=>{const D=()=>x(),T=()=>{document.visibilityState==="hidden"&&x()};return window.addEventListener("pagehide",D),document.addEventListener("visibilitychange",T),()=>{window.removeEventListener("pagehide",D),document.removeEventListener("visibilitychange",T),x()}},[x]),y.useEffect(()=>{const D=()=>{O(),j.current="",N.current=0,E.current="",u(""),p(!1),_([]),b(-1)},T=R=>{if(R.key!==kh)return;if(R.newValue==null){D();return}const M=Zl(S.current,s);M.updatedAt<N.current||(O(),j.current=M.draft,N.current=M.updatedAt,E.current=M.draft,u(M.draft),p(M.expanded),_(M.history),b(-1))},z=()=>D();return window.addEventListener("storage",T),window.addEventListener(Fg,z),()=>{window.removeEventListener("storage",T),window.removeEventListener(Fg,z)}},[O,s]),{cellKey:i,text:c,setText:$,expanded:h,toggleExpanded:K,history:v,historyCursor:g,recallPrevious:q,recallNext:V,selectHistory:ie,confirmSubmitted:B,clearHistory:I,flush:x}}function UC({submitText:t,token:e,session:n,node:s,ownerId:i,readonly:l=!1,keepKeyboardClosedOnVoice:c=!0}){zn();const u=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:h,text:p,setText:v,expanded:_,toggleExpanded:g,history:b,historyCursor:S,recallPrevious:j,recallNext:C,selectHistory:N,confirmSubmitted:E,clearHistory:O,flush:x}=ED({ownerId:i,node:s,session:n}),[W,$]=y.useState(!1),[J,q]=y.useState(""),[V,ie]=y.useState(""),[K,B]=y.useState(!1),I=y.useRef(null),D=y.useRef(null),T=y.useRef(null),[z,R]=y.useState(!1),[M,L]=y.useState({left:0,bottom:0}),[H,A]=y.useState(!1),[U,Q]=y.useState(!1),ae=y.useRef(null),re=y.useRef(null),je=y.useRef(null),te=y.useRef(null),ne=y.useRef(null),me=y.useRef(null),we=y.useRef(null),Fe=y.useRef(null),Ae=y.useRef(!1),[He,X]=y.useState(!1),[ce,Z]=y.useState({left:0,bottom:0,width:320}),ge=y.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);y.useEffect(()=>{let ee=!1;if(s){B(!1);return}return qn(`${u}/voice/status`,e).then(P=>P.json()).then(P=>{ee||B(!!P.serverSttConfigured)}).catch(()=>{ee||B(!1)}),()=>{ee=!0}},[e,u]);const he=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||K);async function Ne(){const ee=T.current&&typeof T.current.value=="string"?T.current.value:p;bg(),ee!==p&&v(ee);const P=ee,le=OT(P);if(!le||U)return;if(l){q(f("settings-readonly"));return}Q(!0),q("");let _e=!1;try{_e=!!await t(le)}catch{_e=!1}_e?E(h,P,le):q(f("composer-send-failed")),Q(!1)}function Ce(){const ee=ae.current&&ae.current.getBoundingClientRect();ee&&L({left:Math.max(6,Math.min(ee.left,window.innerWidth-186)),bottom:window.innerHeight-ee.top+6}),R(!0)}function Ve(ee){R(!1),ee&&ae.current&&ae.current.focus()}function Ye(){const ee=je.current&&je.current.getBoundingClientRect();if(ee){const P=Math.max(220,Math.min(360,window.innerWidth-12));Z({left:Math.max(6,Math.min(ee.right-P,window.innerWidth-P-6)),bottom:window.innerHeight-ee.top+6,width:P})}X(!0)}function ht(ee){X(!1),ee&&je.current&&je.current.focus()}y.useEffect(()=>{if(!z)return;const ee=le=>{le.key==="Escape"&&Ve(!0)},P=le=>{const _e=re.current&&re.current.contains(le.target),Me=ae.current&&ae.current.contains(le.target);!_e&&!Me&&Ve(!1)};return document.addEventListener("keydown",ee),document.addEventListener("pointerdown",P),()=>{document.removeEventListener("keydown",ee),document.removeEventListener("pointerdown",P)}},[z]),y.useEffect(()=>{if(!He)return;const ee=le=>{le.key==="Escape"&&ht(!0)},P=le=>{const _e=te.current&&te.current.contains(le.target),Me=je.current&&je.current.contains(le.target);!_e&&!Me&&ht(!1)};return document.addEventListener("keydown",ee),document.addEventListener("pointerdown",P),()=>{document.removeEventListener("keydown",ee),document.removeEventListener("pointerdown",P)}},[He]);function ze(ee){if(!(ee.isComposing||Ae.current||ee.altKey||ee.ctrlKey||ee.metaKey)){if(ee.key==="ArrowUp"&&ee.currentTarget.selectionStart===0&&ee.currentTarget.selectionEnd===0){j()&&ee.preventDefault();return}ee.key==="ArrowDown"&&S>=0&&ee.currentTarget.selectionStart===p.length&&ee.currentTarget.selectionEnd===p.length&&C()&&ee.preventDefault()}}function ve(ee){Ve(!1),ee.current&&ee.current.click()}async function Oe(ee){if(!ee.length||!n)return;A(!0),q("");const{paths:P,errors:le}=await Ud({files:ee,token:e,session:n,node:s,paste:!1});le.length&&q(le.map(_e=>`${_e.name}: ${_e.message}`).join(" · ")),P.length&&v(_e=>_e+(_e&&!_e.endsWith(" ")?" ":"")+P.join(" ")),A(!1)}async function et(ee){var _e;if(!ee.length||!n)return;A(!0),q(""),ie("");const{paths:P,errors:le}=await Ud({files:ee,token:e,session:n,node:s,paste:!1});if(le.length&&q(le.map(Me=>`${Me.name}: ${Me.message}`).join(" · ")),P.length){ie(f("attach-inbox-done").replace("{n}",String(P.length)));try{(_e=navigator.vibrate)==null||_e.call(navigator,10)}catch{}setTimeout(()=>ie(""),2500)}A(!1)}function Ue(){I.current&&I.current.stop(),D.current&&D.current.stop(),$(!1)}async function st(){q("");const ee=window.SpeechRecognition||window.webkitSpeechRecognition;if(ee){const P=new ee;P.lang="it-IT",P.continuous=!1,P.interimResults=!0;const le=p?`${p} `:"";P.onresult=_e=>{const Me=Array.from(_e.results).map(oe=>oe[0].transcript).join("");v(le+Me)},P.onend=()=>$(!1),P.onerror=_e=>{q(`voice: ${_e.error||"errore"}`),$(!1)},I.current=P,P.start(),$(!0);return}try{const P=await navigator.mediaDevices.getUserMedia({audio:!0}),le=new MediaRecorder(P),_e=[];le.ondataavailable=Me=>_e.push(Me.data),le.onstop=async()=>{P.getTracks().forEach(Me=>Me.stop()),$(!1),q("trascrivo…");try{const Me=new Blob(_e,{type:le.mimeType||"audio/webm"}),Be=await(await qn(`${u}/voice/transcribe`,e,{method:"POST",headers:{"content-type":"application/octet-stream"},body:Me})).json();Be.error?q(Be.error):(q(""),v(gt=>gt+(gt?" ":"")+(Be.text||"")))}catch(Me){q(String(Me))}},D.current={stop:()=>le.state!=="inactive"&&le.stop()},le.start(),$(!0)}catch{q("microfono non disponibile"),$(!1)}}function ot(){c&&bg(),W?Ue():st()}return a.jsxs("div",{className:"nc-composer",children:[J&&a.jsx("div",{className:"nc-composer-err",children:J}),V&&a.jsx("div",{className:"nc-composer-info",children:V}),a.jsxs("div",{className:"nc-composer-row",children:[n&&a.jsx("button",{ref:ae,className:H?"attach busy":"attach",disabled:H,onClick:()=>z?Ve(!1):Ce(),title:f(H?"attach-uploading":"attach"),"aria-label":f("attach"),"aria-haspopup":"menu","aria-expanded":z,"aria-controls":ge.current,children:a.jsx(_t,{name:"attach",size:22})}),z&&a.jsxs("div",{ref:re,id:ge.current,role:"menu",className:"nc-attach-menu",style:{left:M.left,bottom:M.bottom},children:[a.jsxs("button",{role:"menuitem",onClick:()=>ve(ne),children:[a.jsx(_t,{name:"file",size:18})," ",f("attach-file")]}),a.jsxs("button",{role:"menuitem",onClick:()=>ve(me),children:[a.jsx(_t,{name:"camera",size:18})," ",f("attach-camera")]}),a.jsxs("button",{role:"menuitem",onClick:()=>ve(we),children:[a.jsx(_t,{name:"image",size:18})," ",f("attach-gallery")]}),a.jsxs("button",{role:"menuitem",onClick:()=>ve(Fe),children:[a.jsx(_t,{name:"folder",size:18})," ",f("attach-inbox")]})]}),a.jsx("button",{ref:je,type:"button",className:"history",onPointerDown:ee=>ee.preventDefault(),onClick:()=>He?ht(!1):Ye(),title:f("composer-history-tools"),"aria-label":f("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":He,children:a.jsx(_t,{name:"history",size:21})}),He&&a.jsxs("div",{ref:te,role:"menu",className:"nc-composer-history-menu",style:{left:ce.left,bottom:ce.bottom,width:ce.width},children:[a.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:ee=>ee.preventDefault(),onClick:()=>{g(),ht(!1)},children:[a.jsx(_t,{name:_?"chevronDown":"chevronUp",size:18}),f(_?"composer-collapse":"composer-expand")]}),a.jsx("div",{className:"nc-composer-history-title",children:f("composer-history")}),b.length===0&&a.jsx("div",{className:"nc-composer-history-empty",children:f("composer-history-empty")}),b.map((ee,P)=>a.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:le=>le.preventDefault(),onClick:()=>{N(ee.text),ht(!1)},children:[a.jsx("span",{children:ee.text.replace(/\s+/g," ").slice(0,180)}),ee.at>0&&a.jsx("small",{children:new Date(ee.at).toLocaleString()})]},`${ee.at}:${P}`)),b.length>0&&a.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:ee=>ee.preventDefault(),onClick:()=>{O(),ht(!1)},children:f("composer-history-clear")})]}),a.jsx("input",{ref:ne,type:"file",multiple:!0,hidden:!0,onChange:ee=>{Oe(Array.from(ee.target.files||[])),ee.target.value=""}}),a.jsx("input",{ref:me,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:ee=>{Oe(Array.from(ee.target.files||[])),ee.target.value=""}}),a.jsx("input",{ref:we,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:ee=>{Oe(Array.from(ee.target.files||[])),ee.target.value=""}}),a.jsx("input",{ref:Fe,type:"file",multiple:!0,hidden:!0,onChange:ee=>{et(Array.from(ee.target.files||[])),ee.target.value=""}}),a.jsx("textarea",{ref:T,className:_?"expanded":"",rows:_?8:2,value:p,placeholder:f("composer-placeholder"),onChange:ee=>v(ee.target.value),onKeyDown:ze,onCompositionStart:()=>{Ae.current=!0},onCompositionEnd:()=>{Ae.current=!1},onBlur:x}),he&&a.jsx("button",{type:"button",className:W?"mic on":"mic",title:f("voice"),"aria-label":f("voice"),onPointerDown:ee=>{ee.preventDefault(),ot()},onClick:ee=>{ee.detail===0&&ot()},children:a.jsx(_t,{name:"mic",size:22})}),a.jsx("button",{type:"button",className:"go",disabled:U,onPointerDown:ee=>ee.preventDefault(),onClick:Ne,title:f("send"),children:a.jsx(_t,{name:"enter",size:22})})]})]})}const cS=460,ND=320;function jD({row:t,token:e,panelPort:n=0,anchorRect:s,liveHost:i=null,onLiveHostApplied:l,source:c,onSourceChange:u,onExpand:h,onClose:p,onMouseEnter:v,onMouseLeave:_}){y.useEffect(()=>{const S=j=>{j.key==="Escape"&&p()};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[p]);const g=s?Math.max(8,Math.min(s.right+10,window.innerWidth-cS-8)):void 0,b=s?Math.max(8,Math.min(s.top-6,window.innerHeight-ND-8)):void 0;return a.jsxs("div",{className:"nc-peekcloud",style:{left:g,top:b,width:cS},"data-testid":"peek-cloud",onMouseEnter:v,onMouseLeave:_,children:[a.jsxs("div",{className:"nc-peekcloud-testa",children:[a.jsx("b",{className:"nc-peekcloud-nome",children:t.cellName}),[t.nodeLabel,t.subtitle].filter(Boolean).length>0&&a.jsx("span",{className:"nc-peekcloud-sub",children:[t.nodeLabel,t.subtitle].filter(Boolean).join(" · ")}),a.jsx("button",{type:"button",className:"nc-peekcloud-espandi",title:f("cell-peek-expand"),"aria-label":`${f("cell-peek-expand")}: ${t.cellName}`,onClick:()=>h(c),children:"⤢"})]}),a.jsx(Tv,{row:t,token:e,panelPort:n,liveHost:i,onLiveHostApplied:l,source:c,onSourceChange:u})]})}function Bp(t){return String(t||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const LD=180,RD=480,ec=(t,e=[])=>`${e.length?e.join("/"):"local"}:${t}`;function AD({sessions:t=[],cells:e=[],activeSessions:n=[],nodeGroups:s=[],onPick:i,onAddTile:l,onPower:c,onBoot:u,onNodePower:h,onKill:p,onVisibility:v,onNew:_,onNodeRename:g,onSettings:b,onBootError:S,localNodeId:j,fleetCapabilities:C=[],fleetStale:N=!1,fleetOff:E=null,bootSettlement:O=null,localVerified:x=!0,hostByRoute:W={},onDesignateCell:$,onClearHostCell:J,onBootSettlementApplied:q,onOpenVlSession:V,token:ie="",onPeekOpen:K,overlayOpen:B=!1,width:I=240,collapsed:D=!1,onResize:T,onToggleCollapse:z}){const[R,M]=zn(),{pins:L,orders:H,togglePin:A,removePin:U,pinError:Q,reorderBlocked:ae,retryPinPersist:re,clearPinError:je,viewFor:te,updateView:ne,canMoveRoster:me,moveRoster:we,stepRoster:Fe}=zv(),{groupsFor:Ae,moveNode:He,stepNode:X,nodeKey:ce}=bh(),Z=G=>W[Ls(G)]||{},ge=new Set((e||[]).map(G=>G.tmuxSession)),Y=new Map((t||[]).map(G=>[G.name,G])),he=(G,fe)=>QP(L,G,fe),Ne=ZP,Ce=[...e||[]].sort((G,fe)=>Ne(he(G.tmuxSession,(Y.get(G.tmuxSession)||{}).activity),he(fe.tmuxSession,(Y.get(fe.tmuxSession)||{}).activity))),Ve=(t||[]).filter(G=>!ge.has(G.name)).sort((G,fe)=>Ne(he(G.name,G.activity),he(fe.name,fe.activity))||G.name.localeCompare(fe.name)),Ye=new Set(n||[]),[ht,ze]=y.useState(null),[ve,Oe]=y.useState("preview"),[et,Ue]=y.useState(null),st=y.useRef(null),ot=y.useRef(null),ee=y.useRef(null);y.useEffect(()=>{ee.current=ht},[ht]),y.useEffect(()=>()=>{clearTimeout(st.current),clearTimeout(ot.current)},[]);const[P,le]=y.useState(null),[_e,Me]=y.useState(null),[oe,Be]=y.useState(!1),[gt,Lt]=y.useState(null),Nt=(G,fe,Te=[],Ze="",Pe=null)=>{const ke=(Te.length===0?Y.get(fe.tmuxSession):(Pe||[]).find(Le=>Le&&Le.name===fe.tmuxSession))||{};return{key:G.key,cellName:fe.cell,subtitle:G.subtitle||"",nodeLabel:Ze,node:Te.length?Te.join("/"):"",session:fe.tmuxSession,route:Te,panelUrl:fe.panelUrl||"",telemetry:ke.telemetry||null,preview:ke.preview||fe.preview||"",activity:ke.activity||fe.activity||0}},kt=(G,fe,Te=[],Ze="",Pe="preview")=>jt=>{jt&&jt.stopPropagation(),Ue(null),Oe(Pe),ze(G.key),typeof K=="function"&&K()},Kt=(G,fe,Te)=>{Te&&(clearTimeout(ot.current),clearTimeout(st.current),st.current=setTimeout(()=>{ee.current||Ue({itemKey:G.key,routeKey:fe||"",anchorRect:Te.getBoundingClientRect(),source:"stream"})},300))},ft=()=>{clearTimeout(st.current),clearTimeout(ot.current),ot.current=setTimeout(()=>Ue(null),150)},Vt=()=>clearTimeout(ot.current),It=()=>Ue(null),Xt=(G,fe,Te,Ze,Pe)=>{if(P&&P.itemKey===G){le(null);return}le({itemKey:G,routeKey:fe||"",canBoot:!!Ze,preserved:!!Pe}),Me(Te?Te.getBoundingClientRect():null)};y.useEffect(()=>{B&&(ze(null),Oe("preview"))},[B]);const Dt=qv(Ce,Ve,Y,void 0,{autorevole:x,fleetStale:N}),Cn=co(Dt,L,te("local").filter,Ti(H,"local")),on=Ae(s||[]).map(G=>{const fe=(G.route&&G.route.length?G.route:[G.name]).join("/"),Te=te(fe);if(G.kind==="vl")return{g:G,nodeRoute:fe,groupView:Te,rawItems:[],items:[]};const{rawItems:Ze}=bc(G),Pe=co(Ze,L,Te.filter,Ti(H,fe));return{g:G,nodeRoute:fe,groupView:Te,rawItems:Ze,items:Pe}}),tn=[...Cn,...on.flatMap(({items:G,nodeRoute:fe,g:Te})=>(G||[]).map(Ze=>({...Ze,nodeRoute:fe,nodeLabel:Te.label||Te.name})))].filter(G=>G.type==="cell"),un=ht?tn.find(G=>G.key===ht):null,Ht=()=>{if(!et)return null;const G=tn.find(Pe=>Pe.key===et.itemKey);if(!G)return null;const fe=G.value,Te=G.nodeRoute?s.find(Pe=>(Pe.route||[Pe.name]).join("/")===G.nodeRoute)||{}:null,Ze=G.nodeRoute?Te.route||[G.nodeRoute]:[];return a.jsx(jD,{row:Nt(G,fe,Ze,G.nodeLabel||"",Te&&Te.sessions),token:ie,anchorRect:et.anchorRect,source:et.source,onSourceChange:Pe=>Ue(jt=>jt&&{...jt,source:Pe}),onExpand:Pe=>{Ue(null),Oe(Pe),ze(G.key),typeof K=="function"&&K()},onClose:It,onMouseEnter:Vt,onMouseLeave:ft})},sn=(G,fe,Te)=>i&&i({session:G,...fe?{node:fe}:{},...Xa.test(String(Te||""))?{ownerId:Te}:{}}),En=async G=>{if(!(G!=null&&G.direct)||!g)return;const fe=window.prompt(f("rename-node-prompt"),G.label||G.name);if(fe!==null)try{await g(G,fe)||window.alert(f("rename-node-invalid"))}catch(Te){window.alert(String((Te==null?void 0:Te.message)||Te))}},[Qt,an]=y.useState({}),[$s,Vn]=y.useState(new Set);y.useEffect(()=>{const G=new Map;for(const fe of e||[])G.set(ec(fe.cell),!!fe.boot);for(const fe of s||[]){const Te=fe.route||[fe.name];for(const Ze of fe.cells||[])G.set(ec(Ze.cell,Te),!!Ze.boot)}an(fe=>{let Te=!1;const Ze={...fe};for(const[Pe,jt]of Object.entries(fe))G.has(Pe)&&G.get(Pe)===jt&&(delete Ze[Pe],Te=!0);return Te?Ze:fe})},[e,s]),y.useEffect(()=>{if(!(O!=null&&O.cell))return;const G=Array.isArray(O.route)?O.route:[],fe=ec(O.cell,G);an(Te=>({...Te,[fe]:!!O.enabled})),q&&q(O.id)},[O,q]);const Ut=(G,fe=[])=>{const Te=ec(G.cell,fe);return Object.prototype.hasOwnProperty.call(Qt,Te)?Qt[Te]:!!G.boot},zs=async(G,fe,Te=[],Ze)=>{if(!u)return;const Pe=ec(fe.cell,Te),jt=typeof Ze=="boolean"?Ze:!Ut(fe,Te);an(ke=>({...ke,[Pe]:jt})),Vn(ke=>new Set(ke).add(Pe));try{await u(fe.cell,jt,Te)}catch(ke){an(Le=>{const lt={...Le};return delete lt[Pe],lt}),S&&S(ke)}finally{Vn(ke=>{const Le=new Set(ke);return Le.delete(Pe),Le})}},ds=(G,fe,Te)=>({onToggleLive:async()=>{const Ze=oo({item:G,cellName:fe.cell,route:Te,pins:L,hostByRoute:W});Be(!0);const Pe=await dh({action:Ze.isLive?"remove":"use",cellId:fe.cell,route:Te,token:ie});Be(!1),Lt({messageKey:Pe.messageKey,ok:Pe.ok,cell:Pe.hostCell||fe.cell})},onTogglePin:()=>Fv({view:Sh({item:G,pins:L,hostByRoute:W,route:Te}),itemKey:G.key,togglePin:A,removePin:U}),onToggleBoot:Ze=>zs(null,fe,Te,Ze),onWatchLive:()=>{Ue(null),Oe("stream"),ze(G.key),typeof K=="function"&&K()}}),[Yn,xt]=y.useState(null),ue=(G,fe)=>{const Te=G.currentTarget.getBoundingClientRect();xt({text:fe,y:Te.top+Te.height/2})},Ie=()=>xt(null),Qe=y.useRef(null);y.useEffect(()=>()=>{Qe.current&&Qe.current()},[]);function ct(G){G.preventDefault(),G.stopPropagation();const fe=G.clientX,Te=I,Ze=jt=>{const ke=Math.max(LD,Math.min(RD,Te+(jt.clientX-fe)));T&&T(ke)},Pe=()=>{window.removeEventListener("pointermove",Ze),window.removeEventListener("pointerup",Pe),window.removeEventListener("pointercancel",Pe),window.removeEventListener("blur",Pe),Qe.current=null};window.addEventListener("pointermove",Ze),window.addEventListener("pointerup",Pe),window.addEventListener("pointercancel",Pe),window.addEventListener("blur",Pe),Qe.current=Pe}const At=D?{width:48,flex:"0 0 48px"}:{width:I,flex:`0 0 ${I}px`};return D?a.jsxs("aside",{className:"nc-sidebar mini",style:At,children:[a.jsx("div",{className:"nc-side-head mini",children:a.jsx("button",{className:"nc-collapse-btn",onClick:z,title:f("expand"),children:"⟩"})}),a.jsx("button",{className:"nc-side-gear mini",onClick:()=>b&&b("nodes",!1),title:f("settings"),onMouseEnter:G=>ue(G,f("settings")),onMouseLeave:Ie,children:a.jsx(_t,{name:"gear",size:16})}),a.jsx("div",{className:"nc-side-scroll mini",children:a.jsxs("div",{className:"nc-side-group mini",children:[te("local").open&&Cn.map(G=>G.type==="cell"?(()=>{const fe=G.value,Te=fe.degraded?"warn":fe.tmux?"on":"",Ze=!!fe.tmux;return a.jsx("button",{type:"button",className:`nc-mini-dot${Ye.has(fe.tmuxSession)?" active":""}`,onMouseEnter:Pe=>{Ze?Kt(G,"",Pe.currentTarget):ue(Pe,`${fe.cell}: ${G.subtitle}`)},onMouseLeave:()=>{Ze?ft():Ie()},draggable:Ze,onDragStart:Ze?Pe=>Pe.dataTransfer.setData("text/nc-session",fe.tmuxSession):void 0,onClick:Ze?()=>{Ue(null),l&&l(fe.tmuxSession)}:()=>c&&c(fe),onDoubleClick:Ze?()=>sn(fe.tmuxSession,"",j):void 0,children:a.jsx("span",{className:`nc-dot ${Te}${G.working?" working":""}`})},G.key)})():(()=>{const fe=G.value;return a.jsx("button",{type:"button",className:`nc-mini-init${Ye.has(fe.name)?" active":""}`,onMouseEnter:Te=>ue(Te,fe.name),onMouseLeave:Ie,draggable:!0,onDragStart:Te=>Te.dataTransfer.setData("text/nc-session",fe.name),onClick:()=>l&&l(fe.name),onDoubleClick:()=>sn(fe.name,"",j),children:Bp(fe.name)},G.key)})()),on.flatMap(({g:G,nodeRoute:fe,groupView:Te,items:Ze})=>G.kind==="vl"?G.status==="up"&&G.sessions.length?G.sessions.map(Pe=>a.jsx("button",{type:"button",className:"nc-mini-init",onMouseEnter:jt=>ue(jt,`${G.label||fe}: ${Pe.name}`),onMouseLeave:Ie,onClick:()=>V&&V(G.peer),children:Bp(Pe.name)},Pe.key)):[a.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:Pe=>ue(Pe,`${G.label||G.name}: ${Ji(G)||f("no-sessions-short")}`),onMouseLeave:Ie,children:a.jsx("span",{className:`nc-dot${G.status==="up"?" on":" warn"}`})},`nodo-vl-${fe}-${G.name}`)]:G.status==="up"?Te.open?Ze.map(Pe=>Pe.type==="cell"?(()=>{const jt=Pe.value,ke=!!jt.tmux;return a.jsx("button",{type:"button",className:`nc-mini-dot${Ye.has(Pe.key)?" active":""}`,onMouseEnter:Le=>{ke?Kt(Pe,fe,Le.currentTarget):ue(Le,`${G.label||fe}: ${jt.cell} · ${Pe.subtitle}`)},onMouseLeave:()=>{ke?ft():Ie()},draggable:ke,onDragStart:ke?Le=>Le.dataTransfer.setData("text/nc-session",Pe.key):void 0,onClick:ke?()=>{Ue(null),l&&l(Pe.key)}:()=>c&&c({...jt,route:G.route,availableEngines:G.engines||[]}),onDoubleClick:ke?()=>sn(jt.tmuxSession,fe,G.instanceId):void 0,children:a.jsx("span",{className:`nc-dot ${jt.degraded?"warn":ke?`on${Pe.working?" working":""}`:""}`})},Pe.key)})():(()=>{const jt=Pe.value;return a.jsx("button",{type:"button",className:`nc-mini-init${Ye.has(Pe.key)?" active":""}`,onMouseEnter:ke=>ue(ke,`${G.label||fe}: ${jt.name}`),onMouseLeave:Ie,draggable:!0,onDragStart:ke=>ke.dataTransfer.setData("text/nc-session",Pe.key),onClick:()=>l&&l(Pe.key),onDoubleClick:()=>sn(jt.name,fe,G.instanceId),children:Bp(jt.name)},Pe.key)})()):[]:[a.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:Pe=>ue(Pe,`${G.label||(G.route||[G.name]).join(" › ")}: ${Ji(G)}`),onMouseLeave:Ie,children:a.jsx("span",{className:`nc-dot${G.status==="passive"?"":" warn"}`})},`nodo-${(G.route||[G.name]).join("/")}`)])]})}),Ht(),Yn&&a.jsx("div",{className:"nc-mini-tip",style:{top:Yn.y},children:Yn.text})]}):a.jsxs("aside",{className:"nc-sidebar",style:At,children:[a.jsx("div",{className:"nc-side-live-host",children:a.jsx(MD,{view:Va({liveHost:W[Ls([])],cells:e}),notice:gt})}),a.jsxs("div",{className:"nc-side-head",children:[a.jsx("button",{className:"nc-collapse-btn",onClick:z,title:f("collapse"),children:"⟨"}),a.jsx("span",{className:"nc-side-title",children:f("fleet")}),ae&&a.jsx("span",{className:"nc-side-fleet-stale",role:"status",title:f("reorder-blocked"),"aria-label":f("reorder-blocked"),children:"⇅"}),N&&a.jsx("span",{className:"nc-side-fleet-stale",role:"status",title:f("fleet-stale"),"aria-label":f("fleet-stale"),children:"●"}),E!==null&&a.jsx("span",{className:"nc-side-fleet-off",role:"status",title:`${f("fleet-off")}${E?` (${E})`:""}`,"aria-label":`${f("fleet-off")}${E?` (${E})`:""}`,children:"○"}),a.jsxs("button",{className:"nc-new-btn",onClick:_,title:f("fleet-new-cell"),children:["+ ",f("new")]})]}),a.jsxs("button",{className:"nc-side-gear",onClick:()=>b&&b("nodes",!1),title:f("settings"),children:[a.jsx(_t,{name:"gear",size:15})," ",f("settings")]}),a.jsx(iC,{pinError:Q,onRetry:re,onDismiss:je}),a.jsxs("div",{className:"nc-side-scroll",children:[a.jsx(TD,{label:f("position-local"),count:Cn.length,state:te("local"),onToggle:()=>ne("local",{open:!te("local").open}),onFilter:G=>ne("local",{filter:G})}),te("local").open&&a.jsxs("div",{className:"nc-side-group",children:[Cn.map(G=>G.type==="cell"?(()=>{var Yt;const fe=G.value,Te=Z([]),Ze=Id({hostCell:Te.hostCell??null,threadStatus:Te.threadStatus,pins:L,item:G}),Pe=fe.degraded?"warn":fe.tmux?"on":"",jt=jm(Ze,Te.hostLease??null),ke=fe.degraded?f("cell-degraded"):G.subtitle||(fe.tmux?f("cell-idle"):f("cell-off")),Le=jt?`${ke} · ${f(jt)}`:ke,lt=!!fe.tmux;return a.jsxs("div",{"data-roster-key":G.key,"data-position":"local",className:`nc-cell${lt?" live":""}${Ye.has(fe.tmuxSession)?" active":""}`,title:`${fe.cell} · ${G.subtitle}${Le===G.subtitle?"":` · ${Le}`}`,"aria-label":`${fe.cell}, ${G.subtitle}${Le===G.subtitle?"":`, ${Le}`}`,draggable:lt,onDragStart:lt?De=>De.dataTransfer.setData("text/nc-session",fe.tmuxSession):void 0,onClick:lt?()=>l&&l(fe.tmuxSession):void 0,onDoubleClick:lt?()=>sn(fe.tmuxSession,"",j):void 0,children:[a.jsx(Yi,{position:"local",itemKey:G.key,label:fe.cell,canMove:me,onMove:(De,Je)=>we("local",De,Je,Dt),onStep:De=>Fe("local",G.key,De,Dt)}),lt?a.jsx("button",{type:"button",className:"nc-side-peek",title:f("cell-peek"),"aria-label":`${f("cell-peek")}: ${fe.cell}`,onClick:kt(G,fe,[],""),onMouseEnter:De=>Kt(G,"",De.currentTarget),onMouseLeave:ft,children:a.jsx("span",{className:`nc-dot ${Pe}${G.working?" working":""}`})}):a.jsx("span",{className:`nc-dot ${Pe}${G.working?" working":""}`}),a.jsxs("span",{className:"nc-cell-main",children:[a.jsxs("b",{title:fe.cell,children:[fe.cell,oo({item:G,cellName:fe.cell,route:[],pins:L,hostByRoute:W}).isLive&&a.jsx("span",{className:"nc-live-bollino",children:"LIVE"})]}),a.jsx("small",{title:G.subtitle,children:G.subtitle})]}),G.activity?a.jsx("span",{className:"nc-rel",children:ao(G.activity)}):null,G.fresh&&((Yt=(Y.get(fe.tmuxSession)||{}).outbox)==null?void 0:Yt.count)>0?a.jsx("span",{className:"nc-badge",title:f("new-files-outbox"),children:Y.get(fe.tmuxSession).outbox.count}):null,a.jsx("button",{type:"button",className:"nc-cellmenu",title:`${f("cell-actions-open")}: ${fe.cell}`,"aria-label":`${f("cell-actions-open")}: ${fe.cell}`,"aria-haspopup":"menu","aria-expanded":P&&P.itemKey===G.key?"true":"false",onClick:De=>{De.stopPropagation(),Xt(G.key,"",De.currentTarget,C.includes("boot")&&!!u,!1)},children:a.jsx("span",{"aria-hidden":"true",children:"⋯"})}),a.jsx("button",{className:`nc-power${fe.tmux?" on":""}${fe.degraded?" warn":""}`,onClick:De=>{De.stopPropagation(),c&&c({...fe,boot:Ut(fe)})},title:fe.active?f("power-off"):f("power-on"),children:a.jsx(_t,{name:"power",size:14})})]},G.key)})():(()=>{var Te;const fe=G.value;return a.jsxs("div",{"data-roster-key":G.key,"data-position":"local",className:`nc-side-card${Ye.has(fe.name)?" active":""}`,draggable:!0,onDragStart:Ze=>Ze.dataTransfer.setData("text/nc-session",fe.name),onClick:()=>l&&l(fe.name),onDoubleClick:()=>sn(fe.name,"",j),children:[a.jsx(Yi,{position:"local",itemKey:G.key,label:fe.name,canMove:me,onMove:(Ze,Pe)=>we("local",Ze,Pe,Dt),onStep:Ze=>Fe("local",G.key,Ze,Dt)}),a.jsx("span",{className:fe.attached?"nc-dot on":"nc-dot"}),a.jsxs("span",{className:"nc-card-main",children:[a.jsx("b",{children:fe.name}),a.jsxs("small",{children:[fe.preview||fe.cmd||f("windows").replace("{n}",String(fe.windows||0)),((Te=fe.outbox)==null?void 0:Te.count)>0?` · 📦${fe.outbox.count}`:""]})]}),fe.activity?a.jsx("span",{className:"nc-rel",children:ao(fe.activity)}):null,a.jsx("button",{className:`nc-pin${L.includes(G.key)?" on":""}`,title:f("pin"),onClick:Ze=>{Ze.stopPropagation(),A(G.key)},children:L.includes(G.key)?"★":"☆"}),a.jsx("button",{className:`nc-technical${fe.technical?" on":""}`,title:fe.technical?f("mark-normal"):f("mark-technical"),"aria-label":`${fe.technical?f("mark-normal"):f("mark-technical")} ${fe.name}`,onClick:Ze=>{Ze.stopPropagation(),v&&v(fe.name,!fe.technical,[])},children:"T"}),a.jsx("button",{className:"nc-menu",title:f("terminate"),onClick:Ze=>{Ze.stopPropagation(),window.confirm(f("terminate-confirm").replace("{name}",fe.name))&&p&&p(fe.name)},children:"⋯"})]},G.key)})()),Cn.length===0&&a.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]}),on.map(({g:G,nodeRoute:fe,groupView:Te,rawItems:Ze,items:Pe})=>{const jt=cC(G.health),ke=G.fleetState==="stale"?f("fleet-stale"):G.fleetState==="disabled"?f("fleet-off"):"",Le=G.fleetState==="stale"?"warn":jt||(G.status==="up"?"on":G.status==="passive"?"":"warn"),lt=[G.health?qd(G.health):"",ke].filter(Boolean).join(" · "),Yt=G.status==="up"?[f("node-sessions").replace("{n}",String(Pe.length)),ke].filter(Boolean).join(" · "):G.health&&qd(G.health)||Ji(G);if(G.kind==="vl"){const De=Ji(G)||[f("node-sessions").replace("{n}",String(G.sessions.length)),ke].filter(Boolean).join(" · ");return a.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":ce(G),children:[a.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>ne(fe,{open:!Te.open}),onKeyDown:Je=>{(Je.key==="Enter"||Je.key===" ")&&(Je.preventDefault(),ne(fe,{open:!Te.open}))},children:[a.jsx(Yi,{scope:"node",position:"nodes",itemKey:ce(G),label:G.label||G.name,onMove:(Je,Pt)=>He(Je,Pt,s||[]),onStep:Je=>X(ce(G),Je,s||[])}),a.jsx("span",{className:"nc-node-chevron",children:Te.open?"⌄":"›"}),a.jsx("span",{className:`nc-dot ${Le}`,title:lt}),a.jsxs("span",{className:"nc-node-main",children:[a.jsx("b",{children:G.label||G.name}),a.jsx("small",{title:De,children:De})]})]}),G.status==="up"&&Te.open&&a.jsxs("div",{className:"nc-side-group",children:[G.sessions.map(Je=>a.jsxs("div",{className:"nc-side-card nc-vl-session-row",role:"button",tabIndex:0,onClick:()=>V&&V(G.peer),onKeyDown:Pt=>{(Pt.key==="Enter"||Pt.key===" ")&&(Pt.preventDefault(),V&&V(G.peer))},children:[a.jsx("span",{className:"nc-dot on"}),a.jsxs("span",{className:"nc-card-main",children:[a.jsx("b",{children:Je.name}),a.jsx("small",{children:f("vl-events-title")})]})]},Je.key)),G.sessions.length===0&&a.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]})]},`nodo-vl-${fe}-${G.name}`)}return a.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":ce(G),children:[a.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:G.direct&&g?De=>{De.preventDefault(),En(G)}:void 0,onClick:()=>ne(fe,{open:!Te.open}),onKeyDown:De=>{(De.key==="Enter"||De.key===" ")&&(De.preventDefault(),ne(fe,{open:!Te.open}))},children:[a.jsx(Yi,{scope:"node",position:"nodes",itemKey:ce(G),label:G.label||G.name,onMove:(De,Je)=>He(De,Je,s||[]),onStep:De=>X(ce(G),De,s||[])}),a.jsx("span",{className:"nc-node-chevron",children:Te.open?"⌄":"›"}),a.jsx("span",{className:`nc-dot ${Le}`,title:lt}),a.jsxs("span",{className:"nc-node-main",children:[a.jsx("b",{children:G.label||G.name}),a.jsx("small",{title:Yt,children:Yt})]}),G.direct&&g&&a.jsx("button",{type:"button",className:"nc-node-rename",title:f("rename-node"),"aria-label":`${f("rename-node")} ${G.label||G.name}`,onClick:De=>{De.stopPropagation(),En(G)},children:"✎"}),G.direct&&G.health&&G.health.managed!==!1&&a.jsx("button",{type:"button",className:`nc-power${G.tunnelStatus==="up"?" on":""}`,title:G.tunnelStatus==="up"?f("power-off"):f("power-on"),onClick:De=>{De.stopPropagation(),h&&h(G)},children:a.jsx(_t,{name:"power",size:14})}),a.jsxs("select",{className:"nc-node-filter",value:Te.filter,title:f(`view-${Te.filter}`),onClick:De=>De.stopPropagation(),onChange:De=>ne(fe,{filter:De.target.value}),children:[a.jsx("option",{value:"all",children:f("view-all")}),a.jsx("option",{value:"pinned",children:f("view-pinned")}),a.jsx("option",{value:"active",children:f("view-active")}),a.jsx("option",{value:"off",children:f("view-off")}),a.jsx("option",{value:"technical",children:f("view-technical")})]})]}),(G.status==="up"||G.cellsPreserved)&&Te.open&&a.jsxs("div",{className:"nc-side-group",children:[Pe.map(De=>De.type==="cell"?(()=>{var Xn;const Je=De.value,Pt=G.route||[G.name],be=Z(Pt),Re=Id({hostCell:be.hostCell??null,threadStatus:be.threadStatus,pins:L,item:De}),Ke=jm(Re,be.hostLease??null),at=!!Je.tmux&&!G.cellsPreserved,wt=Je.degraded?"warn":Je.tmux&&!G.cellsPreserved?"on":"",Gn=(G.sessions||[]).find(Ot=>Ot&&Ot.name===Je.tmuxSession)||null,Fs=G.cellsPreserved?`${f("fleet-stale")}`:De.subtitle||(Je.tmux?f("cell-idle"):f("cell-off")),Wt=Ke?`${Fs} · ${f(Ke)}`:Fs;return a.jsxs("div",{"data-roster-key":De.key,"data-position":fe,className:`nc-side-card nc-cell${at?" live":""}${G.cellsPreserved?" preserved":""}${Ye.has(Je.key)?" active":""}`,title:Wt,draggable:at,onDragStart:at?Ot=>Ot.dataTransfer.setData("text/nc-session",Je.key):void 0,onClick:at?()=>l&&l(Je.key):void 0,onDoubleClick:at?()=>sn(Je.tmuxSession,fe,G.instanceId):void 0,children:[a.jsx(Yi,{position:fe,itemKey:De.key,label:Je.cell,canMove:me,onMove:(Ot,ws)=>we(fe,Ot,ws,Ze),onStep:Ot=>Fe(fe,De.key,Ot,Ze)}),at?a.jsx("button",{type:"button",className:"nc-side-peek",title:f("cell-peek"),"aria-label":`${f("cell-peek")}: ${Je.cell}`,onClick:kt(De,Je,G.route||[G.name],G.label||G.name),onMouseEnter:Ot=>Kt(De,fe,Ot.currentTarget),onMouseLeave:ft,children:a.jsx("span",{className:`nc-dot ${wt}${De.working?" working":""}`})}):a.jsx("span",{className:`nc-dot ${wt}${De.working?" working":""}`}),a.jsxs("span",{className:"nc-card-main",children:[a.jsxs("b",{children:[Je.cell,oo({item:De,cellName:Je.cell,route:Pt,pins:L,hostByRoute:W}).isLive&&a.jsx("span",{className:"nc-live-bollino",children:"LIVE"})]}),a.jsx("small",{title:De.subtitle,children:De.subtitle})]}),De.activity?a.jsx("span",{className:"nc-rel",children:ao(De.activity)}):null,De.fresh&&((Xn=(Gn||{}).outbox)==null?void 0:Xn.count)>0?a.jsx("span",{className:"nc-badge",title:f("new-files-outbox"),children:Gn.outbox.count}):null,a.jsx("button",{type:"button",className:"nc-cellmenu",title:`${f("cell-actions-open")}: ${Je.cell}`,"aria-label":`${f("cell-actions-open")}: ${Je.cell}`,"aria-haspopup":"menu","aria-expanded":P&&P.itemKey===De.key?"true":"false",onClick:Ot=>{Ot.stopPropagation(),Xt(De.key,fe,Ot.currentTarget,u&&(G.capabilities||[]).includes("boot"),!!G.cellsPreserved)},children:a.jsx("span",{"aria-hidden":"true",children:"⋯"})}),(G.capabilities||[]).includes(Je.active?"down":"up")&&a.jsx("button",{className:`nc-power${Je.active?" on":""}${Je.degraded?" warn":""}`,onClick:Ot=>{Ot.stopPropagation(),c&&c({...Je,boot:Ut(Je,G.route||[]),route:G.route,availableEngines:G.engines||[]})},title:Je.active?f("power-off"):f("power-on"),children:a.jsx(_t,{name:"power",size:14})})]},De.key)})():(()=>{const Je=De.value;return a.jsxs("div",{"data-roster-key":De.key,"data-position":fe,className:`nc-side-card${Ye.has(Je.key)?" active":""}`,draggable:!0,onDragStart:Pt=>Pt.dataTransfer.setData("text/nc-session",Je.key),onClick:()=>l&&l(Je.key),onDoubleClick:()=>sn(Je.name,Je.node||fe,G.instanceId),children:[a.jsx(Yi,{position:fe,itemKey:De.key,label:Je.name,canMove:me,onMove:(Pt,be)=>we(fe,Pt,be,Ze),onStep:Pt=>Fe(fe,De.key,Pt,Ze)}),a.jsx("span",{className:Je.attached?"nc-dot on":"nc-dot"}),a.jsxs("span",{className:"nc-card-main",children:[a.jsx("b",{children:Je.name}),a.jsx("small",{children:Je.preview?Je.preview:Je.cmd?Je.cmd:f("windows").replace("{n}",String(Je.windows||0))})]}),Je.activity?a.jsx("span",{className:"nc-rel",children:ao(Je.activity)}):null,a.jsx("button",{className:`nc-pin${L.includes(De.key)?" on":""}`,title:f("pin"),onClick:Pt=>{Pt.stopPropagation(),A(De.key)},children:L.includes(De.key)?"★":"☆"}),a.jsx("button",{className:`nc-technical${Je.technical?" on":""}`,title:Je.technical?f("mark-normal"):f("mark-technical"),"aria-label":`${Je.technical?f("mark-normal"):f("mark-technical")} ${Je.name}`,onClick:Pt=>{Pt.stopPropagation(),v&&v(Je.name,!Je.technical,G.route||[])},children:"T"}),a.jsx("button",{className:"nc-menu",title:f("terminate"),onClick:Pt=>{Pt.stopPropagation(),window.confirm(f("terminate-confirm").replace("{name}",Je.name))&&p&&p(Je.name,G.route)},children:"⋯"})]},De.key)})()),Pe.length===0&&a.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]})]},`nodo-${(G.route||[G.name]).join("/")}`)})]}),a.jsx("div",{className:"nc-side-lang",children:a1.map((G,fe)=>a.jsxs("span",{children:[fe>0&&" · ",a.jsx("button",{className:`nc-lang-btn${R===G?" on":""}`,onClick:()=>M(G),title:G,children:G.toUpperCase()})]},G))}),a.jsx("div",{className:"nc-side-resize",onPointerDown:ct,title:""}),un&&(()=>{const G=un.value,fe=un.nodeRoute?s.find(Ze=>(Ze.route||[Ze.name]).join("/")===un.nodeRoute)||{}:null,Te=un.nodeRoute?fe.route||[un.nodeRoute]:[];return a.jsx(Wk,{row:Nt(un,G,Te,un.nodeLabel||"",fe&&fe.sessions),token:ie,initialSource:ve,onClose:()=>{ze(null),Oe("preview")}})})(),Ht(),P&&(()=>{const G=tn.find(Le=>Le.key===P.itemKey);if(!G)return null;const fe=G.value,Te=P.routeKey?s.find(Le=>(Le.route||[Le.name]).join("/")===P.routeKey)||{}:null,Ze=P.routeKey?Te.route||[P.routeKey]:[],Pe=P.preserved?!1:!!fe.tmux,jt=oo({item:G,cellName:fe.cell,route:Ze,pins:L,hostByRoute:W}),ke=Hv({...jt,canBoot:P.canBoot,boot:Ut(fe,Ze),alive:Pe,handlers:ds(G,fe,Ze)});return a.jsx(aC,{anchorRect:_e,items:ke,busy:oe,onClose:()=>le(null)})})()]})}function MD({view:t,notice:e}){const n=!!(t&&t.cell),s=n?f("live-host-indicator").replace("{cell}",t.cell).replace("{mode}",f(t.mode?`live-host-mode-${t.mode}`:"live-host-mode-unknown")).replace("{state}",f(`live-host-state-${t.state||"none"}`)):f("live-host-indicator-none");return a.jsxs("div",{className:"nc-live-strip","data-state":t&&t.state?t.state:"none",title:e?`${s} · ${f(e.messageKey)}`:s,children:[a.jsx("span",{className:`nc-live-strip-dot ${mv(t||{})}`,"aria-hidden":"true"}),a.jsx("span",{className:"nc-live-strip-testo",children:n?t.cell:s}),a.jsx(g1,{view:t}),e&&a.jsx("span",{className:`nc-live-strip-notice${e.ok?" ok":" ko"}`,role:"status",children:f(e.messageKey).replace("{cell}",e.cell||t.cell||"")})]})}function TD({label:t,count:e,state:n,onToggle:s,onFilter:i}){return a.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:s,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),s())},children:[a.jsx("span",{className:"nc-node-chevron",children:n.open?"⌄":"›"}),a.jsx("span",{className:"nc-dot on"}),a.jsxs("span",{className:"nc-node-main",children:[a.jsx("b",{children:t}),a.jsx("small",{children:f("node-sessions").replace("{n}",String(e))})]}),a.jsxs("select",{className:"nc-node-filter",value:n.filter,title:f(`view-${n.filter}`),onClick:l=>l.stopPropagation(),onChange:l=>i(l.target.value),children:[a.jsx("option",{value:"all",children:f("view-all")}),a.jsx("option",{value:"pinned",children:f("view-pinned")}),a.jsx("option",{value:"active",children:f("view-active")}),a.jsx("option",{value:"off",children:f("view-off")}),a.jsx("option",{value:"technical",children:f("view-technical")})]})]})}const ms={PRESENTE:"presente-verificata",ASSENTE:"assente-verificata",IGNOTA:"ignota"},$p={OK:"ok",NON_DISPONIBILE:"non-disponibile",RIMOSSO:"rimosso"},ud={LETTURA_NON_VERIFICABILE:"lettura-non-verificabile",OWNER_NON_DISPONIBILE:"owner-non-disponibile",OWNER_RIMOSSO:"owner-rimosso",LOCALE_NON_VERIFICATO:"lettura-locale-non-verificata"},uS={RITORNO:"ritorno-dopo-assenza",IDENTITA:"identita-cambiata"},PD=6e4;function ID(t,e){return!t||!Array.isArray(e)?null:e.find(n=>Array.isArray(n==null?void 0:n.route)&&n.route.join("/")===t)||null}function dS(t){const e=t&&t.created;return Number.isFinite(e)&&e>0?e:null}function DD({tileKey:t,node:e,nodeGroups:n,sessionsAlive:s,localVerified:i=!0,localIdentita:l=null,lastVerifiedAt:c=null,nowMs:u=0}={}){const h=ID(e,n);let p,v=$p.OK,_=null,g=null;if(!e)i?!s||s.has(t)?(p=ms.PRESENTE,g=dS({created:l})):p=ms.ASSENTE:(p=ms.IGNOTA,_=ud.LOCALE_NON_VERIFICATO);else if(!h)p=ms.IGNOTA,v=$p.RIMOSSO,_=ud.OWNER_RIMOSSO;else if(h.status!=="up")p=ms.IGNOTA,v=$p.NON_DISPONIBILE,_=h.cause||ud.OWNER_NON_DISPONIBILE;else if(h.inventoryPartial===!0)p=ms.IGNOTA,_=ud.LETTURA_NON_VERIFICABILE;else if(!s||s.has(t)){p=ms.PRESENTE;const S=Array.isArray(h.sessions)?h.sessions.find(j=>j&&j.key===t):null;g=dS(S)}else p=ms.ASSENTE;const b=p===ms.IGNOTA&&Number.isFinite(c)&&Number.isFinite(u)&&u-c>PD;return{presenza:p,owner:v,causa:_,identita:p===ms.PRESENTE?g:null,verificata:p!==ms.IGNOTA,oltreIlTetto:b}}function WC(){return{presenza:null,identita:null}}function OD(t,e){const n=t&&typeof t=="object"?t:WC();if(!e||e.presenza===ms.IGNOTA)return{runtime:{presenza:n.presenza,identita:n.identita},generazione:0,motivo:null};const s=e.presenza===ms.PRESENTE;let i=null;return s&&(n.presenza===ms.ASSENTE?i=uS.RITORNO:n.presenza===ms.PRESENTE&&n.identita!==null&&e.identita!==null&&n.identita!==e.identita&&(i=uS.IDENTITA)),{runtime:{presenza:e.presenza,identita:s?e.identita===void 0?null:e.identita:null},generazione:i?1:0,motivo:i}}const Gv="nc_input_preferences_v1",zp="nc-input-preferences",qC=Object.freeze(["double-tap","single-tap","never"]),KC=Object.freeze(["full","compact"]);function BD(){try{return typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)").matches:!1}catch{return!1}}const xr=Object.freeze({terminalKeyboardGesture:"double-tap",keybarKeepsKeyboardClosed:!0,voiceKeepsKeyboardClosed:!0,showKeybarEnter:!0,keybarLayout:"full",showComposer:BD()});function Xv(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{};return{terminalKeyboardGesture:qC.includes(e.terminalKeyboardGesture)?e.terminalKeyboardGesture:xr.terminalKeyboardGesture,keybarKeepsKeyboardClosed:typeof e.keybarKeepsKeyboardClosed=="boolean"?e.keybarKeepsKeyboardClosed:xr.keybarKeepsKeyboardClosed,voiceKeepsKeyboardClosed:typeof e.voiceKeepsKeyboardClosed=="boolean"?e.voiceKeepsKeyboardClosed:xr.voiceKeepsKeyboardClosed,showKeybarEnter:typeof e.showKeybarEnter=="boolean"?e.showKeybarEnter:xr.showKeybarEnter,keybarLayout:KC.includes(e.keybarLayout)?e.keybarLayout:xr.keybarLayout,showComposer:typeof e.showComposer=="boolean"?e.showComposer:xr.showComposer}}function VC(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function hS(t=VC()){if(!t)return{...xr};try{return Xv(JSON.parse(t.getItem(Gv)||"null"))}catch{return{...xr}}}function $D(t,e=VC()){const n=Xv(t);if(e)try{e.setItem(Gv,JSON.stringify(n))}catch{}return n}function Jv(){const[t,e]=y.useState(hS);y.useEffect(()=>{const s=i=>{if((i==null?void 0:i.type)==="storage"&&i.key!==Gv&&i.key!==null)return;const l=i!=null&&i.detail?Xv(i.detail):hS();e(l)};return window.addEventListener(zp,s),window.addEventListener("storage",s),()=>{window.removeEventListener(zp,s),window.removeEventListener("storage",s)}},[]);const n=y.useCallback(s=>{e(i=>{const l=$D({...i,...s||{}});return window.dispatchEvent(new CustomEvent(zp,{detail:l})),l})},[]);return[t,n]}function zD({session:t,node:e,ownerId:n,cellName:s,token:i,readonly:l=!1,focused:c,onFocus:u,onClose:h,onOpenSingle:p,onDragTileStart:v,floating:_=!1,minimized:g=!1,takeSize:b=!1,onDetach:S,onReattach:j,onToggleMinimize:C,onFloatDragStart:N,alive:E=!0,sessionAlive:O=E,available:x=!0,stale:W=!1,presence:$=null,fontSize:J=_i,onZoom:q,decks:V=[],currentDeck:ie,onSendToDeck:K,panelUrl:B="",panelCellId:I="",panelPort:D=0}){const[T]=Jv(),z=s||t,R=y.useRef(()=>{}),M=y.useRef(()=>!1),L=y.useRef(()=>{}),H=y.useRef(!1),[A,U]=y.useState(!1),[Q,ae]=y.useState(!1),[re,je]=y.useState(!1),[te,ne]=y.useState(!1),[me,we]=y.useState(null),[Fe,Ae]=y.useState(0),He=y.useRef(WC()),X=e?`${e}:${t}`:t,ce=V.filter(Y=>Y.id!==ie&&Y.available!==!1),Z=$?$.presenza:O?ms.PRESENTE:ms.ASSENTE,ge=$?$.identita??null:null;return y.useEffect(()=>{const Y=OD(He.current,{presenza:Z,identita:ge});He.current=Y.runtime,Y.generazione&&Ae(he=>he+Y.generazione)},[Z,ge]),a.jsxs("div",{className:`nc-tile${c?" focused":""}`,onMouseDown:()=>u&&u(X),children:[a.jsxs("div",{className:`nc-tile-head${_?" nc-float-head":""}`,draggable:!_,onPointerDown:_&&N?Y=>{Y.target&&Y.target.closest&&Y.target.closest(".nc-tile-actions")||N(Y)}:void 0,onDragStart:Y=>{_||(Y.dataTransfer.setData("text/nc-session",X),Y.dataTransfer.effectAllowed="move",v&&v(X))},children:[a.jsxs("button",{className:"nc-tile-name",onClick:()=>u&&u(X),title:e?`${z} · ${e}`:z,children:[a.jsx("span",{className:E?"nc-dot on":"nc-dot"}),a.jsx("b",{children:z})]}),a.jsxs("span",{className:"nc-tile-actions",children:[_?a.jsxs(a.Fragment,{children:[j&&a.jsx("button",{className:"nc-tile-float-btn",onClick:()=>j(X),title:f("tile-reattach"),"aria-label":f("tile-reattach"),children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("rect",{x:"9",y:"3",width:"12",height:"12",rx:"1"}),a.jsx("path",{d:"M11 21H3v-8M3 21l9-9"})]})}),C&&a.jsx("button",{onClick:()=>C(X),title:f(g?"tile-restore":"tile-minimize"),"aria-label":f(g?"tile-restore":"tile-minimize"),children:"–"})]}):a.jsxs(a.Fragment,{children:[q&&a.jsx("button",{onClick:()=>q(-1),title:f("zoom-out"),"aria-label":f("zoom-out"),children:a.jsx(_t,{name:"zoomOut",size:14})}),q&&a.jsx("button",{onClick:()=>q(1),title:f("zoom-in"),"aria-label":f("zoom-in"),children:a.jsx(_t,{name:"zoomIn",size:14})}),K&&ce.length>0&&a.jsxs("select",{className:"nc-tile-deck",title:f("send-to-deck"),value:"",onMouseDown:Y=>Y.stopPropagation(),onChange:Y=>{const he=Y.target.value;he&&K(X,he),Y.target.value=""},children:[a.jsx("option",{value:"",children:f("send-to-deck")}),ce.map(Y=>a.jsxs("option",{value:Y.id,children:[Y.ownerLabel," · ",Y.name]},Y.id))]}),a.jsx("button",{onClick:()=>ae(Y=>!Y),title:f("composer"),children:"⌨"}),a.jsx("button",{onClick:()=>je(Y=>!Y),title:f("files"),children:"📁"}),B&&a.jsx("button",{onClick:()=>ne(Y=>!Y),title:f("panel"),"aria-pressed":te,children:a.jsx(_t,{name:"monitor",size:14})}),p&&a.jsx("button",{onClick:()=>p({session:t,node:e,ownerId:n}),title:f("single-view"),children:"↗"})]}),!_&&S&&a.jsx("button",{className:"nc-tile-float-btn",onClick:()=>S(X),title:f("tile-detach"),"aria-label":f("tile-detach"),children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("rect",{x:"3",y:"9",width:"12",height:"12",rx:"1"}),a.jsx("path",{d:"M13 3h8v8M21 3l-9 9"})]})}),h&&a.jsx("button",{className:"nc-tile-close",onClick:()=>h(X),title:f("close"),"aria-label":f("close"),children:"✕"})]})]}),a.jsxs("div",{className:"nc-tile-body",children:[$&&$.oltreIlTetto===!0&&a.jsx("div",{className:"nc-tile-unverified",role:"status","data-causa":$.causa||"",children:f("tile-unverified")}),a.jsx(wc,{session:t,node:e,token:i,readonly:l,takeSize:b,focused:c,sendRef:R,composerRef:M,actionRef:L,ctrlRef:H,setCtrlArmed:U,onFiles:we,fontSize:J,keyboardGesture:T.terminalKeyboardGesture},`${X}:${Fe}`),!x&&a.jsx("div",{className:"nc-tile-unavailable",title:f("deck-owner-unavailable"),children:f("deck-owner-reconnecting")}),x&&W&&a.jsx("div",{className:"nc-tile-stale",title:f("deck-owner-stale"),children:f("deck-owner-stale")}),x&&re&&a.jsx("div",{className:"nc-tile-files",onMouseDown:Y=>Y.stopPropagation(),children:a.jsx(zg,{session:t,node:e,token:i,filesEvent:me,onClose:()=>je(!1)})})]}),x&&Q&&a.jsx("div",{className:"nc-tile-composer",onMouseDown:Y=>Y.stopPropagation(),children:a.jsx(UC,{submitText:Y=>M.current(Y),token:i,session:t,node:e,ownerId:n,readonly:l,keepKeyboardClosedOnVoice:T.voiceKeepsKeyboardClosed})}),x&&te&&B&&I&&a.jsx(_1,{title:z,onClose:()=>ne(!1),children:a.jsx(Mv,{cellId:I,panelUrl:B,route:e?e.split("/"):[],panelPort:D,token:i,title:z})})]})}function Ug({session:t,node:e,ownerId:n,cells:s,nodeGroups:i}={}){const l=typeof t=="string"?t:"";if(!l)return null;if(e){const u=Array.isArray(i)?i:[];for(const h of u){if(!h||(Array.isArray(h.route)?h.route:[]).join("/")!==e||n&&h.instanceId&&String(n)!==String(h.instanceId))continue;const v=(Array.isArray(h.cells)?h.cells:[]).find(_=>_&&_.tmuxSession===l);if(v)return v}return null}return(Array.isArray(s)?s:[]).find(u=>u&&u.tmuxSession===l)||null}function $c({session:t,cell:e,node:n,ownerId:s,cells:i,nodeGroups:l}={}){const c=typeof t=="string"?t:"";if(e&&typeof e.cell=="string"&&e.cell)return e.cell;const u=Ug({session:c,node:n,ownerId:s,cells:i,nodeGroups:l});return u&&u.cell?u.cell:c}const fS=.22,pS=.3,YC=(t,e)=>Array.from((t==null?void 0:t.types)||[]).includes(e),Fp=t=>YC(t,"text/nc-session"),mS=t=>{var e;return YC(t,"Files")||(((e=t==null?void 0:t.files)==null?void 0:e.length)||0)>0};function FD(t,e){return t&&Array.isArray(e)?e.find(n=>Array.isArray(n==null?void 0:n.route)&&n.route.join("/")===t):null}function HD(t,e,n){const s=(t-n.left)/(n.width||1),i=(e-n.top)/(n.height||1);return s<fS?"left":s>1-fS?"right":i>=pS&&i<=1-pS?"center":i<.5?"top":"bottom"}const UD=[["left","M15 6l-6 6 6 6",22],["top","M6 15l6-6 6 6",22],["center","M4 8h16M20 8l-3-3M20 8l-3 3M20 16H4M4 16l3-3M4 16l3 3",34],["bottom","M6 9l6 6 6-6",22],["right","M9 6l6 6-6 6",22]];function WD({active:t}){return a.jsx("div",{className:"nc-drop-zones","data-testid":"nc-drop-zones","aria-hidden":"true",children:UD.map(([e,n,s])=>a.jsx("div",{className:`nc-drop-zone ${e}${t===e?" on":""}`,"data-zone":e,children:a.jsx("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:n})})},e))})}function Hp(t,e){for(const n of t.columns)for(const s of n.tiles)if(zt(s)===e)return s.float||null;return null}function gS(t,e){for(const n of t.columns)for(const s of n.tiles)if(zt(s)===e)return s.fontSize||null;return null}function qD({layout:t,onLayoutChange:e,token:n,readonly:s=!1,sessionsAlive:i,focusSession:l,onFocus:c,onOpenSingle:u,localVerified:h=!0,localIdentities:p=null,localVerifiedAt:v=null,decks:_=[],currentDeck:g,onSendToDeck:b,onResizeEnd:S,cells:j=[],nodeGroups:C=[],panelPort:N=0,nodePanelPorts:E={}}){zn();const O=Date.now(),[x,W]=y.useState(null),[$,J]=y.useState(null),q=y.useRef(null);q.current=$;const[V,ie]=y.useState({z:{},next:1,focus:null,mini:{}}),[K,B]=y.useState(null),I=y.useRef(null);I.current=K;const D=y.useRef(null),T=y.useRef([]),z=y.useRef(null);function R(Y,he,Ne){const Ce=()=>{window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",Ve),window.removeEventListener("pointercancel",Ye),window.removeEventListener("blur",Ye)},Ve=()=>{Ce(),z.current=null,he&&he()},Ye=()=>{Ce(),z.current=null,Ne&&Ne()};window.addEventListener("pointermove",Y),window.addEventListener("pointerup",Ve),window.addEventListener("pointercancel",Ye),window.addEventListener("blur",Ye),z.current=Ye}y.useEffect(()=>()=>{z.current&&z.current()},[]),y.useEffect(()=>{if(!x&&!K)return;const Y=he=>{he.key==="Escape"&&(W(null),K&&z.current&&z.current())};return window.addEventListener("keydown",Y),()=>{window.removeEventListener("keydown",Y)}},[x,K]),y.useEffect(()=>{const Y=()=>W(null);return window.addEventListener("dragend",Y),window.addEventListener("drop",Y),()=>{window.removeEventListener("dragend",Y),window.removeEventListener("drop",Y)}},[]);const M=t.columns.length,L=t.columns.flatMap(Y=>Y.tiles).filter(Y=>Y.float).map(Y=>zt(Y)),H=Y=>!!Y&&Y.tiles.length>0&&Y.tiles.every(he=>he.float),A=Y=>x&&x.col===Y&&x.row===void 0,U=!!x&&x.col===M,Q=(Y,he)=>x&&x.col===Y&&x.row===he&&x.quadrant?` drop-${x.quadrant}`:"";function ae(Y){var Ve;if(Y.preventDefault(),mS(Y.dataTransfer)){W(null);return}const he=Y.dataTransfer.getData("text/nc-session"),Ne=x;if(W(null),!he||!Ne)return;if(Ne.quadrant==="center"){const Ye=zt(((Ve=t.columns[Ne.col])==null?void 0:Ve.tiles[Ne.row])||{});Ye&&Ye!==he&&e(hI(t,he,Ye));return}let Ce;if(Ne.quadrant){if(Ce=bI(t,Ne.col,Ne.row,Ne.quadrant),!Ce)return}else Ce={col:Ne.col};e(ys(t).includes(he)?uI(t,he,Ce):Dc(t,he,Ce))}function re(Y,he){var ee,P,le;Y.preventDefault(),Y.stopPropagation();try{Y.currentTarget.setPointerCapture&&Y.pointerId!=null&&Y.currentTarget.setPointerCapture(Y.pointerId)}catch{}const Ne=D.current&&D.current.clientWidth||0,Ce=D.current?D.current.getBoundingClientRect():null,Ve=Ce?Ce.left:0,Ye=T.current[he]?T.current[he].getBoundingClientRect():null,ht=T.current[he+1]?T.current[he+1].getBoundingClientRect():null,ze=Ye&&ht&&ht.right>Ye.left?Ye.left-(Ce?Ce.left:0):0,ve=Number.isFinite(Y.clientX)?Y.clientX:0,Oe=t.columns[he].width+(((ee=t.columns[he+1])==null?void 0:ee.width)||0),et=t.columns.reduce((_e,Me)=>_e+Me.width,0),Ue=Ye&&ht&&ht.right>Ye.left?ht.right-Ye.left:Ne*(Oe/(et||1)),st=Math.min(_C,Ue/2),ot=_e=>{const Me=(Number.isFinite(_e.clientX)?_e.clientX:ve)-Ve;let oe=Math.max(st,Math.min(Ue-st,Me-ze)),Be=!1;if(!_e.altKey){for(const gt of _c)if(Math.abs(oe-gt*Ue)<=Pg){oe=gt*Ue,Be=!0;break}}return{border:oe,snapped:Be,alt:_e.altKey===!0}};J({kind:"col",ci:he,coupleLeft:ze,couplePx:Ue,live:ot(Y),pxOther:D.current&&D.current.clientHeight||0,fsA:((P=t.columns[he].tiles[0])==null?void 0:P.fontSize)||_i,fsB:((le=t.columns[he+1].tiles[0])==null?void 0:le.fontSize)||_i}),R(_e=>J(Me=>Me&&{...Me,live:ot(_e)}),()=>{var oe,Be;const _e=q.current,Me=((oe=_e==null?void 0:_e.live)==null?void 0:oe.border)??Ue/2;J(null),e(eS(t,he,Ne,Me,{snap:!((Be=_e==null?void 0:_e.live)!=null&&Be.alt)})),S&&S()},()=>J(null))}function je(Y){const he=D.current&&D.current.clientWidth||0;e(eS(t,Y,he,Number.NaN,{snap:!0,half:!0})),S&&S()}function te(Y,he,Ne){var oe;Y.preventDefault(),Y.stopPropagation();try{Y.currentTarget.setPointerCapture&&Y.pointerId!=null&&Y.currentTarget.setPointerCapture(Y.pointerId)}catch{}const Ce=T.current[he],Ve=Ce&&Ce.clientHeight||D.current&&D.current.clientHeight||0,Ye=D.current?D.current.getBoundingClientRect():null,ht=Ye?Ye.top:0,ze=Ce?Ce.getBoundingClientRect():null,ve=ze?ze.left-(Ye?Ye.left:0):0,Oe=ze&&ze.width>0?ze.width:Ce&&Ce.clientWidth||0,et=Number.isFinite(Y.clientY)?Y.clientY:0,Ue=t.columns[he].tiles,st=Ue[Ne].height+(((oe=Ue[Ne+1])==null?void 0:oe.height)||0),ot=Ue.reduce((Be,gt)=>Be+gt.height,0),ee=Ue.slice(0,Ne).reduce((Be,gt)=>Be+gt.height,0),P=(ze&&ze.height>0?ze.top-ht:0)+Ve*(ee/(ot||1)),le=(ze&&ze.height>0,Ve*(st/(ot||1))),_e=Math.min(yC,le/2),Me=Be=>{const gt=(Number.isFinite(Be.clientY)?Be.clientY:et)-ht;let Lt=Math.max(_e,Math.min(le-_e,gt-P)),Nt=!1;if(!Be.altKey){for(const kt of _c)if(Math.abs(Lt-kt*le)<=Pg){Lt=kt*le,Nt=!0;break}}return{border:Lt,snapped:Nt,alt:Be.altKey===!0}};J({kind:"row",ci:he,ri:Ne,coupleTop:P,couplePx:le,colLeft:ve,colWidth:Oe,live:Me(Y),pxOther:Ce&&Ce.clientWidth||D.current&&D.current.clientWidth||0,fsA:Ue[Ne].fontSize||_i,fsB:Ue[Ne+1].fontSize||_i}),R(Be=>J(gt=>gt&&{...gt,live:Me(Be)}),()=>{var Lt,Nt;const Be=q.current,gt=((Lt=Be==null?void 0:Be.live)==null?void 0:Lt.border)??le/2;J(null),e(tS(t,he,Ne,Ve,gt,{snap:!((Nt=Be==null?void 0:Be.live)!=null&&Nt.alt)})),S&&S()},()=>J(null))}function ne(Y,he){const Ne=T.current[Y],Ce=Ne&&Ne.clientHeight||D.current&&D.current.clientHeight||0;e(tS(t,Y,he,Ce,Number.NaN,{snap:!0,half:!0})),S&&S()}function me(Y){e(Oc(t,Y))}const we={x:.45,y:.12,w:.42,h:.6},Fe=8;function Ae(Y){ie(he=>({...he,z:{...he.z,[Y]:he.next},next:he.next+1,focus:Y})),c&&c(Y)}function He(Y){ie(he=>({...he,mini:{...he.mini,[Y]:!he.mini[Y]}}))}function X(Y){L.length>=Xc||e(fI(t,Y,we))}function ce(Y,he){const Ne=[0,1];let Ce=!1,Ve=Y;for(const Ye of[...Ne,...he])if(Math.abs(Y-Ye)<=Fe/window.innerWidth){Ve=Ye,Ce=!0;break}return{v:Math.max(0,Math.min(1,Ve)),snapped:Ce}}function Z(Y,he){Y.preventDefault(),Y.stopPropagation();try{Y.currentTarget.setPointerCapture&&Y.pointerId!=null&&Y.currentTarget.setPointerCapture(Y.pointerId)}catch{}const Ne=Hp(t,he);if(!Ne)return;const Ce=Number.isFinite(Y.clientX)?Y.clientX:0,Ve=Number.isFinite(Y.clientY)?Y.clientY:0,Ye=L.filter(Oe=>Oe!==he).map(Oe=>Hp(t,Oe)).filter(Boolean),ht=Ye.flatMap(Oe=>[Oe.x,Oe.x+Oe.w]),ze=Ye.flatMap(Oe=>[Oe.y,Oe.y+Oe.h]),ve=Oe=>{const et=(Number.isFinite(Oe.clientX)?Oe.clientX:Ce)-Ce,Ue=(Number.isFinite(Oe.clientY)?Oe.clientY:Ve)-Ve,st=ce(Ne.x+et/Math.max(1,window.innerWidth),ht),ot=ce(Ne.y+Ue/Math.max(1,window.innerHeight),ze);return{x:st.v,y:ot.v,w:Ne.w,h:Ne.h,snappedX:st.snapped,snappedY:ot.snapped}};B({key:he,kind:"move",live:ve(Y)}),R(Oe=>B(et=>et&&{...et,live:ve(Oe)}),()=>{var et;const Oe=(et=I.current)==null?void 0:et.live;B(null),Oe&&e(nS(t,he,Oe))},()=>B(null))}function ge(Y,he,Ne){Y.preventDefault(),Y.stopPropagation();try{Y.currentTarget.setPointerCapture&&Y.pointerId!=null&&Y.currentTarget.setPointerCapture(Y.pointerId)}catch{}const Ce=Hp(t,he);if(!Ce)return;const Ve=Number.isFinite(Y.clientX)?Y.clientX:0,Ye=Number.isFinite(Y.clientY)?Y.clientY:0,ht=Math.max(1,window.innerWidth),ze=Math.max(1,window.innerHeight);gS(t,he);const ve=Oe=>{const et=((Number.isFinite(Oe.clientX)?Oe.clientX:Ve)-Ve)/ht,Ue=((Number.isFinite(Oe.clientY)?Oe.clientY:Ye)-Ye)/ze;let{x:st,y:ot,w:ee,h:P}=Ce;return Ne.includes("e")&&(ee=Ce.w+et),Ne.includes("s")&&(P=Ce.h+Ue),Ne.includes("w")&&(st=Ce.x+et,ee=Ce.w-et),Ne.includes("n")&&(ot=Ce.y+Ue,P=Ce.h-Ue),ee=Math.max(.05,Math.min(1-st,ee)),P=Math.max(.05,Math.min(1-ot,P)),{x:st,y:ot,w:ee,h:P}};B({key:he,kind:"resize",dir:Ne,live:ve(Y),badge:!0}),R(Oe=>B(et=>et&&{...et,live:ve(Oe)}),()=>{var et;const Oe=(et=I.current)==null?void 0:et.live;B(null),Oe&&e(nS(t,he,Oe)),S&&S()},()=>B(null))}return a.jsxs("div",{className:`nc-grid${$||K?" gesturing":""}`,ref:D,onDragOver:Y=>{if(mS(Y.dataTransfer)){Y.preventDefault(),W(null);return}Fp(Y.dataTransfer)&&(Y.preventDefault(),x&&x.col===M||W({col:M}))},onDrop:ae,onDragLeave:Y=>{const he=Y.relatedTarget;(!he||!(D.current&&D.current.contains(he)))&&W(null)},children:[t.columns.flatMap((Y,he)=>{const Ne=[];return Ne.push(a.jsx("div",{className:`nc-col${A(he)?" drop-newcol":""}${H(Y)?" nc-col-emptyfloat":""}`,ref:Ce=>{T.current[he]=Ce},style:{flexGrow:H(Y)?0:Y.width,flexBasis:0},onDragOver:Ce=>{Fp(Ce.dataTransfer)&&(Ce.preventDefault(),Ce.stopPropagation(),x&&x.col===he&&x.row===void 0||W({col:he}))},children:Y.tiles.flatMap((Ce,Ve)=>{const Ye=[],ht=zt(Ce),ze=FD(Ce.node,C),ve=DD({tileKey:ht,node:Ce.node,nodeGroups:C,sessionsAlive:i,localVerified:h,localIdentita:p?p.get(ht):null,lastVerifiedAt:Ce.node?(ze==null?void 0:ze.verifiedAt)??null:v,nowMs:O}),Oe=Ce.unavailable!==!0&&(Ce.node?(ze==null?void 0:ze.status)==="up":ve.owner==="ok"),et=Ce.unavailable!==!0&&ve.presenza!=="assente-verificata",Ue=Ug({session:Ce.session,node:Ce.node,ownerId:Ce.ownerId,cells:j,nodeGroups:C}),st=$c({session:Ce.session,cell:Ue,node:Ce.node,ownerId:Ce.ownerId,cells:j,nodeGroups:C}),ot=typeof(Ue==null?void 0:Ue.panelUrl)=="string"?Ue.panelUrl.trim():"",ee=typeof(Ue==null?void 0:Ue.cell)=="string"?Ue.cell:"",P=Ce.float||null,le=!!(P&&V.mini[ht]);return Ye.push(a.jsxs("div",{className:`nc-tile-slot${Q(he,Ve)}${x&&x.from===ht?" nc-tile-source":""}${P?" nc-float":""}${le?" nc-float-mini":""}`,style:P?{position:"fixed",left:`${P.x*100}%`,top:`${P.y*100}%`,width:`${P.w*100}%`,height:le?"auto":`${P.h*100}%`,zIndex:20+(V.z[ht]||0)}:{flexGrow:Ce.height,flexBasis:0},onPointerDown:P?()=>Ae(ht):void 0,onDragOver:_e=>{if(!Fp(_e.dataTransfer))return;if(P){_e.stopPropagation();return}_e.preventDefault(),_e.stopPropagation();const Me=HD(_e.clientX,_e.clientY,_e.currentTarget.getBoundingClientRect());x&&x.col===he&&x.row===Ve&&x.quadrant===Me||W({col:he,row:Ve,quadrant:Me,from:x==null?void 0:x.from,ghost:{x:_e.clientX,y:_e.clientY}})},children:[a.jsx(zD,{session:Ce.session,node:Ce.node,ownerId:Ce.ownerId,cellName:st,token:n,readonly:s,focused:l===ht,onFocus:c,onClose:me,onOpenSingle:u,floating:!!P,minimized:le,takeSize:!!P,onDetach:P?void 0:X,onReattach:P?_e=>e(pI(t,_e)):void 0,onToggleMinimize:P?He:void 0,onFloatDragStart:P?_e=>Z(_e,ht):void 0,onDragTileStart:P?void 0:_e=>W(Me=>Me?{...Me,from:_e}:{from:_e}),available:Ce.unavailable!==!0,stale:Ce.stale===!0,alive:Oe,sessionAlive:et,presence:ve,fontSize:Ce.fontSize,onZoom:_e=>e(wI(t,he,Ve,_e)),decks:_,currentDeck:g,onSendToDeck:b,panelUrl:ot,panelCellId:ee,panelPort:Tc(Ce.node?Ce.node.split("/"):[],E,N)}),!P&&x&&x.col===he&&x.row===Ve&&x.quadrant&&a.jsx(WD,{active:x.quadrant}),P&&!le&&["n","s","e","w","se"].map(_e=>a.jsx("div",{className:`nc-float-rz ${_e}`,"data-testid":`float-resize-${_e}`,onPointerDown:Me=>ge(Me,ht,_e)},`rz-${_e}`))]},ht)),Ve<Y.tiles.length-1&&Ye.push(a.jsx("div",{className:`nc-divider-h${$&&$.kind==="row"&&$.ci===he&&$.ri===Ve?" dragging":""}`,title:f("grid-resize-rows"),onPointerDown:_e=>te(_e,he,Ve),onDoubleClick:()=>ne(he,Ve)},`h${Ve}`)),Ye})},`c${he}`)),he<M-1&&!H(Y)&&!H(t.columns[he+1])&&Ne.push(a.jsx("div",{className:`nc-divider-v${$&&$.kind==="col"&&$.ci===he?" dragging":""}`,title:f("grid-resize-cols"),onPointerDown:Ce=>re(Ce,he),onDoubleClick:()=>je(he)},`v${he}`)),Ne}),$&&a.jsx("div",{className:`nc-gesture-shield ${$.kind==="col"?"col":"row"}`,"data-testid":"nc-gesture-shield"}),$&&$.kind==="col"&&_c.map(Y=>a.jsx("div",{className:"nc-gesture-ghost v",style:{left:$.coupleLeft+Y*$.couplePx}},`ghost-v-${Y}`)),$&&$.kind==="row"&&_c.map(Y=>a.jsx("div",{className:"nc-gesture-ghost h",style:{top:$.coupleTop+Y*$.couplePx,left:$.colLeft,width:$.colWidth}},`ghost-h-${Y}`)),$&&$.kind==="col"&&a.jsx("div",{className:`nc-gesture-guide v${$.live.snapped?" snap":""}`,"data-testid":"nc-gesture-guide",style:{left:$.coupleLeft+$.live.border}}),$&&$.kind==="row"&&a.jsx("div",{className:`nc-gesture-guide h${$.live.snapped?" snap":""}`,"data-testid":"nc-gesture-guide",style:{top:$.coupleTop+$.live.border,left:$.colLeft,width:$.colWidth}}),$&&a.jsx("div",{className:"nc-gesture-badge","data-testid":"nc-gesture-badge",style:$.kind==="col"?{left:$.coupleLeft+$.live.border,top:"50%"}:{top:$.coupleTop+$.live.border,left:"50%"},children:[$.fsA,$.fsB].map((Y,he)=>{const Ne=he===0?$.live.border:$.couplePx-$.live.border,Ce=Math.max(1,Y*.6),Ve=Math.max(1,Y*1.2),Ye=$.kind==="col"?`${Math.round(Ne/Ce)}×${Math.round($.pxOther/Ve)}`:`${Math.round($.pxOther/Ce)}×${Math.round(Ne/Ve)}`;return a.jsx("span",{className:"nc-gesture-chip",children:Ye},he)})}),K&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:`nc-gesture-shield ${K.kind==="resize"?"row":"col"}`,"data-testid":"nc-gesture-shield"}),K.live.snappedX&&a.jsx("div",{className:"nc-float-snap v",style:{left:`${K.live.x*100}%`}}),K.live.snappedY&&a.jsx("div",{className:"nc-float-snap h",style:{top:`${K.live.y*100}%`}}),K.kind==="resize"&&(()=>{const Y=gS(t,K.key)||_i,he=Math.max(1,Y*.6),Ne=Math.max(1,Y*1.2);return a.jsx("div",{className:"nc-gesture-badge","data-testid":"nc-gesture-badge",style:{left:`${(K.live.x+K.live.w/2)*100}%`,top:`${(K.live.y+K.live.h)*100}%`},children:a.jsx("span",{className:"nc-gesture-chip",children:`${Math.round(K.live.w*window.innerWidth/he)}×${Math.round(K.live.h*window.innerHeight/Ne)}`})})})()]}),x&&x.from&&x.ghost&&(()=>{const Y=t.columns.flatMap(Ne=>Ne.tiles).find(Ne=>zt(Ne)===x.from),he=Y?$c({session:Y.session,node:Y.node,ownerId:Y.ownerId,cells:j,nodeGroups:C,cell:Ug({session:Y.session,node:Y.node,ownerId:Y.ownerId,cells:j,nodeGroups:C})}):x.from;return a.jsxs("div",{className:"nc-drag-ghost","data-testid":"nc-drag-ghost",style:{left:x.ghost.x,top:x.ghost.y},children:[a.jsxs("div",{className:"nc-drag-ghost-head",children:[a.jsx("span",{className:"nc-dot on"}),a.jsx("b",{children:he})]}),a.jsx("div",{className:"nc-drag-ghost-body"})]})})(),U&&a.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),M===0&&a.jsx("div",{className:"nc-grid-empty",children:f("grid-empty")})]})}const Gi="local",Xs=/^[a-f0-9]{16,64}$/,GC=3,Ba=new Map,no=new Map,vS=128;function KD(t){const e=new Set;for(const n of Array.isArray(t)?t:[])!n||!Xs.test(String(n.instanceId||""))||!Array.isArray(n.route)||(e.add(n.instanceId),no.set(n.instanceId,[...n.route]),Ba.set(n.instanceId,0));for(const n of[...no.keys()]){if(e.has(n))continue;const s=(Ba.get(n)||0)+1;Ba.set(n,s),s>GC+32&&(Ba.delete(n),no.delete(n))}if(no.size>vS)for(const n of[...no.keys()].slice(0,no.size-vS))Ba.delete(n),no.delete(n)}function qo(t,e){return`${t&&Xs.test(t)?t:Gi}:${e}`}function Zc(t){const e=String(t||""),n=e.indexOf(":");if(n<1)return null;const s=e.slice(0,n),i=e.slice(n+1);return s!==Gi&&!Xs.test(s)||!/^[a-z0-9-]{1,32}$/.test(i)?null:{ownerId:s===Gi?null:s,name:i}}function zc(t){return Array.isArray(t)&&t.length?t.join("/"):""}function Qv(t){return{columns:Mi(t).columns.map(e=>({width:e.width,tiles:e.tiles.map(n=>({...n}))}))}}function VD(t){const e=new Map;for(const n of Array.isArray(t)?t:[])n&&Xs.test(String(n.instanceId||""))&&Array.isArray(n.route)&&e.set(zc(n.route),n.instanceId);return e}function YD(t){const e=new Map;for(const n of Array.isArray(t)?t:[])n&&Xs.test(String(n.instanceId||""))&&Array.isArray(n.route)&&e.set(n.instanceId,[...n.route]);return e}function Wg(t,e,n=[]){const s=Qv(t),i=VD(n);for(const l of s.columns)for(const c of l.tiles)c.ownerId||(!c.node&&Xs.test(String(e||""))?c.ownerId=e:c.node&&i.has(c.node)&&(c.ownerId=i.get(c.node)));return s}function tc(t,e){const n=Zc(t);return!n||!n.ownerId||!e||n.ownerId!==e?t:qo(null,n.name)}function qa(t,e,n=[]){const s=Qv(t),i=new Map,l=new Set;for(const c of n)c&&Xs.test(String(c.instanceId||""))&&Array.isArray(c.route)&&(i.set(c.instanceId,[...c.route]),c.stale===!0&&l.add(c.instanceId));for(const c of s.columns)for(const u of c.tiles)if(u.ownerId)if(u.ownerId===e)delete u.node,delete u.unavailable,delete u.stale;else if(i.has(u.ownerId))u.node=zc(i.get(u.ownerId)),delete u.unavailable,l.has(u.ownerId)?u.stale=!0:delete u.stale;else{const h=Ba.get(u.ownerId),p=no.get(u.ownerId);p&&h!==void 0&&h<GC?(u.node=zc(p),delete u.unavailable,u.stale=!0):(u.unavailable=!0,delete u.stale)}return s}function nc(t,e,n=[]){const s=Qv(t),i=YD(n);for(const l of s.columns)for(const c of l.tiles)delete c.unavailable,delete c.stale,c.ownerId&&(c.ownerId===e?delete c.node:i.has(c.ownerId)&&(c.node=zc(i.get(c.ownerId))));return s}function XC(t,e,n=[]){const s=jr(t);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...Xs.test(String(e||""))?{ownerId:e}:{}};const i=n.find(l=>zc(l&&l.route)===s.node);return{...s,...i&&Xs.test(String(i.instanceId||""))?{ownerId:i.instanceId}:{}}}const GD=/^[a-z0-9-]{1,32}$/,ii="main",JC="nc_decks",QC="nc_deck_order_v1",ZC=24;function _S(t){return typeof t!="string"?"":t.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function Za(t){return typeof t=="string"&&GD.test(t)}function XD(t){const e=String(t||"").match(/^\/deck\/([^/]+)\/?$/);if(e){let n;try{n=decodeURIComponent(e[1])}catch{n=e[1]}return Za(n)?n:ii}return ii}function JD(t){const e=String(t||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(e){let s,i;try{s=decodeURIComponent(e[1]),i=decodeURIComponent(e[2])}catch{return{id:qo(null,ii),ownerId:null,name:ii}}if(Xs.test(s)&&Za(i))return{id:qo(s,i),ownerId:s,name:i}}const n=XD(t);return{id:qo(null,n),ownerId:null,name:n}}function Up(t,e){const n=typeof t=="object"&&t?{ownerId:t.ownerId||null,name:t.name}:Zc(t)||{ownerId:null,name:t},s=Za(n.name)?n.name:ii,i=n.ownerId?`/deck/${encodeURIComponent(n.ownerId)}/${encodeURIComponent(s)}`:s===ii?"/":`/deck/${encodeURIComponent(s)}`;return e?`${i}#token=${encodeURIComponent(e)}`:i}function eE(t){return t===ii?"nc_grid_v1":`nc_grid_v1__${t}`}function tE(t){const e=[ii];if(Array.isArray(t)){for(const n of t)if(Za(n)&&n!==ii&&!e.includes(n)&&e.push(n),e.length>=ZC)break}return e}function rl(){return typeof localStorage<"u"?localStorage:null}function QD(){const t=rl();if(!t)return[ii];try{return tE(JSON.parse(t.getItem(JC)||"null"))}catch{return[ii]}}function ZD(t){const e=rl();if(e)try{e.setItem(JC,JSON.stringify(tE(t)))}catch{}}function eu(t){return t==="local"||Xs.test(String(t||""))}function Ch(t,e){const n=Zc(t);return!!n&&(n.ownerId||"local")===e}function er(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[n,s]of Object.entries(t).slice(0,64)){if(!eu(n)||!Array.isArray(s))continue;const i=[...new Set(s.filter(l=>typeof l=="string"&&l.length<=100&&Ch(l,n)))].slice(0,ZC);i.length&&(e[n]=i)}return e}function sc(t=rl()){if(!t)return{};try{return er(JSON.parse(t.getItem(QC)||"null"))}catch{return{}}}function Wp(t,e=rl()){const n=er(t);if(e)try{e.setItem(QC,JSON.stringify(n))}catch{}return n}function Eh(t,e){return Array.isArray(t==null?void 0:t[e])?t[e]:[]}function e3(t,e,n,s,i=[]){if(!eu(e)||n===s)return er(t);const l=[...new Set(i.filter(_=>Ch(_,e)))];if(!l.includes(n)||!l.includes(s))return er(t);const c=Eh(t,e).filter(_=>l.includes(_)),u=[...c,...l.filter(_=>!c.includes(_))],h=u.indexOf(n),p=u.indexOf(s);u.splice(h,1);const v=u.indexOf(s);return u.splice(h<p?v+1:v,0,n),er({...t,[e]:u})}function t3(t,e,n,s){if(!eu(e)||!Ch(s,e))return er(t);const i=Eh(t,e);return i.includes(n)?er({...t,[e]:i.map(l=>l===n?s:l)}):er(t)}function n3(t,e,n){return eu(e)?er({...t,[e]:Eh(t,e).filter(s=>s!==n)}):er(t)}function qp(t,e={},n=[]){const s=new Map,i=new Map;for(const h of Array.isArray(t)?t:[]){const p=h!=null&&h.local?"local":String((h==null?void 0:h.ownerId)||"");!eu(p)||!Ch(h==null?void 0:h.id,p)||(s.has(p)||s.set(p,[]),i.has(p)||i.set(p,i.size),s.get(p).push(h))}const l=new Map;(Array.isArray(n)?n:[]).forEach((h,p)=>{typeof h=="string"&&!l.has(h)&&l.set(h,p)});const c=h=>{if(h==="local")return-1;const p=l.get(`id:${h}`);return p===void 0?Number.MAX_SAFE_INTEGER:p},u=[];for(const h of[...s.keys()].sort((p,v)=>c(p)-c(v)||i.get(p)-i.get(v))){const p=s.get(h),v=Eh(e,h),_=new Map(v.map((g,b)=>[g,b]));p.sort((g,b)=>{const S=_.has(g.id)?_.get(g.id):Number.MAX_SAFE_INTEGER,j=_.has(b.id)?_.get(b.id):Number.MAX_SAFE_INTEGER;return S-j}),u.push(...p)}return u}function qg(t){const e=rl();if(!e)return null;try{return JSON.parse(e.getItem(eE(t))||"null")}catch{return null}}function s3(t,e){const n=rl();if(n)try{n.setItem(eE(t),JSON.stringify(e))}catch{}}const Zv="nc_deckbar_collapsed_v1",nE=64;function e_(t){return t===Gi||Xs.test(String(t||""))}function t_(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};let n=0;for(const[s,i]of Object.entries(t)){if(n>=nE)break;if(e_(s)){if(i===!0)e[s]=!0;else if(i===!1)e[s]=!1;else continue;n+=1}}return e}function sE(t,e){return e_(e)&&Object.prototype.hasOwnProperty.call(t||{},e)?t[e]===!0:!0}function i3(t,e){const n=t_(t);return e_(e)&&(!Object.prototype.hasOwnProperty.call(n,e)&&Object.keys(n).length>=nE&&delete n[Object.keys(n)[0]],n[e]=!sE(n,e)),n}function iE(){return typeof localStorage<"u"?localStorage:null}function yS(t=iE()){if(!t)return{};try{return t_(JSON.parse(t.getItem(Zv)||"null"))}catch{return{}}}function r3(t,e=iE()){const n=t_(t);if(e)try{e.setItem(Zv,JSON.stringify(n))}catch{}return n}function o3(){const[t,e]=y.useState(yS);y.useEffect(()=>{const i=l=>{(l.key===Zv||l.key===null)&&e(yS())};return window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[]);const n=y.useCallback(i=>sE(t,i),[t]),s=y.useCallback(i=>{e(l=>r3(i3(l,i)))},[]);return{collapsed:t,isCollapsed:n,toggle:s}}const n_="nc_deck_presence_v1",wS=3e4,a3=18e4,rE=1e4,oE=32,l3=/^[A-Za-z0-9_-]{1,64}$/,c3=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),bS="working",u3="on",d3="neutral",h3="warn";function s_(t){return typeof t=="string"&&l3.test(t)&&!c3.has(t)}function aE(t){return typeof t=="string"&&Zc(t)!==null}function i_(t){return typeof t=="number"&&Number.isFinite(t)&&t>=0}function el(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};let n=0;for(const[s,i]of Object.entries(t)){if(n>=oE)break;s_(s)&&(!i||typeof i!="object"||aE(i.deckId)&&i_(i.ts)&&(e[s]={deckId:i.deckId,ts:i.ts,focus:i.focus===!0,visible:i.visible===!0},n+=1))}return e}function lE(t,e){const n=el(t);if(!i_(e))return n;const s={};for(const[i,l]of Object.entries(n)){const c=l.visible?wS:a3,u=e-c;l.ts>=u&&l.ts<=e+wS&&(s[i]=l)}return s}function SS(t,e,n,s){if(!s_(e)||!i_(s))return el(t);const i=lE(t,s);if(!aE(n==null?void 0:n.deckId))return i;if(!Object.prototype.hasOwnProperty.call(i,e)&&Object.keys(i).length>=oE){let l="",c=1/0;for(const[u,h]of Object.entries(i))h.ts<c&&(l=u,c=h.ts);l&&delete i[l]}return i[e]={deckId:n.deckId,ts:s,focus:(n==null?void 0:n.focus)===!0,visible:(n==null?void 0:n.visible)===!0},el(i)}function f3(t,e){const n=el(t);if(!s_(e))return n;const s={...n};return delete s[e],s}function p3(t,e){const n=lE(t,e),s={};for(const i of Object.values(n)){const l=i.focus&&i.visible?bS:u3;s[i.deckId]!==bS&&(s[i.deckId]=l)}return s}function cE(){return typeof localStorage<"u"?localStorage:null}function dd(t=cE()){if(!t)return{};try{return el(JSON.parse(t.getItem(n_)||"null"))}catch{return{}}}function Kp(t,e=cE()){const n=el(t);if(e)try{e.setItem(n_,JSON.stringify(n))}catch{}return n}const m3=Math.min(rE,5e3);function g3(){var t,e;try{const n=(e=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:e.call(t);if(n)return`w${n.replaceAll("-","")}`}catch{}return`w${Date.now().toString(36)}${Math.random().toString(36).slice(2,14)}`}const v3=g3();function xS(){const t=typeof document<"u"&&typeof document.hasFocus=="function"?document.hasFocus():!0,e=typeof document<"u"&&typeof document.visibilityState=="string"?document.visibilityState!=="hidden":!0;return{focus:t,visible:e}}function _3(t,e=!0){const s=y.useRef(v3).current,i=y.useRef(t);i.current=t;const[l,c]=y.useState(()=>({map:{},now:Date.now()})),u=y.useCallback(()=>{c({map:dd(),now:Date.now()})},[]);y.useEffect(()=>{if(!e)return;const v=()=>{const C=Date.now(),N=SS(dd(),s,{deckId:i.current,...xS()},C);return Kp(N),{map:N,now:C}},_=()=>c(v());_();const g=setInterval(v,rE),b=setInterval(u,m3),S=_,j=C=>{(C.key===n_||C.key===null)&&u()};return window.addEventListener("focus",S),window.addEventListener("blur",S),typeof document<"u"&&document.addEventListener("visibilitychange",S),window.addEventListener("storage",j),()=>{clearInterval(g),clearInterval(b),window.removeEventListener("focus",S),window.removeEventListener("blur",S),typeof document<"u"&&document.removeEventListener("visibilitychange",S),window.removeEventListener("storage",j);try{Kp(f3(dd(),s))}catch{}}},[e,s,u]),y.useEffect(()=>{if(!e)return;const v=Date.now(),_=SS(dd(),s,{deckId:t,...xS()},v);Kp(_),c({map:_,now:v})},[t,e,s]);const h=y.useMemo(()=>e?p3(l.map,l.now):{},[e,l]);return{dotFor:y.useCallback((v,_=!1)=>e?_?h3:h[v]||d3:null,[h,e]),windowId:s}}const kS=52,CS=18;function y3({ownerKey:t,deckId:e,label:n,onMove:s,onStep:i}){const l=y.useRef(null),c=y.useRef(0),[u,h]=y.useState(!1),p=()=>{var j,C,N,E;const S=l.current;(C=(j=S==null?void 0:S.over)==null?void 0:j.classList)==null||C.remove("nc-deck-over"),(E=(N=S==null?void 0:S.source)==null?void 0:N.classList)==null||E.remove("nc-deck-dragging"),c.current&&cancelAnimationFrame(c.current),c.current=0},v=(S=!1)=>{const j=l.current;if(!j)return;const C=j.target;p(),l.current=null,h(!1);try{j.handle.releasePointerCapture(j.pointerId)}catch{}S&&C&&C!==e&&s(e,C)},_=(S,j)=>{var x,W,$,J,q,V,ie,K;const C=l.current;if(!C)return;C.x=S,C.y=j;const N=(W=(x=document.elementFromPoint(S,j))==null?void 0:x.closest)==null?void 0:W.call(x,"[data-deck-id][data-owner-key]"),E=($=N==null?void 0:N.dataset)==null?void 0:$.deckId,O=((J=N==null?void 0:N.dataset)==null?void 0:J.ownerKey)===t&&E&&E!==e;C.over!==(O?N:null)&&((V=(q=C.over)==null?void 0:q.classList)==null||V.remove("nc-deck-over"),C.over=O?N:null,(K=(ie=C.over)==null?void 0:ie.classList)==null||K.add("nc-deck-over")),C.target=O?E:null},g=()=>{var C,N;const S=l.current;if(!S){c.current=0;return}const j=(N=(C=S.container)==null?void 0:C.getBoundingClientRect)==null?void 0:N.call(C);if(j){const E=S.x<j.left+kS?-CS:S.x>j.right-kS?CS:0;E&&(S.container.scrollLeft+=E,_(S.x,S.y))}c.current=requestAnimationFrame(g)};y.useEffect(()=>{const S=C=>{C.key==="Escape"&&l.current&&(C.preventDefault(),v(!1))},j=()=>v(!1);return window.addEventListener("keydown",S),window.addEventListener("blur",j),()=>{window.removeEventListener("keydown",S),window.removeEventListener("blur",j),p(),l.current=null}},[e,t]);const b=S=>{var N;if(S.pointerType==="mouse"&&S.button!==0)return;S.preventDefault(),S.stopPropagation(),S.currentTarget.focus({preventScroll:!0});const j=S.currentTarget.closest("[data-deck-id][data-owner-key]"),C=S.currentTarget.closest(".nc-deckbar");l.current={pointerId:S.pointerId,handle:S.currentTarget,source:j,container:C,target:null,over:null,x:S.clientX,y:S.clientY},(N=j==null?void 0:j.classList)==null||N.add("nc-deck-dragging");try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}h(!0),c.current=requestAnimationFrame(g)};return a.jsx("button",{type:"button",className:`nc-deck-handle${u?" active":""}`,"aria-label":`${f("reorder")} ${n}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:f("reorder-deck-help"),onClick:S=>{S.preventDefault(),S.stopPropagation()},onDragStart:S=>S.preventDefault(),onKeyDown:S=>{S.key!=="ArrowLeft"&&S.key!=="ArrowRight"||(S.preventDefault(),S.stopPropagation(),i(S.key==="ArrowLeft"?-1:1))},onPointerDown:b,onPointerMove:S=>{!l.current||S.pointerId!==l.current.pointerId||(S.preventDefault(),S.stopPropagation(),_(S.clientX,S.clientY))},onPointerUp:S=>{!l.current||S.pointerId!==l.current.pointerId||(S.preventDefault(),S.stopPropagation(),v(!0))},onPointerCancel:()=>v(!1),onLostPointerCapture:()=>{l.current&&v(!1)},children:"↔"})}function w3({decks:t=[],currentDeck:e="local:main",onCreate:n,onRename:s,onDelete:i,onReorder:l,onOpenWindow:c,onNavigate:u,saveState:h="idle",error:p="",sidebarVisible:v,onToggleSidebar:_,conflict:g=!1,onReloadDeck:b=null}){zn();const{isCollapsed:S,toggle:j}=o3(),{dotFor:C}=_3(e),[N,E]=y.useState(null),[O,x]=y.useState(""),[W,$]=y.useState(!1),[J,q]=y.useState(""),[V,ie]=y.useState(""),K=_S(O),B=Za(K),I=[];for(const M of t){const L=M.local?"local":M.ownerId;let H=I.find(A=>A.key===L);H||(H={key:L,label:M.ownerLabel||(M.local?"Local":L),local:!!M.local,decks:[]},I.push(H)),H.decks.push(M)}const D=async()=>{if(B){$(!0),q("");try{n&&await n(K,N),x(""),E(null)}catch(M){q(String(M.message||M))}$(!1)}},T=M=>{ie(""),c&&c(M.id)||ie(M.id)},z=async M=>{if(!(M.id===e||!u||W||M.available===!1)){$(!0),q("");try{await u(M.id)}catch(L){q(String((L==null?void 0:L.message)||L))}$(!1)}},R=(M,L,H)=>{const A=M.decks.findIndex(Q=>Q.id===L.id),U=M.decks[A+H];A>=0&&U&&l&&!W&&l(L.id,U.id)};return a.jsxs("div",{className:"nc-deckbar",children:[_&&a.jsx("button",{className:"nc-deck-sidebar-toggle",title:f("toggle-sidebar"),onClick:_,children:v?"◀":"☰"}),a.jsx("span",{className:"nc-deckbar-label",children:f("decks")}),a.jsx("div",{className:"nc-deck-chips",children:I.map(M=>{const L=S(M.key),H=`nc-deck-content-${M.key}`,A=M.local?"Local":M.label,U=M.decks.some(re=>re.id===e),Q=(M.decks.find(re=>re.id===e)||{}).name,ae=f(M.decks.length===1?"owner-deck-count-one":"owner-deck-count-many").replace("{count}",M.decks.length);return a.jsxs("span",{className:`nc-deck-owner-group${L?" collapsed":""}`,"data-owner-key":M.key,"data-collapsed":L?"1":"0",children:[a.jsxs("button",{type:"button",className:"nc-deck-owner-toggle","aria-expanded":!L,"aria-controls":H,title:f(L?"expand-owner":"collapse-owner").replace("{owner}",A),onClick:()=>{!L&&N===M.key&&(x(""),E(null)),j(M.key)},children:[a.jsx("span",{className:"nc-deck-owner-caret","aria-hidden":"true",children:L?"▸":"▾"}),a.jsx("span",{className:"nc-deck-owner",children:A})]}),L&&a.jsxs("span",{className:"nc-deck-summary",title:ae,children:[a.jsx("span",{className:"nc-deck-summary-count",children:M.decks.length}),U&&a.jsxs("span",{className:"nc-deck-summary-current",children:["• ",Q]})]}),a.jsxs("span",{id:H,className:"nc-deck-owner-content",hidden:L,children:[M.decks.map(re=>{const je=C(re.id,re.available===!1);return a.jsxs("span",{"data-deck-id":re.id,"data-owner-key":M.key,className:`nc-deck-chip${re.id===e?" current":""}${re.available===!1?" offline":""}`,children:[je&&a.jsx(b3,{state:je}),a.jsx(y3,{ownerKey:M.key,deckId:re.id,label:`${M.label} · ${re.name}`,onMove:(te,ne)=>{l&&!W&&l(te,ne)},onStep:te=>R(M,re,te)}),a.jsxs("button",{className:"nc-deck-open",title:re.available===!1?`${re.ownerLabel} offline${re.refreshFailedAt?" · aggiornamento in ritardo":""}`:re.id===e?f("deck-current"):`${re.ownerLabel} · ${re.name}`,disabled:W||re.available===!1,onClick:()=>z(re),children:[re.name,re.id===e?" •":""]}),re.available!==!1&&re.stale===!0&&re.refreshFailedAt?a.jsx("span",{className:"nc-deck-stale",title:`${re.ownerLabel} · ${f("deck-stale")}`,children:f("deck-stale-badge")}):null,a.jsx("button",{className:"nc-deck-mini",disabled:re.available===!1,title:f("detach-deck"),onClick:()=>T(re),children:"↗"}),re.name!==ii&&a.jsxs(a.Fragment,{children:[a.jsx("button",{className:"nc-deck-mini",disabled:re.available===!1,title:f("rename-deck"),onClick:()=>{const te=(typeof window<"u"?window.prompt(f("rename-deck"),re.name):"")||"",ne=_S(te);Za(ne)&&ne!==re.name&&s&&s(re.id,ne).catch(me=>q(String(me.message||me)))},children:"✎"}),a.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:re.available===!1,title:f("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(f("delete-deck-confirm").replace("{name}",`${re.ownerLabel} · ${re.name}`)))&&i&&i(re.id).catch(te=>q(String(te.message||te)))},children:"✕"})]})]},re.id)}),N===M.key?a.jsxs("span",{className:"nc-deck-add",children:[a.jsx("input",{autoFocus:!0,className:B||!O?"":"invalid",placeholder:f("deck-name"),value:O,onChange:re=>x(re.target.value),onKeyDown:re=>{re.key==="Enter"&&D(),re.key==="Escape"&&(x(""),E(null))}}),O&&B&&K!==O&&a.jsxs("span",{className:"nc-deck-slug",children:["→ ",K]}),a.jsx("button",{className:"nc-deck-ok",disabled:!B||W,onClick:D,children:f("create")}),a.jsx("button",{className:"nc-deck-cancel",onClick:()=>{x(""),E(null)},children:f("cancel")})]}):a.jsxs("button",{className:"nc-deck-newbtn",disabled:W||M.decks.every(re=>re.available===!1),title:`${f("new-deck")} · ${M.label}`,onClick:()=>{x(""),E(M.key)},children:["+ ",f("new")]})]})]},M.key)})}),a.jsx("span",{className:`nc-deck-state ${h}`,title:f("deck-autosave"),children:f(h==="saving"?"saving":h==="saved"?"saved":"deck-autosave")}),(J||p)&&a.jsx("span",{className:"nc-deck-error",children:J||p}),g&&b&&a.jsx("button",{className:"nc-deck-reload",onClick:b,children:f("reload")}),V&&a.jsx("button",{className:"nc-deck-fallback",onClick:()=>c&&c(V),children:f("popup-blocked")})]})}function b3({state:t}){if(!t)return null;const e=f(`dot-${t}`);return a.jsx("span",{className:`nc-deck-dot ${t}`,role:"img","aria-label":e,title:e})}var Da={},Vp,ES;function S3(){return ES||(ES=1,Vp=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Vp}var Yp={},Jr={},NS;function Zo(){if(NS)return Jr;NS=1;let t;const e=[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 Jr.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},Jr.getSymbolTotalCodewords=function(s){return e[s]},Jr.getBCHDigit=function(n){let s=0;for(;n!==0;)s++,n>>>=1;return s},Jr.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');t=s},Jr.isKanjiModeEnabled=function(){return typeof t<"u"},Jr.toSJIS=function(s){return t(s)},Jr}var Gp={},jS;function r_(){return jS||(jS=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function e(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+n)}}t.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},t.from=function(s,i){if(t.isValid(s))return s;try{return e(s)}catch{return i}}})(Gp)),Gp}var Xp,LS;function x3(){if(LS)return Xp;LS=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(e){const n=Math.floor(e/8);return(this.buffer[n]>>>7-e%8&1)===1},put:function(e,n){for(let s=0;s<n;s++)this.putBit((e>>>n-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),e&&(this.buffer[n]|=128>>>this.length%8),this.length++}},Xp=t,Xp}var Jp,RS;function k3(){if(RS)return Jp;RS=1;function t(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}return t.prototype.set=function(e,n,s,i){const l=e*this.size+n;this.data[l]=s,i&&(this.reservedBit[l]=!0)},t.prototype.get=function(e,n){return this.data[e*this.size+n]},t.prototype.xor=function(e,n,s){this.data[e*this.size+n]^=s},t.prototype.isReserved=function(e,n){return this.reservedBit[e*this.size+n]},Jp=t,Jp}var Qp={},AS;function C3(){return AS||(AS=1,(function(t){const e=Zo().getSymbolSize;t.getRowColCoords=function(s){if(s===1)return[];const i=Math.floor(s/7)+2,l=e(s),c=l===145?26:Math.ceil((l-13)/(2*i-2))*2,u=[l-7];for(let h=1;h<i-1;h++)u[h]=u[h-1]-c;return u.push(6),u.reverse()},t.getPositions=function(s){const i=[],l=t.getRowColCoords(s),c=l.length;for(let u=0;u<c;u++)for(let h=0;h<c;h++)u===0&&h===0||u===0&&h===c-1||u===c-1&&h===0||i.push([l[u],l[h]]);return i}})(Qp)),Qp}var Zp={},MS;function E3(){if(MS)return Zp;MS=1;const t=Zo().getSymbolSize,e=7;return Zp.getPositions=function(s){const i=t(s);return[[0,0],[i-e,0],[0,i-e]]},Zp}var em={},TS;function N3(){return TS||(TS=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e={N1:3,N2:3,N3:40,N4:10};t.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},t.from=function(i){return t.isValid(i)?parseInt(i,10):void 0},t.getPenaltyN1=function(i){const l=i.size;let c=0,u=0,h=0,p=null,v=null;for(let _=0;_<l;_++){u=h=0,p=v=null;for(let g=0;g<l;g++){let b=i.get(_,g);b===p?u++:(u>=5&&(c+=e.N1+(u-5)),p=b,u=1),b=i.get(g,_),b===v?h++:(h>=5&&(c+=e.N1+(h-5)),v=b,h=1)}u>=5&&(c+=e.N1+(u-5)),h>=5&&(c+=e.N1+(h-5))}return c},t.getPenaltyN2=function(i){const l=i.size;let c=0;for(let u=0;u<l-1;u++)for(let h=0;h<l-1;h++){const p=i.get(u,h)+i.get(u,h+1)+i.get(u+1,h)+i.get(u+1,h+1);(p===4||p===0)&&c++}return c*e.N2},t.getPenaltyN3=function(i){const l=i.size;let c=0,u=0,h=0;for(let p=0;p<l;p++){u=h=0;for(let v=0;v<l;v++)u=u<<1&2047|i.get(p,v),v>=10&&(u===1488||u===93)&&c++,h=h<<1&2047|i.get(v,p),v>=10&&(h===1488||h===93)&&c++}return c*e.N3},t.getPenaltyN4=function(i){let l=0;const c=i.data.length;for(let h=0;h<c;h++)l+=i.data[h];return Math.abs(Math.ceil(l*100/c/5)-10)*e.N4};function n(s,i,l){switch(s){case t.Patterns.PATTERN000:return(i+l)%2===0;case t.Patterns.PATTERN001:return i%2===0;case t.Patterns.PATTERN010:return l%3===0;case t.Patterns.PATTERN011:return(i+l)%3===0;case t.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(l/3))%2===0;case t.Patterns.PATTERN101:return i*l%2+i*l%3===0;case t.Patterns.PATTERN110:return(i*l%2+i*l%3)%2===0;case t.Patterns.PATTERN111:return(i*l%3+(i+l)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}t.applyMask=function(i,l){const c=l.size;for(let u=0;u<c;u++)for(let h=0;h<c;h++)l.isReserved(h,u)||l.xor(h,u,n(i,h,u))},t.getBestMask=function(i,l){const c=Object.keys(t.Patterns).length;let u=0,h=1/0;for(let p=0;p<c;p++){l(p),t.applyMask(p,i);const v=t.getPenaltyN1(i)+t.getPenaltyN2(i)+t.getPenaltyN3(i)+t.getPenaltyN4(i);t.applyMask(p,i),v<h&&(h=v,u=p)}return u}})(em)),em}var hd={},PS;function uE(){if(PS)return hd;PS=1;const t=r_(),e=[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 hd.getBlocksCount=function(i,l){switch(l){case t.L:return e[(i-1)*4+0];case t.M:return e[(i-1)*4+1];case t.Q:return e[(i-1)*4+2];case t.H:return e[(i-1)*4+3];default:return}},hd.getTotalCodewordsCount=function(i,l){switch(l){case t.L:return n[(i-1)*4+0];case t.M:return n[(i-1)*4+1];case t.Q:return n[(i-1)*4+2];case t.H:return n[(i-1)*4+3];default:return}},hd}var tm={},ic={},IS;function j3(){if(IS)return ic;IS=1;const t=new Uint8Array(512),e=new Uint8Array(256);return(function(){let s=1;for(let i=0;i<255;i++)t[i]=s,e[s]=i,s<<=1,s&256&&(s^=285);for(let i=255;i<512;i++)t[i]=t[i-255]})(),ic.log=function(s){if(s<1)throw new Error("log("+s+")");return e[s]},ic.exp=function(s){return t[s]},ic.mul=function(s,i){return s===0||i===0?0:t[e[s]+e[i]]},ic}var DS;function L3(){return DS||(DS=1,(function(t){const e=j3();t.mul=function(s,i){const l=new Uint8Array(s.length+i.length-1);for(let c=0;c<s.length;c++)for(let u=0;u<i.length;u++)l[c+u]^=e.mul(s[c],i[u]);return l},t.mod=function(s,i){let l=new Uint8Array(s);for(;l.length-i.length>=0;){const c=l[0];for(let h=0;h<i.length;h++)l[h]^=e.mul(i[h],c);let u=0;for(;u<l.length&&l[u]===0;)u++;l=l.slice(u)}return l},t.generateECPolynomial=function(s){let i=new Uint8Array([1]);for(let l=0;l<s;l++)i=t.mul(i,new Uint8Array([1,e.exp(l)]));return i}})(tm)),tm}var nm,OS;function R3(){if(OS)return nm;OS=1;const t=L3();function e(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return e.prototype.initialize=function(s){this.degree=s,this.genPoly=t.generateECPolynomial(this.degree)},e.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const i=new Uint8Array(s.length+this.degree);i.set(s);const l=t.mod(i,this.genPoly),c=this.degree-l.length;if(c>0){const u=new Uint8Array(this.degree);return u.set(l,c),u}return l},nm=e,nm}var sm={},im={},rm={},BS;function dE(){return BS||(BS=1,rm.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),rm}var qi={},$S;function hE(){if($S)return qi;$S=1;const t="[0-9]+",e="[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
158
+ ]))+`;qi.KANJI=new RegExp(n,"g"),qi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),qi.BYTE=new RegExp(s,"g"),qi.NUMERIC=new RegExp(t,"g"),qi.ALPHANUMERIC=new RegExp(e,"g");const i=new RegExp("^"+n+"$"),l=new RegExp("^"+t+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return qi.testKanji=function(h){return i.test(h)},qi.testNumeric=function(h){return l.test(h)},qi.testAlphanumeric=function(h){return c.test(h)},qi}var zS;function ea(){return zS||(zS=1,(function(t){const e=dE(),n=hE();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(l,c){if(!l.ccBits)throw new Error("Invalid mode: "+l);if(!e.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?l.ccBits[0]:c<27?l.ccBits[1]:l.ccBits[2]},t.getBestModeForData=function(l){return n.testNumeric(l)?t.NUMERIC:n.testAlphanumeric(l)?t.ALPHANUMERIC:n.testKanji(l)?t.KANJI:t.BYTE},t.toString=function(l){if(l&&l.id)return l.id;throw new Error("Invalid mode")},t.isValid=function(l){return l&&l.bit&&l.ccBits};function s(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+i)}}t.from=function(l,c){if(t.isValid(l))return l;try{return s(l)}catch{return c}}})(im)),im}var FS;function A3(){return FS||(FS=1,(function(t){const e=Zo(),n=uE(),s=r_(),i=ea(),l=dE(),c=7973,u=e.getBCHDigit(c);function h(g,b,S){for(let j=1;j<=40;j++)if(b<=t.getCapacity(j,S,g))return j}function p(g,b){return i.getCharCountIndicator(g,b)+4}function v(g,b){let S=0;return g.forEach(function(j){const C=p(j.mode,b);S+=C+j.getBitsLength()}),S}function _(g,b){for(let S=1;S<=40;S++)if(v(g,S)<=t.getCapacity(S,b,i.MIXED))return S}t.from=function(b,S){return l.isValid(b)?parseInt(b,10):S},t.getCapacity=function(b,S,j){if(!l.isValid(b))throw new Error("Invalid QR Code version");typeof j>"u"&&(j=i.BYTE);const C=e.getSymbolTotalCodewords(b),N=n.getTotalCodewordsCount(b,S),E=(C-N)*8;if(j===i.MIXED)return E;const O=E-p(j,b);switch(j){case i.NUMERIC:return Math.floor(O/10*3);case i.ALPHANUMERIC:return Math.floor(O/11*2);case i.KANJI:return Math.floor(O/13);case i.BYTE:default:return Math.floor(O/8)}},t.getBestVersionForData=function(b,S){let j;const C=s.from(S,s.M);if(Array.isArray(b)){if(b.length>1)return _(b,C);if(b.length===0)return 1;j=b[0]}else j=b;return h(j.mode,j.getLength(),C)},t.getEncodedBits=function(b){if(!l.isValid(b)||b<7)throw new Error("Invalid QR Code version");let S=b<<12;for(;e.getBCHDigit(S)-u>=0;)S^=c<<e.getBCHDigit(S)-u;return b<<12|S}})(sm)),sm}var om={},HS;function M3(){if(HS)return om;HS=1;const t=Zo(),e=1335,n=21522,s=t.getBCHDigit(e);return om.getEncodedBits=function(l,c){const u=l.bit<<3|c;let h=u<<10;for(;t.getBCHDigit(h)-s>=0;)h^=e<<t.getBCHDigit(h)-s;return(u<<10|h)^n},om}var am={},lm,US;function T3(){if(US)return lm;US=1;const t=ea();function e(n){this.mode=t.NUMERIC,this.data=n.toString()}return e.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(s){let i,l,c;for(i=0;i+3<=this.data.length;i+=3)l=this.data.substr(i,3),c=parseInt(l,10),s.put(c,10);const u=this.data.length-i;u>0&&(l=this.data.substr(i),c=parseInt(l,10),s.put(c,u*3+1))},lm=e,lm}var cm,WS;function P3(){if(WS)return cm;WS=1;const t=ea(),e=["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=t.ALPHANUMERIC,this.data=s}return n.getBitsLength=function(i){return 11*Math.floor(i/2)+6*(i%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(i){let l;for(l=0;l+2<=this.data.length;l+=2){let c=e.indexOf(this.data[l])*45;c+=e.indexOf(this.data[l+1]),i.put(c,11)}this.data.length%2&&i.put(e.indexOf(this.data[l]),6)},cm=n,cm}var um,qS;function I3(){if(qS)return um;qS=1;const t=ea();function e(n){this.mode=t.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return e.getBitsLength=function(s){return s*8},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(n){for(let s=0,i=this.data.length;s<i;s++)n.put(this.data[s],8)},um=e,um}var dm,KS;function D3(){if(KS)return dm;KS=1;const t=ea(),e=Zo();function n(s){this.mode=t.KANJI,this.data=s}return n.getBitsLength=function(i){return i*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 i;for(i=0;i<this.data.length;i++){let l=e.toSJIS(this.data[i]);if(l>=33088&&l<=40956)l-=33088;else if(l>=57408&&l<=60351)l-=49472;else throw new Error("Invalid SJIS character: "+this.data[i]+`
159
+ Make sure your charset is UTF-8`);l=(l>>>8&255)*192+(l&255),s.put(l,13)}},dm=n,dm}var hm={exports:{}},VS;function O3(){return VS||(VS=1,(function(t){var e={single_source_shortest_paths:function(n,s,i){var l={},c={};c[s]=0;var u=e.PriorityQueue.make();u.push(s,0);for(var h,p,v,_,g,b,S,j,C;!u.empty();){h=u.pop(),p=h.value,_=h.cost,g=n[p]||{};for(v in g)g.hasOwnProperty(v)&&(b=g[v],S=_+b,j=c[v],C=typeof c[v]>"u",(C||j>S)&&(c[v]=S,u.push(v,S),l[v]=p))}if(typeof i<"u"&&typeof c[i]>"u"){var N=["Could not find a path from ",s," to ",i,"."].join("");throw new Error(N)}return l},extract_shortest_path_from_predecessor_list:function(n,s){for(var i=[],l=s;l;)i.push(l),n[l],l=n[l];return i.reverse(),i},find_path:function(n,s,i){var l=e.single_source_shortest_paths(n,s,i);return e.extract_shortest_path_from_predecessor_list(l,i)},PriorityQueue:{make:function(n){var s=e.PriorityQueue,i={},l;n=n||{};for(l in s)s.hasOwnProperty(l)&&(i[l]=s[l]);return i.queue=[],i.sorter=n.sorter||s.default_sorter,i},default_sorter:function(n,s){return n.cost-s.cost},push:function(n,s){var i={value:n,cost:s};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=e})(hm)),hm.exports}var YS;function B3(){return YS||(YS=1,(function(t){const e=ea(),n=T3(),s=P3(),i=I3(),l=D3(),c=hE(),u=Zo(),h=O3();function p(N){return unescape(encodeURIComponent(N)).length}function v(N,E,O){const x=[];let W;for(;(W=N.exec(O))!==null;)x.push({data:W[0],index:W.index,mode:E,length:W[0].length});return x}function _(N){const E=v(c.NUMERIC,e.NUMERIC,N),O=v(c.ALPHANUMERIC,e.ALPHANUMERIC,N);let x,W;return u.isKanjiModeEnabled()?(x=v(c.BYTE,e.BYTE,N),W=v(c.KANJI,e.KANJI,N)):(x=v(c.BYTE_KANJI,e.BYTE,N),W=[]),E.concat(O,x,W).sort(function(J,q){return J.index-q.index}).map(function(J){return{data:J.data,mode:J.mode,length:J.length}})}function g(N,E){switch(E){case e.NUMERIC:return n.getBitsLength(N);case e.ALPHANUMERIC:return s.getBitsLength(N);case e.KANJI:return l.getBitsLength(N);case e.BYTE:return i.getBitsLength(N)}}function b(N){return N.reduce(function(E,O){const x=E.length-1>=0?E[E.length-1]:null;return x&&x.mode===O.mode?(E[E.length-1].data+=O.data,E):(E.push(O),E)},[])}function S(N){const E=[];for(let O=0;O<N.length;O++){const x=N[O];switch(x.mode){case e.NUMERIC:E.push([x,{data:x.data,mode:e.ALPHANUMERIC,length:x.length},{data:x.data,mode:e.BYTE,length:x.length}]);break;case e.ALPHANUMERIC:E.push([x,{data:x.data,mode:e.BYTE,length:x.length}]);break;case e.KANJI:E.push([x,{data:x.data,mode:e.BYTE,length:p(x.data)}]);break;case e.BYTE:E.push([{data:x.data,mode:e.BYTE,length:p(x.data)}])}}return E}function j(N,E){const O={},x={start:{}};let W=["start"];for(let $=0;$<N.length;$++){const J=N[$],q=[];for(let V=0;V<J.length;V++){const ie=J[V],K=""+$+V;q.push(K),O[K]={node:ie,lastCount:0},x[K]={};for(let B=0;B<W.length;B++){const I=W[B];O[I]&&O[I].node.mode===ie.mode?(x[I][K]=g(O[I].lastCount+ie.length,ie.mode)-g(O[I].lastCount,ie.mode),O[I].lastCount+=ie.length):(O[I]&&(O[I].lastCount=ie.length),x[I][K]=g(ie.length,ie.mode)+4+e.getCharCountIndicator(ie.mode,E))}}W=q}for(let $=0;$<W.length;$++)x[W[$]].end=0;return{map:x,table:O}}function C(N,E){let O;const x=e.getBestModeForData(N);if(O=e.from(E,x),O!==e.BYTE&&O.bit<x.bit)throw new Error('"'+N+'" cannot be encoded with mode '+e.toString(O)+`.
160
+ Suggested mode is: `+e.toString(x));switch(O===e.KANJI&&!u.isKanjiModeEnabled()&&(O=e.BYTE),O){case e.NUMERIC:return new n(N);case e.ALPHANUMERIC:return new s(N);case e.KANJI:return new l(N);case e.BYTE:return new i(N)}}t.fromArray=function(E){return E.reduce(function(O,x){return typeof x=="string"?O.push(C(x,null)):x.data&&O.push(C(x.data,x.mode)),O},[])},t.fromString=function(E,O){const x=_(E,u.isKanjiModeEnabled()),W=S(x),$=j(W,O),J=h.find_path($.map,"start","end"),q=[];for(let V=1;V<J.length-1;V++)q.push($.table[J[V]].node);return t.fromArray(b(q))},t.rawSplit=function(E){return t.fromArray(_(E,u.isKanjiModeEnabled()))}})(am)),am}var GS;function $3(){if(GS)return Yp;GS=1;const t=Zo(),e=r_(),n=x3(),s=k3(),i=C3(),l=E3(),c=N3(),u=uE(),h=R3(),p=A3(),v=M3(),_=ea(),g=B3();function b($,J){const q=$.size,V=l.getPositions(J);for(let ie=0;ie<V.length;ie++){const K=V[ie][0],B=V[ie][1];for(let I=-1;I<=7;I++)if(!(K+I<=-1||q<=K+I))for(let D=-1;D<=7;D++)B+D<=-1||q<=B+D||(I>=0&&I<=6&&(D===0||D===6)||D>=0&&D<=6&&(I===0||I===6)||I>=2&&I<=4&&D>=2&&D<=4?$.set(K+I,B+D,!0,!0):$.set(K+I,B+D,!1,!0))}}function S($){const J=$.size;for(let q=8;q<J-8;q++){const V=q%2===0;$.set(q,6,V,!0),$.set(6,q,V,!0)}}function j($,J){const q=i.getPositions(J);for(let V=0;V<q.length;V++){const ie=q[V][0],K=q[V][1];for(let B=-2;B<=2;B++)for(let I=-2;I<=2;I++)B===-2||B===2||I===-2||I===2||B===0&&I===0?$.set(ie+B,K+I,!0,!0):$.set(ie+B,K+I,!1,!0)}}function C($,J){const q=$.size,V=p.getEncodedBits(J);let ie,K,B;for(let I=0;I<18;I++)ie=Math.floor(I/3),K=I%3+q-8-3,B=(V>>I&1)===1,$.set(ie,K,B,!0),$.set(K,ie,B,!0)}function N($,J,q){const V=$.size,ie=v.getEncodedBits(J,q);let K,B;for(K=0;K<15;K++)B=(ie>>K&1)===1,K<6?$.set(K,8,B,!0):K<8?$.set(K+1,8,B,!0):$.set(V-15+K,8,B,!0),K<8?$.set(8,V-K-1,B,!0):K<9?$.set(8,15-K-1+1,B,!0):$.set(8,15-K-1,B,!0);$.set(V-8,8,1,!0)}function E($,J){const q=$.size;let V=-1,ie=q-1,K=7,B=0;for(let I=q-1;I>0;I-=2)for(I===6&&I--;;){for(let D=0;D<2;D++)if(!$.isReserved(ie,I-D)){let T=!1;B<J.length&&(T=(J[B]>>>K&1)===1),$.set(ie,I-D,T),K--,K===-1&&(B++,K=7)}if(ie+=V,ie<0||q<=ie){ie-=V,V=-V;break}}}function O($,J,q){const V=new n;q.forEach(function(D){V.put(D.mode.bit,4),V.put(D.getLength(),_.getCharCountIndicator(D.mode,$)),D.write(V)});const ie=t.getSymbolTotalCodewords($),K=u.getTotalCodewordsCount($,J),B=(ie-K)*8;for(V.getLengthInBits()+4<=B&&V.put(0,4);V.getLengthInBits()%8!==0;)V.putBit(0);const I=(B-V.getLengthInBits())/8;for(let D=0;D<I;D++)V.put(D%2?17:236,8);return x(V,$,J)}function x($,J,q){const V=t.getSymbolTotalCodewords(J),ie=u.getTotalCodewordsCount(J,q),K=V-ie,B=u.getBlocksCount(J,q),I=V%B,D=B-I,T=Math.floor(V/B),z=Math.floor(K/B),R=z+1,M=T-z,L=new h(M);let H=0;const A=new Array(B),U=new Array(B);let Q=0;const ae=new Uint8Array($.buffer);for(let me=0;me<B;me++){const we=me<D?z:R;A[me]=ae.slice(H,H+we),U[me]=L.encode(A[me]),H+=we,Q=Math.max(Q,we)}const re=new Uint8Array(V);let je=0,te,ne;for(te=0;te<Q;te++)for(ne=0;ne<B;ne++)te<A[ne].length&&(re[je++]=A[ne][te]);for(te=0;te<M;te++)for(ne=0;ne<B;ne++)re[je++]=U[ne][te];return re}function W($,J,q,V){let ie;if(Array.isArray($))ie=g.fromArray($);else if(typeof $=="string"){let T=J;if(!T){const z=g.rawSplit($);T=p.getBestVersionForData(z,q)}ie=g.fromString($,T||40)}else throw new Error("Invalid data");const K=p.getBestVersionForData(ie,q);if(!K)throw new Error("The amount of data is too big to be stored in a QR Code");if(!J)J=K;else if(J<K)throw new Error(`
161
+ The chosen QR Code version cannot contain this amount of data.
162
+ Minimum version required to store current data is: `+K+`.
163
+ `);const B=O(J,q,ie),I=t.getSymbolSize(J),D=new s(I);return b(D,J),S(D),j(D,J),N(D,q,0),J>=7&&C(D,J),E(D,B),isNaN(V)&&(V=c.getBestMask(D,N.bind(null,D,q))),c.applyMask(V,D),N(D,q,V),{modules:D,version:J,errorCorrectionLevel:q,maskPattern:V,segments:ie}}return Yp.create=function(J,q){if(typeof J>"u"||J==="")throw new Error("No input text");let V=e.M,ie,K;return typeof q<"u"&&(V=e.from(q.errorCorrectionLevel,e.M),ie=p.from(q.version),K=c.from(q.maskPattern),q.toSJISFunc&&t.setToSJISFunction(q.toSJISFunc)),W(J,ie,V,K)},Yp}var fm={},pm={},XS;function fE(){return XS||(XS=1,(function(t){function e(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(l){return[l,l]}))),s.length===6&&s.push("F","F");const i=parseInt(s.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+s.slice(0,6).join("")}}t.getOptions=function(s){s||(s={}),s.color||(s.color={});const i=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,l=s.width&&s.width>=21?s.width:void 0,c=s.scale||4;return{width:l,scale:l?4:c,margin:i,color:{dark:e(s.color.dark||"#000000ff"),light:e(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},t.getScale=function(s,i){return i.width&&i.width>=s+i.margin*2?i.width/(s+i.margin*2):i.scale},t.getImageWidth=function(s,i){const l=t.getScale(s,i);return Math.floor((s+i.margin*2)*l)},t.qrToImageData=function(s,i,l){const c=i.modules.size,u=i.modules.data,h=t.getScale(c,l),p=Math.floor((c+l.margin*2)*h),v=l.margin*h,_=[l.color.light,l.color.dark];for(let g=0;g<p;g++)for(let b=0;b<p;b++){let S=(g*p+b)*4,j=l.color.light;if(g>=v&&b>=v&&g<p-v&&b<p-v){const C=Math.floor((g-v)/h),N=Math.floor((b-v)/h);j=_[u[C*c+N]?1:0]}s[S++]=j.r,s[S++]=j.g,s[S++]=j.b,s[S]=j.a}}})(pm)),pm}var JS;function z3(){return JS||(JS=1,(function(t){const e=fE();function n(i,l,c){i.clearRect(0,0,l.width,l.height),l.style||(l.style={}),l.height=c,l.width=c,l.style.height=c+"px",l.style.width=c+"px"}function s(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(l,c,u){let h=u,p=c;typeof h>"u"&&(!c||!c.getContext)&&(h=c,c=void 0),c||(p=s()),h=e.getOptions(h);const v=e.getImageWidth(l.modules.size,h),_=p.getContext("2d"),g=_.createImageData(v,v);return e.qrToImageData(g.data,l,h),n(_,p,v),_.putImageData(g,0,0),p},t.renderToDataURL=function(l,c,u){let h=u;typeof h>"u"&&(!c||!c.getContext)&&(h=c,c=void 0),h||(h={});const p=t.render(l,c,h),v=h.type||"image/png",_=h.rendererOpts||{};return p.toDataURL(v,_.quality)}})(fm)),fm}var mm={},QS;function F3(){if(QS)return mm;QS=1;const t=fE();function e(i,l){const c=i.a/255,u=l+'="'+i.hex+'"';return c<1?u+" "+l+'-opacity="'+c.toFixed(2).slice(1)+'"':u}function n(i,l,c){let u=i+l;return typeof c<"u"&&(u+=" "+c),u}function s(i,l,c){let u="",h=0,p=!1,v=0;for(let _=0;_<i.length;_++){const g=Math.floor(_%l),b=Math.floor(_/l);!g&&!p&&(p=!0),i[_]?(v++,_>0&&g>0&&i[_-1]||(u+=p?n("M",g+c,.5+b+c):n("m",h,0),h=0,p=!1),g+1<l&&i[_+1]||(u+=n("h",v),v=0)):h++}return u}return mm.render=function(l,c,u){const h=t.getOptions(c),p=l.modules.size,v=l.modules.data,_=p+h.margin*2,g=h.color.light.a?"<path "+e(h.color.light,"fill")+' d="M0 0h'+_+"v"+_+'H0z"/>':"",b="<path "+e(h.color.dark,"stroke")+' d="'+s(v,p,h.margin)+'"/>',S='viewBox="0 0 '+_+" "+_+'"',C='<svg xmlns="http://www.w3.org/2000/svg" '+(h.width?'width="'+h.width+'" height="'+h.width+'" ':"")+S+' shape-rendering="crispEdges">'+g+b+`</svg>
164
+ `;return typeof u=="function"&&u(null,C),C},mm}var ZS;function H3(){if(ZS)return Da;ZS=1;const t=S3(),e=$3(),n=z3(),s=F3();function i(l,c,u,h,p){const v=[].slice.call(arguments,1),_=v.length,g=typeof v[_-1]=="function";if(!g&&!t())throw new Error("Callback required as last argument");if(g){if(_<2)throw new Error("Too few arguments provided");_===2?(p=u,u=c,c=h=void 0):_===3&&(c.getContext&&typeof p>"u"?(p=h,h=void 0):(p=h,h=u,u=c,c=void 0))}else{if(_<1)throw new Error("Too few arguments provided");return _===1?(u=c,c=h=void 0):_===2&&!c.getContext&&(h=u,u=c,c=void 0),new Promise(function(b,S){try{const j=e.create(u,h);b(l(j,c,h))}catch(j){S(j)}})}try{const b=e.create(u,h);p(null,l(b,c,h))}catch(b){p(b)}}return Da.create=e.create,Da.toCanvas=i.bind(null,n.render),Da.toDataURL=i.bind(null,n.renderToDataURL),Da.toString=i.bind(null,function(l,c,u){return s.render(l,u)}),Da}var U3=H3();const W3=ov(U3);function ex(t){return typeof t=="string"?t.trim():t&&typeof t=="object"&&typeof t.data=="string"?t.data.trim():""}function q3(t){const e=String(t||"").trim();if(!e)return{kind:"empty"};const n=MI(e);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 K3(t,e,n=new Set,s=!1){if(!e||!e.ok)return t;const i=TI(t,e,n);return e.version===2&&e.name&&!n.has("name")&&!s&&(i.name=e.name),!n.has("label")&&!i.label&&e.label&&(i.label=e.label),i}function tx(t,e,n=new Set,s=!1){const i=String(e||"").trim(),l=q3(i);let c={...t,pairingUrl:i};return(l.kind==="complete"||l.kind==="partial")&&(c={...K3(c,l.decoded,n,s),pairingUrl:i}),{classification:l,form:c}}function Rd(t,e){const n=String(e||"").toLowerCase();if(!/^[a-f0-9]{16,64}$/.test(n))return"";const s=String(t||"NexusCrew").replace(/([a-z0-9])([A-Z])/g,"$1 $2");let i=ho(s);(i==="localhost"||i==="node")&&(i="nexuscrew");const l=n.slice(0,4),c=Math.max(1,32-l.length-1);return`${i.slice(0,c).replace(/-+$/g,"")||"n"}-${l}`}function V3(t,{deviceDefault:e="",localNodeId:n="",localNameDefault:s=""}={}){const i={name:t.name,ssh:t.ssh,pairingUrl:t.pairingUrl,...t.label?{label:t.label}:{},...t.sshPort?{sshPort:Number(t.sshPort)}:{}},l=t.localLabel||e;l&&(i.localLabel=l);const c=String(t.localName||Rd(l,n)||s||"").trim();return c&&(i.localName=c),i}function Y3(){const t=new Set;let e=!1;return{canAuto(n){return!e&&!t.has(String(n||""))},start(n){return e?!1:(e=!0,t.add(String(n||"")),!0)},finish(){e=!1},reset(n){t.delete(String(n||""))},isBusy(){return e}}}const G3=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function X3(t){const e=t&&t.data||{},n=typeof e.stage=="string"&&e.stage?e.stage:"",s=typeof e.detail=="string"&&e.detail?e.detail:"";return{stage:n,code:typeof e.code=="string"?e.code:"",detail:s,hint:typeof e.hint=="string"?e.hint:"",suggestedName:typeof e.suggestedName=="string"?e.suggestedName:"",retryable:typeof e.retryable=="boolean"?e.retryable:!n,message:s||String(t&&t.message||t)}}const J3="modulepreload",Q3=function(t){return"/"+t},nx={},Z3=function(e,n,s){let i=Promise.resolve();if(n&&n.length>0){let c=function(p){return Promise.all(p.map(v=>Promise.resolve(v).then(_=>({status:"fulfilled",value:_}),_=>({status:"rejected",reason:_}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),h=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));i=c(n.map(p=>{if(p=Q3(p),p in nx)return;nx[p]=!0;const v=p.endsWith(".css"),_=v?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${_}`))return;const g=document.createElement("link");if(g.rel=v?"stylesheet":J3,v||(g.as="script"),g.crossOrigin="",g.href=p,h&&g.setAttribute("nonce",h),document.head.appendChild(g),v)return new Promise((b,S)=>{g.addEventListener("load",b),g.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${p}`)))})}))}function l(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return i.then(c=>{for(const u of c||[])u.status==="rejected"&&l(u.reason);return e().catch(l)})};class Bt{constructor(e,n,s,i,l){this._legacyCanvasSize=Bt.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=e,this.$canvas=document.createElement("canvas"),s&&typeof s=="object"?this._onDecode=n:(console.warn(s||i||l?"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 i=="function"?i:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||l||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof i=="number"?i: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),e.disablePictureInPicture=!0,e.playsInline=!0,e.muted=!0;let c=!1;if(e.hidden&&(e.hidden=!1,c=!0),document.body.contains(e)||(document.body.appendChild(e),c=!0),s=e.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(i=!!n.overlay,this.$overlay=n.overlay||document.createElement("div"),l=this.$overlay.style,l.position="absolute",l.display="none",l.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!i&&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(e),requestAnimationFrame(()=>{let u=window.getComputedStyle(e);u.display==="none"&&(e.style.setProperty("display","block","important"),c=!0),u.visibility!=="visible"&&(e.style.setProperty("visibility","visible","important"),c=!0),c&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),e.style.opacity="0",e.style.width="0",e.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),e.addEventListener("play",this._onPlay),e.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=Bt.createQrEngine()}static set WORKER_PATH(e){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 Bt.listCameras(!1)).length}catch{return!1}}static async listCameras(e=!1){if(!navigator.mediaDevices)return[];let n=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(i=>i.kind==="videoinput"),s;try{e&&(await n()).every(i=>!i.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await n()).map((i,l)=>({id:i.deviceId,label:i.label||(l===0?"Default Camera":`Camera ${l+1}`)}))}finally{s&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),Bt._stopVideoStream(s))}}async hasFlash(){let e;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;e=this.$video.srcObject}else e=(await this._getCameraStream()).stream;return"torch"in e.getVideoTracks()[0].getSettings()}catch{return!1}finally{e&&e!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),Bt._stopVideoStream(e))}}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(e){throw this._flashOn=!1,e}}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(),Bt._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:e,facingMode:n}=await this._getCameraStream();!this._active||this._paused?Bt._stopVideoStream(e):(this._setVideoMirror(n),this.$video.srcObject=e,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(e){if(!this._paused)throw this._active=!1,e}}stop(){this.pause(),this._active=!1}async pause(e=!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&&(Bt._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return e?(n(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(n(),!0):!1)}async setCamera(e){e!==this._preferredCamera&&(this._preferredCamera=e,await this._restartVideoStream())}static async scanImage(e,n,s,i,l=!1,c=!1){let u,h=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(u=n.scanRegion,s=n.qrEngine,i=n.canvas,l=n.disallowCanvasResizing||!1,c=n.alsoTryWithoutScanRegion||!1,h=!0):console.warn(n||s||i||l||c?"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 p,v;[s,p]=await Promise.all([s||Bt.createQrEngine(),Bt._loadImage(e)]),[i,v]=Bt._drawToCanvas(p,u,i,l);let _;if(s instanceof Worker){let g=s;n||Bt._postWorkerMessageSync(g,"inversionMode","both"),_=await new Promise((b,S)=>{let j,C,N,E=-1;C=x=>{x.data.id===E&&(g.removeEventListener("message",C),g.removeEventListener("error",N),clearTimeout(j),x.data.data!==null?b({data:x.data.data,cornerPoints:Bt._convertPoints(x.data.cornerPoints,u)}):S(Bt.NO_QR_CODE_FOUND))},N=x=>{g.removeEventListener("message",C),g.removeEventListener("error",N),clearTimeout(j),S("Scanner error: "+(x?x.message||x:"Unknown Error"))},g.addEventListener("message",C),g.addEventListener("error",N),j=setTimeout(()=>N("timeout"),1e4);let O=v.getImageData(0,0,i.width,i.height);E=Bt._postWorkerMessageSync(g,"decode",O,[O.data.buffer])})}else _=await Promise.race([new Promise((g,b)=>window.setTimeout(()=>b("Scanner error: timeout"),1e4)),(async()=>{try{var[g]=await s.detect(i);if(!g)throw Bt.NO_QR_CODE_FOUND;return{data:g.rawValue,cornerPoints:Bt._convertPoints(g.cornerPoints,u)}}catch(b){if(g=b.message||b,/not implemented|service unavailable/.test(g))return Bt._disableBarcodeDetector=!0,Bt.scanImage(e,{scanRegion:u,canvas:i,disallowCanvasResizing:l,alsoTryWithoutScanRegion:c});throw`Scanner error: ${g}`}})()]);return h?_:_.data}catch(p){if(!u||!c)throw p;let v=await Bt.scanImage(e,{qrEngine:s,canvas:i,disallowCanvasResizing:l});return h?v:v.data}finally{n||Bt._postWorkerMessage(s,"close")}}setGrayscaleWeights(e,n,s,i=!0){Bt._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:e,green:n,blue:s,useIntegerApproximation:i})}setInversionMode(e){Bt._postWorkerMessage(this._qrEnginePromise,"inversionMode",e)}static async createQrEngine(e){if(e&&console.warn("Specifying a worker path is not required and not supported anymore."),e=()=>Z3(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!Bt._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return e();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:i})=>/arm/i.test(s||"arm")&&13<=parseInt(i||"13")).catch(()=>!0)?e():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(e){let n=Math.round(.6666666666666666*Math.min(e.videoWidth,e.videoHeight));return{x:Math.round((e.videoWidth-n)/2),y:Math.round((e.videoHeight-n)/2),width:n,height:n,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var e=this.$video,n=e.videoWidth,s=e.videoHeight,i=e.offsetWidth,l=e.offsetHeight,c=e.offsetLeft,u=e.offsetTop,h=window.getComputedStyle(e),p=h.objectFit,v=n/s,_=i/l;switch(p){case"none":var g=n,b=s;break;case"fill":g=i,b=l;break;default:(p==="cover"?v>_:v<_)?(b=l,g=b*v):(g=i,b=g/v),p==="scale-down"&&(g=Math.min(g,n),b=Math.min(b,s))}var[S,j]=h.objectPosition.split(" ").map((N,E)=>{const O=parseFloat(N);return N.endsWith("%")?(E?l-b:i-g)*O/100:O});h=this._scanRegion.width||n,_=this._scanRegion.height||s,p=this._scanRegion.x||0;var C=this._scanRegion.y||0;v=this.$overlay.style,v.width=`${h/n*g}px`,v.height=`${_/s*b}px`,v.top=`${u+j+C/s*b}px`,s=/scaleX\(-1\)/.test(e.style.transform),v.left=`${c+(s?i-S-g:S)+(s?n-p-h:p)/n*g}px`,v.transform=e.style.transform}})}static _convertPoints(e,n){if(!n)return e;let s=n.x||0,i=n.y||0,l=n.width&&n.downScaledWidth?n.width/n.downScaledWidth:1;n=n.height&&n.downScaledHeight?n.height/n.downScaledHeight:1;for(let c of e)c.x=c.x*l+s,c.y=c.y*n+i;return e}_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 e=Date.now()-this._lastScanTimestamp,n=1e3/this._maxScansPerSecond;e<n&&await new Promise(i=>setTimeout(i,n-e)),this._lastScanTimestamp=Date.now();try{var s=await Bt.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(i){if(!this._active)return;this._onDecodeError(i)}!Bt._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=Bt.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:i,y:l})=>`${i},${l}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(e){e!==Bt.NO_QR_CODE_FOUND&&console.log(e)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let e=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",n=[{width:{min:1024}},{width:{min:768}},{}],s=n.map(i=>Object.assign({},i,{[e]:{exact:this._preferredCamera}}));for(let i of[...s,...n])try{let l=await navigator.mediaDevices.getUserMedia({video:i,audio:!1}),c=this._getFacingMode(l)||(i.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:l,facingMode:c}}catch{}throw"Camera not found."}async _restartVideoStream(){let e=this._paused;await this.pause(!0)&&!e&&this._active&&await this.start()}static _stopVideoStream(e){for(let n of e.getTracks())n.stop(),e.removeTrack(n)}_setVideoMirror(e){this.$video.style.transform="scaleX("+(e==="user"?-1:1)+")"}_getFacingMode(e){return(e=e.getVideoTracks()[0])?/rear|back|environment/i.test(e.label)?"environment":/front|user|face/i.test(e.label)?"user":null:null}static _drawToCanvas(e,n,s,i=!1){s=s||document.createElement("canvas");let l=n&&n.x?n.x:0,c=n&&n.y?n.y:0,u=n&&n.width?n.width:e.videoWidth||e.width,h=n&&n.height?n.height:e.videoHeight||e.height;return i||(i=n&&n.downScaledWidth?n.downScaledWidth:u,n=n&&n.downScaledHeight?n.downScaledHeight:h,s.width!==i&&(s.width=i),s.height!==n&&(s.height=n)),n=s.getContext("2d",{alpha:!1}),n.imageSmoothingEnabled=!1,n.drawImage(e,l,c,u,h,0,0,s.width,s.height),[s,n]}static async _loadImage(e){if(e instanceof Image)return await Bt._awaitImageLoad(e),e;if(e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement||e instanceof SVGImageElement||"OffscreenCanvas"in window&&e instanceof OffscreenCanvas||"ImageBitmap"in window&&e instanceof ImageBitmap)return e;if(e instanceof File||e instanceof Blob||e instanceof URL||typeof e=="string"){let n=new Image;n.src=e instanceof File||e instanceof Blob?URL.createObjectURL(e):e.toString();try{return await Bt._awaitImageLoad(n),n}finally{(e instanceof File||e instanceof Blob)&&URL.revokeObjectURL(n.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(e){e.complete&&e.naturalWidth!==0||await new Promise((n,s)=>{let i=l=>{e.removeEventListener("load",i),e.removeEventListener("error",i),l instanceof ErrorEvent?s("Image load error"):n()};e.addEventListener("load",i),e.addEventListener("error",i)})}static async _postWorkerMessage(e,n,s,i){return Bt._postWorkerMessageSync(await e,n,s,i)}static _postWorkerMessageSync(e,n,s,i){if(!(e instanceof Worker))return-1;let l=Bt._workerMessageId++;return e.postMessage({id:l,type:n,data:s},i),l}}Bt.DEFAULT_CANVAS_SIZE=400;Bt.NO_QR_CODE_FOUND="No QR code found";Bt._disableBarcodeDetector=!1;Bt._workerMessageId=0;function e6({onResult:t,onClose:e}){const n=y.useRef(null),s=y.useRef(null),i=y.useRef(!1),[l,c]=y.useState("");y.useEffect(()=>{let h=!1;const p=n.current,v=_=>{h||i.current||(i.current=!0,t(_))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){c(f("qr-unsupported"));return}let _=!1;try{_=await Bt.hasCamera()}catch{_=!1}if(!_){c(f("qr-no-camera"));return}if(h||!p)return;const g=new Bt(p,b=>{const S=ex(b);S&&v(S)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:b=>{const S=b.videoWidth||640,j=b.videoHeight||480,C=Math.max(1,Math.round(Math.min(S,j)*.92));return{x:Math.round((S-C)/2),y:Math.round((j-C)/2),width:C,height:C,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=g;try{await g.start()}catch(b){if(h)return;const S=b&&b.name||"";c(f(S==="NotAllowedError"||S==="SecurityError"?"qr-permission":S==="NotFoundError"||S==="OverconstrainedError"||S==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{h=!0;const _=s.current;if(_){try{_.stop()}catch{}try{_.destroy()}catch{}s.current=null}const g=p,b=g&&g.srcObject;if(b&&typeof b.getTracks=="function"){for(const S of b.getTracks())try{S.stop()}catch{}try{g.srcObject=null}catch{}}}},[]);const u=async h=>{const p=h.target.files&&h.target.files[0];if(h.target.value="",!!p)try{const v=await Bt.scanImage(p,{returnDetailedScanResult:!0}),_=ex(v);if(!_)throw new Error("empty");i.current||(i.current=!0,t(_))}catch{c(f("pairing-qr-invalid"))}};return a.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:e,children:a.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:h=>h.stopPropagation(),children:[a.jsx("div",{className:"nc-sheet-head",children:a.jsx("b",{children:f("scan-qr")})}),a.jsx("video",{ref:n,className:"nc-qr-video",playsInline:!0,muted:!0}),l&&a.jsx("div",{className:"nc-err",role:"alert",children:l}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[f("qr-upload"),a.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:u})]}),a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:e,children:f("cancel")})]})]})})}function o_({line:t,note:e}){const[n,s]=y.useState(!1);return t?a.jsxs("div",{className:"nc-authkeys",role:"group",children:[a.jsx("div",{className:"nc-sheet-label",children:f("pair-authkeys-title")}),a.jsx("small",{className:"nc-set-hint",children:e||f("pair-authkeys-hint")}),a.jsx("textarea",{className:"nc-authkeys-line",readOnly:!0,rows:3,value:t,"aria-label":f("pair-authkeys-title"),onFocus:i=>i.target.select()}),a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:async()=>{s(await Mc(t))},children:f(n?"pair-authkeys-copied":"pair-authkeys-copy")})]}):null}const sx=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:"",localName:""});function pE({token:t,initial:e="",autoStart:n=!1,deviceDefault:s="",localNodeId:i="",localNameDefault:l="",readonly:c=!1,onSuccess:u,onBusyChange:h}){const[p,v]=y.useState(sx),[_,g]=y.useState(!1),[b,S]=y.useState(!1),[j,C]=y.useState("idle"),[N,E]=y.useState(null),[O,x]=y.useState(""),[W,$]=y.useState(null),[J,q]=y.useState(!1),[V,ie]=y.useState(!1),K=y.useRef(Y3()),B=y.useRef(new Set),I=j==="busy",D=Rd(p.localLabel||s,i)||l,T=V?p.localName:D;y.useEffect(()=>(h&&h(I),()=>{h&&h(!1)}),[I,h]);const z=async U=>{const Q=String(U.pairingUrl||"").trim();if(K.current.start(Q)){C("busy"),E(null),x("");try{const ae=await x5(t,V3({...U,localName:V?U.localName:Rd(U.localLabel||s,i)||l},{deviceDefault:s,localNodeId:i,localNameDefault:l}));C("ok"),g(!1),v(sx()),$(ae&&ae.authorizedKeys?{line:ae.authorizedKeys,note:ae.authorizedKeysNote||""}:null),B.current=new Set,q(!1),ie(!1),K.current.finish(),u&&await u(ae)}catch(ae){const re=X3(ae);E(re),C("idle"),K.current.finish(),re.code==="peer-name-conflict"&&Og(re.suggestedName)&&(ie(!0),B.current.add("localName"),v(je=>({...je,localName:re.suggestedName}))),(re.stage==="validation"||re.stage==="conflict"||re.stage==="ssh-start"||re.stage==="ssh-ready"||String(re.code||"").startsWith("ssh-"))&&g(!0)}}},R=(U,Q=!0)=>{const{classification:ae,form:re}=tx(p,U,B.current,J),je=re.pairingUrl;if(E(null),x(""),j==="ok"&&C("idle"),v(re),ae.kind==="invalid"){E({stage:"validation",code:"bad-link",message:f("pair-invalid-link"),hint:f("pair-invalid-hint"),retryable:!0});return}if(ae.kind==="partial"){g(!0),x(ae.missing.includes("ssh")?f("pair-missing-ssh"):f("pair-missing-name"));return}ae.kind==="complete"&&Q&&!c&&K.current.canAuto(je)&&z(re)};y.useEffect(()=>{e&&R(e,n)},[]);const M=()=>{const U=String(p.pairingUrl||"").trim(),{classification:Q,form:ae}=tx(p,U,B.current,J);if(v(ae),x(""),E(null),Q.kind==="empty"){E({stage:"validation",message:f("pairing-required"),retryable:!0});return}if(Q.kind==="invalid"){E({stage:"validation",code:"bad-link",message:f("pair-invalid-link"),hint:f("pair-invalid-hint"),retryable:!0});return}if(!ae.ssh||!ae.name){g(!0),x(ae.ssh?f("pair-missing-name"):f("pair-missing-ssh"));return}if(ae.label&&!Ja(ae.label)){E({stage:"validation",message:f("err-label"),retryable:!0});return}if(ae.localLabel&&!Ja(ae.localLabel)){E({stage:"validation",message:f("err-label"),retryable:!0});return}const re=V?ae.localName:Rd(ae.localLabel||s,i)||l;if(!Og(re)||re==="localhost"){g(!0),E({stage:"validation",code:"bad-local-name",message:f("err-local-name"),retryable:!0});return}K.current.reset(U),z(ae)},L=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const U=await navigator.clipboard.readText();U&&U.trim()?R(U):x(f("pair-clipboard-empty"))}catch{x(f("pair-clipboard-denied"))}},H=(U,Q)=>{B.current.add(U),v(ae=>({...ae,[U]:Q}))},A=N&&N.stage&&(G3.includes(N.stage)||N.stage==="internal")?f(`pair-stage-${N.stage}`):f("pair-stage-generic");return a.jsxs("div",{className:"nc-set-form nc-pair-card",children:[a.jsx("div",{className:"nc-sheet-label",children:f("pair-card-title")}),a.jsx("div",{className:"nc-set-info",children:f("pair-card-help")}),a.jsx("input",{className:"nc-pair-input",placeholder:f("pair-paste-ph"),value:p.pairingUrl,disabled:c||I,onChange:U=>{v({...p,pairingUrl:U.target.value}),E(null),x("")},onPaste:U=>{const Q=U.clipboardData&&U.clipboardData.getData("text")||"";Q.trim()&&(U.preventDefault(),R(Q))},onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),M())}}),a.jsxs("div",{className:"nc-pair-actions",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||I,onClick:L,children:f("pair-paste-btn")}),a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||I,onClick:()=>S(!0),children:f("scan-qr")}),a.jsx("button",{type:"button",className:"nc-btn primary",disabled:c||I,title:c?f("settings-readonly"):"",onClick:M,children:f("test-and-connect")})]}),a.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[I&&a.jsx("div",{className:"nc-pair-progress",children:f("pair-progress")}),j==="ok"&&a.jsx("div",{className:"nc-set-test ok",children:f("node-connected")}),j==="ok"&&W&&a.jsx(o_,{line:W.line,note:W.note}),O&&a.jsx("div",{className:"nc-set-hint nc-pair-notice",children:O}),N&&a.jsxs("div",{className:"nc-err",role:"alert",children:[a.jsx("b",{children:A})," — ",N.message,N.hint&&a.jsx("div",{className:"nc-pair-hint",children:N.hint}),N.retryable&&a.jsx("div",{children:a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||I,onClick:M,children:f("pair-retry")})})]})]}),a.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:I,onClick:()=>g(U=>!U),children:[_?"▾":"▸"," ",f("pair-advanced")]}),_&&a.jsxs("div",{className:"nc-pair-advanced",children:[a.jsxs("label",{className:"nc-field",children:[f("node-display-label"),a.jsx("input",{placeholder:"Home Relay",value:p.label,disabled:c||I,onChange:U=>{B.current.add("label"),v(Q=>({...Q,label:U.target.value,name:J?Q.name:ho(U.target.value)}))}})]}),a.jsxs("label",{className:"nc-field",children:[f("node-name-label"),a.jsx("input",{placeholder:f("node-name-ph"),value:p.name,disabled:c||I,onChange:U=>{q(!0),B.current.add("name"),v(Q=>({...Q,name:U.target.value?ho(U.target.value):""}))}})]}),a.jsx("small",{className:"nc-set-hint",children:f("node-slug-hint").replace("{slug}",p.name||"home-relay")}),a.jsxs("label",{className:"nc-field",children:[f("pair-ssh-local-label"),a.jsx("input",{placeholder:"my-relay",value:p.ssh,disabled:c||I,onChange:U=>{B.current.add("ssh"),H("ssh",U.target.value)}}),a.jsx("small",{className:"nc-set-hint",children:f("node-ssh-local-help")})]}),a.jsxs("label",{className:"nc-field",children:[f("node-ssh-port-label"),a.jsx("input",{inputMode:"numeric",placeholder:f("node-ssh-port-help"),value:p.sshPort,disabled:c||I,onChange:U=>H("sshPort",U.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),a.jsxs("label",{className:"nc-field",children:[f("device-name-label"),a.jsx("input",{placeholder:s||"NexusCrew",value:p.localLabel,disabled:c||I,onChange:U=>H("localLabel",U.target.value)}),a.jsx("small",{className:"nc-set-hint",children:f("device-name-hint")})]}),a.jsxs("label",{className:"nc-field",children:[f("local-route-name-label"),a.jsx("input",{placeholder:D||"nexuscrew-5bd6",value:T,disabled:c||I,onChange:U=>{ie(!0),B.current.add("localName"),v(Q=>({...Q,localName:U.target.value?ho(U.target.value):""}))}}),a.jsx("small",{className:"nc-set-hint",children:f("local-route-name-hint")})]})]}),b&&a.jsx(e6,{onResult:U=>{S(!1),R(U)},onClose:()=>S(!1)})]})}const Vi={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 a_(t){if(!t||typeof t!="object")return{key:Vi.down,up:!1};if(t.kind==="vl")return t.online?{key:Vi.vlOnline,up:!0}:{key:Vi.vlOffline,up:!1};if(t.kind==="transitive"){const n=t.stale===!0;return{key:n?Vi.routedStale:Vi.routed,up:!n,routed:!0}}const e=t.tunnel&&t.tunnel.status;return e==="up"?{key:Vi.up,up:!0}:e==="passive"?{key:Vi.passive,up:!1,passive:!0}:{key:Vi.down,up:!1}}function mE(t){if(!t||typeof t!="object")return{key:"peer-private",shortKey:"row-private",shared:!1};if(t.kind==="vl")return{key:"peer-vl-federated",shortKey:"row-vl-federated",shared:!0};if(t.shared!==!0)return{key:"peer-private",shortKey:"row-private",shared:!1};const e=t.visibility||"network";if(e==="relay-only")return{key:"visibility-relay",shortKey:"visibility-relay",shared:!0,visibility:e};if(e==="selected"){const n=Array.isArray(t.selected)?t.selected.length:0;return{key:"visibility-selected",shortKey:"visibility-selected",shared:!0,visibility:e,count:n}}return{key:"visibility-network",shortKey:"visibility-network",shared:!0,visibility:e}}function t6(t){const n=t.health&&typeof t.health.detail=="string"&&t.health.detail.trim()||f(t.online?Vi.vlOnline:Vi.vlOffline);return t.ownerLabel?`${t.ownerLabel} · ${n}`:n}function n6(t){if(!t||typeof t!="object")return null;const e=typeof t.name=="string"?t.name:"";if(!e)return null;const n=t.kind==="transitive";return{name:e,title:typeof t.label=="string"&&t.label.trim()||e,subtitle:t.kind==="vl"?t6(t):e,reach:a_(t),exposure:mE(t),routed:n,routeLabel:n&&Array.isArray(t.route)?t.route.join(" › "):null}}function s6(t){if(!t||typeof t!="object"||typeof t.name!="string"||!t.name)return null;const e=t.kind==="transitive";return{name:t.name,title:typeof t.label=="string"&&t.label.trim()||t.name,routed:e,route:e&&Array.isArray(t.route)?[...t.route]:null,ssh:!e&&t.direction==="outbound"&&t.ssh?String(t.ssh):null,inbound:!e&&t.direction==="inbound",transport:t.tunnel&&typeof t.tunnel.transport=="string"&&t.tunnel.transport||null}}function i6(t){return!t||typeof t!="object"?null:t.kind==="transitive"?{key:"authority-routed",ownerEquivalent:!1,grants:[],model:"none"}:{key:"authority-owner-equivalent",ownerEquivalent:!0,grants:[],model:"none"}}function r6(t,e){if(!t||t.visibility!=="selected")return[];const n=[...new Set(Array.isArray(t.selected)?t.selected:[])],s=new Map;for(const i of Array.isArray(e)?e:[])i&&i.nodeId&&!s.has(i.nodeId)&&s.set(i.nodeId,i);return n.map(i=>{const l=s.get(i);return{id:i,label:l?typeof l.label=="string"&&l.label.trim()||l.name:i,known:!!l}})}function o6(t,e,n=""){if(!t)return[];const s=new Set(Array.isArray(t.selected)?t.selected:[]),i=String(n||"").trim().toLowerCase(),l=new Set,c=[],u=h=>t.nodeId?h.nodeId===t.nodeId:h.name===t.name;for(const h of Array.isArray(e)?e:[]){if(!h||!h.nodeId||u(h)||s.has(h.nodeId)||l.has(h.nodeId))continue;const p=typeof h.label=="string"&&h.label.trim()||h.name;i&&!`${p} ${h.name}`.toLowerCase().includes(i)||(l.add(h.nodeId),c.push({id:h.nodeId,label:p,name:h.name}))}return c.sort((h,p)=>h.label.localeCompare(p.label))}function a6(t,{readonly:e=!1,busy:n=!1}={}){if(!t||typeof t!="object")return[];const s=t.actions&&typeof t.actions=="object"?t.actions:{},i=a_(t).up,l=[],c=(u,h,{mutating:p=!0,danger:v=!1}={})=>{l.push({key:u,action:h,danger:v,disabled:n||p&&e})};return s.edit&&c("edit","edit"),s.test&&c("node-test","test",{mutating:!1}),s.disconnect&&i&&c("tunnel-stop","down"),s.connect&&!i&&c("tunnel-start","up"),s.restart&&c("tunnel-restart","restart"),s.remove&&c("delete","remove",{danger:!0}),l}function gE(t){const e=t&&typeof t.cellVisibility=="string"?t.cellVisibility:"all";return["all","none","selected"].includes(e)?e:"all"}function l6(t,e){if(gE(t)!=="selected")return[];const n=[...new Set(Array.isArray(t.cells)?t.cells:[])];if(!Array.isArray(e))return n.map(i=>({id:i,label:i,known:!0}));const s=new Set(e.map(i=>typeof i=="string"?i:i&&(i.cell||i.id)).filter(Boolean));return n.map(i=>({id:i,label:i,known:s.has(i)}))}function c6(t,e,n=""){const s=new Set(Array.isArray(t&&t.cells)?t.cells:[]),i=String(n||"").trim().toLowerCase(),l=new Set,c=[];for(const u of Array.isArray(e)?e:[]){const h=typeof u=="string"?u:u&&(u.cell||u.id);!h||s.has(h)||l.has(h)||i&&!h.toLowerCase().includes(i)||(l.add(h),c.push({id:h,label:h}))}return c.sort((u,h)=>u.label.localeCompare(h.label))}function u6(t){if(!t||typeof t!="object"||t.kind!=="direct")return null;const e=t.access&&typeof t.access=="object"&&!Array.isArray(t.access)?t.access:null;return{label:typeof t.accessLabel=="string"?t.accessLabel:"unconfigured",configured:t.accessConfigured===!0,grants:e}}function d6(t,e,{readonly:n=!1,busy:s=!1}={}){const i=s6(t);return i?{identity:i,reach:a_(t),authority:i6(t),exposure:mE(t),grants:r6(t,e),cellScope:gE(t),actions:a6(t,{readonly:n,busy:s}),canEditVisibility:!!(t.actions&&t.actions.visibility)&&t.shared===!0&&t.kind!=="transitive",canEditCellScope:!!(t.actions&&t.actions.edit)&&t.kind!=="transitive"}:null}const h6=Object.freeze(["cellVisibility","eventsAccess","nodeEventsAccess","askReplyAccess","filesReadAccess","liveHostAccess","panelAccess","peerOperatorAccess"]),f6=Object.freeze(["admin","user","nexushost"]),p6=Object.freeze({admin:Object.freeze({cellVisibility:"all",eventsAccess:!0,nodeEventsAccess:!0,askReplyAccess:!0,filesReadAccess:!0,liveHostAccess:!0,panelAccess:!0,peerOperatorAccess:!0}),user:Object.freeze({cellVisibility:"all",eventsAccess:!0,nodeEventsAccess:!0,askReplyAccess:!1,filesReadAccess:!0,liveHostAccess:!1,panelAccess:!1,peerOperatorAccess:!1}),nexushost:Object.freeze({cellVisibility:"none",eventsAccess:!1,nodeEventsAccess:!1,askReplyAccess:!1,filesReadAccess:!1,liveHostAccess:!1,panelAccess:!1,peerOperatorAccess:!1})});function m6(t,e,n=!1){const s=p6[e];if(!s)return[];const i=t&&typeof t=="object"?t:{},l=h6.map(c=>{const u=s[c],h=i[c];return{key:c,current:h,next:u,changed:h!==u}});return e==="admin"&&l.push({key:"eventsReceive",current:n===!0,next:!0,changed:n!==!0}),l}const vE="nc_push_local_v1",ix=Object.freeze({enabled:!0});function _E(t){return{enabled:(t&&typeof t=="object"&&!Array.isArray(t)?t:{}).enabled!==!1}}function l_(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function yE(t=l_()){if(!t)return{...ix};try{return _E(JSON.parse(t.getItem(vE)||"null"))}catch{return{...ix}}}function g6(t,e=l_()){const n=_E(t);if(e)try{e.setItem(vE,JSON.stringify(n))}catch{}return n}function v6(t=l_()){return yE(t).enabled===!1}function c_(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function _6(t){const e="=".repeat((4-t.length%4)%4),n=(t+e).replace(/-/g,"+").replace(/_/g,"/"),s=atob(n),i=new Uint8Array(s.length);for(let l=0;l<s.length;l+=1)i[l]=s.charCodeAt(l);return i}async function wE(){if(!c_())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function bE(t){if(!c_())throw new Error("push-unsupported");if(v6())throw new Error("push-disabled-local");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const n=await qn("/api/push/vapid",t),{publicKey:s}=await n.json();if(!s)throw new Error("vapid non disponibile");const l=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:_6(s)}),c=await qn("/api/push/subscribe",t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:l.toJSON()})});if(!c.ok){try{await l.unsubscribe()}catch{}const u=await c.json().catch(()=>({}));throw new Error(u.error||`HTTP ${c.status}`)}return!0}async function rx(t){if(!c_())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 qn("/api/push/subscribe",t,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const y6=new Set(["update_candidate"]),ox=4096,w6=new Set(["prompt"]),ax={logs:{limit:50}};function b6(t){if(!t||t.kind!=="vl")return[];const e=Array.isArray(t.capabilities)?t.capabilities:[],n=new Set,s=[];for(const i of e)typeof i!="string"||!i||y6.has(i)||w6.has(i)||n.has(i)||(n.add(i),s.push(i));return s}function lx(t){return!!(t&&t.kind==="vl"&&Array.isArray(t.capabilities)&&t.capabilities.includes("prompt"))}function S6(t){return ax[t]?{...ax[t]}:{}}function x6(t,e){return t?t.inflight&&typeof t.inflight=="object"?{phase:"inflight",kind:t.inflight.kind}:e?t.lastAck&&t.lastAck.id===e.id?{phase:"done",kind:e.kind,status:t.lastAck.status,result:t.lastAck.result,at:t.lastAck.at}:{phase:"submitted",kind:e.kind}:t.lastAck&&typeof t.lastAck=="object"?{phase:"done",kind:null,status:t.lastAck.status,result:t.lastAck.result,at:t.lastAck.at}:null:null}function k6({title:t,subtitle:e,status:n,footer:s,onClose:i,plain:l=!1,children:c}){const u=y.useRef(null),h=y.useRef(null);return y.useEffect(()=>(h.current=document.activeElement,u.current&&u.current.focus(),()=>{const p=h.current;p&&typeof p.focus=="function"&&document.contains(p)&&p.focus()}),[]),y.useEffect(()=>{const p=v=>{v.key==="Escape"&&(v.stopPropagation(),i&&i())};return document.addEventListener("keydown",p,!0),()=>document.removeEventListener("keydown",p,!0)},[i]),a.jsx("div",{className:"nc-detail-overlay",onMouseDown:p=>{p.target===p.currentTarget&&i&&i()},children:a.jsxs("div",{className:"nc-detail-sheet",ref:u,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":typeof t=="string"?t:void 0,children:[a.jsxs("div",{className:"nc-detail-head",children:[a.jsxs("div",{className:"nc-detail-title",children:[a.jsx("b",{children:t}),e&&a.jsx("small",{children:e})]}),n,a.jsx("button",{type:"button",className:"nc-btn ghost nc-detail-close",onClick:i,"aria-label":f("close"),children:a.jsx(_t,{name:"x",size:14})})]}),a.jsx("div",{className:`nc-detail-body${l?" plain":""}`,children:c}),s&&a.jsx("div",{className:"nc-detail-foot",children:s})]})})}function Ao({title:t,hint:e,children:n}){return n==null||n===!1?null:a.jsxs("section",{className:"nc-detail-section",children:[t&&a.jsx("div",{className:"nc-sheet-label",children:t}),e&&a.jsx("small",{className:"nc-set-hint",children:e}),n]})}function C6({node:t,nodes:e,token:n,readonly:s,refresh:i,onClose:l,peerAccessRevision:c=null}){var ot,ee;zn();const[u,h]=y.useState(null),[p,v]=y.useState(null),[_,g]=y.useState(null),[b,S]=y.useState(null),[j,C]=y.useState(!1),[N,E]=y.useState(""),[O,x]=y.useState(!1),[W,$]=y.useState(null),[J,q]=y.useState(!1),[V,ie]=y.useState(""),[K,B]=y.useState(!1),[I,D]=y.useState(null),[T,z]=y.useState(!1),[R,M]=y.useState(""),[L,H]=y.useState(null),A=y.useMemo(()=>d6(t,e,{readonly:s,busy:!!u}),[t,e,s,u]);if(!A)return null;const{identity:U,reach:Q,authority:ae,exposure:re,grants:je,actions:te,canEditVisibility:ne,canEditCellScope:me,cellScope:we}=A,Fe=u6(t),Ae=U.routed?{up:Q.up,since:null}:Bg(t.tunnel,Date.now()),He=async(P,le)=>{v(null),h(P);try{await le()}catch(_e){v(String(_e&&_e.message||_e))}h(null)},X=P=>{if(P==="edit"){S({label:t.label||t.name,ssh:t.ssh||"",sshPort:t.sshPort?String(t.sshPort):"",autostart:t.autostart===!0,visibility:t.visibility||"network"});return}if(P==="remove"){C(!0);return}He(`${t.name}:${P}`,async()=>{const le=await hv(n,t.name,P);P==="test"&&g(le),await i()})},ce=(P,le=S6(P))=>He(`${t.nodeId}:${P}`,async()=>{const _e=await Qw(n,t.nodeId,P,le,t.route||[]);D({id:_e.id,kind:P,submittedAt:Date.now()}),await i()}),Z=()=>{const P=R.trim().slice(0,ox);P&&He(`${t.nodeId}:prompt`,async()=>{const le=await Qw(n,t.nodeId,"prompt",{text:P},t.route||[]);D({id:le.id,kind:"prompt",submittedAt:Date.now()}),M(""),z(!1),await i()})},ge=()=>{if(!Ja(b.label)){v(f("err-label"));return}const P=U.inbound?{label:b.label,visibility:b.visibility,selected:b.visibility==="selected"?[...t.selected||[]]:[]}:{label:b.label,ssh:b.ssh,autostart:b.autostart,...b.sshPort?{sshPort:Number(b.sshPort)}:{}};return He(`${t.name}:edit`,async()=>{await rp(n,t.name,P),S(null),await i()})},Y=(P,le)=>He(`${t.name}:visibility`,async()=>{await L5(n,t.name,P,le),await i()}),he=ne&&t.visibility==="selected"?o6(t,e,N):[],Ne=(P,le)=>He(`${t.name}:cell-scope`,async()=>{await rp(n,t.name,P==="selected"?{cellVisibility:P,cells:Array.isArray(le)?le:t.cells||[]}:{cellVisibility:P}),await i()}),Ce=P=>He(`${t.name}:access`,async()=>{try{if(await rp(n,t.name,{accessRole:P,accessRevision:c}),P==="admin"&&typeof Notification<"u"&&Notification.permission==="granted")try{await wE()==="idle"&&await bE(n)}catch{}H(null),await i()}catch(le){if(le&&le.status===409)v(f("peer-access-conflict")),await i();else throw le}}),Ve=async({retry:P=!1}={})=>{if(P&&J)q(!1);else if(W!==null||J)return;try{const le=await rh(n);$(Array.isArray(le&&le.cells)?le.cells:[])}catch{q(!0)}};y.useEffect(()=>{me&&we==="selected"&&W===null&&Ve()},[me,we,W]);const Ye=l6(t,W),ht=we==="selected"?c6(t,W,V):[],ze=a.jsxs("span",{className:`nc-set-tunnel${Q.up?" up":""}`,children:[f(Q.key),Ae.since?` · ${Ae.since}`:""]}),ve=t.kind==="vl",Oe=ve?b6(t):[],et=ve?x6(t,I):null,Ue=P=>{const le=`vl-cmd-${P}`,_e=f(le);return _e===le?P:_e},st=ve?[...Oe.map(P=>a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u||s,title:s?f("settings-readonly"):void 0,onClick:()=>ce(P),children:Ue(P)},P)),...lx(t)?[a.jsx("button",{type:"button",className:`nc-btn ghost${T?" on":""}`,disabled:!!u||s,title:s?f("settings-readonly"):void 0,onClick:()=>z(P=>!P),children:Ue("prompt")},"prompt")]:[]]:te.map(P=>a.jsx("button",{type:"button",className:`nc-btn ${P.danger?"danger":"ghost"}`,disabled:P.disabled,title:P.disabled&&s?f("settings-readonly"):void 0,onClick:()=>X(P.action),children:P.action==="remove"?a.jsxs(a.Fragment,{children:[a.jsx(_t,{name:"trash",size:14})," ",f(P.key)]}):f(P.key)},P.action));return a.jsxs(k6,{title:U.title,subtitle:U.name,status:ze,footer:st,onClose:l,children:[a.jsxs(Ao,{title:f("node-detail-reach"),children:[a.jsxs("dl",{className:"nc-detail-facts",children:[U.route&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:f("node-detail-route")}),a.jsx("dd",{children:U.route.join(" › ")})]}),U.ssh&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:f("node-detail-ssh")}),a.jsxs("dd",{children:[U.ssh,t.sshPort?`:${t.sshPort}`:""]})]}),U.transport&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:f("node-detail-transport")}),a.jsx("dd",{children:U.transport})]}),ve&&t.ownerLabel&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:f("node-detail-owner")}),a.jsx("dd",{children:t.ownerLabel})]})]}),((ot=t.health)==null?void 0:ot.detail)&&a.jsx("div",{className:`nc-set-test${ve?t.health.state==="running"?" ok":t.health.state==="starting"?"":" ko":t.health.status==="healthy"?" ok":t.health.status==="passive"?"":" ko"}`,children:t.health.detail}),(()=>{const P=aI(t.health);return P?P.line?a.jsx(o_,{line:P.line,note:P.note}):a.jsx("small",{className:"nc-set-hint",children:P.note}):null})(),_&&a.jsxs("div",{className:`nc-set-test${_.ok?" ok":" ko"}`,children:[_.result,_.detail?` — ${_.detail}`:""]})]}),ve&&a.jsxs(Ao,{title:f("node-detail-command"),children:[Oe.length===0&&!lx(t)&&a.jsx("small",{className:"nc-set-hint",children:f("vl-no-commands")}),T&&a.jsxs("div",{className:"nc-vl-prompt",children:[a.jsx("textarea",{value:R,maxLength:ox,placeholder:f("vl-prompt-placeholder"),"aria-label":f("vl-prompt-placeholder"),disabled:!!u||s,onChange:P=>M(P.target.value)}),a.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!u||s||!R.trim(),onClick:Z,children:f("vl-prompt-send")})]}),et&&a.jsxs("div",{className:`nc-set-test${et.phase==="done"?et.status==="ok"?" ok":" ko":""}`,children:[et.kind&&`${Ue(et.kind)}: `,et.phase==="submitted"&&f("vl-cmd-phase-submitted"),et.phase==="inflight"&&f("vl-cmd-phase-inflight"),et.phase==="done"&&f(et.status==="ok"?"vl-cmd-phase-done-ok":"vl-cmd-phase-done-error"),et.phase==="done"&&((ee=et.result)!=null&&ee.detail)?` — ${et.result.detail}`:""]})]}),a.jsxs(Ao,{title:f("node-detail-authority"),children:[a.jsx("div",{className:"nc-set-info",children:f(ae.key)}),ae.grants.length===0&&a.jsx("small",{className:"nc-set-hint",children:f(me?"authority-no-grants":"authority-no-grants-elsewhere")})]}),a.jsxs(Ao,{title:f("node-detail-network-view"),children:[a.jsx("div",{className:"nc-set-info",children:f(ve?re.key:re.shared?"peer-shared":"peer-private")}),ne&&a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"nc-field",children:[f("peer-visibility"),a.jsxs("select",{value:t.visibility||"network",disabled:s||!!u,onChange:P=>Y(P.target.value),children:[a.jsx("option",{value:"network",children:f("visibility-network")}),a.jsx("option",{value:"relay-only",children:f("visibility-relay")}),a.jsx("option",{value:"selected",children:f("visibility-selected")})]})]}),t.visibility==="selected"&&a.jsxs("div",{className:"nc-detail-grants",children:[je.length===0&&a.jsx("small",{className:"nc-set-hint",children:f("node-grant-none")}),je.map(P=>a.jsxs("div",{className:`nc-detail-grant${P.known?"":" unknown"}`,children:[a.jsxs("span",{children:[P.label,P.known?"":` — ${f("node-grant-unknown")}`]}),a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>Y("selected",(t.selected||[]).filter(le=>le!==P.id)),children:f("node-grant-remove")})]},P.id)),!O&&a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>{x(!0),E("")},children:f("node-grant-add")}),O&&a.jsxs("div",{className:"nc-detail-picker",children:[a.jsx("input",{value:N,placeholder:f("node-grant-search"),disabled:s||!!u,onChange:P=>E(P.target.value)}),a.jsxs("div",{className:"nc-detail-picker-list",children:[he.length===0&&a.jsx("small",{className:"nc-set-hint",children:f("node-grant-no-candidates")}),he.map(P=>a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await Y("selected",[...t.selected||[],P.id]),x(!1),E("")},children:P.label},P.id))]}),a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{x(!1),E("")},children:f("cancel")})]})]})]})]}),me&&a.jsxs(Ao,{title:f("cell-scope"),children:[a.jsx("small",{className:"nc-set-hint",children:f("cell-scope-help")}),a.jsx("label",{className:"nc-field",children:a.jsxs("select",{value:we,"aria-label":f("cell-scope"),disabled:s||!!u,onChange:P=>{P.target.value==="selected"&&Ve(),Ne(P.target.value)},children:[a.jsx("option",{value:"all",children:f("cell-scope-all")}),a.jsx("option",{value:"none",children:f("cell-scope-none")}),a.jsx("option",{value:"selected",children:f("cell-scope-selected")})]})}),we==="selected"&&Ye.length>0&&a.jsx("small",{className:"nc-set-hint",children:f("cell-scope-reset-warning")}),J&&a.jsx("small",{className:"nc-set-hint",children:f("cell-scope-list-unavailable")}),we==="selected"&&a.jsxs("div",{className:"nc-detail-grants",children:[Ye.length===0&&a.jsx("small",{className:"nc-set-hint",children:f("cell-scope-none-granted")}),Ye.map(P=>a.jsxs("div",{className:`nc-detail-grant${P.known?"":" unknown"}`,children:[a.jsxs("span",{children:[P.label,P.known?"":` — ${f("cell-scope-unknown")}`]}),a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>Ne("selected",(t.cells||[]).filter(le=>le!==P.id)),children:f("node-grant-remove")})]},P.id)),!K&&a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await Ve({retry:!0}),B(!0),ie("")},children:f("cell-scope-add")}),K&&a.jsxs("div",{className:"nc-detail-picker",children:[a.jsx("input",{value:V,placeholder:f("cell-scope-search"),disabled:s||!!u,onChange:P=>ie(P.target.value)}),a.jsxs("div",{className:"nc-detail-picker-list",children:[ht.length===0&&a.jsx("small",{className:"nc-set-hint",children:f("cell-scope-no-candidates")}),ht.map(P=>a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await Ne("selected",[...t.cells||[],P.id]),B(!1),ie("")},children:P.label},P.id))]}),a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{B(!1),ie("")},children:f("cancel")})]})]})]}),Fe&&c!=null&&!ve&&a.jsxs(Ao,{title:f("peer-access"),children:[a.jsx("small",{className:"nc-set-hint",children:f("peer-access-help")}),a.jsxs("div",{className:"nc-set-info",children:[f("peer-access-current"),": ",a.jsx("b",{children:f(`access-label-${Fe.label}`)})]}),a.jsx("label",{className:"nc-field",children:a.jsxs("select",{value:L||"","aria-label":f("peer-access-preset"),disabled:s||!!u,title:s?f("settings-readonly"):void 0,onChange:P=>H(P.target.value||null),children:[a.jsx("option",{value:"",children:f("peer-access-preset-none")}),f6.map(P=>a.jsx("option",{value:P,children:f(`access-label-${P}`)},P))]})}),L&&(()=>{const P=m6(Fe.grants,L,t.eventsReceive),le=P.filter(_e=>_e.changed).length;return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"nc-access-matrix",role:"table","aria-label":f("peer-access-matrix"),children:P.map(_e=>a.jsxs("div",{role:"row",className:`nc-access-row${_e.changed?" changed":""}`,children:[a.jsx("span",{role:"rowheader",children:f(`access-grant-${_e.key}`)}),a.jsx("span",{children:f(`access-value-${_e.current===!0?"yes":_e.current===!1?"no":String(_e.current)}`)}),a.jsx("span",{"aria-hidden":"true",children:"→"}),a.jsx("span",{children:f(`access-value-${_e.next===!0?"yes":_e.next===!1?"no":String(_e.next)}`)})]},_e.key))}),a.jsx("small",{className:"nc-set-hint",children:f(le===0?"peer-access-unchanged":"peer-access-changed-hint")}),a.jsx("button",{type:"button",className:"nc-btn primary",disabled:s||!!u,title:s?f("settings-readonly"):void 0,onClick:()=>Ce(L),children:f("peer-access-apply")})]})})()]}),b&&a.jsxs(Ao,{title:f("edit"),children:[a.jsxs("label",{className:"nc-field",children:[f("node-display-label"),a.jsx("input",{value:b.label,disabled:!!u,onChange:P=>S({...b,label:P.target.value})})]}),U.inbound?a.jsxs("label",{className:"nc-field",children:[f("peer-visibility"),a.jsxs("select",{value:b.visibility,disabled:!!u,onChange:P=>S({...b,visibility:P.target.value}),children:[a.jsx("option",{value:"network",children:f("visibility-network")}),a.jsx("option",{value:"relay-only",children:f("visibility-relay")}),a.jsx("option",{value:"selected",children:f("visibility-selected")})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"nc-field",children:[f("node-ssh-label"),a.jsx("input",{value:b.ssh,disabled:!!u,onChange:P=>S({...b,ssh:P.target.value})})]}),a.jsxs("label",{className:"nc-field",children:[f("node-ssh-port-label"),a.jsx("input",{inputMode:"numeric",value:b.sshPort,disabled:!!u,onChange:P=>S({...b,sshPort:P.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:b.autostart,disabled:!!u,onChange:P=>S({...b,autostart:P.target.checked})})," ",f("boot-persist")]})]}),a.jsxs("div",{className:"nc-set-row",children:[a.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!u,onClick:ge,children:f("save")}),a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>S(null),children:f("cancel")})]})]}),j&&a.jsxs("div",{className:"nc-set-confirm",children:[a.jsx("b",{children:f("node-remove-confirm").replace("{name}",U.title)}),a.jsx("small",{children:f("node-remove-warning")}),a.jsxs("div",{className:"nc-set-row",children:[a.jsx("button",{type:"button",className:"nc-btn danger",disabled:!!u,onClick:()=>He(`${t.name}:remove`,async()=>{await N5(n,t.name),C(!1),await i(),l&&l()}),children:f("delete")}),a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>C(!1),children:f("cancel")})]})]}),p&&a.jsx("div",{className:"nc-err",children:p})]})}function E6(t,e){y.useEffect(()=>{if(typeof document>"u"||!document.addEventListener){const u=setInterval(t,e);return()=>clearInterval(u)}let n=null;const s=()=>document.visibilityState!=="hidden",i=()=>{n!==null&&(clearInterval(n),n=null)},l=()=>{n===null&&s()&&(n=setInterval(t,e))},c=()=>{s()?(i(),t(),l()):i()};return l(),document.addEventListener("visibilitychange",c),()=>{i(),document.removeEventListener("visibilitychange",c)}},[t,e])}const Kg="nexuscrew.fleet",SE=3,N6="nexuscrew.cells",xE=/^[A-Za-z0-9._-]{1,32}$/,Nh=/^[a-z0-9._-]{1,32}$/,kE=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,CE=new Set(["standard","unsafe"]),j6=4096,L6=4096,Jd=256,EE=8192,R6=4096,A6=32,M6=64,fd=100,T6=128,P6=new Set(["format","version","exportedAt","cells","engines","models"]),I6=new Set(["id","cwdRel","engine","boot","model","models","permissionPolicies","commands","systemPrompt","prompt","label","mcp"]),D6=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]);function Io(t){if(typeof t!="string"||t.length>L6)return null;for(let n=0;n<t.length;n+=1){const s=t.charCodeAt(n);if(s<=31||s===127||s===92)return null}if(t==="")return"";if(t.charAt(0)==="/"||/^[A-Za-z]:/.test(t))return null;const e=[];for(const n of t.split("/"))if(!(n===""||n===".")){if(n==="..")return null;e.push(n)}return e.join("/")}const O6=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag","panelUrl"]),B6=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]),$6=new Set(["127.0.0.1","localhost","[::1]"]);function u_(t){if(typeof t!="string"||!t||t.length>512||/[\x00-\x1f\x7f]|\s/.test(t))return!1;let e;try{e=new URL(t)}catch{return!1}return!(e.protocol!=="http:"&&e.protocol!=="https:"||!$6.has(e.hostname))}function kr(t,e){return typeof t=="string"&&t.length<=e&&!/[\x00-\x1f\x7f]/.test(t)}function d_(t){const e=String(t||"");return/(?:bearer\s+|authorization\s*[:=]|(?:api[_-]?key|secret|token)\s*[:=])/i.test(e)||/^-{1,2}(?:api[-_]?key|access[-_]?key|auth(?:orization)?[-_]?token|token|secret|password|credential)(?:$|=)/i.test(e)||/\b(?:sk|fw|fpk|hf|zai)[-_][A-Za-z0-9._-]{8,}\b/i.test(e)||/https?:\/\/[^\s/@:]+:[^\s/@]+@/i.test(e)}function xc(t,e){if(t===void 0)return{};if(!t||typeof t!="object"||Array.isArray(t))return null;const n=Object.entries(t);if(n.length>128)return null;const s={};for(const[i,l]of n){if(!Nh.test(i)||!e(l))return null;s[i]=l}return s}function NE(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(u=>!I6.has(u))||!xE.test(String(t.id||""))||typeof t.cwdRel!="string")return null;const e=Io(t.cwdRel);if(e===null||!Nh.test(String(t.engine||""))||t.boot!==void 0&&typeof t.boot!="boolean"||t.model!==void 0&&(typeof t.model!="string"||t.model.length>Jd)||t.systemPrompt!==void 0&&t.prompt!==void 0&&t.systemPrompt!==t.prompt)return null;const n=t.systemPrompt===void 0?t.prompt===void 0?"":t.prompt:t.systemPrompt;if(typeof n!="string"||n.length>EE)return null;const s=xc(t.models,u=>typeof u=="string"&&!!u&&u.length<=Jd),i=xc(t.permissionPolicies,u=>CE.has(u)),l=xc(t.commands,u=>kr(u,R6)&&!d_(u));if(s===null||i===null||l===null)return null;const c={id:t.id,cwdRel:e,engine:t.engine,boot:t.boot===!0,systemPrompt:n};if(t.model&&(c.model=t.model),t.label!==void 0){if(!kr(t.label,M6)||!String(t.label).trim())return null;c.label=String(t.label).trim()}return Object.keys(s).length&&(c.models=s),Object.keys(i).length&&(c.permissionPolicies=i),Object.keys(l).length&&(c.commands=l),c}function z6(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(l=>!D6.has(l))||!xE.test(String(t.id||""))||typeof t.cwd!="string"||!t.cwd||t.cwd.length>j6||!Nh.test(String(t.engine||""))||t.boot!==void 0&&typeof t.boot!="boolean"||t.model!==void 0&&(typeof t.model!="string"||t.model.length>Jd)||t.systemPrompt!==void 0&&t.prompt!==void 0&&t.systemPrompt!==t.prompt)return null;const e=t.systemPrompt===void 0?t.prompt===void 0?"":t.prompt:t.systemPrompt;if(typeof e!="string"||e.length>EE)return null;const n=xc(t.models,l=>typeof l=="string"&&!!l&&l.length<=Jd),s=xc(t.permissionPolicies,l=>CE.has(l));if(n===null||s===null)return null;const i={id:t.id,cwd:t.cwd,engine:t.engine,boot:t.boot===!0,systemPrompt:e};return t.model&&(i.model=t.model),Object.keys(n).length&&(i.models=n),Object.keys(s).length&&(i.permissionPolicies=s),i}function F6(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(n=>!B6.has(n)))return null;const e={};for(const[n,s]of Object.entries(t)){if(typeof s!="string"||!kr(s,n==="baseUrl"?512:128)||d_(s))return null;e[n]=s}return!e.client||!e.provider||e.envKey&&!kE.test(e.envKey)?null:e}function jE(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(s=>!O6.has(s))||!Nh.test(String(t.id||""))||!kr(t.label||t.id,64)||t.rc!==void 0&&typeof t.rc!="boolean"||t.panelUrl!==void 0&&!u_(t.panelUrl))return null;const e={id:t.id,label:t.label||t.id,rc:t.rc===!0};if(t.panelUrl!==void 0&&(e.panelUrl=t.panelUrl),t.managed!==void 0){const s=F6(t.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(i=>t[i]!==void 0)?null:(e.managed=s,e)}if(!kr(t.command,512)||!t.command.startsWith("/")||!Array.isArray(t.args)||t.args.length>32||t.args.some(s=>!kr(s,1024)||d_(s))||t.promptMode!=="flag"&&t.promptMode!=="send-keys"||t.promptMode==="flag"&&(!kr(t.promptFlag,32)||/\s/.test(t.promptFlag)))return null;if(t.model!==void 0){if(!t.model||typeof t.model!="object"||Array.isArray(t.model)||Object.keys(t.model).some(s=>s!=="flag"&&s!=="value")||!kr(t.model.flag,32)||/\s/.test(t.model.flag)||!kr(t.model.value||"",128))return null;e.model={flag:t.model.flag,value:t.model.value||""}}const n=t.envKeys===void 0?[]:t.envKeys;return!Array.isArray(n)||n.length>32||n.some(s=>!kE.test(s))?null:(Object.assign(e,{command:t.command,args:[...t.args],envKeys:[...new Set(n)].sort(),promptMode:t.promptMode}),t.promptMode==="flag"&&(e.promptFlag=t.promptFlag),e)}function LE(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t.managed?{id:t.id,label:t.label,rc:t.rc,managed:t.managed,...t.panelUrl!==void 0?{panelUrl:t.panelUrl}:{}}:{id:t.id,label:t.label,rc:t.rc,command:t.command,args:t.args,envKeys:t.envKeys,model:t.model,promptMode:t.promptMode,promptFlag:t.promptFlag,...t.panelUrl!==void 0?{panelUrl:t.panelUrl}:{}},n=jE(e);return n||null}function H6(t,e,n){const s=new Set;for(const i of Array.isArray(e)?e:[]){if(!n.has(i.id)||!i.managed)continue;const{client:l,provider:c,credentialProfile:u}=i.managed;s.add(u?`${l}.${c}-${u}`:`${l}.${c}`),s.add(`${l}.${c}`)}return(Array.isArray(t)?t:[]).filter(i=>i&&s.has(i.engine))}function U6(t,e,n=[],s=[],i=new Date,l=[]){n instanceof Date&&(i=n,n=[],s=[]);const c=e instanceof Set?e:new Set(e||[]),u=s instanceof Set?s:new Set(s||[]),h=[];for(const _ of Array.isArray(t)?t:[]){if(!c.has(_.id))continue;const g=NE({id:_.id,cwdRel:_.cwdRel,engine:_.engine,boot:_.boot===!0,..._.label?{label:_.label}:{},..._.model?{model:_.model}:{},..._.models?{models:_.models}:{},..._.permissionPolicies?{permissionPolicies:_.permissionPolicies}:{},systemPrompt:_.prompt||"",..._.commands?{commands:_.commands}:{}});if(!g)return{ok:!1,error:"invalid-cell",invalidCellIds:[_.id]};h.push(g)}const p=[];for(const _ of Array.isArray(n)?n:[]){if(!u.has(_.id))continue;const g=LE(_);g&&p.push(g)}const v=H6(l,n,u);return{format:Kg,version:SE,exportedAt:i.toISOString(),cells:h,engines:p,...v.length?{models:v}:{}}}function W6(t){let e;try{e=JSON.parse(String(t||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const n=(e==null?void 0:e.format)===N6&&(e==null?void 0:e.version)===1,s=(e==null?void 0:e.format)===Kg&&(e==null?void 0:e.version)===2,i=(e==null?void 0:e.format)===Kg&&(e==null?void 0:e.version)===SE,l=n||s,c=s||i;if(c&&Array.isArray(e.engines)&&e.engines.length>fd)return{ok:!1,error:"invalid-format",detail:`${e.engines.length} engine dichiarati, cap ${fd}; riduci gli engine a ${fd} o meno`,cells:[],engines:[]};if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(g=>!P6.has(g))||!n&&!s&&!i||!Array.isArray(e.cells)||e.cells.length>A6||c&&(!Array.isArray(e.engines)||e.engines.length>fd))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const u=[],h=new Set;for(const g of e.cells){const b=l?z6(g):NE(g);if(!b)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(h.has(b.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};h.add(b.id),u.push(b)}const p=[],v=new Set;for(const g of c?e.engines:[]){const b=jE(g);if(!b)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(v.has(b.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};v.add(b.id),p.push(b)}const _=[];if(e.models!==void 0){if(!Array.isArray(e.models)||e.models.length>T6)return{ok:!1,error:"invalid-model",cells:[],engines:[]};const g=new Set;for(const b of e.models){if(!b||typeof b!="object"||Array.isArray(b))return{ok:!1,error:"invalid-model",cells:[],engines:[]};const S=new Set(["id","engine","label","contextWindow","maxTokens","tools","vision","reasoning"]);if(Object.keys(b).some(E=>!S.has(E)))return{ok:!1,error:"invalid-model",cells:[],engines:[]};const j=typeof b.id=="string"?b.id.trim():"",C=typeof b.engine=="string"?b.engine.trim():"";if(!j||!C)return{ok:!1,error:"invalid-model",cells:[],engines:[]};for(const E of["contextWindow","maxTokens"])if(b[E]!==void 0&&(!Number.isSafeInteger(b[E])||b[E]<1024||b[E]>1e8))return{ok:!1,error:"invalid-model",cells:[],engines:[]};for(const E of["tools","vision","reasoning"])if(b[E]!==void 0&&typeof b[E]!="boolean")return{ok:!1,error:"invalid-model",cells:[],engines:[]};const N=`${C}::${j}`;if(g.has(N))return{ok:!1,error:"duplicate-model",cells:[],engines:[]};g.add(N),_.push({...b,id:j,engine:C})}}return{ok:!0,cells:u,engines:p,models:_,legacy:l,exportedAt:typeof e.exportedAt=="string"?e.exportedAt:""}}function q6(t,e,n){const s=new Set(n||[]);if(!s.has(e))return null;const i=p=>Object.fromEntries(Object.entries(p||{}).filter(([v])=>s.has(v))),l={id:t.id,engine:e,boot:t.boot===!0,prompt:t.systemPrompt||""};typeof t.label=="string"&&t.label&&(l.label=t.label),typeof t.cwdRel=="string"?l.cwdRel=t.cwdRel:typeof t.cwd=="string"&&t.cwd&&(l.cwd=t.cwd),e===t.engine&&t.model?l.model=t.model:t.models&&t.models[e]&&(l.model=t.models[e]);const c=i(t.models),u=i(t.permissionPolicies),h=i(t.commands);return Object.keys(c).length&&(l.models=c),Object.keys(u).length&&(l.permissionPolicies=u),Object.keys(h).length&&(l.commands=h),l}const K6=()=>({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,panelUrl:""}),cx=(t="")=>({id:"",cwd:"",engine:t,boot:!1,label:"",model:"",prompt:"",commands:{},command:"",panelUrl:""}),RE=t=>t==="claude"?"unsafe":"standard",Fc=(t,e)=>t.find(n=>n.client===e.client&&n.provider===e.provider&&(n.credentialProfile||"")===(e.credentialProfile||"")),V6=(t,e)=>{var n;return((n=Fc(t,e))==null?void 0:n.label)||`${e.client} · ${e.provider}`};function Y6(t){var e,n,s,i,l,c,u,h,p,v,_,g,b,S,j;return{kind:t.managed?"managed":"custom",id:t.id,label:t.label||"",command:t.command||"",argsText:(t.args||[]).join(`
165
+ `),rc:!!t.rc,client:((e=t.managed)==null?void 0:e.client)||"claude",provider:((n=t.managed)==null?void 0:n.provider)||"native",credentialProfile:((s=t.managed)==null?void 0:s.credentialProfile)||"",managedModel:((i=t.managed)==null?void 0:i.model)||"",permissionPolicy:((l=t.managed)==null?void 0:l.permissionPolicy)||RE((c=t.managed)==null?void 0:c.client),credentialSourcePolicy:((u=t.managed)==null?void 0:u.credentialSourcePolicy)||"auto",displayName:((h=t.managed)==null?void 0:h.displayName)||"",protocol:((p=t.managed)==null?void 0:p.protocol)||"",baseUrl:((v=t.managed)==null?void 0:v.baseUrl)||"",envKey:((_=t.managed)==null?void 0:_.envKey)||"",providerId:((g=t.managed)==null?void 0:g.providerId)||"nexuscrew-custom",modelOptions:t.availableModels||((b=t.managedInfo)==null?void 0:b.models)||[],promptMode:t.promptMode||"send-keys",promptFlag:t.promptFlag||"",modelFlag:((S=t.model)==null?void 0:S.flag)||"",modelValue:((j=t.model)==null?void 0:j.value)||"",envRows:(t.envKeys||[]).map(C=>({key:C,value:"",configured:!0,remove:!1})),credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,panelUrl:t.panelUrl||""}}function ux(t,e,n){const s=(e.panelUrl||"").trim();return n?s&&(t.panelUrl=s):t.panelUrl=s||null,t}function G6(t,e,n=[]){if(t.kind==="managed"){const i={client:t.client,provider:t.provider,model:t.client==="shell"?"":t.managedModel||"",permissionPolicy:t.client==="shell"?"standard":t.permissionPolicy||RE(t.client)};t.credentialProfile&&(i.credentialProfile=t.credentialProfile),t.credentialSourcePolicy&&t.credentialSourcePolicy!=="auto"&&(i.credentialSourcePolicy=t.credentialSourcePolicy);const l=Fc(n,t);return(l==null?void 0:l.credentialEnv)===!0&&(i.envKey=t.envKey),t.provider==="custom"&&Object.assign(i,{displayName:t.displayName,protocol:t.protocol,baseUrl:t.baseUrl,envKey:t.envKey,providerId:t.providerId}),ux({...e?{id:t.id}:{},label:t.label||V6(n,t),rc:!!t.rc,managed:i},t,e)}const s={...e?{id:t.id}:{},label:t.label||t.id,rc:!!t.rc,command:t.command,args:t.argsText.split(`
166
+ `).filter(i=>i!==""),promptMode:t.promptMode};return t.modelFlag&&(s.model={flag:t.modelFlag,value:t.modelValue||""}),t.promptMode==="flag"&&(s.promptFlag=t.promptFlag),e&&(s.env=Object.fromEntries(t.envRows.filter(i=>!i.remove&&i.key).map(i=>[i.key,i.value]))),ux(s,t,e)}function Qr({children:t,onClose:e,label:n,error:s=""}){const i=y.useRef(null),l=y.useRef(null),c=y.useRef(e);return c.current=e,y.useEffect(()=>{const u=document.activeElement,h=i.current,p=()=>Array.from((h==null?void 0:h.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))||[]).filter(g=>g.offsetParent!==null),v=requestAnimationFrame(()=>{var g;return(g=p()[0]||h)==null?void 0:g.focus({preventScroll:!0})}),_=g=>{var C;if(g.key==="Escape"){g.preventDefault(),(C=c.current)==null||C.call(c);return}if(g.key!=="Tab")return;const b=p();if(!b.length){g.preventDefault(),h==null||h.focus();return}const S=b[0],j=b[b.length-1];g.shiftKey&&document.activeElement===S?(g.preventDefault(),j.focus()):!g.shiftKey&&document.activeElement===j&&(g.preventDefault(),S.focus())};return document.addEventListener("keydown",_),()=>{cancelAnimationFrame(v),document.removeEventListener("keydown",_),u&&u.isConnected&&typeof u.focus=="function"&&u.focus({preventScroll:!0})}},[]),y.useEffect(()=>{s&&requestAnimationFrame(()=>{var u;return(u=l.current)==null?void 0:u.scrollIntoView({block:"nearest"})})},[s]),a.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:u=>{u.target===u.currentTarget&&e()},children:a.jsxs("div",{ref:i,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":n||f("settings"),tabIndex:-1,children:[t,s&&a.jsx("div",{ref:l,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:s})]})})}function gm({token:t,targets:e=[],readonly:n=!1,onPower:s,onImport:i}){const[l,c]=y.useState([]),[u,h]=y.useState(0);y.useEffect(()=>{let C=!0;async function N(){const O=[{route:[],label:f("local")}].concat((e||[]).map(W=>({route:Array.isArray(W.route)?W.route:[],label:W.label||(W.route||[]).join(" › ")}))),x=await Promise.all(O.map(async W=>{const $={...W,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const J=await tl(t,W.route);$.available=!!J.available,$.capabilities=J.capabilities||[],$.provider=J.provider||null,$.cells=(J.cells||[]).map(q=>({...q,route:W.route}));try{$.readonly=!!(await qc(t,W.route)).readonlyDefault}catch{}try{const q=await dv(t,W.route),V=new Set($.cells.map(ie=>ie.tmuxSession).filter(Boolean));$.unmanaged=(q.sessions||[]).filter(ie=>ie&&!V.has(ie.name))}catch{}}catch(J){$.err=String(J&&J.message||J)}return $}));C&&c(x)}N();const E=setInterval(N,6e3);return()=>{C=!1,clearInterval(E)}},[t,e,u]);const p=(C,N)=>Array.isArray(C.capabilities)&&C.capabilities.includes(N)&&!n&&!C.readonly,v=()=>h(C=>C+1),_=(C,N)=>{s&&s({...C,route:N})},g=(C,N)=>{s&&s({...C,route:N})},b=async(C,N)=>{try{await oc(t,C.cell,N)}catch{}v()},S=async(C,N)=>{if(window.confirm(f("fleet-remove-cell").replace("{id}",C.cell))){try{await Xx(t,C.cell,!0,N)}catch{}v()}},j=async(C,N)=>{if(window.confirm(f("terminate-confirm").replace("{name}",C.name))){try{await cv(t,C.name,N)}catch{}v()}};return a.jsxs("div",{className:"nc-fleet-inventory",children:[a.jsxs("div",{className:"nc-fleet-section-head",children:[a.jsx("b",{children:f("fleet-inventory")}),a.jsx("small",{children:f("fleet-inventory-help")})]}),l.map(C=>{const N=C.route.length?C.route.join("/"):"local";return a.jsxs("div",{className:"nc-fleet-pos",children:[a.jsxs("div",{className:"nc-fleet-pos-title",children:[a.jsx("span",{className:`dot ${C.available?"on":"warn"}`}),a.jsx("b",{children:C.label}),a.jsx("small",{children:C.available?`${C.cells.length} ${f("fleet-cells")} · ${C.unmanaged.length} ${f("fleet-tmux")}`:C.err||f("fleet-not-available")})]}),C.cells.map(E=>a.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[a.jsxs("span",{children:[a.jsx("b",{children:E.cell}),a.jsx("small",{children:`${E.engine||""}${E.key?`·${E.key}`:""}${E.active?"":` · ${f("cell-off")}`}`})]}),a.jsxs("span",{className:"nc-fleet-cell-actions",children:[E.active&&p(C,"down")&&a.jsx("button",{className:"nc-btn ghost",title:f("power-off"),onClick:()=>g(E,C.route),children:f("stop")}),!E.active&&p(C,"up")&&a.jsx("button",{className:"nc-btn ghost",title:f("power-on"),onClick:()=>_(E,C.route),children:f("start")}),p(C,"restart")&&E.active&&a.jsx("button",{className:"nc-btn ghost",title:f("restart"),onClick:()=>b(E,C.route),children:f("restart")}),p(C,"remove")&&a.jsx("button",{className:"nc-btn danger",title:f("delete"),onClick:()=>S(E,C.route),children:"×"})]})]},`${N}:${E.cell}`)),C.unmanaged.map(E=>a.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[a.jsxs("span",{children:[a.jsx("b",{children:E.name}),a.jsx("small",{children:f("fleet-tmux")})]}),a.jsxs("span",{className:"nc-fleet-cell-actions",children:[p(C,"import")&&i&&a.jsx("button",{className:"nc-btn ghost",title:f("import-as-cell"),onClick:()=>i(E,C.route),children:f("import-as-cell")}),a.jsx("button",{className:"nc-btn danger",title:f("terminate"),onClick:()=>j(E,C.route),children:"×"})]})]},`${N}:u:${E.name}`)),C.available&&C.cells.length===0&&C.unmanaged.length===0&&a.jsx("div",{className:"nc-empty",children:f("fleet-inventory-empty")})]},N)})]})}function X6({cells:t=[],engines:e=[],models:n=[],busy:s,canRestore:i=!1,onRestore:l,onClose:c}){const[u,h]=y.useState("export"),[p,v]=y.useState([]),[_,g]=y.useState(()=>new Set(t.map(z=>z.id))),[b,S]=y.useState(()=>new Set(e.map(z=>z.id))),[j,C]=y.useState([]),[N,E]=y.useState([]),[O,x]=y.useState(""),W=new Set(e.map(z=>z.id)),$=new Set(t.map(z=>z.id)),J=(z,R)=>z(M=>{const L=new Set(M);return L.has(R)?L.delete(R):L.add(R),L}),q=()=>{const z=U6(t,_,e,b,new Date,n);if(z.ok===!1){x(f(`fleet-backup-${z.error}`));return}const R=t.filter(U=>_.has(U.id)).length,M=e.filter(U=>b.has(U.id)).length;if(z.cells.length!==R){x(f("fleet-backup-invalid-cell"));return}if(z.engines.length!==M){x(f("fleet-backup-invalid-engine"));return}if(!z.cells.length&&!z.engines.length){x(f("fleet-backup-select-one"));return}const L=new Blob([`${JSON.stringify(z,null,2)}
167
+ `],{type:"application/json"}),H=URL.createObjectURL(L),A=document.createElement("a");A.href=H,A.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(A),A.click(),A.remove(),setTimeout(()=>URL.revokeObjectURL(H),0),x("")},V=async z=>{if(x(""),C([]),E([]),!!z){if(z.size>1024*1024){x(f("fleet-backup-too-large"));return}try{const R=W6(await z.text());if(!R.ok){x(f(`fleet-backup-${R.error}`));return}v(Array.isArray(R.models)?R.models:[]);const M=new Set(R.engines.map(L=>L.id));E(R.engines.map(L=>({engine:L,exists:W.has(L.id),selected:!W.has(L.id)}))),C(R.cells.map(L=>{const H=W.has(L.engine)||M.has(L.engine),A=$.has(L.id);return{cell:L,engine:H?L.engine:"",selected:H&&!A,exists:A}}))}catch(R){x(String(R.message||R))}}},ie=(z,R)=>C(M=>M.map((L,H)=>H===z?{...L,...R}:L)),K=(z,R)=>E(M=>M.map((L,H)=>H===z?{...L,...R}:L)),B=new Set([...W,...N.filter(z=>z.selected).map(z=>z.engine.id)]),I=j.filter(z=>z.selected&&z.engine&&B.has(z.engine)),D=N.filter(z=>z.selected),T=[...(()=>{const z=new Map(e.map(R=>[R.id,R]));for(const R of N)!R.selected||z.has(R.engine.id)||z.set(R.engine.id,R.engine);return z})().values()];return a.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[a.jsx("b",{children:f("fleet-backup")}),a.jsx("small",{children:f("fleet-backup-help")}),a.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[a.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="export"?" on":""}`,onClick:()=>{h("export"),x("")},children:f("fleet-backup-export")}),a.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="import"?" on":""}`,disabled:!i,title:i?"":f("fleet-backup-restore-unavailable"),onClick:()=>{h("import"),x("")},children:f("fleet-backup-import")})]}),u==="export"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"nc-set-row",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{g(new Set(t.map(z=>z.id))),S(new Set(e.map(z=>z.id)))},children:f("select-all")}),a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{g(new Set),S(new Set)},children:f("select-none")})]}),a.jsxs("div",{className:"nc-backup-list",children:[a.jsx("b",{children:f("fleet-engines")}),e.map(z=>{var R;return a.jsxs("label",{className:"nc-check nc-backup-row",children:[a.jsx("input",{type:"checkbox",checked:b.has(z.id),onChange:()=>J(S,z.id)}),a.jsxs("span",{children:[a.jsx("b",{children:z.label||z.id}),a.jsxs("small",{children:[z.id,(R=z.envKeys)!=null&&R.length?` · ${z.envKeys.length} ${f("fleet-backup-env-names")}`:""]})]})]},z.id)}),a.jsx("b",{children:f("fleet-cells")}),t.map(z=>a.jsxs("label",{className:"nc-check nc-backup-row",children:[a.jsx("input",{type:"checkbox",checked:_.has(z.id),onChange:()=>J(g,z.id)}),a.jsxs("span",{children:[a.jsx("b",{children:z.id}),a.jsxs("small",{children:[z.engine," · ",f("fleet-system-prompt")," ",(z.prompt||"").length," ",f("characters")]})]})]},z.id)),!t.length&&!e.length&&a.jsx("div",{className:"nc-empty",children:f("fleet-backup-empty")})]}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:c,children:f("cancel")}),a.jsx("button",{type:"button",className:"nc-btn primary",disabled:!_.size&&!b.size,onClick:q,children:f("fleet-backup-download")})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("input",{type:"file",accept:"application/json,.json",disabled:s,onChange:z=>V(z.target.files&&z.target.files[0])}),a.jsx("small",{children:f("fleet-backup-import-help")}),!!(j.length||N.length)&&a.jsxs("div",{className:"nc-set-row",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{E(z=>z.map(R=>({...R,selected:!0}))),C(z=>z.map(R=>({...R,selected:!!R.engine})))},children:f("select-all")}),a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{E(z=>z.map(R=>({...R,selected:!1}))),C(z=>z.map(R=>({...R,selected:!1})))},children:f("select-none")})]}),a.jsxs("div",{className:"nc-backup-list",children:[!!N.length&&a.jsx("b",{children:f("fleet-engines")}),N.map((z,R)=>{var M;return a.jsx("div",{className:"nc-backup-import-row",children:a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:z.selected,onChange:L=>K(R,{selected:L.target.checked})}),a.jsxs("span",{children:[a.jsx("b",{children:z.engine.label||z.engine.id}),a.jsxs("small",{children:[z.engine.id," · ",z.exists?f("fleet-backup-overwrite"):f("fleet-backup-new"),(M=z.engine.envKeys)!=null&&M.length?` · ${f("fleet-backup-env-values-required")}`:""]})]})]})},z.engine.id)}),!!j.length&&a.jsx("b",{children:f("fleet-cells")}),j.map((z,R)=>a.jsxs("div",{className:"nc-backup-import-row",children:[a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:z.selected,disabled:!z.engine||!B.has(z.engine),onChange:M=>ie(R,{selected:M.target.checked})}),a.jsxs("span",{children:[a.jsx("b",{children:z.cell.id}),a.jsxs("small",{children:[z.exists?f("fleet-backup-overwrite"):f("fleet-backup-new")," · ",f("fleet-system-prompt")," ",z.cell.systemPrompt.length," ",f("characters")]})]})]}),a.jsxs("select",{value:z.engine,onChange:M=>ie(R,{engine:M.target.value,selected:!!M.target.value}),children:[a.jsx("option",{value:"",children:f("fleet-backup-engine-missing")}),a.jsx(_h,{engines:T})]})]},z.cell.id))]}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:c,children:f("cancel")}),a.jsx("button",{type:"button",className:"nc-btn primary",disabled:s||!I.length&&!D.length,onClick:()=>l({engineRows:N,cellRows:j,models:p}),children:f("fleet-backup-restore")})]})]}),O&&a.jsx("div",{className:"nc-err",children:O})]})}const AE=["contextWindow","maxTokens"],jh=["tools","vision","reasoning"],J6=1024,Q6=1e8;function Do(t){const e=Number(t);return Number.isSafeInteger(e)&&e>=J6&&e<=Q6}function ME(t){const e=t&&typeof t=="object"?t:{},n={};for(const s of AE){const i=e[s];if(i==null)continue;const l=String(i).trim();l&&!Do(l)&&(n[s]="out-of-range")}for(const s of jh){const i=e[s];i==null||i===""||i!==!0&&i!==!1&&i!=="true"&&i!=="false"&&(n[s]="not-a-boolean")}return n}function dx(t){const e=t&&typeof t=="object"?t:{},n=ME(e);if(Object.keys(n).length){const i=new Error(`invalid model values: ${Object.keys(n).join(", ")}`);throw i.code="invalid-model-values",i.fields=n,i}const s={};for(const i of AE){const l=e[i];if(l==null)continue;const c=String(l).trim();if(!c)continue;const u=Number(c);Do(u)&&(s[i]=u)}for(const i of jh){const l=e[i];l===!0||l==="true"?s[i]=!0:(l===!1||l==="false")&&(s[i]=!1)}return s}const hx=[["contextWindow","fleet-models-field-context"],["maxTokens","fleet-models-field-output"],["tools","fleet-models-field-tools"],["vision","fleet-models-field-vision"],["reasoning","fleet-models-field-reasoning"]],Z6=[["contextWindow","fleet-models-field-context"],["maxTokens","fleet-models-field-output"]],fx={user:"fleet-models-source-user",api:"fleet-models-source-api",public:"fleet-models-source-public",backup:"fleet-models-source-backup"},e4=["missing-key","key-rejected","access-denied","credential-unavailable","endpoint-unreachable","provider-error","invalid-response","anonymous-success"];function t4(t,e){return t==="missing-key"&&!e?"fleet-models-auth-missing-key-anonymous":`fleet-models-auth-${t}`}function px({model:t,fields:e,busy:n,onConfirm:s,onCancel:i,mode:l,error:c="",writing:u=!1}){const[h,p]=y.useState(()=>Object.fromEntries(e.map(({field:S,value:j,backup:C})=>[S,j!=null?String(j):C!==void 0?String(C):""]))),v=l==="missing",_=ME(h),g=Object.keys(_).length>0,b=v?f("fleet-models-missing-title"):f("fleet-models-make-mine-title").replace("{model}",t);return a.jsxs("div",{className:"nc-fleet-missing",role:"dialog","aria-label":b,children:[a.jsx("b",{className:v?"nc-err":void 0,children:b}),a.jsx("small",{children:v?f("fleet-models-missing-why").replace("{model}",t):f("fleet-models-make-mine-why")}),e.map(({field:S,label:j,backup:C})=>jh.includes(S)?a.jsxs("label",{className:"nc-field",children:[f(j),a.jsxs("select",{"aria-label":f(j),value:h[S]||"",disabled:n,onChange:N=>p({...h,[S]:N.target.value}),children:[a.jsx("option",{value:"",children:f("fleet-models-value-absent")}),a.jsx("option",{value:"true",children:f("fleet-models-value-true")}),a.jsx("option",{value:"false",children:f("fleet-models-value-false")})]})]},S):a.jsxs("label",{className:"nc-field",children:[f(j),a.jsx("input",{inputMode:"numeric",value:h[S]||"",disabled:n,"aria-label":f(j),placeholder:C!==void 0?String(C):"",autoComplete:"off",onChange:N=>p({...h,[S]:N.target.value.replace(/[^0-9]/g,"").slice(0,9)})}),_[S]&&a.jsx("small",{className:"nc-err",children:f("model-editor-limit-invalid")}),C!==void 0&&a.jsx("small",{className:"nc-fleet-models-note",children:f("fleet-models-missing-backup").replace("{value}",String(C))})]},S)),a.jsx("small",{children:f("fleet-models-missing-user")}),c&&a.jsx("small",{className:"nc-err nc-fleet-write-error",children:c}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||u,onClick:i,children:f(v?"fleet-models-missing-empty":"cancel")}),a.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||u||g,onClick:()=>s(h),children:f(v?"fleet-models-missing-confirm":"fleet-models-make-mine-confirm")})]})]})}function n4({engineId:t,fetchModels:e,onPick:n,activeModel:s,onSetModelValue:i,busy:l}){const[c,u]=y.useState({loading:!0,refreshing:!1,result:null,error:""}),h=y.useRef(e);h.current=e;const p=Q=>h.current(t,Q).then(ae=>({loading:!1,refreshing:!1,result:ae,error:""})).catch(()=>({loading:!1,refreshing:!1,result:null,error:f("fleet-models-error")}));y.useEffect(()=>{let Q=!0;return u({loading:!0,refreshing:!1,result:null,error:""}),p(!1).then(ae=>{Q&&u(ae)}),()=>{Q=!1}},[t]);const v=()=>{c.loading||c.refreshing||(u({...c,refreshing:!0}),h.current(t,!0).then(Q=>{u({loading:!1,refreshing:!1,result:Q,error:""})}).catch(()=>{u({loading:!1,refreshing:!1,result:c.result,error:f("fleet-models-error")})}))},_=String(s||"").trim(),g=c.result,b=g&&Array.isArray(g.models)?g.models:[],S=g&&g.auth&&typeof g.auth=="object"?g.auth:null,j=S&&e4.includes(S.cause)?S.cause:"",C=S&&typeof S.envKey=="string"?S.envKey:"",N=_?b.find(Q=>Q.id===_):null,E=!c.loading&&!c.error&&g&&g.supported!==!1&&_?Z6.filter(([Q])=>!N||N[Q]===void 0).map(([Q,ae])=>({field:Q,label:ae,backup:N&&N.backupValues?N.backupValues[Q]:void 0})):[],O=`${_}:${E.map(Q=>Q.field).join(",")}`,x=y.useRef(""),[W,$]=y.useState(!1);y.useEffect(()=>{!E.length||!i||x.current!==O&&(x.current=O,$(!0))},[O,i]);const J=()=>{$(!1),B("")},q=async(Q,ae)=>{let re;try{const je=await Promise.resolve(i(t,Q,ae));re=je&&je.ok===!1?{ok:!1,error:je.error||f("fleet-models-write-failed")}:{ok:!0}}catch(je){re={ok:!1,error:String(je&&je.message||je)}}if(re.ok){u({loading:!0,refreshing:!1,result:null,error:""});try{u(await p(!1))}catch{}}return re},[V,ie]=y.useState(!1),[K,B]=y.useState(""),I=async Q=>{B(""),ie(!0);const ae=await q(_,Q);ie(!1),ae.ok?$(!1):B(ae.error)},[D,T]=y.useState(null),[z,R]=y.useState(!1),[M,L]=y.useState(""),H=async Q=>{const ae=D&&D.model;if(!ae)return;L(""),R(!0);const re=await q(ae,Q);R(!1),re.ok?T(null):L(re.error)},A=(Q,ae,re)=>{L(""),T({model:Q.id,fields:[{field:ae,label:re,value:Q[ae]}]})},U=Q=>{L(""),T({model:Q.id,fields:hx.map(([ae,re])=>({field:ae,label:re,value:Q[ae]}))})};return a.jsxs("section",{className:"nc-fleet-models","aria-label":f("fleet-models-title"),children:[a.jsxs("div",{className:"nc-fleet-models-head",children:[a.jsx("b",{children:f("fleet-models-usable")}),a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c.loading||c.refreshing,onClick:v,children:f(c.refreshing?"fleet-models-refreshing":"fleet-models-refresh")})]}),c.loading&&a.jsx("small",{children:f("fleet-models-loading")}),!c.loading&&c.error&&a.jsx("small",{className:"nc-err",children:c.error}),!c.loading&&!c.error&&g&&g.stale===!0&&a.jsx("small",{className:"nc-fleet-models-note",children:f("fleet-models-stale")}),!c.loading&&!c.error&&g&&g.supported!==!1&&j&&a.jsx("small",{className:"nc-fleet-models-note nc-fleet-models-auth",children:f(t4(j,C)).replace("{key}",C)}),!c.loading&&g&&g.supported===!1&&a.jsx("small",{children:f("fleet-models-unsupported")}),!c.loading&&g&&g.supported!==!1&&!b.length&&a.jsx("small",{children:f("fleet-models-none")}),W&&E.length>0&&a.jsx(px,{mode:"missing",model:_,fields:E,busy:l,onConfirm:I,onCancel:J,error:K,writing:V}),D&&a.jsx(px,{mode:"edit",model:D.model,fields:D.fields,busy:l,onConfirm:H,onCancel:()=>T(null),error:M,writing:z}),!W&&E.length>0&&i&&a.jsx("button",{type:"button",className:"nc-btn ghost nc-fleet-missing-open",onClick:()=>$(!0),children:f("fleet-models-missing-open").replace("{model}",_)}),b.map(Q=>a.jsxs("div",{className:`nc-fleet-model-row${Q.inApi===!1?" nc-model-not-in-api":""}`,children:[a.jsx("button",{type:"button",className:"nc-btn ghost nc-fleet-model-pick","aria-label":f("fleet-models-use").replace("{model}",Q.id),onClick:()=>n(Q.id),children:Q.id}),Q.inApi===!1&&a.jsx("b",{className:"nc-err",children:f("fleet-models-not-in-api")}),hx.map(([ae,re])=>{const je=Q.fieldSources?Q.fieldSources[ae]:void 0;return a.jsxs("span",{className:"nc-fleet-model-field",children:[f(re),": ",Q[ae]===void 0?"–":String(Q[ae]),je==="public"?a.jsx("small",{className:"nc-fleet-model-src",title:f("fleet-models-source-of").replace("{source}",f("fleet-models-source-public")),children:f("fleet-models-default-badge")}):je&&a.jsx("small",{className:"nc-fleet-model-src",title:f("fleet-models-source-of").replace("{source}",f(fx[je]||je)),children:f(fx[je]||je)}),i&&a.jsx("button",{type:"button",className:"nc-btn ghost nc-fleet-model-mine","aria-label":f("fleet-models-make-mine-field").replace("{field}",f(re)).replace("{model}",Q.id),onClick:()=>A(Q,ae,re),children:f("fleet-models-make-mine")})]},ae)}),i&&a.jsx("button",{type:"button",className:"nc-btn ghost nc-fleet-model-mine-row","aria-label":f("fleet-models-make-mine-row").replace("{model}",Q.id),onClick:()=>U(Q),children:f("fleet-models-make-mine")})]},Q.id)),g&&g.supported!==!1&&a.jsx("small",{className:"nc-fleet-models-note",children:f("fleet-models-cap").replace("{cap}",String(g.cap||128))})]})}function s4({state:t,setState:e,busy:n,onSave:s,catalog:i,fetchModels:l,onSetModelValue:c}){var O;const u=t.form,h=x=>e({...t,form:{...u,...x}}),p=u.envRows||[],v=[...new Map(i.map(x=>[x.client,x.clientLabel||x.client])).entries()],_=i.filter(x=>x.client===u.client),g=Fc(i,u),b=typeof(g==null?void 0:g.credentialEnv)=="string"?g.credentialEnv:"",S=Array.isArray(g==null?void 0:g.credentialUsedBy)?g.credentialUsedBy:[],j=(g==null?void 0:g.credentialSource)||"missing",C=!!(g!=null&&g.credentialEnv)||u.credentialProfile==="a"||u.credentialProfile==="p",N=!!b&&t.mode==="new"&&(g==null?void 0:g.authConfigured)!==!0&&!u.credentialValue&&!u.allowMissingCredential,E=x=>{x&&h({client:x.client,provider:x.provider,credentialProfile:x.credentialProfile||"",managedModel:x.model||"",protocol:x.protocol||"",permissionPolicy:x.permissionPolicyDefault||"standard",credentialSourcePolicy:"auto",rc:!!x.rc,displayName:x.custom?f("fleet-custom-provider-default"):"",baseUrl:x.custom?"":x.endpoint||"",envKey:x.defaultEnvKey||"",providerId:"nexuscrew-custom",credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,...t.mode==="new"?{id:x.id,label:""}:{}})};return a.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[a.jsx("b",{children:t.mode==="new"?f("fleet-new-engine"):`${f("edit")} ${u.id}`}),a.jsx("input",{value:u.id,disabled:t.mode!=="new",placeholder:"id",onChange:x=>h({id:x.target.value})}),a.jsx("input",{value:u.label,placeholder:f("label"),onChange:x=>h({label:x.target.value})}),a.jsxs("select",{value:u.kind,disabled:t.mode!=="new",onChange:x=>h({kind:x.target.value}),children:[a.jsx("option",{value:"managed",children:f("fleet-managed")}),a.jsx("option",{value:"custom",children:f("fleet-custom")})]}),u.kind==="managed"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"nc-fleet-pair",children:[a.jsx("select",{value:u.client,disabled:t.mode!=="new",onChange:x=>E(i.find(W=>W.client===x.target.value&&W.default)||i.find(W=>W.client===x.target.value)),children:v.map(([x,W])=>a.jsx("option",{value:x,children:W},x))}),a.jsx("select",{value:((O=Fc(i,u))==null?void 0:O.id)||"",disabled:t.mode!=="new",onChange:x=>E(i.find(W=>W.id===x.target.value)),children:_.map(x=>a.jsx("option",{value:x.id,children:x.label},x.id))})]}),u.client!=="shell"&&a.jsxs(a.Fragment,{children:[a.jsx("input",{value:u.managedModel,list:"nc-managed-models",placeholder:f(g!=null&&g.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:x=>h({managedModel:x.target.value})}),a.jsx("datalist",{id:"nc-managed-models",children:[...(g==null?void 0:g.models)||[],...u.modelOptions||[]].filter((x,W,$)=>x&&$.indexOf(x)===W).map(x=>a.jsx("option",{value:x},x))}),l&&(t.mode==="edit"?u.id:g==null?void 0:g.id)&&a.jsx(n4,{engineId:t.mode==="edit"?u.id:g==null?void 0:g.id,fetchModels:l,onPick:x=>h({managedModel:x}),activeModel:u.managedModel,onSetModelValue:c,busy:n})]}),g!=null&&g.supportsUnsafe?a.jsxs("select",{value:u.permissionPolicy,onChange:x=>h({permissionPolicy:x.target.value}),children:[a.jsx("option",{value:"standard",children:f("fleet-standard-permissions")}),a.jsx("option",{value:"unsafe",children:f("fleet-unsafe-permissions")})]}):a.jsx("small",{children:f("fleet-standard-permissions")}),(g==null?void 0:g.supportsUnsafe)&&u.permissionPolicy==="unsafe"&&a.jsx("small",{className:"nc-err",children:f("fleet-unsafe-warning")}),C&&a.jsxs("select",{"aria-label":f("fleet-credential-source-policy"),value:u.credentialSourcePolicy||"auto",onChange:x=>h({credentialSourcePolicy:x.target.value}),children:[a.jsx("option",{value:"auto",children:f("fleet-credential-source-policy-auto")}),a.jsx("option",{value:"nexuscrew-store",children:f("fleet-credential-source-policy-nexuscrew-store")}),a.jsx("option",{value:"environment",children:f("fleet-credential-source-policy-environment")})]}),(g==null?void 0:g.credentialEnv)===!0&&a.jsxs(a.Fragment,{children:[a.jsx("input",{value:u.envKey,placeholder:f("fleet-api-key-env"),onChange:x=>h({envKey:x.target.value})}),a.jsx("small",{children:f("fleet-custom-secret-help")})]}),b&&a.jsxs("section",{className:"nc-fleet-key","aria-label":f("fleet-key-section"),children:[a.jsxs("div",{className:"nc-fleet-key-head",children:[a.jsx("b",{children:f("fleet-key-section")}),a.jsx("span",{children:f(`fleet-credential-source-${j}`)})]}),a.jsxs("label",{className:"nc-field",children:[f("fleet-key-variable"),a.jsx("input",{value:b,readOnly:!0,"aria-label":f("fleet-key-variable")})]}),a.jsx("small",{children:S.length?f("fleet-key-used-by").replace("{engines}",S.join(", ")):f("fleet-key-used-by-none")}),S.length>0&&a.jsx("small",{children:f("fleet-key-shared-impact").replace("{key}",b).replace("{engines}",S.join(", "))}),a.jsxs("div",{className:"nc-fleet-key-input",children:[a.jsx("input",{type:u.credentialReveal?"text":"password",value:u.credentialValue||"","aria-label":f("fleet-key-value").replace("{key}",b),autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:g!=null&&g.authConfigured||t.mode==="edit"?f("fleet-key-blank-keeps"):f("fleet-key-enter"),onChange:x=>h({credentialValue:x.target.value,allowMissingCredential:x.target.value?!1:u.allowMissingCredential})}),a.jsx("button",{type:"button",className:"nc-btn ghost","aria-label":f(u.credentialReveal?"fleet-key-hide":"fleet-key-reveal"),onClick:()=>h({credentialReveal:!u.credentialReveal}),children:f(u.credentialReveal?"fleet-key-hide":"fleet-key-reveal")})]}),a.jsx("small",{children:f("fleet-key-local-help")}),t.mode==="new"&&(g==null?void 0:g.authConfigured)!==!0&&!u.credentialValue&&a.jsxs("label",{className:"nc-check nc-fleet-key-missing",children:[a.jsx("input",{type:"checkbox",checked:!!u.allowMissingCredential,onChange:x=>h({allowMissingCredential:x.target.checked})}),f("fleet-key-create-missing")]}),(g==null?void 0:g.notice)&&a.jsx("small",{className:"nc-fleet-provider-notice",children:f(`fleet-provider-notice-${g.notice}`)})]}),(g==null?void 0:g.notice)&&!b&&a.jsx("small",{className:"nc-fleet-provider-notice",children:f(`fleet-provider-notice-${g.notice}`)}),u.provider==="custom"&&a.jsxs(a.Fragment,{children:[a.jsx("input",{value:u.displayName,placeholder:f("fleet-provider-display"),onChange:x=>h({displayName:x.target.value})}),a.jsx("input",{value:u.baseUrl,placeholder:"https://api.example.com/v1",onChange:x=>h({baseUrl:x.target.value})}),((g==null?void 0:g.protocols)||[]).length>1&&a.jsx("select",{value:u.protocol,onChange:x=>h({protocol:x.target.value}),children:g.protocols.map(x=>a.jsx("option",{value:x,children:x},x))}),a.jsxs("div",{className:"nc-fleet-pair",children:[a.jsx("input",{value:u.envKey,placeholder:f("fleet-api-key-env"),onChange:x=>h({envKey:x.target.value})}),a.jsx("input",{value:u.providerId,placeholder:f("fleet-provider-id"),onChange:x=>h({providerId:x.target.value})})]}),a.jsxs("small",{children:[u.protocol," · ",f("fleet-custom-secret-help")]})]}),a.jsx("small",{children:f(u.client==="shell"?"fleet-shell-engine-help":"fleet-managed-help")})]}):a.jsxs(a.Fragment,{children:[a.jsx("input",{value:u.command,placeholder:f("command-path"),onChange:x=>h({command:x.target.value})}),a.jsx("textarea",{value:u.argsText,placeholder:f("args-lines"),onChange:x=>h({argsText:x.target.value})}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:u.rc,onChange:x=>h({rc:x.target.checked})})," ",f("fleet-remote-control")]}),a.jsxs("select",{value:u.promptMode,onChange:x=>h({promptMode:x.target.value}),children:[a.jsx("option",{value:"send-keys",children:"send-keys"}),a.jsx("option",{value:"flag",children:"flag"})]}),u.promptMode==="flag"&&a.jsx("input",{value:u.promptFlag,placeholder:"prompt flag",onChange:x=>h({promptFlag:x.target.value})}),a.jsxs("div",{className:"nc-fleet-pair",children:[a.jsx("input",{value:u.modelFlag,placeholder:"model flag",onChange:x=>h({modelFlag:x.target.value})}),a.jsx("input",{value:u.modelValue,placeholder:"model default",onChange:x=>h({modelValue:x.target.value})})]}),a.jsx("small",{children:f("env-write-only")}),p.map((x,W)=>a.jsxs("div",{className:"nc-fleet-env",children:[a.jsx("input",{value:x.key,disabled:x.configured,placeholder:"ENV_KEY",onChange:$=>{const J=p.slice();J[W]={...x,key:$.target.value},h({envRows:J})}}),a.jsx("input",{type:"password",value:x.value,placeholder:x.configured?"•••••• (unchanged)":"value",onChange:$=>{const J=p.slice();J[W]={...x,value:$.target.value},h({envRows:J})}}),a.jsx("button",{className:"nc-btn danger",onClick:()=>h({envRows:p.filter(($,J)=>J!==W)}),children:"×"})]},`${x.key}-${W}`)),a.jsx("button",{className:"nc-btn ghost",onClick:()=>h({envRows:[...p,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),a.jsx("input",{value:u.panelUrl||"",maxLength:512,placeholder:f("fleet-panel-url"),onChange:x=>h({panelUrl:x.target.value})}),a.jsx("small",{children:f("fleet-panel-url-help")}),u.panelUrl&&!u_(u.panelUrl)&&a.jsx("small",{className:"nc-err",children:f("fleet-panel-url-invalid")}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{className:"nc-btn ghost",onClick:()=>e(null),children:f("cancel")}),a.jsx("button",{className:"nc-btn primary",disabled:n||!u.id||N||u.kind==="custom"&&!u.command||u.kind==="managed"&&(g==null?void 0:g.requiresModel)&&!u.managedModel||u.kind==="managed"&&(g==null?void 0:g.credentialEnv)===!0&&!u.envKey||u.kind==="managed"&&u.provider==="custom"&&(!u.displayName||!u.baseUrl||!u.envKey||!u.providerId),onClick:s,children:f("save")})]})]})}function i4({state:t,setState:e,busy:n,onSave:s,onTest:i,profiles:l=[],canTest:c=!0}){const[u,h]=y.useState(null),[p,v]=y.useState(!1),_=t.form,g=N=>e({...t,form:{..._,...N}}),b=/^[^\x00-\x1f\x7f]{1,128}$/.test(_.id||""),S=["contextWindow","maxTokens"].every(N=>{const E=String(_[N]===void 0?"":_[N]).trim();return!E||Do(E)}),j=!!(_.id||"").trim()&&!!(_.engine||"").trim()&&b&&S,C=async()=>{h(null),v(!0);try{h(await i(_.engine,_.id))}catch(N){h({outcome:"unverified",detail:String(N&&N.message||N)})}v(!1)};return a.jsxs("div",{className:"nc-fleet-form",children:[a.jsxs("label",{className:"nc-field",children:[f("model-editor-engine"),a.jsxs("select",{value:_.engine||"",disabled:n||t.mode==="edit",onChange:N=>{h(null),g({engine:N.target.value})},children:[a.jsx("option",{value:"",children:"—"}),l.map(N=>a.jsx("option",{value:N.id,children:N.label?`${N.id} · ${N.label}`:N.id},N.id))]})]}),a.jsxs("label",{className:"nc-field",children:[f("model-editor-id"),a.jsx("input",{value:_.id||"",disabled:n||t.mode==="edit",placeholder:"qwen3.9-max",onChange:N=>{h(null),g({id:N.target.value})}})]}),a.jsx("small",{className:"nc-set-hint",children:f("model-editor-id-help")}),a.jsxs("label",{className:"nc-field",children:[f("model-editor-context"),a.jsx("input",{inputMode:"numeric","aria-label":f("fleet-models-field-context"),value:_.contextWindow||"",disabled:n,"aria-invalid":_.contextWindow&&!Do(_.contextWindow)?"true":"false",onChange:N=>g({contextWindow:N.target.value.replace(/[^0-9]/g,"").slice(0,9)})})]}),_.contextWindow&&!Do(_.contextWindow)&&a.jsx("small",{className:"nc-err",children:f("model-editor-limit-invalid")}),a.jsxs("label",{className:"nc-field",children:[f("model-editor-max-tokens"),a.jsx("input",{inputMode:"numeric","aria-label":f("fleet-models-field-output"),value:_.maxTokens||"",disabled:n,"aria-invalid":_.maxTokens&&!Do(_.maxTokens)?"true":"false",onChange:N=>g({maxTokens:N.target.value.replace(/[^0-9]/g,"").slice(0,9)})})]}),_.maxTokens&&!Do(_.maxTokens)&&a.jsx("small",{className:"nc-err",children:f("model-editor-limit-invalid")}),jh.map(N=>a.jsxs("label",{className:"nc-field",children:[f(`model-editor-${N==="reasoning"?"reasoning":N}`),a.jsxs("select",{value:_[N]===void 0||_[N]===null?"":String(_[N]),disabled:n,onChange:E=>g({[N]:E.target.value===""?void 0:E.target.value==="true"}),children:[a.jsx("option",{value:"",children:f("model-editor-absent")}),a.jsx("option",{value:"true",children:f("model-editor-true")}),a.jsx("option",{value:"false",children:f("model-editor-false")})]})]},N)),a.jsxs("div",{className:"nc-set-row",children:[c&&a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||p||!j,onClick:C,children:f(p?"model-test-running":"model-test")}),u&&a.jsxs("span",{className:`nc-model-test ${u.outcome}`,children:[f(`model-test-${u.outcome}`),u.outcome==="ok"&&Number.isInteger(u.latencyMs)?` · ${u.latencyMs}ms`:""]})]}),u&&u.detail&&a.jsx("small",{className:"nc-set-hint",children:u.detail}),u&&u.outcome==="unverified"&&a.jsx("small",{className:"nc-set-hint",children:f("model-test-unverified-help")}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>e(null),children:f("cancel")}),a.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||!j,onClick:()=>s(_),children:f("save")})]})]})}function r4({token:t,route:e,targets:n=[],location:s,setLocation:i,state:l,setState:c,engines:u,mcpServers:h=[],managedCatalog:p=[],busy:v,onSave:_}){var D,T,z;const[g,b]=y.useState(null),[S,j]=y.useState(""),C=l.form,N=R=>c({...l,form:{...C,...R}}),E=u.find(R=>R.id===C.engine),O=((D=E==null?void 0:E.managed)==null?void 0:D.client)==="shell",x=((T=E==null?void 0:E.managed)==null?void 0:T.client)||"",W=((z=p.find(R=>R.client===x))==null?void 0:z.mcpManaged)!==!1,$=R=>{var H,A,U,Q;const M=u.find(ae=>ae.id===R),L={...C.commands||{}};((H=E==null?void 0:E.managed)==null?void 0:H.client)==="shell"&&(C.command?L[C.engine]=C.command:delete L[C.engine]),N({engine:R,model:((A=C.models)==null?void 0:A[R])||((U=M==null?void 0:M.managed)==null?void 0:U.model)||((Q=M==null?void 0:M.model)==null?void 0:Q.value)||"",commands:L,command:L[R]||""})},J=R=>{const M={...C.commands||{}};R?M[C.engine]=R:delete M[C.engine],N({command:R,commands:M})},q=O&&/[|&;<>()`$*?{}\[\]~]/.test(C.command||""),V=[...new Set([...h||[],...Array.isArray(C.mcp)?C.mcp:[]])].sort(),ie=Array.isArray(C.mcp)?C.mcp.length?"some":"none":"all",K=R=>{var M;return N({mcp:R==="all"?void 0:R==="none"?[]:(M=C.mcp)!=null&&M.length?C.mcp:[...V]})},B=R=>{const M=Array.isArray(C.mcp)?C.mcp:[];N({mcp:M.includes(R)?M.filter(L=>L!==R):[...M,R].sort()})},I=async R=>{try{const M=await uv(t,R,e);b(M),N({cwd:M.path}),j("")}catch(M){j(String(M.message||M))}};return a.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[a.jsx("b",{children:l.mode==="new"?f("fleet-new-cell"):`${f("edit")} ${C.id}`}),l.mode==="new"&&a.jsxs("label",{className:"nc-field",children:[f("location"),a.jsx("span",{className:"nc-req",children:" *"}),a.jsxs("select",{value:s,onChange:R=>{i(R.target.value),N({engine:""})},children:[a.jsx("option",{value:"",children:f("local")}),n.map(R=>a.jsxs("option",{value:R.route.join("/"),disabled:R.status&&R.status!=="up",children:[R.label,R.status&&R.status!=="up"?` · ${f("node-offline")}`:""]},R.route.join("/")))]})]}),a.jsx("input",{value:C.id,disabled:l.mode!=="new",placeholder:"id",onChange:R=>N({id:R.target.value})}),a.jsx("input",{value:C.label||"",maxLength:64,placeholder:f("fleet-cell-label"),onChange:R=>N({label:R.target.value})}),a.jsxs("div",{className:"nc-fleet-pair",children:[a.jsx("input",{value:C.cwd,placeholder:f("cwd"),onChange:R=>N({cwd:R.target.value})}),a.jsx("button",{className:"nc-btn ghost",onClick:()=>g?b(null):I(C.cwd),children:f("browse")})]}),g&&a.jsxs("div",{className:"nc-fs",children:[a.jsx("div",{className:"nc-fs-path",children:g.path}),a.jsxs("div",{className:"nc-fs-list",children:[g.parent&&a.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>I(g.parent),children:["↑ ",f("fs-parent")]}),(g.dirs||[]).map(R=>a.jsxs("button",{className:"nc-fs-item",onClick:()=>I(`${g.path.replace(/\/$/,"")}/${R}`),children:["📁 ",R]},R))]})]}),S&&a.jsx("div",{className:"nc-err",children:S}),a.jsx("select",{value:C.engine,onChange:R=>$(R.target.value),children:a.jsx(_h,{engines:u})}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:!!C.boot,onChange:R=>N({boot:R.target.checked})})," ",f("fleet-boot")]}),a.jsx("input",{value:C.panelUrl||"",maxLength:512,placeholder:f("fleet-panel-url"),onChange:R=>N({panelUrl:R.target.value})}),a.jsx("small",{children:f("fleet-panel-url-help")}),C.panelUrl&&!u_(C.panelUrl)&&a.jsx("small",{className:"nc-err",children:f("fleet-panel-url-invalid")}),O?a.jsxs(a.Fragment,{children:[a.jsx("input",{value:C.command||"",maxLength:4096,placeholder:f("fleet-shell-command-placeholder"),onChange:R=>J(R.target.value)}),a.jsx("small",{children:C.command?f("fleet-shell-command-help"):f("fleet-shell-interactive")}),q&&a.jsx("small",{className:"nc-note",children:f("fleet-shell-command-metachar")})]}):a.jsxs(a.Fragment,{children:[a.jsx("input",{value:C.model||"",list:"nc-cell-models",placeholder:f("fleet-model-override"),onChange:R=>N({model:R.target.value})}),a.jsx("datalist",{id:"nc-cell-models",children:((E==null?void 0:E.availableModels)||[]).map(R=>a.jsx("option",{value:R},R))}),a.jsx("textarea",{value:C.prompt||"",placeholder:f("cell-prompt"),onChange:R=>N({prompt:R.target.value})}),a.jsx("small",{children:f("cell-prompt-help")}),a.jsxs("label",{className:"nc-field",children:[f("cell-mcp"),a.jsxs("select",{value:ie,onChange:R=>K(R.target.value),children:[a.jsx("option",{value:"all",children:f("cell-mcp-all")}),a.jsx("option",{value:"none",children:f("cell-mcp-none")}),a.jsx("option",{value:"some",children:f("cell-mcp-some")})]})]}),!W&&a.jsx("small",{className:"nc-note",children:f("cell-mcp-inert")}),ie==="some"&&a.jsx("div",{className:"nc-fleet-mcp-list",children:V.map(R=>a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:(C.mcp||[]).includes(R),onChange:()=>B(R)})," ",R]},R))}),a.jsx("small",{children:f("cell-mcp-help")})]}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{className:"nc-btn ghost",onClick:()=>c(null),children:f("cancel")}),a.jsx("button",{className:"nc-btn primary",disabled:v||!C.id||!C.cwd||!C.engine,onClick:_,children:f("save")})]})]})}function mx({token:t,route:e=[],state:n,setState:s,busy:i,onSave:l}){const[c,u]=y.useState(null),[h,p]=y.useState([]),[v,_]=y.useState(""),g=Array.isArray(e)?e.join("/"):"";y.useEffect(()=>{let N=!0;return rh(t,g?g.split("/"):[]).then(E=>{N&&(p(E.engines||[]),_(""))}).catch(E=>{N&&(p([]),_(String(E.message||E)))}),()=>{N=!1}},[t,g]);const b=n.form,S=N=>s({...n,form:{...b,...N}}),j=async N=>{try{const E=await uv(t,N,e);u(E),S({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 a.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[a.jsxs("b",{children:[f("import-as-cell")," · ",b.tmuxSession]}),a.jsx("small",{children:f("import-help")}),a.jsx("input",{value:b.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),a.jsx("input",{value:b.id,placeholder:f("name"),onChange:N=>S({id:N.target.value})}),a.jsxs("div",{className:"nc-fleet-pair",children:[a.jsx("input",{value:b.cwd,placeholder:f("cwd"),onChange:N=>S({cwd:N.target.value})}),a.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>c?u(null):j(b.cwd),children:f("browse")})]}),c&&a.jsxs("div",{className:"nc-fs",children:[a.jsx("div",{className:"nc-fs-path",children:c.path}),a.jsxs("div",{className:"nc-fs-list",children:[c.parent&&a.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>j(c.parent),children:["↑ ",f("fs-parent")]}),(c.dirs||[]).map(N=>a.jsxs("button",{className:"nc-fs-item",onClick:()=>j(`${c.path.replace(/\/$/,"")}/${N}`),children:["📁 ",N]},N))]})]}),a.jsxs("select",{value:b.engine,onChange:N=>S({engine:N.target.value}),children:[a.jsx("option",{value:"",children:f("import-engine-required")}),a.jsx(_h,{engines:h})]}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:!!b.boot,onChange:N=>S({boot:N.target.checked})})," ",f("fleet-boot")]}),(n.err||v)&&a.jsx("div",{className:"nc-err",children:n.err||v}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:f("cancel")}),a.jsx("button",{className:"nc-btn primary",disabled:i||!b.tmuxSession||!b.engine||!h.length,onClick:l,children:f(C?"import-as-cell":"save")})]})]})}function pd(t){const e=Io(t);return e===null?`~/${t}`:e?`~/${e}`:"~"}function o4(t){if(!t||typeof t.path!="string"||typeof t.home!="string")return"";const{path:e,home:n}=t;return!n||e===n||!e.startsWith(n+"/")?"":e.slice(n.length+1).replace(/\/+$/,"")}function a4({token:t,route:e,cell:n,busy:s=!1,onSaved:i,onClose:l}){const[c,u]=y.useState(""),[h,p]=y.useState(null),[v,_]=y.useState(!1),[g,b]=y.useState(""),S=typeof(n==null?void 0:n.cwdSuggestion)=="string"&&Io(n.cwdSuggestion)!==null?Io(n.cwdSuggestion):null,[j,C]=y.useState(S),N=n==null?void 0:n.id,E=s||v,O=async V=>{const ie=Io(V);if(ie===null){p({rel:"",dirs:[],loading:!1,err:f("fleet-cwd-repair-invalid")});return}p({rel:ie,dirs:[],loading:!0,err:""});try{const K=await uv(t,ie,e),B=o4(K);p({rel:B,dirs:Array.isArray(K.dirs)?K.dirs:[],loading:!1,err:""})}catch(K){p({rel:ie,dirs:[],loading:!1,err:String(K&&K.message||K)})}},x=V=>{if(!h)return;const ie=h.rel?`${h.rel}/${V}`:V;O(ie)},W=()=>{h!=null&&h.rel&&O(h.rel.split("/").slice(0,-1).join("/"))},$=()=>{h&&(u(h.rel||""),p(null),b(""),C(null))},J=()=>{j!==null&&(u(j),C(null),b(""))},q=async()=>{if(E)return;const V=Io(c);if(V===null){b(f("fleet-cwd-repair-invalid"));return}const ie=pd(V);let K=!0;try{K=window.confirm(f("fleet-cwd-repair-confirm").replace("{id}",String(N||"")).replace("{path}",ie))}catch{K=!1}if(K){_(!0),b(""),C(null);try{const B=await Gx(t,N,{cwdRel:V},e);i==null||i(B)}catch(B){const I=B&&B.data||{};if(I.code==="unportable-cwd"){b(f("fleet-cwd-repair-unportable"));const D=Array.isArray(I.cells)?I.cells.find(z=>z&&z.id===N):null,T=D&&typeof D.suggestion=="string"?D.suggestion:null;T!==null&&Io(T)!==null&&C(T)}else b(String(B&&B.message||B))}finally{_(!1)}}};return a.jsxs("div",{className:"nc-set-form nc-fleet-form nc-cwd-repair",children:[a.jsx("b",{children:f("fleet-cwd-repair-title").replace("{id}",String(N||""))}),a.jsx("small",{className:"nc-set-info",children:f("fleet-cwd-repair-help")}),a.jsx("small",{className:"nc-cwd-no-source",children:f("fleet-cwd-repair-no-source-path")}),a.jsxs("label",{className:"nc-field",children:[f("cwd"),a.jsxs("div",{className:"nc-cwd-rel-row",children:[a.jsx("span",{className:"nc-cwd-rel-prefix",children:"~/"}),a.jsx("input",{value:c,placeholder:f("fleet-cwd-repair-placeholder"),autoComplete:"off",spellCheck:"false",autoCapitalize:"none",onChange:V=>u(V.target.value)}),a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:E,onClick:()=>h?p(null):O(""),children:f(h?"close":"fleet-cwd-repair-browse")})]})]}),a.jsx("div",{className:"nc-cwd-preview",children:f("fleet-cwd-repair-preview").replace("{path}",pd(c))}),h&&a.jsxs("div",{className:"nc-fs",children:[a.jsx("div",{className:"nc-fs-path",children:pd(h.rel)}),a.jsxs("div",{className:"nc-fs-list",children:[h.rel&&a.jsxs("button",{type:"button",className:"nc-fs-item nc-fs-nav",onClick:W,children:["↑ ",f("fs-parent")]}),h.loading&&a.jsx("div",{className:"nc-fs-empty",children:"…"}),!h.loading&&h.dirs.length===0&&a.jsx("div",{className:"nc-fs-empty",children:f("fleet-cwd-repair-fs-empty")}),!h.loading&&h.dirs.map(V=>a.jsxs("button",{type:"button",className:"nc-fs-item",onClick:()=>x(V),children:["📁 ",V]},V))]}),h.err&&a.jsx("div",{className:"nc-err",children:h.err}),a.jsx("div",{className:"nc-sheet-actions",children:a.jsx("button",{type:"button",className:"nc-btn primary",disabled:E||h.loading||!!h.err,onClick:$,children:f("fleet-cwd-repair-use-current")})})]}),g&&a.jsx("div",{className:"nc-err",role:"alert",children:g}),j!==null&&a.jsxs("div",{className:"nc-cwd-suggestion",role:"status",children:[a.jsx("span",{children:f("fleet-cwd-repair-suggestion")}),a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:J,children:f("fleet-cwd-repair-use-suggestion").replace("{path}",pd(j))})]}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:v,onClick:l,children:f("cancel")}),a.jsx("button",{type:"button",className:"nc-btn primary",disabled:E,onClick:q,children:v?"…":f("save")})]})]})}function l4({token:t,readonly:e,targets:n=[],startNewCell:s=!1,initialLocation:i=""}){const[l,c]=y.useState({engines:[],cells:[],managedCatalog:[]}),[u,h]=y.useState({available:!1,capabilities:[]}),[p,v]=y.useState(!1),[_,g]=y.useState(null),[b,S]=y.useState(null),[j,C]=y.useState({}),[N,E]=y.useState(null),[O,x]=y.useState(!1),[W,$]=y.useState(""),[J,q]=y.useState(""),[V,ie]=y.useState(i),[K,B]=y.useState(!1),[I,D]=y.useState(null),[T,z]=y.useState(null),[R,M]=y.useState(null),[L,H]=y.useState(!1),[A,U]=y.useState([]),[Q,ae]=y.useState(null),[re,je]=y.useState("manage"),te=y.useRef(!1),ne=V?V.split("/"):[],me=y.useCallback(async()=>{try{const ee=await tl(t,ne);h(ee);try{const P=await qc(t,ne);B(!!P.readonlyDefault)}catch{B(!1)}if(ee.provider==="builtin"&&(ee.capabilities||[]).includes("definitions")){const P=await rh(t,ne),le=new Map((ee.engines||[]).map(_e=>[_e.id,_e]));if(P.engines=(P.engines||[]).map(_e=>{var Me;return{..._e,availableModels:((Me=le.get(_e.id))==null?void 0:Me.models)||[]}}),c(P),(ee.capabilities||[]).includes("credentials"))try{U((await r5(t,ne)).credentials||[])}catch{U([])}else U([])}$("")}catch(ee){$(String(ee.message||ee))}finally{v(!0)}},[t,V]);y.useEffect(()=>{document.visibilityState!=="hidden"&&me()},[me]),E6(me,5e3);const we=new Set((u.cells||[]).filter(ee=>ee.active).map(ee=>ee.cell)),Fe=u.provider==="builtin"&&(u.capabilities||[]).includes("edit"),Ae=(u.capabilities||[]).includes("restore");y.useEffect(()=>{!s||te.current||!Fe||!l.engines.length||(te.current=!0,E({mode:"new",form:cx(l.engines[0].id)}))},[s,Fe,l.engines]);const He=async ee=>{x(!0),$(""),q("");try{await ee(),await me()}catch(P){$(String(P.message||P))}x(!1)},X=async(ee,P)=>{const le=await h5(t,ee,P,ne);return C(_e=>({..._e,[`${ee}::${P}`]:le})),le},ce=ee=>He(async()=>{const P={id:String(ee.id||"").trim(),engine:String(ee.engine||"").trim(),...dx(ee)};await Jw(t,P,ne),S(null),await me()}),Z=async(ee,P,le)=>{x(!0),$("");try{const _e=dx(le);return Object.keys(_e).length?((l.models||[]).find(oe=>oe.id===P&&oe.engine===ee)?await u5(t,P,ee,_e,ne):await Jw(t,{id:P,engine:ee,..._e},ne),await me(),{ok:!0,written:!0}):{ok:!0,written:!1}}catch(_e){const Me=String(_e&&_e.message||_e);return $(Me),{ok:!1,error:Me}}finally{x(!1)}},ge=()=>He(async()=>{var Kt;const ee=_.mode==="new",P=_.form,le=l.managedCatalog||[],_e=P.kind==="managed"?Fc(le,P):null,Me=typeof(_e==null?void 0:_e.credentialEnv)=="string"?_e.credentialEnv:"",oe=Me&&P.credentialValue||"",Be=G6(P,ee,le);!ee&&_.form.kind==="custom"&&!_.form.modelFlag&&(Be.model=null),!ee&&_.form.kind==="custom"&&_.form.promptMode!=="flag"&&(Be.promptFlag=null);let gt;if(ee)gt=await a5(t,Be,ne);else{const ft=_.original,Vt=new Set(_.form.envRows.filter(Dt=>!Dt.remove).map(Dt=>Dt.key)),It=(ft.envKeys||[]).filter(Dt=>!Vt.has(Dt)),Xt=Object.fromEntries(_.form.envRows.filter(Dt=>!Dt.remove&&Dt.key&&(!Dt.configured||Dt.value!=="")).map(Dt=>[Dt.key,Dt.value]));gt=await l5(t,ft.id,Be,_.form.kind==="custom"?{set:Xt,remove:It}:void 0,ne)}let Lt=null;if(Me&&oe)try{Lt=await Xw(t,Me,oe,ne),U(Lt.credentials||[])}catch{throw await me(),ee&&g({mode:"edit",original:{...Be,id:P.id},form:{...P,credentialReveal:!1}}),new Error(f(ee?"fleet-key-partial-create":"fleet-key-partial-edit"))}await me(),g(null),q(f("fleet-saved"));const Nt=((Kt=((Lt==null?void 0:Lt.credentials)||[]).find(ft=>ft.envKey===Me))==null?void 0:Kt.activeCells)||[],kt=[...new Set([...(gt==null?void 0:gt.activeCells)||[],...Nt])];if(kt.length&&window.confirm(f("fleet-restart-confirm").replace("{cells}",kt.join(", "))))for(const ft of kt)await oc(t,ft,ne)}),Y=()=>He(async()=>{var Nt,kt,Kt,ft,Vt,It;const ee=N.mode==="new",P=N.form,le={...ee?{id:P.id}:{},cwd:P.cwd,engine:P.engine,boot:!!P.boot},_e={...P.commands||{}},Me=l.engines.find(Xt=>Xt.id===P.engine);((Nt=Me==null?void 0:Me.managed)==null?void 0:Nt.client)==="shell"&&typeof P.command=="string"&&P.command.length?_e[P.engine]=P.command:((kt=Me==null?void 0:Me.managed)==null?void 0:kt.client)==="shell"&&delete _e[P.engine],(Object.keys(_e).length||!ee)&&(le.commands=_e);const oe=(P.label||"").trim();ee?oe&&(le.label=oe):le.label=oe||null;const Be=(P.panelUrl||"").trim();ee?Be&&(le.panelUrl=Be):le.panelUrl=Be||null,ee?Array.isArray(P.mcp)&&(le.mcp=P.mcp):le.mcp=Array.isArray(P.mcp)?P.mcp:null,ee?(((Kt=Me==null?void 0:Me.managed)==null?void 0:Kt.client)!=="shell"&&P.model&&(le.model=P.model),((ft=Me==null?void 0:Me.managed)==null?void 0:ft.client)!=="shell"&&P.prompt&&(le.prompt=P.prompt)):(le.model=((Vt=Me==null?void 0:Me.managed)==null?void 0:Vt.client)==="shell"?null:P.model||null,((It=Me==null?void 0:Me.managed)==null?void 0:It.client)!=="shell"&&(le.prompt=P.prompt||null));const gt=ee?await p5(t,le,ne):await Gx(t,N.original.id,le,ne),Lt=ee?P.id:N.original.id;E(null),q(f("fleet-saved")),!ee&&(gt!=null&&gt.active)&&window.confirm(f("fleet-restart-confirm").replace("{cells}",Lt))&&await oc(t,Lt,ne)}),he=e||K,Ne=u.capabilities||[],Ce=ne.length>0&&he,Ve=ee=>A.find(P=>{var le;return(le=P.engines)==null?void 0:le.includes(ee.id)})||null,Ye=()=>He(async()=>{var le;const ee=await Xw(t,Q.envKey,Q.value,ne);U(ee.credentials||[]),ae(null),q(f("fleet-credential-saved"));const P=((le=(ee.credentials||[]).find(_e=>_e.envKey===Q.envKey))==null?void 0:le.activeCells)||[];if(P.length&&window.confirm(f("fleet-restart-confirm").replace("{cells}",P.join(", "))))for(const _e of P)await oc(t,_e,ne)}),ht=ee=>He(async()=>{if(!window.confirm(f("fleet-credential-remove-confirm").replace("{key}",ee.envKey)))return;const P=await o5(t,ee.envKey,ne);U(P.credentials||[]),q(f("fleet-credential-removed"))}),ze=ee=>D({...ee,route:Array.isArray(ee==null?void 0:ee.route)?ee.route:ne}),ve=async ee=>{if(!I)return;const P={...I,cell:I.cell||I.id};try{await Vv({token:t,powerCell:P,payload:ee,onNotice:q})}catch(le){throw $(String(le&&le.message||le)),le}},Oe=(ee,P)=>{$(""),z({mode:"new",route:Array.isArray(P)?P:ne,form:{tmuxSession:ee.name,id:"",engine:"",cwd:"",boot:!1},err:""})},et=()=>He(async()=>{const ee=T.form;if(!ee.engine){z({...T,err:f("import-engine-required")});return}await m5(t,{tmuxSession:ee.tmuxSession,id:ee.id||void 0,engine:ee.engine,cwd:ee.cwd||void 0,boot:!!ee.boot},ee.route||ne),z(null),q(f("fleet-saved"))}),Ue=({engineRows:ee=[],cellRows:P=[],models:le=[]})=>He(async()=>{const _e=ee.filter(ft=>ft.selected),Me=_e.map(ft=>LE(ft.engine));if(Me.some(ft=>!ft))throw new Error(f("fleet-backup-invalid-engine"));const oe=_e.filter(ft=>ft.exists).map(ft=>ft.engine.id);if(oe.length&&!window.confirm(f("fleet-backup-confirm-engine-overwrite").replace("{engines}",oe.join(", "))))return;const Be=[...new Set([...l.engines.map(ft=>ft.id),...Me.map(ft=>ft.id)])],gt=[];for(const ft of P.filter(Vt=>Vt.selected)){const Vt=q6(ft.cell,ft.engine,Be);if(!Vt)throw new Error(`${ft.cell.id}: ${f("fleet-backup-engine-missing")}`);gt.push(Vt)}const Lt=P.filter(ft=>ft.selected&&ft.exists).map(ft=>ft.cell.id);if(Lt.length&&!window.confirm(f("fleet-backup-confirm-overwrite").replace("{cells}",Lt.join(", "))))return;const Nt=Me.length?await v5(t,Me,oe.length>0,ne,le):{needsRestart:[]},kt=gt.length?await g5(t,gt,ne):{needsRestart:[]},Kt=[...new Set([...Nt.needsRestart||[],...kt.needsRestart||[]])];H(!1),q(`${f("fleet-backup-restored").replace("{n}",String(gt.length))}${Me.length?` · ${Me.length} ${f("fleet-engines").toLowerCase()}`:""}${Kt.length?` · ${f("fleet-backup-needs-restart").replace("{cells}",Kt.join(", "))}`:""}`)}),st=a.jsxs("label",{className:"nc-field",children:[f("location"),a.jsxs("select",{value:V,onChange:ee=>{ie(ee.target.value),g(null),E(null),$(""),q(""),B(!1),v(!1),h({available:!1,capabilities:[]}),c({engines:[],cells:[],managedCatalog:[]}),U([]),ae(null)},children:[a.jsx("option",{value:"",children:f("local")}),n.map(ee=>a.jsxs("option",{value:ee.route.join("/"),disabled:ee.status&&ee.status!=="up",children:[ee.label,ee.status&&ee.status!=="up"?` · ${f("node-offline")}`:""]},ee.route.join("/")))]})]}),ot=a.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":f("tab-fleet"),children:[a.jsx("button",{type:"button",role:"tab","aria-selected":re==="manage",className:`nc-set-tabbtn${re==="manage"?" on":""}`,onClick:()=>je("manage"),children:f("fleet-manage-location")}),a.jsx("button",{type:"button",role:"tab","aria-selected":re==="overview",className:`nc-set-tabbtn${re==="overview"?" on":""}`,onClick:()=>je("overview"),children:f("fleet-network-overview")})]});return p?Fe?a.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[ot,re==="overview"?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"nc-set-info",children:f("fleet-overview-help")}),a.jsx(gm,{token:t,targets:n,readonly:e,onPower:ze,onImport:Oe})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"nc-set-info",children:f("fleet-manage-help")}),st,a.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[a.jsx("button",{className:"nc-btn ghost",disabled:he||O,onClick:()=>{$(""),H(!0)},children:f("fleet-backup")}),a.jsx("small",{children:f("fleet-backup-help")})]}),a.jsxs("div",{className:"nc-fleet-section-head",children:[a.jsx("b",{children:f("fleet-cells")}),a.jsx("span",{className:"nc-fleet-head-actions",children:a.jsxs("button",{className:"nc-btn primary",disabled:he||O||!l.engines.length,onClick:()=>{var ee;$(""),E({mode:"new",form:cx((ee=l.engines[0])==null?void 0:ee.id)})},children:["+ ",f("add")]})})]}),l.cells.map(ee=>{const P=we.has(ee.id),le=ee.needsRepair===!0;return a.jsxs("div",{className:"nc-fleet-item",children:[a.jsxs("span",{children:[a.jsx("b",{children:ee.id}),ee.label?a.jsxs("small",{className:"nc-fleet-label",children:[" ",ee.label]}):null,a.jsxs("small",{children:[ee.engine," · ",le?a.jsx("span",{className:"nc-fleet-tag nc-fleet-tag-warn",children:f("fleet-cwd-needs-repair")}):ee.cwd,P?` · ${f("service-active")}`:` · ${f("cell-off")}`]})]}),a.jsxs("span",{children:[P&&Ne.includes("down")&&a.jsx("button",{className:"nc-btn ghost",disabled:he||O,onClick:()=>He(()=>Vx(t,{cell:ee.id},ne)),children:f("stop")}),!P&&Ne.includes("up")&&a.jsx("button",{className:"nc-btn primary",disabled:he||O,onClick:()=>ze({cell:ee.id,id:ee.id,engine:ee.engine,model:ee.model,models:ee.models,permissionPolicies:ee.permissionPolicies,active:!1,boot:ee.boot}),children:f("start")}),P&&Ne.includes("restart")&&a.jsx("button",{className:"nc-btn ghost",disabled:he||O,onClick:()=>He(()=>oc(t,ee.id,ne)),children:f("restart")}),le?a.jsx("button",{className:"nc-btn ghost",disabled:he||O,onClick:()=>{$(""),M(ee)},children:f("fleet-cwd-repair")}):a.jsx("button",{className:"nc-btn ghost",disabled:he||O,onClick:()=>{var _e;$(""),E({mode:"edit",original:ee,form:{...ee,commands:{...ee.commands||{}},command:((_e=ee.commands)==null?void 0:_e[ee.engine])||""}})},children:f("edit")}),a.jsx("button",{className:"nc-btn danger",disabled:he||O,onClick:()=>He(async()=>{window.confirm(f("fleet-remove-cell").replace("{id}",ee.id))&&await Xx(t,ee.id,!0,ne)}),children:"×"})]})]},ee.id)}),a.jsxs("div",{className:"nc-fleet-section-head",children:[a.jsx("b",{children:f("fleet-engines")}),a.jsxs("button",{className:"nc-btn primary",disabled:he||O,onClick:()=>{$(""),g({mode:"new",form:K6()})},children:["+ ",f("add")]})]}),l.engines.map(ee=>{var le,_e;const P=Ve(ee);return a.jsxs("div",{className:"nc-fleet-item",children:[a.jsxs("span",{children:[a.jsx("b",{children:ee.label}),a.jsx("small",{children:ee.managed?`${ee.id} · ${ee.managed.client} / ${ee.managed.provider} · ${(le=ee.managedInfo)!=null&&le.configured?f("fleet-ready"):((_e=ee.managedInfo)==null?void 0:_e.reason)||f("fleet-not-ready")}`:`${ee.id} · ${ee.command}`}),P&&a.jsxs("small",{children:[P.envKey," · ",f(`fleet-credential-source-${P.source||"missing"}`)]})]}),a.jsxs("span",{children:[P&&a.jsx("button",{className:"nc-btn ghost",disabled:he||O,onClick:()=>{$(""),ae({envKey:P.envKey,value:""})},children:P.configured?f("fleet-credential-change"):f("fleet-credential-set")}),(P==null?void 0:P.source)==="local"&&a.jsx("button",{className:"nc-btn danger",disabled:he||O,onClick:()=>ht(P),children:f("fleet-credential-forget")}),a.jsx("button",{className:"nc-btn ghost",disabled:he||O,onClick:()=>{$(""),g({mode:"edit",original:ee,form:Y6(ee)})},children:f("edit")}),a.jsx("button",{className:"nc-btn danger",disabled:he||O,onClick:()=>He(async()=>{window.confirm(f("fleet-remove-engine").replace("{id}",ee.id))&&await c5(t,ee.id,ne)}),children:"×"})]})]},ee.id)}),a.jsxs("div",{className:"nc-fleet-section-head",children:[a.jsx("b",{children:f("fleet-models")}),a.jsxs("button",{className:"nc-btn primary",disabled:he||O,onClick:()=>{$(""),S({mode:"new",form:{id:"",engine:""}})},children:["+ ",f("add")]})]}),!(l.models||[]).length&&a.jsx("small",{className:"nc-set-hint",children:f("fleet-no-models")}),(l.models||[]).map(ee=>{const P=`${ee.engine}::${ee.id}`,le=j[P],_e=(l.engines||[]).some(Me=>Me.managed&&Me.managed.model===ee.id);return a.jsxs("div",{className:"nc-fleet-item",children:[a.jsxs("span",{children:[a.jsx("b",{children:ee.id}),a.jsxs("small",{children:[ee.engine,ee.contextWindow?` · ${ee.contextWindow}`:"",_e?` · ${f("model-in-use")}`:""]}),le&&a.jsxs("small",{className:`nc-model-test ${le.outcome}`,children:[f(`model-test-${le.outcome}`),le.outcome==="ok"&&Number.isInteger(le.latencyMs)?` · ${le.latencyMs}ms`:""]})]}),a.jsxs("span",{children:[Ne.includes("model-test")&&a.jsx("button",{className:"nc-btn ghost",disabled:O||Ce,onClick:()=>He(()=>X(ee.engine,ee.id)),children:f("model-test")}),a.jsx("button",{className:"nc-btn danger",disabled:he||O,onClick:()=>He(()=>d5(t,ee.id,ee.engine,ne)),children:"×"})]})]},P)})]}),b&&a.jsx(Qr,{onClose:()=>S(null),label:f("fleet-models"),error:W,children:a.jsx(i4,{state:b,setState:S,busy:O,onSave:ce,onTest:X,profiles:l.managedCatalog||[],canTest:Ne.includes("model-test")&&!Ce})}),_&&a.jsx(Qr,{onClose:()=>g(null),label:f("fleet-new-engine"),error:W,children:a.jsx(s4,{state:_,setState:g,busy:O,onSave:ge,catalog:l.managedCatalog||[],fetchModels:Ne.includes("model-discovery")?(ee,P)=>f5(t,ee,P,ne):void 0,onSetModelValue:Ne.includes("edit-model")?Z:void 0})}),N&&a.jsx(Qr,{onClose:()=>E(null),label:f("fleet-new-cell"),error:W,children:a.jsx(r4,{token:t,route:ne,targets:n,location:V,setLocation:ie,state:N,setState:E,engines:l.engines,mcpServers:l.mcpServers||[],managedCatalog:l.managedCatalog||[],busy:O,onSave:Y})}),R&&a.jsx(Qr,{onClose:()=>M(null),label:f("fleet-cwd-repair-title").replace("{id}",R.id),error:"",children:a.jsx(a4,{token:t,route:ne,cell:R,busy:O,onSaved:async()=>{M(null),q(f("fleet-cwd-repaired")),await me()},onClose:()=>M(null)})}),J&&a.jsx("div",{className:"nc-set-note",children:J}),W&&a.jsx("div",{className:"nc-err",children:W}),L&&a.jsx(Qr,{onClose:()=>H(!1),label:f("fleet-backup"),error:W,children:a.jsx(X6,{cells:l.cells,engines:l.engines,models:l.models||[],busy:O,canRestore:Ae,onRestore:Ue,onClose:()=>H(!1)})}),Q&&a.jsx(Qr,{onClose:()=>ae(null),label:f("fleet-credential-title"),error:W,children:a.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[a.jsx("b",{children:f("fleet-credential-title")}),a.jsx("small",{children:f("fleet-credential-help")}),a.jsxs("label",{className:"nc-field",children:[Q.envKey,a.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:Q.value,onChange:ee=>ae({...Q,value:ee.target.value})})]}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{className:"nc-btn ghost",onClick:()=>ae(null),children:f("cancel")}),a.jsx("button",{className:"nc-btn primary",disabled:O||!Q.value,onClick:Ye,children:f("save")})]})]})}),T&&a.jsx(Qr,{onClose:()=>z(null),label:f("import-as-cell"),error:W,children:a.jsx(mx,{token:t,route:T.route||ne,state:T,setState:z,busy:O,onSave:et})}),I&&a.jsx(Wd,{cell:I,token:t,route:Array.isArray(I.route)?I.route:ne,onConfirm:async ee=>{try{await ve(ee)}finally{me()}},onClose:()=>D(null)})]}):a.jsxs("div",{className:"nc-set-tab",children:[ot,re==="overview"?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"nc-set-info",children:f("fleet-overview-help")}),a.jsx(gm,{token:t,targets:n,readonly:e,onPower:ze,onImport:Oe})]}):a.jsxs(a.Fragment,{children:[st,a.jsxs("div",{className:"nc-set-info",children:[f(W?"fleet-editor-load-error":"fleet-editor-unavailable"),!W&&u.reason?` ${u.reason}`:""]})]}),W&&a.jsx("div",{className:"nc-err",children:W}),T&&a.jsx(Qr,{onClose:()=>z(null),label:f("import-as-cell"),error:W,children:a.jsx(mx,{token:t,route:T.route||ne,state:T,setState:z,busy:O,onSave:et})}),I&&a.jsx(Wd,{cell:I,token:t,route:Array.isArray(I.route)?I.route:ne,onConfirm:async ee=>{try{await ve(ee)}finally{me()}},onClose:()=>D(null)})]}):a.jsxs("div",{className:"nc-set-tab",children:[ot,re==="overview"?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"nc-set-info",children:f("fleet-overview-help")}),a.jsx(gm,{token:t,targets:n,readonly:e,onPower:ze,onImport:Oe})]}):a.jsxs(a.Fragment,{children:[st,a.jsx("div",{className:"nc-set-info",children:f("fleet-editor-loading")})]})]})}const TE="nc_bar_files_button",PE="nc_bar_keyboard_button",IE="nc_bar_panel_button";function h_(t,e){try{const n=localStorage.getItem(t);if(n==="on")return!0;if(n==="off")return!1}catch{}return e}function f_(t,e){try{localStorage.setItem(t,e?"on":"off")}catch{}}function DE(){return h_(TE,!0)}function OE(t){f_(TE,t)}function BE(){return h_(PE,!0)}function c4(t){f_(PE,t)}function $E(){return h_(IE,!1)}function u4(t){f_(IE,t)}const p_="nc_notification_speech_v1",md="nc-notification-speech",Vg="nc-notification-speech-preview",d4=320,h4=2,f4=3e4,p4=1e4,m4=6e4,g4=64,gx=Object.freeze({enabled:!1}),v4=Object.freeze({it:"it-IT",en:"en-US",es:"es-ES"}),_4=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"])}),m_=new WeakSet;function g_(t){return{enabled:(t&&typeof t=="object"&&!Array.isArray(t)?t:{}).enabled===!0}}function zE(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function vx(t=zE()){if(!t)return{...gx};try{return g_(JSON.parse(t.getItem(p_)||"null"))}catch{return{...gx}}}function y4(t,e=zE()){const n=g_(t);if(e)try{e.setItem(p_,JSON.stringify(n))}catch{}return n}function ol(){try{return typeof window<"u"?window:null}catch{return null}}function Hc(t=ol()){try{return!!(t&&t.speechSynthesis&&typeof t.speechSynthesis.speak=="function"&&typeof t.SpeechSynthesisUtterance=="function")}catch{return!1}}function FE(t=ol()){return!!(t&&(typeof t=="object"||typeof t=="function")&&m_.has(t))}function Yg(t=ol()){t&&(typeof t=="object"||typeof t=="function")&&m_.delete(t)}function Ka(t){const e=String(t||"").trim().toLowerCase().split("-")[0];return v4[e]||""}function Lh(t){return String(t||"").normalize("NFC").replace(/[\p{Cc}\p{Cf}]+/gu," ").replace(/\s+/g," ").trim()}function w4(t){const e=Lh(t).normalize("NFD").replace(new RegExp("\\p{M}+","gu"),"").toLowerCase(),n=new Set(e.match(new RegExp("\\p{L}+","gu"))||[]);if(n.size<4)return"";const s=Object.entries(_4).map(([i,l])=>({lang:i,score:[...n].reduce((c,u)=>c+(l.has(u)?1:0),0)})).sort((i,l)=>l.score-i.score);return s[0].score>=3&&s[0].score-s[1].score>=2?s[0].lang:""}function b4(t,e){const n=Ka(t&&t.lang);return n||Ka(w4(t&&t.body))||Ka(e)}function HE(t){try{const e=t&&t.speechSynthesis&&t.speechSynthesis.getVoices;return typeof e=="function"?Array.from(e.call(t.speechSynthesis)||[]).filter(Boolean):[]}catch{return[]}}function UE(t,e){const n=Ka(e);if(!n)return null;const s=Array.from(t||[]).filter(u=>u&&typeof u.lang=="string"&&u.lang.trim()),i=s.filter(u=>u.lang.trim().toLowerCase()===n.toLowerCase()),l=n.slice(0,2).toLowerCase(),c=s.filter(u=>u.lang.trim().toLowerCase().split("-")[0]===l);return i.find(u=>u.default===!0)||i[0]||c.find(u=>u.default===!0)||c[0]||null}function _x(t){return Lh(t).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 S4(t,e=d4){const n=_x(t&&t.title),s=_x(t&&t.body),i=[n,s&&s!==n?s:""].filter(Boolean).join(". "),l=Array.from(i);return l.length<=e?i:`${l.slice(0,Math.max(0,e-1)).join("").trimEnd()}…`}function x4(t){try{return!!(t&&t.visibilityState==="visible"&&typeof t.hasFocus=="function"&&t.hasFocus())}catch{return!1}}function WE(t=ol()){if(!Hc(t))return!1;try{return t.speechSynthesis.cancel(),!0}catch{return!1}}function k4(t){try{t&&typeof t.dispatchEvent=="function"&&typeof t.Event=="function"&&t.dispatchEvent(new t.Event(Vg))}catch{}}function C4(t,e,n=ol(),s={}){var p;if(Yg(n),!Hc(n))return Promise.resolve(!1);const i=Lh(t);if(!i||(p=s.signal)!=null&&p.aborted)return Promise.resolve(!1);const l=Number.isFinite(s.timeoutMs)&&s.timeoutMs>0?s.timeoutMs:p4,c=s.setTimer||((v,_)=>setTimeout(v,_)),u=s.clearTimer||(v=>clearTimeout(v)),h=s.signal;return k4(n),new Promise(v=>{let _=!1,g=!1,b=null,S=null;const j=C=>{if(!_){if(_=!0,h&&S&&h.removeEventListener("abort",S),b!==null&&u(b),C!==!0)try{n.speechSynthesis.cancel()}catch{}else m_.add(n);v(C)}};S=()=>j("no-activation"),h&&h.addEventListener("abort",S,{once:!0});try{n.speechSynthesis.cancel();const C=new n.SpeechSynthesisUtterance(i);C.lang=Ka(e);const N=UE(HE(n),C.lang);N&&(C.voice=N),C.onstart=()=>{g=!0},C.onend=()=>j(g?!0:"no-activation"),C.onerror=()=>j("voice-error"),b=c(()=>j("timeout"),l),n.speechSynthesis.speak(C)}catch{j("no-activation")}})}function E4(t={}){const e=t.scope||ol(),n=t.document||e&&e.document,s=Number.isInteger(t.maxPending)&&t.maxPending>=0?t.maxPending:h4,i=Number.isFinite(t.watchdogMs)&&t.watchdogMs>0?t.watchdogMs:f4,l=Number.isFinite(t.dedupWindowMs)&&t.dedupWindowMs>0?t.dedupWindowMs:m4,c=Number.isInteger(t.maxDedup)&&t.maxDedup>0?t.maxDedup:g4,u=t.now||Date.now,h=t.setTimer||((K,B)=>setTimeout(K,B)),p=t.clearTimer||(K=>clearTimeout(K)),v=t.isPrimed||(()=>FE(e)),_=e&&e.speechSynthesis;let g=null,b=null,S=[],j=[],C=()=>{};const N=new Map,E=()=>{j=HE(e)};if(E(),_&&typeof _.addEventListener=="function")_.addEventListener("voiceschanged",E),C=()=>_.removeEventListener("voiceschanged",E);else if(_&&"onvoiceschanged"in _){const K=_.onvoiceschanged,B=(...I)=>{E(),typeof K=="function"&&K.apply(_,I)};_.onvoiceschanged=B,C=()=>{_.onvoiceschanged===B&&(_.onvoiceschanged=K)}}const O=K=>{if(K&&typeof K.id=="string"&&K.id)return`id:${K.id}`;const B=Number(K&&K.ts),I=Lh(K&&K.title);return Number.isFinite(B)&&I?`frame:${B}:${I}`:""},x=K=>{if(!K)return!0;const B=u();for(const[I,D]of N)B-D>=l&&N.delete(I);if(N.has(K))return!1;for(N.set(K,B);N.size>c;)N.delete(N.keys().next().value);return!0},W=()=>{b!==null&&p(b),b=null},$=()=>{W(),g&&(g.onend=null,g.onerror=null,g=null),WE(e)},J=K=>{if(!Hc(e))return S=[],"unsupported";let B;try{B=new e.SpeechSynthesisUtterance(K.text),B.lang=Ka(K.lang);const D=UE(j,B.lang);D&&(B.voice=D)}catch{return S=[],"error"}g=B;const I=()=>{if(g!==B)return;W(),g=null,B.onend=null,B.onerror=null;const D=S.shift();D&&J(D)};B.onend=I,B.onerror=I;try{return b=h(()=>{if(g!==B)return;g=null,B.onend=null,B.onerror=null;try{e.speechSynthesis.cancel()}catch{}W();const D=S.shift();D&&J(D)},i),e.speechSynthesis.speak(B),"speaking"}catch{return I(),"error"}},q=(K,B)=>{if(!Hc(e))return"unsupported";const I=S4(K);if(!I)return"empty";if(!x(O(K)))return"duplicate";if(!x4(n))return"inactive";if(!v())return"unprimed";const D={text:I,lang:B};return K&&K.urgency==="high"?(S=[],$(),J(D)):g?s===0?"dropped":(S.length>=s&&S.shift(),S.push(D),"queued"):J(D)},V=()=>{S=[],$()};return{enqueue:q,stop:V,dispose:()=>{V(),C(),C=()=>{}}}}function qE(){const[t,e]=y.useState(vx);y.useEffect(()=>{const s=i=>{if((i==null?void 0:i.type)==="storage"&&i.key!==p_&&i.key!==null)return;const l=(i==null?void 0:i.type)===md?g_(i.detail):vx();e(l)};return window.addEventListener(md,s),window.addEventListener("storage",s),()=>{window.removeEventListener(md,s),window.removeEventListener("storage",s)}},[]);const n=y.useCallback(s=>{const i=y4({enabled:s===!0});return e(i),window.dispatchEvent(new CustomEvent(md,{detail:i})),i.enabled},[]);return[t.enabled,n]}const v_="nc_storage_persist_v1",N4=1440*60*1e3;function Gg(t=globalThis.localStorage){return Ar(v_,{storage:t,fallback:()=>null,parse:e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0})}async function j4({manager:t=(s=>(s=globalThis.navigator)==null?void 0:s.storage)(),ls:e=globalThis.localStorage,now:n=Date.now}={}){const i=Gg(e),l=n();let c;try{if(!t||typeof t.persist!="function")c={at:l,status:"unsupported"};else if(typeof t.persisted=="function"&&await t.persisted())c={at:l,status:"persistent"};else{if(i&&i.status==="denied"&&l-i.at<N4)return i;c={at:l,status:await t.persist()?"persistent":"denied"}}}catch(u){c={at:l,status:"error",note:String((u==null?void 0:u.message)||u).slice(0,120)}}return(!i||i.status!==c.status)&&Xi({reason:"storage-persist",note:c.status}),yi(v_,c,{storage:e}),c}const L4=t=>{try{return new Date(t).toLocaleString()}catch{return String(t)}},vm=t=>Array.isArray(t)?t.join(", "):"";function R4(){zn();const[t,e]=y.useState(()=>kg()),[n,s]=y.useState(()=>Gg()),[i,l]=y.useState(!1);y.useEffect(()=>{const p=()=>{e(kg()),s(Gg())};return window.addEventListener("storage",p),window.addEventListener("nexuscrew-roster-preferences",p),()=>{window.removeEventListener("storage",p),window.removeEventListener("nexuscrew-roster-preferences",p)}},[]);const c=async()=>{try{await navigator.clipboard.writeText(JSON.stringify(t,null,2)),l(!0),setTimeout(()=>l(!1),1500)}catch{}},u=()=>{LP(),e([])},h=[...t].reverse();return a.jsxs("div",{className:"nc-set-form nc-prefs-journal",children:[a.jsx("div",{className:"nc-sheet-label",children:f("prefs-journal")}),a.jsxs("div",{"data-testid":"persist-status",className:"nc-set-hint","data-key":v_,children:[f("prefs-persist"),": ",n?n.status:f("prefs-persist-unknown")]}),!h.length&&a.jsx("div",{className:"nc-set-hint",children:f("prefs-journal-empty")}),a.jsx("div",{className:"nc-journal-list",style:{maxHeight:220,overflow:"auto"},children:h.map((p,v)=>a.jsxs("div",{"data-testid":"journal-row",className:"nc-set-hint",style:{overflowWrap:"anywhere"},children:[a.jsx("b",{children:p.reason})," · ",L4(p.t),p.position?` · ${p.position}`:"",p.key?` · ${p.key}`:"",p.note?` · ${p.note}`:"",p.before?a.jsxs("div",{children:[f("prefs-before"),": ",vm(p.before)]}):null,p.after?a.jsxs("div",{children:[f("prefs-after"),": ",vm(p.after)]}):null,p.visible?a.jsxs("div",{children:[f("prefs-visible"),": ",vm(p.visible)]}):null]},`${p.t}-${v}`))}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:c,disabled:!t.length,children:f(i?"copied":"prefs-journal-copy")}),a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:u,disabled:!t.length,children:f("prefs-journal-clear")})]})]})}const __="nc_device_id_v1",KE="nc_prefs_sync_v1",A4="nexuscrew-roster-preferences",y_=/^[a-f0-9]{32}$/,M4=192,T4=256,yx=128,VE="nexuscrew-preferences",zo=t=>t&&typeof t=="object"&&!Array.isArray(t),Ad=(t,e)=>typeof t=="string"&&t.length>0&&t.length<=e&&!/[\u0000-\u001f\u007f]/.test(t),_m=(t,e=T4)=>Array.isArray(t)&&t.length<=e&&t.every(n=>Ad(n,M4));function al(t){if(!zo(t)||Object.keys(t).some(n=>!["pins","orders","views","nodeOrder"].includes(n)))return null;const e={pins:[],orders:{},views:{},nodeOrder:[]};if(t.pins!==void 0){if(!_m(t.pins))return null;e.pins=[...new Set(t.pins)]}if(t.nodeOrder!==void 0){if(!_m(t.nodeOrder,128))return null;e.nodeOrder=[...new Set(t.nodeOrder)]}if(t.orders!==void 0){if(!zo(t.orders)||Object.keys(t.orders).length>yx)return null;for(const[n,s]of Object.entries(t.orders)){if(!Ad(n,96)||!_m(s))return null;e.orders[n]=[...new Set(s)]}}if(t.views!==void 0){if(!zo(t.views)||Object.keys(t.views).length>yx)return null;for(const[n,s]of Object.entries(t.views)){if(!Ad(n,96)||!zo(s))return null;const i={};if(s.open!==void 0){if(typeof s.open!="boolean")return null;i.open=s.open}if(s.filter!==void 0){if(!Ad(s.filter,16))return null;i.filter=s.filter}e.views[n]=i}}return e}const Xg=t=>!t||!(t.pins||[]).length&&!(t.nodeOrder||[]).length&&!Object.keys(t.orders||{}).length&&!Object.keys(t.views||{}).length;function w_(t){const e={pins:to(),orders:gc(t),views:Ld(t),nodeOrder:Rg(t)};return al(e)||{pins:[],orders:{},views:{},nodeOrder:[]}}const Jg=t=>Array.isArray(t)?`[${t.map(Jg).join(",")}]`:zo(t)?`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${Jg(t[e])}`).join(",")}}`:JSON.stringify(t),Md=t=>{const e=Jg(al(t)||{});let n=2166136261;for(let s=0;s<e.length;s+=1)n^=e.charCodeAt(s),n=Math.imul(n,16777619);return(n>>>0).toString(16)},ym=["nc_pins",Jo,Xo,wh];function b_(t,{storage:e,note:n="restore"}={}){const s=al(t);if(!s)return new Error("preferenze non valide");let i=e;try{i=i||globalThis.localStorage}catch(u){return u}const l={};for(const u of ym)try{l[u]=i.getItem(u)}catch{l[u]=null}const c={nc_pins:s.pins,[Jo]:s.orders,[Xo]:s.views,[wh]:s.nodeOrder};for(const u of ym){const h=yi(u,c[u],{storage:e});if(h){for(const p of ym)try{l[p]===null||l[p]===void 0?i.removeItem(p):i.setItem(p,l[p])}catch{}return Xi({reason:"prefs-restore-failed",key:u,note:String(h&&h.message||h).slice(0,120)}),h}}Xi({reason:"prefs-restore",note:n,after:s.pins});try{window.dispatchEvent(new Event(A4))}catch{}return null}const YE=t=>({status:"error",code:"storage-write-failed",note:String(t&&t.message||t).slice(0,120)}),S_=t=>{try{return t||globalThis.localStorage}catch{return null}},Rh=t=>{var e;try{const n=(e=S_(t))==null?void 0:e.getItem(__);return y_.test(n||"")?n:""}catch{return""}},GE=(t,e)=>{var n;try{(n=S_(e))==null||n.setItem(__,t)}catch{}};function P4(t,e){y_.test(t||"")&&!Rh(e)&&GE(t,e)}const I4=Rh,D4=t=>Ar(KE,{storage:t,fallback:()=>null,parse:e=>zo(e)?e:void 0}),Qd=(t,e,n)=>yi(KE,{revision:t,hash:Md(e),at:Date.now()},{storage:n});function XE(t){return async(e,n,{headers:s={},body:i}={})=>qn(n,t,{method:e,headers:{...i?{"content-type":"application/json"}:{},...s},body:i,timeoutMs:8e3})}async function wx(t,e){let n=Rh(e);if(!n){const s=await t("POST","/api/prefs/devices");if(s.status!==201)throw Object.assign(new Error(`device ${s.status}`),{status:s.status});if(n=(await s.json()).deviceId,!y_.test(n||""))throw new Error("device non valido");GE(n,e)}return n}async function Qg(t,e,n,s,i){const l=await t("PUT","/api/prefs",{headers:{"x-nc-device":e,"if-match":`"${s}"`},body:JSON.stringify({data:n})});if(l.status===200){const u=await l.json();return Qd(u.revision,n,i),{status:"uploaded",revision:u.revision}}const c=await l.json().catch(()=>({}));return l.status===409&&c.current?{status:"conflict",revision:c.current.revision,conflict:{local:n,server:al(c.current.data)||null,revision:c.current.revision,deviceId:e}}:{status:"error",code:c.code||`http-${l.status}`}}async function O4({request:t,token:e,storage:n}={}){var i;const s=t||XE(e);try{let l=await wx(s,n),c=await s("GET","/api/prefs",{headers:{"x-nc-device":l}});if(c.status===404){try{(i=S_(n))==null||i.removeItem(__)}catch{}l=await wx(s,n),c=await s("GET","/api/prefs",{headers:{"x-nc-device":l}})}if(c.status!==200)return{status:"error",code:`http-${c.status}`};const u=await c.json(),h=w_(n),p=al(u.data);if(!p)return Xg(h)?{status:"synced",revision:u.revision}:Qg(s,l,h,u.revision,n);if(Xg(h)){const _=b_(p,{storage:n});return _?YE(_):(Qd(u.revision,p,n),{status:"restored",revision:u.revision})}if(Md(h)===Md(p))return Qd(u.revision,h,n),{status:"synced",revision:u.revision};const v=D4(n);return v&&v.revision===u.revision&&v.hash!==Md(h)?Qg(s,l,h,u.revision,n):{status:"conflict",revision:u.revision,conflict:{local:h,server:p,revision:u.revision,deviceId:l}}}catch(l){return{status:"offline",note:String((l==null?void 0:l.message)||l).slice(0,120)}}}async function B4(t,e,{request:n,token:s,storage:i}={}){if(!e)return{status:"error",code:"no-conflict"};const l=n||XE(s);try{if(t==="server"){if(!e.server)return{status:"error",code:"no-server-copy"};const c=b_(e.server,{storage:i,note:"restore-from-server"});return c?YE(c):(Qd(e.revision,e.server,i),{status:"restored",revision:e.revision})}return await Qg(l,e.deviceId||Rh(i),e.local,e.revision,i)}catch(c){return{status:"offline",note:String((c==null?void 0:c.message)||c).slice(0,120)}}}function $4(t){return JSON.stringify({kind:VE,version:1,exportedAt:new Date().toISOString(),data:w_(t)},null,2)}function z4(t,{storage:e}={}){let n;try{n=JSON.parse(t)}catch{return{ok:!1,reason:"not-json"}}if(!zo(n)||n.kind!==VE||n.version!==1)return{ok:!1,reason:"wrong-kind"};const s=al(n.data);if(!s)return{ok:!1,reason:"bad-schema"};const i=b_(s,{storage:e,note:"import"});return i?{ok:!1,reason:"storage-write-failed",note:String(i&&i.message||i).slice(0,120)}:{ok:!0,data:s}}const Zd={status:"idle"};let Nr=Zd;const Zg=new Set,eh=t=>{Nr=t,Zg.forEach(e=>e(t))};let ev=null,Uc=0;const F4=t=>{const e=t||null;ev!==e&&(ev=e,Uc+=1,Nr!==Zd&&eh(Zd))},JE=()=>{const[t,e]=y.useState(Nr);return y.useEffect(()=>(Zg.add(e),e(Nr),()=>{Zg.delete(e)}),[]),t};async function QE(t,e){var i;if(Nr.status!=="conflict")return;const n=Uc;if(ev!==(t||null)||((i=Nr.conflict)==null?void 0:i.deviceId)!==I4()){eh(Zd);try{window.dispatchEvent(new Event("nexuscrew-roster-preferences"))}catch{}return}const s=await B4(e,Nr.conflict,{token:t});n===Uc&&eh({...s,at:Date.now()})}const H4=1500,U4=3e3,bx="nexuscrew-roster-preferences";function W4(t){y.useEffect(()=>{if(F4(t),!t)return;let n=null,s=!0;const i=async()=>{if(!s||Nr.status==="conflict")return;const u=Uc,h=await O4({token:t});s&&u===Uc&&eh({...h,at:Date.now()})},l=u=>{clearTimeout(n),n=setTimeout(i,u)},c=()=>{Nr.status!=="conflict"&&l(U4)};return l(H4),window.addEventListener(bx,c),window.addEventListener("storage",c),()=>{s=!1,clearTimeout(n),window.removeEventListener(bx,c),window.removeEventListener("storage",c)}},[t]);const e=y.useCallback(n=>QE(t,n),[t]);return{state:JE(),resolve:e}}const q4=t=>typeof t.text=="function"?t.text():new Promise((e,n)=>{const s=new FileReader;s.onload=()=>e(String(s.result||"")),s.onerror=()=>n(s.error),s.readAsText(t)});function K4({token:t=""}){zn();const e=JE(),n=y.useRef(null),s=h=>QE(t,h),[i,l]=y.useState(null),c=()=>{try{const h=URL.createObjectURL(new Blob([$4()],{type:"application/json"})),p=document.createElement("a");p.href=h,p.download="nexuscrew-preferences.json",document.body.appendChild(p),p.click(),p.remove(),setTimeout(()=>URL.revokeObjectURL(h),1e3),l({ok:!0,text:f("prefs-export-done")})}catch(h){l({ok:!1,text:String((h==null?void 0:h.message)||h)})}},u=async h=>{const p=h.target.files&&h.target.files[0];if(h.target.value="",!p)return;let v="";try{v=await q4(p)}catch(g){l({ok:!1,text:String((g==null?void 0:g.message)||g)});return}if(!Xg(w_())&&!window.confirm(f("prefs-import-confirm")))return;const _=z4(v);l(_.ok?{ok:!0,text:f("prefs-import-done")}:{ok:!1,text:f(_.reason==="not-json"||_.reason==="wrong-kind"?"prefs-import-wrong":_.reason==="storage-write-failed"?"prefs-import-storage":"prefs-import-bad")})};return a.jsxs("div",{className:"nc-set-form nc-prefs-backup",children:[a.jsx("div",{className:"nc-sheet-label",children:f("prefs-backup")}),a.jsxs("div",{"data-testid":"sync-status",className:"nc-set-hint",children:[f("prefs-sync"),": ",e.status,e.revision!==void 0?` (r${e.revision})`:"",e.code?` · ${e.code}`:"",e.note?` · ${e.note}`:""]}),e.status==="conflict"&&a.jsxs("div",{className:"nc-set-confirm",role:"group","aria-label":f("prefs-conflict"),children:[a.jsx("div",{children:f("prefs-conflict")}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>s("local"),children:f("prefs-keep-local")}),a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>s("server"),children:f("prefs-use-server")})]})]}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:c,children:f("prefs-export")}),a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>n.current&&n.current.click(),children:f("prefs-import")}),a.jsx("input",{ref:n,type:"file",accept:"application/json,.json","aria-label":f("prefs-import"),style:{display:"none"},onChange:u})]}),i&&a.jsx("div",{className:i.ok?"nc-set-note":"nc-err",role:i.ok?"status":"alert",children:i.text})]})}function V4({text:t}){const[e,n]=y.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(t),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return a.jsxs("div",{className:"nc-set-copyline",children:[a.jsx("code",{children:t}),a.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:s,children:[a.jsx(_t,{name:"copy",size:14})," ",f(e?"copied":"copy")]})]})}function Y4({value:t}){const[e,n]=y.useState("");return y.useEffect(()=>{let s=!0;return W3.toDataURL(t,{margin:1,width:220}).then(i=>{s&&n(i)}).catch(()=>{}),()=>{s=!1}},[t]),e?a.jsx("img",{src:e,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function G4({token:t,nodes:e,roster:n,settings:s,readonly:i,refresh:l,refreshAliases:c,vlUnavailable:u=[],accessRevision:h=null}){const[p,v]=y.useState(null),[_,g]=y.useState(null),[b,S]=y.useState(null),[j,C]=y.useState({ssh:"",sshPort:"",name:""}),[N,E]=y.useState(""),[O,x]=y.useState(""),[W,$]=y.useState(!1),[J,q]=y.useState(null),V=Date.now(),ie=s&&s.deviceName||"",K=(e||[]).filter(L=>L&&L.direction==="outbound"&&L.name&&L.ssh),B=K.find(L=>L.name===N)||K[0]||null,I=B?Bg(B.tunnel,V):null,D=B!=null&&B.shared?I!=null&&I.up?"share-local-active":"share-local-pending":I!=null&&I.up?"share-local-private":"share-local-private-down",T=[{key:"peer-group-hubs",rows:(e||[]).filter(L=>L.kind!=="transitive"&&L.kind!=="vl"&&L.relation!=="client")},{key:"peer-group-clients",rows:(e||[]).filter(L=>L.kind!=="transitive"&&L.kind!=="vl"&&L.relation==="client")},{key:"peer-group-routed",rows:(e||[]).filter(L=>L.kind==="transitive")},{key:"peer-group-vl",rows:(e||[]).filter(L=>L.kind==="vl")}],z=J&&(e||[]).find(L=>`${L.kind||"direct"}:${L.nodeId||L.name}`===J)||null,R=async L=>{if(B){v(null),g(`${B.name}:share`);try{const H=await j5(t,B.name,L);await l(),H&&H.reversePoolPending===!0&&v(`${B.name}: ${f("share-reverse-pool-pending")}`)}catch(H){const A=H!=null&&H.data&&H.data.shared===!1?H.data:null;if(A)try{await l()}catch{}const U=H!=null&&H.data&&typeof H.data.hint=="string"?H.data.hint:"",Q=(A==null?void 0:A.revoked)===!0&&(A==null?void 0:A.localReconcilePending)===!0?f("share-off-local-reconcile-pending"):(A==null?void 0:A.revoked)===!1&&(A==null?void 0:A.reconcilePending)===!0?f("share-off-hub-reconcile-pending"):"",ae=H!=null&&H.data&&H.data.reversePoolPending===!0?f("share-reverse-pool-pending"):"",re=H!=null&&H.data&&typeof H.data.code=="string"?H.data.code:"",je=H!=null&&H.data&&typeof H.data.detail=="string"?H.data.detail.trim():"",te=je&&je!==String(H.message||"")?je:"";v(`${B.name}: ${String(H.message||H)}${re?` [${re}]`:""}${te?` — ${te}`:""}${U?` — ${U}`:""}${Q?` — ${Q}`:""}${ae?` — ${ae}`:""}`)}g(null)}},M=async()=>{v(null);const L=ho(j.name||O||ie||"NexusCrew"),H=NI({name:L,ssh:j.ssh,sshPort:j.sshPort});if(!H.ok){v(f(H.error));return}g("invite");try{S(await k5(t,{...O||ie?{label:O||ie}:{},name:L,ssh:H.value.ssh,...H.value.sshPort?{sshPort:H.value.sshPort}:{}}))}catch(A){v(String(A.message||A))}g(null)};return a.jsxs("div",{className:"nc-set-tab",children:[a.jsx("div",{className:"nc-sheet-label",children:f("peer-inventory-title")}),(e||[]).length===0&&a.jsx("div",{className:"nc-empty",children:f("no-nodes")}),T.map(L=>L.rows.length>0&&a.jsxs("div",{className:"nc-peer-group",children:[a.jsxs("div",{className:"nc-peer-group-title",children:[f(L.key)," ",a.jsx("span",{children:L.rows.length})]}),L.rows.map(H=>{const A=n6(H);if(!A)return null;const U=`${H.kind||"direct"}:${H.nodeId||H.name}`,Q=A.routed?{up:A.reach.up,since:null}:Bg(H.tunnel,V);return a.jsxs("button",{type:"button",className:`nc-set-node nc-node-row${A.routed?" routed":""}`,"aria-label":`${A.title} — ${f("node-detail-open")}`,onClick:()=>q(U),children:[a.jsx("span",{className:`nc-dot ${A.reach.up?"on":""}`}),a.jsxs("span",{className:"nc-node-row-text",children:[a.jsx("b",{children:A.title}),a.jsxs("small",{children:[A.routed?A.routeLabel:`${A.subtitle} · ${f(A.exposure.shortKey)}`,!A.routed&&A.exposure.shortKey==="visibility-selected"?` (${A.exposure.count})`:""]})]}),a.jsxs("span",{className:`nc-set-tunnel${A.reach.up?" up":""}`,children:[f(A.reach.key),Q.since?` · ${Q.since}`:""]}),a.jsx("span",{className:"nc-node-row-more",children:a.jsx(_t,{name:"chevronDown",size:14})})]},U)})]},L.key)),u.length>0&&a.jsxs("div",{className:"nc-err",children:[f("vl-owners-unavailable"),": ",u.map(L=>L.label||L.route.join("/")).join(", ")]}),z&&a.jsx(C6,{node:z,nodes:e||[],token:t,readonly:i,refresh:l,onClose:()=>q(null),peerAccessRevision:h}),(n||[]).some(L=>!L.direct&&L.instanceId)&&a.jsxs("div",{className:"nc-set-form",children:[a.jsx("div",{className:"nc-sheet-label",children:f("routed-node-aliases")}),a.jsx("small",{className:"nc-set-hint",children:f("routed-node-aliases-help")}),(n||[]).filter(L=>!L.direct&&L.instanceId).map(L=>a.jsxs("div",{className:"nc-set-node",children:[a.jsxs("div",{className:"nc-set-node-head",children:[a.jsx("span",{className:`nc-dot ${L.status==="up"?"on":""}`}),a.jsx("b",{children:L.label||L.name}),a.jsx("small",{children:(L.route||[]).join(" › ")})]}),a.jsxs("div",{className:"nc-set-node-actions",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!_,onClick:async()=>{const H=window.prompt(f("node-local-alias"),L.alias||"");if(H!=null){if(H.trim()&&!Ja(H.normalize("NFC"))){v(f("err-label"));return}g(`${L.instanceId}:alias`),v(null);try{H.trim()?await E5(t,L.instanceId,H):await eb(t,L.instanceId),c()}catch(A){v(String(A.message||A))}g(null)}},children:f("alias-on-device")}),L.alias&&a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!_,onClick:async()=>{g(`${L.instanceId}:alias-reset`),v(null);try{await eb(t,L.instanceId),c()}catch(H){v(String(H.message||H))}g(null)},children:f("reset-alias")})]})]},L.instanceId))]}),B&&a.jsxs("div",{className:"nc-set-form nc-local-share",children:[a.jsx("div",{className:"nc-sheet-label",children:f("share-local-heading")}),K.length>1&&a.jsxs("label",{className:"nc-field",children:[f("share-local-hub"),a.jsx("select",{value:B.name,disabled:i||!!_,onChange:L=>E(L.target.value),children:K.map(L=>a.jsx("option",{value:L.name,children:L.label||L.name},L.name))})]}),a.jsxs("label",{className:"nc-check nc-node-share",children:[a.jsx("input",{type:"checkbox",checked:B.shared===!0,disabled:i||!!_,onChange:L=>R(L.target.checked)}),a.jsxs("span",{children:[a.jsx("b",{children:f("share-local-through").replace("{device}",ie||f("local")).replace("{hub}",B.label||B.name)}),a.jsx("small",{children:f(B.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),a.jsx("div",{className:`nc-set-test${B.shared&&(I!=null&&I.up)?" ok":I!=null&&I.up?"":" ko"}`,children:f(D)}),!(I!=null&&I.up)&&a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!_,onClick:()=>R(B.shared===!0),children:f("share-local-reconnect")})]}),a.jsx(pE,{token:t,deviceDefault:ie,localNodeId:s&&s.nodeId||"",localNameDefault:s&&s.localName||"",readonly:i,onSuccess:l}),a.jsxs("div",{className:"nc-set-form",children:[a.jsx("div",{className:"nc-sheet-label",children:f("invite-node")}),a.jsx("small",{className:"nc-set-hint",children:f("invite-v2-hint")}),a.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[f("invite-target-local"),": ",a.jsx("b",{children:ie||f("invite-target-this")})]}),a.jsxs("label",{className:"nc-field",children:[f("invite-endpoint-label"),a.jsx("input",{placeholder:"user@host",value:j.ssh,disabled:i,onChange:L=>C({...j,ssh:L.target.value})}),a.jsx("small",{className:"nc-set-hint",children:f("invite-endpoint-needed")})]}),K.length>0&&a.jsx("small",{className:"nc-set-hint nc-invite-hub-hint",children:f("invite-hub-only")}),W&&a.jsxs("div",{className:"nc-invite-advanced",children:[a.jsxs("label",{className:"nc-field",children:[f("node-ssh-port-label"),a.jsx("input",{inputMode:"numeric",placeholder:"22",value:j.sshPort,disabled:i,onChange:L=>C({...j,sshPort:L.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),a.jsxs("label",{className:"nc-field",children:[f("device-name-label"),a.jsx("input",{placeholder:ie||"NexusCrew",value:O,disabled:i,onChange:L=>x(L.target.value)}),a.jsx("small",{className:"nc-set-hint",children:f("device-name-hint")})]}),a.jsxs("label",{className:"nc-field",children:[f("node-name-label"),a.jsx("input",{placeholder:ho(O||ie||f("node-name-ph")),value:j.name,disabled:i,onChange:L=>C({...j,name:L.target.value?ho(L.target.value):""})})]})]}),a.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[a.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||!!_||!j.ssh.trim(),onClick:M,children:f("create-pairing-link")}),a.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!_,onClick:()=>$(L=>!L),children:[W?"▾":"▸"," ",f("pair-advanced")]})]}),b&&a.jsxs(a.Fragment,{children:[a.jsx(Y4,{value:b.pairingUrl}),a.jsx(V4,{text:b.pairingUrl}),a.jsx("div",{className:"nc-set-info",children:f("invite-next-steps")})]})]}),p&&a.jsx("div",{className:"nc-err",children:p})]})}function X4({token:t,readonly:e}){const[n,s]=y.useState("idle"),[i,l]=y.useState(()=>yE()),[c,u]=y.useState(!1),[h,p]=y.useState(null);y.useEffect(()=>{let g=!1;return wE().then(b=>{g||s(b)}),()=>{g=!0}},[]);const v=async()=>{p(null),u(!0);try{n==="subscribed"?(await rx(t),s("idle")):(await bE(t),s("subscribed"))}catch(g){const b=String(g.message||g);b==="push-denied"?(s("denied"),p(f("push-denied"))):b==="push-unsupported"?(s("unsupported"),p(f("push-unsupported"))):p(b==="push-disabled-local"?f("push-local-disabled"):b)}u(!1)},_=async()=>{const g=g6({enabled:i.enabled!==!1});if(l(g),p(null),g.enabled===!1&&n==="subscribed"){u(!0);try{await rx(t),s("idle")}catch{}u(!1)}};return n==="unsupported"?a.jsx("div",{className:"nc-set-info",children:f("push-unsupported")}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"nc-set-row",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:_,disabled:c,children:i.enabled===!1?f("push-local-on"):f("push-local-off")}),a.jsx("span",{className:"nc-set-info",children:i.enabled===!1?f("push-local-off-note"):f("push-local-help")})]}),a.jsxs("div",{className:"nc-set-row",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||c||n==="denied",title:e?f("settings-readonly"):"",onClick:v,children:f(n==="subscribed"?"push-disable":"push-enable")}),a.jsx("span",{className:"nc-set-info",children:f(n==="subscribed"?"push-on":n==="denied"?"push-denied":"push-off")})]}),h&&a.jsx("div",{className:"nc-err",children:h})]})}function J4(){const[t,e]=qE(),[n,s]=y.useState(""),[i,l]=y.useState(""),[c,u]=y.useState(!1),[h,p]=y.useState(FE),v=y.useRef(0),_=y.useRef(!1),g=y.useRef(null),b=Hc();y.useEffect(()=>()=>{var C;v.current+=1,_.current&&((C=g.current)==null||C.abort(),g.current=null,_.current=!1,Yg())},[]);const S=async()=>{const C=v.current+=1,N=typeof AbortController=="function"?new AbortController:null;s(""),l(""),u(!0),p(!1),_.current=!0,g.current=N;const E=await C4(f("notification-speech-preview"),Vo(),void 0,N?{signal:N.signal}:{});return C!==v.current||(g.current=null,_.current=!1,u(!1),p(E===!0),E===!0?l(f("notification-speech-preview-ok")):s(f(E==="voice-error"?"notification-speech-preview-voice-error":E==="timeout"?"notification-speech-preview-timeout":"notification-speech-preview-failed"))),E},j=C=>{var N;if(e(C),s(""),l(""),C)S();else{v.current+=1;const E=_.current;(N=g.current)==null||N.abort(),g.current=null,_.current=!1,u(!1),p(!1),Yg(),E||WE()}};return a.jsxs("div",{className:"nc-set-form",children:[a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox","aria-label":f("notification-speech-enable"),checked:t,disabled:!b,onChange:C=>j(C.target.checked)}),a.jsxs("span",{children:[a.jsx("b",{children:f("notification-speech-enable")}),a.jsx("small",{children:f("notification-speech-help")})]})]}),b?a.jsx("div",{className:"nc-set-row",children:a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!t||c,onClick:()=>{S()},children:f(c?"notification-speech-testing":"notification-speech-test")})}):a.jsx("div",{className:"nc-set-info",children:f("notification-speech-unsupported")}),t&&!h&&!c&&!n&&a.jsx("div",{className:"nc-set-info",children:f("notification-speech-needs-test")}),i&&a.jsx("div",{className:"nc-set-info",role:"status",children:i}),n&&a.jsx("div",{className:"nc-err",children:n})]})}function Q4({token:t,readonly:e,nodes:n=[],settings:s=null}){const[i,l]=y.useState(null),[c,u]=y.useState([]),[h,p]=y.useState({name:"",mode:"primary-failover",targets:[]}),[v,_]=y.useState(null),[g,b]=y.useState(!1),[S,j]=y.useState(null),[C,N]=y.useState(""),E=y.useCallback(async()=>{try{const[R,M]=await Promise.all([R5(t),P5(t)]);l(R),u(Array.isArray(M==null?void 0:M.groups)?M.groups:[]),N("")}catch(R){N(String(R.message||R))}},[t]);y.useEffect(()=>{E()},[E]);const O=async R=>{b(!0),j(null),N("");try{l(await A5(t,R))}catch(M){N(String(M.message||M))}b(!1)},x=async()=>{b(!0),j(null),N("");try{j({kind:"test",...await M5(t)})}catch(R){N(String(R.message||R))}b(!1)},W=async()=>{b(!0),j(null),N("");try{j({kind:"stop",...await T5(t)})}catch(R){N(String(R.message||R))}b(!1)},$=[],J=new Set,q=(R,M)=>{const L=typeof R=="string"?R.toLowerCase():"";!/^[a-f0-9]{32}$/.test(L)||J.has(L)||(J.add(L),$.push({id:L,label:M||L}))};q(s==null?void 0:s.nodeId,f("audio-group-local"));for(const R of n||[])q((R==null?void 0:R.nodeId)||(R==null?void 0:R.instanceId),(R==null?void 0:R.label)||(R==null?void 0:R.name)||(R==null?void 0:R.nodeId));for(const R of h.targets)q(R,`${R} (${f("audio-group-unavailable-target")})`);const V=(R=null)=>{N(""),R?(_(R.name),p({name:R.name,mode:R.mode,targets:[...R.targets||[]]})):(_(null),p({name:"",mode:"primary-failover",targets:[]}))},ie=(R,M)=>p(L=>({...L,targets:M?[...new Set([...L.targets,R])]:L.targets.filter(H=>H!==R)})),K=async()=>{const R=h.name.trim().toLowerCase();if(!/^[a-z0-9][a-z0-9-]{0,31}$/.test(R)||h.targets.length<1){N(f("audio-group-invalid"));return}b(!0),N("");try{const M=await I5(t,R,{targets:h.targets,mode:h.mode}),L=M==null?void 0:M.group;if(!L||!L.name)throw new Error(f("audio-group-save-failed"));u(H=>[...H.filter(A=>A.name!==L.name),L].sort((A,U)=>A.name.localeCompare(U.name))),V(null)}catch(M){N(String(M.message||M))}b(!1)},B=async R=>{b(!0),N("");try{await D5(t,R),u(M=>M.filter(L=>L.name!==R)),v===R&&V(null)}catch(M){N(String(M.message||M))}b(!1)},I=(i==null?void 0:i.installed)===!0,D=(i==null?void 0:i.liveness)==="ready",T=(i==null?void 0:i.consent)===!0&&I&&D,z=S?S.kind==="stop"?f(S.stopped?"audio-stop-stopped":"audio-stop-idle"):S.status==="accepted"||S.status==="spoken"?f("audio-test-accepted"):S.status==="unknown"?f("audio-test-unknown"):`${f("audio-test-refused")}${S.reason?` (${S.reason})`:""}`:"";return a.jsxs("div",{className:"nc-set-tab nc-audio-settings",children:[a.jsxs("div",{className:"nc-set-info",children:[a.jsx("b",{children:f("audio-title")}),a.jsx("br",{}),f("audio-help")]}),i?a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox","aria-label":f("audio-consent"),checked:i.consent===!0,disabled:e||g,onChange:R=>{O(R.target.checked)}}),a.jsxs("span",{children:[a.jsx("b",{children:f("audio-consent")}),a.jsx("small",{children:f("audio-consent-help")})]})]}),a.jsxs("div",{className:"nc-set-form",children:[a.jsx("div",{className:"nc-sheet-label",children:f("audio-capability")}),a.jsxs("div",{className:"nc-set-info",children:[f("audio-adapter"),": ",i.adapter||f("audio-adapter-none"),a.jsx("br",{}),f("audio-installed"),": ",f(I?"audio-installed-yes":"audio-installed-no"),a.jsx("br",{}),f("audio-liveness"),": ",f(D?"audio-liveness-ready":"audio-liveness-unavailable"),Array.isArray(i.languages)&&i.languages.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("br",{}),f("audio-languages"),": ",i.languages.join(", ")]})]}),i.limits&&a.jsxs("small",{className:"nc-set-hint",children:[f("audio-limits"),": ",i.limits]})]}),!i.consent&&a.jsx("div",{className:"nc-set-info",children:f("audio-test-needs-consent")}),!I&&a.jsx("div",{className:"nc-set-info",children:f("audio-unavailable")}),a.jsxs("div",{className:"nc-set-row",children:[a.jsx("button",{type:"button",className:"nc-btn primary",disabled:e||g||!T,title:e?f("settings-readonly"):"",onClick:()=>{x()},children:f(g?"audio-testing":"audio-test")}),a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:g,onClick:()=>{W()},children:f(g?"audio-stopping":"audio-stop")}),a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:g,onClick:()=>{E()},children:f("refresh")})]}),a.jsxs("div",{className:"nc-set-form",children:[a.jsx("div",{className:"nc-sheet-label",children:f("audio-groups-title")}),a.jsx("small",{className:"nc-set-hint",children:f("audio-groups-help")}),c.length===0&&a.jsx("div",{className:"nc-set-info",children:f("audio-groups-empty")}),c.map(R=>{var M;return a.jsxs("div",{className:"nc-set-row",children:[a.jsxs("span",{children:[a.jsx("b",{children:R.name})," ",a.jsxs("small",{children:["· ",R.mode==="fanout"?f("audio-group-fanout"):f("audio-group-primary")," · ",((M=R.targets)==null?void 0:M.length)||0]})]}),a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||g,onClick:()=>V(R),children:f("audio-group-edit")}),a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||g,onClick:()=>{B(R.name)},children:f("audio-group-delete")})]},R.name)}),a.jsx("div",{className:"nc-set-row",children:a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||g,onClick:()=>V(null),children:f("audio-group-new")})}),a.jsxs("label",{className:"nc-field",children:[f("audio-group-name"),a.jsx("input",{"aria-label":f("audio-group-name"),value:h.name,maxLength:"32",disabled:e||g,onChange:R=>p(M=>({...M,name:R.target.value}))})]}),a.jsxs("label",{className:"nc-field",children:[f("audio-group-mode"),a.jsxs("select",{"aria-label":f("audio-group-mode"),value:h.mode,disabled:e||g,onChange:R=>p(M=>({...M,mode:R.target.value})),children:[a.jsx("option",{value:"primary-failover",children:f("audio-group-primary")}),a.jsx("option",{value:"fanout",children:f("audio-group-fanout")})]})]}),a.jsx("div",{className:"nc-set-info",children:f("audio-group-targets")}),$.length===0?a.jsx("small",{className:"nc-set-hint",children:f("audio-group-no-targets")}):$.map(R=>a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:h.targets.includes(R.id),disabled:e||g,onChange:M=>ie(R.id,M.target.checked)}),a.jsxs("span",{children:[R.label,a.jsx("small",{children:R.id})]})]},R.id)),a.jsxs("div",{className:"nc-set-row",children:[a.jsx("button",{type:"button",className:"nc-btn primary",disabled:e||g,onClick:()=>{K()},children:f("audio-group-save")}),v&&a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:g,onClick:()=>V(null),children:f("audio-group-cancel")})]})]})]}):a.jsx("div",{className:"nc-set-info",children:f("audio-loading")}),z&&a.jsx("div",{className:"nc-set-note",role:"status",children:z}),C&&a.jsx("div",{className:"nc-err",children:C})]})}function Z4(){const[t,e]=Jv(),[n,s]=y.useState(DE),[i,l]=y.useState(BE),[c,u]=y.useState($E);return a.jsxs("div",{className:"nc-set-tab nc-input-settings",children:[a.jsx("div",{className:"nc-set-info",children:f("input-settings-local")}),a.jsxs("div",{className:"nc-set-form",children:[a.jsxs("label",{className:"nc-field",children:[f("terminal-keyboard-gesture"),a.jsx("select",{"aria-label":f("terminal-keyboard-gesture"),value:t.terminalKeyboardGesture,onChange:h=>e({terminalKeyboardGesture:h.target.value}),children:qC.map(h=>a.jsx("option",{value:h,children:f(`terminal-keyboard-${h}`)},h))}),a.jsx("small",{children:f("terminal-keyboard-gesture-help")})]}),a.jsxs("label",{className:"nc-field",children:[f("keybar-layout"),a.jsx("select",{"aria-label":f("keybar-layout"),value:t.keybarLayout,onChange:h=>e({keybarLayout:h.target.value}),children:KC.map(h=>a.jsx("option",{value:h,children:f(`keybar-layout-${h}`)},h))}),a.jsx("small",{children:f("keybar-layout-help")})]})]}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:t.showComposer,onChange:h=>e({showComposer:h.target.checked})}),a.jsxs("span",{children:[a.jsx("b",{children:f("bar-menu-keyboard")}),a.jsx("small",{children:f("bar-menu-keyboard-desc")})]})]}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:n,onChange:h=>{s(h.target.checked),OE(h.target.checked)}}),a.jsxs("span",{children:[a.jsx("b",{children:f("bar-menu-files")}),a.jsx("small",{children:f("bar-menu-files-setting-desc")})]})]}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:i,onChange:h=>{l(h.target.checked),c4(h.target.checked)}}),a.jsxs("span",{children:[a.jsx("b",{children:f("bar-keyboard-button")}),a.jsx("small",{children:f("bar-keyboard-button-desc")})]})]}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:c,onChange:h=>{u(h.target.checked),u4(h.target.checked)}}),a.jsxs("span",{children:[a.jsx("b",{children:f("bar-panel-button")}),a.jsx("small",{children:f("bar-panel-button-desc")})]})]}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:t.keybarKeepsKeyboardClosed,onChange:h=>e({keybarKeepsKeyboardClosed:h.target.checked})}),a.jsxs("span",{children:[a.jsx("b",{children:f("keybar-ime-lock")}),a.jsx("small",{children:f("keybar-ime-lock-help")})]})]}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:t.voiceKeepsKeyboardClosed,onChange:h=>e({voiceKeepsKeyboardClosed:h.target.checked})}),a.jsxs("span",{children:[a.jsx("b",{children:f("voice-ime-lock")}),a.jsx("small",{children:f("voice-ime-lock-help")})]})]}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:t.showKeybarEnter,onChange:h=>e({showKeybarEnter:h.target.checked})}),a.jsxs("span",{children:[a.jsx("b",{children:f("keybar-enter-show")}),a.jsx("small",{children:f("keybar-enter-show-help")})]})]}),a.jsx("div",{className:"nc-set-row",children:a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>e(xr),children:f("input-settings-reset")})})]})}function eO({token:t,roster:e=[],readonly:n}){const s=[{key:"local",route:[],label:f("diagnostics-local"),status:"up"},...e.filter(T=>Array.isArray(T.route)&&T.route.length).map(T=>({key:T.route.join("/"),route:T.route,label:T.label||T.name,status:T.status}))],[i,l]=y.useState("local"),c=s.find(T=>T.key===i)||s[0],[u,h]=y.useState(null),[p,v]=y.useState([]),[_,g]=y.useState(""),[b,S]=y.useState(!1),[j,C]=y.useState(!0),[N,E]=y.useState(900),[O,x]=y.useState("all"),[W,$]=y.useState(""),J=y.useRef(0),q=y.useRef(null),V=y.useCallback(async()=>{try{const T=await z5(t,c.route);if(h(T),g(""),!b){const z=await F5(t,{after:J.current,limit:200},c.route);Array.isArray(z.records)&&z.records.length&&(J.current=z.cursor,v(R=>[...R,...z.records].slice(-500)))}}catch(T){g(T&&T.status===404?f("diagnostics-unsupported"):String(T.message||T))}},[t,c.key,b]);y.useEffect(()=>{J.current=0,v([]),h(null),g("")},[c.key]),y.useEffect(()=>{let T=null,z=!0;const R=()=>{!z||document.visibilityState==="hidden"||V()},M=()=>{T&&clearInterval(T),T=document.visibilityState==="hidden"?null:setInterval(R,2e3),document.visibilityState!=="hidden"&&R()};return document.addEventListener("visibilitychange",M),M(),()=>{z=!1,T&&clearInterval(T),document.removeEventListener("visibilitychange",M)}},[V]),y.useEffect(()=>{j&&q.current&&(q.current.scrollTop=q.current.scrollHeight)},[p,j]);const ie=p.filter(T=>(O==="all"||T.level===O)&&(!W||String(T.component||"").toLowerCase().includes(W.toLowerCase()))),K=ie.map(T=>`${T.ts} ${T.level.toUpperCase()} ${T.component} ${T.code} ${T.message}${Object.keys(T.meta||{}).length?` ${JSON.stringify(T.meta)}`:""}`).join(`
168
+ `),B=async T=>{g("");try{const z=await T();h(z),await V()}catch(z){g(String(z.message||z))}},I=async()=>{try{await navigator.clipboard.writeText(K)}catch{g(f("copy-manual"))}},D=()=>{try{const T=new Blob([`${JSON.stringify(ie,null,2)}
169
+ `],{type:"application/json"});PC(T,"nexuscrew-diagnostics.json")}catch{g(f("diagnostics-export-failed"))}};return a.jsxs("div",{className:"nc-set-tab nc-diagnostics",children:[a.jsxs("label",{className:"nc-field",children:[f("diagnostics-target"),a.jsx("select",{value:c.key,onChange:T=>l(T.target.value),children:s.map(T=>a.jsxs("option",{value:T.key,children:[T.label,T.status!=="up"?` · ${T.status}`:""]},T.key))})]}),a.jsxs("div",{className:"nc-set-form nc-diag-controls",children:[a.jsx("div",{className:"nc-sheet-label",children:f("diagnostics-verbose")}),a.jsxs("div",{className:"nc-set-row",children:[a.jsx("select",{"aria-label":f("diagnostics-duration"),value:N,onChange:T=>E(Number(T.target.value)),disabled:n,children:[300,900,1800,3600].map(T=>a.jsxs("option",{value:T,children:[T/60," min"]},T))}),a.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||(u==null?void 0:u.verbose)===!0,onClick:()=>B(()=>tb(t,!0,N,c.route)),children:f("enable")}),a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||(u==null?void 0:u.verbose)!==!0,onClick:()=>B(()=>tb(t,!1,N,c.route)),children:f("stop")})]}),a.jsx("small",{className:"nc-set-hint",children:u!=null&&u.verbose?f("diagnostics-expires").replace("{time}",new Date(u.expiresAt).toLocaleTimeString()):f("diagnostics-off")})]}),a.jsxs("div",{className:"nc-diag-filters",children:[a.jsxs("select",{"aria-label":f("diagnostics-level"),value:O,onChange:T=>x(T.target.value),children:[a.jsx("option",{value:"all",children:f("diagnostics-all-levels")}),["debug","info","warn","error"].map(T=>a.jsx("option",{value:T,children:T},T))]}),a.jsx("input",{"aria-label":f("diagnostics-component"),placeholder:f("diagnostics-component"),value:W,onChange:T=>$(T.target.value)})]}),a.jsxs("div",{className:"nc-set-row",children:[a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:b,onChange:T=>S(T.target.checked)})," ",f("diagnostics-pause")]}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:j,onChange:T=>C(T.target.checked)})," ",f("diagnostics-autoscroll")]})]}),a.jsx("pre",{ref:q,className:"nc-diag-log","aria-label":f("diagnostics-log"),children:K||f("diagnostics-empty")}),a.jsxs("div",{className:"nc-set-row",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:I,children:f("copy")}),a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:D,children:f("diagnostics-export")}),a.jsx("button",{type:"button",className:"nc-btn danger",disabled:n,onClick:()=>{window.confirm(f("diagnostics-clear-confirm"))&&B(async()=>{const T=await H5(t,c.route);return J.current=0,v([]),T})},children:f("diagnostics-clear")})]}),_&&a.jsx("div",{className:"nc-err",children:_})]})}function tO(){typeof window<"u"&&window.location&&typeof window.location.reload=="function"&&window.location.reload()}function nO({token:t,settings:e,readonly:n,refresh:s,roster:i,section:l,setSection:c}){const[u,h]=y.useState(Ac),[p,v]=y.useState(null),[_,g]=y.useState(null),[b,S]=y.useState(!1),[j,C]=y.useState(!1),[N,E]=y.useState(null),[O,x]=y.useState(!1),[W,$]=y.useState(!1),[J,q]=y.useState(null);y.useEffect(()=>{E(e&&e.update||null),x(!!(e&&e.autoUpdate===!0)),$(!!(e&&e.alternateScreen))},[e]);const V=async()=>{v(null),g(null),C(!0);try{const L=await S5(t);g(L.note||"ok"),S(!1)}catch(L){v(String(L.message||L))}C(!1)},ie=async()=>{v(null),g(null),C(!0);try{const L=await O5(t);g(`${L.note||"ok"}${L.target?` (${L.target})`:""}`)}catch(L){v(String(L.message||L))}C(!1)},K=async L=>{v(null),g(null),C(!0);try{await Pd(t,{autoUpdate:L}),x(L),s&&await s()}catch(H){v(String(H.message||H))}C(!1)},B=async L=>{v(null),g(null),C(!0);try{await Pd(t,{alternateScreen:L}),$(L),s&&await s()}catch(H){v(String(H.message||H))}C(!1)},I=y.useCallback(async()=>{if(t)try{q(await b5(t))}catch{q(null)}},[t]);y.useEffect(()=>{I()},[I]);const D=async L=>{v(null),g(null),C(!0);try{if(!L&&J&&J.running&&!window.confirm(f("ai-desktop-confirm-stop"))){C(!1);return}const H=await t1(t,L);H&&H.ok===!1&&v(H.error||"comando fallito"),await I(),s&&await s()}catch(H){v(String(H.message||H))}C(!1)},T=async()=>{v(null),g(null),C(!0);try{E(await B5(t))}catch(L){v(String(L.message||L))}C(!1)},z=async()=>{v(null),g(null),C(!0);try{const L=await $5(t);E(L),g(f("npm-update-restarting"))}catch(L){v(String(L.message||L))}C(!1)},R=()=>{window.confirm(f("composer-clear-confirm"))&&(v(null),xD()?(window.dispatchEvent(new Event(Fg)),g(f("composer-clear-done"))):v(f("composer-clear-failed")))},M=e&&e.service;return a.jsxs("div",{className:"nc-set-tab",children:[a.jsx("div",{className:"nc-system-tabs",role:"tablist","aria-label":f("tab-system"),children:["general","diagnostics"].map(L=>a.jsx("button",{type:"button",role:"tab","aria-selected":l===L,className:`nc-set-tabbtn${l===L?" on":""}`,onClick:()=>c(L),children:f(`system-${L}`)},L))}),l==="general"&&a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:"nc-system-group",children:[a.jsx("div",{className:"nc-set-info",children:f("input-settings-local")}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:u===fo,onChange:L=>{const H=Ok(L.target.checked?fo:po);h(H),tO()}}),a.jsxs("span",{children:[a.jsx("b",{children:f("bar-menu-renderer")}),a.jsx("small",{children:f("bar-menu-renderer-desc")})]})]})]}),a.jsxs("section",{className:"nc-system-group",children:[a.jsx("h3",{children:f("system-this-node")}),e&&a.jsxs("div",{className:"nc-set-info",children:["v",e.version," · ",e.platform," · :",e.port,a.jsx("br",{}),M&&M.installed?f("service-installed"):f("service-missing"),M&&M.installed?` · ${M.active?f("service-active"):f("service-inactive")}`:"",M?` · boot ${M.boot?"on":"off"}`:""]}),a.jsx("div",{className:"nc-set-row",children:a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||j,title:n?f("settings-readonly"):"",onClick:ie,children:f("service-regenerate")})}),a.jsx(X4,{token:t,readonly:n}),a.jsx(J4,{})]}),a.jsxs("section",{className:"nc-system-group",children:[a.jsx("h3",{children:f("system-updates")}),a.jsxs("div",{className:"nc-set-form nc-update-settings",children:[a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox",checked:O,disabled:n||j||N&&!N.supported,onChange:L=>K(L.target.checked)}),a.jsxs("span",{children:[a.jsx("b",{children:f("npm-auto-update")}),a.jsx("small",{children:f("npm-auto-update-help")})]})]}),N&&a.jsxs("div",{className:"nc-set-info",children:[f("npm-update-current")," v",N.current,N.latest?` · ${f("npm-update-latest")} v${N.latest}`:""," · ",f(N.supported?N.phase==="idle"&&N.checked!==!0?"npm-update-never":`npm-update-${N.phase}`:"unsupported")]}),a.jsxs("div",{className:"nc-set-row",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||j||!N||!N.supported,onClick:T,children:f("npm-update-check")}),N&&N.available&&a.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||j||N.phase==="installing",onClick:z,children:f("npm-update-install")})]}),N&&N.lastError&&a.jsx("div",{className:"nc-err",children:N.lastError})]})]}),a.jsxs("section",{className:"nc-system-group",children:[a.jsx("h3",{children:f("ai-desktop-title")}),a.jsxs("div",{className:"nc-set-form",children:[a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox","aria-label":f("ai-desktop"),disabled:n||j,checked:!!(J&&J.desired),onChange:L=>D(L.target.checked)}),a.jsxs("span",{children:[a.jsx("b",{children:f("ai-desktop")}),a.jsx("small",{children:f("ai-desktop-help")})]})]}),J&&!J.desired&&J.running&&a.jsx("div",{className:"nc-set-info",children:f("ai-desktop-stop-pending")})]})]}),a.jsxs("section",{className:"nc-system-group",children:[a.jsx("h3",{children:f("system-security")}),a.jsx("div",{className:"nc-set-row",children:a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||j,title:n?f("settings-readonly"):"",onClick:()=>{v(null),g(null),S(!0)},children:f("token-rotate")})})]}),a.jsxs("section",{className:"nc-system-group",children:[a.jsx("h3",{children:f("system-local-data")}),a.jsxs("div",{className:"nc-set-form",children:[a.jsx("div",{className:"nc-sheet-label",children:f("composer-clear-data")}),a.jsx("small",{className:"nc-set-hint",children:f("composer-clear-data-help")}),a.jsx("div",{className:"nc-set-row",children:a.jsx("button",{type:"button",className:"nc-btn ghost",onClick:R,children:f("composer-clear-data")})})]})]})]}),l==="diagnostics"&&a.jsxs("section",{className:"nc-system-group nc-system-diagnostics",children:[a.jsx("h3",{children:f("system-diagnostics")}),a.jsxs("div",{className:"nc-set-form nc-alternate-screen-settings",children:[a.jsx("div",{className:"nc-sheet-label",children:f("system-terminal")}),a.jsxs("label",{className:"nc-check",children:[a.jsx("input",{type:"checkbox","aria-label":f("alternate-screen"),checked:W,disabled:n||j,onChange:L=>B(L.target.checked)}),a.jsxs("span",{children:[a.jsx("b",{children:f("alternate-screen")}),a.jsx("small",{children:f("alternate-screen-help")})]})]})]}),a.jsx(K4,{token:t}),a.jsx(R4,{}),a.jsx(eO,{token:t,roster:i,readonly:n})]}),b&&a.jsxs("div",{className:"nc-set-confirm",children:[a.jsx("div",{children:f("token-rotate-explain")}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:j,onClick:()=>S(!1),children:f("cancel")}),a.jsx("button",{type:"button",className:"nc-btn primary",disabled:j,onClick:V,children:f("confirm")})]})]}),_&&a.jsx("div",{className:"nc-set-note",children:_}),p&&a.jsx("div",{className:"nc-err",children:p})]})}function sO({token:t,onClose:e,initialTab:n="nodes",initialLocation:s="",startNewCell:i=!1}){zn();const l=n==="diagnostics"?"diagnostics":"general",[c,u]=y.useState(n==="diagnostics"?"system":n),h=y.useRef(null),p=y.useRef(null),[v,_]=y.useState({start:!1,end:!1}),[g,b]=y.useState(l),[S,j]=y.useState(null),[C,N]=y.useState([]),[E,O]=y.useState(null),[x,W]=y.useState([]),[$,J]=y.useState(!1),[q,V]=y.useState(null),[ie,K]=y.useState(0),B=Bv(t,!0,ie),I=y.useCallback(()=>{const A=h.current;if(!A)return;const U=A.scrollWidth>A.clientWidth+1,Q={start:U&&A.scrollLeft>1,end:U&&A.scrollLeft+A.clientWidth<A.scrollWidth-1};_(ae=>ae.start===Q.start&&ae.end===Q.end?ae:Q)},[]);y.useEffect(()=>{const A=h.current;if(!A)return;const U=typeof ResizeObserver=="function"?new ResizeObserver(I):null;return U==null||U.observe(A),window.addEventListener("resize",I),I(),()=>{U==null||U.disconnect(),window.removeEventListener("resize",I)}},[I]),y.useEffect(()=>{var U,Q;(Q=(U=p.current)==null?void 0:U.scrollIntoView)==null||Q.call(U,{behavior:"smooth",block:"nearest",inline:"nearest"});const A=window.requestAnimationFrame?window.requestAnimationFrame(I):setTimeout(I,0);return()=>{window.cancelAnimationFrame?window.cancelAnimationFrame(A):clearTimeout(A)}},[c,I]);const D=y.useRef(uh()),T=y.useRef(null),z=y.useRef([]),R=y.useRef(new Map),M=y.useRef({token:null,instanceId:null}),L=y.useCallback((A,U)=>{if(!A.isCurrent(U))return;const Q=z.current,ae=[],re=new Set;for(const je of R.current.values())for(const te of je){const ne=Array.isArray(te.route)&&te.route.length?te.route.join("/"):"local",me=`${te.ownerInstanceId}:${ne}:${te.nodeId||te.name||te.label||""}`;re.has(me)||(re.add(me),ae.push(te))}N([...Q,...ae])},[]),H=y.useCallback(async()=>{const A=D.current,U=A.begin();if(U===null)return;const Q=new AbortController;T.current=Q;const ae={timeoutMs:qx,signal:Q.signal};try{const re=Qx(t,ae).then(ne=>{A.isCurrent(U)&&(j(ne),V(null))}).catch(ne=>{A.isCurrent(U)&&V(String((ne==null?void 0:ne.message)||ne))}),je=y5(t,ae).then(ne=>{if(!A.isCurrent(U))return;const me=ne.peers||[];z.current=me,O(Number.isInteger(ne.accessRevision)?ne.accessRevision:null),L(A,U)}).catch(ne=>{A.isCurrent(U)&&V(String((ne==null?void 0:ne.message)||ne))}),te=(async()=>{const[ne,me]=await Promise.all([qc(t,[],ae).then(X=>X).catch(()=>null),e1(t,ae).then(X=>X).catch(()=>null)]);if(!A.isCurrent(U))return;const we=ne&&typeof ne.instanceId=="string"?ne.instanceId:"";if(!we)return;M.current.instanceId!==we&&(R.current.clear(),M.current.instanceId=we);const Fe=[{instanceId:we||null,route:[],label:null},...Xk(me,we)],Ae=X=>`${X.instanceId}:${X.route.join("/")}`;if(me){const X=new Set(Fe.map(Ae));for(const ce of R.current.keys())X.has(ce)||R.current.delete(ce)}if(!me)for(const[X,ce]of R.current)ce.some(Z=>Z.route.length)&&R.current.set(X,ce.map(Z=>({...Z,stale:!0,online:!1,canManage:!1,capabilities:[]})));const He=new Map;W([]),L(A,U),await Promise.allSettled(Fe.map(async X=>{const ce=Ae(X);try{const Z=await Zx(t,X.route,{signal:Q.signal});if(!A.isCurrent(U))return;const ge=(Z.nodes||[]).map(Y=>Gk(Y,X)).filter(Boolean);R.current.set(ce,ge),He.delete(ce)}catch(Z){if(!A.isCurrent(U))return;if((Z==null?void 0:Z.status)===403||(Z==null?void 0:Z.status)===404)R.current.delete(ce);else{const Y=R.current.get(ce);Y&&R.current.set(ce,Y.map(he=>({...he,stale:!0,online:!1,canManage:!1,capabilities:[]})))}X.route.length>0&&He.set(ce,{instanceId:X.instanceId,label:X.label,route:X.route,failure:/timeout/i.test(String((Z==null?void 0:Z.message)||Z))?"timeout":"unreachable"})}A.isCurrent(U)&&(W([...He.values()]),L(A,U))}))})();await Promise.allSettled([re,je,te])}finally{T.current===Q&&(T.current=null),A.end(U)}},[t,L]);return y.useEffect(()=>{M.current.token!==t&&(M.current={token:t,instanceId:null},z.current=[],R.current.clear(),N([]),W([]),O(null)),H();const A=setInterval(H,5e3);return()=>{clearInterval(A),D.current.reset(),T.current&&T.current.abort()}},[H]),y.useEffect(()=>{let A=!1;return qn("/api/config",t).then(U=>U.json()).then(U=>{A||J(!!U.readonlyDefault)}).catch(()=>{}),()=>{A=!0}},[t]),a.jsx("div",{className:"nc-set-overlay",onClick:e,children:a.jsxs("div",{className:"nc-set-panel",onClick:A=>A.stopPropagation(),children:[a.jsxs("div",{className:"nc-set-head",children:[a.jsx(_t,{name:"gear",size:18}),a.jsx("b",{children:f("settings")}),a.jsx("button",{type:"button",className:"nc-set-close",onClick:e,title:f("close"),children:a.jsx(_t,{name:"x",size:18})})]}),$&&a.jsx("div",{className:"nc-set-readonly",children:f("settings-readonly")}),q&&a.jsx("div",{className:"nc-err",children:q}),a.jsx("div",{className:`nc-set-tabs-wrap${v.start?" has-start-overflow":""}${v.end?" has-end-overflow":""}`,children:a.jsx("div",{className:"nc-set-tabs",ref:h,onScroll:I,children:["nodes","fleet","audio","input","system"].map(A=>a.jsx("button",{ref:c===A?p:null,type:"button",className:`nc-set-tabbtn${c===A?" on":""}`,onClick:()=>u(A),children:f(`tab-${A}`)},A))})}),a.jsxs("div",{className:"nc-set-body",children:[c==="nodes"&&a.jsx(G4,{token:t,nodes:C,roster:B,settings:S,readonly:$,vlUnavailable:x,accessRevision:E,refresh:H,refreshAliases:()=>K(A=>A+1)}),c==="fleet"&&a.jsx(l4,{token:t,readonly:$,startNewCell:i,initialLocation:s,targets:B.map(A=>({route:A.route,label:A.label||A.name,status:A.status}))}),c==="audio"&&a.jsx(Q4,{token:t,readonly:$,nodes:C,settings:S}),c==="input"&&a.jsx(Z4,{}),c==="system"&&a.jsx(nO,{token:t,settings:S,readonly:$,refresh:H,roster:B,section:g,setSection:b})]})]})})}function iO({token:t,initialPair:e,deviceDefault:n="",localNodeId:s="",localNameDefault:i="",deviceNameNeeded:l=!1,deviceNameSuggestion:c="",onPairDone:u,onDone:h}){zn();const[p,v]=y.useState(e?"pair":"welcome"),[_,g]=y.useState(!1),[b,S]=y.useState(null),[j,C]=y.useState(c||""),[N,E]=y.useState(null),O=async()=>{g(!0),S(null);try{const x={wizardDone:!0};l&&j.trim()&&(x.deviceName=j.trim()),await Pd(t,x),u&&u(),h()}catch(x){S(String(x.message||x)),g(!1)}};return a.jsx("div",{className:"nc-wiz-overlay",children:a.jsxs("div",{className:"nc-wiz",children:[a.jsxs("div",{className:"nc-wiz-head",children:[a.jsx("b",{children:f("wizard-title")}),a.jsx("small",{children:f("hydra-simple")})]}),p==="welcome"&&a.jsxs("div",{className:"nc-wiz-body",children:[a.jsx("div",{className:"nc-wiz-done",children:f("local-ready")}),l&&a.jsx("div",{className:"nc-wiz-done",children:f("wizard-device-name")}),l&&a.jsxs("label",{className:"nc-field",children:[a.jsx("span",{children:f("device-name-label")}),a.jsx("input",{value:j,onChange:x=>C(x.target.value),maxLength:64,"data-testid":"wizard-device-name-input"})]}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{className:"nc-btn ghost",disabled:_,onClick:O,children:f("local-only")}),a.jsx("button",{className:"nc-btn primary",disabled:_,onClick:()=>v("pair"),children:f("add-node")})]})]}),p==="pair"&&a.jsxs("div",{className:"nc-wiz-body",children:[a.jsx(pE,{token:t,initial:e||"",autoStart:!!e,deviceDefault:l&&j.trim()?j.trim():n,localNodeId:s,localNameDefault:i,onBusyChange:g,onSuccess:async x=>{E(x&&x.authorizedKeys?{line:x.authorizedKeys,note:x.authorizedKeysNote||""}:null),u&&u(),v("done")}}),a.jsx("div",{className:"nc-sheet-actions",children:a.jsx("button",{className:"nc-btn ghost",disabled:_,onClick:()=>{u&&u(),v("welcome")},children:f("back")})})]}),p==="done"&&a.jsxs("div",{className:"nc-wiz-body",children:[a.jsx("div",{className:"nc-wiz-done",children:f("node-connected")}),N&&a.jsx(o_,{line:N.line,note:N.note}),a.jsx("div",{className:"nc-sheet-actions",children:a.jsx("button",{className:"nc-btn primary",disabled:_,onClick:O,children:f("finish")})})]}),b&&a.jsx("div",{className:"nc-err",children:b})]})})}function rO({token:t,suggestion:e="",onSaved:n,onLater:s}){zn();const[i,l]=y.useState(e||""),[c,u]=y.useState(!1),[h,p]=y.useState(null),v=async()=>{const _=i.trim();if(_){u(!0),p(null);try{await Pd(t,{deviceName:_}),n&&n(_)}catch(g){p(String(g.message||g)),u(!1)}}};return a.jsx("div",{className:"nc-wiz-overlay",role:"dialog","aria-label":f("device-name-ask-title"),"data-testid":"device-name-ask",children:a.jsxs("div",{className:"nc-wiz",children:[a.jsx("div",{className:"nc-wiz-head",children:a.jsx("b",{children:f("device-name-ask-title")})}),a.jsxs("div",{className:"nc-wiz-body",children:[a.jsx("p",{className:"nc-wiz-done",children:f("device-name-ask-text")}),a.jsxs("label",{className:"nc-field",children:[a.jsx("span",{children:f("device-name-label")}),a.jsx("input",{value:i,onChange:_=>l(_.target.value),maxLength:64,"data-testid":"device-name-input"})]}),a.jsxs("div",{className:"nc-sheet-actions",children:[a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c,onClick:s,children:f("device-name-later")}),a.jsx("button",{type:"button",className:"nc-btn primary",disabled:c||!i.trim(),onClick:v,children:f("device-name-save")})]})]}),h&&a.jsx("div",{className:"nc-err",children:h})]})})}const oO=50;function aO(t){if(Number.isFinite(t))return t;const e=typeof t=="string"?Date.parse(t):NaN;return Number.isFinite(e)?e:0}function ZE(t,e){return`${String(t)}|${String(e)}`}function Sx(t,e){if(!t||typeof t!="object")return null;const n=t.frame&&typeof t.frame=="object"?t.frame:t;if(n.type!=="notify"||!t.eventId||typeof n.askId=="string"&&n.askId)return null;const s=typeof n.title=="string"?n.title:"",i=typeof n.body=="string"?n.body:"";return!s&&!i?null:{key:ZE(e,t.eventId),ownerId:String(e),eventId:String(t.eventId),title:s,body:i,urgency:n.urgency==="high"?"high":"normal",ts:aO(t.emittedAt??(t.frame&&t.frame.ts)??t.ts),arrivalSeq:0}}function xx(t){return[...t].sort((e,n)=>n.ts-e.ts).slice(0,oO)}function kx(t,e,n,s=null){const i=new Set((e||[]).map(c=>c&&c.key)),l=new Map;for(const c of t||[])s&&s.owners.has(c.ownerId)&&!i.has(c.key)&&!s.arrivedAfter(c)||(!n||n.has(c.ownerId))&&l.set(c.key,c);for(const c of e||[])c&&l.set(c.key,c);return[...l.values()]}function lO(t,e,n,s){if(typeof EventSource>"u"||!t)return()=>{};const i=new EventSource(`/api/events?token=${encodeURIComponent(t)}`);return i.onopen=()=>{typeof n=="function"&&n()},i.onerror=()=>{typeof s=="function"&&s()},i.onmessage=l=>{try{const c=JSON.parse(l.data);c&&typeof c=="object"&&typeof c.type=="string"&&e(c)}catch{}},()=>{try{i.close()}catch{}}}const cO=6e3,uO=12e3,ns=(t,e,n)=>`${e||""}:${n||t}`,dO=(t,e)=>{const n=t&&t[e];return n?n.stale===!0||n.error===!0?"degraded":"live":"missing"},e2=600*1e3,Cx=30*1e3,hO=300*1e3,tv=new Map,fO=900*1e3,Ha=new Map;function wm(t){Ha.set(t,Date.now()),Ha.size>4096&&Ha.delete(Ha.keys().next().value)}function bm(t){const e=Ha.get(t);return e===void 0?!1:Date.now()-e>fO?(Ha.delete(t),!1):!0}const pO={pending:"ask-dismiss-local-pending",blocked:"ask-dismiss-local-blocked"},mO=t=>pO[t]||t,Ko=t=>Object.hasOwn(t,"ownerAskTs")?t.ownerAskTs:t.ownerAskId||t.originNode?null:t.ts;function t2(t,e){tv.set(t,e?{at:Date.now(),local:!0,ts:Ko(e),fingerprint:e.question===void 0?null:JSON.stringify([e.question,e.options||[],e.session])}:{at:Date.now()})}function n2(t){const e=ns(t.id,t.ownerId,t.ownerAskId),n=tv.get(e);if(n===void 0)return!1;if(n.local){const s=Ko(t);return!(n.ts&&s&&n.ts!==s)&&(n.fingerprint===null||n.fingerprint===JSON.stringify([t.question,t.options||[],t.session]))}return Date.now()-n.at>e2?(tv.delete(e),!1):!0}function Td(t,e){const n=new Map(t.map(s=>[ns(s.id,s.ownerId,s.ownerAskId),s]));for(const s of e||[]){if(!s||!s.id||n2(s))continue;const i=ns(s.id,s.ownerId,s.ownerAskId),l=n.get(i),c=Ko(s),u=l&&Ko(l);(!l||Number.isSafeInteger(c)&&c>0&&Number.isSafeInteger(u)&&u>0&&c>u)&&n.set(i,s)}return[...n.values()]}function gO(t,e){const n=Td([],t.filter(l=>l.imported)),s=new Set(n.map(l=>ns(l.id,l.ownerId,l.ownerAskId)));return[...(e||[]).filter(l=>l&&l.id&&!s.has(ns(l.id,l.ownerId,l.ownerAskId))&&!n2(l)),...n]}function vO({n:t,onClose:e}){return a.jsxs("div",{className:`nc-ntf-toast${t.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[a.jsxs("div",{className:"nc-ntf-toast-txt",children:[a.jsx("b",{children:t.title}),t.body&&a.jsx("small",{children:t.body}),t.session&&a.jsx("span",{className:"nc-ntf-from",children:t.session}),t.ownerId&&a.jsx("span",{className:"nc-ntf-from",children:f("feed-owner")})]}),a.jsx("button",{type:"button",className:"nc-ntf-x",onClick:e,title:f("close"),children:a.jsx(_t,{name:"x",size:14})})]})}function _O({ask:t,token:e,onAnswered:n,onDismiss:s,askReplyAccess:i=!1,feedViewState:l="live",initialUncertainRid:c=null,canDismissLocal:u=!1,canDismissRemote:h=!1,capabilityStatus:p="loading",onRefused:v=()=>{}}){const[_,g]=y.useState(""),[b,S]=y.useState(!1),[j,C]=y.useState(null),[N,E]=y.useState(!1),[O,x]=y.useState(c),[W,$]=y.useState(!1),[J,q]=y.useState(!1),V=y.useRef(null);y.useEffect(()=>{c&&x(c)},[c]);const ie=N||b||!!O||J||!!t.ownerId&&p==="loading",K=!!t.ownerId&&!h,B=async T=>{const z=String(T||"").trim();if(!(!z||b||N||O||J)){C(null),S(!0);try{if(t.ownerId){const R=t.ownerAskId||t.id,M=await K5(e,{ownerId:t.ownerId,askId:R,text:z,requestId:V.current||(V.current=crypto.randomUUID())});if(M&&M.uncertain){const L=M.reason==="delivery-unknown-block"&&!M.originalRequestId;x(L?null:M.originalRequestId||M.requestId||V.current),q(L);return}if(!M||M.status!=="committed"){V.current=null,v(),C(f("ask-reconcile"));return}n(t.id,t.ownerId,t.ownerAskId)}else await W5(e,t.id,z),n(t.id)}catch(R){C(String(R.message||R)),t.ownerId&&!R.status?x(V.current):V.current=null,v()}finally{S(!1)}}},I=async()=>{if(!ie){C(null),E(!0);try{let T;if(K){if(T=await J5(e,{ownerId:t.ownerId,askId:t.ownerAskId||t.id}),(T==null?void 0:T.dismissed)!==!0||T.scope!=="local"||!["pending","blocked"].includes(T.ownerSync))throw new Error(f("ask-dismiss-unconfirmed"))}else t.ownerId?await X5(e,{ownerId:t.ownerId,askId:t.ownerAskId||t.id}):await q5(e,t.id);t2(ns(t.id,t.ownerId,t.ownerAskId),K?t:null),s(t.id,t.ownerId,t.ownerAskId,T)}catch(T){C(String(T&&T.message||T)),v()}finally{E(!1)}}},D=f(O||J?"ask-uncertain":K?"ask-dismiss-local":l==="degraded"?"ask-dismiss-stale":"ask-dismiss");return a.jsxs("div",{className:"nc-ask-card",children:[a.jsxs("div",{className:"nc-ask-head",children:[a.jsx("span",{className:"nc-ntf-from",children:t.session}),t.ownerId&&a.jsx("span",{className:"nc-ntf-from",children:f("feed-owner")}),a.jsxs("code",{className:"nc-ask-id",children:["#",t.id]}),a.jsx("button",{type:"button",className:"nc-ask-dismiss",title:D,"aria-label":D,disabled:ie,onClick:I,children:a.jsx(_t,{name:"x",size:14})})]}),a.jsx("div",{className:"nc-ask-q",children:t.question}),t.ownerId&&i===!1&&a.jsx("small",{className:"nc-set-hint",children:f(p==="loading"?"ask-capability-loading":p==="unsupported"?"ask-capability-unsupported":p==="unreachable"?"ask-capability-unreachable":"ask-remote-readonly")}),t.ownerId&&i!==!1&&l==="degraded"&&a.jsx("small",{className:"nc-set-hint",children:f("ask-feed-stale")}),(O||J)&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"nc-err",children:f("ask-uncertain")}),J&&!O&&a.jsx("div",{className:"nc-err",children:f("ask-reconcile")}),O&&a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:W,onClick:async()=>{$(!0);try{const T=await V5(e,{ownerId:t.ownerId,askId:t.ownerAskId||t.id,requestId:O});(T==null?void 0:T.state)==="committed"?n(t.id,t.ownerId,t.ownerAskId):(T==null?void 0:T.state)==="failed"&&(x(null),V.current=null,v())}catch(T){C(String(T.message||T)),v()}finally{$(!1)}},children:f("ask-verify")})]}),(!t.ownerId||i===!0)&&!O&&!J&&a.jsxs(a.Fragment,{children:[Array.isArray(t.options)&&t.options.length>0&&a.jsx("div",{className:"nc-ask-opts",children:t.options.map(T=>a.jsx("button",{type:"button",className:"nc-btn ghost",disabled:b||N,onClick:()=>B(T),children:T},T))}),a.jsxs("div",{className:"nc-ask-reply",children:[a.jsx("textarea",{rows:2,placeholder:f("ask-reply-ph"),value:_,disabled:b||N,onChange:T=>g(T.target.value)}),a.jsx("button",{type:"button",className:"nc-btn primary",disabled:b||N||!_.trim(),onClick:()=>B(_),children:f("send")})]})]}),j&&a.jsx("div",{className:"nc-err",children:j})]})}function yO({token:t}){const[e]=zn(),[n]=qE(),[s,i]=y.useState([]),[l,c]=y.useState([]),[u,h]=y.useState(null),[p,v]=y.useState([]),[_,g]=y.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),[b,S]=y.useState({}),j=y.useRef(new Map),C=y.useRef(0),[N,E]=y.useState(0),O=y.useRef(new Map),x=y.useRef(0),W=y.useRef(0),$=y.useRef(new Map),J=y.useRef(new Map),q=y.useRef(new Map),V=te=>(te||[]).filter(ne=>{const me=O.current.get(ns(ne.id,ne.ownerId,ne.ownerAskId));if(!me)return!0;if(Date.now()-me.at>e2)return O.current.delete(ns(ne.id,ne.ownerId,ne.ownerAskId)),!0;const we=Ko(ne);return Number.isSafeInteger(we)&&we>0&&Number.isSafeInteger(me.ts)&&me.ts>0?we!==me.ts:me.fingerprint!==null&&me.fingerprint!==void 0&&me.fingerprint!==JSON.stringify([ne.question,ne.options||[],ne.session])}),ie=y.useRef(l);ie.current=l;const K=y.useCallback((te=!1)=>{if(!t)return;const ne=new Set;for(const me of ie.current){if(!me.ownerId)continue;const we=me.ownerAskId||me.id,Fe=`${me.ownerId}|${we}`;ne.add(Fe);const Ae=j.current.get(Fe);if(Ae&&(!te||Ae.pending))continue;const He=new AbortController,X=C.current,ce={controller:He,pending:!0};j.current.set(Fe,ce),S(Z=>({...Z,[Fe]:{canReply:!1,status:"loading"}})),Y5(t,{ownerId:me.ownerId,askId:we},{signal:He.signal}).then(Z=>{if(X!==C.current||He.signal.aborted||j.current.get(Fe)!==ce)return;const ge=Z&&Z.ownerId===me.ownerId&&Z.askId===we&&typeof Z.canReply=="boolean"&&(!Z.canReply||Z.status==="open");S(Y=>({...Y,[Fe]:ge?Z:{canReply:!1,status:"unreachable"}}))}).catch(()=>{X===C.current&&!He.signal.aborted&&j.current.get(Fe)===ce&&S(Z=>({...Z,[Fe]:{canReply:!1,status:"unreachable"}}))}).finally(()=>{ce.pending=!1})}for(const[me,we]of j.current)ne.has(me)||(we.controller.abort(),j.current.delete(me))},[t]);y.useEffect(()=>{C.current++;for(const te of j.current.values())te.controller.abort();return j.current.clear(),S({}),()=>{C.current++;for(const te of j.current.values())te.controller.abort();j.current.clear()}},[t]),y.useEffect(()=>{K()},[l,K]);const B=y.useRef(!1);y.useEffect(()=>{_&&(B.current&&K(!0),B.current=!0)},[_,K]);const I=y.useRef(0),D=y.useRef(null);D.current||(D.current=E4());const T=y.useRef({enabled:n,lang:e});T.current={enabled:n,lang:e};const z=y.useCallback(te=>{i(ne=>ne.filter(me=>me.key!==te))},[]),R=y.useCallback(te=>{if(te.askId&&te.ownerId){const we=Number.isSafeInteger(te.ownerAskTs)&&te.ownerAskTs>0?te.ownerAskTs:te.ownerAskFingerprint;if(we){const Fe=JSON.stringify([te.ownerId,te.ownerAskId||te.askId,we]),Ae=Date.now();for(const[He,X]of q.current)Ae-X>1440*60*1e3&&q.current.delete(He);if(q.current.has(Fe))return;q.current.set(Fe,Ae),q.current.size>4096&&q.current.delete(q.current.keys().next().value)}}const ne=`t${I.current+=1}`;i(we=>[...we.slice(-3),{...te,key:ne}]),setTimeout(()=>z(ne),te.urgency==="high"?uO:cO);const me=T.current;if(me.enabled)try{D.current.enqueue(te,b4(te,me.lang))}catch{}},[z]);y.useEffect(()=>{n||D.current.stop()},[n]),y.useEffect(()=>{const te=()=>{(document.visibilityState!=="visible"||!document.hasFocus())&&D.current.stop()},ne=()=>D.current.stop();return document.addEventListener("visibilitychange",te),window.addEventListener("blur",te),window.addEventListener(Vg,ne),()=>{document.removeEventListener("visibilitychange",te),window.removeEventListener("blur",te),window.removeEventListener(Vg,ne),typeof D.current.dispose=="function"?D.current.dispose():D.current.stop()}},[]);const M=te=>{if(te.ownerAskId||!te.ownerId)return te;const ne=ie.current.filter(we=>we.ownerId===te.ownerId&&(we.id===te.id||we.ownerAskId===te.id)),me=new Set(ne.map(we=>we.ownerAskId||we.id));return me.size>1?null:{...te,ownerAskId:me.size===1?[...me][0]:te.id}},L=(te,ne)=>{const me=ie.current.find(Fe=>ns(Fe.id,Fe.ownerId,Fe.ownerAskId)===te),we=me&&Ko(me);return Number.isSafeInteger(ne==null?void 0:ne.ownerAskTs)&&ne.ownerAskTs>0&&Number.isSafeInteger(we)&&we>0&&ne.ownerAskTs!==we},H=(te,ne,me,we)=>{const Fe=ns(te,ne,me);(we==null?void 0:we.scope)==="local"&&["pending","blocked"].includes(we.ownerSync)&&h(we.ownerSync);const Ae=ie.current.find(ce=>ns(ce.id,ce.ownerId,ce.ownerAskId)===Fe),He=Ae&&Ko(Ae);if(L(Fe,we))return;const X=Ae||(we==null?void 0:we.askGeneration);O.current.set(Fe,{at:Date.now(),ts:Ae?He:we==null?void 0:we.ownerAskTs,fingerprint:X&&X.question!==void 0?JSON.stringify([X.question,X.options||[],X.session]):null}),$.current.delete(Fe),O.current.size>4096&&O.current.delete(O.current.keys().next().value),c(ce=>ce.filter(Z=>ns(Z.id,Z.ownerId,Z.ownerAskId)!==Fe))},A=async te=>{h(null);try{const ne=await Z5(t,{ownerId:te.ownerId,eventId:te.eventId});if(!ne||ne.dismissed!==!0)throw new Error(f("remote-notices-dismiss-failed"));(ne.ownerSync==="pending"||ne.ownerSync==="blocked")&&h(ne.ownerSync),wm(te.key),v(me=>me.filter(we=>we.key!==te.key))}catch{h("remote-notices-dismiss-failed")}},U=async()=>{const te=p,ne=[...new Set(te.map(me=>me.ownerId))];if(ne.length!==0){h(null);try{const me=await ej(t,{owners:ne}),we=me&&me.results||{},Fe=new Set;let Ae=null;for(const He of ne){const X=we[He];if(!X||X.failed){Ae!=="blocked"&&(Ae="failed");continue}X.blocked?Ae="blocked":X.pending&&Ae!=="blocked"&&Ae!=="failed"&&(Ae="pending"),Fe.add(He)}for(const He of te)Fe.has(He.ownerId)&&wm(He.key);v(He=>He.filter(X=>!Fe.has(X.ownerId))),Ae==="blocked"?h("blocked"):Ae==="failed"?h("remote-notices-clear-failed"):Ae==="pending"&&h("pending")}catch{h("remote-notices-clear-failed")}}};y.useEffect(()=>{if(!t)return;let te=!0,ne=!1,me=null,we=Cx;const Fe=()=>{me!==null&&clearTimeout(me),me=null},Ae=()=>{!te||ne||me!==null||(me=setTimeout(()=>{me=null,!(!te||ne)&&(E(X=>X+1),we=Math.min(we*2,hO),Ae())},we))},He=lO(t,X=>{if(te){if(X.type==="feed-state-changed"){E(ce=>ce+1);return}if(X.type==="notify"&&X.ownerId&&X.eventId){const ce=Sx(X,X.ownerId);ce&&(ce.arrivalSeq=++W.current),ce&&!bm(ce.key)&&v(Z=>xx(kx(Z,[ce],null)))}if(X.type==="notify-dismissed"){const ce=String(X.ownerId||""),Z=String(X.eventId||"");if(ce&&Z){const ge=ZE(ce,Z);wm(ge),v(Y=>Y.filter(he=>he.key!==ge))}return}if(X.type==="notify")R(X);else if(X.type==="ask"&&X.ask&&X.ask.id){const ce=ns(X.ask.id,X.ask.ownerId,X.ask.ownerAskId);$.current.set(ce,++x.current),$.current.size>4096&&$.current.delete($.current.keys().next().value),c(Z=>Td(Z,V([X.ask])))}else if(X.type==="ask-answered"&&X.id){const ce=M(X);ce&&H(ce.id,ce.ownerId,ce.ownerAskId,X)}else if(X.type==="ask-dismissed"&&(X.id||X.ownerAskId)){const ce=M(X);if(!ce)return;const Z=ns(ce.id,ce.ownerId,ce.ownerAskId);if(L(Z,X))return;const ge=X.scope==="local"&&ie.current.find(Y=>ns(Y.id,Y.ownerId,Y.ownerAskId)===Z);t2(Z,X.scope==="local"?ge||{...X.askGeneration,ownerAskTs:X.ownerAskTs}:null),H(ce.id,ce.ownerId,ce.ownerAskId,X)}}},()=>{te&&(ne=!0,we=Cx,Fe(),K(!0),E(X=>X+1))},()=>{te&&(ne=!1,Ae())});return Ae(),()=>{te=!1,Fe(),He()}},[t,R,K]),y.useEffect(()=>{let te=!0;const ne=x.current;return t&&U5(t).then(me=>{te&&c(we=>Td(gO(we,V((me.asks||[]).filter(Fe=>!Fe.ownerId||(J.current.get(Fe.ownerId)||0)<=ne))),V(we.filter(Fe=>($.current.get(ns(Fe.id,Fe.ownerId,Fe.ownerAskId))||0)>ne))))}).catch(()=>{}),()=>{te=!1}},[t,N]);const[Q,ae]=y.useState({});y.useEffect(()=>{if(!t)return;let te=!0;return G5(t).then(ne=>{if(!te)return;const me={};for(const we of ne&&ne.attempts||[])we&&we.state==="uncertain"&&we.ownerId&&we.askId&&we.requestId&&(me[we.ownerId+"|"+we.askId]=we.requestId);ae(me)}).catch(()=>{}),()=>{te=!1}},[t]);const[re,je]=y.useState({});return y.useEffect(()=>{let te=!0;const ne=x.current,me=W.current;return Q5(t).then(we=>{if(!te)return;const Fe={},Ae=[],He=new Map,X=new Set;for(const Z of we&&we.views||[]){Fe[Z.ownerId]={stale:Z.stale===!0,error:!!Z.lastError},X.add(Z.ownerId);for(const ge of Z.asks||[])ge&&ge.id&&Ae.push({...ge,ownerId:Z.ownerId,imported:!0});for(const ge of Z.notifications||[]){const Y=Sx(ge,Z.ownerId);Y&&He.set(Y.key,Y)}}je(Fe);const ce=new Set((we&&we.views||[]).filter(Z=>{const ge=typeof Z.cursor=="string"&&/^([1-9]\d*):(\d+)$/.exec(Z.cursor);return Z.stale===!1&&Number.isSafeInteger(Z.viewEpoch)&&Z.viewEpoch>0&&ge&&Number(ge[1])===Z.viewEpoch&&Number.isSafeInteger(Number(ge[2]))&&!Z.lastError&&!Z.error&&Z.resyncRequired!==!0&&Array.isArray(Z.asks)&&Z.asks.length<=100}).map(Z=>Z.ownerId));for(const Z of ce)J.current.delete(Z),J.current.set(Z,++x.current),J.current.size>4096&&J.current.delete(J.current.keys().next().value);c(Z=>Td(Z.filter(ge=>!ce.has(ge.ownerId)||($.current.get(ns(ge.id,ge.ownerId,ge.ownerAskId))||0)>ne),V(Ae))),v(Z=>xx(kx(Z.filter(ge=>!bm(ge.key)),[...He.values()].filter(ge=>!bm(ge.key)),X,{owners:ce,arrivedAfter:ge=>(ge.arrivalSeq||0)>me})))}).catch(()=>{}),()=>{te=!1}},[t,N]),a.jsxs(a.Fragment,{children:[u&&a.jsx("div",{className:"nc-ntf-toasts",children:a.jsxs("div",{className:"nc-ntf-toast",role:"status",children:[a.jsx("div",{className:"nc-ntf-toast-txt",children:f(mO(u))}),a.jsx("button",{type:"button",className:"nc-ntf-x",title:f("close"),onClick:()=>h(null),children:a.jsx(_t,{name:"x",size:14})})]})}),s.length>0&&a.jsx("div",{className:"nc-ntf-toasts",children:s.map(te=>a.jsx(vO,{n:te,onClose:()=>z(te.key)},te.key))}),(l.length>0||p.length>0)&&!_&&a.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>g(!0),title:f("asks-title"),children:["? ",a.jsx("span",{className:"nc-ask-count",children:l.length+p.length})]}),(l.length>0||p.length>0)&&_&&a.jsxs("div",{className:"nc-ask-panel",children:[a.jsxs("div",{className:"nc-ask-panel-head",children:[a.jsx("b",{children:f("asks-title")}),a.jsx("span",{className:"nc-ask-count",children:l.length}),a.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>g(!1),title:f("close"),children:a.jsx(_t,{name:"x",size:16})})]}),a.jsxs("div",{className:"nc-ask-panel-body",children:[l.map(te=>{var ne,me,we,Fe,Ae,He;return a.jsx(_O,{ask:te,token:t,askReplyAccess:!te.ownerId||((ne=b[te.ownerId+"|"+(te.ownerAskId||te.id)])==null?void 0:ne.canReply)===!0,canDismissLocal:((me=b[te.ownerId+"|"+(te.ownerAskId||te.id)])==null?void 0:me.canDismissLocal)===!0,canDismissRemote:((we=b[te.ownerId+"|"+(te.ownerAskId||te.id)])==null?void 0:we.canDismissRemote)===!0||((Fe=b[te.ownerId+"|"+(te.ownerAskId||te.id)])==null?void 0:Fe.canDismissRemote)===void 0&&((Ae=b[te.ownerId+"|"+(te.ownerAskId||te.id)])==null?void 0:Ae.canReply)===!0,capabilityStatus:((He=b[te.ownerId+"|"+(te.ownerAskId||te.id)])==null?void 0:He.status)||"loading",onRefused:()=>K(!0),feedViewState:te.ownerId?dO(re,te.ownerId):"live",initialUncertainRid:te.ownerId&&Q[te.ownerId+"|"+(te.ownerAskId||te.id)]||null,onAnswered:H,onDismiss:H},ns(te.id,te.ownerId,te.ownerAskId))}),p.length>0&&a.jsxs("div",{className:"nc-remote-notices",children:[a.jsxs("div",{className:"nc-remote-notices-head",children:[a.jsx("b",{children:f("remote-notices-title")}),a.jsx("button",{type:"button",className:"nc-remote-notices-clear",onClick:U,children:f("remote-notices-clear")})]}),p.map(te=>a.jsxs("div",{className:"nc-remote-notice"+(te.urgency==="high"?" nc-remote-notice-high":""),children:[a.jsxs("div",{className:"nc-remote-notice-head",children:[te.title?a.jsx("b",{children:te.title}):null,a.jsx("button",{type:"button",className:"nc-ntf-x",title:f("remote-notices-dismiss"),"aria-label":f("remote-notices-dismiss"),onClick:()=>A(te),children:a.jsx(_t,{name:"x",size:14})})]}),te.body?a.jsx("div",{children:te.body}):null,a.jsxs("div",{className:"nc-remote-notice-meta",children:[te.ownerId.slice(0,8)," · ",new Date(te.ts||Date.now()).toLocaleString()]})]},te.key))]})]})]})]})}const s2="nc_fontsize",i2=9,r2=24;function nv(t=globalThis.localStorage){const e=Number(t.getItem(s2));return e>=i2&&e<=r2?e:13}function o2(t,e=globalThis.localStorage){const n=Math.max(i2,Math.min(r2,t));return e.setItem(s2,String(n)),n}async function wO(t){const e=await qn("/api/sessions",t);if((e==null?void 0:e.ok)===!1)throw new Error(`HTTP ${e.status}`);const n=await e.json();if(!Array.isArray(n==null?void 0:n.sessions))throw new Error("invalid sessions payload");return n.sessions}async function bO(t,e=[]){var u;const[n,s]=await Promise.allSettled([e.length?dv(t,e):wO(t),tl(t,e)]),i=n.status==="fulfilled"&&Array.isArray((u=n.value)==null?void 0:u.sessions)?n.value.sessions:Array.isArray(n.value)?n.value:null,l=s.status==="fulfilled"?s.value:null,c=(l==null?void 0:l.available)===!0&&Array.isArray(l.cells)?l.cells:null;return{sessions:i,cells:c,fresh:Array.isArray(i)&&Array.isArray(c)}}function SO(t,e,n){return n===!0&&(t==null?void 0:t.degraded)!==!0&&(t==null?void 0:t.active)===!0&&t.tmux!==!1&&!!t.tmuxSession&&(e||[]).some(s=>(s==null?void 0:s.name)===t.tmuxSession)}function xO(t,e,n,s=[]){if(t.type==="session"){const c=t.value||{};return{kind:"session",key:t.key,cellName:t.label,session:t.label,node:e.length?e.join("/"):"",nodeLabel:n,route:e,live:!0,selectable:!0,working:!1,degraded:!1,active:!0,activity:t.activity||0,telemetry:c.telemetry||null,preview:c.preview||"",panelUrl:""}}const i=t.value||{},l=s.find(c=>c&&c.name===i.tmuxSession)||{};return{kind:"cell",key:t.key,cellName:i.cell,session:i.tmuxSession||i.cell,node:e.length?e.join("/"):"",nodeLabel:n,route:e,live:t.live===!0,selectable:t.live===!0,working:t.working===!0,degraded:!!i.degraded,active:i.active===!0,activity:t.activity||0,telemetry:l.telemetry||i.telemetry||null,preview:l.preview||i.preview||"",panelUrl:i.panelUrl||""}}function kO({token:t,current:e,onPick:n,onClose:s,panelPort:i=0,nodePanelPorts:l={},localNodeLabel:c="",hostByRoute:u={},onDesignateCell:h,onClearHostCell:p,onLiveHostApplied:v,sideKey:_=null,onToggleSide:g}){const[b,S]=y.useState($I),[j,C]=y.useState(!1),[N,E]=y.useState("");y.useEffect(()=>Cc(t,[],P=>{let le=null;if(!P.sessionsError&&P.sessionsJson)try{const Me=JSON.parse(P.sessionsJson);Me&&!Me.error&&Array.isArray(Me.sessions)&&(le=Me.sessions)}catch{}const _e=yh({fs:P.fs,error:P.fleetError});S(Me=>({...Me,...le?{sessions:le}:{},..._e.kind==="data"?{cells:_e.cells,localFresh:!0}:{}}))}),[t]);const[O,x]=y.useState(null),W="stream",[$,J]=y.useState(nv),q=P=>J(le=>o2(le+P)),[V,ie]=y.useState(null),[K,B]=y.useState(!1),[I,D]=y.useState(""),T=y.useRef(null),z=y.useRef(null),{pins:R,orders:M,views:L,togglePin:H,removePin:A,pinError:U,canMoveRoster:Q,moveRoster:ae,stepRoster:re}=zv(),{groupsFor:je}=bh(),{groups:te,hasLoaded:ne}=nC(t),me=ne?te:b.nodeGroups||[],we=y.useMemo(()=>je(me||[]).filter(P=>Array.isArray(P.route)&&P.route.length&&P.kind!=="vl"),[je,me]),Fe=y.useMemo(()=>{const P=new Map,le=Array.isArray(b.sessions)?b.sessions:[],_e=Array.isArray(b.cells)?b.cells:[],Me=new Map(le.map(Be=>[Be.name,Be])),oe=new Set(_e.map(Be=>Be.tmuxSession).filter(Boolean));P.set("local",qv(_e,le.filter(Be=>!oe.has(Be.name)),Me));for(const Be of we)P.set(Be.route.join("/"),bc(Be).rawItems);return P},[b,we]),Ae=y.useMemo(()=>{const P=Me=>j?"all":Cg(L,Me).filter,le=Array.isArray(b.sessions)?b.sessions:[],_e=[];for(const[Me,oe]of Fe){const Be=we.find(ft=>ft.route.join("/")===Me),gt=Be&&(Be.label||Be.name)||"",Lt=Be?Be.route:[],Nt=Be?Array.isArray(Be.sessions)?Be.sessions:[]:le,kt=co(oe,R,P(Me),Ti(M,Me)),Kt=j?kt:kt.filter(ft=>{var Vt,It;return ft.live===!0||ft.type==="cell"&&((Vt=ft.value)==null?void 0:Vt.degraded)===!0&&((It=ft.value)==null?void 0:It.active)===!0});_e.push(...Kt.map(ft=>xO(ft,Lt,gt,Nt)))}return _e},[Fe,we,L,M,R,j,b.sessions]),He=Ae,X=y.useMemo(()=>O?Ae.find(P=>P.key===O&&P.selectable):null,[Ae,O]);y.useEffect(()=>{O&&!Ae.some(P=>P.key===O&&P.selectable)&&x(null)},[Ae,O]);const ce=y.useMemo(()=>V?He.find(P=>P.key===V.key):null,[He,V]),Z=!!(V&&ce);y.useEffect(()=>{U&&U.message&&E(U.message)},[U]),y.useEffect(()=>{var _e;const P=document.activeElement;(_e=z.current)==null||_e.focus();const le=Me=>{Me.key==="Escape"&&!Z&&s()};return document.addEventListener("keydown",le),()=>{var Me;document.removeEventListener("keydown",le),(Me=P==null?void 0:P.focus)==null||Me.call(P)}},[s,Z]);const[ge,Y]=y.useState(""),he={getLiveHost:P=>ah(t,P),designateHostCell:(P,le,_e)=>lh(t,P,le,_e),clearHostCell:(P,le)=>ch(t,P,le)},Ne=P=>(u[Ls(P)]||{}).hostCell||null,Ce=async(P,le)=>{Y(P.key);const _e=await dh({action:le?"remove":"use",cellId:P.cellName,route:P.route||[],api:he});Y(""),E(f(_e.messageKey).replace("{cell}",_e.hostCell||P.cellName)),_e.ok&&v&&v({route:P.route||[],hostCell:_e.hostCell,revision:_e.revision})},Ve=P=>P.degraded?f("cell-degraded"):P.selectable?P.working?f("cell-working"):f("cell-idle"):f("cell-off"),Ye=async P=>{if(E(""),!P.selectable){E(f("cell-switcher-not-active"));return}if(P.kind==="session"){n({session:P.session,...P.node?{node:P.node}:{}}),s();return}D(P.key);try{const le=await bO(t,P.route),_e=(le.cells||[]).find(Me=>(Me==null?void 0:Me.cell)===P.cellName&&(Me==null?void 0:Me.tmuxSession)===P.session);if(le.fresh!==!0){n({session:P.session,...P.node?{node:P.node}:{},cellName:P.cellName}),s();return}if(!SO(_e,le.sessions,le.fresh)){E(f("cell-switcher-not-active"));return}n({session:P.session,...P.node?{node:P.node}:{},cellName:P.cellName}),s()}catch{n({session:P.session,...P.node?{node:P.node}:{},cellName:P.cellName}),s()}finally{D("")}},ht=P=>{if(!P.selectable){Ye(P);return}if(O===P.key){Ye(P);return}x(P.key)},ze=y.useRef(null),ve=8,Oe=P=>{const le=ze.current;if(P.isPrimary===!1){le&&le.state==="open"&&(le.state="invalid");return}if(le&&le.state==="open"&&(le.id!==P.pointerId||le.row!==P.currentTarget)){le.state="invalid";return}ze.current={id:P.pointerId,row:P.currentTarget,x:P.clientX,y:P.clientY,maxDelta:0,state:"open"}},et=P=>{const le=ze.current;!le||le.state!=="open"||le.id!==P.pointerId||(le.maxDelta=Math.max(le.maxDelta,Math.hypot(P.clientX-le.x,P.clientY-le.y)),le.maxDelta>ve&&(le.state="invalid"))},Ue=P=>{const le=ze.current;!le||le.id!==P.pointerId||le.state!=="open"||(le.state=le.maxDelta<=ve?"tap":"invalid")},st=P=>{const le=ze.current;le&&le.id===P.pointerId&&(le.state="invalid")},ot=P=>{const le=ze.current;return ze.current=null,P.detail===0?!0:!le||le.state==="invalid"||le.row!==P.currentTarget?!1:Math.hypot(P.clientX-le.x,P.clientY-le.y)<=ve},ee=P=>({onToggleLive:()=>Ce(P,Ne(P.route||[])===P.cellName),onTogglePin:()=>Fv({view:Sh({item:{key:P.key,value:{cell:P.cellName}},pins:R,hostByRoute:u,route:P.route||[]}),itemKey:P.key,togglePin:H,removePin:A})});return a.jsxs("div",{className:"nc-cell-switcher-backdrop",onClick:s,children:[X&&a.jsxs("div",{className:"nc-cell-switcher-anteprima","data-testid":"cell-switcher-anteprima",onClick:P=>P.stopPropagation(),children:[a.jsxs("div",{className:"nc-cell-switcher-anteprima-testa",children:[a.jsxs("b",{children:[f("cell-switcher-preview-word")," ",X.cellName]}),a.jsx("small",{children:f("cell-switcher-preview-readonly")}),a.jsxs("span",{className:"nc-cell-switcher-anteprima-zoom",children:[a.jsx("button",{type:"button",onClick:()=>q(-1),title:f("zoom-out"),"aria-label":f("zoom-out"),children:"−"}),a.jsxs("span",{"data-testid":"cell-switcher-fontsize",children:[$," px"]}),a.jsx("button",{type:"button",onClick:()=>q(1),title:f("zoom-in"),"aria-label":f("zoom-in"),children:"+"})]})]}),a.jsx(Tv,{row:X,token:t,source:W,chrome:!1,panelPort:Tc(X.route||[],l,i),liveHost:Va({liveHost:u[Ls(X.route||[])],cells:b.cells||[]}),onLiveHostApplied:v,fontSize:$,readOnly:!0})]}),a.jsxs("aside",{ref:T,className:`nc-cell-switcher${X?" with-anteprima":""}`,role:"dialog","aria-label":f("fleet-cells"),tabIndex:-1,onClick:P=>P.stopPropagation(),children:[a.jsxs("div",{className:"nc-cell-switcher-controls",children:[a.jsx("b",{children:f("cell-switcher-title")}),c&&a.jsx("small",{className:"nc-cell-switcher-node",children:c}),a.jsxs("div",{className:"nc-cell-switcher-filter",role:"group","aria-label":f("cell-switcher-filter"),children:[a.jsx("button",{type:"button",className:j?"":"on","aria-pressed":!j,onClick:()=>{E(""),C(!1)},children:f("cell-switcher-show-active")}),a.jsx("button",{type:"button",className:j?"on":"","aria-pressed":j,onClick:()=>{E(""),C(!0)},children:f("cell-switcher-show-all")})]}),a.jsx("button",{type:"button",className:`nc-cell-switcher-reorder${K?" on":""}`,"aria-pressed":K,title:f("reorder-help"),"aria-label":f("reorder"),onClick:()=>{E(""),B(P=>!P)},children:"↕"}),a.jsx("button",{ref:z,type:"button",className:"nc-cell-switcher-close","aria-label":f("cell-switcher-close"),title:f("cell-switcher-close"),onClick:s,children:"×"})]}),!X&&a.jsx("div",{className:"nc-cell-switcher-hint",children:f("cell-switcher-tap-hint")}),a.jsxs("div",{className:"nc-cell-switcher-list",children:[(()=>{const P=Va({liveHost:u[Ls([])],cells:b.cells||[]});if(!P||!P.cell)return null;const{modeKey:le}=mj(P);return a.jsx("div",{className:"nc-cell-switcher-live-strip","data-testid":"cell-switcher-live-strip",children:f("cell-switcher-live-strip").replace("{cell}",P.cell).replace("{mode}",f(le||"live-host-mode-unknown"))})})(),Ae.length===0&&a.jsx("div",{className:"nc-empty",role:"status",children:f("cell-switcher-empty-active")}),Ae.map((P,le)=>{const _e=(e==null?void 0:e.session)===P.session&&((e==null?void 0:e.node)||"")===P.node,Me=!!V&&V.key===P.key,oe=_!=null&&_===P.key,Be=Ve(P),gt=Sg(f,P.activity),Lt=xg(f,P.telemetry),Nt=[gt,Lt].filter(Boolean).join(" · "),kt=P.node||"local",Kt=le>0?Ae[le-1].node||"local":null,ft=kt!==Kt,Vt=Fe.get(kt)||He.filter(It=>(It.node||"local")===kt);return a.jsxs(y.Fragment,{children:[ft&&a.jsx("div",{className:"nc-cell-switcher-position",children:f("cell-switcher-group").replace("{node}",P.nodeLabel||c||f("cell-switcher-group-local"))}),a.jsxs("div",{className:`nc-cell-switcher-row${_e?" current":""}${O===P.key?" selected":""}${oe?" side":""}${P.selectable?"":" off"}`,"data-roster-key":P.key,"data-position":kt,children:[K&&a.jsx(Yi,{position:kt,itemKey:P.key,label:P.cellName,canMove:Q,onMove:(It,Xt)=>ae(kt,It,Xt,Vt),onStep:It=>re(kt,P.key,It,Vt)}),a.jsx("span",{className:"nc-cell-switcher-peek",children:a.jsx("span",{className:`nc-cell-switcher-dot${P.degraded?" warn":P.live?` on${P.working?" working":""}`:""}`})}),a.jsx("button",{type:"button",className:"nc-cell-switcher-row-select","aria-current":_e?"true":void 0,"aria-disabled":!P.selectable,"data-selected":O===P.key?"true":void 0,disabled:I===P.key,onPointerDown:Oe,onPointerMove:et,onPointerUp:Ue,onPointerCancel:st,onClick:It=>{ot(It)&&ht(P)},children:a.jsxs("span",{className:"nc-cell-switcher-copy",children:[a.jsxs("span",{className:"nc-cell-switcher-nameline",children:[a.jsx("b",{children:P.cellName}),_e&&a.jsx("span",{className:"nc-cell-switcher-here",children:f("cell-switcher-here")}),O===P.key&&a.jsx("span",{className:"nc-cell-switcher-taptwo",children:f("cell-switcher-two-taps")})]}),a.jsxs("span",{className:"nc-cell-switcher-stateline",children:[a.jsx("small",{className:"nc-cell-switcher-state",children:Be}),Nt&&a.jsx("small",{className:"nc-cell-switcher-telemetry",children:Nt})]})]})}),g&&a.jsx("button",{type:"button",className:`nc-cell-switcher-side${oe?" on":""}`,title:f(oe?"cell-switcher-side-remove":"cell-switcher-side-add"),"aria-label":f(oe?"cell-switcher-side-remove":"cell-switcher-side-add"),"aria-pressed":oe?"true":"false",disabled:_e||!P.selectable,onClick:It=>{It.stopPropagation(),!_e&&P.selectable&&g(P)},children:a.jsx(_t,{name:"splitView",size:20})}),a.jsx("button",{type:"button",className:`nc-cell-switcher-menu${Me?" on":""}`,title:`${f("cell-actions-open")}: ${P.cellName}`,"aria-label":`${f("cell-actions-open")}: ${P.cellName}`,"aria-haspopup":"menu","aria-expanded":Me?"true":"false",onClick:It=>{It.stopPropagation(),ie({key:P.key})},children:"⋯"})]})]},P.key)})]}),N&&a.jsx("div",{className:"nc-cell-switcher-notice",role:"status",children:N}),Z&&(()=>{const P=ce,le=Hv({...oo({item:{key:P.key,value:{cell:P.cellName}},cellName:P.cellName,route:P.route||[],pins:R,hostByRoute:u}),canBoot:!1,alive:P.selectable,handlers:ee(P)});return a.jsx(Uv,{cellName:P.cellName,items:le,busy:ge===P.key,onClose:()=>ie(null)})})()]})]})}const CO=2e3;function EO(t){if(t.kind==="gap")return`${f("vl-events-gap")} ${t.count||"?"}`;if(t.kind==="truncate")return f("vl-events-truncated");if(t.kind==="turn_end")return f("vl-events-turn-end");if(t.kind==="done")return f("vl-events-done");if(t.kind==="writer_epoch")return f("vl-events-writer-epoch");if(t.kind==="tool_start")return`${f("vl-events-tool")} ${t.name||""}`.trim();if(t.kind==="tool_end"){const e=t.isError?f("vl-events-tool-failed"):f("vl-events-tool-ok");return`${f("vl-events-tool")} ${t.name||""} — ${e}`.trim()}return t.kind==="usage"?t.text||f("vl-events-usage"):t.text||""}function NO({token:t,nodeId:e,route:n=[]}){const[s,i]=y.useState([]),[l,c]=y.useState(!1),u=y.useRef(0),h=y.useRef(!1);return y.useEffect(()=>{let p=!0;u.current=0,h.current=!1,i([]);const v=async()=>{if(!h.current){h.current=!0;try{const b=await w5(t,e,u.current,n);if(!p)return;c(!1);const j=(Array.isArray(b==null?void 0:b.events)?b.events:[]).filter(C=>Number.isSafeInteger(C==null?void 0:C.seq)&&C.seq>u.current);j.length&&(i(C=>C.concat(j).slice(-500)),u.current=j[j.length-1].seq),Number.isSafeInteger(b==null?void 0:b.cursor)&&b.cursor>u.current&&(u.current=b.cursor)}catch{p&&c(!0)}finally{h.current=!1}}},_=()=>{v().catch(()=>{})};_();const g=setInterval(_,CO);return()=>{p=!1,clearInterval(g)}},[t,e,JSON.stringify(n)]),a.jsxs("div",{className:"nc-vl-events",children:[l&&a.jsx("div",{className:"nc-set-hint nc-vl-events-stale",children:f("vl-events-stale")}),s.length===0&&!l&&a.jsx("small",{className:"nc-set-hint","data-testid":"vl-events-empty",children:f("vl-events-empty")}),s.length>0&&a.jsx("ol",{className:"nc-vl-events-list",children:s.map(p=>a.jsx("li",{"data-testid":`vl-ev-${p.seq}`,className:`nc-vl-ev nc-vl-ev-${p.kind}${p.isError?" error":""}${p.kind==="gap"?" gap":""}`,children:EO(p)},`${p.seq}-${p.kind}`))})]})}function Ex({peer:t,token:e,onBack:n}){var s;return zn(),t?a.jsxs("section",{className:"nc-vl-session-view",children:[a.jsxs("header",{className:"nc-bar nc-bar-single",children:[a.jsxs("button",{onClick:n,title:f("back"),children:[a.jsx(_t,{name:"chevronLeft",size:18}),a.jsx("span",{className:"nc-bar-label",children:f("back")})]}),a.jsxs("span",{className:"nc-bar-center",children:[a.jsx("b",{title:t.label,children:t.label}),((s=t.session)==null?void 0:s.profile)&&a.jsxs("small",{className:"nc-bar-sub",children:[t.session.profile," · ",f("vl-events-title")]})]}),a.jsx("span",{className:"nc-bar-right"})]}),a.jsx("div",{className:"nc-vl-session-body",children:a.jsx(NO,{token:e,nodeId:t.nodeId,route:t.route||[]})})]}):null}const th="nc_dual_side";function sv(t,e){return!t||!e?!1:t.session===e.session&&(t.node||"")===(e.node||"")}function jO(t,e,n){return!n||!n.session||t&&sv(t,n)?e:e&&sv(e,n)?null:{session:n.session,...n.node?{node:n.node}:{},...n.ownerId?{ownerId:n.ownerId}:{}}}function LO(){try{const t=JSON.parse(localStorage.getItem(th)||"null");return!t||!t.main||!t.side||!t.main.session||!t.side.session?null:t}catch{return null}}function RO(t,e){try{if(!t||!e||!t.session||!e.session){localStorage.removeItem(th);return}const n=s=>({session:s.session,...s.node?{node:s.node}:{}});localStorage.setItem(th,JSON.stringify({main:n(t),side:n(e)}))}catch{}}function Nx(){try{localStorage.removeItem(th)}catch{}}const AO=.2;function gd(t){return Math.max(AO,t)}function MO(){try{if(typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches)return!0}catch{}try{return Number(globalThis.navigator&&globalThis.navigator.maxTouchPoints)>0}catch{return!1}}function TO({onSubmit:t,reason:e=""}){zn();const[n,s]=y.useState(""),[i,l]=y.useState(MO),c=n.trim(),u=h=>{h&&h.preventDefault&&h.preventDefault(),c&&t(c,i)};return a.jsxs("form",{className:"nc-auth",onSubmit:u,children:[a.jsx("p",{children:f("auth-prompt")}),e==="invalid"&&a.jsx("p",{className:"nc-auth-error",role:"alert",children:f("auth-invalid")}),a.jsx("input",{type:"text",value:n,placeholder:"token","aria-label":"token",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,onChange:h=>s(h.target.value)}),a.jsxs("label",{children:[a.jsx("input",{type:"checkbox",checked:i,onChange:h=>l(h.target.checked)})," ",f("remember-device")]}),a.jsx("button",{type:"submit",disabled:!c,children:"ok"})]})}const Sm=t=>ys(Mi(t)).length===0;function Ua(t,e){return Array.isArray(t)?t.flatMap(n=>{var c;const s={session:n.session,height:1,fontSize:n.fontSize};n.node&&(s.node=n.node),n.ownerId&&(s.ownerId=n.ownerId);const i=(c=e({columns:[{width:1,tiles:[s]}]}).columns[0])==null?void 0:c.tiles[0];if(!i)return[];const l={session:i.session,x:n.x,y:n.y,w:n.w,h:n.h,fontSize:n.fontSize};return i.node&&(l.node=i.node),i.ownerId&&(l.ownerId=i.ownerId),[l]}):[]}function jx(t,e){return t.length?t:Array.isArray(e.floating)&&e.floating.length?[]:void 0}function PO(t,e,n,s,i){const l=c=>Ua(c&&c.floating,u=>qa(u,s,i));return vI(l(t),l(e),n)}function Lx(t,e,n,s,i,l){const c=_=>qa(_,i,l),u=_=>Ua(_&&_.floating,c),{grid:h,floating:p}=Vd(n),v=_I(s(h),PO(t,e,p,i,l),{grid:t?c(t.layout):uo(),floating:u(t)},{grid:c(e.layout),floating:u(e)},{grid:h,floating:p});return Dg(v.grid,v.floating)}const xm=t=>Array.isArray(t)?t.join("/"):"",IO="nc-decks-cache-v1",a2=t=>`${IO}:${t}`;function DO(t){if(!t)return[];try{const e=localStorage.getItem(a2(t));if(!e)return[];const n=JSON.parse(e);return Array.isArray(n)&&n.every(s=>s&&typeof s.id=="string"&&typeof s.name=="string")?n:[]}catch{return[]}}function OO(t,e){if(t)try{localStorage.setItem(a2(t),JSON.stringify(e))}catch{}}function BO(t){const e=new Set,n=[];for(const s of Array.isArray(t)?t:[])!s||!Xs.test(String(s.instanceId||""))||!Array.isArray(s.route)||!s.route.length||e.has(s.instanceId)||(e.add(s.instanceId),n.push({instanceId:s.instanceId,route:[...s.route],label:String(s.label||s.name||s.route.join(" › ")),status:s.status||"offline",stale:s.stale===!0,checking:s.checking===!0}));return n.sort((s,i)=>s.label.localeCompare(i.label))}function rc(t){return{instanceId:t.ownerId,route:t.ownerRoute||[],label:t.ownerLabel,status:t.available===!1?"offline":"up"}}function Mo(t,e,n,s=!1,i=!0){const l=e.instanceId;return{...t,id:qo(s?null:l,t.name),ownerId:l,ownerRoute:s?[]:[...e.route],ownerLabel:s?"Local":e.label,local:s,available:i,ownerTopology:Array.isArray(n)?n:[],layout:Wg(t.layout,l,n)}}function $O(t,e,n,s,i=[],l=[]){const[c,u]=y.useState([]),[h,p]=y.useState(!1),[v,_]=y.useState("idle"),[g,b]=y.useState(""),[S,j]=y.useState(!1),[C,N]=y.useState(""),E=y.useRef([]),O=y.useRef([]),x=y.useRef([]),W=y.useRef(new Map),$=y.useRef(""),J=y.useRef(e),q=y.useRef(n),V=y.useRef(!1),ie=y.useRef(!0),K=y.useRef(""),B=y.useMemo(()=>BO(i),[i]),I=B.map(X=>`${X.instanceId}:${xm(X.route)}`).join("|"),D=B.map(X=>`${X.instanceId}:${X.status??""}:${X.checking?"checking":"settled"}`).join("|"),T=y.useRef(new Map(B.map(X=>[X.instanceId,X.checking?"pending":X.status])));O.current=B,x.current=l,q.current=n,J.current=e,E.current=c;const z=y.useCallback(X=>qa(X.layout,$.current,O.current),[]),R=y.useCallback(()=>tc(J.current,$.current),[]),M=y.useCallback(X=>(Array.isArray(X)?X:[]).find(ce=>ce.id===R()),[R]),L=y.useCallback((X,ce=!0,Z)=>{const ge=Z===void 0?R():tc(Z,$.current),Y=qp(X,sc(),x.current),he=E.current.some(Ce=>Ce.id===ge);E.current=Y,u(Y),OO($.current,Y.map(Ce=>{if(!Ce.refreshFailedAt)return Ce;const Ve={...Ce};return delete Ve.refreshFailedAt,Ve}));const Ne=Y.find(Ce=>Ce.id===ge);if(ce&&Ne){ie.current=!0;const Ce=Dg(z(Ne),Ua(Ne.floating,Ve=>qa(Ve,$.current,O.current)));s(Ce),Ne.local&&s3(Ne.name,Mi(Ce))}else he&&!Ne&&(ie.current=!0,s(uo()),b("deck non più condiviso dal nodo owner"));ZD(Y.filter(Ce=>Ce.local).map(Ce=>Ce.name))},[s,z]),H=y.useCallback(async X=>{let ce=await Xu(t);const Z=ce.decks.find(ge=>ge.name==="main");if(ce.decks.length===1&&Z&&Z.revision===0&&Sm(Z.layout)){const ge=QD(),Y=Mi(qg("main")||uo());if(!Sm(Y)){const he=Wg(Y,X,[]);ce.decks[0]=await Ju(t,"main",he,0,[])}for(const he of ge.filter(Ne=>Ne!=="main"))try{let Ne=await nb(t,he,[]);const Ce=Mi(qg(he)||uo());Sm(Ce)||(Ne=await Ju(t,he,Wg(Ce,X,[]),Ne.revision,[]))}catch{}ce=await Xu(t)}return ce},[t]),A=y.useCallback((X,ce)=>{const Z=new Map(ce.map(he=>[he.id,he])),ge=new Set,Y=[];for(const he of E.current){if(he.local||he.ownerId!==X.instanceId){Y.push(he);continue}const Ne=Z.get(he.id);Ne&&(Y.push(Ne),ge.add(he.id))}for(const he of ce)ge.has(he.id)||Y.push(he);L(Y,!1)},[L]),U=y.useCallback(async X=>{try{const[ce,Z]=await Promise.all([Xu(t,X.route),Zw(t,X.route).catch(()=>({nodes:[]}))]);A(X,ce.decks.map(ge=>Mo(ge,X,Z.nodes,!1,!0)))}catch(ce){if(ce&&(ce.status===403||ce.status===404)){A(X,[]);return}const Z=E.current.filter(ge=>!ge.local&&ge.ownerId===X.instanceId).map(ge=>({...ge,stale:!0,refreshFailedAt:Date.now(),ownerRoute:[...X.route],ownerLabel:X.label}));A(X,Z)}},[t,A]),Q=y.useCallback(async({migrate:X=!1}={})=>{const ce=await qc(t,[]),Z=Xs.test(String(ce.instanceId||""))?ce.instanceId:"";if(!Z)throw new Error("instanceId locale non disponibile");$.current=Z,N(Z);const[ge,Y]=await Promise.all([X?H(Z):Xu(t),Zw(t,[]).catch(()=>({nodes:[]}))]),he={instanceId:Z,route:[],label:"Local"},Ne=ge.decks.map(ve=>Mo(ve,he,Y.nodes,!0,!0)),Ce=new Map(O.current.map(ve=>[ve.instanceId,ve])),Ve=E.current.length?E.current:DO(Z),Ye=W.current,ht=Date.now(),ze=Ve.filter(ve=>!ve.local).flatMap(ve=>{const Oe=Ce.get(ve.ownerId);if(!Oe){const st=Ye.get(ve.ownerId);return st===void 0?(Ye.set(ve.ownerId,ht),[{...ve,available:!1,stale:!0}]):ht-st>Ov?[]:[{...ve,available:!1,stale:!0}]}Ye.delete(ve.ownerId);const et=Oe.status==="up",Ue=Oe.status==="pending"||Oe.checking===!0;return[{...ve,available:Ue?ve.available:et?ve.available!==!1:!1,stale:Oe.stale===!0,ownerRoute:[...Oe.route],ownerLabel:Oe.label}]});return setTimeout(()=>{for(const ve of Ce.values())ve.status==="up"&&!ve.checking&&U(ve)},0),[...Ne,...ze]},[t,H,U,I]);y.useEffect(()=>{if(!t)return;let X=!1;const ce=K.current!==t;return K.current=t,Q({migrate:ce}).then(Z=>{if(X)return;const ge=M(E.current),Y=M(Z),he=Y&&(!ge||Y.revision>ge.revision||ge.available!==Y.available||xm(ge.ownerRoute)!==xm(Y.ownerRoute));L(Z,ce||!!he&&!V.current),p(!0),Y&&b("")}).catch(Z=>{X||(p(!0),b(String(Z.message||Z)))}),()=>{X=!0}},[L,Q,I,t,M]),y.useEffect(()=>{if(!E.current.length)return;const X=qp(E.current,sc(),l);(X.length!==E.current.length||X.some((Z,ge)=>Z.id!==E.current[ge].id))&&(E.current=X,u(X))},[l]),y.useEffect(()=>{const X=T.current,ce=new Map;for(const Z of O.current){if(Z.checking||Z.status==="pending"){ce.set(Z.instanceId,X.get(Z.instanceId)||"pending");continue}Z.status==="up"&&X.get(Z.instanceId)!=="up"&&U(Z),ce.set(Z.instanceId,Z.status)}T.current=ce},[D,U]);const ae=y.useCallback(async(X,ce=!0)=>{if(!h||!V.current)return!0;const Z=X===void 0?R():tc(X,$.current),ge=E.current.find(Y=>Y.id===Z);if(!ge)return b(`deck inesistente: ${Z}`),!1;if(ge.available===!1)return b(`nodo owner offline: ${ge.ownerLabel}`),!1;_("saving");try{const{grid:Y,floating:he}=Vd(q.current),Ne=nc(Mi(Y),ge.ownerId,ge.ownerTopology),Ce=Ua(he,ht=>nc(ht,ge.ownerId,ge.ownerTopology)),Ve=await Ju(t,ge.name,Ne,ge.revision,ge.ownerRoute,jx(Ce,ge)),Ye=Mo(Ve,rc(ge),ge.ownerTopology,ge.local,!0);return L(E.current.map(ht=>ht.id===Z?Ye:ht),!1),V.current=!1,_("saved"),b(""),j(!1),setTimeout(()=>_("idle"),1500),!0}catch(Y){if(ce&&Y.status===409&&Y.data&&Y.data.current){const he=E.current.find(Ne=>Ne.id===Z);if(he){const Ne=Mo(Y.data.current,rc(he),he.ownerTopology,he.local,!0),Ce=Lx(he,Ne,q.current,Ve=>Ve,$.current,O.current);return yI(Ce,q.current)||(q.current=Ce,ie.current=!0,s(Ce)),L(E.current.map(Ve=>Ve.id===Z?Ne:Ve),!1),V.current=!0,ae(Z,!1)}}return _("error"),b(String(Y.message||Y)),Y.status===409&&j(!0),!1}},[h,t,L,s]),re=y.useCallback(async()=>{try{const X=await Q();V.current=!1,j(!1),L(X,!0),b("")}catch(X){b(String(X.message||X))}},[Q,L]);y.useEffect(()=>{if(!h)return;const X=ie.current&&!V.current;if(ie.current=!1,X)return;V.current=!0,_("saving");const ce=setTimeout(ae,650);return()=>clearTimeout(ce)},[n,h,ae]),y.useEffect(()=>{if(!h)return;const X=()=>{if(!V.current)return;const ce=E.current.find(Ne=>Ne.id===R());if(!ce||ce.available===!1)return;const{grid:Z,floating:ge}=Vd(q.current),Y=nc(Mi(Z),ce.ownerId,ce.ownerTopology),he=Ua(ge,Ne=>nc(Ne,ce.ownerId,ce.ownerTopology));tj(t,ce.name,Y,ce.revision,ce.ownerRoute,jx(he,ce))};return window.addEventListener("pagehide",X),window.addEventListener("beforeunload",X),()=>{window.removeEventListener("pagehide",X),window.removeEventListener("beforeunload",X)}},[h,t,R]),y.useEffect(()=>{if(!h)return;const X=setInterval(async()=>{try{const ce=await Q(),Z=M(E.current),ge=M(ce),Y=!!(ge&&Z&&ge.revision>Z.revision),he=!!(ge&&(!Z||Y||Z.available!==ge.available));if(Y&&V.current&&ge){const Ne=Lx(Z,ge,q.current,Ce=>SI(z(ge),Ce),$.current,O.current);L(ce,!1),s(Ne);return}L(ce,he&&!V.current)}catch{}},5e3);return()=>clearInterval(X)},[h,Q,L,z,s]);const je=y.useCallback(X=>{s(ce=>{const Z=X(ce);return Z!==ce&&(ie.current=!0),Z})},[]),te=async(X,ce=null)=>{const Z=ce===Gi?E.current.find(he=>he.local):ce?E.current.find(he=>he.ownerId===ce):null;if(!Z||Z.available===!1)throw new Error("nodo owner non disponibile");const ge=await nb(t,X,Z.ownerRoute),Y=Mo(ge,rc(Z),Z.ownerTopology,Z.local,!0);return L([...E.current,Y],!1),Y},ne=async(X,ce)=>{const Z=E.current.find(Ce=>Ce.id===X);if(!Z)throw new Error("deck inesistente");if(tc(X,$.current)===R()&&V.current&&!await ae(X))throw new Error(`salvataggio di "${Z.name}" fallito: rinomina annullata`);const ge=E.current.find(Ce=>Ce.id===X);if(!ge)throw new Error("deck inesistente");const Y=await nj(t,ge.name,ce,ge.revision,ge.ownerRoute),he=Mo(Y,rc(ge),ge.ownerTopology,ge.local,!0),Ne=ge.local?Gi:ge.ownerId;return Wp(t3(sc(),Ne,X,he.id)),L(E.current.map(Ce=>Ce.id===X?he:Ce),!1),he},me=async X=>{const ce=E.current.find(ge=>ge.id===X);if(!ce)throw new Error("deck inesistente");tc(X,$.current)===R()&&(V.current=!1),await sj(t,ce.name,ce.revision,ce.ownerRoute);const Z=ce.local?Gi:ce.ownerId;Wp(n3(sc(),Z,X)),L(E.current.filter(ge=>ge.id!==X),!1)},we=(X,ce)=>{const Z=E.current.find(Ve=>Ve.id===X),ge=E.current.find(Ve=>Ve.id===ce);if(!Z||!ge)return!1;const Y=Z.local?Gi:Z.ownerId,he=ge.local?Gi:ge.ownerId;if(Y!==he)return!1;const Ne=E.current.filter(Ve=>(Ve.local?Gi:Ve.ownerId)===Y).map(Ve=>Ve.id),Ce=Wp(e3(sc(),Y,X,ce,Ne));return L(qp(E.current,Ce),!1),!0},Fe=async(X,ce)=>{const Z=E.current.find(Ve=>Ve.id===X);if(!Z)throw new Error("deck inesistente");if(Z.available===!1)throw new Error(`nodo owner offline: ${Z.ownerLabel}`);const ge=XC(ce,$.current,O.current);if(!ge)throw new Error("riferimento sessione non valido");const Y=z(Z),he=nc(gC(Y,ge),Z.ownerId,Z.ownerTopology),Ne=await Ju(t,Z.name,he,Z.revision,Z.ownerRoute),Ce=Mo(Ne,rc(Z),Z.ownerTopology,Z.local,!0);return L(E.current.map(Ve=>Ve.id===X?Ce:Ve),!1),Ce},Ae=y.useCallback(X=>Dg(z(X),Ua(X.floating,ce=>qa(ce,$.current,O.current))),[z]);return{decks:c,records:c,localNodeId:C,ready:h,saveState:v,error:g,setError:b,conflict:S,reloadCurrent:re,saveNow:ae,select:async X=>{if(V.current&&!await ae(R()))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const ce=E.current.find(Z=>Z.id===X);if(!ce)throw new Error(`deck inesistente: ${X}`);return V.current=!1,ie.current=!0,Ae(ce)},add:te,rename:ne,remove:me,reorder:we,addTileTo:Fe,viewUpdate:je,vistaMaterializzata:Ae,localMainId:qo(null,"main"),parseDeckId:Zc}}const zO="/sw.js",iv="nc-sw-update";let Wc=null,nh=!1,sh=null,l2=Object.freeze({needed:!1,kind:null,version:"",browserVersion:""}),c2=!1;function x_(){typeof window<"u"&&window.dispatchEvent(new Event(iv))}function k_(){const t=sh||(nh?{kind:"reload",version:"",browserVersion:""}:null);l2=Object.freeze({needed:!!t,kind:(t==null?void 0:t.kind)||null,version:(t==null?void 0:t.version)||"",browserVersion:(t==null?void 0:t.browserVersion)||""})}function Rx(){return l2}function FO(t){return typeof window>"u"?()=>{}:(window.addEventListener(iv,t),()=>window.removeEventListener(iv,t))}function C_(t){nh!==t&&(nh=t,k_(),x_())}const vd="nc-auto-reload",ih="nc-reload";function E_(){try{return typeof location<"u"?location:null}catch{return null}}function u2(){try{return typeof history<"u"?history:null}catch{return null}}function HO(t){const e=t===void 0?E_():t;if(!e||typeof e.search!="string")return null;try{return new URLSearchParams(e.search).get(ih)}catch{return null}}function UO(t,{location:e,history:n}={}){const s=e===void 0?E_():e,i=n===void 0?u2():n;if(!s||!i||typeof i.replaceState!="function")return!1;try{const l=new URLSearchParams(s.search||"");return l.set(ih,t),i.replaceState(i.state??null,"",`${s.pathname||"/"}?${l.toString()}${s.hash||""}`),!0}catch{return!1}}function WO({location:t,history:e}={}){const n=t===void 0?E_():t,s=e===void 0?u2():e;if(!n||!s||typeof s.replaceState!="function")return!1;try{const i=new URLSearchParams(n.search||"");if(!i.has(ih))return!1;i.delete(ih);const l=i.toString();return s.replaceState(s.state??null,"",`${n.pathname||"/"}${l?`?${l}`:""}${n.hash||""}`),!0}catch{return!1}}const d2="nc-update-dismissed";function h2(){try{return typeof sessionStorage<"u"?sessionStorage:null}catch{return null}}function qO(t,e,n){return[t,e,n].map(s=>s||"").join("|")}let rv=null;function KO(t,e,n){const s=n;return t&&e&&t!==e&&t!==s?{kind:"install",version:t,browserVersion:s}:e&&s&&e!==s?{kind:"stale",version:e,browserVersion:s}:null}function VO(t,e){if(!t)return!1;try{return t.getItem(d2)===e}catch{return!1}}function YO(t={}){const e=t.storage===void 0?h2():t.storage;if(rv&&e)try{e.setItem(d2,rv)}catch{}nh=!1,sh=null,k_(),x_()}function GO(t,e,n,s={}){const i=s.storage===void 0?h2():s.storage,l=n,c=qO(t,e,l);rv=c;const u=KO(t,e,l);let h=VO(i,c)?null:u;if(h&&h.kind==="stale"){const v=`${e}|${l}`,_=HO(s.location)===v;let g=!1;if(!_&&i&&i.getItem(vd)!==v){try{i.setItem(vd,v)}catch{}g=i.getItem(vd)===v}g&&(UO(v,{location:s.location,history:s.history}),(s.applyImpl||f2)(),h=null)}const p=JSON.stringify(h)===JSON.stringify(sh);if(sh=h,k_(),p||x_(),!u){try{i&&i.removeItem(vd)}catch{}WO({location:s.location,history:s.history})}}const XO=1200;async function Ax(t){if(typeof fetch=="function")try{await Promise.race([fetch(t,{cache:"reload"}),new Promise(e=>setTimeout(e,XO))])}catch{}}async function f2(){try{Wc&&await Wc.update()}catch{}typeof location<"u"&&(await Ax(location.pathname),await Ax("/version.json"),location.reload())}function JO(t){t.addEventListener("statechange",()=>{t.state==="installed"&&navigator.serviceWorker.controller&&C_(!0)})}function QO(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{c2&&location.reload()}),navigator.serviceWorker.register(zO).then(t=>{Wc=t,t.waiting&&C_(!0),t.addEventListener("updatefound",()=>{const e=t.installing;e&&JO(e)}),setInterval(()=>{t.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function ZO(){c2=!0,C_(!1);const t=Wc&&Wc.waiting;t?(t.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function eB({hash:t="",origin:e="",pathname:n="",search:s=""}={}){const i=String(t||"").replace(/^#/,""),l=`${n||""}${s||""}`;if(!i)return{token:"",pair:"",device:"",nextUrl:l};const c=new URLSearchParams(i),u=c.get("token")||"",h=c.get("device")||"",p=/^[a-f0-9]{32}$/.test(h)?h:"",v=c.get("pair")||"",_=v?`${e||""}${n||""}#pair=${v}`:"";return{token:u,pair:_,device:p,nextUrl:l}}const p2="nc_side_w",Mx="nc_side_min",tB=240,Tx=new Set(["absent","present","active","unknown"]);function nB(){const t=Number(localStorage.getItem(p2));return t>=180&&t<=480?t:tB}function sB(){const t={token:"",pair:""};try{const{token:e,pair:n,device:s,nextUrl:i}=eB({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(e&&(t.token=e,Wx(e,{remember:!0})),s&&P4(s),n){t.pair=n;try{sessionStorage.setItem("nc_pair",n)}catch{}}if(location.hash)try{history.replaceState(null,"",i)}catch{}}catch{}if(t.token||(t.token=ZN()),!t.pair){const e=sessionStorage.getItem("nc_pair");e&&(t.pair=e)}return t}function Px(t){try{return Mi(qg(t))}catch{return uo()}}function Ix(t){if(!t)return"";const e=Math.floor(Date.now()/1e3)-t;return e<0||e<60?"ora":e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h`:`${Math.floor(e/86400)}g`}function iB({showComposer:t,showFiles:e,showPanel:n,hasPanel:s,rendererKind:i,filesSetting:l=null,handlers:c={}}={}){const u=[];return typeof c.onToggleComposer=="function"&&u.push({id:"keyboard",kind:"switch",on:!!t,labelKey:"bar-menu-keyboard",descKey:"bar-menu-keyboard-desc",run:c.onToggleComposer}),typeof c.onToggleFiles=="function"&&u.push(l===null?{id:"files",kind:"switch",on:!!e,labelKey:"bar-menu-files",descKey:"bar-menu-files-desc",run:c.onToggleFiles}:{id:"files",kind:"switch",on:!!l,labelKey:"bar-menu-files",descKey:"bar-menu-files-setting-desc",run:c.onToggleFiles}),s&&typeof c.onTogglePanel=="function"&&u.push({id:"panel",kind:"switch",on:!!n,labelKey:"bar-menu-panel",descKey:"bar-menu-panel-desc",run:c.onTogglePanel}),typeof c.onSwitchRenderer=="function"&&u.push({id:"renderer",kind:"switch",on:i==="webgl",labelKey:"bar-menu-renderer",descKey:"bar-menu-renderer-desc",run:c.onSwitchRenderer}),u}function rB(t,e){if(!t||!t.tmux)return"";const n=Wv(t,e||{});return n.stato==="lavora"?f("cell-working"):n.stato==="attesa"?f("cell-permission"):n.stato==="ferma"?f("cell-idle"):""}const _d=t=>e=>{if(!t||!e[t])return e;const n={...e};return delete n[t],n};function Dx({session:t,node:e,ownerId:n,cellName:s,token:i,readonly:l=!1,panelPort:c=0,onBack:u,onCellSwitcher:h,cellSwitcherOpen:p=!1,liveHost:v=null,side:_=null,onSideClose:g=null,onSideGone:b=null}){var jt;zn();const[S]=Jv(),j=Av(),[C,N]=y.useState(!1),[E,O]=y.useState(null),[x,W]=y.useState(()=>S.showComposer),[$,J]=y.useState(nv),[q,V]=y.useState(()=>Ac()),ie=()=>{Ok(xT(Ac())),typeof window<"u"&&window.location.reload()},[K,B]=y.useState(s||t),[I,D]=y.useState(""),[T,z]=y.useState(""),[R,M]=y.useState(""),[L,H]=y.useState(!1),[A,U]=y.useState(!1),Q=!!_&&A,[ae,re]=y.useState(!1),[je,te]=y.useState({v:{main:1,side:1},h:{main:1,side:1}}),[ne,me]=y.useState(()=>window.matchMedia("(orientation: landscape)").matches);y.useEffect(()=>{const ke=window.matchMedia("(orientation: landscape)"),Le=lt=>me(lt.matches);return ke.addEventListener("change",Le),()=>ke.removeEventListener("change",Le)},[]);const we=ne?je.h:je.v,Fe=y.useRef(we);Fe.current=we;const[Ae,He]=y.useState(null),[X,ce]=y.useState(!0),Z=y.useRef(()=>{}),ge=y.useRef(()=>!1),Y=y.useRef(()=>{}),he=y.useRef(!1),Ne=y.useRef(!1),Ce=y.useRef(null),Ve=y.useRef(null),[Ye,ht]=y.useState(null),[ze,ve]=y.useState({}),Oe=`${e||""}:${t}`,et=_?`${_.node||""}:${_.session}`:"",Ue=y.useRef(Oe);Ue.current=Oe;const st=y.useRef(et);st.current=et;const ot=y.useRef(Ye);ot.current=Ye;const ee=y.useCallback(ke=>{ht(Le=>Le&&Le.source==="main"?{source:"main",ev:ke}:Le),ve(Le=>{var lt;return((lt=ot.current)==null?void 0:lt.source)==="main"?Le:{...Le,[Ue.current]:!0}})},[]),P=y.useCallback(ke=>{ht(Le=>Le&&Le.source==="side"?{source:"side",ev:ke}:Le),ve(Le=>{var lt;return((lt=ot.current)==null?void 0:lt.source)==="side"?Le:{...Le,[st.current]:!0}})},[]),le=!!_&&(Ye==null?void 0:Ye.source)==="side",_e=y.useCallback(()=>{const ke=ot.current;ht(null),ke&&ve(_d(ke.source==="side"?st.current:Ue.current))},[]),Me=ke=>{U(ke),Cn((ke?he:Xt).current),tn((ke?Ne:nn).current)},oe=y.useRef(et);y.useEffect(()=>{const ke=oe.current;oe.current=et,U(!1),re(!1),te({v:{main:1,side:1},h:{main:1,side:1}}),He(null),ht(Le=>Le&&Le.source==="side"?null:Le),ke&&ke!==et&&ve(_d(ke))},[et]);const Be=y.useMemo(()=>{const ke=new Map;return Le=>{if(ke.has(Le))return ke.get(Le);let lt=Le*.6;try{const Yt=document.createElement("span");Yt.style.cssText="position:absolute;visibility:hidden;white-space:pre;font-family:courier-new,courier,monospace;",Yt.style.fontSize=`${Le}px`,Yt.textContent="0".repeat(20),document.body.appendChild(Yt);const De=Yt.getBoundingClientRect().width;document.body.removeChild(Yt),Number.isFinite(De)&&De>0&&(lt=De/20)}catch{}return ke.set(Le,lt),lt}},[]),gt=Math.max(.01,we.main+we.side),Lt=((jt=Ve.current)==null?void 0:jt.clientWidth)||window.innerWidth,Nt=Math.max(0,Lt-12)*(Math.min(we.main,we.side)/gt)-26,kt=!!_&&ne&&Nt/Be(Math.max(1,$))<40,Kt=ke=>J(Le=>o2(Le+ke));y.useEffect(()=>{p||J(nv())},[p]);const ft=y.useRef(()=>{}),Vt=y.useRef(()=>!1),It=y.useRef(()=>{}),Xt=y.useRef(!1),[Dt,Cn]=y.useState(!1),nn=y.useRef(!1),[on,tn]=y.useState(!1),un=y.useRef(null),[Ht,sn]=y.useState(!1),En=()=>{const ke=Q?he:Xt;ke.current=!ke.current,Cn(ke.current)},Qt=()=>{const ke=Q?Ne:nn;ke.current=!ke.current,tn(ke.current)};y.useEffect(()=>{B(s||t),H(!1)},[s,t]);const an=y.useRef(Oe);y.useEffect(()=>{const ke=an.current;an.current=Oe,ke!==Oe&&ve(_d(ke))},[Oe]);const $s=ke=>{const Le=!ke||ke.sessionsError?null:ke.sessionsJson;let lt=null;Le&&Array.isArray(Le.sessions)&&(lt=Le.sessions.find(Pt=>Pt.name===t));const Yt=!ke||ke.fleetError?null:ke.fs;let De=null;Yt&&Yt.available&&Array.isArray(Yt.cells)&&(De=Yt.cells.find(Pt=>Pt.tmuxSession===t)),B($c({session:t,cell:De||(s?{cell:s}:null)})),z(typeof(De==null?void 0:De.panelUrl)=="string"?De.panelUrl.trim():""),M(typeof(De==null?void 0:De.cell)=="string"?De.cell:"");let Je="";De?Je=[`${De.engine}${De.key?`·${De.key}`:""}`,rB(De,lt)].filter(Boolean).join(" · "):lt&&(Je=lt.attached?`attached · ${Ix(lt.activity)}`:lt.activity?Ix(lt.activity):""),D(Je),ce(!!(lt||De))},Vn=y.useRef($s);Vn.current=$s,y.useEffect(()=>{const ke=e?e.split("/"):[],Le=lt=>Vn.current(lt);return Le(ac(ke)),Cc(i,ke,Le)},[e,i]),y.useEffect(()=>{Vn.current(ac(e?e.split("/"):[]))},[t,s]);const Ut=y.useRef(b);Ut.current=b;const zs=ke=>{var be;if(!_)return;const Le=!ke||ke.sessionsError?null:ke.sessionsJson;let lt=null,Yt=!1;Le&&Array.isArray(Le.sessions)&&(Yt=!0,lt=Le.sessions.find(Re=>Re.name===_.session));const De=!ke||ke.fleetError?null:ke.fs;let Je=null,Pt=!1;De&&De.available&&Array.isArray(De.cells)&&(Pt=!0,Je=De.cells.find(Re=>Re.tmuxSession===_.session)),He({title:$c({session:_.session,cell:Je}),present:!!(lt||Je)}),(Yt||Pt)&&!lt&&!Je&&((be=Ut.current)==null||be.call(Ut))},ds=y.useRef(zs);ds.current=zs,y.useEffect(()=>{if(!_){He(null);return}const ke=_.node?_.node.split("/"):[],Le=lt=>ds.current(lt);return Le(ac(ke)),Cc(i,ke,Le)},[_,_==null?void 0:_.node,i]),y.useEffect(()=>{_&&ds.current(ac(_.node?_.node.split("/"):[]))},[_==null?void 0:_.session]);const Yn=Q?"side":"main",xt=Q?et:Oe,ue=()=>{ve(_d(xt)),ht(ke=>ke&&ke.source===Yn?null:{source:Yn,ev:null})},[Ie,Qe]=y.useState(DE),[ct]=y.useState(BE),[At]=y.useState($E),G=iB({showComposer:x,showFiles:(Ye==null?void 0:Ye.source)===Yn,showPanel:L,hasPanel:!!T,rendererKind:q,filesSetting:j?null:Ie,handlers:{onToggleComposer:()=>W(ke=>!ke),onToggleFiles:j?ue:()=>Qe(ke=>(OE(!ke),!ke)),onTogglePanel:()=>H(ke=>!ke),onSwitchRenderer:ie}}),fe=ke=>{ke.preventDefault();const Le=Ve.current;if(!Le)return;const lt=(Ke,at)=>te(wt=>({...wt,[ne?"h":"v"]:{main:Ke,side:at}}));if(ne){const Ke=ke.clientX,at=Fe.current,wt=Le.clientWidth||1,Gn=ae?-1:1,Fs=Xn=>{const Ot=at.main+at.side,ws=(Xn.clientX-Ke)/wt*Ot*Gn,Di=gd(at.main+ws);lt(Di,gd(Ot-Di))},Wt=()=>{window.removeEventListener("pointermove",Fs),window.removeEventListener("pointerup",Wt),window.removeEventListener("pointercancel",Wt),window.removeEventListener("blur",Wt)};window.addEventListener("pointermove",Fs),window.addEventListener("pointerup",Wt),window.addEventListener("pointercancel",Wt),window.addEventListener("blur",Wt);return}const Yt=ke.clientY,De=Fe.current,Je=Le.clientHeight||1,Pt=ae?-1:1,be=Ke=>{const at=De.main+De.side,wt=(Ke.clientY-Yt)/Je*at*Pt,Gn=gd(De.main+wt);lt(Gn,gd(at-Gn))},Re=()=>{window.removeEventListener("pointermove",be),window.removeEventListener("pointerup",Re),window.removeEventListener("pointercancel",Re),window.removeEventListener("blur",Re)};window.addEventListener("pointermove",be),window.addEventListener("pointerup",Re),window.addEventListener("pointercancel",Re),window.addEventListener("blur",Re)},Te=_&&a.jsxs("div",{className:`nc-dual-pane${Q?"":" foco"}${kt&&Q?" nascosto":""}`,"data-testid":"pane-main",style:{flexGrow:we.main,flexBasis:ne?0:void 0},onPointerDown:()=>Me(!1),children:[a.jsxs("div",{className:"nc-dual-strip",children:[a.jsx("span",{className:`nc-dual-dot${X?" on":""}`,"aria-hidden":"true"}),a.jsx("b",{children:K}),!Q&&a.jsx("span",{className:"nc-dual-matita","aria-hidden":"true",title:f("dual-focus"),children:"✎"}),kt&&a.jsxs("button",{type:"button",className:"nc-dual-alt",title:f("dual-go-to").replace("{cell}",(Ae==null?void 0:Ae.title)||_.session),"aria-label":f("dual-go-to").replace("{cell}",(Ae==null?void 0:Ae.title)||_.session),onPointerDown:ke=>ke.stopPropagation(),onClick:ke=>{ke.stopPropagation(),Me(!Q)},children:[a.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true",focusable:"false",children:[a.jsx("rect",{x:"3.5",y:"6",width:"17",height:"12",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),a.jsx("rect",{x:"3.5",y:"6",width:"8.5",height:"12",fill:"currentColor"})]}),a.jsx("span",{className:`nc-dual-dot${Ae!=null&&Ae.present?" on":""}`,"aria-hidden":"true"})]})]}),a.jsx("div",{className:"nc-dual-body",children:a.jsx(wc,{session:t,node:e,token:i,readonly:l,takeSize:!0,focused:!Q,sendRef:ft,composerRef:Vt,actionRef:It,ctrlRef:Xt,setCtrlArmed:Cn,altRef:nn,setAltArmed:tn,keyboardRef:un,onFiles:ee,fontSize:$,selectionMode:Ht,onSelectionModeChange:sn,keyboardGesture:S.terminalKeyboardGesture,onRendererChange:V})})]},"pane-main"),Ze=_&&a.jsxs("div",{className:`nc-dual-pane${Q?" foco":""}${kt&&!Q?" nascosto":""}`,"data-testid":"pane-side",style:{flexGrow:we.side,flexBasis:ne?0:void 0},onPointerDown:()=>Me(!0),children:[a.jsxs("div",{className:"nc-dual-strip",children:[a.jsx("span",{className:`nc-dual-dot${Ae!=null&&Ae.present?" on":""}`,"aria-hidden":"true"}),a.jsx("b",{children:Ae?Ae.title:_.session}),Q&&a.jsx("span",{className:"nc-dual-matita","aria-hidden":"true",title:f("dual-focus"),children:"✎"}),a.jsxs("span",{className:"nc-dual-tasti",children:[a.jsx("button",{type:"button",title:f("dual-swap"),"aria-label":f("dual-swap"),onPointerDown:ke=>ke.stopPropagation(),onClick:ke=>{ke.stopPropagation(),re(Le=>!Le)},children:ne?"⇆":"⇅"}),a.jsx("button",{type:"button",title:f("dual-close"),"aria-label":f("dual-close"),onPointerDown:ke=>ke.stopPropagation(),onClick:ke=>{ke.stopPropagation(),g==null||g()},children:"✕"})]}),kt&&a.jsxs("button",{type:"button",className:"nc-dual-alt",title:f("dual-go-to").replace("{cell}",K),"aria-label":f("dual-go-to").replace("{cell}",K),onPointerDown:ke=>ke.stopPropagation(),onClick:ke=>{ke.stopPropagation(),Me(!Q)},children:[a.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true",focusable:"false",children:[a.jsx("rect",{x:"3.5",y:"6",width:"17",height:"12",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),a.jsx("rect",{x:"12",y:"6",width:"8.5",height:"12",fill:"currentColor"})]}),a.jsx("span",{className:`nc-dual-dot${X?" on":""}`,"aria-hidden":"true"})]})]}),a.jsx("div",{className:"nc-dual-body",children:a.jsx(wc,{session:_.session,node:_.node,token:i,readonly:l,takeSize:!1,focused:Q,sendRef:Z,composerRef:ge,actionRef:Y,ctrlRef:he,setCtrlArmed:Cn,altRef:Ne,setAltArmed:tn,keyboardRef:Ce,onFiles:P,fontSize:$,selectionMode:Ht,onSelectionModeChange:sn,keyboardGesture:S.terminalKeyboardGesture})})]},"pane-side"),Pe=a.jsx("div",{className:"nc-dual-handle","data-testid":"dual-handle",role:"separator","aria-orientation":ne?"vertical":"horizontal",onPointerDown:fe},"dual-handle");return a.jsxs("div",{className:"nc-app",children:[a.jsxs("header",{className:"nc-bar nc-bar-single",children:[a.jsxs("button",{onClick:u,title:f("sessions"),children:[a.jsx(_t,{name:"chevronLeft",size:18}),a.jsx("span",{className:"nc-bar-label",children:f("sessions")})]}),a.jsxs("span",{className:"nc-bar-center",children:[a.jsx("b",{title:e?`${K} · ${e}`:K,children:K}),v&&v.cell&&v.cell===s?a.jsx("span",{className:`nc-live-host-dot ${mv(v)} nc-live-host-dot-header`,"data-testid":"live-host-header-dot",title:f("live-host-indicator").replace("{cell}",v.cell).replace("{mode}",f(v.mode?`live-host-mode-${v.mode}`:"live-host-mode-unknown")).replace("{state}",f(`live-host-state-${v.state}`))}):null,I&&a.jsx("small",{className:"nc-bar-sub",children:I})]}),a.jsxs("span",{className:"nc-bar-right",children:[a.jsx("button",{onClick:()=>Kt(-1),title:f("zoom-out"),"aria-label":f("zoom-out"),children:a.jsx(_t,{name:"zoomOut",size:18})}),a.jsx("button",{onClick:()=>Kt(1),title:f("zoom-in"),"aria-label":f("zoom-in"),children:a.jsx(_t,{name:"zoomIn",size:18})}),Ie&&a.jsxs("button",{type:"button",className:"nc-bar-files",onClick:ue,title:f("bar-menu-files"),"aria-label":f("bar-menu-files"),"aria-pressed":(Ye==null?void 0:Ye.source)===Yn?"true":"false",children:[a.jsx(_t,{name:"folder",size:18}),ze[xt]&&(Ye==null?void 0:Ye.source)!==Yn&&a.jsx("span",{className:"nc-bar-dot-nuovi","data-testid":"bar-files-dot",title:f("new-files-outbox"),"aria-label":f("new-files-outbox")})]}),ct&&a.jsx("button",{type:"button",onClick:()=>W(ke=>!ke),title:f("bar-menu-keyboard"),"aria-label":f("bar-menu-keyboard"),"aria-pressed":x?"true":"false",children:a.jsx(_t,{name:"keyboard",size:18})}),T&&At&&a.jsx("button",{type:"button",onClick:()=>H(ke=>!ke),title:f("bar-menu-panel"),"aria-label":f("bar-menu-panel"),"aria-pressed":L?"true":"false",children:a.jsx(_t,{name:"monitor",size:18})}),a.jsx("button",{type:"button",className:`nc-bar-menu${C?" on":""}`,title:f("bar-menu-open"),"aria-label":f("bar-menu-open"),"aria-haspopup":"menu","aria-expanded":C?"true":"false",onClick:ke=>{C||O(ke.currentTarget.getBoundingClientRect()),N(Le=>!Le)},children:"⋯"})]})]}),a.jsxs("div",{className:"nc-termwrap",children:[_?a.jsx("div",{className:`nc-dual${ne?" row":""}`,ref:Ve,children:kt?ae?[Ze,Te]:[Te,Ze]:ae?[Ze,Pe,Te]:[Te,Pe,Ze]}):a.jsx(wc,{session:t,node:e,token:i,readonly:l,takeSize:!0,sendRef:ft,composerRef:Vt,actionRef:It,ctrlRef:Xt,setCtrlArmed:Cn,altRef:nn,setAltArmed:tn,keyboardRef:un,onFiles:ee,fontSize:$,selectionMode:Ht,onSelectionModeChange:sn,keyboardGesture:S.terminalKeyboardGesture,onRendererChange:V}),L&&T&&R&&a.jsx(Mv,{cellId:R,panelUrl:T,route:e?e.split("/"):[],panelPort:c,token:i,title:K})]}),a.jsx(VI,{onKeyboard:()=>W(ke=>!ke),onCellSwitcher:h,cellSwitcherOpen:p,send:ke=>(Q?Z:ft).current(ke),action:ke=>(Q?Y:It).current(ke),ctrlArmed:Dt,onCtrl:En,altArmed:on,onAlt:Qt,onAltConsume:()=>{const ke=Q?Ne:nn;ke.current=!1,tn(!1)},onKeyboardKeep:()=>{var ke,Le;return(Le=(ke=Q?Ce:un).current)==null?void 0:Le.call(ke)},selectionMode:Ht,onSelectionMode:sn,keepKeyboardClosed:S.keybarKeepsKeyboardClosed,showEnter:S.showKeybarEnter,keybarLayout:S.keybarLayout}),x&&a.jsx(UC,{submitText:ke=>(Q?ge:Vt).current(ke),token:i,session:Q?_.session:t,node:Q?_.node:e,ownerId:Q?_.ownerId:n,readonly:l,keepKeyboardClosedOnVoice:S.voiceKeepsKeyboardClosed}),Ye&&(le?a.jsx(zg,{session:_.session,node:_.node,token:i,filesEvent:Ye.ev,onClose:_e}):Ye.source==="main"?a.jsx(zg,{session:t,node:e,token:i,filesEvent:Ye.ev,onClose:_e}):null),C&&(j?a.jsx(aC,{anchorRect:E,items:G,onClose:()=>N(!1)}):a.jsx(Uv,{cellName:K,items:G,onClose:()=>N(!1)}))]})}function oB(){zn();const[t]=y.useState(sB),[e,n]=y.useState(t.token),[s,i]=y.useState(!1);W4(s?"":e);const l=y.useRef(t.token);l.current=e,y.useEffect(()=>{const be=Re=>{Re&&Re.detail&&Re.detail.token===l.current&&i(!0)};return window.addEventListener(Cm,be),()=>window.removeEventListener(Cm,be)},[]);const c=y.useCallback((be,Re)=>{const Ke=Wx(be,{remember:Re});if(!Ke.ok||Re&&Ke.where!=="local")try{window.dispatchEvent(new CustomEvent(Em))}catch{}i(!1),n(be)},[]),[u,h]=y.useState(t.pair||""),p=y.useCallback(()=>{h("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),v=Av(),[_]=y.useState(()=>JD(typeof location<"u"?location.pathname:"/")),[g,b]=y.useState(_.id),S=g===qo(null,ii),[j,C]=y.useState(null),N=be=>{const Re=jr(be);C(Re?{...Re,...typeof(be==null?void 0:be.cellName)=="string"&&be.cellName?{cellName:be.cellName}:{}}:null)},[E,O]=y.useState(null);y.useEffect(()=>{const be=LO();O(be&&j&&sv(be.main,j)?be.side:null)},[j]);const x=be=>{const Re=j?{session:j.session,node:j.node}:null,Ke=jO(Re,E,be);O(Ke),Ke?RO(Re,Ke):Nx()},W=()=>{O(null),Nx()},[$,J]=y.useState([]),[q,V]=y.useState(!0),[ie,K]=y.useState(null),[B,I]=y.useState([]),[D,T]=y.useState([]),[z,R]=y.useState(!1),[M,L]=y.useState(null),[H,A]=y.useState(()=>_.ownerId?uo():Px(_.name)),[U,Q]=y.useState(null),[ae,re]=y.useState(null),je=be=>re(jr(be)),[te,ne]=y.useState(null),me=Bv(e,v),we=y.useMemo(()=>(me||[]).filter(be=>be.instanceId).map(be=>({instanceId:be.instanceId,route:be.route,label:be.label,status:be.status,stale:be.stale===!0,checking:be.checking===!0})),[me]),{order:Fe}=bh(),Ae=$O(e,g,H,A,we,Fe),{notice:He,showActionNotice:X}=CC(),ce=Ae.decks;y.useEffect(()=>{const be=new Map;for(const Re of me||[]){const Ke=(Re.route||[Re.name]).join("/"),at=new Set((Re.sessions||[]).map(wt=>wt.name));for(const wt of Re.cells||[])!wt.cell||!wt.tmuxSession||wt.cell===wt.tmuxSession||at.has(wt.cell)||be.set(`${Ke}:${wt.cell}`,`${Ke}:${wt.tmuxSession}`)}A(Re=>dI(Re,be))},[me]),y.useEffect(()=>{Ae.localNodeId&&_.ownerId&&_.ownerId===Ae.localNodeId&&A(be=>be.columns.some(Re=>Re.tiles.length)?be:Px(_.name))},[Ae.localNodeId]),y.useEffect(()=>{Ae.localNodeId&&(KD(we),Ae.viewUpdate(be=>{const Re=qa(be,Ae.localNodeId,we);return JSON.stringify(Re)===JSON.stringify(be)?be:Re}))},[we,Ae.localNodeId,Ae.viewUpdate]);const[Z,ge]=y.useState(null),[Y,he]=y.useState(null),Ne=y.useRef(0),[Ce,Ve]=y.useState(!1),[Ye,ht]=y.useState(nB),[ze,ve]=y.useState(!S),[Oe,et]=y.useState(()=>S?localStorage.getItem(Mx)==="1":!0),[Ue,st]=y.useState(!1),[ot,ee]=y.useState("nodes"),[P,le]=y.useState(!1),[_e,Me]=y.useState(""),[oe,Be]=y.useState(!1),gt=(be="nodes",Re=!1,Ke="")=>{ee(be),le(Re),Me(Ke),st(!0)},[Lt,Nt]=y.useState(!1),[kt,Kt]=y.useState(null),[ft,Vt]=y.useState({deviceDefault:"",localNodeId:"",localNameDefault:"",deviceNameNeeded:!1,deviceNameSuggestion:""}),[It,Xt]=y.useState(""),[Dt,Cn]=y.useState(!1),[nn,on]=y.useState(0),[tn,un]=y.useState({});y.useEffect(()=>{try{localStorage.setItem(p2,String(Ye))}catch{}},[Ye]),y.useEffect(()=>{try{localStorage.setItem(Mx,Oe?"1":"")}catch{}},[Oe]),y.useEffect(()=>{if(!e)return;let be=!1;return Promise.all([Qx(e),qn("/api/config",e).then(Re=>Re.json())]).then(([Re,Ke])=>{if(!be){if(Vt({deviceDefault:Re.deviceName||"",localNodeId:Re.nodeId||"",localNameDefault:Re.localName||"",deviceNameNeeded:Re.deviceNameNeeded===!0,deviceNameSuggestion:Re.deviceNameSuggestion||""}),Xt(Re.deviceName||""),Cn(!!Ke.readonlyDefault),NT(Ke.terminal),on(Number.isInteger(Ke.panelPort)?Ke.panelPort:0),un(Ke.nodePanelPorts&&typeof Ke.nodePanelPorts=="object"&&!Array.isArray(Ke.nodePanelPorts)?Ke.nodePanelPorts:{}),vP(Ke.hostOnlyNodes),Re.firstRun===!0&&!Ke.readonlyDefault)Nt(!0);else if(u)Nt(!0);else if(Re.deviceNameNeeded===!0&&!Ke.readonlyDefault){let at=!1;try{at=sessionStorage.getItem("nc_device_ask_later")==="1"}catch{}at||Kt({suggestion:Re.deviceNameSuggestion||""})}}}).catch(()=>{}),()=>{be=!0}},[e,u]);const[Ht,sn]=y.useState({}),En=y.useCallback(({route:be,hostCell:Re,revision:Ke})=>{const at=Ls(be);sn(wt=>({...wt,[at]:{hostCell:Re||null,hostLease:null,hostRevision:Number.isInteger(Ke)?Ke:(wt[at]||{}).hostRevision||0,threadStatus:"absent"}}))},[]),Qt=be=>{const Re=Ls(be),Ke=be.length?((me||[]).find(at=>Ls(Array.isArray(at.route)?at.route:[])===Re)||{}).cells||[]:B;return Va({liveHost:Ht[Re]||null,cells:Ke,localNodeId:Ae.localNodeId,ownerId:be.length?Re:Ae.localNodeId})},an=y.useRef(me);y.useEffect(()=>{an.current=me},[me]);const $s=y.useRef(null);$s.current||($s.current=uh());const Vn=3500;y.useEffect(()=>{let be=!1;const Re=async()=>{const at=$s.current,wt=at.begin();if(wt!==null)try{const Gn=[[],...(an.current||[]).filter(Wt=>Wt.kind!=="vl"&&Wt.status==="up").map(Wt=>Array.isArray(Wt.route)&&Wt.route.length?Wt.route:[Wt.name])],Fs=await Promise.all(Gn.map(async Wt=>{const Xn=Ls(Wt);try{const Ot=await ah(e,Wt,{timeoutMs:Vn});return[Xn,{hostCell:Ot&&typeof Ot.hostCell=="string"?Ot.hostCell:null,hostLease:Ot&&Ot.host&&typeof Ot.host.lease=="string"?Ot.host.lease:null,hostRevision:Number.isInteger(Ot&&Ot.revision)?Ot.revision:0,threadStatus:Ot&&Tx.has(Ot.threadStatus)?Ot.threadStatus:"unknown"}]}catch{return[Xn,{error:!0}]}}));if(be||!at.isCurrent(wt))return;sn(Wt=>{let Xn=!1;const Ot={...Wt};for(const ws of Fs){if(!ws)continue;const[Di,ir]=ws;Ot[Di]=ir.error?{...Wt[Di]||{},threadStatus:"unknown"}:ir,Xn=!0}return Xn?Ot:Wt})}finally{at.end(wt)}};Re();const Ke=setInterval(Re,4e3);return()=>{be=!0,clearInterval(Ke),$s.current.reset()}},[e]),y.useEffect(()=>{if(!v)return;const be=Re=>{if(!Re)return;const Ke=Re.sessionsError?null:Re.sessionsJson;Ke&&!Ke.error?(J(Ke.sessions||[]),V(!0),K(Re.at)):V(!1);const at=yh({fs:Re.fs,error:Re.fleetError});at.kind==="data"?(Ga("local",at.cells),I(at.cells),T(at.capabilities),R(!1),L(null)):at.kind==="stale"?(I(wt=>wt.length?wt:Dv("local")),R(!0),L(null)):(I([]),Ga("local",[]),T([]),R(!1),L(at.reason||""))};return be(ac([])),Cc(e,[],be)},[v,e]);const Ut=y.useCallback(async(be,Re=[])=>{const Ke=Ls(Re),at=Ht[Ke]&&Ht[Ke].hostRevision||0;try{const wt=await lh(e,be,at,Re);return sn(Gn=>({...Gn,[Ke]:{hostCell:wt.hostCell||null,hostLease:wt.host&&typeof wt.host.lease=="string"?wt.host.lease:null,hostRevision:Number.isInteger(wt.revision)?wt.revision:at,threadStatus:Tx.has(wt.threadStatus)?wt.threadStatus:"unknown"}})),{ok:!0}}catch(wt){return{ok:!1,error:wt}}},[e,Ht]),zs=y.useCallback(async(be,Re=[])=>{const Ke=await Ut(be,Re);return Ke.ok||window.alert(f(Lm(Ke.error))),Ke.ok},[Ut]),ds=y.useCallback(async(be=[])=>{const Re=Ls(be),Ke=Ht[Re]&&Ht[Re].hostRevision||0;try{const at=await ch(e,Ke,be);return sn(wt=>({...wt,[Re]:{hostCell:at.hostCell||null,hostLease:null,hostRevision:Number.isInteger(at.revision)?at.revision:Ke,threadStatus:"unknown"}})),{ok:!0}}catch(at){return{ok:!1,error:at}}},[e,Ht]),Yn=y.useCallback(async(be=[])=>{const Re=await ds(be);return Re.ok||window.alert(f(Lm(Re.error))),Re.ok},[ds]);y.useEffect(()=>{let be=!1;const Re=()=>{qn("/api/config",e).then(at=>at.json()).then(at=>{be||GO(at.version,at.uiVersion,"0.9.76")}).catch(()=>{})};Re();const Ke=setInterval(Re,6e4);return()=>{be=!0,clearInterval(Ke)}},[e]);const xt=new Set([...$.map(be=>be.name),...me.flatMap(be=>be.sessions.map(Re=>Re.key))]),ue=y.useMemo(()=>{const be=new Map;for(const Re of $)Re&&typeof Re.name=="string"&&Number.isFinite(Re.created)&&be.set(Re.name,Re.created);return be},[$]),Ie=ys(H),Qe=be=>A(Re=>{const Ke=XC(be,Ae.localNodeId,we)||be,at=gC(Re,Ke);return at===Re&&ys(Re).length>=9&&Ae.setError(f("grid-full")),at}),ct=async(be,Re=[])=>{try{await cv(e,be,Re)}catch{return}const Ke=Re.length?`${Re.join("/")}:${be}`:be;A(at=>Oc(at,Ke)),lc(Re,e)},At=async(be,Re,Ke=[])=>{try{await Jx(e,be,Re,Ke)}catch{return}lc(Ke,e)},G=async(be,Re,Ke=[])=>{await Yx(e,{cell:be,enabled:!!Re},Ke),lc(Ke,e)},fe=async be=>{if(!Z)return;const{cell:Re}=Z,Ke=Array.isArray(Z.route)?Z.route:[];if(!await Vv({token:e,powerCell:Z,payload:be,onNotice:X})){const wt=be.action==="up"?!!be.boot:be.boot?!1:!!Z.boot;he({id:++Ne.current,cell:Re,route:Ke,enabled:wt})}lc(Ke,e)},Te=y.useCallback(be=>{he(Re=>(Re==null?void 0:Re.id)===be?null:Re)},[]),Ze=async be=>{if(!(!(be!=null&&be.direct)||Ce)){Ve(!0);try{await hv(e,be.name,be.tunnelStatus==="up"?"down":"up")}finally{Ve(!1)}}},Pe=async(be,Re)=>{const Ke=String(Re||"").trim();return!(be!=null&&be.direct)||!Ja(Ke)?!1:(await n1(e,be.name,Ke),!0)},jt=be=>{const Re=ce.find(Ke=>Ke.id===be);if(!Re)return!1;try{const Ke=window.open(Up(Re,e),"_blank");return Ke&&(Ke.opener=null),!!Ke}catch{return!1}},ke=async be=>{if(!be||be===g)return;const Re=await Ae.select(be),Ke=Ae.records.find(at=>at.id===be);b(be),A(Re),Q(null),re(null);try{history.replaceState(null,"",Up(Ke||be,null))}catch{}},Le=async(be,Re)=>{const Ke=await Ae.add(be,Re);await ke(Ke.id)},lt=async(be,Re)=>{const Ke=await Ae.rename(be,Re);if(be===g){b(Ke.id),A(Ae.vistaMaterializzata(Ke)),Q(null),re(null);try{history.replaceState(null,"",Up(Ke,null))}catch{}}},Yt=async be=>{await Ae.remove(be),be===g&&await ke(Ae.localMainId)},De=async(be,Re)=>{!Re||Re===g||(await Ae.addTileTo(Re,be),A(Ke=>Oc(Ke,be)))};if(!e||s)return a.jsx(TO,{onSubmit:c,reason:s?"invalid":""});const Je=a.jsxs(a.Fragment,{children:[Ue&&a.jsx(sO,{token:e,initialTab:ot,initialLocation:_e,startNewCell:P,onClose:()=>{st(!1),le(!1),Me("")}}),Lt&&a.jsx(iO,{token:e,initialPair:u,...ft,onPairDone:p,onDone:()=>Nt(!1)}),kt&&a.jsx(rO,{token:e,suggestion:kt.suggestion,onSaved:be=>{Xt(be),Vt(Re=>({...Re,deviceDefault:be,deviceNameNeeded:!1})),Kt(null)},onLater:()=>{try{sessionStorage.setItem("nc_device_ask_later","1")}catch{}Kt(null)}}),a.jsx(yO,{token:e})]});if(!v)return te?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"nc-single-overlay",children:a.jsx(Ex,{peer:te,token:e,onBack:()=>ne(null)})}),Je]}):j?a.jsxs(a.Fragment,{children:[a.jsx(Dx,{session:j.session,node:j.node,ownerId:j.ownerId,cellName:j.cellName,token:e,readonly:Dt,liveHost:Qt(j.node?j.node.split("/"):[]),panelPort:Tc(j.node?j.node.split("/"):[],tn,nn),side:E,onSideClose:W,onSideGone:W,onBack:()=>C(null),onCellSwitcher:()=>Be(!0),cellSwitcherOpen:oe}),oe&&a.jsx(kO,{token:e,current:j,localNodeLabel:It,panelPort:nn,nodePanelPorts:tn,hostByRoute:Ht,onDesignateCell:Ut,onClearHostCell:ds,onLiveHostApplied:En,sideKey:E?Ic(E.node?E.node.split("/"):[],E.session):null,onToggleSide:x,onPick:be=>{N(be),Be(!1)},onClose:()=>Be(!1)}),Je]}):a.jsxs(a.Fragment,{children:[a.jsx(FI,{onPick:N,token:e,onSettings:gt,onOpenVlSession:ne,panelPort:nn,nodePanelPorts:tn,hostByRoute:Ht,onDesignateCell:zs,onClearHostCell:Yn}),Je]});const Pt=S||!ze;return a.jsxs("div",{className:"nc-workspace",children:[Pt&&a.jsx(AD,{sessions:$,cells:B,localVerified:q,activeSessions:Ie,nodeGroups:me,token:e,onPeekOpen:()=>Be(!1),overlayOpen:oe,fleetCapabilities:D,fleetStale:z,fleetOff:M,bootSettlement:Y,onBootSettlementApplied:Te,localNodeId:Ae.localNodeId,hostByRoute:Ht,onDesignateCell:zs,onClearHostCell:Yn,onPick:je,onAddTile:Qe,onPower:ge,onBoot:G,onBootError:be=>Ae.setError(String((be==null?void 0:be.message)||be)),onNodePower:Ze,onNodeRename:Pe,onKill:ct,onVisibility:At,onNew:()=>gt("fleet",!0),onSettings:gt,onOpenVlSession:ne,width:Ye,collapsed:Oe,onResize:ht,onToggleCollapse:()=>et(be=>!be)}),a.jsxs("div",{className:"nc-workspace-main",children:[a.jsx(w3,{decks:ce,currentDeck:g,onCreate:Le,onRename:lt,onDelete:Yt,onReorder:Ae.reorder,onOpenWindow:jt,onNavigate:ke,saveState:Ae.saveState,error:Ae.error,conflict:Ae.conflict,onReloadDeck:Ae.reloadCurrent,sidebarVisible:Pt,onToggleSidebar:S?null:()=>ve(be=>!be)}),He&&a.jsx("div",{className:"nc-notice nc-deck-notice",role:"status",title:He,children:He}),a.jsx(qD,{layout:H,onLayoutChange:A,onResizeEnd:()=>{Ae.saveNow()},token:e,readonly:Dt,sessionsAlive:xt,localVerified:q,localIdentities:ue,localVerifiedAt:ie,focusSession:U,onFocus:Q,onOpenSingle:je,decks:ce,currentDeck:g,onSendToDeck:De,cells:B,nodeGroups:me,panelPort:nn,nodePanelPorts:tn})]}),te&&a.jsx("div",{className:"nc-single-overlay",children:a.jsx(Ex,{peer:te,token:e,onBack:()=>ne(null)})}),ae&&a.jsx("div",{className:"nc-single-overlay",children:a.jsx(Dx,{session:ae.session,node:ae.node,ownerId:ae.ownerId,cellName:$c({session:ae.session,node:ae.node,ownerId:ae.ownerId,cells:B,nodeGroups:me}),token:e,readonly:Dt,liveHost:Qt(ae.node?ae.node.split("/"):[]),panelPort:Tc(ae.node?ae.node.split("/"):[],tn,nn),onBack:()=>re(null)})}),Z&&a.jsx(Wd,{cell:Z,token:e,route:Array.isArray(Z.route)?Z.route:[],onConfirm:fe,onClose:()=>ge(null)}),Je]})}function aB(t){return t.kind==="install"?f("update-installed-restart").replace("{v}",t.version):t.kind==="stale"?f("update-stale").replace("{ui}",t.version).replace("{browser}",t.browserVersion):f("update-available").replace("{v}",t.version).replace(" "," ").trim()}function lB(){zn();const t=y.useSyncExternalStore(FO,Rx,Rx);return t.needed?a.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[a.jsx("span",{className:"nc-update-msg",children:aB(t)}),t.kind==="stale"&&a.jsx("button",{className:"nc-update-btn",onClick:f2,children:f("reload-no-cache")}),t.kind==="reload"&&a.jsx("button",{className:"nc-update-btn",onClick:ZO,children:f("reload")}),a.jsx("button",{className:"nc-update-close",onClick:YO,"aria-label":f("update-dismiss"),title:f("update-dismiss"),children:"×"})]}):null}function cB(){zn();const[t,e]=y.useState(!1);return y.useEffect(()=>{const n=()=>e(!0);return window.addEventListener(Em,n),()=>window.removeEventListener(Em,n)},[]),t?a.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[a.jsx("span",{className:"nc-update-msg",children:f("auth-not-remembered")}),a.jsx("button",{className:"nc-update-close",onClick:()=>e(!1),"aria-label":f("update-dismiss"),title:f("update-dismiss"),children:"×"})]}):null}QO();j4();JN.createRoot(document.getElementById("root")).render(a.jsxs(WN.StrictMode,{children:[a.jsx(oB,{}),a.jsx(lB,{}),a.jsx(cB,{})]}));