@mmmbuto/nexuscrew 0.9.48 → 0.9.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/frontend/dist/assets/index-BDdWDcTt.js +169 -0
- package/frontend/dist/assets/index-CcZskBmy.css +32 -0
- package/frontend/dist/index.html +2 -2
- package/frontend/dist/version.json +1 -1
- package/lib/decks/routes.js +15 -0
- package/lib/decks/store.js +64 -3
- package/lib/settings/routes.js +56 -15
- package/package.json +1 -1
- package/frontend/dist/assets/index-BG_Hkrm6.js +0 -169
- package/frontend/dist/assets/index-BaqhMxzK.css +0 -32
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const c of a.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&i(c)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function i(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function Tm(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Xh={exports:{}},dl={},Qh={exports:{}},Pt={};/**
|
|
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 X_;function Xk(){if(X_)return Pt;X_=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),_=Symbol.iterator;function y(D){return D===null||typeof D!="object"?null:(D=_&&D[_]||D["@@iterator"],typeof D=="function"?D:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,A={};function C(D,q,ce){this.props=D,this.context=q,this.refs=A,this.updater=ce||w}C.prototype.isReactComponent={},C.prototype.setState=function(D,q){if(typeof D!="object"&&typeof D!="function"&&D!=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,D,q,"setState")},C.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function N(){}N.prototype=C.prototype;function k(D,q,ce){this.props=D,this.context=q,this.refs=A,this.updater=ce||w}var O=k.prototype=new N;O.constructor=k,S(O,C.prototype),O.isPureReactComponent=!0;var P=Array.isArray,H=Object.prototype.hasOwnProperty,W={current:null},U={key:!0,ref:!0,__self:!0,__source:!0};function G(D,q,ce){var ge,se={},we=null,_e=null;if(q!=null)for(ge in q.ref!==void 0&&(_e=q.ref),q.key!==void 0&&(we=""+q.key),q)H.call(q,ge)&&!U.hasOwnProperty(ge)&&(se[ge]=q[ge]);var fe=arguments.length-2;if(fe===1)se.children=ce;else if(1<fe){for(var ie=Array(fe),de=0;de<fe;de++)ie[de]=arguments[de+2];se.children=ie}if(D&&D.defaultProps)for(ge in fe=D.defaultProps,fe)se[ge]===void 0&&(se[ge]=fe[ge]);return{$$typeof:t,type:D,key:we,ref:_e,props:se,_owner:W.current}}function X(D,q){return{$$typeof:t,type:D.type,key:q,ref:D.ref,props:D.props,_owner:D._owner}}function Q(D){return typeof D=="object"&&D!==null&&D.$$typeof===t}function V(D){var q={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(ce){return q[ce]})}var T=/\/+/g;function I(D,q){return typeof D=="object"&&D!==null&&D.key!=null?V(""+D.key):q.toString(36)}function $(D,q,ce,ge,se){var we=typeof D;(we==="undefined"||we==="boolean")&&(D=null);var _e=!1;if(D===null)_e=!0;else switch(we){case"string":case"number":_e=!0;break;case"object":switch(D.$$typeof){case t:case e:_e=!0}}if(_e)return _e=D,se=se(_e),D=ge===""?"."+I(_e,0):ge,P(se)?(ce="",D!=null&&(ce=D.replace(T,"$&/")+"/"),$(se,q,ce,"",function(de){return de})):se!=null&&(Q(se)&&(se=X(se,ce+(!se.key||_e&&_e.key===se.key?"":(""+se.key).replace(T,"$&/")+"/")+D)),q.push(se)),1;if(_e=0,ge=ge===""?".":ge+":",P(D))for(var fe=0;fe<D.length;fe++){we=D[fe];var ie=ge+I(we,fe);_e+=$(we,q,ce,ie,se)}else if(ie=y(D),typeof ie=="function")for(D=ie.call(D),fe=0;!(we=D.next()).done;)we=we.value,ie=ge+I(we,fe++),_e+=$(we,q,ce,ie,se);else if(we==="object")throw q=String(D),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.");return _e}function j(D,q,ce){if(D==null)return D;var ge=[],se=0;return $(D,ge,"","",function(we){return q.call(ce,we,se++)}),ge}function M(D){if(D._status===-1){var q=D._result;q=q(),q.then(function(ce){(D._status===0||D._status===-1)&&(D._status=1,D._result=ce)},function(ce){(D._status===0||D._status===-1)&&(D._status=2,D._result=ce)}),D._status===-1&&(D._status=0,D._result=q)}if(D._status===1)return D._result.default;throw D._result}var L={current:null},R={transition:null},E={ReactCurrentDispatcher:L,ReactCurrentBatchConfig:R,ReactCurrentOwner:W};function z(){throw Error("act(...) is not supported in production builds of React.")}return Pt.Children={map:j,forEach:function(D,q,ce){j(D,function(){q.apply(this,arguments)},ce)},count:function(D){var q=0;return j(D,function(){q++}),q},toArray:function(D){return j(D,function(q){return q})||[]},only:function(D){if(!Q(D))throw Error("React.Children.only expected to receive a single React element child.");return D}},Pt.Component=C,Pt.Fragment=n,Pt.Profiler=s,Pt.PureComponent=k,Pt.StrictMode=i,Pt.Suspense=h,Pt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=E,Pt.act=z,Pt.cloneElement=function(D,q,ce){if(D==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+D+".");var ge=S({},D.props),se=D.key,we=D.ref,_e=D._owner;if(q!=null){if(q.ref!==void 0&&(we=q.ref,_e=W.current),q.key!==void 0&&(se=""+q.key),D.type&&D.type.defaultProps)var fe=D.type.defaultProps;for(ie in q)H.call(q,ie)&&!U.hasOwnProperty(ie)&&(ge[ie]=q[ie]===void 0&&fe!==void 0?fe[ie]:q[ie])}var ie=arguments.length-2;if(ie===1)ge.children=ce;else if(1<ie){fe=Array(ie);for(var de=0;de<ie;de++)fe[de]=arguments[de+2];ge.children=fe}return{$$typeof:t,type:D.type,key:se,ref:we,props:ge,_owner:_e}},Pt.createContext=function(D){return D={$$typeof:c,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},D.Provider={$$typeof:a,_context:D},D.Consumer=D},Pt.createElement=G,Pt.createFactory=function(D){var q=G.bind(null,D);return q.type=D,q},Pt.createRef=function(){return{current:null}},Pt.forwardRef=function(D){return{$$typeof:d,render:D}},Pt.isValidElement=Q,Pt.lazy=function(D){return{$$typeof:g,_payload:{_status:-1,_result:D},_init:M}},Pt.memo=function(D,q){return{$$typeof:f,type:D,compare:q===void 0?null:q}},Pt.startTransition=function(D){var q=R.transition;R.transition={};try{D()}finally{R.transition=q}},Pt.unstable_act=z,Pt.useCallback=function(D,q){return L.current.useCallback(D,q)},Pt.useContext=function(D){return L.current.useContext(D)},Pt.useDebugValue=function(){},Pt.useDeferredValue=function(D){return L.current.useDeferredValue(D)},Pt.useEffect=function(D,q){return L.current.useEffect(D,q)},Pt.useId=function(){return L.current.useId()},Pt.useImperativeHandle=function(D,q,ce){return L.current.useImperativeHandle(D,q,ce)},Pt.useInsertionEffect=function(D,q){return L.current.useInsertionEffect(D,q)},Pt.useLayoutEffect=function(D,q){return L.current.useLayoutEffect(D,q)},Pt.useMemo=function(D,q){return L.current.useMemo(D,q)},Pt.useReducer=function(D,q,ce){return L.current.useReducer(D,q,ce)},Pt.useRef=function(D){return L.current.useRef(D)},Pt.useState=function(D){return L.current.useState(D)},Pt.useSyncExternalStore=function(D,q,ce){return L.current.useSyncExternalStore(D,q,ce)},Pt.useTransition=function(){return L.current.useTransition()},Pt.version="18.3.1",Pt}var Q_;function Pm(){return Q_||(Q_=1,Qh.exports=Xk()),Qh.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 J_;function Qk(){if(J_)return dl;J_=1;var t=Pm(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function c(d,h,f){var g,_={},y=null,w=null;f!==void 0&&(y=""+f),h.key!==void 0&&(y=""+h.key),h.ref!==void 0&&(w=h.ref);for(g in h)i.call(h,g)&&!a.hasOwnProperty(g)&&(_[g]=h[g]);if(d&&d.defaultProps)for(g in h=d.defaultProps,h)_[g]===void 0&&(_[g]=h[g]);return{$$typeof:e,type:d,key:y,ref:w,props:_,_owner:s.current}}return dl.Fragment=n,dl.jsx=c,dl.jsxs=c,dl}var Z_;function Jk(){return Z_||(Z_=1,Xh.exports=Qk()),Xh.exports}var l=Jk(),b=Pm();const Zk=Tm(b);var ru={},Jh={exports:{}},Bi={},Zh={exports:{}},ef={};/**
|
|
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 ey;function e2(){return ey||(ey=1,(function(t){function e(R,E){var z=R.length;R.push(E);e:for(;0<z;){var D=z-1>>>1,q=R[D];if(0<s(q,E))R[D]=E,R[z]=q,z=D;else break e}}function n(R){return R.length===0?null:R[0]}function i(R){if(R.length===0)return null;var E=R[0],z=R.pop();if(z!==E){R[0]=z;e:for(var D=0,q=R.length,ce=q>>>1;D<ce;){var ge=2*(D+1)-1,se=R[ge],we=ge+1,_e=R[we];if(0>s(se,z))we<q&&0>s(_e,se)?(R[D]=_e,R[we]=z,D=we):(R[D]=se,R[ge]=z,D=ge);else if(we<q&&0>s(_e,z))R[D]=_e,R[we]=z,D=we;else break e}}return E}function s(R,E){var z=R.sortIndex-E.sortIndex;return z!==0?z:R.id-E.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,d=c.now();t.unstable_now=function(){return c.now()-d}}var h=[],f=[],g=1,_=null,y=3,w=!1,S=!1,A=!1,C=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,k=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(R){for(var E=n(f);E!==null;){if(E.callback===null)i(f);else if(E.startTime<=R)i(f),E.sortIndex=E.expirationTime,e(h,E);else break;E=n(f)}}function P(R){if(A=!1,O(R),!S)if(n(h)!==null)S=!0,M(H);else{var E=n(f);E!==null&&L(P,E.startTime-R)}}function H(R,E){S=!1,A&&(A=!1,N(G),G=-1),w=!0;var z=y;try{for(O(E),_=n(h);_!==null&&(!(_.expirationTime>E)||R&&!V());){var D=_.callback;if(typeof D=="function"){_.callback=null,y=_.priorityLevel;var q=D(_.expirationTime<=E);E=t.unstable_now(),typeof q=="function"?_.callback=q:_===n(h)&&i(h),O(E)}else i(h);_=n(h)}if(_!==null)var ce=!0;else{var ge=n(f);ge!==null&&L(P,ge.startTime-E),ce=!1}return ce}finally{_=null,y=z,w=!1}}var W=!1,U=null,G=-1,X=5,Q=-1;function V(){return!(t.unstable_now()-Q<X)}function T(){if(U!==null){var R=t.unstable_now();Q=R;var E=!0;try{E=U(!0,R)}finally{E?I():(W=!1,U=null)}}else W=!1}var I;if(typeof k=="function")I=function(){k(T)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,j=$.port2;$.port1.onmessage=T,I=function(){j.postMessage(null)}}else I=function(){C(T,0)};function M(R){U=R,W||(W=!0,I())}function L(R,E){G=C(function(){R(t.unstable_now())},E)}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(R){R.callback=null},t.unstable_continueExecution=function(){S||w||(S=!0,M(H))},t.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<R?Math.floor(1e3/R):5},t.unstable_getCurrentPriorityLevel=function(){return y},t.unstable_getFirstCallbackNode=function(){return n(h)},t.unstable_next=function(R){switch(y){case 1:case 2:case 3:var E=3;break;default:E=y}var z=y;y=E;try{return R()}finally{y=z}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(R,E){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var z=y;y=R;try{return E()}finally{y=z}},t.unstable_scheduleCallback=function(R,E,z){var D=t.unstable_now();switch(typeof z=="object"&&z!==null?(z=z.delay,z=typeof z=="number"&&0<z?D+z:D):z=D,R){case 1:var q=-1;break;case 2:q=250;break;case 5:q=1073741823;break;case 4:q=1e4;break;default:q=5e3}return q=z+q,R={id:g++,callback:E,priorityLevel:R,startTime:z,expirationTime:q,sortIndex:-1},z>D?(R.sortIndex=z,e(f,R),n(h)===null&&R===n(f)&&(A?(N(G),G=-1):A=!0,L(P,z-D))):(R.sortIndex=q,e(h,R),S||w||(S=!0,M(H))),R},t.unstable_shouldYield=V,t.unstable_wrapCallback=function(R){var E=y;return function(){var z=y;y=E;try{return R.apply(this,arguments)}finally{y=z}}}})(ef)),ef}var ty;function t2(){return ty||(ty=1,Zh.exports=e2()),Zh.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 ny;function n2(){if(ny)return Bi;ny=1;var t=Pm(),e=t2();function n(r){for(var o="https://reactjs.org/docs/error-decoder.html?invariant="+r,u=1;u<arguments.length;u++)o+="&args[]="+encodeURIComponent(arguments[u]);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 i=new Set,s={};function a(r,o){c(r,o),c(r+"Capture",o)}function c(r,o){for(s[r]=o,r=0;r<o.length;r++)i.add(o[r])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,f=/^[: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]*$/,g={},_={};function y(r){return h.call(_,r)?!0:h.call(g,r)?!1:f.test(r)?_[r]=!0:(g[r]=!0,!1)}function w(r,o,u,m){if(u!==null&&u.type===0)return!1;switch(typeof o){case"function":case"symbol":return!0;case"boolean":return m?!1:u!==null?!u.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function S(r,o,u,m){if(o===null||typeof o>"u"||w(r,o,u,m))return!0;if(m)return!1;if(u!==null)switch(u.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 A(r,o,u,m,v,x,B){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=m,this.attributeNamespace=v,this.mustUseProperty=u,this.propertyName=r,this.type=o,this.sanitizeURL=x,this.removeEmptyString=B}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){C[r]=new A(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 A(o,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){C[r]=new A(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){C[r]=new A(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 A(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){C[r]=new A(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){C[r]=new A(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){C[r]=new A(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){C[r]=new A(r,5,!1,r.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function k(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,k);C[o]=new A(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,k);C[o]=new A(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,k);C[o]=new A(o,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){C[r]=new A(r,1,!1,r.toLowerCase(),null,!1,!1)}),C.xlinkHref=new A("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){C[r]=new A(r,1,!1,r.toLowerCase(),null,!0,!0)});function O(r,o,u,m){var v=C.hasOwnProperty(o)?C[o]:null;(v!==null?v.type!==0:m||!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(S(o,u,v,m)&&(u=null),m||v===null?y(o)&&(u===null?r.removeAttribute(o):r.setAttribute(o,""+u)):v.mustUseProperty?r[v.propertyName]=u===null?v.type===3?!1:"":u:(o=v.attributeName,m=v.attributeNamespace,u===null?r.removeAttribute(o):(v=v.type,u=v===3||v===4&&u===!0?"":""+u,m?r.setAttributeNS(m,o,u):r.setAttribute(o,u))))}var P=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,H=Symbol.for("react.element"),W=Symbol.for("react.portal"),U=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),X=Symbol.for("react.profiler"),Q=Symbol.for("react.provider"),V=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),L=Symbol.for("react.offscreen"),R=Symbol.iterator;function E(r){return r===null||typeof r!="object"?null:(r=R&&r[R]||r["@@iterator"],typeof r=="function"?r:null)}var z=Object.assign,D;function q(r){if(D===void 0)try{throw Error()}catch(u){var o=u.stack.trim().match(/\n( *(at )?)/);D=o&&o[1]||""}return`
|
|
34
|
-
`+D+r}var ce=!1;function ge(r,o){if(!r||ce)return"";ce=!0;var u=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(ve){var m=ve}Reflect.construct(r,[],o)}else{try{o.call()}catch(ve){m=ve}r.call(o.prototype)}else{try{throw Error()}catch(ve){m=ve}r()}}catch(ve){if(ve&&m&&typeof ve.stack=="string"){for(var v=ve.stack.split(`
|
|
35
|
-
`),x=m.stack.split(`
|
|
36
|
-
`),B=v.length-1,Z=x.length-1;1<=B&&0<=Z&&v[B]!==x[Z];)Z--;for(;1<=B&&0<=Z;B--,Z--)if(v[B]!==x[Z]){if(B!==1||Z!==1)do if(B--,Z--,0>Z||v[B]!==x[Z]){var oe=`
|
|
37
|
-
`+v[B].replace(" at new "," at ");return r.displayName&&oe.includes("<anonymous>")&&(oe=oe.replace("<anonymous>",r.displayName)),oe}while(1<=B&&0<=Z);break}}}finally{ce=!1,Error.prepareStackTrace=u}return(r=r?r.displayName||r.name:"")?q(r):""}function se(r){switch(r.tag){case 5:return q(r.type);case 16:return q("Lazy");case 13:return q("Suspense");case 19:return q("SuspenseList");case 0:case 2:case 15:return r=ge(r.type,!1),r;case 11:return r=ge(r.type.render,!1),r;case 1:return r=ge(r.type,!0),r;default:return""}}function we(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 U:return"Fragment";case W:return"Portal";case X:return"Profiler";case G:return"StrictMode";case I:return"Suspense";case $:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case V:return(r.displayName||"Context")+".Consumer";case Q:return(r._context.displayName||"Context")+".Provider";case T:var o=r.render;return r=r.displayName,r||(r=o.displayName||o.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case j:return o=r.displayName||null,o!==null?o:we(r.type)||"Memo";case M:o=r._payload,r=r._init;try{return we(r(o))}catch{}}return null}function _e(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 we(o);case 8:return o===G?"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 fe(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function ie(r){var o=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function de(r){var o=ie(r)?"checked":"value",u=Object.getOwnPropertyDescriptor(r.constructor.prototype,o),m=""+r[o];if(!r.hasOwnProperty(o)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var v=u.get,x=u.set;return Object.defineProperty(r,o,{configurable:!0,get:function(){return v.call(this)},set:function(B){m=""+B,x.call(this,B)}}),Object.defineProperty(r,o,{enumerable:u.enumerable}),{getValue:function(){return m},setValue:function(B){m=""+B},stopTracking:function(){r._valueTracker=null,delete r[o]}}}}function me(r){r._valueTracker||(r._valueTracker=de(r))}function Ee(r){if(!r)return!1;var o=r._valueTracker;if(!o)return!0;var u=o.getValue(),m="";return r&&(m=ie(r)?r.checked?"true":"false":r.value),r=m,r!==u?(o.setValue(r),!0):!1}function Se(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 xe(r,o){var u=o.checked;return z({},o,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:u??r._wrapperState.initialChecked})}function Ye(r,o){var u=o.defaultValue==null?"":o.defaultValue,m=o.checked!=null?o.checked:o.defaultChecked;u=fe(o.value!=null?o.value:u),r._wrapperState={initialChecked:m,initialValue:u,controlled:o.type==="checkbox"||o.type==="radio"?o.checked!=null:o.value!=null}}function Le(r,o){o=o.checked,o!=null&&O(r,"checked",o,!1)}function ze(r,o){Le(r,o);var u=fe(o.value),m=o.type;if(u!=null)m==="number"?(u===0&&r.value===""||r.value!=u)&&(r.value=""+u):r.value!==""+u&&(r.value=""+u);else if(m==="submit"||m==="reset"){r.removeAttribute("value");return}o.hasOwnProperty("value")?_t(r,o.type,u):o.hasOwnProperty("defaultValue")&&_t(r,o.type,fe(o.defaultValue)),o.checked==null&&o.defaultChecked!=null&&(r.defaultChecked=!!o.defaultChecked)}function He(r,o,u){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,u||o===r.value||(r.value=o),r.defaultValue=o}u=r.name,u!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,u!==""&&(r.name=u)}function _t(r,o,u){(o!=="number"||Se(r.ownerDocument)!==r)&&(u==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+u&&(r.defaultValue=""+u))}var at=Array.isArray;function lt(r,o,u,m){if(r=r.options,o){o={};for(var v=0;v<u.length;v++)o["$"+u[v]]=!0;for(u=0;u<r.length;u++)v=o.hasOwnProperty("$"+r[u].value),r[u].selected!==v&&(r[u].selected=v),v&&m&&(r[u].defaultSelected=!0)}else{for(u=""+fe(u),o=null,v=0;v<r.length;v++){if(r[v].value===u){r[v].selected=!0,m&&(r[v].defaultSelected=!0);return}o!==null||r[v].disabled||(o=r[v])}o!==null&&(o.selected=!0)}}function bt(r,o){if(o.dangerouslySetInnerHTML!=null)throw Error(n(91));return z({},o,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function Ht(r,o){var u=o.value;if(u==null){if(u=o.children,o=o.defaultValue,u!=null){if(o!=null)throw Error(n(92));if(at(u)){if(1<u.length)throw Error(n(93));u=u[0]}o=u}o==null&&(o=""),u=o}r._wrapperState={initialValue:fe(u)}}function Rt(r,o){var u=fe(o.value),m=fe(o.defaultValue);u!=null&&(u=""+u,u!==r.value&&(r.value=u),o.defaultValue==null&&r.defaultValue!==u&&(r.defaultValue=u)),m!=null&&(r.defaultValue=""+m)}function fn(r){var o=r.textContent;o===r._wrapperState.initialValue&&o!==""&&o!==null&&(r.value=o)}function It(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 Wt(r,o){return r==null||r==="http://www.w3.org/1999/xhtml"?It(o):r==="http://www.w3.org/2000/svg"&&o==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var ft,qt=(function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(o,u,m,v){MSApp.execUnsafeLocalFunction(function(){return r(o,u,m,v)})}:r})(function(r,o){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=o;else{for(ft=ft||document.createElement("div"),ft.innerHTML="<svg>"+o.valueOf().toString()+"</svg>",o=ft.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;o.firstChild;)r.appendChild(o.firstChild)}});function $t(r,o){if(o){var u=r.firstChild;if(u&&u===r.lastChild&&u.nodeType===3){u.nodeValue=o;return}}r.textContent=o}var F={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},J=["Webkit","ms","Moz","O"];Object.keys(F).forEach(function(r){J.forEach(function(o){o=o+r.charAt(0).toUpperCase()+r.substring(1),F[o]=F[r]})});function ee(r,o,u){return o==null||typeof o=="boolean"||o===""?"":u||typeof o!="number"||o===0||F.hasOwnProperty(r)&&F[r]?(""+o).trim():o+"px"}function K(r,o){r=r.style;for(var u in o)if(o.hasOwnProperty(u)){var m=u.indexOf("--")===0,v=ee(u,o[u],m);u==="float"&&(u="cssFloat"),m?r.setProperty(u,v):r[u]=v}}var ye=z({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 Ze(r,o){if(o){if(ye[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 ct(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 st=null;function xt(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Et=null,jt=null,Ct=null;function Xe(r){if(r=Xa(r)){if(typeof Et!="function")throw Error(n(280));var o=r.stateNode;o&&(o=wc(o),Et(r.stateNode,r.type,o))}}function tt(r){jt?Ct?Ct.push(r):Ct=[r]:jt=r}function Nt(){if(jt){var r=jt,o=Ct;if(Ct=jt=null,Xe(r),o)for(r=0;r<o.length;r++)Xe(o[r])}}function kn(r,o){return r(o)}function Ae(){}var zt=!1;function Qt(r,o,u){if(zt)return r(o,u);zt=!0;try{return kn(r,o,u)}finally{zt=!1,(jt!==null||Ct!==null)&&(Ae(),Nt())}}function Tt(r,o){var u=r.stateNode;if(u===null)return null;var m=wc(u);if(m===null)return null;u=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(u&&typeof u!="function")throw Error(n(231,o,typeof u));return u}var pn=!1;if(d)try{var St={};Object.defineProperty(St,"passive",{get:function(){pn=!0}}),window.addEventListener("test",St,St),window.removeEventListener("test",St,St)}catch{pn=!1}function it(r,o,u,m,v,x,B,Z,oe){var ve=Array.prototype.slice.call(arguments,3);try{o.apply(u,ve)}catch(je){this.onError(je)}}var Dt=!1,Ot=null,Kt=!1,Ge=null,Mn={onError:function(r){Dt=!0,Ot=r}};function Ri(r,o,u,m,v,x,B,Z,oe){Dt=!1,Ot=null,it.apply(Mn,arguments)}function Ai(r,o,u,m,v,x,B,Z,oe){if(Ri.apply(this,arguments),Dt){if(Dt){var ve=Ot;Dt=!1,Ot=null}else throw Error(n(198));Kt||(Kt=!0,Ge=ve)}}function Wn(r){var o=r,u=r;if(r.alternate)for(;o.return;)o=o.return;else{r=o;do o=r,(o.flags&4098)!==0&&(u=o.return),r=o.return;while(r)}return o.tag===3?u:null}function Qi(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 Fi(r){if(Wn(r)!==r)throw Error(n(188))}function Ji(r){var o=r.alternate;if(!o){if(o=Wn(r),o===null)throw Error(n(188));return o!==r?null:r}for(var u=r,m=o;;){var v=u.return;if(v===null)break;var x=v.alternate;if(x===null){if(m=v.return,m!==null){u=m;continue}break}if(v.child===x.child){for(x=v.child;x;){if(x===u)return Fi(v),r;if(x===m)return Fi(v),o;x=x.sibling}throw Error(n(188))}if(u.return!==m.return)u=v,m=x;else{for(var B=!1,Z=v.child;Z;){if(Z===u){B=!0,u=v,m=x;break}if(Z===m){B=!0,m=v,u=x;break}Z=Z.sibling}if(!B){for(Z=x.child;Z;){if(Z===u){B=!0,u=x,m=v;break}if(Z===m){B=!0,m=x,u=v;break}Z=Z.sibling}if(!B)throw Error(n(189))}}if(u.alternate!==m)throw Error(n(190))}if(u.tag!==3)throw Error(n(188));return u.stateNode.current===u?r:o}function re(r){return r=Ji(r),r!==null?be(r):null}function be(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var o=be(r);if(o!==null)return o;r=r.sibling}return null}var Be=e.unstable_scheduleCallback,We=e.unstable_cancelCallback,wt=e.unstable_shouldYield,Y=e.unstable_requestPaint,te=e.unstable_now,Ce=e.unstable_getCurrentPriorityLevel,$e=e.unstable_ImmediatePriority,ke=e.unstable_UserBlockingPriority,ut=e.unstable_NormalPriority,pt=e.unstable_LowPriority,Fe=e.unstable_IdlePriority,Bt=null,ne=null;function le(r){if(ne&&typeof ne.onCommitFiberRoot=="function")try{ne.onCommitFiberRoot(Bt,r,void 0,(r.current.flags&128)===128)}catch{}}var Re=Math.clz32?Math.clz32:ri,ot=Math.log,rt=Math.LN2;function ri(r){return r>>>=0,r===0?32:31-(ot(r)/rt|0)|0}var En=64,Xt=4194304;function Dn(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 Gt(r,o){var u=r.pendingLanes;if(u===0)return 0;var m=0,v=r.suspendedLanes,x=r.pingedLanes,B=u&268435455;if(B!==0){var Z=B&~v;Z!==0?m=Dn(Z):(x&=B,x!==0&&(m=Dn(x)))}else B=u&~v,B!==0?m=Dn(B):x!==0&&(m=Dn(x));if(m===0)return 0;if(o!==0&&o!==m&&(o&v)===0&&(v=m&-m,x=o&-o,v>=x||v===16&&(x&4194240)!==0))return o;if((m&4)!==0&&(m|=u&16),o=r.entangledLanes,o!==0)for(r=r.entanglements,o&=m;0<o;)u=31-Re(o),v=1<<u,m|=r[u],o&=~v;return m}function Zi(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 fi(r,o){for(var u=r.suspendedLanes,m=r.pingedLanes,v=r.expirationTimes,x=r.pendingLanes;0<x;){var B=31-Re(x),Z=1<<B,oe=v[B];oe===-1?((Z&u)===0||(Z&m)!==0)&&(v[B]=Zi(Z,o)):oe<=o&&(r.expiredLanes|=Z),x&=~Z}}function Zt(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function Qr(){var r=En;return En<<=1,(En&4194240)===0&&(En=64),r}function Mi(r){for(var o=[],u=0;31>u;u++)o.push(r);return o}function vr(r,o,u){r.pendingLanes|=o,o!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,o=31-Re(o),r[o]=u}function lc(r,o){var u=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<u;){var v=31-Re(u),x=1<<v;o[v]=0,m[v]=-1,r[v]=-1,u&=~x}}function Po(r,o){var u=r.entangledLanes|=o;for(r=r.entanglements;u;){var m=31-Re(u),v=1<<m;v&o|r[m]&o&&(r[m]|=o),u&=~v}}var Ft=0;function Ns(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var Jr,Io,Do,Da,Vs,Bo=!1,ms=[],Bn=null,es=null,gs=null,On=new Map,_r=new Map,Hi=[],Zr="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 eo(r,o){switch(r){case"focusin":case"focusout":Bn=null;break;case"dragenter":case"dragleave":es=null;break;case"mouseover":case"mouseout":gs=null;break;case"pointerover":case"pointerout":On.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":_r.delete(o.pointerId)}}function yr(r,o,u,m,v,x){return r===null||r.nativeEvent!==x?(r={blockedOn:o,domEventName:u,eventSystemFlags:m,nativeEvent:x,targetContainers:[v]},o!==null&&(o=Xa(o),o!==null&&Io(o)),r):(r.eventSystemFlags|=m,o=r.targetContainers,v!==null&&o.indexOf(v)===-1&&o.push(v),r)}function Oo(r,o,u,m,v){switch(o){case"focusin":return Bn=yr(Bn,r,o,u,m,v),!0;case"dragenter":return es=yr(es,r,o,u,m,v),!0;case"mouseover":return gs=yr(gs,r,o,u,m,v),!0;case"pointerover":var x=v.pointerId;return On.set(x,yr(On.get(x)||null,r,o,u,m,v)),!0;case"gotpointercapture":return x=v.pointerId,_r.set(x,yr(_r.get(x)||null,r,o,u,m,v)),!0}return!1}function Ba(r){var o=to(r.target);if(o!==null){var u=Wn(o);if(u!==null){if(o=u.tag,o===13){if(o=Qi(u),o!==null){r.blockedOn=o,Vs(r.priority,function(){Do(u)});return}}else if(o===3&&u.stateNode.current.memoizedState.isDehydrated){r.blockedOn=u.tag===3?u.stateNode.containerInfo:null;return}}}r.blockedOn=null}function Ys(r){if(r.blockedOn!==null)return!1;for(var o=r.targetContainers;0<o.length;){var u=qn(r.domEventName,r.eventSystemFlags,o[0],r.nativeEvent);if(u===null){u=r.nativeEvent;var m=new u.constructor(u.type,u);st=m,u.target.dispatchEvent(m),st=null}else return o=Xa(u),o!==null&&Io(o),r.blockedOn=u,!1;o.shift()}return!0}function Oa(r,o,u){Ys(r)&&u.delete(o)}function cc(){Bo=!1,Bn!==null&&Ys(Bn)&&(Bn=null),es!==null&&Ys(es)&&(es=null),gs!==null&&Ys(gs)&&(gs=null),On.forEach(Oa),_r.forEach(Oa)}function ue(r,o){r.blockedOn===o&&(r.blockedOn=null,Bo||(Bo=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,cc)))}function Pe(r){function o(v){return ue(v,r)}if(0<ms.length){ue(ms[0],r);for(var u=1;u<ms.length;u++){var m=ms[u];m.blockedOn===r&&(m.blockedOn=null)}}for(Bn!==null&&ue(Bn,r),es!==null&&ue(es,r),gs!==null&&ue(gs,r),On.forEach(o),_r.forEach(o),u=0;u<Hi.length;u++)m=Hi[u],m.blockedOn===r&&(m.blockedOn=null);for(;0<Hi.length&&(u=Hi[0],u.blockedOn===null);)Ba(u),u.blockedOn===null&&Hi.shift()}var Ie=P.ReactCurrentBatchConfig,qe=!0;function mt(r,o,u,m){var v=Ft,x=Ie.transition;Ie.transition=null;try{Ft=1,Vt(r,o,u,m)}finally{Ft=v,Ie.transition=x}}function yt(r,o,u,m){var v=Ft,x=Ie.transition;Ie.transition=null;try{Ft=4,Vt(r,o,u,m)}finally{Ft=v,Ie.transition=x}}function Vt(r,o,u,m){if(qe){var v=qn(r,o,u,m);if(v===null)zd(r,o,m,en,u),eo(r,m);else if(Oo(v,r,o,u,m))m.stopPropagation();else if(eo(r,m),o&4&&-1<Zr.indexOf(r)){for(;v!==null;){var x=Xa(v);if(x!==null&&Jr(x),x=qn(r,o,u,m),x===null&&zd(r,o,m,en,u),x===v)break;v=x}v!==null&&m.stopPropagation()}else zd(r,o,m,null,u)}}var en=null;function qn(r,o,u,m){if(en=null,r=xt(m),r=to(r),r!==null)if(o=Wn(r),o===null)r=null;else if(u=o.tag,u===13){if(r=Qi(o),r!==null)return r;r=null}else if(u===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;r=null}else o!==r&&(r=null);return en=r,null}function yn(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(Ce()){case $e:return 1;case ke:return 4;case ut:case pt:return 16;case Fe:return 536870912;default:return 16}default:return 16}}var Nn=null,ts=null,$o=null;function Cd(){if($o)return $o;var r,o=ts,u=o.length,m,v="value"in Nn?Nn.value:Nn.textContent,x=v.length;for(r=0;r<u&&o[r]===v[r];r++);var B=u-r;for(m=1;m<=B&&o[u-m]===v[x-m];m++);return $o=v.slice(r,1<m?1-m:void 0)}function uc(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 dc(){return!0}function Og(){return!1}function Ui(r){function o(u,m,v,x,B){this._reactName=u,this._targetInst=v,this.type=m,this.nativeEvent=x,this.target=B,this.currentTarget=null;for(var Z in r)r.hasOwnProperty(Z)&&(u=r[Z],this[Z]=u?u(x):x[Z]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?dc:Og,this.isPropagationStopped=Og,this}return z(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var u=this.nativeEvent;u&&(u.preventDefault?u.preventDefault():typeof u.returnValue!="unknown"&&(u.returnValue=!1),this.isDefaultPrevented=dc)},stopPropagation:function(){var u=this.nativeEvent;u&&(u.stopPropagation?u.stopPropagation():typeof u.cancelBubble!="unknown"&&(u.cancelBubble=!0),this.isPropagationStopped=dc)},persist:function(){},isPersistent:dc}),o}var zo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},kd=Ui(zo),$a=z({},zo,{view:0,detail:0}),xC=Ui($a),Ed,Nd,za,hc=z({},$a,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Rd,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!==za&&(za&&r.type==="mousemove"?(Ed=r.screenX-za.screenX,Nd=r.screenY-za.screenY):Nd=Ed=0,za=r),Ed)},movementY:function(r){return"movementY"in r?r.movementY:Nd}}),$g=Ui(hc),CC=z({},hc,{dataTransfer:0}),kC=Ui(CC),EC=z({},$a,{relatedTarget:0}),Ld=Ui(EC),NC=z({},zo,{animationName:0,elapsedTime:0,pseudoElement:0}),LC=Ui(NC),RC=z({},zo,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),AC=Ui(RC),MC=z({},zo,{data:0}),zg=Ui(MC),jC={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},TC={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},PC={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function IC(r){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(r):(r=PC[r])?!!o[r]:!1}function Rd(){return IC}var DC=z({},$a,{key:function(r){if(r.key){var o=jC[r.key]||r.key;if(o!=="Unidentified")return o}return r.type==="keypress"?(r=uc(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?TC[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Rd,charCode:function(r){return r.type==="keypress"?uc(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?uc(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),BC=Ui(DC),OC=z({},hc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Fg=Ui(OC),$C=z({},$a,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Rd}),zC=Ui($C),FC=z({},zo,{propertyName:0,elapsedTime:0,pseudoElement:0}),HC=Ui(FC),UC=z({},hc,{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}),WC=Ui(UC),qC=[9,13,27,32],Ad=d&&"CompositionEvent"in window,Fa=null;d&&"documentMode"in document&&(Fa=document.documentMode);var KC=d&&"TextEvent"in window&&!Fa,Hg=d&&(!Ad||Fa&&8<Fa&&11>=Fa),Ug=" ",Wg=!1;function qg(r,o){switch(r){case"keyup":return qC.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Kg(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Fo=!1;function VC(r,o){switch(r){case"compositionend":return Kg(o);case"keypress":return o.which!==32?null:(Wg=!0,Ug);case"textInput":return r=o.data,r===Ug&&Wg?null:r;default:return null}}function YC(r,o){if(Fo)return r==="compositionend"||!Ad&&qg(r,o)?(r=Cd(),$o=ts=Nn=null,Fo=!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 Hg&&o.locale!=="ko"?null:o.data;default:return null}}var GC={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 Vg(r){var o=r&&r.nodeName&&r.nodeName.toLowerCase();return o==="input"?!!GC[r.type]:o==="textarea"}function Yg(r,o,u,m){tt(m),o=vc(o,"onChange"),0<o.length&&(u=new kd("onChange","change",null,u,m),r.push({event:u,listeners:o}))}var Ha=null,Ua=null;function XC(r){hv(r,0)}function fc(r){var o=Ko(r);if(Ee(o))return r}function QC(r,o){if(r==="change")return o}var Gg=!1;if(d){var Md;if(d){var jd="oninput"in document;if(!jd){var Xg=document.createElement("div");Xg.setAttribute("oninput","return;"),jd=typeof Xg.oninput=="function"}Md=jd}else Md=!1;Gg=Md&&(!document.documentMode||9<document.documentMode)}function Qg(){Ha&&(Ha.detachEvent("onpropertychange",Jg),Ua=Ha=null)}function Jg(r){if(r.propertyName==="value"&&fc(Ua)){var o=[];Yg(o,Ua,r,xt(r)),Qt(XC,o)}}function JC(r,o,u){r==="focusin"?(Qg(),Ha=o,Ua=u,Ha.attachEvent("onpropertychange",Jg)):r==="focusout"&&Qg()}function ZC(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return fc(Ua)}function ek(r,o){if(r==="click")return fc(o)}function tk(r,o){if(r==="input"||r==="change")return fc(o)}function nk(r,o){return r===o&&(r!==0||1/r===1/o)||r!==r&&o!==o}var vs=typeof Object.is=="function"?Object.is:nk;function Wa(r,o){if(vs(r,o))return!0;if(typeof r!="object"||r===null||typeof o!="object"||o===null)return!1;var u=Object.keys(r),m=Object.keys(o);if(u.length!==m.length)return!1;for(m=0;m<u.length;m++){var v=u[m];if(!h.call(o,v)||!vs(r[v],o[v]))return!1}return!0}function Zg(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function ev(r,o){var u=Zg(r);r=0;for(var m;u;){if(u.nodeType===3){if(m=r+u.textContent.length,r<=o&&m>=o)return{node:u,offset:o-r};r=m}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=Zg(u)}}function tv(r,o){return r&&o?r===o?!0:r&&r.nodeType===3?!1:o&&o.nodeType===3?tv(r,o.parentNode):"contains"in r?r.contains(o):r.compareDocumentPosition?!!(r.compareDocumentPosition(o)&16):!1:!1}function nv(){for(var r=window,o=Se();o instanceof r.HTMLIFrameElement;){try{var u=typeof o.contentWindow.location.href=="string"}catch{u=!1}if(u)r=o.contentWindow;else break;o=Se(r.document)}return o}function Td(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 ik(r){var o=nv(),u=r.focusedElem,m=r.selectionRange;if(o!==u&&u&&u.ownerDocument&&tv(u.ownerDocument.documentElement,u)){if(m!==null&&Td(u)){if(o=m.start,r=m.end,r===void 0&&(r=o),"selectionStart"in u)u.selectionStart=o,u.selectionEnd=Math.min(r,u.value.length);else if(r=(o=u.ownerDocument||document)&&o.defaultView||window,r.getSelection){r=r.getSelection();var v=u.textContent.length,x=Math.min(m.start,v);m=m.end===void 0?x:Math.min(m.end,v),!r.extend&&x>m&&(v=m,m=x,x=v),v=ev(u,x);var B=ev(u,m);v&&B&&(r.rangeCount!==1||r.anchorNode!==v.node||r.anchorOffset!==v.offset||r.focusNode!==B.node||r.focusOffset!==B.offset)&&(o=o.createRange(),o.setStart(v.node,v.offset),r.removeAllRanges(),x>m?(r.addRange(o),r.extend(B.node,B.offset)):(o.setEnd(B.node,B.offset),r.addRange(o)))}}for(o=[],r=u;r=r.parentNode;)r.nodeType===1&&o.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof u.focus=="function"&&u.focus(),u=0;u<o.length;u++)r=o[u],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var sk=d&&"documentMode"in document&&11>=document.documentMode,Ho=null,Pd=null,qa=null,Id=!1;function iv(r,o,u){var m=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;Id||Ho==null||Ho!==Se(m)||(m=Ho,"selectionStart"in m&&Td(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}),qa&&Wa(qa,m)||(qa=m,m=vc(Pd,"onSelect"),0<m.length&&(o=new kd("onSelect","select",null,o,u),r.push({event:o,listeners:m}),o.target=Ho)))}function pc(r,o){var u={};return u[r.toLowerCase()]=o.toLowerCase(),u["Webkit"+r]="webkit"+o,u["Moz"+r]="moz"+o,u}var Uo={animationend:pc("Animation","AnimationEnd"),animationiteration:pc("Animation","AnimationIteration"),animationstart:pc("Animation","AnimationStart"),transitionend:pc("Transition","TransitionEnd")},Dd={},sv={};d&&(sv=document.createElement("div").style,"AnimationEvent"in window||(delete Uo.animationend.animation,delete Uo.animationiteration.animation,delete Uo.animationstart.animation),"TransitionEvent"in window||delete Uo.transitionend.transition);function mc(r){if(Dd[r])return Dd[r];if(!Uo[r])return r;var o=Uo[r],u;for(u in o)if(o.hasOwnProperty(u)&&u in sv)return Dd[r]=o[u];return r}var rv=mc("animationend"),ov=mc("animationiteration"),av=mc("animationstart"),lv=mc("transitionend"),cv=new Map,uv="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 wr(r,o){cv.set(r,o),a(o,[r])}for(var Bd=0;Bd<uv.length;Bd++){var Od=uv[Bd],rk=Od.toLowerCase(),ok=Od[0].toUpperCase()+Od.slice(1);wr(rk,"on"+ok)}wr(rv,"onAnimationEnd"),wr(ov,"onAnimationIteration"),wr(av,"onAnimationStart"),wr("dblclick","onDoubleClick"),wr("focusin","onFocus"),wr("focusout","onBlur"),wr(lv,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ka="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(" "),ak=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ka));function dv(r,o,u){var m=r.type||"unknown-event";r.currentTarget=u,Ai(m,o,void 0,r),r.currentTarget=null}function hv(r,o){o=(o&4)!==0;for(var u=0;u<r.length;u++){var m=r[u],v=m.event;m=m.listeners;e:{var x=void 0;if(o)for(var B=m.length-1;0<=B;B--){var Z=m[B],oe=Z.instance,ve=Z.currentTarget;if(Z=Z.listener,oe!==x&&v.isPropagationStopped())break e;dv(v,Z,ve),x=oe}else for(B=0;B<m.length;B++){if(Z=m[B],oe=Z.instance,ve=Z.currentTarget,Z=Z.listener,oe!==x&&v.isPropagationStopped())break e;dv(v,Z,ve),x=oe}}}if(Kt)throw r=Ge,Kt=!1,Ge=null,r}function sn(r,o){var u=o[Kd];u===void 0&&(u=o[Kd]=new Set);var m=r+"__bubble";u.has(m)||(fv(o,r,2,!1),u.add(m))}function $d(r,o,u){var m=0;o&&(m|=4),fv(u,r,m,o)}var gc="_reactListening"+Math.random().toString(36).slice(2);function Va(r){if(!r[gc]){r[gc]=!0,i.forEach(function(u){u!=="selectionchange"&&(ak.has(u)||$d(u,!1,r),$d(u,!0,r))});var o=r.nodeType===9?r:r.ownerDocument;o===null||o[gc]||(o[gc]=!0,$d("selectionchange",!1,o))}}function fv(r,o,u,m){switch(yn(o)){case 1:var v=mt;break;case 4:v=yt;break;default:v=Vt}u=v.bind(null,o,u,r),v=void 0,!pn||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(v=!0),m?v!==void 0?r.addEventListener(o,u,{capture:!0,passive:v}):r.addEventListener(o,u,!0):v!==void 0?r.addEventListener(o,u,{passive:v}):r.addEventListener(o,u,!1)}function zd(r,o,u,m,v){var x=m;if((o&1)===0&&(o&2)===0&&m!==null)e:for(;;){if(m===null)return;var B=m.tag;if(B===3||B===4){var Z=m.stateNode.containerInfo;if(Z===v||Z.nodeType===8&&Z.parentNode===v)break;if(B===4)for(B=m.return;B!==null;){var oe=B.tag;if((oe===3||oe===4)&&(oe=B.stateNode.containerInfo,oe===v||oe.nodeType===8&&oe.parentNode===v))return;B=B.return}for(;Z!==null;){if(B=to(Z),B===null)return;if(oe=B.tag,oe===5||oe===6){m=x=B;continue e}Z=Z.parentNode}}m=m.return}Qt(function(){var ve=x,je=xt(u),Te=[];e:{var Me=cv.get(r);if(Me!==void 0){var Ve=kd,Je=r;switch(r){case"keypress":if(uc(u)===0)break e;case"keydown":case"keyup":Ve=BC;break;case"focusin":Je="focus",Ve=Ld;break;case"focusout":Je="blur",Ve=Ld;break;case"beforeblur":case"afterblur":Ve=Ld;break;case"click":if(u.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ve=$g;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ve=kC;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ve=zC;break;case rv:case ov:case av:Ve=LC;break;case lv:Ve=HC;break;case"scroll":Ve=xC;break;case"wheel":Ve=WC;break;case"copy":case"cut":case"paste":Ve=AC;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ve=Fg}var et=(o&4)!==0,Ln=!et&&r==="scroll",he=et?Me!==null?Me+"Capture":null:Me;et=[];for(var ae=ve,pe;ae!==null;){pe=ae;var De=pe.stateNode;if(pe.tag===5&&De!==null&&(pe=De,he!==null&&(De=Tt(ae,he),De!=null&&et.push(Ya(ae,De,pe)))),Ln)break;ae=ae.return}0<et.length&&(Me=new Ve(Me,Je,null,u,je),Te.push({event:Me,listeners:et}))}}if((o&7)===0){e:{if(Me=r==="mouseover"||r==="pointerover",Ve=r==="mouseout"||r==="pointerout",Me&&u!==st&&(Je=u.relatedTarget||u.fromElement)&&(to(Je)||Je[Gs]))break e;if((Ve||Me)&&(Me=je.window===je?je:(Me=je.ownerDocument)?Me.defaultView||Me.parentWindow:window,Ve?(Je=u.relatedTarget||u.toElement,Ve=ve,Je=Je?to(Je):null,Je!==null&&(Ln=Wn(Je),Je!==Ln||Je.tag!==5&&Je.tag!==6)&&(Je=null)):(Ve=null,Je=ve),Ve!==Je)){if(et=$g,De="onMouseLeave",he="onMouseEnter",ae="mouse",(r==="pointerout"||r==="pointerover")&&(et=Fg,De="onPointerLeave",he="onPointerEnter",ae="pointer"),Ln=Ve==null?Me:Ko(Ve),pe=Je==null?Me:Ko(Je),Me=new et(De,ae+"leave",Ve,u,je),Me.target=Ln,Me.relatedTarget=pe,De=null,to(je)===ve&&(et=new et(he,ae+"enter",Je,u,je),et.target=pe,et.relatedTarget=Ln,De=et),Ln=De,Ve&&Je)t:{for(et=Ve,he=Je,ae=0,pe=et;pe;pe=Wo(pe))ae++;for(pe=0,De=he;De;De=Wo(De))pe++;for(;0<ae-pe;)et=Wo(et),ae--;for(;0<pe-ae;)he=Wo(he),pe--;for(;ae--;){if(et===he||he!==null&&et===he.alternate)break t;et=Wo(et),he=Wo(he)}et=null}else et=null;Ve!==null&&pv(Te,Me,Ve,et,!1),Je!==null&&Ln!==null&&pv(Te,Ln,Je,et,!0)}}e:{if(Me=ve?Ko(ve):window,Ve=Me.nodeName&&Me.nodeName.toLowerCase(),Ve==="select"||Ve==="input"&&Me.type==="file")var nt=QC;else if(Vg(Me))if(Gg)nt=tk;else{nt=ZC;var dt=JC}else(Ve=Me.nodeName)&&Ve.toLowerCase()==="input"&&(Me.type==="checkbox"||Me.type==="radio")&&(nt=ek);if(nt&&(nt=nt(r,ve))){Yg(Te,nt,u,je);break e}dt&&dt(r,Me,ve),r==="focusout"&&(dt=Me._wrapperState)&&dt.controlled&&Me.type==="number"&&_t(Me,"number",Me.value)}switch(dt=ve?Ko(ve):window,r){case"focusin":(Vg(dt)||dt.contentEditable==="true")&&(Ho=dt,Pd=ve,qa=null);break;case"focusout":qa=Pd=Ho=null;break;case"mousedown":Id=!0;break;case"contextmenu":case"mouseup":case"dragend":Id=!1,iv(Te,u,je);break;case"selectionchange":if(sk)break;case"keydown":case"keyup":iv(Te,u,je)}var ht;if(Ad)e:{switch(r){case"compositionstart":var gt="onCompositionStart";break e;case"compositionend":gt="onCompositionEnd";break e;case"compositionupdate":gt="onCompositionUpdate";break e}gt=void 0}else Fo?qg(r,u)&&(gt="onCompositionEnd"):r==="keydown"&&u.keyCode===229&&(gt="onCompositionStart");gt&&(Hg&&u.locale!=="ko"&&(Fo||gt!=="onCompositionStart"?gt==="onCompositionEnd"&&Fo&&(ht=Cd()):(Nn=je,ts="value"in Nn?Nn.value:Nn.textContent,Fo=!0)),dt=vc(ve,gt),0<dt.length&&(gt=new zg(gt,r,null,u,je),Te.push({event:gt,listeners:dt}),ht?gt.data=ht:(ht=Kg(u),ht!==null&&(gt.data=ht)))),(ht=KC?VC(r,u):YC(r,u))&&(ve=vc(ve,"onBeforeInput"),0<ve.length&&(je=new zg("onBeforeInput","beforeinput",null,u,je),Te.push({event:je,listeners:ve}),je.data=ht))}hv(Te,o)})}function Ya(r,o,u){return{instance:r,listener:o,currentTarget:u}}function vc(r,o){for(var u=o+"Capture",m=[];r!==null;){var v=r,x=v.stateNode;v.tag===5&&x!==null&&(v=x,x=Tt(r,u),x!=null&&m.unshift(Ya(r,x,v)),x=Tt(r,o),x!=null&&m.push(Ya(r,x,v))),r=r.return}return m}function Wo(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function pv(r,o,u,m,v){for(var x=o._reactName,B=[];u!==null&&u!==m;){var Z=u,oe=Z.alternate,ve=Z.stateNode;if(oe!==null&&oe===m)break;Z.tag===5&&ve!==null&&(Z=ve,v?(oe=Tt(u,x),oe!=null&&B.unshift(Ya(u,oe,Z))):v||(oe=Tt(u,x),oe!=null&&B.push(Ya(u,oe,Z)))),u=u.return}B.length!==0&&r.push({event:o,listeners:B})}var lk=/\r\n?/g,ck=/\u0000|\uFFFD/g;function mv(r){return(typeof r=="string"?r:""+r).replace(lk,`
|
|
38
|
-
`).replace(ck,"")}function _c(r,o,u){if(o=mv(o),mv(r)!==o&&u)throw Error(n(425))}function yc(){}var Fd=null,Hd=null;function Ud(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 Wd=typeof setTimeout=="function"?setTimeout:void 0,uk=typeof clearTimeout=="function"?clearTimeout:void 0,gv=typeof Promise=="function"?Promise:void 0,dk=typeof queueMicrotask=="function"?queueMicrotask:typeof gv<"u"?function(r){return gv.resolve(null).then(r).catch(hk)}:Wd;function hk(r){setTimeout(function(){throw r})}function qd(r,o){var u=o,m=0;do{var v=u.nextSibling;if(r.removeChild(u),v&&v.nodeType===8)if(u=v.data,u==="/$"){if(m===0){r.removeChild(v),Pe(o);return}m--}else u!=="$"&&u!=="$?"&&u!=="$!"||m++;u=v}while(u);Pe(o)}function br(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 vv(r){r=r.previousSibling;for(var o=0;r;){if(r.nodeType===8){var u=r.data;if(u==="$"||u==="$!"||u==="$?"){if(o===0)return r;o--}else u==="/$"&&o++}r=r.previousSibling}return null}var qo=Math.random().toString(36).slice(2),Ls="__reactFiber$"+qo,Ga="__reactProps$"+qo,Gs="__reactContainer$"+qo,Kd="__reactEvents$"+qo,fk="__reactListeners$"+qo,pk="__reactHandles$"+qo;function to(r){var o=r[Ls];if(o)return o;for(var u=r.parentNode;u;){if(o=u[Gs]||u[Ls]){if(u=o.alternate,o.child!==null||u!==null&&u.child!==null)for(r=vv(r);r!==null;){if(u=r[Ls])return u;r=vv(r)}return o}r=u,u=r.parentNode}return null}function Xa(r){return r=r[Ls]||r[Gs],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function Ko(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(n(33))}function wc(r){return r[Ga]||null}var Vd=[],Vo=-1;function Sr(r){return{current:r}}function rn(r){0>Vo||(r.current=Vd[Vo],Vd[Vo]=null,Vo--)}function tn(r,o){Vo++,Vd[Vo]=r.current,r.current=o}var xr={},pi=Sr(xr),ji=Sr(!1),no=xr;function Yo(r,o){var u=r.type.contextTypes;if(!u)return xr;var m=r.stateNode;if(m&&m.__reactInternalMemoizedUnmaskedChildContext===o)return m.__reactInternalMemoizedMaskedChildContext;var v={},x;for(x in u)v[x]=o[x];return m&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=o,r.__reactInternalMemoizedMaskedChildContext=v),v}function Ti(r){return r=r.childContextTypes,r!=null}function bc(){rn(ji),rn(pi)}function _v(r,o,u){if(pi.current!==xr)throw Error(n(168));tn(pi,o),tn(ji,u)}function yv(r,o,u){var m=r.stateNode;if(o=o.childContextTypes,typeof m.getChildContext!="function")return u;m=m.getChildContext();for(var v in m)if(!(v in o))throw Error(n(108,_e(r)||"Unknown",v));return z({},u,m)}function Sc(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||xr,no=pi.current,tn(pi,r),tn(ji,ji.current),!0}function wv(r,o,u){var m=r.stateNode;if(!m)throw Error(n(169));u?(r=yv(r,o,no),m.__reactInternalMemoizedMergedChildContext=r,rn(ji),rn(pi),tn(pi,r)):rn(ji),tn(ji,u)}var Xs=null,xc=!1,Yd=!1;function bv(r){Xs===null?Xs=[r]:Xs.push(r)}function mk(r){xc=!0,bv(r)}function Cr(){if(!Yd&&Xs!==null){Yd=!0;var r=0,o=Ft;try{var u=Xs;for(Ft=1;r<u.length;r++){var m=u[r];do m=m(!0);while(m!==null)}Xs=null,xc=!1}catch(v){throw Xs!==null&&(Xs=Xs.slice(r+1)),Be($e,Cr),v}finally{Ft=o,Yd=!1}}return null}var Go=[],Xo=0,Cc=null,kc=0,ns=[],is=0,io=null,Qs=1,Js="";function so(r,o){Go[Xo++]=kc,Go[Xo++]=Cc,Cc=r,kc=o}function Sv(r,o,u){ns[is++]=Qs,ns[is++]=Js,ns[is++]=io,io=r;var m=Qs;r=Js;var v=32-Re(m)-1;m&=~(1<<v),u+=1;var x=32-Re(o)+v;if(30<x){var B=v-v%5;x=(m&(1<<B)-1).toString(32),m>>=B,v-=B,Qs=1<<32-Re(o)+v|u<<v|m,Js=x+r}else Qs=1<<x|u<<v|m,Js=r}function Gd(r){r.return!==null&&(so(r,1),Sv(r,1,0))}function Xd(r){for(;r===Cc;)Cc=Go[--Xo],Go[Xo]=null,kc=Go[--Xo],Go[Xo]=null;for(;r===io;)io=ns[--is],ns[is]=null,Js=ns[--is],ns[is]=null,Qs=ns[--is],ns[is]=null}var Wi=null,qi=null,cn=!1,_s=null;function xv(r,o){var u=as(5,null,null,0);u.elementType="DELETED",u.stateNode=o,u.return=r,o=r.deletions,o===null?(r.deletions=[u],r.flags|=16):o.push(u)}function Cv(r,o){switch(r.tag){case 5:var u=r.type;return o=o.nodeType!==1||u.toLowerCase()!==o.nodeName.toLowerCase()?null:o,o!==null?(r.stateNode=o,Wi=r,qi=br(o.firstChild),!0):!1;case 6:return o=r.pendingProps===""||o.nodeType!==3?null:o,o!==null?(r.stateNode=o,Wi=r,qi=null,!0):!1;case 13:return o=o.nodeType!==8?null:o,o!==null?(u=io!==null?{id:Qs,overflow:Js}:null,r.memoizedState={dehydrated:o,treeContext:u,retryLane:1073741824},u=as(18,null,null,0),u.stateNode=o,u.return=r,r.child=u,Wi=r,qi=null,!0):!1;default:return!1}}function Qd(r){return(r.mode&1)!==0&&(r.flags&128)===0}function Jd(r){if(cn){var o=qi;if(o){var u=o;if(!Cv(r,o)){if(Qd(r))throw Error(n(418));o=br(u.nextSibling);var m=Wi;o&&Cv(r,o)?xv(m,u):(r.flags=r.flags&-4097|2,cn=!1,Wi=r)}}else{if(Qd(r))throw Error(n(418));r.flags=r.flags&-4097|2,cn=!1,Wi=r}}}function kv(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;Wi=r}function Ec(r){if(r!==Wi)return!1;if(!cn)return kv(r),cn=!0,!1;var o;if((o=r.tag!==3)&&!(o=r.tag!==5)&&(o=r.type,o=o!=="head"&&o!=="body"&&!Ud(r.type,r.memoizedProps)),o&&(o=qi)){if(Qd(r))throw Ev(),Error(n(418));for(;o;)xv(r,o),o=br(o.nextSibling)}if(kv(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 u=r.data;if(u==="/$"){if(o===0){qi=br(r.nextSibling);break e}o--}else u!=="$"&&u!=="$!"&&u!=="$?"||o++}r=r.nextSibling}qi=null}}else qi=Wi?br(r.stateNode.nextSibling):null;return!0}function Ev(){for(var r=qi;r;)r=br(r.nextSibling)}function Qo(){qi=Wi=null,cn=!1}function Zd(r){_s===null?_s=[r]:_s.push(r)}var gk=P.ReactCurrentBatchConfig;function Qa(r,o,u){if(r=u.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(u._owner){if(u=u._owner,u){if(u.tag!==1)throw Error(n(309));var m=u.stateNode}if(!m)throw Error(n(147,r));var v=m,x=""+r;return o!==null&&o.ref!==null&&typeof o.ref=="function"&&o.ref._stringRef===x?o.ref:(o=function(B){var Z=v.refs;B===null?delete Z[x]:Z[x]=B},o._stringRef=x,o)}if(typeof r!="string")throw Error(n(284));if(!u._owner)throw Error(n(290,r))}return r}function Nc(r,o){throw r=Object.prototype.toString.call(o),Error(n(31,r==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":r))}function Nv(r){var o=r._init;return o(r._payload)}function Lv(r){function o(he,ae){if(r){var pe=he.deletions;pe===null?(he.deletions=[ae],he.flags|=16):pe.push(ae)}}function u(he,ae){if(!r)return null;for(;ae!==null;)o(he,ae),ae=ae.sibling;return null}function m(he,ae){for(he=new Map;ae!==null;)ae.key!==null?he.set(ae.key,ae):he.set(ae.index,ae),ae=ae.sibling;return he}function v(he,ae){return he=jr(he,ae),he.index=0,he.sibling=null,he}function x(he,ae,pe){return he.index=pe,r?(pe=he.alternate,pe!==null?(pe=pe.index,pe<ae?(he.flags|=2,ae):pe):(he.flags|=2,ae)):(he.flags|=1048576,ae)}function B(he){return r&&he.alternate===null&&(he.flags|=2),he}function Z(he,ae,pe,De){return ae===null||ae.tag!==6?(ae=Wh(pe,he.mode,De),ae.return=he,ae):(ae=v(ae,pe),ae.return=he,ae)}function oe(he,ae,pe,De){var nt=pe.type;return nt===U?je(he,ae,pe.props.children,De,pe.key):ae!==null&&(ae.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===M&&Nv(nt)===ae.type)?(De=v(ae,pe.props),De.ref=Qa(he,ae,pe),De.return=he,De):(De=Qc(pe.type,pe.key,pe.props,null,he.mode,De),De.ref=Qa(he,ae,pe),De.return=he,De)}function ve(he,ae,pe,De){return ae===null||ae.tag!==4||ae.stateNode.containerInfo!==pe.containerInfo||ae.stateNode.implementation!==pe.implementation?(ae=qh(pe,he.mode,De),ae.return=he,ae):(ae=v(ae,pe.children||[]),ae.return=he,ae)}function je(he,ae,pe,De,nt){return ae===null||ae.tag!==7?(ae=fo(pe,he.mode,De,nt),ae.return=he,ae):(ae=v(ae,pe),ae.return=he,ae)}function Te(he,ae,pe){if(typeof ae=="string"&&ae!==""||typeof ae=="number")return ae=Wh(""+ae,he.mode,pe),ae.return=he,ae;if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case H:return pe=Qc(ae.type,ae.key,ae.props,null,he.mode,pe),pe.ref=Qa(he,null,ae),pe.return=he,pe;case W:return ae=qh(ae,he.mode,pe),ae.return=he,ae;case M:var De=ae._init;return Te(he,De(ae._payload),pe)}if(at(ae)||E(ae))return ae=fo(ae,he.mode,pe,null),ae.return=he,ae;Nc(he,ae)}return null}function Me(he,ae,pe,De){var nt=ae!==null?ae.key:null;if(typeof pe=="string"&&pe!==""||typeof pe=="number")return nt!==null?null:Z(he,ae,""+pe,De);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case H:return pe.key===nt?oe(he,ae,pe,De):null;case W:return pe.key===nt?ve(he,ae,pe,De):null;case M:return nt=pe._init,Me(he,ae,nt(pe._payload),De)}if(at(pe)||E(pe))return nt!==null?null:je(he,ae,pe,De,null);Nc(he,pe)}return null}function Ve(he,ae,pe,De,nt){if(typeof De=="string"&&De!==""||typeof De=="number")return he=he.get(pe)||null,Z(ae,he,""+De,nt);if(typeof De=="object"&&De!==null){switch(De.$$typeof){case H:return he=he.get(De.key===null?pe:De.key)||null,oe(ae,he,De,nt);case W:return he=he.get(De.key===null?pe:De.key)||null,ve(ae,he,De,nt);case M:var dt=De._init;return Ve(he,ae,pe,dt(De._payload),nt)}if(at(De)||E(De))return he=he.get(pe)||null,je(ae,he,De,nt,null);Nc(ae,De)}return null}function Je(he,ae,pe,De){for(var nt=null,dt=null,ht=ae,gt=ae=0,Yn=null;ht!==null&><pe.length;gt++){ht.index>gt?(Yn=ht,ht=null):Yn=ht.sibling;var Yt=Me(he,ht,pe[gt],De);if(Yt===null){ht===null&&(ht=Yn);break}r&&ht&&Yt.alternate===null&&o(he,ht),ae=x(Yt,ae,gt),dt===null?nt=Yt:dt.sibling=Yt,dt=Yt,ht=Yn}if(gt===pe.length)return u(he,ht),cn&&so(he,gt),nt;if(ht===null){for(;gt<pe.length;gt++)ht=Te(he,pe[gt],De),ht!==null&&(ae=x(ht,ae,gt),dt===null?nt=ht:dt.sibling=ht,dt=ht);return cn&&so(he,gt),nt}for(ht=m(he,ht);gt<pe.length;gt++)Yn=Ve(ht,he,gt,pe[gt],De),Yn!==null&&(r&&Yn.alternate!==null&&ht.delete(Yn.key===null?gt:Yn.key),ae=x(Yn,ae,gt),dt===null?nt=Yn:dt.sibling=Yn,dt=Yn);return r&&ht.forEach(function(Tr){return o(he,Tr)}),cn&&so(he,gt),nt}function et(he,ae,pe,De){var nt=E(pe);if(typeof nt!="function")throw Error(n(150));if(pe=nt.call(pe),pe==null)throw Error(n(151));for(var dt=nt=null,ht=ae,gt=ae=0,Yn=null,Yt=pe.next();ht!==null&&!Yt.done;gt++,Yt=pe.next()){ht.index>gt?(Yn=ht,ht=null):Yn=ht.sibling;var Tr=Me(he,ht,Yt.value,De);if(Tr===null){ht===null&&(ht=Yn);break}r&&ht&&Tr.alternate===null&&o(he,ht),ae=x(Tr,ae,gt),dt===null?nt=Tr:dt.sibling=Tr,dt=Tr,ht=Yn}if(Yt.done)return u(he,ht),cn&&so(he,gt),nt;if(ht===null){for(;!Yt.done;gt++,Yt=pe.next())Yt=Te(he,Yt.value,De),Yt!==null&&(ae=x(Yt,ae,gt),dt===null?nt=Yt:dt.sibling=Yt,dt=Yt);return cn&&so(he,gt),nt}for(ht=m(he,ht);!Yt.done;gt++,Yt=pe.next())Yt=Ve(ht,he,gt,Yt.value,De),Yt!==null&&(r&&Yt.alternate!==null&&ht.delete(Yt.key===null?gt:Yt.key),ae=x(Yt,ae,gt),dt===null?nt=Yt:dt.sibling=Yt,dt=Yt);return r&&ht.forEach(function(Gk){return o(he,Gk)}),cn&&so(he,gt),nt}function Ln(he,ae,pe,De){if(typeof pe=="object"&&pe!==null&&pe.type===U&&pe.key===null&&(pe=pe.props.children),typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case H:e:{for(var nt=pe.key,dt=ae;dt!==null;){if(dt.key===nt){if(nt=pe.type,nt===U){if(dt.tag===7){u(he,dt.sibling),ae=v(dt,pe.props.children),ae.return=he,he=ae;break e}}else if(dt.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===M&&Nv(nt)===dt.type){u(he,dt.sibling),ae=v(dt,pe.props),ae.ref=Qa(he,dt,pe),ae.return=he,he=ae;break e}u(he,dt);break}else o(he,dt);dt=dt.sibling}pe.type===U?(ae=fo(pe.props.children,he.mode,De,pe.key),ae.return=he,he=ae):(De=Qc(pe.type,pe.key,pe.props,null,he.mode,De),De.ref=Qa(he,ae,pe),De.return=he,he=De)}return B(he);case W:e:{for(dt=pe.key;ae!==null;){if(ae.key===dt)if(ae.tag===4&&ae.stateNode.containerInfo===pe.containerInfo&&ae.stateNode.implementation===pe.implementation){u(he,ae.sibling),ae=v(ae,pe.children||[]),ae.return=he,he=ae;break e}else{u(he,ae);break}else o(he,ae);ae=ae.sibling}ae=qh(pe,he.mode,De),ae.return=he,he=ae}return B(he);case M:return dt=pe._init,Ln(he,ae,dt(pe._payload),De)}if(at(pe))return Je(he,ae,pe,De);if(E(pe))return et(he,ae,pe,De);Nc(he,pe)}return typeof pe=="string"&&pe!==""||typeof pe=="number"?(pe=""+pe,ae!==null&&ae.tag===6?(u(he,ae.sibling),ae=v(ae,pe),ae.return=he,he=ae):(u(he,ae),ae=Wh(pe,he.mode,De),ae.return=he,he=ae),B(he)):u(he,ae)}return Ln}var Jo=Lv(!0),Rv=Lv(!1),Lc=Sr(null),Rc=null,Zo=null,eh=null;function th(){eh=Zo=Rc=null}function nh(r){var o=Lc.current;rn(Lc),r._currentValue=o}function ih(r,o,u){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===u)break;r=r.return}}function ea(r,o){Rc=r,eh=Zo=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&o)!==0&&(Pi=!0),r.firstContext=null)}function ss(r){var o=r._currentValue;if(eh!==r)if(r={context:r,memoizedValue:o,next:null},Zo===null){if(Rc===null)throw Error(n(308));Zo=r,Rc.dependencies={lanes:0,firstContext:r}}else Zo=Zo.next=r;return o}var ro=null;function sh(r){ro===null?ro=[r]:ro.push(r)}function Av(r,o,u,m){var v=o.interleaved;return v===null?(u.next=u,sh(o)):(u.next=v.next,v.next=u),o.interleaved=u,Zs(r,m)}function Zs(r,o){r.lanes|=o;var u=r.alternate;for(u!==null&&(u.lanes|=o),u=r,r=r.return;r!==null;)r.childLanes|=o,u=r.alternate,u!==null&&(u.childLanes|=o),u=r,r=r.return;return u.tag===3?u.stateNode:null}var kr=!1;function rh(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Mv(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 er(r,o){return{eventTime:r,lane:o,tag:0,payload:null,callback:null,next:null}}function Er(r,o,u){var m=r.updateQueue;if(m===null)return null;if(m=m.shared,(Ut&2)!==0){var v=m.pending;return v===null?o.next=o:(o.next=v.next,v.next=o),m.pending=o,Zs(r,u)}return v=m.interleaved,v===null?(o.next=o,sh(m)):(o.next=v.next,v.next=o),m.interleaved=o,Zs(r,u)}function Ac(r,o,u){if(o=o.updateQueue,o!==null&&(o=o.shared,(u&4194240)!==0)){var m=o.lanes;m&=r.pendingLanes,u|=m,o.lanes=u,Po(r,u)}}function jv(r,o){var u=r.updateQueue,m=r.alternate;if(m!==null&&(m=m.updateQueue,u===m)){var v=null,x=null;if(u=u.firstBaseUpdate,u!==null){do{var B={eventTime:u.eventTime,lane:u.lane,tag:u.tag,payload:u.payload,callback:u.callback,next:null};x===null?v=x=B:x=x.next=B,u=u.next}while(u!==null);x===null?v=x=o:x=x.next=o}else v=x=o;u={baseState:m.baseState,firstBaseUpdate:v,lastBaseUpdate:x,shared:m.shared,effects:m.effects},r.updateQueue=u;return}r=u.lastBaseUpdate,r===null?u.firstBaseUpdate=o:r.next=o,u.lastBaseUpdate=o}function Mc(r,o,u,m){var v=r.updateQueue;kr=!1;var x=v.firstBaseUpdate,B=v.lastBaseUpdate,Z=v.shared.pending;if(Z!==null){v.shared.pending=null;var oe=Z,ve=oe.next;oe.next=null,B===null?x=ve:B.next=ve,B=oe;var je=r.alternate;je!==null&&(je=je.updateQueue,Z=je.lastBaseUpdate,Z!==B&&(Z===null?je.firstBaseUpdate=ve:Z.next=ve,je.lastBaseUpdate=oe))}if(x!==null){var Te=v.baseState;B=0,je=ve=oe=null,Z=x;do{var Me=Z.lane,Ve=Z.eventTime;if((m&Me)===Me){je!==null&&(je=je.next={eventTime:Ve,lane:0,tag:Z.tag,payload:Z.payload,callback:Z.callback,next:null});e:{var Je=r,et=Z;switch(Me=o,Ve=u,et.tag){case 1:if(Je=et.payload,typeof Je=="function"){Te=Je.call(Ve,Te,Me);break e}Te=Je;break e;case 3:Je.flags=Je.flags&-65537|128;case 0:if(Je=et.payload,Me=typeof Je=="function"?Je.call(Ve,Te,Me):Je,Me==null)break e;Te=z({},Te,Me);break e;case 2:kr=!0}}Z.callback!==null&&Z.lane!==0&&(r.flags|=64,Me=v.effects,Me===null?v.effects=[Z]:Me.push(Z))}else Ve={eventTime:Ve,lane:Me,tag:Z.tag,payload:Z.payload,callback:Z.callback,next:null},je===null?(ve=je=Ve,oe=Te):je=je.next=Ve,B|=Me;if(Z=Z.next,Z===null){if(Z=v.shared.pending,Z===null)break;Me=Z,Z=Me.next,Me.next=null,v.lastBaseUpdate=Me,v.shared.pending=null}}while(!0);if(je===null&&(oe=Te),v.baseState=oe,v.firstBaseUpdate=ve,v.lastBaseUpdate=je,o=v.shared.interleaved,o!==null){v=o;do B|=v.lane,v=v.next;while(v!==o)}else x===null&&(v.shared.lanes=0);lo|=B,r.lanes=B,r.memoizedState=Te}}function Tv(r,o,u){if(r=o.effects,o.effects=null,r!==null)for(o=0;o<r.length;o++){var m=r[o],v=m.callback;if(v!==null){if(m.callback=null,m=u,typeof v!="function")throw Error(n(191,v));v.call(m)}}}var Ja={},Rs=Sr(Ja),Za=Sr(Ja),el=Sr(Ja);function oo(r){if(r===Ja)throw Error(n(174));return r}function oh(r,o){switch(tn(el,o),tn(Za,r),tn(Rs,Ja),r=o.nodeType,r){case 9:case 11:o=(o=o.documentElement)?o.namespaceURI:Wt(null,"");break;default:r=r===8?o.parentNode:o,o=r.namespaceURI||null,r=r.tagName,o=Wt(o,r)}rn(Rs),tn(Rs,o)}function ta(){rn(Rs),rn(Za),rn(el)}function Pv(r){oo(el.current);var o=oo(Rs.current),u=Wt(o,r.type);o!==u&&(tn(Za,r),tn(Rs,u))}function ah(r){Za.current===r&&(rn(Rs),rn(Za))}var mn=Sr(0);function jc(r){for(var o=r;o!==null;){if(o.tag===13){var u=o.memoizedState;if(u!==null&&(u=u.dehydrated,u===null||u.data==="$?"||u.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 lh=[];function ch(){for(var r=0;r<lh.length;r++)lh[r]._workInProgressVersionPrimary=null;lh.length=0}var Tc=P.ReactCurrentDispatcher,uh=P.ReactCurrentBatchConfig,ao=0,gn=null,$n=null,Kn=null,Pc=!1,tl=!1,nl=0,vk=0;function mi(){throw Error(n(321))}function dh(r,o){if(o===null)return!1;for(var u=0;u<o.length&&u<r.length;u++)if(!vs(r[u],o[u]))return!1;return!0}function hh(r,o,u,m,v,x){if(ao=x,gn=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,Tc.current=r===null||r.memoizedState===null?bk:Sk,r=u(m,v),tl){x=0;do{if(tl=!1,nl=0,25<=x)throw Error(n(301));x+=1,Kn=$n=null,o.updateQueue=null,Tc.current=xk,r=u(m,v)}while(tl)}if(Tc.current=Bc,o=$n!==null&&$n.next!==null,ao=0,Kn=$n=gn=null,Pc=!1,o)throw Error(n(300));return r}function fh(){var r=nl!==0;return nl=0,r}function As(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Kn===null?gn.memoizedState=Kn=r:Kn=Kn.next=r,Kn}function rs(){if($n===null){var r=gn.alternate;r=r!==null?r.memoizedState:null}else r=$n.next;var o=Kn===null?gn.memoizedState:Kn.next;if(o!==null)Kn=o,$n=r;else{if(r===null)throw Error(n(310));$n=r,r={memoizedState:$n.memoizedState,baseState:$n.baseState,baseQueue:$n.baseQueue,queue:$n.queue,next:null},Kn===null?gn.memoizedState=Kn=r:Kn=Kn.next=r}return Kn}function il(r,o){return typeof o=="function"?o(r):o}function ph(r){var o=rs(),u=o.queue;if(u===null)throw Error(n(311));u.lastRenderedReducer=r;var m=$n,v=m.baseQueue,x=u.pending;if(x!==null){if(v!==null){var B=v.next;v.next=x.next,x.next=B}m.baseQueue=v=x,u.pending=null}if(v!==null){x=v.next,m=m.baseState;var Z=B=null,oe=null,ve=x;do{var je=ve.lane;if((ao&je)===je)oe!==null&&(oe=oe.next={lane:0,action:ve.action,hasEagerState:ve.hasEagerState,eagerState:ve.eagerState,next:null}),m=ve.hasEagerState?ve.eagerState:r(m,ve.action);else{var Te={lane:je,action:ve.action,hasEagerState:ve.hasEagerState,eagerState:ve.eagerState,next:null};oe===null?(Z=oe=Te,B=m):oe=oe.next=Te,gn.lanes|=je,lo|=je}ve=ve.next}while(ve!==null&&ve!==x);oe===null?B=m:oe.next=Z,vs(m,o.memoizedState)||(Pi=!0),o.memoizedState=m,o.baseState=B,o.baseQueue=oe,u.lastRenderedState=m}if(r=u.interleaved,r!==null){v=r;do x=v.lane,gn.lanes|=x,lo|=x,v=v.next;while(v!==r)}else v===null&&(u.lanes=0);return[o.memoizedState,u.dispatch]}function mh(r){var o=rs(),u=o.queue;if(u===null)throw Error(n(311));u.lastRenderedReducer=r;var m=u.dispatch,v=u.pending,x=o.memoizedState;if(v!==null){u.pending=null;var B=v=v.next;do x=r(x,B.action),B=B.next;while(B!==v);vs(x,o.memoizedState)||(Pi=!0),o.memoizedState=x,o.baseQueue===null&&(o.baseState=x),u.lastRenderedState=x}return[x,m]}function Iv(){}function Dv(r,o){var u=gn,m=rs(),v=o(),x=!vs(m.memoizedState,v);if(x&&(m.memoizedState=v,Pi=!0),m=m.queue,gh($v.bind(null,u,m,r),[r]),m.getSnapshot!==o||x||Kn!==null&&Kn.memoizedState.tag&1){if(u.flags|=2048,sl(9,Ov.bind(null,u,m,v,o),void 0,null),Vn===null)throw Error(n(349));(ao&30)!==0||Bv(u,o,v)}return v}function Bv(r,o,u){r.flags|=16384,r={getSnapshot:o,value:u},o=gn.updateQueue,o===null?(o={lastEffect:null,stores:null},gn.updateQueue=o,o.stores=[r]):(u=o.stores,u===null?o.stores=[r]:u.push(r))}function Ov(r,o,u,m){o.value=u,o.getSnapshot=m,zv(o)&&Fv(r)}function $v(r,o,u){return u(function(){zv(o)&&Fv(r)})}function zv(r){var o=r.getSnapshot;r=r.value;try{var u=o();return!vs(r,u)}catch{return!0}}function Fv(r){var o=Zs(r,1);o!==null&&Ss(o,r,1,-1)}function Hv(r){var o=As();return typeof r=="function"&&(r=r()),o.memoizedState=o.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:il,lastRenderedState:r},o.queue=r,r=r.dispatch=wk.bind(null,gn,r),[o.memoizedState,r]}function sl(r,o,u,m){return r={tag:r,create:o,destroy:u,deps:m,next:null},o=gn.updateQueue,o===null?(o={lastEffect:null,stores:null},gn.updateQueue=o,o.lastEffect=r.next=r):(u=o.lastEffect,u===null?o.lastEffect=r.next=r:(m=u.next,u.next=r,r.next=m,o.lastEffect=r)),r}function Uv(){return rs().memoizedState}function Ic(r,o,u,m){var v=As();gn.flags|=r,v.memoizedState=sl(1|o,u,void 0,m===void 0?null:m)}function Dc(r,o,u,m){var v=rs();m=m===void 0?null:m;var x=void 0;if($n!==null){var B=$n.memoizedState;if(x=B.destroy,m!==null&&dh(m,B.deps)){v.memoizedState=sl(o,u,x,m);return}}gn.flags|=r,v.memoizedState=sl(1|o,u,x,m)}function Wv(r,o){return Ic(8390656,8,r,o)}function gh(r,o){return Dc(2048,8,r,o)}function qv(r,o){return Dc(4,2,r,o)}function Kv(r,o){return Dc(4,4,r,o)}function Vv(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 Yv(r,o,u){return u=u!=null?u.concat([r]):null,Dc(4,4,Vv.bind(null,o,r),u)}function vh(){}function Gv(r,o){var u=rs();o=o===void 0?null:o;var m=u.memoizedState;return m!==null&&o!==null&&dh(o,m[1])?m[0]:(u.memoizedState=[r,o],r)}function Xv(r,o){var u=rs();o=o===void 0?null:o;var m=u.memoizedState;return m!==null&&o!==null&&dh(o,m[1])?m[0]:(r=r(),u.memoizedState=[r,o],r)}function Qv(r,o,u){return(ao&21)===0?(r.baseState&&(r.baseState=!1,Pi=!0),r.memoizedState=u):(vs(u,o)||(u=Qr(),gn.lanes|=u,lo|=u,r.baseState=!0),o)}function _k(r,o){var u=Ft;Ft=u!==0&&4>u?u:4,r(!0);var m=uh.transition;uh.transition={};try{r(!1),o()}finally{Ft=u,uh.transition=m}}function Jv(){return rs().memoizedState}function yk(r,o,u){var m=Ar(r);if(u={lane:m,action:u,hasEagerState:!1,eagerState:null,next:null},Zv(r))e_(o,u);else if(u=Av(r,o,u,m),u!==null){var v=Si();Ss(u,r,m,v),t_(u,o,m)}}function wk(r,o,u){var m=Ar(r),v={lane:m,action:u,hasEagerState:!1,eagerState:null,next:null};if(Zv(r))e_(o,v);else{var x=r.alternate;if(r.lanes===0&&(x===null||x.lanes===0)&&(x=o.lastRenderedReducer,x!==null))try{var B=o.lastRenderedState,Z=x(B,u);if(v.hasEagerState=!0,v.eagerState=Z,vs(Z,B)){var oe=o.interleaved;oe===null?(v.next=v,sh(o)):(v.next=oe.next,oe.next=v),o.interleaved=v;return}}catch{}finally{}u=Av(r,o,v,m),u!==null&&(v=Si(),Ss(u,r,m,v),t_(u,o,m))}}function Zv(r){var o=r.alternate;return r===gn||o!==null&&o===gn}function e_(r,o){tl=Pc=!0;var u=r.pending;u===null?o.next=o:(o.next=u.next,u.next=o),r.pending=o}function t_(r,o,u){if((u&4194240)!==0){var m=o.lanes;m&=r.pendingLanes,u|=m,o.lanes=u,Po(r,u)}}var Bc={readContext:ss,useCallback:mi,useContext:mi,useEffect:mi,useImperativeHandle:mi,useInsertionEffect:mi,useLayoutEffect:mi,useMemo:mi,useReducer:mi,useRef:mi,useState:mi,useDebugValue:mi,useDeferredValue:mi,useTransition:mi,useMutableSource:mi,useSyncExternalStore:mi,useId:mi,unstable_isNewReconciler:!1},bk={readContext:ss,useCallback:function(r,o){return As().memoizedState=[r,o===void 0?null:o],r},useContext:ss,useEffect:Wv,useImperativeHandle:function(r,o,u){return u=u!=null?u.concat([r]):null,Ic(4194308,4,Vv.bind(null,o,r),u)},useLayoutEffect:function(r,o){return Ic(4194308,4,r,o)},useInsertionEffect:function(r,o){return Ic(4,2,r,o)},useMemo:function(r,o){var u=As();return o=o===void 0?null:o,r=r(),u.memoizedState=[r,o],r},useReducer:function(r,o,u){var m=As();return o=u!==void 0?u(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=yk.bind(null,gn,r),[m.memoizedState,r]},useRef:function(r){var o=As();return r={current:r},o.memoizedState=r},useState:Hv,useDebugValue:vh,useDeferredValue:function(r){return As().memoizedState=r},useTransition:function(){var r=Hv(!1),o=r[0];return r=_k.bind(null,r[1]),As().memoizedState=r,[o,r]},useMutableSource:function(){},useSyncExternalStore:function(r,o,u){var m=gn,v=As();if(cn){if(u===void 0)throw Error(n(407));u=u()}else{if(u=o(),Vn===null)throw Error(n(349));(ao&30)!==0||Bv(m,o,u)}v.memoizedState=u;var x={value:u,getSnapshot:o};return v.queue=x,Wv($v.bind(null,m,x,r),[r]),m.flags|=2048,sl(9,Ov.bind(null,m,x,u,o),void 0,null),u},useId:function(){var r=As(),o=Vn.identifierPrefix;if(cn){var u=Js,m=Qs;u=(m&~(1<<32-Re(m)-1)).toString(32)+u,o=":"+o+"R"+u,u=nl++,0<u&&(o+="H"+u.toString(32)),o+=":"}else u=vk++,o=":"+o+"r"+u.toString(32)+":";return r.memoizedState=o},unstable_isNewReconciler:!1},Sk={readContext:ss,useCallback:Gv,useContext:ss,useEffect:gh,useImperativeHandle:Yv,useInsertionEffect:qv,useLayoutEffect:Kv,useMemo:Xv,useReducer:ph,useRef:Uv,useState:function(){return ph(il)},useDebugValue:vh,useDeferredValue:function(r){var o=rs();return Qv(o,$n.memoizedState,r)},useTransition:function(){var r=ph(il)[0],o=rs().memoizedState;return[r,o]},useMutableSource:Iv,useSyncExternalStore:Dv,useId:Jv,unstable_isNewReconciler:!1},xk={readContext:ss,useCallback:Gv,useContext:ss,useEffect:gh,useImperativeHandle:Yv,useInsertionEffect:qv,useLayoutEffect:Kv,useMemo:Xv,useReducer:mh,useRef:Uv,useState:function(){return mh(il)},useDebugValue:vh,useDeferredValue:function(r){var o=rs();return $n===null?o.memoizedState=r:Qv(o,$n.memoizedState,r)},useTransition:function(){var r=mh(il)[0],o=rs().memoizedState;return[r,o]},useMutableSource:Iv,useSyncExternalStore:Dv,useId:Jv,unstable_isNewReconciler:!1};function ys(r,o){if(r&&r.defaultProps){o=z({},o),r=r.defaultProps;for(var u in r)o[u]===void 0&&(o[u]=r[u]);return o}return o}function _h(r,o,u,m){o=r.memoizedState,u=u(m,o),u=u==null?o:z({},o,u),r.memoizedState=u,r.lanes===0&&(r.updateQueue.baseState=u)}var Oc={isMounted:function(r){return(r=r._reactInternals)?Wn(r)===r:!1},enqueueSetState:function(r,o,u){r=r._reactInternals;var m=Si(),v=Ar(r),x=er(m,v);x.payload=o,u!=null&&(x.callback=u),o=Er(r,x,v),o!==null&&(Ss(o,r,v,m),Ac(o,r,v))},enqueueReplaceState:function(r,o,u){r=r._reactInternals;var m=Si(),v=Ar(r),x=er(m,v);x.tag=1,x.payload=o,u!=null&&(x.callback=u),o=Er(r,x,v),o!==null&&(Ss(o,r,v,m),Ac(o,r,v))},enqueueForceUpdate:function(r,o){r=r._reactInternals;var u=Si(),m=Ar(r),v=er(u,m);v.tag=2,o!=null&&(v.callback=o),o=Er(r,v,m),o!==null&&(Ss(o,r,m,u),Ac(o,r,m))}};function n_(r,o,u,m,v,x,B){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(m,x,B):o.prototype&&o.prototype.isPureReactComponent?!Wa(u,m)||!Wa(v,x):!0}function i_(r,o,u){var m=!1,v=xr,x=o.contextType;return typeof x=="object"&&x!==null?x=ss(x):(v=Ti(o)?no:pi.current,m=o.contextTypes,x=(m=m!=null)?Yo(r,v):xr),o=new o(u,x),r.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=Oc,r.stateNode=o,o._reactInternals=r,m&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=v,r.__reactInternalMemoizedMaskedChildContext=x),o}function s_(r,o,u,m){r=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(u,m),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(u,m),o.state!==r&&Oc.enqueueReplaceState(o,o.state,null)}function yh(r,o,u,m){var v=r.stateNode;v.props=u,v.state=r.memoizedState,v.refs={},rh(r);var x=o.contextType;typeof x=="object"&&x!==null?v.context=ss(x):(x=Ti(o)?no:pi.current,v.context=Yo(r,x)),v.state=r.memoizedState,x=o.getDerivedStateFromProps,typeof x=="function"&&(_h(r,o,x,u),v.state=r.memoizedState),typeof o.getDerivedStateFromProps=="function"||typeof v.getSnapshotBeforeUpdate=="function"||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(o=v.state,typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount(),o!==v.state&&Oc.enqueueReplaceState(v,v.state,null),Mc(r,u,v,m),v.state=r.memoizedState),typeof v.componentDidMount=="function"&&(r.flags|=4194308)}function na(r,o){try{var u="",m=o;do u+=se(m),m=m.return;while(m);var v=u}catch(x){v=`
|
|
39
|
-
Error generating stack: `+x.message+`
|
|
40
|
-
`+x.stack}return{value:r,source:o,stack:v,digest:null}}function wh(r,o,u){return{value:r,source:null,stack:u??null,digest:o??null}}function bh(r,o){try{console.error(o.value)}catch(u){setTimeout(function(){throw u})}}var Ck=typeof WeakMap=="function"?WeakMap:Map;function r_(r,o,u){u=er(-1,u),u.tag=3,u.payload={element:null};var m=o.value;return u.callback=function(){qc||(qc=!0,Dh=m),bh(r,o)},u}function o_(r,o,u){u=er(-1,u),u.tag=3;var m=r.type.getDerivedStateFromError;if(typeof m=="function"){var v=o.value;u.payload=function(){return m(v)},u.callback=function(){bh(r,o)}}var x=r.stateNode;return x!==null&&typeof x.componentDidCatch=="function"&&(u.callback=function(){bh(r,o),typeof m!="function"&&(Lr===null?Lr=new Set([this]):Lr.add(this));var B=o.stack;this.componentDidCatch(o.value,{componentStack:B!==null?B:""})}),u}function a_(r,o,u){var m=r.pingCache;if(m===null){m=r.pingCache=new Ck;var v=new Set;m.set(o,v)}else v=m.get(o),v===void 0&&(v=new Set,m.set(o,v));v.has(u)||(v.add(u),r=Ok.bind(null,r,o,u),o.then(r,r))}function l_(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 c_(r,o,u,m,v){return(r.mode&1)===0?(r===o?r.flags|=65536:(r.flags|=128,u.flags|=131072,u.flags&=-52805,u.tag===1&&(u.alternate===null?u.tag=17:(o=er(-1,1),o.tag=2,Er(u,o,1))),u.lanes|=1),r):(r.flags|=65536,r.lanes=v,r)}var kk=P.ReactCurrentOwner,Pi=!1;function bi(r,o,u,m){o.child=r===null?Rv(o,null,u,m):Jo(o,r.child,u,m)}function u_(r,o,u,m,v){u=u.render;var x=o.ref;return ea(o,v),m=hh(r,o,u,m,x,v),u=fh(),r!==null&&!Pi?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~v,tr(r,o,v)):(cn&&u&&Gd(o),o.flags|=1,bi(r,o,m,v),o.child)}function d_(r,o,u,m,v){if(r===null){var x=u.type;return typeof x=="function"&&!Uh(x)&&x.defaultProps===void 0&&u.compare===null&&u.defaultProps===void 0?(o.tag=15,o.type=x,h_(r,o,x,m,v)):(r=Qc(u.type,null,m,o,o.mode,v),r.ref=o.ref,r.return=o,o.child=r)}if(x=r.child,(r.lanes&v)===0){var B=x.memoizedProps;if(u=u.compare,u=u!==null?u:Wa,u(B,m)&&r.ref===o.ref)return tr(r,o,v)}return o.flags|=1,r=jr(x,m),r.ref=o.ref,r.return=o,o.child=r}function h_(r,o,u,m,v){if(r!==null){var x=r.memoizedProps;if(Wa(x,m)&&r.ref===o.ref)if(Pi=!1,o.pendingProps=m=x,(r.lanes&v)!==0)(r.flags&131072)!==0&&(Pi=!0);else return o.lanes=r.lanes,tr(r,o,v)}return Sh(r,o,u,m,v)}function f_(r,o,u){var m=o.pendingProps,v=m.children,x=r!==null?r.memoizedState:null;if(m.mode==="hidden")if((o.mode&1)===0)o.memoizedState={baseLanes:0,cachePool:null,transitions:null},tn(sa,Ki),Ki|=u;else{if((u&1073741824)===0)return r=x!==null?x.baseLanes|u:u,o.lanes=o.childLanes=1073741824,o.memoizedState={baseLanes:r,cachePool:null,transitions:null},o.updateQueue=null,tn(sa,Ki),Ki|=r,null;o.memoizedState={baseLanes:0,cachePool:null,transitions:null},m=x!==null?x.baseLanes:u,tn(sa,Ki),Ki|=m}else x!==null?(m=x.baseLanes|u,o.memoizedState=null):m=u,tn(sa,Ki),Ki|=m;return bi(r,o,v,u),o.child}function p_(r,o){var u=o.ref;(r===null&&u!==null||r!==null&&r.ref!==u)&&(o.flags|=512,o.flags|=2097152)}function Sh(r,o,u,m,v){var x=Ti(u)?no:pi.current;return x=Yo(o,x),ea(o,v),u=hh(r,o,u,m,x,v),m=fh(),r!==null&&!Pi?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~v,tr(r,o,v)):(cn&&m&&Gd(o),o.flags|=1,bi(r,o,u,v),o.child)}function m_(r,o,u,m,v){if(Ti(u)){var x=!0;Sc(o)}else x=!1;if(ea(o,v),o.stateNode===null)zc(r,o),i_(o,u,m),yh(o,u,m,v),m=!0;else if(r===null){var B=o.stateNode,Z=o.memoizedProps;B.props=Z;var oe=B.context,ve=u.contextType;typeof ve=="object"&&ve!==null?ve=ss(ve):(ve=Ti(u)?no:pi.current,ve=Yo(o,ve));var je=u.getDerivedStateFromProps,Te=typeof je=="function"||typeof B.getSnapshotBeforeUpdate=="function";Te||typeof B.UNSAFE_componentWillReceiveProps!="function"&&typeof B.componentWillReceiveProps!="function"||(Z!==m||oe!==ve)&&s_(o,B,m,ve),kr=!1;var Me=o.memoizedState;B.state=Me,Mc(o,m,B,v),oe=o.memoizedState,Z!==m||Me!==oe||ji.current||kr?(typeof je=="function"&&(_h(o,u,je,m),oe=o.memoizedState),(Z=kr||n_(o,u,Z,m,Me,oe,ve))?(Te||typeof B.UNSAFE_componentWillMount!="function"&&typeof B.componentWillMount!="function"||(typeof B.componentWillMount=="function"&&B.componentWillMount(),typeof B.UNSAFE_componentWillMount=="function"&&B.UNSAFE_componentWillMount()),typeof B.componentDidMount=="function"&&(o.flags|=4194308)):(typeof B.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=m,o.memoizedState=oe),B.props=m,B.state=oe,B.context=ve,m=Z):(typeof B.componentDidMount=="function"&&(o.flags|=4194308),m=!1)}else{B=o.stateNode,Mv(r,o),Z=o.memoizedProps,ve=o.type===o.elementType?Z:ys(o.type,Z),B.props=ve,Te=o.pendingProps,Me=B.context,oe=u.contextType,typeof oe=="object"&&oe!==null?oe=ss(oe):(oe=Ti(u)?no:pi.current,oe=Yo(o,oe));var Ve=u.getDerivedStateFromProps;(je=typeof Ve=="function"||typeof B.getSnapshotBeforeUpdate=="function")||typeof B.UNSAFE_componentWillReceiveProps!="function"&&typeof B.componentWillReceiveProps!="function"||(Z!==Te||Me!==oe)&&s_(o,B,m,oe),kr=!1,Me=o.memoizedState,B.state=Me,Mc(o,m,B,v);var Je=o.memoizedState;Z!==Te||Me!==Je||ji.current||kr?(typeof Ve=="function"&&(_h(o,u,Ve,m),Je=o.memoizedState),(ve=kr||n_(o,u,ve,m,Me,Je,oe)||!1)?(je||typeof B.UNSAFE_componentWillUpdate!="function"&&typeof B.componentWillUpdate!="function"||(typeof B.componentWillUpdate=="function"&&B.componentWillUpdate(m,Je,oe),typeof B.UNSAFE_componentWillUpdate=="function"&&B.UNSAFE_componentWillUpdate(m,Je,oe)),typeof B.componentDidUpdate=="function"&&(o.flags|=4),typeof B.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof B.componentDidUpdate!="function"||Z===r.memoizedProps&&Me===r.memoizedState||(o.flags|=4),typeof B.getSnapshotBeforeUpdate!="function"||Z===r.memoizedProps&&Me===r.memoizedState||(o.flags|=1024),o.memoizedProps=m,o.memoizedState=Je),B.props=m,B.state=Je,B.context=oe,m=ve):(typeof B.componentDidUpdate!="function"||Z===r.memoizedProps&&Me===r.memoizedState||(o.flags|=4),typeof B.getSnapshotBeforeUpdate!="function"||Z===r.memoizedProps&&Me===r.memoizedState||(o.flags|=1024),m=!1)}return xh(r,o,u,m,x,v)}function xh(r,o,u,m,v,x){p_(r,o);var B=(o.flags&128)!==0;if(!m&&!B)return v&&wv(o,u,!1),tr(r,o,x);m=o.stateNode,kk.current=o;var Z=B&&typeof u.getDerivedStateFromError!="function"?null:m.render();return o.flags|=1,r!==null&&B?(o.child=Jo(o,r.child,null,x),o.child=Jo(o,null,Z,x)):bi(r,o,Z,x),o.memoizedState=m.state,v&&wv(o,u,!0),o.child}function g_(r){var o=r.stateNode;o.pendingContext?_v(r,o.pendingContext,o.pendingContext!==o.context):o.context&&_v(r,o.context,!1),oh(r,o.containerInfo)}function v_(r,o,u,m,v){return Qo(),Zd(v),o.flags|=256,bi(r,o,u,m),o.child}var Ch={dehydrated:null,treeContext:null,retryLane:0};function kh(r){return{baseLanes:r,cachePool:null,transitions:null}}function __(r,o,u){var m=o.pendingProps,v=mn.current,x=!1,B=(o.flags&128)!==0,Z;if((Z=B)||(Z=r!==null&&r.memoizedState===null?!1:(v&2)!==0),Z?(x=!0,o.flags&=-129):(r===null||r.memoizedState!==null)&&(v|=1),tn(mn,v&1),r===null)return Jd(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):(B=m.children,r=m.fallback,x?(m=o.mode,x=o.child,B={mode:"hidden",children:B},(m&1)===0&&x!==null?(x.childLanes=0,x.pendingProps=B):x=Jc(B,m,0,null),r=fo(r,m,u,null),x.return=o,r.return=o,x.sibling=r,o.child=x,o.child.memoizedState=kh(u),o.memoizedState=Ch,r):Eh(o,B));if(v=r.memoizedState,v!==null&&(Z=v.dehydrated,Z!==null))return Ek(r,o,B,m,Z,v,u);if(x){x=m.fallback,B=o.mode,v=r.child,Z=v.sibling;var oe={mode:"hidden",children:m.children};return(B&1)===0&&o.child!==v?(m=o.child,m.childLanes=0,m.pendingProps=oe,o.deletions=null):(m=jr(v,oe),m.subtreeFlags=v.subtreeFlags&14680064),Z!==null?x=jr(Z,x):(x=fo(x,B,u,null),x.flags|=2),x.return=o,m.return=o,m.sibling=x,o.child=m,m=x,x=o.child,B=r.child.memoizedState,B=B===null?kh(u):{baseLanes:B.baseLanes|u,cachePool:null,transitions:B.transitions},x.memoizedState=B,x.childLanes=r.childLanes&~u,o.memoizedState=Ch,m}return x=r.child,r=x.sibling,m=jr(x,{mode:"visible",children:m.children}),(o.mode&1)===0&&(m.lanes=u),m.return=o,m.sibling=null,r!==null&&(u=o.deletions,u===null?(o.deletions=[r],o.flags|=16):u.push(r)),o.child=m,o.memoizedState=null,m}function Eh(r,o){return o=Jc({mode:"visible",children:o},r.mode,0,null),o.return=r,r.child=o}function $c(r,o,u,m){return m!==null&&Zd(m),Jo(o,r.child,null,u),r=Eh(o,o.pendingProps.children),r.flags|=2,o.memoizedState=null,r}function Ek(r,o,u,m,v,x,B){if(u)return o.flags&256?(o.flags&=-257,m=wh(Error(n(422))),$c(r,o,B,m)):o.memoizedState!==null?(o.child=r.child,o.flags|=128,null):(x=m.fallback,v=o.mode,m=Jc({mode:"visible",children:m.children},v,0,null),x=fo(x,v,B,null),x.flags|=2,m.return=o,x.return=o,m.sibling=x,o.child=m,(o.mode&1)!==0&&Jo(o,r.child,null,B),o.child.memoizedState=kh(B),o.memoizedState=Ch,x);if((o.mode&1)===0)return $c(r,o,B,null);if(v.data==="$!"){if(m=v.nextSibling&&v.nextSibling.dataset,m)var Z=m.dgst;return m=Z,x=Error(n(419)),m=wh(x,m,void 0),$c(r,o,B,m)}if(Z=(B&r.childLanes)!==0,Pi||Z){if(m=Vn,m!==null){switch(B&-B){case 4:v=2;break;case 16:v=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:v=32;break;case 536870912:v=268435456;break;default:v=0}v=(v&(m.suspendedLanes|B))!==0?0:v,v!==0&&v!==x.retryLane&&(x.retryLane=v,Zs(r,v),Ss(m,r,v,-1))}return Hh(),m=wh(Error(n(421))),$c(r,o,B,m)}return v.data==="$?"?(o.flags|=128,o.child=r.child,o=$k.bind(null,r),v._reactRetry=o,null):(r=x.treeContext,qi=br(v.nextSibling),Wi=o,cn=!0,_s=null,r!==null&&(ns[is++]=Qs,ns[is++]=Js,ns[is++]=io,Qs=r.id,Js=r.overflow,io=o),o=Eh(o,m.children),o.flags|=4096,o)}function y_(r,o,u){r.lanes|=o;var m=r.alternate;m!==null&&(m.lanes|=o),ih(r.return,o,u)}function Nh(r,o,u,m,v){var x=r.memoizedState;x===null?r.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:m,tail:u,tailMode:v}:(x.isBackwards=o,x.rendering=null,x.renderingStartTime=0,x.last=m,x.tail=u,x.tailMode=v)}function w_(r,o,u){var m=o.pendingProps,v=m.revealOrder,x=m.tail;if(bi(r,o,m.children,u),m=mn.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&&y_(r,u,o);else if(r.tag===19)y_(r,u,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(tn(mn,m),(o.mode&1)===0)o.memoizedState=null;else switch(v){case"forwards":for(u=o.child,v=null;u!==null;)r=u.alternate,r!==null&&jc(r)===null&&(v=u),u=u.sibling;u=v,u===null?(v=o.child,o.child=null):(v=u.sibling,u.sibling=null),Nh(o,!1,v,u,x);break;case"backwards":for(u=null,v=o.child,o.child=null;v!==null;){if(r=v.alternate,r!==null&&jc(r)===null){o.child=v;break}r=v.sibling,v.sibling=u,u=v,v=r}Nh(o,!0,u,null,x);break;case"together":Nh(o,!1,null,null,void 0);break;default:o.memoizedState=null}return o.child}function zc(r,o){(o.mode&1)===0&&r!==null&&(r.alternate=null,o.alternate=null,o.flags|=2)}function tr(r,o,u){if(r!==null&&(o.dependencies=r.dependencies),lo|=o.lanes,(u&o.childLanes)===0)return null;if(r!==null&&o.child!==r.child)throw Error(n(153));if(o.child!==null){for(r=o.child,u=jr(r,r.pendingProps),o.child=u,u.return=o;r.sibling!==null;)r=r.sibling,u=u.sibling=jr(r,r.pendingProps),u.return=o;u.sibling=null}return o.child}function Nk(r,o,u){switch(o.tag){case 3:g_(o),Qo();break;case 5:Pv(o);break;case 1:Ti(o.type)&&Sc(o);break;case 4:oh(o,o.stateNode.containerInfo);break;case 10:var m=o.type._context,v=o.memoizedProps.value;tn(Lc,m._currentValue),m._currentValue=v;break;case 13:if(m=o.memoizedState,m!==null)return m.dehydrated!==null?(tn(mn,mn.current&1),o.flags|=128,null):(u&o.child.childLanes)!==0?__(r,o,u):(tn(mn,mn.current&1),r=tr(r,o,u),r!==null?r.sibling:null);tn(mn,mn.current&1);break;case 19:if(m=(u&o.childLanes)!==0,(r.flags&128)!==0){if(m)return w_(r,o,u);o.flags|=128}if(v=o.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),tn(mn,mn.current),m)break;return null;case 22:case 23:return o.lanes=0,f_(r,o,u)}return tr(r,o,u)}var b_,Lh,S_,x_;b_=function(r,o){for(var u=o.child;u!==null;){if(u.tag===5||u.tag===6)r.appendChild(u.stateNode);else if(u.tag!==4&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===o)break;for(;u.sibling===null;){if(u.return===null||u.return===o)return;u=u.return}u.sibling.return=u.return,u=u.sibling}},Lh=function(){},S_=function(r,o,u,m){var v=r.memoizedProps;if(v!==m){r=o.stateNode,oo(Rs.current);var x=null;switch(u){case"input":v=xe(r,v),m=xe(r,m),x=[];break;case"select":v=z({},v,{value:void 0}),m=z({},m,{value:void 0}),x=[];break;case"textarea":v=bt(r,v),m=bt(r,m),x=[];break;default:typeof v.onClick!="function"&&typeof m.onClick=="function"&&(r.onclick=yc)}Ze(u,m);var B;u=null;for(ve in v)if(!m.hasOwnProperty(ve)&&v.hasOwnProperty(ve)&&v[ve]!=null)if(ve==="style"){var Z=v[ve];for(B in Z)Z.hasOwnProperty(B)&&(u||(u={}),u[B]="")}else ve!=="dangerouslySetInnerHTML"&&ve!=="children"&&ve!=="suppressContentEditableWarning"&&ve!=="suppressHydrationWarning"&&ve!=="autoFocus"&&(s.hasOwnProperty(ve)?x||(x=[]):(x=x||[]).push(ve,null));for(ve in m){var oe=m[ve];if(Z=v!=null?v[ve]:void 0,m.hasOwnProperty(ve)&&oe!==Z&&(oe!=null||Z!=null))if(ve==="style")if(Z){for(B in Z)!Z.hasOwnProperty(B)||oe&&oe.hasOwnProperty(B)||(u||(u={}),u[B]="");for(B in oe)oe.hasOwnProperty(B)&&Z[B]!==oe[B]&&(u||(u={}),u[B]=oe[B])}else u||(x||(x=[]),x.push(ve,u)),u=oe;else ve==="dangerouslySetInnerHTML"?(oe=oe?oe.__html:void 0,Z=Z?Z.__html:void 0,oe!=null&&Z!==oe&&(x=x||[]).push(ve,oe)):ve==="children"?typeof oe!="string"&&typeof oe!="number"||(x=x||[]).push(ve,""+oe):ve!=="suppressContentEditableWarning"&&ve!=="suppressHydrationWarning"&&(s.hasOwnProperty(ve)?(oe!=null&&ve==="onScroll"&&sn("scroll",r),x||Z===oe||(x=[])):(x=x||[]).push(ve,oe))}u&&(x=x||[]).push("style",u);var ve=x;(o.updateQueue=ve)&&(o.flags|=4)}},x_=function(r,o,u,m){u!==m&&(o.flags|=4)};function rl(r,o){if(!cn)switch(r.tailMode){case"hidden":o=r.tail;for(var u=null;o!==null;)o.alternate!==null&&(u=o),o=o.sibling;u===null?r.tail=null:u.sibling=null;break;case"collapsed":u=r.tail;for(var m=null;u!==null;)u.alternate!==null&&(m=u),u=u.sibling;m===null?o||r.tail===null?r.tail=null:r.tail.sibling=null:m.sibling=null}}function gi(r){var o=r.alternate!==null&&r.alternate.child===r.child,u=0,m=0;if(o)for(var v=r.child;v!==null;)u|=v.lanes|v.childLanes,m|=v.subtreeFlags&14680064,m|=v.flags&14680064,v.return=r,v=v.sibling;else for(v=r.child;v!==null;)u|=v.lanes|v.childLanes,m|=v.subtreeFlags,m|=v.flags,v.return=r,v=v.sibling;return r.subtreeFlags|=m,r.childLanes=u,o}function Lk(r,o,u){var m=o.pendingProps;switch(Xd(o),o.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return gi(o),null;case 1:return Ti(o.type)&&bc(),gi(o),null;case 3:return m=o.stateNode,ta(),rn(ji),rn(pi),ch(),m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null),(r===null||r.child===null)&&(Ec(o)?o.flags|=4:r===null||r.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,_s!==null&&($h(_s),_s=null))),Lh(r,o),gi(o),null;case 5:ah(o);var v=oo(el.current);if(u=o.type,r!==null&&o.stateNode!=null)S_(r,o,u,m,v),r.ref!==o.ref&&(o.flags|=512,o.flags|=2097152);else{if(!m){if(o.stateNode===null)throw Error(n(166));return gi(o),null}if(r=oo(Rs.current),Ec(o)){m=o.stateNode,u=o.type;var x=o.memoizedProps;switch(m[Ls]=o,m[Ga]=x,r=(o.mode&1)!==0,u){case"dialog":sn("cancel",m),sn("close",m);break;case"iframe":case"object":case"embed":sn("load",m);break;case"video":case"audio":for(v=0;v<Ka.length;v++)sn(Ka[v],m);break;case"source":sn("error",m);break;case"img":case"image":case"link":sn("error",m),sn("load",m);break;case"details":sn("toggle",m);break;case"input":Ye(m,x),sn("invalid",m);break;case"select":m._wrapperState={wasMultiple:!!x.multiple},sn("invalid",m);break;case"textarea":Ht(m,x),sn("invalid",m)}Ze(u,x),v=null;for(var B in x)if(x.hasOwnProperty(B)){var Z=x[B];B==="children"?typeof Z=="string"?m.textContent!==Z&&(x.suppressHydrationWarning!==!0&&_c(m.textContent,Z,r),v=["children",Z]):typeof Z=="number"&&m.textContent!==""+Z&&(x.suppressHydrationWarning!==!0&&_c(m.textContent,Z,r),v=["children",""+Z]):s.hasOwnProperty(B)&&Z!=null&&B==="onScroll"&&sn("scroll",m)}switch(u){case"input":me(m),He(m,x,!0);break;case"textarea":me(m),fn(m);break;case"select":case"option":break;default:typeof x.onClick=="function"&&(m.onclick=yc)}m=v,o.updateQueue=m,m!==null&&(o.flags|=4)}else{B=v.nodeType===9?v:v.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=It(u)),r==="http://www.w3.org/1999/xhtml"?u==="script"?(r=B.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof m.is=="string"?r=B.createElement(u,{is:m.is}):(r=B.createElement(u),u==="select"&&(B=r,m.multiple?B.multiple=!0:m.size&&(B.size=m.size))):r=B.createElementNS(r,u),r[Ls]=o,r[Ga]=m,b_(r,o,!1,!1),o.stateNode=r;e:{switch(B=ct(u,m),u){case"dialog":sn("cancel",r),sn("close",r),v=m;break;case"iframe":case"object":case"embed":sn("load",r),v=m;break;case"video":case"audio":for(v=0;v<Ka.length;v++)sn(Ka[v],r);v=m;break;case"source":sn("error",r),v=m;break;case"img":case"image":case"link":sn("error",r),sn("load",r),v=m;break;case"details":sn("toggle",r),v=m;break;case"input":Ye(r,m),v=xe(r,m),sn("invalid",r);break;case"option":v=m;break;case"select":r._wrapperState={wasMultiple:!!m.multiple},v=z({},m,{value:void 0}),sn("invalid",r);break;case"textarea":Ht(r,m),v=bt(r,m),sn("invalid",r);break;default:v=m}Ze(u,v),Z=v;for(x in Z)if(Z.hasOwnProperty(x)){var oe=Z[x];x==="style"?K(r,oe):x==="dangerouslySetInnerHTML"?(oe=oe?oe.__html:void 0,oe!=null&&qt(r,oe)):x==="children"?typeof oe=="string"?(u!=="textarea"||oe!=="")&&$t(r,oe):typeof oe=="number"&&$t(r,""+oe):x!=="suppressContentEditableWarning"&&x!=="suppressHydrationWarning"&&x!=="autoFocus"&&(s.hasOwnProperty(x)?oe!=null&&x==="onScroll"&&sn("scroll",r):oe!=null&&O(r,x,oe,B))}switch(u){case"input":me(r),He(r,m,!1);break;case"textarea":me(r),fn(r);break;case"option":m.value!=null&&r.setAttribute("value",""+fe(m.value));break;case"select":r.multiple=!!m.multiple,x=m.value,x!=null?lt(r,!!m.multiple,x,!1):m.defaultValue!=null&<(r,!!m.multiple,m.defaultValue,!0);break;default:typeof v.onClick=="function"&&(r.onclick=yc)}switch(u){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 gi(o),null;case 6:if(r&&o.stateNode!=null)x_(r,o,r.memoizedProps,m);else{if(typeof m!="string"&&o.stateNode===null)throw Error(n(166));if(u=oo(el.current),oo(Rs.current),Ec(o)){if(m=o.stateNode,u=o.memoizedProps,m[Ls]=o,(x=m.nodeValue!==u)&&(r=Wi,r!==null))switch(r.tag){case 3:_c(m.nodeValue,u,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&_c(m.nodeValue,u,(r.mode&1)!==0)}x&&(o.flags|=4)}else m=(u.nodeType===9?u:u.ownerDocument).createTextNode(m),m[Ls]=o,o.stateNode=m}return gi(o),null;case 13:if(rn(mn),m=o.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(cn&&qi!==null&&(o.mode&1)!==0&&(o.flags&128)===0)Ev(),Qo(),o.flags|=98560,x=!1;else if(x=Ec(o),m!==null&&m.dehydrated!==null){if(r===null){if(!x)throw Error(n(318));if(x=o.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(n(317));x[Ls]=o}else Qo(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;gi(o),x=!1}else _s!==null&&($h(_s),_s=null),x=!0;if(!x)return o.flags&65536?o:null}return(o.flags&128)!==0?(o.lanes=u,o):(m=m!==null,m!==(r!==null&&r.memoizedState!==null)&&m&&(o.child.flags|=8192,(o.mode&1)!==0&&(r===null||(mn.current&1)!==0?zn===0&&(zn=3):Hh())),o.updateQueue!==null&&(o.flags|=4),gi(o),null);case 4:return ta(),Lh(r,o),r===null&&Va(o.stateNode.containerInfo),gi(o),null;case 10:return nh(o.type._context),gi(o),null;case 17:return Ti(o.type)&&bc(),gi(o),null;case 19:if(rn(mn),x=o.memoizedState,x===null)return gi(o),null;if(m=(o.flags&128)!==0,B=x.rendering,B===null)if(m)rl(x,!1);else{if(zn!==0||r!==null&&(r.flags&128)!==0)for(r=o.child;r!==null;){if(B=jc(r),B!==null){for(o.flags|=128,rl(x,!1),m=B.updateQueue,m!==null&&(o.updateQueue=m,o.flags|=4),o.subtreeFlags=0,m=u,u=o.child;u!==null;)x=u,r=m,x.flags&=14680066,B=x.alternate,B===null?(x.childLanes=0,x.lanes=r,x.child=null,x.subtreeFlags=0,x.memoizedProps=null,x.memoizedState=null,x.updateQueue=null,x.dependencies=null,x.stateNode=null):(x.childLanes=B.childLanes,x.lanes=B.lanes,x.child=B.child,x.subtreeFlags=0,x.deletions=null,x.memoizedProps=B.memoizedProps,x.memoizedState=B.memoizedState,x.updateQueue=B.updateQueue,x.type=B.type,r=B.dependencies,x.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),u=u.sibling;return tn(mn,mn.current&1|2),o.child}r=r.sibling}x.tail!==null&&te()>ra&&(o.flags|=128,m=!0,rl(x,!1),o.lanes=4194304)}else{if(!m)if(r=jc(B),r!==null){if(o.flags|=128,m=!0,u=r.updateQueue,u!==null&&(o.updateQueue=u,o.flags|=4),rl(x,!0),x.tail===null&&x.tailMode==="hidden"&&!B.alternate&&!cn)return gi(o),null}else 2*te()-x.renderingStartTime>ra&&u!==1073741824&&(o.flags|=128,m=!0,rl(x,!1),o.lanes=4194304);x.isBackwards?(B.sibling=o.child,o.child=B):(u=x.last,u!==null?u.sibling=B:o.child=B,x.last=B)}return x.tail!==null?(o=x.tail,x.rendering=o,x.tail=o.sibling,x.renderingStartTime=te(),o.sibling=null,u=mn.current,tn(mn,m?u&1|2:u&1),o):(gi(o),null);case 22:case 23:return Fh(),m=o.memoizedState!==null,r!==null&&r.memoizedState!==null!==m&&(o.flags|=8192),m&&(o.mode&1)!==0?(Ki&1073741824)!==0&&(gi(o),o.subtreeFlags&6&&(o.flags|=8192)):gi(o),null;case 24:return null;case 25:return null}throw Error(n(156,o.tag))}function Rk(r,o){switch(Xd(o),o.tag){case 1:return Ti(o.type)&&bc(),r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 3:return ta(),rn(ji),rn(pi),ch(),r=o.flags,(r&65536)!==0&&(r&128)===0?(o.flags=r&-65537|128,o):null;case 5:return ah(o),null;case 13:if(rn(mn),r=o.memoizedState,r!==null&&r.dehydrated!==null){if(o.alternate===null)throw Error(n(340));Qo()}return r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 19:return rn(mn),null;case 4:return ta(),null;case 10:return nh(o.type._context),null;case 22:case 23:return Fh(),null;case 24:return null;default:return null}}var Fc=!1,vi=!1,Ak=typeof WeakSet=="function"?WeakSet:Set,Qe=null;function ia(r,o){var u=r.ref;if(u!==null)if(typeof u=="function")try{u(null)}catch(m){wn(r,o,m)}else u.current=null}function Rh(r,o,u){try{u()}catch(m){wn(r,o,m)}}var C_=!1;function Mk(r,o){if(Fd=qe,r=nv(),Td(r)){if("selectionStart"in r)var u={start:r.selectionStart,end:r.selectionEnd};else e:{u=(u=r.ownerDocument)&&u.defaultView||window;var m=u.getSelection&&u.getSelection();if(m&&m.rangeCount!==0){u=m.anchorNode;var v=m.anchorOffset,x=m.focusNode;m=m.focusOffset;try{u.nodeType,x.nodeType}catch{u=null;break e}var B=0,Z=-1,oe=-1,ve=0,je=0,Te=r,Me=null;t:for(;;){for(var Ve;Te!==u||v!==0&&Te.nodeType!==3||(Z=B+v),Te!==x||m!==0&&Te.nodeType!==3||(oe=B+m),Te.nodeType===3&&(B+=Te.nodeValue.length),(Ve=Te.firstChild)!==null;)Me=Te,Te=Ve;for(;;){if(Te===r)break t;if(Me===u&&++ve===v&&(Z=B),Me===x&&++je===m&&(oe=B),(Ve=Te.nextSibling)!==null)break;Te=Me,Me=Te.parentNode}Te=Ve}u=Z===-1||oe===-1?null:{start:Z,end:oe}}else u=null}u=u||{start:0,end:0}}else u=null;for(Hd={focusedElem:r,selectionRange:u},qe=!1,Qe=o;Qe!==null;)if(o=Qe,r=o.child,(o.subtreeFlags&1028)!==0&&r!==null)r.return=o,Qe=r;else for(;Qe!==null;){o=Qe;try{var Je=o.alternate;if((o.flags&1024)!==0)switch(o.tag){case 0:case 11:case 15:break;case 1:if(Je!==null){var et=Je.memoizedProps,Ln=Je.memoizedState,he=o.stateNode,ae=he.getSnapshotBeforeUpdate(o.elementType===o.type?et:ys(o.type,et),Ln);he.__reactInternalSnapshotBeforeUpdate=ae}break;case 3:var pe=o.stateNode.containerInfo;pe.nodeType===1?pe.textContent="":pe.nodeType===9&&pe.documentElement&&pe.removeChild(pe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(De){wn(o,o.return,De)}if(r=o.sibling,r!==null){r.return=o.return,Qe=r;break}Qe=o.return}return Je=C_,C_=!1,Je}function ol(r,o,u){var m=o.updateQueue;if(m=m!==null?m.lastEffect:null,m!==null){var v=m=m.next;do{if((v.tag&r)===r){var x=v.destroy;v.destroy=void 0,x!==void 0&&Rh(o,u,x)}v=v.next}while(v!==m)}}function Hc(r,o){if(o=o.updateQueue,o=o!==null?o.lastEffect:null,o!==null){var u=o=o.next;do{if((u.tag&r)===r){var m=u.create;u.destroy=m()}u=u.next}while(u!==o)}}function Ah(r){var o=r.ref;if(o!==null){var u=r.stateNode;switch(r.tag){case 5:r=u;break;default:r=u}typeof o=="function"?o(r):o.current=r}}function k_(r){var o=r.alternate;o!==null&&(r.alternate=null,k_(o)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(o=r.stateNode,o!==null&&(delete o[Ls],delete o[Ga],delete o[Kd],delete o[fk],delete o[pk])),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 E_(r){return r.tag===5||r.tag===3||r.tag===4}function N_(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||E_(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 Mh(r,o,u){var m=r.tag;if(m===5||m===6)r=r.stateNode,o?u.nodeType===8?u.parentNode.insertBefore(r,o):u.insertBefore(r,o):(u.nodeType===8?(o=u.parentNode,o.insertBefore(r,u)):(o=u,o.appendChild(r)),u=u._reactRootContainer,u!=null||o.onclick!==null||(o.onclick=yc));else if(m!==4&&(r=r.child,r!==null))for(Mh(r,o,u),r=r.sibling;r!==null;)Mh(r,o,u),r=r.sibling}function jh(r,o,u){var m=r.tag;if(m===5||m===6)r=r.stateNode,o?u.insertBefore(r,o):u.appendChild(r);else if(m!==4&&(r=r.child,r!==null))for(jh(r,o,u),r=r.sibling;r!==null;)jh(r,o,u),r=r.sibling}var oi=null,ws=!1;function Nr(r,o,u){for(u=u.child;u!==null;)L_(r,o,u),u=u.sibling}function L_(r,o,u){if(ne&&typeof ne.onCommitFiberUnmount=="function")try{ne.onCommitFiberUnmount(Bt,u)}catch{}switch(u.tag){case 5:vi||ia(u,o);case 6:var m=oi,v=ws;oi=null,Nr(r,o,u),oi=m,ws=v,oi!==null&&(ws?(r=oi,u=u.stateNode,r.nodeType===8?r.parentNode.removeChild(u):r.removeChild(u)):oi.removeChild(u.stateNode));break;case 18:oi!==null&&(ws?(r=oi,u=u.stateNode,r.nodeType===8?qd(r.parentNode,u):r.nodeType===1&&qd(r,u),Pe(r)):qd(oi,u.stateNode));break;case 4:m=oi,v=ws,oi=u.stateNode.containerInfo,ws=!0,Nr(r,o,u),oi=m,ws=v;break;case 0:case 11:case 14:case 15:if(!vi&&(m=u.updateQueue,m!==null&&(m=m.lastEffect,m!==null))){v=m=m.next;do{var x=v,B=x.destroy;x=x.tag,B!==void 0&&((x&2)!==0||(x&4)!==0)&&Rh(u,o,B),v=v.next}while(v!==m)}Nr(r,o,u);break;case 1:if(!vi&&(ia(u,o),m=u.stateNode,typeof m.componentWillUnmount=="function"))try{m.props=u.memoizedProps,m.state=u.memoizedState,m.componentWillUnmount()}catch(Z){wn(u,o,Z)}Nr(r,o,u);break;case 21:Nr(r,o,u);break;case 22:u.mode&1?(vi=(m=vi)||u.memoizedState!==null,Nr(r,o,u),vi=m):Nr(r,o,u);break;default:Nr(r,o,u)}}function R_(r){var o=r.updateQueue;if(o!==null){r.updateQueue=null;var u=r.stateNode;u===null&&(u=r.stateNode=new Ak),o.forEach(function(m){var v=zk.bind(null,r,m);u.has(m)||(u.add(m),m.then(v,v))})}}function bs(r,o){var u=o.deletions;if(u!==null)for(var m=0;m<u.length;m++){var v=u[m];try{var x=r,B=o,Z=B;e:for(;Z!==null;){switch(Z.tag){case 5:oi=Z.stateNode,ws=!1;break e;case 3:oi=Z.stateNode.containerInfo,ws=!0;break e;case 4:oi=Z.stateNode.containerInfo,ws=!0;break e}Z=Z.return}if(oi===null)throw Error(n(160));L_(x,B,v),oi=null,ws=!1;var oe=v.alternate;oe!==null&&(oe.return=null),v.return=null}catch(ve){wn(v,o,ve)}}if(o.subtreeFlags&12854)for(o=o.child;o!==null;)A_(o,r),o=o.sibling}function A_(r,o){var u=r.alternate,m=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(bs(o,r),Ms(r),m&4){try{ol(3,r,r.return),Hc(3,r)}catch(et){wn(r,r.return,et)}try{ol(5,r,r.return)}catch(et){wn(r,r.return,et)}}break;case 1:bs(o,r),Ms(r),m&512&&u!==null&&ia(u,u.return);break;case 5:if(bs(o,r),Ms(r),m&512&&u!==null&&ia(u,u.return),r.flags&32){var v=r.stateNode;try{$t(v,"")}catch(et){wn(r,r.return,et)}}if(m&4&&(v=r.stateNode,v!=null)){var x=r.memoizedProps,B=u!==null?u.memoizedProps:x,Z=r.type,oe=r.updateQueue;if(r.updateQueue=null,oe!==null)try{Z==="input"&&x.type==="radio"&&x.name!=null&&Le(v,x),ct(Z,B);var ve=ct(Z,x);for(B=0;B<oe.length;B+=2){var je=oe[B],Te=oe[B+1];je==="style"?K(v,Te):je==="dangerouslySetInnerHTML"?qt(v,Te):je==="children"?$t(v,Te):O(v,je,Te,ve)}switch(Z){case"input":ze(v,x);break;case"textarea":Rt(v,x);break;case"select":var Me=v._wrapperState.wasMultiple;v._wrapperState.wasMultiple=!!x.multiple;var Ve=x.value;Ve!=null?lt(v,!!x.multiple,Ve,!1):Me!==!!x.multiple&&(x.defaultValue!=null?lt(v,!!x.multiple,x.defaultValue,!0):lt(v,!!x.multiple,x.multiple?[]:"",!1))}v[Ga]=x}catch(et){wn(r,r.return,et)}}break;case 6:if(bs(o,r),Ms(r),m&4){if(r.stateNode===null)throw Error(n(162));v=r.stateNode,x=r.memoizedProps;try{v.nodeValue=x}catch(et){wn(r,r.return,et)}}break;case 3:if(bs(o,r),Ms(r),m&4&&u!==null&&u.memoizedState.isDehydrated)try{Pe(o.containerInfo)}catch(et){wn(r,r.return,et)}break;case 4:bs(o,r),Ms(r);break;case 13:bs(o,r),Ms(r),v=r.child,v.flags&8192&&(x=v.memoizedState!==null,v.stateNode.isHidden=x,!x||v.alternate!==null&&v.alternate.memoizedState!==null||(Ih=te())),m&4&&R_(r);break;case 22:if(je=u!==null&&u.memoizedState!==null,r.mode&1?(vi=(ve=vi)||je,bs(o,r),vi=ve):bs(o,r),Ms(r),m&8192){if(ve=r.memoizedState!==null,(r.stateNode.isHidden=ve)&&!je&&(r.mode&1)!==0)for(Qe=r,je=r.child;je!==null;){for(Te=Qe=je;Qe!==null;){switch(Me=Qe,Ve=Me.child,Me.tag){case 0:case 11:case 14:case 15:ol(4,Me,Me.return);break;case 1:ia(Me,Me.return);var Je=Me.stateNode;if(typeof Je.componentWillUnmount=="function"){m=Me,u=Me.return;try{o=m,Je.props=o.memoizedProps,Je.state=o.memoizedState,Je.componentWillUnmount()}catch(et){wn(m,u,et)}}break;case 5:ia(Me,Me.return);break;case 22:if(Me.memoizedState!==null){T_(Te);continue}}Ve!==null?(Ve.return=Me,Qe=Ve):T_(Te)}je=je.sibling}e:for(je=null,Te=r;;){if(Te.tag===5){if(je===null){je=Te;try{v=Te.stateNode,ve?(x=v.style,typeof x.setProperty=="function"?x.setProperty("display","none","important"):x.display="none"):(Z=Te.stateNode,oe=Te.memoizedProps.style,B=oe!=null&&oe.hasOwnProperty("display")?oe.display:null,Z.style.display=ee("display",B))}catch(et){wn(r,r.return,et)}}}else if(Te.tag===6){if(je===null)try{Te.stateNode.nodeValue=ve?"":Te.memoizedProps}catch(et){wn(r,r.return,et)}}else if((Te.tag!==22&&Te.tag!==23||Te.memoizedState===null||Te===r)&&Te.child!==null){Te.child.return=Te,Te=Te.child;continue}if(Te===r)break e;for(;Te.sibling===null;){if(Te.return===null||Te.return===r)break e;je===Te&&(je=null),Te=Te.return}je===Te&&(je=null),Te.sibling.return=Te.return,Te=Te.sibling}}break;case 19:bs(o,r),Ms(r),m&4&&R_(r);break;case 21:break;default:bs(o,r),Ms(r)}}function Ms(r){var o=r.flags;if(o&2){try{e:{for(var u=r.return;u!==null;){if(E_(u)){var m=u;break e}u=u.return}throw Error(n(160))}switch(m.tag){case 5:var v=m.stateNode;m.flags&32&&($t(v,""),m.flags&=-33);var x=N_(r);jh(r,x,v);break;case 3:case 4:var B=m.stateNode.containerInfo,Z=N_(r);Mh(r,Z,B);break;default:throw Error(n(161))}}catch(oe){wn(r,r.return,oe)}r.flags&=-3}o&4096&&(r.flags&=-4097)}function jk(r,o,u){Qe=r,M_(r)}function M_(r,o,u){for(var m=(r.mode&1)!==0;Qe!==null;){var v=Qe,x=v.child;if(v.tag===22&&m){var B=v.memoizedState!==null||Fc;if(!B){var Z=v.alternate,oe=Z!==null&&Z.memoizedState!==null||vi;Z=Fc;var ve=vi;if(Fc=B,(vi=oe)&&!ve)for(Qe=v;Qe!==null;)B=Qe,oe=B.child,B.tag===22&&B.memoizedState!==null?P_(v):oe!==null?(oe.return=B,Qe=oe):P_(v);for(;x!==null;)Qe=x,M_(x),x=x.sibling;Qe=v,Fc=Z,vi=ve}j_(r)}else(v.subtreeFlags&8772)!==0&&x!==null?(x.return=v,Qe=x):j_(r)}}function j_(r){for(;Qe!==null;){var o=Qe;if((o.flags&8772)!==0){var u=o.alternate;try{if((o.flags&8772)!==0)switch(o.tag){case 0:case 11:case 15:vi||Hc(5,o);break;case 1:var m=o.stateNode;if(o.flags&4&&!vi)if(u===null)m.componentDidMount();else{var v=o.elementType===o.type?u.memoizedProps:ys(o.type,u.memoizedProps);m.componentDidUpdate(v,u.memoizedState,m.__reactInternalSnapshotBeforeUpdate)}var x=o.updateQueue;x!==null&&Tv(o,x,m);break;case 3:var B=o.updateQueue;if(B!==null){if(u=null,o.child!==null)switch(o.child.tag){case 5:u=o.child.stateNode;break;case 1:u=o.child.stateNode}Tv(o,B,u)}break;case 5:var Z=o.stateNode;if(u===null&&o.flags&4){u=Z;var oe=o.memoizedProps;switch(o.type){case"button":case"input":case"select":case"textarea":oe.autoFocus&&u.focus();break;case"img":oe.src&&(u.src=oe.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(o.memoizedState===null){var ve=o.alternate;if(ve!==null){var je=ve.memoizedState;if(je!==null){var Te=je.dehydrated;Te!==null&&Pe(Te)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}vi||o.flags&512&&Ah(o)}catch(Me){wn(o,o.return,Me)}}if(o===r){Qe=null;break}if(u=o.sibling,u!==null){u.return=o.return,Qe=u;break}Qe=o.return}}function T_(r){for(;Qe!==null;){var o=Qe;if(o===r){Qe=null;break}var u=o.sibling;if(u!==null){u.return=o.return,Qe=u;break}Qe=o.return}}function P_(r){for(;Qe!==null;){var o=Qe;try{switch(o.tag){case 0:case 11:case 15:var u=o.return;try{Hc(4,o)}catch(oe){wn(o,u,oe)}break;case 1:var m=o.stateNode;if(typeof m.componentDidMount=="function"){var v=o.return;try{m.componentDidMount()}catch(oe){wn(o,v,oe)}}var x=o.return;try{Ah(o)}catch(oe){wn(o,x,oe)}break;case 5:var B=o.return;try{Ah(o)}catch(oe){wn(o,B,oe)}}}catch(oe){wn(o,o.return,oe)}if(o===r){Qe=null;break}var Z=o.sibling;if(Z!==null){Z.return=o.return,Qe=Z;break}Qe=o.return}}var Tk=Math.ceil,Uc=P.ReactCurrentDispatcher,Th=P.ReactCurrentOwner,os=P.ReactCurrentBatchConfig,Ut=0,Vn=null,jn=null,ai=0,Ki=0,sa=Sr(0),zn=0,al=null,lo=0,Wc=0,Ph=0,ll=null,Ii=null,Ih=0,ra=1/0,nr=null,qc=!1,Dh=null,Lr=null,Kc=!1,Rr=null,Vc=0,cl=0,Bh=null,Yc=-1,Gc=0;function Si(){return(Ut&6)!==0?te():Yc!==-1?Yc:Yc=te()}function Ar(r){return(r.mode&1)===0?1:(Ut&2)!==0&&ai!==0?ai&-ai:gk.transition!==null?(Gc===0&&(Gc=Qr()),Gc):(r=Ft,r!==0||(r=window.event,r=r===void 0?16:yn(r.type)),r)}function Ss(r,o,u,m){if(50<cl)throw cl=0,Bh=null,Error(n(185));vr(r,u,m),((Ut&2)===0||r!==Vn)&&(r===Vn&&((Ut&2)===0&&(Wc|=u),zn===4&&Mr(r,ai)),Di(r,m),u===1&&Ut===0&&(o.mode&1)===0&&(ra=te()+500,xc&&Cr()))}function Di(r,o){var u=r.callbackNode;fi(r,o);var m=Gt(r,r===Vn?ai:0);if(m===0)u!==null&&We(u),r.callbackNode=null,r.callbackPriority=0;else if(o=m&-m,r.callbackPriority!==o){if(u!=null&&We(u),o===1)r.tag===0?mk(D_.bind(null,r)):bv(D_.bind(null,r)),dk(function(){(Ut&6)===0&&Cr()}),u=null;else{switch(Ns(m)){case 1:u=$e;break;case 4:u=ke;break;case 16:u=ut;break;case 536870912:u=Fe;break;default:u=ut}u=W_(u,I_.bind(null,r))}r.callbackPriority=o,r.callbackNode=u}}function I_(r,o){if(Yc=-1,Gc=0,(Ut&6)!==0)throw Error(n(327));var u=r.callbackNode;if(oa()&&r.callbackNode!==u)return null;var m=Gt(r,r===Vn?ai:0);if(m===0)return null;if((m&30)!==0||(m&r.expiredLanes)!==0||o)o=Xc(r,m);else{o=m;var v=Ut;Ut|=2;var x=O_();(Vn!==r||ai!==o)&&(nr=null,ra=te()+500,uo(r,o));do try{Dk();break}catch(Z){B_(r,Z)}while(!0);th(),Uc.current=x,Ut=v,jn!==null?o=0:(Vn=null,ai=0,o=zn)}if(o!==0){if(o===2&&(v=Zt(r),v!==0&&(m=v,o=Oh(r,v))),o===1)throw u=al,uo(r,0),Mr(r,m),Di(r,te()),u;if(o===6)Mr(r,m);else{if(v=r.current.alternate,(m&30)===0&&!Pk(v)&&(o=Xc(r,m),o===2&&(x=Zt(r),x!==0&&(m=x,o=Oh(r,x))),o===1))throw u=al,uo(r,0),Mr(r,m),Di(r,te()),u;switch(r.finishedWork=v,r.finishedLanes=m,o){case 0:case 1:throw Error(n(345));case 2:ho(r,Ii,nr);break;case 3:if(Mr(r,m),(m&130023424)===m&&(o=Ih+500-te(),10<o)){if(Gt(r,0)!==0)break;if(v=r.suspendedLanes,(v&m)!==m){Si(),r.pingedLanes|=r.suspendedLanes&v;break}r.timeoutHandle=Wd(ho.bind(null,r,Ii,nr),o);break}ho(r,Ii,nr);break;case 4:if(Mr(r,m),(m&4194240)===m)break;for(o=r.eventTimes,v=-1;0<m;){var B=31-Re(m);x=1<<B,B=o[B],B>v&&(v=B),m&=~x}if(m=v,m=te()-m,m=(120>m?120:480>m?480:1080>m?1080:1920>m?1920:3e3>m?3e3:4320>m?4320:1960*Tk(m/1960))-m,10<m){r.timeoutHandle=Wd(ho.bind(null,r,Ii,nr),m);break}ho(r,Ii,nr);break;case 5:ho(r,Ii,nr);break;default:throw Error(n(329))}}}return Di(r,te()),r.callbackNode===u?I_.bind(null,r):null}function Oh(r,o){var u=ll;return r.current.memoizedState.isDehydrated&&(uo(r,o).flags|=256),r=Xc(r,o),r!==2&&(o=Ii,Ii=u,o!==null&&$h(o)),r}function $h(r){Ii===null?Ii=r:Ii.push.apply(Ii,r)}function Pk(r){for(var o=r;;){if(o.flags&16384){var u=o.updateQueue;if(u!==null&&(u=u.stores,u!==null))for(var m=0;m<u.length;m++){var v=u[m],x=v.getSnapshot;v=v.value;try{if(!vs(x(),v))return!1}catch{return!1}}}if(u=o.child,o.subtreeFlags&16384&&u!==null)u.return=o,o=u;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 Mr(r,o){for(o&=~Ph,o&=~Wc,r.suspendedLanes|=o,r.pingedLanes&=~o,r=r.expirationTimes;0<o;){var u=31-Re(o),m=1<<u;r[u]=-1,o&=~m}}function D_(r){if((Ut&6)!==0)throw Error(n(327));oa();var o=Gt(r,0);if((o&1)===0)return Di(r,te()),null;var u=Xc(r,o);if(r.tag!==0&&u===2){var m=Zt(r);m!==0&&(o=m,u=Oh(r,m))}if(u===1)throw u=al,uo(r,0),Mr(r,o),Di(r,te()),u;if(u===6)throw Error(n(345));return r.finishedWork=r.current.alternate,r.finishedLanes=o,ho(r,Ii,nr),Di(r,te()),null}function zh(r,o){var u=Ut;Ut|=1;try{return r(o)}finally{Ut=u,Ut===0&&(ra=te()+500,xc&&Cr())}}function co(r){Rr!==null&&Rr.tag===0&&(Ut&6)===0&&oa();var o=Ut;Ut|=1;var u=os.transition,m=Ft;try{if(os.transition=null,Ft=1,r)return r()}finally{Ft=m,os.transition=u,Ut=o,(Ut&6)===0&&Cr()}}function Fh(){Ki=sa.current,rn(sa)}function uo(r,o){r.finishedWork=null,r.finishedLanes=0;var u=r.timeoutHandle;if(u!==-1&&(r.timeoutHandle=-1,uk(u)),jn!==null)for(u=jn.return;u!==null;){var m=u;switch(Xd(m),m.tag){case 1:m=m.type.childContextTypes,m!=null&&bc();break;case 3:ta(),rn(ji),rn(pi),ch();break;case 5:ah(m);break;case 4:ta();break;case 13:rn(mn);break;case 19:rn(mn);break;case 10:nh(m.type._context);break;case 22:case 23:Fh()}u=u.return}if(Vn=r,jn=r=jr(r.current,null),ai=Ki=o,zn=0,al=null,Ph=Wc=lo=0,Ii=ll=null,ro!==null){for(o=0;o<ro.length;o++)if(u=ro[o],m=u.interleaved,m!==null){u.interleaved=null;var v=m.next,x=u.pending;if(x!==null){var B=x.next;x.next=v,m.next=B}u.pending=m}ro=null}return r}function B_(r,o){do{var u=jn;try{if(th(),Tc.current=Bc,Pc){for(var m=gn.memoizedState;m!==null;){var v=m.queue;v!==null&&(v.pending=null),m=m.next}Pc=!1}if(ao=0,Kn=$n=gn=null,tl=!1,nl=0,Th.current=null,u===null||u.return===null){zn=1,al=o,jn=null;break}e:{var x=r,B=u.return,Z=u,oe=o;if(o=ai,Z.flags|=32768,oe!==null&&typeof oe=="object"&&typeof oe.then=="function"){var ve=oe,je=Z,Te=je.tag;if((je.mode&1)===0&&(Te===0||Te===11||Te===15)){var Me=je.alternate;Me?(je.updateQueue=Me.updateQueue,je.memoizedState=Me.memoizedState,je.lanes=Me.lanes):(je.updateQueue=null,je.memoizedState=null)}var Ve=l_(B);if(Ve!==null){Ve.flags&=-257,c_(Ve,B,Z,x,o),Ve.mode&1&&a_(x,ve,o),o=Ve,oe=ve;var Je=o.updateQueue;if(Je===null){var et=new Set;et.add(oe),o.updateQueue=et}else Je.add(oe);break e}else{if((o&1)===0){a_(x,ve,o),Hh();break e}oe=Error(n(426))}}else if(cn&&Z.mode&1){var Ln=l_(B);if(Ln!==null){(Ln.flags&65536)===0&&(Ln.flags|=256),c_(Ln,B,Z,x,o),Zd(na(oe,Z));break e}}x=oe=na(oe,Z),zn!==4&&(zn=2),ll===null?ll=[x]:ll.push(x),x=B;do{switch(x.tag){case 3:x.flags|=65536,o&=-o,x.lanes|=o;var he=r_(x,oe,o);jv(x,he);break e;case 1:Z=oe;var ae=x.type,pe=x.stateNode;if((x.flags&128)===0&&(typeof ae.getDerivedStateFromError=="function"||pe!==null&&typeof pe.componentDidCatch=="function"&&(Lr===null||!Lr.has(pe)))){x.flags|=65536,o&=-o,x.lanes|=o;var De=o_(x,Z,o);jv(x,De);break e}}x=x.return}while(x!==null)}z_(u)}catch(nt){o=nt,jn===u&&u!==null&&(jn=u=u.return);continue}break}while(!0)}function O_(){var r=Uc.current;return Uc.current=Bc,r===null?Bc:r}function Hh(){(zn===0||zn===3||zn===2)&&(zn=4),Vn===null||(lo&268435455)===0&&(Wc&268435455)===0||Mr(Vn,ai)}function Xc(r,o){var u=Ut;Ut|=2;var m=O_();(Vn!==r||ai!==o)&&(nr=null,uo(r,o));do try{Ik();break}catch(v){B_(r,v)}while(!0);if(th(),Ut=u,Uc.current=m,jn!==null)throw Error(n(261));return Vn=null,ai=0,zn}function Ik(){for(;jn!==null;)$_(jn)}function Dk(){for(;jn!==null&&!wt();)$_(jn)}function $_(r){var o=U_(r.alternate,r,Ki);r.memoizedProps=r.pendingProps,o===null?z_(r):jn=o,Th.current=null}function z_(r){var o=r;do{var u=o.alternate;if(r=o.return,(o.flags&32768)===0){if(u=Lk(u,o,Ki),u!==null){jn=u;return}}else{if(u=Rk(u,o),u!==null){u.flags&=32767,jn=u;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{zn=6,jn=null;return}}if(o=o.sibling,o!==null){jn=o;return}jn=o=r}while(o!==null);zn===0&&(zn=5)}function ho(r,o,u){var m=Ft,v=os.transition;try{os.transition=null,Ft=1,Bk(r,o,u,m)}finally{os.transition=v,Ft=m}return null}function Bk(r,o,u,m){do oa();while(Rr!==null);if((Ut&6)!==0)throw Error(n(327));u=r.finishedWork;var v=r.finishedLanes;if(u===null)return null;if(r.finishedWork=null,r.finishedLanes=0,u===r.current)throw Error(n(177));r.callbackNode=null,r.callbackPriority=0;var x=u.lanes|u.childLanes;if(lc(r,x),r===Vn&&(jn=Vn=null,ai=0),(u.subtreeFlags&2064)===0&&(u.flags&2064)===0||Kc||(Kc=!0,W_(ut,function(){return oa(),null})),x=(u.flags&15990)!==0,(u.subtreeFlags&15990)!==0||x){x=os.transition,os.transition=null;var B=Ft;Ft=1;var Z=Ut;Ut|=4,Th.current=null,Mk(r,u),A_(u,r),ik(Hd),qe=!!Fd,Hd=Fd=null,r.current=u,jk(u),Y(),Ut=Z,Ft=B,os.transition=x}else r.current=u;if(Kc&&(Kc=!1,Rr=r,Vc=v),x=r.pendingLanes,x===0&&(Lr=null),le(u.stateNode),Di(r,te()),o!==null)for(m=r.onRecoverableError,u=0;u<o.length;u++)v=o[u],m(v.value,{componentStack:v.stack,digest:v.digest});if(qc)throw qc=!1,r=Dh,Dh=null,r;return(Vc&1)!==0&&r.tag!==0&&oa(),x=r.pendingLanes,(x&1)!==0?r===Bh?cl++:(cl=0,Bh=r):cl=0,Cr(),null}function oa(){if(Rr!==null){var r=Ns(Vc),o=os.transition,u=Ft;try{if(os.transition=null,Ft=16>r?16:r,Rr===null)var m=!1;else{if(r=Rr,Rr=null,Vc=0,(Ut&6)!==0)throw Error(n(331));var v=Ut;for(Ut|=4,Qe=r.current;Qe!==null;){var x=Qe,B=x.child;if((Qe.flags&16)!==0){var Z=x.deletions;if(Z!==null){for(var oe=0;oe<Z.length;oe++){var ve=Z[oe];for(Qe=ve;Qe!==null;){var je=Qe;switch(je.tag){case 0:case 11:case 15:ol(8,je,x)}var Te=je.child;if(Te!==null)Te.return=je,Qe=Te;else for(;Qe!==null;){je=Qe;var Me=je.sibling,Ve=je.return;if(k_(je),je===ve){Qe=null;break}if(Me!==null){Me.return=Ve,Qe=Me;break}Qe=Ve}}}var Je=x.alternate;if(Je!==null){var et=Je.child;if(et!==null){Je.child=null;do{var Ln=et.sibling;et.sibling=null,et=Ln}while(et!==null)}}Qe=x}}if((x.subtreeFlags&2064)!==0&&B!==null)B.return=x,Qe=B;else e:for(;Qe!==null;){if(x=Qe,(x.flags&2048)!==0)switch(x.tag){case 0:case 11:case 15:ol(9,x,x.return)}var he=x.sibling;if(he!==null){he.return=x.return,Qe=he;break e}Qe=x.return}}var ae=r.current;for(Qe=ae;Qe!==null;){B=Qe;var pe=B.child;if((B.subtreeFlags&2064)!==0&&pe!==null)pe.return=B,Qe=pe;else e:for(B=ae;Qe!==null;){if(Z=Qe,(Z.flags&2048)!==0)try{switch(Z.tag){case 0:case 11:case 15:Hc(9,Z)}}catch(nt){wn(Z,Z.return,nt)}if(Z===B){Qe=null;break e}var De=Z.sibling;if(De!==null){De.return=Z.return,Qe=De;break e}Qe=Z.return}}if(Ut=v,Cr(),ne&&typeof ne.onPostCommitFiberRoot=="function")try{ne.onPostCommitFiberRoot(Bt,r)}catch{}m=!0}return m}finally{Ft=u,os.transition=o}}return!1}function F_(r,o,u){o=na(u,o),o=r_(r,o,1),r=Er(r,o,1),o=Si(),r!==null&&(vr(r,1,o),Di(r,o))}function wn(r,o,u){if(r.tag===3)F_(r,r,u);else for(;o!==null;){if(o.tag===3){F_(o,r,u);break}else if(o.tag===1){var m=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(Lr===null||!Lr.has(m))){r=na(u,r),r=o_(o,r,1),o=Er(o,r,1),r=Si(),o!==null&&(vr(o,1,r),Di(o,r));break}}o=o.return}}function Ok(r,o,u){var m=r.pingCache;m!==null&&m.delete(o),o=Si(),r.pingedLanes|=r.suspendedLanes&u,Vn===r&&(ai&u)===u&&(zn===4||zn===3&&(ai&130023424)===ai&&500>te()-Ih?uo(r,0):Ph|=u),Di(r,o)}function H_(r,o){o===0&&((r.mode&1)===0?o=1:(o=Xt,Xt<<=1,(Xt&130023424)===0&&(Xt=4194304)));var u=Si();r=Zs(r,o),r!==null&&(vr(r,o,u),Di(r,u))}function $k(r){var o=r.memoizedState,u=0;o!==null&&(u=o.retryLane),H_(r,u)}function zk(r,o){var u=0;switch(r.tag){case 13:var m=r.stateNode,v=r.memoizedState;v!==null&&(u=v.retryLane);break;case 19:m=r.stateNode;break;default:throw Error(n(314))}m!==null&&m.delete(o),H_(r,u)}var U_;U_=function(r,o,u){if(r!==null)if(r.memoizedProps!==o.pendingProps||ji.current)Pi=!0;else{if((r.lanes&u)===0&&(o.flags&128)===0)return Pi=!1,Nk(r,o,u);Pi=(r.flags&131072)!==0}else Pi=!1,cn&&(o.flags&1048576)!==0&&Sv(o,kc,o.index);switch(o.lanes=0,o.tag){case 2:var m=o.type;zc(r,o),r=o.pendingProps;var v=Yo(o,pi.current);ea(o,u),v=hh(null,o,m,r,v,u);var x=fh();return o.flags|=1,typeof v=="object"&&v!==null&&typeof v.render=="function"&&v.$$typeof===void 0?(o.tag=1,o.memoizedState=null,o.updateQueue=null,Ti(m)?(x=!0,Sc(o)):x=!1,o.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,rh(o),v.updater=Oc,o.stateNode=v,v._reactInternals=o,yh(o,m,r,u),o=xh(null,o,m,!0,x,u)):(o.tag=0,cn&&x&&Gd(o),bi(null,o,v,u),o=o.child),o;case 16:m=o.elementType;e:{switch(zc(r,o),r=o.pendingProps,v=m._init,m=v(m._payload),o.type=m,v=o.tag=Hk(m),r=ys(m,r),v){case 0:o=Sh(null,o,m,r,u);break e;case 1:o=m_(null,o,m,r,u);break e;case 11:o=u_(null,o,m,r,u);break e;case 14:o=d_(null,o,m,ys(m.type,r),u);break e}throw Error(n(306,m,""))}return o;case 0:return m=o.type,v=o.pendingProps,v=o.elementType===m?v:ys(m,v),Sh(r,o,m,v,u);case 1:return m=o.type,v=o.pendingProps,v=o.elementType===m?v:ys(m,v),m_(r,o,m,v,u);case 3:e:{if(g_(o),r===null)throw Error(n(387));m=o.pendingProps,x=o.memoizedState,v=x.element,Mv(r,o),Mc(o,m,null,u);var B=o.memoizedState;if(m=B.element,x.isDehydrated)if(x={element:m,isDehydrated:!1,cache:B.cache,pendingSuspenseBoundaries:B.pendingSuspenseBoundaries,transitions:B.transitions},o.updateQueue.baseState=x,o.memoizedState=x,o.flags&256){v=na(Error(n(423)),o),o=v_(r,o,m,u,v);break e}else if(m!==v){v=na(Error(n(424)),o),o=v_(r,o,m,u,v);break e}else for(qi=br(o.stateNode.containerInfo.firstChild),Wi=o,cn=!0,_s=null,u=Rv(o,null,m,u),o.child=u;u;)u.flags=u.flags&-3|4096,u=u.sibling;else{if(Qo(),m===v){o=tr(r,o,u);break e}bi(r,o,m,u)}o=o.child}return o;case 5:return Pv(o),r===null&&Jd(o),m=o.type,v=o.pendingProps,x=r!==null?r.memoizedProps:null,B=v.children,Ud(m,v)?B=null:x!==null&&Ud(m,x)&&(o.flags|=32),p_(r,o),bi(r,o,B,u),o.child;case 6:return r===null&&Jd(o),null;case 13:return __(r,o,u);case 4:return oh(o,o.stateNode.containerInfo),m=o.pendingProps,r===null?o.child=Jo(o,null,m,u):bi(r,o,m,u),o.child;case 11:return m=o.type,v=o.pendingProps,v=o.elementType===m?v:ys(m,v),u_(r,o,m,v,u);case 7:return bi(r,o,o.pendingProps,u),o.child;case 8:return bi(r,o,o.pendingProps.children,u),o.child;case 12:return bi(r,o,o.pendingProps.children,u),o.child;case 10:e:{if(m=o.type._context,v=o.pendingProps,x=o.memoizedProps,B=v.value,tn(Lc,m._currentValue),m._currentValue=B,x!==null)if(vs(x.value,B)){if(x.children===v.children&&!ji.current){o=tr(r,o,u);break e}}else for(x=o.child,x!==null&&(x.return=o);x!==null;){var Z=x.dependencies;if(Z!==null){B=x.child;for(var oe=Z.firstContext;oe!==null;){if(oe.context===m){if(x.tag===1){oe=er(-1,u&-u),oe.tag=2;var ve=x.updateQueue;if(ve!==null){ve=ve.shared;var je=ve.pending;je===null?oe.next=oe:(oe.next=je.next,je.next=oe),ve.pending=oe}}x.lanes|=u,oe=x.alternate,oe!==null&&(oe.lanes|=u),ih(x.return,u,o),Z.lanes|=u;break}oe=oe.next}}else if(x.tag===10)B=x.type===o.type?null:x.child;else if(x.tag===18){if(B=x.return,B===null)throw Error(n(341));B.lanes|=u,Z=B.alternate,Z!==null&&(Z.lanes|=u),ih(B,u,o),B=x.sibling}else B=x.child;if(B!==null)B.return=x;else for(B=x;B!==null;){if(B===o){B=null;break}if(x=B.sibling,x!==null){x.return=B.return,B=x;break}B=B.return}x=B}bi(r,o,v.children,u),o=o.child}return o;case 9:return v=o.type,m=o.pendingProps.children,ea(o,u),v=ss(v),m=m(v),o.flags|=1,bi(r,o,m,u),o.child;case 14:return m=o.type,v=ys(m,o.pendingProps),v=ys(m.type,v),d_(r,o,m,v,u);case 15:return h_(r,o,o.type,o.pendingProps,u);case 17:return m=o.type,v=o.pendingProps,v=o.elementType===m?v:ys(m,v),zc(r,o),o.tag=1,Ti(m)?(r=!0,Sc(o)):r=!1,ea(o,u),i_(o,m,v),yh(o,m,v,u),xh(null,o,m,!0,r,u);case 19:return w_(r,o,u);case 22:return f_(r,o,u)}throw Error(n(156,o.tag))};function W_(r,o){return Be(r,o)}function Fk(r,o,u,m){this.tag=r,this.key=u,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 as(r,o,u,m){return new Fk(r,o,u,m)}function Uh(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Hk(r){if(typeof r=="function")return Uh(r)?1:0;if(r!=null){if(r=r.$$typeof,r===T)return 11;if(r===j)return 14}return 2}function jr(r,o){var u=r.alternate;return u===null?(u=as(r.tag,o,r.key,r.mode),u.elementType=r.elementType,u.type=r.type,u.stateNode=r.stateNode,u.alternate=r,r.alternate=u):(u.pendingProps=o,u.type=r.type,u.flags=0,u.subtreeFlags=0,u.deletions=null),u.flags=r.flags&14680064,u.childLanes=r.childLanes,u.lanes=r.lanes,u.child=r.child,u.memoizedProps=r.memoizedProps,u.memoizedState=r.memoizedState,u.updateQueue=r.updateQueue,o=r.dependencies,u.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},u.sibling=r.sibling,u.index=r.index,u.ref=r.ref,u}function Qc(r,o,u,m,v,x){var B=2;if(m=r,typeof r=="function")Uh(r)&&(B=1);else if(typeof r=="string")B=5;else e:switch(r){case U:return fo(u.children,v,x,o);case G:B=8,v|=8;break;case X:return r=as(12,u,o,v|2),r.elementType=X,r.lanes=x,r;case I:return r=as(13,u,o,v),r.elementType=I,r.lanes=x,r;case $:return r=as(19,u,o,v),r.elementType=$,r.lanes=x,r;case L:return Jc(u,v,x,o);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case Q:B=10;break e;case V:B=9;break e;case T:B=11;break e;case j:B=14;break e;case M:B=16,m=null;break e}throw Error(n(130,r==null?r:typeof r,""))}return o=as(B,u,o,v),o.elementType=r,o.type=m,o.lanes=x,o}function fo(r,o,u,m){return r=as(7,r,m,o),r.lanes=u,r}function Jc(r,o,u,m){return r=as(22,r,m,o),r.elementType=L,r.lanes=u,r.stateNode={isHidden:!1},r}function Wh(r,o,u){return r=as(6,r,null,o),r.lanes=u,r}function qh(r,o,u){return o=as(4,r.children!==null?r.children:[],r.key,o),o.lanes=u,o.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},o}function Uk(r,o,u,m,v){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=Mi(0),this.expirationTimes=Mi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mi(0),this.identifierPrefix=m,this.onRecoverableError=v,this.mutableSourceEagerHydrationData=null}function Kh(r,o,u,m,v,x,B,Z,oe){return r=new Uk(r,o,u,Z,oe),o===1?(o=1,x===!0&&(o|=8)):o=0,x=as(3,null,null,o),r.current=x,x.stateNode=r,x.memoizedState={element:m,isDehydrated:u,cache:null,transitions:null,pendingSuspenseBoundaries:null},rh(x),r}function Wk(r,o,u){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:W,key:m==null?null:""+m,children:r,containerInfo:o,implementation:u}}function q_(r){if(!r)return xr;r=r._reactInternals;e:{if(Wn(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(Ti(o.type)){o=o.stateNode.__reactInternalMemoizedMergedChildContext;break e}}o=o.return}while(o!==null);throw Error(n(171))}if(r.tag===1){var u=r.type;if(Ti(u))return yv(r,u,o)}return o}function K_(r,o,u,m,v,x,B,Z,oe){return r=Kh(u,m,!0,r,v,x,B,Z,oe),r.context=q_(null),u=r.current,m=Si(),v=Ar(u),x=er(m,v),x.callback=o??null,Er(u,x,v),r.current.lanes=v,vr(r,v,m),Di(r,m),r}function Zc(r,o,u,m){var v=o.current,x=Si(),B=Ar(v);return u=q_(u),o.context===null?o.context=u:o.pendingContext=u,o=er(x,B),o.payload={element:r},m=m===void 0?null:m,m!==null&&(o.callback=m),r=Er(v,o,B),r!==null&&(Ss(r,v,B,x),Ac(r,v,B)),B}function eu(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 V_(r,o){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var u=r.retryLane;r.retryLane=u!==0&&u<o?u:o}}function Vh(r,o){V_(r,o),(r=r.alternate)&&V_(r,o)}function qk(){return null}var Y_=typeof reportError=="function"?reportError:function(r){console.error(r)};function Yh(r){this._internalRoot=r}tu.prototype.render=Yh.prototype.render=function(r){var o=this._internalRoot;if(o===null)throw Error(n(409));Zc(r,o,null,null)},tu.prototype.unmount=Yh.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var o=r.containerInfo;co(function(){Zc(null,r,null,null)}),o[Gs]=null}};function tu(r){this._internalRoot=r}tu.prototype.unstable_scheduleHydration=function(r){if(r){var o=Da();r={blockedOn:null,target:r,priority:o};for(var u=0;u<Hi.length&&o!==0&&o<Hi[u].priority;u++);Hi.splice(u,0,r),u===0&&Ba(r)}};function Gh(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function nu(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function G_(){}function Kk(r,o,u,m,v){if(v){if(typeof m=="function"){var x=m;m=function(){var ve=eu(B);x.call(ve)}}var B=K_(o,m,r,0,null,!1,!1,"",G_);return r._reactRootContainer=B,r[Gs]=B.current,Va(r.nodeType===8?r.parentNode:r),co(),B}for(;v=r.lastChild;)r.removeChild(v);if(typeof m=="function"){var Z=m;m=function(){var ve=eu(oe);Z.call(ve)}}var oe=Kh(r,0,!1,null,null,!1,!1,"",G_);return r._reactRootContainer=oe,r[Gs]=oe.current,Va(r.nodeType===8?r.parentNode:r),co(function(){Zc(o,oe,u,m)}),oe}function iu(r,o,u,m,v){var x=u._reactRootContainer;if(x){var B=x;if(typeof v=="function"){var Z=v;v=function(){var oe=eu(B);Z.call(oe)}}Zc(o,B,r,v)}else B=Kk(u,o,r,v,m);return eu(B)}Jr=function(r){switch(r.tag){case 3:var o=r.stateNode;if(o.current.memoizedState.isDehydrated){var u=Dn(o.pendingLanes);u!==0&&(Po(o,u|1),Di(o,te()),(Ut&6)===0&&(ra=te()+500,Cr()))}break;case 13:co(function(){var m=Zs(r,1);if(m!==null){var v=Si();Ss(m,r,1,v)}}),Vh(r,1)}},Io=function(r){if(r.tag===13){var o=Zs(r,134217728);if(o!==null){var u=Si();Ss(o,r,134217728,u)}Vh(r,134217728)}},Do=function(r){if(r.tag===13){var o=Ar(r),u=Zs(r,o);if(u!==null){var m=Si();Ss(u,r,o,m)}Vh(r,o)}},Da=function(){return Ft},Vs=function(r,o){var u=Ft;try{return Ft=r,o()}finally{Ft=u}},Et=function(r,o,u){switch(o){case"input":if(ze(r,u),o=u.name,u.type==="radio"&&o!=null){for(u=r;u.parentNode;)u=u.parentNode;for(u=u.querySelectorAll("input[name="+JSON.stringify(""+o)+'][type="radio"]'),o=0;o<u.length;o++){var m=u[o];if(m!==r&&m.form===r.form){var v=wc(m);if(!v)throw Error(n(90));Ee(m),ze(m,v)}}}break;case"textarea":Rt(r,u);break;case"select":o=u.value,o!=null&<(r,!!u.multiple,o,!1)}},kn=zh,Ae=co;var Vk={usingClientEntryPoint:!1,Events:[Xa,Ko,wc,tt,Nt,zh]},ul={findFiberByHostInstance:to,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Yk={bundleType:ul.bundleType,version:ul.version,rendererPackageName:ul.rendererPackageName,rendererConfig:ul.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:P.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=re(r),r===null?null:r.stateNode},findFiberByHostInstance:ul.findFiberByHostInstance||qk,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 su=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!su.isDisabled&&su.supportsFiber)try{Bt=su.inject(Yk),ne=su}catch{}}return Bi.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Vk,Bi.createPortal=function(r,o){var u=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Gh(o))throw Error(n(200));return Wk(r,o,null,u)},Bi.createRoot=function(r,o){if(!Gh(r))throw Error(n(299));var u=!1,m="",v=Y_;return o!=null&&(o.unstable_strictMode===!0&&(u=!0),o.identifierPrefix!==void 0&&(m=o.identifierPrefix),o.onRecoverableError!==void 0&&(v=o.onRecoverableError)),o=Kh(r,1,!1,null,null,u,!1,m,v),r[Gs]=o.current,Va(r.nodeType===8?r.parentNode:r),new Yh(o)},Bi.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=re(o),r=r===null?null:r.stateNode,r},Bi.flushSync=function(r){return co(r)},Bi.hydrate=function(r,o,u){if(!nu(o))throw Error(n(200));return iu(null,r,o,!0,u)},Bi.hydrateRoot=function(r,o,u){if(!Gh(r))throw Error(n(405));var m=u!=null&&u.hydratedSources||null,v=!1,x="",B=Y_;if(u!=null&&(u.unstable_strictMode===!0&&(v=!0),u.identifierPrefix!==void 0&&(x=u.identifierPrefix),u.onRecoverableError!==void 0&&(B=u.onRecoverableError)),o=K_(o,null,r,1,u??null,v,!1,x,B),r[Gs]=o.current,Va(r),m)for(r=0;r<m.length;r++)u=m[r],v=u._getVersion,v=v(u._source),o.mutableSourceEagerHydrationData==null?o.mutableSourceEagerHydrationData=[u,v]:o.mutableSourceEagerHydrationData.push(u,v);return new tu(o)},Bi.render=function(r,o,u){if(!nu(o))throw Error(n(200));return iu(null,r,o,!1,u)},Bi.unmountComponentAtNode=function(r){if(!nu(r))throw Error(n(40));return r._reactRootContainer?(co(function(){iu(null,null,r,!1,function(){r._reactRootContainer=null,r[Gs]=null})}),!0):!1},Bi.unstable_batchedUpdates=zh,Bi.unstable_renderSubtreeIntoContainer=function(r,o,u,m){if(!nu(u))throw Error(n(200));if(r==null||r._reactInternals===void 0)throw Error(n(38));return iu(r,o,u,!1,m)},Bi.version="18.3.1-next-f1338f8080-20240426",Bi}var iy;function i2(){if(iy)return Jh.exports;iy=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(),Jh.exports=n2(),Jh.exports}var sy;function s2(){if(sy)return ru;sy=1;var t=i2();return ru.createRoot=t.createRoot,ru.hydrateRoot=t.hydrateRoot,ru}var r2=s2();const o2=Tm(r2),a2=8e3;function l2(t){const e=new AbortController,n=setTimeout(()=>e.abort(new DOMException("timeout","TimeoutError")),t);return{signal:e.signal,cancel:()=>clearTimeout(n),controller:e}}function un(t,e,n={}){const i=Number(n.timeoutMs);if(!Number.isFinite(i)||i<=0)return fetch(t,{...n,headers:{...n.headers||{},Authorization:`Bearer ${e}`}});const{signal:s,cancel:a,controller:c}=l2(i),d=n.signal,h=()=>c.abort(d.reason),f=()=>{a(),d&&d.removeEventListener("abort",h)};if(d){if(d.aborted)return f(),c.abort(d.reason),Promise.reject(d.reason instanceof Error?d.reason:new DOMException("aborted","AbortError"));d.addEventListener("abort",h,{once:!0})}const{timeoutMs:g,..._}=n;return fetch(t,{..._,signal:s,headers:{..._.headers||{},Authorization:`Bearer ${e}`}}).then(y=>(y.__cleanupTimeout=f,y),y=>{throw f(),y})}const O0=t=>`nc_seen_${t}`;async function Ue(t,e,n={}){const i=await un(t,e,{method:n.method||"GET",headers:{"content-type":"application/json"},body:n.body?JSON.stringify(n.body):void 0,timeoutMs:n.timeoutMs});let s;try{try{s=await i.json()}catch(a){if(a&&(a.name==="AbortError"||a.name==="TimeoutError"))throw a;s={}}}finally{typeof i.__cleanupTimeout=="function"&&i.__cleanupTimeout()}if(!i.ok){const a=new Error(s.error||`HTTP ${i.status}`);throw a.status=i.status,a.data=s,a}return s}const hn=t=>Array.isArray(t)&&t.length?`/api/route/${t.map(encodeURIComponent).join("/")}/_`:"/api",An=(t,e)=>`${hn(t)}/fleet/${e}`;async function c2(t,e,n,{signal:i}={}){const s=await un(`${hn(e)}/panel/${encodeURIComponent(n)}/ticket`,t,{method:"POST",signal:i}),a=await s.json().catch(()=>({}));return s.status===200&&a&&typeof a.ticket=="string"?{ok:!0,ticket:a.ticket}:s.status===403&&a&&a.reason==="panel-not-granted"?{ok:!1,cause:"not-granted"}:s.status===403?{ok:!1,cause:"node-refused"}:s.status===404?{ok:!1,cause:"no-panel"}:s.status===401?{ok:!1,cause:"unauthorized"}:{ok:!1,cause:"denied"}}const fr=(t,e,n)=>Ue(An(e,"status"),t,n),$0=6e4,u2=(t,e,n)=>Ue(An(n,"up"),t,{method:"POST",body:e,timeoutMs:$0}),z0=(t,e,n)=>Ue(An(n,"down"),t,{method:"POST",body:e,timeoutMs:$0}),F0=(t,e,n)=>Ue(An(n,"boot"),t,{method:"POST",body:e}),Ll=(t,e,n)=>Ue(An(n,"restart"),t,{method:"POST",body:{cell:e}}),rd=(t,e)=>Ue(An(e,"definitions"),t),d2=(t,e)=>Ue(An(e,"credentials/status"),t),ry=(t,e,n,i)=>Ue(An(i,"credentials/set"),t,{method:"POST",body:{envKey:e,value:n}}),h2=(t,e,n)=>Ue(An(n,"credentials/remove"),t,{method:"POST",body:{envKey:e}}),f2=(t,e,n)=>Ue(An(n,"define-engine"),t,{method:"POST",body:{def:e}}),p2=(t,e,n,i,s)=>Ue(An(s,"edit-engine"),t,{method:"POST",body:{id:e,patch:n,envChanges:i}}),m2=(t,e,n)=>Ue(An(n,"remove-engine"),t,{method:"POST",body:{id:e}}),g2=(t,e,n)=>Ue(An(n,"define-model"),t,{method:"POST",body:{def:e}}),v2=(t,e,n,i)=>Ue(An(i,"remove-model"),t,{method:"POST",body:{id:e,engine:n}}),_2=(t,e,n,i)=>Ue(An(i,"model-test"),t,{method:"POST",body:{engine:e,model:n}}),y2=(t,e,n)=>Ue(An(n,"define-cell"),t,{method:"POST",body:{def:e}}),H0=(t,e,n,i)=>Ue(An(i,"edit-cell"),t,{method:"POST",body:{id:e,patch:n}}),U0=(t,e,n=!1,i)=>Ue(An(i,"remove-cell"),t,{method:"POST",body:{id:e,stop:n}}),w2=(t,e,n)=>Ue(An(n,"import-cell"),t,{method:"POST",body:e}),b2=(t,e,n)=>Ue(An(n,"restore-cells"),t,{method:"POST",body:{cells:e}}),S2=(t,e,n,i,s)=>Ue(An(i,"restore-engines"),t,{method:"POST",body:{engines:e,overwrite:!!n,...Array.isArray(s)&&s.length?{models:s}:{}}}),Im=(t,e,n)=>Ue(`${hn(n)}/sessions/${encodeURIComponent(e)}`,t,{method:"DELETE"}),W0=(t,e,n,i)=>Ue(`${hn(i)}/sessions/${encodeURIComponent(e)}/visibility`,t,{method:"PATCH",body:{technical:!!n}}),Dm=(t,e,n)=>Ue(`${hn(n)}/fs/dirs${e?`?path=${encodeURIComponent(e)}`:""}`,t),q0=t=>Ue("/api/settings",t),x2=t=>Ue("/api/nodes",t),C2=t=>Ue("/api/peers",t),K0=(t,e=[])=>Ue(`${hn(e)}/vl-nodes`,t),oy=(t,e,n,i={},s=[])=>Ue(`${hn(s)}/vl-nodes/${encodeURIComponent(e)}/commands`,t,{method:"POST",body:{kind:n,args:i}}),k2=(t,e,n=0,i=[])=>Ue(`${hn(i)}/vl-nodes/${encodeURIComponent(e)}/events${n?`?after=${encodeURIComponent(n)}`:""}`,t),V0=t=>Ue("/api/topology",t),Bm=(t,e)=>Ue(`${hn(e)}/sessions`,t),Om=(t,e)=>Ue(`${hn(e)}/config`,t),ay=(t,e)=>Ue(`${hn(e)}/topology`,t),fp=(t,e)=>Ue("/api/settings/config",t,{method:"POST",body:e}),E2=t=>Ue("/api/settings/ai-desktop",t),Y0=(t,e)=>Ue("/api/settings/ai-desktop",t,{method:"POST",body:{enabled:e}}),N2=t=>Ue("/api/settings/token/rotate",t,{method:"POST"}),L2=(t,e)=>Ue("/api/settings/nodes/pair",t,{method:"POST",body:e}),R2=(t,e,n=[])=>Ue(`${hn(n)}/settings/peering/invite`,t,{method:"POST",body:e||{}}),G0=(t,e,n)=>Ue(`/api/settings/nodes/${encodeURIComponent(e)}/label`,t,{method:"PATCH",body:{label:n}}),A2=t=>Ue("/api/settings/node-aliases",t),M2=(t,e,n)=>Ue(`/api/settings/node-aliases/${encodeURIComponent(e)}`,t,{method:"PATCH",body:{alias:n}}),ly=(t,e)=>Ue(`/api/settings/node-aliases/${encodeURIComponent(e)}`,t,{method:"DELETE"}),tf=(t,e,n)=>Ue(`/api/settings/nodes/${encodeURIComponent(e)}`,t,{method:"PATCH",body:n}),j2=(t,e)=>Ue(`/api/settings/nodes/${encodeURIComponent(e)}`,t,{method:"DELETE"}),$m=(t,e,n)=>Ue(`/api/settings/nodes/${encodeURIComponent(e)}/${n}`,t,{method:"POST"}),T2=(t,e,n)=>Ue(`/api/settings/nodes/${encodeURIComponent(e)}/share`,t,{method:"PATCH",body:{shared:n}}),P2=(t,e,n,i=[])=>Ue(`/api/settings/nodes/${encodeURIComponent(e)}/visibility`,t,{method:"PATCH",body:{visibility:n,selected:i}}),I2=t=>Ue("/api/settings/audio",t),D2=(t,e)=>Ue("/api/settings/audio/consent",t,{method:"PATCH",body:{consent:e}}),B2=t=>Ue("/api/settings/audio/test",t,{method:"POST",body:{}}),O2=t=>Ue("/api/settings/audio/stop",t,{method:"POST",body:{}}),$2=t=>Ue("/api/settings/audio/groups",t),z2=(t,e,n)=>Ue(`/api/settings/audio/groups/${encodeURIComponent(e)}`,t,{method:"PUT",body:n}),F2=(t,e)=>Ue(`/api/settings/audio/groups/${encodeURIComponent(e)}`,t,{method:"DELETE"}),H2=t=>Ue("/api/settings/service/regenerate",t,{method:"POST"}),U2=t=>Ue("/api/settings/update/check",t,{method:"POST"}),W2=t=>Ue("/api/settings/update/apply",t,{method:"POST"}),od=(t,e)=>`${hn(t)}/diagnostics/${e}`,q2=(t,e=[])=>Ue(od(e,"status"),t),K2=(t,{after:e=0,limit:n=200}={},i=[])=>Ue(`${od(i,"logs")}?after=${encodeURIComponent(e)}&limit=${encodeURIComponent(n)}`,t),cy=(t,e,n,i=[])=>Ue(od(i,"verbose"),t,{method:"PATCH",body:{enabled:e,durationSeconds:n}}),V2=(t,e=[])=>Ue(od(e,"logs"),t,{method:"DELETE"}),Y2=(t,e=!0)=>Ue(`/api/asks${e?"?open=1":""}`,t),G2=(t,e,n)=>Ue(`/api/asks/${encodeURIComponent(e)}/answer`,t,{method:"POST",body:{text:n}}),X2=(t,e)=>Ue(`/api/asks/${encodeURIComponent(e)}`,t,{method:"DELETE"}),Q2=(t,{ownerId:e,askId:n,text:i})=>Ue("/api/asks-relay",t,{method:"POST",body:{ownerId:e,askId:n,text:i}}),J2=(t,{ownerId:e,askId:n,requestId:i})=>Ue("/api/asks-relay",t,{method:"POST",body:{action:"verify",ownerId:e,askId:n,requestId:i}}),Z2=t=>Ue("/api/asks-relay/state",t),eE=(t,{ownerId:e,askId:n})=>Ue("/api/asks-relay",t,{method:"POST",body:{action:"dismiss",ownerId:e,askId:n}}),tE=t=>Ue("/api/feed-state",t),ou=(t,e=[])=>Ue(`${hn(e)}/decks`,t,e.length?{timeoutMs:a2}:{}),uy=(t,e,n=[])=>Ue(`${hn(n)}/decks`,t,{method:"POST",body:{name:e}}),au=(t,e,n,i,s=[])=>Ue(`${hn(s)}/decks/${encodeURIComponent(e)}`,t,{method:"PUT",body:{layout:n,expectedRevision:i}}),nE=(t,e,n,i,s=[])=>un(`${hn(s)}/decks/${encodeURIComponent(e)}`,t,{method:"PUT",keepalive:!0,headers:{"content-type":"application/json"},body:JSON.stringify({layout:n,expectedRevision:i})}),iE=(t,e,n,i,s=[])=>Ue(`${hn(s)}/decks/${encodeURIComponent(e)}`,t,{method:"PATCH",body:{name:n,expectedRevision:i}}),sE=(t,e,n,i=[])=>Ue(`${hn(i)}/decks/${encodeURIComponent(e)}`,t,{method:"DELETE",body:{expectedRevision:n}}),ad=(t,e=[],n)=>Ue(`${hn(e)}/live-host`,t,n),ld=(t,e,n,i=[])=>Ue(`${hn(i)}/live-host/designate`,t,{method:"POST",body:{cellId:e,expectedRevision:n}}),cd=(t,e,n=[])=>Ue(`${hn(n)}/live-host/clear`,t,{method:"POST",body:{expectedRevision:e}}),rE={power:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M12 3v8"}),l.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:l.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:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),l.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),l.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),l.jsx("path",{d:"M12 18v3"})]}),enter:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),l.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),l.jsx("path",{d:"M22 2 11 13"})]}),trash:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M4 7h16"}),l.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),l.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),l.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:l.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),broadcast:l.jsxs(l.Fragment,{children:[l.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor",stroke:"none"}),l.jsx("path",{d:"M7.6 16.4a6.2 6.2 0 0 1 0-8.8"}),l.jsx("path",{d:"M16.4 7.6a6.2 6.2 0 0 1 0 8.8"}),l.jsx("path",{d:"M4.6 19.4a10.6 10.6 0 0 1 0-14.8"}),l.jsx("path",{d:"M19.4 4.6a10.6 10.6 0 0 1 0 14.8"})]}),monitor:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3",y:"4",width:"18",height:"12",rx:"2"}),l.jsx("path",{d:"M8 20h8M12 16v4"})]}),refresh:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),l.jsx("polyline",{points:"21 3 21 8 16 8"})]}),boot:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),l.jsx("path",{d:"M8 21h8M12 17v4M12 12V7"}),l.jsx("polyline",{points:"9 10 12 7 15 10"})]}),upload:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M12 16V5"}),l.jsx("polyline",{points:"8 9 12 5 16 9"}),l.jsx("path",{d:"M5 20h14"})]}),chevronLeft:l.jsx("polyline",{points:"14 6 8 12 14 18"}),chevronUp:l.jsx("polyline",{points:"6 14 12 8 18 14"}),chevronDown:l.jsx("polyline",{points:"6 10 12 16 18 10"}),history:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),l.jsx("polyline",{points:"3 3 3 8 8 8"}),l.jsx("path",{d:"M12 7v5l3 2"})]}),attach:l.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:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),l.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:l.jsxs(l.Fragment,{children:[l.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"}),l.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),l.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),l.jsx("path",{d:"M21 15l-5-5L5 21"})]}),gpu:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"}),l.jsx("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),l.jsx("path",{d:"M9 3v3M15 3v3M9 18v3M15 18v3M3 9h3M3 15h3M18 9h3M18 15h3"})]}),zoomIn:l.jsxs(l.Fragment,{children:[l.jsx("circle",{cx:"11",cy:"11",r:"7"}),l.jsx("path",{d:"M21 21l-4.35-4.35"}),l.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:l.jsxs(l.Fragment,{children:[l.jsx("circle",{cx:"11",cy:"11",r:"7"}),l.jsx("path",{d:"M21 21l-4.35-4.35"}),l.jsx("path",{d:"M8 11h6"})]}),gear:l.jsxs(l.Fragment,{children:[l.jsx("circle",{cx:"12",cy:"12",r:"3"}),l.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),copy:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),l.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})};function kt({name:t,size:e=20}){return l.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:rE[t]||null})}const zm=["it","en","es"];function oE(){try{const t=typeof navigator<"u"&&navigator.language||"",e=String(t).slice(0,2).toLowerCase();return zm.includes(e)?e:"en"}catch{return"en"}}const Nu=oE(),X0="nc_lang",pp="nc-lang";function Q0(){return typeof localStorage<"u"?localStorage:null}const lu={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):","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande","dual-swap":"scambia le due celle","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-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","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",upload:"carica","no-sessions-short":"nessuna sessione","composer-placeholder":"scrivi o detta…","composer-history-tools":"cronologia e dimensione input","composer-history":"cronologia della cella","composer-history-empty":"nessun input inviato","composer-history-clear":"cancella cronologia di questa cella","composer-expand":"espandi input","composer-collapse":"riduci input","composer-clear-data":"cancella bozze e cronologia","composer-clear-data-help":"Rimuove da questo browser tutte le bozze e la cronologia input delle celle.","composer-clear-confirm":"Cancellare tutte le bozze e la cronologia input salvate in questo browser?","composer-clear-done":"Bozze e cronologia cancellate.","composer-clear-failed":"Impossibile cancellare i dati del composer in questo browser.",attach:"allega","attach-file":"File","attach-camera":"Fotocamera","attach-gallery":"Galleria","attach-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-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","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.","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-model-default":"modello predefinito (opzionale)","fleet-model-required":"modello (obbligatorio)","fleet-standard-permissions":"permessi standard","fleet-unsafe-permissions":"non sicuro · ignora approvazioni/sandbox","fleet-unsafe-warning":"Modalità non sicura esplicita: il worker può agire senza le normali approvazioni o protezioni sandbox.","fleet-provider-display":"nome visualizzato del provider","fleet-custom-provider-default":"Provider personalizzato","fleet-api-key-env":"NOME_VARIABILE_API_KEY","fleet-provider-id":"id-provider","fleet-custom-secret-help":"NexusCrew salva solo il nome della variabile d’ambiente, mai il suo valore.","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-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-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","ask-dismiss":"Scarta la domanda","ask-reply-ph":"scrivi la risposta…","push-enable":"attiva notifiche push","push-disable":"disattiva notifiche push","push-on":"push attive su questo device","push-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-remote-no-feed":"Non ricevi gli eventi di questo nodo: attiva la ricezione (nodes edit <peer> --events-receive true).","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-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):","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text","dual-swap":"swap the two cells","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-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","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",upload:"upload","no-sessions-short":"no sessions","composer-placeholder":"type or dictate…","composer-history-tools":"input history and size","composer-history":"cell history","composer-history-empty":"no submitted input","composer-history-clear":"clear this cell history","composer-expand":"expand input","composer-collapse":"collapse input","composer-clear-data":"clear drafts and history","composer-clear-data-help":"Removes every saved cell draft and input-history entry from this browser.","composer-clear-confirm":"Clear every saved draft and input-history entry from this browser?","composer-clear-done":"Drafts and history cleared.","composer-clear-failed":"Could not clear composer data in this browser.",attach:"attach","attach-file":"File","attach-camera":"Camera","attach-gallery":"Gallery","attach-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-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","visibility-relay":"relay only","visibility-selected":"selected nodes","hydra-simple":"local + nodes, one network","local-ready":"This device is ready. Use it alone or connect it to a node.","local-only":"local only","add-node":"add node",connect:"connect","node-connected":"Node connected. The network will synchronize automatically.","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.","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-model-default":"default model (optional)","fleet-model-required":"model (required)","fleet-standard-permissions":"standard permissions","fleet-unsafe-permissions":"unsafe · bypass approvals/sandbox","fleet-unsafe-warning":"Explicit unsafe mode: the worker can act without normal approval or sandbox gates.","fleet-provider-display":"provider display name","fleet-custom-provider-default":"Custom provider","fleet-api-key-env":"API_KEY_ENV_NAME","fleet-provider-id":"provider-id","fleet-custom-secret-help":"NexusCrew stores only the environment-variable name, never its value.","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-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-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","ask-dismiss":"Dismiss question","ask-reply-ph":"type your answer…","push-enable":"enable push notifications","push-disable":"disable push notifications","push-on":"push active on this device","push-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-remote-no-feed":"You are not receiving this node’s events: enable receiving (nodes edit <peer> --events-receive true).","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-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):","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-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-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","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",upload:"subir","no-sessions-short":"sin sesiones","composer-placeholder":"escribe o dicta…","composer-history-tools":"historial y tamaño de entrada","composer-history":"historial de la celda","composer-history-empty":"ninguna entrada enviada","composer-history-clear":"borrar historial de esta celda","composer-expand":"ampliar entrada","composer-collapse":"reducir entrada","composer-clear-data":"borrar borradores e historial","composer-clear-data-help":"Elimina de este navegador todos los borradores y el historial de entrada de las celdas.","composer-clear-confirm":"¿Borrar todos los borradores y el historial de entrada guardados en este navegador?","composer-clear-done":"Borradores e historial eliminados.","composer-clear-failed":"No se pudieron borrar los datos del composer en este navegador.",attach:"adjuntar","attach-file":"Archivo","attach-camera":"Cámara","attach-gallery":"Galería","attach-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-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.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","invite-node":"invitar un nodo","create-pairing-link":"crear enlace / QR","visibility-network":"toda la red","visibility-relay":"solo relay","visibility-selected":"nodos seleccionados","hydra-simple":"local + nodos, una red","local-ready":"Este dispositivo está listo. Úsalo solo o conéctalo a un nodo.","local-only":"solo local","add-node":"añadir nodo",connect:"conectar","node-connected":"Nodo conectado. La red se sincronizará automáticamente.","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.","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-model-default":"modelo predeterminado (opcional)","fleet-model-required":"modelo (obligatorio)","fleet-standard-permissions":"permisos estándar","fleet-unsafe-permissions":"inseguro · omitir aprobaciones/sandbox","fleet-unsafe-warning":"Modo inseguro explícito: el worker puede actuar sin las aprobaciones normales ni las protecciones del sandbox.","fleet-provider-display":"nombre visible del proveedor","fleet-custom-provider-default":"Proveedor personalizado","fleet-api-key-env":"NOMBRE_VARIABLE_API_KEY","fleet-provider-id":"id-proveedor","fleet-custom-secret-help":"NexusCrew guarda solo el nombre de la variable de entorno, nunca su valor.","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-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-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","ask-dismiss":"Descartar la pregunta","ask-reply-ph":"escribe la respuesta…","push-enable":"activar notificaciones push","push-disable":"desactivar notificaciones push","push-on":"push activas en este dispositivo","push-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-remote-no-feed":"No recibes los eventos de este nodo: activa la recepción (nodes edit <peer> --events-receive true).","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-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 Ou(){const t=Q0(),e=t?t.getItem(X0):null;return zm.includes(e)?e:Nu}function aE(t){const e=Q0();if(e)try{e.setItem(X0,t)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(pp))}function p(t){const e=Ou(),n=lu[e]||lu[Nu];return Object.prototype.hasOwnProperty.call(n,t)?n[t]:Object.prototype.hasOwnProperty.call(lu[Nu],t)?lu[Nu][t]:t}function lE(t){return typeof window>"u"?()=>{}:(window.addEventListener(pp,t),()=>window.removeEventListener(pp,t))}const J0=zm,Fm="nc_popup_assetto",cE=320,uE=240,dE=1100,hE=820,dy=48,fE=44;function Z0(){return{vw:window.innerWidth||1024,vh:window.innerHeight||768}}function Rl(t){const{vw:e,vh:n}=Z0(),i=Math.max(cE,Math.min(t.w,e)),s=Math.max(uE,Math.min(t.h,n)),a=Math.max(-(i-dy),Math.min(t.x,e-dy)),c=Math.max(0,Math.min(t.y,Math.max(0,n-fE)));return{x:a,y:c,w:i,h:s}}function hy(){try{const t=window.localStorage.getItem(Fm);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:Rl(e)}catch{return null}}function pE(t){try{window.localStorage.setItem(Fm,JSON.stringify(t))}catch{}}function mE(){const[t,e]=b.useState(()=>typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 720px)").matches);return b.useEffect(()=>{if(typeof window.matchMedia!="function")return;const n=window.matchMedia("(max-width: 720px)"),i=s=>e(!!(s&&s.matches));if(typeof n.addEventListener=="function")return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[]),t}function eS({title:t,subtitle:e,onClose:n,children:i}){const s=b.useRef(null),a=b.useRef(null),c=mE(),[d,h]=b.useState(()=>c?null:hy()),f=b.useRef(null),[g,_]=b.useState(!1),y=b.useCallback(()=>{n&&n()},[n]);b.useEffect(()=>{const N=k=>{k.key==="Escape"&&(k.stopPropagation(),y())};return document.addEventListener("keydown",N,!0),()=>document.removeEventListener("keydown",N,!0)},[y]),b.useEffect(()=>{const N=a.current;N&&typeof N.focus=="function"&&N.focus()},[]);const w=()=>{const{vw:N,vh:k}=Z0(),O=Math.min(dE,Math.floor(N*.96)),P=Math.min(hE,Math.floor(k*.92));return Rl({x:Math.round((N-O)/2),y:Math.round((k-P)/2),w:O,h:P})},S=N=>k=>{if(c||k.button!==0||k.target&&typeof k.target.closest=="function"&&k.target.closest(".nc-popup-chiudi"))return;k.preventDefault();const O=d||w();f.current={mode:N,startX:k.clientX,startY:k.clientY,base:O},h(O),_(!0)};b.useEffect(()=>{if(!g)return;const N=O=>{const P=f.current;if(!P)return;const H=O.clientX-P.startX,W=O.clientY-P.startY;P.mode==="move"?h(Rl({...P.base,x:P.base.x+H,y:P.base.y+W})):h(Rl({...P.base,w:P.base.w+H,h:P.base.h+W}))},k=()=>{f.current=null,_(!1),h(O=>(O&&pE(O),O))};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",k),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",k)}},[g]);const A=()=>{if(!c){f.current=null,_(!1),h(null);try{window.localStorage.removeItem(Fm)}catch{}}};b.useEffect(()=>{if(c)return;const N=()=>h(k=>k&&Rl(k));return window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[c]),b.useEffect(()=>{c||h(N=>N||hy())},[c]);const C=!!(d&&!c);return l.jsxs("div",{className:"nc-popup-velo",onMouseDown:N=>{N.target===N.currentTarget&&y()},role:"presentation",children:[l.jsxs("div",{className:C?"nc-popup nc-popup-libera":"nc-popup",style:C?{left:d.x,top:d.y,width:d.w,height:d.h}:void 0,ref:s,role:"dialog","aria-modal":"true","aria-label":t||p("panel"),children:[l.jsxs("header",{className:"nc-popup-testa",onMouseDown:S("move"),onDoubleClick:A,title:p("popup-drag-hint"),children:[l.jsxs("span",{className:"nc-popup-titolo",children:[t,e?l.jsx("small",{className:"nc-popup-sub",children:e}):null]}),l.jsx("button",{type:"button",ref:a,className:"nc-popup-chiudi",onClick:y,title:p("close"),"aria-label":p("close"),children:"✕"})]}),l.jsx("div",{className:"nc-popup-corpo",children:i}),!c&&l.jsx("div",{className:"nc-popup-angolo",onMouseDown:S("resize"),title:p("popup-resize-hint"),role:"presentation"})]}),g&&l.jsx("div",{className:"nc-popup-velo-drag",role:"presentation"})]})}const Hl="none",tS="favorite",nS="designated",iS="thread-present",sS="thread-active",rS="thread-unknown",oS=new Set([nS,iS,sS,rS]);function aS(t){return t==="absent"?nS:t==="present"?iS:t==="active"?sS:rS}function gE(t){return oS.has(t)?`host-thread-${t.replace("thread-","")}`:null}function $u({hostCell:t,threadStatus:e,pins:n=[],item:i}){const s=i&&i.value&&typeof i.value.cell=="string"?i.value.cell:null;return s!=null&&t===s?aS(e):Array.isArray(n)&&i&&n.includes(i.key)?tS:Hl}const vE=Object.freeze(["live","grace","expired","none","unavailable"]);function mp(t,e){return!oS.has(t)||!vE.includes(e)?null:`host-lease-${e}`}const _E="local";function yi(t){return Array.isArray(t)&&t.length?t.join("/"):_E}function gp(t){return(t&&t.data&&typeof t.data=="object"?t.data.reason:null)==="live-host-not-granted"?"live-host-not-granted":"live-host-error"}function fy(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":gp(t)}async function ud({action:t,cellId:e,route:n=[],token:i,api:s={}}={}){const a=s.getLiveHost||(g=>ad(i,g)),c=s.designateHostCell||((g,_,y)=>ld(i,g,_,y)),d=s.clearHostCell||((g,_)=>cd(i,g,_));let h;try{h=await a(n)}catch(g){return{ok:!1,messageKey:fy(g),error:g}}const f=Number.isInteger(h&&h.revision)?h.revision:0;try{if(t==="remove"){const _=await d(f,n);return{ok:!0,messageKey:"live-host-cleared",hostCell:_&&typeof _.hostCell=="string"?_.hostCell:null,revision:_&&_.revision}}const g=await c(e,f,n);return{ok:!0,messageKey:"live-host-designated",hostCell:g&&typeof g.hostCell=="string"?g.hostCell:e,revision:g&&g.revision}}catch(g){return{ok:!1,messageKey:fy(g),error:g}}}/**
|
|
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 lS=Object.defineProperty,yE=Object.getOwnPropertyDescriptor,wE=(t,e)=>{for(var n in e)lS(t,n,{get:e[n],enumerable:!0})},Cn=(t,e,n,i)=>{for(var s=i>1?void 0:i?yE(e,n):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(s=(i?c(e,n,s):c(s))||s);return i&&s&&lS(e,n,s),s},Ke=(t,e)=>(n,i)=>e(n,i,t),py="Terminal input",vp={get:()=>py,set:t=>py=t},my="Too much output to announce, navigate to rows manually to read",_p={get:()=>my,set:t=>my=t};function bE(t){return t.replace(/\r?\n/g,"\r")}function SE(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function xE(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function CE(t,e,n,i){if(t.stopPropagation(),t.clipboardData){let s=t.clipboardData.getData("text/plain");cS(s,e,n,i)}}function cS(t,e,n,i){t=bE(t),t=SE(t,n.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(t,!0),e.value=""}function uS(t,e,n){let i=n.getBoundingClientRect(),s=t.clientX-i.left-10,a=t.clientY-i.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${s}px`,e.style.top=`${a}px`,e.style.zIndex="1000",e.focus()}function gy(t,e,n,i,s){uS(t,e,n),s&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function Ur(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function dd(t,e=0,n=t.length){let i="";for(let s=e;s<n;++s){let a=t[s];a>65535?(a-=65536,i+=String.fromCharCode((a>>10)+55296)+String.fromCharCode(a%1024+56320)):i+=String.fromCharCode(a)}return i}var kE=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,n){let i=e.length;if(!i)return 0;let s=0,a=0;if(this._interim){let c=e.charCodeAt(a++);56320<=c&&c<=57343?n[s++]=(this._interim-55296)*1024+c-56320+65536:(n[s++]=this._interim,n[s++]=c),this._interim=0}for(let c=a;c<i;++c){let d=e.charCodeAt(c);if(55296<=d&&d<=56319){if(++c>=i)return this._interim=d,s;let h=e.charCodeAt(c);56320<=h&&h<=57343?n[s++]=(d-55296)*1024+h-56320+65536:(n[s++]=d,n[s++]=h);continue}d!==65279&&(n[s++]=d)}return s}},EE=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,n){let i=e.length;if(!i)return 0;let s=0,a,c,d,h,f=0,g=0;if(this.interim[0]){let w=!1,S=this.interim[0];S&=(S&224)===192?31:(S&240)===224?15:7;let A=0,C;for(;(C=this.interim[++A]&63)&&A<4;)S<<=6,S|=C;let N=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,k=N-A;for(;g<k;){if(g>=i)return 0;if(C=e[g++],(C&192)!==128){g--,w=!0;break}else this.interim[A++]=C,S<<=6,S|=C&63}w||(N===2?S<128?g--:n[s++]=S:N===3?S<2048||S>=55296&&S<=57343||S===65279||(n[s++]=S):S<65536||S>1114111||(n[s++]=S)),this.interim.fill(0)}let _=i-4,y=g;for(;y<i;){for(;y<_&&!((a=e[y])&128)&&!((c=e[y+1])&128)&&!((d=e[y+2])&128)&&!((h=e[y+3])&128);)n[s++]=a,n[s++]=c,n[s++]=d,n[s++]=h,y+=4;if(a=e[y++],a<128)n[s++]=a;else if((a&224)===192){if(y>=i)return this.interim[0]=a,s;if(c=e[y++],(c&192)!==128){y--;continue}if(f=(a&31)<<6|c&63,f<128){y--;continue}n[s++]=f}else if((a&240)===224){if(y>=i)return this.interim[0]=a,s;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=i)return this.interim[0]=a,this.interim[1]=c,s;if(d=e[y++],(d&192)!==128){y--;continue}if(f=(a&15)<<12|(c&63)<<6|d&63,f<2048||f>=55296&&f<=57343||f===65279)continue;n[s++]=f}else if((a&248)===240){if(y>=i)return this.interim[0]=a,s;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=i)return this.interim[0]=a,this.interim[1]=c,s;if(d=e[y++],(d&192)!==128){y--;continue}if(y>=i)return this.interim[0]=a,this.interim[1]=c,this.interim[2]=d,s;if(h=e[y++],(h&192)!==128){y--;continue}if(f=(a&7)<<18|(c&63)<<12|(d&63)<<6|h&63,f<65536||f>1114111)continue;n[s++]=f}}return s}},dS="",qr=" ",ec=class hS{constructor(){this.fg=0,this.bg=0,this.extended=new zu}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 hS;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}},zu=class fS{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 fS(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},ps=class pS extends ec{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new zu,this.combinedData=""}static fromCharData(e){let n=new pS;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?Ur(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 i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let s=e[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(i-55296)*1024+s-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()]}},vy="di$target",yp="di$dependencies",nf=new Map;function NE(t){return t[yp]||[]}function si(t){if(nf.has(t))return nf.get(t);let e=function(n,i,s){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");LE(e,n,s)};return e._id=t,nf.set(t,e),e}function LE(t,e,n){e[vy]===e?e[yp].push({id:t,index:n}):(e[yp]=[{id:t,index:n}],e[vy]=e)}var Ei=si("BufferService"),mS=si("CoreMouseService"),Mo=si("CoreService"),RE=si("CharsetService"),Hm=si("InstantiationService"),gS=si("LogService"),Ni=si("OptionsService"),vS=si("OscLinkService"),AE=si("UnicodeService"),tc=si("DecorationService"),wp=class{constructor(e,n,i){this._bufferService=e,this._optionsService=n,this._oscLinkService=i}provideLinks(e,n){var _;let i=this._bufferService.buffer.lines.get(e-1);if(!i){n(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,c=new ps,d=i.getTrimmedLength(),h=-1,f=-1,g=!1;for(let y=0;y<d;y++)if(!(f===-1&&!i.hasContent(y))){if(i.loadCell(y,c),c.hasExtendedAttrs()&&c.extended.urlId)if(f===-1){f=y,h=c.extended.urlId;continue}else g=c.extended.urlId!==h;else f!==-1&&(g=!0);if(g||f!==-1&&y===d-1){let w=(_=this._oscLinkService.getLinkData(h))==null?void 0:_.uri;if(w){let S={start:{x:f+1,y:e},end:{x:y+(!g&&y===d-1?1:0),y:e}},A=!1;if(!(a!=null&&a.allowNonHttpProtocols))try{let C=new URL(w);["http:","https:"].includes(C.protocol)||(A=!0)}catch{A=!0}A||s.push({text:w,range:S,activate:(C,N)=>a?a.activate(C,N,S):ME(C,N),hover:(C,N)=>{var k;return(k=a==null?void 0:a.hover)==null?void 0:k.call(a,C,N,S)},leave:(C,N)=>{var k;return(k=a==null?void 0:a.leave)==null?void 0:k.call(a,C,N,S)}})}g=!1,c.hasExtendedAttrs()&&c.extended.urlId?(f=y,h=c.extended.urlId):(f=-1,h=-1)}}n(s)}};wp=Cn([Ke(0,Ei),Ke(1,Ni),Ke(2,vS)],wp);function ME(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 hd=si("CharSizeService"),mr=si("CoreBrowserService"),Um=si("MouseService"),gr=si("RenderService"),jE=si("SelectionService"),_S=si("CharacterJoinerService"),Aa=si("ThemeService"),yS=si("LinkProviderService"),TE=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?_y.isErrorNoTelemetry(e)?new _y(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)}},PE=new TE;function Lu(t){IE(t)||PE.onUnexpectedError(t)}var bp="Canceled";function IE(t){return t instanceof DE?!0:t instanceof Error&&t.name===bp&&t.message===bp}var DE=class extends Error{constructor(){super(bp),this.name=this.message}};function BE(t){return new Error(`Illegal argument: ${t}`)}var _y=class Sp extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof Sp)return e;let n=new Sp;return n.message=e.message,n.stack=e.stack,n}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},xp=class wS extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,wS.prototype)}};function Vi(t,e=0){return t[t.length-(1+e)]}var OE;(t=>{function e(a){return a<0}t.isLessThan=e;function n(a){return a<=0}t.isLessThanOrEqual=n;function i(a){return a>0}t.isGreaterThan=i;function s(a){return a===0}t.isNeitherLessOrGreaterThan=s,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(OE||(OE={}));function $E(t,e){let n=this,i=!1,s;return function(){return i||(i=!0,e||(s=t.apply(n,arguments))),s}}var bS;(t=>{function e(P){return P&&typeof P=="object"&&typeof P[Symbol.iterator]=="function"}t.is=e;let n=Object.freeze([]);function i(){return n}t.empty=i;function*s(P){yield P}t.single=s;function a(P){return e(P)?P:s(P)}t.wrap=a;function c(P){return P||n}t.from=c;function*d(P){for(let H=P.length-1;H>=0;H--)yield P[H]}t.reverse=d;function h(P){return!P||P[Symbol.iterator]().next().done===!0}t.isEmpty=h;function f(P){return P[Symbol.iterator]().next().value}t.first=f;function g(P,H){let W=0;for(let U of P)if(H(U,W++))return!0;return!1}t.some=g;function _(P,H){for(let W of P)if(H(W))return W}t.find=_;function*y(P,H){for(let W of P)H(W)&&(yield W)}t.filter=y;function*w(P,H){let W=0;for(let U of P)yield H(U,W++)}t.map=w;function*S(P,H){let W=0;for(let U of P)yield*H(U,W++)}t.flatMap=S;function*A(...P){for(let H of P)yield*H}t.concat=A;function C(P,H,W){let U=W;for(let G of P)U=H(U,G);return U}t.reduce=C;function*N(P,H,W=P.length){for(H<0&&(H+=P.length),W<0?W+=P.length:W>P.length&&(W=P.length);H<W;H++)yield P[H]}t.slice=N;function k(P,H=Number.POSITIVE_INFINITY){let W=[];if(H===0)return[W,P];let U=P[Symbol.iterator]();for(let G=0;G<H;G++){let X=U.next();if(X.done)return[W,t.empty()];W.push(X.value)}return[W,{[Symbol.iterator](){return U}}]}t.consume=k;async function O(P){let H=[];for await(let W of P)H.push(W);return Promise.resolve(H)}t.asyncToArray=O})(bS||(bS={}));function Lo(t){if(bS.is(t)){let e=[];for(let n of t)if(n)try{n.dispose()}catch(i){e.push(i)}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 zE(...t){return dn(()=>Lo(t))}function dn(t){return{dispose:$E(()=>{t()})}}var SS=class xS{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{Lo(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?xS.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)}};SS.DISABLE_DISPOSED_WARNING=!1;var Yr=SS,Mt=class{constructor(){this._store=new Yr,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)}};Mt.None=Object.freeze({dispose(){}});var Sa=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}},ur=typeof window=="object"?window:globalThis,Cp=class kp{constructor(e){this.element=e,this.next=kp.Undefined,this.prev=kp.Undefined}};Cp.Undefined=new Cp(void 0);var vn=Cp,yy=class{constructor(){this._first=vn.Undefined,this._last=vn.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===vn.Undefined}clear(){let e=this._first;for(;e!==vn.Undefined;){let n=e.next;e.prev=vn.Undefined,e.next=vn.Undefined,e=n}this._first=vn.Undefined,this._last=vn.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,n){let i=new vn(e);if(this._first===vn.Undefined)this._first=i,this._last=i;else if(n){let a=this._last;this._last=i,i.prev=a,a.next=i}else{let a=this._first;this._first=i,i.next=a,a.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==vn.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==vn.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==vn.Undefined&&e.next!==vn.Undefined){let n=e.prev;n.next=e.next,e.next.prev=n}else e.prev===vn.Undefined&&e.next===vn.Undefined?(this._first=vn.Undefined,this._last=vn.Undefined):e.next===vn.Undefined?(this._last=this._last.prev,this._last.next=vn.Undefined):e.prev===vn.Undefined&&(this._first=this._first.next,this._first.prev=vn.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==vn.Undefined;)yield e.element,e=e.next}},FE=globalThis.performance&&typeof globalThis.performance.now=="function",HE=class CS{static create(e){return new CS(e)}constructor(e){this._now=FE&&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}},hi;(t=>{t.None=()=>Mt.None;function e(T,I){return _(T,()=>{},0,void 0,!0,void 0,I)}t.defer=e;function n(T){return(I,$=null,j)=>{let M=!1,L;return L=T(R=>{if(!M)return L?L.dispose():M=!0,I.call($,R)},null,j),M&&L.dispose(),L}}t.once=n;function i(T,I,$){return f((j,M=null,L)=>T(R=>j.call(M,I(R)),null,L),$)}t.map=i;function s(T,I,$){return f((j,M=null,L)=>T(R=>{I(R),j.call(M,R)},null,L),$)}t.forEach=s;function a(T,I,$){return f((j,M=null,L)=>T(R=>I(R)&&j.call(M,R),null,L),$)}t.filter=a;function c(T){return T}t.signal=c;function d(...T){return(I,$=null,j)=>{let M=zE(...T.map(L=>L(R=>I.call($,R))));return g(M,j)}}t.any=d;function h(T,I,$,j){let M=$;return i(T,L=>(M=I(M,L),M),j)}t.reduce=h;function f(T,I){let $,j={onWillAddFirstListener(){$=T(M.fire,M)},onDidRemoveLastListener(){$==null||$.dispose()}},M=new Oe(j);return I==null||I.add(M),M.event}function g(T,I){return I instanceof Array?I.push(T):I&&I.add(T),T}function _(T,I,$=100,j=!1,M=!1,L,R){let E,z,D,q=0,ce,ge={leakWarningThreshold:L,onWillAddFirstListener(){E=T(we=>{q++,z=I(z,we),j&&!D&&(se.fire(z),z=void 0),ce=()=>{let _e=z;z=void 0,D=void 0,(!j||q>1)&&se.fire(_e),q=0},typeof $=="number"?(clearTimeout(D),D=setTimeout(ce,$)):D===void 0&&(D=0,queueMicrotask(ce))})},onWillRemoveListener(){M&&q>0&&(ce==null||ce())},onDidRemoveLastListener(){ce=void 0,E.dispose()}},se=new Oe(ge);return R==null||R.add(se),se.event}t.debounce=_;function y(T,I=0,$){return t.debounce(T,(j,M)=>j?(j.push(M),j):[M],I,void 0,!0,void 0,$)}t.accumulate=y;function w(T,I=(j,M)=>j===M,$){let j=!0,M;return a(T,L=>{let R=j||!I(L,M);return j=!1,M=L,R},$)}t.latch=w;function S(T,I,$){return[t.filter(T,I,$),t.filter(T,j=>!I(j),$)]}t.split=S;function A(T,I=!1,$=[],j){let M=$.slice(),L=T(z=>{M?M.push(z):E.fire(z)});j&&j.add(L);let R=()=>{M==null||M.forEach(z=>E.fire(z)),M=null},E=new Oe({onWillAddFirstListener(){L||(L=T(z=>E.fire(z)),j&&j.add(L))},onDidAddFirstListener(){M&&(I?setTimeout(R):R())},onDidRemoveLastListener(){L&&L.dispose(),L=null}});return j&&j.add(E),E.event}t.buffer=A;function C(T,I){return($,j,M)=>{let L=I(new k);return T(function(R){let E=L.evaluate(R);E!==N&&$.call(j,E)},void 0,M)}}t.chain=C;let N=Symbol("HaltChainable");class k{constructor(){this.steps=[]}map(I){return this.steps.push(I),this}forEach(I){return this.steps.push($=>(I($),$)),this}filter(I){return this.steps.push($=>I($)?$:N),this}reduce(I,$){let j=$;return this.steps.push(M=>(j=I(j,M),j)),this}latch(I=($,j)=>$===j){let $=!0,j;return this.steps.push(M=>{let L=$||!I(M,j);return $=!1,j=M,L?M:N}),this}evaluate(I){for(let $ of this.steps)if(I=$(I),I===N)break;return I}}function O(T,I,$=j=>j){let j=(...E)=>R.fire($(...E)),M=()=>T.on(I,j),L=()=>T.removeListener(I,j),R=new Oe({onWillAddFirstListener:M,onDidRemoveLastListener:L});return R.event}t.fromNodeEventEmitter=O;function P(T,I,$=j=>j){let j=(...E)=>R.fire($(...E)),M=()=>T.addEventListener(I,j),L=()=>T.removeEventListener(I,j),R=new Oe({onWillAddFirstListener:M,onDidRemoveLastListener:L});return R.event}t.fromDOMEventEmitter=P;function H(T){return new Promise(I=>n(T)(I))}t.toPromise=H;function W(T){let I=new Oe;return T.then($=>{I.fire($)},()=>{I.fire(void 0)}).finally(()=>{I.dispose()}),I.event}t.fromPromise=W;function U(T,I){return T($=>I.fire($))}t.forward=U;function G(T,I,$){return I($),T(j=>I(j))}t.runAndSubscribe=G;class X{constructor(I,$){this._observable=I,this._counter=0,this._hasChanged=!1;let j={onWillAddFirstListener:()=>{I.addObserver(this)},onDidRemoveLastListener:()=>{I.removeObserver(this)}};this.emitter=new Oe(j),$&&$.add(this.emitter)}beginUpdate(I){this._counter++}handlePossibleChange(I){}handleChange(I,$){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 Q(T,I){return new X(T,I).emitter.event}t.fromObservable=Q;function V(T){return(I,$,j)=>{let M=0,L=!1,R={beginUpdate(){M++},endUpdate(){M--,M===0&&(T.reportChanges(),L&&(L=!1,I.call($)))},handlePossibleChange(){},handleChange(){L=!0}};T.addObserver(R),T.reportChanges();let E={dispose(){T.removeObserver(R)}};return j instanceof Yr?j.add(E):Array.isArray(j)&&j.push(E),E}}t.fromObservableLight=V})(hi||(hi={}));var Ep=class Np{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${Np._idPool++}`,Np.all.add(this)}start(e){this._stopWatch=new HE,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}}};Ep.all=new Set,Ep._idPool=0;var UE=Ep,WE=-1,kS=class ES{constructor(e,n,i=(ES._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=n,this.name=i,this._warnCountdown=0}dispose(){var e;(e=this._stacks)==null||e.clear()}check(e,n){let i=this.threshold;if(i<=0||n<i)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[a,c]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${c}):`;console.warn(d),console.warn(a);let h=new VE(d,a);this._errorHandler(h)}return()=>{let a=this._stacks.get(e.value)||0;this._stacks.set(e.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,n=0;for(let[i,s]of this._stacks)(!e||n<s)&&(e=[i,s],n=s);return e}};kS._idPool=1;var qE=kS,KE=class NS{constructor(e){this.value=e}static create(){let e=new Error;return new NS(e.stack??"")}print(){console.warn(this.value.split(`
|
|
58
|
-
`).slice(2).join(`
|
|
59
|
-
`))}},VE=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},YE=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},GE=0,sf=class{constructor(e){this.value=e,this.id=GE++}},XE=2,QE,Oe=class{constructor(t){var e,n,i,s;this._size=0,this._options=t,this._leakageMon=(e=this._options)!=null&&e.leakWarningThreshold?new qE((t==null?void 0:t.onListenerError)??Lu,((n=this._options)==null?void 0:n.leakWarningThreshold)??WE):void 0,this._perfMon=(i=this._options)!=null&&i._profName?new UE(this._options._profName):void 0,this._deliveryQueue=(s=this._options)==null?void 0:s.deliveryQueue}dispose(){var t,e,n,i;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),(i=this._leakageMon)==null||i.dispose())}get event(){return this._event??(this._event=(t,e,n)=>{var c,d,h,f,g;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 y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],w=new YE(`${_}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((c=this._options)==null?void 0:c.onListenerError)||Lu)(w),Mt.None}if(this._disposed)return Mt.None;e&&(t=t.bind(e));let i=new sf(t),s;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=KE.create(),s=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof sf?(this._deliveryQueue??(this._deliveryQueue=new JE),this._listeners=[this._listeners,i]):this._listeners.push(i):((h=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||h.call(d,this),this._listeners=i,(g=(f=this._options)==null?void 0:f.onDidAddFirstListener)==null||g.call(f,this)),this._size++;let a=dn(()=>{s==null||s(),this._removeListener(i)});return n instanceof Yr?n.add(a):Array.isArray(n)&&n.push(a),a}),this._event}_removeListener(t){var s,a,c,d;if((a=(s=this._options)==null?void 0:s.onWillRemoveListener)==null||a.call(s,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(d=(c=this._options)==null?void 0:c.onDidRemoveLastListener)==null||d.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 i=this._deliveryQueue.current===this;if(this._size*XE<=e.length){let h=0;for(let f=0;f<e.length;f++)e[f]?e[h++]=e[f]:i&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=h}}_deliver(t,e){var i;if(!t)return;let n=((i=this._options)==null?void 0:i.onListenerError)||Lu;if(!n){t.value(e);return}try{t.value(e)}catch(s){n(s)}}_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,i,s;if((e=this._deliveryQueue)!=null&&e.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(i=this._perfMon)==null||i.start(this._size),this._listeners)if(this._listeners instanceof sf)this._deliver(this._listeners,t);else{let a=this._deliveryQueue;a.enqueue(this,t,this._listeners.length),this._deliverQueue(a)}(s=this._perfMon)==null||s.stop()}hasListeners(){return this._size>0}},JE=class{constructor(){this.i=-1,this.end=0}enqueue(e,n,i){this.i=0,this.end=i,this.current=e,this.value=n}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Lp=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Oe,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Oe,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 i=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(i,e),this._onDidChangeZoomLevel.fire(i)}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 i=this.getWindowId(n);this.mapWindowIdToFullScreen.set(i,e),this._onDidChangeFullscreen.fire(i)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Lp.INSTANCE=new Lp;var Wm=Lp;function ZE(t,e,n){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",n)}Wm.INSTANCE.onDidChangeZoomLevel;function e5(t){return Wm.INSTANCE.getZoomFactor(t)}Wm.INSTANCE.onDidChangeFullscreen;var Ma=typeof navigator=="object"?navigator.userAgent:"",Rp=Ma.indexOf("Firefox")>=0,t5=Ma.indexOf("AppleWebKit")>=0,qm=Ma.indexOf("Chrome")>=0,n5=!qm&&Ma.indexOf("Safari")>=0;Ma.indexOf("Electron/")>=0;Ma.indexOf("Android")>=0;var rf=!1;if(typeof ur.matchMedia=="function"){let t=ur.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=ur.matchMedia("(display-mode: fullscreen)");rf=t.matches,ZE(ur,t,({matches:n})=>{rf&&e.matches||(rf=n)})}var ga="en",Ap=!1,Mp=!1,Ru=!1,LS=!1,cu,Au=ga,wy=ga,i5,xs,Co=globalThis,ui,j0;typeof Co.vscode<"u"&&typeof Co.vscode.process<"u"?ui=Co.vscode.process:typeof process<"u"&&typeof((j0=process==null?void 0:process.versions)==null?void 0:j0.node)=="string"&&(ui=process);var T0,s5=typeof((T0=ui==null?void 0:ui.versions)==null?void 0:T0.electron)=="string",r5=s5&&(ui==null?void 0:ui.type)==="renderer",P0;if(typeof ui=="object"){Ap=ui.platform==="win32",Mp=ui.platform==="darwin",Ru=ui.platform==="linux",Ru&&ui.env.SNAP&&ui.env.SNAP_REVISION,ui.env.CI||ui.env.BUILD_ARTIFACTSTAGINGDIRECTORY,cu=ga,Au=ga;let t=ui.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);cu=e.userLocale,wy=e.osLocale,Au=e.resolvedLanguage||ga,i5=(P0=e.languagePack)==null?void 0:P0.translationsConfigFile}catch{}LS=!0}else typeof navigator=="object"&&!r5?(xs=navigator.userAgent,Ap=xs.indexOf("Windows")>=0,Mp=xs.indexOf("Macintosh")>=0,(xs.indexOf("Macintosh")>=0||xs.indexOf("iPad")>=0||xs.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ru=xs.indexOf("Linux")>=0,(xs==null?void 0:xs.indexOf("Mobi"))>=0,Au=globalThis._VSCODE_NLS_LANGUAGE||ga,cu=navigator.language.toLowerCase(),wy=cu):console.error("Unable to resolve platform.");var RS=Ap,Hs=Mp,o5=Ru,by=LS,Ws=xs,Pr=Au,a5;(t=>{function e(){return Pr}t.value=e;function n(){return Pr.length===2?Pr==="en":Pr.length>=3?Pr[0]==="e"&&Pr[1]==="n"&&Pr[2]==="-":!1}t.isDefaultVariant=n;function i(){return Pr==="en"}t.isDefault=i})(a5||(a5={}));var l5=typeof Co.postMessage=="function"&&!Co.importScripts;(()=>{if(l5){let t=[];Co.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let i=0,s=t.length;i<s;i++){let a=t[i];if(a.id===n.data.vscodeScheduleAsyncWork){t.splice(i,1),a.callback();return}}});let e=0;return n=>{let i=++e;t.push({id:i,callback:n}),Co.postMessage({vscodeScheduleAsyncWork:i},"*")}}return t=>setTimeout(t)})();var c5=!!(Ws&&Ws.indexOf("Chrome")>=0);Ws&&Ws.indexOf("Firefox")>=0;!c5&&Ws&&Ws.indexOf("Safari")>=0;Ws&&Ws.indexOf("Edg/")>=0;Ws&&Ws.indexOf("Android")>=0;var aa=typeof navigator=="object"?navigator:{};by||document.queryCommandSupported&&document.queryCommandSupported("copy")||aa&&aa.clipboard&&aa.clipboard.writeText,by||aa&&aa.clipboard&&aa.clipboard.readText;var Km=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}},of=new Km,Sy=new Km,xy=new Km,u5=new Array(230),AS;(t=>{function e(d){return of.keyCodeToStr(d)}t.toString=e;function n(d){return of.strToKeyCode(d)}t.fromString=n;function i(d){return Sy.keyCodeToStr(d)}t.toUserSettingsUS=i;function s(d){return xy.keyCodeToStr(d)}t.toUserSettingsGeneral=s;function a(d){return Sy.strToKeyCode(d)||xy.strToKeyCode(d)}t.fromUserSettings=a;function c(d){if(d>=98&&d<=113)return null;switch(d){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return of.keyCodeToStr(d)}t.toElectronAccelerator=c})(AS||(AS={}));var d5=class MS{constructor(e,n,i,s,a){this.ctrlKey=e,this.shiftKey=n,this.altKey=i,this.metaKey=s,this.keyCode=a}equals(e){return e instanceof MS&&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",i=this.altKey?"1":"0",s=this.metaKey?"1":"0";return`K${e}${n}${i}${s}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new h5([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},h5=class{constructor(t){if(t.length===0)throw BE("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 f5(t){if(t.charCode){let n=String.fromCharCode(t.charCode).toUpperCase();return AS.fromString(n)}let e=t.keyCode;if(e===3)return 7;if(Rp)switch(e){case 59:return 85;case 60:if(o5)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Hs)return 57;break}else if(t5&&(Hs&&e===93||!Hs&&e===92))return 57;return u5[e]||0}var p5=Hs?256:2048,m5=512,g5=1024,v5=Hs?2048:256,Cy=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=f5(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|=p5),this.altKey&&(e|=m5),this.shiftKey&&(e|=g5),this.metaKey&&(e|=v5),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new d5(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},ky=new WeakMap;function _5(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 y5=class{static getSameOriginWindowChain(t){let e=ky.get(t);if(!e){e=[],ky.set(t,e);let n=t,i;do i=_5(n),i?e.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):e.push({window:new WeakRef(n),iframeElement:null}),n=i;while(n)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let n=0,i=0,s=this.getSameOriginWindowChain(t);for(let a of s){let c=a.window.deref();if(n+=(c==null?void 0:c.scrollY)??0,i+=(c==null?void 0:c.scrollX)??0,c===e||!a.iframeElement)break;let d=a.iframeElement.getBoundingClientRect();n+=d.top,i+=d.left}return{top:n,left:i}}},uu=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 i=y5.getPositionOfChildWindowRelativeToAncestorWindow(e,n.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Ey=class{constructor(e,n=0,i=0){var a;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=n;let s=!1;if(qm){let c=navigator.userAgent.match(/Chrome\/(\d+)/);s=(c?parseInt(c[1]):123)<=122}if(e){let c=e,d=e,h=((a=e.view)==null?void 0:a.devicePixelRatio)||1;if(typeof c.wheelDeltaY<"u")s?this.deltaY=c.wheelDeltaY/(120*h):this.deltaY=c.wheelDeltaY/120;else if(typeof d.VERTICAL_AXIS<"u"&&d.axis===d.VERTICAL_AXIS)this.deltaY=-d.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?Rp&&!Hs?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof c.wheelDeltaX<"u")n5&&RS?this.deltaX=-(c.wheelDeltaX/120):s?this.deltaX=c.wheelDeltaX/(120*h):this.deltaX=c.wheelDeltaX/120;else if(typeof d.HORIZONTAL_AXIS<"u"&&d.axis===d.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?Rp&&!Hs?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},jS=Object.freeze(function(t,e){let n=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(n)}}}),w5;(t=>{function e(n){return n===t.None||n===t.Cancelled||n instanceof b5?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:hi.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:jS})})(w5||(w5={}));var b5=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?jS:(this._emitter||(this._emitter=new Oe),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Vm=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 xp("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},n)}setIfNotSet(e,n){if(this._isDisposed)throw new xp("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},n))}},S5=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,i=globalThis){if(this.isDisposed)throw new xp("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},n);this.disposable=dn(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},x5;(t=>{async function e(i){let s,a=await Promise.all(i.map(c=>c.then(d=>d,d=>{s||(s=d)})));if(typeof s<"u")throw s;return a}t.settled=e;function n(i){return new Promise(async(s,a)=>{try{await i(s,a)}catch(c){a(c)}})}t.withAsyncBody=n})(x5||(x5={}));var Ny=class cs{static fromArray(e){return new cs(n=>{n.emitMany(e)})}static fromPromise(e){return new cs(async n=>{n.emitMany(await e)})}static fromPromises(e){return new cs(async n=>{await Promise.all(e.map(async i=>n.emitOne(await i)))})}static merge(e){return new cs(async n=>{await Promise.all(e.map(async i=>{for await(let s of i)n.emitOne(s)}))})}constructor(e,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new Oe,queueMicrotask(async()=>{let i={emitOne:s=>this.emitOne(s),emitMany:s=>this.emitMany(s),reject:s=>this.reject(s)};try{await Promise.resolve(e(i)),this.resolve()}catch(s){this.reject(s)}finally{i.emitOne=void 0,i.emitMany=void 0,i.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 hi.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 cs(async i=>{for await(let s of e)i.emitOne(n(s))})}map(e){return cs.map(this,e)}static filter(e,n){return new cs(async i=>{for await(let s of e)n(s)&&i.emitOne(s)})}filter(e){return cs.filter(this,e)}static coalesce(e){return cs.filter(e,n=>!!n)}coalesce(){return cs.coalesce(this)}static async toPromise(e){let n=[];for await(let i of e)n.push(i);return n}toPromise(){return cs.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())}};Ny.EMPTY=Ny.fromArray([]);var{getWindow:Fs,getWindowId:C5,onDidRegisterWindow:k5}=(function(){let t=new Map,e={window:ur,disposables:new Yr};t.set(ur.vscodeWindowId,e);let n=new Oe,i=new Oe,s=new Oe;function a(c,d){return(typeof c=="number"?t.get(c):void 0)??(d?e:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:i.event,registerWindow(c){if(t.has(c.vscodeWindowId))return Mt.None;let d=new Yr,h={window:c,disposables:d.add(new Yr)};return t.set(c.vscodeWindowId,h),d.add(dn(()=>{t.delete(c.vscodeWindowId),i.fire(c)})),d.add(vt(c,Xn.BEFORE_UNLOAD,()=>{s.fire(c)})),n.fire(h),d},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return t.has(c)},getWindowById:a,getWindow(c){var f;let d=c;if((f=d==null?void 0:d.ownerDocument)!=null&&f.defaultView)return d.ownerDocument.defaultView.window;let h=c;return h!=null&&h.view?h.view.window:ur},getDocument(c){return Fs(c).document}}})(),E5=class{constructor(e,n,i,s){this._node=e,this._type=n,this._handler=i,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 vt(t,e,n,i){return new E5(t,e,n,i)}var Ly=function(t,e,n,i){return vt(t,e,n,i)},Ym,N5=class extends S5{constructor(t){super(),this.defaultTarget=t&&Fs(t)}cancelAndSet(t,e,n){return super.cancelAndSet(t,e,n??this.defaultTarget)}},Ry=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){Lu(e)}}static sort(e,n){return n.priority-e.priority}};(function(){let t=new Map,e=new Map,n=new Map,i=new Map,s=a=>{n.set(a,!1);let c=t.get(a)??[];for(e.set(a,c),t.set(a,[]),i.set(a,!0);c.length>0;)c.sort(Ry.sort),c.shift().execute();i.set(a,!1)};Ym=(a,c,d=0)=>{let h=C5(a),f=new Ry(c,d),g=t.get(h);return g||(g=[],t.set(h,g)),g.push(f),n.get(h)||(n.set(h,!0),a.requestAnimationFrame(()=>s(h))),f}})();function L5(t){let e=t.getBoundingClientRect(),n=Fs(t);return{left:e.left+n.scrollX,top:e.top+n.scrollY,width:e.width,height:e.height}}var Xn={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"},R5=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=Oi(e);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let n=Oi(e);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(e){let n=Oi(e);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(e){let n=Oi(e);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(e){let n=Oi(e);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(e){let n=Oi(e);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(e){let n=Oi(e);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(e){let n=Oi(e);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let n=Oi(e);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let n=Oi(e);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let n=Oi(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=Oi(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=Oi(e);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let n=Oi(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 Oi(t){return typeof t=="number"?`${t}px`:t}function Bl(t){return new R5(t)}var TS=class{constructor(){this._hooks=new Yr,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 i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(n)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,n,i,s,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=a;let c=e;try{e.setPointerCapture(n),this._hooks.add(dn(()=>{try{e.releasePointerCapture(n)}catch{}}))}catch{c=Fs(e)}this._hooks.add(vt(c,Xn.POINTER_MOVE,d=>{if(d.buttons!==i){this.stopMonitoring(!0);return}d.preventDefault(),this._pointerMoveCallback(d)})),this._hooks.add(vt(c,Xn.POINTER_UP,d=>this.stopMonitoring(!0)))}};function A5(t,e,n){let i=null,s=null;if(typeof n.value=="function"?(i="value",s=n.value,s.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(i="get",s=n.get),!s)throw new Error("not supported");let a=`$memoize$${e}`;n[i]=function(...c){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:s.apply(this,c)}),this[a]}}var Ds;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(Ds||(Ds={}));var Al=class _i extends Mt{constructor(){super(),this.dispatched=!1,this.targets=new yy,this.ignoreTargets=new yy,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(hi.runAndSubscribe(k5,({window:e,disposables:n})=>{n.add(vt(e.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),n.add(vt(e.document,"touchend",i=>this.onTouchEnd(e,i))),n.add(vt(e.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:ur,disposables:this._store}))}static addTarget(e){if(!_i.isTouchDevice())return Mt.None;_i.INSTANCE||(_i.INSTANCE=new _i);let n=_i.INSTANCE.targets.push(e);return dn(n)}static ignoreTarget(e){if(!_i.isTouchDevice())return Mt.None;_i.INSTANCE||(_i.INSTANCE=new _i);let n=_i.INSTANCE.ignoreTargets.push(e);return dn(n)}static isTouchDevice(){return"ontouchstart"in ur||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 i=0,s=e.targetTouches.length;i<s;i++){let a=e.targetTouches.item(i);this.activeTouches[a.identifier]={id:a.identifier,initialTarget:a.target,initialTimeStamp:n,initialPageX:a.pageX,initialPageY:a.pageY,rollingTimestamps:[n],rollingPageX:[a.pageX],rollingPageY:[a.pageY]};let c=this.newGestureEvent(Ds.Start,a.target);c.pageX=a.pageX,c.pageY=a.pageY,this.dispatchEvent(c)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,n){let i=Date.now(),s=Object.keys(this.activeTouches).length;for(let a=0,c=n.changedTouches.length;a<c;a++){let d=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("move of an UNKNOWN touch",d);continue}let h=this.activeTouches[d.identifier],f=Date.now()-h.initialTimeStamp;if(f<_i.HOLD_DELAY&&Math.abs(h.initialPageX-Vi(h.rollingPageX))<30&&Math.abs(h.initialPageY-Vi(h.rollingPageY))<30){let g=this.newGestureEvent(Ds.Tap,h.initialTarget);g.pageX=Vi(h.rollingPageX),g.pageY=Vi(h.rollingPageY),this.dispatchEvent(g)}else if(f>=_i.HOLD_DELAY&&Math.abs(h.initialPageX-Vi(h.rollingPageX))<30&&Math.abs(h.initialPageY-Vi(h.rollingPageY))<30){let g=this.newGestureEvent(Ds.Contextmenu,h.initialTarget);g.pageX=Vi(h.rollingPageX),g.pageY=Vi(h.rollingPageY),this.dispatchEvent(g)}else if(s===1){let g=Vi(h.rollingPageX),_=Vi(h.rollingPageY),y=Vi(h.rollingTimestamps)-h.rollingTimestamps[0],w=g-h.rollingPageX[0],S=_-h.rollingPageY[0],A=[...this.targets].filter(C=>h.initialTarget instanceof Node&&C.contains(h.initialTarget));this.inertia(e,A,i,Math.abs(w)/y,w>0?1:-1,g,Math.abs(S)/y,S>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(Ds.End,h.initialTarget)),delete this.activeTouches[d.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,n){let i=document.createEvent("CustomEvent");return i.initEvent(e,!1,!0),i.initialTarget=n,i.tapCount=0,i}dispatchEvent(e){if(e.type===Ds.Tap){let n=new Date().getTime(),i=0;n-this._lastSetTapCountTime>_i.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=n,e.tapCount=i}else(e.type===Ds.Change||e.type===Ds.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(e.initialTarget))return;let n=[];for(let i of this.targets)if(i.contains(e.initialTarget)){let s=0,a=e.initialTarget;for(;a&&a!==i;)s++,a=a.parentElement;n.push([s,i])}n.sort((i,s)=>i[0]-s[0]);for(let[i,s]of n)s.dispatchEvent(e),this.dispatched=!0}}inertia(e,n,i,s,a,c,d,h,f){this.handle=Ym(e,()=>{let g=Date.now(),_=g-i,y=0,w=0,S=!0;s+=_i.SCROLL_FRICTION*_,d+=_i.SCROLL_FRICTION*_,s>0&&(S=!1,y=a*s*_),d>0&&(S=!1,w=h*d*_);let A=this.newGestureEvent(Ds.Change);A.translationX=y,A.translationY=w,n.forEach(C=>C.dispatchEvent(A)),S||this.inertia(e,n,g,s,a,c+y,d,h,f+w)})}onTouchMove(e){let n=Date.now();for(let i=0,s=e.changedTouches.length;i<s;i++){let a=e.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("end of an UNKNOWN touch",a);continue}let c=this.activeTouches[a.identifier],d=this.newGestureEvent(Ds.Change,c.initialTarget);d.translationX=a.pageX-Vi(c.rollingPageX),d.translationY=a.pageY-Vi(c.rollingPageY),d.pageX=a.pageX,d.pageY=a.pageY,this.dispatchEvent(d),c.rollingPageX.length>3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(a.pageX),c.rollingPageY.push(a.pageY),c.rollingTimestamps.push(n)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};Al.SCROLL_FRICTION=-.005,Al.HOLD_DELAY=700,Al.CLEAR_TAP_COUNT_TIME=400,Cn([A5],Al,"isTouchDevice",1);var M5=Al,Gm=class extends Mt{onclick(e,n){this._register(vt(e,Xn.CLICK,i=>n(new uu(Fs(e),i))))}onmousedown(e,n){this._register(vt(e,Xn.MOUSE_DOWN,i=>n(new uu(Fs(e),i))))}onmouseover(e,n){this._register(vt(e,Xn.MOUSE_OVER,i=>n(new uu(Fs(e),i))))}onmouseleave(e,n){this._register(vt(e,Xn.MOUSE_LEAVE,i=>n(new uu(Fs(e),i))))}onkeydown(e,n){this._register(vt(e,Xn.KEY_DOWN,i=>n(new Cy(i))))}onkeyup(e,n){this._register(vt(e,Xn.KEY_UP,i=>n(new Cy(i))))}oninput(e,n){this._register(vt(e,Xn.INPUT,n))}onblur(e,n){this._register(vt(e,Xn.BLUR,n))}onfocus(e,n){this._register(vt(e,Xn.FOCUS,n))}onchange(e,n){this._register(vt(e,Xn.CHANGE,n))}ignoreGesture(e){return M5.ignoreTarget(e)}},Ay=11,j5=class extends Gm{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=Ay+"px",this.domNode.style.height=Ay+"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 TS),this._register(Ly(this.bgDomNode,Xn.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(Ly(this.domNode,Xn.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new N5),this._pointerdownScheduleRepeatTimer=this._register(new Vm)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Fs(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()}},T5=class jp{constructor(e,n,i,s,a,c,d){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,i=i|0,s=s|0,a=a|0,c=c|0,d=d|0),this.rawScrollLeft=s,this.rawScrollTop=d,n<0&&(n=0),s+n>i&&(s=i-n),s<0&&(s=0),a<0&&(a=0),d+a>c&&(d=c-a),d<0&&(d=0),this.width=n,this.scrollWidth=i,this.scrollLeft=s,this.height=a,this.scrollHeight=c,this.scrollTop=d}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 jp(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 jp(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 i=this.width!==e.width,s=this.scrollWidth!==e.scrollWidth,a=this.scrollLeft!==e.scrollLeft,c=this.height!==e.height,d=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:i,scrollWidthChanged:s,scrollLeftChanged:a,heightChanged:c,scrollHeightChanged:d,scrollTopChanged:h}}},P5=class extends Mt{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Oe),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new T5(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 i;let n=this._state.withScrollDimensions(t,e);this._setState(n,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.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 i;e?i=new jy(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let n=this._state.withScrollPosition(t);this._smoothScrolling=jy.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)))}},My=class{constructor(e,n,i){this.scrollLeft=e,this.scrollTop=n,this.isDone=i}};function af(t,e){let n=e-t;return function(i){return t+n*B5(i)}}function I5(t,e,n){return function(i){return i<n?t(i/n):e((i-n)/(1-n))}}var jy=class Tp{constructor(e,n,i,s){this.from=e,this.to=n,this.duration=s,this.startTime=i,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,i){if(Math.abs(e-n)>2.5*i){let s,a;return e<n?(s=e+.75*i,a=n-.75*i):(s=e-.75*i,a=n+.75*i),I5(af(e,s),af(a,n),.33)}return af(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 i=this.scrollLeft(n),s=this.scrollTop(n);return new My(i,s,!1)}return new My(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,n,i){return Tp.start(e,n,i)}static start(e,n,i){i=i+10;let s=Date.now()-10;return new Tp(e,n,s,i)}};function D5(t){return Math.pow(t,3)}function B5(t){return 1-D5(1-t)}var O5=class extends Mt{constructor(e,n,i){super(),this._visibility=e,this._visibleClassName=n,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Vm)}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":"")))}},$5=140,PS=class extends Gm{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 O5(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new TS),this._shouldRender=!0,this.domNode=Bl(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(vt(this.domNode.domNode,Xn.POINTER_DOWN,n=>this._domNodePointerDown(n)))}_createArrow(e){let n=this._register(new j5(e));this.domNode.domNode.appendChild(n.bgDomNode),this.domNode.domNode.appendChild(n.domNode)}_createSlider(e,n,i,s){this.slider=Bl(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(n),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(vt(this.slider.domNode,Xn.POINTER_DOWN,a=>{a.button===0&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.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,i=n+this._scrollbarState.getSliderPosition(),s=n+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);i<=a&&a<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let n,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")n=e.offsetX,i=e.offsetY;else{let a=L5(this.domNode.domNode);n=e.pageX-a.left,i=e.pageY-a.top}let s=this._pointerDownRelativePosition(n,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let n=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,a=>{let c=this._sliderOrthogonalPointerPosition(a),d=Math.abs(c-i);if(RS&&d>$5){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let h=this._sliderPointerPosition(a)-n;this._setDesiredScrollPositionNow(s.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()}},IS=class Pp{constructor(e,n,i,s,a,c){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(e),this._visibleSize=s,this._scrollSize=a,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Pp(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,i,s,a){let c=Math.max(0,i-e),d=Math.max(0,c-2*n),h=s>0&&s>i;if(!h)return{computedAvailableSize:Math.round(c),computedIsNeeded:h,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let f=Math.round(Math.max(20,Math.floor(i*d/s))),g=(d-f)/(s-i),_=a*g;return{computedAvailableSize:Math.round(c),computedIsNeeded:h,computedSliderSize:Math.round(f),computedSliderRatio:g,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let e=Pp._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,i=this._scrollPosition;return n<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+e;return Math.round(n/this._computedSliderRatio)}},z5=class extends PS{constructor(e,n,i){let s=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:n.lazyRender,host:i,scrollbarState:new IS(n.horizontalHasArrows?n.arrowSize:0,n.horizontal===2?0:n.horizontalScrollbarSize,n.vertical===2?0:n.verticalScrollbarSize,s.width,s.scrollWidth,a.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}},F5=class extends PS{constructor(t,e,n){let i=t.getScrollDimensions(),s=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:n,scrollbarState:new IS(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,i.height,i.scrollHeight,s.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}},H5=500,Ty=50,U5=class{constructor(e,n,i){this.timestamp=e,this.deltaX=n,this.deltaY=i,this.score=0}},Ip=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,i=1,s=this._rear;do{let a=s===this._front?e:Math.pow(2,-i);if(e-=a,n+=this._memory[s].score*a,s===this._front)break;s=(this._capacity+s-1)%this._capacity,i++}while(!0);return n<=.5}acceptStandardWheelEvent(e){if(qm){let n=Fs(e.browserEvent),i=e5(n);this.accept(Date.now(),e.deltaX*i,e.deltaY*i)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,n,i){let s=null,a=new U5(e,n,i);this._front===-1&&this._rear===-1?(this._memory[0]=a,this._front=0,this._rear=0):(s=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=a),a.score=this._computeScore(a,s)}_computeScore(e,n){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(i+=.25),n){let s=Math.abs(e.deltaX),a=Math.abs(e.deltaY),c=Math.abs(n.deltaX),d=Math.abs(n.deltaY),h=Math.max(Math.min(s,c),1),f=Math.max(Math.min(a,d),1),g=Math.max(s,c),_=Math.max(a,d);g%h===0&&_%f===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Ip.INSTANCE=new Ip;var W5=Ip,q5=class extends Gm{constructor(t,e,n){super(),this._onScroll=this._register(new Oe),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Oe),this.onWillScroll=this._onWillScroll.event,this._options=V5(e),this._scrollable=n,this._register(this._scrollable.onScroll(s=>{this._onWillScroll.fire(s),this._onDidScroll(s),this._onScroll.fire(s)}));let i={onMouseWheel:s=>this._onMouseWheel(s),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new F5(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new z5(this._scrollable,this._options,i)),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=Bl(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Bl(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Bl(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,s=>this._onMouseOver(s)),this.onmouseleave(this._listenOnDomNode,s=>this._onMouseLeave(s)),this._hideTimeout=this._register(new Vm),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Lo(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,Hs&&(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 Ey(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=Lo(this._mouseWheelToDispose),t)){let e=n=>{this._onMouseWheel(new Ey(n))};this._mouseWheelToDispose.push(vt(this._listenOnDomNode,Xn.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){var s;if((s=t.browserEvent)!=null&&s.defaultPrevented)return;let e=W5.INSTANCE;e.acceptStandardWheelEvent(t);let n=!1;if(t.deltaY||t.deltaX){let a=t.deltaY*this._options.mouseWheelScrollSensitivity,c=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+a===0?c=a=0:Math.abs(a)>=Math.abs(c)?c=0:a=0),this._options.flipAxes&&([a,c]=[c,a]);let d=!Hs&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!c&&(c=a,a=0),t.browserEvent&&t.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,a=a*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),f={};if(a){let g=Ty*a,_=h.scrollTop-(g<0?Math.floor(g):Math.ceil(g));this._verticalScrollbar.writeScrollPosition(f,_)}if(c){let g=Ty*c,_=h.scrollLeft-(g<0?Math.floor(g):Math.ceil(g));this._horizontalScrollbar.writeScrollPosition(f,_)}f=this._scrollable.validateScrollPosition(f),(h.scrollLeft!==f.scrollLeft||h.scrollTop!==f.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(f):this._scrollable.setScrollPositionNow(f),n=!0)}let i=n;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(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,i=n?" left":"",s=e?" top":"",a=n||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${s}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${s}${i}`)}}_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(),H5)}},K5=class extends q5{constructor(e,n,i){super(e,n,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function V5(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,Hs&&(e.className+=" mac"),e}var Dp=class extends Mt{constructor(e,n,i,s,a,c,d,h){super(),this._bufferService=i,this._optionsService=d,this._renderService=h,this._onRequestScrollLines=this._register(new Oe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let f=this._register(new P5({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:g=>Ym(s.window,g)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{f.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new K5(n,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},f)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(g=>{this._scrollableElement.updateOptions({handleMouseWheel:!(g&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(hi.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(dn(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),n.appendChild(this._styleElement),this._register(dn(()=>this._styleElement.remove())),this._register(hi.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(g=>this._handleScroll(g)))}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),i=n-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=n,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};Dp=Cn([Ke(2,Ei),Ke(3,mr),Ke(4,mS),Ke(5,Aa),Ke(6,Ni),Ke(7,gr)],Dp);var Bp=class extends Mt{constructor(e,n,i,s,a){super(),this._screenElement=e,this._bufferService=n,this._coreBrowserService=i,this._decorationService=s,this._renderService=a,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(dn(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let n=this._coreBrowserService.mainDocument.createElement("div");n.classList.add("xterm-decoration"),n.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.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 i=e.options.x??0;return i&&i>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 i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${n*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,n=e.element){if(!n)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?n.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":n.style.left=i?`${i*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()}};Bp=Cn([Ke(1,Ei),Ke(2,mr),Ke(3,tc),Ke(4,gr)],Bp);var Y5=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,i){return n>=e.startBufferLine-this._linePadding[i||"full"]&&n<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,n){e.startBufferLine=Math.min(e.startBufferLine,n),e.endBufferLine=Math.max(e.endBufferLine,n)}},js={full:0,left:0,center:0,right:0},Ir={full:0,left:0,center:0,right:0},hl={full:0,left:0,center:0,right:0},Fu=class extends Mt{constructor(e,n,i,s,a,c,d,h){var g;super(),this._viewportElement=e,this._screenElement=n,this._bufferService=i,this._decorationService=s,this._renderService=a,this._optionsService=c,this._themeService=d,this._coreBrowserService=h,this._colorZoneStore=new Y5,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(),(g=this._viewportElement.parentElement)==null||g.insertBefore(this._canvas,this._viewportElement),this._register(dn(()=>{var _;return(_=this._canvas)==null?void 0:_.remove()}));let f=this._canvas.getContext("2d");if(f)this._ctx=f;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),n=Math.ceil((this._canvas.width-1)/3);Ir.full=this._canvas.width,Ir.left=e,Ir.center=n,Ir.right=e,this._refreshDrawHeightConstants(),hl.full=1,hl.left=1,hl.center=1+Ir.left,hl.right=1+Ir.left+Ir.center}_refreshDrawHeightConstants(){js.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);js.left=n,js.center=n,js.right=n}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*js.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*js.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*js.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*js.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)-js[e.position||"full"]/2),Ir[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+js[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}))}};Fu=Cn([Ke(2,Ei),Ke(3,tc),Ke(4,gr),Ke(5,Ni),Ke(6,Aa),Ke(7,mr)],Fu);var Ne;(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=""))(Ne||(Ne={}));var Mu;(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=""))(Mu||(Mu={}));var DS;(t=>t.ST=`${Ne.ESC}\\`)(DS||(DS={}));var Op=class{constructor(e,n,i,s,a,c){this._textarea=e,this._compositionView=n,this._bufferService=i,this._optionsService=s,this._coreService=a,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 i;n.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(n.start,this._compositionPosition.start):i=this._textarea.value.substring(n.start),i.length>0&&this._coreService.triggerDataEvent(i,!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,i=n.replace(e,"");this._dataAlreadySent=i,n.length>e.length?this._coreService.triggerDataEvent(i,!0):n.length<e.length?this._coreService.triggerDataEvent(`${Ne.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),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,a=n*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=a+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"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=a+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Op=Cn([Ke(2,Ei),Ke(3,Ni),Ke(4,Mo),Ke(5,gr)],Op);var Qn=0,Jn=0,Zn=0,Sn=0,Py={css:"#00000000",rgba:0},In;(t=>{function e(s,a,c,d){return d!==void 0?`#${po(s)}${po(a)}${po(c)}${po(d)}`:`#${po(s)}${po(a)}${po(c)}`}t.toCss=e;function n(s,a,c,d=255){return(s<<24|a<<16|c<<8|d)>>>0}t.toRgba=n;function i(s,a,c,d){return{css:t.toCss(s,a,c,d),rgba:t.toRgba(s,a,c,d)}}t.toColor=i})(In||(In={}));var an;(t=>{function e(h,f){if(Sn=(f.rgba&255)/255,Sn===1)return{css:f.css,rgba:f.rgba};let g=f.rgba>>24&255,_=f.rgba>>16&255,y=f.rgba>>8&255,w=h.rgba>>24&255,S=h.rgba>>16&255,A=h.rgba>>8&255;Qn=w+Math.round((g-w)*Sn),Jn=S+Math.round((_-S)*Sn),Zn=A+Math.round((y-A)*Sn);let C=In.toCss(Qn,Jn,Zn),N=In.toRgba(Qn,Jn,Zn);return{css:C,rgba:N}}t.blend=e;function n(h){return(h.rgba&255)===255}t.isOpaque=n;function i(h,f,g){let _=ju.ensureContrastRatio(h.rgba,f.rgba,g);if(_)return In.toColor(_>>24&255,_>>16&255,_>>8&255)}t.ensureContrastRatio=i;function s(h){let f=(h.rgba|255)>>>0;return[Qn,Jn,Zn]=ju.toChannels(f),{css:In.toCss(Qn,Jn,Zn),rgba:f}}t.opaque=s;function a(h,f){return Sn=Math.round(f*255),[Qn,Jn,Zn]=ju.toChannels(h.rgba),{css:In.toCss(Qn,Jn,Zn,Sn),rgba:In.toRgba(Qn,Jn,Zn,Sn)}}t.opacity=a;function c(h,f){return Sn=h.rgba&255,a(h,Sn*f/255)}t.multiplyOpacity=c;function d(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}t.toColorRGB=d})(an||(an={}));var _n;(t=>{let e,n;try{let s=document.createElement("canvas");s.width=1,s.height=1;let a=s.getContext("2d",{willReadFrequently:!0});a&&(e=a,e.globalCompositeOperation="copy",n=e.createLinearGradient(0,0,1,1))}catch{}function i(s){if(s.match(/#[\da-f]{3,8}/i))switch(s.length){case 4:return Qn=parseInt(s.slice(1,2).repeat(2),16),Jn=parseInt(s.slice(2,3).repeat(2),16),Zn=parseInt(s.slice(3,4).repeat(2),16),In.toColor(Qn,Jn,Zn);case 5:return Qn=parseInt(s.slice(1,2).repeat(2),16),Jn=parseInt(s.slice(2,3).repeat(2),16),Zn=parseInt(s.slice(3,4).repeat(2),16),Sn=parseInt(s.slice(4,5).repeat(2),16),In.toColor(Qn,Jn,Zn,Sn);case 7:return{css:s,rgba:(parseInt(s.slice(1),16)<<8|255)>>>0};case 9:return{css:s,rgba:parseInt(s.slice(1),16)>>>0}}let a=s.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(a)return Qn=parseInt(a[1]),Jn=parseInt(a[2]),Zn=parseInt(a[3]),Sn=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),In.toColor(Qn,Jn,Zn,Sn);if(!e||!n)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=n,e.fillStyle=s,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[Qn,Jn,Zn,Sn]=e.getImageData(0,0,1,1).data,Sn!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:In.toRgba(Qn,Jn,Zn,Sn),css:s}}t.toColor=i})(_n||(_n={}));var xi;(t=>{function e(i){return n(i>>16&255,i>>8&255,i&255)}t.relativeLuminance=e;function n(i,s,a){let c=i/255,d=s/255,h=a/255,f=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),_=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return f*.2126+g*.7152+_*.0722}t.relativeLuminance2=n})(xi||(xi={}));var ju;(t=>{function e(c,d){if(Sn=(d&255)/255,Sn===1)return d;let h=d>>24&255,f=d>>16&255,g=d>>8&255,_=c>>24&255,y=c>>16&255,w=c>>8&255;return Qn=_+Math.round((h-_)*Sn),Jn=y+Math.round((f-y)*Sn),Zn=w+Math.round((g-w)*Sn),In.toRgba(Qn,Jn,Zn)}t.blend=e;function n(c,d,h){let f=xi.relativeLuminance(c>>8),g=xi.relativeLuminance(d>>8);if(ir(f,g)<h){if(g<f){let w=i(c,d,h),S=ir(f,xi.relativeLuminance(w>>8));if(S<h){let A=s(c,d,h),C=ir(f,xi.relativeLuminance(A>>8));return S>C?w:A}return w}let _=s(c,d,h),y=ir(f,xi.relativeLuminance(_>>8));if(y<h){let w=i(c,d,h),S=ir(f,xi.relativeLuminance(w>>8));return y>S?_:w}return _}}t.ensureContrastRatio=n;function i(c,d,h){let f=c>>24&255,g=c>>16&255,_=c>>8&255,y=d>>24&255,w=d>>16&255,S=d>>8&255,A=ir(xi.relativeLuminance2(y,w,S),xi.relativeLuminance2(f,g,_));for(;A<h&&(y>0||w>0||S>0);)y-=Math.max(0,Math.ceil(y*.1)),w-=Math.max(0,Math.ceil(w*.1)),S-=Math.max(0,Math.ceil(S*.1)),A=ir(xi.relativeLuminance2(y,w,S),xi.relativeLuminance2(f,g,_));return(y<<24|w<<16|S<<8|255)>>>0}t.reduceLuminance=i;function s(c,d,h){let f=c>>24&255,g=c>>16&255,_=c>>8&255,y=d>>24&255,w=d>>16&255,S=d>>8&255,A=ir(xi.relativeLuminance2(y,w,S),xi.relativeLuminance2(f,g,_));for(;A<h&&(y<255||w<255||S<255);)y=Math.min(255,y+Math.ceil((255-y)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),A=ir(xi.relativeLuminance2(y,w,S),xi.relativeLuminance2(f,g,_));return(y<<24|w<<16|S<<8|255)>>>0}t.increaseLuminance=s;function a(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}t.toChannels=a})(ju||(ju={}));function po(t){let e=t.toString(16);return e.length<2?"0"+e:e}function ir(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var G5=class extends ec{constructor(e,n,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=n,this._width=i}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()]}},Hu=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ps}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=[],i=e.translateToString(!0),s=0,a=0,c=0,d=e.getFg(0),h=e.getBg(0);for(let f=0;f<e.getTrimmedLength();f++)if(e.loadCell(f,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==d||this._workCell.bg!==h){if(f-s>1){let g=this._getJoinedRanges(i,c,a,e,s);for(let _=0;_<g.length;_++)n.push(g[_])}s=f,c=a,d=this._workCell.fg,h=this._workCell.bg}a+=this._workCell.getChars().length||qr.length}if(this._bufferService.cols-s>1){let f=this._getJoinedRanges(i,c,a,e,s);for(let g=0;g<f.length;g++)n.push(f[g])}return n}_getJoinedRanges(t,e,n,i,s){let a=t.substring(e,n),c=[];try{c=this._characterJoiners[0].handler(a)}catch(d){console.error(d)}for(let d=1;d<this._characterJoiners.length;d++)try{let h=this._characterJoiners[d].handler(a);for(let f=0;f<h.length;f++)Hu._mergeRanges(c,h[f])}catch(h){console.error(h)}return this._stringRangesToCellRanges(c,i,s),c}_stringRangesToCellRanges(t,e,n){let i=0,s=!1,a=0,c=t[i];if(c){for(let d=n;d<this._bufferService.cols;d++){let h=e.getWidth(d),f=e.getString(d).length||qr.length;if(h!==0){if(!s&&c[0]<=a&&(c[0]=d,s=!0),c[1]<=a){if(c[1]=d,c=t[++i],!c)break;c[0]<=a?(c[0]=d,s=!0):s=!1}a+=f}}c&&(c[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let n=!1;for(let i=0;i<t.length;i++){let s=t[i];if(n){if(e[1]<=s[0])return t[i-1][1]=e[1],t;if(e[1]<=s[1])return t[i-1][1]=Math.max(e[1],s[1]),t.splice(i,1),t;t.splice(i,1),i--}else{if(e[1]<=s[0])return t.splice(i,0,e),t;if(e[1]<=s[1])return s[0]=Math.min(e[0],s[0]),t;e[0]<s[1]&&(s[0]=Math.min(e[0],s[0]),n=!0);continue}}return n?t[t.length-1][1]=e[1]:t.push(e),t}};Hu=Cn([Ke(0,Ei)],Hu);function X5(t){return 57508<=t&&t<=57558}function Q5(t){return 9472<=t&&t<=9631}function J5(t){return X5(t)||Q5(t)}function Z5(){return{css:{canvas:du(),cell:du()},device:{canvas:du(),cell:du(),char:{width:0,height:0,left:0,top:0}}}}function du(){return{width:0,height:0}}var $p=class{constructor(e,n,i,s,a,c,d){this._document=e,this._characterJoinerService=n,this._optionsService=i,this._coreBrowserService=s,this._coreService=a,this._decorationService=c,this._themeService=d,this._workCell=new ps,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,n,i){this._selectionStart=e,this._selectionEnd=n,this._columnSelectMode=i}createRow(e,n,i,s,a,c,d,h,f,g,_){let y=[],w=this._characterJoinerService.getJoinedCharacters(n),S=this._themeService.colors,A=e.getNoBgTrimmedLength();i&&A<c+1&&(A=c+1);let C,N=0,k="",O=0,P=0,H=0,W=0,U=!1,G=0,X=!1,Q=0,V=0,T=[],I=g!==-1&&_!==-1;for(let $=0;$<A;$++){e.loadCell($,this._workCell);let j=this._workCell.getWidth();if(j===0)continue;let M=!1,L=$>=V,R=$,E=this._workCell;if(w.length>0&&$===w[0][0]&&L){let xe=w.shift(),Ye=this._isCellInSelection(xe[0],n);for(O=xe[0]+1;O<xe[1];O++)L&&(L=Ye===this._isCellInSelection(O,n));L&&(L=!i||c<xe[0]||c>=xe[1]),L?(M=!0,E=new G5(this._workCell,e.translateToString(!0,xe[0],xe[1]),xe[1]-xe[0]),R=xe[1]-1,j=E.getWidth()):V=xe[1]}let z=this._isCellInSelection($,n),D=i&&$===c,q=I&&$>=g&&$<=_,ce=!1;this._decorationService.forEachDecorationAtCell($,n,void 0,xe=>{ce=!0});let ge=E.getChars()||qr;if(ge===" "&&(E.isUnderline()||E.isOverline())&&(ge=" "),Q=j*h-f.get(ge,E.isBold(),E.isItalic()),!C)C=this._document.createElement("span");else if(N&&(z&&X||!z&&!X&&E.bg===P)&&(z&&X&&S.selectionForeground||E.fg===H)&&E.extended.ext===W&&q===U&&Q===G&&!D&&!M&&!ce&&L){E.isInvisible()?k+=qr:k+=ge,N++;continue}else N&&(C.textContent=k),C=this._document.createElement("span"),N=0,k="";if(P=E.bg,H=E.fg,W=E.extended.ext,U=q,G=Q,X=z,M&&c>=$&&c<=R&&(c=$),!this._coreService.isCursorHidden&&D&&this._coreService.isCursorInitialized){if(T.push("xterm-cursor"),this._coreBrowserService.isFocused)d&&T.push("xterm-cursor-blink"),T.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":T.push("xterm-cursor-outline");break;case"block":T.push("xterm-cursor-block");break;case"bar":T.push("xterm-cursor-bar");break;case"underline":T.push("xterm-cursor-underline");break}}if(E.isBold()&&T.push("xterm-bold"),E.isItalic()&&T.push("xterm-italic"),E.isDim()&&T.push("xterm-dim"),E.isInvisible()?k=qr:k=E.getChars()||qr,E.isUnderline()&&(T.push(`xterm-underline-${E.extended.underlineStyle}`),k===" "&&(k=" "),!E.isUnderlineColorDefault()))if(E.isUnderlineColorRGB())C.style.textDecorationColor=`rgb(${ec.toColorRGB(E.getUnderlineColor()).join(",")})`;else{let xe=E.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&E.isBold()&&xe<8&&(xe+=8),C.style.textDecorationColor=S.ansi[xe].css}E.isOverline()&&(T.push("xterm-overline"),k===" "&&(k=" ")),E.isStrikethrough()&&T.push("xterm-strikethrough"),q&&(C.style.textDecoration="underline");let se=E.getFgColor(),we=E.getFgColorMode(),_e=E.getBgColor(),fe=E.getBgColorMode(),ie=!!E.isInverse();if(ie){let xe=se;se=_e,_e=xe;let Ye=we;we=fe,fe=Ye}let de,me,Ee=!1;this._decorationService.forEachDecorationAtCell($,n,void 0,xe=>{xe.options.layer!=="top"&&Ee||(xe.backgroundColorRGB&&(fe=50331648,_e=xe.backgroundColorRGB.rgba>>8&16777215,de=xe.backgroundColorRGB),xe.foregroundColorRGB&&(we=50331648,se=xe.foregroundColorRGB.rgba>>8&16777215,me=xe.foregroundColorRGB),Ee=xe.options.layer==="top")}),!Ee&&z&&(de=this._coreBrowserService.isFocused?S.selectionBackgroundOpaque:S.selectionInactiveBackgroundOpaque,_e=de.rgba>>8&16777215,fe=50331648,Ee=!0,S.selectionForeground&&(we=50331648,se=S.selectionForeground.rgba>>8&16777215,me=S.selectionForeground)),Ee&&T.push("xterm-decoration-top");let Se;switch(fe){case 16777216:case 33554432:Se=S.ansi[_e],T.push(`xterm-bg-${_e}`);break;case 50331648:Se=In.toColor(_e>>16,_e>>8&255,_e&255),this._addStyle(C,`background-color:#${Iy((_e>>>0).toString(16),"0",6)}`);break;case 0:default:ie?(Se=S.foreground,T.push("xterm-bg-257")):Se=S.background}switch(de||E.isDim()&&(de=an.multiplyOpacity(Se,.5)),we){case 16777216:case 33554432:E.isBold()&&se<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(se+=8),this._applyMinimumContrast(C,Se,S.ansi[se],E,de,void 0)||T.push(`xterm-fg-${se}`);break;case 50331648:let xe=In.toColor(se>>16&255,se>>8&255,se&255);this._applyMinimumContrast(C,Se,xe,E,de,me)||this._addStyle(C,`color:#${Iy(se.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(C,Se,S.foreground,E,de,me)||ie&&T.push("xterm-fg-257")}T.length&&(C.className=T.join(" "),T.length=0),!D&&!M&&!ce&&L?N++:C.textContent=k,Q!==this.defaultSpacing&&(C.style.letterSpacing=`${Q}px`),y.push(C),$=R}return C&&N&&(C.textContent=k),y}_applyMinimumContrast(e,n,i,s,a,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||J5(s.getCode()))return!1;let d=this._getContrastCache(s),h;if(!a&&!c&&(h=d.getColor(n.rgba,i.rgba)),h===void 0){let f=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);h=an.ensureContrastRatio(a||n,c||i,f),d.setColor((a||n).rgba,(c||i).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 i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&n>=i[1]&&e<s[0]&&n<=s[1]:e<i[0]&&n>=i[1]&&e>=s[0]&&n<=s[1]:n>i[1]&&n<s[1]||i[1]===s[1]&&n===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&n===s[1]&&e<s[0]||i[1]<s[1]&&n===i[1]&&e>=i[0]}};$p=Cn([Ke(1,_S),Ke(2,Ni),Ke(3,mr),Ke(4,Mo),Ke(5,tc),Ke(6,Aa)],$p);function Iy(t,e,n){for(;t.length<n;)t=e+t;return t}var eN=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 i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.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=[i,s,a,c],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(a),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,i,s){e===this._font&&n===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=n,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,n,i){let s=0;if(!n&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let d=this._measure(e,0);return d>0&&(this._flat[s]=d),d}let a=e;n&&(a+="B"),i&&(a+="I");let c=this._holey.get(a);if(c===void 0){let d=0;n&&(d|=1),i&&(d|=2),c=this._measure(e,d),c>0&&this._holey.set(a,c)}return c}_measure(e,n){let i=this._measureElements[n];return i.textContent=e.repeat(32),i.offsetWidth/32}},tN=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,i,s=!1){if(this.selectionStart=n,this.selectionEnd=i,!n||!i||n[0]===i[0]&&n[1]===i[1]){this.clear();return}let a=e.buffers.active.ydisp,c=n[1]-a,d=i[1]-a,h=Math.max(c,0),f=Math.min(d,e.rows-1);if(h>=e.rows||f<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=c,this.viewportEndRow=d,this.viewportCappedStartRow=h,this.viewportCappedEndRow=f,this.startCol=n[0],this.endCol=i[0]}isCellSelected(e,n,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?n>=this.startCol&&i>=this.viewportCappedStartRow&&n<this.endCol&&i<=this.viewportCappedEndRow:n<this.startCol&&i>=this.viewportCappedStartRow&&n>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&n>=this.startCol&&n<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&n<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&n>=this.startCol):!1}};function nN(){return new tN}var lf="xterm-dom-renderer-owner-",ls="xterm-rows",hu="xterm-fg-",Dy="xterm-bg-",fl="xterm-focus",fu="xterm-selection",iN=1,zp=class extends Mt{constructor(e,n,i,s,a,c,d,h,f,g,_,y,w,S){super(),this._terminal=e,this._document=n,this._element=i,this._screenElement=s,this._viewportElement=a,this._helperContainer=c,this._linkifier2=d,this._charSizeService=f,this._optionsService=g,this._bufferService=_,this._coreService=y,this._coreBrowserService=w,this._themeService=S,this._terminalClass=iN++,this._rowElements=[],this._selectionRenderModel=nN(),this.onRequestRedraw=this._register(new Oe).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(ls),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(fu),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Z5(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(A=>this._injectCss(A))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance($p,document),this._element.classList.add(lf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(A=>this._handleLinkHover(A))),this._register(this._linkifier2.onHideLinkUnderline(A=>this._handleLinkLeave(A))),this._register(dn(()=>{this._element.classList.remove(lf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new eN(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 i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let n=`${this._terminalSelector} .${ls} 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} .${ls} { 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} .${ls} .xterm-dim { color: ${an.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 i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;n+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,n+=`@keyframes ${s} { 50% { box-shadow: none; }}`,n+=`@keyframes ${a} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,n+=`${this._terminalSelector} .${ls}.${fl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${ls}.${fl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${ls}.${fl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${ls} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${ls} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${ls} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${ls} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${ls} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,n+=`${this._terminalSelector} .${fu} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${fu} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${fu} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,d]of e.ansi.entries())n+=`${this._terminalSelector} .${hu}${c} { color: ${d.css}; }${this._terminalSelector} .${hu}${c}.xterm-dim { color: ${an.multiplyOpacity(d,.5).css}; }${this._terminalSelector} .${Dy}${c} { background-color: ${d.css}; }`;n+=`${this._terminalSelector} .${hu}257 { color: ${an.opaque(e.background).css}; }${this._terminalSelector} .${hu}257.xterm-dim { color: ${an.multiplyOpacity(an.opaque(e.background),.5).css}; }${this._terminalSelector} .${Dy}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 i=this._rowElements.length;i<=n;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}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(fl),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(fl),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,n,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,n,i),this.renderRows(0,this._bufferService.rows-1),!e||!n||(this._selectionRenderModel.update(this._terminal,e,n,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,d=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(i){let f=e[0]>n[0];h.appendChild(this._createSelectionElement(c,f?n[0]:e[0],f?e[0]:n[0],d-c+1))}else{let f=s===c?e[0]:0,g=c===a?n[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(c,f,g));let _=d-c-1;if(h.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,_)),c!==d){let y=a===d?n[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(d,0,y))}}this._selectionContainer.appendChild(h)}_createSelectionElement(e,n,i,s=1){let a=this._document.createElement("div"),c=n*this.dimensions.css.cell.width,d=this.dimensions.css.cell.width*(i-n);return c+d>this.dimensions.css.canvas.width&&(d=this.dimensions.css.canvas.width-c),a.style.height=`${s*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${c}px`,a.style.width=`${d}px`,a}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 i=this._bufferService.buffer,s=i.ybase+i.y,a=Math.min(i.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,d=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=e;f<=n;f++){let g=f+i.ydisp,_=this._rowElements[f],y=i.lines.get(g);if(!_||!y)break;_.replaceChildren(...this._rowFactory.createRow(y,g,g===s,d,h,a,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${lf}${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,i,s,a,c){i<0&&(e=0),s<0&&(n=0);let d=this._bufferService.rows-1;i=Math.max(Math.min(i,d),0),s=Math.max(Math.min(s,d),0),a=Math.min(a,this._bufferService.cols);let h=this._bufferService.buffer,f=h.ybase+h.y,g=Math.min(h.x,a-1),_=this._optionsService.rawOptions.cursorBlink,y=this._optionsService.rawOptions.cursorStyle,w=this._optionsService.rawOptions.cursorInactiveStyle;for(let S=i;S<=s;++S){let A=S+h.ydisp,C=this._rowElements[S],N=h.lines.get(A);if(!C||!N)break;C.replaceChildren(...this._rowFactory.createRow(N,A,A===f,y,w,g,_,this.dimensions.css.cell.width,this._widthCache,c?S===i?e:0:-1,c?(S===s?n:a)-1:-1))}}};zp=Cn([Ke(7,Hm),Ke(8,hd),Ke(9,Ni),Ke(10,Ei),Ke(11,Mo),Ke(12,mr),Ke(13,Aa)],zp);var Fp=class extends Mt{constructor(e,n,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Oe),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new rN(this._optionsService))}catch{this._measureStrategy=this._register(new sN(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())}};Fp=Cn([Ke(2,Ni)],Fp);var BS=class extends Mt{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)}},sN=class extends BS{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}},rN=class extends BS{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}},oN=class extends Mt{constructor(e,n,i){super(),this._textarea=e,this._window=n,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new aN(this._window)),this._onDprChange=this._register(new Oe),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Oe),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(hi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(vt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(vt(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}},aN=class extends Mt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Sa),this._onDprChange=this._register(new Oe),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(dn(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=vt(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)}},lN=class extends Mt{constructor(){super(),this.linkProviders=[],this._register(dn(()=>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 Xm(t,e,n){let i=n.getBoundingClientRect(),s=t.getComputedStyle(n),a=parseInt(s.getPropertyValue("padding-left")),c=parseInt(s.getPropertyValue("padding-top"));return[e.clientX-i.left-a,e.clientY-i.top-c]}function cN(t,e,n,i,s,a,c,d,h){if(!a)return;let f=Xm(t,e,n);if(f)return f[0]=Math.ceil((f[0]+(h?c/2:0))/c),f[1]=Math.ceil(f[1]/d),f[0]=Math.min(Math.max(f[0],1),i+(h?1:0)),f[1]=Math.min(Math.max(f[1],1),s),f}var Hp=class{constructor(e,n){this._renderService=e,this._charSizeService=n}getCoords(e,n,i,s,a){return cN(window,e,n,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,n){let i=Xm(window,e,n);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Hp=Cn([Ke(0,gr),Ke(1,hd)],Hp);var uN=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,i){this._rowCount=i,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=[]}},OS={};wE(OS,{getSafariVersion:()=>hN,isChromeOS:()=>HS,isFirefox:()=>$S,isIpad:()=>fN,isIphone:()=>pN,isLegacyEdge:()=>dN,isLinux:()=>Qm,isMac:()=>Uu,isNode:()=>fd,isSafari:()=>zS,isWindows:()=>FS});var fd=typeof process<"u"&&"title"in process,nc=fd?"node":navigator.userAgent,ic=fd?"node":navigator.platform,$S=nc.includes("Firefox"),dN=nc.includes("Edge"),zS=/^((?!chrome|android).)*safari/i.test(nc);function hN(){if(!zS)return 0;let t=nc.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var Uu=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ic),fN=ic==="iPad",pN=ic==="iPhone",FS=["Windows","Win16","Win32","WinCE"].includes(ic),Qm=ic.indexOf("Linux")>=0,HS=/\bCrOS\b/.test(nc),US=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,i=t.timeRemaining(),s=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),s=t.timeRemaining(),n*1.5>s){i-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-e))}ms`),this._start();return}i=s}this.clear()}},mN=class extends US{_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())}}},gN=class extends US{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},Wu=!fd&&"requestIdleCallback"in window?gN:mN,vN=class{constructor(){this._queue=new Wu}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},Up=class extends Mt{constructor(e,n,i,s,a,c,d,h,f){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=a,this._coreBrowserService=h,this._renderer=this._register(new Sa),this._pausedResizeTask=new vN,this._observerDisposable=this._register(new Sa),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 Oe),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Oe),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Oe),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Oe),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new uN((g,_)=>this._renderRows(g,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new _N(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(dn(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(d.onResize(()=>this._fullRefresh())),this._register(d.buffers.onBufferActivate(()=>{var g;return(g=this._renderer.value)==null?void 0:g.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(d.cols,d.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(d.buffer.y,d.buffer.y,!0))),this._register(f.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,n),this._register(this._coreBrowserService.onWindowChange(g=>this._registerIntersectionObserver(g,n)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,n){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(n),this._observerDisposable.value=dn(()=>i.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,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,n);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),n=Math.max(n,s.end)),i||(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 i;return(i=this._renderer.value)==null?void 0:i.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,i){var s;this._selectionState.start=e,this._selectionState.end=n,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,n,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Up=Cn([Ke(2,Ni),Ke(3,hd),Ke(4,Mo),Ke(5,tc),Ke(6,Ei),Ke(7,mr),Ke(8,Aa)],Up);var _N=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 yN(t,e,n,i){let s=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return SN(s,a,t,e,n,i)+pd(a,e,n,i)+xN(s,a,t,e,n,i);let c;if(a===e)return c=s>t?"D":"C",Wl(Math.abs(s-t),Ul(c,i));c=a>e?"D":"C";let d=Math.abs(a-e),h=bN(a>e?t:s,n)+(d-1)*n.cols+1+wN(a>e?s:t);return Wl(h,Ul(c,i))}function wN(t,e){return t-1}function bN(t,e){return e.cols-t}function SN(t,e,n,i,s,a){return pd(e,i,s,a).length===0?"":Wl(qS(t,e,t,e-Ro(e,s),!1,s).length,Ul("D",a))}function pd(t,e,n,i){let s=t-Ro(t,n),a=e-Ro(e,n),c=Math.abs(s-a)-CN(t,e,n);return Wl(c,Ul(WS(t,e),i))}function xN(t,e,n,i,s,a){let c;pd(e,i,s,a).length>0?c=i-Ro(i,s):c=e;let d=i,h=kN(t,e,n,i,s,a);return Wl(qS(t,c,n,d,h==="C",s).length,Ul(h,a))}function CN(t,e,n){var c;let i=0,s=t-Ro(t,n),a=e-Ro(e,n);for(let d=0;d<Math.abs(s-a);d++){let h=WS(t,e)==="A"?-1:1;(c=n.buffer.lines.get(s+h*d))!=null&&c.isWrapped&&i++}return i}function Ro(t,e){let n=0,i=e.buffer.lines.get(t),s=i==null?void 0:i.isWrapped;for(;s&&t>=0&&t<e.rows;)n++,i=e.buffer.lines.get(--t),s=i==null?void 0:i.isWrapped;return n}function kN(t,e,n,i,s,a){let c;return pd(n,i,s,a).length>0?c=i-Ro(i,s):c=e,t<n&&c<=i||t>=n&&c<i?"C":"D"}function WS(t,e){return t>e?"A":"B"}function qS(t,e,n,i,s,a){let c=t,d=e,h="";for(;(c!==n||d!==i)&&d>=0&&d<a.buffer.lines.length;)c+=s?1:-1,s&&c>a.cols-1?(h+=a.buffer.translateBufferLineToString(d,!1,t,c),c=0,t=0,d++):!s&&c<0&&(h+=a.buffer.translateBufferLineToString(d,!1,0,t+1),c=a.cols-1,t=c,d--);return h+a.buffer.translateBufferLineToString(d,!1,t,c)}function Ul(t,e){let n=e?"O":"[";return Ne.ESC+n+t}function Wl(t,e){t=Math.floor(t);let n="";for(let i=0;i<t;i++)n+=e;return n}var EN=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 By(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 cf=50,NN=15,LN=50,RN=500,AN=" ",MN=new RegExp(AN,"g"),Wp=class extends Mt{constructor(e,n,i,s,a,c,d,h,f){super(),this._element=e,this._screenElement=n,this._linkifier=i,this._bufferService=s,this._coreService=a,this._mouseService=c,this._optionsService=d,this._renderService=h,this._coreBrowserService=f,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new ps,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Oe),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Oe),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Oe),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Oe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=g=>this._handleMouseMove(g),this._mouseUpListener=g=>this._handleMouseUp(g),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(g=>this._handleTrim(g)),this._register(this._bufferService.buffers.onBufferActivate(g=>this._handleBufferActivate(g))),this.enable(),this._model=new EN(this._bufferService),this._activeSelectionMode=0,this._register(dn(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(g=>{g.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 i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===n[0])return"";let a=e[0]<n[0]?e[0]:n[0],c=e[0]<n[0]?n[0]:e[0];for(let d=e[1];d<=n[1];d++){let h=i.translateBufferLineToString(d,!0,a,c);s.push(h)}}else{let a=e[1]===n[1]?n[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],a));for(let c=e[1]+1;c<=n[1]-1;c++){let d=i.lines.get(c),h=i.translateBufferLineToString(c,!0);d!=null&&d.isWrapped?s[s.length-1]+=h:s.push(h)}if(e[1]!==n[1]){let c=i.lines.get(n[1]),d=i.translateBufferLineToString(n[1],!0,0,n[0]);c&&c.isWrapped?s[s.length-1]+=d:s.push(d)}}return s.map(a=>a.replace(MN," ")).join(FS?`\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())),Qm&&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),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!n?!1:this._areCoordsInSelection(n,i,s)}isCellInSelection(e,n){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,n],i,s)}_areCoordsInSelection(e,n,i){return e[1]>n[1]&&e[1]<i[1]||n[1]===i[1]&&e[1]===n[1]&&e[0]>=n[0]&&e[0]<i[0]||n[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||n[1]<i[1]&&e[1]===n[1]&&e[0]>=n[0]}_selectWordAtCursor(e,n){var a,c;let i=(c=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:c.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=By(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,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=Xm(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return n>=0&&n<=i?0:(n>i&&(n-=i),n=Math.min(Math.max(n,-cf),cf),n/=cf,n/Math.abs(n)+Math.round(n*(NN-1)))}shouldForceSelection(e){return Uu?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(),LN)}_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&&!(Uu&&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 i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!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<RN&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=yN(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,n=this._model.finalSelectionEnd,i=!!e&&!!n&&(e[0]!==n[0]||e[1]!==n[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,n,i);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,i)}_fireOnSelectionChange(e,n,i){this._oldSelectionStart=e,this._oldSelectionEnd=n,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(n=>this._handleTrim(n))}_convertViewportColToCharacterIndex(e,n){let i=n;for(let s=0;n>=s;s++){let a=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:a>1&&n!==s&&(i+=a-1)}return i}setSelection(e,n,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,n],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,n,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,c=a.lines.get(e[1]);if(!c)return;let d=a.translateBufferLineToString(e[1],!1),h=this._convertViewportColToCharacterIndex(c,e[0]),f=h,g=e[0]-h,_=0,y=0,w=0,S=0;if(d.charAt(h)===" "){for(;h>0&&d.charAt(h-1)===" ";)h--;for(;f<d.length&&d.charAt(f+1)===" ";)f++}else{let N=e[0],k=e[0];c.getWidth(N)===0&&(_++,N--),c.getWidth(k)===2&&(y++,k++);let O=c.getString(k).length;for(O>1&&(S+=O-1,f+=O-1);N>0&&h>0&&!this._isCharWordSeparator(c.loadCell(N-1,this._workCell));){c.loadCell(N-1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,N--):P>1&&(w+=P-1,h-=P-1),h--,N--}for(;k<c.length&&f+1<d.length&&!this._isCharWordSeparator(c.loadCell(k+1,this._workCell));){c.loadCell(k+1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===2?(y++,k++):P>1&&(S+=P-1,f+=P-1),f++,k++}}f++;let A=h+g-_+w,C=Math.min(this._bufferService.cols,f-h+_+y-w-S);if(!(!n&&d.slice(h,f).trim()==="")){if(i&&A===0&&c.getCodePoint(0)!==32){let N=a.lines.get(e[1]-1);if(N&&c.isWrapped&&N.getCodePoint(this._bufferService.cols-1)!==32){let k=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(k){let O=this._bufferService.cols-k.start;A-=O,C+=O}}}if(s&&A+C===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let N=a.lines.get(e[1]+1);if(N!=null&&N.isWrapped&&N.getCodePoint(0)!==32){let k=this._getWordAt([0,e[1]+1],!1,!1,!0);k&&(C+=k.length)}}return{start:A,length:C}}}_selectWordAt(e,n){let i=this._getWordAt(e,n);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let n=this._getWordAt(e,!0);if(n){let i=e[1];for(;n.start<0;)n.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;n.start+n.length>this._bufferService.cols;)n.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?n.start:n.start+n.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let n=this._bufferService.buffer.getWrappedRangeForLine(e),i={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=By(i,this._bufferService.cols)}};Wp=Cn([Ke(3,Ei),Ke(4,Mo),Ke(5,Um),Ke(6,Ni),Ke(7,gr),Ke(8,mr)],Wp);var Oy=class{constructor(){this._data={}}set(e,n,i){this._data[e]||(this._data[e]={}),this._data[e][n]=i}get(e,n){return this._data[e]?this._data[e][n]:void 0}clear(){this._data={}}},$y=class{constructor(){this._color=new Oy,this._css=new Oy}setCss(e,n,i){this._css.set(e,n,i)}getCss(e,n){return this._css.get(e,n)}setColor(e,n,i){this._color.set(e,n,i)}getColor(e,n){return this._color.get(e,n)}clear(){this._color.clear(),this._css.clear()}},Fn=Object.freeze((()=>{let t=[_n.toColor("#2e3436"),_n.toColor("#cc0000"),_n.toColor("#4e9a06"),_n.toColor("#c4a000"),_n.toColor("#3465a4"),_n.toColor("#75507b"),_n.toColor("#06989a"),_n.toColor("#d3d7cf"),_n.toColor("#555753"),_n.toColor("#ef2929"),_n.toColor("#8ae234"),_n.toColor("#fce94f"),_n.toColor("#729fcf"),_n.toColor("#ad7fa8"),_n.toColor("#34e2e2"),_n.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let n=0;n<216;n++){let i=e[n/36%6|0],s=e[n/6%6|0],a=e[n%6];t.push({css:In.toCss(i,s,a),rgba:In.toRgba(i,s,a)})}for(let n=0;n<24;n++){let i=8+n*10;t.push({css:In.toCss(i,i,i),rgba:In.toRgba(i,i,i)})}return t})()),_o=_n.toColor("#ffffff"),Ml=_n.toColor("#000000"),zy=_n.toColor("#ffffff"),Fy=Ml,pl={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},jN=_o,qp=class extends Mt{constructor(e){super(),this._optionsService=e,this._contrastCache=new $y,this._halfContrastCache=new $y,this._onChangeColors=this._register(new Oe),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:_o,background:Ml,cursor:zy,cursorAccent:Fy,selectionForeground:void 0,selectionBackgroundTransparent:pl,selectionBackgroundOpaque:an.blend(Ml,pl),selectionInactiveBackgroundTransparent:pl,selectionInactiveBackgroundOpaque:an.blend(Ml,pl),scrollbarSliderBackground:an.opacity(_o,.2),scrollbarSliderHoverBackground:an.opacity(_o,.4),scrollbarSliderActiveBackground:an.opacity(_o,.5),overviewRulerBorder:_o,ansi:Fn.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=Jt(e.foreground,_o),n.background=Jt(e.background,Ml),n.cursor=an.blend(n.background,Jt(e.cursor,zy)),n.cursorAccent=an.blend(n.background,Jt(e.cursorAccent,Fy)),n.selectionBackgroundTransparent=Jt(e.selectionBackground,pl),n.selectionBackgroundOpaque=an.blend(n.background,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundTransparent=Jt(e.selectionInactiveBackground,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundOpaque=an.blend(n.background,n.selectionInactiveBackgroundTransparent),n.selectionForeground=e.selectionForeground?Jt(e.selectionForeground,Py):void 0,n.selectionForeground===Py&&(n.selectionForeground=void 0),an.isOpaque(n.selectionBackgroundTransparent)&&(n.selectionBackgroundTransparent=an.opacity(n.selectionBackgroundTransparent,.3)),an.isOpaque(n.selectionInactiveBackgroundTransparent)&&(n.selectionInactiveBackgroundTransparent=an.opacity(n.selectionInactiveBackgroundTransparent,.3)),n.scrollbarSliderBackground=Jt(e.scrollbarSliderBackground,an.opacity(n.foreground,.2)),n.scrollbarSliderHoverBackground=Jt(e.scrollbarSliderHoverBackground,an.opacity(n.foreground,.4)),n.scrollbarSliderActiveBackground=Jt(e.scrollbarSliderActiveBackground,an.opacity(n.foreground,.5)),n.overviewRulerBorder=Jt(e.overviewRulerBorder,jN),n.ansi=Fn.slice(),n.ansi[0]=Jt(e.black,Fn[0]),n.ansi[1]=Jt(e.red,Fn[1]),n.ansi[2]=Jt(e.green,Fn[2]),n.ansi[3]=Jt(e.yellow,Fn[3]),n.ansi[4]=Jt(e.blue,Fn[4]),n.ansi[5]=Jt(e.magenta,Fn[5]),n.ansi[6]=Jt(e.cyan,Fn[6]),n.ansi[7]=Jt(e.white,Fn[7]),n.ansi[8]=Jt(e.brightBlack,Fn[8]),n.ansi[9]=Jt(e.brightRed,Fn[9]),n.ansi[10]=Jt(e.brightGreen,Fn[10]),n.ansi[11]=Jt(e.brightYellow,Fn[11]),n.ansi[12]=Jt(e.brightBlue,Fn[12]),n.ansi[13]=Jt(e.brightMagenta,Fn[13]),n.ansi[14]=Jt(e.brightCyan,Fn[14]),n.ansi[15]=Jt(e.brightWhite,Fn[15]),e.extendedAnsi){let i=Math.min(n.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)n.ansi[s+16]=Jt(e.extendedAnsi[s],Fn[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let 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()}}};qp=Cn([Ke(0,Ni)],qp);function Jt(t,e){if(t!==void 0)try{return _n.toColor(t)}catch{}return e}var TN=class{constructor(...e){this._entries=new Map;for(let[n,i]of e)this.set(n,i)}set(e,n){let i=this._entries.get(e);return this._entries.set(e,n),i}forEach(e){for(let[n,i]of this._entries.entries())e(n,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},PN=class{constructor(){this._services=new TN,this._services.set(Hm,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let n=NE(t).sort((a,c)=>a.index-c.index),i=[];for(let a of n){let c=this._services.get(a.id);if(!c)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${a.id._id}.`);i.push(c)}let s=n.length>0?n[0].index:e.length;if(e.length!==s)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${s+1} conflicts with ${e.length} static arguments`);return new t(...e,...i)}},IN={trace:0,debug:1,info:2,warn:3,error:4,off:5},DN="xterm.js: ",Kp=class extends Mt{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=IN[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,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":DN)+n,...i)}trace(e,...n){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,n)}debug(e,...n){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,n)}info(e,...n){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,n)}warn(e,...n){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,n)}error(e,...n){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,n)}};Kp=Cn([Ke(0,Ni)],Kp);var Hy=class extends Mt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Oe),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Oe),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Oe),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 i=0;i<Math.min(e,this.length);i++)n[i]=this._array[this._getCyclicIndex(i)];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,...i){if(n){for(let s=e;s<this._length-n;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+n)];this._length-=n,this.onDeleteEmitter.fire({index:e,amount:n})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,n,i){if(!(n<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let a=n-1;a>=0;a--)this.set(e+a+i,this.get(e+a));let s=e+n+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<n;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},At=3,Tn=Object.freeze(new ec),pu=0,uf=2,jl=class KS{constructor(e,n,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*At);let s=n||ps.fromCharData([0,dS,1,0]);for(let a=0;a<e;++a)this.setCell(a,s);this.length=e}get(e){let n=this._data[e*At+0],i=n&2097151;return[this._data[e*At+1],n&2097152?this._combined[e]:i?Ur(i):"",n>>22,n&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i]}set(e,n){this._data[e*At+1]=n[0],n[1].length>1?(this._combined[e]=n[1],this._data[e*At+0]=e|2097152|n[2]<<22):this._data[e*At+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(e){return this._data[e*At+0]>>22}hasWidth(e){return this._data[e*At+0]&12582912}getFg(e){return this._data[e*At+1]}getBg(e){return this._data[e*At+2]}hasContent(e){return this._data[e*At+0]&4194303}getCodePoint(e){let n=this._data[e*At+0];return n&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n&2097151}isCombined(e){return this._data[e*At+0]&2097152}getString(e){let n=this._data[e*At+0];return n&2097152?this._combined[e]:n&2097151?Ur(n&2097151):""}isProtected(e){return this._data[e*At+2]&536870912}loadCell(e,n){return pu=e*At,n.content=this._data[pu+0],n.fg=this._data[pu+1],n.bg=this._data[pu+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*At+0]=n.content,this._data[e*At+1]=n.fg,this._data[e*At+2]=n.bg}setCellFromCodepoint(e,n,i,s){s.bg&268435456&&(this._extendedAttrs[e]=s.extended),this._data[e*At+0]=n|i<<22,this._data[e*At+1]=s.fg,this._data[e*At+2]=s.bg}addCodepointToCell(e,n,i){let s=this._data[e*At+0];s&2097152?this._combined[e]+=Ur(n):s&2097151?(this._combined[e]=Ur(s&2097151)+Ur(n),s&=-2097152,s|=2097152):s=n|1<<22,i&&(s&=-12582913,s|=i<<22),this._data[e*At+0]=s}insertCells(e,n,i){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),n<this.length-e){let s=new ps;for(let a=this.length-e-n-1;a>=0;--a)this.setCell(e+n+a,this.loadCell(e+a,s));for(let a=0;a<n;++a)this.setCell(e+a,i)}else for(let s=e;s<this.length;++s)this.setCell(s,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(e,n,i){if(e%=this.length,n<this.length-e){let s=new ps;for(let a=0;a<this.length-e-n;++a)this.setCell(e+a,this.loadCell(e+n+a,s));for(let a=this.length-n;a<this.length;++a)this.setCell(a,i)}else for(let s=e;s<this.length;++s)this.setCell(s,i);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,i)}replaceCells(e,n,i,s=!1){if(s){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,i);e<n&&e<this.length;)this.isProtected(e)||this.setCell(e,i),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,i);e<n&&e<this.length;)this.setCell(e++,i)}resize(e,n){if(e===this.length)return this._data.length*4*uf<this._data.buffer.byteLength;let i=e*At;if(e>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let s=new Uint32Array(i);s.set(this._data),this._data=s}for(let s=this.length;s<e;++s)this.setCell(s,n)}else{this._data=this._data.subarray(0,i);let s=Object.keys(this._combined);for(let c=0;c<s.length;c++){let d=parseInt(s[c],10);d>=e&&delete this._combined[d]}let a=Object.keys(this._extendedAttrs);for(let c=0;c<a.length;c++){let d=parseInt(a[c],10);d>=e&&delete this._extendedAttrs[d]}}return this.length=e,i*4*uf<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*uf<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 i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,e);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,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 KS(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*At+0]&4194303)return e+(this._data[e*At+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*At+0]&4194303||this._data[e*At+2]&50331648)return e+(this._data[e*At+0]>>22);return 0}copyCellsFrom(e,n,i,s,a){let c=e._data;if(a)for(let h=s-1;h>=0;h--){for(let f=0;f<At;f++)this._data[(i+h)*At+f]=c[(n+h)*At+f];c[(n+h)*At+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[n+h])}else for(let h=0;h<s;h++){for(let f=0;f<At;f++)this._data[(i+h)*At+f]=c[(n+h)*At+f];c[(n+h)*At+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[n+h])}let d=Object.keys(e._combined);for(let h=0;h<d.length;h++){let f=parseInt(d[h],10);f>=n&&(this._combined[f-n+i]=e._combined[f])}}translateToString(e,n,i,s){n=n??0,i=i??this.length,e&&(i=Math.min(i,this.getTrimmedLength())),s&&(s.length=0);let a="";for(;n<i;){let c=this._data[n*At+0],d=c&2097151,h=c&2097152?this._combined[n]:d?Ur(d):qr;if(a+=h,s)for(let f=0;f<h.length;++f)s.push(n);n+=c>>22||1}return s&&s.push(n),a}};function BN(t,e,n,i,s,a){let c=[];for(let d=0;d<t.length-1;d++){let h=d,f=t.get(++h);if(!f.isWrapped)continue;let g=[t.get(d)];for(;h<t.length&&f.isWrapped;)g.push(f),f=t.get(++h);if(!a&&i>=d&&i<h){d+=g.length-1;continue}let _=0,y=ql(g,_,e),w=1,S=0;for(;w<g.length;){let C=ql(g,w,e),N=C-S,k=n-y,O=Math.min(N,k);g[_].copyCellsFrom(g[w],S,y,O,!1),y+=O,y===n&&(_++,y=0),S+=O,S===C&&(w++,S=0),y===0&&_!==0&&g[_-1].getWidth(n-1)===2&&(g[_].copyCellsFrom(g[_-1],n-1,y++,1,!1),g[_-1].setCell(n-1,s))}g[_].replaceCells(y,n,s);let A=0;for(let C=g.length-1;C>0&&(C>_||g[C].getTrimmedLength()===0);C--)A++;A>0&&(c.push(d+g.length-A),c.push(A)),d+=g.length-1}return c}function ON(t,e){let n=[],i=0,s=e[i],a=0;for(let c=0;c<t.length;c++)if(s===c){let d=e[++i];t.onDeleteEmitter.fire({index:c-a,amount:d}),c+=d-1,a+=d,s=e[++i]}else n.push(c);return{layout:n,countRemoved:a}}function $N(t,e){let n=[];for(let i=0;i<e.length;i++)n.push(t.get(e[i]));for(let i=0;i<n.length;i++)t.set(i,n[i]);t.length=e.length}function zN(t,e,n){let i=[],s=t.map((h,f)=>ql(t,f,e)).reduce((h,f)=>h+f),a=0,c=0,d=0;for(;d<s;){if(s-d<n){i.push(s-d);break}a+=n;let h=ql(t,c,e);a>h&&(a-=h,c++);let f=t[c].getWidth(a-1)===2;f&&a--;let g=f?n-1:n;i.push(g),d+=g}return i}function ql(t,e,n){if(e===t.length-1)return t[e].getTrimmedLength();let i=!t[e].hasContent(n-1)&&t[e].getWidth(n-1)===1,s=t[e+1].getWidth(0)===2;return i&&s?n-1:n}var VS=class YS{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=YS._nextId++,this._onDispose=this.register(new Oe),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Lo(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};VS._nextId=1;var FN=VS,Un={},yo=Un.B;Un[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Un.A={"#":"£"};Un.B=void 0;Un[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Un.C=Un[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Un.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Un.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Un.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Un.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Un.E=Un[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Un.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Un.H=Un[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Un["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Uy=4294967295,Wy=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=Tn.clone(),this.savedCharset=yo,this.markers=[],this._nullCell=ps.fromCharData([0,dS,1,0]),this._whitespaceCell=ps.fromCharData([0,qr,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Wu,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Hy(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 zu),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 zu),this._whitespaceCell}getBlankLine(t,e){return new jl(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>Uy?Uy:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=Tn);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 Hy(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let n=this.getNullCell(Tn),i=0,s=this._getCorrectBufferLength(e);if(s>this.lines.maxLength&&(this.lines.maxLength=s),this.lines.length>0){if(this._cols<t)for(let c=0;c<this.lines.length;c++)i+=+this.lines.get(c).resize(t,n);let a=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 jl(t,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new jl(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(s<this.lines.maxLength){let c=this.lines.length-s;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=s}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),a&&(this.y+=a),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 a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(t,n);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),i>.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,i=BN(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Tn),n);if(i.length>0){let s=ON(this.lines,i);$N(this.lines,s.layout),this._reflowLargerAdjustViewport(t,e,s.countRemoved)}}_reflowLargerAdjustViewport(t,e,n){let i=this.getNullCell(Tn),s=n;for(;s-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new jl(t,i))):(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,i=this.getNullCell(Tn),s=[],a=0;for(let c=this.lines.length-1;c>=0;c--){let d=this.lines.get(c);if(!d||!d.isWrapped&&d.getTrimmedLength()<=t)continue;let h=[d];for(;d.isWrapped&&c>0;)d=this.lines.get(--c),h.unshift(d);if(!n){let O=this.ybase+this.y;if(O>=c&&O<c+h.length)continue}let f=h[h.length-1].getTrimmedLength(),g=zN(h,this._cols,t),_=g.length-h.length,y;this.ybase===0&&this.y!==this.lines.length-1?y=Math.max(0,this.y-this.lines.maxLength+_):y=Math.max(0,this.lines.length-this.lines.maxLength+_);let w=[];for(let O=0;O<_;O++){let P=this.getBlankLine(Tn,!0);w.push(P)}w.length>0&&(s.push({start:c+h.length+a,newLines:w}),a+=w.length),h.push(...w);let S=g.length-1,A=g[S];A===0&&(S--,A=g[S]);let C=h.length-_-1,N=f;for(;C>=0;){let O=Math.min(N,A);if(h[S]===void 0)break;if(h[S].copyCellsFrom(h[C],N-O,A-O,O,!0),A-=O,A===0&&(S--,A=g[S]),N-=O,N===0){C--;let P=Math.max(C,0);N=ql(h,P,this._cols)}}for(let O=0;O<h.length;O++)g[O]<t&&h[O].setCell(g[O],i);let k=_-y;for(;k-- >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+a)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+_,this.ybase+e-1)}if(s.length>0){let c=[],d=[];for(let A=0;A<this.lines.length;A++)d.push(this.lines.get(A));let h=this.lines.length,f=h-1,g=0,_=s[g];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let y=0;for(let A=Math.min(this.lines.maxLength-1,h+a-1);A>=0;A--)if(_&&_.start>f+y){for(let C=_.newLines.length-1;C>=0;C--)this.lines.set(A--,_.newLines[C]);A++,c.push({index:f+1,amount:_.newLines.length}),y+=_.newLines.length,_=s[++g]}else this.lines.set(A,d[f--]);let w=0;for(let A=c.length-1;A>=0;A--)c[A].index+=w,this.lines.onInsertEmitter.fire(c[A]),w+=c[A].amount;let S=Math.max(0,h+a-this.lines.maxLength);S>0&&this.lines.onTrimEmitter.fire(S)}}translateBufferLineToString(t,e,n=0,i){let s=this.lines.get(t);return s?s.translateToString(e,n,i):""}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 FN(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)}},HN=class extends Mt{constructor(e,n){super(),this._optionsService=e,this._bufferService=n,this._onBufferActivate=this._register(new Oe),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 Wy(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Wy(!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)}},GS=2,XS=1,Vp=class extends Mt{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new Oe),this.onResize=this._onResize.event,this._onScroll=this._register(new Oe),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,GS),this.rows=Math.max(t.rawOptions.rows||0,XS),this.buffers=this._register(new HN(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,i=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:n,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let n=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==t.fg||i.getBg(0)!==t.bg)&&(i=n.getBlankLine(t,e),this._cachedBlankLine=i),i.isWrapped=e;let s=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let c=n.lines.isFull;a===n.lines.length-1?c?n.lines.recycle().copyFrom(i):n.lines.push(i.clone()):n.lines.splice(a+1,0,i.clone()),c?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let c=a-s+1;n.lines.shiftElements(s+1,c-1,-1),n.lines.set(a,i.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 i=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+t,n.ybase),0),i!==n.ydisp&&(e||this._onScroll.fire(n.ydisp))}};Vp=Cn([Ke(0,Ni)],Vp);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:Uu,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},UN=["normal","bold","100","200","300","400","500","600","700","800","900"],WN=class extends Mt{constructor(e){super(),this._onOptionChange=this._register(new Oe),this.onOptionChange=this._onOptionChange.event;let n={...la};for(let i in e)if(i in n)try{let s=e[i];n[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=n,this.options={...n},this._setupOptions(),this._register(dn(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,n){return this.onOptionChange(i=>{i===e&&n(this.rawOptions[e])})}onMultipleOptionChange(e,n){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&n()})}_setupOptions(){let e=i=>{if(!(i in la))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},n=(i,s)=>{if(!(i in la))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:n.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,n){switch(e){case"cursorStyle":if(n||(n=la[e]),!qN(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=UN.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 qN(t){return t==="block"||t==="underline"||t==="bar"}function Tl(t,e=5){if(typeof t!="object")return t;let n=Array.isArray(t)?[]:{};for(let i in t)n[i]=e<=1?t[i]:t[i]&&Tl(t[i],e-1);return n}var qy=Object.freeze({insertMode:!1}),Ky=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Yp=class extends Mt{constructor(e,n,i){super(),this._bufferService=e,this._logService=n,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Oe),this.onData=this._onData.event,this._onUserInput=this._register(new Oe),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Oe),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Oe),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Tl(qy),this.decPrivateModes=Tl(Ky)}reset(){this.modes=Tl(qy),this.decPrivateModes=Tl(Ky)}triggerDataEvent(e,n=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;n&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),n&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(n=>n.charCodeAt(0))),this._onBinary.fire(e))}};Yp=Cn([Ke(0,Ei),Ke(1,gS),Ke(2,Ni)],Yp);var Vy={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 df(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 hf=String.fromCharCode,Yy={DEFAULT:t=>{let e=[df(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${hf(e[0])}${hf(e[1])}${hf(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${df(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${df(t,!0)};${t.x};${t.y}${e}`}},Gp=class extends Mt{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 Oe),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(Vy))this.addProtocol(i,Vy[i]);for(let i of Object.keys(Yy))this.addEncoding(i,Yy[i]);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 i=e/n,s=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(s/=i+0,Math.abs(t.deltaY)<50&&(s*=.3),this._wheelPartialScroll+=s,s=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(s*=this._bufferService.rows),s}_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)}};Gp=Cn([Ke(0,Ei),Ke(1,Mo),Ke(2,Ni)],Gp);var ff=[[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]],KN=[[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]],Hn;function VN(t,e){let n=0,i=e.length-1,s;if(t<e[0][0]||t>e[i][1])return!1;for(;i>=n;)if(s=n+i>>1,t>e[s][1])n=s+1;else if(t<e[s][0])i=s-1;else return!0;return!1}var YN=class{constructor(){if(this.version="6",!Hn){Hn=new Uint8Array(65536),Hn.fill(1),Hn[0]=0,Hn.fill(0,1,32),Hn.fill(0,127,160),Hn.fill(2,4352,4448),Hn[9001]=2,Hn[9002]=2,Hn.fill(2,11904,42192),Hn[12351]=1,Hn.fill(2,44032,55204),Hn.fill(2,63744,64256),Hn.fill(2,65040,65050),Hn.fill(2,65072,65136),Hn.fill(2,65280,65377),Hn.fill(2,65504,65511);for(let e=0;e<ff.length;++e)Hn.fill(0,ff[e][0],ff[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Hn[e]:VN(e,KN)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,n){let i=this.wcwidth(e),s=i===0&&n!==0;if(s){let a=bo.extractWidth(n);a===0?s=!1:a>i&&(i=a)}return bo.createPropertyValue(0,i,s)}},bo=class Tu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Oe,this.onChange=this._onChange.event;let e=new YN;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,i=!1){return(e&16777215)<<3|(n&3)<<1|(i?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,i=0,s=e.length;for(let a=0;a<s;++a){let c=e.charCodeAt(a);if(55296<=c&&c<=56319){if(++a>=s)return n+this.wcwidth(c);let f=e.charCodeAt(a);56320<=f&&f<=57343?c=(c-55296)*1024+f-56320+65536:n+=this.wcwidth(f)}let d=this.charProperties(c,i),h=Tu.extractWidth(d);Tu.extractShouldJoin(d)&&(h-=Tu.extractWidth(i)),n+=h,i=d}return n}charProperties(e,n){return this._activeProvider.charProperties(e,n)}},GN=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 Gy(t){var i;let e=(i=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1))==null?void 0:i.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 ml=2147483647,XN=256,QS=class Xp{constructor(e=32,n=32){if(this.maxLength=e,this.maxSubParamsLength=n,n>XN)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 Xp;if(!e.length)return n;for(let i=Array.isArray(e[0])?1:0;i<e.length;++i){let s=e[i];if(Array.isArray(s))for(let a=0;a<s.length;++a)n.addSubParam(s[a]);else n.addParam(s)}return n}clone(){let e=new Xp(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 i=this._subParamsIdx[n]>>8,s=this._subParamsIdx[n]&255;s-i>0&&e.push(Array.prototype.slice.call(this._subParams,i,s))}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>ml?ml: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>ml?ml: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,i=this._subParamsIdx[e]&255;return i-n>0?this._subParams.subarray(n,i):null}getSubParamsAll(){let e={};for(let n=0;n<this.length;++n){let i=this._subParamsIdx[n]>>8,s=this._subParamsIdx[n]&255;s-i>0&&(e[n]=this._subParams.slice(i,s))}return e}addDigit(e){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,s=i[n-1];i[n-1]=~s?Math.min(s*10+e,ml):e}},gl=[],QN=class{constructor(){this._state=0,this._active=gl,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 i=this._handlers[e];return i.push(n),{dispose:()=>{let s=i.indexOf(n);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=gl}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=gl,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||gl,!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,i){if(!this._active.length)this._handlerFb(this._id,"PUT",dd(e,n,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,n,i)}start(){this.reset(),this._state=1}put(e,n,i){if(this._state!==3){if(this._state===1)for(;n<i;){let s=e[n++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-n>0&&this._put(e,n,i)}}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 i=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=n,a=this._stack.fallThrough,this._stack.paused=!1),!a&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=gl,this._id=-1,this._state=0}}},Yi=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,n,i){this._hitLimit||(this._data+=dd(e,n,i),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(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,n}},vl=[],JN=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 i=this._handlers[e];return i.push(n),{dispose:()=>{let s=i.indexOf(n);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=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 i=this._active.length-1;i>=0;i--)this._active[i].hook(n)}put(e,n,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",dd(e,n,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,n,i)}unhook(e,n=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=n,a=this._stack.fallThrough,this._stack.paused=!1),!a&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=vl,this._ident=0}},Pl=new QS;Pl.addParam(0);var Xy=class{constructor(t){this._handler=t,this._data="",this._params=Pl,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():Pl,this._data="",this._hitLimit=!1}put(t,e,n){this._hitLimit||(this._data+=dd(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=Pl,this._data="",this._hitLimit=!1,n));return this._params=Pl,this._data="",this._hitLimit=!1,e}},ZN=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,n){this.table.fill(e<<4|n)}add(e,n,i,s){this.table[n<<8|e]=i<<4|s}addMany(e,n,i,s){for(let a=0;a<e.length;a++)this.table[n<<8|e[a]]=i<<4|s}},hs=160,eL=(function(){let t=new ZN(4095),e=Array.apply(null,Array(256)).map((d,h)=>h),n=(d,h)=>e.slice(d,h),i=n(32,127),s=n(0,24);s.push(25),s.push.apply(s,n(28,32));let a=n(0,14),c;t.setDefault(1,0),t.addMany(i,0,2,0);for(c in a)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(s,0,3,0),t.addMany(s,1,3,1),t.add(127,1,0,1),t.addMany(s,8,0,8),t.addMany(s,3,3,3),t.add(127,3,0,3),t.addMany(s,4,3,4),t.add(127,4,0,4),t.addMany(s,6,3,6),t.addMany(s,5,3,5),t.add(127,5,0,5),t.addMany(s,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(i,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(i,7,0,7),t.addMany(s,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(s,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(s,11,0,11),t.addMany(n(32,128),11,0,11),t.addMany(n(28,32),11,0,11),t.addMany(s,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(s,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(s,13,13,13),t.addMany(i,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(hs,0,2,0),t.add(hs,8,5,8),t.add(hs,6,0,6),t.add(hs,11,0,11),t.add(hs,13,13,13),t})(),tL=class extends Mt{constructor(e=eL){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 QS,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(n,i,s)=>{},this._executeHandlerFb=n=>{},this._csiHandlerFb=(n,i)=>{},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(dn(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new QN),this._dcsParser=this._register(new JN),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,n=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>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 a=0;a<e.intermediates.length;++a){let c=e.intermediates.charCodeAt(a);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=c}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(n[0]>s||s>n[1])throw new Error(`final must be in range ${n[0]} .. ${n[1]}`);return i<<=8,i|=s,i}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 i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(n),{dispose:()=>{let a=s.indexOf(n);a!==-1&&s.splice(a,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 i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(n),{dispose:()=>{let a=s.indexOf(n);a!==-1&&s.splice(a,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,i,s,a){this._parseStack.state=e,this._parseStack.handlers=n,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=a}parse(e,n,i){let s=0,a=0,c=0,d;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let h=this._parseStack.handlers,f=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&f>-1){for(;f>=0&&(d=h[f](this._params),d!==!0);f--)if(d instanceof Promise)return this._parseStack.handlerPos=f,d}this._parseStack.handlers=[];break;case 4:if(i===!1&&f>-1){for(;f>=0&&(d=h[f](),d!==!0);f--)if(d instanceof Promise)return this._parseStack.handlerPos=f,d}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],d=this._dcsParser.unhook(s!==24&&s!==26,i),d)return d;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],d=this._oscParser.end(s!==24&&s!==26,i),d)return d;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let h=c;h<n;++h){switch(s=e[h],a=this._transitions.table[this.currentState<<8|(s<160?s:hs)],a>>4){case 2:for(let w=h+1;;++w){if(w>=n||(s=e[w])<32||s>126&&s<hs){this._printHandler(e,h,w),h=w-1;break}if(++w>=n||(s=e[w])<32||s>126&&s<hs){this._printHandler(e,h,w),h=w-1;break}if(++w>=n||(s=e[w])<32||s>126&&s<hs){this._printHandler(e,h,w),h=w-1;break}if(++w>=n||(s=e[w])<32||s>126&&s<hs){this._printHandler(e,h,w),h=w-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:h,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let f=this._csiHandlers[this._collect<<8|s],g=f?f.length-1:-1;for(;g>=0&&(d=f[g](this._params),d!==!0);g--)if(d instanceof Promise)return this._preserveStack(3,f,g,a,h),d;g<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++h<n&&(s=e[h])>47&&s<60);h--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let _=this._escHandlers[this._collect<<8|s],y=_?_.length-1:-1;for(;y>=0&&(d=_[y](),d!==!0);y--)if(d instanceof Promise)return this._preserveStack(4,_,y,a,h),d;y<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let w=h+1;;++w)if(w>=n||(s=e[w])===24||s===26||s===27||s>127&&s<hs){this._dcsParser.put(e,h,w),h=w-1;break}break;case 14:if(d=this._dcsParser.unhook(s!==24&&s!==26),d)return this._preserveStack(6,[],0,a,h),d;s===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let w=h+1;;w++)if(w>=n||(s=e[w])<32||s>127&&s<hs){this._oscParser.put(e,h,w),h=w-1;break}break;case 6:if(d=this._oscParser.end(s!==24&&s!==26),d)return this._preserveStack(5,[],0,a,h),d;s===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=a&15}}},nL=/^([\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})$/,iL=/^[\da-f]+$/;function Qy(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let n=nL.exec(e);if(n){let i=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/i*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/i*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/i*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),iL.exec(e)&&[3,6,9,12].includes(e.length))){let n=e.length/3,i=[0,0,0];for(let s=0;s<3;++s){let a=parseInt(e.slice(n*s,n*s+n),16);i[s]=n===1?a<<4:n===2?a:n===3?a>>4:a>>8}return i}}function pf(t,e){let n=t.toString(16),i=n.length<2?"0"+n:n;switch(e){case 4:return n[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function sL(t,e=16){let[n,i,s]=t;return`rgb:${pf(n,e)}/${pf(i,e)}/${pf(s,e)}`}var rL={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Dr=131072,Jy=10;function Zy(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 ew=5e3,tw=0,oL=class extends Mt{constructor(t,e,n,i,s,a,c,d,h=new tL){super(),this._bufferService=t,this._charsetService=e,this._coreService=n,this._logService=i,this._optionsService=s,this._oscLinkService=a,this._coreMouseService=c,this._unicodeService=d,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new kE,this._utf8Decoder=new EE,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Tn.clone(),this._eraseAttrDataInternal=Tn.clone(),this._onRequestBell=this._register(new Oe),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Oe),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Oe),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Oe),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Oe),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Oe),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Oe),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Oe),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Oe),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Oe),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Oe),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Oe),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Oe),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 Qp(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,g)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:g.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,g,_)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:g,data:_})}),this._parser.setDcsHandlerFallback((f,g,_)=>{g==="HOOK"&&(_=_.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:g,payload:_})}),this._parser.setPrintHandler((f,g,_)=>this.print(f,g,_)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(Ne.BEL,()=>this.bell()),this._parser.setExecuteHandler(Ne.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Ne.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Ne.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Ne.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Ne.BS,()=>this.backspace()),this._parser.setExecuteHandler(Ne.HT,()=>this.tab()),this._parser.setExecuteHandler(Ne.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Ne.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Mu.IND,()=>this.index()),this._parser.setExecuteHandler(Mu.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Mu.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Yi(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new Yi(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new Yi(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new Yi(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new Yi(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new Yi(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new Yi(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new Yi(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new Yi(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new Yi(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new Yi(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new Yi(f=>this.restoreCursorColor(f))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let f in Un)this._parser.registerEscHandler({intermediates:"(",final:f},()=>this.selectCharset("("+f)),this._parser.registerEscHandler({intermediates:")",final:f},()=>this.selectCharset(")"+f)),this._parser.registerEscHandler({intermediates:"*",final:f},()=>this.selectCharset("*"+f)),this._parser.registerEscHandler({intermediates:"+",final:f},()=>this.selectCharset("+"+f)),this._parser.registerEscHandler({intermediates:"-",final:f},()=>this.selectCharset("-"+f)),this._parser.registerEscHandler({intermediates:".",final:f},()=>this.selectCharset("."+f)),this._parser.registerEscHandler({intermediates:"/",final:f},()=>this.selectCharset("/"+f));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(f=>(this._logService.error("Parsing error: ",f),f)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Xy((f,g)=>this.requestStatusString(f,g)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,n,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=n,this._parseStack.position=i}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),ew))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${ew} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let n,i=this._activeBuffer.x,s=this._activeBuffer.y,a=0,c=this._parseStack.paused;if(c){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(n),n;i=this._parseStack.cursorStartX,s=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>Dr&&(a=this._parseStack.position+Dr)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,f=>String.fromCharCode(f)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(f=>f.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<Dr&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Dr))),c||this._dirtyRowTracker.clearRange(),t.length>Dr)for(let f=a;f<t.length;f+=Dr){let g=f+Dr<t.length?f+Dr:t.length,_=typeof t=="string"?this._stringDecoder.decode(t.substring(f,g),this._parseBuffer):this._utf8Decoder.decode(t.subarray(f,g),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,_))return this._preserveStack(i,s,_,f),this._logSlowResolvingAsync(n),n}else if(!c){let f=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,f))return this._preserveStack(i,s,f,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==i||this._activeBuffer.y!==s)&&this._onCursorMove.fire();let d=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(d,this._bufferService.rows-1)})}print(t,e,n){let i,s,a=this._charsetService.charset,c=this._optionsService.rawOptions.screenReaderMode,d=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,g=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,g);let y=this._parser.precedingJoinState;for(let w=e;w<n;++w){if(i=t[w],i<127&&a){let N=a[String.fromCharCode(i)];N&&(i=N.charCodeAt(0))}let S=this._unicodeService.charProperties(i,y);s=bo.extractWidth(S);let A=bo.extractShouldJoin(S),C=A?bo.extractWidth(y):0;if(y=S,c&&this._onA11yChar.fire(Ur(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+s-C>d){if(h){let N=_,k=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 jl&&_.copyCellsFrom(N,k,0,C,!1);k<d;)N.setCellFromCodepoint(k++,0,1,g)}else if(this._activeBuffer.x=d-1,s===2)continue}if(A&&this._activeBuffer.x){let N=_.getWidth(this._activeBuffer.x-1)?1:2;_.addCodepointToCell(this._activeBuffer.x-N,i,s);for(let k=s-C;--k>=0;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g);continue}if(f&&(_.insertCells(this._activeBuffer.x,s-C,this._activeBuffer.getNullCell(g)),_.getWidth(d-1)===2&&_.setCellFromCodepoint(d-1,0,1,g)),_.setCellFromCodepoint(this._activeBuffer.x++,i,s,g),s>0)for(;--s;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,g)}this._parser.precedingJoinState=y,this._activeBuffer.x<d&&n-e>0&&_.getWidth(this._activeBuffer.x)===0&&!_.hasContent(this._activeBuffer.x)&&_.setCellFromCodepoint(this._activeBuffer.x,0,1,g),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,n=>Zy(n.params[0],this._optionsService.rawOptions.windowOptions)?e(n):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new Xy(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new Yi(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,i=!1,s=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);a.replaceCells(e,n,this._activeBuffer.getNullCell(this._eraseAttrData()),s),i&&(a.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 i;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--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&i.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 s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(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,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;e--;)this._activeBuffer.lines.splice(s-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,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;e--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(i,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(Tn));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 i=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);i.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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 i=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);i.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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 i=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);i.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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 i=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);i.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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,i=bo.extractWidth(e),s=this._activeBuffer.x-i,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(s),c=new Uint32Array(a.length*n),d=0;for(let f=0;f<a.length;){let g=a.codePointAt(f)||0;c[d++]=g,f+=g>65535?2:1}let h=d;for(let f=1;f<n;++f)c.copyWithin(h,0,d),h+=d;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(Ne.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(Ne.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(Ne.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(Ne.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(Ne.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,yo),this._charsetService.setgCharset(1,yo),this._charsetService.setgCharset(2,yo),this._charsetService.setgCharset(3,yo);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){(A=>(A[A.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",A[A.SET=1]="SET",A[A.RESET=2]="RESET",A[A.PERMANENTLY_SET=3]="PERMANENTLY_SET",A[A.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let i=this._coreService.decPrivateModes,{activeProtocol:s,activeEncoding:a}=this._coreMouseService,c=this._coreService,{buffers:d,cols:h}=this._bufferService,{active:f,alt:g}=d,_=this._optionsService.rawOptions,y=(A,C)=>(c.triggerDataEvent(`${Ne.ESC}[${e?"":"?"}${A};${C}$y`),!0),w=A=>A?1:2,S=t.params[0];return e?S===2?y(S,4):S===4?y(S,w(c.modes.insertMode)):S===12?y(S,3):S===20?y(S,w(_.convertEol)):y(S,0):S===1?y(S,w(i.applicationCursorKeys)):S===3?y(S,_.windowOptions.setWinLines?h===80?2:h===132?1:0:0):S===6?y(S,w(i.origin)):S===7?y(S,w(i.wraparound)):S===8?y(S,3):S===9?y(S,w(s==="X10")):S===12?y(S,w(_.cursorBlink)):S===25?y(S,w(!c.isCursorHidden)):S===45?y(S,w(i.reverseWraparound)):S===66?y(S,w(i.applicationKeypad)):S===67?y(S,4):S===1e3?y(S,w(s==="VT200")):S===1002?y(S,w(s==="DRAG")):S===1003?y(S,w(s==="ANY")):S===1004?y(S,w(i.sendFocus)):S===1005?y(S,4):S===1006?y(S,w(a==="SGR")):S===1015?y(S,4):S===1016?y(S,w(a==="SGR_PIXELS")):S===1048?y(S,1):S===47||S===1047||S===1049?y(S,w(f===g)):S===2004?y(S,w(i.bracketedPasteMode)):S===2026?y(S,w(i.synchronizedOutput)):y(S,0)}_updateAttrColor(t,e,n,i,s){return e===2?(t|=50331648,t&=-16777216,t|=ec.fromColorRGB([n,i,s])):e===5&&(t&=-50331904,t|=33554432|n&255),t}_extractColor(t,e,n){let i=[0,0,-1,0,0,0],s=0,a=0;do{if(i[a+s]=t.params[e+a],t.hasSubParams(e+a)){let c=t.getSubParams(e+a),d=0;do i[1]===5&&(s=1),i[a+d+1+s]=c[d];while(++d<c.length&&d+a+1+s<i.length);break}if(i[1]===5&&a+s>=2||i[1]===2&&a+s>=5)break;i[1]&&(s=1)}while(++a+e<t.length&&a+s<i.length);for(let c=2;c<i.length;++c)i[c]===-1&&(i[c]=0);switch(i[0]){case 38:n.fg=this._updateAttrColor(n.fg,i[1],i[3],i[4],i[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,i[1],i[3],i[4],i[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,i[1],i[3],i[4],i[5])}return a}_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=Tn.fg,t.bg=Tn.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,i=this._curAttrData;for(let s=0;s<e;s++)n=t.params[s],n>=30&&n<=37?(i.fg&=-50331904,i.fg|=16777216|n-30):n>=40&&n<=47?(i.bg&=-50331904,i.bg|=16777216|n-40):n>=90&&n<=97?(i.fg&=-50331904,i.fg|=16777216|n-90|8):n>=100&&n<=107?(i.bg&=-50331904,i.bg|=16777216|n-100|8):n===0?this._processSGR0(i):n===1?i.fg|=134217728:n===3?i.bg|=67108864:n===4?(i.fg|=268435456,this._processUnderline(t.hasSubParams(s)?t.getSubParams(s)[0]:1,i)):n===5?i.fg|=536870912:n===7?i.fg|=67108864:n===8?i.fg|=1073741824:n===9?i.fg|=2147483648:n===2?i.bg|=134217728:n===21?this._processUnderline(2,i):n===22?(i.fg&=-134217729,i.bg&=-134217729):n===23?i.bg&=-67108865:n===24?(i.fg&=-268435457,this._processUnderline(0,i)):n===25?i.fg&=-536870913:n===27?i.fg&=-67108865:n===28?i.fg&=-1073741825:n===29?i.fg&=2147483647:n===39?(i.fg&=-67108864,i.fg|=Tn.fg&16777215):n===49?(i.bg&=-67108864,i.bg|=Tn.bg&16777215):n===38||n===48||n===58?s+=this._extractColor(t,s,i):n===53?i.bg|=1073741824:n===55?i.bg&=-1073741825:n===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):n===100?(i.fg&=-67108864,i.fg|=Tn.fg&16777215,i.bg&=-67108864,i.bg|=Tn.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${Ne.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Ne.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(`${Ne.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=Tn.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(!Zy(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(`${Ne.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Jy&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Jy&&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 i=n.shift(),s=n.shift();if(/^\d+$/.exec(i)){let a=parseInt(i);if(nw(a))if(s==="?")e.push({type:0,index:a});else{let c=Qy(s);c&&e.push({type:1,index:a,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(),i=t.slice(e+1);return i?this._createHyperlink(n,i):n.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let n=t.split(":"),i,s=n.findIndex(a=>a.startsWith("id="));return s!==-1&&(i=n[s].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,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 i=0;i<n.length&&!(e>=this._specialColors.length);++i,++e)if(n[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let s=Qy(n[i]);s&&this._onColor.fire([{type:1,index:this._specialColors[e],color:s}])}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 i=0;i<n.length;++i)if(/^\d+$/.exec(n[i])){let s=parseInt(n[i]);nw(s)&&e.push({type:2,index:s})}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,yo),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(rL[t[0]],Un[t[1]]||yo),!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=Tn.clone(),this._eraseAttrDataInternal=Tn.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 ps;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,i=this._activeBuffer.lines.get(n);i&&(i.fill(t),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let n=c=>(this._coreService.triggerDataEvent(`${Ne.ESC}${c}${Ne.ESC}\\`),!0),i=this._bufferService.buffer,s=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${i.scrollTop+1};${i.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[s.cursorStyle]-(s.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},Qp=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&&(tw=t,t=e,e=tw),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Qp=Cn([Ke(0,Ei)],Qp);function nw(t){return 0<=t&&t<256}var aL=5e7,iw=12,lL=50,cL=class extends Mt{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 Oe),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 i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,n){if(this._pendingData>aL)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 i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],a=this._action(s,n);if(a){let d=h=>performance.now()-i>=iw?setTimeout(()=>this._innerWrite(0,h)):this._innerWrite(i,h);a.catch(h=>(queueMicrotask(()=>{throw h}),Promise.resolve(!1))).then(d);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=iw)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>lL&&(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()}},Jp=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),f={data:e,id:this._nextId++,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(f,h)),this._dataByLinkId.set(f.id,f),f.id}let i=e,s=this._getEntryIdKey(i),a=this._entriesWithId.get(s);if(a)return this.addLineToLink(a.id,n.ybase+n.y),a.id;let c=n.addMarker(n.ybase+n.y),d={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(d,c)),this._entriesWithId.set(d.key,d),this._dataByLinkId.set(d.id,d),d.id}addLineToLink(e,n){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==n)){let s=this._bufferService.buffer.addMarker(n);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}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 i=e.lines.indexOf(n);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Jp=Cn([Ke(0,Ei)],Jp);var sw=!1,uL=class extends Mt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Sa),this._onBinary=this._register(new Oe),this.onBinary=this._onBinary.event,this._onData=this._register(new Oe),this.onData=this._onData.event,this._onLineFeed=this._register(new Oe),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Oe),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Oe),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Oe),this._instantiationService=new PN,this.optionsService=this._register(new WN(e)),this._instantiationService.setService(Ni,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Vp)),this._instantiationService.setService(Ei,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Kp)),this._instantiationService.setService(gS,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Yp)),this._instantiationService.setService(Mo,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Gp)),this._instantiationService.setService(mS,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(bo)),this._instantiationService.setService(AE,this.unicodeService),this._charsetService=this._instantiationService.createInstance(GN),this._instantiationService.setService(RE,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Jp),this._instantiationService.setService(vS,this._oscLinkService),this._inputHandler=this._register(new oL(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(hi.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(hi.forward(this._bufferService.onResize,this._onResize)),this._register(hi.forward(this.coreService.onData,this._onData)),this._register(hi.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 cL((n,i)=>this._inputHandler.parse(n,i))),this._register(hi.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Oe),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&&!sw&&(this._logService.warn("writeSync is unreliable and will be removed soon."),sw=!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,GS),n=Math.max(n,XS),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(Gy.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Gy(this._bufferService),!1))),this._windowsWrappingHeuristics.value=dn(()=>{for(let n of e)n.dispose()})}}},dL={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 hL(t,e,n,i){var c;let s={type:0,cancel:!1,key:void 0},a=(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?s.key=Ne.ESC+"OA":s.key=Ne.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?s.key=Ne.ESC+"OD":s.key=Ne.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?s.key=Ne.ESC+"OC":s.key=Ne.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?s.key=Ne.ESC+"OB":s.key=Ne.ESC+"[B");break;case 8:s.key=t.ctrlKey?"\b":Ne.DEL,t.altKey&&(s.key=Ne.ESC+s.key);break;case 9:if(t.shiftKey){s.key=Ne.ESC+"[Z";break}s.key=Ne.HT,s.cancel=!0;break;case 13:s.key=t.altKey?Ne.ESC+Ne.CR:Ne.CR,s.cancel=!0;break;case 27:s.key=Ne.ESC,t.altKey&&(s.key=Ne.ESC+Ne.ESC),s.cancel=!0;break;case 37:if(t.metaKey)break;a?s.key=Ne.ESC+"[1;"+(a+1)+"D":e?s.key=Ne.ESC+"OD":s.key=Ne.ESC+"[D";break;case 39:if(t.metaKey)break;a?s.key=Ne.ESC+"[1;"+(a+1)+"C":e?s.key=Ne.ESC+"OC":s.key=Ne.ESC+"[C";break;case 38:if(t.metaKey)break;a?s.key=Ne.ESC+"[1;"+(a+1)+"A":e?s.key=Ne.ESC+"OA":s.key=Ne.ESC+"[A";break;case 40:if(t.metaKey)break;a?s.key=Ne.ESC+"[1;"+(a+1)+"B":e?s.key=Ne.ESC+"OB":s.key=Ne.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(s.key=Ne.ESC+"[2~");break;case 46:a?s.key=Ne.ESC+"[3;"+(a+1)+"~":s.key=Ne.ESC+"[3~";break;case 36:a?s.key=Ne.ESC+"[1;"+(a+1)+"H":e?s.key=Ne.ESC+"OH":s.key=Ne.ESC+"[H";break;case 35:a?s.key=Ne.ESC+"[1;"+(a+1)+"F":e?s.key=Ne.ESC+"OF":s.key=Ne.ESC+"[F";break;case 33:t.shiftKey?s.type=2:t.ctrlKey?s.key=Ne.ESC+"[5;"+(a+1)+"~":s.key=Ne.ESC+"[5~";break;case 34:t.shiftKey?s.type=3:t.ctrlKey?s.key=Ne.ESC+"[6;"+(a+1)+"~":s.key=Ne.ESC+"[6~";break;case 112:a?s.key=Ne.ESC+"[1;"+(a+1)+"P":s.key=Ne.ESC+"OP";break;case 113:a?s.key=Ne.ESC+"[1;"+(a+1)+"Q":s.key=Ne.ESC+"OQ";break;case 114:a?s.key=Ne.ESC+"[1;"+(a+1)+"R":s.key=Ne.ESC+"OR";break;case 115:a?s.key=Ne.ESC+"[1;"+(a+1)+"S":s.key=Ne.ESC+"OS";break;case 116:a?s.key=Ne.ESC+"[15;"+(a+1)+"~":s.key=Ne.ESC+"[15~";break;case 117:a?s.key=Ne.ESC+"[17;"+(a+1)+"~":s.key=Ne.ESC+"[17~";break;case 118:a?s.key=Ne.ESC+"[18;"+(a+1)+"~":s.key=Ne.ESC+"[18~";break;case 119:a?s.key=Ne.ESC+"[19;"+(a+1)+"~":s.key=Ne.ESC+"[19~";break;case 120:a?s.key=Ne.ESC+"[20;"+(a+1)+"~":s.key=Ne.ESC+"[20~";break;case 121:a?s.key=Ne.ESC+"[21;"+(a+1)+"~":s.key=Ne.ESC+"[21~";break;case 122:a?s.key=Ne.ESC+"[23;"+(a+1)+"~":s.key=Ne.ESC+"[23~";break;case 123:a?s.key=Ne.ESC+"[24;"+(a+1)+"~":s.key=Ne.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?s.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?s.key=Ne.NUL:t.keyCode>=51&&t.keyCode<=55?s.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?s.key=Ne.DEL:t.keyCode===219?s.key=Ne.ESC:t.keyCode===220?s.key=Ne.FS:t.keyCode===221&&(s.key=Ne.GS);else if((!n||i)&&t.altKey&&!t.metaKey){let d=(c=dL[t.keyCode])==null?void 0:c[t.shiftKey?1:0];if(d)s.key=Ne.ESC+d;else if(t.keyCode>=65&&t.keyCode<=90){let h=t.ctrlKey?t.keyCode-64:t.keyCode+32,f=String.fromCharCode(h);t.shiftKey&&(f=f.toUpperCase()),s.key=Ne.ESC+f}else if(t.keyCode===32)s.key=Ne.ESC+(t.ctrlKey?Ne.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let h=t.code.slice(3,4);t.shiftKey||(h=h.toLowerCase()),s.key=Ne.ESC+h,s.cancel=!0}}else n&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(s.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?s.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(s.key=Ne.US),t.key==="@"&&(s.key=Ne.NUL));break}return s}var Rn=0,fL=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Wu,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Wu,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((a,c)=>this._getKey(a)-this._getKey(c)),n=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let a=0;a<s.length;a++)i>=this._array.length||this._getKey(e[n])<=this._getKey(this._array[i])?(s[a]=e[n],n++):s[a]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let n=this._getKey(e);if(n===void 0||(Rn=this._search(n),Rn===-1)||this._getKey(this._array[Rn])!==n)return!1;do if(this._array[Rn]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Rn),!0;while(++Rn<this._array.length&&this._getKey(this._array[Rn])===n);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((a,c)=>a-c),n=0,i=new Array(this._array.length-e.length),s=0;for(let a=0;a<this._array.length;a++)e[n]===a?n++:i[s++]=this._array[a];this._array=i,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&&(Rn=this._search(e),!(Rn<0||Rn>=this._array.length)&&this._getKey(this._array[Rn])===e))do yield this._array[Rn];while(++Rn<this._array.length&&this._getKey(this._array[Rn])===e)}forEachByKey(e,n){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Rn=this._search(e),!(Rn<0||Rn>=this._array.length)&&this._getKey(this._array[Rn])===e))do n(this._array[Rn]);while(++Rn<this._array.length&&this._getKey(this._array[Rn])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let n=0,i=this._array.length-1;for(;i>=n;){let s=n+i>>1,a=this._getKey(this._array[s]);if(a>e)i=s-1;else if(a<e)n=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return n}},mf=0,rw=0,pL=class extends Mt{constructor(){super(),this._decorations=new fL(t=>t==null?void 0:t.marker.line),this._onDecorationRegistered=this._register(new Oe),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Oe),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(dn(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new mL(t);if(e){let n=e.marker.onDispose(()=>e.dispose()),i=e.onDispose(()=>{i.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 i=0,s=0;for(let a of this._decorations.getKeyIterator(e))i=a.options.x??0,s=i+(a.options.width??1),t>=i&&t<s&&(!n||(a.options.layer??"bottom")===n)&&(yield a)}forEachDecorationAtCell(t,e,n,i){this._decorations.forEachByKey(e,s=>{mf=s.options.x??0,rw=mf+(s.options.width??1),t>=mf&&t<rw&&(!n||(s.options.layer??"bottom")===n)&&i(s)})}},mL=class extends Yr{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new Oe),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Oe),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=_n.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=_n.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},gL=1e3,vL=class{constructor(e,n=gL){this._renderCallback=e,this._debounceThresholdMS=n,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,n,i){this._rowCount=i,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 s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=s-this._lastRefreshMs,c=this._debounceThresholdMS-a;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)}},ow=20,qu=class extends Mt{constructor(t,e,n,i){super(),this._terminal=t,this._coreBrowserService=n,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let s=this._coreBrowserService.mainDocument;this._accessibilityContainer=s.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=s.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=s.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new vL(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(a=>this._handleResize(a.rows))),this._register(this._terminal.onRender(a=>this._refreshRows(a.start,a.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(a=>this._handleChar(a))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
64
|
-
`))),this._register(this._terminal.onA11yTab(a=>this._handleTab(a))),this._register(this._terminal.onKey(a=>this._handleKey(a.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(vt(s,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(dn(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<ow+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
|
|
65
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===ow+1&&(this._liveRegion.textContent+=_p.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,i=n.lines.length.toString();for(let s=t;s<=e;s++){let a=n.lines.get(n.ydisp+s),c=[],d=(a==null?void 0:a.translateToString(!0,void 0,void 0,c))||"",h=(n.ydisp+s+1).toString(),f=this._rowElements[s];f&&(d.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=d,this._rowColumns.set(f,c)),f.setAttribute("aria-posinset",h),f.setAttribute("aria-setsize",i),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let n=t.target,i=this._rowElements[e===0?1:this._rowElements.length-2],s=n.getAttribute("aria-posinset"),a=e===0?"1":`${this._terminal.buffer.lines.length}`;if(s===a||t.relatedTarget!==i)return;let c,d;if(e===0?(c=n,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(c=this._rowElements.shift(),d=n,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),d.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 d;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 i=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:i,offset:((d=i.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(n.node))return;let s=({node:h,offset:f})=>{let g=h instanceof Text?h.parentNode:h,_=parseInt(g==null?void 0:g.getAttribute("aria-posinset"),10)-1;if(isNaN(_))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(g);if(!y)return console.warn("columns is null. Race condition?"),null;let w=f<y.length?y[f]:y.slice(-1)[0]+1;return w>=this._terminal.cols&&(++_,w=0),{row:_,column:w}},a=s(e),c=s(n);if(!(!a||!c)){if(a.row>c.row||a.row===c.row&&a.column>=c.column)throw new Error("invalid range");this._terminal.select(a.column,a.row,(c.row-a.row)*this._terminal.cols-a.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 s,a;t.style.transform="";let e=t.getBoundingClientRect().width,n=(a=(s=this._rowColumns.get(t))==null?void 0:s.slice(-1))==null?void 0:a[0];if(!n)return;let i=n*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${i/e})`}};qu=Cn([Ke(1,Hm),Ke(2,mr),Ke(3,gr)],qu);var Zp=class extends Mt{constructor(t,e,n,i,s){super(),this._element=t,this._mouseService=e,this._renderService=n,this._bufferService=i,this._linkProviderService=s,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Oe),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Oe),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(dn(()=>{var a;Lo(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(a=this._activeProviderReplies)==null||a.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(vt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(vt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(vt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(vt(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 i=0;i<n.length;i++){let s=n[i];if(s.classList.contains("xterm"))break;if(s.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 i,s;(!this._activeProviderReplies||!e)&&((i=this._activeProviderReplies)==null||i.forEach(a=>{a==null||a.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let n=!1;for(let[a,c]of this._linkProviderService.linkProviders.entries())e?(s=this._activeProviderReplies)!=null&&s.get(a)&&(n=this._checkLinkProviderResult(a,t,n)):c.provideLinks(t.y,d=>{var f,g;if(this._isMouseOut)return;let h=d==null?void 0:d.map(_=>({link:_}));(f=this._activeProviderReplies)==null||f.set(a,h),n=this._checkLinkProviderResult(a,t,n),((g=this._activeProviderReplies)==null?void 0:g.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let n=new Set;for(let i=0;i<e.size;i++){let s=e.get(i);if(s)for(let a=0;a<s.length;a++){let c=s[a],d=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 f=d;f<=h;f++){if(n.has(f)){s.splice(a--,1);break}n.add(f)}}}}_checkLinkProviderResult(t,e,n){var a;if(!this._activeProviderReplies)return n;let i=this._activeProviderReplies.get(t),s=!1;for(let c=0;c<t;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(s=!0);if(!s&&i){let c=i.find(d=>this._linkAtPosition(d.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 d=(a=this._activeProviderReplies.get(c))==null?void 0:a.find(h=>this._linkAtPosition(h.link,e));if(d){n=!0,this._handleNewLink(d);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&&_L(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,Lo(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,i;return(i=(n=this._currentLink)==null?void 0:n.state)==null?void 0:i.decorations.pointerCursor},set:n=>{var i;(i=this._currentLink)!=null&&i.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,i;return(i=(n=this._currentLink)==null?void 0:n.state)==null?void 0:i.decorations.underline},set:n=>{var i,s,a;(i=this._currentLink)!=null&&i.state&&((a=(s=this._currentLink)==null?void 0:s.state)==null?void 0:a.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 i=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(i,s),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(t,e,n){var i;(i=this._currentLink)!=null&&i.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,i=this._bufferService.buffer.ydisp,s=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-i-1,n.end.x,n.end.y-i-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(s)}_linkLeave(t,e,n){var i;(i=this._currentLink)!=null&&i.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,i=t.range.end.y*this._bufferService.cols+t.range.end.x,s=e.y*this._bufferService.cols+e.x;return n<=s&&s<=i}_positionFromMouseEvent(t,e,n){let i=n.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,n,i,s){return{x1:t,y1:e,x2:n,y2:i,cols:this._bufferService.cols,fg:s}}};Zp=Cn([Ke(1,Um),Ke(2,gr),Ke(3,Ei),Ke(4,yS)],Zp);function _L(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 yL=class extends uL{constructor(e={}){super(e),this._linkifier=this._register(new Sa),this.browser=OS,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Sa),this._onCursorMove=this._register(new Oe),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Oe),this.onKey=this._onKey.event,this._onRender=this._register(new Oe),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Oe),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Oe),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Oe),this.onBell=this._onBell.event,this._onFocus=this._register(new Oe),this._onBlur=this._register(new Oe),this._onA11yCharEmitter=this._register(new Oe),this._onA11yTabEmitter=this._register(new Oe),this._onWillOpen=this._register(new Oe),this._setup(),this._decorationService=this._instantiationService.createInstance(pL),this._instantiationService.setService(tc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(lN),this._instantiationService.setService(yS,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(wp)),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(hi.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(hi.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(hi.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(hi.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(n=>this._afterResize(n.cols,n.rows))),this._register(dn(()=>{var n,i;this._customKeyEventHandler=void 0,(i=(n=this.element)==null?void 0:n.parentNode)==null||i.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 i,s="";switch(n.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+n.index}switch(n.type){case 0:let a=an.toColorRGB(i==="ansi"?this._themeService.colors.ansi[n.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${Ne.ESC}]${s};${sL(a)}${DS.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(c=>c.ansi[n.index]=In.toColor(...n.color));else{let c=i;this._themeService.modifyColors(d=>d[c]=In.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(qu,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Ne.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(Ne.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 i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,a=n.getWidth(i),c=this._renderService.dimensions.css.cell.width*a,d=this.buffer.y*this._renderService.dimensions.css.cell.height,h=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=d+"px",this.textarea.style.width=c+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(vt(this.element,"copy",n=>{this.hasSelection()&&xE(n,this._selectionService)}));let e=n=>CE(n,this.textarea,this.coreService,this.optionsService);this._register(vt(this.textarea,"paste",e)),this._register(vt(this.element,"paste",e)),$S?this._register(vt(this.element,"mousedown",n=>{n.button===2&&gy(n,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(vt(this.element,"contextmenu",n=>{gy(n,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Qm&&this._register(vt(this.element,"auxclick",n=>{n.button===1&&uS(n,this.textarea,this.screenElement)}))}_bindKeys(){this._register(vt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(vt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(vt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(vt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(vt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(vt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(vt(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var a;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"),((a=this.element)==null?void 0:a.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(vt(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 i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",vp.get()),HS||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",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(oN,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(mr,this._coreBrowserService),this._register(vt(this.textarea,"focus",c=>this._handleTextAreaFocus(c))),this._register(vt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Fp,this._document,this._helperContainer),this._instantiationService.setService(hd,this._charSizeService),this._themeService=this._instantiationService.createInstance(qp),this._instantiationService.setService(Aa,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Hu),this._instantiationService.setService(_S,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Up,this.rows,this.screenElement)),this._instantiationService.setService(gr,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(Op,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Hp),this._instantiationService.setService(Um,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Zp,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(Dp,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(Wp,this.element,this.screenElement,s)),this._instantiationService.setService(jE,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(hi.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var c;this._selectionService.refresh(),(c=this._viewport)==null||c.queueSync()})),this._register(this._instantiationService.createInstance(Bp,this.screenElement)),this._register(vt(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(qu,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",c=>this._handleScreenReaderModeOptionChange(c))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Fu,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",c=>{!this._overviewRulerRenderer&&c&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Fu,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(zp,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,n=this.element;function i(c){var g,_,y,w,S;let d=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!d)return!1;let h,f;switch(c.overrideType||c.type){case"mousemove":f=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":f=0,h=c.button<3?c.button:3;break;case"mousedown":f=1,h=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let A=c.deltaY;if(A===0||e.coreMouseService.consumeWheelEvent(c,(w=(y=(_=(g=e._renderService)==null?void 0:g.dimensions)==null?void 0:_.device)==null?void 0:y.cell)==null?void 0:w.height,(S=e._coreBrowserService)==null?void 0:S.dpr)===0)return!1;f=A<0?0:1,h=4;break;default:return!1}return f===void 0||h===void 0||h>4?!1:e.coreMouseService.triggerMouseEvent({col:d.col,row:d.row,x:d.x,y:d.y,button:h,action:f,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:c=>(i(c),c.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(c)),wheel:c=>(i(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&i(c)},mousemove:c=>{c.buttons||i(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),c&8?s.mousemove||(n.addEventListener("mousemove",a.mousemove),s.mousemove=a.mousemove):(n.removeEventListener("mousemove",s.mousemove),s.mousemove=null),c&16?s.wheel||(n.addEventListener("wheel",a.wheel,{passive:!1}),s.wheel=a.wheel):(n.removeEventListener("wheel",s.wheel),s.wheel=null),c&2?s.mouseup||(s.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),c&4?s.mousedrag||(s.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(vt(n,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return i(c),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(c)})),this._register(vt(n,"wheel",c=>{var d,h,f,g,_;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,(g=(f=(h=(d=e._renderService)==null?void 0:d.dimensions)==null?void 0:h.device)==null?void 0:f.cell)==null?void 0:g.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return this.cancel(c,!0);let y=Ne.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(y,!0),this.cancel(c,!0)}}},{passive:!1}))}refresh(e,n){var i;(i=this._renderService)==null||i.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){cS(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,i){this._selectionService.setSelection(e,n,i)}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 i;(i=this._selectionService)==null||i.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 i=hL(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.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((i.key===Ne.ETX||i.key===Ne.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,n){let i=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"?i:i&&(!n.keyCode||n.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(wL(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 i;(i=this._charSizeService)==null||i.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(Tn));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(Ne.ESC+"[I"):this.coreService.triggerDataEvent(Ne.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let n=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Ne.ESC}[4;${i};${n}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),a=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Ne.ESC}[6;${a};${s}t`);break}}cancel(e,n){if(!(!this.options.cancelEvents&&!n))return e.preventDefault(),e.stopPropagation(),!1}};function wL(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var bL=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,n){let i={instance:n,dispose:n.dispose,isDisposed:!1};this._addons.push(i),n.dispose=()=>this._wrappedAddonDispose(i),n.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let n=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){n=i;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)}},SL=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 ps)}translateToString(e,n,i){return this._line.translateToString(e,n,i)}},aw=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 SL(e)}getNullCell(){return new ps}},xL=class extends Mt{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new Oe),this.onBufferChange=this._onBufferChange.event,this._normal=new aw(this._core.buffers.normal,"normal"),this._alternate=new aw(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)}},CL=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,i)=>e(n,i.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)}},kL=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}},EL=["cols","rows"],Ts=0,NL=class extends Mt{constructor(t){super(),this._core=this._register(new yL(t)),this._addonManager=this._register(new bL),this._publicOptions={...this._core.options};let e=i=>this._core.options[i],n=(i,s)=>{this._checkReadonlyOptions(i),this._core.options[i]=s};for(let i in this._core.options){let s={get:e.bind(this,i),set:n.bind(this,i)};Object.defineProperty(this._publicOptions,i,s)}}_checkReadonlyOptions(t){if(EL.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 CL(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new kL(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 xL(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 vp.get()},set promptLabel(t){vp.set(t)},get tooMuchOutput(){return _p.get()},set tooMuchOutput(t){_p.set(t)}}}_verifyIntegers(...t){for(Ts of t)if(Ts===1/0||isNaN(Ts)||Ts%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(Ts of t)if(Ts&&(Ts===1/0||isNaN(Ts)||Ts%1!==0||Ts<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 LL=2,RL=1,AL=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),i=parseInt(n.getPropertyValue("height")),s=Math.max(0,parseInt(n.getPropertyValue("width"))),a=window.getComputedStyle(this._terminal.element),c={top:parseInt(a.getPropertyValue("padding-top")),bottom:parseInt(a.getPropertyValue("padding-bottom")),right:parseInt(a.getPropertyValue("padding-right")),left:parseInt(a.getPropertyValue("padding-left"))},d=c.top+c.bottom,h=c.right+c.left,f=i-d,g=s-h-e;return{cols:Math.max(LL,Math.floor(g/t.css.cell.width)),rows:Math.max(RL,Math.floor(f/t.css.cell.height))}}};const ML=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]]),jL=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]]),TL="nc-15.1";function lw(t,e){let n=0,i=t.length-1;for(;n<=i;){const s=n+i>>1,[a,c]=t[s];if(e<a)i=s-1;else if(e>c)n=s+1;else return!0}return!1}function PL(t,e,n){return(t&16777215)<<3|(e&3)<<1|(n?1:0)}function cw(t){const e=Number(t);return!Number.isFinite(e)||e<0||e<32||e>=127&&e<160||lw(jL,e)?0:lw(ML,e)?2:1}function IL(){return{version:TL,wcwidth:cw,charProperties(t,e){let n=cw(t),i=n===0&&e!==0;if(i){const s=e>>1&3;s===0?i=!1:s>n&&(n=s)}return PL(t,n,i)}}}function DL(t){try{const e=t&&t.unicode;if(!e||typeof e.register!="function")return null;const n=IL();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 BL=(t,e,n,i)=>{for(var s=e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(s=c(s)||s);return s},OL=(t,e)=>(n,i)=>e(n,i,t),$L=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?uw.isErrorNoTelemetry(t)?new uw(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)}},zL=new $L;function gf(t){FL(t)||zL.onUnexpectedError(t)}var em="Canceled";function FL(t){return t instanceof HL?!0:t instanceof Error&&t.name===em&&t.message===em}var HL=class extends Error{constructor(){super(em),this.name=this.message}},uw=class tm extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof tm)return e;let n=new tm;return n.message=e.message,n.stack=e.stack,n}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},UL;(t=>{function e(a){return a<0}t.isLessThan=e;function n(a){return a<=0}t.isLessThanOrEqual=n;function i(a){return a>0}t.isGreaterThan=i;function s(a){return a===0}t.isNeitherLessOrGreaterThan=s,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(UL||(UL={}));function WL(t,e){let n=this,i=!1,s;return function(){return i||(i=!0,e||(s=t.apply(n,arguments))),s}}var JS;(t=>{function e(P){return P&&typeof P=="object"&&typeof P[Symbol.iterator]=="function"}t.is=e;let n=Object.freeze([]);function i(){return n}t.empty=i;function*s(P){yield P}t.single=s;function a(P){return e(P)?P:s(P)}t.wrap=a;function c(P){return P||n}t.from=c;function*d(P){for(let H=P.length-1;H>=0;H--)yield P[H]}t.reverse=d;function h(P){return!P||P[Symbol.iterator]().next().done===!0}t.isEmpty=h;function f(P){return P[Symbol.iterator]().next().value}t.first=f;function g(P,H){let W=0;for(let U of P)if(H(U,W++))return!0;return!1}t.some=g;function _(P,H){for(let W of P)if(H(W))return W}t.find=_;function*y(P,H){for(let W of P)H(W)&&(yield W)}t.filter=y;function*w(P,H){let W=0;for(let U of P)yield H(U,W++)}t.map=w;function*S(P,H){let W=0;for(let U of P)yield*H(U,W++)}t.flatMap=S;function*A(...P){for(let H of P)yield*H}t.concat=A;function C(P,H,W){let U=W;for(let G of P)U=H(U,G);return U}t.reduce=C;function*N(P,H,W=P.length){for(H<0&&(H+=P.length),W<0?W+=P.length:W>P.length&&(W=P.length);H<W;H++)yield P[H]}t.slice=N;function k(P,H=Number.POSITIVE_INFINITY){let W=[];if(H===0)return[W,P];let U=P[Symbol.iterator]();for(let G=0;G<H;G++){let X=U.next();if(X.done)return[W,t.empty()];W.push(X.value)}return[W,{[Symbol.iterator](){return U}}]}t.consume=k;async function O(P){let H=[];for await(let W of P)H.push(W);return Promise.resolve(H)}t.asyncToArray=O})(JS||(JS={}));function ZS(t){if(JS.is(t)){let e=[];for(let n of t)if(n)try{n.dispose()}catch(i){e.push(i)}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 e1(...t){return wi(()=>ZS(t))}function wi(t){return{dispose:WL(()=>{t()})}}var t1=class n1{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{ZS(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?n1.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 ya=t1,Es=class{constructor(){this._store=new ya,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)}};Es.None=Object.freeze({dispose(){}});var _l=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}},Jm=typeof process<"u"&&"title"in process,md=Jm?"node":navigator.userAgent,qL=Jm?"node":navigator.platform,KL=md.includes("Firefox"),VL=md.includes("Edge"),i1=/^((?!chrome|android).)*safari/i.test(md);function YL(){if(!i1)return 0;let t=md.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}qL.indexOf("Linux")>=0;var GL="",ei=0,ti=0,ni=0,xn=0,us={css:"#00000000",rgba:0},ki;(t=>{function e(s,a,c,d){return d!==void 0?`#${mo(s)}${mo(a)}${mo(c)}${mo(d)}`:`#${mo(s)}${mo(a)}${mo(c)}`}t.toCss=e;function n(s,a,c,d=255){return(s<<24|a<<16|c<<8|d)>>>0}t.toRgba=n;function i(s,a,c,d){return{css:t.toCss(s,a,c,d),rgba:t.toRgba(s,a,c,d)}}t.toColor=i})(ki||(ki={}));var Il;(t=>{function e(h,f){if(xn=(f.rgba&255)/255,xn===1)return{css:f.css,rgba:f.rgba};let g=f.rgba>>24&255,_=f.rgba>>16&255,y=f.rgba>>8&255,w=h.rgba>>24&255,S=h.rgba>>16&255,A=h.rgba>>8&255;ei=w+Math.round((g-w)*xn),ti=S+Math.round((_-S)*xn),ni=A+Math.round((y-A)*xn);let C=ki.toCss(ei,ti,ni),N=ki.toRgba(ei,ti,ni);return{css:C,rgba:N}}t.blend=e;function n(h){return(h.rgba&255)===255}t.isOpaque=n;function i(h,f,g){let _=ko.ensureContrastRatio(h.rgba,f.rgba,g);if(_)return ki.toColor(_>>24&255,_>>16&255,_>>8&255)}t.ensureContrastRatio=i;function s(h){let f=(h.rgba|255)>>>0;return[ei,ti,ni]=ko.toChannels(f),{css:ki.toCss(ei,ti,ni),rgba:f}}t.opaque=s;function a(h,f){return xn=Math.round(f*255),[ei,ti,ni]=ko.toChannels(h.rgba),{css:ki.toCss(ei,ti,ni,xn),rgba:ki.toRgba(ei,ti,ni,xn)}}t.opacity=a;function c(h,f){return xn=h.rgba&255,a(h,xn*f/255)}t.multiplyOpacity=c;function d(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}t.toColorRGB=d})(Il||(Il={}));var XL;(t=>{let e,n;try{let s=document.createElement("canvas");s.width=1,s.height=1;let a=s.getContext("2d",{willReadFrequently:!0});a&&(e=a,e.globalCompositeOperation="copy",n=e.createLinearGradient(0,0,1,1))}catch{}function i(s){if(s.match(/#[\da-f]{3,8}/i))switch(s.length){case 4:return ei=parseInt(s.slice(1,2).repeat(2),16),ti=parseInt(s.slice(2,3).repeat(2),16),ni=parseInt(s.slice(3,4).repeat(2),16),ki.toColor(ei,ti,ni);case 5:return ei=parseInt(s.slice(1,2).repeat(2),16),ti=parseInt(s.slice(2,3).repeat(2),16),ni=parseInt(s.slice(3,4).repeat(2),16),xn=parseInt(s.slice(4,5).repeat(2),16),ki.toColor(ei,ti,ni,xn);case 7:return{css:s,rgba:(parseInt(s.slice(1),16)<<8|255)>>>0};case 9:return{css:s,rgba:parseInt(s.slice(1),16)>>>0}}let a=s.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(a)return ei=parseInt(a[1]),ti=parseInt(a[2]),ni=parseInt(a[3]),xn=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),ki.toColor(ei,ti,ni,xn);if(!e||!n)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=n,e.fillStyle=s,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[ei,ti,ni,xn]=e.getImageData(0,0,1,1).data,xn!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ki.toRgba(ei,ti,ni,xn),css:s}}t.toColor=i})(XL||(XL={}));var Ci;(t=>{function e(i){return n(i>>16&255,i>>8&255,i&255)}t.relativeLuminance=e;function n(i,s,a){let c=i/255,d=s/255,h=a/255,f=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),_=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return f*.2126+g*.7152+_*.0722}t.relativeLuminance2=n})(Ci||(Ci={}));var ko;(t=>{function e(c,d){if(xn=(d&255)/255,xn===1)return d;let h=d>>24&255,f=d>>16&255,g=d>>8&255,_=c>>24&255,y=c>>16&255,w=c>>8&255;return ei=_+Math.round((h-_)*xn),ti=y+Math.round((f-y)*xn),ni=w+Math.round((g-w)*xn),ki.toRgba(ei,ti,ni)}t.blend=e;function n(c,d,h){let f=Ci.relativeLuminance(c>>8),g=Ci.relativeLuminance(d>>8);if(sr(f,g)<h){if(g<f){let w=i(c,d,h),S=sr(f,Ci.relativeLuminance(w>>8));if(S<h){let A=s(c,d,h),C=sr(f,Ci.relativeLuminance(A>>8));return S>C?w:A}return w}let _=s(c,d,h),y=sr(f,Ci.relativeLuminance(_>>8));if(y<h){let w=i(c,d,h),S=sr(f,Ci.relativeLuminance(w>>8));return y>S?_:w}return _}}t.ensureContrastRatio=n;function i(c,d,h){let f=c>>24&255,g=c>>16&255,_=c>>8&255,y=d>>24&255,w=d>>16&255,S=d>>8&255,A=sr(Ci.relativeLuminance2(y,w,S),Ci.relativeLuminance2(f,g,_));for(;A<h&&(y>0||w>0||S>0);)y-=Math.max(0,Math.ceil(y*.1)),w-=Math.max(0,Math.ceil(w*.1)),S-=Math.max(0,Math.ceil(S*.1)),A=sr(Ci.relativeLuminance2(y,w,S),Ci.relativeLuminance2(f,g,_));return(y<<24|w<<16|S<<8|255)>>>0}t.reduceLuminance=i;function s(c,d,h){let f=c>>24&255,g=c>>16&255,_=c>>8&255,y=d>>24&255,w=d>>16&255,S=d>>8&255,A=sr(Ci.relativeLuminance2(y,w,S),Ci.relativeLuminance2(f,g,_));for(;A<h&&(y<255||w<255||S<255);)y=Math.min(255,y+Math.ceil((255-y)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),A=sr(Ci.relativeLuminance2(y,w,S),Ci.relativeLuminance2(f,g,_));return(y<<24|w<<16|S<<8|255)>>>0}t.increaseLuminance=s;function a(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}t.toChannels=a})(ko||(ko={}));function mo(t){let e=t.toString(16);return e.length<2?"0"+e:e}function sr(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}function Pn(t){if(!t)throw new Error("value must not be falsy");return t}function Zm(t){return 57508<=t&&t<=57558}function QL(t){return 57520<=t&&t<=57527}function JL(t){return 57344<=t&&t<=63743}function ZL(t){return 9472<=t&&t<=9631}function eR(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 tR(t,e,n,i){return e===1&&n>Math.ceil(i*1.5)&&t!==void 0&&t>255&&!eR(t)&&!Zm(t)&&!JL(t)}function s1(t){return Zm(t)||ZL(t)}function nR(){return{css:{canvas:mu(),cell:mu()},device:{canvas:mu(),cell:mu(),char:{width:0,height:0,left:0,top:0}}}}function mu(){return{width:0,height:0}}function iR(t,e,n=0){return(t-(Math.round(e)*2-n))%(Math.round(e)*2)}var li=0,Gn=0,Ps=!1,rr=!1,gu=!1,$i,vf=0,sR=class{constructor(t,e,n,i,s,a){this._terminal=t,this._optionService=e,this._selectionRenderModel=n,this._decorationService=i,this._coreBrowserService=s,this._themeService=a,this.result={fg:0,bg:0,ext:0}}resolve(t,e,n,i){if(this.result.bg=t.bg,this.result.fg=t.fg,this.result.ext=t.bg&268435456?t.extended.ext:0,Gn=0,li=0,rr=!1,Ps=!1,gu=!1,$i=this._themeService.colors,vf=0,t.getCode()!==0&&t.extended.underlineStyle===4){let s=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));vf=e*i%(Math.round(s)*2)}if(this._decorationService.forEachDecorationAtCell(e,n,"bottom",s=>{s.backgroundColorRGB&&(Gn=s.backgroundColorRGB.rgba>>8&16777215,rr=!0),s.foregroundColorRGB&&(li=s.foregroundColorRGB.rgba>>8&16777215,Ps=!0)}),gu=this._selectionRenderModel.isCellSelected(this._terminal,e,n),gu){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:Gn=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:Gn=(this.result.fg&16777215)<<8|255;break;case 0:default:Gn=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:Gn=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:Gn=(this.result.bg&16777215)<<8|255;break}Gn=ko.blend(Gn,(this._coreBrowserService.isFocused?$i.selectionBackgroundOpaque:$i.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else Gn=(this._coreBrowserService.isFocused?$i.selectionBackgroundOpaque:$i.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(rr=!0,$i.selectionForeground&&(li=$i.selectionForeground.rgba>>8&16777215,Ps=!0),s1(t.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)li=(this._coreBrowserService.isFocused?$i.selectionBackgroundOpaque:$i.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:li=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:li=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:li=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:li=(this.result.fg&16777215)<<8|255;break;case 0:default:li=this._themeService.colors.foreground.rgba}li=ko.blend(li,(this._coreBrowserService.isFocused?$i.selectionBackgroundOpaque:$i.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}Ps=!0}}this._decorationService.forEachDecorationAtCell(e,n,"top",s=>{s.backgroundColorRGB&&(Gn=s.backgroundColorRGB.rgba>>8&16777215,rr=!0),s.foregroundColorRGB&&(li=s.foregroundColorRGB.rgba>>8&16777215,Ps=!0)}),rr&&(gu?Gn=t.bg&-16777216&-134217729|Gn|50331648:Gn=t.bg&-16777216|Gn|50331648),Ps&&(li=t.fg&-16777216&-67108865|li|50331648),this.result.fg&67108864&&(rr&&!Ps&&((this.result.bg&50331648)===0?li=this.result.fg&-134217728|$i.background.rgba>>8&16777215&16777215|50331648:li=this.result.fg&-134217728|this.result.bg&67108863,Ps=!0),!rr&&Ps&&((this.result.fg&50331648)===0?Gn=this.result.bg&-67108864|$i.foreground.rgba>>8&16777215&16777215|50331648:Gn=this.result.bg&-67108864|this.result.fg&67108863,rr=!0)),$i=void 0,this.result.bg=rr?Gn:this.result.bg,this.result.fg=Ps?li:this.result.fg,this.result.ext&=536870911,this.result.ext|=vf<<29&3758096384}},rR=.5,r1=KL||VL?"bottom":"ideographic",oR={"▀":[{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}]},aR={"░":[[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]]},lR={"─":{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`}},Kl={"":{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}};Kl[""]=Kl[""];Kl[""]=Kl[""];function cR(t,e,n,i,s,a,c,d){let h=oR[e];if(h)return uR(t,h,n,i,s,a),!0;let f=aR[e];if(f)return dR(t,f,n,i,s,a),!0;let g=lR[e];if(g)return hR(t,g,n,i,s,a,d),!0;let _=Kl[e];return _?(fR(t,_,n,i,s,a,c,d),!0):!1}function uR(t,e,n,i,s,a){for(let c=0;c<e.length;c++){let d=e[c],h=s/8,f=a/8;t.fillRect(n+d.x*h,i+d.y*f,d.w*h,d.h*f)}}var dw=new Map;function dR(t,e,n,i,s,a){let c=dw.get(e);c||(c=new Map,dw.set(e,c));let d=t.fillStyle;if(typeof d!="string")throw new Error(`Unexpected fillStyle type "${d}"`);let h=c.get(d);if(!h){let f=e[0].length,g=e.length,_=t.canvas.ownerDocument.createElement("canvas");_.width=f,_.height=g;let y=Pn(_.getContext("2d")),w=new ImageData(f,g),S,A,C,N;if(d.startsWith("#"))S=parseInt(d.slice(1,3),16),A=parseInt(d.slice(3,5),16),C=parseInt(d.slice(5,7),16),N=d.length>7&&parseInt(d.slice(7,9),16)||1;else if(d.startsWith("rgba"))[S,A,C,N]=d.substring(5,d.length-1).split(",").map(k=>parseFloat(k));else throw new Error(`Unexpected fillStyle color format "${d}" when drawing pattern glyph`);for(let k=0;k<g;k++)for(let O=0;O<f;O++)w.data[(k*f+O)*4]=S,w.data[(k*f+O)*4+1]=A,w.data[(k*f+O)*4+2]=C,w.data[(k*f+O)*4+3]=e[k][O]*(N*255);y.putImageData(w,0,0),h=Pn(t.createPattern(_,null)),c.set(d,h)}t.fillStyle=h,t.fillRect(n,i,s,a)}function hR(t,e,n,i,s,a,c){t.strokeStyle=t.fillStyle;for(let[d,h]of Object.entries(e)){t.beginPath(),t.lineWidth=c*Number.parseInt(d);let f;if(typeof h=="function"){let g=.15/a*s;f=h(.15,g)}else f=h;for(let g of f.split(" ")){let _=g[0],y=o1[_];if(!y){console.error(`Could not find drawing instructions for "${_}"`);continue}let w=g.substring(1).split(",");!w[0]||!w[1]||y(t,a1(w,s,a,n,i,!0,c))}t.stroke(),t.closePath()}}function fR(t,e,n,i,s,a,c,d){let h=new Path2D;h.rect(n,i,s,a),t.clip(h),t.beginPath();let f=c/12;t.lineWidth=d*f;for(let g of e.d.split(" ")){let _=g[0],y=o1[_];if(!y){console.error(`Could not find drawing instructions for "${_}"`);continue}let w=g.substring(1).split(",");!w[0]||!w[1]||y(t,a1(w,s,a,n,i,!1,d,(e.leftPadding??0)*(f/2),(e.rightPadding??0)*(f/2)))}e.type===1?(t.strokeStyle=t.fillStyle,t.stroke()):t.fill(),t.closePath()}function hw(t,e,n=0){return Math.max(Math.min(t,e),n)}var o1={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 a1(t,e,n,i,s,a,c,d=0,h=0){let f=t.map(g=>parseFloat(g)||parseInt(g));if(f.length<2)throw new Error("Too few arguments for instruction");for(let g=0;g<f.length;g+=2)f[g]*=e-d*c-h*c,a&&f[g]!==0&&(f[g]=hw(Math.round(f[g]+.5)-.5,e,0)),f[g]+=i+d*c;for(let g=1;g<f.length;g+=2)f[g]*=n,a&&f[g]!==0&&(f[g]=hw(Math.round(f[g]+.5)-.5,n,0)),f[g]+=s;return f}var fw=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={}}},pw=class{constructor(){this._data=new fw}set(t,e,n,i,s){this._data.get(t,e)||this._data.set(t,e,new fw),this._data.get(t,e).set(n,i,s)}get(t,e,n,i){var s;return(s=this._data.get(t,e))==null?void 0:s.get(n,i)}clear(){this._data.clear()}},l1=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,i=t.timeRemaining(),s=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),s=t.timeRemaining(),n*1.5>s){i-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-e))}ms`),this._start();return}i=s}this.clear()}},pR=class extends l1{_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())}}},mR=class extends l1{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},gR=!Jm&&"requestIdleCallback"in window?mR:pR,va=class c1{constructor(){this.fg=0,this.bg=0,this.extended=new u1}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 c1;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}},u1=class d1{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 d1(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},vR=globalThis.performance&&typeof globalThis.performance.now=="function",_R=class h1{static create(e){return new h1(e)}constructor(e){this._now=vR&&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}},dr;(t=>{t.None=()=>Es.None;function e(T,I){return _(T,()=>{},0,void 0,!0,void 0,I)}t.defer=e;function n(T){return(I,$=null,j)=>{let M=!1,L;return L=T(R=>{if(!M)return L?L.dispose():M=!0,I.call($,R)},null,j),M&&L.dispose(),L}}t.once=n;function i(T,I,$){return f((j,M=null,L)=>T(R=>j.call(M,I(R)),null,L),$)}t.map=i;function s(T,I,$){return f((j,M=null,L)=>T(R=>{I(R),j.call(M,R)},null,L),$)}t.forEach=s;function a(T,I,$){return f((j,M=null,L)=>T(R=>I(R)&&j.call(M,R),null,L),$)}t.filter=a;function c(T){return T}t.signal=c;function d(...T){return(I,$=null,j)=>{let M=e1(...T.map(L=>L(R=>I.call($,R))));return g(M,j)}}t.any=d;function h(T,I,$,j){let M=$;return i(T,L=>(M=I(M,L),M),j)}t.reduce=h;function f(T,I){let $,j={onWillAddFirstListener(){$=T(M.fire,M)},onDidRemoveLastListener(){$==null||$.dispose()}},M=new ln(j);return I==null||I.add(M),M.event}function g(T,I){return I instanceof Array?I.push(T):I&&I.add(T),T}function _(T,I,$=100,j=!1,M=!1,L,R){let E,z,D,q=0,ce,ge={leakWarningThreshold:L,onWillAddFirstListener(){E=T(we=>{q++,z=I(z,we),j&&!D&&(se.fire(z),z=void 0),ce=()=>{let _e=z;z=void 0,D=void 0,(!j||q>1)&&se.fire(_e),q=0},typeof $=="number"?(clearTimeout(D),D=setTimeout(ce,$)):D===void 0&&(D=0,queueMicrotask(ce))})},onWillRemoveListener(){M&&q>0&&(ce==null||ce())},onDidRemoveLastListener(){ce=void 0,E.dispose()}},se=new ln(ge);return R==null||R.add(se),se.event}t.debounce=_;function y(T,I=0,$){return t.debounce(T,(j,M)=>j?(j.push(M),j):[M],I,void 0,!0,void 0,$)}t.accumulate=y;function w(T,I=(j,M)=>j===M,$){let j=!0,M;return a(T,L=>{let R=j||!I(L,M);return j=!1,M=L,R},$)}t.latch=w;function S(T,I,$){return[t.filter(T,I,$),t.filter(T,j=>!I(j),$)]}t.split=S;function A(T,I=!1,$=[],j){let M=$.slice(),L=T(z=>{M?M.push(z):E.fire(z)});j&&j.add(L);let R=()=>{M==null||M.forEach(z=>E.fire(z)),M=null},E=new ln({onWillAddFirstListener(){L||(L=T(z=>E.fire(z)),j&&j.add(L))},onDidAddFirstListener(){M&&(I?setTimeout(R):R())},onDidRemoveLastListener(){L&&L.dispose(),L=null}});return j&&j.add(E),E.event}t.buffer=A;function C(T,I){return($,j,M)=>{let L=I(new k);return T(function(R){let E=L.evaluate(R);E!==N&&$.call(j,E)},void 0,M)}}t.chain=C;let N=Symbol("HaltChainable");class k{constructor(){this.steps=[]}map(I){return this.steps.push(I),this}forEach(I){return this.steps.push($=>(I($),$)),this}filter(I){return this.steps.push($=>I($)?$:N),this}reduce(I,$){let j=$;return this.steps.push(M=>(j=I(j,M),j)),this}latch(I=($,j)=>$===j){let $=!0,j;return this.steps.push(M=>{let L=$||!I(M,j);return $=!1,j=M,L?M:N}),this}evaluate(I){for(let $ of this.steps)if(I=$(I),I===N)break;return I}}function O(T,I,$=j=>j){let j=(...E)=>R.fire($(...E)),M=()=>T.on(I,j),L=()=>T.removeListener(I,j),R=new ln({onWillAddFirstListener:M,onDidRemoveLastListener:L});return R.event}t.fromNodeEventEmitter=O;function P(T,I,$=j=>j){let j=(...E)=>R.fire($(...E)),M=()=>T.addEventListener(I,j),L=()=>T.removeEventListener(I,j),R=new ln({onWillAddFirstListener:M,onDidRemoveLastListener:L});return R.event}t.fromDOMEventEmitter=P;function H(T){return new Promise(I=>n(T)(I))}t.toPromise=H;function W(T){let I=new ln;return T.then($=>{I.fire($)},()=>{I.fire(void 0)}).finally(()=>{I.dispose()}),I.event}t.fromPromise=W;function U(T,I){return T($=>I.fire($))}t.forward=U;function G(T,I,$){return I($),T(j=>I(j))}t.runAndSubscribe=G;class X{constructor(I,$){this._observable=I,this._counter=0,this._hasChanged=!1;let j={onWillAddFirstListener:()=>{I.addObserver(this)},onDidRemoveLastListener:()=>{I.removeObserver(this)}};this.emitter=new ln(j),$&&$.add(this.emitter)}beginUpdate(I){this._counter++}handlePossibleChange(I){}handleChange(I,$){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 Q(T,I){return new X(T,I).emitter.event}t.fromObservable=Q;function V(T){return(I,$,j)=>{let M=0,L=!1,R={beginUpdate(){M++},endUpdate(){M--,M===0&&(T.reportChanges(),L&&(L=!1,I.call($)))},handlePossibleChange(){},handleChange(){L=!0}};T.addObserver(R),T.reportChanges();let E={dispose(){T.removeObserver(R)}};return j instanceof ya?j.add(E):Array.isArray(j)&&j.push(E),E}}t.fromObservableLight=V})(dr||(dr={}));var nm=class im{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${im._idPool++}`,im.all.add(this)}start(e){this._stopWatch=new _R,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}}};nm.all=new Set,nm._idPool=0;var yR=nm,wR=-1,f1=class p1{constructor(e,n,i=(p1._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=n,this.name=i,this._warnCountdown=0}dispose(){var e;(e=this._stacks)==null||e.clear()}check(e,n){let i=this.threshold;if(i<=0||n<i)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[a,c]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${c}):`;console.warn(d),console.warn(a);let h=new xR(d,a);this._errorHandler(h)}return()=>{let a=this._stacks.get(e.value)||0;this._stacks.set(e.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,n=0;for(let[i,s]of this._stacks)(!e||n<s)&&(e=[i,s],n=s);return e}};f1._idPool=1;var bR=f1,SR=class m1{constructor(e){this.value=e}static create(){let e=new Error;return new m1(e.stack??"")}print(){console.warn(this.value.split(`
|
|
93
|
-
`).slice(2).join(`
|
|
94
|
-
`))}},xR=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},CR=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},kR=0,_f=class{constructor(t){this.value=t,this.id=kR++}},ER=2,NR,ln=class{constructor(t){var e,n,i,s;this._size=0,this._options=t,this._leakageMon=(e=this._options)!=null&&e.leakWarningThreshold?new bR((t==null?void 0:t.onListenerError)??gf,((n=this._options)==null?void 0:n.leakWarningThreshold)??wR):void 0,this._perfMon=(i=this._options)!=null&&i._profName?new yR(this._options._profName):void 0,this._deliveryQueue=(s=this._options)==null?void 0:s.deliveryQueue}dispose(){var t,e,n,i;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),(i=this._leakageMon)==null||i.dispose())}get event(){return this._event??(this._event=(t,e,n)=>{var c,d,h,f,g;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 y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],w=new CR(`${_}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((c=this._options)==null?void 0:c.onListenerError)||gf)(w),Es.None}if(this._disposed)return Es.None;e&&(t=t.bind(e));let i=new _f(t),s;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=SR.create(),s=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof _f?(this._deliveryQueue??(this._deliveryQueue=new LR),this._listeners=[this._listeners,i]):this._listeners.push(i):((h=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||h.call(d,this),this._listeners=i,(g=(f=this._options)==null?void 0:f.onDidAddFirstListener)==null||g.call(f,this)),this._size++;let a=wi(()=>{s==null||s(),this._removeListener(i)});return n instanceof ya?n.add(a):Array.isArray(n)&&n.push(a),a}),this._event}_removeListener(t){var s,a,c,d;if((a=(s=this._options)==null?void 0:s.onWillRemoveListener)==null||a.call(s,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(d=(c=this._options)==null?void 0:c.onDidRemoveLastListener)==null||d.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 i=this._deliveryQueue.current===this;if(this._size*ER<=e.length){let h=0;for(let f=0;f<e.length;f++)e[f]?e[h++]=e[f]:i&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=h}}_deliver(t,e){var i;if(!t)return;let n=((i=this._options)==null?void 0:i.onListenerError)||gf;if(!n){t.value(e);return}try{t.value(e)}catch(s){n(s)}}_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,i,s;if((e=this._deliveryQueue)!=null&&e.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(i=this._perfMon)==null||i.start(this._size),this._listeners)if(this._listeners instanceof _f)this._deliver(this._listeners,t);else{let a=this._deliveryQueue;a.enqueue(this,t,this._listeners.length),this._deliverQueue(a)}(s=this._perfMon)==null||s.stop()}hasListeners(){return this._size>0}},LR=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}},mw={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}},yl=2,wl,zr=class pa{constructor(e,n,i){this._document=e,this._config=n,this._unicodeService=i,this._didWarmUp=!1,this._cacheMap=new pw,this._cacheMapCombined=new pw,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new va,this._textureSize=512,this._onAddTextureAtlasCanvas=new ln,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new ln,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=g1(e,this._config.deviceCellWidth*4+yl*2,this._config.deviceCellHeight+yl*2),this._tmpCtx=Pn(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 gR;for(let n=33;n<126;n++)e.enqueue(()=>{if(!this._cacheMap.get(n,0,0,0)){let i=this._drawToCache(n,0,0,0,!1,void 0);this._cacheMap.set(n,0,0,0,i)}})}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(pa.maxAtlasPages&&this._pages.length>=Math.max(4,pa.maxAtlasPages)){let n=this._pages.filter(f=>f.canvas.width*2<=(pa.maxTextureSize||4096)).sort((f,g)=>g.canvas.width!==f.canvas.width?g.canvas.width-f.canvas.width:g.percentageUsed-f.percentageUsed),i=-1,s=0;for(let f=0;f<n.length;f++)if(n[f].canvas.width!==s)i=f,s=n[f].canvas.width;else if(f-i===3)break;let a=n.slice(i,i+4),c=a.map(f=>f.glyphs[0].texturePage).sort((f,g)=>f>g?1:-1),d=this.pages.length-a.length,h=this._mergePages(a,d);h.version++;for(let f=c.length-1;f>=0;f--)this._deletePage(c[f]);this.pages.push(h),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(h.canvas)}let e=new yf(this._document,this._textureSize);return this._pages.push(e),this._activePages.push(e),this._onAddTextureAtlasCanvas.fire(e.canvas),e}_mergePages(e,n){let i=e[0].canvas.width*2,s=new yf(this._document,i,e);for(let[a,c]of e.entries()){let d=a*c.canvas.width%i,h=Math.floor(a/2)*c.canvas.height;s.ctx.drawImage(c.canvas,d,h);for(let g of c.glyphs)g.texturePage=n,g.sizeClipSpace.x=g.size.x/i,g.sizeClipSpace.y=g.size.y/i,g.texturePosition.x+=d,g.texturePosition.y+=h,g.texturePositionClipSpace.x=g.texturePosition.x/i,g.texturePositionClipSpace.y=g.texturePosition.y/i;this._onRemoveTextureAtlasCanvas.fire(c.canvas);let f=this._activePages.indexOf(c);f!==-1&&this._activePages.splice(f,1)}return s}_deletePage(e){this._pages.splice(e,1);for(let n=e;n<this._pages.length;n++){let i=this._pages[n];for(let s of i.glyphs)s.texturePage--;i.version++}}getRasterizedGlyphCombinedChar(e,n,i,s,a,c){return this._getFromCacheMap(this._cacheMapCombined,e,n,i,s,a,c)}getRasterizedGlyph(e,n,i,s,a,c){return this._getFromCacheMap(this._cacheMap,e,n,i,s,a,c)}_getFromCacheMap(e,n,i,s,a,c,d){return wl=e.get(n,i,s,a),wl||(wl=this._drawToCache(n,i,s,a,c,d),e.set(n,i,s,a,wl)),wl}_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,i,s){if(this._config.allowTransparency)return us;let a;switch(e){case 16777216:case 33554432:a=this._getColorFromAnsiIndex(n);break;case 50331648:let c=va.toColorRGB(n);a=ki.toColor(c[0],c[1],c[2]);break;case 0:default:i?a=Il.opaque(this._config.colors.foreground):a=this._config.colors.background;break}return this._config.allowTransparency||(a=Il.opaque(a)),a}_getForegroundColor(e,n,i,s,a,c,d,h,f,g){let _=this._getMinimumContrastColor(e,n,i,s,a,c,d,f,h,g);if(_)return _;let y;switch(a){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&f&&c<8&&(c+=8),y=this._getColorFromAnsiIndex(c);break;case 50331648:let w=va.toColorRGB(c);y=ki.toColor(w[0],w[1],w[2]);break;case 0:default:d?y=this._config.colors.background:y=this._config.colors.foreground}return this._config.allowTransparency&&(y=Il.opaque(y)),h&&(y=Il.multiplyOpacity(y,rR)),y}_resolveBackgroundRgba(e,n,i){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(n).rgba;case 50331648:return n<<8;case 0:default:return i?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,n,i,s){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&s&&n<8&&(n+=8),this._getColorFromAnsiIndex(n).rgba;case 50331648:return n<<8;case 0:default:return i?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,n,i,s,a,c,d,h,f,g){if(this._config.minimumContrastRatio===1||g)return;let _=this._getContrastCache(f),y=_.getColor(e,s);if(y!==void 0)return y||void 0;let w=this._resolveBackgroundRgba(n,i,d),S=this._resolveForegroundRgba(a,c,d,h),A=ko.ensureContrastRatio(w,S,this._config.minimumContrastRatio/(f?2:1));if(!A){_.setColor(e,s,null);return}let C=ki.toColor(A>>24&255,A>>16&255,A>>8&255);return _.setColor(e,s,C),C}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(e,n,i,s,a,c){let d=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(d.length,2)+yl*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<h&&(this._tmpCanvas.width=h);let f=Math.min(this._config.deviceCellHeight+yl*4,this._textureSize);if(this._tmpCanvas.height<f&&(this._tmpCanvas.height=f),this._tmpCtx.save(),this._workAttributeData.fg=i,this._workAttributeData.bg=n,this._workAttributeData.extended.ext=s,!!this._workAttributeData.isInvisible())return mw;let g=!!this._workAttributeData.isBold(),_=!!this._workAttributeData.isInverse(),y=!!this._workAttributeData.isDim(),w=!!this._workAttributeData.isItalic(),S=!!this._workAttributeData.isUnderline(),A=!!this._workAttributeData.isStrikethrough(),C=!!this._workAttributeData.isOverline(),N=this._workAttributeData.getFgColor(),k=this._workAttributeData.getFgColorMode(),O=this._workAttributeData.getBgColor(),P=this._workAttributeData.getBgColorMode();if(_){let z=N;N=O,O=z;let D=k;k=P,P=D}let H=this._getBackgroundColor(P,O,_,y);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=H.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let W=g?this._config.fontWeightBold:this._config.fontWeight,U=w?"italic":"";this._tmpCtx.font=`${U} ${W} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=r1;let G=d.length===1&&Zm(d.charCodeAt(0)),X=d.length===1&&QL(d.charCodeAt(0)),Q=this._getForegroundColor(n,P,O,i,k,N,_,y,g,s1(d.charCodeAt(0)));this._tmpCtx.fillStyle=Q.css;let V=X?0:yl*2,T=!1;this._config.customGlyphs!==!1&&(T=cR(this._tmpCtx,d,V,V,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let I=!G,$;if(typeof e=="number"?$=this._unicodeService.wcwidth(e):$=this._unicodeService.getStringCellWidth(e),S){this._tmpCtx.save();let z=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),D=z%2===1?.5:0;if(this._tmpCtx.lineWidth=z,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())I=!1,this._tmpCtx.strokeStyle=`rgb(${va.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{I=!1;let _e=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&_e<8&&(_e+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(_e).css}this._tmpCtx.beginPath();let q=V,ce=Math.ceil(V+this._config.deviceCharHeight)-D-(a?z*2:0),ge=ce+z,se=ce+z*2,we=this._workAttributeData.getUnderlineVariantOffset();for(let _e=0;_e<$;_e++){this._tmpCtx.save();let fe=q+_e*this._config.deviceCellWidth,ie=q+(_e+1)*this._config.deviceCellWidth,de=fe+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(fe,ce),this._tmpCtx.lineTo(ie,ce),this._tmpCtx.moveTo(fe,se),this._tmpCtx.lineTo(ie,se);break;case 3:let me=z<=1?se:Math.ceil(V+this._config.deviceCharHeight-z/2)-D,Ee=z<=1?ce:Math.ceil(V+this._config.deviceCharHeight+z/2)-D,Se=new Path2D;Se.rect(fe,ce,this._config.deviceCellWidth,se-ce),this._tmpCtx.clip(Se),this._tmpCtx.moveTo(fe-this._config.deviceCellWidth/2,ge),this._tmpCtx.bezierCurveTo(fe-this._config.deviceCellWidth/2,Ee,fe,Ee,fe,ge),this._tmpCtx.bezierCurveTo(fe,me,de,me,de,ge),this._tmpCtx.bezierCurveTo(de,Ee,ie,Ee,ie,ge),this._tmpCtx.bezierCurveTo(ie,me,ie+this._config.deviceCellWidth/2,me,ie+this._config.deviceCellWidth/2,ge);break;case 4:let xe=we===0?0:we>=z?z*2-we:z-we;we>=z||xe===0?(this._tmpCtx.setLineDash([Math.round(z),Math.round(z)]),this._tmpCtx.moveTo(fe+xe,ce),this._tmpCtx.lineTo(ie,ce)):(this._tmpCtx.setLineDash([Math.round(z),Math.round(z)]),this._tmpCtx.moveTo(fe,ce),this._tmpCtx.lineTo(fe+xe,ce),this._tmpCtx.moveTo(fe+xe+z,ce),this._tmpCtx.lineTo(ie,ce)),we=iR(ie-fe,z,we);break;case 5:let Ye=.6,Le=.3,ze=ie-fe,He=Math.floor(Ye*ze),_t=Math.floor(Le*ze),at=ze-He-_t;this._tmpCtx.setLineDash([He,_t,at]),this._tmpCtx.moveTo(fe,ce),this._tmpCtx.lineTo(ie,ce);break;case 1:default:this._tmpCtx.moveTo(fe,ce),this._tmpCtx.lineTo(ie,ce);break}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!T&&this._config.fontSize>=12&&!this._config.allowTransparency&&d!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let _e=this._tmpCtx.measureText(d);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in _e&&_e.actualBoundingBoxDescent>0){this._tmpCtx.save();let fe=new Path2D;fe.rect(q,ce-Math.ceil(z/2),this._config.deviceCellWidth*$,se-ce+Math.ceil(z/2)),this._tmpCtx.clip(fe),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=H.css,this._tmpCtx.strokeText(d,V,V+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(C){let z=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),D=z%2===1?.5:0;this._tmpCtx.lineWidth=z,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(V,V+D),this._tmpCtx.lineTo(V+this._config.deviceCharWidth*$,V+D),this._tmpCtx.stroke()}if(T||this._tmpCtx.fillText(d,V,V+this._config.deviceCharHeight),d==="_"&&!this._config.allowTransparency){let z=wf(this._tmpCtx.getImageData(V,V,this._config.deviceCellWidth,this._config.deviceCellHeight),H,Q,I);if(z)for(let D=1;D<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=H.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(d,V,V+this._config.deviceCharHeight-D),z=wf(this._tmpCtx.getImageData(V,V,this._config.deviceCellWidth,this._config.deviceCellHeight),H,Q,I),!!z);D++);}if(A){let z=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),D=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=z,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(V,V+Math.floor(this._config.deviceCharHeight/2)-D),this._tmpCtx.lineTo(V+this._config.deviceCharWidth*$,V+Math.floor(this._config.deviceCharHeight/2)-D),this._tmpCtx.stroke()}this._tmpCtx.restore();let j=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),M;if(this._config.allowTransparency?M=RR(j):M=wf(j,H,Q,I),M)return mw;let L=this._findGlyphBoundingBox(j,this._workBoundingBox,h,X,T,V),R,E;for(;;){if(this._activePages.length===0){let z=this._createNewPage();R=z,E=z.currentRow,E.height=L.size.y;break}R=this._activePages[this._activePages.length-1],E=R.currentRow;for(let z of this._activePages)L.size.y<=z.currentRow.height&&(R=z,E=z.currentRow);for(let z=this._activePages.length-1;z>=0;z--)for(let D of this._activePages[z].fixedRows)D.height<=E.height&&L.size.y<=D.height&&(R=this._activePages[z],E=D);if(L.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new yf(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),R=this._overflowSizePage,E=this._overflowSizePage.currentRow,E.x+L.size.x>=R.canvas.width&&(E.x=0,E.y+=E.height,E.height=0);break}if(E.y+L.size.y>=R.canvas.height||E.height>L.size.y+2){let z=!1;if(R.currentRow.y+R.currentRow.height+L.size.y>=R.canvas.height){let D;for(let q of this._activePages)if(q.currentRow.y+q.currentRow.height+L.size.y<q.canvas.height){D=q;break}if(D)R=D;else if(pa.maxAtlasPages&&this._pages.length>=pa.maxAtlasPages&&E.y+L.size.y<=R.canvas.height&&E.height>=L.size.y&&E.x+L.size.x<=R.canvas.width)z=!0;else{let q=this._createNewPage();R=q,E=q.currentRow,E.height=L.size.y,z=!0}}z||(R.currentRow.height>0&&R.fixedRows.push(R.currentRow),E={x:0,y:R.currentRow.y+R.currentRow.height,height:L.size.y},R.fixedRows.push(E),R.currentRow={x:0,y:E.y+E.height,height:0})}if(E.x+L.size.x<=R.canvas.width)break;E===R.currentRow?(E.x=0,E.y+=E.height,E.height=0):R.fixedRows.splice(R.fixedRows.indexOf(E),1)}return L.texturePage=this._pages.indexOf(R),L.texturePosition.x=E.x,L.texturePosition.y=E.y,L.texturePositionClipSpace.x=E.x/R.canvas.width,L.texturePositionClipSpace.y=E.y/R.canvas.height,L.sizeClipSpace.x/=R.canvas.width,L.sizeClipSpace.y/=R.canvas.height,E.height=Math.max(E.height,L.size.y),E.x+=L.size.x,R.ctx.putImageData(j,L.texturePosition.x-this._workBoundingBox.left,L.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,L.size.x,L.size.y),R.addGlyph(L),R.version++,L}_findGlyphBoundingBox(e,n,i,s,a,c){n.top=0;let d=s?this._config.deviceCellHeight:this._tmpCanvas.height,h=s?this._config.deviceCellWidth:i,f=!1;for(let g=0;g<d;g++){for(let _=0;_<h;_++){let y=g*this._tmpCanvas.width*4+_*4+3;if(e.data[y]!==0){n.top=g,f=!0;break}}if(f)break}n.left=0,f=!1;for(let g=0;g<c+h;g++){for(let _=0;_<d;_++){let y=_*this._tmpCanvas.width*4+g*4+3;if(e.data[y]!==0){n.left=g,f=!0;break}}if(f)break}n.right=h,f=!1;for(let g=c+h-1;g>=c;g--){for(let _=0;_<d;_++){let y=_*this._tmpCanvas.width*4+g*4+3;if(e.data[y]!==0){n.right=g,f=!0;break}}if(f)break}n.bottom=d,f=!1;for(let g=d-1;g>=0;g--){for(let _=0;_<h;_++){let y=g*this._tmpCanvas.width*4+_*4+3;if(e.data[y]!==0){n.bottom=g,f=!0;break}}if(f)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+(s||a?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-n.top+c+(s||a?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},yf=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 i of n)this._glyphs.push(...i.glyphs),this._usedPixels+=i._usedPixels;this.canvas=g1(t,e,e),this.ctx=Pn(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 wf(t,e,n,i){let s=e.rgba>>>24,a=e.rgba>>>16&255,c=e.rgba>>>8&255,d=n.rgba>>>24,h=n.rgba>>>16&255,f=n.rgba>>>8&255,g=Math.floor((Math.abs(s-d)+Math.abs(a-h)+Math.abs(c-f))/12),_=!0;for(let y=0;y<t.data.length;y+=4)t.data[y]===s&&t.data[y+1]===a&&t.data[y+2]===c||i&&Math.abs(t.data[y]-s)+Math.abs(t.data[y+1]-a)+Math.abs(t.data[y+2]-c)<g?t.data[y+3]=0:_=!1;return _}function RR(t){for(let e=0;e<t.data.length;e+=4)if(t.data[e+3]>0)return!1;return!0}function g1(t,e,n){let i=t.createElement("canvas");return i.width=e,i.height=n,i}function AR(t,e,n,i,s,a,c,d){let h={foreground:a.foreground,background:a.background,cursor:us,cursorAccent:us,selectionForeground:us,selectionBackgroundTransparent:us,selectionBackgroundOpaque:us,selectionInactiveBackgroundTransparent:us,selectionInactiveBackgroundOpaque:us,overviewRulerBorder:us,scrollbarSliderBackground:us,scrollbarSliderHoverBackground:us,scrollbarSliderActiveBackground:us,ansi:a.ansi.slice(),contrastCache:a.contrastCache,halfContrastCache:a.halfContrastCache};return{customGlyphs:s.customGlyphs,devicePixelRatio:c,deviceMaxTextureSize:d,letterSpacing:s.letterSpacing,lineHeight:s.lineHeight,deviceCellWidth:t,deviceCellHeight:e,deviceCharWidth:n,deviceCharHeight:i,fontFamily:s.fontFamily,fontSize:s.fontSize,fontWeight:s.fontWeight,fontWeightBold:s.fontWeightBold,allowTransparency:s.allowTransparency,drawBoldTextInBrightColors:s.drawBoldTextInBrightColors,minimumContrastRatio:s.minimumContrastRatio,colors:h}}function gw(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 MR(t){return(t&50331648)===16777216||(t&50331648)===33554432}var fs=[];function v1(t,e,n,i,s,a,c,d,h){let f=AR(i,s,a,c,e,n,d,h);for(let y=0;y<fs.length;y++){let w=fs[y],S=w.ownedBy.indexOf(t);if(S>=0){if(gw(w.config,f))return w.atlas;w.ownedBy.length===1?(w.atlas.dispose(),fs.splice(y,1)):w.ownedBy.splice(S,1);break}}for(let y=0;y<fs.length;y++){let w=fs[y];if(gw(w.config,f))return w.ownedBy.push(t),w.atlas}let g=t._core,_={atlas:new zr(document,f,g.unicodeService),config:f,ownedBy:[t]};return fs.push(_),_.atlas}function vw(t){for(let e=0;e<fs.length;e++){let n=fs[e].ownedBy.indexOf(t);if(n!==-1){fs[e].ownedBy.length===1?(fs[e].atlas.dispose(),fs.splice(e,1)):fs[e].ownedBy.splice(n,1);break}}}var vu=600,jR=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=vu){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=vu-(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=vu-(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})},vu)},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 _w(t,e,n){let i=new e.ResizeObserver(s=>{let a=s.find(h=>h.target===t);if(!a)return;if(!("devicePixelContentBoxSize"in a)){i==null||i.disconnect(),i=void 0;return}let c=a.devicePixelContentBoxSize[0].inlineSize,d=a.devicePixelContentBoxSize[0].blockSize;c>0&&d>0&&n(c,d)});try{i.observe(t,{box:["device-pixel-content-box"]})}catch{i.disconnect(),i=void 0}return wi(()=>i==null?void 0:i.disconnect())}function TR(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}var yw=class _1 extends va{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new u1,this.combinedData=""}static fromCharData(e){let n=new _1;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?TR(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 i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let s=e[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(i-55296)*1024+s-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()]}},y1=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function w1(t,e,n){let i=Pn(t.createProgram());if(t.attachShader(i,Pn(ww(t,t.VERTEX_SHADER,e))),t.attachShader(i,Pn(ww(t,t.FRAGMENT_SHADER,n))),t.linkProgram(i),t.getProgramParameter(i,t.LINK_STATUS))return i;console.error(t.getProgramInfoLog(i)),t.deleteProgram(i)}function ww(t,e,n){let i=Pn(t.createShader(e));if(t.shaderSource(i,n),t.compileShader(i),t.getShaderParameter(i,t.COMPILE_STATUS))return i;console.error(t.getShaderInfoLog(i)),t.deleteShader(i)}function PR(t,e){let n=Math.min(t.length*2,e),i=new Float32Array(n);for(let s=0;s<t.length;s++)i[s]=t[s];return i}var IR=class{constructor(t){this.texture=t,this.version=-1}},DR=`#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 BR(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 Fr=11,ca=Fr*Float32Array.BYTES_PER_ELEMENT,OR=2,bn=0,on,bf=0,bl=0,$R=class extends Es{constructor(t,e,n,i){super(),this._terminal=t,this._gl=e,this._dimensions=n,this._optionsService=i,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let s=this._gl;zr.maxAtlasPages===void 0&&(zr.maxAtlasPages=Math.min(32,Pn(s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS))),zr.maxTextureSize=Pn(s.getParameter(s.MAX_TEXTURE_SIZE))),this._program=Pn(w1(s,DR,BR(zr.maxAtlasPages))),this._register(wi(()=>s.deleteProgram(this._program))),this._projectionLocation=Pn(s.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=Pn(s.getUniformLocation(this._program,"u_resolution")),this._textureLocation=Pn(s.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),c=s.createBuffer();this._register(wi(()=>s.deleteBuffer(c))),s.bindBuffer(s.ARRAY_BUFFER,c),s.bufferData(s.ARRAY_BUFFER,a,s.STATIC_DRAW),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let d=new Uint8Array([0,1,2,3]),h=s.createBuffer();this._register(wi(()=>s.deleteBuffer(h))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,h),s.bufferData(s.ELEMENT_ARRAY_BUFFER,d,s.STATIC_DRAW),this._attributesBuffer=Pn(s.createBuffer()),this._register(wi(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,2,s.FLOAT,!1,ca,0),s.vertexAttribDivisor(2,1),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,s.FLOAT,!1,ca,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(3,1),s.enableVertexAttribArray(4),s.vertexAttribPointer(4,1,s.FLOAT,!1,ca,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(4,1),s.enableVertexAttribArray(5),s.vertexAttribPointer(5,2,s.FLOAT,!1,ca,5*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(5,1),s.enableVertexAttribArray(6),s.vertexAttribPointer(6,2,s.FLOAT,!1,ca,7*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(6,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,ca,9*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.useProgram(this._program);let f=new Int32Array(zr.maxAtlasPages);for(let g=0;g<zr.maxAtlasPages;g++)f[g]=g;s.uniform1iv(this._textureLocation,f),s.uniformMatrix4fv(this._projectionLocation,!1,y1),this._atlasTextures=[];for(let g=0;g<zr.maxAtlasPages;g++){let _=new IR(Pn(s.createTexture()));this._register(wi(()=>s.deleteTexture(_.texture))),s.activeTexture(s.TEXTURE0+g),s.bindTexture(s.TEXTURE_2D,_.texture),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[g]=_}s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return this._atlas?this._atlas.beginFrame():!0}updateCell(t,e,n,i,s,a,c,d,h){this._updateCell(this._vertices.attributes,t,e,n,i,s,a,c,d,h)}_updateCell(t,e,n,i,s,a,c,d,h,f){if(bn=(n*this._terminal.cols+e)*Fr,i===0||i===void 0){t.fill(0,bn,bn+Fr-1-OR);return}this._atlas&&(d&&d.length>1?on=this._atlas.getRasterizedGlyphCombinedChar(d,s,a,c,!1,this._terminal.element):on=this._atlas.getRasterizedGlyph(i,s,a,c,!1,this._terminal.element),bf=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),s!==f&&on.offset.x>bf?(bl=on.offset.x-bf,t[bn]=-(on.offset.x-bl)+this._dimensions.device.char.left,t[bn+1]=-on.offset.y+this._dimensions.device.char.top,t[bn+2]=(on.size.x-bl)/this._dimensions.device.canvas.width,t[bn+3]=on.size.y/this._dimensions.device.canvas.height,t[bn+4]=on.texturePage,t[bn+5]=on.texturePositionClipSpace.x+bl/this._atlas.pages[on.texturePage].canvas.width,t[bn+6]=on.texturePositionClipSpace.y,t[bn+7]=on.sizeClipSpace.x-bl/this._atlas.pages[on.texturePage].canvas.width,t[bn+8]=on.sizeClipSpace.y):(t[bn]=-on.offset.x+this._dimensions.device.char.left,t[bn+1]=-on.offset.y+this._dimensions.device.char.top,t[bn+2]=on.size.x/this._dimensions.device.canvas.width,t[bn+3]=on.size.y/this._dimensions.device.canvas.height,t[bn+4]=on.texturePage,t[bn+5]=on.texturePositionClipSpace.x,t[bn+6]=on.texturePositionClipSpace.y,t[bn+7]=on.sizeClipSpace.x,t[bn+8]=on.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&tR(i,h,on.size.x,this._dimensions.device.cell.width)&&(t[bn+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let t=this._terminal,e=t.cols*t.rows*Fr;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 i=0;i<t.rows;i++)for(let s=0;s<t.cols;s++)this._vertices.attributes[n+9]=s/t.cols,this._vertices.attributes[n+10]=i/t.rows,n+=Fr}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],i=0;for(let s=0;s<t.lineLengths.length;s++){let a=s*this._terminal.cols*Fr,c=this._vertices.attributes.subarray(a,a+t.lineLengths[s]*Fr);n.set(c,i),i+=c.length}e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,n.subarray(0,i),e.STREAM_DRAW);for(let s=0;s<this._atlas.pages.length;s++)this._atlas.pages[s].version!==this._atlasTextures[s].version&&this._bindAtlasPageTexture(e,this._atlas,s);e.drawElementsInstanced(e.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,i/Fr)}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}},zR=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,i=!1){if(this.selectionStart=e,this.selectionEnd=n,!e||!n||e[0]===n[0]&&e[1]===n[1]){this.clear();return}let s=t.buffers.active.ydisp,a=e[1]-s,c=n[1]-s,d=Math.max(a,0),h=Math.min(c,t.rows-1);if(d>=t.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=a,this.viewportEndRow=c,this.viewportCappedStartRow=d,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 FR(){return new zR}var Ku=4,Pu=1,Iu=2,Sf=3,HR=2147483648,UR=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=FR()}resize(t,e){let n=t*e*Ku;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)}},WR=`#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
|
-
}`,qR=`#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
|
-
}`,ar=8,xf=ar*Float32Array.BYTES_PER_ELEMENT,KR=20*ar,bw=class{constructor(){this.attributes=new Float32Array(KR),this.count=0}},or=0,Sw=0,xw=0,Cw=0,kw=0,Ew=0,Nw=0,VR=class extends Es{constructor(t,e,n,i){super(),this._terminal=t,this._gl=e,this._dimensions=n,this._themeService=i,this._vertices=new bw,this._verticesCursor=new bw;let s=this._gl;this._program=Pn(w1(s,WR,qR)),this._register(wi(()=>s.deleteProgram(this._program))),this._projectionLocation=Pn(s.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),c=s.createBuffer();this._register(wi(()=>s.deleteBuffer(c))),s.bindBuffer(s.ARRAY_BUFFER,c),s.bufferData(s.ARRAY_BUFFER,a,s.STATIC_DRAW),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let d=new Uint8Array([0,1,2,3]),h=s.createBuffer();this._register(wi(()=>s.deleteBuffer(h))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,h),s.bufferData(s.ELEMENT_ARRAY_BUFFER,d,s.STATIC_DRAW),this._attributesBuffer=Pn(s.createBuffer()),this._register(wi(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,s.FLOAT,!1,xf,0),s.vertexAttribDivisor(0,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,xf,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,4,s.FLOAT,!1,xf,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(2,1),this._updateCachedColors(i.colors),this._register(this._themeService.onChangeColors(f=>{this._updateCachedColors(f),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,y1),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,i=1,s,a,c,d,h,f,g,_,y,w,S;for(s=0;s<e.rows;s++){for(c=-1,d=0,h=0,f=!1,a=0;a<e.cols;a++)g=(s*e.cols+a)*Ku,_=t.cells[g+Pu],y=t.cells[g+Iu],w=!!(y&67108864),(_!==d||y!==h&&(f||w))&&((d!==0||f&&h!==0)&&(S=i++*ar,this._updateRectangle(n,S,h,d,c,a,s)),c=a,d=_,h=y,f=w);(d!==0||f&&h!==0)&&(S=i++*ar,this._updateRectangle(n,S,h,d,c,e.cols,s))}n.count=i}updateCursor(t){let e=this._verticesCursor,n=t.cursor;if(!n||n.style==="block"){e.count=0;return}let i,s=0;(n.style==="bar"||n.style==="outline")&&(i=s++*ar,this._addRectangleFloat(e.attributes,i,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")&&(i=s++*ar,this._addRectangleFloat(e.attributes,i,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"&&(i=s++*ar,this._addRectangleFloat(e.attributes,i,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),i=s++*ar,this._addRectangleFloat(e.attributes,i,(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=s}_updateRectangle(t,e,n,i,s,a,c){if(n&67108864)switch(n&50331648){case 16777216:case 33554432:or=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:or=(n&16777215)<<8;break;case 0:default:or=this._themeService.colors.foreground.rgba}else switch(i&50331648){case 16777216:case 33554432:or=this._themeService.colors.ansi[i&255].rgba;break;case 50331648:or=(i&16777215)<<8;break;case 0:default:or=this._themeService.colors.background.rgba}t.attributes.length<e+4&&(t.attributes=PR(t.attributes,this._terminal.rows*this._terminal.cols*ar)),Sw=s*this._dimensions.device.cell.width,xw=c*this._dimensions.device.cell.height,Cw=(or>>24&255)/255,kw=(or>>16&255)/255,Ew=(or>>8&255)/255,Nw=1,this._addRectangle(t.attributes,e,Sw,xw,(a-s)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,Cw,kw,Ew,Nw)}_addRectangle(t,e,n,i,s,a,c,d,h,f){t[e]=n/this._dimensions.device.canvas.width,t[e+1]=i/this._dimensions.device.canvas.height,t[e+2]=s/this._dimensions.device.canvas.width,t[e+3]=a/this._dimensions.device.canvas.height,t[e+4]=c,t[e+5]=d,t[e+6]=h,t[e+7]=f}_addRectangleFloat(t,e,n,i,s,a,c){t[e]=n/this._dimensions.device.canvas.width,t[e+1]=i/this._dimensions.device.canvas.height,t[e+2]=s/this._dimensions.device.canvas.width,t[e+3]=a/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])}},YR=class extends Es{constructor(t,e,n,i,s,a,c,d){super(),this._container=e,this._alpha=s,this._coreBrowserService=a,this._optionsService=c,this._themeService=d,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=i.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(h=>{this._refreshCharAtlas(t,h),this.reset(t)})),this._register(wi(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=Pn(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,i=!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=v1(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,i){this._alpha?this._ctx.clearRect(t*this._deviceCellWidth,e*this._deviceCellHeight,n*this._deviceCellWidth,i*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(t*this._deviceCellWidth,e*this._deviceCellHeight,n*this._deviceCellWidth,i*this._deviceCellHeight))}_fillCharTrueColor(t,e,n,i){this._ctx.font=this._getFont(t,!1,!1),this._ctx.textBaseline=r1,this._clipCell(n,i,e.getWidth()),this._ctx.fillText(e.getChars(),n*this._deviceCellWidth+this._deviceCharLeft,i*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 i=e?t.options.fontWeightBold:t.options.fontWeight;return`${n?"italic":""} ${i} ${t.options.fontSize*this._coreBrowserService.dpr}px ${t.options.fontFamily}`}},GR=class extends YR{constructor(t,e,n,i,s,a,c){super(n,t,"link",e,!0,s,a,c),this._register(i.onShowLinkUnderline(d=>this._handleShowLinkUnderline(d))),this._register(i.onHideLinkUnderline(d=>this._handleHideLinkUnderline(d)))}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&&MR(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()}},So=typeof window=="object"?window:globalThis,sm=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ln,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ln,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 i=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(i,e),this._onDidChangeZoomLevel.fire(i)}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 i=this.getWindowId(n);this.mapWindowIdToFullScreen.set(i,e),this._onDidChangeFullscreen.fire(i)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};sm.INSTANCE=new sm;var b1=sm;function XR(t,e,n){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",n)}b1.INSTANCE.onDidChangeZoomLevel;b1.INSTANCE.onDidChangeFullscreen;var ja=typeof navigator=="object"?navigator.userAgent:"";ja.indexOf("Firefox")>=0;ja.indexOf("AppleWebKit")>=0;var QR=ja.indexOf("Chrome")>=0;!QR&&ja.indexOf("Safari")>=0;ja.indexOf("Electron/")>=0;ja.indexOf("Android")>=0;var Cf=!1;if(typeof So.matchMedia=="function"){let t=So.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=So.matchMedia("(display-mode: fullscreen)");Cf=t.matches,XR(So,t,({matches:n})=>{Cf&&e.matches||(Cf=n)})}var _a="en",kf=!1,S1=!1,_u,Du=_a,Lw=_a,JR,Cs,Eo=globalThis,di,I0;typeof Eo.vscode<"u"&&typeof Eo.vscode.process<"u"?di=Eo.vscode.process:typeof process<"u"&&typeof((I0=process==null?void 0:process.versions)==null?void 0:I0.node)=="string"&&(di=process);var D0,ZR=typeof((D0=di==null?void 0:di.versions)==null?void 0:D0.electron)=="string",eA=ZR&&(di==null?void 0:di.type)==="renderer",B0;if(typeof di=="object"){di.platform,di.platform,kf=di.platform==="linux",kf&&di.env.SNAP&&di.env.SNAP_REVISION,di.env.CI||di.env.BUILD_ARTIFACTSTAGINGDIRECTORY,_u=_a,Du=_a;let t=di.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);_u=e.userLocale,Lw=e.osLocale,Du=e.resolvedLanguage||_a,JR=(B0=e.languagePack)==null?void 0:B0.translationsConfigFile}catch{}S1=!0}else typeof navigator=="object"&&!eA?(Cs=navigator.userAgent,Cs.indexOf("Windows")>=0,Cs.indexOf("Macintosh")>=0,(Cs.indexOf("Macintosh")>=0||Cs.indexOf("iPad")>=0||Cs.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,kf=Cs.indexOf("Linux")>=0,(Cs==null?void 0:Cs.indexOf("Mobi"))>=0,Du=globalThis._VSCODE_NLS_LANGUAGE||_a,_u=navigator.language.toLowerCase(),Lw=_u):console.error("Unable to resolve platform.");var Rw=S1,qs=Cs,Br=Du,tA;(t=>{function e(){return Br}t.value=e;function n(){return Br.length===2?Br==="en":Br.length>=3?Br[0]==="e"&&Br[1]==="n"&&Br[2]==="-":!1}t.isDefaultVariant=n;function i(){return Br==="en"}t.isDefault=i})(tA||(tA={}));var nA=typeof Eo.postMessage=="function"&&!Eo.importScripts;(()=>{if(nA){let t=[];Eo.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let i=0,s=t.length;i<s;i++){let a=t[i];if(a.id===n.data.vscodeScheduleAsyncWork){t.splice(i,1),a.callback();return}}});let e=0;return n=>{let i=++e;t.push({id:i,callback:n}),Eo.postMessage({vscodeScheduleAsyncWork:i},"*")}}return t=>setTimeout(t)})();var iA=!!(qs&&qs.indexOf("Chrome")>=0);qs&&qs.indexOf("Firefox")>=0;!iA&&qs&&qs.indexOf("Safari")>=0;qs&&qs.indexOf("Edg/")>=0;qs&&qs.indexOf("Android")>=0;var ua=typeof navigator=="object"?navigator:{};Rw||document.queryCommandSupported&&document.queryCommandSupported("copy")||ua&&ua.clipboard&&ua.clipboard.writeText,Rw||ua&&ua.clipboard&&ua.clipboard.readText;var eg=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}},Ef=new eg,Aw=new eg,Mw=new eg;new Array(230);var sA;(t=>{function e(d){return Ef.keyCodeToStr(d)}t.toString=e;function n(d){return Ef.strToKeyCode(d)}t.fromString=n;function i(d){return Aw.keyCodeToStr(d)}t.toUserSettingsUS=i;function s(d){return Mw.keyCodeToStr(d)}t.toUserSettingsGeneral=s;function a(d){return Aw.strToKeyCode(d)||Mw.strToKeyCode(d)}t.fromUserSettings=a;function c(d){if(d>=98&&d<=113)return null;switch(d){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Ef.keyCodeToStr(d)}t.toElectronAccelerator=c})(sA||(sA={}));var x1=Object.freeze(function(t,e){let n=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(n)}}}),rA;(t=>{function e(n){return n===t.None||n===t.Cancelled||n instanceof oA?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:dr.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:x1})})(rA||(rA={}));var oA=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?x1:(this._emitter||(this._emitter=new ln),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},aA;(t=>{async function e(i){let s,a=await Promise.all(i.map(c=>c.then(d=>d,d=>{s||(s=d)})));if(typeof s<"u")throw s;return a}t.settled=e;function n(i){return new Promise(async(s,a)=>{try{await i(s,a)}catch(c){a(c)}})}t.withAsyncBody=n})(aA||(aA={}));var jw=class ds{static fromArray(e){return new ds(n=>{n.emitMany(e)})}static fromPromise(e){return new ds(async n=>{n.emitMany(await e)})}static fromPromises(e){return new ds(async n=>{await Promise.all(e.map(async i=>n.emitOne(await i)))})}static merge(e){return new ds(async n=>{await Promise.all(e.map(async i=>{for await(let s of i)n.emitOne(s)}))})}constructor(e,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new ln,queueMicrotask(async()=>{let i={emitOne:s=>this.emitOne(s),emitMany:s=>this.emitMany(s),reject:s=>this.reject(s)};try{await Promise.resolve(e(i)),this.resolve()}catch(s){this.reject(s)}finally{i.emitOne=void 0,i.emitMany=void 0,i.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 dr.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 ds(async i=>{for await(let s of e)i.emitOne(n(s))})}map(e){return ds.map(this,e)}static filter(e,n){return new ds(async i=>{for await(let s of e)n(s)&&i.emitOne(s)})}filter(e){return ds.filter(this,e)}static coalesce(e){return ds.filter(e,n=>!!n)}coalesce(){return ds.coalesce(this)}static async toPromise(e){let n=[];for await(let i of e)n.push(i);return n}toPromise(){return ds.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())}};jw.EMPTY=jw.fromArray([]);var{getWindow:lA}=(function(){let t=new Map,e={window:So,disposables:new ya};t.set(So.vscodeWindowId,e);let n=new ln,i=new ln,s=new ln;function a(c,d){return(typeof c=="number"?t.get(c):void 0)??(d?e:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:i.event,registerWindow(c){if(t.has(c.vscodeWindowId))return Es.None;let d=new ya,h={window:c,disposables:d.add(new ya)};return t.set(c.vscodeWindowId,h),d.add(wi(()=>{t.delete(c.vscodeWindowId),i.fire(c)})),d.add(rm(c,uA.BEFORE_UNLOAD,()=>{s.fire(c)})),n.fire(h),d},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return t.has(c)},getWindowById:a,getWindow(c){var f;let d=c;if((f=d==null?void 0:d.ownerDocument)!=null&&f.defaultView)return d.ownerDocument.defaultView.window;let h=c;return h!=null&&h.view?h.view.window:So},getDocument(c){return lA(c).document}}})(),cA=class{constructor(t,e,n,i){this._node=t,this._type=e,this._handler=n,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 rm(t,e,n,i){return new cA(t,e,n,i)}var uA={BEFORE_UNLOAD:"beforeunload"},dA=class extends Es{constructor(t,e,n,i,s,a,c,d,h){super(),this._terminal=t,this._characterJoinerService=e,this._charSizeService=n,this._coreBrowserService=i,this._coreService=s,this._decorationService=a,this._optionsService=c,this._themeService=d,this._cursorBlinkStateManager=new _l,this._charAtlasDisposable=this._register(new _l),this._observerDisposable=this._register(new _l),this._model=new UR,this._workCell=new yw,this._workCell2=new yw,this._rectangleRenderer=this._register(new _l),this._glyphRenderer=this._register(new _l),this._onChangeTextureAtlas=this._register(new ln),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new ln),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new ln),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new ln),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new ln),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let f={antialias:!1,depth:!1,preserveDrawingBuffer:h};if(this._gl=this._canvas.getContext("webgl2",f),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new sR(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new GR(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,c,this._themeService)],this.dimensions=nR(),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(rm(this._canvas,"webglcontextlost",g=>{console.log("webglcontextlost event received"),g.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(g)},3e3)})),this._register(rm(this._canvas,"webglcontextrestored",g=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,vw(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=_w(this._canvas,this._coreBrowserService.window,(g,_)=>this._setCanvasDevicePixelDimensions(g,_)),this._register(this._coreBrowserService.onWindowChange(g=>{this._observerDisposable.value=_w(this._canvas,g,(_,y)=>this._setCanvasDevicePixelDimensions(_,y))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(wi(()=>{var g;for(let _ of this._renderLayers)_.dispose();(g=this._canvas.parentElement)==null||g.removeChild(this._canvas),vw(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,i,s,a;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),(i=this._rectangleRenderer.value)==null||i.handleResize(),(s=this._glyphRenderer.value)==null||s.setDimensions(this.dimensions),(a=this._glyphRenderer.value)==null||a.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 i of this._renderLayers)i.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 VR(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new $R(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=v1(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=e1(dr.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),dr.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 i of this._renderLayers)i.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 jR(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(t,e){let n=this._core,i=this._workCell,s,a,c,d,h,f,g=0,_=!0,y,w,S,A,C,N,k,O,P;t=Tw(t,n.rows-1,0),e=Tw(e,n.rows-1,0);let H=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??"block",W=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,U=W-n.buffer.ydisp,G=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),X=-1,Q=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let V=!1;for(a=t;a<=e;a++)for(c=a+n.buffer.ydisp,d=n.buffer.lines.get(c),this._model.lineLengths[a]=0,S=W===c,g=0,h=this._characterJoinerService.getJoinedCharacters(c),O=0;O<n.cols;O++){if(s=this._cellColorResolver.result.bg,d.loadCell(O,i),O===0&&(s=this._cellColorResolver.result.bg),f=!1,_=O>=g,y=O,h.length>0&&O===h[0][0]&&_){w=h.shift();let T=this._model.selection.isCellSelected(this._terminal,w[0],c);for(k=w[0]+1;k<w[1];k++)_&&(_=T===this._model.selection.isCellSelected(this._terminal,k,c));_&&(_=!S||G<w[0]||G>=w[1]),_?(f=!0,i=new hA(i,d.translateToString(!0,w[0],w[1]),w[1]-w[0]),y=w[1]-1):g=w[1]}if(A=i.getChars(),C=i.getCode(),k=(a*n.cols+O)*Ku,this._cellColorResolver.resolve(i,O,c,this.dimensions.device.cell.width),Q&&c===W&&(O===G&&(this._model.cursor={x:G,y:U,width:i.getWidth(),style:this._coreBrowserService.isFocused?H:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},X=G+i.getWidth()-1),O>=G&&O<=X&&(this._coreBrowserService.isFocused&&H==="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[a]=O+1),!(this._model.cells[k]===C&&this._model.cells[k+Pu]===this._cellColorResolver.result.bg&&this._model.cells[k+Iu]===this._cellColorResolver.result.fg&&this._model.cells[k+Sf]===this._cellColorResolver.result.ext)&&(V=!0,A.length>1&&(C|=HR),this._model.cells[k]=C,this._model.cells[k+Pu]=this._cellColorResolver.result.bg,this._model.cells[k+Iu]=this._cellColorResolver.result.fg,this._model.cells[k+Sf]=this._cellColorResolver.result.ext,N=i.getWidth(),this._glyphRenderer.value.updateCell(O,a,C,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,A,N,s),f)){for(i=this._workCell,O++;O<=y;O++)P=(a*n.cols+O)*Ku,this._glyphRenderer.value.updateCell(O,a,0,0,0,0,GL,0,0),this._model.cells[P]=0,this._model.cells[P+Pu]=this._cellColorResolver.result.bg,this._model.cells[P+Iu]=this._cellColorResolver.result.fg,this._model.cells[P+Sf]=this._cellColorResolver.result.ext;O--}}V&&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})}},hA=class extends va{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 Tw(t,e,n=0){return Math.max(Math.min(t,e),n)}var Pw="di$target",Iw="di$dependencies",Nf=new Map;function Ks(t){if(Nf.has(t))return Nf.get(t);let e=function(n,i,s){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");fA(e,n,s)};return e._id=t,Nf.set(t,e),e}function fA(t,e,n){e[Pw]===e?e[Iw].push({id:t,index:n}):(e[Iw]=[{id:t,index:n}],e[Pw]=e)}Ks("BufferService");Ks("CoreMouseService");Ks("CoreService");Ks("CharsetService");Ks("InstantiationService");Ks("LogService");var pA=Ks("OptionsService");Ks("OscLinkService");Ks("UnicodeService");Ks("DecorationService");var mA={trace:0,debug:1,info:2,warn:3,error:4,off:5},gA="xterm.js: ",Dw=class extends Es{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=mA[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?"":gA)+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)}};Dw=BL([OL(0,pA)],Dw);var vA=class extends Es{constructor(t){if(i1&&YL()<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 ln),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new ln),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new ln),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new ln),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,i=e.optionsService,s=e,a=s._renderService,c=s._characterJoinerService,d=s._charSizeService,h=s._coreBrowserService,f=s._decorationService;s._logService;let g=s._themeService;this._renderer=this._register(new dA(t,c,d,h,n,f,i,g,this._preserveDrawingBuffer)),this._register(dr.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(dr.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(dr.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(dr.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(wi(()=>{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 C1="nc-terminal-renderer",xa="webgl",Ao="dom";function k1(t){if(t!==void 0)return t;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Ol(t){const e=k1(t);try{return e&&e.getItem(C1)===Ao?Ao:xa}catch{return xa}}function _A(t,e){const n=t===Ao?Ao:xa,i=k1(e);try{i&&i.setItem(C1,n)}catch{}return n}function yA(t){return t===Ao?xa:Ao}function wA(t,{preference:e,createAddon:n,onFallback:i}={}){const s=e||Ol(),a={kind:Ao,dispose:()=>{}};if(s!==xa||!t||typeof t.loadAddon!="function"||typeof n!="function")return a;let c;try{if(c=n(),!c)return a;t.loadAddon(c)}catch{try{c&&c.dispose()}catch{}return i&&i("unavailable"),a}let d=!1;const h=()=>{if(!d){d=!0;try{c.dispose()}catch{}}};return typeof c.onContextLoss=="function"&&c.onContextLoss(()=>{h(),i&&i("context-loss")}),{kind:xa,dispose:h}}const bA=Object.freeze({retryBaseMs:250,retryMaxMs:5e3,pingMs:5e3,deadMs:1e4,queuedInputBytes:4096,overlayDelayMs:1e3}),SA=(t,e)=>{const n=Number(t);return Number.isFinite(n)&&n>0?n:e};function E1(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},n={};for(const[i,s]of Object.entries(bA))n[i]=SA(e[i],s);return n}let om=E1(null);function xA(t){return om=E1(t),{...om}}function N1(){return{...om}}function CA(t,e,n=null,i=null){if(!t)return"/ws";let a=`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(e||"")}`;return n&&(a+=`&attachId=${encodeURIComponent(n)}`,i&&(a+=`&attachSession=${encodeURIComponent(i)}`)),a}function kA(t,e,n=null){const i=n===null?typeof sessionStorage<"u"?sessionStorage:null:n;if(!i)return null;const s=`nc-attach:${e||"local"}:${String(t||"")}`;try{const a=i.getItem(s);if(typeof a=="string"&&/^[0-9a-f]{32}$/.test(a))return a;const c=new Uint8Array(16),d=globalThis.crypto;if(!d||typeof d.getRandomValues!="function")return null;d.getRandomValues(c);const h=Array.from(c).map(f=>f.toString(16).padStart(2,"0")).join("");return i.setItem(s,h),h}catch{return null}}function EA({session:t,node:e,token:n,cols:i,rows:s,readonly:a=!1,takeSize:c,focused:d,onData:h,onExit:f,onFiles:g,onSnapshot:_,onLink:y,retryBaseMs:w,retryMaxMs:S,retryStableMs:A=5e3,onRetryScheduled:C,pingMs:N,deadMs:k,queuedInputBytes:O,onQueued:P}){const H=N1(),W=w===void 0?H.retryBaseMs:w,U=S===void 0?H.retryMaxMs:S,G=N===void 0?H.pingMs:N,X=k===void 0?H.deadMs:k,Q=O===void 0?H.queuedInputBytes:O,V=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!V)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const T=location.protocol==="https:"?"wss":"ws",I=kA(t,e),$=`${T}://${location.host}${CA(e,n,I,t)}`;let j=null,M=!1,L=!1,R=null,E=null,z=0,D=null,q=!1,ce=null,ge=0,se=null;const we=Math.max(1,Number(Q)||4096);let _e=[],fe=0;const ie=()=>{if(typeof P=="function")try{P(fe)}catch{}},de=()=>{if(!j||j.readyState!==1||!_e.length)return;const Le=_e;_e=[],fe=0;for(const ze of Le)try{j.send(ze)}catch{}ie()},me=()=>{ce&&(clearInterval(ce),ce=null)},Ee=Le=>{me(),ge=Date.now();const ze=Math.max(1,Number(G)||5e3),He=Math.max(1,Number(X)||1e4);ce=setInterval(()=>{if(j!==Le||M||L){me();return}if(Date.now()-ge>He){me();try{Le.close(4e3,"liveness timeout")}catch{}return}if(Le.readyState===1)try{Le.send(JSON.stringify({type:"ping",t:Date.now()}))}catch{}},ze),typeof ce.unref=="function"&&ce.unref()};let Se=d;const xe=()=>{if(M||L||R)return;const Le=Math.min(U,Math.max(0,W)*2**Math.min(z++,5));typeof C=="function"&&C(Le),R=setTimeout(()=>{R=null,Ye()},Le)},Ye=()=>{if(M||L)return;const Le=new WebSocket($);j=Le,Le.binaryType="arraybuffer",Le.onopen=()=>{if(j!==Le||M)return;E&&clearTimeout(E);const ze=Number(A),He=Number.isFinite(ze)?Math.max(0,ze):5e3;E=setTimeout(()=>{E=null,j===Le&&Le.readyState===1&&(z=0)},He),typeof E.unref=="function"&&E.unref();const _t={type:"attach",session:t,token:n,cols:i,rows:s,readonly:a};D&&(_t.reconnectToken=D),c!==void 0&&(_t.takeSize=c),Le.send(JSON.stringify(_t)),Se!==void 0&&Le.send(JSON.stringify({type:"focus",on:!!Se})),q&&Le.send(JSON.stringify(se===null?{type:"resync"}:{type:"resume",seq:se})),de(),Ee(Le)},Le.onmessage=ze=>{if(!(j!==Le||M))if(ge=Date.now(),typeof ze.data=="string"){let He;try{He=JSON.parse(ze.data)}catch{return}if(He.type==="attached"&&typeof He.reconnectToken=="string"&&He.reconnectToken&&(D=He.reconnectToken),He.type==="exit"&&(L=!0,f&&f(He.code)),He.type==="files"&&g&&g(He),He.type==="snapshot"&&_&&_(typeof He.data=="string"?He.data:""),He.type==="link"&&y&&y(He.state==="live"?"live":"reconnecting"),He.type==="resync-needed")try{Le.send(JSON.stringify({type:"resync"}))}catch{}}else{let He=new Uint8Array(ze.data);try{ze.data&&ze.data.byteLength>=4&&(se=new DataView(ze.data).getUint32(0),He=new Uint8Array(ze.data,4))}catch{}h&&h(He)}},Le.onerror=()=>{if(j===Le)try{Le.close()}catch{}},Le.onclose=ze=>{me(),!(j!==Le||M||L)&&(E&&(clearTimeout(E),E=null),![4401,4403,4404].includes(ze==null?void 0:ze.code)&&(q=!0,y&&y("reconnecting"),xe()))}};return Ye(),{sendInput:Le=>{const ze=typeof Le=="string"?new TextEncoder().encode(Le):Le;if(j&&j.readyState===1)try{return j.send(ze),!0}catch{try{j.close()}catch{}}return fe+ze.length>we?!1:(_e.push(ze),fe+=ze.length,ie(),!0)},isReady:()=>!!j&&j.readyState===1,resize:(Le,ze)=>{i=Le,s=ze,(j==null?void 0:j.readyState)===1&&j.send(JSON.stringify({type:"resize",cols:Le,rows:ze}))},action:Le=>{(j==null?void 0:j.readyState)===1&&j.send(JSON.stringify({type:"action",name:Le}))},focus:Le=>{Se=Le,(j==null?void 0:j.readyState)===1&&j.send(JSON.stringify({type:"focus",on:!!Le}))},close:()=>{if(M=!0,me(),R&&clearTimeout(R),E&&clearTimeout(E),R=null,E=null,j)try{j.close()}catch{}},get raw(){return j}}}const L1=1e3;function NA(t,e,n=L1){if(t==null)return!1;const i=Number(e)-Number(t);return Number.isFinite(i)?i>=Math.max(0,Number(n)||0):!1}function LA(t={},e={}){const n=Number(t.viewportY)||0,i=Number(t.baseY)||0,s=Math.max(0,Number(e.baseY)||0);return n>=i?{atBottom:!0,line:null}:{atBottom:!1,line:Math.min(n,s)}}function RA(t){return t?`\r
|
|
152
|
-
\x1B[2m── riconnesso ──\x1B[0m\r
|
|
153
|
-
`:""}async function am(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 i=document.execCommand&&document.execCommand("copy");if(n.remove(),i)return!0}catch{}return!1}const AA="\r";function MA(t){const e=String(t||"");let n=e.length;for(;n>0;){const i=e.charCodeAt(n-1);if(i===10||i===13)n-=1;else break}return e.slice(0,n)}function jA({isReady:t,paste:e,send:n}){return i=>{if(!i||!t())return!1;try{return e(i)===!1||!t()?!1:n(AA)!==!1}catch{return!1}}}function TA(t){return!t||typeof t!="object"?!1:!!t.shiftKey}function PA(t){return!t||typeof t!="object"||String(t.key||"").toLowerCase()!=="c"?!1:!!(t.metaKey||t.ctrlKey&&t.shiftKey)}function IA(t){return/mac|iphone|ipad/i.test(String(t||""))?"⌘C":"Ctrl+Shift+C"}const DA=450,Bw=8;function Ow(t,e,n,i){return Math.abs(Number(n)-Number(t))>Bw||Math.abs(Number(i)-Number(e))>Bw}function BA({range:t,cell:e,cols:n}){const i=Number(n),s=Number(t.start.row)*i+Number(t.start.col),a=Number(t.end.row)*i+Number(t.end.col),c=Number(e.row)*i+Number(e.col),d={start:{row:t.start.row,col:t.start.col},end:{row:t.end.row,col:t.end.col},moved:null};if(c<s)d.start={row:Number(e.row),col:Number(e.col)},d.moved="start";else if(c>a)d.end={row:Number(e.row),col:Number(e.col)},d.moved="end";else{if(c===s||c===a)return d;c-s<=a-c?(d.start={row:Number(e.row),col:Number(e.col)},d.moved="start"):(d.end={row:Number(e.row),col:Number(e.col)},d.moved="end")}return d}function OA(t){const e=t!=="mouse";return{handles:e,magnifier:e}}function $A(t,e){if(!t||!t.start||!t.end)return null;const n=Number(e);if(!Number.isFinite(n)||n<=0)return null;const i=Number(t.start.y)*n+Number(t.start.x),s=Number(t.end.y)*n+Number(t.end.x),a=Math.min(i,s),c=Math.max(a,Math.max(i,s)-1);return{start:{row:Math.floor(a/n),col:a%n},end:{row:Math.floor(c/n),col:c%n}}}function $w(t,e,n){const i=Number(t.row)*Number(n)+Number(t.col),s=Number(e.row)*Number(n)+Number(e.col);return i<=s?{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 zA({moving:t,fixed:e,which:n,cols:i,maxRow:s}){const a=Number(i);let c=Math.max(0,Math.min(Number(s),Number(t.row))),d=Math.max(0,Math.min(a-1,Number(t.col)));const h=c*a+d,f=Number(e.row)*a+Number(e.col);return n==="start"&&h>f&&(c=Number(e.row),d=Number(e.col)),n==="end"&&h<f&&(c=Number(e.row),d=Number(e.col)),{row:c,col:d}}function da({line:t,col:e,side:n,cols:i}){const s=Math.max(0,Math.min(Number(i)-1,Number(e))),a=t&&typeof t.getCell=="function"?t.getCell(s):null;return(a&&typeof a.getWidth=="function"?Number(a.getWidth()):1)!==0?s:n==="end"?Math.min(Number(i)-1,s+1):Math.max(0,s-1)}function zw({line:t,col:e,cols:n}){const i=Math.max(0,Math.min(Number(n)-1,Number(e))),s=d=>{const h=t&&typeof t.getCell=="function"?t.getCell(d):null;return h&&typeof h.getChars=="function"?h.getChars():""};if(s(i)===""||s(i)===" ")return{start:i,end:i};let a=i;for(;a>0;){const d=s(a-1);if(d===""||d===" ")break;a-=1}let c=i;for(;c<Number(n)-1;){const d=s(c+1);if(d===""||d===" ")break;c+=1}return{start:a,end:c}}function FA({startLeft:t,endLeft:e,targetWidth:n=46}){return Math.abs(Number(e)-Number(t))<Number(n)}function HA({anchorLeft:t,anchorTop:e,hostWidth:n,hostHeight:i,bubbleWidth:s,bubbleHeight:a,pinHeight:c=30,margin:d=4,gap:h=8}){const f=Number(s),g=Number(a),_=Number(d),y=Math.max(_,Number(n)-_-f),w=Math.max(_,Math.min(y,Number(t)-Math.round(f/2)));let S=Number(e)-Number(h)-g,A=!1;S<_&&(S=Number(e)+Number(c)+Number(h),A=!0);const C=Math.max(_,Number(i)-_-g);return S>C&&(S=C),{left:w,top:S,flipped:A}}function Fw(t,e){const n=Number(e),i=Number(t.start.row)*n+Number(t.start.col),s=Number(t.end.row)*n+Number(t.end.col);return{col:t.start.col,row:t.start.row,length:s-i+1}}const Hw=28,UA=50;function WA({range:t,viewportY:e,rows:n,cols:i=0,cellWidth:s,cellHeight:a,screenLeft:c=0,screenTop:d=0}){const h={},f=Number(i)*Number(s);for(const g of["start","end"]){const _=t[g],y=Number(_.row)-Number(e),w=y>=0&&y<Number(n),S=(g==="start"?Number(_.col):Number(_.col)+1)*Number(s),A=g==="start"?S-Hw<0:S+Hw>f;h[g]={left:Number(c)+S,top:Number(d)+(y+1)*Number(a),visible:w,flip:A}}return h}function qA({visibleRow:t,rows:e}){const n=Number(t);return n<=0?-1:n>=Number(e)-1?1:0}function KA({range:t,side:e,line:n,cols:i}){if(!t||!t.start||!t.end||!n)return null;const s=Math.max(0,Number(i)-1),a=e==="end"?t.end:t.start,c=Number(a.row);let d,h;Number(t.start.row)===Number(t.end.row)?(d=Number(t.start.col),h=Number(t.end.col)):c===Number(t.start.row)?(d=Number(t.start.col),h=s):c===Number(t.end.row)?(d=0,h=Number(t.end.col)):(d=0,h=s),d=Math.max(0,Math.min(s,d)),h=Math.max(d,Math.min(s,h));const f=n.translateToString(!0,0,d);let g=n.translateToString(!1,d,h+1);g.replace(/\s+$/,"")===""&&(g="");const _=n.translateToString(!0,Math.min(s+1,h+1),s+1);return{row:c,before:f,sel:g,after:_}}const lm="(min-width:1024px) and (pointer:fine)";function R1(){const[t,e]=b.useState(()=>window.matchMedia(lm).matches);return b.useEffect(()=>{const n=window.matchMedia(lm),i=s=>e(s.matches);return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[]),t}const VA=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function Lf(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 Uw(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 YA(t,e=0,n=Date.now()){const i=String((t==null?void 0:t.name)||"").trim();if(i)return i;const s=VA.get(String((t==null?void 0:t.type)||"").toLowerCase())||"bin";return`clipboard-${n}-${e+1}.${s}`}async function cm({files:t,token:e,session:n,node:i="",paste:s=!0,fetchImpl:a=un,onProgress:c=()=>{},now:d=Date.now()}={}){const h=Array.from(t||[]).filter(Boolean),f=[],g=[];if(!n||!h.length)return{paths:f,errors:g};const _=hn(i?String(i).split("/"):[]);for(let y=0;y<h.length;y+=1){const w=h[y],S=YA(w,y,d);c({index:y,total:h.length,name:S,state:"uploading"});try{const A=new FormData;A.append("session",n),A.append("paste",s?"true":"false"),A.append("file",w,S);const C=await a(`${_}/files/upload`,e,{method:"POST",body:A}),N=await C.json().catch(()=>({}));if(!C.ok||N.error)throw new Error(N.error||`HTTP ${C.status}`);f.push(N.path),c({index:y,total:h.length,name:S,state:"done",path:N.path})}catch(A){const C=String((A==null?void 0:A.message)||A);g.push({name:S,message:C}),c({index:y,total:h.length,name:S,state:"error",error:C})}}return{paths:f,errors:g}}const GA=420,XA=32;function QA(t){if(!t||typeof t!="object")return!1;const e=String(t.tagName||"").toLowerCase();return e==="textarea"||e==="input"||t.isContentEditable===!0}function um({documentRef:t,navigatorRef:e}={}){const n=t||(typeof document<"u"?document:null),i=e||(typeof navigator<"u"?navigator:null);let s=!1;try{i!=null&&i.virtualKeyboard&&typeof i.virtualKeyboard.hide=="function"&&(i.virtualKeyboard.hide(),s=!0)}catch{}const a=n&&n.activeElement;let c=!1;if(QA(a)&&typeof a.blur=="function")try{a.blur(),c=!0}catch{}return{blurred:c,apiRequested:s}}function A1(t,e,n=!1){const i=t&&t.textarea;if(!i)return null;const a=e==="single-tap"||e==="double-tap"&&n?"text":"none";return i.inputMode=a,i.setAttribute("inputmode",a),a}function JA(t,e){if(!t||!t.textarea)return!1;A1(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 ZA(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<=GA&&Math.hypot(n.x-e.x,n.y-e.y)<=XA?{open:!0,next:null}:{open:!1,next:n}}const eM=24,Ww=80,M1=8,tM="\x1B[5~",nM="\x1B[6~",iM=64,sM=65;function rM(t,e,n){const i=t==="up"?iM:sM,s=a=>Math.max(1,Math.min(9999,Number.isFinite(a)?Math.round(a):1));return`\x1B[<${i};${s(e)};${s(n)}M`}function oM({alternateScreen:t=!1,readonly:e=!1,mouseTracking:n=!1}={}){return e?"scroll":n?"mouse":t?"page":"scroll"}function aM(t,e){return t==="page"?Number.isFinite(e)&&e>0?Math.max(Ww,e):Ww:Number.isFinite(e)&&e>0?e:eM}function lM({mode:t="scroll",accumulated:e=0,threshold:n=0}={}){const i=aM(t,n);if(!Number.isFinite(e))return{mode:t,up:0,down:0,remainder:0};const s=Math.abs(e);if(s<i)return{mode:t,up:0,down:0,remainder:e};const a=Math.floor(s/i),c=Math.min(a,M1),d=(e>=0?1:-1)*(s%i);return{mode:t,up:e>0?c:0,down:e<0?c:0,remainder:d}}function cM(t,e=null){const n=[],i=e&&Number.isFinite(e.col)?e.col:1,s=e&&Number.isFinite(e.row)?e.row:1,a=d=>Math.min(M1,Number.isFinite(d)?Math.max(0,Math.floor(d)):0),c=d=>t.mode==="mouse"?{kind:"input",seq:rM(d,i,s)}:t.mode==="page"?{kind:"input",seq:d==="up"?tM:nM}:{kind:"action",name:d==="up"?"scroll-up":"scroll-down"};for(let d=0;d<a(t.up);d+=1)n.push(c("up"));for(let d=0;d<a(t.down);d+=1)n.push(c("down"));return n}function $l({session:t,node:e,token:n,readonly:i,takeSize:s,focused:a,sendRef:c,composerRef:d,actionRef:h,ctrlRef:f,setCtrlArmed:g,onFiles:_,fontSize:y=13,selectionMode:w=!1,onSelectionModeChange:S,keyboardGesture:A="double-tap",onRendererChange:C}){const N=b.useRef(null),k=b.useRef(null),O=b.useRef(null),P=b.useRef(y);P.current=y;const H=b.useRef(a);H.current=a;const W=b.useRef(w);W.current=w;const U=b.useRef(A);U.current=A;const[G,X]=b.useState(""),[Q,V]=b.useState(""),[T,I]=b.useState(null),[$,j]=b.useState(null),[M,L]=b.useState(!1),[R,E]=b.useState(0),z=b.useRef(null),D=b.useRef(null),[q,ce]=b.useState(!1),[ge,se]=b.useState(null),we=b.useRef(null),[_e,fe]=b.useState(null),[ie,de]=b.useState(0),[me,Ee]=b.useState(null),[Se,xe]=b.useState("start"),[Ye,Le]=b.useState(null),[ze,He]=b.useState(!1),[_t,at]=b.useState(null),[lt,bt]=b.useState(null),Ht=b.useRef(null),Rt=b.useRef(null),[fn,It]=b.useState(!1),Wt=async()=>{var Ze,ct,st,xt;const K=((ct=(Ze=k.current)==null?void 0:Ze.term)==null?void 0:ct.getSelection())||G;if(!K){V(p("copy-empty")),setTimeout(()=>V(""),1500);return}const ye=await am(K);V(p(ye?"copied":"copy-manual")),ye&&((xt=(st=k.current)==null?void 0:st.term)==null||xt.clearSelection(),X(""),ce(!1),S==null||S(!1)),setTimeout(()=>V(""),1800)},ft=b.useRef(Wt);ft.current=Wt;const qt=b.useRef({startHandleDrag:()=>{}}),$t=b.useRef(null);$t.current=_e,b.useEffect(()=>{const K=N.current;K&&(K.dataset.selectionOrigin=lt||"")},[lt]),b.useEffect(()=>{const K=k.current;K&&K.sock&&K.sock.focus&&K.sock.focus(!!a)},[a]),b.useEffect(()=>{const K=k.current;K&&(K.term.options.fontSize=y,K.fit.fit(),K.sock.resize(K.term.cols,K.term.rows))},[y]),b.useEffect(()=>{var K,ye;(ye=(K=k.current)==null?void 0:K.setKeyboardGesture)==null||ye.call(K,A)},[A]),b.useEffect(()=>{var eo,yr,Oo,Ba,Ys,Oa,cc;const K=new NL({cursorBlink:!0,fontSize:P.current,scrollback:1e3,allowProposedApi:!0,theme:{background:"#0a0e0a"}}),ye=new AL;K.loadAddon(ye),K.open(N.current),ye.fit(),DL(K);const Ze=wA(K,{preference:Ol(),createAddon:()=>new vA,onFallback:()=>{C&&C("dom")}});O.current=Ze,C&&C(Ze.kind);let ct=!1,st=!1;const xt=ue=>Pe=>{for(const Ie of Pe){const qe=Array.isArray(Ie)?Ie[0]:Ie;qe===1006&&(ct=ue),qe===1016&&(st=ue)}return!1};(yr=(eo=K.parser)==null?void 0:eo.registerCsiHandler)==null||yr.call(eo,{prefix:"?",final:"h"},xt(!0)),(Ba=(Oo=K.parser)==null?void 0:Oo.registerCsiHandler)==null||Ba.call(Oo,{prefix:"?",final:"l"},xt(!1)),(Oa=(Ys=K.parser)==null?void 0:Ys.registerEscHandler)==null||Oa.call(Ys,{final:"c"},()=>(ct=!1,st=!1,!1));const Et=()=>{const ue=ct&&!st&&(K.modes&&K.modes.mouseTrackingMode||"none")!=="none",Pe=N.current;return Pe&&(Pe.dataset.mouseTracking=ue?"on":"off"),ue},jt=new TextDecoder;let Ct=U.current==="single-tap",Xe=null;const tt=()=>{Ct=U.current==="single-tap",A1(K,U.current,Ct)},Nt=ue=>{U.current=ue,Xe=null,tt()},kn=()=>U.current==="never"?!1:(Ct=!0,JA(K));tt();const Ae=K.textarea,zt=()=>{U.current==="double-tap"&&tt()};Ae==null||Ae.addEventListener("blur",zt);let Qt;try{Qt=EA({session:t,node:e,token:n,readonly:i,takeSize:s,focused:H.current,onFiles:_,cols:K.cols,rows:K.rows,onData:ue=>K.write(jt.decode(ue)),onExit:()=>K.write(`\r
|
|
154
|
-
\x1B[33m[sessione finita]\x1B[0m\r
|
|
155
|
-
`),onSnapshot:ue=>{try{const Pe=K.buffer&&K.buffer.active,Ie=LA({viewportY:Pe?Pe.viewportY:0,baseY:Pe?Pe.baseY:0},{baseY:Pe?Pe.baseY:0});K.reset(),K.write(ue),!Ie.atBottom&&Ie.line!==null&&typeof K.scrollToLine=="function"&&K.scrollToLine(Ie.line)}catch{}},onQueued:ue=>E(ue),onLink:ue=>{if(D.current&&(clearTimeout(D.current),D.current=null),ue==="live"){const Pe=z.current!==null&&NA(z.current,Date.now());if(z.current=null,L(!1),Pe)try{K.write(RA(!0))}catch{}return}z.current===null&&(z.current=Date.now()),D.current=setTimeout(()=>{D.current=null,L(!0)},N1().overlayDelayMs||L1)}})}catch(ue){return K.write(`\r
|
|
156
|
-
\x1B[31m${ue.message}\x1B[0m\r
|
|
157
|
-
`),()=>{var Pe,Ie;try{(Ie=(Pe=O.current)==null?void 0:Pe.dispose)==null||Ie.call(Pe)}catch{}O.current=null,K.dispose()}}k.current={term:K,fit:ye,sock:Qt,setKeyboardGesture:Nt};let Tt=null;const pn=K.onData(ue=>{if(i){Tt&&(Tt.ok=!1);return}if(!Tt&&f&&f.current&&ue.length===1){const Ie=ue.charCodeAt(0);let qe=Ie;Ie>=97&&Ie<=122?qe=Ie-96:Ie>=64&&Ie<=95?qe=Ie-64:Ie===32&&(qe=0),ue=String.fromCharCode(qe),f.current=!1,g&&g(!1)}const Pe=Qt.sendInput(ue);Tt&&(Tt.seen=!0,Tt.ok=Tt.ok&&Pe)});c&&(c.current=ue=>Qt.sendInput(ue)),h&&(h.current=ue=>Qt.action(ue)),d&&(d.current=jA({isReady:()=>!i&&Qt.isReady(),paste:ue=>{const Pe={seen:!1,ok:!0};Tt=Pe;try{K.paste(ue)}catch{Pe.ok=!1}finally{Tt=null}return Pe.seen&&Pe.ok},send:ue=>Qt.sendInput(ue)}));const St=ue=>{Ht.current=ue,bt(ue)};let it=null;const Dt=K.onSelectionChange(()=>{const ue=K.getSelection();ue?(X(ue),ce(!1)):ce(!0);const Pe=$A(K.getSelectionPosition(),K.cols),Ie=Pe?$w(Pe.start,Pe.end,K.cols):null;se(Ie),we.current=Ie,Ie||St(null),!Ie&&it&&Da();let qe=null;if(Ie&&typeof K.buffer.active.getLine=="function"){const mt=[];for(let yt=Ie.start.row;yt<=Ie.end.row;yt++){const Vt=K.buffer.active.getLine(yt);mt.push(Vt?Vt.translateToString():"")}qe={startRow:Ie.start.row,endRow:Ie.end.row,lines:mt}}Rt.current=qe,It(!1)}),Ot=K.onRender(ue=>{var Pe;if((Pe=K.hasSelection)!=null&&Pe.call(K)){const Ie=Rt.current,qe=ue&&ue.start,mt=ue&&ue.end;if(Ie&&Number.isInteger(qe)&&Number.isInteger(mt)&&typeof K.buffer.active.getLine=="function"){const yt=Number(K.buffer.active.viewportY)||0,Vt=Math.max(yt+qe,Ie.startRow),en=Math.min(yt+mt,Ie.endRow);for(let qn=Vt;qn<=en;qn++){const yn=K.buffer.active.getLine(qn);if((yn?yn.translateToString():"")!==Ie.lines[qn-Ie.startRow]){It(!0);break}}}de(yt=>yt+1)}}),Kt=K.onScroll(()=>{var ue;(ue=K.hasSelection)!=null&&ue.call(K)&&de(Pe=>Pe+1)});K.attachCustomKeyEventHandler(ue=>(ue.ctrlKey||ue.metaKey)&&ue.key.toLowerCase()==="c"&&K.getSelection()?(ue.type==="keydown"&&am(K.getSelection()),!1):!0);const Ge=N.current;let Mn=!1;const Ri=async ue=>{if(!ue.length||Mn)return;if(i){I({error:p("settings-readonly")});return}Mn=!0,I({current:0,total:ue.length,name:""});const Pe=await cm({files:ue,token:n,session:t,node:e,paste:!0,onProgress:({index:Ie,total:qe,name:mt,state:yt,error:Vt})=>I({current:Ie+1,total:qe,name:mt,...yt==="error"?{error:Vt}:{}})});Mn=!1,Pe.errors.length?I({error:Pe.errors.map(Ie=>`${Ie.name}: ${Ie.message}`).join(" · ")}):(I({done:!0,total:Pe.paths.length}),setTimeout(()=>I(null),1600))},Ai=ue=>{const Pe=ue.clipboardData;if(!Lf(Pe))return;const Ie=Uw(Pe);Ie.length&&(ue.preventDefault(),ue.stopPropagation(),Ri(Ie))},Wn=ue=>{Lf(ue.dataTransfer)&&(ue.preventDefault(),ue.stopPropagation())},Qi=ue=>{Lf(ue.dataTransfer)&&(ue.preventDefault(),ue.stopPropagation(),Ri(Uw(ue.dataTransfer)))};Ge.addEventListener("paste",Ai,!0),Ge.addEventListener("dragenter",Wn,!0),Ge.addEventListener("dragover",Wn,!0),Ge.addEventListener("drop",Qi,!0);const Fi=24,Ji=(ue,Pe)=>{const qe=(Ge.querySelector(".xterm-screen")||Ge).getBoundingClientRect(),mt=Math.floor((ue-qe.left)/Math.max(1,qe.width)*K.cols)+1,yt=Math.floor((Pe-qe.top)/Math.max(1,qe.height)*K.rows)+1;return{col:Math.max(1,Math.min(K.cols,mt)),row:Math.max(1,Math.min(K.rows,yt))}},re=(ue,Pe={mode:null,remainder:0},Ie=null,qe=null)=>{const mt=N.current,yt=mt?mt.getBoundingClientRect().height:Fi,Vt=oM({alternateScreen:K.buffer.active.type==="alternate",readonly:i,mouseTracking:Et()}),en=Vt==="mouse"?"mouse":Ie||Vt,qn=Pe.mode===en?Pe.remainder+ue:ue,yn=lM({mode:en,accumulated:qn,threshold:en==="page"?yt:Fi});for(const Nn of cM(yn,qe))Nn.kind==="input"?Qt.sendInput(Nn.seq):Qt.action(Nn.name);return{mode:en,remainder:yn.remainder}};let be=null,Be=null,We=null,wt=null,Y=!1,te=!1,Ce={mode:null,remainder:0},$e=null,ke=null,ut=null,pt=!1;const Fe=750;let Bt=0;const ne=()=>{ut&&clearTimeout(ut),ut=null},le=(ue,Pe)=>{const qe=(Ge.querySelector(".xterm-screen")||Ge).getBoundingClientRect(),mt=Math.max(0,Math.min(K.cols-1,Math.floor((ue-qe.left)/Math.max(1,qe.width)*K.cols))),yt=Math.max(0,Math.min(K.rows-1,Math.floor((Pe-qe.top)/Math.max(1,qe.height)*K.rows)));return{col:mt,row:K.buffer.active.viewportY+yt}},Re=()=>{const Ie=(Ge.querySelector(".xterm-screen")||Ge).getBoundingClientRect().height/Math.max(1,K.rows),qe=Ge.querySelector(".nc-sel-handle"),mt=qe?qe.getBoundingClientRect().height:0;return-.3*(mt>0?mt:Ie)},ot=(ue,Pe)=>le(ue.clientX,ue.clientY+Pe),rt=ue=>{const Ie=(Ge.querySelector(".xterm-screen")||Ge).getBoundingClientRect(),qe=Ge.getBoundingClientRect(),mt=Ie.width/Math.max(1,K.cols),yt=Ie.height/Math.max(1,K.rows),Vt=Number(K.buffer.active.viewportY)||0,en=Math.max(0,Math.min(K.rows-1,ue.row-Vt));j({left:`${Ie.left-qe.left+ue.col*mt}px`,top:`${Ie.top-qe.top+en*yt}px`,width:`${mt}px`,height:`${yt}px`})},ri=ue=>{if(Bt=Date.now(),St("touch"),ne(),pt=!1,Y=!1,te||ue.touches.length!==1){te=!0,Y=!0,Xe=null,j(null),be=null,Be=null,We=null,wt=null;return}if(W.current){ue.preventDefault(),ue.stopPropagation();const Ie=le(ue.touches[0].clientX,ue.touches[0].clientY),qe=K.buffer.active.getLine(Ie.row),mt=da({line:qe,col:Ie.col,side:"start",cols:K.cols}),yt=zw({line:qe,col:mt,cols:K.cols});ke={row:Ie.row,col:yt.start};const Vt={row:Ie.row,col:yt.end};K.clearSelection(),St("touch"),He(!0),xe("end"),K.select(yt.start,Ie.row,yt.end-yt.start+1),rt(Vt);return}be=ue.touches[0].clientY,Be=ue.touches[0].clientX,We=Be,wt=be,Ce={mode:null,remainder:0},$e=null;const Pe={x:Be,y:be};ut=setTimeout(()=>{var en;ut=null,pt=!0,Y=!0,Xe=null,W.current=!0,S==null||S(!0);const Ie=le(Pe.x,Pe.y),qe=K.buffer.active.getLine(Ie.row),mt=da({line:qe,col:Ie.col,side:"start",cols:K.cols}),yt=zw({line:qe,col:mt,cols:K.cols});ke={row:Ie.row,col:yt.start};const Vt={row:Ie.row,col:yt.end};K.clearSelection(),St("touch"),He(!0),xe("end"),K.select(yt.start,Ie.row,yt.end-yt.start+1),rt(Vt);try{(en=navigator.vibrate)==null||en.call(navigator,10)}catch{}be=null,Be=null,$e=null,Ce={mode:null,remainder:0}},DA)},En=ue=>{if(pt&&ke&&ue.touches.length===1){ue.preventDefault(),ue.stopPropagation();const qe=le(ue.touches[0].clientX,ue.touches[0].clientY),mt=ke.row*K.cols+ke.col,yt=qe.row*K.cols+qe.col,Vt=mt<=yt?"end":"start",en=K.buffer.active.getLine(qe.row),qn=da({line:en,col:qe.col,side:Vt,cols:K.cols}),yn={row:qe.row,col:qn},Nn=yn.row*K.cols+yn.col,ts=mt<=Nn?ke:yn;xe(Vt),K.select(ts.col,ts.row,Math.abs(Nn-mt)+1),rt(yn);return}if(W.current&&ke&&ue.touches.length===1){ue.preventDefault(),ue.stopPropagation();const qe=le(ue.touches[0].clientX,ue.touches[0].clientY),mt=ke.row*K.cols+ke.col,yt=qe.row*K.cols+qe.col,Vt=mt<=yt?"end":"start",en=K.buffer.active.getLine(qe.row),qn=da({line:en,col:qe.col,side:Vt,cols:K.cols}),yn={row:qe.row,col:qn},Nn=yn.row*K.cols+yn.col,ts=mt<=Nn?ke:yn;xe(Vt),K.select(ts.col,ts.row,Math.abs(Nn-mt)+1),rt(yn);return}if(be===null||ue.touches.length!==1)return;ue.preventDefault(),ue.stopPropagation();const Pe=ue.touches[0];if(Ow(We,wt,Pe.clientX,Pe.clientY)&&(Y=!0,Xe=null,ut&&ne()),$e===null&&(Math.abs(Pe.clientY-be)>8||Math.abs(Pe.clientX-Be)>8)&&($e=Math.abs(Pe.clientY-be)>Math.abs(Pe.clientX-Be)),!$e)return;const Ie=Pe.clientY-be;be=Pe.clientY,Ce=re(Ie,Ce,"scroll",Ji(Pe.clientX,Pe.clientY))},Xt=()=>{ne(),be=null,Be=null,We=null,wt=null,ke=null,pt=!1,Y=!1,te=!1,j(null),He(!1),Ce={mode:null,remainder:0},Bt=Date.now()},Dn=ue=>{if(te){Xe=null,ne(),(!ue.touches||ue.touches.length===0)&&Xt();return}const Pe=ue.changedTouches&&ue.changedTouches[0];if(!Y&&!pt&&!W.current&&Pe){const Ie={at:Date.now(),x:Pe.clientX,y:Pe.clientY},qe=ZA(U.current,Xe,Ie);Xe=qe.next,qe.open&&kn()}Xt()},Gt=()=>{Xe=null,Xt()};let Zi={mode:null,remainder:0};const fi=ue=>{ue.preventDefault(),ue.stopPropagation(),Zi=re(-ue.deltaY,Zi,"scroll",Ji(ue.clientX,ue.clientY))};Ge.addEventListener("touchstart",ri,{passive:!1}),Ge.addEventListener("touchmove",En,{passive:!1,capture:!0}),Ge.addEventListener("touchend",Dn,{passive:!0}),Ge.addEventListener("touchcancel",Gt,{passive:!0});const Zt=()=>{typeof window.matchMedia=="function"&&window.matchMedia(lm).matches||!W.current&&U.current==="double-tap"&&kn()};Ge.addEventListener("dblclick",Zt);const Qr=ue=>{(W.current||pt)&&(ue.preventDefault(),ue.stopPropagation())};Ge.addEventListener("contextmenu",Qr,!0),Ge.addEventListener("wheel",fi,{passive:!1,capture:!0});let Mi=null;const vr=ue=>{Date.now()-Bt>=Fe&&St("mouse"),TA(ue)&&(ue.preventDefault(),ue.stopPropagation(),Mi={cell:le(ue.clientX,ue.clientY),clientX:ue.clientX,clientY:ue.clientY,extendFrom:we.current,dragged:!1})},lc=ue=>{var Vt;if(!Mi){(Vt=K.hasSelection)!=null&&Vt.call(K)&&Et()&&(ue.preventDefault(),ue.stopPropagation());return}if(ue.preventDefault(),ue.stopPropagation(),!Mi.dragged&&!Ow(Mi.clientX,Mi.clientY,ue.clientX,ue.clientY))return;Mi.dragged=!0;const Pe=Mi.cell,Ie=le(ue.clientX,ue.clientY),qe=Pe.row*K.cols+Pe.col,mt=Ie.row*K.cols+Ie.col,yt=qe<=mt?Pe:Ie;K.select(yt.col,yt.row,Math.abs(mt-qe)+1)},Po=ue=>{if(!Mi)return;ue.stopPropagation();const{cell:Pe,extendFrom:Ie,dragged:qe}=Mi;if(Mi=null,qe||!Ie)return;const mt=BA({range:Ie,cell:Pe,cols:K.cols});if(!mt.moved)return;const yt=mt[mt.moved],Vt=K.buffer.active.getLine(yt.row);yt.col=da({line:Vt,col:yt.col,side:mt.moved,cols:K.cols});const en=Fw({start:mt.start,end:mt.end},K.cols);K.select(en.col,en.row,en.length)};Ge.addEventListener("mousedown",vr,!0),Ge.addEventListener("mousemove",lc,!0),Ge.addEventListener("mouseup",Po,!0);let Ft=null,Ns={x:0,y:0,type:"touch"};const Jr=()=>{Ft&&(clearInterval(Ft),Ft=null)},Io=(ue,Pe,Ie)=>{if(!it||!it.fixed)return;const qe=it.fixed,mt=Ie==="mouse"?le(ue,Pe):ot({clientX:ue,clientY:Pe},Re()),yt=K.buffer.active.getLine(mt.row),Vt={row:mt.row,col:da({line:yt,col:mt.col,side:it.which,cols:K.cols})},en=Math.max(0,Number(K.buffer.active.baseY||0)+K.rows-1),qn=zA({moving:Vt,fixed:qe,which:it.which,cols:K.cols,maxRow:en}),yn=Fw($w(qn,qe,K.cols),K.cols);K.select(yn.col,yn.row,yn.length);const Nn=Number(K.buffer.active.viewportY)||0,ts=qA({visibleRow:qn.row-Nn,rows:K.rows});Jr(),!(ts===0||K.buffer.active.type==="alternate")&&(Ft=setInterval(()=>{const $o=Number(K.buffer.active.viewportY)||0;if(K.scrollLines(ts),(Number(K.buffer.active.viewportY)||0)===$o){Jr();return}Io(Ns.x-it.offsetX,Ns.y-it.offsetY,Ns.type)},130))},Do=ue=>{it&&(ue.preventDefault(),Ns={x:ue.clientX,y:ue.clientY,type:ue.pointerType||Ns.type},Io(ue.clientX-it.offsetX,ue.clientY-it.offsetY,Ns.type))},Da=()=>{it=null,Jr(),Ee(null),window.removeEventListener("pointermove",Do),window.removeEventListener("pointerup",Vs),window.removeEventListener("pointercancel",Vs)},Vs=()=>Da();qt.current={startHandleDrag:(ue,Pe)=>{if(!K.getSelectionPosition())return;Pe.preventDefault(),Pe.stopPropagation();const Ie=$t.current&&$t.current[ue],qe=Ge.getBoundingClientRect();it={which:ue,offsetX:Ie?Pe.clientX-(qe.left+Ie.left):0,offsetY:Ie?Pe.clientY-(qe.top+Ie.top):0,fixed:we.current?ue==="start"?we.current.end:we.current.start:null},Ns={x:Pe.clientX,y:Pe.clientY,type:Pe.pointerType||"touch"},Ee(ue),xe(ue),window.addEventListener("pointermove",Do),window.addEventListener("pointerup",Vs),window.addEventListener("pointercancel",Vs)}};const Bo=ue=>{!PA(ue)||!(k.current&&k.current.term&&k.current.term.getSelection())||(ue.preventDefault(),ue.stopPropagation(),ft.current&&ft.current())};Ge.addEventListener("keydown",Bo,!0);const ms=()=>{ye.fit(),Qt.resize(K.cols,K.rows)};window.addEventListener("resize",ms);const Bn=window.visualViewport;let es=Bn&&Number(Bn.height);const gs=()=>{const ue=Bn&&Number(Bn.height);Ct&&U.current==="double-tap"&&Number.isFinite(es)&&Number.isFinite(ue)&&ue>es+80&&tt(),es=ue,ms()};Bn&&(Bn.addEventListener("resize",gs),Bn.addEventListener("scroll",ms));const On=typeof navigator<"u"?navigator.virtualKeyboard:null,_r=()=>{var ue;Ct&&U.current==="double-tap"&&Number(((ue=On==null?void 0:On.boundingRect)==null?void 0:ue.height)||0)===0&&tt()};(cc=On==null?void 0:On.addEventListener)==null||cc.call(On,"geometrychange",_r);let Hi=null,Zr=0;return typeof ResizeObserver<"u"&&(Hi=new ResizeObserver(()=>{Zr&&cancelAnimationFrame(Zr),Zr=requestAnimationFrame(ms)}),Hi.observe(Ge)),()=>{var ue;k.current=null,D.current&&(clearTimeout(D.current),D.current=null),c&&(c.current=()=>!1),d&&(d.current=()=>!1),h&&(h.current=()=>!1),pn.dispose(),Dt.dispose(),Ot.dispose(),Kt.dispose(),Jr(),window.removeEventListener("pointermove",Do),window.removeEventListener("pointerup",Vs),window.removeEventListener("pointercancel",Vs),qt.current={startHandleDrag:()=>{}},Ge.removeEventListener("touchstart",ri),Ge.removeEventListener("touchmove",En,{capture:!0}),Ge.removeEventListener("touchend",Dn),Ge.removeEventListener("touchcancel",Gt),Ge.removeEventListener("dblclick",Zt),Ge.removeEventListener("contextmenu",Qr,!0),ne(),Ge.removeEventListener("wheel",fi,{capture:!0}),Ge.removeEventListener("mousedown",vr,!0),Ge.removeEventListener("mousemove",lc,!0),Ge.removeEventListener("mouseup",Po,!0),Ge.removeEventListener("keydown",Bo,!0),Ge.removeEventListener("paste",Ai,!0),Ge.removeEventListener("dragenter",Wn,!0),Ge.removeEventListener("dragover",Wn,!0),Ge.removeEventListener("drop",Qi,!0),window.removeEventListener("resize",ms),Bn&&(Bn.removeEventListener("resize",gs),Bn.removeEventListener("scroll",ms)),(ue=On==null?void 0:On.removeEventListener)==null||ue.call(On,"geometrychange",_r),Ae==null||Ae.removeEventListener("blur",zt),Hi&&Hi.disconnect(),Zr&&cancelAnimationFrame(Zr),Qt.close(),K.dispose()}},[t,e,n,i,s,c,d,h,f,g,_]),b.useEffect(()=>{const K=N.current,ye=k.current?k.current.term:null;if(!K||!ye||!ge){fe(null),Le(null),at(null);return}const ct=(K.querySelector(".xterm-screen")||K).getBoundingClientRect(),st=K.getBoundingClientRect(),xt=ct.width/Math.max(1,ye.cols),Et=ct.height/Math.max(1,ye.rows),jt=WA({range:ge,viewportY:Number(ye.buffer.active.viewportY)||0,rows:ye.rows,cols:ye.cols,cellWidth:xt,cellHeight:Et,screenLeft:ct.left-st.left,screenTop:ct.top-st.top});fe(jt);let Ct=null;const Xe=ge[Se==="end"?"end":"start"].row;typeof ye.buffer.active.getLine=="function"&&(Ct=ye.buffer.active.getLine(Number(Xe)));const tt=Math.max(16,Math.round(Et*2)),Nt=Ct?{...KA({range:ge,side:Se,line:Ct,cols:ye.cols}),fontSize:tt}:null;Le(Nt);const kn=me!==null||ze,Ae=jt[Se==="end"?"end":"start"];if(!kn||!Nt||!Ae||!Ae.visible){at(null);return}const zt=(Nt.before+Nt.sel+Nt.after).length,Qt=xt*(tt/Math.max(1,Et)),Tt=Math.min(st.width-8,Math.round(zt*Qt)+16),pn=Math.round(tt*1.25)+12;at(HA({anchorLeft:Ae.left,anchorTop:Ae.top,hostWidth:st.width,hostHeight:st.height,bubbleWidth:Tt,bubbleHeight:pn}))},[ge,ie,Se,me,ze]);const F=OA(lt),J=b.useRef({}),ee=(K,ye)=>{if(me!==K)return J.current[K]={flip:ye,ts:0},ye;const Ze=J.current[K]||{flip:ye,ts:0};if(Ze.flip===ye)return J.current[K]=Ze,ye;const ct=Date.now();return ct-Ze.ts<UA?Ze.flip:(J.current[K]={flip:ye,ts:ct},ye)};return l.jsxs("div",{className:`nc-terminal${w?" selecting":""}`,children:[l.jsx("div",{className:"nc-terminal-host",ref:N}),M&&l.jsxs("div",{className:"nc-terminal-link-overlay",children:["riconnessione…",R>0?` (${R} byte in coda)`:""]}),$&&l.jsx("div",{className:"nc-touch-selection-caret",style:$,"aria-hidden":"true"}),ge&&_e&&F.handles&&["start","end"].map(K=>_e[K].visible&&l.jsx("div",{className:`nc-sel-handle ${K}${me===K?" dragging":""}${ee(K,_e[K].flip)?" flip":""}${FA({startLeft:_e.start.left,endLeft:_e.end.left})?" tight":""}`,style:{left:`${_e[K].left}px`,top:`${_e[K].top}px`},onPointerDown:ye=>qt.current.startHandleDrag(K,ye),"aria-hidden":"true"},`nc-sel-handle-${K}`)),ge&&Ye&&F.magnifier&&_t&&l.jsx("div",{className:`nc-zoom-bubble${_t.flipped?" flipped":""}`,style:{left:`${_t.left}px`,top:`${_t.top}px`},"aria-hidden":"true",children:l.jsxs("pre",{className:"nc-zoom-line",style:{fontSize:`${Ye.fontSize}px`},children:[l.jsx("span",{children:Ye.before}),l.jsx("span",{className:"nc-zoom-sel",children:Ye.sel}),l.jsx("span",{children:Ye.after})]})}),T&&l.jsx("div",{className:`nc-upload-state${T.error?" error":""}`,role:"status",children:T.error?T.error:T.done?p("attach-uploaded").replace("{n}",String(T.total||0)):p("attach-upload-progress").replace("{n}",String(T.current||0)).replace("{total}",String(T.total||0))}),(G||w)&&l.jsxs("div",{className:"nc-selection-tools",children:[G?l.jsx("button",{type:"button",onClick:Wt,children:Q||`${p("copy")} · ${IA(typeof navigator<"u"?navigator.userAgent:"")}`}):l.jsx("span",{children:p("select-drag")}),G&&q&&l.jsx("span",{className:"nc-selection-held",children:p("selection-held")}),G&&!q&&fn&&l.jsx("span",{className:"nc-selection-changed",children:p("selection-changed")}),l.jsx("button",{type:"button",onClick:()=>{var K,ye;(ye=(K=k.current)==null?void 0:K.term)==null||ye.clearSelection(),X(""),ce(!1),S==null||S(!1)},children:p("cancel")}),Q===p("copy-manual")&&l.jsx("textarea",{readOnly:!0,value:G,onFocus:K=>K.target.select()})]})]})}function Vl(t,e,n){const i=c=>Number.isInteger(c)&&c>0&&c<65536?c:0;if(t==null)return i(n);if(!Array.isArray(t))return 0;if(t.length===0)return i(n);const s=typeof t[0]=="string"?t[0]:null;return s?i((e&&typeof e=="object"?e:{})[s]):0}const uM=6901;function tg({cellId:t,panelUrl:e,route:n=[],panelPort:i=0,token:s,title:a,requestTimeoutMs:c=4e3}){const[d,h]=b.useState(t&&s?"requesting":"none"),[f,g]=b.useState(""),_=Array.isArray(n)?n.join("\0"):"",y=b.useMemo(()=>Array.isArray(n)?n:[],[_]),w=b.useRef(0),S=b.useCallback(async()=>{if(!t||!s||!e){h("none");return}const T=w.current+=1;h("requesting");const I=new AbortController,$=setTimeout(()=>I.abort(),c);try{const j=await c2(s,y,t,{signal:I.signal});if(clearTimeout($),T!==w.current)return;if(j.ok){let M="/";try{M=new URL(e).pathname||"/"}catch{}const L=i?`http://127.0.0.1:${i}`:hn(y);g(`${L}/panel/${encodeURIComponent(t)}${M}?ticket=${encodeURIComponent(j.ticket)}`),h("ready")}else h(j.cause)}catch(j){if(clearTimeout($),T!==w.current)return;h(j&&j.name==="AbortError"?"timeout":"unreachable")}},[t,e,y,i,s,c]),A=b.useCallback(()=>{h(T=>T==="ready"?"loaded":T)},[]),C=b.useCallback(()=>{h(T=>T==="ready"||T==="loaded"?"frame-error":T)},[]),N=b.useRef(null),k=b.useCallback(T=>{T&&(N.current=T,T.onload=A,T.onerror=C)},[A,C]);b.useEffect(()=>{S()},[S]);const P=b.useMemo(()=>{try{return Number(new URL(e).port)===uM}catch{return!1}},[e])&&y.length===0,[H,W]=b.useState(!1),[U,G]=b.useState("");b.useEffect(()=>{const T=I=>{const $=N.current;if(!$||!$.contentWindow||I.source!==$.contentWindow)return;let j=null;try{j=new URL(f,window.location.href).origin}catch{return}!j||I.origin!==j||!I.data||I.data.type!=="nc-panel-unreachable"||h(M=>M==="ready"||M==="loaded"?"unreachable":M)};return window.addEventListener("message",T),()=>window.removeEventListener("message",T)},[f]);const X=b.useCallback(async()=>{if(!s||H)return;W(!0),G("");let T=!1;try{const I=await Y0(s,!0);I&&I.ok===!1&&(G(I.error||"comando fallito"),T=!0)}catch(I){G(String(I&&I.message||I)),T=!0}W(!1),T||S()},[s,H,S]),Q=(T,I=!0,$=null)=>l.jsxs("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:[l.jsx("span",{children:p(T)}),I&&l.jsxs("span",{className:"nc-cellpanel-actions",children:[$,l.jsx("button",{type:"button",title:p("panel-retry"),onClick:()=>S(),children:p("panel-retry")})]})]}),V=P?l.jsx("button",{type:"button",disabled:H,onClick:X,children:p("panel-start-desktop")}):null;return d==="none"||d==="no-panel"?Q("panel-none",!1):d==="requesting"?l.jsx("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:l.jsx("span",{children:p("panel-checking")})}):d==="not-granted"?Q("panel-not-granted",!1):d==="node-refused"?Q("panel-node-refused",!1):d==="unauthorized"?Q("panel-unauthorized",!1):d==="denied"?Q("panel-denied"):d==="timeout"?Q("panel-timeout"):d==="unreachable"?l.jsxs("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:[l.jsxs("span",{children:[p("panel-unreachable"),U?` — ${U}`:""]}),l.jsxs("span",{className:"nc-cellpanel-actions",children:[V,l.jsx("button",{type:"button",title:p("panel-retry"),onClick:()=>S(),children:p("panel-retry")})]})]}):d==="frame-error"?Q("panel-frame-error",!0,V):l.jsxs(l.Fragment,{children:[d==="ready"&&l.jsx("div",{className:"nc-cellpanel-loading",role:"status",children:p("panel-frame-loading")}),l.jsx("iframe",{ref:k,className:"nc-cellpanel nc-cellpanel-frame","data-frame-state":d,src:f,title:a||p("panel"),allowFullScreen:!0})]})}const dM=1800*1e3;function dm(t,e,n=Date.now()){const i=Number(e);if(!Number.isFinite(i)||i<=0)return"";const s=n-i;if(s<0||s>dM)return"";if(s<60*1e3)return`${t("cell-activity")} ${t("cell-activity-now")}`;const a=Math.floor(s/6e4);return a<60?`${t("cell-activity")} ${a}m`:`${t("cell-activity")} ${Math.floor(a/60)}h`}function hm(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 ng({row:t,token:e,panelPort:n=0,liveHost:i=null,onLiveHostApplied:s,source:a,onSourceChange:c,fontSize:d,readOnly:h=!1,chrome:f=!0}){const g=G=>c&&c(G),_=b.useRef(()=>{}),y=b.useRef(()=>!1),w=b.useRef(()=>{}),S=b.useRef(!1),[A,C]=b.useState(!1),[N,k]=b.useState(""),[O,P]=b.useState(!1),H=!!(i&&i.cell&&i.cell===t.cellName),W=async()=>{P(!0);const G=await ud({action:H?"remove":"use",cellId:t.cellName,route:t.route||[],token:e,api:{getLiveHost:X=>ad(e,X),designateHostCell:(X,Q,V)=>ld(e,X,Q,V),clearHostCell:(X,Q)=>cd(e,X,Q)}});P(!1),k(p(G.messageKey).replace("{cell}",G.hostCell||t.cellName)),G.ok&&s&&s({route:t.route||[],hostCell:G.hostCell,revision:G.revision})},U=[["preview",p("cell-peek-preview")],["stream",p("cell-peek-stream")],...t.panelUrl?[["panel",p("cell-peek-panel")]]:[]];return l.jsxs(l.Fragment,{children:[f&&l.jsx("div",{className:"nc-peek-sorgenti",role:"tablist",children:U.map(([G,X])=>l.jsx("button",{type:"button",role:"tab","aria-selected":a===G,className:`nc-peek-sorgente${a===G?" attiva":""}`,onClick:()=>g(G),children:X},G))}),f&&l.jsxs("div",{className:"nc-peek-host",children:[l.jsx("button",{type:"button",className:"nc-peek-host-btn",disabled:O,onClick:W,children:p(H?"live-host-action-remove":"live-host-action-use")}),N&&l.jsx("div",{className:"nc-peek-notice",role:"status",children:N})]}),a==="stream"?l.jsx("div",{className:"nc-peek-stream",children:l.jsx($l,{session:t.session,node:t.node||void 0,token:e,readonly:h,takeSize:!1,focused:!0,sendRef:_,composerRef:y,actionRef:w,ctrlRef:S,setCtrlArmed:C,fontSize:d},`peek:${t.key}`)}):a==="panel"?l.jsx(tg,{cellId:t.cellName,panelUrl:t.panelUrl,route:t.route||[],panelPort:n,token:e,title:t.cellName}):l.jsxs(l.Fragment,{children:[l.jsx("pre",{className:"nc-peek-testo",children:t.preview||p("cell-peek-vuoto")}),[dm(p,t.activity),hm(p,t.telemetry)].filter(Boolean).join(" · ")&&l.jsx("small",{className:"nc-cell-switcher-telemetry",children:[dm(p,t.activity),hm(p,t.telemetry)].filter(Boolean).join(" · ")})]})]})}function j1({row:t,token:e,initialSource:n="preview",panelPort:i=0,onClose:s,liveHost:a=null,onLiveHostApplied:c}){const[d,h]=b.useState(n==="panel"&&!t.panelUrl?"preview":n);return l.jsx(eS,{title:t.cellName,subtitle:[t.nodeLabel,t.subtitle].filter(Boolean).join(" · "),onClose:s,children:l.jsx(ng,{row:t,token:e,panelPort:i,liveHost:a,onLiveHostApplied:c,source:d,onSourceChange:h})})}const hM=["all","pinned","active","off","technical"],T1="nc_sidebar_views_v1",P1="nc_sidebar_order_v1";function I1(t){return hM.includes(t)?t:"all"}function fM(t,e=[],n="all"){const i=I1(n);return i==="technical"?t.technical===!0:t.technical===!0?!1:i==="pinned"?e.includes(t.key):i==="active"?!!t.live:i==="off"?!t.live:!0}function pM(t,e,n=[],i=[]){const s=n.indexOf(t.key),a=n.indexOf(e.key),c=s===-1?Number.MAX_SAFE_INTEGER:s,d=a===-1?Number.MAX_SAFE_INTEGER:a,h=i.indexOf(t.key),f=i.indexOf(e.key),g=h===-1?Number.MAX_SAFE_INTEGER:h,_=f===-1?Number.MAX_SAFE_INTEGER:f;return c-d||g-_||+!!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 mM(t=globalThis.localStorage){try{const e=JSON.parse(t.getItem(P1));if(!e||typeof e!="object"||Array.isArray(e))return{};const n={};for(const[i,s]of Object.entries(e).slice(0,64)){if(typeof i!="string"||!i||i.length>160||!Array.isArray(s))continue;const a=[...new Set(s.filter(c=>typeof c=="string"&&c&&c.length<=256))].slice(0,128);a.length&&(n[i]=a)}return n}catch{return{}}}function hr(t,e){return Array.isArray(t==null?void 0:t[e])?t[e]:[]}function gM(t,e=globalThis.localStorage){try{e.setItem(P1,JSON.stringify(t))}catch{}return t}function vM(t,e,n,i,s=[]){if(typeof e!="string"||!e||n===i)return t;const a=[...new Set(s.filter(y=>typeof y=="string"&&y))];if(!a.includes(n)||!a.includes(i))return t;const c=hr(t,e).filter(y=>a.includes(y)),d=[...c,...a.filter(y=>!c.includes(y))],h=d.indexOf(n),f=d.indexOf(i);d.splice(h,1);const g=d.indexOf(i),_=h<f?g+1:g;return d.splice(_,0,n),{...t,[e]:d}}function _M(t=globalThis.localStorage){try{const e=JSON.parse(t.getItem(T1));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function qw(t,e){var n,i;return{open:((n=t==null?void 0:t[e])==null?void 0:n.open)!==!1,filter:I1((i=t==null?void 0:t[e])==null?void 0:i.filter)}}function yM(t,e=globalThis.localStorage){try{e.setItem(T1,JSON.stringify(t))}catch{}return t}function Kw(t,e=""){const n=String(e||"").trim().toLocaleLowerCase();return n?[t.label,t.key,t.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(n):!0}function Gr(t=[],e=[],n="all",i=[]){return[...t].filter(s=>fM(s,e,n)).sort((s,a)=>pM(s,a,e,i))}function Li(){return[b.useSyncExternalStore(lE,Ou,Ou),aE]}function Vu({cell:t,token:e,route:n=[],onConfirm:i,onClose:s}){var M,L;Li();const a=!!(t&&t.active),c=Array.isArray(n)?n.join("/"):"",[d,h]=b.useState([]),[f,g]=b.useState(!1);b.useEffect(()=>{let R=!0;return(async()=>{if(e)try{const E=await fr(e,c?c.split("/"):[]);if(!R)return;if(g(E.provider==="builtin"&&(E.capabilities||[]).includes("edit")),E.provider==="builtin"&&(E.capabilities||[]).includes("definitions")){const z=await rd(e,c?c.split("/"):[]);if(!R)return;const D=new Map((E.engines||[]).map(q=>[q.id,q]));h((z.engines||[]).map(q=>{var ce,ge,se,we,_e,fe,ie;return{id:q.id,label:q.label||q.id,client:((ce=q.managed)==null?void 0:ce.client)||"",models:[...new Set([...((ge=D.get(q.id))==null?void 0:ge.models)||[],...((se=q.managedInfo)==null?void 0:se.models)||[]])].filter(Boolean),defaultModel:((we=q.managed)==null?void 0:we.model)||((_e=q.managedInfo)==null?void 0:_e.defaultModel)||"",policyDefault:((fe=q.managed)==null?void 0:fe.permissionPolicy)||((ie=q.managed)!=null&&ie.client&&q.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{R=!1}},[e,c]);const _=(t==null?void 0:t.engine)||((M=d[0])==null?void 0:M.id)||"",y=R=>(t==null?void 0:t.models)&&t.models[R]||"",w=R=>{const E=(t==null?void 0:t.permissionPolicies)&&t.permissionPolicies[R];if(E==="standard"||E==="unsafe")return E;const z=d.find(D=>D.id===R);return z?z.policyDefault:"standard"},[S,A]=b.useState(_),[C,N]=b.useState((t==null?void 0:t.model)||""),k=(t==null?void 0:t.permissionPolicy)==="standard"||(t==null?void 0:t.permissionPolicy)==="unsafe"?t.permissionPolicy:((L=t==null?void 0:t.permissionPolicies)==null?void 0:L[t==null?void 0:t.engine])||"",[O,P]=b.useState(k),[H,W]=b.useState((t==null?void 0:t.boot)??!0),[U,G]=b.useState(!1),[X,Q]=b.useState(null);b.useEffect(()=>{d.length&&(A(R=>R||_),N(R=>R||y((t==null?void 0:t.engine)||_)||""),P(R=>R==="standard"||R==="unsafe"?R:w((t==null?void 0:t.engine)||_)))},[d.length]);const V=b.useMemo(()=>d.find(R=>R.id===S)||null,[d,S]),T=!!(V&&["claude","codex","codex-vl","agy","kimi"].includes(V.client)),I=(V==null?void 0:V.client)==="shell";function $(R){A(R);const E=d.find(z=>z.id===R);N(y(R)||(E==null?void 0:E.defaultModel)||""),P(w(R))}async function j(R){R.preventDefault(),G(!0),Q(null);try{if(a)await i({action:"down",boot:H});else{const E=O==="standard"||O==="unsafe"?O:(V==null?void 0:V.policyDefault)||"standard";await i({action:"up",...f?{engine:S,model:C||"",...T?{permissionPolicy:E}:(V==null?void 0:V.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:H})}s()}catch(E){Q(String(E&&E.message||E)),G(!1)}}return l.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:s,children:l.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:R=>R.stopPropagation(),onSubmit:j,children:[l.jsxs("div",{className:"nc-sheet-head",children:[l.jsx("b",{children:t==null?void 0:t.cell}),l.jsx("span",{className:"nc-sheet-state",children:p(a?"state-on":"state-off")})]}),a?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-power-config",children:[l.jsx("span",{children:p("engine")}),l.jsx("b",{children:(t==null?void 0:t.engine)||"—"}),(t==null?void 0:t.model)&&l.jsxs("small",{children:[p("model"),": ",t.model]}),l.jsx("small",{children:p("power-on-hint")})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:H,onChange:R=>W(R.target.checked)}),p("remove-boot")]})]}):l.jsxs(l.Fragment,{children:[f&&d.length>0?l.jsxs("div",{className:"nc-launch-fields",children:[l.jsxs("label",{className:"nc-field",children:[p("engine"),l.jsx("select",{value:S,onChange:R=>$(R.target.value),children:d.map(R=>l.jsx("option",{value:R.id,children:R.label},R.id))})]}),!I&&l.jsxs("label",{className:"nc-field",children:[p("model"),l.jsx("input",{value:C,list:"nc-launch-models",placeholder:p("model-default"),onChange:R=>N(R.target.value)}),l.jsx("datalist",{id:"nc-launch-models",children:((V==null?void 0:V.models)||[]).map(R=>l.jsx("option",{value:R},R))})]}),T?l.jsxs("label",{className:"nc-field",children:[p("permissions"),l.jsxs("select",{value:O,onChange:R=>P(R.target.value),children:[l.jsx("option",{value:"standard",children:p("fleet-standard-permissions")}),l.jsx("option",{value:"unsafe",children:p("fleet-unsafe-permissions")})]})]}):l.jsx("small",{className:"nc-note",children:p("fleet-standard-permissions")}),T&&O==="unsafe"&&l.jsx("small",{className:"nc-err",children:p("fleet-unsafe-warning")}),l.jsx("small",{className:"nc-note",children:p(I?"fleet-shell-launch-help":"launch-engine-help")})]}):l.jsxs("div",{className:"nc-power-config",children:[l.jsx("span",{children:p("engine")}),l.jsx("b",{children:(t==null?void 0:t.engine)||"—"}),(t==null?void 0:t.model)&&l.jsxs("small",{children:[p("model"),": ",t.model]}),l.jsx("small",{children:p("launch-unavailable-hint")})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:H,onChange:R=>W(R.target.checked)}),p("boot-persist")]})]}),X&&l.jsx("div",{className:"nc-err",children:X}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:s,children:p("cancel")}),l.jsx("button",{type:"submit",className:"nc-btn primary",disabled:U,children:p(U?a?"power-stopping":"power-starting":a?"power-off":"save-and-start")})]})]})})}const Vw=/^[a-z0-9-]{1,32}$/;function Ca(t,e){const n=Array.isArray(t)?t:[];return n.length?`${n.map(encodeURIComponent).join("/")}:${e}`:String(e)}function wM(t,e,n){const i={};for(const s of Array.isArray(e)?e:[]){const a=Array.isArray(s==null?void 0:s.route)?s.route:typeof(s==null?void 0:s.name)=="string"?[s.name]:[];if(!a.length)continue;const c=a.join("/"),d=s.status==="up"||s.tunnel&&s.tunnel.status==="up",h=s.status==="passive"||s.tunnel&&s.tunnel.status==="passive";!d&&!h&&(i[c]=t&&t[c]||n)}return i}function fm(t,e,n,i=!1){return!t||!Array.isArray(t.cells)?[]:t.cells.map(s=>({...s,route:e,key:`${n}:${s.tmuxSession||s.cell}`,...i?{preserved:!0}:{}}))}function Sl(t,e,n){if(!t)return{};const i=pm(t);return!Dl(t,i)||i!=="stale"?{}:{cells:fm(t,e,n,!0),fleetState:"stale",fleetAvailable:!1,cellsPreserved:!0}}function pm(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 Dl(t,e){return(e==="available"||e==="stale")&&Array.isArray(t==null?void 0:t.cells)}function Yw(t,e){const n=t?e&&e.at:e&&e.lastGoodAt;return Number.isFinite(n)?n:null}function Gw({nodes:t,topology:e,remote:n,down:i,fleet:s,aliases:a}={}){var f,g,_,y;const c=[],d=new Set,h=new Set;for(const w of Array.isArray(t)?t:[]){if(!w||typeof w.name!="string"||!Vw.test(w.name)||w.direction==="inbound"&&w.shared!==!0)continue;const S=[w.name],A=w.name;d.add(A);const C=((f=w.tunnel)==null?void 0:f.status)||"unknown",N=C==="up",k={name:w.name,label:w.label||w.name,originalLabel:w.label||w.name,alias:null,route:S,direct:!0,instanceId:w.nodeId||null,shared:w.shared===!0,stale:w.stale===!0,tunnelStatus:C,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:w.health||null,direction:w.direction||"outbound",roles:w.roles||null,rolesKnown:w.rolesKnown===!0};if(w.nodeId&&h.add(w.nodeId),!w.nodeId&&w.paired===!1){c.push({...k,status:"needs-repair",downSince:i&&i[A]||null,...Sl(s&&(s[A]||s[w.name]),S,A)});continue}if(((g=w.health)==null?void 0:g.auth)==="failed"||C==="degraded"&&((_=w.health)==null?void 0:_.status)==="degraded"){c.push({...k,status:"needs-repair",downSince:i&&i[A]||null,...Sl(s&&(s[A]||s[w.name]),S,A)});continue}if(C==="passive"||((y=w.health)==null?void 0:y.status)==="passive"){c.push({...k,status:"passive",downSince:null,...Sl(s&&(s[A]||s[w.name]),S,A)});continue}if(!N){c.push({...k,status:"down",downSince:i&&i[A]||null,...Sl(s&&(s[A]||s[w.name]),S,A)});continue}const O=n&&(n[A]||n[w.name])||null,P=s&&(s[A]||s[w.name]),H=!!(O&&!O.error&&Array.isArray(O.sessions)),W=pm(P),U=W==="available"&&Dl(P,W),G=Dl(P,W);if(!H&&!G){c.push({...k,status:"unreachable",cause:O&&O.cause||null});continue}const X=(H?O.sessions:[]).filter(T=>T&&typeof T.name=="string"&&T.name).map(T=>({...T,node:A,route:S,key:`${A}:${T.name}`})),Q=fm(P,S,A),V=new Set(Q.map(T=>T.tmuxSession).filter(Boolean));c.push({...k,status:"up",sessions:X,cells:Q,unmanaged:X.filter(T=>!V.has(T.name)),fleetAvailable:U,fleetState:W,capabilities:P&&P.capabilities||[],engines:P&&P.engines||[],fleetProvider:P&&P.provider||null,sessionsAvailable:H,inventoryPartial:!H,verifiedAt:Yw(H,O)})}for(const w of Array.isArray(e)?e:[]){if(!w||!Array.isArray(w.route)||w.route.length<1||w.route.some(V=>!Vw.test(V)))continue;const S=w.route.join("/");if(d.has(S)||w.instanceId&&h.has(w.instanceId))continue;w.instanceId&&h.add(w.instanceId);const A=w.label||w.route.join(" › "),C=w.instanceId&&a&&typeof a[w.instanceId]=="string"?a[w.instanceId]:null,N={name:w.name,label:C||A,originalLabel:A,alias:C,route:[...w.route],direct:!1,instanceId:w.instanceId||null,shared:!0,stale:w.stale===!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:w.health||null,lastSeen:w.lastSeen||null};if(w.stale){c.push({...N,status:"offline",downSince:i&&i[S]||w.lastSeen||null,...Sl(s&&s[S],w.route,S)});continue}const k=n&&n[S]||null,O=s&&s[S],P=!!(k&&!k.error&&Array.isArray(k.sessions)),H=pm(O),W=H==="available"&&Dl(O,H),U=Dl(O,H);if(!P&&!U){c.push({...N,status:"unreachable",downSince:i&&i[S]||null,cause:k&&k.cause||null});continue}const G=(P?k.sessions:[]).filter(V=>V&&typeof V.name=="string"&&V.name).map(V=>({...V,node:S,route:w.route,key:`${S}:${V.name}`})),X=fm(O,w.route,S),Q=new Set(X.map(V=>V.tmuxSession).filter(Boolean));c.push({...N,status:"up",sessions:G,cells:X,unmanaged:G.filter(V=>!Q.has(V.name)),fleetAvailable:W,fleetState:H,capabilities:O&&O.capabilities||[],engines:O&&O.engines||[],fleetProvider:O&&O.provider||null,lastSeen:w.lastSeen||null,sessionsAvailable:P,inventoryPartial:!P,verifiedAt:Yw(P,k)})}return c.sort((w,S)=>w.label.localeCompare(S.label))}function D1(t,e={}){if(!t||typeof t!="object")return null;const n=typeof t.nodeId=="string"?t.nodeId:"";if(!n)return null;const i=typeof t.label=="string"&&t.label.trim()||typeof t.cell=="string"&&t.cell.trim()||n,s=Array.isArray(e.route)?[...e.route]:[];return{kind:"vl",nodeId:n,name:n,label:i,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:s,isLocal:s.length===0,ownerInstanceId:typeof e.instanceId=="string"?e.instanceId:null,ownerLabel:typeof e.label=="string"&&e.label?e.label:null}}function bM(t){var n;const e=[];for(const i of Array.isArray(t)?t:[]){if(!i||i.kind!=="vl"||!i.nodeId)continue;const s=i.online===!0,a=s&&((n=i.session)==null?void 0:n.attached)===!0,c=i.ownerInstanceId||"local";e.push({kind:"vl",name:`vl-${i.nodeId.slice(0,8)}`,label:i.label,route:Array.isArray(i.route)?[...i.route]:[],instanceId:null,direct:!1,status:s?"up":"offline",downSince:s?null:i.lastSeen??null,sessions:a?[{key:`vl:${c}:${i.nodeId}`,name:i.session.profile,attached:!0}]:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:i.health??null,peer:i})}return e}function B1(t,e){const n=t&&Array.isArray(t.nodes)?t.nodes:[],i=new Set([e]),s=[];for(const a of n){const c=a&&typeof a.instanceId=="string"?a.instanceId:"";if(!c||i.has(c)||a.stale===!0||!Array.isArray(a.route)||a.route.length===0)continue;i.add(c);const d=typeof a.label=="string"&&a.label||typeof a.name=="string"&&a.name||a.route.join(" › ");s.push({instanceId:c,route:[...a.route],label:d})}return s}const SM=/fleet\.json/;function ig({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}:SM.test(n)?{kind:"stale"}:{kind:"disabled",reason:n||null}}const O1={baseMs:4e3,capMs:6e4},$1="peer-assente",z1="peer-nega",F1="rotta-inesistente";function Rf(t){const e=t&&t.status;return e===403?z1:e===404?F1:$1}function xM(t,{baseMs:e,capMs:n}=O1){return!Number.isFinite(t)||t<1?0:Math.min(e*2**(t-1),n)}function Xw(t,e,n){const i=t&&t[e];return!i||!(i.failures>=1)?!0:n>=i.nextAtMs}function Qw(t,e,n,i,s=O1){const c=(t&&t[e]||{failures:0}).failures+1;return{...t,[e]:{failures:c,cause:n,nextAtMs:i+xM(c,s)}}}function Jw(t,e){if(!t||!(e in t))return t;const n={...t};return delete n[e],n}const CM=4e3,H1=600*1e3,U1="nc-sticky-owners-v1";function kM(){try{const t=localStorage.getItem(U1);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 EM(t){try{localStorage.setItem(U1,JSON.stringify(t))}catch{}}function Zw(t,e,n,i,s){if(!e){for(const c of t.values())c.data={...c.data,stale:!0};return t}const a=new Map(n.map(c=>[i(c),c]));for(const[c,d]of t)a.has(c)?(d.data=a.get(c),d.missingSince=null,a.delete(c)):(d.missingSince??(d.missingSince=s),s-d.missingSince>H1?t.delete(c):d.data={...d.data,stale:!0});for(const[c,d]of a)t.set(c,{data:d,missingSince:null});return t}function sg(t,e=!0,n=0){const[i,s]=b.useState([]),a=b.useRef({}),c=b.useRef({}),d=b.useRef({remote:{},fleet:{}}),h=b.useRef(null),f=b.useRef(!1);return b.useEffect(()=>{if(!e||!t){s([]);return}let g=!0;h.current!==t&&(h.current=t,c.current={},d.current={remote:{},fleet:{}},a.current={});const _={instanceId:"",nodes:new Map,topology:new Map},y=kM();if(y){_.instanceId=y.instanceId||"";for(const C of y.nodes)_.nodes.set(C.name,{data:C,missingSince:null});for(const C of y.topology)_.topology.set(C.route.join("/"),{data:C,missingSince:null})}async function w(){if(!f.current){f.current=!0;try{await S()}finally{f.current=!1}}}async function S(){var $,j;const C=Date.now();let N=[],k=[],O={},P="",H=!1,W=!1;if(await Promise.all([x2(t).then(M=>{N=Array.isArray(M.nodes)?M.nodes:[],H=!0}).catch(()=>{}),V0(t).then(M=>{k=Array.isArray(M.nodes)?M.nodes:[],W=!0}).catch(()=>{}),A2(t).then(M=>{O=M&&typeof M.aliasesByInstanceId=="object"?M.aliasesByInstanceId:{}}).catch(()=>{}),un("/api/config",t).then(M=>M.json()).then(M=>{P=M&&typeof M.instanceId=="string"?M.instanceId:""}).catch(()=>{})]),!g)return;P&&_.instanceId!==P?(_.instanceId=P,_.nodes.clear(),_.topology.clear(),c.current={},d.current={remote:{},fleet:{}}):P&&(_.instanceId=P),Zw(_.nodes,H,N,M=>M&&M.name,C),Zw(_.topology,W,k,M=>Array.isArray(M&&M.route)?M.route.join("/"):"",C),N=[..._.nodes.values()].map(M=>M.data),k=[..._.topology.values()].map(M=>M.data),(H||W)&&EM({instanceId:_.instanceId,savedAt:C,nodes:[..._.nodes.values()].map(M=>M.data),topology:[..._.topology.values()].map(M=>M.data)});const U=[{instanceId:P||null,route:[],label:null},...B1({nodes:k},P)],G=[];if(await Promise.all(U.map(async M=>{const L=`vl:${M.route.join("/")}`;if(Xw(c.current,L,C))try{const R=await K0(t,M.route);c.current=Jw(c.current,L);for(const E of R.nodes||[]){const z=D1(E,M);z&&G.push(z)}}catch(R){c.current=Qw(c.current,L,Rf(R),C)}})),!g)return;const X={},Q={},V=new Set(N.map(M=>M.name)),T=[];for(const M of N)(($=M.tunnel)==null?void 0:$.status)==="up"&&(M.nodeId||M.paired!==!1)&&(M.direction!=="inbound"||M.shared===!0)&&T.push([M.name]);for(const M of k)!M.stale&&Array.isArray(M.route)&&M.route.length>0&&!(M.route.length===1&&V.has(M.route[0]))&&T.push(M.route);if(await Promise.all(T.map(async M=>{const L=M.join("/"),R=d.current.remote[L]||null;if(!Xw(c.current,L,C)){const D=c.current[L];X[L]={error:"unreachable",cause:D&&D.cause||null,lastGoodAt:R?R.at:null};const q=d.current.fleet[L];q&&(Q[L]={...q,available:!1,fleetState:"stale"});return}let E=!1;try{const D=await Bm(t,M);E=!0,X[L]={...D,at:C},d.current.remote[L]={payload:D,at:C}}catch(D){X[L]={error:"unreachable",cause:Rf(D),lastGoodAt:R?R.at:null}}const z=d.current.fleet[L]||null;try{const D=await fr(t,M),q=ig({fs:D});q.kind==="data"?Q[L]={...D,available:!0,cells:q.cells,fleetState:"available"}:q.kind==="disabled"?Q[L]={...D,available:!1,cells:[],fleetState:"disabled"}:Q[L]={...z||{},available:!1,cells:Array.isArray(z==null?void 0:z.cells)?z.cells:[],fleetState:"stale",...D!=null&&D.reason?{reason:D.reason}:{}},d.current.fleet[L]=Q[L]}catch(D){Q[L]={...z||{},available:!1,cells:Array.isArray(z==null?void 0:z.cells)?z.cells:[],fleetState:"stale",cause:Rf(D)},d.current.fleet[L]=Q[L]}c.current=E?Jw(c.current,L):Qw(c.current,L,X[L].cause,C)})),!g)return;for(const M of N){if(((j=M.tunnel)==null?void 0:j.status)==="up")continue;const L=d.current.fleet[M.name];L&&!Q[M.name]&&(Q[M.name]={...L,available:!1,fleetState:"stale"})}for(const M of k){if(!M.stale||!Array.isArray(M.route)||!M.route.length)continue;const L=M.route.join("/"),R=d.current.fleet[L];R&&!Q[L]&&(Q[L]={...R,available:!1,fleetState:"stale"})}const I=Gw({nodes:N,topology:k,remote:X,fleet:Q,aliases:O,down:a.current});a.current=wM(a.current,I,Math.floor(Date.now()/1e3)),s([...Gw({nodes:N,topology:k,remote:X,fleet:Q,aliases:O,down:a.current}),...bM(G)])}w();const A=setInterval(w,CM);return()=>{g=!1,clearInterval(A)}},[t,e,n]),i}const eb=52,tb=14;function Os({position:t,itemKey:e,label:n,onMove:i,onStep:s,canMove:a=()=>!0,scope:c="roster"}){const d=b.useRef(null),h=b.useRef(0),[f,g]=b.useState(!1),_=()=>{var N,k,O,P;const C=d.current;(k=(N=C==null?void 0:C.over)==null?void 0:N.classList)==null||k.remove("nc-roster-over"),(P=(O=C==null?void 0:C.source)==null?void 0:O.classList)==null||P.remove("nc-roster-dragging"),h.current&&cancelAnimationFrame(h.current),h.current=0},y=(C=!1)=>{const N=d.current;if(!N)return;const k=N.target;_(),d.current=null,g(!1);try{N.handle.releasePointerCapture(N.pointerId)}catch{}C&&k&&k!==e&&a(e,k)&&i(e,k)},w=(C,N)=>{var G,X,Q,V,T,I,$,j,M;const k=d.current;if(!k)return;k.x=C,k.y=N;const O=c==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",P=(X=(G=document.elementFromPoint(C,N))==null?void 0:G.closest)==null?void 0:X.call(G,O),H=c==="node"?(Q=P==null?void 0:P.dataset)==null?void 0:Q.nodeOrderKey:(V=P==null?void 0:P.dataset)==null?void 0:V.rosterKey,U=(c==="node"||((T=P==null?void 0:P.dataset)==null?void 0:T.position)===t)&&H&&H!==e&&a(e,H);k.over!==(U?P:null)&&(($=(I=k.over)==null?void 0:I.classList)==null||$.remove("nc-roster-over"),k.over=U?P:null,(M=(j=k.over)==null?void 0:j.classList)==null||M.add("nc-roster-over")),k.target=U?H:null},S=()=>{const C=d.current;if(!C){h.current=0;return}const N=C.container;if(N){const k=N.getBoundingClientRect(),O=C.y<k.top+eb?-tb:C.y>k.bottom-eb?tb:0;O&&(N.scrollTop+=O,w(C.x,C.y))}h.current=requestAnimationFrame(S)};b.useEffect(()=>{const C=k=>{k.key==="Escape"&&d.current&&(k.preventDefault(),y(!1))},N=()=>y(!1);return window.addEventListener("keydown",C),window.addEventListener("blur",N),()=>{window.removeEventListener("keydown",C),window.removeEventListener("blur",N),_(),d.current=null}},[e,t,c]);const A=C=>{var P;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]",k=C.currentTarget.closest(N),O=C.currentTarget.closest(".nc-side-scroll, .nc-home-scroll, .nc-cell-switcher-list");d.current={pointerId:C.pointerId,handle:C.currentTarget,source:k,container:O,target:null,over:null,x:C.clientX,y:C.clientY},(P=k==null?void 0:k.classList)==null||P.add("nc-roster-dragging");try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}g(!0),h.current=requestAnimationFrame(S)};return l.jsx("button",{type:"button",className:`nc-roster-handle${f?" active":""}`,"aria-label":`${p("reorder")} ${n}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:p("reorder-help"),onClick:C=>{C.preventDefault(),C.stopPropagation()},onDragStart:C=>C.preventDefault(),onKeyDown:C=>{C.key!=="ArrowUp"&&C.key!=="ArrowDown"||(C.preventDefault(),C.stopPropagation(),s(C.key==="ArrowUp"?-1:1))},onPointerDown:A,onPointerMove:C=>{!d.current||C.pointerId!==d.current.pointerId||(C.preventDefault(),C.stopPropagation(),w(C.clientX,C.clientY))},onPointerUp:C=>{!d.current||C.pointerId!==d.current.pointerId||(C.preventDefault(),C.stopPropagation(),y(!0))},onPointerCancel:()=>y(!1),onLostPointerCapture:()=>{d.current&&y(!1)},children:"↕"})}const rg="nc_pins";function Af(){try{const t=JSON.parse(localStorage.getItem(rg));return Array.isArray(t)?t:[]}catch{return[]}}function W1(t){try{return localStorage.setItem(rg,JSON.stringify(t)),null}catch(e){return e instanceof Error?e:new Error(String(e))}}function NM(t,e){const n=t.includes(e)?t.filter(i=>i!==e):[...t,e];return{next:n,error:W1(n)}}function nb(t,e){if(!Array.isArray(t)||!t.includes(e))return{next:Array.isArray(t)?t:[],error:null};const n=t.filter(i=>i!==e);return{next:n,error:W1(n)}}function LM(t,e,n){if(!t.includes(e)||!t.includes(n)||e===n)return t;const i=[...t],s=i.indexOf(e),a=i.indexOf(n);i.splice(s,1);const c=i.indexOf(n);i.splice(s<a?c+1:c,0,e);try{localStorage.setItem(rg,JSON.stringify(i))}catch{}return i}function RM(t,e,n){const i=t.indexOf(e);return[i===-1?1e9:i,-(n||0)]}function AM(t,e){return t[0]-e[0]||t[1]-e[1]}function og(){const[t,e]=b.useState(Af),[n,i]=b.useState(_M),[s,a]=b.useState(mM),[c,d]=b.useState(null),h=N=>e(k=>NM(k,N).next),f=N=>{const k=nb(Af(),N);return e(k.next),d(k.error?{key:N,message:k.error.message||String(k.error)}:null),k.error},g=()=>{if(!c)return;const N=nb(Af(),c.key);e(N.next),d(N.error?{...c,message:N.error.message||String(N.error)}:null)},_=()=>d(null),y=N=>qw(n,N),w=(N,k)=>i(O=>{const P={...O,[N]:{...qw(O,N),...k}};return yM(P)}),S=(N,k)=>t.includes(N)===t.includes(k);function A(N,k,O,P){const H=t.includes(k),W=t.includes(O);if(H===W){if(H){e(U=>LM(U,k,O));return}a(U=>{var Q;const G=((Q=P.find(V=>V.key===k))==null?void 0:Q.technical)===!0,X=Gr(P,t,G?"technical":"all",hr(U,N)).map(V=>V.key);return gM(vM(U,N,k,O,X))})}}function C(N,k,O,P){var Q;const H=((Q=P.find(V=>V.key===k))==null?void 0:Q.technical)===!0,W=t.includes(k),U=Gr(P,t,H?"technical":"all",hr(s,N)).map(V=>V.key).filter(V=>t.includes(V)===W),G=U.indexOf(k),X=U[G+O];G>=0&&X&&A(N,k,X,P)}return{pins:t,views:n,orders:s,togglePin:h,removePin:f,pinError:c,retryPinPersist:g,clearPinError:_,viewFor:y,updateView:w,canMoveRoster:S,moveRoster:A,stepRoster:C}}const q1="nc_node_order_v1",MM=/^[a-f0-9]{16,64}$/;function xo(t){if(MM.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 ib(t=globalThis.localStorage){try{const e=JSON.parse(t.getItem(q1));return Array.isArray(e)?[...new Set(e.filter(n=>typeof n=="string"&&n&&n.length<=192))].slice(0,128):[]}catch{return[]}}function jM(t,e=globalThis.localStorage){try{e.setItem(q1,JSON.stringify(t))}catch{}return t}function sb(t=[],e=[]){const n=new Map(e.map((i,s)=>[i,s]));return t.map((i,s)=>({group:i,index:s})).sort((i,s)=>{const a=n.has(xo(i.group))?n.get(xo(i.group)):Number.MAX_SAFE_INTEGER,c=n.has(xo(s.group))?n.get(xo(s.group)):Number.MAX_SAFE_INTEGER;return a-c||i.index-s.index}).map(({group:i})=>i)}function TM(t,e,n,i=[]){if(!e||!n||e===n)return t;const s=i.map(xo).filter(Boolean);if(!s.includes(e)||!s.includes(n))return t;const a=[...t.filter(f=>s.includes(f)),...s.filter(f=>!t.includes(f))],c=a.indexOf(e),d=a.indexOf(n);a.splice(c,1);const h=a.indexOf(n);return a.splice(c<d?h+1:h,0,e),a}const mm="nexuscrew-node-preferences";function PM(){try{window.dispatchEvent(new Event(mm))}catch{}}function K1(){const[t,e]=b.useState(ib);b.useEffect(()=>{const a=()=>e(ib());return window.addEventListener("storage",a),window.addEventListener(mm,a),()=>{window.removeEventListener("storage",a),window.removeEventListener(mm,a)}},[]);const n=a=>sb(a,t),i=(a,c,d)=>e(h=>{const f=TM(h,a,c,d);return jM(f),PM(),f});return{order:t,groupsFor:n,moveNode:i,stepNode:(a,c,d)=>{const h=sb(d,t).map(xo),f=h.indexOf(a),g=h[f+c];f>=0&&g&&i(a,g,d)},nodeKey:xo}}function V1({pinError:t,onRetry:e,onDismiss:n}){return t?l.jsxs("div",{className:"nc-pin-error",role:"alert",children:[l.jsx("span",{className:"nc-pin-error-text",children:"★ preferenza non salvata"}),l.jsx("button",{type:"button",className:"nc-pin-error-retry",onClick:e,children:"riprova"}),l.jsx("button",{type:"button",className:"nc-pin-error-close",onClick:n,"aria-label":"chiudi avviso",children:"×"})]}):null}function gd({item:t,pins:e,hostByRoute:n,route:i}){const s=(n||{})[yi(i)]||{},a=$u({hostCell:s.hostCell??null,threadStatus:s.threadStatus,pins:e,item:t}),c=gE(a);return{state:a,live:!!c,favorite:a==="favorite",filled:a!=="none",titleKey:c||"pin",action:a===tS?"removePin":"addPin"}}async function ag({view:t,itemKey:e,togglePin:n,removePin:i}){return t.action==="removePin"?(i(e),{ok:!0}):(n(e),{ok:!0})}function Kr({item:t,cellName:e,route:n=[],pins:i=[],hostByRoute:s={}}={}){const a=gd({item:t,pins:i,hostByRoute:s,route:n}),c=(s||{})[yi(n)]||{};return{pinned:a.favorite,isLive:!!c.hostCell&&c.hostCell===e}}function lg({isLive:t,pinned:e,canBoot:n,boot:i,alive:s,handlers:a={}}={}){const c=[];return typeof a.onToggleLive=="function"&&c.push({id:"live",kind:"action",on:!!t,labelKey:t?"cell-actions-live-remove":"cell-actions-live-assign",run:a.onToggleLive}),typeof a.onTogglePin=="function"&&c.push({id:"pin",kind:"action",on:!!e,labelKey:e?"cell-actions-unpin":"cell-actions-pin",run:a.onTogglePin}),n&&typeof a.onToggleBoot=="function"&&c.push({id:"boot",kind:"switch",on:!!i,labelKey:"cell-actions-boot",run:()=>a.onToggleBoot(!i)}),s&&typeof a.onWatchLive=="function"&&c.push({id:"watch",kind:"action",on:!1,labelKey:"cell-actions-watch",run:a.onWatchLive}),c}function Y1({items:t=[],busy:e=!1,onRun:n}){return l.jsx("div",{className:"nc-cellactions",role:"menu","aria-busy":e||void 0,children:t.map(i=>{const s=i.descKey?p(i.descKey):i.descText;return l.jsxs("button",{type:"button",role:i.kind==="switch"?"menuitemcheckbox":"menuitem","aria-checked":i.kind==="switch"?i.on?"true":"false":void 0,className:`nc-cellactions-voce${i.on?" on":""}`,disabled:e,"data-cellaction":i.id,onClick:a=>{a.stopPropagation(),n?n(i):i.run()},children:[i.kind==="switch"?l.jsx("span",{className:`nc-cellactions-toggle${i.on?" on":""}`,"aria-hidden":"true"}):null,l.jsxs("span",{className:"nc-cellactions-testo",children:[p(i.labelKey),s?l.jsx("small",{className:"nc-cellactions-desc",children:s}):null]})]},i.id)})})}function G1({aperto:t,refGuscio:e,onClose:n}){b.useEffect(()=>{const i=a=>{e.current&&!e.current.contains(a.target)&&n()},s=a=>{a.key==="Escape"&&n()};return document.addEventListener("pointerdown",i),document.addEventListener("keydown",s),()=>{document.removeEventListener("pointerdown",i),document.removeEventListener("keydown",s)}},[t,e,n])}function X1({anchorRect:t,items:e,busy:n,onClose:i}){const s=b.useRef(null);G1({aperto:!0,refGuscio:s,onClose:i});const a=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 l.jsx("div",{className:"nc-cellactions-popover",style:a,ref:s,"data-testid":"cell-actions-popover",children:l.jsx(Y1,{items:e,busy:n,onRun:c=>{c.run(),i()}})})}function cg({cellName:t,items:e,busy:n,onClose:i}){const s=b.useRef(null);return G1({aperto:!0,refGuscio:s,onClose:i}),l.jsx("div",{className:"nc-cellactions-velo","data-testid":"cell-actions-sheet",children:l.jsxs("div",{className:"nc-cellactions-foglio",role:"dialog","aria-modal":"true","aria-label":p("cell-actions-title").replace("{cell}",t||""),ref:s,children:[l.jsxs("div",{className:"nc-cellactions-testa",children:[l.jsx("span",{className:"nc-cellactions-titolo",children:p("cell-actions-title").replace("{cell}",t||"")}),l.jsx("button",{type:"button",className:"nc-cellactions-chiudi",onClick:i,title:p("close"),"aria-label":p("close"),children:"✕"})]}),l.jsx(Y1,{items:e,busy:n,onRun:a=>{a.run(),i()}})]})})}const IM="native",DM="tmux";function BM(t){return typeof t!="string"||!t?null:t.startsWith("codex-vl")?IM:DM}function ka({liveHost:t,cells:e=[],localNodeId:n="",ownerId:i=null}={}){const s=t&&typeof t.hostCell=="string"&&t.hostCell?t.hostCell:null,a=s&&(Array.isArray(e)?e:[]).find(d=>d&&d.cell===s)||null,c=a&&typeof a.engine=="string"&&a.engine?a.engine:null;return{hostCell:s,cell:s,known:!!a,engine:c,mode:BM(c),state:s?aS(t&&t.threadStatus):Hl,remote:!!(i&&n&&i!==n),lease:t&&(t.hostLease||(t.host&&typeof t.host.lease=="string"?t.host.lease:null))||null}}function OM(t){const e=t&&t.state?t.state:Hl;return{modeKey:t&&t.mode?`live-host-mode-${t.mode}`:null,stateKey:`live-host-state-${e}`}}function ug(t){const e=t&&t.state?t.state:Hl;return e==="thread-active"?"active":e==="thread-present"?"present":e===Hl?"none":e==="thread-unknown"?"unknown":"designated"}function Vr(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 Q1(t){const e=t||{};return!(e.sessionsAvailable===!1||typeof e.status=="string"&&e.status!=="up")}function zs(t){return t.status==="up"&&!Q1(t)?p("node-sessions-unverified"):t.status==="passive"?p("node-passive"):t.status==="down"?t.downSince?p("tunnel-down-since").replace("{t}",Vr(t.downSince)):p("tunnel-down"):t.status==="unreachable"?t.cause===z1?p("peer-cause-nega"):t.cause===F1?p("peer-cause-rotta"):t.cause===$1?p("peer-cause-assente"):p("node-unreachable"):t.status==="offline"?t.lastSeen?p("node-offline-seen").replace("{t}",Vr(t.lastSeen)):p("node-offline"):t.status==="needs-repair"?p("node-needs-repair"):""}function J1(t,{passive:e=null}={}){return t?t.status==="passive"?e:t.status==="healthy"?"on":"warn":null}function Yu(t){return t&&(t.detail||t.status)||""}const $M="restrict,port-forwarding,permitopen=";function zM(t){const e=t&&typeof t.hint=="string"&&t.hint.trim()||"",n=t&&typeof t.authorizedKeys=="string"&&t.authorizedKeys.trim()||"";if(n){const s=e.indexOf(n);return{note:s>=0?e.slice(0,s).replace(/[:\s]+$/,""):e,line:n}}if(!e)return null;const i=e.indexOf($M);return i<0?{note:e,line:""}:{note:e.slice(0,i).replace(/[:\s]+$/,""),line:e.slice(i).trim()}}function Gu(t,e,n=globalThis.localStorage){if(!(t!=null&&t.outbox)||t.outbox.count<1)return!1;const i=Number(n.getItem(O0(e))||0);return t.outbox.latest>i}function vd(t,e={},{autorevole:n=!0}={}){const i=t||{},s=`${i.engine||""}${i.key?`·${i.key}`:""}`,a=[s,i.model&&i.model!==s?i.model:""].filter(Boolean).join(" · ");if(!i.tmux)return{working:!1,subtitle:String(a||p("cell-off")).trim()};const c=e.attivita&&typeof e.attivita=="object"?e.attivita.stato:null;if(c==="lavora"||c==="attesa"){const d=p(c==="attesa"?"cell-permission":"cell-working"),h=String(e.status||"").trim(),f=!h||/^working(?:\.{3}|…)?$/i.test(h);return{working:!0,stato:c,subtitle:c==="lavora"&&!f?`${d} · ${h}`:d}}if(c==="ferma")return{working:!1,stato:"ferma",subtitle:p("cell-stopped")};if(!n)return{working:!1,stato:"ignoto",subtitle:[p("cell-unknown"),a].filter(Boolean).join(" · ")};if(e.working===!0){const d=String(e.status||"").trim();return{working:!0,stato:"ignoto",subtitle:!d||/^working(?:\.{3}|…)?$/i.test(d)?p("cell-unknown"):`${p("cell-unknown")} · ${d}`}}return e.working===!1?{working:!1,stato:"ignoto",subtitle:p("cell-unknown")}:{working:!1,stato:"ignoto",subtitle:String(e.preview||i.preview||p("cell-on")).trim()}}function Z1(t,e){return[...new Set([t.engine,t.model,t.key,e.preview,t.preview,e.status].filter(Boolean).map(String))].join(" ")}function dg(t,e,n,i=globalThis.localStorage,{autorevole:s=!0}={}){return[...(Array.isArray(t)?t:[]).map(a=>{const c=n.get(a.tmuxSession)||{},d=Ca([],a.tmuxSession),h=vd(a,c,{autorevole:s});return{type:"cell",value:a,key:d,label:a.cell,live:!!a.tmux,fresh:Gu(c,d,i),activity:c.activity||0,working:h.working,stato:h.stato,subtitle:h.subtitle,searchText:Z1(a,c)}}),...(Array.isArray(e)?e:[]).map(a=>{const c=Ca([],a.name);return{type:"session",value:a,key:c,label:a.name,live:!0,technical:a.technical===!0,fresh:Gu(a,c,i),activity:a.activity||0,searchText:`${a.preview||""} ${a.cmd||""}`}})]}function zl(t,e=globalThis.localStorage){const n=t||{},i=Array.isArray(n.route)?n.route:[],s=Q1(n),a=new Map((n.sessions||[]).map(d=>[d.name,d])),c=[...(n.cells||[]).map(d=>{const h=a.get(d.tmuxSession)||{},f=Ca(i,d.tmuxSession||d.cell),g=vd(d,h,{autorevole:s});return{type:"cell",value:d,key:f,label:d.cell,live:!!d.tmux&&!d.preserved,fresh:Gu(h,f,e),activity:h.activity||d.activity||0,working:g.working,stato:g.stato,subtitle:g.subtitle,searchText:Z1(d,h)}}),...(n.unmanaged||[]).map(d=>{const h=Ca(i,d.name);return{type:"session",value:d,key:h,label:d.name,live:!0,technical:d.technical===!0,fresh:Gu(d,h,e),activity:d.activity||0,searchText:`${d.preview||""} ${d.cmd||""}`}})];return{route:i,rawItems:c}}const _d=9,Yl=.2,FM=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,Ea=/^[a-f0-9]{16,64}$/,gm=t=>FM.test(t)&&new Set(t.split("/")).size===t.split("/").length;function pr(t){if(typeof t=="string"&&t){const e=t.indexOf(":");if(e<0)return{session:t};const n=t.slice(0,e),i=t.slice(e+1);return!gm(n)||!i?null:{session:i,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"&&Ea.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"&&gm(t.node)?{session:t.session,node:t.node,...e?{ownerId:e}:{}}:null}return null}function ii(t){const e=pr(t);return e?e.node?`${e.node}:${e.session}`:e.session:""}const ex=9,tx=24,sc=11,nx=t=>{const e=Number(t);return e>=ex&&e<=tx?e:sc};function wa(){return{columns:[]}}function Gi(t){return t.columns.flatMap(e=>e.tiles.map(n=>ii(n)))}function HM(t){const e=[],n=Math.max(0,...t.columns.map(i=>i.tiles.length));for(let i=0;i<n;i+=1)for(const s of t.columns)s.tiles[i]&&e.push(ii(s.tiles[i]));return e}const Ta=t=>({columns:t.columns.map(e=>({width:e.width,tiles:e.tiles.map(n=>({...n}))}))});function Gl(t,e,n,i){const s=pr(e);if(!s||Gi(t).includes(ii(s))||Gi(t).length>=_d)return t;const a=Ta(t),c={session:s.session,height:1,fontSize:sc,...i||{}};if(s.node&&(c.node=s.node),s.ownerId&&(c.ownerId=s.ownerId),n==="end")return a.columns.push({width:1,tiles:[c]}),a;if(n&&typeof n.col=="number"&&typeof n.row=="number"&&a.columns[n.col])return a.columns[n.col].tiles.splice(n.row,0,c),a;if(n&&typeof n.col=="number"){const d=Math.max(0,Math.min(a.columns.length,n.col));return a.columns.splice(d,0,{width:1,tiles:[c]}),a}return a.columns.push({width:1,tiles:[c]}),a}function ix(t,e){const n=ii(e);if(!n||Gi(t).includes(n)||Gi(t).length>=_d)return t;const i=Gi(t).length+1,s=Math.ceil(Math.sqrt(i));if(t.columns.length>=s){let g=0;for(let _=1;_<t.columns.length;_+=1)t.columns[_].tiles.length<t.columns[g].tiles.length&&(g=_);return Gl(t,e,{col:g,row:t.columns[g].tiles.length})}const a=[...HM(t),n],c=new Map(t.columns.flatMap(g=>g.tiles.map(_=>[ii(_),_]))),d=pr(e),h=t.columns.length?t.columns.reduce((g,_)=>g+(Number(_.width)||1),0)/t.columns.length:1,f=Array.from({length:s},(g,_)=>{var y;return{width:((y=t.columns[_])==null?void 0:y.width)||h,tiles:[]}});return a.forEach((g,_)=>{const y=pr(g);if(!y)return;const w=c.get(g)||(g===n?d:{})||{},S={session:y.session,height:w.height||1,fontSize:w.fontSize||sc};y.node&&(S.node=y.node),w.ownerId&&(S.ownerId=w.ownerId),w.unavailable===!0&&(S.unavailable=!0),w.stale===!0&&(S.stale=!0),f[_%s].tiles.push(S)}),{columns:f.filter(g=>g.tiles.length)}}function UM(t,e){const n=pr(e);if(!n)return t;const i=ii(n);if(!i||Gi(t).includes(i)||Gi(t).length>=_d)return t;const s=e&&typeof e=="object"?e:{},a={height:Math.max(Yl,Number(s.height)||1),fontSize:nx(s.fontSize),...n.ownerId?{ownerId:n.ownerId}:{}};if(!t.columns.length)return Gl(t,n,null,a);let c=0;for(let d=1;d<t.columns.length;d+=1)t.columns[d].tiles.length<t.columns[c].tiles.length&&(c=d);return Gl(t,n,{col:c,row:t.columns[c].tiles.length},a)}function Xu(t,e){const n=ii(e),i=Ta(t);for(const s of i.columns)s.tiles=s.tiles.filter(a=>ii(a)!==n);return i.columns=i.columns.filter(s=>s.tiles.length>0),i}function WM(t,e,n){const i=ii(e);if(!Gi(t).includes(i))return t;const s=t.columns.flatMap(a=>a.tiles).find(a=>ii(a)===i);return Gl(Xu(t,i),i,n,{fontSize:s.fontSize,height:s.height,...s.ownerId?{ownerId:s.ownerId}:{},...s.unavailable===!0?{unavailable:!0}:{},...s.stale===!0?{stale:!0}:{}})}function qM(t,e){if(!(e instanceof Map)||e.size===0)return t;let n=!1;const i=Ta(t);for(const s of i.columns)for(const a of s.tiles){const c=e.get(ii(a));if(!c)continue;const d=pr(c);d&&(a.session=d.session,d.node?a.node=d.node:delete a.node,d.ownerId&&(a.ownerId=d.ownerId),n=!0)}return n?ks(i):t}function KM(t,e,n){const i=Ta(t);return i.columns[e]&&(i.columns[e].width=Math.max(Yl,Number(n)||1)),i}function VM(t,e,n,i){const s=Ta(t),a=s.columns[e]&&s.columns[e].tiles[n];return a&&(a.height=Math.max(Yl,Number(i)||1)),s}function YM(t,e,n,i){if(!(t.columns[e]&&t.columns[e].tiles[n]))return t;const a=Ta(t),c=a.columns[e].tiles[n],d=Number(c.fontSize)||sc;return c.fontSize=Math.max(ex,Math.min(tx,d+(Number(i)||0))),a}function GM(t,e,n,i){const s=t.columns[e];if(!s||!s.tiles[n])return null;switch(i){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 rb(t){for(const e of[.25,.5,.75])if(Math.abs(t-e)<=.03)return e;return t}function ks(t){if(!t||!Array.isArray(t.columns))return wa();const e=t.columns.map(i=>({width:Math.max(Yl,Number(i&&i.width)||1),tiles:(Array.isArray(i&&i.tiles)?i.tiles:[]).filter(s=>s&&typeof s.session=="string"&&s.session).filter(s=>s.node==null||typeof s.node=="string"&&gm(s.node)).filter(s=>s.ownerId==null||typeof s.ownerId=="string"&&Ea.test(s.ownerId)).map(s=>{const a={session:s.session,height:Math.max(Yl,Number(s.height)||1),fontSize:nx(s.fontSize)};return s.node!=null&&(a.node=s.node),s.ownerId!=null&&(a.ownerId=s.ownerId),a})})).filter(i=>i.tiles.length>0),n=new Set;for(const i of e)i.tiles=i.tiles.filter(s=>!n.has(ii(s))&&n.add(ii(s))&&n.size<=_d);return{columns:e.filter(i=>i.tiles.length>0)}}function XM(t,e){let n=ks(t);const i=ks(e),s=new Map;for(const c of i.columns)for(const d of c.tiles)s.set(ii(d),d);for(const c of n.columns)for(let d=0;d<c.tiles.length;d+=1){const h=ii(c.tiles[d]);s.has(h)&&(c.tiles[d]=s.get(h))}const a=new Map;for(const c of i.columns){const d=c.tiles.map(h=>ii(h)).sort().join("|");a.has(d)||a.set(d,c.width)}for(const c of n.columns){const d=c.tiles.map(f=>ii(f)).sort().join("|"),h=a.get(d);h!=null&&(c.width=h)}for(const[c,d]of s)Gi(n).includes(c)||(n=UM(n,d));return n}const sx=/^[a-z0-9-]{1,32}$/,QM=/^[A-Za-z0-9._-]{1,32}$/,JM=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,ZM=320;function vm(t){return typeof t=="string"&&sx.test(t)}const ej=64;function Na(t){if(typeof t!="string")return!1;const e=t.trim();return e.length>0&&e.length<=ej&&!/[\x00-\x1f\x7f]/.test(e)}function Xr(t){return String(t??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function rx(t){if(typeof t!="string"||!t||t.length>ZM||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:QM.test(t.slice(0,e))&&JM.test(t.slice(e+1))}function ob(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 tj({name:t,ssh:e,sshPort:n,remotePort:i}={}){const s=typeof t=="string"?t.trim():t,a=typeof e=="string"?e.trim():e;if(!vm(s))return{ok:!1,error:"err-node-name"};if(!rx(a))return{ok:!1,error:"err-ssh"};const c=ob(n);if(c===void 0)return{ok:!1,error:"err-ssh-port"};const d=ob(i);if(d===void 0)return{ok:!1,error:"err-node-port"};const h={name:s,ssh:a};return c!==null&&(h.sshPort=c),d!==null&&(h.remotePort=d),{ok:!0,value:h}}function nj(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 _m(t,e){const n=!!(t&&t.status==="up"),i=!!(t&&t.status==="passive");return{up:n,...i?{passive:!0}:{},label:n?"tunnel-up":i?"node-passive":"tunnel-down",since:n?nj(t.since,e):null}}const ij=new Set(["v","instanceId","port","label","invite"]),sj=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function rj(t){const e=String(t).replace(/-/g,"+").replace(/_/g,"/"),n=e+"=".repeat((4-e.length%4)%4),i=typeof atob=="function"?atob(n):Buffer.from(n,"base64").toString("binary"),s=Uint8Array.from(i,a=>a.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(s):Buffer.from(s).toString("utf8")}function oj(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(rj(e))}catch{return{ok:!1}}if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1};const i=n.v===1?ij:n.v===2?sj:null;if(!i)return{ok:!1};for(const c of Object.keys(n))if(!i.has(c))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(n.instanceId)))return{ok:!1};const s=Number(n.port);if(!Number.isInteger(s)||s<1||s>65535)return{ok:!1};if(typeof n.label!="string")return{ok:!1};if(typeof n.invite!="string"||!n.invite)return{ok:!1};const a={ok:!0,version:n.v,label:n.label,invite:n.invite,instanceId:n.instanceId,port:s};if(n.v===2){if(n.name!==void 0){if(typeof n.name!="string"||!sx.test(n.name))return{ok:!1};a.name=n.name}if(n.ssh!==void 0){if(!rx(n.ssh))return{ok:!1};a.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};a.sshPort=c}}return a}function aj(t,e,n=new Set){if(!e||!e.ok)return t;const i={...t},s=(a,c)=>{c==null||c===""||n.has(a)||(i[a]=c)};return s("label",e.label),e.version===2&&(s("name",e.name||(e.ssh?Xr(e.label):"")),s("ssh",e.ssh),e.sshPort!==void 0&&s("sshPort",String(e.sshPort))),i}const lj=["KIMI_AUTH_ACTION_REQUIRED","CLIENT_INTERACTION_REQUIRED"],cj=["kimi-code-consent-yes","kimi-code-config-custom-api-key","kimi-cli-login","client-terminal-dialog"];function uj(t){const e=t&&typeof t=="object"?t.actionRequired:null;if(e&&typeof e=="object"&&lj.includes(e.code)&&cj.includes(e.recovery))return{code:e.code,recovery:e.recovery,text:p(`fleet-recovery-${e.recovery}`)};if(t&&typeof t=="object"&&t.vlPromptDegraded===!0)return{code:"VL_PROMPT_DEGRADED",recovery:null,text:p("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(i=>typeof i=="string"&&i).slice(0,16);if(n.length)return{code:"READINESS_DEGRADED",recovery:null,text:p("fleet-mcp-degraded")+" "+n.join(", ")}}return{code:"READINESS_DEGRADED",recovery:null,text:p("fleet-readiness-degraded")}}return null}function dj(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:p(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:p("fleet-up-duplicate")}:null}async function hg({token:t,powerCell:e,payload:n,onNotice:i,fleetApi:s}){const a=s||{fleetUp:u2,fleetDown:z0},{cell:c}=e,d=Array.isArray(e.route)?e.route:[];try{if(n.action==="up"){const h=await a.fleetUp(t,{cell:c,boot:!!n.boot,...n.engine?{engine:n.engine}:{},...n.model!==void 0?{model:n.model}:{},...n.permissionPolicy?{permissionPolicy:n.permissionPolicy}:{}},d),f=uj(h);f&&i(f.text)}else await a.fleetDown(t,{cell:c,boot:!!n.boot},d);return}catch(h){const f=dj(h,n.action);if(f)return i(f.text),{benign:f.code};throw h}}const hj=1e4;function fj(){const[t,e]=b.useState(null),n=b.useRef(null),i=b.useCallback(s=>{typeof s!="string"||!s||(n.current&&clearTimeout(n.current),e(s),n.current=setTimeout(()=>e(null),hj))},[]);return b.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]),{notice:t,showActionNotice:i}}let ym={sessions:[],cells:[],nodeGroups:[],localNodeId:"",localFresh:!1,refreshedAt:0};function ab(){return ym}function ox(t={}){return ym={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},ym}const ha=(t,e=[])=>`${e.length?e.join("/"):"local"}:${t}`;function pj({onPick:t,token:e,onSettings:n,onOpenVlSession:i,hostByRoute:s={},onDesignateCell:a,onClearHostCell:c,panelPort:d=0,nodePanelPorts:h=null}){const[f,g]=Li(),_=sg(e),[y,w]=b.useState(null),[S,A]=b.useState(null),[C,N]=b.useState(!0),[k,O]=b.useState(""),[P,H]=b.useState(""),[W,U]=b.useState({bind:"127.0.0.1",port:""}),[G,X]=b.useState(""),[Q,V]=b.useState([]),[T,I]=b.useState([]),[$,j]=b.useState(!1),[M,L]=b.useState(null),[R,E]=b.useState({}),[z,D]=b.useState(new Set),[q,ce]=b.useState(null),{notice:ge,showActionNotice:se}=fj(),[we,_e]=b.useState(null),[fe,ie]=b.useState(null),[de,me]=b.useState(!1),[Ee,Se]=b.useState(null),[xe,Ye]=b.useState(null),[Le,ze]=b.useState("preview"),[He,_t]=b.useState(!1),{pins:at,orders:lt,togglePin:bt,removePin:Ht,pinError:Rt,retryPinPersist:fn,clearPinError:It,viewFor:Wt,updateView:ft,canMoveRoster:qt,moveRoster:$t,stepRoster:F}=og(),J=re=>s[yi(re)]||{},{groupsFor:ee,moveNode:K,stepNode:ye,nodeKey:Ze}=K1(),ct=ee(_);b.useEffect(()=>{ox({sessions:y||[],cells:Q,nodeGroups:_,localNodeId:G})},[y,Q,_,G]),b.useEffect(()=>{const re=new Map;for(const be of Q)re.set(ha(be.cell),!!be.boot);for(const be of _){const Be=be.route||[be.name];for(const We of be.cells||[])re.set(ha(We.cell,Be),!!We.boot)}E(be=>{let Be=!1;const We={...be};for(const[wt,Y]of Object.entries(be))re.has(wt)&&re.get(wt)===Y&&(delete We[wt],Be=!0);return Be?We:be})},[Q,_]);async function st(){try{const wt=await(await un("/api/sessions",e)).json();wt.error?(A(wt.error),w([]),N(!1)):(A(null),w(wt.sessions||[]),N(!0))}catch(We){A(String(We)),w([]),N(!1)}let re=null,be=null;try{re=await fr(e)}catch(We){be=We}const Be=ig({fs:re,error:be});Be.kind==="data"?(V(Be.cells),I(Be.capabilities),j(!1),L(null)):Be.kind==="stale"?(j(!0),L(null)):(V([]),I([]),j(!1),L(Be.reason||""))}b.useEffect(()=>{st(),un("/api/config",e).then(be=>be.json()).then(be=>{H(be.version||""),U({bind:be.bind||"127.0.0.1",port:be.port||""}),X(Ea.test(String(be.instanceId||""))?be.instanceId:"")}).catch(()=>{});const re=setInterval(st,4e3);return()=>clearInterval(re)},[]);async function xt(){if(!W.port)return;const re=`http://${W.bind}:${W.port}/#token=${e}`;try{await navigator.clipboard.writeText(re)}catch{}}function Et(re,be,Be){const We=ha(re,be);E(wt=>({...wt,[We]:!!Be}))}function jt(re,be=[]){const Be=ha(re.cell,be);return Object.prototype.hasOwnProperty.call(R,Be)?R[Be]:!!re.boot}async function Ct(re,be,Be=[],We){const wt=ha(be.cell,Be),Y=typeof We=="boolean"?We:!jt(be,Be);Et(be.cell,Be,Y),D(te=>new Set(te).add(wt));try{await F0(e,{cell:be.cell,enabled:Y},Be),Be.length||V(te=>te.map(Ce=>Ce.cell===be.cell?{...Ce,boot:Y}:Ce))}catch(te){E(Ce=>{const $e={...Ce};return delete $e[wt],$e}),A(String((te==null?void 0:te.message)||te))}finally{D(te=>{const Ce=new Set(te);return Ce.delete(wt),Ce})}}const Xe=(re,be,Be)=>({onToggleLive:async()=>{const We=Kr({item:re,cellName:be.cell,route:Be,pins:at,hostByRoute:s});me(!0);const wt=await ud({action:We.isLive?"remove":"use",cellId:be.cell,route:Be,token:e});me(!1),Se({messageKey:wt.messageKey,ok:wt.ok,cell:wt.hostCell||be.cell})},onTogglePin:()=>ag({view:gd({item:re,pins:at,hostByRoute:s,route:Be}),itemKey:re.key,togglePin:bt,removePin:Ht}),onToggleBoot:We=>Ct(null,be,Be,We),onWatchLive:()=>{ze("stream"),Ye(re.key)}});async function tt(re){if(!q)return;let be=null;try{be=await hg({token:e,powerCell:q,payload:re,onNotice:se})}catch(Be){throw se(String(Be&&Be.message||Be)),Be}if(!be){const{cell:Be}=q,We=Array.isArray(q.route)?q.route:[];re.action==="up"?Et(Be,We,!!re.boot):re.boot&&Et(Be,We,!1)}st()}const Nt=b.useMemo(()=>{if(!q)return null;const re=(Array.isArray(q.route)?q.route:[]).join("/"),Be=[...Q,..._.flatMap(We=>(We.cells||[]).map(wt=>({...wt,route:We.route||[We.name]})))].find(We=>We.cell===q.cell&&(Array.isArray(We.route)?We.route.join("/"):"")===re);return Be?{...q,active:!!Be.active}:q},[q,Q,_]);async function kn(re,be=[]){try{await Im(e,re,be)}catch{return}st()}async function Ae(re,be,Be=[]){try{await W0(e,re,be,Be)}catch{return}st()}async function zt(re){if(!(!(re!=null&&re.direct)||we)){_e(re.name);try{await $m(e,re.name,re.tunnelStatus==="up"?"down":"up")}catch{}_e(null)}}async function Qt(re){if(!(re!=null&&re.direct))return;const be=window.prompt(p("rename-node-prompt"),re.label||re.name);if(be===null)return;const Be=String(be).trim();if(!Na(Be)){window.alert(p("rename-node-invalid"));return}try{await G0(e,re.name,Be)}catch(We){window.alert(String((We==null?void 0:We.message)||We))}}const Tt=b.useMemo(()=>new Map((y||[]).map(re=>[re.name,re])),[y]),pn=b.useMemo(()=>new Set(Q.map(re=>re.tmuxSession)),[Q]),St=b.useMemo(()=>(y||[]).filter(re=>!pn.has(re.name)),[y,pn]),it=b.useMemo(()=>dg(Q,St,Tt,void 0,{autorevole:C}),[Q,St,Tt]),Dt=b.useMemo(()=>{const re=new Map;for(const be of it)be.type==="cell"&&re.set(be.key,{item:be,route:[],nodeLabel:"",sessions:y||[],cells:Q});for(const be of ct){const Be=Array.isArray(be.route)?be.route:[];if(!Be.length||be.kind==="vl")continue;const{rawItems:We}=zl(be);for(const wt of We)wt.type==="cell"&&re.set(wt.key,{item:wt,route:Be,nodeLabel:be.label||be.name||"",sessions:be.sessions||[],cells:be.cells||[]})}return re},[it,ct,y,Q]),Ot=b.useMemo(()=>{if(!xe)return null;const re=Dt.get(xe);if(!re)return null;const be=re.item.value,Be=(re.sessions||[]).find(We=>We.name===be.tmuxSession)||{};return{row:{key:re.item.key,cellName:be.cell,subtitle:re.item.subtitle||"",nodeLabel:re.nodeLabel,node:re.route.length?re.route.join("/"):"",session:be.tmuxSession,route:re.route,panelUrl:be.panelUrl||"",telemetry:Be.telemetry||null,preview:Be.preview||be.preview||"",activity:Be.activity||be.activity||0},cells:re.cells||[]}},[xe,Dt]),Kt=Wt("local"),Ge=b.useMemo(()=>Gr(it,at,Kt.filter,hr(lt,"local")).filter(re=>Kw(re,k)),[it,at,Kt.filter,k,lt]),Mn=ct.reduce((re,be)=>re+(be.cells||[]).length+(be.unmanaged||[]).filter(Be=>!Be.technical).length,0),Ri=Gr(it,at,"all",hr(lt,"local")).length+Mn,Ai=it.filter(re=>re.live).length+ct.reduce((re,be)=>re+zl(be).rawItems.filter(Be=>Be.live).length,0),Wn=(y||[]).filter(re=>re.attached).length+ct.reduce((re,be)=>re+(be.sessions||[]).filter(Be=>Be.attached).length,0),Qi=Math.min(Wn,Ai),Fi=W.port?`${W.bind}:${W.port}`:W.bind;function Ji(re,be=null,Be=it){var ut,pt;const We=Array.isArray(be==null?void 0:be.route)?be.route:[],wt=We.join("/"),Y=wt||"local",te=We.length?be==null?void 0:be.instanceId:G,Ce=(Fe,Bt)=>t({session:Fe,...wt?{node:wt}:{},...Ea.test(String(te||""))?{ownerId:te}:{},...typeof Bt=="string"&&Bt?{cellName:Bt}:{}}),$e=qt;if(re.type==="cell"){const Fe=re.value,Bt=J(We),ne=$u({hostCell:Bt.hostCell??null,threadStatus:Bt.threadStatus,pins:at,item:re}),le=We.length?((be==null?void 0:be.sessions)||[]).find(fi=>fi.name===Fe.tmuxSession):Tt.get(Fe.tmuxSession),Re=mp(ne,Bt.hostLease??null),ot=Fe.degraded?p("cell-degraded"):re.subtitle||(Fe.tmux?p("cell-idle"):p("cell-off")),rt=Re?`${ot} · ${p(Re)}`:ot,ri=We.length===0||((be==null?void 0:be.capabilities)||[]).includes(Fe.active?"down":"up"),En=We.length===0?T.includes("boot"):((be==null?void 0:be.capabilities)||[]).includes("boot"),Xt=jt(Fe,We),Dn=Kr({item:re,cellName:Fe.cell,route:We,pins:at,hostByRoute:s}),Gt=!!fe&&fe.itemKey===re.key,Zi=`${p("cell-actions-open")}: ${Fe.cell}`;return l.jsxs("div",{className:"nc-mcard","data-roster-key":re.key,"data-position":Y,children:[He&&l.jsx(Os,{position:Y,itemKey:re.key,label:Fe.cell,canMove:$e,onMove:(fi,Zt)=>$t(Y,fi,Zt,Be),onStep:fi=>F(Y,re.key,fi,Be)}),l.jsxs("button",{className:"nc-mcard-main",onClick:()=>Fe.tmux&&Ce(Fe.tmuxSession,Fe.cell),title:rt,"aria-label":`${Fe.cell}, ${rt}`,children:[l.jsx("span",{className:`dot ${Fe.degraded?"warn":Fe.tmux?`on${re.working?" working":""}`:""}`}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsxs("span",{className:"nc-mcard-nome",children:[l.jsx("b",{children:Fe.cell}),Dn.isLive&&l.jsx("span",{className:"nc-m-live",children:"LIVE"})]}),l.jsx("small",{title:re.subtitle,children:re.subtitle})]})]}),re.activity?l.jsx("span",{className:"nc-rel",children:Vr(re.activity)}):null,re.fresh&&((ut=le==null?void 0:le.outbox)==null?void 0:ut.count)>0&&l.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:le.outbox.count}),l.jsx("button",{type:"button",className:`nc-act cellmenu${Gt?" on":""}`,title:Zi,"aria-label":Zi,"aria-haspopup":"menu","aria-expanded":Gt?"true":"false",onClick:()=>ie({itemKey:re.key,item:re,cell:Fe,route:We,canBoot:En}),children:"⋯"}),ri&&l.jsx("button",{className:`nc-act power${Fe.tmux?" on":""}${Fe.degraded?" warn":""}`,onClick:()=>ce(We.length?{...Fe,boot:Xt,route:We,availableEngines:(be==null?void 0:be.engines)||[]}:{...Fe,boot:Xt}),title:Fe.active?p("power-off"):p("power-on"),"aria-label":`${Fe.active?p("power-off"):p("power-on")} ${Fe.cell}`,children:l.jsx(kt,{name:"power",size:16})})]},re.key)}const ke=re.value;return l.jsxs("div",{className:"nc-mcard","data-roster-key":re.key,"data-position":Y,children:[l.jsx(Os,{position:Y,itemKey:re.key,label:ke.name,canMove:$e,onMove:(Fe,Bt)=>$t(Y,Fe,Bt,Be),onStep:Fe=>F(Y,re.key,Fe,Be)}),l.jsxs("button",{className:"nc-mcard-main",onClick:()=>Ce(ke.name),children:[l.jsx("span",{className:ke.attached?"dot on":"dot"}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsx("b",{children:ke.name}),l.jsx("small",{children:ke.preview?ke.preview:ke.cmd?ke.cmd:p("windows").replace("{n}",String(ke.windows||0))})]})]}),re.activity?l.jsx("span",{className:"nc-rel",children:Vr(re.activity)}):null,re.fresh&&((pt=ke.outbox)==null?void 0:pt.count)>0&&l.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:ke.outbox.count}),l.jsx("button",{className:`nc-act pin${at.includes(re.key)?" on":""}`,"aria-label":`${p("pin")} ${ke.name}`,title:p("pin"),onClick:()=>bt(re.key),children:at.includes(re.key)?"★":"☆"}),l.jsx("button",{className:`nc-act technical${ke.technical?" on":""}`,title:ke.technical?p("mark-normal"):p("mark-technical"),"aria-label":`${ke.technical?p("mark-normal"):p("mark-technical")} ${ke.name}`,onClick:()=>Ae(ke.name,!ke.technical,We),children:"T"}),l.jsx("button",{className:"nc-menu",title:p("terminate"),"aria-label":`${p("terminate")} ${ke.name}`,onClick:()=>{window.confirm(p("terminate-confirm").replace("{name}",ke.name))&&kn(ke.name,We)},children:"⋯"})]},re.key)}return l.jsxs("div",{className:"nc-home",children:[l.jsxs("header",{className:"nc-home-head",children:[l.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",l.jsx("span",{className:"nc-cursor"})]}),l.jsxs("div",{className:"nc-home-sub",children:[p("fleet-tmux")," · ",Ai," ",p("sessions"),Qi>0&&` · ${Qi} attached`]}),l.jsxs("span",{className:"nc-head-actions",children:[l.jsx("button",{className:`nc-refresh${He?" on":""}`,onClick:()=>_t(re=>!re),"aria-pressed":He,title:p("reorder-help"),"aria-label":p("reorder"),children:"↕"}),l.jsx("button",{className:"nc-refresh",onClick:()=>n("nodes",!1),title:p("settings"),children:l.jsx(kt,{name:"gear",size:18})}),l.jsx("button",{className:"nc-refresh",onClick:st,title:p("refresh"),children:l.jsx(kt,{name:"refresh",size:18})})]})]}),l.jsxs("main",{className:"nc-home-scroll",children:[l.jsx(mj,{view:ka({liveHost:s[yi([])],cells:Q}),notice:Ee}),l.jsx(V1,{pinError:Rt,onRetry:fn,onDismiss:It}),Ri>8&&l.jsx("input",{className:"nc-filter",type:"search",placeholder:p("filter-placeholder"),"aria-label":p("filter-placeholder"),value:k,onChange:re=>O(re.target.value)}),S&&l.jsx("div",{className:"nc-err",children:S}),ge&&l.jsx("div",{className:"nc-notice",role:"status",children:ge}),$&&l.jsx("div",{className:"nc-set-hint nc-fleet-stale",role:"status",children:p("fleet-stale")}),M!==null&&l.jsxs("div",{className:"nc-set-hint nc-fleet-off",role:"status",children:[p("fleet-off"),M?` (${M})`:""]}),l.jsxs("section",{className:"nc-group","data-position":"local",children:[l.jsx(Mf,{label:p("position-local"),count:Ge.length,state:Kt,dotClass:"on",onToggle:()=>ft("local",{open:!Kt.open}),onFilter:re=>ft("local",{filter:re})}),Kt.open&&Ge.map(re=>Ji(re,null,it)),Kt.open&&y===null&&l.jsx("div",{className:"nc-empty",children:p("loading-fleet")}),Kt.open&&y!==null&&Ge.length===0&&!S&&l.jsx("div",{className:"nc-empty",children:k?p("no-match").replace("{q}",k):p("no-sessions-short")})]}),ct.map(re=>{const be=J1(re.health,{passive:"warn"}),Be=re.fleetState==="stale"?p("fleet-stale"):re.fleetState==="disabled"?p("fleet-off"):"",We=re.fleetState==="stale"?"warn":be||(re.status==="up"?"on":re.status==="passive"?"":"warn"),wt=[re.health?Yu(re.health):zs(re),Be].filter(Boolean).join(" · "),te=(re.route&&re.route.length?re.route:[re.name]).join("/"),Ce=Wt(te);if(re.kind==="vl")return l.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":te,"data-node-order-key":Ze(re),children:[l.jsx(Mf,{label:re.label||re.name,count:re.sessions.length,state:Ce,dotClass:We,dotTitle:wt,detail:zs(re),onToggle:()=>ft(te,{open:!Ce.open}),onFilter:Fe=>ft(te,{filter:Fe})}),re.status==="up"&&Ce.open&&re.sessions.map(Fe=>l.jsx("div",{className:"nc-mcard nc-vl-session-row",children:l.jsxs("button",{className:"nc-mcard-main",onClick:()=>i&&i(re.peer),"aria-label":`${re.label||re.name}: ${Fe.name}`,children:[l.jsx("span",{className:"dot on"}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsx("b",{children:Fe.name}),l.jsx("small",{children:p("vl-events-title")})]})]})},Fe.key)),re.status==="up"&&Ce.open&&re.sessions.length===0&&l.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]},`nodo-vl-${te}-${re.name}`);const{rawItems:$e}=zl(re),ke=Gr($e,at,Ce.filter,hr(lt,te)).filter(Fe=>Kw(Fe,k)),ut=re.direct&&re.health&&re.health.managed!==!1?l.jsx("button",{type:"button",className:`nc-act power${re.tunnelStatus==="up"?" on":""}`,disabled:we===re.name,title:re.tunnelStatus==="up"?p("power-off"):p("power-on"),"aria-label":`${re.tunnelStatus==="up"?p("power-off"):p("power-on")} ${re.label||re.name}`,onClick:()=>zt(re),children:l.jsx(kt,{name:"power",size:15})}):null,pt=l.jsxs("span",{className:"nc-node-actions",children:[l.jsx(Os,{scope:"node",position:"nodes",itemKey:Ze(re),label:re.label||re.name,onMove:(Fe,Bt)=>K(Fe,Bt,_),onStep:Fe=>ye(Ze(re),Fe,_)}),re.direct&&l.jsx("button",{type:"button",className:"nc-node-rename",title:p("rename-node"),"aria-label":`${p("rename-node")} ${re.label||re.name}`,onClick:()=>Qt(re),children:"✎"}),ut]});return l.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":te,"data-node-order-key":Ze(re),children:[l.jsx(Mf,{label:re.label||re.name,count:ke.length,state:Ce,dotClass:We,dotTitle:wt,detail:re.status==="up"?[zs(re),Be].filter(Boolean).join(" · "):re.health&&Yu(re.health)||zs(re),onToggle:()=>ft(te,{open:!Ce.open}),onFilter:Fe=>ft(te,{filter:Fe}),onRename:re.direct?()=>Qt(re):null,action:pt}),re.status==="up"&&Ce.open&&ke.map(Fe=>Ji(Fe,re,$e)),re.status==="up"&&Ce.open&&ke.length===0&&l.jsx("div",{className:"nc-empty",children:k?p("no-match").replace("{q}",k):p("no-sessions-short")})]},`nodo-${te}`)}),l.jsxs("footer",{className:"nc-home-foot",onClick:xt,title:p("copy-url"),children:[l.jsxs("span",{className:"nc-home-meta",children:[P&&l.jsxs("span",{className:"nc-home-version",children:["v",P]}),l.jsxs("span",{className:"nc-home-endpoint",children:[Fi," · ",p("ssh-only")]})]}),l.jsx("span",{className:"nc-lang",onClick:re=>re.stopPropagation(),children:J0.map((re,be)=>l.jsxs("span",{children:[be>0&&" · ",l.jsx("button",{className:`nc-lang-btn${f===re?" on":""}`,onClick:()=>g(re),title:re,children:re.toUpperCase()})]},re))})]})]}),l.jsx("button",{className:"nc-fab",onClick:()=>n("fleet",!0),title:p("fleet-new-cell"),"aria-label":p("fleet-new-cell"),children:"+"}),Nt&&l.jsx(Vu,{cell:Nt,token:e,route:Array.isArray(Nt.route)?Nt.route:[],onConfirm:tt,onClose:()=>ce(null)}),Ot&&l.jsx(j1,{row:Ot.row,token:e,initialSource:Le,panelPort:Vl(Ot.row.route||[],h,d),liveHost:ka({liveHost:s[yi(Ot.row.route||[])],cells:Ot.cells}),onClose:()=>{Ye(null),ze("preview")}}),fe&&(()=>{const{item:re,cell:be,route:Be=[],canBoot:We}=fe,wt=Kr({item:re,cellName:be.cell,route:Be,pins:at,hostByRoute:s}),Y=lg({...wt,canBoot:We,boot:jt(be,Be),alive:!!be.tmux,handlers:Xe(re,be,Be)});return l.jsx(cg,{cellName:be.cell,items:Y,busy:de||z.has(ha(be.cell,Be)),onClose:()=>ie(null)})})()]})}function mj({view:t,notice:e}){const n=!!(t&&t.cell),i=n?p("live-host-indicator").replace("{cell}",t.cell).replace("{mode}",p(t.mode?`live-host-mode-${t.mode}`:"live-host-mode-unknown")).replace("{state}",p(`live-host-state-${t.state||"none"}`)):p("live-host-indicator-none");return l.jsxs("div",{className:"nc-m-live-strip","data-state":t&&t.state?t.state:"none",title:e?`${i} · ${p(e.messageKey)}`:i,children:[l.jsx("span",{className:`nc-m-live-dot ${ug(t||{})}`,"aria-hidden":"true"}),l.jsx("span",{className:"nc-m-live-testo",children:n?t.cell:i}),e&&l.jsx("span",{className:`nc-m-live-notice${e.ok?" ok":" ko"}`,role:"status",children:p(e.messageKey).replace("{cell}",e.cell||t.cell||"")})]})}function Mf({label:t,count:e,state:n,dotClass:i="",dotTitle:s="",detail:a="",onToggle:c,onFilter:d,onRename:h=null,action:f=null}){return l.jsxs("div",{className:"nc-mobile-position-head",onContextMenu:h?g=>{g.preventDefault(),h()}:void 0,children:[l.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:c,"aria-expanded":n.open,"aria-label":`${t} · ${p("node-sessions").replace("{n}",String(e))}`,children:[l.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:n.open?"⌄":"›"}),l.jsx("span",{className:`dot ${i}`,title:s}),l.jsxs("span",{className:"nc-mobile-position-copy",children:[l.jsx("b",{children:t}),l.jsx("small",{children:a||p("node-sessions").replace("{n}",String(e))})]})]}),l.jsxs("select",{className:"nc-mobile-position-filter",value:n.filter,"aria-label":`${t} · ${p("filter-placeholder")}`,title:p(`view-${n.filter}`),onChange:g=>d(g.target.value),children:[l.jsx("option",{value:"all",children:p("view-all")}),l.jsx("option",{value:"pinned",children:p("view-pinned")}),l.jsx("option",{value:"active",children:p("view-active")}),l.jsx("option",{value:"off",children:p("view-off")}),l.jsx("option",{value:"technical",children:p("view-technical")})]}),f]})}const lb="",nn="\x1B",gj=[{label:"↑",seq:nn+"[A"},{label:"↓",seq:nn+"[B"},{label:"PGUP",seq:nn+"[5~"},{label:"PGDN",seq:nn+"[6~"}],vj=new Set([nn+"[A",nn+"[B",nn+"[C",nn+"[D",nn+"[5~",nn+"[6~"]),_j=350,yj=55;function wj({send:t,action:e,ctrlArmed:n=!1,onCtrl:i,onKeyboard:s,selectionMode:a=!1,onSelectionMode:c,onCellSwitcher:d,cellSwitcherOpen:h=!1,keepKeyboardClosed:f=!0,showEnter:g=!0,keybarLayout:_="full"}){const[y,w]=b.useState(!1),[S,A]=b.useState(!1),[C,N]=b.useState(!1),[k,O]=b.useState(!1),P=_==="compact"&&!k,H=b.useRef({delay:null,interval:null}),W=b.useRef(()=>{}),U=()=>{const E=H.current;E.delay!==null&&clearTimeout(E.delay),E.interval!==null&&clearInterval(E.interval),E.delay=null,E.interval=null};W.current=U,b.useEffect(()=>{const E=()=>{document.visibilityState==="hidden"&&W.current()},z=()=>W.current();return window.addEventListener("blur",z),document.addEventListener("visibilitychange",E),()=>{window.removeEventListener("blur",z),document.removeEventListener("visibilitychange",E),W.current()}},[]),b.useEffect(()=>{_!=="compact"&&O(!1)},[_]);const G=E=>{C?(t(nn+E),N(!1)):t(E)},X=E=>{f&&um(),E()},Q=E=>({onPointerDown:z=>{z.preventDefault(),X(E)},onClick:z=>{z.detail===0&&X(E)}}),V=E=>({onPointerDown:z=>{z.preventDefault(),U(),X(E),!C&&(H.current.delay=setTimeout(()=>{H.current.delay=null,E(),H.current.interval=setInterval(E,yj)},_j))},onPointerUp:U,onPointerLeave:U,onPointerCancel:U,onLostPointerCapture:U,onTouchCancel:U,onClick:z=>{z.detail===0&&X(E)}}),T=(E,z,D)=>l.jsx("button",{type:"button",...vj.has(z)&&!D?V(()=>G(z)):Q(()=>{G(z),D&&D()}),children:E},E),I=(E,z)=>l.jsx("button",{type:"button",...Q(()=>{e(z),A(!1)}),children:E},E),$=d?l.jsx("button",{type:"button","aria-label":p("fleet-cells"),title:p("fleet-cells"),"aria-expanded":h,...Q(d),children:"◫"},"cells"):l.jsx("button",{type:"button",...Q(()=>{s&&s()}),children:"⌨"},"kbd"),j=g&&l.jsx("button",{type:"button",className:"nc-enter-key","aria-label":"ENTER",title:"ENTER",...Q(()=>G("\r")),children:l.jsx(kt,{name:"enter",size:24})}),M=S&&l.jsxs("div",{className:"nc-keymenu",children:[I("←WIN","prev-window"),I("WIN→","next-window"),I("⬅PANE","pane-left"),I("PANE➡","pane-right"),T("SCROLL",lb+"[",()=>{w(!0),A(!1)}),l.jsx("button",{type:"button",className:a?"armed":"",...Q(()=>{c==null||c(!a),A(!1)}),children:"SELECT"}),T("⌃C","",()=>A(!1)),T("DETACH",lb+"d",()=>A(!1))]});if(y)return l.jsxs("div",{className:"nc-keybar copy",children:[l.jsx("span",{className:"tag",children:"copy-mode"}),gj.map(E=>T(E.label,E.seq)),T("ESCI (q)","q",()=>w(!1))]});if(P)return l.jsxs("div",{className:"nc-keybar termux",children:[M,l.jsxs("div",{className:`nc-keygrid compact${g?"":" no-enter"}`,children:[l.jsx("div",{className:"nc-keyrows",children:l.jsxs("div",{className:"row",children:[l.jsx("button",{type:"button","aria-label":p("keybar-expand"),title:p("expand"),...Q(()=>O(!0)),children:l.jsx(kt,{name:"chevronUp",size:20})},"expand"),$,l.jsx("button",{type:"button",className:S?"armed":"",...Q(()=>A(E=>!E)),children:"☰"},"menu"),T("↑",nn+"[A"),T("↓",nn+"[B"),T("←",nn+"[D"),T("→",nn+"[C"),T("PGUP",nn+"[5~"),T("PGDN",nn+"[6~")]})}),j]})]});const L=_==="compact"&&k,R=L&&l.jsx("button",{type:"button",className:"nc-retract-key","aria-label":p("keybar-retract"),title:p("retract"),...Q(()=>O(!1)),children:l.jsx(kt,{name:"chevronDown",size:20})});return l.jsxs("div",{className:`nc-keybar termux${L?" expanded":""}`,children:[M,l.jsxs("div",{className:`nc-keygrid${g?"":" no-enter"}${L?" expanded":""}`,children:[R,l.jsxs("div",{className:"nc-keyrows",children:[l.jsxs("div",{className:"row",children:[T("ESC",nn),l.jsx("button",{type:"button",className:S?"armed":"",...Q(()=>A(E=>!E)),children:"☰"},"menu"),T("/","/"),T("—","-"),T("HOME",nn+"[H"),T("↑",nn+"[A"),T("END",nn+"[F"),T("PGUP",nn+"[5~")]}),l.jsxs("div",{className:"row",children:[T("⇥"," "),$,l.jsx("button",{type:"button",className:n?"armed":"",...Q(()=>{i&&i()}),children:"CTRL"},"ctrl"),l.jsx("button",{type:"button",className:C?"armed":"",...Q(()=>N(E=>!E)),children:"ALT"},"alt"),T("←",nn+"[D"),T("↓",nn+"[B"),T("→",nn+"[C"),T("PGDN",nn+"[6~")]})]}),j]})]})}const bj=t=>t>1048576?`${(t/1048576).toFixed(1)}M`:t>1024?`${(t/1024).toFixed(0)}K`:`${t}B`;function wm({session:t,node:e,token:n,filesEvent:i,onClose:s}){Li();const a=e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_`:"/api",c=e?`${e}:${t}`:t,[d,h]=b.useState("outbox"),[f,g]=b.useState({inbox:[],outbox:[]}),[_,y]=b.useState(""),w=b.useRef(null);async function S(){try{const O=await(await un(`${a}/files?session=${encodeURIComponent(t)}`,n)).json();if(O.error){y(O.error);return}g(O);const P=O.outbox[0]?O.outbox[0].mtime:0;localStorage.setItem(O0(c),String(P))}catch(k){y(String(k))}}b.useEffect(()=>{S()},[t,e]),b.useEffect(()=>{i&&i.session===t&&S()},[i]);async function A(k){for(const O of k){y(`carico ${O.name}…`);const P=new FormData;P.append("session",t),P.append("file",O);try{const W=await(await un(`${a}/files/upload`,n,{method:"POST",body:P})).json();y(W.error?`errore: ${W.error}`:"")}catch(H){y(String(H))}}S()}async function C(k){const O=await un(`${a}/files/download?session=${encodeURIComponent(t)}&box=${d}&name=${encodeURIComponent(k)}`,n);if(!O.ok){const U=await O.json().catch(()=>({}));y(U.error?`errore: ${U.error}`:"errore download");return}const P=await O.blob(),H=URL.createObjectURL(P),W=document.createElement("a");W.href=H,W.download=k,W.click(),URL.revokeObjectURL(H)}async function N(k){const O=await un(`${a}/files?session=${encodeURIComponent(t)}&box=${d}&name=${encodeURIComponent(k)}`,n,{method:"DELETE"});if(!O.ok){const P=await O.json().catch(()=>({}));y(P.error?`errore: ${P.error}`:"errore delete");return}S()}return l.jsxs("div",{className:"nc-files",children:[l.jsxs("header",{children:[l.jsx("b",{children:e?`${e}:${t}`:t}),l.jsx("button",{onClick:s,title:p("close"),children:l.jsx(kt,{name:"x",size:20})})]}),l.jsxs("nav",{children:[l.jsx("button",{className:d==="outbox"?"on":"",onClick:()=>h("outbox"),children:"outbox"}),l.jsx("button",{className:d==="inbox"?"on":"",onClick:()=>h("inbox"),children:"inbox"}),l.jsxs("button",{className:"up",onClick:()=>w.current&&w.current.click(),children:[l.jsx(kt,{name:"upload",size:18})," ",p("upload")]}),l.jsx("input",{type:"file",multiple:!0,ref:w,style:{display:"none"},onChange:k=>{A(Array.from(k.target.files||[])),k.target.value=""}})]}),_&&l.jsx("div",{className:"nc-busy",children:_}),l.jsxs("ul",{children:[f[d].map(k=>l.jsxs("li",{children:[l.jsx("span",{className:"name",onClick:()=>C(k.name),children:k.name}),l.jsx("small",{children:bj(k.size)}),l.jsx("button",{onClick:()=>N(k.name),title:p("delete"),children:l.jsx(kt,{name:"trash",size:18})})]},k.name)),f[d].length===0&&l.jsx("li",{className:"empty",children:p("empty-files")})]})]})}const yd="nc_composer_v1",bm="nc-composer-reset",Sj=50,ax=256*1024,lx=512*1024,xj=768*1024,cb=2*1024*1024,cx=720*60*60*1e3,Sm=1;function ux(t){const e=Number(t);return Number.isFinite(e)&&e>0?e:0}function fg(t){if(t!==void 0)return t;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Qu(){return{version:Sm,cells:{}}}function dx(t){const e=[];for(const i of Array.isArray(t)?t:[]){const s=typeof i=="string"?i:i&&i.text,a=ux(typeof i=="string"?0:i&&i.at);if(!(typeof s!="string"||!s||s.length>ax)&&!(e.length&&e[e.length-1].text===s)&&(e.push({text:s,at:a}),e.length>=Sj))break}let n=0;return e.filter(i=>n+i.text.length>xj?!1:(n+=i.text.length,!0))}function Ju(t){if(!t||typeof t!="object")return null;const e=typeof t.draft=="string"&&t.draft.length<=lx?t.draft:"",n=dx(t.history),i=ux(t.updatedAt),s=t.expanded===!0;return!e&&!n.length&&!s?null:{draft:e,history:n,expanded:s,updatedAt:i}}function Cj(t){let e;try{e=typeof t=="string"?JSON.parse(t):t}catch{return Qu()}if(!e||typeof e!="object"||e.version!==Sm||!e.cells||typeof e.cells!="object")return Qu();const n=Object.create(null);for(const[i,s]of Object.entries(e.cells)){if(!i||typeof i!="string"||i.length>512||i==="__proto__"||i==="constructor"||i==="prototype")continue;const a=Ju(s);a&&(n[i]=a)}return{version:Sm,cells:n}}function hx(t){const e=fg(t);if(!e)return Qu();try{return Cj(e.getItem(yd))}catch{return Qu()}}function ub(t){try{return JSON.stringify(t).length}catch{return 1/0}}function kj(t,e,n){for(const[i,s]of Object.entries(t.cells))i!==n&&s.updatedAt>0&&e-s.updatedAt>cx&&delete t.cells[i]}function fx(t,e){return Object.entries(t.cells).filter(([n])=>n!==e).sort((n,i)=>n[1].updatedAt-i[1].updatedAt).map(([n])=>n)}function Ej(t,e){for(;ub(t)>cb;){const n=Object.entries(t.cells).filter(([,i])=>i.history.length).sort((i,s)=>i[1].updatedAt-s[1].updatedAt);if(!n.length)break;n[0][1].history.pop()}for(const n of fx(t,e)){if(ub(t)<=cb)break;delete t.cells[n]}}function px(t,e,n){const i=fg(t);if(!i)return!1;Ej(e,n);const s=()=>(i.setItem(yd,JSON.stringify(e)),!0);try{return s()}catch{for(const c of fx(e,n)){delete e.cells[c];try{return s()}catch{}}return!1}}function rc(t,e,n,i){const s=hx(e);kj(s,n,t);const a=Ju(s.cells[t])||{draft:"",history:[],expanded:!1,updatedAt:0},c=i({...a,history:[...a.history]}),d=Ju(c);return d?s.cells[t]={...d,updatedAt:n}:delete s.cells[t],{ok:px(e,s,t),cell:s.cells[t]||{draft:"",history:[],expanded:!1,updatedAt:n}}}function Nj({ownerId:t,node:e,session:n}){const i=String(n||"");if(!i)return"";const s=Ea.test(String(t||""))?String(t):e?`route:${String(e)}`:"local";return`${encodeURIComponent(s)}:${encodeURIComponent(i)}`}function xl(t,e,n=Date.now()){if(!t)return{draft:"",history:[],expanded:!1,updatedAt:0};const i=hx(e),s=Ju(i.cells[t]);return!s||s.updatedAt>0&&n-s.updatedAt>cx?(i.cells[t]&&(delete i.cells[t],px(e,i,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...s,history:[...s.history]}}function db(t,e,n,i=Date.now()){const s=String(e||"");return!t||s.length>lx?!1:rc(t,n,i,a=>({...a,draft:s})).ok}function hb(t,e,n=Date.now()){return t?rc(t,e,n,i=>({...i,draft:""})).ok:!1}function Lj(t,e,n,i=Date.now()){return t?rc(t,n,i,s=>({...s,expanded:!!e})).ok:!1}function Rj(t,e,n,i=Date.now()){const s=String(e||"");return!t||!s||s.length>ax?!1:rc(t,n,i,a=>{const c=a.history.filter(d=>d.text!==s);return c.unshift({text:s,at:i}),{...a,history:dx(c)}}).ok}function Aj(t,e,n=Date.now()){return t?rc(t,e,n,i=>({...i,history:[]})).ok:!1}function Mj(t){const e=fg(t);if(!e)return!1;try{return e.removeItem(yd),!0}catch{return!1}}const jj=300;function Tj(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Pj({ownerId:t,node:e,session:n,storage:i=Tj()}){const s=b.useMemo(()=>Nj({ownerId:t,node:e,session:n}),[t,e,n]),a=b.useMemo(()=>xl(s,i),[]),[c,d]=b.useState(a.draft),[h,f]=b.useState(a.expanded),[g,_]=b.useState(a.history),[y,w]=b.useState(-1),S=b.useRef(s),A=b.useRef(a.draft),C=b.useRef(null),N=b.useRef(a.updatedAt||0),k=b.useRef(a.draft),O=b.useCallback(()=>{C.current&&clearTimeout(C.current),C.current=null},[]),P=b.useCallback(()=>{O(),db(S.current,A.current,i)},[O,i]),H=b.useCallback(()=>{O(),C.current=setTimeout(()=>{C.current=null,db(S.current,A.current,i)},jj)},[O,i]),W=b.useCallback($=>{const j=String(typeof $=="function"?$(A.current):$||"");A.current=j,N.current=Date.now(),k.current=j,w(-1),d(j),H()},[H]),U=b.useCallback(($,j)=>{O(),A.current=$,N.current=Date.now(),d($),w(j),H()},[O,H]),G=b.useCallback(()=>{if(!g.length)return!1;const $=Math.min(y+1,g.length-1);return y<0&&(k.current=A.current),U(g[$].text,$),!0},[U,g,y]),X=b.useCallback(()=>{if(y<0)return!1;const $=y-1;return U($<0?k.current:g[$].text,$),!0},[U,g,y]),Q=b.useCallback($=>{k.current=A.current;const j=g.findIndex(M=>M.text===$);U(String($||""),j)},[U,g]),V=b.useCallback(()=>{f($=>{const j=!$;return Lj(S.current,j,i),j})},[i]),T=b.useCallback(($,j,M)=>{if(!$)return;if(Rj($,M,i),!(S.current===$)){xl($,i).draft===j&&hb($,i);return}_(xl($,i).history),k.current="",w(-1),A.current===j?(O(),A.current="",N.current=Date.now(),d(""),hb($,i)):H()},[O,H,i]),I=b.useCallback(()=>{Aj(S.current,i),_([]),w(-1),k.current=A.current},[i]);return b.useEffect(()=>{if(S.current===s)return;P(),S.current=s;const $=xl(s,i);A.current=$.draft,N.current=$.updatedAt||0,k.current=$.draft,d($.draft),f($.expanded),_($.history),w(-1)},[s,P,i]),b.useEffect(()=>{const $=()=>P(),j=()=>{document.visibilityState==="hidden"&&P()};return window.addEventListener("pagehide",$),document.addEventListener("visibilitychange",j),()=>{window.removeEventListener("pagehide",$),document.removeEventListener("visibilitychange",j),P()}},[P]),b.useEffect(()=>{const $=()=>{O(),A.current="",N.current=0,k.current="",d(""),f(!1),_([]),w(-1)},j=L=>{if(L.key!==yd)return;if(L.newValue==null){$();return}const R=xl(S.current,i);R.updatedAt<N.current||(O(),A.current=R.draft,N.current=R.updatedAt,k.current=R.draft,d(R.draft),f(R.expanded),_(R.history),w(-1))},M=()=>$();return window.addEventListener("storage",j),window.addEventListener(bm,M),()=>{window.removeEventListener("storage",j),window.removeEventListener(bm,M)}},[O,i]),{cellKey:s,text:c,setText:W,expanded:h,toggleExpanded:V,history:g,historyCursor:y,recallPrevious:G,recallNext:X,selectHistory:Q,confirmSubmitted:T,clearHistory:I,flush:P}}function mx({submitText:t,token:e,session:n,node:i,ownerId:s,readonly:a=!1,keepKeyboardClosedOnVoice:c=!0}){Li();const d=i?`/api/route/${String(i).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:h,text:f,setText:g,expanded:_,toggleExpanded:y,history:w,historyCursor:S,recallPrevious:A,recallNext:C,selectHistory:N,confirmSubmitted:k,clearHistory:O,flush:P}=Pj({ownerId:s,node:i,session:n}),[H,W]=b.useState(!1),[U,G]=b.useState(""),[X,Q]=b.useState(""),[V,T]=b.useState(!1),I=b.useRef(null),$=b.useRef(null),j=b.useRef(null),[M,L]=b.useState(!1),[R,E]=b.useState({left:0,bottom:0}),[z,D]=b.useState(!1),[q,ce]=b.useState(!1),ge=b.useRef(null),se=b.useRef(null),we=b.useRef(null),_e=b.useRef(null),fe=b.useRef(null),ie=b.useRef(null),de=b.useRef(null),me=b.useRef(null),Ee=b.useRef(!1),[Se,xe]=b.useState(!1),[Ye,Le]=b.useState({left:0,bottom:0,width:320}),ze=b.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);b.useEffect(()=>{let J=!1;if(i){T(!1);return}return un(`${d}/voice/status`,e).then(ee=>ee.json()).then(ee=>{J||T(!!ee.serverSttConfigured)}).catch(()=>{J||T(!1)}),()=>{J=!0}},[e,d]);const _t=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||V);async function at(){const J=j.current&&typeof j.current.value=="string"?j.current.value:f;um(),J!==f&&g(J);const ee=J,K=MA(ee);if(!K||q)return;if(a){G(p("settings-readonly"));return}ce(!0),G("");let ye=!1;try{ye=!!await t(K)}catch{ye=!1}ye?k(h,ee,K):G(p("composer-send-failed")),ce(!1)}function lt(){const J=ge.current&&ge.current.getBoundingClientRect();J&&E({left:Math.max(6,Math.min(J.left,window.innerWidth-186)),bottom:window.innerHeight-J.top+6}),L(!0)}function bt(J){L(!1),J&&ge.current&&ge.current.focus()}function Ht(){const J=we.current&&we.current.getBoundingClientRect();if(J){const ee=Math.max(220,Math.min(360,window.innerWidth-12));Le({left:Math.max(6,Math.min(J.right-ee,window.innerWidth-ee-6)),bottom:window.innerHeight-J.top+6,width:ee})}xe(!0)}function Rt(J){xe(!1),J&&we.current&&we.current.focus()}b.useEffect(()=>{if(!M)return;const J=K=>{K.key==="Escape"&&bt(!0)},ee=K=>{const ye=se.current&&se.current.contains(K.target),Ze=ge.current&&ge.current.contains(K.target);!ye&&!Ze&&bt(!1)};return document.addEventListener("keydown",J),document.addEventListener("pointerdown",ee),()=>{document.removeEventListener("keydown",J),document.removeEventListener("pointerdown",ee)}},[M]),b.useEffect(()=>{if(!Se)return;const J=K=>{K.key==="Escape"&&Rt(!0)},ee=K=>{const ye=_e.current&&_e.current.contains(K.target),Ze=we.current&&we.current.contains(K.target);!ye&&!Ze&&Rt(!1)};return document.addEventListener("keydown",J),document.addEventListener("pointerdown",ee),()=>{document.removeEventListener("keydown",J),document.removeEventListener("pointerdown",ee)}},[Se]);function fn(J){if(!(J.isComposing||Ee.current||J.altKey||J.ctrlKey||J.metaKey)){if(J.key==="ArrowUp"&&J.currentTarget.selectionStart===0&&J.currentTarget.selectionEnd===0){A()&&J.preventDefault();return}J.key==="ArrowDown"&&S>=0&&J.currentTarget.selectionStart===f.length&&J.currentTarget.selectionEnd===f.length&&C()&&J.preventDefault()}}function It(J){bt(!1),J.current&&J.current.click()}async function Wt(J){if(!J.length||!n)return;D(!0),G("");const{paths:ee,errors:K}=await cm({files:J,token:e,session:n,node:i,paste:!1});K.length&&G(K.map(ye=>`${ye.name}: ${ye.message}`).join(" · ")),ee.length&&g(ye=>ye+(ye&&!ye.endsWith(" ")?" ":"")+ee.join(" ")),D(!1)}async function ft(J){var ye;if(!J.length||!n)return;D(!0),G(""),Q("");const{paths:ee,errors:K}=await cm({files:J,token:e,session:n,node:i,paste:!1});if(K.length&&G(K.map(Ze=>`${Ze.name}: ${Ze.message}`).join(" · ")),ee.length){Q(p("attach-inbox-done").replace("{n}",String(ee.length)));try{(ye=navigator.vibrate)==null||ye.call(navigator,10)}catch{}setTimeout(()=>Q(""),2500)}D(!1)}function qt(){I.current&&I.current.stop(),$.current&&$.current.stop(),W(!1)}async function $t(){G("");const J=window.SpeechRecognition||window.webkitSpeechRecognition;if(J){const ee=new J;ee.lang="it-IT",ee.continuous=!1,ee.interimResults=!0;const K=f?`${f} `:"";ee.onresult=ye=>{const Ze=Array.from(ye.results).map(ct=>ct[0].transcript).join("");g(K+Ze)},ee.onend=()=>W(!1),ee.onerror=ye=>{G(`voice: ${ye.error||"errore"}`),W(!1)},I.current=ee,ee.start(),W(!0);return}try{const ee=await navigator.mediaDevices.getUserMedia({audio:!0}),K=new MediaRecorder(ee),ye=[];K.ondataavailable=Ze=>ye.push(Ze.data),K.onstop=async()=>{ee.getTracks().forEach(Ze=>Ze.stop()),W(!1),G("trascrivo…");try{const Ze=new Blob(ye,{type:K.mimeType||"audio/webm"}),st=await(await un(`${d}/voice/transcribe`,e,{method:"POST",headers:{"content-type":"application/octet-stream"},body:Ze})).json();st.error?G(st.error):(G(""),g(xt=>xt+(xt?" ":"")+(st.text||"")))}catch(Ze){G(String(Ze))}},$.current={stop:()=>K.state!=="inactive"&&K.stop()},K.start(),W(!0)}catch{G("microfono non disponibile"),W(!1)}}function F(){c&&um(),H?qt():$t()}return l.jsxs("div",{className:"nc-composer",children:[U&&l.jsx("div",{className:"nc-composer-err",children:U}),X&&l.jsx("div",{className:"nc-composer-info",children:X}),l.jsxs("div",{className:"nc-composer-row",children:[n&&l.jsx("button",{ref:ge,className:z?"attach busy":"attach",disabled:z,onClick:()=>M?bt(!1):lt(),title:p(z?"attach-uploading":"attach"),"aria-label":p("attach"),"aria-haspopup":"menu","aria-expanded":M,"aria-controls":ze.current,children:l.jsx(kt,{name:"attach",size:22})}),M&&l.jsxs("div",{ref:se,id:ze.current,role:"menu",className:"nc-attach-menu",style:{left:R.left,bottom:R.bottom},children:[l.jsxs("button",{role:"menuitem",onClick:()=>It(fe),children:[l.jsx(kt,{name:"file",size:18})," ",p("attach-file")]}),l.jsxs("button",{role:"menuitem",onClick:()=>It(ie),children:[l.jsx(kt,{name:"camera",size:18})," ",p("attach-camera")]}),l.jsxs("button",{role:"menuitem",onClick:()=>It(de),children:[l.jsx(kt,{name:"image",size:18})," ",p("attach-gallery")]}),l.jsxs("button",{role:"menuitem",onClick:()=>It(me),children:[l.jsx(kt,{name:"folder",size:18})," ",p("attach-inbox")]})]}),l.jsx("button",{ref:we,type:"button",className:"history",onPointerDown:J=>J.preventDefault(),onClick:()=>Se?Rt(!1):Ht(),title:p("composer-history-tools"),"aria-label":p("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":Se,children:l.jsx(kt,{name:"history",size:21})}),Se&&l.jsxs("div",{ref:_e,role:"menu",className:"nc-composer-history-menu",style:{left:Ye.left,bottom:Ye.bottom,width:Ye.width},children:[l.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:J=>J.preventDefault(),onClick:()=>{y(),Rt(!1)},children:[l.jsx(kt,{name:_?"chevronDown":"chevronUp",size:18}),p(_?"composer-collapse":"composer-expand")]}),l.jsx("div",{className:"nc-composer-history-title",children:p("composer-history")}),w.length===0&&l.jsx("div",{className:"nc-composer-history-empty",children:p("composer-history-empty")}),w.map((J,ee)=>l.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:K=>K.preventDefault(),onClick:()=>{N(J.text),Rt(!1)},children:[l.jsx("span",{children:J.text.replace(/\s+/g," ").slice(0,180)}),J.at>0&&l.jsx("small",{children:new Date(J.at).toLocaleString()})]},`${J.at}:${ee}`)),w.length>0&&l.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:J=>J.preventDefault(),onClick:()=>{O(),Rt(!1)},children:p("composer-history-clear")})]}),l.jsx("input",{ref:fe,type:"file",multiple:!0,hidden:!0,onChange:J=>{Wt(Array.from(J.target.files||[])),J.target.value=""}}),l.jsx("input",{ref:ie,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:J=>{Wt(Array.from(J.target.files||[])),J.target.value=""}}),l.jsx("input",{ref:de,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:J=>{Wt(Array.from(J.target.files||[])),J.target.value=""}}),l.jsx("input",{ref:me,type:"file",multiple:!0,hidden:!0,onChange:J=>{ft(Array.from(J.target.files||[])),J.target.value=""}}),l.jsx("textarea",{ref:j,className:_?"expanded":"",rows:_?8:2,value:f,placeholder:p("composer-placeholder"),onChange:J=>g(J.target.value),onKeyDown:fn,onCompositionStart:()=>{Ee.current=!0},onCompositionEnd:()=>{Ee.current=!1},onBlur:P}),_t&&l.jsx("button",{type:"button",className:H?"mic on":"mic",title:p("voice"),"aria-label":p("voice"),onPointerDown:J=>{J.preventDefault(),F()},onClick:J=>{J.detail===0&&F()},children:l.jsx(kt,{name:"mic",size:22})}),l.jsx("button",{type:"button",className:"go",disabled:q,onPointerDown:J=>J.preventDefault(),onClick:at,title:p("send"),children:l.jsx(kt,{name:"enter",size:22})})]})]})}const fb=460,Ij=320;function Dj({row:t,token:e,panelPort:n=0,anchorRect:i,liveHost:s=null,onLiveHostApplied:a,source:c,onSourceChange:d,onExpand:h,onClose:f,onMouseEnter:g,onMouseLeave:_}){b.useEffect(()=>{const S=A=>{A.key==="Escape"&&f()};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[f]);const y=i?Math.max(8,Math.min(i.right+10,window.innerWidth-fb-8)):void 0,w=i?Math.max(8,Math.min(i.top-6,window.innerHeight-Ij-8)):void 0;return l.jsxs("div",{className:"nc-peekcloud",style:{left:y,top:w,width:fb},"data-testid":"peek-cloud",onMouseEnter:g,onMouseLeave:_,children:[l.jsxs("div",{className:"nc-peekcloud-testa",children:[l.jsx("b",{className:"nc-peekcloud-nome",children:t.cellName}),[t.nodeLabel,t.subtitle].filter(Boolean).length>0&&l.jsx("span",{className:"nc-peekcloud-sub",children:[t.nodeLabel,t.subtitle].filter(Boolean).join(" · ")}),l.jsx("button",{type:"button",className:"nc-peekcloud-espandi",title:p("cell-peek-expand"),"aria-label":`${p("cell-peek-expand")}: ${t.cellName}`,onClick:()=>h(c),children:"⤢"})]}),l.jsx(ng,{row:t,token:e,panelPort:n,liveHost:s,onLiveHostApplied:a,source:c,onSourceChange:d})]})}function jf(t){return String(t||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const Bj=180,Oj=480,Cl=(t,e=[])=>`${e.length?e.join("/"):"local"}:${t}`;function $j({sessions:t=[],cells:e=[],activeSessions:n=[],nodeGroups:i=[],onPick:s,onAddTile:a,onPower:c,onBoot:d,onNodePower:h,onKill:f,onVisibility:g,onNew:_,onNodeRename:y,onSettings:w,onBootError:S,localNodeId:A,fleetCapabilities:C=[],fleetStale:N=!1,fleetOff:k=null,bootSettlement:O=null,localVerified:P=!0,hostByRoute:H={},onDesignateCell:W,onClearHostCell:U,onBootSettlementApplied:G,onOpenVlSession:X,token:Q="",onPeekOpen:V,overlayOpen:T=!1,width:I=240,collapsed:$=!1,onResize:j,onToggleCollapse:M}){const[L,R]=Li(),{pins:E,orders:z,togglePin:D,removePin:q,pinError:ce,retryPinPersist:ge,clearPinError:se,viewFor:we,updateView:_e,canMoveRoster:fe,moveRoster:ie,stepRoster:de}=og(),{groupsFor:me,moveNode:Ee,stepNode:Se,nodeKey:xe}=K1(),Ye=Y=>H[yi(Y)]||{},Le=new Set((e||[]).map(Y=>Y.tmuxSession)),ze=new Map((t||[]).map(Y=>[Y.name,Y])),He=(Y,te)=>RM(E,Y,te),_t=AM,at=[...e||[]].sort((Y,te)=>_t(He(Y.tmuxSession,(ze.get(Y.tmuxSession)||{}).activity),He(te.tmuxSession,(ze.get(te.tmuxSession)||{}).activity))),lt=(t||[]).filter(Y=>!Le.has(Y.name)).sort((Y,te)=>_t(He(Y.name,Y.activity),He(te.name,te.activity))||Y.name.localeCompare(te.name)),bt=new Set(n||[]),[Ht,Rt]=b.useState(null),[fn,It]=b.useState("preview"),[Wt,ft]=b.useState(null),qt=b.useRef(null),$t=b.useRef(null),F=b.useRef(null);b.useEffect(()=>{F.current=Ht},[Ht]),b.useEffect(()=>()=>{clearTimeout(qt.current),clearTimeout($t.current)},[]);const[J,ee]=b.useState(null),[K,ye]=b.useState(null),[Ze,ct]=b.useState(!1),[st,xt]=b.useState(null),Et=(Y,te,Ce=[],$e="",ke=null)=>{const pt=(Ce.length===0?ze.get(te.tmuxSession):(ke||[]).find(Fe=>Fe&&Fe.name===te.tmuxSession))||{};return{key:Y.key,cellName:te.cell,subtitle:Y.subtitle||"",nodeLabel:$e,node:Ce.length?Ce.join("/"):"",session:te.tmuxSession,route:Ce,panelUrl:te.panelUrl||"",telemetry:pt.telemetry||null,preview:pt.preview||te.preview||"",activity:pt.activity||te.activity||0}},jt=(Y,te,Ce=[],$e="",ke="preview")=>ut=>{ut&&ut.stopPropagation(),ft(null),It(ke),Rt(Y.key),typeof V=="function"&&V()},Ct=(Y,te,Ce)=>{Ce&&(clearTimeout($t.current),clearTimeout(qt.current),qt.current=setTimeout(()=>{F.current||ft({itemKey:Y.key,routeKey:te||"",anchorRect:Ce.getBoundingClientRect(),source:"stream"})},300))},Xe=()=>{clearTimeout(qt.current),clearTimeout($t.current),$t.current=setTimeout(()=>ft(null),150)},tt=()=>clearTimeout($t.current),Nt=()=>ft(null),kn=(Y,te,Ce,$e,ke)=>{if(J&&J.itemKey===Y){ee(null);return}ee({itemKey:Y,routeKey:te||"",canBoot:!!$e,preserved:!!ke}),ye(Ce?Ce.getBoundingClientRect():null)};b.useEffect(()=>{T&&(Rt(null),It("preview"))},[T]);const Ae=dg(at,lt,ze,void 0,{autorevole:P}),zt=Gr(Ae,E,we("local").filter,hr(z,"local")),Tt=me(i||[]).map(Y=>{const te=(Y.route&&Y.route.length?Y.route:[Y.name]).join("/"),Ce=we(te);if(Y.kind==="vl")return{g:Y,nodeRoute:te,groupView:Ce,rawItems:[],items:[]};const{rawItems:$e}=zl(Y),ke=Gr($e,E,Ce.filter,hr(z,te));return{g:Y,nodeRoute:te,groupView:Ce,rawItems:$e,items:ke}}),pn=[...zt,...Tt.flatMap(({items:Y,nodeRoute:te,g:Ce})=>(Y||[]).map($e=>({...$e,nodeRoute:te,nodeLabel:Ce.label||Ce.name})))].filter(Y=>Y.type==="cell"),St=Ht?pn.find(Y=>Y.key===Ht):null,it=()=>{if(!Wt)return null;const Y=pn.find(ke=>ke.key===Wt.itemKey);if(!Y)return null;const te=Y.value,Ce=Y.nodeRoute?i.find(ke=>(ke.route||[ke.name]).join("/")===Y.nodeRoute)||{}:null,$e=Y.nodeRoute?Ce.route||[Y.nodeRoute]:[];return l.jsx(Dj,{row:Et(Y,te,$e,Y.nodeLabel||"",Ce&&Ce.sessions),token:Q,anchorRect:Wt.anchorRect,source:Wt.source,onSourceChange:ke=>ft(ut=>ut&&{...ut,source:ke}),onExpand:ke=>{ft(null),It(ke),Rt(Y.key),typeof V=="function"&&V()},onClose:Nt,onMouseEnter:tt,onMouseLeave:Xe})},Dt=(Y,te,Ce)=>s&&s({session:Y,...te?{node:te}:{},...Ea.test(String(Ce||""))?{ownerId:Ce}:{}}),Ot=async Y=>{if(!(Y!=null&&Y.direct)||!y)return;const te=window.prompt(p("rename-node-prompt"),Y.label||Y.name);if(te!==null)try{await y(Y,te)||window.alert(p("rename-node-invalid"))}catch(Ce){window.alert(String((Ce==null?void 0:Ce.message)||Ce))}},[Kt,Ge]=b.useState({}),[Mn,Ri]=b.useState(new Set);b.useEffect(()=>{const Y=new Map;for(const te of e||[])Y.set(Cl(te.cell),!!te.boot);for(const te of i||[]){const Ce=te.route||[te.name];for(const $e of te.cells||[])Y.set(Cl($e.cell,Ce),!!$e.boot)}Ge(te=>{let Ce=!1;const $e={...te};for(const[ke,ut]of Object.entries(te))Y.has(ke)&&Y.get(ke)===ut&&(delete $e[ke],Ce=!0);return Ce?$e:te})},[e,i]),b.useEffect(()=>{if(!(O!=null&&O.cell))return;const Y=Array.isArray(O.route)?O.route:[],te=Cl(O.cell,Y);Ge(Ce=>({...Ce,[te]:!!O.enabled})),G&&G(O.id)},[O,G]);const Ai=(Y,te=[])=>{const Ce=Cl(Y.cell,te);return Object.prototype.hasOwnProperty.call(Kt,Ce)?Kt[Ce]:!!Y.boot},Wn=async(Y,te,Ce=[],$e)=>{if(!d)return;const ke=Cl(te.cell,Ce),ut=typeof $e=="boolean"?$e:!Ai(te,Ce);Ge(pt=>({...pt,[ke]:ut})),Ri(pt=>new Set(pt).add(ke));try{await d(te.cell,ut,Ce)}catch(pt){Ge(Fe=>{const Bt={...Fe};return delete Bt[ke],Bt}),S&&S(pt)}finally{Ri(pt=>{const Fe=new Set(pt);return Fe.delete(ke),Fe})}},Qi=(Y,te,Ce)=>({onToggleLive:async()=>{const $e=Kr({item:Y,cellName:te.cell,route:Ce,pins:E,hostByRoute:H});ct(!0);const ke=await ud({action:$e.isLive?"remove":"use",cellId:te.cell,route:Ce,token:Q});ct(!1),xt({messageKey:ke.messageKey,ok:ke.ok,cell:ke.hostCell||te.cell})},onTogglePin:()=>ag({view:gd({item:Y,pins:E,hostByRoute:H,route:Ce}),itemKey:Y.key,togglePin:D,removePin:q}),onToggleBoot:$e=>Wn(null,te,Ce,$e),onWatchLive:()=>{ft(null),It("stream"),Rt(Y.key),typeof V=="function"&&V()}}),[Fi,Ji]=b.useState(null),re=(Y,te)=>{const Ce=Y.currentTarget.getBoundingClientRect();Ji({text:te,y:Ce.top+Ce.height/2})},be=()=>Ji(null),Be=b.useRef(null);b.useEffect(()=>()=>{Be.current&&Be.current()},[]);function We(Y){Y.preventDefault(),Y.stopPropagation();const te=Y.clientX,Ce=I,$e=ut=>{const pt=Math.max(Bj,Math.min(Oj,Ce+(ut.clientX-te)));j&&j(pt)},ke=()=>{window.removeEventListener("pointermove",$e),window.removeEventListener("pointerup",ke),window.removeEventListener("pointercancel",ke),window.removeEventListener("blur",ke),Be.current=null};window.addEventListener("pointermove",$e),window.addEventListener("pointerup",ke),window.addEventListener("pointercancel",ke),window.addEventListener("blur",ke),Be.current=ke}const wt=$?{width:48,flex:"0 0 48px"}:{width:I,flex:`0 0 ${I}px`};return $?l.jsxs("aside",{className:"nc-sidebar mini",style:wt,children:[l.jsx("div",{className:"nc-side-head mini",children:l.jsx("button",{className:"nc-collapse-btn",onClick:M,title:p("expand"),children:"⟩"})}),l.jsx("button",{className:"nc-side-gear mini",onClick:()=>w&&w("nodes",!1),title:p("settings"),onMouseEnter:Y=>re(Y,p("settings")),onMouseLeave:be,children:l.jsx(kt,{name:"gear",size:16})}),l.jsx("div",{className:"nc-side-scroll mini",children:l.jsxs("div",{className:"nc-side-group mini",children:[we("local").open&&zt.map(Y=>Y.type==="cell"?(()=>{const te=Y.value,Ce=te.degraded?"warn":te.tmux?"on":"",$e=!!te.tmux;return l.jsx("button",{type:"button",className:`nc-mini-dot${bt.has(te.tmuxSession)?" active":""}`,onMouseEnter:ke=>{$e?Ct(Y,"",ke.currentTarget):re(ke,`${te.cell}: ${Y.subtitle}`)},onMouseLeave:()=>{$e?Xe():be()},draggable:$e,onDragStart:$e?ke=>ke.dataTransfer.setData("text/nc-session",te.tmuxSession):void 0,onClick:$e?()=>{ft(null),a&&a(te.tmuxSession)}:()=>c&&c(te),onDoubleClick:$e?()=>Dt(te.tmuxSession,"",A):void 0,children:l.jsx("span",{className:`nc-dot ${Ce}${Y.working?" working":""}`})},Y.key)})():(()=>{const te=Y.value;return l.jsx("button",{type:"button",className:`nc-mini-init${bt.has(te.name)?" active":""}`,onMouseEnter:Ce=>re(Ce,te.name),onMouseLeave:be,draggable:!0,onDragStart:Ce=>Ce.dataTransfer.setData("text/nc-session",te.name),onClick:()=>a&&a(te.name),onDoubleClick:()=>Dt(te.name,"",A),children:jf(te.name)},Y.key)})()),Tt.flatMap(({g:Y,nodeRoute:te,groupView:Ce,items:$e})=>Y.kind==="vl"?Y.status==="up"&&Y.sessions.length?Y.sessions.map(ke=>l.jsx("button",{type:"button",className:"nc-mini-init",onMouseEnter:ut=>re(ut,`${Y.label||te}: ${ke.name}`),onMouseLeave:be,onClick:()=>X&&X(Y.peer),children:jf(ke.name)},ke.key)):[l.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:ke=>re(ke,`${Y.label||Y.name}: ${zs(Y)||p("no-sessions-short")}`),onMouseLeave:be,children:l.jsx("span",{className:`nc-dot${Y.status==="up"?" on":" warn"}`})},`nodo-vl-${te}-${Y.name}`)]:Y.status==="up"?Ce.open?$e.map(ke=>ke.type==="cell"?(()=>{const ut=ke.value,pt=!!ut.tmux;return l.jsx("button",{type:"button",className:`nc-mini-dot${bt.has(ke.key)?" active":""}`,onMouseEnter:Fe=>{pt?Ct(ke,te,Fe.currentTarget):re(Fe,`${Y.label||te}: ${ut.cell} · ${ke.subtitle}`)},onMouseLeave:()=>{pt?Xe():be()},draggable:pt,onDragStart:pt?Fe=>Fe.dataTransfer.setData("text/nc-session",ke.key):void 0,onClick:pt?()=>{ft(null),a&&a(ke.key)}:()=>c&&c({...ut,route:Y.route,availableEngines:Y.engines||[]}),onDoubleClick:pt?()=>Dt(ut.tmuxSession,te,Y.instanceId):void 0,children:l.jsx("span",{className:`nc-dot ${ut.degraded?"warn":pt?`on${ke.working?" working":""}`:""}`})},ke.key)})():(()=>{const ut=ke.value;return l.jsx("button",{type:"button",className:`nc-mini-init${bt.has(ke.key)?" active":""}`,onMouseEnter:pt=>re(pt,`${Y.label||te}: ${ut.name}`),onMouseLeave:be,draggable:!0,onDragStart:pt=>pt.dataTransfer.setData("text/nc-session",ke.key),onClick:()=>a&&a(ke.key),onDoubleClick:()=>Dt(ut.name,te,Y.instanceId),children:jf(ut.name)},ke.key)})()):[]:[l.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:ke=>re(ke,`${Y.label||(Y.route||[Y.name]).join(" › ")}: ${zs(Y)}`),onMouseLeave:be,children:l.jsx("span",{className:`nc-dot${Y.status==="passive"?"":" warn"}`})},`nodo-${(Y.route||[Y.name]).join("/")}`)])]})}),it(),Fi&&l.jsx("div",{className:"nc-mini-tip",style:{top:Fi.y},children:Fi.text})]}):l.jsxs("aside",{className:"nc-sidebar",style:wt,children:[l.jsx("div",{className:"nc-side-live-host",children:l.jsx(zj,{view:ka({liveHost:H[yi([])],cells:e}),notice:st})}),l.jsxs("div",{className:"nc-side-head",children:[l.jsx("button",{className:"nc-collapse-btn",onClick:M,title:p("collapse"),children:"⟨"}),l.jsx("span",{className:"nc-side-title",children:p("fleet")}),N&&l.jsx("span",{className:"nc-side-fleet-stale",role:"status",title:p("fleet-stale"),"aria-label":p("fleet-stale"),children:"●"}),k!==null&&l.jsx("span",{className:"nc-side-fleet-off",role:"status",title:`${p("fleet-off")}${k?` (${k})`:""}`,"aria-label":`${p("fleet-off")}${k?` (${k})`:""}`,children:"○"}),l.jsxs("button",{className:"nc-new-btn",onClick:_,title:p("fleet-new-cell"),children:["+ ",p("new")]})]}),l.jsxs("button",{className:"nc-side-gear",onClick:()=>w&&w("nodes",!1),title:p("settings"),children:[l.jsx(kt,{name:"gear",size:15})," ",p("settings")]}),l.jsx(V1,{pinError:ce,onRetry:ge,onDismiss:se}),l.jsxs("div",{className:"nc-side-scroll",children:[l.jsx(Fj,{label:p("position-local"),count:zt.length,state:we("local"),onToggle:()=>_e("local",{open:!we("local").open}),onFilter:Y=>_e("local",{filter:Y})}),we("local").open&&l.jsxs("div",{className:"nc-side-group",children:[zt.map(Y=>Y.type==="cell"?(()=>{var ne;const te=Y.value,Ce=Ye([]),$e=$u({hostCell:Ce.hostCell??null,threadStatus:Ce.threadStatus,pins:E,item:Y}),ke=te.degraded?"warn":te.tmux?"on":"",ut=mp($e,Ce.hostLease??null),pt=te.degraded?p("cell-degraded"):Y.subtitle||(te.tmux?p("cell-idle"):p("cell-off")),Fe=ut?`${pt} · ${p(ut)}`:pt,Bt=!!te.tmux;return l.jsxs("div",{"data-roster-key":Y.key,"data-position":"local",className:`nc-cell${Bt?" live":""}${bt.has(te.tmuxSession)?" active":""}`,title:`${te.cell} · ${Y.subtitle}${Fe===Y.subtitle?"":` · ${Fe}`}`,"aria-label":`${te.cell}, ${Y.subtitle}${Fe===Y.subtitle?"":`, ${Fe}`}`,draggable:Bt,onDragStart:Bt?le=>le.dataTransfer.setData("text/nc-session",te.tmuxSession):void 0,onClick:Bt?()=>a&&a(te.tmuxSession):void 0,onDoubleClick:Bt?()=>Dt(te.tmuxSession,"",A):void 0,children:[l.jsx(Os,{position:"local",itemKey:Y.key,label:te.cell,canMove:fe,onMove:(le,Re)=>ie("local",le,Re,Ae),onStep:le=>de("local",Y.key,le,Ae)}),Bt?l.jsx("button",{type:"button",className:"nc-side-peek",title:p("cell-peek"),"aria-label":`${p("cell-peek")}: ${te.cell}`,onClick:jt(Y,te,[],""),onMouseEnter:le=>Ct(Y,"",le.currentTarget),onMouseLeave:Xe,children:l.jsx("span",{className:`nc-dot ${ke}${Y.working?" working":""}`})}):l.jsx("span",{className:`nc-dot ${ke}${Y.working?" working":""}`}),l.jsxs("span",{className:"nc-cell-main",children:[l.jsxs("b",{title:te.cell,children:[te.cell,Kr({item:Y,cellName:te.cell,route:[],pins:E,hostByRoute:H}).isLive&&l.jsx("span",{className:"nc-live-bollino",children:"LIVE"})]}),l.jsx("small",{title:Y.subtitle,children:Y.subtitle})]}),Y.activity?l.jsx("span",{className:"nc-rel",children:Vr(Y.activity)}):null,Y.fresh&&((ne=(ze.get(te.tmuxSession)||{}).outbox)==null?void 0:ne.count)>0?l.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:ze.get(te.tmuxSession).outbox.count}):null,l.jsx("button",{type:"button",className:"nc-cellmenu",title:`${p("cell-actions-open")}: ${te.cell}`,"aria-label":`${p("cell-actions-open")}: ${te.cell}`,"aria-haspopup":"menu","aria-expanded":J&&J.itemKey===Y.key?"true":"false",onClick:le=>{le.stopPropagation(),kn(Y.key,"",le.currentTarget,C.includes("boot")&&!!d,!1)},children:l.jsx("span",{"aria-hidden":"true",children:"⋯"})}),l.jsx("button",{className:`nc-power${te.tmux?" on":""}${te.degraded?" warn":""}`,onClick:le=>{le.stopPropagation(),c&&c({...te,boot:Ai(te)})},title:te.active?p("power-off"):p("power-on"),children:l.jsx(kt,{name:"power",size:14})})]},Y.key)})():(()=>{var Ce;const te=Y.value;return l.jsxs("div",{"data-roster-key":Y.key,"data-position":"local",className:`nc-side-card${bt.has(te.name)?" active":""}`,draggable:!0,onDragStart:$e=>$e.dataTransfer.setData("text/nc-session",te.name),onClick:()=>a&&a(te.name),onDoubleClick:()=>Dt(te.name,"",A),children:[l.jsx(Os,{position:"local",itemKey:Y.key,label:te.name,canMove:fe,onMove:($e,ke)=>ie("local",$e,ke,Ae),onStep:$e=>de("local",Y.key,$e,Ae)}),l.jsx("span",{className:te.attached?"nc-dot on":"nc-dot"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:te.name}),l.jsxs("small",{children:[te.preview||te.cmd||p("windows").replace("{n}",String(te.windows||0)),((Ce=te.outbox)==null?void 0:Ce.count)>0?` · 📦${te.outbox.count}`:""]})]}),te.activity?l.jsx("span",{className:"nc-rel",children:Vr(te.activity)}):null,l.jsx("button",{className:`nc-pin${E.includes(Y.key)?" on":""}`,title:p("pin"),onClick:$e=>{$e.stopPropagation(),D(Y.key)},children:E.includes(Y.key)?"★":"☆"}),l.jsx("button",{className:`nc-technical${te.technical?" on":""}`,title:te.technical?p("mark-normal"):p("mark-technical"),"aria-label":`${te.technical?p("mark-normal"):p("mark-technical")} ${te.name}`,onClick:$e=>{$e.stopPropagation(),g&&g(te.name,!te.technical,[])},children:"T"}),l.jsx("button",{className:"nc-menu",title:p("terminate"),onClick:$e=>{$e.stopPropagation(),window.confirm(p("terminate-confirm").replace("{name}",te.name))&&f&&f(te.name)},children:"⋯"})]},Y.key)})()),zt.length===0&&l.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]}),Tt.map(({g:Y,nodeRoute:te,groupView:Ce,rawItems:$e,items:ke})=>{const ut=J1(Y.health),pt=Y.fleetState==="stale"?p("fleet-stale"):Y.fleetState==="disabled"?p("fleet-off"):"",Fe=Y.fleetState==="stale"?"warn":ut||(Y.status==="up"?"on":Y.status==="passive"?"":"warn"),Bt=[Y.health?Yu(Y.health):"",pt].filter(Boolean).join(" · ");return Y.kind==="vl"?l.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":xe(Y),children:[l.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>_e(te,{open:!Ce.open}),onKeyDown:ne=>{(ne.key==="Enter"||ne.key===" ")&&(ne.preventDefault(),_e(te,{open:!Ce.open}))},children:[l.jsx(Os,{scope:"node",position:"nodes",itemKey:xe(Y),label:Y.label||Y.name,onMove:(ne,le)=>Ee(ne,le,i||[]),onStep:ne=>Se(xe(Y),ne,i||[])}),l.jsx("span",{className:"nc-node-chevron",children:Ce.open?"⌄":"›"}),l.jsx("span",{className:`nc-dot ${Fe}`,title:Bt}),l.jsx("b",{children:Y.label||Y.name}),l.jsxs("small",{children:[" · ",zs(Y)||[p("node-sessions").replace("{n}",String(Y.sessions.length)),pt].filter(Boolean).join(" · ")]})]}),Y.status==="up"&&Ce.open&&l.jsxs("div",{className:"nc-side-group",children:[Y.sessions.map(ne=>l.jsxs("div",{className:"nc-side-card nc-vl-session-row",role:"button",tabIndex:0,onClick:()=>X&&X(Y.peer),onKeyDown:le=>{(le.key==="Enter"||le.key===" ")&&(le.preventDefault(),X&&X(Y.peer))},children:[l.jsx("span",{className:"nc-dot on"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:ne.name}),l.jsx("small",{children:p("vl-events-title")})]})]},ne.key)),Y.sessions.length===0&&l.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]})]},`nodo-vl-${te}-${Y.name}`):l.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":xe(Y),children:[l.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:Y.direct&&y?ne=>{ne.preventDefault(),Ot(Y)}:void 0,onClick:()=>_e(te,{open:!Ce.open}),onKeyDown:ne=>{(ne.key==="Enter"||ne.key===" ")&&(ne.preventDefault(),_e(te,{open:!Ce.open}))},children:[l.jsx(Os,{scope:"node",position:"nodes",itemKey:xe(Y),label:Y.label||Y.name,onMove:(ne,le)=>Ee(ne,le,i||[]),onStep:ne=>Se(xe(Y),ne,i||[])}),l.jsx("span",{className:"nc-node-chevron",children:Ce.open?"⌄":"›"}),l.jsx("span",{className:`nc-dot ${Fe}`,title:Bt}),l.jsx("b",{children:Y.label||Y.name}),l.jsxs("small",{children:[" · ",Y.status==="up"?[p("node-sessions").replace("{n}",String(ke.length)),pt].filter(Boolean).join(" · "):Y.health&&Yu(Y.health)||zs(Y)]}),l.jsxs("select",{className:"nc-node-filter",value:Ce.filter,title:p(`view-${Ce.filter}`),onClick:ne=>ne.stopPropagation(),onChange:ne=>_e(te,{filter:ne.target.value}),children:[l.jsx("option",{value:"all",children:p("view-all")}),l.jsx("option",{value:"pinned",children:p("view-pinned")}),l.jsx("option",{value:"active",children:p("view-active")}),l.jsx("option",{value:"off",children:p("view-off")}),l.jsx("option",{value:"technical",children:p("view-technical")})]}),Y.direct&&y&&l.jsx("button",{type:"button",className:"nc-node-rename",title:p("rename-node"),"aria-label":`${p("rename-node")} ${Y.label||Y.name}`,onClick:ne=>{ne.stopPropagation(),Ot(Y)},children:"✎"}),Y.direct&&Y.health&&Y.health.managed!==!1&&l.jsx("button",{type:"button",className:`nc-power${Y.tunnelStatus==="up"?" on":""}`,title:Y.tunnelStatus==="up"?p("power-off"):p("power-on"),onClick:ne=>{ne.stopPropagation(),h&&h(Y)},children:l.jsx(kt,{name:"power",size:14})})]}),(Y.status==="up"||Y.cellsPreserved)&&Ce.open&&l.jsxs("div",{className:"nc-side-group",children:[ke.map(ne=>ne.type==="cell"?(()=>{var fi;const le=ne.value,Re=Y.route||[Y.name],ot=Ye(Re),rt=$u({hostCell:ot.hostCell??null,threadStatus:ot.threadStatus,pins:E,item:ne}),ri=mp(rt,ot.hostLease??null),En=!!le.tmux&&!Y.cellsPreserved,Xt=le.degraded?"warn":le.tmux&&!Y.cellsPreserved?"on":"",Dn=(Y.sessions||[]).find(Zt=>Zt&&Zt.name===le.tmuxSession)||null,Gt=Y.cellsPreserved?`${p("fleet-stale")}`:ne.subtitle||(le.tmux?p("cell-idle"):p("cell-off")),Zi=ri?`${Gt} · ${p(ri)}`:Gt;return l.jsxs("div",{"data-roster-key":ne.key,"data-position":te,className:`nc-side-card nc-cell${En?" live":""}${Y.cellsPreserved?" preserved":""}${bt.has(le.key)?" active":""}`,title:Zi,draggable:En,onDragStart:En?Zt=>Zt.dataTransfer.setData("text/nc-session",le.key):void 0,onClick:En?()=>a&&a(le.key):void 0,onDoubleClick:En?()=>Dt(le.tmuxSession,te,Y.instanceId):void 0,children:[l.jsx(Os,{position:te,itemKey:ne.key,label:le.cell,canMove:fe,onMove:(Zt,Qr)=>ie(te,Zt,Qr,$e),onStep:Zt=>de(te,ne.key,Zt,$e)}),En?l.jsx("button",{type:"button",className:"nc-side-peek",title:p("cell-peek"),"aria-label":`${p("cell-peek")}: ${le.cell}`,onClick:jt(ne,le,Y.route||[Y.name],Y.label||Y.name),onMouseEnter:Zt=>Ct(ne,te,Zt.currentTarget),onMouseLeave:Xe,children:l.jsx("span",{className:`nc-dot ${Xt}${ne.working?" working":""}`})}):l.jsx("span",{className:`nc-dot ${Xt}${ne.working?" working":""}`}),l.jsxs("span",{className:"nc-card-main",children:[l.jsxs("b",{children:[le.cell,Kr({item:ne,cellName:le.cell,route:Re,pins:E,hostByRoute:H}).isLive&&l.jsx("span",{className:"nc-live-bollino",children:"LIVE"})]}),l.jsx("small",{title:ne.subtitle,children:ne.subtitle})]}),ne.activity?l.jsx("span",{className:"nc-rel",children:Vr(ne.activity)}):null,ne.fresh&&((fi=(Dn||{}).outbox)==null?void 0:fi.count)>0?l.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:Dn.outbox.count}):null,l.jsx("button",{type:"button",className:"nc-cellmenu",title:`${p("cell-actions-open")}: ${le.cell}`,"aria-label":`${p("cell-actions-open")}: ${le.cell}`,"aria-haspopup":"menu","aria-expanded":J&&J.itemKey===ne.key?"true":"false",onClick:Zt=>{Zt.stopPropagation(),kn(ne.key,te,Zt.currentTarget,d&&(Y.capabilities||[]).includes("boot"),!!Y.cellsPreserved)},children:l.jsx("span",{"aria-hidden":"true",children:"⋯"})}),(Y.capabilities||[]).includes(le.active?"down":"up")&&l.jsx("button",{className:`nc-power${le.active?" on":""}${le.degraded?" warn":""}`,onClick:Zt=>{Zt.stopPropagation(),c&&c({...le,boot:Ai(le,Y.route||[]),route:Y.route,availableEngines:Y.engines||[]})},title:le.active?p("power-off"):p("power-on"),children:l.jsx(kt,{name:"power",size:14})})]},ne.key)})():(()=>{const le=ne.value;return l.jsxs("div",{"data-roster-key":ne.key,"data-position":te,className:`nc-side-card${bt.has(le.key)?" active":""}`,draggable:!0,onDragStart:Re=>Re.dataTransfer.setData("text/nc-session",le.key),onClick:()=>a&&a(le.key),onDoubleClick:()=>Dt(le.name,le.node||te,Y.instanceId),children:[l.jsx(Os,{position:te,itemKey:ne.key,label:le.name,canMove:fe,onMove:(Re,ot)=>ie(te,Re,ot,$e),onStep:Re=>de(te,ne.key,Re,$e)}),l.jsx("span",{className:le.attached?"nc-dot on":"nc-dot"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:le.name}),l.jsx("small",{children:le.preview?le.preview:le.cmd?le.cmd:p("windows").replace("{n}",String(le.windows||0))})]}),le.activity?l.jsx("span",{className:"nc-rel",children:Vr(le.activity)}):null,l.jsx("button",{className:`nc-pin${E.includes(ne.key)?" on":""}`,title:p("pin"),onClick:Re=>{Re.stopPropagation(),D(ne.key)},children:E.includes(ne.key)?"★":"☆"}),l.jsx("button",{className:`nc-technical${le.technical?" on":""}`,title:le.technical?p("mark-normal"):p("mark-technical"),"aria-label":`${le.technical?p("mark-normal"):p("mark-technical")} ${le.name}`,onClick:Re=>{Re.stopPropagation(),g&&g(le.name,!le.technical,Y.route||[])},children:"T"}),l.jsx("button",{className:"nc-menu",title:p("terminate"),onClick:Re=>{Re.stopPropagation(),window.confirm(p("terminate-confirm").replace("{name}",le.name))&&f&&f(le.name,Y.route)},children:"⋯"})]},ne.key)})()),ke.length===0&&l.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]})]},`nodo-${(Y.route||[Y.name]).join("/")}`)})]}),l.jsx("div",{className:"nc-side-lang",children:J0.map((Y,te)=>l.jsxs("span",{children:[te>0&&" · ",l.jsx("button",{className:`nc-lang-btn${L===Y?" on":""}`,onClick:()=>R(Y),title:Y,children:Y.toUpperCase()})]},Y))}),l.jsx("div",{className:"nc-side-resize",onPointerDown:We,title:""}),St&&(()=>{const Y=St.value,te=St.nodeRoute?i.find($e=>($e.route||[$e.name]).join("/")===St.nodeRoute)||{}:null,Ce=St.nodeRoute?te.route||[St.nodeRoute]:[];return l.jsx(j1,{row:Et(St,Y,Ce,St.nodeLabel||"",te&&te.sessions),token:Q,initialSource:fn,onClose:()=>{Rt(null),It("preview")}})})(),it(),J&&(()=>{const Y=pn.find(Fe=>Fe.key===J.itemKey);if(!Y)return null;const te=Y.value,Ce=J.routeKey?i.find(Fe=>(Fe.route||[Fe.name]).join("/")===J.routeKey)||{}:null,$e=J.routeKey?Ce.route||[J.routeKey]:[],ke=J.preserved?!1:!!te.tmux,ut=Kr({item:Y,cellName:te.cell,route:$e,pins:E,hostByRoute:H}),pt=lg({...ut,canBoot:J.canBoot,boot:Ai(te,$e),alive:ke,handlers:Qi(Y,te,$e)});return l.jsx(X1,{anchorRect:K,items:pt,busy:Ze,onClose:()=>ee(null)})})()]})}function zj({view:t,notice:e}){const n=!!(t&&t.cell),i=n?p("live-host-indicator").replace("{cell}",t.cell).replace("{mode}",p(t.mode?`live-host-mode-${t.mode}`:"live-host-mode-unknown")).replace("{state}",p(`live-host-state-${t.state||"none"}`)):p("live-host-indicator-none");return l.jsxs("div",{className:"nc-live-strip","data-state":t&&t.state?t.state:"none",title:e?`${i} · ${p(e.messageKey)}`:i,children:[l.jsx("span",{className:`nc-live-strip-dot ${ug(t||{})}`,"aria-hidden":"true"}),l.jsx("span",{className:"nc-live-strip-testo",children:n?t.cell:i}),e&&l.jsx("span",{className:`nc-live-strip-notice${e.ok?" ok":" ko"}`,role:"status",children:p(e.messageKey).replace("{cell}",e.cell||t.cell||"")})]})}function Fj({label:t,count:e,state:n,onToggle:i,onFilter:s}){return l.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:i,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),i())},children:[l.jsx("span",{className:"nc-node-chevron",children:n.open?"⌄":"›"}),l.jsx("span",{className:"nc-dot on"}),l.jsx("b",{children:t}),l.jsxs("small",{children:[" · ",p("node-sessions").replace("{n}",String(e))]}),l.jsxs("select",{className:"nc-node-filter",value:n.filter,title:p(`view-${n.filter}`),onClick:a=>a.stopPropagation(),onChange:a=>s(a.target.value),children:[l.jsx("option",{value:"all",children:p("view-all")}),l.jsx("option",{value:"pinned",children:p("view-pinned")}),l.jsx("option",{value:"active",children:p("view-active")}),l.jsx("option",{value:"off",children:p("view-off")}),l.jsx("option",{value:"technical",children:p("view-technical")})]})]})}const ci={PRESENTE:"presente-verificata",ASSENTE:"assente-verificata",IGNOTA:"ignota"},Tf={OK:"ok",NON_DISPONIBILE:"non-disponibile",RIMOSSO:"rimosso"},yu={LETTURA_NON_VERIFICABILE:"lettura-non-verificabile",OWNER_NON_DISPONIBILE:"owner-non-disponibile",OWNER_RIMOSSO:"owner-rimosso",LOCALE_NON_VERIFICATO:"lettura-locale-non-verificata"},pb={RITORNO:"ritorno-dopo-assenza",IDENTITA:"identita-cambiata"},Hj=6e4;function Uj(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 mb(t){const e=t&&t.created;return Number.isFinite(e)&&e>0?e:null}function Wj({tileKey:t,node:e,nodeGroups:n,sessionsAlive:i,localVerified:s=!0,localIdentita:a=null,lastVerifiedAt:c=null,nowMs:d=0}={}){const h=Uj(e,n);let f,g=Tf.OK,_=null,y=null;if(!e)s?!i||i.has(t)?(f=ci.PRESENTE,y=mb({created:a})):f=ci.ASSENTE:(f=ci.IGNOTA,_=yu.LOCALE_NON_VERIFICATO);else if(!h)f=ci.IGNOTA,g=Tf.RIMOSSO,_=yu.OWNER_RIMOSSO;else if(h.status!=="up")f=ci.IGNOTA,g=Tf.NON_DISPONIBILE,_=h.cause||yu.OWNER_NON_DISPONIBILE;else if(h.inventoryPartial===!0)f=ci.IGNOTA,_=yu.LETTURA_NON_VERIFICABILE;else if(!i||i.has(t)){f=ci.PRESENTE;const S=Array.isArray(h.sessions)?h.sessions.find(A=>A&&A.key===t):null;y=mb(S)}else f=ci.ASSENTE;const w=f===ci.IGNOTA&&Number.isFinite(c)&&Number.isFinite(d)&&d-c>Hj;return{presenza:f,owner:g,causa:_,identita:f===ci.PRESENTE?y:null,verificata:f!==ci.IGNOTA,oltreIlTetto:w}}function gx(){return{presenza:null,identita:null}}function qj(t,e){const n=t&&typeof t=="object"?t:gx();if(!e||e.presenza===ci.IGNOTA)return{runtime:{presenza:n.presenza,identita:n.identita},generazione:0,motivo:null};const i=e.presenza===ci.PRESENTE;let s=null;return i&&(n.presenza===ci.ASSENTE?s=pb.RITORNO:n.presenza===ci.PRESENTE&&n.identita!==null&&e.identita!==null&&n.identita!==e.identita&&(s=pb.IDENTITA)),{runtime:{presenza:e.presenza,identita:i?e.identita===void 0?null:e.identita:null},generazione:s?1:0,motivo:s}}const pg="nc_input_preferences_v1",Pf="nc-input-preferences",vx=Object.freeze(["double-tap","single-tap","never"]),_x=Object.freeze(["full","compact"]),Wr=Object.freeze({terminalKeyboardGesture:"double-tap",keybarKeepsKeyboardClosed:!0,voiceKeepsKeyboardClosed:!0,showKeybarEnter:!0,keybarLayout:"full"});function mg(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{};return{terminalKeyboardGesture:vx.includes(e.terminalKeyboardGesture)?e.terminalKeyboardGesture:Wr.terminalKeyboardGesture,keybarKeepsKeyboardClosed:typeof e.keybarKeepsKeyboardClosed=="boolean"?e.keybarKeepsKeyboardClosed:Wr.keybarKeepsKeyboardClosed,voiceKeepsKeyboardClosed:typeof e.voiceKeepsKeyboardClosed=="boolean"?e.voiceKeepsKeyboardClosed:Wr.voiceKeepsKeyboardClosed,showKeybarEnter:typeof e.showKeybarEnter=="boolean"?e.showKeybarEnter:Wr.showKeybarEnter,keybarLayout:_x.includes(e.keybarLayout)?e.keybarLayout:Wr.keybarLayout}}function yx(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function gb(t=yx()){if(!t)return{...Wr};try{return mg(JSON.parse(t.getItem(pg)||"null"))}catch{return{...Wr}}}function Kj(t,e=yx()){const n=mg(t);if(e)try{e.setItem(pg,JSON.stringify(n))}catch{}return n}function gg(){const[t,e]=b.useState(gb);b.useEffect(()=>{const i=s=>{if((s==null?void 0:s.type)==="storage"&&s.key!==pg&&s.key!==null)return;const a=s!=null&&s.detail?mg(s.detail):gb();e(a)};return window.addEventListener(Pf,i),window.addEventListener("storage",i),()=>{window.removeEventListener(Pf,i),window.removeEventListener("storage",i)}},[]);const n=b.useCallback(i=>{e(s=>{const a=Kj({...s,...i||{}});return window.dispatchEvent(new CustomEvent(Pf,{detail:a})),a})},[]);return[t,n]}function Vj({session:t,node:e,ownerId:n,cellName:i,token:s,readonly:a=!1,focused:c,onFocus:d,onClose:h,onOpenSingle:f,alive:g=!0,sessionAlive:_=g,available:y=!0,stale:w=!1,presence:S=null,fontSize:A=sc,onZoom:C,decks:N=[],currentDeck:k,onSendToDeck:O,panelUrl:P="",panelCellId:H="",panelPort:W=0}){const[U]=gg(),G=i||t,X=b.useRef(()=>{}),Q=b.useRef(()=>!1),V=b.useRef(()=>{}),T=b.useRef(!1),[I,$]=b.useState(!1),[j,M]=b.useState(!1),[L,R]=b.useState(!1),[E,z]=b.useState(!1),[D,q]=b.useState(null),[ce,ge]=b.useState(0),se=b.useRef(gx()),we=e?`${e}:${t}`:t,_e=N.filter(de=>de.id!==k&&de.available!==!1),fe=S?S.presenza:_?ci.PRESENTE:ci.ASSENTE,ie=S?S.identita??null:null;return b.useEffect(()=>{const de=qj(se.current,{presenza:fe,identita:ie});se.current=de.runtime,de.generazione&&ge(me=>me+de.generazione)},[fe,ie]),l.jsxs("div",{className:`nc-tile${c?" focused":""}`,onMouseDown:()=>d&&d(we),children:[l.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:de=>{de.dataTransfer.setData("text/nc-session",we),de.dataTransfer.effectAllowed="move"},children:[l.jsxs("button",{className:"nc-tile-name",onClick:()=>d&&d(we),title:e?`${G} · ${e}`:G,children:[l.jsx("span",{className:g?"nc-dot on":"nc-dot"}),l.jsx("b",{children:G})]}),l.jsxs("span",{className:"nc-tile-actions",children:[C&&l.jsx("button",{onClick:()=>C(-1),title:p("zoom-out"),children:l.jsx(kt,{name:"zoomOut",size:14})}),C&&l.jsx("button",{onClick:()=>C(1),title:p("zoom-in"),children:l.jsx(kt,{name:"zoomIn",size:14})}),O&&_e.length>0&&l.jsxs("select",{className:"nc-tile-deck",title:p("send-to-deck"),value:"",onMouseDown:de=>de.stopPropagation(),onChange:de=>{const me=de.target.value;me&&O(we,me),de.target.value=""},children:[l.jsx("option",{value:"",children:p("send-to-deck")}),_e.map(de=>l.jsxs("option",{value:de.id,children:[de.ownerLabel," · ",de.name]},de.id))]}),l.jsx("button",{onClick:()=>M(de=>!de),title:p("composer"),children:"⌨"}),l.jsx("button",{onClick:()=>R(de=>!de),title:p("files"),children:"📁"}),P&&l.jsx("button",{onClick:()=>z(de=>!de),title:p("panel"),"aria-pressed":E,children:l.jsx(kt,{name:"monitor",size:14})}),f&&l.jsx("button",{onClick:()=>f({session:t,node:e,ownerId:n}),title:p("single-view"),children:"↗"}),h&&l.jsx("button",{className:"nc-tile-close",onClick:()=>h(we),title:p("close"),children:"✕"})]})]}),l.jsxs("div",{className:"nc-tile-body",children:[S&&S.oltreIlTetto===!0&&l.jsx("div",{className:"nc-tile-unverified",role:"status","data-causa":S.causa||"",children:p("tile-unverified")}),l.jsx($l,{session:t,node:e,token:s,readonly:a,takeSize:!1,focused:c,sendRef:X,composerRef:Q,actionRef:V,ctrlRef:T,setCtrlArmed:$,onFiles:q,fontSize:A,keyboardGesture:U.terminalKeyboardGesture},`${we}:${ce}`),!y&&l.jsx("div",{className:"nc-tile-unavailable",title:p("deck-owner-unavailable"),children:p("deck-owner-reconnecting")}),y&&w&&l.jsx("div",{className:"nc-tile-stale",title:p("deck-owner-stale"),children:p("deck-owner-stale")}),y&&L&&l.jsx("div",{className:"nc-tile-files",onMouseDown:de=>de.stopPropagation(),children:l.jsx(wm,{session:t,node:e,token:s,filesEvent:D,onClose:()=>R(!1)})})]}),y&&j&&l.jsx("div",{className:"nc-tile-composer",onMouseDown:de=>de.stopPropagation(),children:l.jsx(mx,{submitText:de=>Q.current(de),token:s,session:t,node:e,ownerId:n,readonly:a,keepKeyboardClosedOnVoice:U.voiceKeepsKeyboardClosed})}),y&&E&&P&&H&&l.jsx(eS,{title:G,onClose:()=>z(!1),children:l.jsx(tg,{cellId:H,panelUrl:P,route:e?e.split("/"):[],panelPort:W,token:s,title:G})})]})}function wx({session:t,node:e,ownerId:n,cells:i,nodeGroups:s}={}){const a=typeof t=="string"?t:"";if(!a)return null;if(e){const d=Array.isArray(s)?s:[];for(const h of d){if(!h||(Array.isArray(h.route)?h.route:[]).join("/")!==e||n&&h.instanceId&&String(n)!==String(h.instanceId))continue;const g=(Array.isArray(h.cells)?h.cells:[]).find(_=>_&&_.tmuxSession===a);if(g)return g}return null}return(Array.isArray(i)?i:[]).find(d=>d&&d.tmuxSession===a)||null}function Zu({session:t,cell:e,node:n,ownerId:i,cells:s,nodeGroups:a}={}){const c=typeof t=="string"?t:"";if(e&&typeof e.cell=="string"&&e.cell)return e.cell;const d=wx({session:c,node:n,ownerId:i,cells:s,nodeGroups:a});return d&&d.cell?d.cell:c}const vb=.2,_b=.28,bx=(t,e)=>Array.from((t==null?void 0:t.types)||[]).includes(e),If=t=>bx(t,"text/nc-session"),yb=t=>{var e;return bx(t,"Files")||(((e=t==null?void 0:t.files)==null?void 0:e.length)||0)>0};function Yj(t,e){return t&&Array.isArray(e)?e.find(n=>Array.isArray(n==null?void 0:n.route)&&n.route.join("/")===t):null}function Gj(t,e,n){const i=(t-n.left)/(n.width||1),s=(e-n.top)/(n.height||1);return i<_b?"left":i>1-_b?"right":s<.5?"top":"bottom"}function Xj({layout:t,onLayoutChange:e,token:n,readonly:i=!1,sessionsAlive:s,focusSession:a,onFocus:c,onOpenSingle:d,localVerified:h=!0,localIdentities:f=null,localVerifiedAt:g=null,decks:_=[],currentDeck:y,onSendToDeck:w,onResizeEnd:S,cells:A=[],nodeGroups:C=[],panelPort:N=0,nodePanelPorts:k={}}){Li();const O=Date.now(),[P,H]=b.useState(null),W=b.useRef(null),U=b.useRef([]),G=b.useRef(null);function X(R,E){const z=()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",z),window.removeEventListener("pointercancel",z),window.removeEventListener("blur",z),G.current=null,E&&E()};window.addEventListener("pointermove",R),window.addEventListener("pointerup",z),window.addEventListener("pointercancel",z),window.addEventListener("blur",z),G.current=z}b.useEffect(()=>()=>{G.current&&G.current()},[]),b.useEffect(()=>{const R=()=>H(null);return window.addEventListener("dragend",R),window.addEventListener("drop",R),()=>{window.removeEventListener("dragend",R),window.removeEventListener("drop",R)}},[]);const Q=t.columns.length,V=R=>P&&P.col===R&&P.row===void 0,T=!!P&&P.col===Q,I=(R,E)=>P&&P.col===R&&P.row===E&&P.quadrant?` drop-${P.quadrant}`:"";function $(R){if(R.preventDefault(),yb(R.dataTransfer)){H(null);return}const E=R.dataTransfer.getData("text/nc-session"),z=P;if(H(null),!E||!z)return;let D;if(z.quadrant){if(D=GM(t,z.col,z.row,z.quadrant),!D)return}else D={col:z.col};e(Gi(t).includes(E)?WM(t,E,D):Gl(t,E,D))}function j(R,E){R.preventDefault(),R.stopPropagation();const z=R.clientX,D=t.columns[E].width,q=W.current&&W.current.clientWidth||1,ce=t.columns[E+1];X(se=>{let we=Math.max(vb,D+(se.clientX-z)/q);if(ce){const _e=rb(we/(we+ce.width));we=_e/(1-_e)*ce.width}e(KM(t,E,we))},S)}function M(R,E,z){R.preventDefault(),R.stopPropagation();const D=R.clientY,q=t.columns[E].tiles[z].height,ce=U.current[E],ge=ce&&ce.clientHeight||1,se=t.columns[E].tiles[z+1];X(_e=>{let fe=Math.max(vb,q+(_e.clientY-D)/ge);if(se){const ie=rb(fe/(fe+se.height));fe=ie/(1-ie)*se.height}e(VM(t,E,z,fe))},S)}function L(R){e(Xu(t,R))}return l.jsxs("div",{className:"nc-grid",ref:W,onDragOver:R=>{if(yb(R.dataTransfer)){R.preventDefault(),H(null);return}If(R.dataTransfer)&&(R.preventDefault(),P&&P.col===Q||H({col:Q}))},onDrop:$,onDragLeave:R=>{const E=R.relatedTarget;(!E||!(W.current&&W.current.contains(E)))&&H(null)},children:[t.columns.flatMap((R,E)=>{const z=[];return z.push(l.jsx("div",{className:`nc-col${V(E)?" drop-newcol":""}`,ref:D=>{U.current[E]=D},style:{flexGrow:R.width,flexBasis:0},onDragOver:D=>{If(D.dataTransfer)&&(D.preventDefault(),D.stopPropagation(),P&&P.col===E&&P.row===void 0||H({col:E}))},children:R.tiles.flatMap((D,q)=>{const ce=[],ge=ii(D),se=Yj(D.node,C),we=Wj({tileKey:ge,node:D.node,nodeGroups:C,sessionsAlive:s,localVerified:h,localIdentita:f?f.get(ge):null,lastVerifiedAt:D.node?(se==null?void 0:se.verifiedAt)??null:g,nowMs:O}),_e=D.unavailable!==!0&&(D.node?(se==null?void 0:se.status)==="up":we.owner==="ok"),fe=D.unavailable!==!0&&we.presenza!=="assente-verificata",ie=wx({session:D.session,node:D.node,ownerId:D.ownerId,cells:A,nodeGroups:C}),de=Zu({session:D.session,cell:ie,node:D.node,ownerId:D.ownerId,cells:A,nodeGroups:C}),me=typeof(ie==null?void 0:ie.panelUrl)=="string"?ie.panelUrl.trim():"",Ee=typeof(ie==null?void 0:ie.cell)=="string"?ie.cell:"";return ce.push(l.jsx("div",{className:`nc-tile-slot${I(E,q)}`,style:{flexGrow:D.height,flexBasis:0},onDragOver:Se=>{if(!If(Se.dataTransfer))return;Se.preventDefault(),Se.stopPropagation();const xe=Gj(Se.clientX,Se.clientY,Se.currentTarget.getBoundingClientRect());P&&P.col===E&&P.row===q&&P.quadrant===xe||H({col:E,row:q,quadrant:xe})},children:l.jsx(Vj,{session:D.session,node:D.node,ownerId:D.ownerId,cellName:de,token:n,readonly:i,focused:a===ge,onFocus:c,onClose:L,onOpenSingle:d,available:D.unavailable!==!0,stale:D.stale===!0,alive:_e,sessionAlive:fe,presence:we,fontSize:D.fontSize,onZoom:Se=>e(YM(t,E,q,Se)),decks:_,currentDeck:y,onSendToDeck:w,panelUrl:me,panelCellId:Ee,panelPort:Vl(D.node?D.node.split("/"):[],k,N)})},ge)),q<R.tiles.length-1&&ce.push(l.jsx("div",{className:"nc-divider-h",onPointerDown:Se=>M(Se,E,q)},`h${q}`)),ce})},`c${E}`)),E<Q-1&&z.push(l.jsx("div",{className:"nc-divider-v",onPointerDown:D=>j(D,E)},`v${E}`)),z}),T&&l.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),Q===0&&l.jsx("div",{className:"nc-grid-empty",children:p("grid-empty")})]})}const $s="local",zi=/^[a-f0-9]{16,64}$/,Sx=3,ma=new Map,Hr=new Map,wb=128;function Qj(t){const e=new Set;for(const n of Array.isArray(t)?t:[])!n||!zi.test(String(n.instanceId||""))||!Array.isArray(n.route)||(e.add(n.instanceId),Hr.set(n.instanceId,[...n.route]),ma.set(n.instanceId,0));for(const n of[...Hr.keys()]){if(e.has(n))continue;const i=(ma.get(n)||0)+1;ma.set(n,i),i>Sx+32&&(ma.delete(n),Hr.delete(n))}if(Hr.size>wb)for(const n of[...Hr.keys()].slice(0,Hr.size-wb))ma.delete(n),Hr.delete(n)}function No(t,e){return`${t&&zi.test(t)?t:$s}:${e}`}function oc(t){const e=String(t||""),n=e.indexOf(":");if(n<1)return null;const i=e.slice(0,n),s=e.slice(n+1);return i!==$s&&!zi.test(i)||!/^[a-z0-9-]{1,32}$/.test(s)?null:{ownerId:i===$s?null:i,name:s}}function Xl(t){return Array.isArray(t)&&t.length?t.join("/"):""}function vg(t){return{columns:ks(t).columns.map(e=>({width:e.width,tiles:e.tiles.map(n=>({...n}))}))}}function Jj(t){const e=new Map;for(const n of Array.isArray(t)?t:[])n&&zi.test(String(n.instanceId||""))&&Array.isArray(n.route)&&e.set(Xl(n.route),n.instanceId);return e}function Zj(t){const e=new Map;for(const n of Array.isArray(t)?t:[])n&&zi.test(String(n.instanceId||""))&&Array.isArray(n.route)&&e.set(n.instanceId,[...n.route]);return e}function xm(t,e,n=[]){const i=vg(t),s=Jj(n);for(const a of i.columns)for(const c of a.tiles)c.ownerId||(!c.node&&zi.test(String(e||""))?c.ownerId=e:c.node&&s.has(c.node)&&(c.ownerId=s.get(c.node)));return i}function kl(t,e){const n=oc(t);return!n||!n.ownerId||!e||n.ownerId!==e?t:No(null,n.name)}function Cm(t,e,n=[]){const i=vg(t),s=new Map,a=new Set;for(const c of n)c&&zi.test(String(c.instanceId||""))&&Array.isArray(c.route)&&(s.set(c.instanceId,[...c.route]),c.stale===!0&&a.add(c.instanceId));for(const c of i.columns)for(const d of c.tiles)if(d.ownerId)if(d.ownerId===e)delete d.node,delete d.unavailable,delete d.stale;else if(s.has(d.ownerId))d.node=Xl(s.get(d.ownerId)),delete d.unavailable,a.has(d.ownerId)?d.stale=!0:delete d.stale;else{const h=ma.get(d.ownerId),f=Hr.get(d.ownerId);f&&h!==void 0&&h<Sx?(d.node=Xl(f),delete d.unavailable,d.stale=!0):(d.unavailable=!0,delete d.stale)}return i}function Df(t,e,n=[]){const i=vg(t),s=Zj(n);for(const a of i.columns)for(const c of a.tiles)delete c.unavailable,delete c.stale,c.ownerId&&(c.ownerId===e?delete c.node:s.has(c.ownerId)&&(c.node=Xl(s.get(c.ownerId))));return i}function xx(t,e,n=[]){const i=pr(t);if(!i)return null;if(i.ownerId)return i;if(!i.node)return{...i,...zi.test(String(e||""))?{ownerId:e}:{}};const s=n.find(a=>Xl(a&&a.route)===i.node);return{...i,...s&&zi.test(String(s.instanceId||""))?{ownerId:s.instanceId}:{}}}const eT=/^[a-z0-9-]{1,32}$/,Xi="main",Cx="nc_decks",kx="nc_deck_order_v1",Ex=24;function bb(t){return typeof t!="string"?"":t.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function La(t){return typeof t=="string"&&eT.test(t)}function tT(t){const e=String(t||"").match(/^\/deck\/([^/]+)\/?$/);if(e){let n;try{n=decodeURIComponent(e[1])}catch{n=e[1]}return La(n)?n:Xi}return Xi}function nT(t){const e=String(t||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(e){let i,s;try{i=decodeURIComponent(e[1]),s=decodeURIComponent(e[2])}catch{return{id:No(null,Xi),ownerId:null,name:Xi}}if(zi.test(i)&&La(s))return{id:No(i,s),ownerId:i,name:s}}const n=tT(t);return{id:No(null,n),ownerId:null,name:n}}function Bf(t,e){const n=typeof t=="object"&&t?{ownerId:t.ownerId||null,name:t.name}:oc(t)||{ownerId:null,name:t},i=La(n.name)?n.name:Xi,s=n.ownerId?`/deck/${encodeURIComponent(n.ownerId)}/${encodeURIComponent(i)}`:i===Xi?"/":`/deck/${encodeURIComponent(i)}`;return e?`${s}#token=${encodeURIComponent(e)}`:s}function Nx(t){return t===Xi?"nc_grid_v1":`nc_grid_v1__${t}`}function Lx(t){const e=[Xi];if(Array.isArray(t)){for(const n of t)if(La(n)&&n!==Xi&&!e.includes(n)&&e.push(n),e.length>=Ex)break}return e}function Pa(){return typeof localStorage<"u"?localStorage:null}function iT(){const t=Pa();if(!t)return[Xi];try{return Lx(JSON.parse(t.getItem(Cx)||"null"))}catch{return[Xi]}}function sT(t){const e=Pa();if(e)try{e.setItem(Cx,JSON.stringify(Lx(t)))}catch{}}function ac(t){return t==="local"||zi.test(String(t||""))}function wd(t,e){const n=oc(t);return!!n&&(n.ownerId||"local")===e}function Us(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[n,i]of Object.entries(t).slice(0,64)){if(!ac(n)||!Array.isArray(i))continue;const s=[...new Set(i.filter(a=>typeof a=="string"&&a.length<=100&&wd(a,n)))].slice(0,Ex);s.length&&(e[n]=s)}return e}function wu(t=Pa()){if(!t)return{};try{return Us(JSON.parse(t.getItem(kx)||"null"))}catch{return{}}}function Of(t,e=Pa()){const n=Us(t);if(e)try{e.setItem(kx,JSON.stringify(n))}catch{}return n}function bd(t,e){return Array.isArray(t==null?void 0:t[e])?t[e]:[]}function rT(t,e,n,i,s=[]){if(!ac(e)||n===i)return Us(t);const a=[...new Set(s.filter(_=>wd(_,e)))];if(!a.includes(n)||!a.includes(i))return Us(t);const c=bd(t,e).filter(_=>a.includes(_)),d=[...c,...a.filter(_=>!c.includes(_))],h=d.indexOf(n),f=d.indexOf(i);d.splice(h,1);const g=d.indexOf(i);return d.splice(h<f?g+1:g,0,n),Us({...t,[e]:d})}function oT(t,e,n,i){if(!ac(e)||!wd(i,e))return Us(t);const s=bd(t,e);return s.includes(n)?Us({...t,[e]:s.map(a=>a===n?i:a)}):Us(t)}function aT(t,e,n){return ac(e)?Us({...t,[e]:bd(t,e).filter(i=>i!==n)}):Us(t)}function Sb(t,e={}){const n=new Map;for(const s of Array.isArray(t)?t:[]){const a=s!=null&&s.local?"local":String((s==null?void 0:s.ownerId)||"");!ac(a)||!wd(s==null?void 0:s.id,a)||(n.has(a)||n.set(a,[]),n.get(a).push(s))}const i=[];for(const[,s]of n){const a=s[0].local?"local":s[0].ownerId,c=bd(e,a),d=new Map(c.map((h,f)=>[h,f]));s.sort((h,f)=>{const g=d.has(h.id)?d.get(h.id):Number.MAX_SAFE_INTEGER,_=d.has(f.id)?d.get(f.id):Number.MAX_SAFE_INTEGER;return g-_}),i.push(...s)}return i}function km(t){const e=Pa();if(!e)return null;try{return JSON.parse(e.getItem(Nx(t))||"null")}catch{return null}}function lT(t,e){const n=Pa();if(n)try{n.setItem(Nx(t),JSON.stringify(e))}catch{}}const _g="nc_deckbar_collapsed_v1",Rx=64;function yg(t){return t===$s||zi.test(String(t||""))}function wg(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};let n=0;for(const[i,s]of Object.entries(t)){if(n>=Rx)break;if(yg(i)){if(s===!0)e[i]=!0;else if(s===!1)e[i]=!1;else continue;n+=1}}return e}function Ax(t,e){return yg(e)&&Object.prototype.hasOwnProperty.call(t||{},e)?t[e]===!0:!0}function cT(t,e){const n=wg(t);return yg(e)&&(!Object.prototype.hasOwnProperty.call(n,e)&&Object.keys(n).length>=Rx&&delete n[Object.keys(n)[0]],n[e]=!Ax(n,e)),n}function Mx(){return typeof localStorage<"u"?localStorage:null}function xb(t=Mx()){if(!t)return{};try{return wg(JSON.parse(t.getItem(_g)||"null"))}catch{return{}}}function uT(t,e=Mx()){const n=wg(t);if(e)try{e.setItem(_g,JSON.stringify(n))}catch{}return n}function dT(){const[t,e]=b.useState(xb);b.useEffect(()=>{const s=a=>{(a.key===_g||a.key===null)&&e(xb())};return window.addEventListener("storage",s),()=>window.removeEventListener("storage",s)},[]);const n=b.useCallback(s=>Ax(t,s),[t]),i=b.useCallback(s=>{e(a=>uT(cT(a,s)))},[]);return{collapsed:t,isCollapsed:n,toggle:i}}const bg="nc_deck_presence_v1",Cb=3e4,hT=18e4,jx=1e4,Tx=32,fT=/^[A-Za-z0-9_-]{1,64}$/,pT=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),kb="working",mT="on",gT="neutral",vT="warn";function Sg(t){return typeof t=="string"&&fT.test(t)&&!pT.has(t)}function Px(t){return typeof t=="string"&&oc(t)!==null}function xg(t){return typeof t=="number"&&Number.isFinite(t)&&t>=0}function Ra(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};let n=0;for(const[i,s]of Object.entries(t)){if(n>=Tx)break;Sg(i)&&(!s||typeof s!="object"||Px(s.deckId)&&xg(s.ts)&&(e[i]={deckId:s.deckId,ts:s.ts,focus:s.focus===!0,visible:s.visible===!0},n+=1))}return e}function Ix(t,e){const n=Ra(t);if(!xg(e))return n;const i={};for(const[s,a]of Object.entries(n)){const c=a.visible?Cb:hT,d=e-c;a.ts>=d&&a.ts<=e+Cb&&(i[s]=a)}return i}function Eb(t,e,n,i){if(!Sg(e)||!xg(i))return Ra(t);const s=Ix(t,i);if(!Px(n==null?void 0:n.deckId))return s;if(!Object.prototype.hasOwnProperty.call(s,e)&&Object.keys(s).length>=Tx){let a="",c=1/0;for(const[d,h]of Object.entries(s))h.ts<c&&(a=d,c=h.ts);a&&delete s[a]}return s[e]={deckId:n.deckId,ts:i,focus:(n==null?void 0:n.focus)===!0,visible:(n==null?void 0:n.visible)===!0},Ra(s)}function _T(t,e){const n=Ra(t);if(!Sg(e))return n;const i={...n};return delete i[e],i}function yT(t,e){const n=Ix(t,e),i={};for(const s of Object.values(n)){const a=s.focus&&s.visible?kb:mT;i[s.deckId]!==kb&&(i[s.deckId]=a)}return i}function Dx(){return typeof localStorage<"u"?localStorage:null}function bu(t=Dx()){if(!t)return{};try{return Ra(JSON.parse(t.getItem(bg)||"null"))}catch{return{}}}function $f(t,e=Dx()){const n=Ra(t);if(e)try{e.setItem(bg,JSON.stringify(n))}catch{}return n}const wT=Math.min(jx,5e3);function bT(){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 ST=bT();function Nb(){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 xT(t,e=!0){const i=b.useRef(ST).current,s=b.useRef(t);s.current=t;const[a,c]=b.useState(()=>({map:{},now:Date.now()})),d=b.useCallback(()=>{c({map:bu(),now:Date.now()})},[]);b.useEffect(()=>{if(!e)return;const g=()=>{const C=Date.now(),N=Eb(bu(),i,{deckId:s.current,...Nb()},C);return $f(N),{map:N,now:C}},_=()=>c(g());_();const y=setInterval(g,jx),w=setInterval(d,wT),S=_,A=C=>{(C.key===bg||C.key===null)&&d()};return window.addEventListener("focus",S),window.addEventListener("blur",S),typeof document<"u"&&document.addEventListener("visibilitychange",S),window.addEventListener("storage",A),()=>{clearInterval(y),clearInterval(w),window.removeEventListener("focus",S),window.removeEventListener("blur",S),typeof document<"u"&&document.removeEventListener("visibilitychange",S),window.removeEventListener("storage",A);try{$f(_T(bu(),i))}catch{}}},[e,i,d]),b.useEffect(()=>{if(!e)return;const g=Date.now(),_=Eb(bu(),i,{deckId:t,...Nb()},g);$f(_),c({map:_,now:g})},[t,e,i]);const h=b.useMemo(()=>e?yT(a.map,a.now):{},[e,a]);return{dotFor:b.useCallback((g,_=!1)=>e?_?vT:h[g]||gT:null,[h,e]),windowId:i}}const Lb=52,Rb=18;function CT({ownerKey:t,deckId:e,label:n,onMove:i,onStep:s}){const a=b.useRef(null),c=b.useRef(0),[d,h]=b.useState(!1),f=()=>{var A,C,N,k;const S=a.current;(C=(A=S==null?void 0:S.over)==null?void 0:A.classList)==null||C.remove("nc-deck-over"),(k=(N=S==null?void 0:S.source)==null?void 0:N.classList)==null||k.remove("nc-deck-dragging"),c.current&&cancelAnimationFrame(c.current),c.current=0},g=(S=!1)=>{const A=a.current;if(!A)return;const C=A.target;f(),a.current=null,h(!1);try{A.handle.releasePointerCapture(A.pointerId)}catch{}S&&C&&C!==e&&i(e,C)},_=(S,A)=>{var P,H,W,U,G,X,Q,V;const C=a.current;if(!C)return;C.x=S,C.y=A;const N=(H=(P=document.elementFromPoint(S,A))==null?void 0:P.closest)==null?void 0:H.call(P,"[data-deck-id][data-owner-key]"),k=(W=N==null?void 0:N.dataset)==null?void 0:W.deckId,O=((U=N==null?void 0:N.dataset)==null?void 0:U.ownerKey)===t&&k&&k!==e;C.over!==(O?N:null)&&((X=(G=C.over)==null?void 0:G.classList)==null||X.remove("nc-deck-over"),C.over=O?N:null,(V=(Q=C.over)==null?void 0:Q.classList)==null||V.add("nc-deck-over")),C.target=O?k:null},y=()=>{var C,N;const S=a.current;if(!S){c.current=0;return}const A=(N=(C=S.container)==null?void 0:C.getBoundingClientRect)==null?void 0:N.call(C);if(A){const k=S.x<A.left+Lb?-Rb:S.x>A.right-Lb?Rb:0;k&&(S.container.scrollLeft+=k,_(S.x,S.y))}c.current=requestAnimationFrame(y)};b.useEffect(()=>{const S=C=>{C.key==="Escape"&&a.current&&(C.preventDefault(),g(!1))},A=()=>g(!1);return window.addEventListener("keydown",S),window.addEventListener("blur",A),()=>{window.removeEventListener("keydown",S),window.removeEventListener("blur",A),f(),a.current=null}},[e,t]);const w=S=>{var N;if(S.pointerType==="mouse"&&S.button!==0)return;S.preventDefault(),S.stopPropagation(),S.currentTarget.focus({preventScroll:!0});const A=S.currentTarget.closest("[data-deck-id][data-owner-key]"),C=S.currentTarget.closest(".nc-deckbar");a.current={pointerId:S.pointerId,handle:S.currentTarget,source:A,container:C,target:null,over:null,x:S.clientX,y:S.clientY},(N=A==null?void 0:A.classList)==null||N.add("nc-deck-dragging");try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}h(!0),c.current=requestAnimationFrame(y)};return l.jsx("button",{type:"button",className:`nc-deck-handle${d?" active":""}`,"aria-label":`${p("reorder")} ${n}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:p("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(),s(S.key==="ArrowLeft"?-1:1))},onPointerDown:w,onPointerMove:S=>{!a.current||S.pointerId!==a.current.pointerId||(S.preventDefault(),S.stopPropagation(),_(S.clientX,S.clientY))},onPointerUp:S=>{!a.current||S.pointerId!==a.current.pointerId||(S.preventDefault(),S.stopPropagation(),g(!0))},onPointerCancel:()=>g(!1),onLostPointerCapture:()=>{a.current&&g(!1)},children:"↔"})}function kT({decks:t=[],currentDeck:e="local:main",onCreate:n,onRename:i,onDelete:s,onReorder:a,onOpenWindow:c,onNavigate:d,saveState:h="idle",error:f="",sidebarVisible:g,onToggleSidebar:_,conflict:y=!1,onReloadDeck:w=null}){Li();const{isCollapsed:S,toggle:A}=dT(),{dotFor:C}=xT(e),[N,k]=b.useState(null),[O,P]=b.useState(""),[H,W]=b.useState(!1),[U,G]=b.useState(""),[X,Q]=b.useState(""),V=bb(O),T=La(V),I=[];for(const R of t){const E=R.local?"local":R.ownerId;let z=I.find(D=>D.key===E);z||(z={key:E,label:R.ownerLabel||(R.local?"Local":E),local:!!R.local,decks:[]},I.push(z)),z.decks.push(R)}const $=async()=>{if(T){W(!0),G("");try{n&&await n(V,N),P(""),k(null)}catch(R){G(String(R.message||R))}W(!1)}},j=R=>{Q(""),c&&c(R.id)||Q(R.id)},M=async R=>{if(!(R.id===e||!d||H||R.available===!1)){W(!0),G("");try{await d(R.id)}catch(E){G(String((E==null?void 0:E.message)||E))}W(!1)}},L=(R,E,z)=>{const D=R.decks.findIndex(ce=>ce.id===E.id),q=R.decks[D+z];D>=0&&q&&a&&!H&&a(E.id,q.id)};return l.jsxs("div",{className:"nc-deckbar",children:[_&&l.jsx("button",{className:"nc-deck-sidebar-toggle",title:p("toggle-sidebar"),onClick:_,children:g?"◀":"☰"}),l.jsx("span",{className:"nc-deckbar-label",children:p("decks")}),l.jsx("div",{className:"nc-deck-chips",children:I.map(R=>{const E=S(R.key),z=`nc-deck-content-${R.key}`,D=R.local?"Local":R.label,q=R.decks.some(se=>se.id===e),ce=(R.decks.find(se=>se.id===e)||{}).name,ge=p(R.decks.length===1?"owner-deck-count-one":"owner-deck-count-many").replace("{count}",R.decks.length);return l.jsxs("span",{className:`nc-deck-owner-group${E?" collapsed":""}`,"data-owner-key":R.key,"data-collapsed":E?"1":"0",children:[l.jsxs("button",{type:"button",className:"nc-deck-owner-toggle","aria-expanded":!E,"aria-controls":z,title:p(E?"expand-owner":"collapse-owner").replace("{owner}",D),onClick:()=>{!E&&N===R.key&&(P(""),k(null)),A(R.key)},children:[l.jsx("span",{className:"nc-deck-owner-caret","aria-hidden":"true",children:E?"▸":"▾"}),l.jsx("span",{className:"nc-deck-owner",children:D})]}),E&&l.jsxs("span",{className:"nc-deck-summary",title:ge,children:[l.jsx("span",{className:"nc-deck-summary-count",children:R.decks.length}),q&&l.jsxs("span",{className:"nc-deck-summary-current",children:["• ",ce]})]}),l.jsxs("span",{id:z,className:"nc-deck-owner-content",hidden:E,children:[R.decks.map(se=>{const we=C(se.id,se.available===!1);return l.jsxs("span",{"data-deck-id":se.id,"data-owner-key":R.key,className:`nc-deck-chip${se.id===e?" current":""}${se.available===!1?" offline":""}`,children:[we&&l.jsx(ET,{state:we}),l.jsx(CT,{ownerKey:R.key,deckId:se.id,label:`${R.label} · ${se.name}`,onMove:(_e,fe)=>{a&&!H&&a(_e,fe)},onStep:_e=>L(R,se,_e)}),l.jsxs("button",{className:"nc-deck-open",title:se.available===!1?`${se.ownerLabel} offline${se.refreshFailedAt?" · aggiornamento in ritardo":""}`:se.id===e?p("deck-current"):`${se.ownerLabel} · ${se.name}`,disabled:H||se.available===!1,onClick:()=>M(se),children:[se.name,se.id===e?" •":""]}),l.jsx("button",{className:"nc-deck-mini",disabled:se.available===!1,title:p("detach-deck"),onClick:()=>j(se),children:"↗"}),se.name!==Xi&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"nc-deck-mini",disabled:se.available===!1,title:p("rename-deck"),onClick:()=>{const _e=(typeof window<"u"?window.prompt(p("rename-deck"),se.name):"")||"",fe=bb(_e);La(fe)&&fe!==se.name&&i&&i(se.id,fe).catch(ie=>G(String(ie.message||ie)))},children:"✎"}),l.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:se.available===!1,title:p("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(p("delete-deck-confirm").replace("{name}",`${se.ownerLabel} · ${se.name}`)))&&s&&s(se.id).catch(_e=>G(String(_e.message||_e)))},children:"✕"})]})]},se.id)}),N===R.key?l.jsxs("span",{className:"nc-deck-add",children:[l.jsx("input",{autoFocus:!0,className:T||!O?"":"invalid",placeholder:p("deck-name"),value:O,onChange:se=>P(se.target.value),onKeyDown:se=>{se.key==="Enter"&&$(),se.key==="Escape"&&(P(""),k(null))}}),O&&T&&V!==O&&l.jsxs("span",{className:"nc-deck-slug",children:["→ ",V]}),l.jsx("button",{className:"nc-deck-ok",disabled:!T||H,onClick:$,children:p("create")}),l.jsx("button",{className:"nc-deck-cancel",onClick:()=>{P(""),k(null)},children:p("cancel")})]}):l.jsxs("button",{className:"nc-deck-newbtn",disabled:H||R.decks.every(se=>se.available===!1),title:`${p("new-deck")} · ${R.label}`,onClick:()=>{P(""),k(R.key)},children:["+ ",p("new")]})]})]},R.key)})}),l.jsx("span",{className:`nc-deck-state ${h}`,title:p("deck-autosave"),children:p(h==="saving"?"saving":h==="saved"?"saved":"deck-autosave")}),(U||f)&&l.jsx("span",{className:"nc-deck-error",children:U||f}),y&&w&&l.jsx("button",{className:"nc-deck-reload",onClick:w,children:p("reload")}),X&&l.jsx("button",{className:"nc-deck-fallback",onClick:()=>c&&c(X),children:p("popup-blocked")})]})}function ET({state:t}){if(!t)return null;const e=p(`dot-${t}`);return l.jsx("span",{className:`nc-deck-dot ${t}`,role:"img","aria-label":e,title:e})}var fa={},zf,Ab;function NT(){return Ab||(Ab=1,zf=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),zf}var Ff={},Or={},Mb;function jo(){if(Mb)return Or;Mb=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 Or.getSymbolSize=function(i){if(!i)throw new Error('"version" cannot be null or undefined');if(i<1||i>40)throw new Error('"version" should be in range from 1 to 40');return i*4+17},Or.getSymbolTotalCodewords=function(i){return e[i]},Or.getBCHDigit=function(n){let i=0;for(;n!==0;)i++,n>>>=1;return i},Or.setToSJISFunction=function(i){if(typeof i!="function")throw new Error('"toSJISFunc" is not a valid function.');t=i},Or.isKanjiModeEnabled=function(){return typeof t<"u"},Or.toSJIS=function(i){return t(i)},Or}var Hf={},jb;function Cg(){return jb||(jb=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(i){return i&&typeof i.bit<"u"&&i.bit>=0&&i.bit<4},t.from=function(i,s){if(t.isValid(i))return i;try{return e(i)}catch{return s}}})(Hf)),Hf}var Uf,Tb;function LT(){if(Tb)return Uf;Tb=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 i=0;i<n;i++)this.putBit((e>>>n-i-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++}},Uf=t,Uf}var Wf,Pb;function RT(){if(Pb)return Wf;Pb=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,i,s){const a=e*this.size+n;this.data[a]=i,s&&(this.reservedBit[a]=!0)},t.prototype.get=function(e,n){return this.data[e*this.size+n]},t.prototype.xor=function(e,n,i){this.data[e*this.size+n]^=i},t.prototype.isReserved=function(e,n){return this.reservedBit[e*this.size+n]},Wf=t,Wf}var qf={},Ib;function AT(){return Ib||(Ib=1,(function(t){const e=jo().getSymbolSize;t.getRowColCoords=function(i){if(i===1)return[];const s=Math.floor(i/7)+2,a=e(i),c=a===145?26:Math.ceil((a-13)/(2*s-2))*2,d=[a-7];for(let h=1;h<s-1;h++)d[h]=d[h-1]-c;return d.push(6),d.reverse()},t.getPositions=function(i){const s=[],a=t.getRowColCoords(i),c=a.length;for(let d=0;d<c;d++)for(let h=0;h<c;h++)d===0&&h===0||d===0&&h===c-1||d===c-1&&h===0||s.push([a[d],a[h]]);return s}})(qf)),qf}var Kf={},Db;function MT(){if(Db)return Kf;Db=1;const t=jo().getSymbolSize,e=7;return Kf.getPositions=function(i){const s=t(i);return[[0,0],[s-e,0],[0,s-e]]},Kf}var Vf={},Bb;function jT(){return Bb||(Bb=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(s){return s!=null&&s!==""&&!isNaN(s)&&s>=0&&s<=7},t.from=function(s){return t.isValid(s)?parseInt(s,10):void 0},t.getPenaltyN1=function(s){const a=s.size;let c=0,d=0,h=0,f=null,g=null;for(let _=0;_<a;_++){d=h=0,f=g=null;for(let y=0;y<a;y++){let w=s.get(_,y);w===f?d++:(d>=5&&(c+=e.N1+(d-5)),f=w,d=1),w=s.get(y,_),w===g?h++:(h>=5&&(c+=e.N1+(h-5)),g=w,h=1)}d>=5&&(c+=e.N1+(d-5)),h>=5&&(c+=e.N1+(h-5))}return c},t.getPenaltyN2=function(s){const a=s.size;let c=0;for(let d=0;d<a-1;d++)for(let h=0;h<a-1;h++){const f=s.get(d,h)+s.get(d,h+1)+s.get(d+1,h)+s.get(d+1,h+1);(f===4||f===0)&&c++}return c*e.N2},t.getPenaltyN3=function(s){const a=s.size;let c=0,d=0,h=0;for(let f=0;f<a;f++){d=h=0;for(let g=0;g<a;g++)d=d<<1&2047|s.get(f,g),g>=10&&(d===1488||d===93)&&c++,h=h<<1&2047|s.get(g,f),g>=10&&(h===1488||h===93)&&c++}return c*e.N3},t.getPenaltyN4=function(s){let a=0;const c=s.data.length;for(let h=0;h<c;h++)a+=s.data[h];return Math.abs(Math.ceil(a*100/c/5)-10)*e.N4};function n(i,s,a){switch(i){case t.Patterns.PATTERN000:return(s+a)%2===0;case t.Patterns.PATTERN001:return s%2===0;case t.Patterns.PATTERN010:return a%3===0;case t.Patterns.PATTERN011:return(s+a)%3===0;case t.Patterns.PATTERN100:return(Math.floor(s/2)+Math.floor(a/3))%2===0;case t.Patterns.PATTERN101:return s*a%2+s*a%3===0;case t.Patterns.PATTERN110:return(s*a%2+s*a%3)%2===0;case t.Patterns.PATTERN111:return(s*a%3+(s+a)%2)%2===0;default:throw new Error("bad maskPattern:"+i)}}t.applyMask=function(s,a){const c=a.size;for(let d=0;d<c;d++)for(let h=0;h<c;h++)a.isReserved(h,d)||a.xor(h,d,n(s,h,d))},t.getBestMask=function(s,a){const c=Object.keys(t.Patterns).length;let d=0,h=1/0;for(let f=0;f<c;f++){a(f),t.applyMask(f,s);const g=t.getPenaltyN1(s)+t.getPenaltyN2(s)+t.getPenaltyN3(s)+t.getPenaltyN4(s);t.applyMask(f,s),g<h&&(h=g,d=f)}return d}})(Vf)),Vf}var Su={},Ob;function Bx(){if(Ob)return Su;Ob=1;const t=Cg(),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 Su.getBlocksCount=function(s,a){switch(a){case t.L:return e[(s-1)*4+0];case t.M:return e[(s-1)*4+1];case t.Q:return e[(s-1)*4+2];case t.H:return e[(s-1)*4+3];default:return}},Su.getTotalCodewordsCount=function(s,a){switch(a){case t.L:return n[(s-1)*4+0];case t.M:return n[(s-1)*4+1];case t.Q:return n[(s-1)*4+2];case t.H:return n[(s-1)*4+3];default:return}},Su}var Yf={},El={},$b;function TT(){if($b)return El;$b=1;const t=new Uint8Array(512),e=new Uint8Array(256);return(function(){let i=1;for(let s=0;s<255;s++)t[s]=i,e[i]=s,i<<=1,i&256&&(i^=285);for(let s=255;s<512;s++)t[s]=t[s-255]})(),El.log=function(i){if(i<1)throw new Error("log("+i+")");return e[i]},El.exp=function(i){return t[i]},El.mul=function(i,s){return i===0||s===0?0:t[e[i]+e[s]]},El}var zb;function PT(){return zb||(zb=1,(function(t){const e=TT();t.mul=function(i,s){const a=new Uint8Array(i.length+s.length-1);for(let c=0;c<i.length;c++)for(let d=0;d<s.length;d++)a[c+d]^=e.mul(i[c],s[d]);return a},t.mod=function(i,s){let a=new Uint8Array(i);for(;a.length-s.length>=0;){const c=a[0];for(let h=0;h<s.length;h++)a[h]^=e.mul(s[h],c);let d=0;for(;d<a.length&&a[d]===0;)d++;a=a.slice(d)}return a},t.generateECPolynomial=function(i){let s=new Uint8Array([1]);for(let a=0;a<i;a++)s=t.mul(s,new Uint8Array([1,e.exp(a)]));return s}})(Yf)),Yf}var Gf,Fb;function IT(){if(Fb)return Gf;Fb=1;const t=PT();function e(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return e.prototype.initialize=function(i){this.degree=i,this.genPoly=t.generateECPolynomial(this.degree)},e.prototype.encode=function(i){if(!this.genPoly)throw new Error("Encoder not initialized");const s=new Uint8Array(i.length+this.degree);s.set(i);const a=t.mod(s,this.genPoly),c=this.degree-a.length;if(c>0){const d=new Uint8Array(this.degree);return d.set(a,c),d}return a},Gf=e,Gf}var Xf={},Qf={},Jf={},Hb;function Ox(){return Hb||(Hb=1,Jf.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),Jf}var Is={},Ub;function $x(){if(Ub)return Is;Ub=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 i="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
|
|
158
|
-
]))+`;Is.KANJI=new RegExp(n,"g"),Is.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Is.BYTE=new RegExp(i,"g"),Is.NUMERIC=new RegExp(t,"g"),Is.ALPHANUMERIC=new RegExp(e,"g");const s=new RegExp("^"+n+"$"),a=new RegExp("^"+t+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Is.testKanji=function(h){return s.test(h)},Is.testNumeric=function(h){return a.test(h)},Is.testAlphanumeric=function(h){return c.test(h)},Is}var Wb;function To(){return Wb||(Wb=1,(function(t){const e=Ox(),n=$x();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(a,c){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!e.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?a.ccBits[0]:c<27?a.ccBits[1]:a.ccBits[2]},t.getBestModeForData=function(a){return n.testNumeric(a)?t.NUMERIC:n.testAlphanumeric(a)?t.ALPHANUMERIC:n.testKanji(a)?t.KANJI:t.BYTE},t.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},t.isValid=function(a){return a&&a.bit&&a.ccBits};function i(s){if(typeof s!="string")throw new Error("Param is not a string");switch(s.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: "+s)}}t.from=function(a,c){if(t.isValid(a))return a;try{return i(a)}catch{return c}}})(Qf)),Qf}var qb;function DT(){return qb||(qb=1,(function(t){const e=jo(),n=Bx(),i=Cg(),s=To(),a=Ox(),c=7973,d=e.getBCHDigit(c);function h(y,w,S){for(let A=1;A<=40;A++)if(w<=t.getCapacity(A,S,y))return A}function f(y,w){return s.getCharCountIndicator(y,w)+4}function g(y,w){let S=0;return y.forEach(function(A){const C=f(A.mode,w);S+=C+A.getBitsLength()}),S}function _(y,w){for(let S=1;S<=40;S++)if(g(y,S)<=t.getCapacity(S,w,s.MIXED))return S}t.from=function(w,S){return a.isValid(w)?parseInt(w,10):S},t.getCapacity=function(w,S,A){if(!a.isValid(w))throw new Error("Invalid QR Code version");typeof A>"u"&&(A=s.BYTE);const C=e.getSymbolTotalCodewords(w),N=n.getTotalCodewordsCount(w,S),k=(C-N)*8;if(A===s.MIXED)return k;const O=k-f(A,w);switch(A){case s.NUMERIC:return Math.floor(O/10*3);case s.ALPHANUMERIC:return Math.floor(O/11*2);case s.KANJI:return Math.floor(O/13);case s.BYTE:default:return Math.floor(O/8)}},t.getBestVersionForData=function(w,S){let A;const C=i.from(S,i.M);if(Array.isArray(w)){if(w.length>1)return _(w,C);if(w.length===0)return 1;A=w[0]}else A=w;return h(A.mode,A.getLength(),C)},t.getEncodedBits=function(w){if(!a.isValid(w)||w<7)throw new Error("Invalid QR Code version");let S=w<<12;for(;e.getBCHDigit(S)-d>=0;)S^=c<<e.getBCHDigit(S)-d;return w<<12|S}})(Xf)),Xf}var Zf={},Kb;function BT(){if(Kb)return Zf;Kb=1;const t=jo(),e=1335,n=21522,i=t.getBCHDigit(e);return Zf.getEncodedBits=function(a,c){const d=a.bit<<3|c;let h=d<<10;for(;t.getBCHDigit(h)-i>=0;)h^=e<<t.getBCHDigit(h)-i;return(d<<10|h)^n},Zf}var ep={},tp,Vb;function OT(){if(Vb)return tp;Vb=1;const t=To();function e(n){this.mode=t.NUMERIC,this.data=n.toString()}return e.getBitsLength=function(i){return 10*Math.floor(i/3)+(i%3?i%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(i){let s,a,c;for(s=0;s+3<=this.data.length;s+=3)a=this.data.substr(s,3),c=parseInt(a,10),i.put(c,10);const d=this.data.length-s;d>0&&(a=this.data.substr(s),c=parseInt(a,10),i.put(c,d*3+1))},tp=e,tp}var np,Yb;function $T(){if(Yb)return np;Yb=1;const t=To(),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(i){this.mode=t.ALPHANUMERIC,this.data=i}return n.getBitsLength=function(s){return 11*Math.floor(s/2)+6*(s%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(s){let a;for(a=0;a+2<=this.data.length;a+=2){let c=e.indexOf(this.data[a])*45;c+=e.indexOf(this.data[a+1]),s.put(c,11)}this.data.length%2&&s.put(e.indexOf(this.data[a]),6)},np=n,np}var ip,Gb;function zT(){if(Gb)return ip;Gb=1;const t=To();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(i){return i*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 i=0,s=this.data.length;i<s;i++)n.put(this.data[i],8)},ip=e,ip}var sp,Xb;function FT(){if(Xb)return sp;Xb=1;const t=To(),e=jo();function n(i){this.mode=t.KANJI,this.data=i}return n.getBitsLength=function(s){return s*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(i){let s;for(s=0;s<this.data.length;s++){let a=e.toSJIS(this.data[s]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[s]+`
|
|
159
|
-
Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),i.put(a,13)}},sp=n,sp}var rp={exports:{}},Qb;function HT(){return Qb||(Qb=1,(function(t){var e={single_source_shortest_paths:function(n,i,s){var a={},c={};c[i]=0;var d=e.PriorityQueue.make();d.push(i,0);for(var h,f,g,_,y,w,S,A,C;!d.empty();){h=d.pop(),f=h.value,_=h.cost,y=n[f]||{};for(g in y)y.hasOwnProperty(g)&&(w=y[g],S=_+w,A=c[g],C=typeof c[g]>"u",(C||A>S)&&(c[g]=S,d.push(g,S),a[g]=f))}if(typeof s<"u"&&typeof c[s]>"u"){var N=["Could not find a path from ",i," to ",s,"."].join("");throw new Error(N)}return a},extract_shortest_path_from_predecessor_list:function(n,i){for(var s=[],a=i;a;)s.push(a),n[a],a=n[a];return s.reverse(),s},find_path:function(n,i,s){var a=e.single_source_shortest_paths(n,i,s);return e.extract_shortest_path_from_predecessor_list(a,s)},PriorityQueue:{make:function(n){var i=e.PriorityQueue,s={},a;n=n||{};for(a in i)i.hasOwnProperty(a)&&(s[a]=i[a]);return s.queue=[],s.sorter=n.sorter||i.default_sorter,s},default_sorter:function(n,i){return n.cost-i.cost},push:function(n,i){var s={value:n,cost:i};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=e})(rp)),rp.exports}var Jb;function UT(){return Jb||(Jb=1,(function(t){const e=To(),n=OT(),i=$T(),s=zT(),a=FT(),c=$x(),d=jo(),h=HT();function f(N){return unescape(encodeURIComponent(N)).length}function g(N,k,O){const P=[];let H;for(;(H=N.exec(O))!==null;)P.push({data:H[0],index:H.index,mode:k,length:H[0].length});return P}function _(N){const k=g(c.NUMERIC,e.NUMERIC,N),O=g(c.ALPHANUMERIC,e.ALPHANUMERIC,N);let P,H;return d.isKanjiModeEnabled()?(P=g(c.BYTE,e.BYTE,N),H=g(c.KANJI,e.KANJI,N)):(P=g(c.BYTE_KANJI,e.BYTE,N),H=[]),k.concat(O,P,H).sort(function(U,G){return U.index-G.index}).map(function(U){return{data:U.data,mode:U.mode,length:U.length}})}function y(N,k){switch(k){case e.NUMERIC:return n.getBitsLength(N);case e.ALPHANUMERIC:return i.getBitsLength(N);case e.KANJI:return a.getBitsLength(N);case e.BYTE:return s.getBitsLength(N)}}function w(N){return N.reduce(function(k,O){const P=k.length-1>=0?k[k.length-1]:null;return P&&P.mode===O.mode?(k[k.length-1].data+=O.data,k):(k.push(O),k)},[])}function S(N){const k=[];for(let O=0;O<N.length;O++){const P=N[O];switch(P.mode){case e.NUMERIC:k.push([P,{data:P.data,mode:e.ALPHANUMERIC,length:P.length},{data:P.data,mode:e.BYTE,length:P.length}]);break;case e.ALPHANUMERIC:k.push([P,{data:P.data,mode:e.BYTE,length:P.length}]);break;case e.KANJI:k.push([P,{data:P.data,mode:e.BYTE,length:f(P.data)}]);break;case e.BYTE:k.push([{data:P.data,mode:e.BYTE,length:f(P.data)}])}}return k}function A(N,k){const O={},P={start:{}};let H=["start"];for(let W=0;W<N.length;W++){const U=N[W],G=[];for(let X=0;X<U.length;X++){const Q=U[X],V=""+W+X;G.push(V),O[V]={node:Q,lastCount:0},P[V]={};for(let T=0;T<H.length;T++){const I=H[T];O[I]&&O[I].node.mode===Q.mode?(P[I][V]=y(O[I].lastCount+Q.length,Q.mode)-y(O[I].lastCount,Q.mode),O[I].lastCount+=Q.length):(O[I]&&(O[I].lastCount=Q.length),P[I][V]=y(Q.length,Q.mode)+4+e.getCharCountIndicator(Q.mode,k))}}H=G}for(let W=0;W<H.length;W++)P[H[W]].end=0;return{map:P,table:O}}function C(N,k){let O;const P=e.getBestModeForData(N);if(O=e.from(k,P),O!==e.BYTE&&O.bit<P.bit)throw new Error('"'+N+'" cannot be encoded with mode '+e.toString(O)+`.
|
|
160
|
-
Suggested mode is: `+e.toString(P));switch(O===e.KANJI&&!d.isKanjiModeEnabled()&&(O=e.BYTE),O){case e.NUMERIC:return new n(N);case e.ALPHANUMERIC:return new i(N);case e.KANJI:return new a(N);case e.BYTE:return new s(N)}}t.fromArray=function(k){return k.reduce(function(O,P){return typeof P=="string"?O.push(C(P,null)):P.data&&O.push(C(P.data,P.mode)),O},[])},t.fromString=function(k,O){const P=_(k,d.isKanjiModeEnabled()),H=S(P),W=A(H,O),U=h.find_path(W.map,"start","end"),G=[];for(let X=1;X<U.length-1;X++)G.push(W.table[U[X]].node);return t.fromArray(w(G))},t.rawSplit=function(k){return t.fromArray(_(k,d.isKanjiModeEnabled()))}})(ep)),ep}var Zb;function WT(){if(Zb)return Ff;Zb=1;const t=jo(),e=Cg(),n=LT(),i=RT(),s=AT(),a=MT(),c=jT(),d=Bx(),h=IT(),f=DT(),g=BT(),_=To(),y=UT();function w(W,U){const G=W.size,X=a.getPositions(U);for(let Q=0;Q<X.length;Q++){const V=X[Q][0],T=X[Q][1];for(let I=-1;I<=7;I++)if(!(V+I<=-1||G<=V+I))for(let $=-1;$<=7;$++)T+$<=-1||G<=T+$||(I>=0&&I<=6&&($===0||$===6)||$>=0&&$<=6&&(I===0||I===6)||I>=2&&I<=4&&$>=2&&$<=4?W.set(V+I,T+$,!0,!0):W.set(V+I,T+$,!1,!0))}}function S(W){const U=W.size;for(let G=8;G<U-8;G++){const X=G%2===0;W.set(G,6,X,!0),W.set(6,G,X,!0)}}function A(W,U){const G=s.getPositions(U);for(let X=0;X<G.length;X++){const Q=G[X][0],V=G[X][1];for(let T=-2;T<=2;T++)for(let I=-2;I<=2;I++)T===-2||T===2||I===-2||I===2||T===0&&I===0?W.set(Q+T,V+I,!0,!0):W.set(Q+T,V+I,!1,!0)}}function C(W,U){const G=W.size,X=f.getEncodedBits(U);let Q,V,T;for(let I=0;I<18;I++)Q=Math.floor(I/3),V=I%3+G-8-3,T=(X>>I&1)===1,W.set(Q,V,T,!0),W.set(V,Q,T,!0)}function N(W,U,G){const X=W.size,Q=g.getEncodedBits(U,G);let V,T;for(V=0;V<15;V++)T=(Q>>V&1)===1,V<6?W.set(V,8,T,!0):V<8?W.set(V+1,8,T,!0):W.set(X-15+V,8,T,!0),V<8?W.set(8,X-V-1,T,!0):V<9?W.set(8,15-V-1+1,T,!0):W.set(8,15-V-1,T,!0);W.set(X-8,8,1,!0)}function k(W,U){const G=W.size;let X=-1,Q=G-1,V=7,T=0;for(let I=G-1;I>0;I-=2)for(I===6&&I--;;){for(let $=0;$<2;$++)if(!W.isReserved(Q,I-$)){let j=!1;T<U.length&&(j=(U[T]>>>V&1)===1),W.set(Q,I-$,j),V--,V===-1&&(T++,V=7)}if(Q+=X,Q<0||G<=Q){Q-=X,X=-X;break}}}function O(W,U,G){const X=new n;G.forEach(function($){X.put($.mode.bit,4),X.put($.getLength(),_.getCharCountIndicator($.mode,W)),$.write(X)});const Q=t.getSymbolTotalCodewords(W),V=d.getTotalCodewordsCount(W,U),T=(Q-V)*8;for(X.getLengthInBits()+4<=T&&X.put(0,4);X.getLengthInBits()%8!==0;)X.putBit(0);const I=(T-X.getLengthInBits())/8;for(let $=0;$<I;$++)X.put($%2?17:236,8);return P(X,W,U)}function P(W,U,G){const X=t.getSymbolTotalCodewords(U),Q=d.getTotalCodewordsCount(U,G),V=X-Q,T=d.getBlocksCount(U,G),I=X%T,$=T-I,j=Math.floor(X/T),M=Math.floor(V/T),L=M+1,R=j-M,E=new h(R);let z=0;const D=new Array(T),q=new Array(T);let ce=0;const ge=new Uint8Array(W.buffer);for(let ie=0;ie<T;ie++){const de=ie<$?M:L;D[ie]=ge.slice(z,z+de),q[ie]=E.encode(D[ie]),z+=de,ce=Math.max(ce,de)}const se=new Uint8Array(X);let we=0,_e,fe;for(_e=0;_e<ce;_e++)for(fe=0;fe<T;fe++)_e<D[fe].length&&(se[we++]=D[fe][_e]);for(_e=0;_e<R;_e++)for(fe=0;fe<T;fe++)se[we++]=q[fe][_e];return se}function H(W,U,G,X){let Q;if(Array.isArray(W))Q=y.fromArray(W);else if(typeof W=="string"){let j=U;if(!j){const M=y.rawSplit(W);j=f.getBestVersionForData(M,G)}Q=y.fromString(W,j||40)}else throw new Error("Invalid data");const V=f.getBestVersionForData(Q,G);if(!V)throw new Error("The amount of data is too big to be stored in a QR Code");if(!U)U=V;else if(U<V)throw new Error(`
|
|
161
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
162
|
-
Minimum version required to store current data is: `+V+`.
|
|
163
|
-
`);const T=O(U,G,Q),I=t.getSymbolSize(U),$=new i(I);return w($,U),S($),A($,U),N($,G,0),U>=7&&C($,U),k($,T),isNaN(X)&&(X=c.getBestMask($,N.bind(null,$,G))),c.applyMask(X,$),N($,G,X),{modules:$,version:U,errorCorrectionLevel:G,maskPattern:X,segments:Q}}return Ff.create=function(U,G){if(typeof U>"u"||U==="")throw new Error("No input text");let X=e.M,Q,V;return typeof G<"u"&&(X=e.from(G.errorCorrectionLevel,e.M),Q=f.from(G.version),V=c.from(G.maskPattern),G.toSJISFunc&&t.setToSJISFunction(G.toSJISFunc)),H(U,Q,X,V)},Ff}var op={},ap={},e0;function zx(){return e0||(e0=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 i=n.slice().replace("#","").split("");if(i.length<3||i.length===5||i.length>8)throw new Error("Invalid hex color: "+n);(i.length===3||i.length===4)&&(i=Array.prototype.concat.apply([],i.map(function(a){return[a,a]}))),i.length===6&&i.push("F","F");const s=parseInt(i.join(""),16);return{r:s>>24&255,g:s>>16&255,b:s>>8&255,a:s&255,hex:"#"+i.slice(0,6).join("")}}t.getOptions=function(i){i||(i={}),i.color||(i.color={});const s=typeof i.margin>"u"||i.margin===null||i.margin<0?4:i.margin,a=i.width&&i.width>=21?i.width:void 0,c=i.scale||4;return{width:a,scale:a?4:c,margin:s,color:{dark:e(i.color.dark||"#000000ff"),light:e(i.color.light||"#ffffffff")},type:i.type,rendererOpts:i.rendererOpts||{}}},t.getScale=function(i,s){return s.width&&s.width>=i+s.margin*2?s.width/(i+s.margin*2):s.scale},t.getImageWidth=function(i,s){const a=t.getScale(i,s);return Math.floor((i+s.margin*2)*a)},t.qrToImageData=function(i,s,a){const c=s.modules.size,d=s.modules.data,h=t.getScale(c,a),f=Math.floor((c+a.margin*2)*h),g=a.margin*h,_=[a.color.light,a.color.dark];for(let y=0;y<f;y++)for(let w=0;w<f;w++){let S=(y*f+w)*4,A=a.color.light;if(y>=g&&w>=g&&y<f-g&&w<f-g){const C=Math.floor((y-g)/h),N=Math.floor((w-g)/h);A=_[d[C*c+N]?1:0]}i[S++]=A.r,i[S++]=A.g,i[S++]=A.b,i[S]=A.a}}})(ap)),ap}var t0;function qT(){return t0||(t0=1,(function(t){const e=zx();function n(s,a,c){s.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=c,a.width=c,a.style.height=c+"px",a.style.width=c+"px"}function i(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(a,c,d){let h=d,f=c;typeof h>"u"&&(!c||!c.getContext)&&(h=c,c=void 0),c||(f=i()),h=e.getOptions(h);const g=e.getImageWidth(a.modules.size,h),_=f.getContext("2d"),y=_.createImageData(g,g);return e.qrToImageData(y.data,a,h),n(_,f,g),_.putImageData(y,0,0),f},t.renderToDataURL=function(a,c,d){let h=d;typeof h>"u"&&(!c||!c.getContext)&&(h=c,c=void 0),h||(h={});const f=t.render(a,c,h),g=h.type||"image/png",_=h.rendererOpts||{};return f.toDataURL(g,_.quality)}})(op)),op}var lp={},n0;function KT(){if(n0)return lp;n0=1;const t=zx();function e(s,a){const c=s.a/255,d=a+'="'+s.hex+'"';return c<1?d+" "+a+'-opacity="'+c.toFixed(2).slice(1)+'"':d}function n(s,a,c){let d=s+a;return typeof c<"u"&&(d+=" "+c),d}function i(s,a,c){let d="",h=0,f=!1,g=0;for(let _=0;_<s.length;_++){const y=Math.floor(_%a),w=Math.floor(_/a);!y&&!f&&(f=!0),s[_]?(g++,_>0&&y>0&&s[_-1]||(d+=f?n("M",y+c,.5+w+c):n("m",h,0),h=0,f=!1),y+1<a&&s[_+1]||(d+=n("h",g),g=0)):h++}return d}return lp.render=function(a,c,d){const h=t.getOptions(c),f=a.modules.size,g=a.modules.data,_=f+h.margin*2,y=h.color.light.a?"<path "+e(h.color.light,"fill")+' d="M0 0h'+_+"v"+_+'H0z"/>':"",w="<path "+e(h.color.dark,"stroke")+' d="'+i(g,f,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">'+y+w+`</svg>
|
|
164
|
-
`;return typeof d=="function"&&d(null,C),C},lp}var i0;function VT(){if(i0)return fa;i0=1;const t=NT(),e=WT(),n=qT(),i=KT();function s(a,c,d,h,f){const g=[].slice.call(arguments,1),_=g.length,y=typeof g[_-1]=="function";if(!y&&!t())throw new Error("Callback required as last argument");if(y){if(_<2)throw new Error("Too few arguments provided");_===2?(f=d,d=c,c=h=void 0):_===3&&(c.getContext&&typeof f>"u"?(f=h,h=void 0):(f=h,h=d,d=c,c=void 0))}else{if(_<1)throw new Error("Too few arguments provided");return _===1?(d=c,c=h=void 0):_===2&&!c.getContext&&(h=d,d=c,c=void 0),new Promise(function(w,S){try{const A=e.create(d,h);w(a(A,c,h))}catch(A){S(A)}})}try{const w=e.create(d,h);f(null,a(w,c,h))}catch(w){f(w)}}return fa.create=e.create,fa.toCanvas=s.bind(null,n.render),fa.toDataURL=s.bind(null,n.renderToDataURL),fa.toString=s.bind(null,function(a,c,d){return i.render(a,d)}),fa}var YT=VT();const GT=Tm(YT);function s0(t){return typeof t=="string"?t.trim():t&&typeof t=="object"&&typeof t.data=="string"?t.data.trim():""}function XT(t){const e=String(t||"").trim();if(!e)return{kind:"empty"};const n=oj(e);if(!n||!n.ok)return{kind:"invalid"};const i=[];return n.ssh||i.push("ssh"),n.name||i.push("name"),i.length?{kind:"partial",decoded:n,missing:i}:{kind:"complete",decoded:n}}function QT(t,e,n=new Set,i=!1){if(!e||!e.ok)return t;const s=aj(t,e,n);return e.version===2&&e.name&&!n.has("name")&&!i&&(s.name=e.name),!n.has("label")&&!s.label&&e.label&&(s.label=e.label),s}function r0(t,e,n=new Set,i=!1){const s=String(e||"").trim(),a=XT(s);let c={...t,pairingUrl:s};return(a.kind==="complete"||a.kind==="partial")&&(c={...QT(c,a.decoded,n,i),pairingUrl:s}),{classification:a,form:c}}function Bu(t,e){const n=String(e||"").toLowerCase();if(!/^[a-f0-9]{16,64}$/.test(n))return"";const i=String(t||"NexusCrew").replace(/([a-z0-9])([A-Z])/g,"$1 $2");let s=Xr(i);(s==="localhost"||s==="node")&&(s="nexuscrew");const a=n.slice(0,4),c=Math.max(1,32-a.length-1);return`${s.slice(0,c).replace(/-+$/g,"")||"n"}-${a}`}function JT(t,{deviceDefault:e="",localNodeId:n="",localNameDefault:i=""}={}){const s={name:t.name,ssh:t.ssh,pairingUrl:t.pairingUrl,...t.label?{label:t.label}:{},...t.sshPort?{sshPort:Number(t.sshPort)}:{}},a=t.localLabel||e;a&&(s.localLabel=a);const c=String(t.localName||Bu(a,n)||i||"").trim();return c&&(s.localName=c),s}function ZT(){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 eP=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function tP(t){const e=t&&t.data||{},n=typeof e.stage=="string"&&e.stage?e.stage:"",i=typeof e.detail=="string"&&e.detail?e.detail:"";return{stage:n,code:typeof e.code=="string"?e.code:"",detail:i,hint:typeof e.hint=="string"?e.hint:"",suggestedName:typeof e.suggestedName=="string"?e.suggestedName:"",retryable:typeof e.retryable=="boolean"?e.retryable:!n,message:i||String(t&&t.message||t)}}const nP="modulepreload",iP=function(t){return"/"+t},o0={},sP=function(e,n,i){let s=Promise.resolve();if(n&&n.length>0){let c=function(f){return Promise.all(f.map(g=>Promise.resolve(g).then(_=>({status:"fulfilled",value:_}),_=>({status:"rejected",reason:_}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),h=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));s=c(n.map(f=>{if(f=iP(f),f in o0)return;o0[f]=!0;const g=f.endsWith(".css"),_=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${_}`))return;const y=document.createElement("link");if(y.rel=g?"stylesheet":nP,g||(y.as="script"),y.crossOrigin="",y.href=f,h&&y.setAttribute("nonce",h),document.head.appendChild(y),g)return new Promise((w,S)=>{y.addEventListener("load",w),y.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${f}`)))})}))}function a(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return s.then(c=>{for(const d of c||[])d.status==="rejected"&&a(d.reason);return e().catch(a)})};class Lt{constructor(e,n,i,s,a){this._legacyCanvasSize=Lt.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"),i&&typeof i=="object"?this._onDecode=n:(console.warn(i||s||a?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=n),n=typeof i=="object"?i:{},this._onDecodeError=n.onDecodeError||(typeof i=="function"?i:this._onDecodeError),this._calculateScanRegion=n.calculateScanRegion||(typeof s=="function"?s:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||a||this._preferredCamera,this._legacyCanvasSize=typeof i=="number"?i:typeof s=="number"?s: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),i=e.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(s=!!n.overlay,this.$overlay=n.overlay||document.createElement("div"),a=this.$overlay.style,a.position="absolute",a.display="none",a.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!s&&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{}i.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 d=window.getComputedStyle(e);d.display==="none"&&(e.style.setProperty("display","block","important"),c=!0),d.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=Lt.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 Lt.listCameras(!1)).length}catch{return!1}}static async listCameras(e=!1){if(!navigator.mediaDevices)return[];let n=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(s=>s.kind==="videoinput"),i;try{e&&(await n()).every(s=>!s.label)&&(i=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await n()).map((s,a)=>({id:s.deviceId,label:s.label||(a===0?"Default Camera":`Camera ${a+1}`)}))}finally{i&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),Lt._stopVideoStream(i))}}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"),Lt._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(),Lt._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?Lt._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&&(Lt._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return e?(n(),!0):(await new Promise(i=>setTimeout(i,300)),this._paused?(n(),!0):!1)}async setCamera(e){e!==this._preferredCamera&&(this._preferredCamera=e,await this._restartVideoStream())}static async scanImage(e,n,i,s,a=!1,c=!1){let d,h=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(d=n.scanRegion,i=n.qrEngine,s=n.canvas,a=n.disallowCanvasResizing||!1,c=n.alsoTryWithoutScanRegion||!1,h=!0):console.warn(n||i||s||a||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=!!i;try{let f,g;[i,f]=await Promise.all([i||Lt.createQrEngine(),Lt._loadImage(e)]),[s,g]=Lt._drawToCanvas(f,d,s,a);let _;if(i instanceof Worker){let y=i;n||Lt._postWorkerMessageSync(y,"inversionMode","both"),_=await new Promise((w,S)=>{let A,C,N,k=-1;C=P=>{P.data.id===k&&(y.removeEventListener("message",C),y.removeEventListener("error",N),clearTimeout(A),P.data.data!==null?w({data:P.data.data,cornerPoints:Lt._convertPoints(P.data.cornerPoints,d)}):S(Lt.NO_QR_CODE_FOUND))},N=P=>{y.removeEventListener("message",C),y.removeEventListener("error",N),clearTimeout(A),S("Scanner error: "+(P?P.message||P:"Unknown Error"))},y.addEventListener("message",C),y.addEventListener("error",N),A=setTimeout(()=>N("timeout"),1e4);let O=g.getImageData(0,0,s.width,s.height);k=Lt._postWorkerMessageSync(y,"decode",O,[O.data.buffer])})}else _=await Promise.race([new Promise((y,w)=>window.setTimeout(()=>w("Scanner error: timeout"),1e4)),(async()=>{try{var[y]=await i.detect(s);if(!y)throw Lt.NO_QR_CODE_FOUND;return{data:y.rawValue,cornerPoints:Lt._convertPoints(y.cornerPoints,d)}}catch(w){if(y=w.message||w,/not implemented|service unavailable/.test(y))return Lt._disableBarcodeDetector=!0,Lt.scanImage(e,{scanRegion:d,canvas:s,disallowCanvasResizing:a,alsoTryWithoutScanRegion:c});throw`Scanner error: ${y}`}})()]);return h?_:_.data}catch(f){if(!d||!c)throw f;let g=await Lt.scanImage(e,{qrEngine:i,canvas:s,disallowCanvasResizing:a});return h?g:g.data}finally{n||Lt._postWorkerMessage(i,"close")}}setGrayscaleWeights(e,n,i,s=!0){Lt._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:e,green:n,blue:i,useIntegerApproximation:s})}setInversionMode(e){Lt._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=()=>sP(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(i=>i.createWorker()),!(!Lt._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return e();let n=navigator.userAgentData;return n&&n.brands.some(({brand:i})=>/Chromium/i.test(i))&&/mac ?OS/i.test(n.platform)&&await n.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:i,platformVersion:s})=>/arm/i.test(i||"arm")&&13<=parseInt(s||"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,i=e.videoHeight,s=e.offsetWidth,a=e.offsetHeight,c=e.offsetLeft,d=e.offsetTop,h=window.getComputedStyle(e),f=h.objectFit,g=n/i,_=s/a;switch(f){case"none":var y=n,w=i;break;case"fill":y=s,w=a;break;default:(f==="cover"?g>_:g<_)?(w=a,y=w*g):(y=s,w=y/g),f==="scale-down"&&(y=Math.min(y,n),w=Math.min(w,i))}var[S,A]=h.objectPosition.split(" ").map((N,k)=>{const O=parseFloat(N);return N.endsWith("%")?(k?a-w:s-y)*O/100:O});h=this._scanRegion.width||n,_=this._scanRegion.height||i,f=this._scanRegion.x||0;var C=this._scanRegion.y||0;g=this.$overlay.style,g.width=`${h/n*y}px`,g.height=`${_/i*w}px`,g.top=`${d+A+C/i*w}px`,i=/scaleX\(-1\)/.test(e.style.transform),g.left=`${c+(i?s-S-y:S)+(i?n-f-h:f)/n*y}px`,g.transform=e.style.transform}})}static _convertPoints(e,n){if(!n)return e;let i=n.x||0,s=n.y||0,a=n.width&&n.downScaledWidth?n.width/n.downScaledWidth:1;n=n.height&&n.downScaledHeight?n.height/n.downScaledHeight:1;for(let c of e)c.x=c.x*a+i,c.y=c.y*n+s;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(s=>setTimeout(s,n-e)),this._lastScanTimestamp=Date.now();try{var i=await Lt.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(s){if(!this._active)return;this._onDecodeError(s)}!Lt._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=Lt.createQrEngine()),i?(this._onDecode?this._onDecode(i):this._legacyOnDecode&&this._legacyOnDecode(i.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",i.cornerPoints.map(({x:s,y:a})=>`${s},${a}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(e){e!==Lt.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}},{}],i=n.map(s=>Object.assign({},s,{[e]:{exact:this._preferredCamera}}));for(let s of[...i,...n])try{let a=await navigator.mediaDevices.getUserMedia({video:s,audio:!1}),c=this._getFacingMode(a)||(s.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:a,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,i,s=!1){i=i||document.createElement("canvas");let a=n&&n.x?n.x:0,c=n&&n.y?n.y:0,d=n&&n.width?n.width:e.videoWidth||e.width,h=n&&n.height?n.height:e.videoHeight||e.height;return s||(s=n&&n.downScaledWidth?n.downScaledWidth:d,n=n&&n.downScaledHeight?n.downScaledHeight:h,i.width!==s&&(i.width=s),i.height!==n&&(i.height=n)),n=i.getContext("2d",{alpha:!1}),n.imageSmoothingEnabled=!1,n.drawImage(e,a,c,d,h,0,0,i.width,i.height),[i,n]}static async _loadImage(e){if(e instanceof Image)return await Lt._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 Lt._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,i)=>{let s=a=>{e.removeEventListener("load",s),e.removeEventListener("error",s),a instanceof ErrorEvent?i("Image load error"):n()};e.addEventListener("load",s),e.addEventListener("error",s)})}static async _postWorkerMessage(e,n,i,s){return Lt._postWorkerMessageSync(await e,n,i,s)}static _postWorkerMessageSync(e,n,i,s){if(!(e instanceof Worker))return-1;let a=Lt._workerMessageId++;return e.postMessage({id:a,type:n,data:i},s),a}}Lt.DEFAULT_CANVAS_SIZE=400;Lt.NO_QR_CODE_FOUND="No QR code found";Lt._disableBarcodeDetector=!1;Lt._workerMessageId=0;function rP({onResult:t,onClose:e}){const n=b.useRef(null),i=b.useRef(null),s=b.useRef(!1),[a,c]=b.useState("");b.useEffect(()=>{let h=!1;const f=n.current,g=_=>{h||s.current||(s.current=!0,t(_))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){c(p("qr-unsupported"));return}let _=!1;try{_=await Lt.hasCamera()}catch{_=!1}if(!_){c(p("qr-no-camera"));return}if(h||!f)return;const y=new Lt(f,w=>{const S=s0(w);S&&g(S)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:w=>{const S=w.videoWidth||640,A=w.videoHeight||480,C=Math.max(1,Math.round(Math.min(S,A)*.92));return{x:Math.round((S-C)/2),y:Math.round((A-C)/2),width:C,height:C,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});i.current=y;try{await y.start()}catch(w){if(h)return;const S=w&&w.name||"";c(p(S==="NotAllowedError"||S==="SecurityError"?"qr-permission":S==="NotFoundError"||S==="OverconstrainedError"||S==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{h=!0;const _=i.current;if(_){try{_.stop()}catch{}try{_.destroy()}catch{}i.current=null}const y=f,w=y&&y.srcObject;if(w&&typeof w.getTracks=="function"){for(const S of w.getTracks())try{S.stop()}catch{}try{y.srcObject=null}catch{}}}},[]);const d=async h=>{const f=h.target.files&&h.target.files[0];if(h.target.value="",!!f)try{const g=await Lt.scanImage(f,{returnDetailedScanResult:!0}),_=s0(g);if(!_)throw new Error("empty");s.current||(s.current=!0,t(_))}catch{c(p("pairing-qr-invalid"))}};return l.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:e,children:l.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:h=>h.stopPropagation(),children:[l.jsx("div",{className:"nc-sheet-head",children:l.jsx("b",{children:p("scan-qr")})}),l.jsx("video",{ref:n,className:"nc-qr-video",playsInline:!0,muted:!0}),a&&l.jsx("div",{className:"nc-err",role:"alert",children:a}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[p("qr-upload"),l.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:d})]}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:e,children:p("cancel")})]})]})})}function kg({line:t,note:e}){const[n,i]=b.useState(!1);return t?l.jsxs("div",{className:"nc-authkeys",role:"group",children:[l.jsx("div",{className:"nc-sheet-label",children:p("pair-authkeys-title")}),l.jsx("small",{className:"nc-set-hint",children:e||p("pair-authkeys-hint")}),l.jsx("textarea",{className:"nc-authkeys-line",readOnly:!0,rows:3,value:t,"aria-label":p("pair-authkeys-title"),onFocus:s=>s.target.select()}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:async()=>{i(await am(t))},children:p(n?"pair-authkeys-copied":"pair-authkeys-copy")})]}):null}const a0=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:"",localName:""});function Fx({token:t,initial:e="",autoStart:n=!1,deviceDefault:i="",localNodeId:s="",localNameDefault:a="",readonly:c=!1,onSuccess:d,onBusyChange:h}){const[f,g]=b.useState(a0),[_,y]=b.useState(!1),[w,S]=b.useState(!1),[A,C]=b.useState("idle"),[N,k]=b.useState(null),[O,P]=b.useState(""),[H,W]=b.useState(null),[U,G]=b.useState(!1),[X,Q]=b.useState(!1),V=b.useRef(ZT()),T=b.useRef(new Set),I=A==="busy",$=Bu(f.localLabel||i,s)||a,j=X?f.localName:$;b.useEffect(()=>(h&&h(I),()=>{h&&h(!1)}),[I,h]);const M=async q=>{const ce=String(q.pairingUrl||"").trim();if(V.current.start(ce)){C("busy"),k(null),P("");try{const ge=await L2(t,JT({...q,localName:X?q.localName:Bu(q.localLabel||i,s)||a},{deviceDefault:i,localNodeId:s,localNameDefault:a}));C("ok"),y(!1),g(a0()),W(ge&&ge.authorizedKeys?{line:ge.authorizedKeys,note:ge.authorizedKeysNote||""}:null),T.current=new Set,G(!1),Q(!1),V.current.finish(),d&&await d(ge)}catch(ge){const se=tP(ge);k(se),C("idle"),V.current.finish(),se.code==="peer-name-conflict"&&vm(se.suggestedName)&&(Q(!0),T.current.add("localName"),g(we=>({...we,localName:se.suggestedName}))),(se.stage==="validation"||se.stage==="conflict"||se.stage==="ssh-start"||se.stage==="ssh-ready"||String(se.code||"").startsWith("ssh-"))&&y(!0)}}},L=(q,ce=!0)=>{const{classification:ge,form:se}=r0(f,q,T.current,U),we=se.pairingUrl;if(k(null),P(""),A==="ok"&&C("idle"),g(se),ge.kind==="invalid"){k({stage:"validation",code:"bad-link",message:p("pair-invalid-link"),hint:p("pair-invalid-hint"),retryable:!0});return}if(ge.kind==="partial"){y(!0),P(ge.missing.includes("ssh")?p("pair-missing-ssh"):p("pair-missing-name"));return}ge.kind==="complete"&&ce&&!c&&V.current.canAuto(we)&&M(se)};b.useEffect(()=>{e&&L(e,n)},[]);const R=()=>{const q=String(f.pairingUrl||"").trim(),{classification:ce,form:ge}=r0(f,q,T.current,U);if(g(ge),P(""),k(null),ce.kind==="empty"){k({stage:"validation",message:p("pairing-required"),retryable:!0});return}if(ce.kind==="invalid"){k({stage:"validation",code:"bad-link",message:p("pair-invalid-link"),hint:p("pair-invalid-hint"),retryable:!0});return}if(!ge.ssh||!ge.name){y(!0),P(ge.ssh?p("pair-missing-name"):p("pair-missing-ssh"));return}if(ge.label&&!Na(ge.label)){k({stage:"validation",message:p("err-label"),retryable:!0});return}if(ge.localLabel&&!Na(ge.localLabel)){k({stage:"validation",message:p("err-label"),retryable:!0});return}const se=X?ge.localName:Bu(ge.localLabel||i,s)||a;if(!vm(se)||se==="localhost"){y(!0),k({stage:"validation",code:"bad-local-name",message:p("err-local-name"),retryable:!0});return}V.current.reset(q),M(ge)},E=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const q=await navigator.clipboard.readText();q&&q.trim()?L(q):P(p("pair-clipboard-empty"))}catch{P(p("pair-clipboard-denied"))}},z=(q,ce)=>{T.current.add(q),g(ge=>({...ge,[q]:ce}))},D=N&&N.stage&&(eP.includes(N.stage)||N.stage==="internal")?p(`pair-stage-${N.stage}`):p("pair-stage-generic");return l.jsxs("div",{className:"nc-set-form nc-pair-card",children:[l.jsx("div",{className:"nc-sheet-label",children:p("pair-card-title")}),l.jsx("div",{className:"nc-set-info",children:p("pair-card-help")}),l.jsx("input",{className:"nc-pair-input",placeholder:p("pair-paste-ph"),value:f.pairingUrl,disabled:c||I,onChange:q=>{g({...f,pairingUrl:q.target.value}),k(null),P("")},onPaste:q=>{const ce=q.clipboardData&&q.clipboardData.getData("text")||"";ce.trim()&&(q.preventDefault(),L(ce))},onKeyDown:q=>{q.key==="Enter"&&(q.preventDefault(),R())}}),l.jsxs("div",{className:"nc-pair-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||I,onClick:E,children:p("pair-paste-btn")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||I,onClick:()=>S(!0),children:p("scan-qr")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:c||I,title:c?p("settings-readonly"):"",onClick:R,children:p("test-and-connect")})]}),l.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[I&&l.jsx("div",{className:"nc-pair-progress",children:p("pair-progress")}),A==="ok"&&l.jsx("div",{className:"nc-set-test ok",children:p("node-connected")}),A==="ok"&&H&&l.jsx(kg,{line:H.line,note:H.note}),O&&l.jsx("div",{className:"nc-set-hint nc-pair-notice",children:O}),N&&l.jsxs("div",{className:"nc-err",role:"alert",children:[l.jsx("b",{children:D})," — ",N.message,N.hint&&l.jsx("div",{className:"nc-pair-hint",children:N.hint}),N.retryable&&l.jsx("div",{children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||I,onClick:R,children:p("pair-retry")})})]})]}),l.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:I,onClick:()=>y(q=>!q),children:[_?"▾":"▸"," ",p("pair-advanced")]}),_&&l.jsxs("div",{className:"nc-pair-advanced",children:[l.jsxs("label",{className:"nc-field",children:[p("node-display-label"),l.jsx("input",{placeholder:"Home Relay",value:f.label,disabled:c||I,onChange:q=>{T.current.add("label"),g(ce=>({...ce,label:q.target.value,name:U?ce.name:Xr(q.target.value)}))}})]}),l.jsxs("label",{className:"nc-field",children:[p("node-name-label"),l.jsx("input",{placeholder:p("node-name-ph"),value:f.name,disabled:c||I,onChange:q=>{G(!0),T.current.add("name"),g(ce=>({...ce,name:q.target.value?Xr(q.target.value):""}))}})]}),l.jsx("small",{className:"nc-set-hint",children:p("node-slug-hint").replace("{slug}",f.name||"home-relay")}),l.jsxs("label",{className:"nc-field",children:[p("pair-ssh-local-label"),l.jsx("input",{placeholder:"my-relay",value:f.ssh,disabled:c||I,onChange:q=>{T.current.add("ssh"),z("ssh",q.target.value)}}),l.jsx("small",{className:"nc-set-hint",children:p("node-ssh-local-help")})]}),l.jsxs("label",{className:"nc-field",children:[p("node-ssh-port-label"),l.jsx("input",{inputMode:"numeric",placeholder:p("node-ssh-port-help"),value:f.sshPort,disabled:c||I,onChange:q=>z("sshPort",q.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),l.jsxs("label",{className:"nc-field",children:[p("device-name-label"),l.jsx("input",{placeholder:i||"NexusCrew",value:f.localLabel,disabled:c||I,onChange:q=>z("localLabel",q.target.value)}),l.jsx("small",{className:"nc-set-hint",children:p("device-name-hint")})]}),l.jsxs("label",{className:"nc-field",children:[p("local-route-name-label"),l.jsx("input",{placeholder:$||"nexuscrew-5bd6",value:j,disabled:c||I,onChange:q=>{Q(!0),T.current.add("localName"),g(ce=>({...ce,localName:q.target.value?Xr(q.target.value):""}))}}),l.jsx("small",{className:"nc-set-hint",children:p("local-route-name-hint")})]})]}),w&&l.jsx(rP,{onResult:q=>{S(!1),L(q)},onClose:()=>S(!1)})]})}const Bs={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 Eg(t){if(!t||typeof t!="object")return{key:Bs.down,up:!1};if(t.kind==="vl")return t.online?{key:Bs.vlOnline,up:!0}:{key:Bs.vlOffline,up:!1};if(t.kind==="transitive"){const n=t.stale===!0;return{key:n?Bs.routedStale:Bs.routed,up:!n,routed:!0}}const e=t.tunnel&&t.tunnel.status;return e==="up"?{key:Bs.up,up:!0}:e==="passive"?{key:Bs.passive,up:!1,passive:!0}:{key:Bs.down,up:!1}}function Hx(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 oP(t){const n=t.health&&typeof t.health.detail=="string"&&t.health.detail.trim()||p(t.online?Bs.vlOnline:Bs.vlOffline);return t.ownerLabel?`${t.ownerLabel} · ${n}`:n}function aP(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"?oP(t):e,reach:Eg(t),exposure:Hx(t),routed:n,routeLabel:n&&Array.isArray(t.route)?t.route.join(" › "):null}}function lP(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 cP(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 uP(t,e){if(!t||t.visibility!=="selected")return[];const n=[...new Set(Array.isArray(t.selected)?t.selected:[])],i=new Map;for(const s of Array.isArray(e)?e:[])s&&s.nodeId&&!i.has(s.nodeId)&&i.set(s.nodeId,s);return n.map(s=>{const a=i.get(s);return{id:s,label:a?typeof a.label=="string"&&a.label.trim()||a.name:s,known:!!a}})}function dP(t,e,n=""){if(!t)return[];const i=new Set(Array.isArray(t.selected)?t.selected:[]),s=String(n||"").trim().toLowerCase(),a=new Set,c=[],d=h=>t.nodeId?h.nodeId===t.nodeId:h.name===t.name;for(const h of Array.isArray(e)?e:[]){if(!h||!h.nodeId||d(h)||i.has(h.nodeId)||a.has(h.nodeId))continue;const f=typeof h.label=="string"&&h.label.trim()||h.name;s&&!`${f} ${h.name}`.toLowerCase().includes(s)||(a.add(h.nodeId),c.push({id:h.nodeId,label:f,name:h.name}))}return c.sort((h,f)=>h.label.localeCompare(f.label))}function hP(t,{readonly:e=!1,busy:n=!1}={}){if(!t||typeof t!="object")return[];const i=t.actions&&typeof t.actions=="object"?t.actions:{},s=Eg(t).up,a=[],c=(d,h,{mutating:f=!0,danger:g=!1}={})=>{a.push({key:d,action:h,danger:g,disabled:n||f&&e})};return i.edit&&c("edit","edit"),i.test&&c("node-test","test",{mutating:!1}),i.disconnect&&s&&c("tunnel-stop","down"),i.connect&&!s&&c("tunnel-start","up"),i.restart&&c("tunnel-restart","restart"),i.remove&&c("delete","remove",{danger:!0}),a}function Ux(t){const e=t&&typeof t.cellVisibility=="string"?t.cellVisibility:"all";return["all","none","selected"].includes(e)?e:"all"}function fP(t,e){if(Ux(t)!=="selected")return[];const n=[...new Set(Array.isArray(t.cells)?t.cells:[])];if(!Array.isArray(e))return n.map(s=>({id:s,label:s,known:!0}));const i=new Set(e.map(s=>typeof s=="string"?s:s&&(s.cell||s.id)).filter(Boolean));return n.map(s=>({id:s,label:s,known:i.has(s)}))}function pP(t,e,n=""){const i=new Set(Array.isArray(t&&t.cells)?t.cells:[]),s=String(n||"").trim().toLowerCase(),a=new Set,c=[];for(const d of Array.isArray(e)?e:[]){const h=typeof d=="string"?d:d&&(d.cell||d.id);!h||i.has(h)||a.has(h)||s&&!h.toLowerCase().includes(s)||(a.add(h),c.push({id:h,label:h}))}return c.sort((d,h)=>d.label.localeCompare(h.label))}function mP(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 gP(t,e,{readonly:n=!1,busy:i=!1}={}){const s=lP(t);return s?{identity:s,reach:Eg(t),authority:cP(t),exposure:Hx(t),grants:uP(t,e),cellScope:Ux(t),actions:hP(t,{readonly:n,busy:i}),canEditVisibility:!!(t.actions&&t.actions.visibility)&&t.shared===!0&&t.kind!=="transitive",canEditCellScope:!!(t.actions&&t.actions.edit)&&t.kind!=="transitive"}:null}const vP=Object.freeze(["cellVisibility","eventsAccess","nodeEventsAccess","askReplyAccess","filesReadAccess","liveHostAccess","panelAccess","peerOperatorAccess"]),_P=Object.freeze(["admin","user","nexushost"]),yP=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 wP(t,e){const n=yP[e];if(!n)return[];const i=t&&typeof t=="object"?t:{};return vP.map(s=>{const a=n[s],c=i[s];return{key:s,current:c,next:a,changed:c!==a}})}const bP=new Set(["update_candidate"]),l0=4096,SP=new Set(["prompt"]),c0={logs:{limit:50}};function xP(t){if(!t||t.kind!=="vl")return[];const e=Array.isArray(t.capabilities)?t.capabilities:[],n=new Set,i=[];for(const s of e)typeof s!="string"||!s||bP.has(s)||SP.has(s)||n.has(s)||(n.add(s),i.push(s));return i}function u0(t){return!!(t&&t.kind==="vl"&&Array.isArray(t.capabilities)&&t.capabilities.includes("prompt"))}function CP(t){return c0[t]?{...c0[t]}:{}}function kP(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 EP({title:t,subtitle:e,status:n,footer:i,onClose:s,plain:a=!1,children:c}){const d=b.useRef(null),h=b.useRef(null);return b.useEffect(()=>(h.current=document.activeElement,d.current&&d.current.focus(),()=>{const f=h.current;f&&typeof f.focus=="function"&&document.contains(f)&&f.focus()}),[]),b.useEffect(()=>{const f=g=>{g.key==="Escape"&&(g.stopPropagation(),s&&s())};return document.addEventListener("keydown",f,!0),()=>document.removeEventListener("keydown",f,!0)},[s]),l.jsx("div",{className:"nc-detail-overlay",onMouseDown:f=>{f.target===f.currentTarget&&s&&s()},children:l.jsxs("div",{className:"nc-detail-sheet",ref:d,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":typeof t=="string"?t:void 0,children:[l.jsxs("div",{className:"nc-detail-head",children:[l.jsxs("div",{className:"nc-detail-title",children:[l.jsx("b",{children:t}),e&&l.jsx("small",{children:e})]}),n,l.jsx("button",{type:"button",className:"nc-btn ghost nc-detail-close",onClick:s,"aria-label":p("close"),children:l.jsx(kt,{name:"x",size:14})})]}),l.jsx("div",{className:`nc-detail-body${a?" plain":""}`,children:c}),i&&l.jsx("div",{className:"nc-detail-foot",children:i})]})})}function go({title:t,hint:e,children:n}){return n==null||n===!1?null:l.jsxs("section",{className:"nc-detail-section",children:[t&&l.jsx("div",{className:"nc-sheet-label",children:t}),e&&l.jsx("small",{className:"nc-set-hint",children:e}),n]})}function NP({node:t,nodes:e,token:n,readonly:i,refresh:s,onClose:a,peerAccessRevision:c=null}){var F,J;Li();const[d,h]=b.useState(null),[f,g]=b.useState(null),[_,y]=b.useState(null),[w,S]=b.useState(null),[A,C]=b.useState(!1),[N,k]=b.useState(""),[O,P]=b.useState(!1),[H,W]=b.useState(null),[U,G]=b.useState(!1),[X,Q]=b.useState(""),[V,T]=b.useState(!1),[I,$]=b.useState(null),[j,M]=b.useState(!1),[L,R]=b.useState(""),[E,z]=b.useState(null),D=b.useMemo(()=>gP(t,e,{readonly:i,busy:!!d}),[t,e,i,d]);if(!D)return null;const{identity:q,reach:ce,authority:ge,exposure:se,grants:we,actions:_e,canEditVisibility:fe,canEditCellScope:ie,cellScope:de}=D,me=mP(t),Ee=q.routed?{up:ce.up,since:null}:_m(t.tunnel,Date.now()),Se=async(ee,K)=>{g(null),h(ee);try{await K()}catch(ye){g(String(ye&&ye.message||ye))}h(null)},xe=ee=>{if(ee==="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(ee==="remove"){C(!0);return}Se(`${t.name}:${ee}`,async()=>{const K=await $m(n,t.name,ee);ee==="test"&&y(K),await s()})},Ye=(ee,K=CP(ee))=>Se(`${t.nodeId}:${ee}`,async()=>{const ye=await oy(n,t.nodeId,ee,K,t.route||[]);$({id:ye.id,kind:ee,submittedAt:Date.now()}),await s()}),Le=()=>{const ee=L.trim().slice(0,l0);ee&&Se(`${t.nodeId}:prompt`,async()=>{const K=await oy(n,t.nodeId,"prompt",{text:ee},t.route||[]);$({id:K.id,kind:"prompt",submittedAt:Date.now()}),R(""),M(!1),await s()})},ze=()=>{if(!Na(w.label)){g(p("err-label"));return}const ee=q.inbound?{label:w.label,visibility:w.visibility,selected:w.visibility==="selected"?[...t.selected||[]]:[]}:{label:w.label,ssh:w.ssh,autostart:w.autostart,...w.sshPort?{sshPort:Number(w.sshPort)}:{}};return Se(`${t.name}:edit`,async()=>{await tf(n,t.name,ee),S(null),await s()})},He=(ee,K)=>Se(`${t.name}:visibility`,async()=>{await P2(n,t.name,ee,K),await s()}),_t=fe&&t.visibility==="selected"?dP(t,e,N):[],at=(ee,K)=>Se(`${t.name}:cell-scope`,async()=>{await tf(n,t.name,ee==="selected"?{cellVisibility:ee,cells:Array.isArray(K)?K:t.cells||[]}:{cellVisibility:ee}),await s()}),lt=ee=>Se(`${t.name}:access`,async()=>{try{await tf(n,t.name,{accessRole:ee,accessRevision:c}),z(null),await s()}catch(K){if(K&&K.status===409)g(p("peer-access-conflict")),await s();else throw K}}),bt=async({retry:ee=!1}={})=>{if(ee&&U)G(!1);else if(H!==null||U)return;try{const K=await rd(n);W(Array.isArray(K&&K.cells)?K.cells:[])}catch{G(!0)}};b.useEffect(()=>{ie&&de==="selected"&&H===null&&bt()},[ie,de,H]);const Ht=fP(t,H),Rt=de==="selected"?pP(t,H,X):[],fn=l.jsxs("span",{className:`nc-set-tunnel${ce.up?" up":""}`,children:[p(ce.key),Ee.since?` · ${Ee.since}`:""]}),It=t.kind==="vl",Wt=It?xP(t):[],ft=It?kP(t,I):null,qt=ee=>{const K=`vl-cmd-${ee}`,ye=p(K);return ye===K?ee:ye},$t=It?[...Wt.map(ee=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d||i,title:i?p("settings-readonly"):void 0,onClick:()=>Ye(ee),children:qt(ee)},ee)),...u0(t)?[l.jsx("button",{type:"button",className:`nc-btn ghost${j?" on":""}`,disabled:!!d||i,title:i?p("settings-readonly"):void 0,onClick:()=>M(ee=>!ee),children:qt("prompt")},"prompt")]:[]]:_e.map(ee=>l.jsx("button",{type:"button",className:`nc-btn ${ee.danger?"danger":"ghost"}`,disabled:ee.disabled,title:ee.disabled&&i?p("settings-readonly"):void 0,onClick:()=>xe(ee.action),children:ee.action==="remove"?l.jsxs(l.Fragment,{children:[l.jsx(kt,{name:"trash",size:14})," ",p(ee.key)]}):p(ee.key)},ee.action));return l.jsxs(EP,{title:q.title,subtitle:q.name,status:fn,footer:$t,onClose:a,children:[l.jsxs(go,{title:p("node-detail-reach"),children:[l.jsxs("dl",{className:"nc-detail-facts",children:[q.route&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:p("node-detail-route")}),l.jsx("dd",{children:q.route.join(" › ")})]}),q.ssh&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:p("node-detail-ssh")}),l.jsxs("dd",{children:[q.ssh,t.sshPort?`:${t.sshPort}`:""]})]}),q.transport&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:p("node-detail-transport")}),l.jsx("dd",{children:q.transport})]}),It&&t.ownerLabel&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:p("node-detail-owner")}),l.jsx("dd",{children:t.ownerLabel})]})]}),((F=t.health)==null?void 0:F.detail)&&l.jsx("div",{className:`nc-set-test${It?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 ee=zM(t.health);return ee?ee.line?l.jsx(kg,{line:ee.line,note:ee.note}):l.jsx("small",{className:"nc-set-hint",children:ee.note}):null})(),_&&l.jsxs("div",{className:`nc-set-test${_.ok?" ok":" ko"}`,children:[_.result,_.detail?` — ${_.detail}`:""]})]}),It&&l.jsxs(go,{title:p("node-detail-command"),children:[Wt.length===0&&!u0(t)&&l.jsx("small",{className:"nc-set-hint",children:p("vl-no-commands")}),j&&l.jsxs("div",{className:"nc-vl-prompt",children:[l.jsx("textarea",{value:L,maxLength:l0,placeholder:p("vl-prompt-placeholder"),"aria-label":p("vl-prompt-placeholder"),disabled:!!d||i,onChange:ee=>R(ee.target.value)}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!d||i||!L.trim(),onClick:Le,children:p("vl-prompt-send")})]}),ft&&l.jsxs("div",{className:`nc-set-test${ft.phase==="done"?ft.status==="ok"?" ok":" ko":""}`,children:[ft.kind&&`${qt(ft.kind)}: `,ft.phase==="submitted"&&p("vl-cmd-phase-submitted"),ft.phase==="inflight"&&p("vl-cmd-phase-inflight"),ft.phase==="done"&&p(ft.status==="ok"?"vl-cmd-phase-done-ok":"vl-cmd-phase-done-error"),ft.phase==="done"&&((J=ft.result)!=null&&J.detail)?` — ${ft.result.detail}`:""]})]}),l.jsxs(go,{title:p("node-detail-authority"),children:[l.jsx("div",{className:"nc-set-info",children:p(ge.key)}),ge.grants.length===0&&l.jsx("small",{className:"nc-set-hint",children:p(ie?"authority-no-grants":"authority-no-grants-elsewhere")})]}),l.jsxs(go,{title:p("node-detail-network-view"),children:[l.jsx("div",{className:"nc-set-info",children:p(It?se.key:se.shared?"peer-shared":"peer-private")}),fe&&l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"nc-field",children:[p("peer-visibility"),l.jsxs("select",{value:t.visibility||"network",disabled:i||!!d,onChange:ee=>He(ee.target.value),children:[l.jsx("option",{value:"network",children:p("visibility-network")}),l.jsx("option",{value:"relay-only",children:p("visibility-relay")}),l.jsx("option",{value:"selected",children:p("visibility-selected")})]})]}),t.visibility==="selected"&&l.jsxs("div",{className:"nc-detail-grants",children:[we.length===0&&l.jsx("small",{className:"nc-set-hint",children:p("node-grant-none")}),we.map(ee=>l.jsxs("div",{className:`nc-detail-grant${ee.known?"":" unknown"}`,children:[l.jsxs("span",{children:[ee.label,ee.known?"":` — ${p("node-grant-unknown")}`]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!d,onClick:()=>He("selected",(t.selected||[]).filter(K=>K!==ee.id)),children:p("node-grant-remove")})]},ee.id)),!O&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!d,onClick:()=>{P(!0),k("")},children:p("node-grant-add")}),O&&l.jsxs("div",{className:"nc-detail-picker",children:[l.jsx("input",{value:N,placeholder:p("node-grant-search"),disabled:i||!!d,onChange:ee=>k(ee.target.value)}),l.jsxs("div",{className:"nc-detail-picker-list",children:[_t.length===0&&l.jsx("small",{className:"nc-set-hint",children:p("node-grant-no-candidates")}),_t.map(ee=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!d,onClick:async()=>{await He("selected",[...t.selected||[],ee.id]),P(!1),k("")},children:ee.label},ee.id))]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>{P(!1),k("")},children:p("cancel")})]})]})]})]}),ie&&l.jsxs(go,{title:p("cell-scope"),children:[l.jsx("small",{className:"nc-set-hint",children:p("cell-scope-help")}),l.jsx("label",{className:"nc-field",children:l.jsxs("select",{value:de,"aria-label":p("cell-scope"),disabled:i||!!d,onChange:ee=>{ee.target.value==="selected"&&bt(),at(ee.target.value)},children:[l.jsx("option",{value:"all",children:p("cell-scope-all")}),l.jsx("option",{value:"none",children:p("cell-scope-none")}),l.jsx("option",{value:"selected",children:p("cell-scope-selected")})]})}),de==="selected"&&Ht.length>0&&l.jsx("small",{className:"nc-set-hint",children:p("cell-scope-reset-warning")}),U&&l.jsx("small",{className:"nc-set-hint",children:p("cell-scope-list-unavailable")}),de==="selected"&&l.jsxs("div",{className:"nc-detail-grants",children:[Ht.length===0&&l.jsx("small",{className:"nc-set-hint",children:p("cell-scope-none-granted")}),Ht.map(ee=>l.jsxs("div",{className:`nc-detail-grant${ee.known?"":" unknown"}`,children:[l.jsxs("span",{children:[ee.label,ee.known?"":` — ${p("cell-scope-unknown")}`]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!d,onClick:()=>at("selected",(t.cells||[]).filter(K=>K!==ee.id)),children:p("node-grant-remove")})]},ee.id)),!V&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!d,onClick:async()=>{await bt({retry:!0}),T(!0),Q("")},children:p("cell-scope-add")}),V&&l.jsxs("div",{className:"nc-detail-picker",children:[l.jsx("input",{value:X,placeholder:p("cell-scope-search"),disabled:i||!!d,onChange:ee=>Q(ee.target.value)}),l.jsxs("div",{className:"nc-detail-picker-list",children:[Rt.length===0&&l.jsx("small",{className:"nc-set-hint",children:p("cell-scope-no-candidates")}),Rt.map(ee=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!d,onClick:async()=>{await at("selected",[...t.cells||[],ee.id]),T(!1),Q("")},children:ee.label},ee.id))]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>{T(!1),Q("")},children:p("cancel")})]})]})]}),me&&c!=null&&!It&&l.jsxs(go,{title:p("peer-access"),children:[l.jsx("small",{className:"nc-set-hint",children:p("peer-access-help")}),l.jsxs("div",{className:"nc-set-info",children:[p("peer-access-current"),": ",l.jsx("b",{children:p(`access-label-${me.label}`)})]}),l.jsx("label",{className:"nc-field",children:l.jsxs("select",{value:E||"","aria-label":p("peer-access-preset"),disabled:i||!!d,title:i?p("settings-readonly"):void 0,onChange:ee=>z(ee.target.value||null),children:[l.jsx("option",{value:"",children:p("peer-access-preset-none")}),_P.map(ee=>l.jsx("option",{value:ee,children:p(`access-label-${ee}`)},ee))]})}),E&&(()=>{const ee=wP(me.grants,E),K=ee.filter(ye=>ye.changed).length;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-access-matrix",role:"table","aria-label":p("peer-access-matrix"),children:ee.map(ye=>l.jsxs("div",{role:"row",className:`nc-access-row${ye.changed?" changed":""}`,children:[l.jsx("span",{role:"rowheader",children:p(`access-grant-${ye.key}`)}),l.jsx("span",{children:p(`access-value-${ye.current===!0?"yes":ye.current===!1?"no":String(ye.current)}`)}),l.jsx("span",{"aria-hidden":"true",children:"→"}),l.jsx("span",{children:p(`access-value-${ye.next===!0?"yes":ye.next===!1?"no":String(ye.next)}`)})]},ye.key))}),l.jsx("small",{className:"nc-set-hint",children:p(K===0?"peer-access-unchanged":"peer-access-changed-hint")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||!!d,title:i?p("settings-readonly"):void 0,onClick:()=>lt(E),children:p("peer-access-apply")})]})})()]}),w&&l.jsxs(go,{title:p("edit"),children:[l.jsxs("label",{className:"nc-field",children:[p("node-display-label"),l.jsx("input",{value:w.label,disabled:!!d,onChange:ee=>S({...w,label:ee.target.value})})]}),q.inbound?l.jsxs("label",{className:"nc-field",children:[p("peer-visibility"),l.jsxs("select",{value:w.visibility,disabled:!!d,onChange:ee=>S({...w,visibility:ee.target.value}),children:[l.jsx("option",{value:"network",children:p("visibility-network")}),l.jsx("option",{value:"relay-only",children:p("visibility-relay")}),l.jsx("option",{value:"selected",children:p("visibility-selected")})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"nc-field",children:[p("node-ssh-label"),l.jsx("input",{value:w.ssh,disabled:!!d,onChange:ee=>S({...w,ssh:ee.target.value})})]}),l.jsxs("label",{className:"nc-field",children:[p("node-ssh-port-label"),l.jsx("input",{inputMode:"numeric",value:w.sshPort,disabled:!!d,onChange:ee=>S({...w,sshPort:ee.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:w.autostart,disabled:!!d,onChange:ee=>S({...w,autostart:ee.target.checked})})," ",p("boot-persist")]})]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!d,onClick:ze,children:p("save")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>S(null),children:p("cancel")})]})]}),A&&l.jsxs("div",{className:"nc-set-confirm",children:[l.jsx("b",{children:p("node-remove-confirm").replace("{name}",q.title)}),l.jsx("small",{children:p("node-remove-warning")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn danger",disabled:!!d,onClick:()=>Se(`${t.name}:remove`,async()=>{await j2(n,t.name),C(!1),await s(),a&&a()}),children:p("delete")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>C(!1),children:p("cancel")})]})]}),f&&l.jsx("div",{className:"nc-err",children:f})]})}const Wx="nc_push_local_v1",d0=Object.freeze({enabled:!0});function qx(t){return{enabled:(t&&typeof t=="object"&&!Array.isArray(t)?t:{}).enabled!==!1}}function Ng(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Kx(t=Ng()){if(!t)return{...d0};try{return qx(JSON.parse(t.getItem(Wx)||"null"))}catch{return{...d0}}}function LP(t,e=Ng()){const n=qx(t);if(e)try{e.setItem(Wx,JSON.stringify(n))}catch{}return n}function RP(t=Ng()){return Kx(t).enabled===!1}function Lg(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function AP(t){const e="=".repeat((4-t.length%4)%4),n=(t+e).replace(/-/g,"+").replace(/_/g,"/"),i=atob(n),s=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)s[a]=i.charCodeAt(a);return s}async function MP(){if(!Lg())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function jP(t){if(!Lg())throw new Error("push-unsupported");if(RP())throw new Error("push-disabled-local");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const n=await un("/api/push/vapid",t),{publicKey:i}=await n.json();if(!i)throw new Error("vapid non disponibile");const a=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:AP(i)}),c=await un("/api/push/subscribe",t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:a.toJSON()})});if(!c.ok){try{await a.unsubscribe()}catch{}const d=await c.json().catch(()=>({}));throw new Error(d.error||`HTTP ${c.status}`)}return!0}async function h0(t){if(!Lg())return!1;const n=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!n)return!1;const i=n.endpoint;try{await n.unsubscribe()}catch{}try{await un("/api/push/subscribe",t,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:i})})}catch{}return!0}const Em="nexuscrew.fleet",Vx=3,TP="nexuscrew.cells",Yx=/^[A-Za-z0-9._-]{1,32}$/,Sd=/^[a-z0-9._-]{1,32}$/,Gx=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,Xx=new Set(["standard","unsafe"]),PP=4096,IP=4096,ed=256,Qx=8192,DP=4096,BP=32,OP=64,xu=100,$P=128,zP=new Set(["format","version","exportedAt","cells","engines","models"]),FP=new Set(["id","cwdRel","engine","boot","model","models","permissionPolicies","commands","systemPrompt","prompt","label","mcp"]),HP=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]);function wo(t){if(typeof t!="string"||t.length>IP)return null;for(let n=0;n<t.length;n+=1){const i=t.charCodeAt(n);if(i<=31||i===127||i===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 UP=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag","panelUrl"]),WP=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]),qP=new Set(["127.0.0.1","localhost","[::1]"]);function Rg(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:"||!qP.has(e.hostname))}function lr(t,e){return typeof t=="string"&&t.length<=e&&!/[\x00-\x1f\x7f]/.test(t)}function Ag(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 Fl(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 i={};for(const[s,a]of n){if(!Sd.test(s)||!e(a))return null;i[s]=a}return i}function Jx(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(d=>!FP.has(d))||!Yx.test(String(t.id||""))||typeof t.cwdRel!="string")return null;const e=wo(t.cwdRel);if(e===null||!Sd.test(String(t.engine||""))||t.boot!==void 0&&typeof t.boot!="boolean"||t.model!==void 0&&(typeof t.model!="string"||t.model.length>ed)||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>Qx)return null;const i=Fl(t.models,d=>typeof d=="string"&&!!d&&d.length<=ed),s=Fl(t.permissionPolicies,d=>Xx.has(d)),a=Fl(t.commands,d=>lr(d,DP)&&!Ag(d));if(i===null||s===null||a===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(!lr(t.label,OP)||!String(t.label).trim())return null;c.label=String(t.label).trim()}return Object.keys(i).length&&(c.models=i),Object.keys(s).length&&(c.permissionPolicies=s),Object.keys(a).length&&(c.commands=a),c}function KP(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(a=>!HP.has(a))||!Yx.test(String(t.id||""))||typeof t.cwd!="string"||!t.cwd||t.cwd.length>PP||!Sd.test(String(t.engine||""))||t.boot!==void 0&&typeof t.boot!="boolean"||t.model!==void 0&&(typeof t.model!="string"||t.model.length>ed)||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>Qx)return null;const n=Fl(t.models,a=>typeof a=="string"&&!!a&&a.length<=ed),i=Fl(t.permissionPolicies,a=>Xx.has(a));if(n===null||i===null)return null;const s={id:t.id,cwd:t.cwd,engine:t.engine,boot:t.boot===!0,systemPrompt:e};return t.model&&(s.model=t.model),Object.keys(n).length&&(s.models=n),Object.keys(i).length&&(s.permissionPolicies=i),s}function VP(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(n=>!WP.has(n)))return null;const e={};for(const[n,i]of Object.entries(t)){if(typeof i!="string"||!lr(i,n==="baseUrl"?512:128)||Ag(i))return null;e[n]=i}return!e.client||!e.provider||e.envKey&&!Gx.test(e.envKey)?null:e}function Zx(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(i=>!UP.has(i))||!Sd.test(String(t.id||""))||!lr(t.label||t.id,64)||t.rc!==void 0&&typeof t.rc!="boolean"||t.panelUrl!==void 0&&!Rg(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 i=VP(t.managed);return!i||["command","args","envKeys","model","promptMode","promptFlag"].some(s=>t[s]!==void 0)?null:(e.managed=i,e)}if(!lr(t.command,512)||!t.command.startsWith("/")||!Array.isArray(t.args)||t.args.length>32||t.args.some(i=>!lr(i,1024)||Ag(i))||t.promptMode!=="flag"&&t.promptMode!=="send-keys"||t.promptMode==="flag"&&(!lr(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(i=>i!=="flag"&&i!=="value")||!lr(t.model.flag,32)||/\s/.test(t.model.flag)||!lr(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(i=>!Gx.test(i))?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 eC(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=Zx(e);return n||null}function YP(t,e,n){const i=new Set;for(const s of Array.isArray(e)?e:[]){if(!n.has(s.id)||!s.managed)continue;const{client:a,provider:c,credentialProfile:d}=s.managed;i.add(d?`${a}.${c}-${d}`:`${a}.${c}`),i.add(`${a}.${c}`)}return(Array.isArray(t)?t:[]).filter(s=>s&&i.has(s.engine))}function GP(t,e,n=[],i=[],s=new Date,a=[]){n instanceof Date&&(s=n,n=[],i=[]);const c=e instanceof Set?e:new Set(e||[]),d=i instanceof Set?i:new Set(i||[]),h=[];for(const _ of Array.isArray(t)?t:[]){if(!c.has(_.id))continue;const y=Jx({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(!y)return{ok:!1,error:"invalid-cell",invalidCellIds:[_.id]};h.push(y)}const f=[];for(const _ of Array.isArray(n)?n:[]){if(!d.has(_.id))continue;const y=eC(_);y&&f.push(y)}const g=YP(a,n,d);return{format:Em,version:Vx,exportedAt:s.toISOString(),cells:h,engines:f,...g.length?{models:g}:{}}}function XP(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)===TP&&(e==null?void 0:e.version)===1,i=(e==null?void 0:e.format)===Em&&(e==null?void 0:e.version)===2,s=(e==null?void 0:e.format)===Em&&(e==null?void 0:e.version)===Vx,a=n||i,c=i||s;if(c&&Array.isArray(e.engines)&&e.engines.length>xu)return{ok:!1,error:"invalid-format",detail:`${e.engines.length} engine dichiarati, cap ${xu}; riduci gli engine a ${xu} o meno`,cells:[],engines:[]};if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(y=>!zP.has(y))||!n&&!i&&!s||!Array.isArray(e.cells)||e.cells.length>BP||c&&(!Array.isArray(e.engines)||e.engines.length>xu))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const d=[],h=new Set;for(const y of e.cells){const w=a?KP(y):Jx(y);if(!w)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(h.has(w.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};h.add(w.id),d.push(w)}const f=[],g=new Set;for(const y of c?e.engines:[]){const w=Zx(y);if(!w)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(g.has(w.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};g.add(w.id),f.push(w)}const _=[];if(e.models!==void 0){if(!Array.isArray(e.models)||e.models.length>$P)return{ok:!1,error:"invalid-model",cells:[],engines:[]};const y=new Set;for(const w of e.models){if(!w||typeof w!="object"||Array.isArray(w))return{ok:!1,error:"invalid-model",cells:[],engines:[]};const S=new Set(["id","engine","label","contextWindow","maxTokens","reasoning"]);if(Object.keys(w).some(k=>!S.has(k)))return{ok:!1,error:"invalid-model",cells:[],engines:[]};const A=typeof w.id=="string"?w.id.trim():"",C=typeof w.engine=="string"?w.engine.trim():"";if(!A||!C)return{ok:!1,error:"invalid-model",cells:[],engines:[]};const N=`${C}::${A}`;if(y.has(N))return{ok:!1,error:"duplicate-model",cells:[],engines:[]};y.add(N),_.push({...w,id:A,engine:C})}}return{ok:!0,cells:d,engines:f,models:_,legacy:a,exportedAt:typeof e.exportedAt=="string"?e.exportedAt:""}}function QP(t,e,n){const i=new Set(n||[]);if(!i.has(e))return null;const s=f=>Object.fromEntries(Object.entries(f||{}).filter(([g])=>i.has(g))),a={id:t.id,engine:e,boot:t.boot===!0,prompt:t.systemPrompt||""};typeof t.label=="string"&&t.label&&(a.label=t.label),typeof t.cwdRel=="string"?a.cwdRel=t.cwdRel:typeof t.cwd=="string"&&t.cwd&&(a.cwd=t.cwd),e===t.engine&&t.model?a.model=t.model:t.models&&t.models[e]&&(a.model=t.models[e]);const c=s(t.models),d=s(t.permissionPolicies),h=s(t.commands);return Object.keys(c).length&&(a.models=c),Object.keys(d).length&&(a.permissionPolicies=d),Object.keys(h).length&&(a.commands=h),a}const JP=()=>({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:""}),f0=(t="")=>({id:"",cwd:"",engine:t,boot:!1,label:"",model:"",prompt:"",commands:{},command:"",panelUrl:""}),tC=t=>t==="claude"?"unsafe":"standard",Ql=(t,e)=>t.find(n=>n.client===e.client&&n.provider===e.provider&&(n.credentialProfile||"")===(e.credentialProfile||"")),ZP=(t,e)=>{var n;return((n=Ql(t,e))==null?void 0:n.label)||`${e.client} · ${e.provider}`};function eI(t){var e,n,i,s,a,c,d,h,f,g,_,y,w,S,A;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:((i=t.managed)==null?void 0:i.credentialProfile)||"",managedModel:((s=t.managed)==null?void 0:s.model)||"",permissionPolicy:((a=t.managed)==null?void 0:a.permissionPolicy)||tC((c=t.managed)==null?void 0:c.client),credentialSourcePolicy:((d=t.managed)==null?void 0:d.credentialSourcePolicy)||"auto",displayName:((h=t.managed)==null?void 0:h.displayName)||"",protocol:((f=t.managed)==null?void 0:f.protocol)||"",baseUrl:((g=t.managed)==null?void 0:g.baseUrl)||"",envKey:((_=t.managed)==null?void 0:_.envKey)||"",providerId:((y=t.managed)==null?void 0:y.providerId)||"nexuscrew-custom",modelOptions:t.availableModels||((w=t.managedInfo)==null?void 0:w.models)||[],promptMode:t.promptMode||"send-keys",promptFlag:t.promptFlag||"",modelFlag:((S=t.model)==null?void 0:S.flag)||"",modelValue:((A=t.model)==null?void 0:A.value)||"",envRows:(t.envKeys||[]).map(C=>({key:C,value:"",configured:!0,remove:!1})),credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,panelUrl:t.panelUrl||""}}function p0(t,e,n){const i=(e.panelUrl||"").trim();return n?i&&(t.panelUrl=i):t.panelUrl=i||null,t}function tI(t,e,n=[]){if(t.kind==="managed"){const s={client:t.client,provider:t.provider,model:t.client==="shell"?"":t.managedModel||"",permissionPolicy:t.client==="shell"?"standard":t.permissionPolicy||tC(t.client)};t.credentialProfile&&(s.credentialProfile=t.credentialProfile),t.credentialSourcePolicy&&t.credentialSourcePolicy!=="auto"&&(s.credentialSourcePolicy=t.credentialSourcePolicy);const a=Ql(n,t);return(a==null?void 0:a.credentialEnv)===!0&&(s.envKey=t.envKey),t.provider==="custom"&&Object.assign(s,{displayName:t.displayName,protocol:t.protocol,baseUrl:t.baseUrl,envKey:t.envKey,providerId:t.providerId}),p0({...e?{id:t.id}:{},label:t.label||ZP(n,t),rc:!!t.rc,managed:s},t,e)}const i={...e?{id:t.id}:{},label:t.label||t.id,rc:!!t.rc,command:t.command,args:t.argsText.split(`
|
|
166
|
-
`).filter(s=>s!==""),promptMode:t.promptMode};return t.modelFlag&&(i.model={flag:t.modelFlag,value:t.modelValue||""}),t.promptMode==="flag"&&(i.promptFlag=t.promptFlag),e&&(i.env=Object.fromEntries(t.envRows.filter(s=>!s.remove&&s.key).map(s=>[s.key,s.value]))),p0(i,t,e)}function $r({children:t,onClose:e,label:n,error:i=""}){const s=b.useRef(null),a=b.useRef(null),c=b.useRef(e);return c.current=e,b.useEffect(()=>{const d=document.activeElement,h=s.current,f=()=>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(y=>y.offsetParent!==null),g=requestAnimationFrame(()=>{var y;return(y=f()[0]||h)==null?void 0:y.focus({preventScroll:!0})}),_=y=>{var C;if(y.key==="Escape"){y.preventDefault(),(C=c.current)==null||C.call(c);return}if(y.key!=="Tab")return;const w=f();if(!w.length){y.preventDefault(),h==null||h.focus();return}const S=w[0],A=w[w.length-1];y.shiftKey&&document.activeElement===S?(y.preventDefault(),A.focus()):!y.shiftKey&&document.activeElement===A&&(y.preventDefault(),S.focus())};return document.addEventListener("keydown",_),()=>{cancelAnimationFrame(g),document.removeEventListener("keydown",_),d&&d.isConnected&&typeof d.focus=="function"&&d.focus({preventScroll:!0})}},[]),b.useEffect(()=>{i&&requestAnimationFrame(()=>{var d;return(d=a.current)==null?void 0:d.scrollIntoView({block:"nearest"})})},[i]),l.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:d=>{d.target===d.currentTarget&&e()},children:l.jsxs("div",{ref:s,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":n||p("settings"),tabIndex:-1,children:[t,i&&l.jsx("div",{ref:a,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:i})]})})}function cp({token:t,targets:e=[],readonly:n=!1,onPower:i,onImport:s}){const[a,c]=b.useState([]),[d,h]=b.useState(0);b.useEffect(()=>{let C=!0;async function N(){const O=[{route:[],label:p("local")}].concat((e||[]).map(H=>({route:Array.isArray(H.route)?H.route:[],label:H.label||(H.route||[]).join(" › ")}))),P=await Promise.all(O.map(async H=>{const W={...H,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const U=await fr(t,H.route);W.available=!!U.available,W.capabilities=U.capabilities||[],W.provider=U.provider||null,W.cells=(U.cells||[]).map(G=>({...G,route:H.route}));try{W.readonly=!!(await Om(t,H.route)).readonlyDefault}catch{}try{const G=await Bm(t,H.route),X=new Set(W.cells.map(Q=>Q.tmuxSession).filter(Boolean));W.unmanaged=(G.sessions||[]).filter(Q=>Q&&!X.has(Q.name))}catch{}}catch(U){W.err=String(U&&U.message||U)}return W}));C&&c(P)}N();const k=setInterval(N,6e3);return()=>{C=!1,clearInterval(k)}},[t,e,d]);const f=(C,N)=>Array.isArray(C.capabilities)&&C.capabilities.includes(N)&&!n&&!C.readonly,g=()=>h(C=>C+1),_=(C,N)=>{i&&i({...C,route:N})},y=(C,N)=>{i&&i({...C,route:N})},w=async(C,N)=>{try{await Ll(t,C.cell,N)}catch{}g()},S=async(C,N)=>{if(window.confirm(p("fleet-remove-cell").replace("{id}",C.cell))){try{await U0(t,C.cell,!0,N)}catch{}g()}},A=async(C,N)=>{if(window.confirm(p("terminate-confirm").replace("{name}",C.name))){try{await Im(t,C.name,N)}catch{}g()}};return l.jsxs("div",{className:"nc-fleet-inventory",children:[l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:p("fleet-inventory")}),l.jsx("small",{children:p("fleet-inventory-help")})]}),a.map(C=>{const N=C.route.length?C.route.join("/"):"local";return l.jsxs("div",{className:"nc-fleet-pos",children:[l.jsxs("div",{className:"nc-fleet-pos-title",children:[l.jsx("span",{className:`dot ${C.available?"on":"warn"}`}),l.jsx("b",{children:C.label}),l.jsx("small",{children:C.available?`${C.cells.length} ${p("fleet-cells")} · ${C.unmanaged.length} ${p("fleet-tmux")}`:C.err||p("fleet-not-available")})]}),C.cells.map(k=>l.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[l.jsxs("span",{children:[l.jsx("b",{children:k.cell}),l.jsx("small",{children:`${k.engine||""}${k.key?`·${k.key}`:""}${k.active?"":` · ${p("cell-off")}`}`})]}),l.jsxs("span",{className:"nc-fleet-cell-actions",children:[k.active&&f(C,"down")&&l.jsx("button",{className:"nc-btn ghost",title:p("power-off"),onClick:()=>y(k,C.route),children:p("stop")}),!k.active&&f(C,"up")&&l.jsx("button",{className:"nc-btn ghost",title:p("power-on"),onClick:()=>_(k,C.route),children:p("start")}),f(C,"restart")&&k.active&&l.jsx("button",{className:"nc-btn ghost",title:p("restart"),onClick:()=>w(k,C.route),children:p("restart")}),f(C,"remove")&&l.jsx("button",{className:"nc-btn danger",title:p("delete"),onClick:()=>S(k,C.route),children:"×"})]})]},`${N}:${k.cell}`)),C.unmanaged.map(k=>l.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[l.jsxs("span",{children:[l.jsx("b",{children:k.name}),l.jsx("small",{children:p("fleet-tmux")})]}),l.jsxs("span",{className:"nc-fleet-cell-actions",children:[f(C,"import")&&s&&l.jsx("button",{className:"nc-btn ghost",title:p("import-as-cell"),onClick:()=>s(k,C.route),children:p("import-as-cell")}),l.jsx("button",{className:"nc-btn danger",title:p("terminate"),onClick:()=>A(k,C.route),children:"×"})]})]},`${N}:u:${k.name}`)),C.available&&C.cells.length===0&&C.unmanaged.length===0&&l.jsx("div",{className:"nc-empty",children:p("fleet-inventory-empty")})]},N)})]})}function nI({cells:t=[],engines:e=[],models:n=[],busy:i,canRestore:s=!1,onRestore:a,onClose:c}){const[d,h]=b.useState("export"),[f,g]=b.useState([]),[_,y]=b.useState(()=>new Set(t.map(M=>M.id))),[w,S]=b.useState(()=>new Set(e.map(M=>M.id))),[A,C]=b.useState([]),[N,k]=b.useState([]),[O,P]=b.useState(""),H=new Set(e.map(M=>M.id)),W=new Set(t.map(M=>M.id)),U=(M,L)=>M(R=>{const E=new Set(R);return E.has(L)?E.delete(L):E.add(L),E}),G=()=>{const M=GP(t,_,e,w,new Date,n);if(M.ok===!1){P(p(`fleet-backup-${M.error}`));return}const L=t.filter(q=>_.has(q.id)).length,R=e.filter(q=>w.has(q.id)).length;if(M.cells.length!==L){P(p("fleet-backup-invalid-cell"));return}if(M.engines.length!==R){P(p("fleet-backup-invalid-engine"));return}if(!M.cells.length&&!M.engines.length){P(p("fleet-backup-select-one"));return}const E=new Blob([`${JSON.stringify(M,null,2)}
|
|
167
|
-
`],{type:"application/json"}),z=URL.createObjectURL(E),D=document.createElement("a");D.href=z,D.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(D),D.click(),D.remove(),setTimeout(()=>URL.revokeObjectURL(z),0),P("")},X=async M=>{if(P(""),C([]),k([]),!!M){if(M.size>1024*1024){P(p("fleet-backup-too-large"));return}try{const L=XP(await M.text());if(!L.ok){P(p(`fleet-backup-${L.error}`));return}g(Array.isArray(L.models)?L.models:[]);const R=new Set(L.engines.map(E=>E.id));k(L.engines.map(E=>({engine:E,exists:H.has(E.id),selected:!H.has(E.id)}))),C(L.cells.map(E=>{const z=H.has(E.engine)||R.has(E.engine),D=W.has(E.id);return{cell:E,engine:z?E.engine:"",selected:z&&!D,exists:D}}))}catch(L){P(String(L.message||L))}}},Q=(M,L)=>C(R=>R.map((E,z)=>z===M?{...E,...L}:E)),V=(M,L)=>k(R=>R.map((E,z)=>z===M?{...E,...L}:E)),T=new Set([...H,...N.filter(M=>M.selected).map(M=>M.engine.id)]),I=A.filter(M=>M.selected&&M.engine&&T.has(M.engine)),$=N.filter(M=>M.selected),j=[...new Map([...e.map(M=>[M.id,M.label||M.id]),...N.filter(M=>M.selected).map(M=>[M.engine.id,M.engine.label||M.engine.id])]).entries()];return l.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[l.jsx("b",{children:p("fleet-backup")}),l.jsx("small",{children:p("fleet-backup-help")}),l.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[l.jsx("button",{type:"button",className:`nc-set-tabbtn${d==="export"?" on":""}`,onClick:()=>{h("export"),P("")},children:p("fleet-backup-export")}),l.jsx("button",{type:"button",className:`nc-set-tabbtn${d==="import"?" on":""}`,disabled:!s,title:s?"":p("fleet-backup-restore-unavailable"),onClick:()=>{h("import"),P("")},children:p("fleet-backup-import")})]}),d==="export"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{y(new Set(t.map(M=>M.id))),S(new Set(e.map(M=>M.id)))},children:p("select-all")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{y(new Set),S(new Set)},children:p("select-none")})]}),l.jsxs("div",{className:"nc-backup-list",children:[l.jsx("b",{children:p("fleet-engines")}),e.map(M=>{var L;return l.jsxs("label",{className:"nc-check nc-backup-row",children:[l.jsx("input",{type:"checkbox",checked:w.has(M.id),onChange:()=>U(S,M.id)}),l.jsxs("span",{children:[l.jsx("b",{children:M.label||M.id}),l.jsxs("small",{children:[M.id,(L=M.envKeys)!=null&&L.length?` · ${M.envKeys.length} ${p("fleet-backup-env-names")}`:""]})]})]},M.id)}),l.jsx("b",{children:p("fleet-cells")}),t.map(M=>l.jsxs("label",{className:"nc-check nc-backup-row",children:[l.jsx("input",{type:"checkbox",checked:_.has(M.id),onChange:()=>U(y,M.id)}),l.jsxs("span",{children:[l.jsx("b",{children:M.id}),l.jsxs("small",{children:[M.engine," · ",p("fleet-system-prompt")," ",(M.prompt||"").length," ",p("characters")]})]})]},M.id)),!t.length&&!e.length&&l.jsx("div",{className:"nc-empty",children:p("fleet-backup-empty")})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:c,children:p("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!_.size&&!w.size,onClick:G,children:p("fleet-backup-download")})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{type:"file",accept:"application/json,.json",disabled:i,onChange:M=>X(M.target.files&&M.target.files[0])}),l.jsx("small",{children:p("fleet-backup-import-help")}),!!(A.length||N.length)&&l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{k(M=>M.map(L=>({...L,selected:!0}))),C(M=>M.map(L=>({...L,selected:!!L.engine})))},children:p("select-all")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{k(M=>M.map(L=>({...L,selected:!1}))),C(M=>M.map(L=>({...L,selected:!1})))},children:p("select-none")})]}),l.jsxs("div",{className:"nc-backup-list",children:[!!N.length&&l.jsx("b",{children:p("fleet-engines")}),N.map((M,L)=>{var R;return l.jsx("div",{className:"nc-backup-import-row",children:l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:M.selected,onChange:E=>V(L,{selected:E.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:M.engine.label||M.engine.id}),l.jsxs("small",{children:[M.engine.id," · ",M.exists?p("fleet-backup-overwrite"):p("fleet-backup-new"),(R=M.engine.envKeys)!=null&&R.length?` · ${p("fleet-backup-env-values-required")}`:""]})]})]})},M.engine.id)}),!!A.length&&l.jsx("b",{children:p("fleet-cells")}),A.map((M,L)=>l.jsxs("div",{className:"nc-backup-import-row",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:M.selected,disabled:!M.engine||!T.has(M.engine),onChange:R=>Q(L,{selected:R.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:M.cell.id}),l.jsxs("small",{children:[M.exists?p("fleet-backup-overwrite"):p("fleet-backup-new")," · ",p("fleet-system-prompt")," ",M.cell.systemPrompt.length," ",p("characters")]})]})]}),l.jsxs("select",{value:M.engine,onChange:R=>Q(L,{engine:R.target.value,selected:!!R.target.value}),children:[l.jsx("option",{value:"",children:p("fleet-backup-engine-missing")}),j.map(([R,E])=>l.jsx("option",{value:R,children:E},R))]})]},M.cell.id))]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:c,children:p("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||!I.length&&!$.length,onClick:()=>a({engineRows:N,cellRows:A,models:f}),children:p("fleet-backup-restore")})]})]}),O&&l.jsx("div",{className:"nc-err",children:O})]})}function iI({state:t,setState:e,busy:n,onSave:i,catalog:s}){var N;const a=t.form,c=k=>e({...t,form:{...a,...k}}),d=a.envRows||[],h=[...new Map(s.map(k=>[k.client,k.clientLabel||k.client])).entries()],f=s.filter(k=>k.client===a.client),g=Ql(s,a),_=typeof(g==null?void 0:g.credentialEnv)=="string"?g.credentialEnv:"",y=Array.isArray(g==null?void 0:g.credentialUsedBy)?g.credentialUsedBy:[],w=(g==null?void 0:g.credentialSource)||"missing",S=!!(g!=null&&g.credentialEnv)||a.credentialProfile==="a"||a.credentialProfile==="p",A=!!_&&t.mode==="new"&&(g==null?void 0:g.authConfigured)!==!0&&!a.credentialValue&&!a.allowMissingCredential,C=k=>{k&&c({client:k.client,provider:k.provider,credentialProfile:k.credentialProfile||"",managedModel:k.model||"",protocol:k.protocol||"",permissionPolicy:k.permissionPolicyDefault||"standard",credentialSourcePolicy:"auto",rc:!!k.rc,displayName:k.custom?p("fleet-custom-provider-default"):"",baseUrl:k.custom?"":k.endpoint||"",envKey:k.defaultEnvKey||"",providerId:"nexuscrew-custom",credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,...t.mode==="new"?{id:k.id,label:""}:{}})};return l.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[l.jsx("b",{children:t.mode==="new"?p("fleet-new-engine"):`${p("edit")} ${a.id}`}),l.jsx("input",{value:a.id,disabled:t.mode!=="new",placeholder:"id",onChange:k=>c({id:k.target.value})}),l.jsx("input",{value:a.label,placeholder:p("label"),onChange:k=>c({label:k.target.value})}),l.jsxs("select",{value:a.kind,disabled:t.mode!=="new",onChange:k=>c({kind:k.target.value}),children:[l.jsx("option",{value:"managed",children:p("fleet-managed")}),l.jsx("option",{value:"custom",children:p("fleet-custom")})]}),a.kind==="managed"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("select",{value:a.client,disabled:t.mode!=="new",onChange:k=>C(s.find(O=>O.client===k.target.value&&O.default)||s.find(O=>O.client===k.target.value)),children:h.map(([k,O])=>l.jsx("option",{value:k,children:O},k))}),l.jsx("select",{value:((N=Ql(s,a))==null?void 0:N.id)||"",disabled:t.mode!=="new",onChange:k=>C(s.find(O=>O.id===k.target.value)),children:f.map(k=>l.jsx("option",{value:k.id,children:k.label},k.id))})]}),a.client!=="shell"&&l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.managedModel,list:"nc-managed-models",placeholder:p(g!=null&&g.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:k=>c({managedModel:k.target.value})}),l.jsx("datalist",{id:"nc-managed-models",children:[...(g==null?void 0:g.models)||[],...a.modelOptions||[]].filter((k,O,P)=>k&&P.indexOf(k)===O).map(k=>l.jsx("option",{value:k},k))})]}),g!=null&&g.supportsUnsafe?l.jsxs("select",{value:a.permissionPolicy,onChange:k=>c({permissionPolicy:k.target.value}),children:[l.jsx("option",{value:"standard",children:p("fleet-standard-permissions")}),l.jsx("option",{value:"unsafe",children:p("fleet-unsafe-permissions")})]}):l.jsx("small",{children:p("fleet-standard-permissions")}),(g==null?void 0:g.supportsUnsafe)&&a.permissionPolicy==="unsafe"&&l.jsx("small",{className:"nc-err",children:p("fleet-unsafe-warning")}),S&&l.jsxs("select",{"aria-label":p("fleet-credential-source-policy"),value:a.credentialSourcePolicy||"auto",onChange:k=>c({credentialSourcePolicy:k.target.value}),children:[l.jsx("option",{value:"auto",children:p("fleet-credential-source-policy-auto")}),l.jsx("option",{value:"nexuscrew-store",children:p("fleet-credential-source-policy-nexuscrew-store")}),l.jsx("option",{value:"environment",children:p("fleet-credential-source-policy-environment")})]}),(g==null?void 0:g.credentialEnv)===!0&&l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.envKey,placeholder:p("fleet-api-key-env"),onChange:k=>c({envKey:k.target.value})}),l.jsx("small",{children:p("fleet-custom-secret-help")})]}),_&&l.jsxs("section",{className:"nc-fleet-key","aria-label":p("fleet-key-section"),children:[l.jsxs("div",{className:"nc-fleet-key-head",children:[l.jsx("b",{children:p("fleet-key-section")}),l.jsx("span",{children:p(`fleet-credential-source-${w}`)})]}),l.jsxs("label",{className:"nc-field",children:[p("fleet-key-variable"),l.jsx("input",{value:_,readOnly:!0,"aria-label":p("fleet-key-variable")})]}),l.jsx("small",{children:y.length?p("fleet-key-used-by").replace("{engines}",y.join(", ")):p("fleet-key-used-by-none")}),y.length>0&&l.jsx("small",{children:p("fleet-key-shared-impact").replace("{key}",_).replace("{engines}",y.join(", "))}),l.jsxs("div",{className:"nc-fleet-key-input",children:[l.jsx("input",{type:a.credentialReveal?"text":"password",value:a.credentialValue||"","aria-label":p("fleet-key-value").replace("{key}",_),autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:g!=null&&g.authConfigured||t.mode==="edit"?p("fleet-key-blank-keeps"):p("fleet-key-enter"),onChange:k=>c({credentialValue:k.target.value,allowMissingCredential:k.target.value?!1:a.allowMissingCredential})}),l.jsx("button",{type:"button",className:"nc-btn ghost","aria-label":p(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal"),onClick:()=>c({credentialReveal:!a.credentialReveal}),children:p(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal")})]}),l.jsx("small",{children:p("fleet-key-local-help")}),t.mode==="new"&&(g==null?void 0:g.authConfigured)!==!0&&!a.credentialValue&&l.jsxs("label",{className:"nc-check nc-fleet-key-missing",children:[l.jsx("input",{type:"checkbox",checked:!!a.allowMissingCredential,onChange:k=>c({allowMissingCredential:k.target.checked})}),p("fleet-key-create-missing")]}),(g==null?void 0:g.notice)&&l.jsx("small",{className:"nc-fleet-provider-notice",children:p(`fleet-provider-notice-${g.notice}`)})]}),(g==null?void 0:g.notice)&&!_&&l.jsx("small",{className:"nc-fleet-provider-notice",children:p(`fleet-provider-notice-${g.notice}`)}),a.provider==="custom"&&l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.displayName,placeholder:p("fleet-provider-display"),onChange:k=>c({displayName:k.target.value})}),l.jsx("input",{value:a.baseUrl,placeholder:"https://api.example.com/v1",onChange:k=>c({baseUrl:k.target.value})}),((g==null?void 0:g.protocols)||[]).length>1&&l.jsx("select",{value:a.protocol,onChange:k=>c({protocol:k.target.value}),children:g.protocols.map(k=>l.jsx("option",{value:k,children:k},k))}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:a.envKey,placeholder:p("fleet-api-key-env"),onChange:k=>c({envKey:k.target.value})}),l.jsx("input",{value:a.providerId,placeholder:p("fleet-provider-id"),onChange:k=>c({providerId:k.target.value})})]}),l.jsxs("small",{children:[a.protocol," · ",p("fleet-custom-secret-help")]})]}),l.jsx("small",{children:p(a.client==="shell"?"fleet-shell-engine-help":"fleet-managed-help")})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.command,placeholder:p("command-path"),onChange:k=>c({command:k.target.value})}),l.jsx("textarea",{value:a.argsText,placeholder:p("args-lines"),onChange:k=>c({argsText:k.target.value})}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:a.rc,onChange:k=>c({rc:k.target.checked})})," ",p("fleet-remote-control")]}),l.jsxs("select",{value:a.promptMode,onChange:k=>c({promptMode:k.target.value}),children:[l.jsx("option",{value:"send-keys",children:"send-keys"}),l.jsx("option",{value:"flag",children:"flag"})]}),a.promptMode==="flag"&&l.jsx("input",{value:a.promptFlag,placeholder:"prompt flag",onChange:k=>c({promptFlag:k.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:a.modelFlag,placeholder:"model flag",onChange:k=>c({modelFlag:k.target.value})}),l.jsx("input",{value:a.modelValue,placeholder:"model default",onChange:k=>c({modelValue:k.target.value})})]}),l.jsx("small",{children:p("env-write-only")}),d.map((k,O)=>l.jsxs("div",{className:"nc-fleet-env",children:[l.jsx("input",{value:k.key,disabled:k.configured,placeholder:"ENV_KEY",onChange:P=>{const H=d.slice();H[O]={...k,key:P.target.value},c({envRows:H})}}),l.jsx("input",{type:"password",value:k.value,placeholder:k.configured?"•••••• (unchanged)":"value",onChange:P=>{const H=d.slice();H[O]={...k,value:P.target.value},c({envRows:H})}}),l.jsx("button",{className:"nc-btn danger",onClick:()=>c({envRows:d.filter((P,H)=>H!==O)}),children:"×"})]},`${k.key}-${O}`)),l.jsx("button",{className:"nc-btn ghost",onClick:()=>c({envRows:[...d,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),l.jsx("input",{value:a.panelUrl||"",maxLength:512,placeholder:p("fleet-panel-url"),onChange:k=>c({panelUrl:k.target.value})}),l.jsx("small",{children:p("fleet-panel-url-help")}),a.panelUrl&&!Rg(a.panelUrl)&&l.jsx("small",{className:"nc-err",children:p("fleet-panel-url-invalid")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>e(null),children:p("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:n||!a.id||A||a.kind==="custom"&&!a.command||a.kind==="managed"&&(g==null?void 0:g.requiresModel)&&!a.managedModel||a.kind==="managed"&&(g==null?void 0:g.credentialEnv)===!0&&!a.envKey||a.kind==="managed"&&a.provider==="custom"&&(!a.displayName||!a.baseUrl||!a.envKey||!a.providerId),onClick:i,children:p("save")})]})]})}function sI({state:t,setState:e,busy:n,onSave:i,onTest:s,profiles:a=[],canTest:c=!0}){const[d,h]=b.useState(null),[f,g]=b.useState(!1),_=t.form,y=C=>e({...t,form:{..._,...C}}),w=/^[^\x00-\x1f\x7f]{1,128}$/.test(_.id||""),S=!!(_.id||"").trim()&&!!(_.engine||"").trim()&&w,A=async()=>{h(null),g(!0);try{h(await s(_.engine,_.id))}catch(C){h({outcome:"unverified",detail:String(C&&C.message||C)})}g(!1)};return l.jsxs("div",{className:"nc-fleet-form",children:[l.jsxs("label",{className:"nc-field",children:[p("model-editor-engine"),l.jsxs("select",{value:_.engine||"",disabled:n||t.mode==="edit",onChange:C=>{h(null),y({engine:C.target.value})},children:[l.jsx("option",{value:"",children:"—"}),a.map(C=>l.jsx("option",{value:C.id,children:C.label?`${C.id} · ${C.label}`:C.id},C.id))]})]}),l.jsxs("label",{className:"nc-field",children:[p("model-editor-id"),l.jsx("input",{value:_.id||"",disabled:n||t.mode==="edit",placeholder:"qwen3.9-max",onChange:C=>{h(null),y({id:C.target.value})}})]}),l.jsx("small",{className:"nc-set-hint",children:p("model-editor-id-help")}),l.jsxs("label",{className:"nc-field",children:[p("model-editor-context"),l.jsx("input",{inputMode:"numeric",value:_.contextWindow||"",disabled:n,onChange:C=>y({contextWindow:C.target.value.replace(/[^0-9]/g,"").slice(0,9)})})]}),l.jsxs("label",{className:"nc-field",children:[p("model-editor-max-tokens"),l.jsx("input",{inputMode:"numeric",value:_.maxTokens||"",disabled:n,onChange:C=>y({maxTokens:C.target.value.replace(/[^0-9]/g,"").slice(0,9)})})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:_.reasoning===!0,disabled:n,onChange:C=>y({reasoning:C.target.checked})})," ",p("model-editor-reasoning")]}),l.jsxs("div",{className:"nc-set-row",children:[c&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||f||!S,onClick:A,children:p(f?"model-test-running":"model-test")}),d&&l.jsxs("span",{className:`nc-model-test ${d.outcome}`,children:[p(`model-test-${d.outcome}`),d.outcome==="ok"&&Number.isInteger(d.latencyMs)?` · ${d.latencyMs}ms`:""]})]}),d&&d.detail&&l.jsx("small",{className:"nc-set-hint",children:d.detail}),d&&d.outcome==="unverified"&&l.jsx("small",{className:"nc-set-hint",children:p("model-test-unverified-help")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>e(null),children:p("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||!S,onClick:()=>i(_),children:p("save")})]})]})}function rI({token:t,route:e,targets:n=[],location:i,setLocation:s,state:a,setState:c,engines:d,mcpServers:h=[],managedCatalog:f=[],busy:g,onSave:_}){var $,j,M;const[y,w]=b.useState(null),[S,A]=b.useState(""),C=a.form,N=L=>c({...a,form:{...C,...L}}),k=d.find(L=>L.id===C.engine),O=(($=k==null?void 0:k.managed)==null?void 0:$.client)==="shell",P=((j=k==null?void 0:k.managed)==null?void 0:j.client)||"",H=((M=f.find(L=>L.client===P))==null?void 0:M.mcpManaged)!==!1,W=L=>{var z,D,q,ce;const R=d.find(ge=>ge.id===L),E={...C.commands||{}};((z=k==null?void 0:k.managed)==null?void 0:z.client)==="shell"&&(C.command?E[C.engine]=C.command:delete E[C.engine]),N({engine:L,model:((D=C.models)==null?void 0:D[L])||((q=R==null?void 0:R.managed)==null?void 0:q.model)||((ce=R==null?void 0:R.model)==null?void 0:ce.value)||"",commands:E,command:E[L]||""})},U=L=>{const R={...C.commands||{}};L?R[C.engine]=L:delete R[C.engine],N({command:L,commands:R})},G=O&&/[|&;<>()`$*?{}\[\]~]/.test(C.command||""),X=[...new Set([...h||[],...Array.isArray(C.mcp)?C.mcp:[]])].sort(),Q=Array.isArray(C.mcp)?C.mcp.length?"some":"none":"all",V=L=>{var R;return N({mcp:L==="all"?void 0:L==="none"?[]:(R=C.mcp)!=null&&R.length?C.mcp:[...X]})},T=L=>{const R=Array.isArray(C.mcp)?C.mcp:[];N({mcp:R.includes(L)?R.filter(E=>E!==L):[...R,L].sort()})},I=async L=>{try{const R=await Dm(t,L,e);w(R),N({cwd:R.path}),A("")}catch(R){A(String(R.message||R))}};return l.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[l.jsx("b",{children:a.mode==="new"?p("fleet-new-cell"):`${p("edit")} ${C.id}`}),a.mode==="new"&&l.jsxs("label",{className:"nc-field",children:[p("location"),l.jsx("span",{className:"nc-req",children:" *"}),l.jsxs("select",{value:i,onChange:L=>{s(L.target.value),N({engine:""})},children:[l.jsx("option",{value:"",children:p("local")}),n.map(L=>l.jsxs("option",{value:L.route.join("/"),disabled:L.status&&L.status!=="up",children:[L.label,L.status&&L.status!=="up"?` · ${p("node-offline")}`:""]},L.route.join("/")))]})]}),l.jsx("input",{value:C.id,disabled:a.mode!=="new",placeholder:"id",onChange:L=>N({id:L.target.value})}),l.jsx("input",{value:C.label||"",maxLength:64,placeholder:p("fleet-cell-label"),onChange:L=>N({label:L.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:C.cwd,placeholder:p("cwd"),onChange:L=>N({cwd:L.target.value})}),l.jsx("button",{className:"nc-btn ghost",onClick:()=>y?w(null):I(C.cwd),children:p("browse")})]}),y&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:y.path}),l.jsxs("div",{className:"nc-fs-list",children:[y.parent&&l.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>I(y.parent),children:["↑ ",p("fs-parent")]}),(y.dirs||[]).map(L=>l.jsxs("button",{className:"nc-fs-item",onClick:()=>I(`${y.path.replace(/\/$/,"")}/${L}`),children:["📁 ",L]},L))]})]}),S&&l.jsx("div",{className:"nc-err",children:S}),l.jsx("select",{value:C.engine,onChange:L=>W(L.target.value),children:d.map(L=>l.jsx("option",{value:L.id,children:L.label},L.id))}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:!!C.boot,onChange:L=>N({boot:L.target.checked})})," ",p("fleet-boot")]}),l.jsx("input",{value:C.panelUrl||"",maxLength:512,placeholder:p("fleet-panel-url"),onChange:L=>N({panelUrl:L.target.value})}),l.jsx("small",{children:p("fleet-panel-url-help")}),C.panelUrl&&!Rg(C.panelUrl)&&l.jsx("small",{className:"nc-err",children:p("fleet-panel-url-invalid")}),O?l.jsxs(l.Fragment,{children:[l.jsx("input",{value:C.command||"",maxLength:4096,placeholder:p("fleet-shell-command-placeholder"),onChange:L=>U(L.target.value)}),l.jsx("small",{children:C.command?p("fleet-shell-command-help"):p("fleet-shell-interactive")}),G&&l.jsx("small",{className:"nc-note",children:p("fleet-shell-command-metachar")})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{value:C.model||"",list:"nc-cell-models",placeholder:p("fleet-model-override"),onChange:L=>N({model:L.target.value})}),l.jsx("datalist",{id:"nc-cell-models",children:((k==null?void 0:k.availableModels)||[]).map(L=>l.jsx("option",{value:L},L))}),l.jsx("textarea",{value:C.prompt||"",placeholder:p("cell-prompt"),onChange:L=>N({prompt:L.target.value})}),l.jsx("small",{children:p("cell-prompt-help")}),l.jsxs("label",{className:"nc-field",children:[p("cell-mcp"),l.jsxs("select",{value:Q,onChange:L=>V(L.target.value),children:[l.jsx("option",{value:"all",children:p("cell-mcp-all")}),l.jsx("option",{value:"none",children:p("cell-mcp-none")}),l.jsx("option",{value:"some",children:p("cell-mcp-some")})]})]}),!H&&l.jsx("small",{className:"nc-note",children:p("cell-mcp-inert")}),Q==="some"&&l.jsx("div",{className:"nc-fleet-mcp-list",children:X.map(L=>l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:(C.mcp||[]).includes(L),onChange:()=>T(L)})," ",L]},L))}),l.jsx("small",{children:p("cell-mcp-help")})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>c(null),children:p("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:g||!C.id||!C.cwd||!C.engine,onClick:_,children:p("save")})]})]})}function m0({token:t,route:e=[],state:n,setState:i,busy:s,onSave:a}){const[c,d]=b.useState(null),[h,f]=b.useState([]),[g,_]=b.useState(""),y=Array.isArray(e)?e.join("/"):"";b.useEffect(()=>{let N=!0;return rd(t,y?y.split("/"):[]).then(k=>{N&&(f(k.engines||[]),_(""))}).catch(k=>{N&&(f([]),_(String(k.message||k)))}),()=>{N=!1}},[t,y]);const w=n.form,S=N=>i({...n,form:{...w,...N}}),A=async N=>{try{const k=await Dm(t,N,e);d(k),S({cwd:k.path})}catch{}},C=!w.id&&w.tmuxSession?w.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):w.id;return l.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[l.jsxs("b",{children:[p("import-as-cell")," · ",w.tmuxSession]}),l.jsx("small",{children:p("import-help")}),l.jsx("input",{value:w.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),l.jsx("input",{value:w.id,placeholder:p("name"),onChange:N=>S({id:N.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:w.cwd,placeholder:p("cwd"),onChange:N=>S({cwd:N.target.value})}),l.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>c?d(null):A(w.cwd),children:p("browse")})]}),c&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:c.path}),l.jsxs("div",{className:"nc-fs-list",children:[c.parent&&l.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>A(c.parent),children:["↑ ",p("fs-parent")]}),(c.dirs||[]).map(N=>l.jsxs("button",{className:"nc-fs-item",onClick:()=>A(`${c.path.replace(/\/$/,"")}/${N}`),children:["📁 ",N]},N))]})]}),l.jsxs("select",{value:w.engine,onChange:N=>S({engine:N.target.value}),children:[l.jsx("option",{value:"",children:p("import-engine-required")}),h.map(N=>l.jsx("option",{value:N.id,children:N.label},N.id))]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:!!w.boot,onChange:N=>S({boot:N.target.checked})})," ",p("fleet-boot")]}),(n.err||g)&&l.jsx("div",{className:"nc-err",children:n.err||g}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>i(null),children:p("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:s||!w.tmuxSession||!w.engine||!h.length,onClick:a,children:p(C?"import-as-cell":"save")})]})]})}function Cu(t){const e=wo(t);return e===null?`~/${t}`:e?`~/${e}`:"~"}function oI(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 aI({token:t,route:e,cell:n,busy:i=!1,onSaved:s,onClose:a}){const[c,d]=b.useState(""),[h,f]=b.useState(null),[g,_]=b.useState(!1),[y,w]=b.useState(""),S=typeof(n==null?void 0:n.cwdSuggestion)=="string"&&wo(n.cwdSuggestion)!==null?wo(n.cwdSuggestion):null,[A,C]=b.useState(S),N=n==null?void 0:n.id,k=i||g,O=async X=>{const Q=wo(X);if(Q===null){f({rel:"",dirs:[],loading:!1,err:p("fleet-cwd-repair-invalid")});return}f({rel:Q,dirs:[],loading:!0,err:""});try{const V=await Dm(t,Q,e),T=oI(V);f({rel:T,dirs:Array.isArray(V.dirs)?V.dirs:[],loading:!1,err:""})}catch(V){f({rel:Q,dirs:[],loading:!1,err:String(V&&V.message||V)})}},P=X=>{if(!h)return;const Q=h.rel?`${h.rel}/${X}`:X;O(Q)},H=()=>{h!=null&&h.rel&&O(h.rel.split("/").slice(0,-1).join("/"))},W=()=>{h&&(d(h.rel||""),f(null),w(""),C(null))},U=()=>{A!==null&&(d(A),C(null),w(""))},G=async()=>{if(k)return;const X=wo(c);if(X===null){w(p("fleet-cwd-repair-invalid"));return}const Q=Cu(X);let V=!0;try{V=window.confirm(p("fleet-cwd-repair-confirm").replace("{id}",String(N||"")).replace("{path}",Q))}catch{V=!1}if(V){_(!0),w(""),C(null);try{const T=await H0(t,N,{cwdRel:X},e);s==null||s(T)}catch(T){const I=T&&T.data||{};if(I.code==="unportable-cwd"){w(p("fleet-cwd-repair-unportable"));const $=Array.isArray(I.cells)?I.cells.find(M=>M&&M.id===N):null,j=$&&typeof $.suggestion=="string"?$.suggestion:null;j!==null&&wo(j)!==null&&C(j)}else w(String(T&&T.message||T))}finally{_(!1)}}};return l.jsxs("div",{className:"nc-set-form nc-fleet-form nc-cwd-repair",children:[l.jsx("b",{children:p("fleet-cwd-repair-title").replace("{id}",String(N||""))}),l.jsx("small",{className:"nc-set-info",children:p("fleet-cwd-repair-help")}),l.jsx("small",{className:"nc-cwd-no-source",children:p("fleet-cwd-repair-no-source-path")}),l.jsxs("label",{className:"nc-field",children:[p("cwd"),l.jsxs("div",{className:"nc-cwd-rel-row",children:[l.jsx("span",{className:"nc-cwd-rel-prefix",children:"~/"}),l.jsx("input",{value:c,placeholder:p("fleet-cwd-repair-placeholder"),autoComplete:"off",spellCheck:"false",autoCapitalize:"none",onChange:X=>d(X.target.value)}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:k,onClick:()=>h?f(null):O(""),children:p(h?"close":"fleet-cwd-repair-browse")})]})]}),l.jsx("div",{className:"nc-cwd-preview",children:p("fleet-cwd-repair-preview").replace("{path}",Cu(c))}),h&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:Cu(h.rel)}),l.jsxs("div",{className:"nc-fs-list",children:[h.rel&&l.jsxs("button",{type:"button",className:"nc-fs-item nc-fs-nav",onClick:H,children:["↑ ",p("fs-parent")]}),h.loading&&l.jsx("div",{className:"nc-fs-empty",children:"…"}),!h.loading&&h.dirs.length===0&&l.jsx("div",{className:"nc-fs-empty",children:p("fleet-cwd-repair-fs-empty")}),!h.loading&&h.dirs.map(X=>l.jsxs("button",{type:"button",className:"nc-fs-item",onClick:()=>P(X),children:["📁 ",X]},X))]}),h.err&&l.jsx("div",{className:"nc-err",children:h.err}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{type:"button",className:"nc-btn primary",disabled:k||h.loading||!!h.err,onClick:W,children:p("fleet-cwd-repair-use-current")})})]}),y&&l.jsx("div",{className:"nc-err",role:"alert",children:y}),A!==null&&l.jsxs("div",{className:"nc-cwd-suggestion",role:"status",children:[l.jsx("span",{children:p("fleet-cwd-repair-suggestion")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:U,children:p("fleet-cwd-repair-use-suggestion").replace("{path}",Cu(A))})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:g,onClick:a,children:p("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:k,onClick:G,children:g?"…":p("save")})]})]})}function lI({token:t,readonly:e,targets:n=[],startNewCell:i=!1,initialLocation:s=""}){const[a,c]=b.useState({engines:[],cells:[],managedCatalog:[]}),[d,h]=b.useState({available:!1,capabilities:[]}),[f,g]=b.useState(!1),[_,y]=b.useState(null),[w,S]=b.useState(null),[A,C]=b.useState({}),[N,k]=b.useState(null),[O,P]=b.useState(!1),[H,W]=b.useState(""),[U,G]=b.useState(""),[X,Q]=b.useState(s),[V,T]=b.useState(!1),[I,$]=b.useState(null),[j,M]=b.useState(null),[L,R]=b.useState(null),[E,z]=b.useState(!1),[D,q]=b.useState([]),[ce,ge]=b.useState(null),[se,we]=b.useState("manage"),_e=b.useRef(!1),fe=X?X.split("/"):[],ie=b.useCallback(async()=>{try{const F=await fr(t,fe);h(F);try{const J=await Om(t,fe);T(!!J.readonlyDefault)}catch{T(!1)}if(F.provider==="builtin"&&(F.capabilities||[]).includes("definitions")){const J=await rd(t,fe),ee=new Map((F.engines||[]).map(K=>[K.id,K]));if(J.engines=(J.engines||[]).map(K=>{var ye;return{...K,availableModels:((ye=ee.get(K.id))==null?void 0:ye.models)||[]}}),c(J),(F.capabilities||[]).includes("credentials"))try{q((await d2(t,fe)).credentials||[])}catch{q([])}else q([])}W("")}catch(F){W(String(F.message||F))}finally{g(!0)}},[t,X]);b.useEffect(()=>{ie();const F=setInterval(ie,5e3);return()=>clearInterval(F)},[ie]);const de=new Set((d.cells||[]).filter(F=>F.active).map(F=>F.cell)),me=d.provider==="builtin"&&(d.capabilities||[]).includes("edit"),Ee=(d.capabilities||[]).includes("restore");b.useEffect(()=>{!i||_e.current||!me||!a.engines.length||(_e.current=!0,k({mode:"new",form:f0(a.engines[0].id)}))},[i,me,a.engines]);const Se=async F=>{P(!0),W(""),G("");try{await F(),await ie()}catch(J){W(String(J.message||J))}P(!1)},xe=async(F,J)=>{const ee=await _2(t,F,J,fe);return C(K=>({...K,[`${F}::${J}`]:ee})),ee},Ye=F=>Se(async()=>{const J={id:String(F.id||"").trim(),engine:String(F.engine||"").trim()};for(const ee of["contextWindow","maxTokens"]){const K=String(F[ee]||"").trim();K&&(J[ee]=Number(K))}F.reasoning===!0&&(J.reasoning=!0),await g2(t,J,fe),S(null),await ie()}),Le=()=>Se(async()=>{var Ct;const F=_.mode==="new",J=_.form,ee=a.managedCatalog||[],K=J.kind==="managed"?Ql(ee,J):null,ye=typeof(K==null?void 0:K.credentialEnv)=="string"?K.credentialEnv:"",Ze=ye&&J.credentialValue||"",ct=tI(J,F,ee);!F&&_.form.kind==="custom"&&!_.form.modelFlag&&(ct.model=null),!F&&_.form.kind==="custom"&&_.form.promptMode!=="flag"&&(ct.promptFlag=null);let st;if(F)st=await f2(t,ct,fe);else{const Xe=_.original,tt=new Set(_.form.envRows.filter(Ae=>!Ae.remove).map(Ae=>Ae.key)),Nt=(Xe.envKeys||[]).filter(Ae=>!tt.has(Ae)),kn=Object.fromEntries(_.form.envRows.filter(Ae=>!Ae.remove&&Ae.key&&(!Ae.configured||Ae.value!=="")).map(Ae=>[Ae.key,Ae.value]));st=await p2(t,Xe.id,ct,_.form.kind==="custom"?{set:kn,remove:Nt}:void 0,fe)}let xt=null;if(ye&&Ze)try{xt=await ry(t,ye,Ze,fe),q(xt.credentials||[])}catch{throw await ie(),F&&y({mode:"edit",original:{...ct,id:J.id},form:{...J,credentialReveal:!1}}),new Error(p(F?"fleet-key-partial-create":"fleet-key-partial-edit"))}await ie(),y(null),G(p("fleet-saved"));const Et=((Ct=((xt==null?void 0:xt.credentials)||[]).find(Xe=>Xe.envKey===ye))==null?void 0:Ct.activeCells)||[],jt=[...new Set([...(st==null?void 0:st.activeCells)||[],...Et])];if(jt.length&&window.confirm(p("fleet-restart-confirm").replace("{cells}",jt.join(", "))))for(const Xe of jt)await Ll(t,Xe,fe)}),ze=()=>Se(async()=>{var Et,jt,Ct,Xe,tt,Nt;const F=N.mode==="new",J=N.form,ee={...F?{id:J.id}:{},cwd:J.cwd,engine:J.engine,boot:!!J.boot},K={...J.commands||{}},ye=a.engines.find(kn=>kn.id===J.engine);((Et=ye==null?void 0:ye.managed)==null?void 0:Et.client)==="shell"&&typeof J.command=="string"&&J.command.length?K[J.engine]=J.command:((jt=ye==null?void 0:ye.managed)==null?void 0:jt.client)==="shell"&&delete K[J.engine],(Object.keys(K).length||!F)&&(ee.commands=K);const Ze=(J.label||"").trim();F?Ze&&(ee.label=Ze):ee.label=Ze||null;const ct=(J.panelUrl||"").trim();F?ct&&(ee.panelUrl=ct):ee.panelUrl=ct||null,F?Array.isArray(J.mcp)&&(ee.mcp=J.mcp):ee.mcp=Array.isArray(J.mcp)?J.mcp:null,F?(((Ct=ye==null?void 0:ye.managed)==null?void 0:Ct.client)!=="shell"&&J.model&&(ee.model=J.model),((Xe=ye==null?void 0:ye.managed)==null?void 0:Xe.client)!=="shell"&&J.prompt&&(ee.prompt=J.prompt)):(ee.model=((tt=ye==null?void 0:ye.managed)==null?void 0:tt.client)==="shell"?null:J.model||null,((Nt=ye==null?void 0:ye.managed)==null?void 0:Nt.client)!=="shell"&&(ee.prompt=J.prompt||null));const st=F?await y2(t,ee,fe):await H0(t,N.original.id,ee,fe),xt=F?J.id:N.original.id;k(null),G(p("fleet-saved")),!F&&(st!=null&&st.active)&&window.confirm(p("fleet-restart-confirm").replace("{cells}",xt))&&await Ll(t,xt,fe)}),He=e||V,_t=d.capabilities||[],at=fe.length>0&&He,lt=F=>D.find(J=>{var ee;return(ee=J.engines)==null?void 0:ee.includes(F.id)})||null,bt=()=>Se(async()=>{var ee;const F=await ry(t,ce.envKey,ce.value,fe);q(F.credentials||[]),ge(null),G(p("fleet-credential-saved"));const J=((ee=(F.credentials||[]).find(K=>K.envKey===ce.envKey))==null?void 0:ee.activeCells)||[];if(J.length&&window.confirm(p("fleet-restart-confirm").replace("{cells}",J.join(", "))))for(const K of J)await Ll(t,K,fe)}),Ht=F=>Se(async()=>{if(!window.confirm(p("fleet-credential-remove-confirm").replace("{key}",F.envKey)))return;const J=await h2(t,F.envKey,fe);q(J.credentials||[]),G(p("fleet-credential-removed"))}),Rt=F=>$({...F,route:Array.isArray(F==null?void 0:F.route)?F.route:fe}),fn=async F=>{if(!I)return;const J={...I,cell:I.cell||I.id};try{await hg({token:t,powerCell:J,payload:F,onNotice:G})}catch(ee){throw W(String(ee&&ee.message||ee)),ee}},It=(F,J)=>{W(""),M({mode:"new",route:Array.isArray(J)?J:fe,form:{tmuxSession:F.name,id:"",engine:"",cwd:"",boot:!1},err:""})},Wt=()=>Se(async()=>{const F=j.form;if(!F.engine){M({...j,err:p("import-engine-required")});return}await w2(t,{tmuxSession:F.tmuxSession,id:F.id||void 0,engine:F.engine,cwd:F.cwd||void 0,boot:!!F.boot},F.route||fe),M(null),G(p("fleet-saved"))}),ft=({engineRows:F=[],cellRows:J=[],models:ee=[]})=>Se(async()=>{const K=F.filter(Xe=>Xe.selected),ye=K.map(Xe=>eC(Xe.engine));if(ye.some(Xe=>!Xe))throw new Error(p("fleet-backup-invalid-engine"));const Ze=K.filter(Xe=>Xe.exists).map(Xe=>Xe.engine.id);if(Ze.length&&!window.confirm(p("fleet-backup-confirm-engine-overwrite").replace("{engines}",Ze.join(", "))))return;const ct=[...new Set([...a.engines.map(Xe=>Xe.id),...ye.map(Xe=>Xe.id)])],st=[];for(const Xe of J.filter(tt=>tt.selected)){const tt=QP(Xe.cell,Xe.engine,ct);if(!tt)throw new Error(`${Xe.cell.id}: ${p("fleet-backup-engine-missing")}`);st.push(tt)}const xt=J.filter(Xe=>Xe.selected&&Xe.exists).map(Xe=>Xe.cell.id);if(xt.length&&!window.confirm(p("fleet-backup-confirm-overwrite").replace("{cells}",xt.join(", "))))return;const Et=ye.length?await S2(t,ye,Ze.length>0,fe,ee):{needsRestart:[]},jt=st.length?await b2(t,st,fe):{needsRestart:[]},Ct=[...new Set([...Et.needsRestart||[],...jt.needsRestart||[]])];z(!1),G(`${p("fleet-backup-restored").replace("{n}",String(st.length))}${ye.length?` · ${ye.length} ${p("fleet-engines").toLowerCase()}`:""}${Ct.length?` · ${p("fleet-backup-needs-restart").replace("{cells}",Ct.join(", "))}`:""}`)}),qt=l.jsxs("label",{className:"nc-field",children:[p("location"),l.jsxs("select",{value:X,onChange:F=>{Q(F.target.value),y(null),k(null),W(""),G(""),T(!1),g(!1),h({available:!1,capabilities:[]}),c({engines:[],cells:[],managedCatalog:[]}),q([]),ge(null)},children:[l.jsx("option",{value:"",children:p("local")}),n.map(F=>l.jsxs("option",{value:F.route.join("/"),disabled:F.status&&F.status!=="up",children:[F.label,F.status&&F.status!=="up"?` · ${p("node-offline")}`:""]},F.route.join("/")))]})]}),$t=l.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":p("tab-fleet"),children:[l.jsx("button",{type:"button",role:"tab","aria-selected":se==="manage",className:`nc-set-tabbtn${se==="manage"?" on":""}`,onClick:()=>we("manage"),children:p("fleet-manage-location")}),l.jsx("button",{type:"button",role:"tab","aria-selected":se==="overview",className:`nc-set-tabbtn${se==="overview"?" on":""}`,onClick:()=>we("overview"),children:p("fleet-network-overview")})]});return f?me?l.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[$t,se==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:p("fleet-overview-help")}),l.jsx(cp,{token:t,targets:n,readonly:e,onPower:Rt,onImport:It})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:p("fleet-manage-help")}),qt,l.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[l.jsx("button",{className:"nc-btn ghost",disabled:He||O,onClick:()=>{W(""),z(!0)},children:p("fleet-backup")}),l.jsx("small",{children:p("fleet-backup-help")})]}),l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:p("fleet-cells")}),l.jsx("span",{className:"nc-fleet-head-actions",children:l.jsxs("button",{className:"nc-btn primary",disabled:He||O||!a.engines.length,onClick:()=>{var F;W(""),k({mode:"new",form:f0((F=a.engines[0])==null?void 0:F.id)})},children:["+ ",p("add")]})})]}),a.cells.map(F=>{const J=de.has(F.id),ee=F.needsRepair===!0;return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:F.id}),F.label?l.jsxs("small",{className:"nc-fleet-label",children:[" ",F.label]}):null,l.jsxs("small",{children:[F.engine," · ",ee?l.jsx("span",{className:"nc-fleet-tag nc-fleet-tag-warn",children:p("fleet-cwd-needs-repair")}):F.cwd,J?` · ${p("service-active")}`:` · ${p("cell-off")}`]})]}),l.jsxs("span",{children:[J&&_t.includes("down")&&l.jsx("button",{className:"nc-btn ghost",disabled:He||O,onClick:()=>Se(()=>z0(t,{cell:F.id},fe)),children:p("stop")}),!J&&_t.includes("up")&&l.jsx("button",{className:"nc-btn primary",disabled:He||O,onClick:()=>Rt({cell:F.id,id:F.id,engine:F.engine,model:F.model,models:F.models,permissionPolicies:F.permissionPolicies,active:!1,boot:F.boot}),children:p("start")}),J&&_t.includes("restart")&&l.jsx("button",{className:"nc-btn ghost",disabled:He||O,onClick:()=>Se(()=>Ll(t,F.id,fe)),children:p("restart")}),ee?l.jsx("button",{className:"nc-btn ghost",disabled:He||O,onClick:()=>{W(""),R(F)},children:p("fleet-cwd-repair")}):l.jsx("button",{className:"nc-btn ghost",disabled:He||O,onClick:()=>{var K;W(""),k({mode:"edit",original:F,form:{...F,commands:{...F.commands||{}},command:((K=F.commands)==null?void 0:K[F.engine])||""}})},children:p("edit")}),l.jsx("button",{className:"nc-btn danger",disabled:He||O,onClick:()=>Se(async()=>{window.confirm(p("fleet-remove-cell").replace("{id}",F.id))&&await U0(t,F.id,!0,fe)}),children:"×"})]})]},F.id)}),l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:p("fleet-engines")}),l.jsxs("button",{className:"nc-btn primary",disabled:He||O,onClick:()=>{W(""),y({mode:"new",form:JP()})},children:["+ ",p("add")]})]}),a.engines.map(F=>{var ee,K;const J=lt(F);return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:F.label}),l.jsx("small",{children:F.managed?`${F.id} · ${F.managed.client} / ${F.managed.provider} · ${(ee=F.managedInfo)!=null&&ee.configured?p("fleet-ready"):((K=F.managedInfo)==null?void 0:K.reason)||p("fleet-not-ready")}`:`${F.id} · ${F.command}`}),J&&l.jsxs("small",{children:[J.envKey," · ",p(`fleet-credential-source-${J.source||"missing"}`)]})]}),l.jsxs("span",{children:[J&&l.jsx("button",{className:"nc-btn ghost",disabled:He||O,onClick:()=>{W(""),ge({envKey:J.envKey,value:""})},children:J.configured?p("fleet-credential-change"):p("fleet-credential-set")}),(J==null?void 0:J.source)==="local"&&l.jsx("button",{className:"nc-btn danger",disabled:He||O,onClick:()=>Ht(J),children:p("fleet-credential-forget")}),l.jsx("button",{className:"nc-btn ghost",disabled:He||O,onClick:()=>{W(""),y({mode:"edit",original:F,form:eI(F)})},children:p("edit")}),l.jsx("button",{className:"nc-btn danger",disabled:He||O,onClick:()=>Se(async()=>{window.confirm(p("fleet-remove-engine").replace("{id}",F.id))&&await m2(t,F.id,fe)}),children:"×"})]})]},F.id)}),l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:p("fleet-models")}),l.jsxs("button",{className:"nc-btn primary",disabled:He||O,onClick:()=>{W(""),S({mode:"new",form:{id:"",engine:""}})},children:["+ ",p("add")]})]}),!(a.models||[]).length&&l.jsx("small",{className:"nc-set-hint",children:p("fleet-no-models")}),(a.models||[]).map(F=>{const J=`${F.engine}::${F.id}`,ee=A[J],K=(a.engines||[]).some(ye=>ye.managed&&ye.managed.model===F.id);return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:F.id}),l.jsxs("small",{children:[F.engine,F.contextWindow?` · ${F.contextWindow}`:"",K?` · ${p("model-in-use")}`:""]}),ee&&l.jsxs("small",{className:`nc-model-test ${ee.outcome}`,children:[p(`model-test-${ee.outcome}`),ee.outcome==="ok"&&Number.isInteger(ee.latencyMs)?` · ${ee.latencyMs}ms`:""]})]}),l.jsxs("span",{children:[_t.includes("model-test")&&l.jsx("button",{className:"nc-btn ghost",disabled:O||at,onClick:()=>Se(()=>xe(F.engine,F.id)),children:p("model-test")}),l.jsx("button",{className:"nc-btn danger",disabled:He||O,onClick:()=>Se(()=>v2(t,F.id,F.engine,fe)),children:"×"})]})]},J)})]}),w&&l.jsx($r,{onClose:()=>S(null),label:p("fleet-models"),error:H,children:l.jsx(sI,{state:w,setState:S,busy:O,onSave:Ye,onTest:xe,profiles:a.managedCatalog||[],canTest:_t.includes("model-test")&&!at})}),_&&l.jsx($r,{onClose:()=>y(null),label:p("fleet-new-engine"),error:H,children:l.jsx(iI,{state:_,setState:y,busy:O,onSave:Le,catalog:a.managedCatalog||[]})}),N&&l.jsx($r,{onClose:()=>k(null),label:p("fleet-new-cell"),error:H,children:l.jsx(rI,{token:t,route:fe,targets:n,location:X,setLocation:Q,state:N,setState:k,engines:a.engines,mcpServers:a.mcpServers||[],managedCatalog:a.managedCatalog||[],busy:O,onSave:ze})}),L&&l.jsx($r,{onClose:()=>R(null),label:p("fleet-cwd-repair-title").replace("{id}",L.id),error:"",children:l.jsx(aI,{token:t,route:fe,cell:L,busy:O,onSaved:async()=>{R(null),G(p("fleet-cwd-repaired")),await ie()},onClose:()=>R(null)})}),U&&l.jsx("div",{className:"nc-set-note",children:U}),H&&l.jsx("div",{className:"nc-err",children:H}),E&&l.jsx($r,{onClose:()=>z(!1),label:p("fleet-backup"),error:H,children:l.jsx(nI,{cells:a.cells,engines:a.engines,models:a.models||[],busy:O,canRestore:Ee,onRestore:ft,onClose:()=>z(!1)})}),ce&&l.jsx($r,{onClose:()=>ge(null),label:p("fleet-credential-title"),error:H,children:l.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[l.jsx("b",{children:p("fleet-credential-title")}),l.jsx("small",{children:p("fleet-credential-help")}),l.jsxs("label",{className:"nc-field",children:[ce.envKey,l.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:ce.value,onChange:F=>ge({...ce,value:F.target.value})})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>ge(null),children:p("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:O||!ce.value,onClick:bt,children:p("save")})]})]})}),j&&l.jsx($r,{onClose:()=>M(null),label:p("import-as-cell"),error:H,children:l.jsx(m0,{token:t,route:j.route||fe,state:j,setState:M,busy:O,onSave:Wt})}),I&&l.jsx(Vu,{cell:I,token:t,route:Array.isArray(I.route)?I.route:fe,onConfirm:async F=>{try{await fn(F)}finally{ie()}},onClose:()=>$(null)})]}):l.jsxs("div",{className:"nc-set-tab",children:[$t,se==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:p("fleet-overview-help")}),l.jsx(cp,{token:t,targets:n,readonly:e,onPower:Rt,onImport:It})]}):l.jsxs(l.Fragment,{children:[qt,l.jsxs("div",{className:"nc-set-info",children:[p(H?"fleet-editor-load-error":"fleet-editor-unavailable"),!H&&d.reason?` ${d.reason}`:""]})]}),H&&l.jsx("div",{className:"nc-err",children:H}),j&&l.jsx($r,{onClose:()=>M(null),label:p("import-as-cell"),error:H,children:l.jsx(m0,{token:t,route:j.route||fe,state:j,setState:M,busy:O,onSave:Wt})}),I&&l.jsx(Vu,{cell:I,token:t,route:Array.isArray(I.route)?I.route:fe,onConfirm:async F=>{try{await fn(F)}finally{ie()}},onClose:()=>$(null)})]}):l.jsxs("div",{className:"nc-set-tab",children:[$t,se==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:p("fleet-overview-help")}),l.jsx(cp,{token:t,targets:n,readonly:e,onPower:Rt,onImport:It})]}):l.jsxs(l.Fragment,{children:[qt,l.jsx("div",{className:"nc-set-info",children:p("fleet-editor-loading")})]})]})}const Mg="nc_notification_speech_v1",ku="nc-notification-speech",Nm="nc-notification-speech-preview",cI=320,uI=2,dI=3e4,hI=1e4,fI=6e4,pI=64,g0=Object.freeze({enabled:!1}),mI=Object.freeze({it:"it-IT",en:"en-US",es:"es-ES"}),gI=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"])}),jg=new WeakSet;function Tg(t){return{enabled:(t&&typeof t=="object"&&!Array.isArray(t)?t:{}).enabled===!0}}function nC(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function v0(t=nC()){if(!t)return{...g0};try{return Tg(JSON.parse(t.getItem(Mg)||"null"))}catch{return{...g0}}}function vI(t,e=nC()){const n=Tg(t);if(e)try{e.setItem(Mg,JSON.stringify(n))}catch{}return n}function Ia(){try{return typeof window<"u"?window:null}catch{return null}}function Jl(t=Ia()){try{return!!(t&&t.speechSynthesis&&typeof t.speechSynthesis.speak=="function"&&typeof t.SpeechSynthesisUtterance=="function")}catch{return!1}}function iC(t=Ia()){return!!(t&&(typeof t=="object"||typeof t=="function")&&jg.has(t))}function Lm(t=Ia()){t&&(typeof t=="object"||typeof t=="function")&&jg.delete(t)}function ba(t){const e=String(t||"").trim().toLowerCase().split("-")[0];return mI[e]||""}function xd(t){return String(t||"").normalize("NFC").replace(/[\p{Cc}\p{Cf}]+/gu," ").replace(/\s+/g," ").trim()}function _I(t){const e=xd(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 i=Object.entries(gI).map(([s,a])=>({lang:s,score:[...n].reduce((c,d)=>c+(a.has(d)?1:0),0)})).sort((s,a)=>a.score-s.score);return i[0].score>=3&&i[0].score-i[1].score>=2?i[0].lang:""}function yI(t,e){const n=ba(t&&t.lang);return n||ba(_I(t&&t.body))||ba(e)}function sC(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 rC(t,e){const n=ba(e);if(!n)return null;const i=Array.from(t||[]).filter(d=>d&&typeof d.lang=="string"&&d.lang.trim()),s=i.filter(d=>d.lang.trim().toLowerCase()===n.toLowerCase()),a=n.slice(0,2).toLowerCase(),c=i.filter(d=>d.lang.trim().toLowerCase().split("-")[0]===a);return s.find(d=>d.default===!0)||s[0]||c.find(d=>d.default===!0)||c[0]||null}function _0(t){return xd(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 wI(t,e=cI){const n=_0(t&&t.title),i=_0(t&&t.body),s=[n,i&&i!==n?i:""].filter(Boolean).join(". "),a=Array.from(s);return a.length<=e?s:`${a.slice(0,Math.max(0,e-1)).join("").trimEnd()}…`}function bI(t){try{return!!(t&&t.visibilityState==="visible"&&typeof t.hasFocus=="function"&&t.hasFocus())}catch{return!1}}function oC(t=Ia()){if(!Jl(t))return!1;try{return t.speechSynthesis.cancel(),!0}catch{return!1}}function SI(t){try{t&&typeof t.dispatchEvent=="function"&&typeof t.Event=="function"&&t.dispatchEvent(new t.Event(Nm))}catch{}}function xI(t,e,n=Ia(),i={}){var f;if(Lm(n),!Jl(n))return Promise.resolve(!1);const s=xd(t);if(!s||(f=i.signal)!=null&&f.aborted)return Promise.resolve(!1);const a=Number.isFinite(i.timeoutMs)&&i.timeoutMs>0?i.timeoutMs:hI,c=i.setTimer||((g,_)=>setTimeout(g,_)),d=i.clearTimer||(g=>clearTimeout(g)),h=i.signal;return SI(n),new Promise(g=>{let _=!1,y=!1,w=null,S=null;const A=C=>{if(!_){if(_=!0,h&&S&&h.removeEventListener("abort",S),w!==null&&d(w),C!==!0)try{n.speechSynthesis.cancel()}catch{}else jg.add(n);g(C)}};S=()=>A("no-activation"),h&&h.addEventListener("abort",S,{once:!0});try{n.speechSynthesis.cancel();const C=new n.SpeechSynthesisUtterance(s);C.lang=ba(e);const N=rC(sC(n),C.lang);N&&(C.voice=N),C.onstart=()=>{y=!0},C.onend=()=>A(y?!0:"no-activation"),C.onerror=()=>A("voice-error"),w=c(()=>A("timeout"),a),n.speechSynthesis.speak(C)}catch{A("no-activation")}})}function CI(t={}){const e=t.scope||Ia(),n=t.document||e&&e.document,i=Number.isInteger(t.maxPending)&&t.maxPending>=0?t.maxPending:uI,s=Number.isFinite(t.watchdogMs)&&t.watchdogMs>0?t.watchdogMs:dI,a=Number.isFinite(t.dedupWindowMs)&&t.dedupWindowMs>0?t.dedupWindowMs:fI,c=Number.isInteger(t.maxDedup)&&t.maxDedup>0?t.maxDedup:pI,d=t.now||Date.now,h=t.setTimer||((V,T)=>setTimeout(V,T)),f=t.clearTimer||(V=>clearTimeout(V)),g=t.isPrimed||(()=>iC(e)),_=e&&e.speechSynthesis;let y=null,w=null,S=[],A=[],C=()=>{};const N=new Map,k=()=>{A=sC(e)};if(k(),_&&typeof _.addEventListener=="function")_.addEventListener("voiceschanged",k),C=()=>_.removeEventListener("voiceschanged",k);else if(_&&"onvoiceschanged"in _){const V=_.onvoiceschanged,T=(...I)=>{k(),typeof V=="function"&&V.apply(_,I)};_.onvoiceschanged=T,C=()=>{_.onvoiceschanged===T&&(_.onvoiceschanged=V)}}const O=V=>{if(V&&typeof V.id=="string"&&V.id)return`id:${V.id}`;const T=Number(V&&V.ts),I=xd(V&&V.title);return Number.isFinite(T)&&I?`frame:${T}:${I}`:""},P=V=>{if(!V)return!0;const T=d();for(const[I,$]of N)T-$>=a&&N.delete(I);if(N.has(V))return!1;for(N.set(V,T);N.size>c;)N.delete(N.keys().next().value);return!0},H=()=>{w!==null&&f(w),w=null},W=()=>{H(),y&&(y.onend=null,y.onerror=null,y=null),oC(e)},U=V=>{if(!Jl(e))return S=[],"unsupported";let T;try{T=new e.SpeechSynthesisUtterance(V.text),T.lang=ba(V.lang);const $=rC(A,T.lang);$&&(T.voice=$)}catch{return S=[],"error"}y=T;const I=()=>{if(y!==T)return;H(),y=null,T.onend=null,T.onerror=null;const $=S.shift();$&&U($)};T.onend=I,T.onerror=I;try{return w=h(()=>{if(y!==T)return;y=null,T.onend=null,T.onerror=null;try{e.speechSynthesis.cancel()}catch{}H();const $=S.shift();$&&U($)},s),e.speechSynthesis.speak(T),"speaking"}catch{return I(),"error"}},G=(V,T)=>{if(!Jl(e))return"unsupported";const I=wI(V);if(!I)return"empty";if(!P(O(V)))return"duplicate";if(!bI(n))return"inactive";if(!g())return"unprimed";const $={text:I,lang:T};return V&&V.urgency==="high"?(S=[],W(),U($)):y?i===0?"dropped":(S.length>=i&&S.shift(),S.push($),"queued"):U($)},X=()=>{S=[],W()};return{enqueue:G,stop:X,dispose:()=>{X(),C(),C=()=>{}}}}function aC(){const[t,e]=b.useState(v0);b.useEffect(()=>{const i=s=>{if((s==null?void 0:s.type)==="storage"&&s.key!==Mg&&s.key!==null)return;const a=(s==null?void 0:s.type)===ku?Tg(s.detail):v0();e(a)};return window.addEventListener(ku,i),window.addEventListener("storage",i),()=>{window.removeEventListener(ku,i),window.removeEventListener("storage",i)}},[]);const n=b.useCallback(i=>{const s=vI({enabled:i===!0});return e(s),window.dispatchEvent(new CustomEvent(ku,{detail:s})),s.enabled},[]);return[t.enabled,n]}function kI({text:t}){const[e,n]=b.useState(!1),i=async()=>{try{await navigator.clipboard.writeText(t),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return l.jsxs("div",{className:"nc-set-copyline",children:[l.jsx("code",{children:t}),l.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:i,children:[l.jsx(kt,{name:"copy",size:14})," ",p(e?"copied":"copy")]})]})}function EI({value:t}){const[e,n]=b.useState("");return b.useEffect(()=>{let i=!0;return GT.toDataURL(t,{margin:1,width:220}).then(s=>{i&&n(s)}).catch(()=>{}),()=>{i=!1}},[t]),e?l.jsx("img",{src:e,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function NI({token:t,nodes:e,roster:n,settings:i,readonly:s,refresh:a,refreshAliases:c,vlUnavailable:d=[],accessRevision:h=null}){const[f,g]=b.useState(null),[_,y]=b.useState(null),[w,S]=b.useState(null),[A,C]=b.useState({ssh:"",sshPort:"",name:""}),[N,k]=b.useState(""),[O,P]=b.useState(""),[H,W]=b.useState(!1),[U,G]=b.useState(null),X=Date.now(),Q=i&&i.deviceName||"",V=(e||[]).filter(E=>E&&E.direction==="outbound"&&E.name&&E.ssh),T=V.find(E=>E.name===N)||V[0]||null,I=T?_m(T.tunnel,X):null,$=T!=null&&T.shared?I!=null&&I.up?"share-local-active":"share-local-pending":I!=null&&I.up?"share-local-private":"share-local-private-down",j=[{key:"peer-group-hubs",rows:(e||[]).filter(E=>E.kind!=="transitive"&&E.kind!=="vl"&&E.relation!=="client")},{key:"peer-group-clients",rows:(e||[]).filter(E=>E.kind!=="transitive"&&E.kind!=="vl"&&E.relation==="client")},{key:"peer-group-routed",rows:(e||[]).filter(E=>E.kind==="transitive")},{key:"peer-group-vl",rows:(e||[]).filter(E=>E.kind==="vl")}],M=U&&(e||[]).find(E=>`${E.kind||"direct"}:${E.nodeId||E.name}`===U)||null,L=async E=>{if(T){g(null),y(`${T.name}:share`);try{const z=await T2(t,T.name,E);await a(),z&&z.reversePoolPending===!0&&g(`${T.name}: ${p("share-reverse-pool-pending")}`)}catch(z){const D=z!=null&&z.data&&z.data.shared===!1?z.data:null;if(D)try{await a()}catch{}const q=z!=null&&z.data&&typeof z.data.hint=="string"?z.data.hint:"",ce=(D==null?void 0:D.revoked)===!0&&(D==null?void 0:D.localReconcilePending)===!0?p("share-off-local-reconcile-pending"):(D==null?void 0:D.revoked)===!1&&(D==null?void 0:D.reconcilePending)===!0?p("share-off-hub-reconcile-pending"):"",ge=z!=null&&z.data&&z.data.reversePoolPending===!0?p("share-reverse-pool-pending"):"",se=z!=null&&z.data&&typeof z.data.code=="string"?z.data.code:"",we=z!=null&&z.data&&typeof z.data.detail=="string"?z.data.detail.trim():"",_e=we&&we!==String(z.message||"")?we:"";g(`${T.name}: ${String(z.message||z)}${se?` [${se}]`:""}${_e?` — ${_e}`:""}${q?` — ${q}`:""}${ce?` — ${ce}`:""}${ge?` — ${ge}`:""}`)}y(null)}},R=async()=>{g(null);const E=Xr(A.name||O||Q||"NexusCrew"),z=tj({name:E,ssh:A.ssh,sshPort:A.sshPort});if(!z.ok){g(p(z.error));return}y("invite");try{S(await R2(t,{...O||Q?{label:O||Q}:{},name:E,ssh:z.value.ssh,...z.value.sshPort?{sshPort:z.value.sshPort}:{}}))}catch(D){g(String(D.message||D))}y(null)};return l.jsxs("div",{className:"nc-set-tab",children:[l.jsx("div",{className:"nc-sheet-label",children:p("peer-inventory-title")}),(e||[]).length===0&&l.jsx("div",{className:"nc-empty",children:p("no-nodes")}),j.map(E=>E.rows.length>0&&l.jsxs("div",{className:"nc-peer-group",children:[l.jsxs("div",{className:"nc-peer-group-title",children:[p(E.key)," ",l.jsx("span",{children:E.rows.length})]}),E.rows.map(z=>{const D=aP(z);if(!D)return null;const q=`${z.kind||"direct"}:${z.nodeId||z.name}`,ce=D.routed?{up:D.reach.up,since:null}:_m(z.tunnel,X);return l.jsxs("button",{type:"button",className:`nc-set-node nc-node-row${D.routed?" routed":""}`,"aria-label":`${D.title} — ${p("node-detail-open")}`,onClick:()=>G(q),children:[l.jsx("span",{className:`nc-dot ${D.reach.up?"on":""}`}),l.jsxs("span",{className:"nc-node-row-text",children:[l.jsx("b",{children:D.title}),l.jsxs("small",{children:[D.routed?D.routeLabel:`${D.subtitle} · ${p(D.exposure.shortKey)}`,!D.routed&&D.exposure.shortKey==="visibility-selected"?` (${D.exposure.count})`:""]})]}),l.jsxs("span",{className:`nc-set-tunnel${D.reach.up?" up":""}`,children:[p(D.reach.key),ce.since?` · ${ce.since}`:""]}),l.jsx("span",{className:"nc-node-row-more",children:l.jsx(kt,{name:"chevronDown",size:14})})]},q)})]},E.key)),d.length>0&&l.jsxs("div",{className:"nc-err",children:[p("vl-owners-unavailable"),": ",d.map(E=>E.label||E.route.join("/")).join(", ")]}),M&&l.jsx(NP,{node:M,nodes:e||[],token:t,readonly:s,refresh:a,onClose:()=>G(null),peerAccessRevision:h}),(n||[]).some(E=>!E.direct&&E.instanceId)&&l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:p("routed-node-aliases")}),l.jsx("small",{className:"nc-set-hint",children:p("routed-node-aliases-help")}),(n||[]).filter(E=>!E.direct&&E.instanceId).map(E=>l.jsxs("div",{className:"nc-set-node",children:[l.jsxs("div",{className:"nc-set-node-head",children:[l.jsx("span",{className:`nc-dot ${E.status==="up"?"on":""}`}),l.jsx("b",{children:E.label||E.name}),l.jsx("small",{children:(E.route||[]).join(" › ")})]}),l.jsxs("div",{className:"nc-set-node-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!_,onClick:async()=>{const z=window.prompt(p("node-local-alias"),E.alias||"");if(z!=null){if(z.trim()&&!Na(z.normalize("NFC"))){g(p("err-label"));return}y(`${E.instanceId}:alias`),g(null);try{z.trim()?await M2(t,E.instanceId,z):await ly(t,E.instanceId),c()}catch(D){g(String(D.message||D))}y(null)}},children:p("alias-on-device")}),E.alias&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!_,onClick:async()=>{y(`${E.instanceId}:alias-reset`),g(null);try{await ly(t,E.instanceId),c()}catch(z){g(String(z.message||z))}y(null)},children:p("reset-alias")})]})]},E.instanceId))]}),T&&l.jsxs("div",{className:"nc-set-form nc-local-share",children:[l.jsx("div",{className:"nc-sheet-label",children:p("share-local-heading")}),V.length>1&&l.jsxs("label",{className:"nc-field",children:[p("share-local-hub"),l.jsx("select",{value:T.name,disabled:s||!!_,onChange:E=>k(E.target.value),children:V.map(E=>l.jsx("option",{value:E.name,children:E.label||E.name},E.name))})]}),l.jsxs("label",{className:"nc-check nc-node-share",children:[l.jsx("input",{type:"checkbox",checked:T.shared===!0,disabled:s||!!_,onChange:E=>L(E.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:p("share-local-through").replace("{device}",Q||p("local")).replace("{hub}",T.label||T.name)}),l.jsx("small",{children:p(T.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),l.jsx("div",{className:`nc-set-test${T.shared&&(I!=null&&I.up)?" ok":I!=null&&I.up?"":" ko"}`,children:p($)}),!(I!=null&&I.up)&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!_,onClick:()=>L(T.shared===!0),children:p("share-local-reconnect")})]}),l.jsx(Fx,{token:t,deviceDefault:Q,localNodeId:i&&i.nodeId||"",localNameDefault:i&&i.localName||"",readonly:s,onSuccess:a}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:p("invite-node")}),l.jsx("small",{className:"nc-set-hint",children:p("invite-v2-hint")}),l.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[p("invite-target-local"),": ",l.jsx("b",{children:Q||p("invite-target-this")})]}),l.jsxs("label",{className:"nc-field",children:[p("invite-endpoint-label"),l.jsx("input",{placeholder:"user@host",value:A.ssh,disabled:s,onChange:E=>C({...A,ssh:E.target.value})}),l.jsx("small",{className:"nc-set-hint",children:p("invite-endpoint-needed")})]}),V.length>0&&l.jsx("small",{className:"nc-set-hint nc-invite-hub-hint",children:p("invite-hub-only")}),H&&l.jsxs("div",{className:"nc-invite-advanced",children:[l.jsxs("label",{className:"nc-field",children:[p("node-ssh-port-label"),l.jsx("input",{inputMode:"numeric",placeholder:"22",value:A.sshPort,disabled:s,onChange:E=>C({...A,sshPort:E.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),l.jsxs("label",{className:"nc-field",children:[p("device-name-label"),l.jsx("input",{placeholder:Q||"NexusCrew",value:O,disabled:s,onChange:E=>P(E.target.value)}),l.jsx("small",{className:"nc-set-hint",children:p("device-name-hint")})]}),l.jsxs("label",{className:"nc-field",children:[p("node-name-label"),l.jsx("input",{placeholder:Xr(O||Q||p("node-name-ph")),value:A.name,disabled:s,onChange:E=>C({...A,name:E.target.value?Xr(E.target.value):""})})]})]}),l.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:s||!!_||!A.ssh.trim(),onClick:R,children:p("create-pairing-link")}),l.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!_,onClick:()=>W(E=>!E),children:[H?"▾":"▸"," ",p("pair-advanced")]})]}),w&&l.jsxs(l.Fragment,{children:[l.jsx(EI,{value:w.pairingUrl}),l.jsx(kI,{text:w.pairingUrl}),l.jsx("div",{className:"nc-set-info",children:p("invite-next-steps")})]})]}),f&&l.jsx("div",{className:"nc-err",children:f})]})}function LI({token:t,readonly:e}){const[n,i]=b.useState("idle"),[s,a]=b.useState(()=>Kx()),[c,d]=b.useState(!1),[h,f]=b.useState(null);b.useEffect(()=>{let y=!1;return MP().then(w=>{y||i(w)}),()=>{y=!0}},[]);const g=async()=>{f(null),d(!0);try{n==="subscribed"?(await h0(t),i("idle")):(await jP(t),i("subscribed"))}catch(y){const w=String(y.message||y);w==="push-denied"?(i("denied"),f(p("push-denied"))):w==="push-unsupported"?(i("unsupported"),f(p("push-unsupported"))):f(w==="push-disabled-local"?p("push-local-disabled"):w)}d(!1)},_=async()=>{const y=LP({enabled:s.enabled!==!1});if(a(y),f(null),y.enabled===!1&&n==="subscribed"){d(!0);try{await h0(t),i("idle")}catch{}d(!1)}};return n==="unsupported"?l.jsx("div",{className:"nc-set-info",children:p("push-unsupported")}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:_,disabled:c,children:s.enabled===!1?p("push-local-on"):p("push-local-off")}),l.jsx("span",{className:"nc-set-info",children:s.enabled===!1?p("push-local-off-note"):p("push-local-help")})]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||c||n==="denied",title:e?p("settings-readonly"):"",onClick:g,children:p(n==="subscribed"?"push-disable":"push-enable")}),l.jsx("span",{className:"nc-set-info",children:p(n==="subscribed"?"push-on":n==="denied"?"push-denied":"push-off")})]}),h&&l.jsx("div",{className:"nc-err",children:h})]})}function RI(){const[t,e]=aC(),[n,i]=b.useState(""),[s,a]=b.useState(""),[c,d]=b.useState(!1),[h,f]=b.useState(iC),g=b.useRef(0),_=b.useRef(!1),y=b.useRef(null),w=Jl();b.useEffect(()=>()=>{var C;g.current+=1,_.current&&((C=y.current)==null||C.abort(),y.current=null,_.current=!1,Lm())},[]);const S=async()=>{const C=g.current+=1,N=typeof AbortController=="function"?new AbortController:null;i(""),a(""),d(!0),f(!1),_.current=!0,y.current=N;const k=await xI(p("notification-speech-preview"),Ou(),void 0,N?{signal:N.signal}:{});return C!==g.current||(y.current=null,_.current=!1,d(!1),f(k===!0),k===!0?a(p("notification-speech-preview-ok")):i(p(k==="voice-error"?"notification-speech-preview-voice-error":k==="timeout"?"notification-speech-preview-timeout":"notification-speech-preview-failed"))),k},A=C=>{var N;if(e(C),i(""),a(""),C)S();else{g.current+=1;const k=_.current;(N=y.current)==null||N.abort(),y.current=null,_.current=!1,d(!1),f(!1),Lm(),k||oC()}};return l.jsxs("div",{className:"nc-set-form",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":p("notification-speech-enable"),checked:t,disabled:!w,onChange:C=>A(C.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:p("notification-speech-enable")}),l.jsx("small",{children:p("notification-speech-help")})]})]}),w?l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!t||c,onClick:()=>{S()},children:p(c?"notification-speech-testing":"notification-speech-test")})}):l.jsx("div",{className:"nc-set-info",children:p("notification-speech-unsupported")}),t&&!h&&!c&&!n&&l.jsx("div",{className:"nc-set-info",children:p("notification-speech-needs-test")}),s&&l.jsx("div",{className:"nc-set-info",role:"status",children:s}),n&&l.jsx("div",{className:"nc-err",children:n})]})}function AI({token:t,readonly:e,nodes:n=[],settings:i=null}){const[s,a]=b.useState(null),[c,d]=b.useState([]),[h,f]=b.useState({name:"",mode:"primary-failover",targets:[]}),[g,_]=b.useState(null),[y,w]=b.useState(!1),[S,A]=b.useState(null),[C,N]=b.useState(""),k=b.useCallback(async()=>{try{const[L,R]=await Promise.all([I2(t),$2(t)]);a(L),d(Array.isArray(R==null?void 0:R.groups)?R.groups:[]),N("")}catch(L){N(String(L.message||L))}},[t]);b.useEffect(()=>{k()},[k]);const O=async L=>{w(!0),A(null),N("");try{a(await D2(t,L))}catch(R){N(String(R.message||R))}w(!1)},P=async()=>{w(!0),A(null),N("");try{A({kind:"test",...await B2(t)})}catch(L){N(String(L.message||L))}w(!1)},H=async()=>{w(!0),A(null),N("");try{A({kind:"stop",...await O2(t)})}catch(L){N(String(L.message||L))}w(!1)},W=[],U=new Set,G=(L,R)=>{const E=typeof L=="string"?L.toLowerCase():"";!/^[a-f0-9]{32}$/.test(E)||U.has(E)||(U.add(E),W.push({id:E,label:R||E}))};G(i==null?void 0:i.nodeId,p("audio-group-local"));for(const L of n||[])G((L==null?void 0:L.nodeId)||(L==null?void 0:L.instanceId),(L==null?void 0:L.label)||(L==null?void 0:L.name)||(L==null?void 0:L.nodeId));for(const L of h.targets)G(L,`${L} (${p("audio-group-unavailable-target")})`);const X=(L=null)=>{N(""),L?(_(L.name),f({name:L.name,mode:L.mode,targets:[...L.targets||[]]})):(_(null),f({name:"",mode:"primary-failover",targets:[]}))},Q=(L,R)=>f(E=>({...E,targets:R?[...new Set([...E.targets,L])]:E.targets.filter(z=>z!==L)})),V=async()=>{const L=h.name.trim().toLowerCase();if(!/^[a-z0-9][a-z0-9-]{0,31}$/.test(L)||h.targets.length<1){N(p("audio-group-invalid"));return}w(!0),N("");try{const R=await z2(t,L,{targets:h.targets,mode:h.mode}),E=R==null?void 0:R.group;if(!E||!E.name)throw new Error(p("audio-group-save-failed"));d(z=>[...z.filter(D=>D.name!==E.name),E].sort((D,q)=>D.name.localeCompare(q.name))),X(null)}catch(R){N(String(R.message||R))}w(!1)},T=async L=>{w(!0),N("");try{await F2(t,L),d(R=>R.filter(E=>E.name!==L)),g===L&&X(null)}catch(R){N(String(R.message||R))}w(!1)},I=(s==null?void 0:s.installed)===!0,$=(s==null?void 0:s.liveness)==="ready",j=(s==null?void 0:s.consent)===!0&&I&&$,M=S?S.kind==="stop"?p(S.stopped?"audio-stop-stopped":"audio-stop-idle"):S.status==="accepted"||S.status==="spoken"?p("audio-test-accepted"):S.status==="unknown"?p("audio-test-unknown"):`${p("audio-test-refused")}${S.reason?` (${S.reason})`:""}`:"";return l.jsxs("div",{className:"nc-set-tab nc-audio-settings",children:[l.jsxs("div",{className:"nc-set-info",children:[l.jsx("b",{children:p("audio-title")}),l.jsx("br",{}),p("audio-help")]}),s?l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":p("audio-consent"),checked:s.consent===!0,disabled:e||y,onChange:L=>{O(L.target.checked)}}),l.jsxs("span",{children:[l.jsx("b",{children:p("audio-consent")}),l.jsx("small",{children:p("audio-consent-help")})]})]}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:p("audio-capability")}),l.jsxs("div",{className:"nc-set-info",children:[p("audio-adapter"),": ",s.adapter||p("audio-adapter-none"),l.jsx("br",{}),p("audio-installed"),": ",p(I?"audio-installed-yes":"audio-installed-no"),l.jsx("br",{}),p("audio-liveness"),": ",p($?"audio-liveness-ready":"audio-liveness-unavailable"),Array.isArray(s.languages)&&s.languages.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("br",{}),p("audio-languages"),": ",s.languages.join(", ")]})]}),s.limits&&l.jsxs("small",{className:"nc-set-hint",children:[p("audio-limits"),": ",s.limits]})]}),!s.consent&&l.jsx("div",{className:"nc-set-info",children:p("audio-test-needs-consent")}),!I&&l.jsx("div",{className:"nc-set-info",children:p("audio-unavailable")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:e||y||!j,title:e?p("settings-readonly"):"",onClick:()=>{P()},children:p(y?"audio-testing":"audio-test")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:y,onClick:()=>{H()},children:p(y?"audio-stopping":"audio-stop")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:y,onClick:()=>{k()},children:p("refresh")})]}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:p("audio-groups-title")}),l.jsx("small",{className:"nc-set-hint",children:p("audio-groups-help")}),c.length===0&&l.jsx("div",{className:"nc-set-info",children:p("audio-groups-empty")}),c.map(L=>{var R;return l.jsxs("div",{className:"nc-set-row",children:[l.jsxs("span",{children:[l.jsx("b",{children:L.name})," ",l.jsxs("small",{children:["· ",L.mode==="fanout"?p("audio-group-fanout"):p("audio-group-primary")," · ",((R=L.targets)==null?void 0:R.length)||0]})]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||y,onClick:()=>X(L),children:p("audio-group-edit")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||y,onClick:()=>{T(L.name)},children:p("audio-group-delete")})]},L.name)}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||y,onClick:()=>X(null),children:p("audio-group-new")})}),l.jsxs("label",{className:"nc-field",children:[p("audio-group-name"),l.jsx("input",{"aria-label":p("audio-group-name"),value:h.name,maxLength:"32",disabled:e||y,onChange:L=>f(R=>({...R,name:L.target.value}))})]}),l.jsxs("label",{className:"nc-field",children:[p("audio-group-mode"),l.jsxs("select",{"aria-label":p("audio-group-mode"),value:h.mode,disabled:e||y,onChange:L=>f(R=>({...R,mode:L.target.value})),children:[l.jsx("option",{value:"primary-failover",children:p("audio-group-primary")}),l.jsx("option",{value:"fanout",children:p("audio-group-fanout")})]})]}),l.jsx("div",{className:"nc-set-info",children:p("audio-group-targets")}),W.length===0?l.jsx("small",{className:"nc-set-hint",children:p("audio-group-no-targets")}):W.map(L=>l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:h.targets.includes(L.id),disabled:e||y,onChange:R=>Q(L.id,R.target.checked)}),l.jsxs("span",{children:[L.label,l.jsx("small",{children:L.id})]})]},L.id)),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:e||y,onClick:()=>{V()},children:p("audio-group-save")}),g&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:y,onClick:()=>X(null),children:p("audio-group-cancel")})]})]})]}):l.jsx("div",{className:"nc-set-info",children:p("audio-loading")}),M&&l.jsx("div",{className:"nc-set-note",role:"status",children:M}),C&&l.jsx("div",{className:"nc-err",children:C})]})}function MI(){const[t,e]=gg();return l.jsxs("div",{className:"nc-set-tab nc-input-settings",children:[l.jsx("div",{className:"nc-set-info",children:p("input-settings-local")}),l.jsxs("div",{className:"nc-set-form",children:[l.jsxs("label",{className:"nc-field",children:[p("terminal-keyboard-gesture"),l.jsx("select",{"aria-label":p("terminal-keyboard-gesture"),value:t.terminalKeyboardGesture,onChange:n=>e({terminalKeyboardGesture:n.target.value}),children:vx.map(n=>l.jsx("option",{value:n,children:p(`terminal-keyboard-${n}`)},n))}),l.jsx("small",{children:p("terminal-keyboard-gesture-help")})]}),l.jsxs("label",{className:"nc-field",children:[p("keybar-layout"),l.jsx("select",{"aria-label":p("keybar-layout"),value:t.keybarLayout,onChange:n=>e({keybarLayout:n.target.value}),children:_x.map(n=>l.jsx("option",{value:n,children:p(`keybar-layout-${n}`)},n))}),l.jsx("small",{children:p("keybar-layout-help")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:t.keybarKeepsKeyboardClosed,onChange:n=>e({keybarKeepsKeyboardClosed:n.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:p("keybar-ime-lock")}),l.jsx("small",{children:p("keybar-ime-lock-help")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:t.voiceKeepsKeyboardClosed,onChange:n=>e({voiceKeepsKeyboardClosed:n.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:p("voice-ime-lock")}),l.jsx("small",{children:p("voice-ime-lock-help")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:t.showKeybarEnter,onChange:n=>e({showKeybarEnter:n.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:p("keybar-enter-show")}),l.jsx("small",{children:p("keybar-enter-show-help")})]})]}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>e(Wr),children:p("input-settings-reset")})})]})}function jI({token:t,roster:e=[],readonly:n}){const i=[{key:"local",route:[],label:p("diagnostics-local"),status:"up"},...e.filter(j=>Array.isArray(j.route)&&j.route.length).map(j=>({key:j.route.join("/"),route:j.route,label:j.label||j.name,status:j.status}))],[s,a]=b.useState("local"),c=i.find(j=>j.key===s)||i[0],[d,h]=b.useState(null),[f,g]=b.useState([]),[_,y]=b.useState(""),[w,S]=b.useState(!1),[A,C]=b.useState(!0),[N,k]=b.useState(900),[O,P]=b.useState("all"),[H,W]=b.useState(""),U=b.useRef(0),G=b.useRef(null),X=b.useCallback(async()=>{try{const j=await q2(t,c.route);if(h(j),y(""),!w){const M=await K2(t,{after:U.current,limit:200},c.route);Array.isArray(M.records)&&M.records.length&&(U.current=M.cursor,g(L=>[...L,...M.records].slice(-500)))}}catch(j){y(j&&j.status===404?p("diagnostics-unsupported"):String(j.message||j))}},[t,c.key,w]);b.useEffect(()=>{U.current=0,g([]),h(null),y("")},[c.key]),b.useEffect(()=>{let j=null,M=!0;const L=()=>{!M||document.visibilityState==="hidden"||X()},R=()=>{j&&clearInterval(j),j=document.visibilityState==="hidden"?null:setInterval(L,2e3),document.visibilityState!=="hidden"&&L()};return document.addEventListener("visibilitychange",R),R(),()=>{M=!1,j&&clearInterval(j),document.removeEventListener("visibilitychange",R)}},[X]),b.useEffect(()=>{A&&G.current&&(G.current.scrollTop=G.current.scrollHeight)},[f,A]);const Q=f.filter(j=>(O==="all"||j.level===O)&&(!H||String(j.component||"").toLowerCase().includes(H.toLowerCase()))),V=Q.map(j=>`${j.ts} ${j.level.toUpperCase()} ${j.component} ${j.code} ${j.message}${Object.keys(j.meta||{}).length?` ${JSON.stringify(j.meta)}`:""}`).join(`
|
|
168
|
-
`),T=async j=>{y("");try{const M=await j();h(M),await X()}catch(M){y(String(M.message||M))}},I=async()=>{try{await navigator.clipboard.writeText(V)}catch{y(p("copy-manual"))}},$=()=>{try{const j=new Blob([`${JSON.stringify(Q,null,2)}
|
|
169
|
-
`],{type:"application/json"}),M=URL.createObjectURL(j),L=document.createElement("a");L.href=M,L.download="nexuscrew-diagnostics.json",L.click(),URL.revokeObjectURL(M)}catch{y(p("diagnostics-export-failed"))}};return l.jsxs("div",{className:"nc-set-tab nc-diagnostics",children:[l.jsxs("label",{className:"nc-field",children:[p("diagnostics-target"),l.jsx("select",{value:c.key,onChange:j=>a(j.target.value),children:i.map(j=>l.jsxs("option",{value:j.key,children:[j.label,j.status!=="up"?` · ${j.status}`:""]},j.key))})]}),l.jsxs("div",{className:"nc-set-form nc-diag-controls",children:[l.jsx("div",{className:"nc-sheet-label",children:p("diagnostics-verbose")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("select",{"aria-label":p("diagnostics-duration"),value:N,onChange:j=>k(Number(j.target.value)),disabled:n,children:[300,900,1800,3600].map(j=>l.jsxs("option",{value:j,children:[j/60," min"]},j))}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||(d==null?void 0:d.verbose)===!0,onClick:()=>T(()=>cy(t,!0,N,c.route)),children:p("enable")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||(d==null?void 0:d.verbose)!==!0,onClick:()=>T(()=>cy(t,!1,N,c.route)),children:p("stop")})]}),l.jsx("small",{className:"nc-set-hint",children:d!=null&&d.verbose?p("diagnostics-expires").replace("{time}",new Date(d.expiresAt).toLocaleTimeString()):p("diagnostics-off")})]}),l.jsxs("div",{className:"nc-diag-filters",children:[l.jsxs("select",{"aria-label":p("diagnostics-level"),value:O,onChange:j=>P(j.target.value),children:[l.jsx("option",{value:"all",children:p("diagnostics-all-levels")}),["debug","info","warn","error"].map(j=>l.jsx("option",{value:j,children:j},j))]}),l.jsx("input",{"aria-label":p("diagnostics-component"),placeholder:p("diagnostics-component"),value:H,onChange:j=>W(j.target.value)})]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:w,onChange:j=>S(j.target.checked)})," ",p("diagnostics-pause")]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:A,onChange:j=>C(j.target.checked)})," ",p("diagnostics-autoscroll")]})]}),l.jsx("pre",{ref:G,className:"nc-diag-log","aria-label":p("diagnostics-log"),children:V||p("diagnostics-empty")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:I,children:p("copy")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:$,children:p("diagnostics-export")}),l.jsx("button",{type:"button",className:"nc-btn danger",disabled:n,onClick:()=>{window.confirm(p("diagnostics-clear-confirm"))&&T(async()=>{const j=await V2(t,c.route);return U.current=0,g([]),j})},children:p("diagnostics-clear")})]}),_&&l.jsx("div",{className:"nc-err",children:_})]})}function TI({token:t,settings:e,readonly:n,refresh:i,roster:s,section:a,setSection:c}){const[d,h]=b.useState(null),[f,g]=b.useState(null),[_,y]=b.useState(!1),[w,S]=b.useState(!1),[A,C]=b.useState(null),[N,k]=b.useState(!0),[O,P]=b.useState(!1),[H,W]=b.useState(null);b.useEffect(()=>{C(e&&e.update||null),k(!e||e.autoUpdate!==!1),P(!!(e&&e.alternateScreen))},[e]);const U=async()=>{h(null),g(null),S(!0);try{const L=await N2(t);g(L.note||"ok"),y(!1)}catch(L){h(String(L.message||L))}S(!1)},G=async()=>{h(null),g(null),S(!0);try{const L=await H2(t);g(`${L.note||"ok"}${L.target?` (${L.target})`:""}`)}catch(L){h(String(L.message||L))}S(!1)},X=async L=>{h(null),g(null),S(!0);try{await fp(t,{autoUpdate:L}),k(L),i&&await i()}catch(R){h(String(R.message||R))}S(!1)},Q=async L=>{h(null),g(null),S(!0);try{await fp(t,{alternateScreen:L}),P(L),i&&await i()}catch(R){h(String(R.message||R))}S(!1)},V=b.useCallback(async()=>{if(t)try{W(await E2(t))}catch{W(null)}},[t]);b.useEffect(()=>{V()},[V]);const T=async L=>{h(null),g(null),S(!0);try{if(!L&&H&&H.running&&!window.confirm(p("ai-desktop-confirm-stop"))){S(!1);return}const R=await Y0(t,L);R&&R.ok===!1&&h(R.error||"comando fallito"),await V(),i&&await i()}catch(R){h(String(R.message||R))}S(!1)},I=async()=>{h(null),g(null),S(!0);try{C(await U2(t))}catch(L){h(String(L.message||L))}S(!1)},$=async()=>{h(null),g(null),S(!0);try{const L=await W2(t);C(L),g(p("npm-update-restarting"))}catch(L){h(String(L.message||L))}S(!1)},j=()=>{window.confirm(p("composer-clear-confirm"))&&(h(null),Mj()?(window.dispatchEvent(new Event(bm)),g(p("composer-clear-done"))):h(p("composer-clear-failed")))},M=e&&e.service;return l.jsxs("div",{className:"nc-set-tab",children:[l.jsx("div",{className:"nc-system-tabs",role:"tablist","aria-label":p("tab-system"),children:["general","diagnostics"].map(L=>l.jsx("button",{type:"button",role:"tab","aria-selected":a===L,className:`nc-set-tabbtn${a===L?" on":""}`,onClick:()=>c(L),children:p(`system-${L}`)},L))}),a==="general"&&l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:p("system-this-node")}),e&&l.jsxs("div",{className:"nc-set-info",children:["v",e.version," · ",e.platform," · :",e.port,l.jsx("br",{}),M&&M.installed?p("service-installed"):p("service-missing"),M&&M.installed?` · ${M.active?p("service-active"):p("service-inactive")}`:"",M?` · boot ${M.boot?"on":"off"}`:""]}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||w,title:n?p("settings-readonly"):"",onClick:G,children:p("service-regenerate")})}),l.jsx(LI,{token:t,readonly:n}),l.jsx(RI,{})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:p("system-updates")}),l.jsxs("div",{className:"nc-set-form nc-update-settings",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:N,disabled:n||w||A&&!A.supported,onChange:L=>X(L.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:p("npm-auto-update")}),l.jsx("small",{children:p("npm-auto-update-help")})]})]}),A&&l.jsxs("div",{className:"nc-set-info",children:[p("npm-update-current")," v",A.current,A.latest?` · ${p("npm-update-latest")} v${A.latest}`:""," · ",p(A.supported?A.phase==="idle"&&A.checked!==!0?"npm-update-never":`npm-update-${A.phase}`:"unsupported")]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||w||!A||!A.supported,onClick:I,children:p("npm-update-check")}),A&&A.available&&l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||w||A.phase==="installing",onClick:$,children:p("npm-update-install")})]}),A&&A.lastError&&l.jsx("div",{className:"nc-err",children:A.lastError})]})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:p("ai-desktop-title")}),l.jsxs("div",{className:"nc-set-form",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":p("ai-desktop"),disabled:n||w,checked:!!(H&&H.desired),onChange:L=>T(L.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:p("ai-desktop")}),l.jsx("small",{children:p("ai-desktop-help")})]})]}),H&&!H.desired&&H.running&&l.jsx("div",{className:"nc-set-info",children:p("ai-desktop-stop-pending")})]})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:p("system-security")}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||w,title:n?p("settings-readonly"):"",onClick:()=>{h(null),g(null),y(!0)},children:p("token-rotate")})})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:p("system-local-data")}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:p("composer-clear-data")}),l.jsx("small",{className:"nc-set-hint",children:p("composer-clear-data-help")}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:j,children:p("composer-clear-data")})})]})]})]}),a==="diagnostics"&&l.jsxs("section",{className:"nc-system-group nc-system-diagnostics",children:[l.jsx("h3",{children:p("system-diagnostics")}),l.jsxs("div",{className:"nc-set-form nc-alternate-screen-settings",children:[l.jsx("div",{className:"nc-sheet-label",children:p("system-terminal")}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":p("alternate-screen"),checked:O,disabled:n||w,onChange:L=>Q(L.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:p("alternate-screen")}),l.jsx("small",{children:p("alternate-screen-help")})]})]})]}),l.jsx(jI,{token:t,roster:s,readonly:n})]}),_&&l.jsxs("div",{className:"nc-set-confirm",children:[l.jsx("div",{children:p("token-rotate-explain")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:w,onClick:()=>y(!1),children:p("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:w,onClick:U,children:p("confirm")})]})]}),f&&l.jsx("div",{className:"nc-set-note",children:f}),d&&l.jsx("div",{className:"nc-err",children:d})]})}function PI({token:t,onClose:e,initialTab:n="nodes",initialLocation:i="",startNewCell:s=!1}){Li();const a=n==="diagnostics"?"diagnostics":"general",[c,d]=b.useState(n==="diagnostics"?"system":n),h=b.useRef(null),f=b.useRef(null),[g,_]=b.useState({start:!1,end:!1}),[y,w]=b.useState(a),[S,A]=b.useState(null),[C,N]=b.useState([]),[k,O]=b.useState(null),[P,H]=b.useState([]),[W,U]=b.useState(!1),[G,X]=b.useState(null),[Q,V]=b.useState(0),T=sg(t,!0,Q),I=b.useCallback(()=>{const j=h.current;if(!j)return;const M=j.scrollWidth>j.clientWidth+1,L={start:M&&j.scrollLeft>1,end:M&&j.scrollLeft+j.clientWidth<j.scrollWidth-1};_(R=>R.start===L.start&&R.end===L.end?R:L)},[]);b.useEffect(()=>{const j=h.current;if(!j)return;const M=typeof ResizeObserver=="function"?new ResizeObserver(I):null;return M==null||M.observe(j),window.addEventListener("resize",I),I(),()=>{M==null||M.disconnect(),window.removeEventListener("resize",I)}},[I]),b.useEffect(()=>{var M,L;(L=(M=f.current)==null?void 0:M.scrollIntoView)==null||L.call(M,{behavior:"smooth",block:"nearest",inline:"nearest"});const j=window.requestAnimationFrame?window.requestAnimationFrame(I):setTimeout(I,0);return()=>{window.cancelAnimationFrame?window.cancelAnimationFrame(j):clearTimeout(j)}},[c,I]);const $=b.useCallback(async()=>{var j;try{const M=await q0(t);A(M),X(null)}catch(M){X(String(M.message||M))}try{const M=await C2(t),L=M.peers||[];O(Number.isInteger(M.accessRevision)?M.accessRevision:null);let R=[],E=[];try{const[z,D]=await Promise.all([un("/api/config",t).then(se=>se.json()).catch(()=>null),V0(t).catch(()=>null)]),q=z&&typeof z.instanceId=="string"?z.instanceId:"",ce=[{instanceId:q||null,route:[],label:null},...B1(D,q)],ge=await Promise.all(ce.map(async se=>{try{return{ok:!0,peers:((await K0(t,se.route)).nodes||[]).map(fe=>D1(fe,se)).filter(Boolean)}}catch(we){return{ok:!1,owner:se,error:we}}}));for(const se of ge){if(se.ok){R.push(...se.peers);continue}se.owner.route.length!==0&&E.push({instanceId:se.owner.instanceId,label:se.owner.label,route:se.owner.route,failure:/timeout/i.test(String(((j=se.error)==null?void 0:j.message)||se.error))?"timeout":"unreachable"})}}catch{}H(E),N([...L,...R])}catch(M){X(String(M.message||M))}},[t]);return b.useEffect(()=>{$();const j=setInterval($,5e3);return()=>clearInterval(j)},[$]),b.useEffect(()=>{let j=!1;return un("/api/config",t).then(M=>M.json()).then(M=>{j||U(!!M.readonlyDefault)}).catch(()=>{}),()=>{j=!0}},[t]),l.jsx("div",{className:"nc-set-overlay",onClick:e,children:l.jsxs("div",{className:"nc-set-panel",onClick:j=>j.stopPropagation(),children:[l.jsxs("div",{className:"nc-set-head",children:[l.jsx(kt,{name:"gear",size:18}),l.jsx("b",{children:p("settings")}),l.jsx("button",{type:"button",className:"nc-set-close",onClick:e,title:p("close"),children:l.jsx(kt,{name:"x",size:18})})]}),W&&l.jsx("div",{className:"nc-set-readonly",children:p("settings-readonly")}),G&&l.jsx("div",{className:"nc-err",children:G}),l.jsx("div",{className:`nc-set-tabs-wrap${g.start?" has-start-overflow":""}${g.end?" has-end-overflow":""}`,children:l.jsx("div",{className:"nc-set-tabs",ref:h,onScroll:I,children:["nodes","fleet","audio","input","system"].map(j=>l.jsx("button",{ref:c===j?f:null,type:"button",className:`nc-set-tabbtn${c===j?" on":""}`,onClick:()=>d(j),children:p(`tab-${j}`)},j))})}),l.jsxs("div",{className:"nc-set-body",children:[c==="nodes"&&l.jsx(NI,{token:t,nodes:C,roster:T,settings:S,readonly:W,vlUnavailable:P,accessRevision:k,refresh:$,refreshAliases:()=>V(j=>j+1)}),c==="fleet"&&l.jsx(lI,{token:t,readonly:W,startNewCell:s,initialLocation:i,targets:T.map(j=>({route:j.route,label:j.label||j.name,status:j.status}))}),c==="audio"&&l.jsx(AI,{token:t,readonly:W,nodes:C,settings:S}),c==="input"&&l.jsx(MI,{}),c==="system"&&l.jsx(TI,{token:t,settings:S,readonly:W,refresh:$,roster:T,section:y,setSection:w})]})]})})}function II({token:t,initialPair:e,deviceDefault:n="",localNodeId:i="",localNameDefault:s="",onPairDone:a,onDone:c}){Li();const[d,h]=b.useState(e?"pair":"welcome"),[f,g]=b.useState(!1),[_,y]=b.useState(null),[w,S]=b.useState(null),A=async()=>{g(!0),y(null);try{await fp(t,{wizardDone:!0}),a&&a(),c()}catch(C){y(String(C.message||C)),g(!1)}};return l.jsx("div",{className:"nc-wiz-overlay",children:l.jsxs("div",{className:"nc-wiz",children:[l.jsxs("div",{className:"nc-wiz-head",children:[l.jsx("b",{children:p("wizard-title")}),l.jsx("small",{children:p("hydra-simple")})]}),d==="welcome"&&l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx("div",{className:"nc-wiz-done",children:p("local-ready")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",disabled:f,onClick:A,children:p("local-only")}),l.jsx("button",{className:"nc-btn primary",disabled:f,onClick:()=>h("pair"),children:p("add-node")})]})]}),d==="pair"&&l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx(Fx,{token:t,initial:e||"",autoStart:!!e,deviceDefault:n,localNodeId:i,localNameDefault:s,onBusyChange:g,onSuccess:async C=>{S(C&&C.authorizedKeys?{line:C.authorizedKeys,note:C.authorizedKeysNote||""}:null),a&&a(),h("done")}}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{className:"nc-btn ghost",disabled:f,onClick:()=>{a&&a(),h("welcome")},children:p("back")})})]}),d==="done"&&l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx("div",{className:"nc-wiz-done",children:p("node-connected")}),w&&l.jsx(kg,{line:w.line,note:w.note}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{className:"nc-btn primary",disabled:f,onClick:A,children:p("finish")})})]}),_&&l.jsx("div",{className:"nc-err",children:_})]})})}const DI=50;function BI(t){if(Number.isFinite(t))return t;const e=typeof t=="string"?Date.parse(t):NaN;return Number.isFinite(e)?e:0}function OI(t,e){return`${String(t)}|${String(e)}`}function y0(t,e){if(!t||typeof t!="object"||t.type!=="notify"||!t.eventId)return null;const n=typeof t.title=="string"?t.title:"",i=typeof t.body=="string"?t.body:"";return!n&&!i?null:{key:OI(e,t.eventId),ownerId:String(e),eventId:String(t.eventId),title:n,body:i,urgency:t.urgency==="high"?"high":"normal",ts:BI(t.ts)}}function w0(t){return[...t].sort((e,n)=>n.ts-e.ts).slice(0,DI)}function $I(t,e,n){const i=new Map;for(const s of t||[])i.set(s.key,s);for(const s of e||[])s&&i.set(s.key,s);return[...i.values()]}function zI(t,e){if(typeof EventSource>"u"||!t)return()=>{};const n=new EventSource(`/api/events?token=${encodeURIComponent(t)}`);return n.onmessage=i=>{try{const s=JSON.parse(i.data);s&&typeof s=="object"&&typeof s.type=="string"&&e(s)}catch{}},()=>{try{n.close()}catch{}}}const FI=6e3,HI=12e3,cr=(t,e,n)=>`${e||""}:${n||t}`,UI=(t,e)=>{const n=t&&t[e];return n?n.stale===!0||n.error===!0?"degraded":"live":"missing"};function lC(t,e){const n=new Set(t.map(s=>cr(s.id,s.ownerId,s.ownerAskId))),i=(e||[]).filter(s=>s&&s.id&&!n.has(cr(s.id,s.ownerId,s.ownerAskId)));return i.length?[...t,...i]:t}function WI(t,e){const n=lC([],t.filter(a=>a.imported)),i=new Set(n.map(a=>cr(a.id,a.ownerId,a.ownerAskId)));return[...(e||[]).filter(a=>a&&a.id&&!i.has(cr(a.id,a.ownerId,a.ownerAskId))),...n]}function qI({n:t,onClose:e}){return l.jsxs("div",{className:`nc-ntf-toast${t.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[l.jsxs("div",{className:"nc-ntf-toast-txt",children:[l.jsx("b",{children:t.title}),t.body&&l.jsx("small",{children:t.body}),t.session&&l.jsx("span",{className:"nc-ntf-from",children:t.session}),t.ownerId&&l.jsx("span",{className:"nc-ntf-from",children:p("feed-owner")})]}),l.jsx("button",{type:"button",className:"nc-ntf-x",onClick:e,title:p("close"),children:l.jsx(kt,{name:"x",size:14})})]})}function KI({ask:t,token:e,onAnswered:n,onDismiss:i,askReplyAccess:s=!1,feedViewState:a="live",initialUncertainRid:c=null}){const[d,h]=b.useState(""),[f,g]=b.useState(!1),[_,y]=b.useState(null),[w,S]=b.useState(!1),[A,C]=b.useState(c),[N,k]=b.useState(!1),[O,P]=b.useState(!1),H=async U=>{const G=String(U||"").trim();if(!(!G||f)){y(null),g(!0);try{if(t.ownerId){const X=t.ownerAskId||t.id,Q=await Q2(e,{ownerId:t.ownerId,askId:X,text:G});if(Q&&Q.uncertain){C(Q.originalRequestId||null),P(!Q.originalRequestId);return}n(t.id,t.ownerId)}else await G2(e,t.id,G),n(t.id)}catch(X){y(String(X.message||X))}g(!1)}},W=async()=>{if(!w){S(!0);try{if(t.ownerId){if(A)return;await eE(e,{ownerId:t.ownerId,askId:t.ownerAskId||t.id}),i(t.id,t.ownerId)}else await X2(e,t.id),i(t.id)}catch{S(!1)}}};return l.jsxs("div",{className:"nc-ask-card",children:[l.jsxs("div",{className:"nc-ask-head",children:[l.jsx("span",{className:"nc-ntf-from",children:t.session}),t.ownerId&&l.jsx("span",{className:"nc-ntf-from",children:p("feed-owner")}),l.jsxs("code",{className:"nc-ask-id",children:["#",t.id]}),l.jsx("button",{type:"button",className:"nc-ask-dismiss",title:p("ask-dismiss"),"aria-label":p("ask-dismiss"),disabled:w||!!t.ownerId&&s===!1,onClick:W,children:l.jsx(kt,{name:"x",size:14})})]}),l.jsx("div",{className:"nc-ask-q",children:t.question}),t.ownerId&&s===!1&&l.jsx("small",{className:"nc-set-hint",children:p(a==="live"?"ask-remote-readonly":"ask-remote-no-feed")}),(A||O)&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-err",children:p("ask-uncertain")}),O&&!A&&l.jsx("div",{className:"nc-err",children:p("ask-reconcile")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:N,onClick:async()=>{k(!0);try{const U=await J2(e,{ownerId:t.ownerId,askId:t.ownerAskId||t.id,requestId:A});U&&(U.state==="committed"||U.state==="failed")&&i(t.id,t.ownerId)}finally{k(!1)}},children:p("ask-verify")})]}),(!t.ownerId||s===!0)&&!A&&!O&&l.jsxs(l.Fragment,{children:[Array.isArray(t.options)&&t.options.length>0&&l.jsx("div",{className:"nc-ask-opts",children:t.options.map(U=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:f,onClick:()=>H(U),children:U},U))}),l.jsxs("div",{className:"nc-ask-reply",children:[l.jsx("textarea",{rows:2,placeholder:p("ask-reply-ph"),value:d,disabled:f,onChange:U=>h(U.target.value)}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:f||!d.trim(),onClick:()=>H(d),children:p("send")})]})]}),_&&l.jsx("div",{className:"nc-err",children:_})]})}function VI({token:t}){const[e]=Li(),[n]=aC(),[i,s]=b.useState([]),[a,c]=b.useState([]),[d,h]=b.useState([]),[f,g]=b.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),_=b.useRef(0),y=b.useRef(null);y.current||(y.current=CI());const w=b.useRef({enabled:n,lang:e});w.current={enabled:n,lang:e};const S=b.useCallback(U=>{s(G=>G.filter(X=>X.key!==U))},[]),A=b.useCallback(U=>{const G=`t${_.current+=1}`;s(Q=>[...Q.slice(-3),{...U,key:G}]),setTimeout(()=>S(G),U.urgency==="high"?HI:FI);const X=w.current;if(X.enabled)try{y.current.enqueue(U,yI(U,X.lang))}catch{}},[S]);b.useEffect(()=>{n||y.current.stop()},[n]),b.useEffect(()=>{const U=()=>{(document.visibilityState!=="visible"||!document.hasFocus())&&y.current.stop()},G=()=>y.current.stop();return document.addEventListener("visibilitychange",U),window.addEventListener("blur",U),window.addEventListener(Nm,G),()=>{document.removeEventListener("visibilitychange",U),window.removeEventListener("blur",U),window.removeEventListener(Nm,G),typeof y.current.dispose=="function"?y.current.dispose():y.current.stop()}},[]);const C=(U,G)=>c(X=>X.filter(Q=>cr(Q.id,Q.ownerId)!==cr(U,G)));b.useEffect(()=>{if(!t)return;let U=!1;Y2(t).then(X=>{U||c(Q=>WI(Q,X.asks))}).catch(()=>{});const G=zI(t,X=>{if(X.type==="notify"&&X.ownerId&&X.eventId){const Q=y0(X,X.ownerId);if(!Q)return;h(V=>w0($I(V,[Q],null)))}if(X.type==="notify")A(X);else if(X.type==="ask"&&X.ask&&X.ask.id){const Q=cr(X.ask.id,X.ask.ownerId);c(V=>V.some(T=>cr(T.id,T.ownerId)===Q)?V:[...V,X.ask])}else(X.type==="ask-answered"&&X.id||X.type==="ask-dismissed"&&X.id)&&C(X.id,X.ownerId)});return()=>{U=!0,G()}},[t,A]);const[N,k]=b.useState({});b.useEffect(()=>{if(!t)return;let U=!0;return Z2(t).then(G=>{if(!U)return;const X={};for(const Q of G&&G.attempts||[])Q&&Q.state==="uncertain"&&Q.ownerId&&Q.askId&&Q.requestId&&(X[Q.ownerId+"|"+Q.askId]=Q.requestId);k(X)}).catch(()=>{}),()=>{U=!1}},[t]);const[O,P]=b.useState({}),[H,W]=b.useState({});return b.useEffect(()=>{let U=!0;return tE(t).then(G=>{if(!U)return;const X={},Q={},V=[],T=new Map,I=new Set;for(const $ of G&&G.views||[]){X[$.ownerId]=$.askReplyAccess===!0,Q[$.ownerId]={stale:$.stale===!0,error:!!$.lastError},I.add($.ownerId);for(const j of $.asks||[])j&&j.id&&V.push({...j,ownerId:$.ownerId,imported:!0});for(const j of $.notifications||[]){const M=y0(j,$.ownerId);M&&T.set(M.key,M)}}P(X),W(Q),V.length&&c($=>lC($,V)),h($=>{const j=[];for(const M of $)I.has(M.ownerId)&&j.push(M);for(const M of T.values())j.push({...M,key:M.key});return w0(j)})}).catch(()=>{}),()=>{U=!1}},[t]),l.jsxs(l.Fragment,{children:[i.length>0&&l.jsx("div",{className:"nc-ntf-toasts",children:i.map(U=>l.jsx(qI,{n:U,onClose:()=>S(U.key)},U.key))}),(a.length>0||d.length>0)&&!f&&l.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>g(!0),title:p("asks-title"),children:["? ",l.jsx("span",{className:"nc-ask-count",children:a.length+d.length})]}),(a.length>0||d.length>0)&&f&&l.jsxs("div",{className:"nc-ask-panel",children:[l.jsxs("div",{className:"nc-ask-panel-head",children:[l.jsx("b",{children:p("asks-title")}),l.jsx("span",{className:"nc-ask-count",children:a.length}),l.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>g(!1),title:p("close"),children:l.jsx(kt,{name:"x",size:16})})]}),l.jsxs("div",{className:"nc-ask-panel-body",children:[a.map(U=>l.jsx(KI,{ask:U,token:t,askReplyAccess:!U.ownerId||O[U.ownerId]===!0,feedViewState:U.ownerId?UI(H,U.ownerId):"live",initialUncertainRid:U.ownerId&&N[U.ownerId+"|"+(U.ownerAskId||U.id)]||null,onAnswered:C,onDismiss:C},cr(U.id,U.ownerId))),d.length>0&&l.jsxs("div",{className:"nc-remote-notices",children:[l.jsx("div",{className:"nc-remote-notices-head",children:l.jsx("b",{children:p("remote-notices-title")})}),d.map(U=>l.jsxs("div",{className:"nc-remote-notice"+(U.urgency==="high"?" nc-remote-notice-high":""),children:[U.title?l.jsx("b",{children:U.title}):null,U.body?l.jsx("div",{children:U.body}):null,l.jsxs("div",{className:"nc-remote-notice-meta",children:[U.ownerId.slice(0,8)," · ",new Date(U.ts||Date.now()).toLocaleString()]})]},U.key))]})]})]})]})}const cC="nc_fontsize",uC=9,dC=24;function Rm(t=globalThis.localStorage){const e=Number(t.getItem(cC));return e>=uC&&e<=dC?e:13}function hC(t,e=globalThis.localStorage){const n=Math.max(uC,Math.min(dC,t));return e.setItem(cC,String(n)),n}const YI=4e3;async function GI(t){const e=await un("/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 up(t,e=[]){var d;const[n,i]=await Promise.allSettled([e.length?Bm(t,e):GI(t),fr(t,e)]),s=n.status==="fulfilled"&&Array.isArray((d=n.value)==null?void 0:d.sessions)?n.value.sessions:Array.isArray(n.value)?n.value:null,a=i.status==="fulfilled"?i.value:null,c=(a==null?void 0:a.available)===!0&&Array.isArray(a.cells)?a.cells:null;return{sessions:s,cells:c,fresh:Array.isArray(s)&&Array.isArray(c)}}function fC(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(i=>(i==null?void 0:i.name)===t.tmuxSession)}function XI(t){const e=new Map((t.sessions||[]).map(s=>[s.name,s])),n=[],i=(s,a,c,d=[],h="")=>{const f=new Map((a||[]).map(g=>[g.name,g]));for(const g of s||[]){const _=f.get(g.tmuxSession)||{},y=vd(g,_),w=fC(g,a,c);n.push({key:Ca(d,g.tmuxSession||g.cell),session:g.tmuxSession,route:d,cellName:g.cell,label:g.cell,node:d.length?d.join("/"):"",nodeLabel:h,live:w,selectable:w,verified:c===!0,working:y.working,degraded:!!g.degraded,active:g.active===!0,activity:_.activity||g.activity||0,subtitle:y.subtitle,preview:_.preview||g.preview||"",telemetry:_.telemetry||null,panelUrl:g.panelUrl||""})}};i(t.cells,[...e.values()],t.localFresh===!0);for(const s of t.nodeGroups||[]){const a=Array.isArray(s.route)?s.route:[];s.kind==="vl"||!a.length||i(s.cells,s.sessions,s.switcherFresh===!0,a,s.label||s.name||"")}return n}function QI(t){const e=new Map,n=Array.isArray(t.sessions)?t.sessions:[],i=Array.isArray(t.cells)?t.cells:[],s=new Map(n.map(c=>[c.name,c])),a=new Set(i.map(c=>c.tmuxSession).filter(Boolean));e.set("local",dg(i,n.filter(c=>!a.has(c.name)),s));for(const c of t.nodeGroups||[]){const d=Array.isArray(c.route)?c.route:[];if(c.kind==="vl"||!d.length)continue;const h=Array.isArray(c.cells)?c.cells:[],f=Array.isArray(c.sessions)?c.sessions:[],g=new Set(h.map(_=>_.tmuxSession).filter(Boolean));e.set(d.join("/"),zl({...c,route:d,cells:h,sessions:f,unmanaged:f.filter(_=>!g.has(_.name))}).rawItems)}return e}function JI(t,e,n,i){return[...new Set(t.map(a=>a.node||"local"))].flatMap(a=>{const c=t.filter(g=>(g.node||"local")===a),d=new Map((e.get(a)||[]).map(g=>[g.key,g])),h=new Map(c.map(g=>[g.key,g])),f=c.map(g=>{const _=d.get(g.key);return{...g,label:(_==null?void 0:_.label)||g.label,live:(_==null?void 0:_.live)??g.live,fresh:(_==null?void 0:_.fresh)===!0,activity:(_==null?void 0:_.activity)??g.activity}});return Gr(f,n,"all",hr(i,a)).map(g=>h.get(g.key))})}function ZI({token:t,current:e,onPick:n,onClose:i,panelPort:s=0,nodePanelPorts:a={},localNodeLabel:c="",hostByRoute:d={},onDesignateCell:h,onClearHostCell:f,onLiveHostApplied:g,sideKey:_=null,onToggleSide:y,pollMs:w=YI}){const[S,A]=b.useState(ab),[C,N]=b.useState(!1),[k,O]=b.useState(!1),[P,H]=b.useState(""),[W,U]=b.useState(null),G="stream",[X,Q]=b.useState(Rm),V=F=>Q(J=>hC(J+F)),[T,I]=b.useState(null),[$,j]=b.useState(!1),[M,L]=b.useState(""),R=b.useRef(null),E=b.useRef(null),z=b.useMemo(()=>XI(S),[S]),D=b.useMemo(()=>QI(S),[S]),{pins:q,orders:ce,togglePin:ge,removePin:se,pinError:we,canMoveRoster:_e,moveRoster:fe,stepRoster:ie}=og(),de=b.useMemo(()=>JI(z,D,q,ce),[z,D,q,ce]),me=b.useMemo(()=>C?de:de.filter(F=>F.selectable||F.degraded&&F.active),[de,C]),Ee=b.useMemo(()=>W?me.find(F=>F.key===W&&F.selectable):null,[me,W]);b.useEffect(()=>{W&&!me.some(F=>F.key===W&&F.selectable)&&U(null)},[me,W]);const Se=b.useMemo(()=>T?z.find(F=>F.key===T.key):null,[z,T]),xe=!!(T&&Se);b.useEffect(()=>{we&&we.message&&H(we.message)},[we]),b.useEffect(()=>{var ee;const F=document.activeElement;(ee=E.current)==null||ee.focus();const J=K=>{K.key==="Escape"&&!xe&&i()};return document.addEventListener("keydown",J),()=>{var K;document.removeEventListener("keydown",J),(K=F==null?void 0:F.focus)==null||K.call(F)}},[i,xe]),b.useEffect(()=>{let F=!0,J=!1;const ee=async()=>{if(J)return;J=!0;const ye=ab(),Ze=Array.isArray(ye.nodeGroups)?ye.nodeGroups:[],ct=up(t),st=tt=>tt.kind!=="vl"&&Array.isArray(tt.route)&&tt.route.length>0,xt=await Promise.all(Ze.filter(st).map(async tt=>({group:tt,result:await up(t,tt.route)}))),Et=await ct;if(!F)return;const jt=new Map(xt.map(({group:tt,result:Nt})=>[JSON.stringify(tt.route||[]),Nt])),Ct=Ze.map(tt=>{if(!st(tt))return{...tt,switcherFresh:!1};const Nt=jt.get(JSON.stringify(tt.route||[]));return Nt?{...tt,sessions:Nt.sessions||tt.sessions||[],cells:Nt.cells||tt.cells||[],switcherFresh:Nt.fresh}:{...tt,switcherFresh:!1}}),Xe=ox({...ye,sessions:Et.sessions||ye.sessions||[],cells:Et.cells||ye.cells||[],localFresh:Et.fresh,nodeGroups:Ct,refreshedAt:Date.now()});A(Xe),O(!0),J=!1};ee();const K=setInterval(ee,w);return()=>{F=!1,clearInterval(K)}},[t,w]);const[Ye,Le]=b.useState(""),ze={getLiveHost:F=>ad(t,F),designateHostCell:(F,J,ee)=>ld(t,F,J,ee),clearHostCell:(F,J)=>cd(t,F,J)},He=F=>(d[yi(F)]||{}).hostCell||null,_t=async(F,J)=>{Le(F.key);const ee=await ud({action:J?"remove":"use",cellId:F.cellName,route:F.route||[],api:ze});Le(""),H(p(ee.messageKey).replace("{cell}",ee.hostCell||F.cellName)),ee.ok&&g&&g({route:F.route||[],hostCell:ee.hostCell,revision:ee.revision})},at=F=>F.degraded?p("cell-degraded"):F.verified?F.selectable?F.working?p("cell-working"):p("cell-idle"):p("cell-off"):p("cell-switcher-not-confirmed"),lt=async F=>{if(H(""),!F.selectable){H(F.verified?p("cell-switcher-not-active"):p("cell-switcher-not-confirmed"));return}L(F.key);try{const J=await up(t,F.route),ee=(J.cells||[]).find(K=>(K==null?void 0:K.cell)===F.cellName&&(K==null?void 0:K.tmuxSession)===F.session);if(J.fresh!==!0){H(p("cell-switcher-verify-failed"));return}if(!fC(ee,J.sessions,J.fresh)){H(p("cell-switcher-not-active"));return}n({session:F.session,...F.node?{node:F.node}:{},cellName:F.cellName}),i()}catch{H(p("cell-switcher-verify-failed"))}finally{L("")}},bt=F=>{if(!F.selectable){lt(F);return}if(W===F.key){lt(F);return}U(F.key)},Ht=b.useRef(null),Rt=8,fn=F=>{const J=Ht.current;if(F.isPrimary===!1){J&&J.state==="open"&&(J.state="invalid");return}if(J&&J.state==="open"&&(J.id!==F.pointerId||J.row!==F.currentTarget)){J.state="invalid";return}Ht.current={id:F.pointerId,row:F.currentTarget,x:F.clientX,y:F.clientY,maxDelta:0,state:"open"}},It=F=>{const J=Ht.current;!J||J.state!=="open"||J.id!==F.pointerId||(J.maxDelta=Math.max(J.maxDelta,Math.hypot(F.clientX-J.x,F.clientY-J.y)),J.maxDelta>Rt&&(J.state="invalid"))},Wt=F=>{const J=Ht.current;!J||J.id!==F.pointerId||J.state!=="open"||(J.state=J.maxDelta<=Rt?"tap":"invalid")},ft=F=>{const J=Ht.current;J&&J.id===F.pointerId&&(J.state="invalid")},qt=F=>{const J=Ht.current;return Ht.current=null,F.detail===0?!0:!J||J.state==="invalid"||J.row!==F.currentTarget?!1:Math.hypot(F.clientX-J.x,F.clientY-J.y)<=Rt},$t=F=>({onToggleLive:()=>_t(F,He(F.route||[])===F.cellName),onTogglePin:()=>ag({view:gd({item:{key:F.key,value:{cell:F.cellName}},pins:q,hostByRoute:d,route:F.route||[]}),itemKey:F.key,togglePin:ge,removePin:se})});return l.jsxs("div",{className:"nc-cell-switcher-backdrop",onClick:i,children:[Ee&&l.jsxs("div",{className:"nc-cell-switcher-anteprima","data-testid":"cell-switcher-anteprima",onClick:F=>F.stopPropagation(),children:[l.jsxs("div",{className:"nc-cell-switcher-anteprima-testa",children:[l.jsxs("b",{children:[p("cell-switcher-preview-word")," ",Ee.cellName]}),l.jsx("small",{children:p("cell-switcher-preview-readonly")}),l.jsxs("span",{className:"nc-cell-switcher-anteprima-zoom",children:[l.jsx("button",{type:"button",onClick:()=>V(-1),title:p("zoom-out"),"aria-label":p("zoom-out"),children:"−"}),l.jsxs("span",{"data-testid":"cell-switcher-fontsize",children:[X," px"]}),l.jsx("button",{type:"button",onClick:()=>V(1),title:p("zoom-in"),"aria-label":p("zoom-in"),children:"+"})]})]}),l.jsx(ng,{row:Ee,token:t,source:G,chrome:!1,panelPort:Vl(Ee.route||[],a,s),liveHost:ka({liveHost:d[yi(Ee.route||[])],cells:S.cells||[]}),onLiveHostApplied:g,fontSize:X,readOnly:!0})]}),l.jsxs("aside",{ref:R,className:`nc-cell-switcher${Ee?" with-anteprima":""}`,role:"dialog","aria-label":p("fleet-cells"),tabIndex:-1,onClick:F=>F.stopPropagation(),children:[l.jsxs("div",{className:"nc-cell-switcher-controls",children:[l.jsx("b",{children:p("cell-switcher-title")}),c&&l.jsx("small",{className:"nc-cell-switcher-node",children:c}),l.jsxs("div",{className:"nc-cell-switcher-filter",role:"group","aria-label":p("cell-switcher-filter"),children:[l.jsx("button",{type:"button",className:C?"":"on","aria-pressed":!C,onClick:()=>{H(""),N(!1)},children:p("cell-switcher-show-active")}),l.jsx("button",{type:"button",className:C?"on":"","aria-pressed":C,onClick:()=>{H(""),N(!0)},children:p("cell-switcher-show-all")})]}),l.jsx("button",{type:"button",className:`nc-cell-switcher-reorder${$?" on":""}`,"aria-pressed":$,title:p("reorder-help"),"aria-label":p("reorder"),onClick:()=>{H(""),j(F=>!F)},children:"↕"}),l.jsx("button",{ref:E,type:"button",className:"nc-cell-switcher-close","aria-label":p("cell-switcher-close"),title:p("cell-switcher-close"),onClick:i,children:"×"})]}),!Ee&&l.jsx("div",{className:"nc-cell-switcher-hint",children:p("cell-switcher-tap-hint")}),l.jsxs("div",{className:"nc-cell-switcher-list",children:[(()=>{const F=ka({liveHost:d[yi([])],cells:S.cells||[]});if(!F||!F.cell)return null;const{modeKey:J}=OM(F);return l.jsx("div",{className:"nc-cell-switcher-live-strip","data-testid":"cell-switcher-live-strip",children:p("cell-switcher-live-strip").replace("{cell}",F.cell).replace("{mode}",p(J||"live-host-mode-unknown"))})})(),!k&&l.jsx("div",{className:"nc-empty",role:"status",children:p("cell-switcher-refreshing")}),k&&me.length===0&&l.jsx("div",{className:"nc-empty",role:"status",children:p("cell-switcher-empty-active")}),me.map((F,J)=>{const ee=(e==null?void 0:e.session)===F.session&&((e==null?void 0:e.node)||"")===F.node,K=!!T&&T.key===F.key,ye=_!=null&&_===F.key,Ze=at(F),ct=dm(p,F.activity),st=hm(p,F.telemetry),xt=[ct,st].filter(Boolean).join(" · "),Et=F.node||"local",jt=J>0?me[J-1].node||"local":null,Ct=Et!==jt,Xe=D.get(Et)||z.filter(tt=>(tt.node||"local")===Et);return l.jsxs(b.Fragment,{children:[Ct&&l.jsx("div",{className:"nc-cell-switcher-position",children:p("cell-switcher-group").replace("{node}",F.nodeLabel||c||p("cell-switcher-group-local"))}),l.jsxs("div",{className:`nc-cell-switcher-row${ee?" current":""}${W===F.key?" selected":""}${ye?" side":""}${F.selectable?"":" off"}`,"data-roster-key":F.key,"data-position":Et,children:[$&&l.jsx(Os,{position:Et,itemKey:F.key,label:F.cellName,canMove:_e,onMove:(tt,Nt)=>fe(Et,tt,Nt,Xe),onStep:tt=>ie(Et,F.key,tt,Xe)}),l.jsx("span",{className:"nc-cell-switcher-peek",children:l.jsx("span",{className:`nc-cell-switcher-dot${F.degraded?" warn":F.live?` on${F.working?" working":""}`:""}`})}),l.jsx("button",{type:"button",className:"nc-cell-switcher-row-select","aria-current":ee?"true":void 0,"aria-disabled":!F.selectable,"data-selected":W===F.key?"true":void 0,disabled:M===F.key,onPointerDown:fn,onPointerMove:It,onPointerUp:Wt,onPointerCancel:ft,onClick:tt=>{qt(tt)&&bt(F)},children:l.jsxs("span",{className:"nc-cell-switcher-copy",children:[l.jsxs("span",{className:"nc-cell-switcher-nameline",children:[l.jsx("b",{children:F.cellName}),ee&&l.jsx("span",{className:"nc-cell-switcher-here",children:p("cell-switcher-here")}),W===F.key&&l.jsx("span",{className:"nc-cell-switcher-taptwo",children:p("cell-switcher-two-taps")})]}),l.jsxs("span",{className:"nc-cell-switcher-stateline",children:[l.jsx("small",{className:"nc-cell-switcher-state",children:Ze}),xt&&l.jsx("small",{className:"nc-cell-switcher-telemetry",children:xt})]})]})}),y&&l.jsx("button",{type:"button",className:`nc-cell-switcher-side${ye?" on":""}`,title:p(ye?"cell-switcher-side-remove":"cell-switcher-side-add"),"aria-label":p(ye?"cell-switcher-side-remove":"cell-switcher-side-add"),"aria-pressed":ye?"true":"false",disabled:ee||!F.selectable,onClick:tt=>{tt.stopPropagation(),!ee&&F.selectable&&y(F)},children:l.jsxs("svg",{viewBox:"0 0 24 24",width:"20",height:"20","aria-hidden":"true",focusable:"false",children:[l.jsx("rect",{x:"3.5",y:"5.5",width:"17",height:"13",rx:"1.5"}),l.jsx("line",{x1:"3.5",y1:"12",x2:"20.5",y2:"12"})]})}),l.jsx("button",{type:"button",className:`nc-cell-switcher-menu${K?" on":""}`,title:`${p("cell-actions-open")}: ${F.cellName}`,"aria-label":`${p("cell-actions-open")}: ${F.cellName}`,"aria-haspopup":"menu","aria-expanded":K?"true":"false",onClick:tt=>{tt.stopPropagation(),I({key:F.key})},children:"⋯"})]})]},F.key)})]}),P&&l.jsx("div",{className:"nc-cell-switcher-notice",role:"status",children:P}),xe&&(()=>{const F=Se,J=lg({...Kr({item:{key:F.key,value:{cell:F.cellName}},cellName:F.cellName,route:F.route||[],pins:q,hostByRoute:d}),canBoot:!1,alive:F.selectable,handlers:$t(F)});return l.jsx(cg,{cellName:F.cellName,items:J,busy:Ye===F.key,onClose:()=>I(null)})})()]})]})}function b0(){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 e3=2e3;function t3(t){if(t.kind==="gap")return`${p("vl-events-gap")} ${t.count||"?"}`;if(t.kind==="truncate")return p("vl-events-truncated");if(t.kind==="turn_end")return p("vl-events-turn-end");if(t.kind==="done")return p("vl-events-done");if(t.kind==="writer_epoch")return p("vl-events-writer-epoch");if(t.kind==="tool_start")return`${p("vl-events-tool")} ${t.name||""}`.trim();if(t.kind==="tool_end"){const e=t.isError?p("vl-events-tool-failed"):p("vl-events-tool-ok");return`${p("vl-events-tool")} ${t.name||""} — ${e}`.trim()}return t.kind==="usage"?t.text||p("vl-events-usage"):t.text||""}function n3({token:t,nodeId:e,route:n=[]}){const[i,s]=b.useState([]),[a,c]=b.useState(!1),d=b.useRef(0),h=b.useRef(!1);return b.useEffect(()=>{let f=!0;d.current=0,h.current=!1,s([]);const g=async()=>{if(!h.current){h.current=!0;try{const w=await k2(t,e,d.current,n);if(!f)return;c(!1);const A=(Array.isArray(w==null?void 0:w.events)?w.events:[]).filter(C=>Number.isSafeInteger(C==null?void 0:C.seq)&&C.seq>d.current);A.length&&(s(C=>C.concat(A).slice(-500)),d.current=A[A.length-1].seq),Number.isSafeInteger(w==null?void 0:w.cursor)&&w.cursor>d.current&&(d.current=w.cursor)}catch{f&&c(!0)}finally{h.current=!1}}},_=()=>{g().catch(()=>{})};_();const y=setInterval(_,e3);return()=>{f=!1,clearInterval(y)}},[t,e,JSON.stringify(n)]),l.jsxs("div",{className:"nc-vl-events",children:[a&&l.jsx("div",{className:"nc-set-hint nc-vl-events-stale",children:p("vl-events-stale")}),i.length===0&&!a&&l.jsx("small",{className:"nc-set-hint","data-testid":"vl-events-empty",children:p("vl-events-empty")}),i.length>0&&l.jsx("ol",{className:"nc-vl-events-list",children:i.map(f=>l.jsx("li",{"data-testid":`vl-ev-${f.seq}`,className:`nc-vl-ev nc-vl-ev-${f.kind}${f.isError?" error":""}${f.kind==="gap"?" gap":""}`,children:t3(f)},`${f.seq}-${f.kind}`))})]})}function S0({peer:t,token:e,onBack:n}){var i;return Li(),t?l.jsxs("section",{className:"nc-vl-session-view",children:[l.jsxs("header",{className:"nc-bar nc-bar-single",children:[l.jsxs("button",{onClick:n,title:p("back"),children:[l.jsx(kt,{name:"chevronLeft",size:18}),l.jsx("span",{className:"nc-bar-label",children:p("back")})]}),l.jsxs("span",{className:"nc-bar-center",children:[l.jsx("b",{title:t.label,children:t.label}),((i=t.session)==null?void 0:i.profile)&&l.jsxs("small",{className:"nc-bar-sub",children:[t.session.profile," · ",p("vl-events-title")]})]}),l.jsx("span",{className:"nc-bar-right"})]}),l.jsx("div",{className:"nc-vl-session-body",children:l.jsx(n3,{token:e,nodeId:t.nodeId,route:t.route||[]})})]}):null}const td="nc_dual_side";function Am(t,e){return!t||!e?!1:t.session===e.session&&(t.node||"")===(e.node||"")}function i3(t,e,n){return!n||!n.session||t&&Am(t,n)?e:e&&Am(e,n)?null:{session:n.session,...n.node?{node:n.node}:{},...n.ownerId?{ownerId:n.ownerId}:{}}}function s3(){try{const t=JSON.parse(localStorage.getItem(td)||"null");return!t||!t.main||!t.side||!t.main.session||!t.side.session?null:t}catch{return null}}function r3(t,e){try{if(!t||!e||!t.session||!e.session){localStorage.removeItem(td);return}const n=i=>({session:i.session,...i.node?{node:i.node}:{}});localStorage.setItem(td,JSON.stringify({main:n(t),side:n(e)}))}catch{}}function x0(){try{localStorage.removeItem(td)}catch{}}const o3=.2;function C0(t){return Math.max(o3,t)}const dp=t=>Gi(ks(t)).length===0,hp=t=>Array.isArray(t)?t.join("/"):"",a3="nc-decks-cache-v1",pC=t=>`${a3}:${t}`;function l3(t){if(!t)return[];try{const e=localStorage.getItem(pC(t));if(!e)return[];const n=JSON.parse(e);return Array.isArray(n)&&n.every(i=>i&&typeof i.id=="string"&&typeof i.name=="string")?n:[]}catch{return[]}}function c3(t,e){if(t)try{localStorage.setItem(pC(t),JSON.stringify(e))}catch{}}function u3(t){const e=new Set,n=[];for(const i of Array.isArray(t)?t:[])!i||!zi.test(String(i.instanceId||""))||!Array.isArray(i.route)||!i.route.length||e.has(i.instanceId)||(e.add(i.instanceId),n.push({instanceId:i.instanceId,route:[...i.route],label:String(i.label||i.name||i.route.join(" › ")),status:i.status||"offline",stale:i.stale===!0}));return n.sort((i,s)=>i.label.localeCompare(s.label))}function Nl(t){return{instanceId:t.ownerId,route:t.ownerRoute||[],label:t.ownerLabel,status:t.available===!1?"offline":"up"}}function vo(t,e,n,i=!1,s=!0){const a=e.instanceId;return{...t,id:No(i?null:a,t.name),ownerId:a,ownerRoute:i?[]:[...e.route],ownerLabel:i?"Local":e.label,local:i,available:s,ownerTopology:Array.isArray(n)?n:[],layout:xm(t.layout,a,n)}}function d3(t,e,n,i,s=[]){const[a,c]=b.useState([]),[d,h]=b.useState(!1),[f,g]=b.useState("idle"),[_,y]=b.useState(""),[w,S]=b.useState(!1),[A,C]=b.useState(""),N=b.useRef([]),k=b.useRef([]),O=b.useRef(new Map),P=b.useRef(""),H=b.useRef(e),W=b.useRef(n),U=b.useRef(!1),G=b.useRef(!0),X=b.useRef(""),Q=b.useMemo(()=>u3(s),[s]),V=Q.map(ie=>`${ie.instanceId}:${hp(ie.route)}`).join("|");k.current=Q,W.current=n,H.current=e,N.current=a;const T=b.useCallback(ie=>Cm(ie.layout,P.current,k.current),[]),I=b.useCallback(()=>kl(H.current,P.current),[]),$=b.useCallback(ie=>(Array.isArray(ie)?ie:[]).find(de=>de.id===I()),[I]),j=b.useCallback((ie,de=!0,me)=>{const Ee=me===void 0?I():kl(me,P.current),Se=Sb(ie,wu()),xe=N.current.some(Le=>Le.id===Ee);N.current=Se,c(Se),c3(P.current,Se.map(Le=>{if(!Le.refreshFailedAt)return Le;const ze={...Le};return delete ze.refreshFailedAt,ze}));const Ye=Se.find(Le=>Le.id===Ee);if(de&&Ye){G.current=!0;const Le=T(Ye);i(Le),Ye.local&&lT(Ye.name,ks(Le))}else xe&&!Ye&&(G.current=!0,i(wa()),y("deck non più condiviso dal nodo owner"));sT(Se.filter(Le=>Le.local).map(Le=>Le.name))},[i,T]),M=b.useCallback(async ie=>{let de=await ou(t);const me=de.decks.find(Ee=>Ee.name==="main");if(de.decks.length===1&&me&&me.revision===0&&dp(me.layout)){const Ee=iT(),Se=ks(km("main")||wa());if(!dp(Se)){const xe=xm(Se,ie,[]);de.decks[0]=await au(t,"main",xe,0,[])}for(const xe of Ee.filter(Ye=>Ye!=="main"))try{let Ye=await uy(t,xe,[]);const Le=ks(km(xe)||wa());dp(Le)||(Ye=await au(t,xe,xm(Le,ie,[]),Ye.revision,[]))}catch{}de=await ou(t)}return de},[t]),L=b.useCallback((ie,de)=>{const me=new Map(de.map(xe=>[xe.id,xe])),Ee=new Set,Se=[];for(const xe of N.current){if(xe.local||xe.ownerId!==ie.instanceId){Se.push(xe);continue}const Ye=me.get(xe.id);Ye&&(Se.push(Ye),Ee.add(xe.id))}for(const xe of de)Ee.has(xe.id)||Se.push(xe);j(Se,!1)},[j]),R=b.useCallback(async ie=>{try{const[de,me]=await Promise.all([ou(t,ie.route),ay(t,ie.route).catch(()=>({nodes:[]}))]);L(ie,de.decks.map(Ee=>vo(Ee,ie,me.nodes,!1,!0)))}catch(de){if(de&&(de.status===403||de.status===404)){L(ie,[]);return}const me=N.current.filter(Ee=>!Ee.local&&Ee.ownerId===ie.instanceId).map(Ee=>({...Ee,available:!1,stale:!0,refreshFailedAt:Date.now(),ownerRoute:[...ie.route],ownerLabel:ie.label}));L(ie,me)}},[t,L]),E=b.useCallback(async({migrate:ie=!1}={})=>{const de=await Om(t,[]),me=zi.test(String(de.instanceId||""))?de.instanceId:"";if(!me)throw new Error("instanceId locale non disponibile");P.current=me,C(me);const[Ee,Se]=await Promise.all([ie?M(me):ou(t),ay(t,[]).catch(()=>({nodes:[]}))]),xe={instanceId:me,route:[],label:"Local"},Ye=Ee.decks.map(lt=>vo(lt,xe,Se.nodes,!0,!0)),Le=new Map(k.current.map(lt=>[lt.instanceId,lt])),ze=N.current.length?N.current:l3(me),He=O.current,_t=Date.now(),at=ze.filter(lt=>!lt.local).flatMap(lt=>{const bt=Le.get(lt.ownerId);if(!bt){const Rt=He.get(lt.ownerId);return Rt===void 0?(He.set(lt.ownerId,_t),[{...lt,available:!1,stale:!0}]):_t-Rt>H1?[]:[{...lt,available:!1,stale:!0}]}He.delete(lt.ownerId);const Ht=bt.status==="up";return[{...lt,available:Ht?lt.available!==!1:!1,stale:bt.stale===!0,ownerRoute:[...bt.route],ownerLabel:bt.label}]});return setTimeout(()=>{for(const lt of Le.values())lt.status==="up"&&R(lt)},0),[...Ye,...at]},[t,M,R,V]);b.useEffect(()=>{if(!t)return;let ie=!1;const de=X.current!==t;return X.current=t,E({migrate:de}).then(me=>{if(ie)return;const Ee=$(N.current),Se=$(me),xe=Se&&(!Ee||Se.revision>Ee.revision||Ee.available!==Se.available||hp(Ee.ownerRoute)!==hp(Se.ownerRoute));j(me,de||!!xe&&!U.current),h(!0),Se&&y("")}).catch(me=>{ie||(h(!0),y(String(me.message||me)))}),()=>{ie=!0}},[j,E,V,t,$]);const z=b.useCallback(async(ie,de=!0)=>{if(!d||!U.current)return!0;const me=ie===void 0?I():kl(ie,P.current),Ee=N.current.find(Se=>Se.id===me);if(!Ee)return y(`deck inesistente: ${me}`),!1;if(Ee.available===!1)return y(`nodo owner offline: ${Ee.ownerLabel}`),!1;g("saving");try{const Se=Df(ks(W.current),Ee.ownerId,Ee.ownerTopology),xe=await au(t,Ee.name,Se,Ee.revision,Ee.ownerRoute),Ye=vo(xe,Nl(Ee),Ee.ownerTopology,Ee.local,!0);return j(N.current.map(Le=>Le.id===me?Ye:Le),!1),U.current=!1,g("saved"),y(""),S(!1),setTimeout(()=>g("idle"),1500),!0}catch(Se){if(de&&Se.status===409&&Se.data&&Se.data.current){const xe=N.current.find(Ye=>Ye.id===me);if(xe){const Ye=vo(Se.data.current,Nl(xe),xe.ownerTopology,xe.local,!0);return j(N.current.map(Le=>Le.id===me?Ye:Le),!1),U.current=!0,z(me,!1)}}return g("error"),y(String(Se.message||Se)),Se.status===409&&S(!0),!1}},[d,t,j]),D=b.useCallback(async()=>{try{const ie=await E();U.current=!1,S(!1),j(ie,!0),y("")}catch(ie){y(String(ie.message||ie))}},[E,j]);b.useEffect(()=>{if(!d)return;const ie=G.current&&!U.current;if(G.current=!1,ie)return;U.current=!0,g("saving");const de=setTimeout(z,650);return()=>clearTimeout(de)},[n,d,z]),b.useEffect(()=>{if(!d)return;const ie=()=>{if(!U.current)return;const de=N.current.find(Ee=>Ee.id===I());if(!de||de.available===!1)return;const me=Df(ks(W.current),de.ownerId,de.ownerTopology);nE(t,de.name,me,de.revision,de.ownerRoute)};return window.addEventListener("pagehide",ie),window.addEventListener("beforeunload",ie),()=>{window.removeEventListener("pagehide",ie),window.removeEventListener("beforeunload",ie)}},[d,t,I]),b.useEffect(()=>{if(!d)return;const ie=setInterval(async()=>{try{const de=await E(),me=$(N.current),Ee=$(de),Se=!!(Ee&&me&&Ee.revision>me.revision),xe=!!(Ee&&(!me||Se||me.available!==Ee.available));if(Se&&U.current&&Ee){const Ye=XM(T(Ee),W.current);j(de,!1),i(Ye);return}j(de,xe&&!U.current)}catch{}},5e3);return()=>clearInterval(ie)},[d,E,j,T,i]);const q=b.useCallback(ie=>{i(de=>{const me=ie(de);return me!==de&&(G.current=!0),me})},[]);return{decks:a,records:a,localNodeId:A,ready:d,saveState:f,error:_,setError:y,conflict:w,reloadCurrent:D,saveNow:z,select:async ie=>{if(U.current&&!await z(I()))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const de=N.current.find(me=>me.id===ie);if(!de)throw new Error(`deck inesistente: ${ie}`);return U.current=!1,G.current=!0,T(de)},add:async(ie,de=null)=>{const me=de===$s?N.current.find(xe=>xe.local):de?N.current.find(xe=>xe.ownerId===de):null;if(!me||me.available===!1)throw new Error("nodo owner non disponibile");const Ee=await uy(t,ie,me.ownerRoute),Se=vo(Ee,Nl(me),me.ownerTopology,me.local,!0);return j([...N.current,Se],!1),Se},rename:async(ie,de)=>{const me=N.current.find(Le=>Le.id===ie);if(!me)throw new Error("deck inesistente");if(kl(ie,P.current)===I()&&U.current&&!await z(ie))throw new Error(`salvataggio di "${me.name}" fallito: rinomina annullata`);const Ee=N.current.find(Le=>Le.id===ie);if(!Ee)throw new Error("deck inesistente");const Se=await iE(t,Ee.name,de,Ee.revision,Ee.ownerRoute),xe=vo(Se,Nl(Ee),Ee.ownerTopology,Ee.local,!0),Ye=Ee.local?$s:Ee.ownerId;return Of(oT(wu(),Ye,ie,xe.id)),j(N.current.map(Le=>Le.id===ie?xe:Le),!1),xe},remove:async ie=>{const de=N.current.find(Ee=>Ee.id===ie);if(!de)throw new Error("deck inesistente");kl(ie,P.current)===I()&&(U.current=!1),await sE(t,de.name,de.revision,de.ownerRoute);const me=de.local?$s:de.ownerId;Of(aT(wu(),me,ie)),j(N.current.filter(Ee=>Ee.id!==ie),!1)},reorder:(ie,de)=>{const me=N.current.find(ze=>ze.id===ie),Ee=N.current.find(ze=>ze.id===de);if(!me||!Ee)return!1;const Se=me.local?$s:me.ownerId,xe=Ee.local?$s:Ee.ownerId;if(Se!==xe)return!1;const Ye=N.current.filter(ze=>(ze.local?$s:ze.ownerId)===Se).map(ze=>ze.id),Le=Of(rT(wu(),Se,ie,de,Ye));return j(Sb(N.current,Le),!1),!0},addTileTo:async(ie,de)=>{const me=N.current.find(ze=>ze.id===ie);if(!me)throw new Error("deck inesistente");if(me.available===!1)throw new Error(`nodo owner offline: ${me.ownerLabel}`);const Ee=xx(de,P.current,k.current);if(!Ee)throw new Error("riferimento sessione non valido");const Se=T(me),xe=Df(ix(Se,Ee),me.ownerId,me.ownerTopology),Ye=await au(t,me.name,xe,me.revision,me.ownerRoute),Le=vo(Ye,Nl(me),me.ownerTopology,me.local,!0);return j(N.current.map(ze=>ze.id===ie?Le:ze),!1),Le},viewUpdate:q,localMainId:No(null,"main"),parseDeckId:oc}}const h3="/sw.js",Mm="nc-sw-update";let Zl=null,nd=!1,id=null,mC=Object.freeze({needed:!1,kind:null,version:"",browserVersion:""}),gC=!1;function Pg(){typeof window<"u"&&window.dispatchEvent(new Event(Mm))}function Ig(){const t=id||(nd?{kind:"reload",version:"",browserVersion:""}:null);mC=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 k0(){return mC}function f3(t){return typeof window>"u"?()=>{}:(window.addEventListener(Mm,t),()=>window.removeEventListener(Mm,t))}function Dg(t){nd!==t&&(nd=t,Ig(),Pg())}const Eu="nc-auto-reload",sd="nc-reload";function Bg(){try{return typeof location<"u"?location:null}catch{return null}}function vC(){try{return typeof history<"u"?history:null}catch{return null}}function p3(t){const e=t===void 0?Bg():t;if(!e||typeof e.search!="string")return null;try{return new URLSearchParams(e.search).get(sd)}catch{return null}}function m3(t,{location:e,history:n}={}){const i=e===void 0?Bg():e,s=n===void 0?vC():n;if(!i||!s||typeof s.replaceState!="function")return!1;try{const a=new URLSearchParams(i.search||"");return a.set(sd,t),s.replaceState(s.state??null,"",`${i.pathname||"/"}?${a.toString()}${i.hash||""}`),!0}catch{return!1}}function g3({location:t,history:e}={}){const n=t===void 0?Bg():t,i=e===void 0?vC():e;if(!n||!i||typeof i.replaceState!="function")return!1;try{const s=new URLSearchParams(n.search||"");if(!s.has(sd))return!1;s.delete(sd);const a=s.toString();return i.replaceState(i.state??null,"",`${n.pathname||"/"}${a?`?${a}`:""}${n.hash||""}`),!0}catch{return!1}}const _C="nc-update-dismissed";function yC(){try{return typeof sessionStorage<"u"?sessionStorage:null}catch{return null}}function v3(t,e,n){return[t,e,n].map(i=>i||"").join("|")}let jm=null;function _3(t,e,n){const i=n;return t&&e&&t!==e&&t!==i?{kind:"install",version:t,browserVersion:i}:e&&i&&e!==i?{kind:"stale",version:e,browserVersion:i}:null}function y3(t,e){if(!t)return!1;try{return t.getItem(_C)===e}catch{return!1}}function w3(t={}){const e=t.storage===void 0?yC():t.storage;if(jm&&e)try{e.setItem(_C,jm)}catch{}nd=!1,id=null,Ig(),Pg()}function b3(t,e,n,i={}){const s=i.storage===void 0?yC():i.storage,a=n,c=v3(t,e,a);jm=c;const d=_3(t,e,a);let h=y3(s,c)?null:d;if(h&&h.kind==="stale"){const g=`${e}|${a}`,_=p3(i.location)===g;let y=!1;if(!_&&s&&s.getItem(Eu)!==g){try{s.setItem(Eu,g)}catch{}y=s.getItem(Eu)===g}y&&(m3(g,{location:i.location,history:i.history}),(i.applyImpl||wC)(),h=null)}const f=JSON.stringify(h)===JSON.stringify(id);if(id=h,Ig(),f||Pg(),!d){try{s&&s.removeItem(Eu)}catch{}g3({location:i.location,history:i.history})}}const S3=1200;async function E0(t){if(typeof fetch=="function")try{await Promise.race([fetch(t,{cache:"reload"}),new Promise(e=>setTimeout(e,S3))])}catch{}}async function wC(){try{Zl&&await Zl.update()}catch{}typeof location<"u"&&(await E0(location.pathname),await E0("/version.json"),location.reload())}function x3(t){t.addEventListener("statechange",()=>{t.state==="installed"&&navigator.serviceWorker.controller&&Dg(!0)})}function C3(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{gC&&location.reload()}),navigator.serviceWorker.register(h3).then(t=>{Zl=t,t.waiting&&Dg(!0),t.addEventListener("updatefound",()=>{const e=t.installing;e&&x3(e)}),setInterval(()=>{t.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function k3(){gC=!0,Dg(!1);const t=Zl&&Zl.waiting;t?(t.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function E3({hash:t="",origin:e="",pathname:n="",search:i=""}={}){const s=String(t||"").replace(/^#/,""),a=`${n||""}${i||""}`;if(!s)return{token:"",pair:"",nextUrl:a};const c=new URLSearchParams(s),d=c.get("token")||"",h=c.get("pair")||"",f=h?`${e||""}${n||""}#pair=${h}`:"";return{token:d,pair:f,nextUrl:a}}const bC="nc_side_w",N0="nc_side_min",N3=240,L0=new Set(["absent","present","active","unknown"]);function L3(){const t=Number(localStorage.getItem(bC));return t>=180&&t<=480?t:N3}function R3(){const t={token:"",pair:""};try{const{token:e,pair:n,nextUrl:i}=E3({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(e){t.token=e;try{localStorage.setItem("nc_token",e)}catch{}}if(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=sessionStorage.getItem("nc_token")||localStorage.getItem("nc_token")||""),!t.pair){const e=sessionStorage.getItem("nc_pair");e&&(t.pair=e)}return t}function R0(t){try{return ks(km(t))}catch{return wa()}}function A0(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`}const SC="nc_bar_files_button";function A3(){try{return localStorage.getItem(SC)==="on"}catch{return!1}}function M3(t){try{localStorage.setItem(SC,t?"on":"off")}catch{}}function j3({showComposer:t,showFiles:e,showPanel:n,hasPanel:i,rendererKind:s,filesSetting:a=null,handlers:c={}}={}){const d=[];return typeof c.onToggleComposer=="function"&&d.push({id:"keyboard",kind:"switch",on:!!t,labelKey:"bar-menu-keyboard",descKey:"bar-menu-keyboard-desc",run:c.onToggleComposer}),typeof c.onToggleFiles=="function"&&d.push(a===null?{id:"files",kind:"switch",on:!!e,labelKey:"bar-menu-files",descKey:"bar-menu-files-desc",run:c.onToggleFiles}:{id:"files",kind:"switch",on:!!a,labelKey:"bar-menu-files",descKey:"bar-menu-files-setting-desc",run:c.onToggleFiles}),i&&typeof c.onTogglePanel=="function"&&d.push({id:"panel",kind:"switch",on:!!n,labelKey:"bar-menu-panel",descKey:"bar-menu-panel-desc",run:c.onTogglePanel}),typeof c.onSwitchRenderer=="function"&&d.push({id:"renderer",kind:"switch",on:s==="webgl",labelKey:"bar-menu-renderer",descKey:"bar-menu-renderer-desc",run:c.onSwitchRenderer}),d}function T3(t,e){if(!t||!t.tmux)return"";const n=vd(t,e||{});return n.stato==="lavora"?p("cell-working"):n.stato==="attesa"?p("cell-permission"):n.stato==="ferma"?p("cell-idle"):""}function M0({session:t,node:e,ownerId:n,cellName:i,token:s,readonly:a=!1,panelPort:c=0,onBack:d,onCellSwitcher:h,cellSwitcherOpen:f=!1,liveHost:g=null,side:_=null,onSideClose:y=null,onSideGone:w=null}){Li();const[S]=gg(),A=R1(),[C,N]=b.useState(!1),[k,O]=b.useState(null),[P,H]=b.useState(()=>window.matchMedia("(pointer: coarse)").matches),[W,U]=b.useState(Rm),[G,X]=b.useState(Ol),[Q,V]=b.useState(()=>Ol()),T=()=>{const Ae=_A(yA(Ol()));X(Ae),typeof window<"u"&&window.location.reload()},[I,$]=b.useState(i||t),[j,M]=b.useState(""),[L,R]=b.useState(""),[E,z]=b.useState(""),[D,q]=b.useState(!1),[ce,ge]=b.useState(!1),se=!!_&&ce,[we,_e]=b.useState(!1),[fe,ie]=b.useState({main:1,side:1}),de=b.useRef(fe);de.current=fe;const[me,Ee]=b.useState(null),[Se,xe]=b.useState(!0),Ye=b.useRef(()=>{}),Le=b.useRef(()=>!1),ze=b.useRef(()=>{}),He=b.useRef(!1),_t=b.useRef(null),[at,lt]=b.useState(null),bt=b.useCallback(Ae=>lt({source:"main",ev:Ae}),[]),Ht=b.useCallback(Ae=>lt({source:"side",ev:Ae}),[]),Rt=!!_&&(at==null?void 0:at.source)==="side",fn=Ae=>{ge(Ae),ee((Ae?He:F).current)},It=_?`${_.node||""}:${_.session}`:"";b.useEffect(()=>{ge(!1),_e(!1),ie({main:1,side:1}),Ee(null),lt(Ae=>Ae&&Ae.source==="side"?null:Ae)},[It]);const Wt=Ae=>U(zt=>hC(zt+Ae));b.useEffect(()=>{f||U(Rm())},[f]);const ft=b.useRef(()=>{}),qt=b.useRef(()=>!1),$t=b.useRef(()=>{}),F=b.useRef(!1),[J,ee]=b.useState(!1),[K,ye]=b.useState(!1),Ze=()=>{const Ae=se?He:F;Ae.current=!Ae.current,ee(Ae.current)};b.useEffect(()=>{$(i||t),q(!1)},[i,t]),b.useEffect(()=>{let Ae=!0;const zt=e?e.split("/"):[],Qt=e?`/api/route/${e.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function Tt(){let St=null,it=null;try{const Kt=await(await un(`${Qt}/sessions`,s)).json();Array.isArray(Kt.sessions)&&(St=Kt.sessions.find(Ge=>Ge.name===t))}catch{}try{const Ot=await fr(s,zt);Ot.available&&Array.isArray(Ot.cells)&&(it=Ot.cells.find(Kt=>Kt.tmuxSession===t))}catch{}if(!Ae)return;$(Zu({session:t,cell:it||(i?{cell:i}:null)})),R(typeof(it==null?void 0:it.panelUrl)=="string"?it.panelUrl.trim():""),z(typeof(it==null?void 0:it.cell)=="string"?it.cell:"");let Dt="";it?Dt=[`${it.engine}${it.key?`·${it.key}`:""}`,T3(it,St)].filter(Boolean).join(" · "):St&&(Dt=St.attached?`attached · ${A0(St.activity)}`:St.activity?A0(St.activity):""),M(Dt),xe(!!(St||it))}Tt();const pn=setInterval(Tt,4e3);return()=>{Ae=!1,clearInterval(pn)}},[t,e,s]);const ct=b.useRef(w);ct.current=w,b.useEffect(()=>{if(!_){Ee(null);return}let Ae=!0;const zt=_.node?_.node.split("/"):[],Qt=_.node?`/api/route/${_.node.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function Tt(){var Kt;let St=null,it=null,Dt=!1,Ot=!1;try{const Mn=await(await un(`${Qt}/sessions`,s)).json();Array.isArray(Mn.sessions)&&(Dt=!0,St=Mn.sessions.find(Ri=>Ri.name===_.session))}catch{}try{const Ge=await fr(s,zt);Ge.available&&Array.isArray(Ge.cells)&&(Ot=!0,it=Ge.cells.find(Mn=>Mn.tmuxSession===_.session))}catch{}Ae&&(Ee({title:Zu({session:_.session,cell:it}),present:!!(St||it)}),(Dt||Ot)&&!St&&!it&&((Kt=ct.current)==null||Kt.call(ct)))}Tt();const pn=setInterval(Tt,4e3);return()=>{Ae=!1,clearInterval(pn)}},[_==null?void 0:_.session,_==null?void 0:_.node,s]);const st=se?"side":"main",[xt,Et]=b.useState(A3),jt=()=>lt(Ae=>Ae&&Ae.source===st?null:{source:st,ev:null}),Ct=j3({showComposer:P,showFiles:(at==null?void 0:at.source)===st,showPanel:D,hasPanel:!!L,rendererKind:Q,filesSetting:A?null:xt,handlers:{onToggleComposer:()=>H(Ae=>!Ae),onToggleFiles:A?jt:()=>Et(Ae=>(M3(!Ae),!Ae)),onTogglePanel:()=>q(Ae=>!Ae),onSwitchRenderer:T}}),Xe=Ae=>{Ae.preventDefault();const zt=_t.current;if(!zt)return;const Qt=Ae.clientY,Tt=de.current,pn=zt.clientHeight||1,St=we?-1:1,it=Ot=>{const Kt=Tt.main+Tt.side,Ge=(Qt-Ot.clientY)/pn*Kt*St,Mn=C0(Tt.main+Ge);ie({main:Mn,side:C0(Kt-Mn)})},Dt=()=>{window.removeEventListener("pointermove",it),window.removeEventListener("pointerup",Dt),window.removeEventListener("pointercancel",Dt),window.removeEventListener("blur",Dt)};window.addEventListener("pointermove",it),window.addEventListener("pointerup",Dt),window.addEventListener("pointercancel",Dt),window.addEventListener("blur",Dt)},tt=_&&l.jsxs("div",{className:`nc-dual-pane${se?"":" foco"}`,"data-testid":"pane-main",style:{flexGrow:fe.main},onPointerDown:()=>fn(!1),children:[l.jsxs("div",{className:"nc-dual-strip",children:[l.jsx("span",{className:`nc-dual-dot${Se?" on":""}`,"aria-hidden":"true"}),l.jsx("b",{children:I}),!se&&l.jsx("span",{className:"nc-dual-matita","aria-hidden":"true",title:p("dual-focus"),children:"✎"})]}),l.jsx("div",{className:"nc-dual-body",children:l.jsx($l,{session:t,node:e,token:s,readonly:a,takeSize:!0,focused:!se,sendRef:ft,composerRef:qt,actionRef:$t,ctrlRef:F,setCtrlArmed:ee,onFiles:bt,fontSize:W,selectionMode:K,onSelectionModeChange:ye,keyboardGesture:S.terminalKeyboardGesture,onRendererChange:V})})]},"pane-main"),Nt=_&&l.jsxs("div",{className:`nc-dual-pane${se?" foco":""}`,"data-testid":"pane-side",style:{flexGrow:fe.side},onPointerDown:()=>fn(!0),children:[l.jsxs("div",{className:"nc-dual-strip",children:[l.jsx("span",{className:`nc-dual-dot${me!=null&&me.present?" on":""}`,"aria-hidden":"true"}),l.jsx("b",{children:me?me.title:_.session}),se&&l.jsx("span",{className:"nc-dual-matita","aria-hidden":"true",title:p("dual-focus"),children:"✎"}),l.jsxs("span",{className:"nc-dual-tasti",children:[l.jsx("button",{type:"button",title:p("dual-swap"),"aria-label":p("dual-swap"),onPointerDown:Ae=>Ae.stopPropagation(),onClick:Ae=>{Ae.stopPropagation(),_e(zt=>!zt)},children:"⇅"}),l.jsx("button",{type:"button",title:p("dual-close"),"aria-label":p("dual-close"),onPointerDown:Ae=>Ae.stopPropagation(),onClick:Ae=>{Ae.stopPropagation(),y==null||y()},children:"✕"})]})]}),l.jsx("div",{className:"nc-dual-body",children:l.jsx($l,{session:_.session,node:_.node,token:s,readonly:a,takeSize:!1,focused:se,sendRef:Ye,composerRef:Le,actionRef:ze,ctrlRef:He,setCtrlArmed:ee,onFiles:Ht,fontSize:W,selectionMode:K,onSelectionModeChange:ye,keyboardGesture:S.terminalKeyboardGesture})})]},"pane-side"),kn=l.jsx("div",{className:"nc-dual-handle","data-testid":"dual-handle",role:"separator","aria-orientation":"horizontal",onPointerDown:Xe},"dual-handle");return l.jsxs("div",{className:"nc-app",children:[l.jsxs("header",{className:"nc-bar nc-bar-single",children:[l.jsxs("button",{onClick:d,title:p("sessions"),children:[l.jsx(kt,{name:"chevronLeft",size:18}),l.jsx("span",{className:"nc-bar-label",children:p("sessions")})]}),l.jsxs("span",{className:"nc-bar-center",children:[l.jsx("b",{title:e?`${I} · ${e}`:I,children:I}),g&&g.cell&&g.cell===i?l.jsx("span",{className:`nc-live-host-dot ${ug(g)} nc-live-host-dot-header`,"data-testid":"live-host-header-dot",title:p("live-host-indicator").replace("{cell}",g.cell).replace("{mode}",p(g.mode?`live-host-mode-${g.mode}`:"live-host-mode-unknown")).replace("{state}",p(`live-host-state-${g.state}`))}):null,j&&l.jsx("small",{className:"nc-bar-sub",children:j})]}),l.jsxs("span",{className:"nc-bar-right",children:[l.jsx("button",{onClick:()=>Wt(-1),title:p("zoom-out"),children:l.jsx(kt,{name:"zoomOut",size:18})}),l.jsx("button",{onClick:()=>Wt(1),title:p("zoom-in"),children:l.jsx(kt,{name:"zoomIn",size:18})}),!A&&xt&&l.jsx("button",{type:"button",onClick:jt,title:p("bar-menu-files"),"aria-label":p("bar-menu-files"),"aria-pressed":(at==null?void 0:at.source)===st?"true":"false",children:l.jsx(kt,{name:"folder",size:18})}),l.jsx("button",{type:"button",className:`nc-bar-menu${C?" on":""}`,title:p("bar-menu-open"),"aria-label":p("bar-menu-open"),"aria-haspopup":"menu","aria-expanded":C?"true":"false",onClick:Ae=>{C||O(Ae.currentTarget.getBoundingClientRect()),N(zt=>!zt)},children:"⋯"})]})]}),l.jsxs("div",{className:"nc-termwrap",children:[_?l.jsx("div",{className:"nc-dual",ref:_t,children:we?[Nt,kn,tt]:[tt,kn,Nt]}):l.jsx($l,{session:t,node:e,token:s,readonly:a,takeSize:!0,sendRef:ft,composerRef:qt,actionRef:$t,ctrlRef:F,setCtrlArmed:ee,onFiles:bt,fontSize:W,selectionMode:K,onSelectionModeChange:ye,keyboardGesture:S.terminalKeyboardGesture,onRendererChange:V}),D&&L&&E&&l.jsx(tg,{cellId:E,panelUrl:L,route:e?e.split("/"):[],panelPort:c,token:s,title:I})]}),l.jsx(wj,{onKeyboard:()=>H(Ae=>!Ae),onCellSwitcher:h,cellSwitcherOpen:f,send:Ae=>(se?Ye:ft).current(Ae),action:Ae=>(se?ze:$t).current(Ae),ctrlArmed:J,onCtrl:Ze,selectionMode:K,onSelectionMode:ye,keepKeyboardClosed:S.keybarKeepsKeyboardClosed,showEnter:S.showKeybarEnter,keybarLayout:S.keybarLayout}),P&&l.jsx(mx,{submitText:Ae=>(se?Le:qt).current(Ae),token:s,session:se?_.session:t,node:se?_.node:e,ownerId:se?_.ownerId:n,readonly:a,keepKeyboardClosedOnVoice:S.voiceKeepsKeyboardClosed}),at&&(Rt?l.jsx(wm,{session:_.session,node:_.node,token:s,filesEvent:at.ev,onClose:()=>lt(null)}):at.source==="main"?l.jsx(wm,{session:t,node:e,token:s,filesEvent:at.ev,onClose:()=>lt(null)}):null),C&&(A?l.jsx(X1,{anchorRect:k,items:Ct,onClose:()=>N(!1)}):l.jsx(cg,{cellName:I,items:Ct,onClose:()=>N(!1)}))]})}function P3(){Li();const[t]=b.useState(R3),[e,n]=b.useState(t.token),[i,s]=b.useState(t.pair||""),a=b.useCallback(()=>{s("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[c,d]=b.useState(!1),h=R1(),[f]=b.useState(()=>nT(typeof location<"u"?location.pathname:"/")),[g,_]=b.useState(f.id),y=g===No(null,Xi),[w,S]=b.useState(null),A=ne=>{const le=pr(ne);S(le?{...le,...typeof(ne==null?void 0:ne.cellName)=="string"&&ne.cellName?{cellName:ne.cellName}:{}}:null)},[C,N]=b.useState(null);b.useEffect(()=>{const ne=s3();N(ne&&w&&Am(ne.main,w)?ne.side:null)},[w]);const k=ne=>{const le=w?{session:w.session,node:w.node}:null,Re=i3(le,C,ne);N(Re),Re?r3(le,Re):x0()},O=()=>{N(null),x0()},[P,H]=b.useState([]),[W,U]=b.useState(!0),[G,X]=b.useState(null),[Q,V]=b.useState([]),[T,I]=b.useState([]),[$,j]=b.useState(!1),[M,L]=b.useState(null),[R,E]=b.useState(()=>f.ownerId?wa():R0(f.name)),[z,D]=b.useState(null),[q,ce]=b.useState(null),ge=ne=>ce(pr(ne)),[se,we]=b.useState(null),_e=sg(e,h),fe=b.useMemo(()=>(_e||[]).filter(ne=>ne.instanceId).map(ne=>({instanceId:ne.instanceId,route:ne.route,label:ne.label,status:ne.status,stale:ne.stale===!0})),[_e]),ie=d3(e,g,R,E,fe),de=ie.decks;b.useEffect(()=>{const ne=new Map;for(const le of _e||[]){const Re=(le.route||[le.name]).join("/"),ot=new Set((le.sessions||[]).map(rt=>rt.name));for(const rt of le.cells||[])!rt.cell||!rt.tmuxSession||rt.cell===rt.tmuxSession||ot.has(rt.cell)||ne.set(`${Re}:${rt.cell}`,`${Re}:${rt.tmuxSession}`)}E(le=>qM(le,ne))},[_e]),b.useEffect(()=>{ie.localNodeId&&f.ownerId&&f.ownerId===ie.localNodeId&&E(ne=>ne.columns.some(le=>le.tiles.length)?ne:R0(f.name))},[ie.localNodeId]),b.useEffect(()=>{ie.localNodeId&&(Qj(fe),ie.viewUpdate(ne=>{const le=Cm(ne,ie.localNodeId,fe);return JSON.stringify(le)===JSON.stringify(ne)?ne:le}))},[fe,ie.localNodeId,ie.viewUpdate]);const[me,Ee]=b.useState(null),[Se,xe]=b.useState(null),Ye=b.useRef(0),[Le,ze]=b.useState(!1),[He,_t]=b.useState(L3),[at,lt]=b.useState(!y),[bt,Ht]=b.useState(()=>y?localStorage.getItem(N0)==="1":!0),[Rt,fn]=b.useState(!1),[It,Wt]=b.useState("nodes"),[ft,qt]=b.useState(!1),[$t,F]=b.useState(""),[J,ee]=b.useState(!1),K=(ne="nodes",le=!1,Re="")=>{Wt(ne),qt(le),F(Re),fn(!0)},[ye,Ze]=b.useState(!1),[ct,st]=b.useState({deviceDefault:"",localNodeId:"",localNameDefault:""}),[xt,Et]=b.useState(""),[jt,Ct]=b.useState(!1),[Xe,tt]=b.useState(0),[Nt,kn]=b.useState({});b.useEffect(()=>{try{localStorage.setItem(bC,String(He))}catch{}},[He]),b.useEffect(()=>{try{localStorage.setItem(N0,bt?"1":"")}catch{}},[bt]),b.useEffect(()=>{if(!e)return;let ne=!1;return Promise.all([q0(e),un("/api/config",e).then(le=>le.json())]).then(([le,Re])=>{ne||(st({deviceDefault:le.deviceName||"",localNodeId:le.nodeId||"",localNameDefault:le.localName||""}),Et(le.deviceName||""),Ct(!!Re.readonlyDefault),xA(Re.terminal),tt(Number.isInteger(Re.panelPort)?Re.panelPort:0),kn(Re.nodePanelPorts&&typeof Re.nodePanelPorts=="object"&&!Array.isArray(Re.nodePanelPorts)?Re.nodePanelPorts:{}),(le.firstRun===!0&&!Re.readonlyDefault||i)&&Ze(!0))}).catch(()=>{}),()=>{ne=!0}},[e,i]);const[Ae,zt]=b.useState({}),Qt=b.useCallback(({route:ne,hostCell:le,revision:Re})=>{const ot=yi(ne);zt(rt=>({...rt,[ot]:{hostCell:le||null,hostLease:null,hostRevision:Number.isInteger(Re)?Re:(rt[ot]||{}).hostRevision||0,threadStatus:"absent"}}))},[]),Tt=ne=>{const le=yi(ne),Re=ne.length?((_e||[]).find(ot=>yi(Array.isArray(ot.route)?ot.route:[])===le)||{}).cells||[]:Q;return ka({liveHost:Ae[le]||null,cells:Re,localNodeId:ie.localNodeId,ownerId:ne.length?le:ie.localNodeId})},pn=b.useRef(_e);b.useEffect(()=>{pn.current=_e},[_e]);const St=b.useRef(null);St.current||(St.current=b0());const it=b.useRef(null);it.current||(it.current=b0());const Dt=3500,Ot=b.useCallback(async()=>{const ne=it.current,le=ne.begin();if(le!==null)try{try{const En=await(await un("/api/sessions",e,{timeoutMs:Dt})).json();if(!ne.isCurrent(le))return;En.error?U(!1):(H(En.sessions||[]),U(!0),X(Date.now()))}catch{ne.isCurrent(le)&&U(!1)}let Re=null,ot=null;try{Re=await fr(e,void 0,{timeoutMs:Dt})}catch(ri){ot=ri}if(!ne.isCurrent(le))return;const rt=ig({fs:Re,error:ot});rt.kind==="data"?(V(rt.cells),I(rt.capabilities),j(!1),L(null)):rt.kind==="stale"?(j(!0),L(null)):(V([]),I([]),j(!1),L(rt.reason||""))}finally{ne.end(le)}},[e]);b.useEffect(()=>{let ne=!1;const le=async()=>{const ot=St.current,rt=ot.begin();if(rt!==null)try{const ri=[[],...(pn.current||[]).filter(Xt=>Xt.kind!=="vl"&&Xt.status==="up").map(Xt=>Array.isArray(Xt.route)&&Xt.route.length?Xt.route:[Xt.name])],En=await Promise.all(ri.map(async Xt=>{const Dn=yi(Xt);try{const Gt=await ad(e,Xt,{timeoutMs:Dt});return[Dn,{hostCell:Gt&&typeof Gt.hostCell=="string"?Gt.hostCell:null,hostLease:Gt&&Gt.host&&typeof Gt.host.lease=="string"?Gt.host.lease:null,hostRevision:Number.isInteger(Gt&&Gt.revision)?Gt.revision:0,threadStatus:Gt&&L0.has(Gt.threadStatus)?Gt.threadStatus:"unknown"}]}catch{return[Dn,{error:!0}]}}));if(ne||!ot.isCurrent(rt))return;zt(Xt=>{let Dn=!1;const Gt={...Xt};for(const Zi of En){if(!Zi)continue;const[fi,Zt]=Zi;Gt[fi]=Zt.error?{...Xt[fi]||{},threadStatus:"unknown"}:Zt,Dn=!0}return Dn?Gt:Xt})}finally{ot.end(rt)}};le();const Re=setInterval(le,4e3);return()=>{ne=!0,clearInterval(Re),St.current.reset()}},[e]),b.useEffect(()=>{if(!h)return;Ot();const ne=setInterval(Ot,4e3);return()=>{clearInterval(ne),it.current.reset()}},[h,Ot]);const Kt=b.useCallback(async(ne,le=[])=>{const Re=yi(le),ot=Ae[Re]&&Ae[Re].hostRevision||0;try{const rt=await ld(e,ne,ot,le);return zt(ri=>({...ri,[Re]:{hostCell:rt.hostCell||null,hostLease:rt.host&&typeof rt.host.lease=="string"?rt.host.lease:null,hostRevision:Number.isInteger(rt.revision)?rt.revision:ot,threadStatus:L0.has(rt.threadStatus)?rt.threadStatus:"unknown"}})),{ok:!0}}catch(rt){return{ok:!1,error:rt}}},[e,Ae]),Ge=b.useCallback(async(ne,le=[])=>{const Re=await Kt(ne,le);return Re.ok||window.alert(p(gp(Re.error))),Re.ok},[Kt]),Mn=b.useCallback(async(ne=[])=>{const le=yi(ne),Re=Ae[le]&&Ae[le].hostRevision||0;try{const ot=await cd(e,Re,ne);return zt(rt=>({...rt,[le]:{hostCell:ot.hostCell||null,hostLease:null,hostRevision:Number.isInteger(ot.revision)?ot.revision:Re,threadStatus:"unknown"}})),{ok:!0}}catch(ot){return{ok:!1,error:ot}}},[e,Ae]),Ri=b.useCallback(async(ne=[])=>{const le=await Mn(ne);return le.ok||window.alert(p(gp(le.error))),le.ok},[Mn]);b.useEffect(()=>{let ne=!1;const le=()=>{un("/api/config",e).then(ot=>ot.json()).then(ot=>{ne||b3(ot.version,ot.uiVersion,"0.9.48")}).catch(()=>{})};le();const Re=setInterval(le,6e4);return()=>{ne=!0,clearInterval(Re)}},[e]);const Ai=new Set([...P.map(ne=>ne.name),..._e.flatMap(ne=>ne.sessions.map(le=>le.key))]),Wn=b.useMemo(()=>{const ne=new Map;for(const le of P)le&&typeof le.name=="string"&&Number.isFinite(le.created)&&ne.set(le.name,le.created);return ne},[P]),Qi=Gi(R),Fi=ne=>E(le=>{const Re=xx(ne,ie.localNodeId,fe)||ne,ot=ix(le,Re);return ot===le&&Gi(le).length>=9&&ie.setError(p("grid-full")),ot}),Ji=async(ne,le=[])=>{try{await Im(e,ne,le)}catch{return}const Re=le.length?`${le.join("/")}:${ne}`:ne;E(ot=>Xu(ot,Re)),Ot()},re=async(ne,le,Re=[])=>{try{await W0(e,ne,le,Re)}catch{return}Ot()},be=async(ne,le,Re=[])=>{await F0(e,{cell:ne,enabled:!!le},Re),Ot()},Be=async ne=>{if(!me)return;const{cell:le}=me,Re=Array.isArray(me.route)?me.route:[];let ot=null;try{ot=await hg({token:e,powerCell:me,payload:ne,onNotice:rt=>ie.setError(rt)})}catch(rt){throw ie.setError(String(rt&&rt.message||rt)),rt}if(!ot){const rt=ne.action==="up"?!!ne.boot:ne.boot?!1:!!me.boot;xe({id:++Ye.current,cell:le,route:Re,enabled:rt})}Ot()},We=b.useCallback(ne=>{xe(le=>(le==null?void 0:le.id)===ne?null:le)},[]),wt=async ne=>{if(!(!(ne!=null&&ne.direct)||Le)){ze(!0);try{await $m(e,ne.name,ne.tunnelStatus==="up"?"down":"up")}finally{ze(!1)}}},Y=async(ne,le)=>{const Re=String(le||"").trim();return!(ne!=null&&ne.direct)||!Na(Re)?!1:(await G0(e,ne.name,Re),!0)},te=ne=>{const le=de.find(Re=>Re.id===ne);if(!le)return!1;try{const Re=window.open(Bf(le,e),"_blank");return Re&&(Re.opener=null),!!Re}catch{return!1}},Ce=async ne=>{if(!ne||ne===g)return;const le=await ie.select(ne),Re=ie.records.find(ot=>ot.id===ne);_(ne),E(le),D(null),ce(null);try{history.replaceState(null,"",Bf(Re||ne,null))}catch{}},$e=async(ne,le)=>{const Re=await ie.add(ne,le);await Ce(Re.id)},ke=async(ne,le)=>{const Re=await ie.rename(ne,le);if(ne===g){_(Re.id),E(Cm(Re.layout,ie.localNodeId,fe)),D(null),ce(null);try{history.replaceState(null,"",Bf(Re,null))}catch{}}},ut=async ne=>{await ie.remove(ne),ne===g&&await Ce(ie.localMainId)},pt=async(ne,le)=>{!le||le===g||(await ie.addTileTo(le,ne),E(Re=>Xu(Re,ne)))};if(!e)return l.jsxs("div",{className:"nc-auth",children:[l.jsx("p",{children:p("auth-prompt")}),l.jsx("input",{onChange:ne=>n(ne.target.value.trim()),placeholder:"token"}),l.jsxs("label",{children:[l.jsx("input",{type:"checkbox",checked:c,onChange:ne=>d(ne.target.checked)})," ",p("remember-device")]}),l.jsx("button",{onClick:()=>{(c?localStorage:sessionStorage).setItem("nc_token",e)},children:"ok"})]});const Fe=l.jsxs(l.Fragment,{children:[Rt&&l.jsx(PI,{token:e,initialTab:It,initialLocation:$t,startNewCell:ft,onClose:()=>{fn(!1),qt(!1),F("")}}),ye&&l.jsx(II,{token:e,initialPair:i,...ct,onPairDone:a,onDone:()=>Ze(!1)}),l.jsx(VI,{token:e})]});if(!h)return se?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-single-overlay",children:l.jsx(S0,{peer:se,token:e,onBack:()=>we(null)})}),Fe]}):w?l.jsxs(l.Fragment,{children:[l.jsx(M0,{session:w.session,node:w.node,ownerId:w.ownerId,cellName:w.cellName,token:e,readonly:jt,liveHost:Tt(w.node?w.node.split("/"):[]),panelPort:Vl(w.node?w.node.split("/"):[],Nt,Xe),side:C,onSideClose:O,onSideGone:O,onBack:()=>S(null),onCellSwitcher:()=>ee(!0),cellSwitcherOpen:J}),J&&l.jsx(ZI,{token:e,current:w,localNodeLabel:xt,panelPort:Xe,nodePanelPorts:Nt,hostByRoute:Ae,onDesignateCell:Kt,onClearHostCell:Mn,onLiveHostApplied:Qt,sideKey:C?Ca(C.node?C.node.split("/"):[],C.session):null,onToggleSide:k,onPick:ne=>{A(ne),ee(!1)},onClose:()=>ee(!1)}),Fe]}):l.jsxs(l.Fragment,{children:[l.jsx(pj,{onPick:A,token:e,onSettings:K,onOpenVlSession:we,panelPort:Xe,nodePanelPorts:Nt,hostByRoute:Ae,onDesignateCell:Ge,onClearHostCell:Ri}),Fe]});const Bt=y||!at;return l.jsxs("div",{className:"nc-workspace",children:[Bt&&l.jsx($j,{sessions:P,cells:Q,localVerified:W,activeSessions:Qi,nodeGroups:_e,token:e,onPeekOpen:()=>ee(!1),overlayOpen:J,fleetCapabilities:T,fleetStale:$,fleetOff:M,bootSettlement:Se,onBootSettlementApplied:We,localNodeId:ie.localNodeId,hostByRoute:Ae,onDesignateCell:Ge,onClearHostCell:Ri,onPick:ge,onAddTile:Fi,onPower:Ee,onBoot:be,onBootError:ne=>ie.setError(String((ne==null?void 0:ne.message)||ne)),onNodePower:wt,onNodeRename:Y,onKill:Ji,onVisibility:re,onNew:()=>K("fleet",!0),onSettings:K,onOpenVlSession:we,width:He,collapsed:bt,onResize:_t,onToggleCollapse:()=>Ht(ne=>!ne)}),l.jsxs("div",{className:"nc-workspace-main",children:[l.jsx(kT,{decks:de,currentDeck:g,onCreate:$e,onRename:ke,onDelete:ut,onReorder:ie.reorder,onOpenWindow:te,onNavigate:Ce,saveState:ie.saveState,error:ie.error,conflict:ie.conflict,onReloadDeck:ie.reloadCurrent,sidebarVisible:Bt,onToggleSidebar:y?null:()=>lt(ne=>!ne)}),l.jsx(Xj,{layout:R,onLayoutChange:E,onResizeEnd:()=>{ie.saveNow()},token:e,readonly:jt,sessionsAlive:Ai,localVerified:W,localIdentities:Wn,localVerifiedAt:G,focusSession:z,onFocus:D,onOpenSingle:ge,decks:de,currentDeck:g,onSendToDeck:pt,cells:Q,nodeGroups:_e,panelPort:Xe,nodePanelPorts:Nt})]}),se&&l.jsx("div",{className:"nc-single-overlay",children:l.jsx(S0,{peer:se,token:e,onBack:()=>we(null)})}),q&&l.jsx("div",{className:"nc-single-overlay",children:l.jsx(M0,{session:q.session,node:q.node,ownerId:q.ownerId,cellName:Zu({session:q.session,node:q.node,ownerId:q.ownerId,cells:Q,nodeGroups:_e}),token:e,readonly:jt,liveHost:Tt(q.node?q.node.split("/"):[]),panelPort:Vl(q.node?q.node.split("/"):[],Nt,Xe),onBack:()=>ce(null)})}),me&&l.jsx(Vu,{cell:me,token:e,route:Array.isArray(me.route)?me.route:[],onConfirm:Be,onClose:()=>Ee(null)}),Fe]})}function I3(t){return t.kind==="install"?p("update-installed-restart").replace("{v}",t.version):t.kind==="stale"?p("update-stale").replace("{ui}",t.version).replace("{browser}",t.browserVersion):p("update-available").replace("{v}",t.version).replace(" "," ").trim()}function D3(){Li();const t=b.useSyncExternalStore(f3,k0,k0);return t.needed?l.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"nc-update-msg",children:I3(t)}),t.kind==="stale"&&l.jsx("button",{className:"nc-update-btn",onClick:wC,children:p("reload-no-cache")}),t.kind==="reload"&&l.jsx("button",{className:"nc-update-btn",onClick:k3,children:p("reload")}),l.jsx("button",{className:"nc-update-close",onClick:w3,"aria-label":p("update-dismiss"),title:p("update-dismiss"),children:"×"})]}):null}C3();o2.createRoot(document.getElementById("root")).render(l.jsxs(Zk.StrictMode,{children:[l.jsx(P3,{}),l.jsx(D3,{})]}));
|