@mmmbuto/nexuscrew 0.9.13 → 0.9.15

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.
@@ -1,93 +0,0 @@
1
- (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const u of a.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&s(u)}).observe(document,{childList:!0,subtree:!0});function n(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(o){if(o.ep)return;o.ep=!0;const a=n(o);fetch(o.href,a)}})();function Rf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var pd={exports:{}},na={},md={exports:{}},bt={};/**
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 Wg;function X0(){if(Wg)return bt;Wg=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.iterator;function b(D){return D===null||typeof D!="object"?null:(D=y&&D[y]||D["@@iterator"],typeof D=="function"?D:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,E={};function w(D,B,U){this.props=D,this.context=B,this.refs=E,this.updater=U||S}w.prototype.isReactComponent={},w.prototype.setState=function(D,B){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,B,"setState")},w.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function N(){}N.prototype=w.prototype;function C(D,B,U){this.props=D,this.context=B,this.refs=E,this.updater=U||S}var L=C.prototype=new N;L.constructor=C,x(L,w.prototype),L.isPureReactComponent=!0;var I=Array.isArray,G=Object.prototype.hasOwnProperty,K={current:null},Y={key:!0,ref:!0,__self:!0,__source:!0};function Q(D,B,U){var se,ee={},de=null,ve=null;if(B!=null)for(se in B.ref!==void 0&&(ve=B.ref),B.key!==void 0&&(de=""+B.key),B)G.call(B,se)&&!Y.hasOwnProperty(se)&&(ee[se]=B[se]);var fe=arguments.length-2;if(fe===1)ee.children=U;else if(1<fe){for(var pe=Array(fe),Ve=0;Ve<fe;Ve++)pe[Ve]=arguments[Ve+2];ee.children=pe}if(D&&D.defaultProps)for(se in fe=D.defaultProps,fe)ee[se]===void 0&&(ee[se]=fe[se]);return{$$typeof:e,type:D,key:de,ref:ve,props:ee,_owner:K.current}}function W(D,B){return{$$typeof:e,type:D.type,key:B,ref:D.ref,props:D.props,_owner:D._owner}}function X(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function H(D){var B={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(U){return B[U]})}var $=/\/+/g;function R(D,B){return typeof D=="object"&&D!==null&&D.key!=null?H(""+D.key):B.toString(36)}function O(D,B,U,se,ee){var de=typeof D;(de==="undefined"||de==="boolean")&&(D=null);var ve=!1;if(D===null)ve=!0;else switch(de){case"string":case"number":ve=!0;break;case"object":switch(D.$$typeof){case e:case t:ve=!0}}if(ve)return ve=D,ee=ee(ve),D=se===""?"."+R(ve,0):se,I(ee)?(U="",D!=null&&(U=D.replace($,"$&/")+"/"),O(ee,B,U,"",function(Ve){return Ve})):ee!=null&&(X(ee)&&(ee=W(ee,U+(!ee.key||ve&&ve.key===ee.key?"":(""+ee.key).replace($,"$&/")+"/")+D)),B.push(ee)),1;if(ve=0,se=se===""?".":se+":",I(D))for(var fe=0;fe<D.length;fe++){de=D[fe];var pe=se+R(de,fe);ve+=O(de,B,U,pe,ee)}else if(pe=b(D),typeof pe=="function")for(D=pe.call(D),fe=0;!(de=D.next()).done;)de=de.value,pe=se+R(de,fe++),ve+=O(de,B,U,pe,ee);else if(de==="object")throw B=String(D),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.");return ve}function F(D,B,U){if(D==null)return D;var se=[],ee=0;return O(D,se,"","",function(de){return B.call(U,de,ee++)}),se}function A(D){if(D._status===-1){var B=D._result;B=B(),B.then(function(U){(D._status===0||D._status===-1)&&(D._status=1,D._result=U)},function(U){(D._status===0||D._status===-1)&&(D._status=2,D._result=U)}),D._status===-1&&(D._status=0,D._result=B)}if(D._status===1)return D._result.default;throw D._result}var T={current:null},j={transition:null},z={ReactCurrentDispatcher:T,ReactCurrentBatchConfig:j,ReactCurrentOwner:K};function M(){throw Error("act(...) is not supported in production builds of React.")}return bt.Children={map:F,forEach:function(D,B,U){F(D,function(){B.apply(this,arguments)},U)},count:function(D){var B=0;return F(D,function(){B++}),B},toArray:function(D){return F(D,function(B){return B})||[]},only:function(D){if(!X(D))throw Error("React.Children.only expected to receive a single React element child.");return D}},bt.Component=w,bt.Fragment=n,bt.Profiler=o,bt.PureComponent=C,bt.StrictMode=s,bt.Suspense=p,bt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=z,bt.act=M,bt.cloneElement=function(D,B,U){if(D==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+D+".");var se=x({},D.props),ee=D.key,de=D.ref,ve=D._owner;if(B!=null){if(B.ref!==void 0&&(de=B.ref,ve=K.current),B.key!==void 0&&(ee=""+B.key),D.type&&D.type.defaultProps)var fe=D.type.defaultProps;for(pe in B)G.call(B,pe)&&!Y.hasOwnProperty(pe)&&(se[pe]=B[pe]===void 0&&fe!==void 0?fe[pe]:B[pe])}var pe=arguments.length-2;if(pe===1)se.children=U;else if(1<pe){fe=Array(pe);for(var Ve=0;Ve<pe;Ve++)fe[Ve]=arguments[Ve+2];se.children=fe}return{$$typeof:e,type:D.type,key:ee,ref:de,props:se,_owner:ve}},bt.createContext=function(D){return D={$$typeof:u,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},D.Provider={$$typeof:a,_context:D},D.Consumer=D},bt.createElement=Q,bt.createFactory=function(D){var B=Q.bind(null,D);return B.type=D,B},bt.createRef=function(){return{current:null}},bt.forwardRef=function(D){return{$$typeof:d,render:D}},bt.isValidElement=X,bt.lazy=function(D){return{$$typeof:v,_payload:{_status:-1,_result:D},_init:A}},bt.memo=function(D,B){return{$$typeof:m,type:D,compare:B===void 0?null:B}},bt.startTransition=function(D){var B=j.transition;j.transition={};try{D()}finally{j.transition=B}},bt.unstable_act=M,bt.useCallback=function(D,B){return T.current.useCallback(D,B)},bt.useContext=function(D){return T.current.useContext(D)},bt.useDebugValue=function(){},bt.useDeferredValue=function(D){return T.current.useDeferredValue(D)},bt.useEffect=function(D,B){return T.current.useEffect(D,B)},bt.useId=function(){return T.current.useId()},bt.useImperativeHandle=function(D,B,U){return T.current.useImperativeHandle(D,B,U)},bt.useInsertionEffect=function(D,B){return T.current.useInsertionEffect(D,B)},bt.useLayoutEffect=function(D,B){return T.current.useLayoutEffect(D,B)},bt.useMemo=function(D,B){return T.current.useMemo(D,B)},bt.useReducer=function(D,B,U){return T.current.useReducer(D,B,U)},bt.useRef=function(D){return T.current.useRef(D)},bt.useState=function(D){return T.current.useState(D)},bt.useSyncExternalStore=function(D,B,U){return T.current.useSyncExternalStore(D,B,U)},bt.useTransition=function(){return T.current.useTransition()},bt.version="18.3.1",bt}var Kg;function Pf(){return Kg||(Kg=1,md.exports=X0()),md.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 qg;function Q0(){if(qg)return na;qg=1;var e=Pf(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function u(d,p,m){var v,y={},b=null,S=null;m!==void 0&&(b=""+m),p.key!==void 0&&(b=""+p.key),p.ref!==void 0&&(S=p.ref);for(v in p)s.call(p,v)&&!a.hasOwnProperty(v)&&(y[v]=p[v]);if(d&&d.defaultProps)for(v in p=d.defaultProps,p)y[v]===void 0&&(y[v]=p[v]);return{$$typeof:t,type:d,key:b,ref:S,props:y,_owner:o.current}}return na.Fragment=n,na.jsx=u,na.jsxs=u,na}var Vg;function J0(){return Vg||(Vg=1,pd.exports=Q0()),pd.exports}var l=J0(),k=Pf();const Z0=Rf(k);var zl={},gd={exports:{}},ii={},vd={exports:{}},_d={};/**
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 Yg;function ex(){return Yg||(Yg=1,(function(e){function t(j,z){var M=j.length;j.push(z);e:for(;0<M;){var D=M-1>>>1,B=j[D];if(0<o(B,z))j[D]=z,j[M]=B,M=D;else break e}}function n(j){return j.length===0?null:j[0]}function s(j){if(j.length===0)return null;var z=j[0],M=j.pop();if(M!==z){j[0]=M;e:for(var D=0,B=j.length,U=B>>>1;D<U;){var se=2*(D+1)-1,ee=j[se],de=se+1,ve=j[de];if(0>o(ee,M))de<B&&0>o(ve,ee)?(j[D]=ve,j[de]=M,D=de):(j[D]=ee,j[se]=M,D=se);else if(de<B&&0>o(ve,M))j[D]=ve,j[de]=M,D=de;else break e}}return z}function o(j,z){var M=j.sortIndex-z.sortIndex;return M!==0?M:j.id-z.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var u=Date,d=u.now();e.unstable_now=function(){return u.now()-d}}var p=[],m=[],v=1,y=null,b=3,S=!1,x=!1,E=!1,w=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function L(j){for(var z=n(m);z!==null;){if(z.callback===null)s(m);else if(z.startTime<=j)s(m),z.sortIndex=z.expirationTime,t(p,z);else break;z=n(m)}}function I(j){if(E=!1,L(j),!x)if(n(p)!==null)x=!0,A(G);else{var z=n(m);z!==null&&T(I,z.startTime-j)}}function G(j,z){x=!1,E&&(E=!1,N(Q),Q=-1),S=!0;var M=b;try{for(L(z),y=n(p);y!==null&&(!(y.expirationTime>z)||j&&!H());){var D=y.callback;if(typeof D=="function"){y.callback=null,b=y.priorityLevel;var B=D(y.expirationTime<=z);z=e.unstable_now(),typeof B=="function"?y.callback=B:y===n(p)&&s(p),L(z)}else s(p);y=n(p)}if(y!==null)var U=!0;else{var se=n(m);se!==null&&T(I,se.startTime-z),U=!1}return U}finally{y=null,b=M,S=!1}}var K=!1,Y=null,Q=-1,W=5,X=-1;function H(){return!(e.unstable_now()-X<W)}function $(){if(Y!==null){var j=e.unstable_now();X=j;var z=!0;try{z=Y(!0,j)}finally{z?R():(K=!1,Y=null)}}else K=!1}var R;if(typeof C=="function")R=function(){C($)};else if(typeof MessageChannel<"u"){var O=new MessageChannel,F=O.port2;O.port1.onmessage=$,R=function(){F.postMessage(null)}}else R=function(){w($,0)};function A(j){Y=j,K||(K=!0,R())}function T(j,z){Q=w(function(){j(e.unstable_now())},z)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(j){j.callback=null},e.unstable_continueExecution=function(){x||S||(x=!0,A(G))},e.unstable_forceFrameRate=function(j){0>j||125<j?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):W=0<j?Math.floor(1e3/j):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_getFirstCallbackNode=function(){return n(p)},e.unstable_next=function(j){switch(b){case 1:case 2:case 3:var z=3;break;default:z=b}var M=b;b=z;try{return j()}finally{b=M}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(j,z){switch(j){case 1:case 2:case 3:case 4:case 5:break;default:j=3}var M=b;b=j;try{return z()}finally{b=M}},e.unstable_scheduleCallback=function(j,z,M){var D=e.unstable_now();switch(typeof M=="object"&&M!==null?(M=M.delay,M=typeof M=="number"&&0<M?D+M:D):M=D,j){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=M+B,j={id:v++,callback:z,priorityLevel:j,startTime:M,expirationTime:B,sortIndex:-1},M>D?(j.sortIndex=M,t(m,j),n(p)===null&&j===n(m)&&(E?(N(Q),Q=-1):E=!0,T(I,M-D))):(j.sortIndex=B,t(p,j),x||S||(x=!0,A(G))),j},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(j){var z=b;return function(){var M=b;b=z;try{return j.apply(this,arguments)}finally{b=M}}}})(_d)),_d}var Gg;function tx(){return Gg||(Gg=1,vd.exports=ex()),vd.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 Xg;function nx(){if(Xg)return ii;Xg=1;var e=Pf(),t=tx();function n(i){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+i,c=1;c<arguments.length;c++)r+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+i+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,o={};function a(i,r){u(i,r),u(i+"Capture",r)}function u(i,r){for(o[i]=r,i=0;i<r.length;i++)s.add(r[i])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,m=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},y={};function b(i){return p.call(y,i)?!0:p.call(v,i)?!1:m.test(i)?y[i]=!0:(v[i]=!0,!1)}function S(i,r,c,h){if(c!==null&&c.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return h?!1:c!==null?!c.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function x(i,r,c,h){if(r===null||typeof r>"u"||S(i,r,c,h))return!0;if(h)return!1;if(c!==null)switch(c.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function E(i,r,c,h,g,_,P){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=h,this.attributeNamespace=g,this.mustUseProperty=c,this.propertyName=i,this.type=r,this.sanitizeURL=_,this.removeEmptyString=P}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){w[i]=new E(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var r=i[0];w[r]=new E(r,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){w[i]=new E(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){w[i]=new E(i,2,!1,i,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(i){w[i]=new E(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){w[i]=new E(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){w[i]=new E(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){w[i]=new E(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){w[i]=new E(i,5,!1,i.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function C(i){return i[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(i){var r=i.replace(N,C);w[r]=new E(r,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var r=i.replace(N,C);w[r]=new E(r,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var r=i.replace(N,C);w[r]=new E(r,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){w[i]=new E(i,1,!1,i.toLowerCase(),null,!1,!1)}),w.xlinkHref=new E("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){w[i]=new E(i,1,!1,i.toLowerCase(),null,!0,!0)});function L(i,r,c,h){var g=w.hasOwnProperty(r)?w[r]:null;(g!==null?g.type!==0:h||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(x(r,c,g,h)&&(c=null),h||g===null?b(r)&&(c===null?i.removeAttribute(r):i.setAttribute(r,""+c)):g.mustUseProperty?i[g.propertyName]=c===null?g.type===3?!1:"":c:(r=g.attributeName,h=g.attributeNamespace,c===null?i.removeAttribute(r):(g=g.type,c=g===3||g===4&&c===!0?"":""+c,h?i.setAttributeNS(h,r,c):i.setAttribute(r,c))))}var I=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,G=Symbol.for("react.element"),K=Symbol.for("react.portal"),Y=Symbol.for("react.fragment"),Q=Symbol.for("react.strict_mode"),W=Symbol.for("react.profiler"),X=Symbol.for("react.provider"),H=Symbol.for("react.context"),$=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),O=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),T=Symbol.for("react.offscreen"),j=Symbol.iterator;function z(i){return i===null||typeof i!="object"?null:(i=j&&i[j]||i["@@iterator"],typeof i=="function"?i:null)}var M=Object.assign,D;function B(i){if(D===void 0)try{throw Error()}catch(c){var r=c.stack.trim().match(/\n( *(at )?)/);D=r&&r[1]||""}return`
34
- `+D+i}var U=!1;function se(i,r){if(!i||U)return"";U=!0;var c=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(he){var h=he}Reflect.construct(i,[],r)}else{try{r.call()}catch(he){h=he}i.call(r.prototype)}else{try{throw Error()}catch(he){h=he}i()}}catch(he){if(he&&h&&typeof he.stack=="string"){for(var g=he.stack.split(`
35
- `),_=h.stack.split(`
36
- `),P=g.length-1,q=_.length-1;1<=P&&0<=q&&g[P]!==_[q];)q--;for(;1<=P&&0<=q;P--,q--)if(g[P]!==_[q]){if(P!==1||q!==1)do if(P--,q--,0>q||g[P]!==_[q]){var Z=`
37
- `+g[P].replace(" at new "," at ");return i.displayName&&Z.includes("<anonymous>")&&(Z=Z.replace("<anonymous>",i.displayName)),Z}while(1<=P&&0<=q);break}}}finally{U=!1,Error.prepareStackTrace=c}return(i=i?i.displayName||i.name:"")?B(i):""}function ee(i){switch(i.tag){case 5:return B(i.type);case 16:return B("Lazy");case 13:return B("Suspense");case 19:return B("SuspenseList");case 0:case 2:case 15:return i=se(i.type,!1),i;case 11:return i=se(i.type.render,!1),i;case 1:return i=se(i.type,!0),i;default:return""}}function de(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case Y:return"Fragment";case K:return"Portal";case W:return"Profiler";case Q:return"StrictMode";case R:return"Suspense";case O:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case H:return(i.displayName||"Context")+".Consumer";case X:return(i._context.displayName||"Context")+".Provider";case $:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case F:return r=i.displayName||null,r!==null?r:de(i.type)||"Memo";case A:r=i._payload,i=i._init;try{return de(i(r))}catch{}}return null}function ve(i){var r=i.type;switch(i.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=r.render,i=i.displayName||i.name||"",r.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return de(r);case 8:return r===Q?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function fe(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function pe(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Ve(i){var r=pe(i)?"checked":"value",c=Object.getOwnPropertyDescriptor(i.constructor.prototype,r),h=""+i[r];if(!i.hasOwnProperty(r)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var g=c.get,_=c.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return g.call(this)},set:function(P){h=""+P,_.call(this,P)}}),Object.defineProperty(i,r,{enumerable:c.enumerable}),{getValue:function(){return h},setValue:function(P){h=""+P},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function ut(i){i._valueTracker||(i._valueTracker=Ve(i))}function vt(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var c=r.getValue(),h="";return i&&(h=pe(i)?i.checked?"true":"false":i.value),i=h,i!==c?(r.setValue(i),!0):!1}function je(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}function Ct(i,r){var c=r.checked;return M({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:c??i._wrapperState.initialChecked})}function dn(i,r){var c=r.defaultValue==null?"":r.defaultValue,h=r.checked!=null?r.checked:r.defaultChecked;c=fe(r.value!=null?r.value:c),i._wrapperState={initialChecked:h,initialValue:c,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function gn(i,r){r=r.checked,r!=null&&L(i,"checked",r,!1)}function Yt(i,r){gn(i,r);var c=fe(r.value),h=r.type;if(c!=null)h==="number"?(c===0&&i.value===""||i.value!=c)&&(i.value=""+c):i.value!==""+c&&(i.value=""+c);else if(h==="submit"||h==="reset"){i.removeAttribute("value");return}r.hasOwnProperty("value")?Ot(i,r.type,c):r.hasOwnProperty("defaultValue")&&Ot(i,r.type,fe(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(i.defaultChecked=!!r.defaultChecked)}function xt(i,r,c){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var h=r.type;if(!(h!=="submit"&&h!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+i._wrapperState.initialValue,c||r===i.value||(i.value=r),i.defaultValue=r}c=i.name,c!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,c!==""&&(i.name=c)}function Ot(i,r,c){(r!=="number"||je(i.ownerDocument)!==i)&&(c==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+c&&(i.defaultValue=""+c))}var Ut=Array.isArray;function Nt(i,r,c,h){if(i=i.options,r){r={};for(var g=0;g<c.length;g++)r["$"+c[g]]=!0;for(c=0;c<i.length;c++)g=r.hasOwnProperty("$"+i[c].value),i[c].selected!==g&&(i[c].selected=g),g&&h&&(i[c].defaultSelected=!0)}else{for(c=""+fe(c),r=null,g=0;g<i.length;g++){if(i[g].value===c){i[g].selected=!0,h&&(i[g].defaultSelected=!0);return}r!==null||i[g].disabled||(r=i[g])}r!==null&&(r.selected=!0)}}function Dt(i,r){if(r.dangerouslySetInnerHTML!=null)throw Error(n(91));return M({},r,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function At(i,r){var c=r.value;if(c==null){if(c=r.children,r=r.defaultValue,c!=null){if(r!=null)throw Error(n(92));if(Ut(c)){if(1<c.length)throw Error(n(93));c=c[0]}r=c}r==null&&(r=""),c=r}i._wrapperState={initialValue:fe(c)}}function jt(i,r){var c=fe(r.value),h=fe(r.defaultValue);c!=null&&(c=""+c,c!==i.value&&(i.value=c),r.defaultValue==null&&i.defaultValue!==c&&(i.defaultValue=c)),h!=null&&(i.defaultValue=""+h)}function hn(i){var r=i.textContent;r===i._wrapperState.initialValue&&r!==""&&r!==null&&(i.value=r)}function re(i){switch(i){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Qe(i,r){return i==null||i==="http://www.w3.org/1999/xhtml"?re(r):i==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var me,Ge=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,c,h,g){MSApp.execUnsafeLocalFunction(function(){return i(r,c,h,g)})}:i})(function(i,r){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=r;else{for(me=me||document.createElement("div"),me.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=me.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;r.firstChild;)i.appendChild(r.firstChild)}});function ct(i,r){if(r){var c=i.firstChild;if(c&&c===i.lastChild&&c.nodeType===3){c.nodeValue=r;return}}i.textContent=r}var oe={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},ie=["Webkit","ms","Moz","O"];Object.keys(oe).forEach(function(i){ie.forEach(function(r){r=r+i.charAt(0).toUpperCase()+i.substring(1),oe[r]=oe[i]})});function _e(i,r,c){return r==null||typeof r=="boolean"||r===""?"":c||typeof r!="number"||r===0||oe.hasOwnProperty(i)&&oe[i]?(""+r).trim():r+"px"}function be(i,r){i=i.style;for(var c in r)if(r.hasOwnProperty(c)){var h=c.indexOf("--")===0,g=_e(c,r[c],h);c==="float"&&(c="cssFloat"),h?i.setProperty(c,g):i[c]=g}}var ke=M({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 it(i,r){if(r){if(ke[i]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(n(137,i));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(n(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(n(61))}if(r.style!=null&&typeof r.style!="object")throw Error(n(62))}}function ht(i,r){if(i.indexOf("-")===-1)return typeof r.is=="string";switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var dt=null;function Rt(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var wt=null,_t=null,zt=null;function Je(i){if(i=Fo(i)){if(typeof wt!="function")throw Error(n(280));var r=i.stateNode;r&&(r=el(r),wt(i.stateNode,i.type,r))}}function J(i){_t?zt?zt.push(i):zt=[i]:_t=i}function Ne(){if(_t){var i=_t,r=zt;if(zt=_t=null,Je(i),r)for(i=0;i<r.length;i++)Je(r[i])}}function Ue(i,r){return i(r)}function Oe(){}var Le=!1;function Et(i,r,c){if(Le)return i(r,c);Le=!0;try{return Ue(i,r,c)}finally{Le=!1,(_t!==null||zt!==null)&&(Oe(),Ne())}}function kt(i,r){var c=i.stateNode;if(c===null)return null;var h=el(c);if(h===null)return null;c=h[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(h=!h.disabled)||(i=i.type,h=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!h;break e;default:i=!1}if(i)return null;if(c&&typeof c!="function")throw Error(n(231,r,typeof c));return c}var V=!1;if(d)try{var ae={};Object.defineProperty(ae,"passive",{get:function(){V=!0}}),window.addEventListener("test",ae,ae),window.removeEventListener("test",ae,ae)}catch{V=!1}function ye(i,r,c,h,g,_,P,q,Z){var he=Array.prototype.slice.call(arguments,3);try{r.apply(c,he)}catch(xe){this.onError(xe)}}var Me=!1,De=null,Ee=!1,Xe=null,yt={onError:function(i){Me=!0,De=i}};function $t(i,r,c,h,g,_,P,q,Z){Me=!1,De=null,ye.apply(yt,arguments)}function Be(i,r,c,h,g,_,P,q,Z){if($t.apply(this,arguments),Me){if(Me){var he=De;Me=!1,De=null}else throw Error(n(198));Ee||(Ee=!0,Xe=he)}}function te(i){var r=i,c=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(c=r.return),i=r.return;while(i)}return r.tag===3?c:null}function Se(i){if(i.tag===13){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function Te(i){if(te(i)!==i)throw Error(n(188))}function tt(i){var r=i.alternate;if(!r){if(r=te(i),r===null)throw Error(n(188));return r!==i?null:i}for(var c=i,h=r;;){var g=c.return;if(g===null)break;var _=g.alternate;if(_===null){if(h=g.return,h!==null){c=h;continue}break}if(g.child===_.child){for(_=g.child;_;){if(_===c)return Te(g),i;if(_===h)return Te(g),r;_=_.sibling}throw Error(n(188))}if(c.return!==h.return)c=g,h=_;else{for(var P=!1,q=g.child;q;){if(q===c){P=!0,c=g,h=_;break}if(q===h){P=!0,h=g,c=_;break}q=q.sibling}if(!P){for(q=_.child;q;){if(q===c){P=!0,c=_,h=g;break}if(q===h){P=!0,h=_,c=g;break}q=q.sibling}if(!P)throw Error(n(189))}}if(c.alternate!==h)throw Error(n(190))}if(c.tag!==3)throw Error(n(188));return c.stateNode.current===c?i:r}function nt(i){return i=tt(i),i!==null?St(i):null}function St(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var r=St(i);if(r!==null)return r;i=i.sibling}return null}var It=t.unstable_scheduleCallback,Sn=t.unstable_cancelCallback,ri=t.unstable_shouldYield,An=t.unstable_requestPaint,Mt=t.unstable_now,zc=t.unstable_getCurrentPriorityLevel,No=t.unstable_ImmediatePriority,Qs=t.unstable_UserBlockingPriority,Js=t.unstable_NormalPriority,Oa=t.unstable_LowPriority,Pr=t.unstable_IdlePriority,Zs=null,oi=null;function Ba(i){if(oi&&typeof oi.onCommitFiberRoot=="function")try{oi.onCommitFiberRoot(Zs,i,void 0,(i.current.flags&128)===128)}catch{}}var Qn=Math.clz32?Math.clz32:_i,za=Math.log,$a=Math.LN2;function _i(i){return i>>>=0,i===0?32:31-(za(i)/$a|0)|0}var er=64,tr=4194304;function _s(i){switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function ts(i,r){var c=i.pendingLanes;if(c===0)return 0;var h=0,g=i.suspendedLanes,_=i.pingedLanes,P=c&268435455;if(P!==0){var q=P&~g;q!==0?h=_s(q):(_&=P,_!==0&&(h=_s(_)))}else P=c&~g,P!==0?h=_s(P):_!==0&&(h=_s(_));if(h===0)return 0;if(r!==0&&r!==h&&(r&g)===0&&(g=h&-h,_=r&-r,g>=_||g===16&&(_&4194240)!==0))return r;if((h&4)!==0&&(h|=c&16),r=i.entangledLanes,r!==0)for(i=i.entanglements,r&=h;0<r;)c=31-Qn(r),g=1<<c,h|=i[c],r&=~g;return h}function ns(i,r){switch(i){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Lr(i,r){for(var c=i.suspendedLanes,h=i.pingedLanes,g=i.expirationTimes,_=i.pendingLanes;0<_;){var P=31-Qn(_),q=1<<P,Z=g[P];Z===-1?((q&c)===0||(q&h)!==0)&&(g[P]=ns(q,r)):Z<=r&&(i.expiredLanes|=q),_&=~q}}function Ar(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function Mr(){var i=er;return er<<=1,(er&4194240)===0&&(er=64),i}function Tr(i){for(var r=[],c=0;31>c;c++)r.push(i);return r}function yi(i,r,c){i.pendingLanes|=r,r!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,r=31-Qn(r),i[r]=c}function Fa(i,r){var c=i.pendingLanes&~r;i.pendingLanes=r,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=r,i.mutableReadLanes&=r,i.entangledLanes&=r,r=i.entanglements;var h=i.eventTimes;for(i=i.expirationTimes;0<c;){var g=31-Qn(c),_=1<<g;r[g]=0,h[g]=-1,i[g]=-1,c&=~_}}function Bi(i,r){var c=i.entangledLanes|=r;for(i=i.entanglements;c;){var h=31-Qn(c),g=1<<h;g&r|i[h]&r&&(i[h]|=r),c&=~g}}var ft=0;function Dr(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var jo,Mn,Ro,nr,ys,bs=!1,ir=[],ai=null,Pi=null,li=null,ws=new Map,Ss=new Map,le=[],Ie="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 Ae(i,r){switch(i){case"focusin":case"focusout":ai=null;break;case"dragenter":case"dragleave":Pi=null;break;case"mouseover":case"mouseout":li=null;break;case"pointerover":case"pointerout":ws.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ss.delete(r.pointerId)}}function $e(i,r,c,h,g,_){return i===null||i.nativeEvent!==_?(i={blockedOn:r,domEventName:c,eventSystemFlags:h,nativeEvent:_,targetContainers:[g]},r!==null&&(r=Fo(r),r!==null&&Mn(r)),i):(i.eventSystemFlags|=h,r=i.targetContainers,g!==null&&r.indexOf(g)===-1&&r.push(g),i)}function st(i,r,c,h,g){switch(r){case"focusin":return ai=$e(ai,i,r,c,h,g),!0;case"dragenter":return Pi=$e(Pi,i,r,c,h,g),!0;case"mouseover":return li=$e(li,i,r,c,h,g),!0;case"pointerover":var _=g.pointerId;return ws.set(_,$e(ws.get(_)||null,i,r,c,h,g)),!0;case"gotpointercapture":return _=g.pointerId,Ss.set(_,$e(Ss.get(_)||null,i,r,c,h,g)),!0}return!1}function rt(i){var r=sr(i.target);if(r!==null){var c=te(r);if(c!==null){if(r=c.tag,r===13){if(r=Se(c),r!==null){i.blockedOn=r,ys(i.priority,function(){Ro(c)});return}}else if(r===3&&c.stateNode.current.memoizedState.isDehydrated){i.blockedOn=c.tag===3?c.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Pt(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var c=Fc(i.domEventName,i.eventSystemFlags,r[0],i.nativeEvent);if(c===null){c=i.nativeEvent;var h=new c.constructor(c.type,c);dt=h,c.target.dispatchEvent(h),dt=null}else return r=Fo(c),r!==null&&Mn(r),i.blockedOn=c,!1;r.shift()}return!0}function Gt(i,r,c){Pt(i)&&c.delete(r)}function Bn(){bs=!1,ai!==null&&Pt(ai)&&(ai=null),Pi!==null&&Pt(Pi)&&(Pi=null),li!==null&&Pt(li)&&(li=null),ws.forEach(Gt),Ss.forEach(Gt)}function Wt(i,r){i.blockedOn===r&&(i.blockedOn=null,bs||(bs=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Bn)))}function xn(i){function r(g){return Wt(g,i)}if(0<ir.length){Wt(ir[0],i);for(var c=1;c<ir.length;c++){var h=ir[c];h.blockedOn===i&&(h.blockedOn=null)}}for(ai!==null&&Wt(ai,i),Pi!==null&&Wt(Pi,i),li!==null&&Wt(li,i),ws.forEach(r),Ss.forEach(r),c=0;c<le.length;c++)h=le[c],h.blockedOn===i&&(h.blockedOn=null);for(;0<le.length&&(c=le[0],c.blockedOn===null);)rt(c),c.blockedOn===null&&le.shift()}var Wn=I.ReactCurrentBatchConfig,Ir=!0;function Rp(i,r,c,h){var g=ft,_=Wn.transition;Wn.transition=null;try{ft=1,$c(i,r,c,h)}finally{ft=g,Wn.transition=_}}function SS(i,r,c,h){var g=ft,_=Wn.transition;Wn.transition=null;try{ft=4,$c(i,r,c,h)}finally{ft=g,Wn.transition=_}}function $c(i,r,c,h){if(Ir){var g=Fc(i,r,c,h);if(g===null)su(i,r,h,Ha,c),Ae(i,h);else if(st(g,i,r,c,h))h.stopPropagation();else if(Ae(i,h),r&4&&-1<Ie.indexOf(i)){for(;g!==null;){var _=Fo(g);if(_!==null&&jo(_),_=Fc(i,r,c,h),_===null&&su(i,r,h,Ha,c),_===g)break;g=_}g!==null&&h.stopPropagation()}else su(i,r,h,null,c)}}var Ha=null;function Fc(i,r,c,h){if(Ha=null,i=Rt(h),i=sr(i),i!==null)if(r=te(i),r===null)i=null;else if(c=r.tag,c===13){if(i=Se(r),i!==null)return i;i=null}else if(c===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null);return Ha=i,null}function Pp(i){switch(i){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(zc()){case No:return 1;case Qs:return 4;case Js:case Oa:return 16;case Pr:return 536870912;default:return 16}default:return 16}}var xs=null,Hc=null,Ua=null;function Lp(){if(Ua)return Ua;var i,r=Hc,c=r.length,h,g="value"in xs?xs.value:xs.textContent,_=g.length;for(i=0;i<c&&r[i]===g[i];i++);var P=c-i;for(h=1;h<=P&&r[c-h]===g[_-h];h++);return Ua=g.slice(i,1<h?1-h:void 0)}function Wa(i){var r=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&r===13&&(i=13)):i=r,i===10&&(i=13),32<=i||i===13?i:0}function Ka(){return!0}function Ap(){return!1}function ci(i){function r(c,h,g,_,P){this._reactName=c,this._targetInst=g,this.type=h,this.nativeEvent=_,this.target=P,this.currentTarget=null;for(var q in i)i.hasOwnProperty(q)&&(c=i[q],this[q]=c?c(_):_[q]);return this.isDefaultPrevented=(_.defaultPrevented!=null?_.defaultPrevented:_.returnValue===!1)?Ka:Ap,this.isPropagationStopped=Ap,this}return M(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var c=this.nativeEvent;c&&(c.preventDefault?c.preventDefault():typeof c.returnValue!="unknown"&&(c.returnValue=!1),this.isDefaultPrevented=Ka)},stopPropagation:function(){var c=this.nativeEvent;c&&(c.stopPropagation?c.stopPropagation():typeof c.cancelBubble!="unknown"&&(c.cancelBubble=!0),this.isPropagationStopped=Ka)},persist:function(){},isPersistent:Ka}),r}var Or={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Uc=ci(Or),Po=M({},Or,{view:0,detail:0}),xS=ci(Po),Wc,Kc,Lo,qa=M({},Po,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Vc,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==Lo&&(Lo&&i.type==="mousemove"?(Wc=i.screenX-Lo.screenX,Kc=i.screenY-Lo.screenY):Kc=Wc=0,Lo=i),Wc)},movementY:function(i){return"movementY"in i?i.movementY:Kc}}),Mp=ci(qa),kS=M({},qa,{dataTransfer:0}),CS=ci(kS),ES=M({},Po,{relatedTarget:0}),qc=ci(ES),NS=M({},Or,{animationName:0,elapsedTime:0,pseudoElement:0}),jS=ci(NS),RS=M({},Or,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),PS=ci(RS),LS=M({},Or,{data:0}),Tp=ci(LS),AS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},MS={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"},TS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function DS(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=TS[i])?!!r[i]:!1}function Vc(){return DS}var IS=M({},Po,{key:function(i){if(i.key){var r=AS[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=Wa(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?MS[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Vc,charCode:function(i){return i.type==="keypress"?Wa(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Wa(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),OS=ci(IS),BS=M({},qa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Dp=ci(BS),zS=M({},Po,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Vc}),$S=ci(zS),FS=M({},Or,{propertyName:0,elapsedTime:0,pseudoElement:0}),HS=ci(FS),US=M({},qa,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),WS=ci(US),KS=[9,13,27,32],Yc=d&&"CompositionEvent"in window,Ao=null;d&&"documentMode"in document&&(Ao=document.documentMode);var qS=d&&"TextEvent"in window&&!Ao,Ip=d&&(!Yc||Ao&&8<Ao&&11>=Ao),Op=" ",Bp=!1;function zp(i,r){switch(i){case"keyup":return KS.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $p(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Br=!1;function VS(i,r){switch(i){case"compositionend":return $p(r);case"keypress":return r.which!==32?null:(Bp=!0,Op);case"textInput":return i=r.data,i===Op&&Bp?null:i;default:return null}}function YS(i,r){if(Br)return i==="compositionend"||!Yc&&zp(i,r)?(i=Lp(),Ua=Hc=xs=null,Br=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Ip&&r.locale!=="ko"?null:r.data;default:return null}}var GS={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 Fp(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!GS[i.type]:r==="textarea"}function Hp(i,r,c,h){J(h),r=Qa(r,"onChange"),0<r.length&&(c=new Uc("onChange","change",null,c,h),i.push({event:c,listeners:r}))}var Mo=null,To=null;function XS(i){om(i,0)}function Va(i){var r=Ur(i);if(vt(r))return i}function QS(i,r){if(i==="change")return r}var Up=!1;if(d){var Gc;if(d){var Xc="oninput"in document;if(!Xc){var Wp=document.createElement("div");Wp.setAttribute("oninput","return;"),Xc=typeof Wp.oninput=="function"}Gc=Xc}else Gc=!1;Up=Gc&&(!document.documentMode||9<document.documentMode)}function Kp(){Mo&&(Mo.detachEvent("onpropertychange",qp),To=Mo=null)}function qp(i){if(i.propertyName==="value"&&Va(To)){var r=[];Hp(r,To,i,Rt(i)),Et(XS,r)}}function JS(i,r,c){i==="focusin"?(Kp(),Mo=r,To=c,Mo.attachEvent("onpropertychange",qp)):i==="focusout"&&Kp()}function ZS(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Va(To)}function e0(i,r){if(i==="click")return Va(r)}function t0(i,r){if(i==="input"||i==="change")return Va(r)}function n0(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var Li=typeof Object.is=="function"?Object.is:n0;function Do(i,r){if(Li(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var c=Object.keys(i),h=Object.keys(r);if(c.length!==h.length)return!1;for(h=0;h<c.length;h++){var g=c[h];if(!p.call(r,g)||!Li(i[g],r[g]))return!1}return!0}function Vp(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Yp(i,r){var c=Vp(i);i=0;for(var h;c;){if(c.nodeType===3){if(h=i+c.textContent.length,i<=r&&h>=r)return{node:c,offset:r-i};i=h}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=Vp(c)}}function Gp(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Gp(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Xp(){for(var i=window,r=je();r instanceof i.HTMLIFrameElement;){try{var c=typeof r.contentWindow.location.href=="string"}catch{c=!1}if(c)i=r.contentWindow;else break;r=je(i.document)}return r}function Qc(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}function i0(i){var r=Xp(),c=i.focusedElem,h=i.selectionRange;if(r!==c&&c&&c.ownerDocument&&Gp(c.ownerDocument.documentElement,c)){if(h!==null&&Qc(c)){if(r=h.start,i=h.end,i===void 0&&(i=r),"selectionStart"in c)c.selectionStart=r,c.selectionEnd=Math.min(i,c.value.length);else if(i=(r=c.ownerDocument||document)&&r.defaultView||window,i.getSelection){i=i.getSelection();var g=c.textContent.length,_=Math.min(h.start,g);h=h.end===void 0?_:Math.min(h.end,g),!i.extend&&_>h&&(g=h,h=_,_=g),g=Yp(c,_);var P=Yp(c,h);g&&P&&(i.rangeCount!==1||i.anchorNode!==g.node||i.anchorOffset!==g.offset||i.focusNode!==P.node||i.focusOffset!==P.offset)&&(r=r.createRange(),r.setStart(g.node,g.offset),i.removeAllRanges(),_>h?(i.addRange(r),i.extend(P.node,P.offset)):(r.setEnd(P.node,P.offset),i.addRange(r)))}}for(r=[],i=c;i=i.parentNode;)i.nodeType===1&&r.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof c.focus=="function"&&c.focus(),c=0;c<r.length;c++)i=r[c],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var s0=d&&"documentMode"in document&&11>=document.documentMode,zr=null,Jc=null,Io=null,Zc=!1;function Qp(i,r,c){var h=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;Zc||zr==null||zr!==je(h)||(h=zr,"selectionStart"in h&&Qc(h)?h={start:h.selectionStart,end:h.selectionEnd}:(h=(h.ownerDocument&&h.ownerDocument.defaultView||window).getSelection(),h={anchorNode:h.anchorNode,anchorOffset:h.anchorOffset,focusNode:h.focusNode,focusOffset:h.focusOffset}),Io&&Do(Io,h)||(Io=h,h=Qa(Jc,"onSelect"),0<h.length&&(r=new Uc("onSelect","select",null,r,c),i.push({event:r,listeners:h}),r.target=zr)))}function Ya(i,r){var c={};return c[i.toLowerCase()]=r.toLowerCase(),c["Webkit"+i]="webkit"+r,c["Moz"+i]="moz"+r,c}var $r={animationend:Ya("Animation","AnimationEnd"),animationiteration:Ya("Animation","AnimationIteration"),animationstart:Ya("Animation","AnimationStart"),transitionend:Ya("Transition","TransitionEnd")},eu={},Jp={};d&&(Jp=document.createElement("div").style,"AnimationEvent"in window||(delete $r.animationend.animation,delete $r.animationiteration.animation,delete $r.animationstart.animation),"TransitionEvent"in window||delete $r.transitionend.transition);function Ga(i){if(eu[i])return eu[i];if(!$r[i])return i;var r=$r[i],c;for(c in r)if(r.hasOwnProperty(c)&&c in Jp)return eu[i]=r[c];return i}var Zp=Ga("animationend"),em=Ga("animationiteration"),tm=Ga("animationstart"),nm=Ga("transitionend"),im=new Map,sm="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 ks(i,r){im.set(i,r),a(r,[i])}for(var tu=0;tu<sm.length;tu++){var nu=sm[tu],r0=nu.toLowerCase(),o0=nu[0].toUpperCase()+nu.slice(1);ks(r0,"on"+o0)}ks(Zp,"onAnimationEnd"),ks(em,"onAnimationIteration"),ks(tm,"onAnimationStart"),ks("dblclick","onDoubleClick"),ks("focusin","onFocus"),ks("focusout","onBlur"),ks(nm,"onTransitionEnd"),u("onMouseEnter",["mouseout","mouseover"]),u("onMouseLeave",["mouseout","mouseover"]),u("onPointerEnter",["pointerout","pointerover"]),u("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Oo="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),a0=new Set("cancel close invalid load scroll toggle".split(" ").concat(Oo));function rm(i,r,c){var h=i.type||"unknown-event";i.currentTarget=c,Be(h,r,void 0,i),i.currentTarget=null}function om(i,r){r=(r&4)!==0;for(var c=0;c<i.length;c++){var h=i[c],g=h.event;h=h.listeners;e:{var _=void 0;if(r)for(var P=h.length-1;0<=P;P--){var q=h[P],Z=q.instance,he=q.currentTarget;if(q=q.listener,Z!==_&&g.isPropagationStopped())break e;rm(g,q,he),_=Z}else for(P=0;P<h.length;P++){if(q=h[P],Z=q.instance,he=q.currentTarget,q=q.listener,Z!==_&&g.isPropagationStopped())break e;rm(g,q,he),_=Z}}}if(Ee)throw i=Xe,Ee=!1,Xe=null,i}function Kt(i,r){var c=r[uu];c===void 0&&(c=r[uu]=new Set);var h=i+"__bubble";c.has(h)||(am(r,i,2,!1),c.add(h))}function iu(i,r,c){var h=0;r&&(h|=4),am(c,i,h,r)}var Xa="_reactListening"+Math.random().toString(36).slice(2);function Bo(i){if(!i[Xa]){i[Xa]=!0,s.forEach(function(c){c!=="selectionchange"&&(a0.has(c)||iu(c,!1,i),iu(c,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[Xa]||(r[Xa]=!0,iu("selectionchange",!1,r))}}function am(i,r,c,h){switch(Pp(r)){case 1:var g=Rp;break;case 4:g=SS;break;default:g=$c}c=g.bind(null,r,c,i),g=void 0,!V||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(g=!0),h?g!==void 0?i.addEventListener(r,c,{capture:!0,passive:g}):i.addEventListener(r,c,!0):g!==void 0?i.addEventListener(r,c,{passive:g}):i.addEventListener(r,c,!1)}function su(i,r,c,h,g){var _=h;if((r&1)===0&&(r&2)===0&&h!==null)e:for(;;){if(h===null)return;var P=h.tag;if(P===3||P===4){var q=h.stateNode.containerInfo;if(q===g||q.nodeType===8&&q.parentNode===g)break;if(P===4)for(P=h.return;P!==null;){var Z=P.tag;if((Z===3||Z===4)&&(Z=P.stateNode.containerInfo,Z===g||Z.nodeType===8&&Z.parentNode===g))return;P=P.return}for(;q!==null;){if(P=sr(q),P===null)return;if(Z=P.tag,Z===5||Z===6){h=_=P;continue e}q=q.parentNode}}h=h.return}Et(function(){var he=_,xe=Rt(c),Ce=[];e:{var we=im.get(i);if(we!==void 0){var He=Uc,Ke=i;switch(i){case"keypress":if(Wa(c)===0)break e;case"keydown":case"keyup":He=OS;break;case"focusin":Ke="focus",He=qc;break;case"focusout":Ke="blur",He=qc;break;case"beforeblur":case"afterblur":He=qc;break;case"click":if(c.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":He=Mp;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":He=CS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":He=$S;break;case Zp:case em:case tm:He=jS;break;case nm:He=HS;break;case"scroll":He=xS;break;case"wheel":He=WS;break;case"copy":case"cut":case"paste":He=PS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":He=Dp}var qe=(r&4)!==0,ln=!qe&&i==="scroll",ce=qe?we!==null?we+"Capture":null:we;qe=[];for(var ne=he,ue;ne!==null;){ue=ne;var Re=ue.stateNode;if(ue.tag===5&&Re!==null&&(ue=Re,ce!==null&&(Re=kt(ne,ce),Re!=null&&qe.push(zo(ne,Re,ue)))),ln)break;ne=ne.return}0<qe.length&&(we=new He(we,Ke,null,c,xe),Ce.push({event:we,listeners:qe}))}}if((r&7)===0){e:{if(we=i==="mouseover"||i==="pointerover",He=i==="mouseout"||i==="pointerout",we&&c!==dt&&(Ke=c.relatedTarget||c.fromElement)&&(sr(Ke)||Ke[is]))break e;if((He||we)&&(we=xe.window===xe?xe:(we=xe.ownerDocument)?we.defaultView||we.parentWindow:window,He?(Ke=c.relatedTarget||c.toElement,He=he,Ke=Ke?sr(Ke):null,Ke!==null&&(ln=te(Ke),Ke!==ln||Ke.tag!==5&&Ke.tag!==6)&&(Ke=null)):(He=null,Ke=he),He!==Ke)){if(qe=Mp,Re="onMouseLeave",ce="onMouseEnter",ne="mouse",(i==="pointerout"||i==="pointerover")&&(qe=Dp,Re="onPointerLeave",ce="onPointerEnter",ne="pointer"),ln=He==null?we:Ur(He),ue=Ke==null?we:Ur(Ke),we=new qe(Re,ne+"leave",He,c,xe),we.target=ln,we.relatedTarget=ue,Re=null,sr(xe)===he&&(qe=new qe(ce,ne+"enter",Ke,c,xe),qe.target=ue,qe.relatedTarget=ln,Re=qe),ln=Re,He&&Ke)t:{for(qe=He,ce=Ke,ne=0,ue=qe;ue;ue=Fr(ue))ne++;for(ue=0,Re=ce;Re;Re=Fr(Re))ue++;for(;0<ne-ue;)qe=Fr(qe),ne--;for(;0<ue-ne;)ce=Fr(ce),ue--;for(;ne--;){if(qe===ce||ce!==null&&qe===ce.alternate)break t;qe=Fr(qe),ce=Fr(ce)}qe=null}else qe=null;He!==null&&lm(Ce,we,He,qe,!1),Ke!==null&&ln!==null&&lm(Ce,ln,Ke,qe,!0)}}e:{if(we=he?Ur(he):window,He=we.nodeName&&we.nodeName.toLowerCase(),He==="select"||He==="input"&&we.type==="file")var Ye=QS;else if(Fp(we))if(Up)Ye=t0;else{Ye=ZS;var Ze=JS}else(He=we.nodeName)&&He.toLowerCase()==="input"&&(we.type==="checkbox"||we.type==="radio")&&(Ye=e0);if(Ye&&(Ye=Ye(i,he))){Hp(Ce,Ye,c,xe);break e}Ze&&Ze(i,we,he),i==="focusout"&&(Ze=we._wrapperState)&&Ze.controlled&&we.type==="number"&&Ot(we,"number",we.value)}switch(Ze=he?Ur(he):window,i){case"focusin":(Fp(Ze)||Ze.contentEditable==="true")&&(zr=Ze,Jc=he,Io=null);break;case"focusout":Io=Jc=zr=null;break;case"mousedown":Zc=!0;break;case"contextmenu":case"mouseup":case"dragend":Zc=!1,Qp(Ce,c,xe);break;case"selectionchange":if(s0)break;case"keydown":case"keyup":Qp(Ce,c,xe)}var et;if(Yc)e:{switch(i){case"compositionstart":var ot="onCompositionStart";break e;case"compositionend":ot="onCompositionEnd";break e;case"compositionupdate":ot="onCompositionUpdate";break e}ot=void 0}else Br?zp(i,c)&&(ot="onCompositionEnd"):i==="keydown"&&c.keyCode===229&&(ot="onCompositionStart");ot&&(Ip&&c.locale!=="ko"&&(Br||ot!=="onCompositionStart"?ot==="onCompositionEnd"&&Br&&(et=Lp()):(xs=xe,Hc="value"in xs?xs.value:xs.textContent,Br=!0)),Ze=Qa(he,ot),0<Ze.length&&(ot=new Tp(ot,i,null,c,xe),Ce.push({event:ot,listeners:Ze}),et?ot.data=et:(et=$p(c),et!==null&&(ot.data=et)))),(et=qS?VS(i,c):YS(i,c))&&(he=Qa(he,"onBeforeInput"),0<he.length&&(xe=new Tp("onBeforeInput","beforeinput",null,c,xe),Ce.push({event:xe,listeners:he}),xe.data=et))}om(Ce,r)})}function zo(i,r,c){return{instance:i,listener:r,currentTarget:c}}function Qa(i,r){for(var c=r+"Capture",h=[];i!==null;){var g=i,_=g.stateNode;g.tag===5&&_!==null&&(g=_,_=kt(i,c),_!=null&&h.unshift(zo(i,_,g)),_=kt(i,r),_!=null&&h.push(zo(i,_,g))),i=i.return}return h}function Fr(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function lm(i,r,c,h,g){for(var _=r._reactName,P=[];c!==null&&c!==h;){var q=c,Z=q.alternate,he=q.stateNode;if(Z!==null&&Z===h)break;q.tag===5&&he!==null&&(q=he,g?(Z=kt(c,_),Z!=null&&P.unshift(zo(c,Z,q))):g||(Z=kt(c,_),Z!=null&&P.push(zo(c,Z,q)))),c=c.return}P.length!==0&&i.push({event:r,listeners:P})}var l0=/\r\n?/g,c0=/\u0000|\uFFFD/g;function cm(i){return(typeof i=="string"?i:""+i).replace(l0,`
38
- `).replace(c0,"")}function Ja(i,r,c){if(r=cm(r),cm(i)!==r&&c)throw Error(n(425))}function Za(){}var ru=null,ou=null;function au(i,r){return i==="textarea"||i==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var lu=typeof setTimeout=="function"?setTimeout:void 0,u0=typeof clearTimeout=="function"?clearTimeout:void 0,um=typeof Promise=="function"?Promise:void 0,d0=typeof queueMicrotask=="function"?queueMicrotask:typeof um<"u"?function(i){return um.resolve(null).then(i).catch(h0)}:lu;function h0(i){setTimeout(function(){throw i})}function cu(i,r){var c=r,h=0;do{var g=c.nextSibling;if(i.removeChild(c),g&&g.nodeType===8)if(c=g.data,c==="/$"){if(h===0){i.removeChild(g),xn(r);return}h--}else c!=="$"&&c!=="$?"&&c!=="$!"||h++;c=g}while(c);xn(r)}function Cs(i){for(;i!=null;i=i.nextSibling){var r=i.nodeType;if(r===1||r===3)break;if(r===8){if(r=i.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return i}function dm(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var c=i.data;if(c==="$"||c==="$!"||c==="$?"){if(r===0)return i;r--}else c==="/$"&&r++}i=i.previousSibling}return null}var Hr=Math.random().toString(36).slice(2),zi="__reactFiber$"+Hr,$o="__reactProps$"+Hr,is="__reactContainer$"+Hr,uu="__reactEvents$"+Hr,f0="__reactListeners$"+Hr,p0="__reactHandles$"+Hr;function sr(i){var r=i[zi];if(r)return r;for(var c=i.parentNode;c;){if(r=c[is]||c[zi]){if(c=r.alternate,r.child!==null||c!==null&&c.child!==null)for(i=dm(i);i!==null;){if(c=i[zi])return c;i=dm(i)}return r}i=c,c=i.parentNode}return null}function Fo(i){return i=i[zi]||i[is],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function Ur(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function el(i){return i[$o]||null}var du=[],Wr=-1;function Es(i){return{current:i}}function qt(i){0>Wr||(i.current=du[Wr],du[Wr]=null,Wr--)}function Ft(i,r){Wr++,du[Wr]=i.current,i.current=r}var Ns={},zn=Es(Ns),Jn=Es(!1),rr=Ns;function Kr(i,r){var c=i.type.contextTypes;if(!c)return Ns;var h=i.stateNode;if(h&&h.__reactInternalMemoizedUnmaskedChildContext===r)return h.__reactInternalMemoizedMaskedChildContext;var g={},_;for(_ in c)g[_]=r[_];return h&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=r,i.__reactInternalMemoizedMaskedChildContext=g),g}function Zn(i){return i=i.childContextTypes,i!=null}function tl(){qt(Jn),qt(zn)}function hm(i,r,c){if(zn.current!==Ns)throw Error(n(168));Ft(zn,r),Ft(Jn,c)}function fm(i,r,c){var h=i.stateNode;if(r=r.childContextTypes,typeof h.getChildContext!="function")return c;h=h.getChildContext();for(var g in h)if(!(g in r))throw Error(n(108,ve(i)||"Unknown",g));return M({},c,h)}function nl(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||Ns,rr=zn.current,Ft(zn,i),Ft(Jn,Jn.current),!0}function pm(i,r,c){var h=i.stateNode;if(!h)throw Error(n(169));c?(i=fm(i,r,rr),h.__reactInternalMemoizedMergedChildContext=i,qt(Jn),qt(zn),Ft(zn,i)):qt(Jn),Ft(Jn,c)}var ss=null,il=!1,hu=!1;function mm(i){ss===null?ss=[i]:ss.push(i)}function m0(i){il=!0,mm(i)}function js(){if(!hu&&ss!==null){hu=!0;var i=0,r=ft;try{var c=ss;for(ft=1;i<c.length;i++){var h=c[i];do h=h(!0);while(h!==null)}ss=null,il=!1}catch(g){throw ss!==null&&(ss=ss.slice(i+1)),It(No,js),g}finally{ft=r,hu=!1}}return null}var qr=[],Vr=0,sl=null,rl=0,bi=[],wi=0,or=null,rs=1,os="";function ar(i,r){qr[Vr++]=rl,qr[Vr++]=sl,sl=i,rl=r}function gm(i,r,c){bi[wi++]=rs,bi[wi++]=os,bi[wi++]=or,or=i;var h=rs;i=os;var g=32-Qn(h)-1;h&=~(1<<g),c+=1;var _=32-Qn(r)+g;if(30<_){var P=g-g%5;_=(h&(1<<P)-1).toString(32),h>>=P,g-=P,rs=1<<32-Qn(r)+g|c<<g|h,os=_+i}else rs=1<<_|c<<g|h,os=i}function fu(i){i.return!==null&&(ar(i,1),gm(i,1,0))}function pu(i){for(;i===sl;)sl=qr[--Vr],qr[Vr]=null,rl=qr[--Vr],qr[Vr]=null;for(;i===or;)or=bi[--wi],bi[wi]=null,os=bi[--wi],bi[wi]=null,rs=bi[--wi],bi[wi]=null}var ui=null,di=null,Xt=!1,Ai=null;function vm(i,r){var c=Ci(5,null,null,0);c.elementType="DELETED",c.stateNode=r,c.return=i,r=i.deletions,r===null?(i.deletions=[c],i.flags|=16):r.push(c)}function _m(i,r){switch(i.tag){case 5:var c=i.type;return r=r.nodeType!==1||c.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(i.stateNode=r,ui=i,di=Cs(r.firstChild),!0):!1;case 6:return r=i.pendingProps===""||r.nodeType!==3?null:r,r!==null?(i.stateNode=r,ui=i,di=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(c=or!==null?{id:rs,overflow:os}:null,i.memoizedState={dehydrated:r,treeContext:c,retryLane:1073741824},c=Ci(18,null,null,0),c.stateNode=r,c.return=i,i.child=c,ui=i,di=null,!0):!1;default:return!1}}function mu(i){return(i.mode&1)!==0&&(i.flags&128)===0}function gu(i){if(Xt){var r=di;if(r){var c=r;if(!_m(i,r)){if(mu(i))throw Error(n(418));r=Cs(c.nextSibling);var h=ui;r&&_m(i,r)?vm(h,c):(i.flags=i.flags&-4097|2,Xt=!1,ui=i)}}else{if(mu(i))throw Error(n(418));i.flags=i.flags&-4097|2,Xt=!1,ui=i}}}function ym(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;ui=i}function ol(i){if(i!==ui)return!1;if(!Xt)return ym(i),Xt=!0,!1;var r;if((r=i.tag!==3)&&!(r=i.tag!==5)&&(r=i.type,r=r!=="head"&&r!=="body"&&!au(i.type,i.memoizedProps)),r&&(r=di)){if(mu(i))throw bm(),Error(n(418));for(;r;)vm(i,r),r=Cs(r.nextSibling)}if(ym(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,r=0;i;){if(i.nodeType===8){var c=i.data;if(c==="/$"){if(r===0){di=Cs(i.nextSibling);break e}r--}else c!=="$"&&c!=="$!"&&c!=="$?"||r++}i=i.nextSibling}di=null}}else di=ui?Cs(i.stateNode.nextSibling):null;return!0}function bm(){for(var i=di;i;)i=Cs(i.nextSibling)}function Yr(){di=ui=null,Xt=!1}function vu(i){Ai===null?Ai=[i]:Ai.push(i)}var g0=I.ReactCurrentBatchConfig;function Ho(i,r,c){if(i=c.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(c._owner){if(c=c._owner,c){if(c.tag!==1)throw Error(n(309));var h=c.stateNode}if(!h)throw Error(n(147,i));var g=h,_=""+i;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===_?r.ref:(r=function(P){var q=g.refs;P===null?delete q[_]:q[_]=P},r._stringRef=_,r)}if(typeof i!="string")throw Error(n(284));if(!c._owner)throw Error(n(290,i))}return i}function al(i,r){throw i=Object.prototype.toString.call(r),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i))}function wm(i){var r=i._init;return r(i._payload)}function Sm(i){function r(ce,ne){if(i){var ue=ce.deletions;ue===null?(ce.deletions=[ne],ce.flags|=16):ue.push(ne)}}function c(ce,ne){if(!i)return null;for(;ne!==null;)r(ce,ne),ne=ne.sibling;return null}function h(ce,ne){for(ce=new Map;ne!==null;)ne.key!==null?ce.set(ne.key,ne):ce.set(ne.index,ne),ne=ne.sibling;return ce}function g(ce,ne){return ce=Is(ce,ne),ce.index=0,ce.sibling=null,ce}function _(ce,ne,ue){return ce.index=ue,i?(ue=ce.alternate,ue!==null?(ue=ue.index,ue<ne?(ce.flags|=2,ne):ue):(ce.flags|=2,ne)):(ce.flags|=1048576,ne)}function P(ce){return i&&ce.alternate===null&&(ce.flags|=2),ce}function q(ce,ne,ue,Re){return ne===null||ne.tag!==6?(ne=ld(ue,ce.mode,Re),ne.return=ce,ne):(ne=g(ne,ue),ne.return=ce,ne)}function Z(ce,ne,ue,Re){var Ye=ue.type;return Ye===Y?xe(ce,ne,ue.props.children,Re,ue.key):ne!==null&&(ne.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===A&&wm(Ye)===ne.type)?(Re=g(ne,ue.props),Re.ref=Ho(ce,ne,ue),Re.return=ce,Re):(Re=Ll(ue.type,ue.key,ue.props,null,ce.mode,Re),Re.ref=Ho(ce,ne,ue),Re.return=ce,Re)}function he(ce,ne,ue,Re){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==ue.containerInfo||ne.stateNode.implementation!==ue.implementation?(ne=cd(ue,ce.mode,Re),ne.return=ce,ne):(ne=g(ne,ue.children||[]),ne.return=ce,ne)}function xe(ce,ne,ue,Re,Ye){return ne===null||ne.tag!==7?(ne=mr(ue,ce.mode,Re,Ye),ne.return=ce,ne):(ne=g(ne,ue),ne.return=ce,ne)}function Ce(ce,ne,ue){if(typeof ne=="string"&&ne!==""||typeof ne=="number")return ne=ld(""+ne,ce.mode,ue),ne.return=ce,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case G:return ue=Ll(ne.type,ne.key,ne.props,null,ce.mode,ue),ue.ref=Ho(ce,null,ne),ue.return=ce,ue;case K:return ne=cd(ne,ce.mode,ue),ne.return=ce,ne;case A:var Re=ne._init;return Ce(ce,Re(ne._payload),ue)}if(Ut(ne)||z(ne))return ne=mr(ne,ce.mode,ue,null),ne.return=ce,ne;al(ce,ne)}return null}function we(ce,ne,ue,Re){var Ye=ne!==null?ne.key:null;if(typeof ue=="string"&&ue!==""||typeof ue=="number")return Ye!==null?null:q(ce,ne,""+ue,Re);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case G:return ue.key===Ye?Z(ce,ne,ue,Re):null;case K:return ue.key===Ye?he(ce,ne,ue,Re):null;case A:return Ye=ue._init,we(ce,ne,Ye(ue._payload),Re)}if(Ut(ue)||z(ue))return Ye!==null?null:xe(ce,ne,ue,Re,null);al(ce,ue)}return null}function He(ce,ne,ue,Re,Ye){if(typeof Re=="string"&&Re!==""||typeof Re=="number")return ce=ce.get(ue)||null,q(ne,ce,""+Re,Ye);if(typeof Re=="object"&&Re!==null){switch(Re.$$typeof){case G:return ce=ce.get(Re.key===null?ue:Re.key)||null,Z(ne,ce,Re,Ye);case K:return ce=ce.get(Re.key===null?ue:Re.key)||null,he(ne,ce,Re,Ye);case A:var Ze=Re._init;return He(ce,ne,ue,Ze(Re._payload),Ye)}if(Ut(Re)||z(Re))return ce=ce.get(ue)||null,xe(ne,ce,Re,Ye,null);al(ne,Re)}return null}function Ke(ce,ne,ue,Re){for(var Ye=null,Ze=null,et=ne,ot=ne=0,En=null;et!==null&&ot<ue.length;ot++){et.index>ot?(En=et,et=null):En=et.sibling;var Tt=we(ce,et,ue[ot],Re);if(Tt===null){et===null&&(et=En);break}i&&et&&Tt.alternate===null&&r(ce,et),ne=_(Tt,ne,ot),Ze===null?Ye=Tt:Ze.sibling=Tt,Ze=Tt,et=En}if(ot===ue.length)return c(ce,et),Xt&&ar(ce,ot),Ye;if(et===null){for(;ot<ue.length;ot++)et=Ce(ce,ue[ot],Re),et!==null&&(ne=_(et,ne,ot),Ze===null?Ye=et:Ze.sibling=et,Ze=et);return Xt&&ar(ce,ot),Ye}for(et=h(ce,et);ot<ue.length;ot++)En=He(et,ce,ot,ue[ot],Re),En!==null&&(i&&En.alternate!==null&&et.delete(En.key===null?ot:En.key),ne=_(En,ne,ot),Ze===null?Ye=En:Ze.sibling=En,Ze=En);return i&&et.forEach(function(Os){return r(ce,Os)}),Xt&&ar(ce,ot),Ye}function qe(ce,ne,ue,Re){var Ye=z(ue);if(typeof Ye!="function")throw Error(n(150));if(ue=Ye.call(ue),ue==null)throw Error(n(151));for(var Ze=Ye=null,et=ne,ot=ne=0,En=null,Tt=ue.next();et!==null&&!Tt.done;ot++,Tt=ue.next()){et.index>ot?(En=et,et=null):En=et.sibling;var Os=we(ce,et,Tt.value,Re);if(Os===null){et===null&&(et=En);break}i&&et&&Os.alternate===null&&r(ce,et),ne=_(Os,ne,ot),Ze===null?Ye=Os:Ze.sibling=Os,Ze=Os,et=En}if(Tt.done)return c(ce,et),Xt&&ar(ce,ot),Ye;if(et===null){for(;!Tt.done;ot++,Tt=ue.next())Tt=Ce(ce,Tt.value,Re),Tt!==null&&(ne=_(Tt,ne,ot),Ze===null?Ye=Tt:Ze.sibling=Tt,Ze=Tt);return Xt&&ar(ce,ot),Ye}for(et=h(ce,et);!Tt.done;ot++,Tt=ue.next())Tt=He(et,ce,ot,Tt.value,Re),Tt!==null&&(i&&Tt.alternate!==null&&et.delete(Tt.key===null?ot:Tt.key),ne=_(Tt,ne,ot),Ze===null?Ye=Tt:Ze.sibling=Tt,Ze=Tt);return i&&et.forEach(function(G0){return r(ce,G0)}),Xt&&ar(ce,ot),Ye}function ln(ce,ne,ue,Re){if(typeof ue=="object"&&ue!==null&&ue.type===Y&&ue.key===null&&(ue=ue.props.children),typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case G:e:{for(var Ye=ue.key,Ze=ne;Ze!==null;){if(Ze.key===Ye){if(Ye=ue.type,Ye===Y){if(Ze.tag===7){c(ce,Ze.sibling),ne=g(Ze,ue.props.children),ne.return=ce,ce=ne;break e}}else if(Ze.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===A&&wm(Ye)===Ze.type){c(ce,Ze.sibling),ne=g(Ze,ue.props),ne.ref=Ho(ce,Ze,ue),ne.return=ce,ce=ne;break e}c(ce,Ze);break}else r(ce,Ze);Ze=Ze.sibling}ue.type===Y?(ne=mr(ue.props.children,ce.mode,Re,ue.key),ne.return=ce,ce=ne):(Re=Ll(ue.type,ue.key,ue.props,null,ce.mode,Re),Re.ref=Ho(ce,ne,ue),Re.return=ce,ce=Re)}return P(ce);case K:e:{for(Ze=ue.key;ne!==null;){if(ne.key===Ze)if(ne.tag===4&&ne.stateNode.containerInfo===ue.containerInfo&&ne.stateNode.implementation===ue.implementation){c(ce,ne.sibling),ne=g(ne,ue.children||[]),ne.return=ce,ce=ne;break e}else{c(ce,ne);break}else r(ce,ne);ne=ne.sibling}ne=cd(ue,ce.mode,Re),ne.return=ce,ce=ne}return P(ce);case A:return Ze=ue._init,ln(ce,ne,Ze(ue._payload),Re)}if(Ut(ue))return Ke(ce,ne,ue,Re);if(z(ue))return qe(ce,ne,ue,Re);al(ce,ue)}return typeof ue=="string"&&ue!==""||typeof ue=="number"?(ue=""+ue,ne!==null&&ne.tag===6?(c(ce,ne.sibling),ne=g(ne,ue),ne.return=ce,ce=ne):(c(ce,ne),ne=ld(ue,ce.mode,Re),ne.return=ce,ce=ne),P(ce)):c(ce,ne)}return ln}var Gr=Sm(!0),xm=Sm(!1),ll=Es(null),cl=null,Xr=null,_u=null;function yu(){_u=Xr=cl=null}function bu(i){var r=ll.current;qt(ll),i._currentValue=r}function wu(i,r,c){for(;i!==null;){var h=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,h!==null&&(h.childLanes|=r)):h!==null&&(h.childLanes&r)!==r&&(h.childLanes|=r),i===c)break;i=i.return}}function Qr(i,r){cl=i,_u=Xr=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&r)!==0&&(ei=!0),i.firstContext=null)}function Si(i){var r=i._currentValue;if(_u!==i)if(i={context:i,memoizedValue:r,next:null},Xr===null){if(cl===null)throw Error(n(308));Xr=i,cl.dependencies={lanes:0,firstContext:i}}else Xr=Xr.next=i;return r}var lr=null;function Su(i){lr===null?lr=[i]:lr.push(i)}function km(i,r,c,h){var g=r.interleaved;return g===null?(c.next=c,Su(r)):(c.next=g.next,g.next=c),r.interleaved=c,as(i,h)}function as(i,r){i.lanes|=r;var c=i.alternate;for(c!==null&&(c.lanes|=r),c=i,i=i.return;i!==null;)i.childLanes|=r,c=i.alternate,c!==null&&(c.childLanes|=r),c=i,i=i.return;return c.tag===3?c.stateNode:null}var Rs=!1;function xu(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Cm(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function ls(i,r){return{eventTime:i,lane:r,tag:0,payload:null,callback:null,next:null}}function Ps(i,r,c){var h=i.updateQueue;if(h===null)return null;if(h=h.shared,(Lt&2)!==0){var g=h.pending;return g===null?r.next=r:(r.next=g.next,g.next=r),h.pending=r,as(i,c)}return g=h.interleaved,g===null?(r.next=r,Su(h)):(r.next=g.next,g.next=r),h.interleaved=r,as(i,c)}function ul(i,r,c){if(r=r.updateQueue,r!==null&&(r=r.shared,(c&4194240)!==0)){var h=r.lanes;h&=i.pendingLanes,c|=h,r.lanes=c,Bi(i,c)}}function Em(i,r){var c=i.updateQueue,h=i.alternate;if(h!==null&&(h=h.updateQueue,c===h)){var g=null,_=null;if(c=c.firstBaseUpdate,c!==null){do{var P={eventTime:c.eventTime,lane:c.lane,tag:c.tag,payload:c.payload,callback:c.callback,next:null};_===null?g=_=P:_=_.next=P,c=c.next}while(c!==null);_===null?g=_=r:_=_.next=r}else g=_=r;c={baseState:h.baseState,firstBaseUpdate:g,lastBaseUpdate:_,shared:h.shared,effects:h.effects},i.updateQueue=c;return}i=c.lastBaseUpdate,i===null?c.firstBaseUpdate=r:i.next=r,c.lastBaseUpdate=r}function dl(i,r,c,h){var g=i.updateQueue;Rs=!1;var _=g.firstBaseUpdate,P=g.lastBaseUpdate,q=g.shared.pending;if(q!==null){g.shared.pending=null;var Z=q,he=Z.next;Z.next=null,P===null?_=he:P.next=he,P=Z;var xe=i.alternate;xe!==null&&(xe=xe.updateQueue,q=xe.lastBaseUpdate,q!==P&&(q===null?xe.firstBaseUpdate=he:q.next=he,xe.lastBaseUpdate=Z))}if(_!==null){var Ce=g.baseState;P=0,xe=he=Z=null,q=_;do{var we=q.lane,He=q.eventTime;if((h&we)===we){xe!==null&&(xe=xe.next={eventTime:He,lane:0,tag:q.tag,payload:q.payload,callback:q.callback,next:null});e:{var Ke=i,qe=q;switch(we=r,He=c,qe.tag){case 1:if(Ke=qe.payload,typeof Ke=="function"){Ce=Ke.call(He,Ce,we);break e}Ce=Ke;break e;case 3:Ke.flags=Ke.flags&-65537|128;case 0:if(Ke=qe.payload,we=typeof Ke=="function"?Ke.call(He,Ce,we):Ke,we==null)break e;Ce=M({},Ce,we);break e;case 2:Rs=!0}}q.callback!==null&&q.lane!==0&&(i.flags|=64,we=g.effects,we===null?g.effects=[q]:we.push(q))}else He={eventTime:He,lane:we,tag:q.tag,payload:q.payload,callback:q.callback,next:null},xe===null?(he=xe=He,Z=Ce):xe=xe.next=He,P|=we;if(q=q.next,q===null){if(q=g.shared.pending,q===null)break;we=q,q=we.next,we.next=null,g.lastBaseUpdate=we,g.shared.pending=null}}while(!0);if(xe===null&&(Z=Ce),g.baseState=Z,g.firstBaseUpdate=he,g.lastBaseUpdate=xe,r=g.shared.interleaved,r!==null){g=r;do P|=g.lane,g=g.next;while(g!==r)}else _===null&&(g.shared.lanes=0);dr|=P,i.lanes=P,i.memoizedState=Ce}}function Nm(i,r,c){if(i=r.effects,r.effects=null,i!==null)for(r=0;r<i.length;r++){var h=i[r],g=h.callback;if(g!==null){if(h.callback=null,h=c,typeof g!="function")throw Error(n(191,g));g.call(h)}}}var Uo={},$i=Es(Uo),Wo=Es(Uo),Ko=Es(Uo);function cr(i){if(i===Uo)throw Error(n(174));return i}function ku(i,r){switch(Ft(Ko,r),Ft(Wo,i),Ft($i,Uo),i=r.nodeType,i){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Qe(null,"");break;default:i=i===8?r.parentNode:r,r=i.namespaceURI||null,i=i.tagName,r=Qe(r,i)}qt($i),Ft($i,r)}function Jr(){qt($i),qt(Wo),qt(Ko)}function jm(i){cr(Ko.current);var r=cr($i.current),c=Qe(r,i.type);r!==c&&(Ft(Wo,i),Ft($i,c))}function Cu(i){Wo.current===i&&(qt($i),qt(Wo))}var Jt=Es(0);function hl(i){for(var r=i;r!==null;){if(r.tag===13){var c=r.memoizedState;if(c!==null&&(c=c.dehydrated,c===null||c.data==="$?"||c.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Eu=[];function Nu(){for(var i=0;i<Eu.length;i++)Eu[i]._workInProgressVersionPrimary=null;Eu.length=0}var fl=I.ReactCurrentDispatcher,ju=I.ReactCurrentBatchConfig,ur=0,Zt=null,vn=null,kn=null,pl=!1,qo=!1,Vo=0,v0=0;function $n(){throw Error(n(321))}function Ru(i,r){if(r===null)return!1;for(var c=0;c<r.length&&c<i.length;c++)if(!Li(i[c],r[c]))return!1;return!0}function Pu(i,r,c,h,g,_){if(ur=_,Zt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,fl.current=i===null||i.memoizedState===null?w0:S0,i=c(h,g),qo){_=0;do{if(qo=!1,Vo=0,25<=_)throw Error(n(301));_+=1,kn=vn=null,r.updateQueue=null,fl.current=x0,i=c(h,g)}while(qo)}if(fl.current=vl,r=vn!==null&&vn.next!==null,ur=0,kn=vn=Zt=null,pl=!1,r)throw Error(n(300));return i}function Lu(){var i=Vo!==0;return Vo=0,i}function Fi(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return kn===null?Zt.memoizedState=kn=i:kn=kn.next=i,kn}function xi(){if(vn===null){var i=Zt.alternate;i=i!==null?i.memoizedState:null}else i=vn.next;var r=kn===null?Zt.memoizedState:kn.next;if(r!==null)kn=r,vn=i;else{if(i===null)throw Error(n(310));vn=i,i={memoizedState:vn.memoizedState,baseState:vn.baseState,baseQueue:vn.baseQueue,queue:vn.queue,next:null},kn===null?Zt.memoizedState=kn=i:kn=kn.next=i}return kn}function Yo(i,r){return typeof r=="function"?r(i):r}function Au(i){var r=xi(),c=r.queue;if(c===null)throw Error(n(311));c.lastRenderedReducer=i;var h=vn,g=h.baseQueue,_=c.pending;if(_!==null){if(g!==null){var P=g.next;g.next=_.next,_.next=P}h.baseQueue=g=_,c.pending=null}if(g!==null){_=g.next,h=h.baseState;var q=P=null,Z=null,he=_;do{var xe=he.lane;if((ur&xe)===xe)Z!==null&&(Z=Z.next={lane:0,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null}),h=he.hasEagerState?he.eagerState:i(h,he.action);else{var Ce={lane:xe,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null};Z===null?(q=Z=Ce,P=h):Z=Z.next=Ce,Zt.lanes|=xe,dr|=xe}he=he.next}while(he!==null&&he!==_);Z===null?P=h:Z.next=q,Li(h,r.memoizedState)||(ei=!0),r.memoizedState=h,r.baseState=P,r.baseQueue=Z,c.lastRenderedState=h}if(i=c.interleaved,i!==null){g=i;do _=g.lane,Zt.lanes|=_,dr|=_,g=g.next;while(g!==i)}else g===null&&(c.lanes=0);return[r.memoizedState,c.dispatch]}function Mu(i){var r=xi(),c=r.queue;if(c===null)throw Error(n(311));c.lastRenderedReducer=i;var h=c.dispatch,g=c.pending,_=r.memoizedState;if(g!==null){c.pending=null;var P=g=g.next;do _=i(_,P.action),P=P.next;while(P!==g);Li(_,r.memoizedState)||(ei=!0),r.memoizedState=_,r.baseQueue===null&&(r.baseState=_),c.lastRenderedState=_}return[_,h]}function Rm(){}function Pm(i,r){var c=Zt,h=xi(),g=r(),_=!Li(h.memoizedState,g);if(_&&(h.memoizedState=g,ei=!0),h=h.queue,Tu(Mm.bind(null,c,h,i),[i]),h.getSnapshot!==r||_||kn!==null&&kn.memoizedState.tag&1){if(c.flags|=2048,Go(9,Am.bind(null,c,h,g,r),void 0,null),Cn===null)throw Error(n(349));(ur&30)!==0||Lm(c,r,g)}return g}function Lm(i,r,c){i.flags|=16384,i={getSnapshot:r,value:c},r=Zt.updateQueue,r===null?(r={lastEffect:null,stores:null},Zt.updateQueue=r,r.stores=[i]):(c=r.stores,c===null?r.stores=[i]:c.push(i))}function Am(i,r,c,h){r.value=c,r.getSnapshot=h,Tm(r)&&Dm(i)}function Mm(i,r,c){return c(function(){Tm(r)&&Dm(i)})}function Tm(i){var r=i.getSnapshot;i=i.value;try{var c=r();return!Li(i,c)}catch{return!0}}function Dm(i){var r=as(i,1);r!==null&&Ii(r,i,1,-1)}function Im(i){var r=Fi();return typeof i=="function"&&(i=i()),r.memoizedState=r.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Yo,lastRenderedState:i},r.queue=i,i=i.dispatch=b0.bind(null,Zt,i),[r.memoizedState,i]}function Go(i,r,c,h){return i={tag:i,create:r,destroy:c,deps:h,next:null},r=Zt.updateQueue,r===null?(r={lastEffect:null,stores:null},Zt.updateQueue=r,r.lastEffect=i.next=i):(c=r.lastEffect,c===null?r.lastEffect=i.next=i:(h=c.next,c.next=i,i.next=h,r.lastEffect=i)),i}function Om(){return xi().memoizedState}function ml(i,r,c,h){var g=Fi();Zt.flags|=i,g.memoizedState=Go(1|r,c,void 0,h===void 0?null:h)}function gl(i,r,c,h){var g=xi();h=h===void 0?null:h;var _=void 0;if(vn!==null){var P=vn.memoizedState;if(_=P.destroy,h!==null&&Ru(h,P.deps)){g.memoizedState=Go(r,c,_,h);return}}Zt.flags|=i,g.memoizedState=Go(1|r,c,_,h)}function Bm(i,r){return ml(8390656,8,i,r)}function Tu(i,r){return gl(2048,8,i,r)}function zm(i,r){return gl(4,2,i,r)}function $m(i,r){return gl(4,4,i,r)}function Fm(i,r){if(typeof r=="function")return i=i(),r(i),function(){r(null)};if(r!=null)return i=i(),r.current=i,function(){r.current=null}}function Hm(i,r,c){return c=c!=null?c.concat([i]):null,gl(4,4,Fm.bind(null,r,i),c)}function Du(){}function Um(i,r){var c=xi();r=r===void 0?null:r;var h=c.memoizedState;return h!==null&&r!==null&&Ru(r,h[1])?h[0]:(c.memoizedState=[i,r],i)}function Wm(i,r){var c=xi();r=r===void 0?null:r;var h=c.memoizedState;return h!==null&&r!==null&&Ru(r,h[1])?h[0]:(i=i(),c.memoizedState=[i,r],i)}function Km(i,r,c){return(ur&21)===0?(i.baseState&&(i.baseState=!1,ei=!0),i.memoizedState=c):(Li(c,r)||(c=Mr(),Zt.lanes|=c,dr|=c,i.baseState=!0),r)}function _0(i,r){var c=ft;ft=c!==0&&4>c?c:4,i(!0);var h=ju.transition;ju.transition={};try{i(!1),r()}finally{ft=c,ju.transition=h}}function qm(){return xi().memoizedState}function y0(i,r,c){var h=Ts(i);if(c={lane:h,action:c,hasEagerState:!1,eagerState:null,next:null},Vm(i))Ym(r,c);else if(c=km(i,r,c,h),c!==null){var g=qn();Ii(c,i,h,g),Gm(c,r,h)}}function b0(i,r,c){var h=Ts(i),g={lane:h,action:c,hasEagerState:!1,eagerState:null,next:null};if(Vm(i))Ym(r,g);else{var _=i.alternate;if(i.lanes===0&&(_===null||_.lanes===0)&&(_=r.lastRenderedReducer,_!==null))try{var P=r.lastRenderedState,q=_(P,c);if(g.hasEagerState=!0,g.eagerState=q,Li(q,P)){var Z=r.interleaved;Z===null?(g.next=g,Su(r)):(g.next=Z.next,Z.next=g),r.interleaved=g;return}}catch{}finally{}c=km(i,r,g,h),c!==null&&(g=qn(),Ii(c,i,h,g),Gm(c,r,h))}}function Vm(i){var r=i.alternate;return i===Zt||r!==null&&r===Zt}function Ym(i,r){qo=pl=!0;var c=i.pending;c===null?r.next=r:(r.next=c.next,c.next=r),i.pending=r}function Gm(i,r,c){if((c&4194240)!==0){var h=r.lanes;h&=i.pendingLanes,c|=h,r.lanes=c,Bi(i,c)}}var vl={readContext:Si,useCallback:$n,useContext:$n,useEffect:$n,useImperativeHandle:$n,useInsertionEffect:$n,useLayoutEffect:$n,useMemo:$n,useReducer:$n,useRef:$n,useState:$n,useDebugValue:$n,useDeferredValue:$n,useTransition:$n,useMutableSource:$n,useSyncExternalStore:$n,useId:$n,unstable_isNewReconciler:!1},w0={readContext:Si,useCallback:function(i,r){return Fi().memoizedState=[i,r===void 0?null:r],i},useContext:Si,useEffect:Bm,useImperativeHandle:function(i,r,c){return c=c!=null?c.concat([i]):null,ml(4194308,4,Fm.bind(null,r,i),c)},useLayoutEffect:function(i,r){return ml(4194308,4,i,r)},useInsertionEffect:function(i,r){return ml(4,2,i,r)},useMemo:function(i,r){var c=Fi();return r=r===void 0?null:r,i=i(),c.memoizedState=[i,r],i},useReducer:function(i,r,c){var h=Fi();return r=c!==void 0?c(r):r,h.memoizedState=h.baseState=r,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:r},h.queue=i,i=i.dispatch=y0.bind(null,Zt,i),[h.memoizedState,i]},useRef:function(i){var r=Fi();return i={current:i},r.memoizedState=i},useState:Im,useDebugValue:Du,useDeferredValue:function(i){return Fi().memoizedState=i},useTransition:function(){var i=Im(!1),r=i[0];return i=_0.bind(null,i[1]),Fi().memoizedState=i,[r,i]},useMutableSource:function(){},useSyncExternalStore:function(i,r,c){var h=Zt,g=Fi();if(Xt){if(c===void 0)throw Error(n(407));c=c()}else{if(c=r(),Cn===null)throw Error(n(349));(ur&30)!==0||Lm(h,r,c)}g.memoizedState=c;var _={value:c,getSnapshot:r};return g.queue=_,Bm(Mm.bind(null,h,_,i),[i]),h.flags|=2048,Go(9,Am.bind(null,h,_,c,r),void 0,null),c},useId:function(){var i=Fi(),r=Cn.identifierPrefix;if(Xt){var c=os,h=rs;c=(h&~(1<<32-Qn(h)-1)).toString(32)+c,r=":"+r+"R"+c,c=Vo++,0<c&&(r+="H"+c.toString(32)),r+=":"}else c=v0++,r=":"+r+"r"+c.toString(32)+":";return i.memoizedState=r},unstable_isNewReconciler:!1},S0={readContext:Si,useCallback:Um,useContext:Si,useEffect:Tu,useImperativeHandle:Hm,useInsertionEffect:zm,useLayoutEffect:$m,useMemo:Wm,useReducer:Au,useRef:Om,useState:function(){return Au(Yo)},useDebugValue:Du,useDeferredValue:function(i){var r=xi();return Km(r,vn.memoizedState,i)},useTransition:function(){var i=Au(Yo)[0],r=xi().memoizedState;return[i,r]},useMutableSource:Rm,useSyncExternalStore:Pm,useId:qm,unstable_isNewReconciler:!1},x0={readContext:Si,useCallback:Um,useContext:Si,useEffect:Tu,useImperativeHandle:Hm,useInsertionEffect:zm,useLayoutEffect:$m,useMemo:Wm,useReducer:Mu,useRef:Om,useState:function(){return Mu(Yo)},useDebugValue:Du,useDeferredValue:function(i){var r=xi();return vn===null?r.memoizedState=i:Km(r,vn.memoizedState,i)},useTransition:function(){var i=Mu(Yo)[0],r=xi().memoizedState;return[i,r]},useMutableSource:Rm,useSyncExternalStore:Pm,useId:qm,unstable_isNewReconciler:!1};function Mi(i,r){if(i&&i.defaultProps){r=M({},r),i=i.defaultProps;for(var c in i)r[c]===void 0&&(r[c]=i[c]);return r}return r}function Iu(i,r,c,h){r=i.memoizedState,c=c(h,r),c=c==null?r:M({},r,c),i.memoizedState=c,i.lanes===0&&(i.updateQueue.baseState=c)}var _l={isMounted:function(i){return(i=i._reactInternals)?te(i)===i:!1},enqueueSetState:function(i,r,c){i=i._reactInternals;var h=qn(),g=Ts(i),_=ls(h,g);_.payload=r,c!=null&&(_.callback=c),r=Ps(i,_,g),r!==null&&(Ii(r,i,g,h),ul(r,i,g))},enqueueReplaceState:function(i,r,c){i=i._reactInternals;var h=qn(),g=Ts(i),_=ls(h,g);_.tag=1,_.payload=r,c!=null&&(_.callback=c),r=Ps(i,_,g),r!==null&&(Ii(r,i,g,h),ul(r,i,g))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var c=qn(),h=Ts(i),g=ls(c,h);g.tag=2,r!=null&&(g.callback=r),r=Ps(i,g,h),r!==null&&(Ii(r,i,h,c),ul(r,i,h))}};function Xm(i,r,c,h,g,_,P){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(h,_,P):r.prototype&&r.prototype.isPureReactComponent?!Do(c,h)||!Do(g,_):!0}function Qm(i,r,c){var h=!1,g=Ns,_=r.contextType;return typeof _=="object"&&_!==null?_=Si(_):(g=Zn(r)?rr:zn.current,h=r.contextTypes,_=(h=h!=null)?Kr(i,g):Ns),r=new r(c,_),i.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=_l,i.stateNode=r,r._reactInternals=i,h&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=g,i.__reactInternalMemoizedMaskedChildContext=_),r}function Jm(i,r,c,h){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(c,h),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(c,h),r.state!==i&&_l.enqueueReplaceState(r,r.state,null)}function Ou(i,r,c,h){var g=i.stateNode;g.props=c,g.state=i.memoizedState,g.refs={},xu(i);var _=r.contextType;typeof _=="object"&&_!==null?g.context=Si(_):(_=Zn(r)?rr:zn.current,g.context=Kr(i,_)),g.state=i.memoizedState,_=r.getDerivedStateFromProps,typeof _=="function"&&(Iu(i,r,_,c),g.state=i.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(r=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),r!==g.state&&_l.enqueueReplaceState(g,g.state,null),dl(i,c,g,h),g.state=i.memoizedState),typeof g.componentDidMount=="function"&&(i.flags|=4194308)}function Zr(i,r){try{var c="",h=r;do c+=ee(h),h=h.return;while(h);var g=c}catch(_){g=`
39
- Error generating stack: `+_.message+`
40
- `+_.stack}return{value:i,source:r,stack:g,digest:null}}function Bu(i,r,c){return{value:i,source:null,stack:c??null,digest:r??null}}function zu(i,r){try{console.error(r.value)}catch(c){setTimeout(function(){throw c})}}var k0=typeof WeakMap=="function"?WeakMap:Map;function Zm(i,r,c){c=ls(-1,c),c.tag=3,c.payload={element:null};var h=r.value;return c.callback=function(){Cl||(Cl=!0,ed=h),zu(i,r)},c}function eg(i,r,c){c=ls(-1,c),c.tag=3;var h=i.type.getDerivedStateFromError;if(typeof h=="function"){var g=r.value;c.payload=function(){return h(g)},c.callback=function(){zu(i,r)}}var _=i.stateNode;return _!==null&&typeof _.componentDidCatch=="function"&&(c.callback=function(){zu(i,r),typeof h!="function"&&(As===null?As=new Set([this]):As.add(this));var P=r.stack;this.componentDidCatch(r.value,{componentStack:P!==null?P:""})}),c}function tg(i,r,c){var h=i.pingCache;if(h===null){h=i.pingCache=new k0;var g=new Set;h.set(r,g)}else g=h.get(r),g===void 0&&(g=new Set,h.set(r,g));g.has(c)||(g.add(c),i=B0.bind(null,i,r,c),r.then(i,i))}function ng(i){do{var r;if((r=i.tag===13)&&(r=i.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return i;i=i.return}while(i!==null);return null}function ig(i,r,c,h,g){return(i.mode&1)===0?(i===r?i.flags|=65536:(i.flags|=128,c.flags|=131072,c.flags&=-52805,c.tag===1&&(c.alternate===null?c.tag=17:(r=ls(-1,1),r.tag=2,Ps(c,r,1))),c.lanes|=1),i):(i.flags|=65536,i.lanes=g,i)}var C0=I.ReactCurrentOwner,ei=!1;function Kn(i,r,c,h){r.child=i===null?xm(r,null,c,h):Gr(r,i.child,c,h)}function sg(i,r,c,h,g){c=c.render;var _=r.ref;return Qr(r,g),h=Pu(i,r,c,h,_,g),c=Lu(),i!==null&&!ei?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~g,cs(i,r,g)):(Xt&&c&&fu(r),r.flags|=1,Kn(i,r,h,g),r.child)}function rg(i,r,c,h,g){if(i===null){var _=c.type;return typeof _=="function"&&!ad(_)&&_.defaultProps===void 0&&c.compare===null&&c.defaultProps===void 0?(r.tag=15,r.type=_,og(i,r,_,h,g)):(i=Ll(c.type,null,h,r,r.mode,g),i.ref=r.ref,i.return=r,r.child=i)}if(_=i.child,(i.lanes&g)===0){var P=_.memoizedProps;if(c=c.compare,c=c!==null?c:Do,c(P,h)&&i.ref===r.ref)return cs(i,r,g)}return r.flags|=1,i=Is(_,h),i.ref=r.ref,i.return=r,r.child=i}function og(i,r,c,h,g){if(i!==null){var _=i.memoizedProps;if(Do(_,h)&&i.ref===r.ref)if(ei=!1,r.pendingProps=h=_,(i.lanes&g)!==0)(i.flags&131072)!==0&&(ei=!0);else return r.lanes=i.lanes,cs(i,r,g)}return $u(i,r,c,h,g)}function ag(i,r,c){var h=r.pendingProps,g=h.children,_=i!==null?i.memoizedState:null;if(h.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ft(to,hi),hi|=c;else{if((c&1073741824)===0)return i=_!==null?_.baseLanes|c:c,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:i,cachePool:null,transitions:null},r.updateQueue=null,Ft(to,hi),hi|=i,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},h=_!==null?_.baseLanes:c,Ft(to,hi),hi|=h}else _!==null?(h=_.baseLanes|c,r.memoizedState=null):h=c,Ft(to,hi),hi|=h;return Kn(i,r,g,c),r.child}function lg(i,r){var c=r.ref;(i===null&&c!==null||i!==null&&i.ref!==c)&&(r.flags|=512,r.flags|=2097152)}function $u(i,r,c,h,g){var _=Zn(c)?rr:zn.current;return _=Kr(r,_),Qr(r,g),c=Pu(i,r,c,h,_,g),h=Lu(),i!==null&&!ei?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~g,cs(i,r,g)):(Xt&&h&&fu(r),r.flags|=1,Kn(i,r,c,g),r.child)}function cg(i,r,c,h,g){if(Zn(c)){var _=!0;nl(r)}else _=!1;if(Qr(r,g),r.stateNode===null)bl(i,r),Qm(r,c,h),Ou(r,c,h,g),h=!0;else if(i===null){var P=r.stateNode,q=r.memoizedProps;P.props=q;var Z=P.context,he=c.contextType;typeof he=="object"&&he!==null?he=Si(he):(he=Zn(c)?rr:zn.current,he=Kr(r,he));var xe=c.getDerivedStateFromProps,Ce=typeof xe=="function"||typeof P.getSnapshotBeforeUpdate=="function";Ce||typeof P.UNSAFE_componentWillReceiveProps!="function"&&typeof P.componentWillReceiveProps!="function"||(q!==h||Z!==he)&&Jm(r,P,h,he),Rs=!1;var we=r.memoizedState;P.state=we,dl(r,h,P,g),Z=r.memoizedState,q!==h||we!==Z||Jn.current||Rs?(typeof xe=="function"&&(Iu(r,c,xe,h),Z=r.memoizedState),(q=Rs||Xm(r,c,q,h,we,Z,he))?(Ce||typeof P.UNSAFE_componentWillMount!="function"&&typeof P.componentWillMount!="function"||(typeof P.componentWillMount=="function"&&P.componentWillMount(),typeof P.UNSAFE_componentWillMount=="function"&&P.UNSAFE_componentWillMount()),typeof P.componentDidMount=="function"&&(r.flags|=4194308)):(typeof P.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=h,r.memoizedState=Z),P.props=h,P.state=Z,P.context=he,h=q):(typeof P.componentDidMount=="function"&&(r.flags|=4194308),h=!1)}else{P=r.stateNode,Cm(i,r),q=r.memoizedProps,he=r.type===r.elementType?q:Mi(r.type,q),P.props=he,Ce=r.pendingProps,we=P.context,Z=c.contextType,typeof Z=="object"&&Z!==null?Z=Si(Z):(Z=Zn(c)?rr:zn.current,Z=Kr(r,Z));var He=c.getDerivedStateFromProps;(xe=typeof He=="function"||typeof P.getSnapshotBeforeUpdate=="function")||typeof P.UNSAFE_componentWillReceiveProps!="function"&&typeof P.componentWillReceiveProps!="function"||(q!==Ce||we!==Z)&&Jm(r,P,h,Z),Rs=!1,we=r.memoizedState,P.state=we,dl(r,h,P,g);var Ke=r.memoizedState;q!==Ce||we!==Ke||Jn.current||Rs?(typeof He=="function"&&(Iu(r,c,He,h),Ke=r.memoizedState),(he=Rs||Xm(r,c,he,h,we,Ke,Z)||!1)?(xe||typeof P.UNSAFE_componentWillUpdate!="function"&&typeof P.componentWillUpdate!="function"||(typeof P.componentWillUpdate=="function"&&P.componentWillUpdate(h,Ke,Z),typeof P.UNSAFE_componentWillUpdate=="function"&&P.UNSAFE_componentWillUpdate(h,Ke,Z)),typeof P.componentDidUpdate=="function"&&(r.flags|=4),typeof P.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof P.componentDidUpdate!="function"||q===i.memoizedProps&&we===i.memoizedState||(r.flags|=4),typeof P.getSnapshotBeforeUpdate!="function"||q===i.memoizedProps&&we===i.memoizedState||(r.flags|=1024),r.memoizedProps=h,r.memoizedState=Ke),P.props=h,P.state=Ke,P.context=Z,h=he):(typeof P.componentDidUpdate!="function"||q===i.memoizedProps&&we===i.memoizedState||(r.flags|=4),typeof P.getSnapshotBeforeUpdate!="function"||q===i.memoizedProps&&we===i.memoizedState||(r.flags|=1024),h=!1)}return Fu(i,r,c,h,_,g)}function Fu(i,r,c,h,g,_){lg(i,r);var P=(r.flags&128)!==0;if(!h&&!P)return g&&pm(r,c,!1),cs(i,r,_);h=r.stateNode,C0.current=r;var q=P&&typeof c.getDerivedStateFromError!="function"?null:h.render();return r.flags|=1,i!==null&&P?(r.child=Gr(r,i.child,null,_),r.child=Gr(r,null,q,_)):Kn(i,r,q,_),r.memoizedState=h.state,g&&pm(r,c,!0),r.child}function ug(i){var r=i.stateNode;r.pendingContext?hm(i,r.pendingContext,r.pendingContext!==r.context):r.context&&hm(i,r.context,!1),ku(i,r.containerInfo)}function dg(i,r,c,h,g){return Yr(),vu(g),r.flags|=256,Kn(i,r,c,h),r.child}var Hu={dehydrated:null,treeContext:null,retryLane:0};function Uu(i){return{baseLanes:i,cachePool:null,transitions:null}}function hg(i,r,c){var h=r.pendingProps,g=Jt.current,_=!1,P=(r.flags&128)!==0,q;if((q=P)||(q=i!==null&&i.memoizedState===null?!1:(g&2)!==0),q?(_=!0,r.flags&=-129):(i===null||i.memoizedState!==null)&&(g|=1),Ft(Jt,g&1),i===null)return gu(r),i=r.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((r.mode&1)===0?r.lanes=1:i.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(P=h.children,i=h.fallback,_?(h=r.mode,_=r.child,P={mode:"hidden",children:P},(h&1)===0&&_!==null?(_.childLanes=0,_.pendingProps=P):_=Al(P,h,0,null),i=mr(i,h,c,null),_.return=r,i.return=r,_.sibling=i,r.child=_,r.child.memoizedState=Uu(c),r.memoizedState=Hu,i):Wu(r,P));if(g=i.memoizedState,g!==null&&(q=g.dehydrated,q!==null))return E0(i,r,P,h,q,g,c);if(_){_=h.fallback,P=r.mode,g=i.child,q=g.sibling;var Z={mode:"hidden",children:h.children};return(P&1)===0&&r.child!==g?(h=r.child,h.childLanes=0,h.pendingProps=Z,r.deletions=null):(h=Is(g,Z),h.subtreeFlags=g.subtreeFlags&14680064),q!==null?_=Is(q,_):(_=mr(_,P,c,null),_.flags|=2),_.return=r,h.return=r,h.sibling=_,r.child=h,h=_,_=r.child,P=i.child.memoizedState,P=P===null?Uu(c):{baseLanes:P.baseLanes|c,cachePool:null,transitions:P.transitions},_.memoizedState=P,_.childLanes=i.childLanes&~c,r.memoizedState=Hu,h}return _=i.child,i=_.sibling,h=Is(_,{mode:"visible",children:h.children}),(r.mode&1)===0&&(h.lanes=c),h.return=r,h.sibling=null,i!==null&&(c=r.deletions,c===null?(r.deletions=[i],r.flags|=16):c.push(i)),r.child=h,r.memoizedState=null,h}function Wu(i,r){return r=Al({mode:"visible",children:r},i.mode,0,null),r.return=i,i.child=r}function yl(i,r,c,h){return h!==null&&vu(h),Gr(r,i.child,null,c),i=Wu(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function E0(i,r,c,h,g,_,P){if(c)return r.flags&256?(r.flags&=-257,h=Bu(Error(n(422))),yl(i,r,P,h)):r.memoizedState!==null?(r.child=i.child,r.flags|=128,null):(_=h.fallback,g=r.mode,h=Al({mode:"visible",children:h.children},g,0,null),_=mr(_,g,P,null),_.flags|=2,h.return=r,_.return=r,h.sibling=_,r.child=h,(r.mode&1)!==0&&Gr(r,i.child,null,P),r.child.memoizedState=Uu(P),r.memoizedState=Hu,_);if((r.mode&1)===0)return yl(i,r,P,null);if(g.data==="$!"){if(h=g.nextSibling&&g.nextSibling.dataset,h)var q=h.dgst;return h=q,_=Error(n(419)),h=Bu(_,h,void 0),yl(i,r,P,h)}if(q=(P&i.childLanes)!==0,ei||q){if(h=Cn,h!==null){switch(P&-P){case 4:g=2;break;case 16:g=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:g=32;break;case 536870912:g=268435456;break;default:g=0}g=(g&(h.suspendedLanes|P))!==0?0:g,g!==0&&g!==_.retryLane&&(_.retryLane=g,as(i,g),Ii(h,i,g,-1))}return od(),h=Bu(Error(n(421))),yl(i,r,P,h)}return g.data==="$?"?(r.flags|=128,r.child=i.child,r=z0.bind(null,i),g._reactRetry=r,null):(i=_.treeContext,di=Cs(g.nextSibling),ui=r,Xt=!0,Ai=null,i!==null&&(bi[wi++]=rs,bi[wi++]=os,bi[wi++]=or,rs=i.id,os=i.overflow,or=r),r=Wu(r,h.children),r.flags|=4096,r)}function fg(i,r,c){i.lanes|=r;var h=i.alternate;h!==null&&(h.lanes|=r),wu(i.return,r,c)}function Ku(i,r,c,h,g){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:h,tail:c,tailMode:g}:(_.isBackwards=r,_.rendering=null,_.renderingStartTime=0,_.last=h,_.tail=c,_.tailMode=g)}function pg(i,r,c){var h=r.pendingProps,g=h.revealOrder,_=h.tail;if(Kn(i,r,h.children,c),h=Jt.current,(h&2)!==0)h=h&1|2,r.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&fg(i,c,r);else if(i.tag===19)fg(i,c,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}h&=1}if(Ft(Jt,h),(r.mode&1)===0)r.memoizedState=null;else switch(g){case"forwards":for(c=r.child,g=null;c!==null;)i=c.alternate,i!==null&&hl(i)===null&&(g=c),c=c.sibling;c=g,c===null?(g=r.child,r.child=null):(g=c.sibling,c.sibling=null),Ku(r,!1,g,c,_);break;case"backwards":for(c=null,g=r.child,r.child=null;g!==null;){if(i=g.alternate,i!==null&&hl(i)===null){r.child=g;break}i=g.sibling,g.sibling=c,c=g,g=i}Ku(r,!0,c,null,_);break;case"together":Ku(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function bl(i,r){(r.mode&1)===0&&i!==null&&(i.alternate=null,r.alternate=null,r.flags|=2)}function cs(i,r,c){if(i!==null&&(r.dependencies=i.dependencies),dr|=r.lanes,(c&r.childLanes)===0)return null;if(i!==null&&r.child!==i.child)throw Error(n(153));if(r.child!==null){for(i=r.child,c=Is(i,i.pendingProps),r.child=c,c.return=r;i.sibling!==null;)i=i.sibling,c=c.sibling=Is(i,i.pendingProps),c.return=r;c.sibling=null}return r.child}function N0(i,r,c){switch(r.tag){case 3:ug(r),Yr();break;case 5:jm(r);break;case 1:Zn(r.type)&&nl(r);break;case 4:ku(r,r.stateNode.containerInfo);break;case 10:var h=r.type._context,g=r.memoizedProps.value;Ft(ll,h._currentValue),h._currentValue=g;break;case 13:if(h=r.memoizedState,h!==null)return h.dehydrated!==null?(Ft(Jt,Jt.current&1),r.flags|=128,null):(c&r.child.childLanes)!==0?hg(i,r,c):(Ft(Jt,Jt.current&1),i=cs(i,r,c),i!==null?i.sibling:null);Ft(Jt,Jt.current&1);break;case 19:if(h=(c&r.childLanes)!==0,(i.flags&128)!==0){if(h)return pg(i,r,c);r.flags|=128}if(g=r.memoizedState,g!==null&&(g.rendering=null,g.tail=null,g.lastEffect=null),Ft(Jt,Jt.current),h)break;return null;case 22:case 23:return r.lanes=0,ag(i,r,c)}return cs(i,r,c)}var mg,qu,gg,vg;mg=function(i,r){for(var c=r.child;c!==null;){if(c.tag===5||c.tag===6)i.appendChild(c.stateNode);else if(c.tag!==4&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===r)break;for(;c.sibling===null;){if(c.return===null||c.return===r)return;c=c.return}c.sibling.return=c.return,c=c.sibling}},qu=function(){},gg=function(i,r,c,h){var g=i.memoizedProps;if(g!==h){i=r.stateNode,cr($i.current);var _=null;switch(c){case"input":g=Ct(i,g),h=Ct(i,h),_=[];break;case"select":g=M({},g,{value:void 0}),h=M({},h,{value:void 0}),_=[];break;case"textarea":g=Dt(i,g),h=Dt(i,h),_=[];break;default:typeof g.onClick!="function"&&typeof h.onClick=="function"&&(i.onclick=Za)}it(c,h);var P;c=null;for(he in g)if(!h.hasOwnProperty(he)&&g.hasOwnProperty(he)&&g[he]!=null)if(he==="style"){var q=g[he];for(P in q)q.hasOwnProperty(P)&&(c||(c={}),c[P]="")}else he!=="dangerouslySetInnerHTML"&&he!=="children"&&he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&he!=="autoFocus"&&(o.hasOwnProperty(he)?_||(_=[]):(_=_||[]).push(he,null));for(he in h){var Z=h[he];if(q=g!=null?g[he]:void 0,h.hasOwnProperty(he)&&Z!==q&&(Z!=null||q!=null))if(he==="style")if(q){for(P in q)!q.hasOwnProperty(P)||Z&&Z.hasOwnProperty(P)||(c||(c={}),c[P]="");for(P in Z)Z.hasOwnProperty(P)&&q[P]!==Z[P]&&(c||(c={}),c[P]=Z[P])}else c||(_||(_=[]),_.push(he,c)),c=Z;else he==="dangerouslySetInnerHTML"?(Z=Z?Z.__html:void 0,q=q?q.__html:void 0,Z!=null&&q!==Z&&(_=_||[]).push(he,Z)):he==="children"?typeof Z!="string"&&typeof Z!="number"||(_=_||[]).push(he,""+Z):he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&(o.hasOwnProperty(he)?(Z!=null&&he==="onScroll"&&Kt("scroll",i),_||q===Z||(_=[])):(_=_||[]).push(he,Z))}c&&(_=_||[]).push("style",c);var he=_;(r.updateQueue=he)&&(r.flags|=4)}},vg=function(i,r,c,h){c!==h&&(r.flags|=4)};function Xo(i,r){if(!Xt)switch(i.tailMode){case"hidden":r=i.tail;for(var c=null;r!==null;)r.alternate!==null&&(c=r),r=r.sibling;c===null?i.tail=null:c.sibling=null;break;case"collapsed":c=i.tail;for(var h=null;c!==null;)c.alternate!==null&&(h=c),c=c.sibling;h===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:h.sibling=null}}function Fn(i){var r=i.alternate!==null&&i.alternate.child===i.child,c=0,h=0;if(r)for(var g=i.child;g!==null;)c|=g.lanes|g.childLanes,h|=g.subtreeFlags&14680064,h|=g.flags&14680064,g.return=i,g=g.sibling;else for(g=i.child;g!==null;)c|=g.lanes|g.childLanes,h|=g.subtreeFlags,h|=g.flags,g.return=i,g=g.sibling;return i.subtreeFlags|=h,i.childLanes=c,r}function j0(i,r,c){var h=r.pendingProps;switch(pu(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Fn(r),null;case 1:return Zn(r.type)&&tl(),Fn(r),null;case 3:return h=r.stateNode,Jr(),qt(Jn),qt(zn),Nu(),h.pendingContext&&(h.context=h.pendingContext,h.pendingContext=null),(i===null||i.child===null)&&(ol(r)?r.flags|=4:i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Ai!==null&&(id(Ai),Ai=null))),qu(i,r),Fn(r),null;case 5:Cu(r);var g=cr(Ko.current);if(c=r.type,i!==null&&r.stateNode!=null)gg(i,r,c,h,g),i.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!h){if(r.stateNode===null)throw Error(n(166));return Fn(r),null}if(i=cr($i.current),ol(r)){h=r.stateNode,c=r.type;var _=r.memoizedProps;switch(h[zi]=r,h[$o]=_,i=(r.mode&1)!==0,c){case"dialog":Kt("cancel",h),Kt("close",h);break;case"iframe":case"object":case"embed":Kt("load",h);break;case"video":case"audio":for(g=0;g<Oo.length;g++)Kt(Oo[g],h);break;case"source":Kt("error",h);break;case"img":case"image":case"link":Kt("error",h),Kt("load",h);break;case"details":Kt("toggle",h);break;case"input":dn(h,_),Kt("invalid",h);break;case"select":h._wrapperState={wasMultiple:!!_.multiple},Kt("invalid",h);break;case"textarea":At(h,_),Kt("invalid",h)}it(c,_),g=null;for(var P in _)if(_.hasOwnProperty(P)){var q=_[P];P==="children"?typeof q=="string"?h.textContent!==q&&(_.suppressHydrationWarning!==!0&&Ja(h.textContent,q,i),g=["children",q]):typeof q=="number"&&h.textContent!==""+q&&(_.suppressHydrationWarning!==!0&&Ja(h.textContent,q,i),g=["children",""+q]):o.hasOwnProperty(P)&&q!=null&&P==="onScroll"&&Kt("scroll",h)}switch(c){case"input":ut(h),xt(h,_,!0);break;case"textarea":ut(h),hn(h);break;case"select":case"option":break;default:typeof _.onClick=="function"&&(h.onclick=Za)}h=g,r.updateQueue=h,h!==null&&(r.flags|=4)}else{P=g.nodeType===9?g:g.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=re(c)),i==="http://www.w3.org/1999/xhtml"?c==="script"?(i=P.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof h.is=="string"?i=P.createElement(c,{is:h.is}):(i=P.createElement(c),c==="select"&&(P=i,h.multiple?P.multiple=!0:h.size&&(P.size=h.size))):i=P.createElementNS(i,c),i[zi]=r,i[$o]=h,mg(i,r,!1,!1),r.stateNode=i;e:{switch(P=ht(c,h),c){case"dialog":Kt("cancel",i),Kt("close",i),g=h;break;case"iframe":case"object":case"embed":Kt("load",i),g=h;break;case"video":case"audio":for(g=0;g<Oo.length;g++)Kt(Oo[g],i);g=h;break;case"source":Kt("error",i),g=h;break;case"img":case"image":case"link":Kt("error",i),Kt("load",i),g=h;break;case"details":Kt("toggle",i),g=h;break;case"input":dn(i,h),g=Ct(i,h),Kt("invalid",i);break;case"option":g=h;break;case"select":i._wrapperState={wasMultiple:!!h.multiple},g=M({},h,{value:void 0}),Kt("invalid",i);break;case"textarea":At(i,h),g=Dt(i,h),Kt("invalid",i);break;default:g=h}it(c,g),q=g;for(_ in q)if(q.hasOwnProperty(_)){var Z=q[_];_==="style"?be(i,Z):_==="dangerouslySetInnerHTML"?(Z=Z?Z.__html:void 0,Z!=null&&Ge(i,Z)):_==="children"?typeof Z=="string"?(c!=="textarea"||Z!=="")&&ct(i,Z):typeof Z=="number"&&ct(i,""+Z):_!=="suppressContentEditableWarning"&&_!=="suppressHydrationWarning"&&_!=="autoFocus"&&(o.hasOwnProperty(_)?Z!=null&&_==="onScroll"&&Kt("scroll",i):Z!=null&&L(i,_,Z,P))}switch(c){case"input":ut(i),xt(i,h,!1);break;case"textarea":ut(i),hn(i);break;case"option":h.value!=null&&i.setAttribute("value",""+fe(h.value));break;case"select":i.multiple=!!h.multiple,_=h.value,_!=null?Nt(i,!!h.multiple,_,!1):h.defaultValue!=null&&Nt(i,!!h.multiple,h.defaultValue,!0);break;default:typeof g.onClick=="function"&&(i.onclick=Za)}switch(c){case"button":case"input":case"select":case"textarea":h=!!h.autoFocus;break e;case"img":h=!0;break e;default:h=!1}}h&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return Fn(r),null;case 6:if(i&&r.stateNode!=null)vg(i,r,i.memoizedProps,h);else{if(typeof h!="string"&&r.stateNode===null)throw Error(n(166));if(c=cr(Ko.current),cr($i.current),ol(r)){if(h=r.stateNode,c=r.memoizedProps,h[zi]=r,(_=h.nodeValue!==c)&&(i=ui,i!==null))switch(i.tag){case 3:Ja(h.nodeValue,c,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Ja(h.nodeValue,c,(i.mode&1)!==0)}_&&(r.flags|=4)}else h=(c.nodeType===9?c:c.ownerDocument).createTextNode(h),h[zi]=r,r.stateNode=h}return Fn(r),null;case 13:if(qt(Jt),h=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(Xt&&di!==null&&(r.mode&1)!==0&&(r.flags&128)===0)bm(),Yr(),r.flags|=98560,_=!1;else if(_=ol(r),h!==null&&h.dehydrated!==null){if(i===null){if(!_)throw Error(n(318));if(_=r.memoizedState,_=_!==null?_.dehydrated:null,!_)throw Error(n(317));_[zi]=r}else Yr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Fn(r),_=!1}else Ai!==null&&(id(Ai),Ai=null),_=!0;if(!_)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=c,r):(h=h!==null,h!==(i!==null&&i.memoizedState!==null)&&h&&(r.child.flags|=8192,(r.mode&1)!==0&&(i===null||(Jt.current&1)!==0?_n===0&&(_n=3):od())),r.updateQueue!==null&&(r.flags|=4),Fn(r),null);case 4:return Jr(),qu(i,r),i===null&&Bo(r.stateNode.containerInfo),Fn(r),null;case 10:return bu(r.type._context),Fn(r),null;case 17:return Zn(r.type)&&tl(),Fn(r),null;case 19:if(qt(Jt),_=r.memoizedState,_===null)return Fn(r),null;if(h=(r.flags&128)!==0,P=_.rendering,P===null)if(h)Xo(_,!1);else{if(_n!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(P=hl(i),P!==null){for(r.flags|=128,Xo(_,!1),h=P.updateQueue,h!==null&&(r.updateQueue=h,r.flags|=4),r.subtreeFlags=0,h=c,c=r.child;c!==null;)_=c,i=h,_.flags&=14680066,P=_.alternate,P===null?(_.childLanes=0,_.lanes=i,_.child=null,_.subtreeFlags=0,_.memoizedProps=null,_.memoizedState=null,_.updateQueue=null,_.dependencies=null,_.stateNode=null):(_.childLanes=P.childLanes,_.lanes=P.lanes,_.child=P.child,_.subtreeFlags=0,_.deletions=null,_.memoizedProps=P.memoizedProps,_.memoizedState=P.memoizedState,_.updateQueue=P.updateQueue,_.type=P.type,i=P.dependencies,_.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),c=c.sibling;return Ft(Jt,Jt.current&1|2),r.child}i=i.sibling}_.tail!==null&&Mt()>no&&(r.flags|=128,h=!0,Xo(_,!1),r.lanes=4194304)}else{if(!h)if(i=hl(P),i!==null){if(r.flags|=128,h=!0,c=i.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),Xo(_,!0),_.tail===null&&_.tailMode==="hidden"&&!P.alternate&&!Xt)return Fn(r),null}else 2*Mt()-_.renderingStartTime>no&&c!==1073741824&&(r.flags|=128,h=!0,Xo(_,!1),r.lanes=4194304);_.isBackwards?(P.sibling=r.child,r.child=P):(c=_.last,c!==null?c.sibling=P:r.child=P,_.last=P)}return _.tail!==null?(r=_.tail,_.rendering=r,_.tail=r.sibling,_.renderingStartTime=Mt(),r.sibling=null,c=Jt.current,Ft(Jt,h?c&1|2:c&1),r):(Fn(r),null);case 22:case 23:return rd(),h=r.memoizedState!==null,i!==null&&i.memoizedState!==null!==h&&(r.flags|=8192),h&&(r.mode&1)!==0?(hi&1073741824)!==0&&(Fn(r),r.subtreeFlags&6&&(r.flags|=8192)):Fn(r),null;case 24:return null;case 25:return null}throw Error(n(156,r.tag))}function R0(i,r){switch(pu(r),r.tag){case 1:return Zn(r.type)&&tl(),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return Jr(),qt(Jn),qt(zn),Nu(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 5:return Cu(r),null;case 13:if(qt(Jt),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(n(340));Yr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return qt(Jt),null;case 4:return Jr(),null;case 10:return bu(r.type._context),null;case 22:case 23:return rd(),null;case 24:return null;default:return null}}var wl=!1,Hn=!1,P0=typeof WeakSet=="function"?WeakSet:Set,We=null;function eo(i,r){var c=i.ref;if(c!==null)if(typeof c=="function")try{c(null)}catch(h){sn(i,r,h)}else c.current=null}function Vu(i,r,c){try{c()}catch(h){sn(i,r,h)}}var _g=!1;function L0(i,r){if(ru=Ir,i=Xp(),Qc(i)){if("selectionStart"in i)var c={start:i.selectionStart,end:i.selectionEnd};else e:{c=(c=i.ownerDocument)&&c.defaultView||window;var h=c.getSelection&&c.getSelection();if(h&&h.rangeCount!==0){c=h.anchorNode;var g=h.anchorOffset,_=h.focusNode;h=h.focusOffset;try{c.nodeType,_.nodeType}catch{c=null;break e}var P=0,q=-1,Z=-1,he=0,xe=0,Ce=i,we=null;t:for(;;){for(var He;Ce!==c||g!==0&&Ce.nodeType!==3||(q=P+g),Ce!==_||h!==0&&Ce.nodeType!==3||(Z=P+h),Ce.nodeType===3&&(P+=Ce.nodeValue.length),(He=Ce.firstChild)!==null;)we=Ce,Ce=He;for(;;){if(Ce===i)break t;if(we===c&&++he===g&&(q=P),we===_&&++xe===h&&(Z=P),(He=Ce.nextSibling)!==null)break;Ce=we,we=Ce.parentNode}Ce=He}c=q===-1||Z===-1?null:{start:q,end:Z}}else c=null}c=c||{start:0,end:0}}else c=null;for(ou={focusedElem:i,selectionRange:c},Ir=!1,We=r;We!==null;)if(r=We,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,We=i;else for(;We!==null;){r=We;try{var Ke=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Ke!==null){var qe=Ke.memoizedProps,ln=Ke.memoizedState,ce=r.stateNode,ne=ce.getSnapshotBeforeUpdate(r.elementType===r.type?qe:Mi(r.type,qe),ln);ce.__reactInternalSnapshotBeforeUpdate=ne}break;case 3:var ue=r.stateNode.containerInfo;ue.nodeType===1?ue.textContent="":ue.nodeType===9&&ue.documentElement&&ue.removeChild(ue.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Re){sn(r,r.return,Re)}if(i=r.sibling,i!==null){i.return=r.return,We=i;break}We=r.return}return Ke=_g,_g=!1,Ke}function Qo(i,r,c){var h=r.updateQueue;if(h=h!==null?h.lastEffect:null,h!==null){var g=h=h.next;do{if((g.tag&i)===i){var _=g.destroy;g.destroy=void 0,_!==void 0&&Vu(r,c,_)}g=g.next}while(g!==h)}}function Sl(i,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var c=r=r.next;do{if((c.tag&i)===i){var h=c.create;c.destroy=h()}c=c.next}while(c!==r)}}function Yu(i){var r=i.ref;if(r!==null){var c=i.stateNode;switch(i.tag){case 5:i=c;break;default:i=c}typeof r=="function"?r(i):r.current=i}}function yg(i){var r=i.alternate;r!==null&&(i.alternate=null,yg(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&(delete r[zi],delete r[$o],delete r[uu],delete r[f0],delete r[p0])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function bg(i){return i.tag===5||i.tag===3||i.tag===4}function wg(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||bg(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function Gu(i,r,c){var h=i.tag;if(h===5||h===6)i=i.stateNode,r?c.nodeType===8?c.parentNode.insertBefore(i,r):c.insertBefore(i,r):(c.nodeType===8?(r=c.parentNode,r.insertBefore(i,c)):(r=c,r.appendChild(i)),c=c._reactRootContainer,c!=null||r.onclick!==null||(r.onclick=Za));else if(h!==4&&(i=i.child,i!==null))for(Gu(i,r,c),i=i.sibling;i!==null;)Gu(i,r,c),i=i.sibling}function Xu(i,r,c){var h=i.tag;if(h===5||h===6)i=i.stateNode,r?c.insertBefore(i,r):c.appendChild(i);else if(h!==4&&(i=i.child,i!==null))for(Xu(i,r,c),i=i.sibling;i!==null;)Xu(i,r,c),i=i.sibling}var Tn=null,Ti=!1;function Ls(i,r,c){for(c=c.child;c!==null;)Sg(i,r,c),c=c.sibling}function Sg(i,r,c){if(oi&&typeof oi.onCommitFiberUnmount=="function")try{oi.onCommitFiberUnmount(Zs,c)}catch{}switch(c.tag){case 5:Hn||eo(c,r);case 6:var h=Tn,g=Ti;Tn=null,Ls(i,r,c),Tn=h,Ti=g,Tn!==null&&(Ti?(i=Tn,c=c.stateNode,i.nodeType===8?i.parentNode.removeChild(c):i.removeChild(c)):Tn.removeChild(c.stateNode));break;case 18:Tn!==null&&(Ti?(i=Tn,c=c.stateNode,i.nodeType===8?cu(i.parentNode,c):i.nodeType===1&&cu(i,c),xn(i)):cu(Tn,c.stateNode));break;case 4:h=Tn,g=Ti,Tn=c.stateNode.containerInfo,Ti=!0,Ls(i,r,c),Tn=h,Ti=g;break;case 0:case 11:case 14:case 15:if(!Hn&&(h=c.updateQueue,h!==null&&(h=h.lastEffect,h!==null))){g=h=h.next;do{var _=g,P=_.destroy;_=_.tag,P!==void 0&&((_&2)!==0||(_&4)!==0)&&Vu(c,r,P),g=g.next}while(g!==h)}Ls(i,r,c);break;case 1:if(!Hn&&(eo(c,r),h=c.stateNode,typeof h.componentWillUnmount=="function"))try{h.props=c.memoizedProps,h.state=c.memoizedState,h.componentWillUnmount()}catch(q){sn(c,r,q)}Ls(i,r,c);break;case 21:Ls(i,r,c);break;case 22:c.mode&1?(Hn=(h=Hn)||c.memoizedState!==null,Ls(i,r,c),Hn=h):Ls(i,r,c);break;default:Ls(i,r,c)}}function xg(i){var r=i.updateQueue;if(r!==null){i.updateQueue=null;var c=i.stateNode;c===null&&(c=i.stateNode=new P0),r.forEach(function(h){var g=$0.bind(null,i,h);c.has(h)||(c.add(h),h.then(g,g))})}}function Di(i,r){var c=r.deletions;if(c!==null)for(var h=0;h<c.length;h++){var g=c[h];try{var _=i,P=r,q=P;e:for(;q!==null;){switch(q.tag){case 5:Tn=q.stateNode,Ti=!1;break e;case 3:Tn=q.stateNode.containerInfo,Ti=!0;break e;case 4:Tn=q.stateNode.containerInfo,Ti=!0;break e}q=q.return}if(Tn===null)throw Error(n(160));Sg(_,P,g),Tn=null,Ti=!1;var Z=g.alternate;Z!==null&&(Z.return=null),g.return=null}catch(he){sn(g,r,he)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)kg(r,i),r=r.sibling}function kg(i,r){var c=i.alternate,h=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(Di(r,i),Hi(i),h&4){try{Qo(3,i,i.return),Sl(3,i)}catch(qe){sn(i,i.return,qe)}try{Qo(5,i,i.return)}catch(qe){sn(i,i.return,qe)}}break;case 1:Di(r,i),Hi(i),h&512&&c!==null&&eo(c,c.return);break;case 5:if(Di(r,i),Hi(i),h&512&&c!==null&&eo(c,c.return),i.flags&32){var g=i.stateNode;try{ct(g,"")}catch(qe){sn(i,i.return,qe)}}if(h&4&&(g=i.stateNode,g!=null)){var _=i.memoizedProps,P=c!==null?c.memoizedProps:_,q=i.type,Z=i.updateQueue;if(i.updateQueue=null,Z!==null)try{q==="input"&&_.type==="radio"&&_.name!=null&&gn(g,_),ht(q,P);var he=ht(q,_);for(P=0;P<Z.length;P+=2){var xe=Z[P],Ce=Z[P+1];xe==="style"?be(g,Ce):xe==="dangerouslySetInnerHTML"?Ge(g,Ce):xe==="children"?ct(g,Ce):L(g,xe,Ce,he)}switch(q){case"input":Yt(g,_);break;case"textarea":jt(g,_);break;case"select":var we=g._wrapperState.wasMultiple;g._wrapperState.wasMultiple=!!_.multiple;var He=_.value;He!=null?Nt(g,!!_.multiple,He,!1):we!==!!_.multiple&&(_.defaultValue!=null?Nt(g,!!_.multiple,_.defaultValue,!0):Nt(g,!!_.multiple,_.multiple?[]:"",!1))}g[$o]=_}catch(qe){sn(i,i.return,qe)}}break;case 6:if(Di(r,i),Hi(i),h&4){if(i.stateNode===null)throw Error(n(162));g=i.stateNode,_=i.memoizedProps;try{g.nodeValue=_}catch(qe){sn(i,i.return,qe)}}break;case 3:if(Di(r,i),Hi(i),h&4&&c!==null&&c.memoizedState.isDehydrated)try{xn(r.containerInfo)}catch(qe){sn(i,i.return,qe)}break;case 4:Di(r,i),Hi(i);break;case 13:Di(r,i),Hi(i),g=i.child,g.flags&8192&&(_=g.memoizedState!==null,g.stateNode.isHidden=_,!_||g.alternate!==null&&g.alternate.memoizedState!==null||(Zu=Mt())),h&4&&xg(i);break;case 22:if(xe=c!==null&&c.memoizedState!==null,i.mode&1?(Hn=(he=Hn)||xe,Di(r,i),Hn=he):Di(r,i),Hi(i),h&8192){if(he=i.memoizedState!==null,(i.stateNode.isHidden=he)&&!xe&&(i.mode&1)!==0)for(We=i,xe=i.child;xe!==null;){for(Ce=We=xe;We!==null;){switch(we=We,He=we.child,we.tag){case 0:case 11:case 14:case 15:Qo(4,we,we.return);break;case 1:eo(we,we.return);var Ke=we.stateNode;if(typeof Ke.componentWillUnmount=="function"){h=we,c=we.return;try{r=h,Ke.props=r.memoizedProps,Ke.state=r.memoizedState,Ke.componentWillUnmount()}catch(qe){sn(h,c,qe)}}break;case 5:eo(we,we.return);break;case 22:if(we.memoizedState!==null){Ng(Ce);continue}}He!==null?(He.return=we,We=He):Ng(Ce)}xe=xe.sibling}e:for(xe=null,Ce=i;;){if(Ce.tag===5){if(xe===null){xe=Ce;try{g=Ce.stateNode,he?(_=g.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none"):(q=Ce.stateNode,Z=Ce.memoizedProps.style,P=Z!=null&&Z.hasOwnProperty("display")?Z.display:null,q.style.display=_e("display",P))}catch(qe){sn(i,i.return,qe)}}}else if(Ce.tag===6){if(xe===null)try{Ce.stateNode.nodeValue=he?"":Ce.memoizedProps}catch(qe){sn(i,i.return,qe)}}else if((Ce.tag!==22&&Ce.tag!==23||Ce.memoizedState===null||Ce===i)&&Ce.child!==null){Ce.child.return=Ce,Ce=Ce.child;continue}if(Ce===i)break e;for(;Ce.sibling===null;){if(Ce.return===null||Ce.return===i)break e;xe===Ce&&(xe=null),Ce=Ce.return}xe===Ce&&(xe=null),Ce.sibling.return=Ce.return,Ce=Ce.sibling}}break;case 19:Di(r,i),Hi(i),h&4&&xg(i);break;case 21:break;default:Di(r,i),Hi(i)}}function Hi(i){var r=i.flags;if(r&2){try{e:{for(var c=i.return;c!==null;){if(bg(c)){var h=c;break e}c=c.return}throw Error(n(160))}switch(h.tag){case 5:var g=h.stateNode;h.flags&32&&(ct(g,""),h.flags&=-33);var _=wg(i);Xu(i,_,g);break;case 3:case 4:var P=h.stateNode.containerInfo,q=wg(i);Gu(i,q,P);break;default:throw Error(n(161))}}catch(Z){sn(i,i.return,Z)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function A0(i,r,c){We=i,Cg(i)}function Cg(i,r,c){for(var h=(i.mode&1)!==0;We!==null;){var g=We,_=g.child;if(g.tag===22&&h){var P=g.memoizedState!==null||wl;if(!P){var q=g.alternate,Z=q!==null&&q.memoizedState!==null||Hn;q=wl;var he=Hn;if(wl=P,(Hn=Z)&&!he)for(We=g;We!==null;)P=We,Z=P.child,P.tag===22&&P.memoizedState!==null?jg(g):Z!==null?(Z.return=P,We=Z):jg(g);for(;_!==null;)We=_,Cg(_),_=_.sibling;We=g,wl=q,Hn=he}Eg(i)}else(g.subtreeFlags&8772)!==0&&_!==null?(_.return=g,We=_):Eg(i)}}function Eg(i){for(;We!==null;){var r=We;if((r.flags&8772)!==0){var c=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Hn||Sl(5,r);break;case 1:var h=r.stateNode;if(r.flags&4&&!Hn)if(c===null)h.componentDidMount();else{var g=r.elementType===r.type?c.memoizedProps:Mi(r.type,c.memoizedProps);h.componentDidUpdate(g,c.memoizedState,h.__reactInternalSnapshotBeforeUpdate)}var _=r.updateQueue;_!==null&&Nm(r,_,h);break;case 3:var P=r.updateQueue;if(P!==null){if(c=null,r.child!==null)switch(r.child.tag){case 5:c=r.child.stateNode;break;case 1:c=r.child.stateNode}Nm(r,P,c)}break;case 5:var q=r.stateNode;if(c===null&&r.flags&4){c=q;var Z=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":Z.autoFocus&&c.focus();break;case"img":Z.src&&(c.src=Z.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var he=r.alternate;if(he!==null){var xe=he.memoizedState;if(xe!==null){var Ce=xe.dehydrated;Ce!==null&&xn(Ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Hn||r.flags&512&&Yu(r)}catch(we){sn(r,r.return,we)}}if(r===i){We=null;break}if(c=r.sibling,c!==null){c.return=r.return,We=c;break}We=r.return}}function Ng(i){for(;We!==null;){var r=We;if(r===i){We=null;break}var c=r.sibling;if(c!==null){c.return=r.return,We=c;break}We=r.return}}function jg(i){for(;We!==null;){var r=We;try{switch(r.tag){case 0:case 11:case 15:var c=r.return;try{Sl(4,r)}catch(Z){sn(r,c,Z)}break;case 1:var h=r.stateNode;if(typeof h.componentDidMount=="function"){var g=r.return;try{h.componentDidMount()}catch(Z){sn(r,g,Z)}}var _=r.return;try{Yu(r)}catch(Z){sn(r,_,Z)}break;case 5:var P=r.return;try{Yu(r)}catch(Z){sn(r,P,Z)}}}catch(Z){sn(r,r.return,Z)}if(r===i){We=null;break}var q=r.sibling;if(q!==null){q.return=r.return,We=q;break}We=r.return}}var M0=Math.ceil,xl=I.ReactCurrentDispatcher,Qu=I.ReactCurrentOwner,ki=I.ReactCurrentBatchConfig,Lt=0,Cn=null,fn=null,Dn=0,hi=0,to=Es(0),_n=0,Jo=null,dr=0,kl=0,Ju=0,Zo=null,ti=null,Zu=0,no=1/0,us=null,Cl=!1,ed=null,As=null,El=!1,Ms=null,Nl=0,ea=0,td=null,jl=-1,Rl=0;function qn(){return(Lt&6)!==0?Mt():jl!==-1?jl:jl=Mt()}function Ts(i){return(i.mode&1)===0?1:(Lt&2)!==0&&Dn!==0?Dn&-Dn:g0.transition!==null?(Rl===0&&(Rl=Mr()),Rl):(i=ft,i!==0||(i=window.event,i=i===void 0?16:Pp(i.type)),i)}function Ii(i,r,c,h){if(50<ea)throw ea=0,td=null,Error(n(185));yi(i,c,h),((Lt&2)===0||i!==Cn)&&(i===Cn&&((Lt&2)===0&&(kl|=c),_n===4&&Ds(i,Dn)),ni(i,h),c===1&&Lt===0&&(r.mode&1)===0&&(no=Mt()+500,il&&js()))}function ni(i,r){var c=i.callbackNode;Lr(i,r);var h=ts(i,i===Cn?Dn:0);if(h===0)c!==null&&Sn(c),i.callbackNode=null,i.callbackPriority=0;else if(r=h&-h,i.callbackPriority!==r){if(c!=null&&Sn(c),r===1)i.tag===0?m0(Pg.bind(null,i)):mm(Pg.bind(null,i)),d0(function(){(Lt&6)===0&&js()}),c=null;else{switch(Dr(h)){case 1:c=No;break;case 4:c=Qs;break;case 16:c=Js;break;case 536870912:c=Pr;break;default:c=Js}c=Bg(c,Rg.bind(null,i))}i.callbackPriority=r,i.callbackNode=c}}function Rg(i,r){if(jl=-1,Rl=0,(Lt&6)!==0)throw Error(n(327));var c=i.callbackNode;if(io()&&i.callbackNode!==c)return null;var h=ts(i,i===Cn?Dn:0);if(h===0)return null;if((h&30)!==0||(h&i.expiredLanes)!==0||r)r=Pl(i,h);else{r=h;var g=Lt;Lt|=2;var _=Ag();(Cn!==i||Dn!==r)&&(us=null,no=Mt()+500,fr(i,r));do try{I0();break}catch(q){Lg(i,q)}while(!0);yu(),xl.current=_,Lt=g,fn!==null?r=0:(Cn=null,Dn=0,r=_n)}if(r!==0){if(r===2&&(g=Ar(i),g!==0&&(h=g,r=nd(i,g))),r===1)throw c=Jo,fr(i,0),Ds(i,h),ni(i,Mt()),c;if(r===6)Ds(i,h);else{if(g=i.current.alternate,(h&30)===0&&!T0(g)&&(r=Pl(i,h),r===2&&(_=Ar(i),_!==0&&(h=_,r=nd(i,_))),r===1))throw c=Jo,fr(i,0),Ds(i,h),ni(i,Mt()),c;switch(i.finishedWork=g,i.finishedLanes=h,r){case 0:case 1:throw Error(n(345));case 2:pr(i,ti,us);break;case 3:if(Ds(i,h),(h&130023424)===h&&(r=Zu+500-Mt(),10<r)){if(ts(i,0)!==0)break;if(g=i.suspendedLanes,(g&h)!==h){qn(),i.pingedLanes|=i.suspendedLanes&g;break}i.timeoutHandle=lu(pr.bind(null,i,ti,us),r);break}pr(i,ti,us);break;case 4:if(Ds(i,h),(h&4194240)===h)break;for(r=i.eventTimes,g=-1;0<h;){var P=31-Qn(h);_=1<<P,P=r[P],P>g&&(g=P),h&=~_}if(h=g,h=Mt()-h,h=(120>h?120:480>h?480:1080>h?1080:1920>h?1920:3e3>h?3e3:4320>h?4320:1960*M0(h/1960))-h,10<h){i.timeoutHandle=lu(pr.bind(null,i,ti,us),h);break}pr(i,ti,us);break;case 5:pr(i,ti,us);break;default:throw Error(n(329))}}}return ni(i,Mt()),i.callbackNode===c?Rg.bind(null,i):null}function nd(i,r){var c=Zo;return i.current.memoizedState.isDehydrated&&(fr(i,r).flags|=256),i=Pl(i,r),i!==2&&(r=ti,ti=c,r!==null&&id(r)),i}function id(i){ti===null?ti=i:ti.push.apply(ti,i)}function T0(i){for(var r=i;;){if(r.flags&16384){var c=r.updateQueue;if(c!==null&&(c=c.stores,c!==null))for(var h=0;h<c.length;h++){var g=c[h],_=g.getSnapshot;g=g.value;try{if(!Li(_(),g))return!1}catch{return!1}}}if(c=r.child,r.subtreeFlags&16384&&c!==null)c.return=r,r=c;else{if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Ds(i,r){for(r&=~Ju,r&=~kl,i.suspendedLanes|=r,i.pingedLanes&=~r,i=i.expirationTimes;0<r;){var c=31-Qn(r),h=1<<c;i[c]=-1,r&=~h}}function Pg(i){if((Lt&6)!==0)throw Error(n(327));io();var r=ts(i,0);if((r&1)===0)return ni(i,Mt()),null;var c=Pl(i,r);if(i.tag!==0&&c===2){var h=Ar(i);h!==0&&(r=h,c=nd(i,h))}if(c===1)throw c=Jo,fr(i,0),Ds(i,r),ni(i,Mt()),c;if(c===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=r,pr(i,ti,us),ni(i,Mt()),null}function sd(i,r){var c=Lt;Lt|=1;try{return i(r)}finally{Lt=c,Lt===0&&(no=Mt()+500,il&&js())}}function hr(i){Ms!==null&&Ms.tag===0&&(Lt&6)===0&&io();var r=Lt;Lt|=1;var c=ki.transition,h=ft;try{if(ki.transition=null,ft=1,i)return i()}finally{ft=h,ki.transition=c,Lt=r,(Lt&6)===0&&js()}}function rd(){hi=to.current,qt(to)}function fr(i,r){i.finishedWork=null,i.finishedLanes=0;var c=i.timeoutHandle;if(c!==-1&&(i.timeoutHandle=-1,u0(c)),fn!==null)for(c=fn.return;c!==null;){var h=c;switch(pu(h),h.tag){case 1:h=h.type.childContextTypes,h!=null&&tl();break;case 3:Jr(),qt(Jn),qt(zn),Nu();break;case 5:Cu(h);break;case 4:Jr();break;case 13:qt(Jt);break;case 19:qt(Jt);break;case 10:bu(h.type._context);break;case 22:case 23:rd()}c=c.return}if(Cn=i,fn=i=Is(i.current,null),Dn=hi=r,_n=0,Jo=null,Ju=kl=dr=0,ti=Zo=null,lr!==null){for(r=0;r<lr.length;r++)if(c=lr[r],h=c.interleaved,h!==null){c.interleaved=null;var g=h.next,_=c.pending;if(_!==null){var P=_.next;_.next=g,h.next=P}c.pending=h}lr=null}return i}function Lg(i,r){do{var c=fn;try{if(yu(),fl.current=vl,pl){for(var h=Zt.memoizedState;h!==null;){var g=h.queue;g!==null&&(g.pending=null),h=h.next}pl=!1}if(ur=0,kn=vn=Zt=null,qo=!1,Vo=0,Qu.current=null,c===null||c.return===null){_n=1,Jo=r,fn=null;break}e:{var _=i,P=c.return,q=c,Z=r;if(r=Dn,q.flags|=32768,Z!==null&&typeof Z=="object"&&typeof Z.then=="function"){var he=Z,xe=q,Ce=xe.tag;if((xe.mode&1)===0&&(Ce===0||Ce===11||Ce===15)){var we=xe.alternate;we?(xe.updateQueue=we.updateQueue,xe.memoizedState=we.memoizedState,xe.lanes=we.lanes):(xe.updateQueue=null,xe.memoizedState=null)}var He=ng(P);if(He!==null){He.flags&=-257,ig(He,P,q,_,r),He.mode&1&&tg(_,he,r),r=He,Z=he;var Ke=r.updateQueue;if(Ke===null){var qe=new Set;qe.add(Z),r.updateQueue=qe}else Ke.add(Z);break e}else{if((r&1)===0){tg(_,he,r),od();break e}Z=Error(n(426))}}else if(Xt&&q.mode&1){var ln=ng(P);if(ln!==null){(ln.flags&65536)===0&&(ln.flags|=256),ig(ln,P,q,_,r),vu(Zr(Z,q));break e}}_=Z=Zr(Z,q),_n!==4&&(_n=2),Zo===null?Zo=[_]:Zo.push(_),_=P;do{switch(_.tag){case 3:_.flags|=65536,r&=-r,_.lanes|=r;var ce=Zm(_,Z,r);Em(_,ce);break e;case 1:q=Z;var ne=_.type,ue=_.stateNode;if((_.flags&128)===0&&(typeof ne.getDerivedStateFromError=="function"||ue!==null&&typeof ue.componentDidCatch=="function"&&(As===null||!As.has(ue)))){_.flags|=65536,r&=-r,_.lanes|=r;var Re=eg(_,q,r);Em(_,Re);break e}}_=_.return}while(_!==null)}Tg(c)}catch(Ye){r=Ye,fn===c&&c!==null&&(fn=c=c.return);continue}break}while(!0)}function Ag(){var i=xl.current;return xl.current=vl,i===null?vl:i}function od(){(_n===0||_n===3||_n===2)&&(_n=4),Cn===null||(dr&268435455)===0&&(kl&268435455)===0||Ds(Cn,Dn)}function Pl(i,r){var c=Lt;Lt|=2;var h=Ag();(Cn!==i||Dn!==r)&&(us=null,fr(i,r));do try{D0();break}catch(g){Lg(i,g)}while(!0);if(yu(),Lt=c,xl.current=h,fn!==null)throw Error(n(261));return Cn=null,Dn=0,_n}function D0(){for(;fn!==null;)Mg(fn)}function I0(){for(;fn!==null&&!ri();)Mg(fn)}function Mg(i){var r=Og(i.alternate,i,hi);i.memoizedProps=i.pendingProps,r===null?Tg(i):fn=r,Qu.current=null}function Tg(i){var r=i;do{var c=r.alternate;if(i=r.return,(r.flags&32768)===0){if(c=j0(c,r,hi),c!==null){fn=c;return}}else{if(c=R0(c,r),c!==null){c.flags&=32767,fn=c;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{_n=6,fn=null;return}}if(r=r.sibling,r!==null){fn=r;return}fn=r=i}while(r!==null);_n===0&&(_n=5)}function pr(i,r,c){var h=ft,g=ki.transition;try{ki.transition=null,ft=1,O0(i,r,c,h)}finally{ki.transition=g,ft=h}return null}function O0(i,r,c,h){do io();while(Ms!==null);if((Lt&6)!==0)throw Error(n(327));c=i.finishedWork;var g=i.finishedLanes;if(c===null)return null;if(i.finishedWork=null,i.finishedLanes=0,c===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var _=c.lanes|c.childLanes;if(Fa(i,_),i===Cn&&(fn=Cn=null,Dn=0),(c.subtreeFlags&2064)===0&&(c.flags&2064)===0||El||(El=!0,Bg(Js,function(){return io(),null})),_=(c.flags&15990)!==0,(c.subtreeFlags&15990)!==0||_){_=ki.transition,ki.transition=null;var P=ft;ft=1;var q=Lt;Lt|=4,Qu.current=null,L0(i,c),kg(c,i),i0(ou),Ir=!!ru,ou=ru=null,i.current=c,A0(c),An(),Lt=q,ft=P,ki.transition=_}else i.current=c;if(El&&(El=!1,Ms=i,Nl=g),_=i.pendingLanes,_===0&&(As=null),Ba(c.stateNode),ni(i,Mt()),r!==null)for(h=i.onRecoverableError,c=0;c<r.length;c++)g=r[c],h(g.value,{componentStack:g.stack,digest:g.digest});if(Cl)throw Cl=!1,i=ed,ed=null,i;return(Nl&1)!==0&&i.tag!==0&&io(),_=i.pendingLanes,(_&1)!==0?i===td?ea++:(ea=0,td=i):ea=0,js(),null}function io(){if(Ms!==null){var i=Dr(Nl),r=ki.transition,c=ft;try{if(ki.transition=null,ft=16>i?16:i,Ms===null)var h=!1;else{if(i=Ms,Ms=null,Nl=0,(Lt&6)!==0)throw Error(n(331));var g=Lt;for(Lt|=4,We=i.current;We!==null;){var _=We,P=_.child;if((We.flags&16)!==0){var q=_.deletions;if(q!==null){for(var Z=0;Z<q.length;Z++){var he=q[Z];for(We=he;We!==null;){var xe=We;switch(xe.tag){case 0:case 11:case 15:Qo(8,xe,_)}var Ce=xe.child;if(Ce!==null)Ce.return=xe,We=Ce;else for(;We!==null;){xe=We;var we=xe.sibling,He=xe.return;if(yg(xe),xe===he){We=null;break}if(we!==null){we.return=He,We=we;break}We=He}}}var Ke=_.alternate;if(Ke!==null){var qe=Ke.child;if(qe!==null){Ke.child=null;do{var ln=qe.sibling;qe.sibling=null,qe=ln}while(qe!==null)}}We=_}}if((_.subtreeFlags&2064)!==0&&P!==null)P.return=_,We=P;else e:for(;We!==null;){if(_=We,(_.flags&2048)!==0)switch(_.tag){case 0:case 11:case 15:Qo(9,_,_.return)}var ce=_.sibling;if(ce!==null){ce.return=_.return,We=ce;break e}We=_.return}}var ne=i.current;for(We=ne;We!==null;){P=We;var ue=P.child;if((P.subtreeFlags&2064)!==0&&ue!==null)ue.return=P,We=ue;else e:for(P=ne;We!==null;){if(q=We,(q.flags&2048)!==0)try{switch(q.tag){case 0:case 11:case 15:Sl(9,q)}}catch(Ye){sn(q,q.return,Ye)}if(q===P){We=null;break e}var Re=q.sibling;if(Re!==null){Re.return=q.return,We=Re;break e}We=q.return}}if(Lt=g,js(),oi&&typeof oi.onPostCommitFiberRoot=="function")try{oi.onPostCommitFiberRoot(Zs,i)}catch{}h=!0}return h}finally{ft=c,ki.transition=r}}return!1}function Dg(i,r,c){r=Zr(c,r),r=Zm(i,r,1),i=Ps(i,r,1),r=qn(),i!==null&&(yi(i,1,r),ni(i,r))}function sn(i,r,c){if(i.tag===3)Dg(i,i,c);else for(;r!==null;){if(r.tag===3){Dg(r,i,c);break}else if(r.tag===1){var h=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof h.componentDidCatch=="function"&&(As===null||!As.has(h))){i=Zr(c,i),i=eg(r,i,1),r=Ps(r,i,1),i=qn(),r!==null&&(yi(r,1,i),ni(r,i));break}}r=r.return}}function B0(i,r,c){var h=i.pingCache;h!==null&&h.delete(r),r=qn(),i.pingedLanes|=i.suspendedLanes&c,Cn===i&&(Dn&c)===c&&(_n===4||_n===3&&(Dn&130023424)===Dn&&500>Mt()-Zu?fr(i,0):Ju|=c),ni(i,r)}function Ig(i,r){r===0&&((i.mode&1)===0?r=1:(r=tr,tr<<=1,(tr&130023424)===0&&(tr=4194304)));var c=qn();i=as(i,r),i!==null&&(yi(i,r,c),ni(i,c))}function z0(i){var r=i.memoizedState,c=0;r!==null&&(c=r.retryLane),Ig(i,c)}function $0(i,r){var c=0;switch(i.tag){case 13:var h=i.stateNode,g=i.memoizedState;g!==null&&(c=g.retryLane);break;case 19:h=i.stateNode;break;default:throw Error(n(314))}h!==null&&h.delete(r),Ig(i,c)}var Og;Og=function(i,r,c){if(i!==null)if(i.memoizedProps!==r.pendingProps||Jn.current)ei=!0;else{if((i.lanes&c)===0&&(r.flags&128)===0)return ei=!1,N0(i,r,c);ei=(i.flags&131072)!==0}else ei=!1,Xt&&(r.flags&1048576)!==0&&gm(r,rl,r.index);switch(r.lanes=0,r.tag){case 2:var h=r.type;bl(i,r),i=r.pendingProps;var g=Kr(r,zn.current);Qr(r,c),g=Pu(null,r,h,i,g,c);var _=Lu();return r.flags|=1,typeof g=="object"&&g!==null&&typeof g.render=="function"&&g.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,Zn(h)?(_=!0,nl(r)):_=!1,r.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,xu(r),g.updater=_l,r.stateNode=g,g._reactInternals=r,Ou(r,h,i,c),r=Fu(null,r,h,!0,_,c)):(r.tag=0,Xt&&_&&fu(r),Kn(null,r,g,c),r=r.child),r;case 16:h=r.elementType;e:{switch(bl(i,r),i=r.pendingProps,g=h._init,h=g(h._payload),r.type=h,g=r.tag=H0(h),i=Mi(h,i),g){case 0:r=$u(null,r,h,i,c);break e;case 1:r=cg(null,r,h,i,c);break e;case 11:r=sg(null,r,h,i,c);break e;case 14:r=rg(null,r,h,Mi(h.type,i),c);break e}throw Error(n(306,h,""))}return r;case 0:return h=r.type,g=r.pendingProps,g=r.elementType===h?g:Mi(h,g),$u(i,r,h,g,c);case 1:return h=r.type,g=r.pendingProps,g=r.elementType===h?g:Mi(h,g),cg(i,r,h,g,c);case 3:e:{if(ug(r),i===null)throw Error(n(387));h=r.pendingProps,_=r.memoizedState,g=_.element,Cm(i,r),dl(r,h,null,c);var P=r.memoizedState;if(h=P.element,_.isDehydrated)if(_={element:h,isDehydrated:!1,cache:P.cache,pendingSuspenseBoundaries:P.pendingSuspenseBoundaries,transitions:P.transitions},r.updateQueue.baseState=_,r.memoizedState=_,r.flags&256){g=Zr(Error(n(423)),r),r=dg(i,r,h,c,g);break e}else if(h!==g){g=Zr(Error(n(424)),r),r=dg(i,r,h,c,g);break e}else for(di=Cs(r.stateNode.containerInfo.firstChild),ui=r,Xt=!0,Ai=null,c=xm(r,null,h,c),r.child=c;c;)c.flags=c.flags&-3|4096,c=c.sibling;else{if(Yr(),h===g){r=cs(i,r,c);break e}Kn(i,r,h,c)}r=r.child}return r;case 5:return jm(r),i===null&&gu(r),h=r.type,g=r.pendingProps,_=i!==null?i.memoizedProps:null,P=g.children,au(h,g)?P=null:_!==null&&au(h,_)&&(r.flags|=32),lg(i,r),Kn(i,r,P,c),r.child;case 6:return i===null&&gu(r),null;case 13:return hg(i,r,c);case 4:return ku(r,r.stateNode.containerInfo),h=r.pendingProps,i===null?r.child=Gr(r,null,h,c):Kn(i,r,h,c),r.child;case 11:return h=r.type,g=r.pendingProps,g=r.elementType===h?g:Mi(h,g),sg(i,r,h,g,c);case 7:return Kn(i,r,r.pendingProps,c),r.child;case 8:return Kn(i,r,r.pendingProps.children,c),r.child;case 12:return Kn(i,r,r.pendingProps.children,c),r.child;case 10:e:{if(h=r.type._context,g=r.pendingProps,_=r.memoizedProps,P=g.value,Ft(ll,h._currentValue),h._currentValue=P,_!==null)if(Li(_.value,P)){if(_.children===g.children&&!Jn.current){r=cs(i,r,c);break e}}else for(_=r.child,_!==null&&(_.return=r);_!==null;){var q=_.dependencies;if(q!==null){P=_.child;for(var Z=q.firstContext;Z!==null;){if(Z.context===h){if(_.tag===1){Z=ls(-1,c&-c),Z.tag=2;var he=_.updateQueue;if(he!==null){he=he.shared;var xe=he.pending;xe===null?Z.next=Z:(Z.next=xe.next,xe.next=Z),he.pending=Z}}_.lanes|=c,Z=_.alternate,Z!==null&&(Z.lanes|=c),wu(_.return,c,r),q.lanes|=c;break}Z=Z.next}}else if(_.tag===10)P=_.type===r.type?null:_.child;else if(_.tag===18){if(P=_.return,P===null)throw Error(n(341));P.lanes|=c,q=P.alternate,q!==null&&(q.lanes|=c),wu(P,c,r),P=_.sibling}else P=_.child;if(P!==null)P.return=_;else for(P=_;P!==null;){if(P===r){P=null;break}if(_=P.sibling,_!==null){_.return=P.return,P=_;break}P=P.return}_=P}Kn(i,r,g.children,c),r=r.child}return r;case 9:return g=r.type,h=r.pendingProps.children,Qr(r,c),g=Si(g),h=h(g),r.flags|=1,Kn(i,r,h,c),r.child;case 14:return h=r.type,g=Mi(h,r.pendingProps),g=Mi(h.type,g),rg(i,r,h,g,c);case 15:return og(i,r,r.type,r.pendingProps,c);case 17:return h=r.type,g=r.pendingProps,g=r.elementType===h?g:Mi(h,g),bl(i,r),r.tag=1,Zn(h)?(i=!0,nl(r)):i=!1,Qr(r,c),Qm(r,h,g),Ou(r,h,g,c),Fu(null,r,h,!0,i,c);case 19:return pg(i,r,c);case 22:return ag(i,r,c)}throw Error(n(156,r.tag))};function Bg(i,r){return It(i,r)}function F0(i,r,c,h){this.tag=i,this.key=c,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=h,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ci(i,r,c,h){return new F0(i,r,c,h)}function ad(i){return i=i.prototype,!(!i||!i.isReactComponent)}function H0(i){if(typeof i=="function")return ad(i)?1:0;if(i!=null){if(i=i.$$typeof,i===$)return 11;if(i===F)return 14}return 2}function Is(i,r){var c=i.alternate;return c===null?(c=Ci(i.tag,r,i.key,i.mode),c.elementType=i.elementType,c.type=i.type,c.stateNode=i.stateNode,c.alternate=i,i.alternate=c):(c.pendingProps=r,c.type=i.type,c.flags=0,c.subtreeFlags=0,c.deletions=null),c.flags=i.flags&14680064,c.childLanes=i.childLanes,c.lanes=i.lanes,c.child=i.child,c.memoizedProps=i.memoizedProps,c.memoizedState=i.memoizedState,c.updateQueue=i.updateQueue,r=i.dependencies,c.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},c.sibling=i.sibling,c.index=i.index,c.ref=i.ref,c}function Ll(i,r,c,h,g,_){var P=2;if(h=i,typeof i=="function")ad(i)&&(P=1);else if(typeof i=="string")P=5;else e:switch(i){case Y:return mr(c.children,g,_,r);case Q:P=8,g|=8;break;case W:return i=Ci(12,c,r,g|2),i.elementType=W,i.lanes=_,i;case R:return i=Ci(13,c,r,g),i.elementType=R,i.lanes=_,i;case O:return i=Ci(19,c,r,g),i.elementType=O,i.lanes=_,i;case T:return Al(c,g,_,r);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case X:P=10;break e;case H:P=9;break e;case $:P=11;break e;case F:P=14;break e;case A:P=16,h=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return r=Ci(P,c,r,g),r.elementType=i,r.type=h,r.lanes=_,r}function mr(i,r,c,h){return i=Ci(7,i,h,r),i.lanes=c,i}function Al(i,r,c,h){return i=Ci(22,i,h,r),i.elementType=T,i.lanes=c,i.stateNode={isHidden:!1},i}function ld(i,r,c){return i=Ci(6,i,null,r),i.lanes=c,i}function cd(i,r,c){return r=Ci(4,i.children!==null?i.children:[],i.key,r),r.lanes=c,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}function U0(i,r,c,h,g){this.tag=r,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Tr(0),this.expirationTimes=Tr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Tr(0),this.identifierPrefix=h,this.onRecoverableError=g,this.mutableSourceEagerHydrationData=null}function ud(i,r,c,h,g,_,P,q,Z){return i=new U0(i,r,c,q,Z),r===1?(r=1,_===!0&&(r|=8)):r=0,_=Ci(3,null,null,r),i.current=_,_.stateNode=i,_.memoizedState={element:h,isDehydrated:c,cache:null,transitions:null,pendingSuspenseBoundaries:null},xu(_),i}function W0(i,r,c){var h=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:K,key:h==null?null:""+h,children:i,containerInfo:r,implementation:c}}function zg(i){if(!i)return Ns;i=i._reactInternals;e:{if(te(i)!==i||i.tag!==1)throw Error(n(170));var r=i;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(Zn(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(n(171))}if(i.tag===1){var c=i.type;if(Zn(c))return fm(i,c,r)}return r}function $g(i,r,c,h,g,_,P,q,Z){return i=ud(c,h,!0,i,g,_,P,q,Z),i.context=zg(null),c=i.current,h=qn(),g=Ts(c),_=ls(h,g),_.callback=r??null,Ps(c,_,g),i.current.lanes=g,yi(i,g,h),ni(i,h),i}function Ml(i,r,c,h){var g=r.current,_=qn(),P=Ts(g);return c=zg(c),r.context===null?r.context=c:r.pendingContext=c,r=ls(_,P),r.payload={element:i},h=h===void 0?null:h,h!==null&&(r.callback=h),i=Ps(g,r,P),i!==null&&(Ii(i,g,P,_),ul(i,g,P)),P}function Tl(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function Fg(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var c=i.retryLane;i.retryLane=c!==0&&c<r?c:r}}function dd(i,r){Fg(i,r),(i=i.alternate)&&Fg(i,r)}function K0(){return null}var Hg=typeof reportError=="function"?reportError:function(i){console.error(i)};function hd(i){this._internalRoot=i}Dl.prototype.render=hd.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(n(409));Ml(i,r,null,null)},Dl.prototype.unmount=hd.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;hr(function(){Ml(null,i,null,null)}),r[is]=null}};function Dl(i){this._internalRoot=i}Dl.prototype.unstable_scheduleHydration=function(i){if(i){var r=nr();i={blockedOn:null,target:i,priority:r};for(var c=0;c<le.length&&r!==0&&r<le[c].priority;c++);le.splice(c,0,i),c===0&&rt(i)}};function fd(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function Il(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function Ug(){}function q0(i,r,c,h,g){if(g){if(typeof h=="function"){var _=h;h=function(){var he=Tl(P);_.call(he)}}var P=$g(r,h,i,0,null,!1,!1,"",Ug);return i._reactRootContainer=P,i[is]=P.current,Bo(i.nodeType===8?i.parentNode:i),hr(),P}for(;g=i.lastChild;)i.removeChild(g);if(typeof h=="function"){var q=h;h=function(){var he=Tl(Z);q.call(he)}}var Z=ud(i,0,!1,null,null,!1,!1,"",Ug);return i._reactRootContainer=Z,i[is]=Z.current,Bo(i.nodeType===8?i.parentNode:i),hr(function(){Ml(r,Z,c,h)}),Z}function Ol(i,r,c,h,g){var _=c._reactRootContainer;if(_){var P=_;if(typeof g=="function"){var q=g;g=function(){var Z=Tl(P);q.call(Z)}}Ml(r,P,i,g)}else P=q0(c,r,i,g,h);return Tl(P)}jo=function(i){switch(i.tag){case 3:var r=i.stateNode;if(r.current.memoizedState.isDehydrated){var c=_s(r.pendingLanes);c!==0&&(Bi(r,c|1),ni(r,Mt()),(Lt&6)===0&&(no=Mt()+500,js()))}break;case 13:hr(function(){var h=as(i,1);if(h!==null){var g=qn();Ii(h,i,1,g)}}),dd(i,1)}},Mn=function(i){if(i.tag===13){var r=as(i,134217728);if(r!==null){var c=qn();Ii(r,i,134217728,c)}dd(i,134217728)}},Ro=function(i){if(i.tag===13){var r=Ts(i),c=as(i,r);if(c!==null){var h=qn();Ii(c,i,r,h)}dd(i,r)}},nr=function(){return ft},ys=function(i,r){var c=ft;try{return ft=i,r()}finally{ft=c}},wt=function(i,r,c){switch(r){case"input":if(Yt(i,c),r=c.name,c.type==="radio"&&r!=null){for(c=i;c.parentNode;)c=c.parentNode;for(c=c.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<c.length;r++){var h=c[r];if(h!==i&&h.form===i.form){var g=el(h);if(!g)throw Error(n(90));vt(h),Yt(h,g)}}}break;case"textarea":jt(i,c);break;case"select":r=c.value,r!=null&&Nt(i,!!c.multiple,r,!1)}},Ue=sd,Oe=hr;var V0={usingClientEntryPoint:!1,Events:[Fo,Ur,el,J,Ne,sd]},ta={findFiberByHostInstance:sr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Y0={bundleType:ta.bundleType,version:ta.version,rendererPackageName:ta.rendererPackageName,rendererConfig:ta.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:I.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=nt(i),i===null?null:i.stateNode},findFiberByHostInstance:ta.findFiberByHostInstance||K0,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 Bl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Bl.isDisabled&&Bl.supportsFiber)try{Zs=Bl.inject(Y0),oi=Bl}catch{}}return ii.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V0,ii.createPortal=function(i,r){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!fd(r))throw Error(n(200));return W0(i,r,null,c)},ii.createRoot=function(i,r){if(!fd(i))throw Error(n(299));var c=!1,h="",g=Hg;return r!=null&&(r.unstable_strictMode===!0&&(c=!0),r.identifierPrefix!==void 0&&(h=r.identifierPrefix),r.onRecoverableError!==void 0&&(g=r.onRecoverableError)),r=ud(i,1,!1,null,null,c,!1,h,g),i[is]=r.current,Bo(i.nodeType===8?i.parentNode:i),new hd(r)},ii.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var r=i._reactInternals;if(r===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=nt(r),i=i===null?null:i.stateNode,i},ii.flushSync=function(i){return hr(i)},ii.hydrate=function(i,r,c){if(!Il(r))throw Error(n(200));return Ol(null,i,r,!0,c)},ii.hydrateRoot=function(i,r,c){if(!fd(i))throw Error(n(405));var h=c!=null&&c.hydratedSources||null,g=!1,_="",P=Hg;if(c!=null&&(c.unstable_strictMode===!0&&(g=!0),c.identifierPrefix!==void 0&&(_=c.identifierPrefix),c.onRecoverableError!==void 0&&(P=c.onRecoverableError)),r=$g(r,null,i,1,c??null,g,!1,_,P),i[is]=r.current,Bo(i),h)for(i=0;i<h.length;i++)c=h[i],g=c._getVersion,g=g(c._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[c,g]:r.mutableSourceEagerHydrationData.push(c,g);return new Dl(r)},ii.render=function(i,r,c){if(!Il(r))throw Error(n(200));return Ol(null,i,r,!1,c)},ii.unmountComponentAtNode=function(i){if(!Il(i))throw Error(n(40));return i._reactRootContainer?(hr(function(){Ol(null,null,i,!1,function(){i._reactRootContainer=null,i[is]=null})}),!0):!1},ii.unstable_batchedUpdates=sd,ii.unstable_renderSubtreeIntoContainer=function(i,r,c,h){if(!Il(c))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return Ol(i,r,c,!1,h)},ii.version="18.3.1-next-f1338f8080-20240426",ii}var Qg;function ix(){if(Qg)return gd.exports;Qg=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),gd.exports=nx(),gd.exports}var Jg;function sx(){if(Jg)return zl;Jg=1;var e=ix();return zl.createRoot=e.createRoot,zl.hydrateRoot=e.hydrateRoot,zl}var rx=sx();const ox=Rf(rx);function on(e,t,n={}){return fetch(e,{...n,headers:{...n.headers||{},Authorization:`Bearer ${t}`}})}const $y=e=>`nc_seen_${e}`;async function ze(e,t,n={}){const s=await on(e,t,{method:n.method||"GET",headers:{"content-type":"application/json"},body:n.body?JSON.stringify(n.body):void 0}),o=await s.json().catch(()=>({}));if(!s.ok){const a=new Error(o.error||`HTTP ${s.status}`);throw a.status=s.status,a.data=o,a}return o}const nn=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",un=(e,t)=>`${nn(e)}/fleet/${t}`;async function ax(e,t,n,{signal:s}={}){const o=await on(`${nn(t)}/panel/${encodeURIComponent(n)}/ticket`,e,{method:"POST",signal:s}),a=await o.json().catch(()=>({}));return o.status===200&&a&&typeof a.ticket=="string"?{ok:!0,ticket:a.ticket}:o.status===403&&a&&a.reason==="panel-not-granted"?{ok:!1,cause:"not-granted"}:o.status===403?{ok:!1,cause:"node-refused"}:o.status===404?{ok:!1,cause:"no-panel"}:o.status===401?{ok:!1,cause:"unauthorized"}:{ok:!1,cause:"denied"}}const Xs=(e,t)=>ze(un(t,"status"),e),Lf=(e,t,n)=>ze(un(n,"up"),e,{method:"POST",body:t}),lc=(e,t,n)=>ze(un(n,"down"),e,{method:"POST",body:t}),Fy=(e,t,n)=>ze(un(n,"boot"),e,{method:"POST",body:t}),fa=(e,t,n)=>ze(un(n,"restart"),e,{method:"POST",body:{cell:t}}),Ec=(e,t)=>ze(un(t,"definitions"),e),lx=(e,t)=>ze(un(t,"credentials/status"),e),Zg=(e,t,n,s)=>ze(un(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:n}}),cx=(e,t,n)=>ze(un(n,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),ux=(e,t,n)=>ze(un(n,"define-engine"),e,{method:"POST",body:{def:t}}),dx=(e,t,n,s,o)=>ze(un(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:n,envChanges:s}}),hx=(e,t,n)=>ze(un(n,"remove-engine"),e,{method:"POST",body:{id:t}}),fx=(e,t,n)=>ze(un(n,"define-model"),e,{method:"POST",body:{def:t}}),px=(e,t,n,s)=>ze(un(s,"remove-model"),e,{method:"POST",body:{id:t,engine:n}}),mx=(e,t,n,s)=>ze(un(s,"model-test"),e,{method:"POST",body:{engine:t,model:n}}),gx=(e,t,n)=>ze(un(n,"define-cell"),e,{method:"POST",body:{def:t}}),Hy=(e,t,n,s)=>ze(un(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:n}}),Uy=(e,t,n=!1,s)=>ze(un(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:n}}),vx=(e,t,n)=>ze(un(n,"import-cell"),e,{method:"POST",body:t}),_x=(e,t,n)=>ze(un(n,"restore-cells"),e,{method:"POST",body:{cells:t}}),yx=(e,t,n,s,o)=>ze(un(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!n,...Array.isArray(o)&&o.length?{models:o}:{}}}),Af=(e,t,n)=>ze(`${nn(n)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Wy=(e,t,n,s)=>ze(`${nn(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!n}}),Mf=(e,t,n)=>ze(`${nn(n)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),Ky=e=>ze("/api/settings",e),bx=e=>ze("/api/nodes",e),wx=e=>ze("/api/peers",e),qy=(e,t=[])=>ze(`${nn(t)}/vl-nodes`,e),ev=(e,t,n,s={},o=[])=>ze(`${nn(o)}/vl-nodes/${encodeURIComponent(t)}/commands`,e,{method:"POST",body:{kind:n,args:s}}),Sx=(e,t,n=0,s=[])=>ze(`${nn(s)}/vl-nodes/${encodeURIComponent(t)}/events${n?`?after=${encodeURIComponent(n)}`:""}`,e),Vy=e=>ze("/api/topology",e),Tf=(e,t)=>ze(`${nn(t)}/sessions`,e),Df=(e,t)=>ze(`${nn(t)}/config`,e),tv=(e,t)=>ze(`${nn(t)}/topology`,e),gh=(e,t)=>ze("/api/settings/config",e,{method:"POST",body:t}),xx=e=>ze("/api/settings/token/rotate",e,{method:"POST"}),kx=(e,t)=>ze("/api/settings/nodes/pair",e,{method:"POST",body:t}),Cx=(e,t,n=[])=>ze(`${nn(n)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),Yy=(e,t,n)=>ze(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:n}}),Ex=e=>ze("/api/settings/node-aliases",e),Nx=(e,t,n)=>ze(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{alias:n}}),nv=(e,t)=>ze(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"DELETE"}),iv=(e,t,n)=>ze(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"PATCH",body:n}),jx=(e,t)=>ze(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),If=(e,t,n)=>ze(`/api/settings/nodes/${encodeURIComponent(t)}/${n}`,e,{method:"POST"}),Rx=(e,t,n)=>ze(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:n}}),Px=(e,t,n,s=[])=>ze(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:n,selected:s}}),Lx=e=>ze("/api/settings/audio",e),Ax=(e,t)=>ze("/api/settings/audio/consent",e,{method:"PATCH",body:{consent:t}}),Mx=e=>ze("/api/settings/audio/test",e,{method:"POST",body:{}}),Tx=e=>ze("/api/settings/audio/stop",e,{method:"POST",body:{}}),Dx=e=>ze("/api/settings/audio/groups",e),Ix=(e,t,n)=>ze(`/api/settings/audio/groups/${encodeURIComponent(t)}`,e,{method:"PUT",body:n}),Ox=(e,t)=>ze(`/api/settings/audio/groups/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Bx=e=>ze("/api/settings/service/regenerate",e,{method:"POST"}),zx=e=>ze("/api/settings/update/check",e,{method:"POST"}),$x=e=>ze("/api/settings/update/apply",e,{method:"POST"}),Nc=(e,t)=>`${nn(e)}/diagnostics/${t}`,Fx=(e,t=[])=>ze(Nc(t,"status"),e),Hx=(e,{after:t=0,limit:n=200}={},s=[])=>ze(`${Nc(s,"logs")}?after=${encodeURIComponent(t)}&limit=${encodeURIComponent(n)}`,e),sv=(e,t,n,s=[])=>ze(Nc(s,"verbose"),e,{method:"PATCH",body:{enabled:t,durationSeconds:n}}),Ux=(e,t=[])=>ze(Nc(t,"logs"),e,{method:"DELETE"}),Wx=(e,t=!0)=>ze(`/api/asks${t?"?open=1":""}`,e),Kx=(e,t,n)=>ze(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:n}}),qx=(e,t)=>ze(`/api/asks/${encodeURIComponent(t)}`,e,{method:"DELETE"}),$l=(e,t=[])=>ze(`${nn(t)}/decks`,e),rv=(e,t,n=[])=>ze(`${nn(n)}/decks`,e,{method:"POST",body:{name:t}}),Fl=(e,t,n,s,o=[])=>ze(`${nn(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:n,expectedRevision:s}}),Vx=(e,t,n,s,o=[])=>ze(`${nn(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:n,expectedRevision:s}}),Yx=(e,t,n,s=[])=>ze(`${nn(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:n}}),Gx=(e,t=[])=>ze(`${nn(t)}/live-host`,e),Xx=(e,t,n,s=[])=>ze(`${nn(s)}/live-host/designate`,e,{method:"POST",body:{cellId:t,expectedRevision:n}}),Qx=(e,t,n=[])=>ze(`${nn(n)}/live-host/clear`,e,{method:"POST",body:{expectedRevision:t}}),Jx={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"}),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"})]}),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 lt({name:e,size:t=20}){return l.jsx("svg",{className:"nc-icon",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Jx[e]||null})}const Zx=["all","pinned","active","off","technical"],Gy="nc_sidebar_views_v1",Xy="nc_sidebar_order_v1";function Qy(e){return Zx.includes(e)?e:"all"}function ek(e,t=[],n="all"){const s=Qy(n);return s==="technical"?e.technical===!0:e.technical===!0?!1:s==="pinned"?t.includes(e.key):s==="active"?!!e.live:s==="off"?!e.live:!0}function tk(e,t,n=[],s=[]){const o=n.indexOf(e.key),a=n.indexOf(t.key),u=o===-1?Number.MAX_SAFE_INTEGER:o,d=a===-1?Number.MAX_SAFE_INTEGER:a,p=s.indexOf(e.key),m=s.indexOf(t.key),v=p===-1?Number.MAX_SAFE_INTEGER:p,y=m===-1?Number.MAX_SAFE_INTEGER:m;return u-d||v-y||+!!t.live-+!!e.live||+!!t.fresh-+!!e.fresh||Number(t.activity||0)-Number(e.activity||0)||String(e.label||"").localeCompare(String(t.label||""))||String(e.key||"").localeCompare(String(t.key||""))}function nk(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Xy));if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[s,o]of Object.entries(t).slice(0,64)){if(typeof s!="string"||!s||s.length>160||!Array.isArray(o))continue;const a=[...new Set(o.filter(u=>typeof u=="string"&&u&&u.length<=256))].slice(0,128);a.length&&(n[s]=a)}return n}catch{return{}}}function ms(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function ik(e,t=globalThis.localStorage){try{t.setItem(Xy,JSON.stringify(e))}catch{}return e}function sk(e,t,n,s,o=[]){if(typeof t!="string"||!t||n===s)return e;const a=[...new Set(o.filter(b=>typeof b=="string"&&b))];if(!a.includes(n)||!a.includes(s))return e;const u=ms(e,t).filter(b=>a.includes(b)),d=[...u,...a.filter(b=>!u.includes(b))],p=d.indexOf(n),m=d.indexOf(s);d.splice(p,1);const v=d.indexOf(s),y=p<m?v+1:v;return d.splice(y,0,n),{...e,[t]:d}}function rk(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Gy));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function ov(e,t){var n,s;return{open:((n=e==null?void 0:e[t])==null?void 0:n.open)!==!1,filter:Qy((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function ok(e,t=globalThis.localStorage){try{t.setItem(Gy,JSON.stringify(e))}catch{}return e}function av(e,t=""){const n=String(t||"").trim().toLocaleLowerCase();return n?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(n):!0}function qs(e=[],t=[],n="all",s=[]){return[...e].filter(o=>ek(o,t,n)).sort((o,a)=>tk(o,a,t,s))}const Of=["it","en","es"];function ak(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return Of.includes(t)?t:"en"}catch{return"en"}}const ec=ak(),Jy="nc_lang",vh="nc-lang";function Zy(){return typeof localStorage<"u"?localStorage:null}const Hl={it:{"update-available":"nuova versione {v} disponibile","install-version-mismatch":"installazione incompleta: frontend e server non coincidono (v{v})",reload:"ricarica","grid-empty":"trascina qui una sessione dalla sidebar, o doppio-clic per la vista singola","grid-full":"il deck può mostrare al massimo 9 sessioni",pin:"fissa in cima",reorder:"riordina","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","cell-working":"al lavoro","cell-idle":"in attesa","cell-degraded":"degradata: unit attiva, tmux morto","power-on":"accendi","power-off":"spegni","boot-enable":"attiva al boot","boot-disable":"disattiva al boot","state-on":"accesa","state-off":"spenta",engine:"Engine",model:"Modello","model-default":"Modello predefinito del provider","model-remembered":"Ultimo modello usato con questo engine","boot-persist":"avvia al boot","remove-boot":"togli anche dal boot","power-config-in-settings":"Engine, provider, profilo, modello e permessi si modificano in Impostazioni → Flotta.","no-remote-control":"⚠ engine non-native: niente RC da app claude.ai (da qui la piloti comunque)",cancel:"annulla",name:"nome","name-invalid":"nome non valido: a-zA-Z0-9._- max 64, senza '-' iniziale",cwd:"cartella",browse:"sfoglia","fs-home":"home","fs-parent":".. su",preset:"preset","preset-2x2":"griglia 2×2","preset-columns":"colonne","preset-equalize":"equalizza",collapse:"comprimi",expand:"espandi",create:"crea","auth-prompt":"Incolla il token (stampato dal server):","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande",composer:"composer",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-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.",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","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-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. Dev","fleet-cwd-repair-preview":"Nuova cartella: {path}","fleet-cwd-repair-browse":"sfoglia sotto ~","fleet-cwd-repair-fs-empty":"nessuna sottocartella","fleet-cwd-repair-use-current":"usa questa cartella","fleet-cwd-repair-invalid":'percorso non valido: niente assoluto, "..", barra rovesciata o lettera disco',"fleet-cwd-repair-confirm":"Impostare la cartella della cella {id} su {path}? Verrà ricalcolata sul dispositivo target.","fleet-cwd-repair-unportable":"Il percorso scelto non è portabile su questo dispositivo: deve esistere sotto la home.","fleet-cwd-repair-suggestion":"Suggerimento dal dispositivo:","fleet-cwd-repair-use-suggestion":"usa {path}","fleet-cwd-repaired":"Cartella della cella riparata.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: conferma la custom API key (Yes) nel terminale della cella, poi riavvia la cella.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: nel terminale della cella apri /config e abilita "Use custom API key", poi riavvia la cella. Se la chiave è cambiata, aggiorna la credenziale e riprova.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: nel terminale della cella esegui /login (device-code Kimi) oppure /provider, poi riavvia la cella.","fleet-readiness-degraded":"Avviata senza conferma di prontezza: potrebbe non elaborare subito. Verifica nel terminale prima di affidarle un incarico.","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","ask-dismiss":"Scarta la domanda","ask-reply-ph":"scrivi la risposta…","push-enable":"attiva notifiche push","push-disable":"disattiva notifiche push","push-on":"push attive su questo device","push-off":"push non attive","push-denied":"permesso notifiche negato dal browser","push-unsupported":"push non supportate in questo browser","notification-speech-enable":"leggi le notifiche ad alta voce","notification-speech-help":"Usa la voce del browser solo per nuove notifiche mentre questa PWA è visibile e in primo piano. Con l’app chiusa resta la notifica di sistema.","notification-speech-test":"prova voce","notification-speech-testing":"prova in corso…","notification-speech-preview":"NexusCrew. Notifiche vocali attive.","notification-speech-preview-ok":"Prova vocale completata.","notification-speech-preview-failed":"Il browser non ha avviato la prova vocale. Interagisci con la pagina e riprova.","notification-speech-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-show-active":"attive","cell-switcher-close":"chiudi selettore celle","fleet-not-available":"fleet non disponibile su questa posizione",start:"avvia",stop:"ferma",restart:"riavvia",delete:"elimina","copy-manual":"copia non riuscita — seleziona e Cmd+C, o copia a mano","copy-empty":"niente selezione: trascina con Shift per selezionare","selection-held":"evidenziazione persa, testo ancora in mano","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.","single-view":"vista singola",retract:"riduci","keybar-expand":"espandi la barra tasti","keybar-retract":"riduci la barra tasti","save-and-start":"salva e avvia",permissions:"Permessi","power-on-hint":"Spegni la cella; puoi anche toglierla dal boot.","launch-engine-help":"Provider, credenziali e nuovi engine si creano in Impostazioni → Flotta. Modello e permessi sono per questa cella.","launch-unavailable-hint":"Configurazione engine non disponibile su questo nodo.","import-as-cell":"Importa come cella","import-help":"Riconcilia una sessione tmux esistente in una cella gestita. Scegli un engine già dichiarato: nessun engine viene inventato.","import-engine-required":"scegli un engine (obbligatorio)","test-and-connect":"testa e collega","pairing-v2-hint":"Incolla o scansiona UN solo link: precompila nome, Host SSH ed etichetta quando il link li include (v2).","invite-v2-hint":"Crea un invito monouso. Serve l’indirizzo SSH di questo dispositivo, raggiungibile da chi lo userà.","invite-target-local":"Il nuovo dispositivo entrerà in","invite-target-this":"questo dispositivo","invite-endpoint-label":"Indirizzo SSH di questo hub visto dagli altri dispositivi","invite-endpoint-auto":"Endpoint già configurato","invite-endpoint-needed":"Inserisci user@host o un alias SSH condiviso. Non è 127.0.0.1 e non è l’URL HTTP NexusCrew.","invite-ssh-hint":"Il target SSH con cui L’ALTRO dispositivo raggiunge QUESTA installazione (user@host o alias). Obbligatorio: viene incluso nel link.","invite-next-steps":"copia questo link, apri NexusCrew sull’altro dispositivo e incollalo in Impostazioni → Nodi (o scansiona il QR): al resto pensa NexusCrew","pair-card-title":"collega con un solo link","pair-card-help":"Incolla il link di pairing generato sull’altro dispositivo (o scansiona il suo QR): NexusCrew decodifica, prova la connessione SSH e collega da solo.","pair-paste-ph":"incolla qui il link di pairing","pair-paste-btn":"incolla","pair-advanced":"avanzate / modifica","pair-progress":"collegamento in corso: SSH → invito → conferma → verifica…","pair-retry":"riprova","pair-invalid-link":"questo non è un link di pairing valido","pair-invalid-hint":"serve il link completo (http://…#pair=…) generato dall’altro NexusCrew: non aprirlo, incollalo qui","pair-missing-ssh":"il link non include il target SSH (formato v1): indica in “avanzate” come questo dispositivo raggiunge l’altro via SSH — non viene mai inventato","pair-missing-name":"manca il nome del nodo: completalo in “avanzate”","pair-clipboard-denied":"lettura degli appunti non consentita: incolla manualmente nel campo","pair-clipboard-empty":"appunti vuoti: copia prima il link di pairing","pair-stage-validation":"dati non validi","pair-stage-conflict":"nome già in uso","pair-stage-ssh-start":"avvio del tunnel SSH fallito","pair-stage-ssh-ready":"peer non raggiungibile via SSH","pair-stage-join":"scambio dell’invito fallito","pair-stage-tunnel-final":"tunnel negoziato fallito","pair-stage-confirm":"conferma del pairing fallita","pair-stage-health":"verifica finale della federazione fallita","pair-stage-internal":"errore interno","pair-stage-generic":"connessione fallita","qr-no-camera":"nessuna camera disponibile su questo dispositivo: usa una foto del QR","qr-permission":"permesso camera negato: consentilo nel browser o usa una foto del QR","qr-unsupported":"scanner live non supportato qui: carica una foto del QR","qr-upload":"usa una foto"},en:{"update-available":"new version {v} available","install-version-mismatch":"incomplete installation: frontend and server do not match (v{v})",reload:"reload","grid-empty":"drag a session here from the sidebar, or double-click for single view","grid-full":"a deck can show at most 9 sessions",pin:"pin to top",reorder:"reorder","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","cell-working":"working","cell-idle":"idle","cell-degraded":"degraded: unit active, tmux dead","power-on":"power on","power-off":"power off","boot-enable":"enable at boot","boot-disable":"disable at boot","state-on":"running","state-off":"stopped",engine:"Engine",model:"Model","model-default":"Provider default model","model-remembered":"Last model used with this engine","boot-persist":"start at boot","remove-boot":"also remove from boot","power-config-in-settings":"Edit engine, provider, profile, model and permissions in Settings → Fleet.","no-remote-control":"⚠ non-native engine: no claude.ai app RC (you can still drive it from here)",cancel:"cancel",name:"name","name-invalid":"invalid name: a-zA-Z0-9._- max 64, no leading '-'",cwd:"folder",browse:"browse","fs-home":"home","fs-parent":".. up",preset:"preset","preset-2x2":"2×2 grid","preset-columns":"columns","preset-equalize":"equalize",collapse:"collapse",expand:"expand",create:"create","auth-prompt":"Paste the token (printed by the server):","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text",composer:"composer",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-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.",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","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-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. Dev","fleet-cwd-repair-preview":"New folder: {path}","fleet-cwd-repair-browse":"browse under ~","fleet-cwd-repair-fs-empty":"no subfolders","fleet-cwd-repair-use-current":"use this folder","fleet-cwd-repair-invalid":'invalid path: no absolute path, "..", backslash or drive letter',"fleet-cwd-repair-confirm":"Set the folder of cell {id} to {path}? It will be recomputed on the target device.","fleet-cwd-repair-unportable":"The chosen path is not portable on this device: it must exist under the home directory.","fleet-cwd-repair-suggestion":"Suggestion from device:","fleet-cwd-repair-use-suggestion":"use {path}","fleet-cwd-repaired":"Cell folder repaired.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: confirm the custom API key (Yes) in the cell terminal, then restart the cell.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: in the cell terminal open /config and enable "Use custom API key", then restart the cell. If the key changed, update the credential and retry.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: in the cell terminal run /login (Kimi device code) or /provider, then restart the cell.","fleet-readiness-degraded":"Started without readiness confirmation: it may not process right away. Check its terminal before assigning work.","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","ask-dismiss":"Dismiss question","ask-reply-ph":"type your answer…","push-enable":"enable push notifications","push-disable":"disable push notifications","push-on":"push active on this device","push-off":"push not active","push-denied":"notification permission denied by the browser","push-unsupported":"push not supported in this browser","notification-speech-enable":"read notifications aloud","notification-speech-help":"Uses the browser voice only for new notifications while this PWA is visible and in the foreground. When the app is closed, the system notification remains available.","notification-speech-test":"test voice","notification-speech-testing":"testing voice…","notification-speech-preview":"NexusCrew. Spoken notifications are active.","notification-speech-preview-ok":"Voice test completed.","notification-speech-preview-failed":"The browser did not start the voice test. Interact with the page and try again.","notification-speech-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-show-active":"active","cell-switcher-close":"close cell switcher","fleet-not-available":"fleet not available on this position",start:"start",stop:"stop",restart:"restart",delete:"delete","copy-manual":"copy failed — select and press Cmd+C, or copy manually","copy-empty":"nothing selected: drag with Shift to select","selection-held":"highlight gone, text still held","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.","single-view":"single view",retract:"retract","keybar-expand":"expand the key bar","keybar-retract":"retract the key bar","save-and-start":"save and start",permissions:"Permissions","power-on-hint":"Stop the cell; you can also remove it from boot.","launch-engine-help":"Providers, credentials and new engines are created in Settings → Fleet. Model and permissions are per cell.","launch-unavailable-hint":"Engine configuration is unavailable on this node.","import-as-cell":"Import as cell","import-help":"Reconcile an existing tmux session into a managed cell. Pick an already-declared engine: no engine is invented.","import-engine-required":"pick an engine (required)","test-and-connect":"test and connect","pairing-v2-hint":"Paste or scan ONE link: it prefills name, SSH host and label when the link carries them (v2).","invite-v2-hint":"Create one one-time invitation. It needs this device’s SSH address, reachable by whoever will use it.","invite-target-local":"The new device will join","invite-target-this":"this device","invite-endpoint-label":"This hub’s SSH address as seen by other devices","invite-endpoint-auto":"Configured endpoint","invite-endpoint-needed":"Enter user@host or a shared SSH alias. This is not 127.0.0.1 and not the NexusCrew HTTP URL.","invite-ssh-hint":"The SSH target the OTHER device uses to reach THIS installation (user@host or alias). Required: it is included in the link.","invite-next-steps":"copy this link, open NexusCrew on the other device and paste it in Settings → Nodes (or scan the QR): NexusCrew does the rest","pair-card-title":"connect with one link","pair-card-help":"Paste the pairing link generated on the other device (or scan its QR): NexusCrew decodes it, tests the SSH connection and connects on its own.","pair-paste-ph":"paste the pairing link here","pair-paste-btn":"paste","pair-advanced":"advanced / edit","pair-progress":"connecting: SSH → invite → confirm → verify…","pair-retry":"retry","pair-invalid-link":"this is not a valid pairing link","pair-invalid-hint":"you need the full link (http://…#pair=…) generated by the other NexusCrew: don’t open it, paste it here","pair-missing-ssh":"the link carries no SSH target (v1 format): set in “advanced” how this device reaches the other one over SSH — it is never invented","pair-missing-name":"the node name is missing: fill it in “advanced”","pair-clipboard-denied":"clipboard read not allowed: paste manually into the field","pair-clipboard-empty":"clipboard is empty: copy the pairing link first","pair-stage-validation":"invalid data","pair-stage-conflict":"name already in use","pair-stage-ssh-start":"SSH tunnel start failed","pair-stage-ssh-ready":"peer unreachable over SSH","pair-stage-join":"invite exchange failed","pair-stage-tunnel-final":"negotiated tunnel failed","pair-stage-confirm":"pairing confirmation failed","pair-stage-health":"final federation check failed","pair-stage-internal":"internal error","pair-stage-generic":"connection failed","qr-no-camera":"no camera available on this device: use a photo of the QR","qr-permission":"camera permission denied: allow it in the browser or use a photo of the QR","qr-unsupported":"live scanner not supported here: upload a photo of the QR","qr-upload":"use a photo"},es:{"update-available":"nueva versión {v} disponible","install-version-mismatch":"instalación incompleta: frontend y servidor no coinciden (v{v})",reload:"recargar","grid-empty":"arrastra aquí una sesión desde la barra lateral, o doble clic para vista única","grid-full":"un deck puede mostrar como máximo 9 sesiones",pin:"fijar arriba",reorder:"reordenar","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","cell-working":"trabajando","cell-idle":"en espera","cell-degraded":"degradada: unit activa, tmux muerto","power-on":"encender","power-off":"apagar","boot-enable":"activar al iniciar","boot-disable":"desactivar al iniciar","state-on":"encendida","state-off":"apagada",engine:"Motor",model:"Modelo","model-default":"Modelo predeterminado del proveedor","model-remembered":"Último modelo usado con este motor","boot-persist":"iniciar en el boot","remove-boot":"quitar también del boot","power-config-in-settings":"Modifica motor, proveedor, perfil, modelo y permisos en Ajustes → Flota.","no-remote-control":"⚠ motor no nativo: sin RC de la app claude.ai (aquí puedes pilotarla igual)",cancel:"cancelar",name:"nombre","name-invalid":"nombre inválido: a-zA-Z0-9._- máx 64, sin '-' inicial",cwd:"carpeta",browse:"explorar","fs-home":"home","fs-parent":".. arriba",preset:"preset","preset-2x2":"cuadrícula 2×2","preset-columns":"columnas","preset-equalize":"igualar",collapse:"contraer",expand:"expandir",create:"crear","auth-prompt":"Pega el token (impreso por el servidor):","remember-device":"recordar en este dispositivo","zoom-out":"texto más pequeño","zoom-in":"texto más grande",composer:"composer",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-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.",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","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-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-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","ask-dismiss":"Descartar la pregunta","ask-reply-ph":"escribe la respuesta…","push-enable":"activar notificaciones push","push-disable":"desactivar notificaciones push","push-on":"push activas en este dispositivo","push-off":"push no activas","push-denied":"permiso de notificaciones denegado por el navegador","push-unsupported":"push no soportadas en este navegador","notification-speech-enable":"leer las notificaciones en voz alta","notification-speech-help":"Usa la voz del navegador solo para notificaciones nuevas mientras esta PWA está visible y en primer plano. Con la aplicación cerrada permanece la notificación del sistema.","notification-speech-test":"probar voz","notification-speech-testing":"probando voz…","notification-speech-preview":"NexusCrew. Las notificaciones por voz están activas.","notification-speech-preview-ok":"Prueba de voz completada.","notification-speech-preview-failed":"El navegador no inició la prueba de voz. Interactúa con la página y vuelve a intentarlo.","notification-speech-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-show-active":"activas","cell-switcher-close":"cerrar selector de celdas","fleet-not-available":"fleet no disponible en esta posición",start:"iniciar",stop:"detener",restart:"reiniciar",delete:"eliminar","copy-manual":"copia fallida — selecciona y pulsa Cmd+C, o copia a mano","copy-empty":"nada seleccionado: arrastra con Shift para seleccionar","selection-held":"resaltado perdido, texto aún retenido","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.","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 cc(){const e=Zy(),t=e?e.getItem(Jy):null;return Of.includes(t)?t:ec}function lk(e){const t=Zy();if(t)try{t.setItem(Jy,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(vh))}function f(e){const t=cc(),n=Hl[t]||Hl[ec];return Object.prototype.hasOwnProperty.call(n,e)?n[e]:Object.prototype.hasOwnProperty.call(Hl[ec],e)?Hl[ec][e]:e}function ck(e){return typeof window>"u"?()=>{}:(window.addEventListener(vh,e),()=>window.removeEventListener(vh,e))}const eb=Of;function Yn(){return[k.useSyncExternalStore(ck,cc,cc),lk]}function uc({cell:e,token:t,route:n=[],onConfirm:s,onClose:o}){var A,T;Yn();const a=!!(e&&e.active),u=Array.isArray(n)?n.join("/"):"",[d,p]=k.useState([]),[m,v]=k.useState(!1);k.useEffect(()=>{let j=!0;return(async()=>{if(t)try{const z=await Xs(t,u?u.split("/"):[]);if(!j)return;if(v(z.provider==="builtin"&&(z.capabilities||[]).includes("edit")),z.provider==="builtin"&&(z.capabilities||[]).includes("definitions")){const M=await Ec(t,u?u.split("/"):[]);if(!j)return;const D=new Map((z.engines||[]).map(B=>[B.id,B]));p((M.engines||[]).map(B=>{var U,se,ee,de,ve,fe,pe;return{id:B.id,label:B.label||B.id,client:((U=B.managed)==null?void 0:U.client)||"",models:[...new Set([...((se=D.get(B.id))==null?void 0:se.models)||[],...((ee=B.managedInfo)==null?void 0:ee.models)||[]])].filter(Boolean),defaultModel:((de=B.managed)==null?void 0:de.model)||((ve=B.managedInfo)==null?void 0:ve.defaultModel)||"",policyDefault:((fe=B.managed)==null?void 0:fe.permissionPolicy)||((pe=B.managed)!=null&&pe.client&&B.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{j=!1}},[t,u]);const y=(e==null?void 0:e.engine)||((A=d[0])==null?void 0:A.id)||"",b=j=>(e==null?void 0:e.models)&&e.models[j]||"",S=j=>{const z=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[j];if(z==="standard"||z==="unsafe")return z;const M=d.find(D=>D.id===j);return M?M.policyDefault:"standard"},[x,E]=k.useState(y),[w,N]=k.useState((e==null?void 0:e.model)||""),C=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((T=e==null?void 0:e.permissionPolicies)==null?void 0:T[e==null?void 0:e.engine])||"",[L,I]=k.useState(C),[G,K]=k.useState((e==null?void 0:e.boot)??!0),[Y,Q]=k.useState(!1),[W,X]=k.useState(null);k.useEffect(()=>{d.length&&(E(j=>j||y),N(j=>j||b((e==null?void 0:e.engine)||y)||""),I(j=>j==="standard"||j==="unsafe"?j:S((e==null?void 0:e.engine)||y)))},[d.length]);const H=k.useMemo(()=>d.find(j=>j.id===x)||null,[d,x]),$=!!(H&&["claude","codex","codex-vl","agy","kimi"].includes(H.client)),R=(H==null?void 0:H.client)==="shell";function O(j){E(j);const z=d.find(M=>M.id===j);N(b(j)||(z==null?void 0:z.defaultModel)||""),I(S(j))}async function F(j){j.preventDefault(),Q(!0),X(null);try{if(a)await s({action:"down",boot:G});else{const z=L==="standard"||L==="unsafe"?L:(H==null?void 0:H.policyDefault)||"standard";await s({action:"up",...m?{engine:x,model:w||"",...$?{permissionPolicy:z}:(H==null?void 0:H.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:G})}o()}catch(z){X(String(z&&z.message||z)),Q(!1)}}return l.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:o,children:l.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:j=>j.stopPropagation(),onSubmit:F,children:[l.jsxs("div",{className:"nc-sheet-head",children:[l.jsx("b",{children:e==null?void 0:e.cell}),l.jsx("span",{className:"nc-sheet-state",children:f(a?"state-on":"state-off")})]}),a?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-power-config",children:[l.jsx("span",{children:f("engine")}),l.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&l.jsxs("small",{children:[f("model"),": ",e.model]}),l.jsx("small",{children:f("power-on-hint")})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:G,onChange:j=>K(j.target.checked)}),f("remove-boot")]})]}):l.jsxs(l.Fragment,{children:[m&&d.length>0?l.jsxs("div",{className:"nc-launch-fields",children:[l.jsxs("label",{className:"nc-field",children:[f("engine"),l.jsx("select",{value:x,onChange:j=>O(j.target.value),children:d.map(j=>l.jsx("option",{value:j.id,children:j.label},j.id))})]}),!R&&l.jsxs("label",{className:"nc-field",children:[f("model"),l.jsx("input",{value:w,list:"nc-launch-models",placeholder:f("model-default"),onChange:j=>N(j.target.value)}),l.jsx("datalist",{id:"nc-launch-models",children:((H==null?void 0:H.models)||[]).map(j=>l.jsx("option",{value:j},j))})]}),$?l.jsxs("label",{className:"nc-field",children:[f("permissions"),l.jsxs("select",{value:L,onChange:j=>I(j.target.value),children:[l.jsx("option",{value:"standard",children:f("fleet-standard-permissions")}),l.jsx("option",{value:"unsafe",children:f("fleet-unsafe-permissions")})]})]}):l.jsx("small",{className:"nc-note",children:f("fleet-standard-permissions")}),$&&L==="unsafe"&&l.jsx("small",{className:"nc-err",children:f("fleet-unsafe-warning")}),l.jsx("small",{className:"nc-note",children:f(R?"fleet-shell-launch-help":"launch-engine-help")})]}):l.jsxs("div",{className:"nc-power-config",children:[l.jsx("span",{children:f("engine")}),l.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&l.jsxs("small",{children:[f("model"),": ",e.model]}),l.jsx("small",{children:f("launch-unavailable-hint")})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:G,onChange:j=>K(j.target.checked)}),f("boot-persist")]})]}),W&&l.jsx("div",{className:"nc-err",children:W}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:Y,children:f("cancel")}),l.jsx("button",{type:"submit",className:"nc-btn primary",disabled:Y,children:f(a?"power-off":"save-and-start")})]})]})})}const lv=/^[a-z0-9-]{1,32}$/;function ka(e,t){const n=Array.isArray(e)?e:[];return n.length?`${n.map(encodeURIComponent).join("/")}:${t}`:String(t)}function uk(e,t,n){const s={};for(const o of Array.isArray(t)?t:[]){const a=Array.isArray(o==null?void 0:o.route)?o.route:typeof(o==null?void 0:o.name)=="string"?[o.name]:[];if(!a.length)continue;const u=a.join("/"),d=o.status==="up"||o.tunnel&&o.tunnel.status==="up",p=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!d&&!p&&(s[u]=e&&e[u]||n)}return s}function _h(e,t,n,s=!1){return!e||!Array.isArray(e.cells)?[]:e.cells.map(o=>({...o,route:t,key:`${n}:${o.tmuxSession||o.cell}`,...s?{preserved:!0}:{}}))}function ia(e,t,n){if(!e)return{};const s=yh(e);return!pa(e,s)||s!=="stale"?{}:{cells:_h(e,t,n,!0),fleetState:"stale",fleetAvailable:!1,cellsPreserved:!0}}function yh(e){return(e==null?void 0:e.fleetState)==="stale"?"stale":(e==null?void 0:e.fleetState)==="disabled"?"disabled":(e==null?void 0:e.available)===!0&&Array.isArray(e.cells)?"available":(e==null?void 0:e.available)===!1?"disabled":"stale"}function pa(e,t){return(t==="available"||t==="stale")&&Array.isArray(e==null?void 0:e.cells)}function cv({nodes:e,topology:t,remote:n,down:s,fleet:o,aliases:a}={}){var m,v,y,b;const u=[],d=new Set,p=new Set;for(const S of Array.isArray(e)?e:[]){if(!S||typeof S.name!="string"||!lv.test(S.name)||S.direction==="inbound"&&S.shared!==!0)continue;const x=[S.name],E=S.name;d.add(E);const w=((m=S.tunnel)==null?void 0:m.status)||"unknown",N=w==="up",C={name:S.name,label:S.label||S.name,originalLabel:S.label||S.name,alias:null,route:x,direct:!0,instanceId:S.nodeId||null,shared:S.shared===!0,tunnelStatus:w,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:S.health||null,direction:S.direction||"outbound",roles:S.roles||null,rolesKnown:S.rolesKnown===!0};if(S.nodeId&&p.add(S.nodeId),!S.nodeId&&S.paired===!1){u.push({...C,status:"needs-repair",downSince:s&&s[E]||null,...ia(o&&(o[E]||o[S.name]),x,E)});continue}if(((v=S.health)==null?void 0:v.auth)==="failed"||w==="degraded"&&((y=S.health)==null?void 0:y.status)==="degraded"){u.push({...C,status:"needs-repair",downSince:s&&s[E]||null,...ia(o&&(o[E]||o[S.name]),x,E)});continue}if(w==="passive"||((b=S.health)==null?void 0:b.status)==="passive"){u.push({...C,status:"passive",downSince:null,...ia(o&&(o[E]||o[S.name]),x,E)});continue}if(!N){u.push({...C,status:"down",downSince:s&&s[E]||null,...ia(o&&(o[E]||o[S.name]),x,E)});continue}const L=n&&(n[E]||n[S.name])||null,I=o&&(o[E]||o[S.name]),G=!!(L&&!L.error&&Array.isArray(L.sessions)),K=yh(I),Y=K==="available"&&pa(I,K),Q=pa(I,K);if(!G&&!Q){u.push({...C,status:"unreachable",cause:L&&L.cause||null});continue}const W=(G?L.sessions:[]).filter($=>$&&typeof $.name=="string"&&$.name).map($=>({...$,node:E,route:x,key:`${E}:${$.name}`})),X=_h(I,x,E),H=new Set(X.map($=>$.tmuxSession).filter(Boolean));u.push({...C,status:"up",sessions:W,cells:X,unmanaged:W.filter($=>!H.has($.name)),fleetAvailable:Y,fleetState:K,capabilities:I&&I.capabilities||[],engines:I&&I.engines||[],fleetProvider:I&&I.provider||null,sessionsAvailable:G,inventoryPartial:!G})}for(const S of Array.isArray(t)?t:[]){if(!S||!Array.isArray(S.route)||S.route.length<1||S.route.some(H=>!lv.test(H)))continue;const x=S.route.join("/");if(d.has(x)||S.instanceId&&p.has(S.instanceId))continue;S.instanceId&&p.add(S.instanceId);const E=S.label||S.route.join(" › "),w=S.instanceId&&a&&typeof a[S.instanceId]=="string"?a[S.instanceId]:null,N={name:S.name,label:w||E,originalLabel:E,alias:w,route:[...S.route],direct:!1,instanceId:S.instanceId||null,shared:!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:S.health||null,lastSeen:S.lastSeen||null};if(S.stale){u.push({...N,status:"offline",downSince:s&&s[x]||S.lastSeen||null,...ia(o&&o[x],S.route,x)});continue}const C=n&&n[x]||null,L=o&&o[x],I=!!(C&&!C.error&&Array.isArray(C.sessions)),G=yh(L),K=G==="available"&&pa(L,G),Y=pa(L,G);if(!I&&!Y){u.push({...N,status:"unreachable",downSince:s&&s[x]||null,cause:C&&C.cause||null});continue}const Q=(I?C.sessions:[]).filter(H=>H&&typeof H.name=="string"&&H.name).map(H=>({...H,node:x,route:S.route,key:`${x}:${H.name}`})),W=_h(L,S.route,x),X=new Set(W.map(H=>H.tmuxSession).filter(Boolean));u.push({...N,status:"up",sessions:Q,cells:W,unmanaged:Q.filter(H=>!X.has(H.name)),fleetAvailable:K,fleetState:G,capabilities:L&&L.capabilities||[],engines:L&&L.engines||[],fleetProvider:L&&L.provider||null,lastSeen:S.lastSeen||null,sessionsAvailable:I,inventoryPartial:!I})}return u.sort((S,x)=>S.label.localeCompare(x.label))}function tb(e,t={}){if(!e||typeof e!="object")return null;const n=typeof e.nodeId=="string"?e.nodeId:"";if(!n)return null;const s=typeof e.label=="string"&&e.label.trim()||typeof e.cell=="string"&&e.cell.trim()||n,o=Array.isArray(t.route)?[...t.route]:[];return{kind:"vl",nodeId:n,name:n,label:s,cell:e.cell??null,paired:!!e.pairedAt,online:!!e.online,lastSeen:e.lastSeen??null,generation:e.generation??null,version:e.version??null,health:e.health??null,session:e.session??null,capabilities:Array.isArray(e.capabilities)?e.capabilities:[],inflight:e.inflight??null,lastAck:e.lastAck??null,canManage:!!e.canManage,route:o,isLocal:o.length===0,ownerInstanceId:typeof t.instanceId=="string"?t.instanceId:null,ownerLabel:typeof t.label=="string"&&t.label?t.label:null}}function dk(e){var n;const t=[];for(const s of Array.isArray(e)?e:[]){if(!s||s.kind!=="vl"||!s.nodeId)continue;const o=s.online===!0,a=o&&((n=s.session)==null?void 0:n.attached)===!0,u=s.ownerInstanceId||"local";t.push({kind:"vl",name:`vl-${s.nodeId.slice(0,8)}`,label:s.label,route:Array.isArray(s.route)?[...s.route]:[],instanceId:null,direct:!1,status:o?"up":"offline",downSince:o?null:s.lastSeen??null,sessions:a?[{key:`vl:${u}:${s.nodeId}`,name:s.session.profile,attached:!0}]:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:s.health??null,peer:s})}return t}function nb(e,t){const n=e&&Array.isArray(e.nodes)?e.nodes:[],s=new Set([t]),o=[];for(const a of n){const u=a&&typeof a.instanceId=="string"?a.instanceId:"";if(!u||s.has(u)||a.stale===!0||!Array.isArray(a.route)||a.route.length===0)continue;s.add(u);const d=typeof a.label=="string"&&a.label||typeof a.name=="string"&&a.name||a.route.join(" › ");o.push({instanceId:u,route:[...a.route],label:d})}return o}const hk=/fleet\.json/;function Bf({fs:e=null,error:t=null}={}){if(t)return{kind:"stale"};if(!e)return{kind:"stale"};if(e.available===!0)return{kind:"data",cells:e.cells||[],capabilities:e.capabilities||[]};const n=typeof e.reason=="string"?e.reason:"";return typeof e.migrationCode=="string"&&e.migrationCode?{kind:"disabled",reason:n||null}:hk.test(n)?{kind:"stale"}:{kind:"disabled",reason:n||null}}const ib={baseMs:4e3,capMs:6e4},sb="peer-assente",rb="peer-nega",ob="rotta-inesistente";function yd(e){const t=e&&e.status;return t===403?rb:t===404?ob:sb}function fk(e,{baseMs:t,capMs:n}=ib){return!Number.isFinite(e)||e<1?0:Math.min(t*2**(e-1),n)}function uv(e,t,n){const s=e&&e[t];return!s||!(s.failures>=1)?!0:n>=s.nextAtMs}function dv(e,t,n,s,o=ib){const u=(e&&e[t]||{failures:0}).failures+1;return{...e,[t]:{failures:u,cause:n,nextAtMs:s+fk(u,o)}}}function hv(e,t){if(!e||!(t in e))return e;const n={...e};return delete n[t],n}const pk=4e3;function zf(e,t=!0,n=0){const[s,o]=k.useState([]),a=k.useRef({}),u=k.useRef({}),d=k.useRef({remote:{},fleet:{}});return k.useEffect(()=>{if(!t||!e){o([]);return}let p=!0;async function m(){var Y,Q;const y=Date.now();let b=[],S=[],x={},E="";if(await Promise.all([bx(e).then(W=>{b=Array.isArray(W.nodes)?W.nodes:[]}).catch(()=>{}),Vy(e).then(W=>{S=Array.isArray(W.nodes)?W.nodes:[]}).catch(()=>{}),Ex(e).then(W=>{x=W&&typeof W.aliasesByInstanceId=="object"?W.aliasesByInstanceId:{}}).catch(()=>{}),on("/api/config",e).then(W=>W.json()).then(W=>{E=W&&typeof W.instanceId=="string"?W.instanceId:""}).catch(()=>{})]),!p)return;const w=[{instanceId:E||null,route:[],label:null},...nb({nodes:S},E)],N=[];if(await Promise.all(w.map(async W=>{const X=`vl:${W.route.join("/")}`;if(uv(u.current,X,y))try{const H=await qy(e,W.route);u.current=hv(u.current,X);for(const $ of H.nodes||[]){const R=tb($,W);R&&N.push(R)}}catch(H){u.current=dv(u.current,X,yd(H),y)}})),!p)return;const C={},L={},I=new Set(b.map(W=>W.name)),G=[];for(const W of b)((Y=W.tunnel)==null?void 0:Y.status)==="up"&&(W.nodeId||W.paired!==!1)&&(W.direction!=="inbound"||W.shared===!0)&&G.push([W.name]);for(const W of S)!W.stale&&Array.isArray(W.route)&&W.route.length>0&&!(W.route.length===1&&I.has(W.route[0]))&&G.push(W.route);if(await Promise.all(G.map(async W=>{const X=W.join("/");if(!uv(u.current,X,y)){const R=d.current.remote[X];R&&(C[X]=R);const O=d.current.fleet[X];O&&(L[X]={...O,available:!1,fleetState:"stale"});return}let H=!1;try{C[X]=await Tf(e,W),H=!0,d.current.remote[X]=C[X]}catch(R){C[X]={error:"unreachable",cause:yd(R)},d.current.remote[X]=C[X]}const $=d.current.fleet[X]||null;try{const R=await Xs(e,W),O=Bf({fs:R});O.kind==="data"?L[X]={...R,available:!0,cells:O.cells,fleetState:"available"}:O.kind==="disabled"?L[X]={...R,available:!1,cells:[],fleetState:"disabled"}:L[X]={...$||{},available:!1,cells:Array.isArray($==null?void 0:$.cells)?$.cells:[],fleetState:"stale",...R!=null&&R.reason?{reason:R.reason}:{}},d.current.fleet[X]=L[X]}catch(R){L[X]={...$||{},available:!1,cells:Array.isArray($==null?void 0:$.cells)?$.cells:[],fleetState:"stale",cause:yd(R)},d.current.fleet[X]=L[X]}u.current=H?hv(u.current,X):dv(u.current,X,C[X].cause,y)})),!p)return;for(const W of b){if(((Q=W.tunnel)==null?void 0:Q.status)==="up")continue;const X=d.current.fleet[W.name];X&&!L[W.name]&&(L[W.name]={...X,available:!1,fleetState:"stale"})}for(const W of S){if(!W.stale||!Array.isArray(W.route)||!W.route.length)continue;const X=W.route.join("/"),H=d.current.fleet[X];H&&!L[X]&&(L[X]={...H,available:!1,fleetState:"stale"})}const K=cv({nodes:b,topology:S,remote:C,fleet:L,aliases:x,down:a.current});a.current=uk(a.current,K,Math.floor(Date.now()/1e3)),o([...cv({nodes:b,topology:S,remote:C,fleet:L,aliases:x,down:a.current}),...dk(N)])}m();const v=setInterval(m,pk);return()=>{p=!1,clearInterval(v)}},[e,t,n]),s}const fv=52,pv=14;function Yi({position:e,itemKey:t,label:n,onMove:s,onStep:o,canMove:a=()=>!0,scope:u="roster"}){const d=k.useRef(null),p=k.useRef(0),[m,v]=k.useState(!1),y=()=>{var N,C,L,I;const w=d.current;(C=(N=w==null?void 0:w.over)==null?void 0:N.classList)==null||C.remove("nc-roster-over"),(I=(L=w==null?void 0:w.source)==null?void 0:L.classList)==null||I.remove("nc-roster-dragging"),p.current&&cancelAnimationFrame(p.current),p.current=0},b=(w=!1)=>{const N=d.current;if(!N)return;const C=N.target;y(),d.current=null,v(!1);try{N.handle.releasePointerCapture(N.pointerId)}catch{}w&&C&&C!==t&&a(t,C)&&s(t,C)},S=(w,N)=>{var Q,W,X,H,$,R,O,F,A;const C=d.current;if(!C)return;C.x=w,C.y=N;const L=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",I=(W=(Q=document.elementFromPoint(w,N))==null?void 0:Q.closest)==null?void 0:W.call(Q,L),G=u==="node"?(X=I==null?void 0:I.dataset)==null?void 0:X.nodeOrderKey:(H=I==null?void 0:I.dataset)==null?void 0:H.rosterKey,Y=(u==="node"||(($=I==null?void 0:I.dataset)==null?void 0:$.position)===e)&&G&&G!==t&&a(t,G);C.over!==(Y?I:null)&&((O=(R=C.over)==null?void 0:R.classList)==null||O.remove("nc-roster-over"),C.over=Y?I:null,(A=(F=C.over)==null?void 0:F.classList)==null||A.add("nc-roster-over")),C.target=Y?G:null},x=()=>{const w=d.current;if(!w){p.current=0;return}const N=w.container;if(N){const C=N.getBoundingClientRect(),L=w.y<C.top+fv?-pv:w.y>C.bottom-fv?pv:0;L&&(N.scrollTop+=L,S(w.x,w.y))}p.current=requestAnimationFrame(x)};k.useEffect(()=>{const w=C=>{C.key==="Escape"&&d.current&&(C.preventDefault(),b(!1))},N=()=>b(!1);return window.addEventListener("keydown",w),window.addEventListener("blur",N),()=>{window.removeEventListener("keydown",w),window.removeEventListener("blur",N),y(),d.current=null}},[t,e,u]);const E=w=>{var I;if(w.pointerType==="mouse"&&w.button!==0)return;w.preventDefault(),w.stopPropagation(),w.currentTarget.focus({preventScroll:!0});const N=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",C=w.currentTarget.closest(N),L=w.currentTarget.closest(".nc-side-scroll, .nc-home-scroll, .nc-cell-switcher-list");d.current={pointerId:w.pointerId,handle:w.currentTarget,source:C,container:L,target:null,over:null,x:w.clientX,y:w.clientY},(I=C==null?void 0:C.classList)==null||I.add("nc-roster-dragging");try{w.currentTarget.setPointerCapture(w.pointerId)}catch{}v(!0),p.current=requestAnimationFrame(x)};return l.jsx("button",{type:"button",className:`nc-roster-handle${m?" active":""}`,"aria-label":`${f("reorder")} ${n}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:f("reorder-help"),onClick:w=>{w.preventDefault(),w.stopPropagation()},onDragStart:w=>w.preventDefault(),onKeyDown:w=>{w.key!=="ArrowUp"&&w.key!=="ArrowDown"||(w.preventDefault(),w.stopPropagation(),o(w.key==="ArrowUp"?-1:1))},onPointerDown:E,onPointerMove:w=>{!d.current||w.pointerId!==d.current.pointerId||(w.preventDefault(),w.stopPropagation(),S(w.clientX,w.clientY))},onPointerUp:w=>{!d.current||w.pointerId!==d.current.pointerId||(w.preventDefault(),w.stopPropagation(),b(!0))},onPointerCancel:()=>b(!1),onLostPointerCapture:()=>{d.current&&b(!1)},children:"↕"})}const $f="nc_pins";function bd(){try{const e=JSON.parse(localStorage.getItem($f));return Array.isArray(e)?e:[]}catch{return[]}}function ab(e){try{return localStorage.setItem($f,JSON.stringify(e)),null}catch(t){return t instanceof Error?t:new Error(String(t))}}function mk(e,t){const n=e.includes(t)?e.filter(s=>s!==t):[...e,t];return{next:n,error:ab(n)}}function mv(e,t){if(!Array.isArray(e)||!e.includes(t))return{next:Array.isArray(e)?e:[],error:null};const n=e.filter(s=>s!==t);return{next:n,error:ab(n)}}function gk(e,t,n){if(!e.includes(t)||!e.includes(n)||t===n)return e;const s=[...e],o=s.indexOf(t),a=s.indexOf(n);s.splice(o,1);const u=s.indexOf(n);s.splice(o<a?u+1:u,0,t);try{localStorage.setItem($f,JSON.stringify(s))}catch{}return s}function vk(e,t,n){const s=e.indexOf(t);return[s===-1?1e9:s,-(n||0)]}function _k(e,t){return e[0]-t[0]||e[1]-t[1]}function Ff(){const[e,t]=k.useState(bd),[n,s]=k.useState(rk),[o,a]=k.useState(nk),[u,d]=k.useState(null),p=N=>t(C=>mk(C,N).next),m=N=>{const C=mv(bd(),N);return t(C.next),d(C.error?{key:N,message:C.error.message||String(C.error)}:null),C.error},v=()=>{if(!u)return;const N=mv(bd(),u.key);t(N.next),d(N.error?{...u,message:N.error.message||String(N.error)}:null)},y=()=>d(null),b=N=>ov(n,N),S=(N,C)=>s(L=>{const I={...L,[N]:{...ov(L,N),...C}};return ok(I)}),x=(N,C)=>e.includes(N)===e.includes(C);function E(N,C,L,I){const G=e.includes(C),K=e.includes(L);if(G===K){if(G){t(Y=>gk(Y,C,L));return}a(Y=>{var X;const Q=((X=I.find(H=>H.key===C))==null?void 0:X.technical)===!0,W=qs(I,e,Q?"technical":"all",ms(Y,N)).map(H=>H.key);return ik(sk(Y,N,C,L,W))})}}function w(N,C,L,I){var X;const G=((X=I.find(H=>H.key===C))==null?void 0:X.technical)===!0,K=e.includes(C),Y=qs(I,e,G?"technical":"all",ms(o,N)).map(H=>H.key).filter(H=>e.includes(H)===K),Q=Y.indexOf(C),W=Y[Q+L];Q>=0&&W&&E(N,C,W,I)}return{pins:e,views:n,orders:o,togglePin:p,removePin:m,pinError:u,retryPinPersist:v,clearPinError:y,viewFor:b,updateView:S,canMoveRoster:x,moveRoster:E,stepRoster:w}}const lb="nc_node_order_v1",yk=/^[a-f0-9]{16,64}$/;function wr(e){if(yk.test(String((e==null?void 0:e.instanceId)||"")))return`id:${e.instanceId}`;const t=Array.isArray(e==null?void 0:e.route)?e.route.filter(n=>typeof n=="string"&&n):[];return t.length?`route:${t.map(encodeURIComponent).join("/")}`:typeof(e==null?void 0:e.name)=="string"&&e.name?`name:${encodeURIComponent(e.name)}`:""}function gv(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(lb));return Array.isArray(t)?[...new Set(t.filter(n=>typeof n=="string"&&n&&n.length<=192))].slice(0,128):[]}catch{return[]}}function bk(e,t=globalThis.localStorage){try{t.setItem(lb,JSON.stringify(e))}catch{}return e}function vv(e=[],t=[]){const n=new Map(t.map((s,o)=>[s,o]));return e.map((s,o)=>({group:s,index:o})).sort((s,o)=>{const a=n.has(wr(s.group))?n.get(wr(s.group)):Number.MAX_SAFE_INTEGER,u=n.has(wr(o.group))?n.get(wr(o.group)):Number.MAX_SAFE_INTEGER;return a-u||s.index-o.index}).map(({group:s})=>s)}function wk(e,t,n,s=[]){if(!t||!n||t===n)return e;const o=s.map(wr).filter(Boolean);if(!o.includes(t)||!o.includes(n))return e;const a=[...e.filter(m=>o.includes(m)),...o.filter(m=>!e.includes(m))],u=a.indexOf(t),d=a.indexOf(n);a.splice(u,1);const p=a.indexOf(n);return a.splice(u<d?p+1:p,0,t),a}const bh="nexuscrew-node-preferences";function Sk(){try{window.dispatchEvent(new Event(bh))}catch{}}function cb(){const[e,t]=k.useState(gv);k.useEffect(()=>{const a=()=>t(gv());return window.addEventListener("storage",a),window.addEventListener(bh,a),()=>{window.removeEventListener("storage",a),window.removeEventListener(bh,a)}},[]);const n=a=>vv(a,e),s=(a,u,d)=>t(p=>{const m=wk(p,a,u,d);return bk(m),Sk(),m});return{order:e,groupsFor:n,moveNode:s,stepNode:(a,u,d)=>{const p=vv(d,e).map(wr),m=p.indexOf(a),v=p[m+u];m>=0&&v&&s(a,v,d)},nodeKey:wr}}const xk="none",ub="favorite",Hf="live";function wh({hostCell:e,pins:t=[],item:n}){const s=n&&n.value&&typeof n.value.cell=="string"?n.value.cell:null;return s!=null&&e===s?Hf:Array.isArray(t)&&n&&t.includes(n.key)?ub:xk}function db(e){return e===Hf?"clearAndUnpin":e===ub?"designate":"addPin"}const kk=Object.freeze(["live","grace","expired","none","unavailable"]);function Sh(e,t){return e!==Hf||!kk.includes(t)?null:`host-lease-${t}`}const Ck="local";function wa(e){return Array.isArray(e)&&e.length?e.join("/"):Ck}function _v(e){return(e&&e.data&&typeof e.data=="object"?e.data.reason:null)==="live-host-not-granted"?"live-host-not-granted":"live-host-error"}function hb({pinError:e,onRetry:t,onDismiss:n}){return e?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:t,children:"riprova"}),l.jsx("button",{type:"button",className:"nc-pin-error-close",onClick:n,"aria-label":"chiudi avviso",children:"×"})]}):null}function go(e,t=Math.floor(Date.now()/1e3)){if(!e)return"";const n=t-e;return n<0||n<60?"ora":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}g`}function fs(e){return e.status==="passive"?f("node-passive"):e.status==="down"?e.downSince?f("tunnel-down-since").replace("{t}",go(e.downSince)):f("tunnel-down"):e.status==="unreachable"?e.cause===rb?f("peer-cause-nega"):e.cause===ob?f("peer-cause-rotta"):e.cause===sb?f("peer-cause-assente"):f("node-unreachable"):e.status==="offline"?e.lastSeen?f("node-offline-seen").replace("{t}",go(e.lastSeen)):f("node-offline"):e.status==="needs-repair"?f("node-needs-repair"):""}function fb(e,{passive:t=null}={}){return e?e.status==="passive"?t:e.status==="healthy"?"on":"warn":null}function dc(e){return e&&(e.detail||e.status)||""}const Ek="restrict,port-forwarding,permitopen=";function Nk(e){const t=e&&typeof e.hint=="string"&&e.hint.trim()||"",n=e&&typeof e.authorizedKeys=="string"&&e.authorizedKeys.trim()||"";if(n){const o=t.indexOf(n);return{note:o>=0?t.slice(0,o).replace(/[:\s]+$/,""):t,line:n}}if(!t)return null;const s=t.indexOf(Ek);return s<0?{note:t,line:""}:{note:t.slice(0,s).replace(/[:\s]+$/,""),line:t.slice(s).trim()}}function hc(e,t,n=globalThis.localStorage){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const s=Number(n.getItem($y(t))||0);return e.outbox.latest>s}function Uf(e,t={}){const n=e||{};if(!n.tmux){const s=`${n.engine||""}${n.key?`·${n.key}`:""}`,o=[s,n.model&&n.model!==s?n.model:""].filter(Boolean).join(" · ");return{working:!1,subtitle:String(o||f("cell-off")).trim()}}if(t.working===!0){const s=f("cell-working"),o=String(t.status||"").trim();return{working:!0,subtitle:!o||/^working(?:\.{3}|…)?$/i.test(o)?s:`${s} · ${o}`}}return t.working===!1?{working:!1,subtitle:f("cell-idle")}:{working:!1,subtitle:String(t.preview||n.preview||f("cell-on")).trim()}}function pb(e,t){return[...new Set([e.engine,e.model,e.key,t.preview,e.preview,t.status].filter(Boolean).map(String))].join(" ")}function Wf(e,t,n,s=globalThis.localStorage){return[...(Array.isArray(e)?e:[]).map(o=>{const a=n.get(o.tmuxSession)||{},u=ka([],o.tmuxSession),d=Uf(o,a);return{type:"cell",value:o,key:u,label:o.cell,live:!!o.tmux,fresh:hc(a,u,s),activity:a.activity||0,working:d.working,subtitle:d.subtitle,searchText:pb(o,a)}}),...(Array.isArray(t)?t:[]).map(o=>{const a=ka([],o.name);return{type:"session",value:o,key:a,label:o.name,live:!0,technical:o.technical===!0,fresh:hc(o,a,s),activity:o.activity||0,searchText:`${o.preview||""} ${o.cmd||""}`}})]}function fc(e,t=globalThis.localStorage){const n=e||{},s=Array.isArray(n.route)?n.route:[],o=new Map((n.sessions||[]).map(u=>[u.name,u])),a=[...(n.cells||[]).map(u=>{const d=o.get(u.tmuxSession)||{},p=ka(s,u.tmuxSession||u.cell),m=Uf(u,d);return{type:"cell",value:u,key:p,label:u.cell,live:!!u.tmux&&!u.preserved,fresh:hc(d,p,t),activity:d.activity||u.activity||0,working:m.working,subtitle:m.subtitle,searchText:pb(u,d)}}),...(n.unmanaged||[]).map(u=>{const d=ka(s,u.name);return{type:"session",value:u,key:d,label:u.name,live:!0,technical:u.technical===!0,fresh:hc(u,d,t),activity:u.activity||0,searchText:`${u.preview||""} ${u.cmd||""}`}})];return{route:s,rawItems:a}}const Kf=9,pc=.2,jk=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,vo=/^[a-f0-9]{16,64}$/,xh=e=>jk.test(e)&&new Set(e.split("/")).size===e.split("/").length;function Gs(e){if(typeof e=="string"&&e){const t=e.indexOf(":");if(t<0)return{session:e};const n=e.slice(0,t),s=e.slice(t+1);return!xh(n)||!s?null:{session:s,node:n}}if(e&&typeof e=="object"&&typeof e.session=="string"&&e.session){const t=e.ownerId===void 0?void 0:typeof e.ownerId=="string"&&vo.test(e.ownerId)?e.ownerId:null;return t===null?null:e.node===void 0||e.node===null||e.node===""?{session:e.session,...t?{ownerId:t}:{}}:typeof e.node=="string"&&xh(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function mi(e){const t=Gs(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const mb=9,gb=24,Pa=11,Rk=e=>{const t=Number(e);return t>=mb&&t<=gb?t:Pa};function fo(){return{columns:[]}}function Qi(e){return e.columns.flatMap(t=>t.tiles.map(n=>mi(n)))}function Pk(e){const t=[],n=Math.max(0,...e.columns.map(s=>s.tiles.length));for(let s=0;s<n;s+=1)for(const o of e.columns)o.tiles[s]&&t.push(mi(o.tiles[s]));return t}const So=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))});function qf(e,t,n,s){const o=Gs(t);if(!o||Qi(e).includes(mi(o))||Qi(e).length>=Kf)return e;const a=So(e),u={session:o.session,height:1,fontSize:Pa,...s||{}};if(o.node&&(u.node=o.node),o.ownerId&&(u.ownerId=o.ownerId),n==="end")return a.columns.push({width:1,tiles:[u]}),a;if(n&&typeof n.col=="number"&&typeof n.row=="number"&&a.columns[n.col])return a.columns[n.col].tiles.splice(n.row,0,u),a;if(n&&typeof n.col=="number"){const d=Math.max(0,Math.min(a.columns.length,n.col));return a.columns.splice(d,0,{width:1,tiles:[u]}),a}return a.columns.push({width:1,tiles:[u]}),a}function vb(e,t){const n=mi(t);if(!n||Qi(e).includes(n)||Qi(e).length>=Kf)return e;const s=Qi(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let v=0;for(let y=1;y<e.columns.length;y+=1)e.columns[y].tiles.length<e.columns[v].tiles.length&&(v=y);return qf(e,t,{col:v,row:e.columns[v].tiles.length})}const a=[...Pk(e),n],u=new Map(e.columns.flatMap(v=>v.tiles.map(y=>[mi(y),y]))),d=Gs(t),p=e.columns.length?e.columns.reduce((v,y)=>v+(Number(y.width)||1),0)/e.columns.length:1,m=Array.from({length:o},(v,y)=>{var b;return{width:((b=e.columns[y])==null?void 0:b.width)||p,tiles:[]}});return a.forEach((v,y)=>{const b=Gs(v);if(!b)return;const S=u.get(v)||(v===n?d:{})||{},x={session:b.session,height:S.height||1,fontSize:S.fontSize||Pa};b.node&&(x.node=b.node),S.ownerId&&(x.ownerId=S.ownerId),S.unavailable===!0&&(x.unavailable=!0),m[y%o].tiles.push(x)}),{columns:m.filter(v=>v.tiles.length)}}function mc(e,t){const n=mi(t),s=So(e);for(const o of s.columns)o.tiles=o.tiles.filter(a=>mi(a)!==n);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function Lk(e,t,n){const s=mi(t);if(!Qi(e).includes(s))return e;const o=e.columns.flatMap(a=>a.tiles).find(a=>mi(a)===s);return qf(mc(e,s),s,n,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function Ak(e,t){if(!(t instanceof Map)||t.size===0)return e;let n=!1;const s=So(e);for(const o of s.columns)for(const a of o.tiles){const u=t.get(mi(a));if(!u)continue;const d=Gs(u);d&&(a.session=d.session,d.node?a.node=d.node:delete a.node,d.ownerId&&(a.ownerId=d.ownerId),n=!0)}return n?xr(s):e}function Mk(e,t,n){const s=So(e);return s.columns[t]&&(s.columns[t].width=Math.max(pc,Number(n)||1)),s}function Tk(e,t,n,s){const o=So(e),a=o.columns[t]&&o.columns[t].tiles[n];return a&&(a.height=Math.max(pc,Number(s)||1)),o}function Dk(e,t,n,s){if(!(e.columns[t]&&e.columns[t].tiles[n]))return e;const a=So(e),u=a.columns[t].tiles[n],d=Number(u.fontSize)||Pa;return u.fontSize=Math.max(mb,Math.min(gb,d+(Number(s)||0))),a}function Ik(e,t,n,s){const o=e.columns[t];if(!o||!o.tiles[n])return null;switch(s){case"left":return{col:t};case"right":return{col:t+1};case"top":return{col:t,row:n};case"bottom":return{col:t,row:n+1};default:return null}}function yv(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function xr(e){if(!e||!Array.isArray(e.columns))return fo();const t=e.columns.map(s=>({width:Math.max(pc,Number(s&&s.width)||1),tiles:(Array.isArray(s&&s.tiles)?s.tiles:[]).filter(o=>o&&typeof o.session=="string"&&o.session).filter(o=>o.node==null||typeof o.node=="string"&&xh(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&vo.test(o.ownerId)).map(o=>{const a={session:o.session,height:Math.max(pc,Number(o.height)||1),fontSize:Rk(o.fontSize)};return o.node!=null&&(a.node=o.node),o.ownerId!=null&&(a.ownerId=o.ownerId),o.unavailable===!0&&(a.unavailable=!0),a})})).filter(s=>s.tiles.length>0),n=new Set;for(const s of t)s.tiles=s.tiles.filter(o=>!n.has(mi(o))&&n.add(mi(o))&&n.size<=Kf);return{columns:t.filter(s=>s.tiles.length>0)}}const _b=/^[a-z0-9-]{1,32}$/,Ok=/^[A-Za-z0-9._-]{1,32}$/,Bk=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,zk=320;function kh(e){return typeof e=="string"&&_b.test(e)}const $k=64;function _o(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=$k&&!/[\x00-\x1f\x7f]/.test(t)}function Vs(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function yb(e){if(typeof e!="string"||!e||e.length>zk||e.startsWith("-")||/[\0-\x20\x7f]/.test(e))return!1;if(!e.includes("@"))return/^[A-Za-z0-9][A-Za-z0-9._:-]{0,254}$/.test(e);const t=e.indexOf("@");return t<=0||t!==e.lastIndexOf("@")?!1:Ok.test(e.slice(0,t))&&Bk.test(e.slice(t+1))}function bv(e){if(e===""||e===null||e===void 0)return null;const t=String(e).trim();if(!/^[0-9]{1,5}$/.test(t))return;const n=Number(t);return Number.isInteger(n)&&n>=1&&n<=65535?n:void 0}function Fk({name:e,ssh:t,sshPort:n,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,a=typeof t=="string"?t.trim():t;if(!kh(o))return{ok:!1,error:"err-node-name"};if(!yb(a))return{ok:!1,error:"err-ssh"};const u=bv(n);if(u===void 0)return{ok:!1,error:"err-ssh-port"};const d=bv(s);if(d===void 0)return{ok:!1,error:"err-node-port"};const p={name:o,ssh:a};return u!==null&&(p.sshPort=u),d!==null&&(p.remotePort=d),{ok:!0,value:p}}function Hk(e,t){if(!e||!t||t<e)return null;const n=Math.floor((t-e)/1e3);return n<60?"ora":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}g`}function Ch(e,t){const n=!!(e&&e.status==="up"),s=!!(e&&e.status==="passive");return{up:n,...s?{passive:!0}:{},label:n?"tunnel-up":s?"node-passive":"tunnel-down",since:n?Hk(e.since,t):null}}const Uk=new Set(["v","instanceId","port","label","invite"]),Wk=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function Kk(e){const t=String(e).replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),s=typeof atob=="function"?atob(n):Buffer.from(n,"base64").toString("binary"),o=Uint8Array.from(s,a=>a.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function qk(e){let t="";try{const u=new URL(String(e));t=new URLSearchParams(u.hash.replace(/^#/,"")).get("pair")||""}catch{return{ok:!1}}if(!t)return{ok:!1};let n;try{n=JSON.parse(Kk(t))}catch{return{ok:!1}}if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1};const s=n.v===1?Uk:n.v===2?Wk:null;if(!s)return{ok:!1};for(const u of Object.keys(n))if(!s.has(u))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(n.instanceId)))return{ok:!1};const o=Number(n.port);if(!Number.isInteger(o)||o<1||o>65535)return{ok:!1};if(typeof n.label!="string")return{ok:!1};if(typeof n.invite!="string"||!n.invite)return{ok:!1};const a={ok:!0,version:n.v,label:n.label,invite:n.invite,instanceId:n.instanceId,port:o};if(n.v===2){if(n.name!==void 0){if(typeof n.name!="string"||!_b.test(n.name))return{ok:!1};a.name=n.name}if(n.ssh!==void 0){if(!yb(n.ssh))return{ok:!1};a.ssh=String(n.ssh).trim()}if(n.sshPort!==void 0){const u=Number(n.sshPort);if(!Number.isInteger(u)||u<1||u>65535)return{ok:!1};a.sshPort=u}}return a}function Vk(e,t,n=new Set){if(!t||!t.ok)return e;const s={...e},o=(a,u)=>{u==null||u===""||n.has(a)||(s[a]=u)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?Vs(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}const Yk=["KIMI_AUTH_ACTION_REQUIRED","CLIENT_INTERACTION_REQUIRED"],Gk=["kimi-code-consent-yes","kimi-code-config-custom-api-key","kimi-cli-login","client-terminal-dialog"];function Vf(e){const t=e&&typeof e=="object"?e.actionRequired:null;return t&&typeof t=="object"&&Yk.includes(t.code)&&Gk.includes(t.recovery)?{code:t.code,recovery:t.recovery,text:f(`fleet-recovery-${t.recovery}`)}:e&&typeof e=="object"&&e.vlPromptDegraded===!0?{code:"VL_PROMPT_DEGRADED",recovery:null,text:f("fleet-vl-prompt-degraded")}:e&&typeof e=="object"&&e.readinessDegraded===!0?{code:"READINESS_DEGRADED",recovery:null,text:f("fleet-readiness-degraded")}:null}let Eh={sessions:[],cells:[],nodeGroups:[],localNodeId:"",localFresh:!1,refreshedAt:0};function wv(){return Eh}function bb(e={}){return Eh={sessions:Array.isArray(e.sessions)?e.sessions:[],cells:Array.isArray(e.cells)?e.cells:[],nodeGroups:Array.isArray(e.nodeGroups)?e.nodeGroups:[],localNodeId:typeof e.localNodeId=="string"?e.localNodeId:"",localFresh:e.localFresh===!0,refreshedAt:Number.isFinite(e.refreshedAt)?e.refreshedAt:0},Eh}const so=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function Xk({onPick:e,token:t,onSettings:n,onOpenVlSession:s,hostByRoute:o={},onDesignateCell:a,onClearHostCell:u}){const[d,p]=Yn(),m=zf(t),[v,y]=k.useState(null),[b,S]=k.useState(null),[x,E]=k.useState(""),[w,N]=k.useState(""),[C,L]=k.useState({bind:"127.0.0.1",port:""}),[I,G]=k.useState(""),[K,Y]=k.useState([]),[Q,W]=k.useState([]),[X,H]=k.useState(!1),[$,R]=k.useState(null),[O,F]=k.useState({}),[A,T]=k.useState(new Set),[j,z]=k.useState(null),[M,D]=k.useState(null),{pins:B,orders:U,togglePin:se,removePin:ee,pinError:de,retryPinPersist:ve,clearPinError:fe,viewFor:pe,updateView:Ve,canMoveRoster:ut,moveRoster:vt,stepRoster:je}=Ff(),Ct=J=>o[wa(J)]||{};function dn(J,Ne,Ue,Oe){const Le=db(Ue);if(Le==="addPin"){se(J.key);return}if(Le==="designate"){a&&a(Ne.cell,Oe);return}if(Le==="clearAndUnpin"){if(!u)return;Promise.resolve(u(Oe)).then(Et=>{Et&&ee(J.key)})}}const{groupsFor:gn,moveNode:Yt,stepNode:xt,nodeKey:Ot}=cb(),Ut=gn(m);k.useEffect(()=>{bb({sessions:v||[],cells:K,nodeGroups:m,localNodeId:I})},[v,K,m,I]),k.useEffect(()=>{const J=new Map;for(const Ne of K)J.set(so(Ne.cell),!!Ne.boot);for(const Ne of m){const Ue=Ne.route||[Ne.name];for(const Oe of Ne.cells||[])J.set(so(Oe.cell,Ue),!!Oe.boot)}F(Ne=>{let Ue=!1;const Oe={...Ne};for(const[Le,Et]of Object.entries(Ne))J.has(Le)&&J.get(Le)===Et&&(delete Oe[Le],Ue=!0);return Ue?Oe:Ne})},[K,m]);async function Nt(){try{const Le=await(await on("/api/sessions",t)).json();Le.error?(S(Le.error),y([])):(S(null),y(Le.sessions||[]))}catch(Oe){S(String(Oe)),y([])}let J=null,Ne=null;try{J=await Xs(t)}catch(Oe){Ne=Oe}const Ue=Bf({fs:J,error:Ne});Ue.kind==="data"?(Y(Ue.cells),W(Ue.capabilities),H(!1),R(null)):Ue.kind==="stale"?(H(!0),R(null)):(Y([]),W([]),H(!1),R(Ue.reason||""))}k.useEffect(()=>{Nt(),on("/api/config",t).then(Ne=>Ne.json()).then(Ne=>{N(Ne.version||""),L({bind:Ne.bind||"127.0.0.1",port:Ne.port||""}),G(vo.test(String(Ne.instanceId||""))?Ne.instanceId:"")}).catch(()=>{});const J=setInterval(Nt,4e3);return()=>clearInterval(J)},[]);async function Dt(){if(!C.port)return;const J=`http://${C.bind}:${C.port}/#token=${t}`;try{await navigator.clipboard.writeText(J)}catch{}}function At(J,Ne,Ue){const Oe=so(J,Ne);F(Le=>({...Le,[Oe]:!!Ue}))}function jt(J,Ne=[]){const Ue=so(J.cell,Ne);return Object.prototype.hasOwnProperty.call(O,Ue)?O[Ue]:!!J.boot}async function hn(J,Ne,Ue=[]){J.stopPropagation();const Oe=so(Ne.cell,Ue),Le=!jt(Ne,Ue);At(Ne.cell,Ue,Le),T(Et=>new Set(Et).add(Oe));try{await Fy(t,{cell:Ne.cell,enabled:Le},Ue),Ue.length||Y(Et=>Et.map(kt=>kt.cell===Ne.cell?{...kt,boot:Le}:kt))}catch(Et){F(kt=>{const V={...kt};return delete V[Oe],V}),S(String((Et==null?void 0:Et.message)||Et))}finally{T(Et=>{const kt=new Set(Et);return kt.delete(Oe),kt})}}async function re(J){if(!j)return;const{cell:Ne}=j,Ue=Array.isArray(j.route)?j.route:[];if(J.action==="up"){const Oe=await Lf(t,{cell:Ne,boot:!!J.boot,...J.engine?{engine:J.engine}:{},...J.model!==void 0?{model:J.model}:{},...J.permissionPolicy?{permissionPolicy:J.permissionPolicy}:{}},Ue),Le=Vf(Oe);Le&&S(Le.text),At(Ne,Ue,!!J.boot)}else await lc(t,{cell:Ne,boot:!!J.boot},Ue),J.boot&&At(Ne,Ue,!1);Nt()}async function Qe(J,Ne=[]){try{await Af(t,J,Ne)}catch{return}Nt()}async function me(J,Ne,Ue=[]){try{await Wy(t,J,Ne,Ue)}catch{return}Nt()}async function Ge(J){if(!(!(J!=null&&J.direct)||M)){D(J.name);try{await If(t,J.name,J.tunnelStatus==="up"?"down":"up")}catch{}D(null)}}async function ct(J){if(!(J!=null&&J.direct))return;const Ne=window.prompt(f("rename-node-prompt"),J.label||J.name);if(Ne===null)return;const Ue=String(Ne).trim();if(!_o(Ue)){window.alert(f("rename-node-invalid"));return}try{await Yy(t,J.name,Ue)}catch(Oe){window.alert(String((Oe==null?void 0:Oe.message)||Oe))}}const oe=k.useMemo(()=>new Map((v||[]).map(J=>[J.name,J])),[v]),ie=k.useMemo(()=>new Set(K.map(J=>J.tmuxSession)),[K]),_e=k.useMemo(()=>(v||[]).filter(J=>!ie.has(J.name)),[v,ie]),be=k.useMemo(()=>Wf(K,_e,oe),[K,_e,oe]),ke=pe("local"),it=k.useMemo(()=>qs(be,B,ke.filter,ms(U,"local")).filter(J=>av(J,x)),[be,B,ke.filter,x,U]),ht=Ut.reduce((J,Ne)=>J+(Ne.cells||[]).length+(Ne.unmanaged||[]).filter(Ue=>!Ue.technical).length,0),dt=qs(be,B,"all",ms(U,"local")).length+ht,Rt=be.filter(J=>J.live).length+Ut.reduce((J,Ne)=>J+fc(Ne).rawItems.filter(Ue=>Ue.live).length,0),wt=(v||[]).filter(J=>J.attached).length+Ut.reduce((J,Ne)=>J+(Ne.sessions||[]).filter(Ue=>Ue.attached).length,0),_t=Math.min(wt,Rt),zt=C.port?`${C.bind}:${C.port}`:C.bind;function Je(J,Ne=null,Ue=be){var Me,De;const Oe=Array.isArray(Ne==null?void 0:Ne.route)?Ne.route:[],Le=Oe.join("/"),Et=Le||"local",kt=Oe.length?Ne==null?void 0:Ne.instanceId:I,V=(Ee,Xe)=>e({session:Ee,...Le?{node:Le}:{},...vo.test(String(kt||""))?{ownerId:kt}:{},...typeof Xe=="string"&&Xe?{cellName:Xe}:{}}),ae=ut;if(J.type==="cell"){const Ee=J.value,Xe=Ct(Oe),yt=wh({hostCell:Xe.hostCell??null,pins:B,item:J}),$t=Oe.length?((Ne==null?void 0:Ne.sessions)||[]).find(Sn=>Sn.name===Ee.tmuxSession):oe.get(Ee.tmuxSession),Be=Sh(yt,Xe.hostLease??null),te=Ee.degraded?f("cell-degraded"):J.working?J.subtitle:Ee.tmux?f("cell-idle"):f("cell-off"),Se=Be?`${te} · ${f(Be)}`:te,Te=Oe.length===0||((Ne==null?void 0:Ne.capabilities)||[]).includes(Ee.active?"down":"up"),tt=Oe.length===0?Q.includes("boot"):((Ne==null?void 0:Ne.capabilities)||[]).includes("boot"),nt=jt(Ee,Oe),St=so(Ee.cell,Oe),It=`${f(nt?"boot-disable":"boot-enable")} ${Ee.cell}`;return l.jsxs("div",{className:"nc-mcard","data-roster-key":J.key,"data-position":Et,children:[l.jsx(Yi,{position:Et,itemKey:J.key,label:Ee.cell,canMove:ae,onMove:(Sn,ri)=>vt(Et,Sn,ri,Ue),onStep:Sn=>je(Et,J.key,Sn,Ue)}),l.jsxs("button",{className:"nc-mcard-main",onClick:()=>Ee.tmux&&V(Ee.tmuxSession,Ee.cell),title:Se,"aria-label":`${Ee.cell}, ${Se}`,children:[l.jsx("span",{className:`dot ${Ee.degraded?"warn":Ee.tmux?`on${J.working?" working":""}`:""}`}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsx("b",{children:Ee.cell}),l.jsx("small",{title:J.subtitle,children:J.subtitle})]})]}),J.activity?l.jsx("span",{className:"nc-rel",children:go(J.activity)}):null,J.fresh&&((Me=$t==null?void 0:$t.outbox)==null?void 0:Me.count)>0&&l.jsx("span",{className:"nc-badge",title:f("new-files-outbox"),children:$t.outbox.count}),l.jsx("button",{className:`nc-act pin${yt==="live"?" live":yt==="favorite"?" on":""}`,"aria-label":`${yt==="live"?"live host":f("pin")} ${Ee.cell}`,title:yt==="live"?"live host":f("pin"),onClick:()=>dn(J,Ee,yt,Oe),children:yt==="none"?"☆":"★"}),tt&&l.jsx("button",{className:`nc-act boot${nt?" on":""}`,disabled:A.has(St),onClick:Sn=>hn(Sn,Ee,Oe),title:It,"aria-label":It,children:l.jsx(lt,{name:"boot",size:16})}),Te&&l.jsx("button",{className:`nc-act power${Ee.tmux?" on":""}${Ee.degraded?" warn":""}`,onClick:()=>z(Oe.length?{...Ee,boot:nt,route:Oe,availableEngines:(Ne==null?void 0:Ne.engines)||[]}:{...Ee,boot:nt}),title:Ee.active?f("power-off"):f("power-on"),"aria-label":`${Ee.active?f("power-off"):f("power-on")} ${Ee.cell}`,children:l.jsx(lt,{name:"power",size:16})})]},J.key)}const ye=J.value;return l.jsxs("div",{className:"nc-mcard","data-roster-key":J.key,"data-position":Et,children:[l.jsx(Yi,{position:Et,itemKey:J.key,label:ye.name,canMove:ae,onMove:(Ee,Xe)=>vt(Et,Ee,Xe,Ue),onStep:Ee=>je(Et,J.key,Ee,Ue)}),l.jsxs("button",{className:"nc-mcard-main",onClick:()=>V(ye.name),children:[l.jsx("span",{className:ye.attached?"dot on":"dot"}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsx("b",{children:ye.name}),l.jsx("small",{children:ye.preview?ye.preview:ye.cmd?ye.cmd:f("windows").replace("{n}",String(ye.windows||0))})]})]}),J.activity?l.jsx("span",{className:"nc-rel",children:go(J.activity)}):null,J.fresh&&((De=ye.outbox)==null?void 0:De.count)>0&&l.jsx("span",{className:"nc-badge",title:f("new-files-outbox"),children:ye.outbox.count}),l.jsx("button",{className:`nc-act pin${B.includes(J.key)?" on":""}`,"aria-label":`${f("pin")} ${ye.name}`,title:f("pin"),onClick:()=>se(J.key),children:B.includes(J.key)?"★":"☆"}),l.jsx("button",{className:`nc-act technical${ye.technical?" on":""}`,title:ye.technical?f("mark-normal"):f("mark-technical"),"aria-label":`${ye.technical?f("mark-normal"):f("mark-technical")} ${ye.name}`,onClick:()=>me(ye.name,!ye.technical,Oe),children:"T"}),l.jsx("button",{className:"nc-menu",title:f("terminate"),"aria-label":`${f("terminate")} ${ye.name}`,onClick:()=>{window.confirm(f("terminate-confirm").replace("{name}",ye.name))&&Qe(ye.name,Oe)},children:"⋯"})]},J.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:[f("fleet-tmux")," · ",Rt," ",f("sessions"),_t>0&&` · ${_t} attached`]}),l.jsxs("span",{className:"nc-head-actions",children:[l.jsx("button",{className:"nc-refresh",onClick:()=>n("nodes",!1),title:f("settings"),children:l.jsx(lt,{name:"gear",size:18})}),l.jsx("button",{className:"nc-refresh",onClick:Nt,title:f("refresh"),children:l.jsx(lt,{name:"refresh",size:18})})]})]}),l.jsxs("main",{className:"nc-home-scroll",children:[l.jsx(hb,{pinError:de,onRetry:ve,onDismiss:fe}),dt>8&&l.jsx("input",{className:"nc-filter",type:"search",placeholder:f("filter-placeholder"),"aria-label":f("filter-placeholder"),value:x,onChange:J=>E(J.target.value)}),b&&l.jsx("div",{className:"nc-err",children:b}),X&&l.jsx("div",{className:"nc-set-hint nc-fleet-stale",role:"status",children:f("fleet-stale")}),$!==null&&l.jsxs("div",{className:"nc-set-hint nc-fleet-off",role:"status",children:[f("fleet-off"),$?` (${$})`:""]}),l.jsxs("section",{className:"nc-group","data-position":"local",children:[l.jsx(wd,{label:f("position-local"),count:it.length,state:ke,dotClass:"on",onToggle:()=>Ve("local",{open:!ke.open}),onFilter:J=>Ve("local",{filter:J})}),ke.open&&it.map(J=>Je(J,null,be)),ke.open&&v===null&&l.jsx("div",{className:"nc-empty",children:f("loading-fleet")}),ke.open&&v!==null&&it.length===0&&!b&&l.jsx("div",{className:"nc-empty",children:x?f("no-match").replace("{q}",x):f("no-sessions-short")})]}),Ut.map(J=>{const Ne=fb(J.health,{passive:"warn"}),Ue=J.fleetState==="stale"?f("fleet-stale"):J.fleetState==="disabled"?f("fleet-off"):"",Oe=J.fleetState==="stale"?"warn":Ne||(J.status==="up"?"on":J.status==="passive"?"":"warn"),Le=[J.health?dc(J.health):J.status==="up"?"":fs(J),Ue].filter(Boolean).join(" · "),kt=(J.route&&J.route.length?J.route:[J.name]).join("/"),V=pe(kt);if(J.kind==="vl")return l.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":kt,"data-node-order-key":Ot(J),children:[l.jsx(wd,{label:J.label||J.name,count:J.sessions.length,state:V,dotClass:Oe,dotTitle:Le,detail:J.status==="up"?"":fs(J),onToggle:()=>Ve(kt,{open:!V.open}),onFilter:Ee=>Ve(kt,{filter:Ee})}),J.status==="up"&&V.open&&J.sessions.map(Ee=>l.jsx("div",{className:"nc-mcard nc-vl-session-row",children:l.jsxs("button",{className:"nc-mcard-main",onClick:()=>s&&s(J.peer),"aria-label":`${J.label||J.name}: ${Ee.name}`,children:[l.jsx("span",{className:"dot on"}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsx("b",{children:Ee.name}),l.jsx("small",{children:f("vl-events-title")})]})]})},Ee.key)),J.status==="up"&&V.open&&J.sessions.length===0&&l.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]},`nodo-vl-${kt}-${J.name}`);const{rawItems:ae}=fc(J),ye=qs(ae,B,V.filter,ms(U,kt)).filter(Ee=>av(Ee,x)),Me=J.direct&&J.health&&J.health.managed!==!1?l.jsx("button",{type:"button",className:`nc-act power${J.tunnelStatus==="up"?" on":""}`,disabled:M===J.name,title:J.tunnelStatus==="up"?f("power-off"):f("power-on"),"aria-label":`${J.tunnelStatus==="up"?f("power-off"):f("power-on")} ${J.label||J.name}`,onClick:()=>Ge(J),children:l.jsx(lt,{name:"power",size:15})}):null,De=l.jsxs("span",{className:"nc-node-actions",children:[l.jsx(Yi,{scope:"node",position:"nodes",itemKey:Ot(J),label:J.label||J.name,onMove:(Ee,Xe)=>Yt(Ee,Xe,m),onStep:Ee=>xt(Ot(J),Ee,m)}),J.direct&&l.jsx("button",{type:"button",className:"nc-node-rename",title:f("rename-node"),"aria-label":`${f("rename-node")} ${J.label||J.name}`,onClick:()=>ct(J),children:"✎"}),Me]});return l.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":kt,"data-node-order-key":Ot(J),children:[l.jsx(wd,{label:J.label||J.name,count:ye.length,state:V,dotClass:Oe,dotTitle:Le,detail:J.status==="up"?Ue:J.health&&dc(J.health)||fs(J),onToggle:()=>Ve(kt,{open:!V.open}),onFilter:Ee=>Ve(kt,{filter:Ee}),onRename:J.direct?()=>ct(J):null,action:De}),J.status==="up"&&V.open&&ye.map(Ee=>Je(Ee,J,ae)),J.status==="up"&&V.open&&ye.length===0&&l.jsx("div",{className:"nc-empty",children:x?f("no-match").replace("{q}",x):f("no-sessions-short")})]},`nodo-${kt}`)}),l.jsxs("footer",{className:"nc-home-foot",onClick:Dt,title:f("copy-url"),children:[l.jsxs("span",{className:"nc-home-meta",children:[w&&l.jsxs("span",{className:"nc-home-version",children:["v",w]}),l.jsxs("span",{className:"nc-home-endpoint",children:[zt," · ",f("ssh-only")]})]}),l.jsx("span",{className:"nc-lang",onClick:J=>J.stopPropagation(),children:eb.map((J,Ne)=>l.jsxs("span",{children:[Ne>0&&" · ",l.jsx("button",{className:`nc-lang-btn${d===J?" on":""}`,onClick:()=>p(J),title:J,children:J.toUpperCase()})]},J))})]})]}),l.jsx("button",{className:"nc-fab",onClick:()=>n("fleet",!0),title:f("fleet-new-cell"),"aria-label":f("fleet-new-cell"),children:"+"}),j&&l.jsx(uc,{cell:j,token:t,route:Array.isArray(j.route)?j.route:[],onConfirm:re,onClose:()=>z(null)})]})}function wd({label:e,count:t,state:n,dotClass:s="",dotTitle:o="",detail:a="",onToggle:u,onFilter:d,onRename:p=null,action:m=null}){return l.jsxs("div",{className:"nc-mobile-position-head",onContextMenu:p?v=>{v.preventDefault(),p()}:void 0,children:[l.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:u,"aria-expanded":n.open,"aria-label":`${e} · ${f("node-sessions").replace("{n}",String(t))}`,children:[l.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:n.open?"⌄":"›"}),l.jsx("span",{className:`dot ${s}`,title:o}),l.jsxs("span",{className:"nc-mobile-position-copy",children:[l.jsx("b",{children:e}),l.jsx("small",{children:a||f("node-sessions").replace("{n}",String(t))})]})]}),l.jsxs("select",{className:"nc-mobile-position-filter",value:n.filter,"aria-label":`${e} · ${f("filter-placeholder")}`,title:f(`view-${n.filter}`),onChange:v=>d(v.target.value),children:[l.jsx("option",{value:"all",children:f("view-all")}),l.jsx("option",{value:"pinned",children:f("view-pinned")}),l.jsx("option",{value:"active",children:f("view-active")}),l.jsx("option",{value:"off",children:f("view-off")}),l.jsx("option",{value:"technical",children:f("view-technical")})]}),m]})}/**
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 wb=Object.defineProperty,Qk=Object.getOwnPropertyDescriptor,Jk=(e,t)=>{for(var n in t)wb(e,n,{get:t[n],enumerable:!0})},an=(e,t,n,s)=>{for(var o=s>1?void 0:s?Qk(t,n):t,a=e.length-1,u;a>=0;a--)(u=e[a])&&(o=(s?u(t,n,o):u(o))||o);return s&&o&&wb(t,n,o),o},Fe=(e,t)=>(n,s)=>t(n,s,e),Sv="Terminal input",Nh={get:()=>Sv,set:e=>Sv=e},xv="Too much output to announce, navigate to rows manually to read",jh={get:()=>xv,set:e=>xv=e};function Zk(e){return e.replace(/\r?\n/g,"\r")}function e1(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function t1(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function n1(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");Sb(o,t,n,s)}}function Sb(e,t,n,s){e=Zk(e),e=e1(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function xb(e,t,n){let s=n.getBoundingClientRect(),o=e.clientX-s.left-10,a=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${a}px`,t.style.zIndex="1000",t.focus()}function kv(e,t,n,s,o){xb(e,t,n),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Us(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function jc(e,t=0,n=e.length){let s="";for(let o=t;o<n;++o){let a=e[o];a>65535?(a-=65536,s+=String.fromCharCode((a>>10)+55296)+String.fromCharCode(a%1024+56320)):s+=String.fromCharCode(a)}return s}var i1=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,o=0;if(this._interim){let a=e.charCodeAt(o++);56320<=a&&a<=57343?t[s++]=(this._interim-55296)*1024+a-56320+65536:(t[s++]=this._interim,t[s++]=a),this._interim=0}for(let a=o;a<n;++a){let u=e.charCodeAt(a);if(55296<=u&&u<=56319){if(++a>=n)return this._interim=u,s;let d=e.charCodeAt(a);56320<=d&&d<=57343?t[s++]=(u-55296)*1024+d-56320+65536:(t[s++]=u,t[s++]=d);continue}u!==65279&&(t[s++]=u)}return s}},s1=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,o,a,u,d,p=0,m=0;if(this.interim[0]){let b=!1,S=this.interim[0];S&=(S&224)===192?31:(S&240)===224?15:7;let x=0,E;for(;(E=this.interim[++x]&63)&&x<4;)S<<=6,S|=E;let w=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,N=w-x;for(;m<N;){if(m>=n)return 0;if(E=e[m++],(E&192)!==128){m--,b=!0;break}else this.interim[x++]=E,S<<=6,S|=E&63}b||(w===2?S<128?m--:t[s++]=S:w===3?S<2048||S>=55296&&S<=57343||S===65279||(t[s++]=S):S<65536||S>1114111||(t[s++]=S)),this.interim.fill(0)}let v=n-4,y=m;for(;y<n;){for(;y<v&&!((o=e[y])&128)&&!((a=e[y+1])&128)&&!((u=e[y+2])&128)&&!((d=e[y+3])&128);)t[s++]=o,t[s++]=a,t[s++]=u,t[s++]=d,y+=4;if(o=e[y++],o<128)t[s++]=o;else if((o&224)===192){if(y>=n)return this.interim[0]=o,s;if(a=e[y++],(a&192)!==128){y--;continue}if(p=(o&31)<<6|a&63,p<128){y--;continue}t[s++]=p}else if((o&240)===224){if(y>=n)return this.interim[0]=o,s;if(a=e[y++],(a&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=a,s;if(u=e[y++],(u&192)!==128){y--;continue}if(p=(o&15)<<12|(a&63)<<6|u&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[s++]=p}else if((o&248)===240){if(y>=n)return this.interim[0]=o,s;if(a=e[y++],(a&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=a,s;if(u=e[y++],(u&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=a,this.interim[2]=u,s;if(d=e[y++],(d&192)!==128){y--;continue}if(p=(o&7)<<18|(a&63)<<12|(u&63)<<6|d&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},kb="",Ks=" ",La=class Cb{constructor(){this.fg=0,this.bg=0,this.extended=new gc}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Cb;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},gc=class Eb{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Eb(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ri=class Nb extends La{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new gc,this.combinedData=""}static fromCharData(t){let n=new Nb;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Us(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(s-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Cv="di$target",Rh="di$dependencies",Sd=new Map;function r1(e){return e[Rh]||[]}function Ln(e){if(Sd.has(e))return Sd.get(e);let t=function(n,s,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");o1(t,n,o)};return t._id=e,Sd.set(e,t),t}function o1(e,t,n){t[Cv]===t?t[Rh].push({id:e,index:n}):(t[Rh]=[{id:e,index:n}],t[Cv]=t)}var Gn=Ln("BufferService"),jb=Ln("CoreMouseService"),Nr=Ln("CoreService"),a1=Ln("CharsetService"),Yf=Ln("InstantiationService"),Rb=Ln("LogService"),Xn=Ln("OptionsService"),Pb=Ln("OscLinkService"),l1=Ln("UnicodeService"),Aa=Ln("DecorationService"),Ph=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var v;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,a=new Ri,u=n.getTrimmedLength(),d=-1,p=-1,m=!1;for(let y=0;y<u;y++)if(!(p===-1&&!n.hasContent(y))){if(n.loadCell(y,a),a.hasExtendedAttrs()&&a.extended.urlId)if(p===-1){p=y,d=a.extended.urlId;continue}else m=a.extended.urlId!==d;else p!==-1&&(m=!0);if(m||p!==-1&&y===u-1){let b=(v=this._oscLinkService.getLinkData(d))==null?void 0:v.uri;if(b){let S={start:{x:p+1,y:e},end:{x:y+(!m&&y===u-1?1:0),y:e}},x=!1;if(!(o!=null&&o.allowNonHttpProtocols))try{let E=new URL(b);["http:","https:"].includes(E.protocol)||(x=!0)}catch{x=!0}x||s.push({text:b,range:S,activate:(E,w)=>o?o.activate(E,w,S):c1(E,w),hover:(E,w)=>{var N;return(N=o==null?void 0:o.hover)==null?void 0:N.call(o,E,w,S)},leave:(E,w)=>{var N;return(N=o==null?void 0:o.leave)==null?void 0:N.call(o,E,w,S)}})}m=!1,a.hasExtendedAttrs()&&a.extended.urlId?(p=y,d=a.extended.urlId):(p=-1,d=-1)}}t(s)}};Ph=an([Fe(0,Gn),Fe(1,Xn),Fe(2,Pb)],Ph);function c1(e,t){if(confirm(`Do you want to navigate to ${t}?
52
-
53
- WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Rc=Ln("CharSizeService"),gs=Ln("CoreBrowserService"),Gf=Ln("MouseService"),vs=Ln("RenderService"),u1=Ln("SelectionService"),Lb=Ln("CharacterJoinerService"),xo=Ln("ThemeService"),Ab=Ln("LinkProviderService"),d1=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Ev.isErrorNoTelemetry(e)?new Ev(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(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},h1=new d1;function tc(e){f1(e)||h1.onUnexpectedError(e)}var Lh="Canceled";function f1(e){return e instanceof p1?!0:e instanceof Error&&e.name===Lh&&e.message===Lh}var p1=class extends Error{constructor(){super(Lh),this.name=this.message}};function m1(e){return new Error(`Illegal argument: ${e}`)}var Ev=class Ah extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Ah)return t;let n=new Ah;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Mh=class Mb extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Mb.prototype)}};function fi(e,t=0){return e[e.length-(1+t)]}var g1;(e=>{function t(a){return a<0}e.isLessThan=t;function n(a){return a<=0}e.isLessThanOrEqual=n;function s(a){return a>0}e.isGreaterThan=s;function o(a){return a===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(g1||(g1={}));function v1(e,t){let n=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(n,arguments))),o}}var Tb;(e=>{function t(I){return I&&typeof I=="object"&&typeof I[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*o(I){yield I}e.single=o;function a(I){return t(I)?I:o(I)}e.wrap=a;function u(I){return I||n}e.from=u;function*d(I){for(let G=I.length-1;G>=0;G--)yield I[G]}e.reverse=d;function p(I){return!I||I[Symbol.iterator]().next().done===!0}e.isEmpty=p;function m(I){return I[Symbol.iterator]().next().value}e.first=m;function v(I,G){let K=0;for(let Y of I)if(G(Y,K++))return!0;return!1}e.some=v;function y(I,G){for(let K of I)if(G(K))return K}e.find=y;function*b(I,G){for(let K of I)G(K)&&(yield K)}e.filter=b;function*S(I,G){let K=0;for(let Y of I)yield G(Y,K++)}e.map=S;function*x(I,G){let K=0;for(let Y of I)yield*G(Y,K++)}e.flatMap=x;function*E(...I){for(let G of I)yield*G}e.concat=E;function w(I,G,K){let Y=K;for(let Q of I)Y=G(Y,Q);return Y}e.reduce=w;function*N(I,G,K=I.length){for(G<0&&(G+=I.length),K<0?K+=I.length:K>I.length&&(K=I.length);G<K;G++)yield I[G]}e.slice=N;function C(I,G=Number.POSITIVE_INFINITY){let K=[];if(G===0)return[K,I];let Y=I[Symbol.iterator]();for(let Q=0;Q<G;Q++){let W=Y.next();if(W.done)return[K,e.empty()];K.push(W.value)}return[K,{[Symbol.iterator](){return Y}}]}e.consume=C;async function L(I){let G=[];for await(let K of I)G.push(K);return Promise.resolve(G)}e.asyncToArray=L})(Tb||(Tb={}));function Cr(e){if(Tb.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function _1(...e){return Qt(()=>Cr(e))}function Qt(e){return{dispose:v1(()=>{e()})}}var Db=class Ib{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{Cr(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Ib.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Db.DISABLE_DISPOSED_WARNING=!1;var Ys=Db,gt=class{constructor(){this._store=new Ys,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)}};gt.None=Object.freeze({dispose(){}});var yo=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},ps=typeof window=="object"?window:globalThis,Th=class Dh{constructor(t){this.element=t,this.next=Dh.Undefined,this.prev=Dh.Undefined}};Th.Undefined=new Th(void 0);var en=Th,Nv=class{constructor(){this._first=en.Undefined,this._last=en.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===en.Undefined}clear(){let e=this._first;for(;e!==en.Undefined;){let t=e.next;e.prev=en.Undefined,e.next=en.Undefined,e=t}this._first=en.Undefined,this._last=en.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new en(e);if(this._first===en.Undefined)this._first=n,this._last=n;else if(t){let o=this._last;this._last=n,n.prev=o,o.next=n}else{let o=this._first;this._first=n,n.next=o,o.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==en.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==en.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==en.Undefined&&e.next!==en.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===en.Undefined&&e.next===en.Undefined?(this._first=en.Undefined,this._last=en.Undefined):e.next===en.Undefined?(this._last=this._last.prev,this._last.next=en.Undefined):e.prev===en.Undefined&&(this._first=this._first.next,this._first.prev=en.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==en.Undefined;)yield e.element,e=e.next}},y1=globalThis.performance&&typeof globalThis.performance.now=="function",b1=class Ob{static create(t){return new Ob(t)}constructor(t){this._now=y1&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},On;(e=>{e.None=()=>gt.None;function t($,R){return y($,()=>{},0,void 0,!0,void 0,R)}e.defer=t;function n($){return(R,O=null,F)=>{let A=!1,T;return T=$(j=>{if(!A)return T?T.dispose():A=!0,R.call(O,j)},null,F),A&&T.dispose(),T}}e.once=n;function s($,R,O){return m((F,A=null,T)=>$(j=>F.call(A,R(j)),null,T),O)}e.map=s;function o($,R,O){return m((F,A=null,T)=>$(j=>{R(j),F.call(A,j)},null,T),O)}e.forEach=o;function a($,R,O){return m((F,A=null,T)=>$(j=>R(j)&&F.call(A,j),null,T),O)}e.filter=a;function u($){return $}e.signal=u;function d(...$){return(R,O=null,F)=>{let A=_1(...$.map(T=>T(j=>R.call(O,j))));return v(A,F)}}e.any=d;function p($,R,O,F){let A=O;return s($,T=>(A=R(A,T),A),F)}e.reduce=p;function m($,R){let O,F={onWillAddFirstListener(){O=$(A.fire,A)},onDidRemoveLastListener(){O==null||O.dispose()}},A=new Pe(F);return R==null||R.add(A),A.event}function v($,R){return R instanceof Array?R.push($):R&&R.add($),$}function y($,R,O=100,F=!1,A=!1,T,j){let z,M,D,B=0,U,se={leakWarningThreshold:T,onWillAddFirstListener(){z=$(de=>{B++,M=R(M,de),F&&!D&&(ee.fire(M),M=void 0),U=()=>{let ve=M;M=void 0,D=void 0,(!F||B>1)&&ee.fire(ve),B=0},typeof O=="number"?(clearTimeout(D),D=setTimeout(U,O)):D===void 0&&(D=0,queueMicrotask(U))})},onWillRemoveListener(){A&&B>0&&(U==null||U())},onDidRemoveLastListener(){U=void 0,z.dispose()}},ee=new Pe(se);return j==null||j.add(ee),ee.event}e.debounce=y;function b($,R=0,O){return e.debounce($,(F,A)=>F?(F.push(A),F):[A],R,void 0,!0,void 0,O)}e.accumulate=b;function S($,R=(F,A)=>F===A,O){let F=!0,A;return a($,T=>{let j=F||!R(T,A);return F=!1,A=T,j},O)}e.latch=S;function x($,R,O){return[e.filter($,R,O),e.filter($,F=>!R(F),O)]}e.split=x;function E($,R=!1,O=[],F){let A=O.slice(),T=$(M=>{A?A.push(M):z.fire(M)});F&&F.add(T);let j=()=>{A==null||A.forEach(M=>z.fire(M)),A=null},z=new Pe({onWillAddFirstListener(){T||(T=$(M=>z.fire(M)),F&&F.add(T))},onDidAddFirstListener(){A&&(R?setTimeout(j):j())},onDidRemoveLastListener(){T&&T.dispose(),T=null}});return F&&F.add(z),z.event}e.buffer=E;function w($,R){return(O,F,A)=>{let T=R(new C);return $(function(j){let z=T.evaluate(j);z!==N&&O.call(F,z)},void 0,A)}}e.chain=w;let N=Symbol("HaltChainable");class C{constructor(){this.steps=[]}map(R){return this.steps.push(R),this}forEach(R){return this.steps.push(O=>(R(O),O)),this}filter(R){return this.steps.push(O=>R(O)?O:N),this}reduce(R,O){let F=O;return this.steps.push(A=>(F=R(F,A),F)),this}latch(R=(O,F)=>O===F){let O=!0,F;return this.steps.push(A=>{let T=O||!R(A,F);return O=!1,F=A,T?A:N}),this}evaluate(R){for(let O of this.steps)if(R=O(R),R===N)break;return R}}function L($,R,O=F=>F){let F=(...z)=>j.fire(O(...z)),A=()=>$.on(R,F),T=()=>$.removeListener(R,F),j=new Pe({onWillAddFirstListener:A,onDidRemoveLastListener:T});return j.event}e.fromNodeEventEmitter=L;function I($,R,O=F=>F){let F=(...z)=>j.fire(O(...z)),A=()=>$.addEventListener(R,F),T=()=>$.removeEventListener(R,F),j=new Pe({onWillAddFirstListener:A,onDidRemoveLastListener:T});return j.event}e.fromDOMEventEmitter=I;function G($){return new Promise(R=>n($)(R))}e.toPromise=G;function K($){let R=new Pe;return $.then(O=>{R.fire(O)},()=>{R.fire(void 0)}).finally(()=>{R.dispose()}),R.event}e.fromPromise=K;function Y($,R){return $(O=>R.fire(O))}e.forward=Y;function Q($,R,O){return R(O),$(F=>R(F))}e.runAndSubscribe=Q;class W{constructor(R,O){this._observable=R,this._counter=0,this._hasChanged=!1;let F={onWillAddFirstListener:()=>{R.addObserver(this)},onDidRemoveLastListener:()=>{R.removeObserver(this)}};this.emitter=new Pe(F),O&&O.add(this.emitter)}beginUpdate(R){this._counter++}handlePossibleChange(R){}handleChange(R,O){this._hasChanged=!0}endUpdate(R){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function X($,R){return new W($,R).emitter.event}e.fromObservable=X;function H($){return(R,O,F)=>{let A=0,T=!1,j={beginUpdate(){A++},endUpdate(){A--,A===0&&($.reportChanges(),T&&(T=!1,R.call(O)))},handlePossibleChange(){},handleChange(){T=!0}};$.addObserver(j),$.reportChanges();let z={dispose(){$.removeObserver(j)}};return F instanceof Ys?F.add(z):Array.isArray(F)&&F.push(z),z}}e.fromObservableLight=H})(On||(On={}));var Ih=class Oh{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Oh._idPool++}`,Oh.all.add(this)}start(t){this._stopWatch=new b1,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Ih.all=new Set,Ih._idPool=0;var w1=Ih,S1=-1,Bb=class zb{constructor(t,n,s=(zb._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n<s)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[a,u]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${u}):`;console.warn(d),console.warn(a);let p=new C1(d,a);this._errorHandler(p)}return()=>{let a=this._stacks.get(t.value)||0;this._stacks.set(t.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,o]of this._stacks)(!t||n<o)&&(t=[s,o],n=o);return t}};Bb._idPool=1;var x1=Bb,k1=class $b{constructor(t){this.value=t}static create(){let t=new Error;return new $b(t.stack??"")}print(){console.warn(this.value.split(`
58
- `).slice(2).join(`
59
- `))}},C1=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},E1=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},N1=0,xd=class{constructor(e){this.value=e,this.id=N1++}},j1=2,R1,Pe=class{constructor(e){var t,n,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new x1((e==null?void 0:e.onListenerError)??tc,((n=this._options)==null?void 0:n.leakWarningThreshold)??S1):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new w1(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var e,t,n,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||n.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,n)=>{var u,d,p,m,v;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let y=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(y);let b=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],S=new E1(`${y}. HINT: Stack shows most frequent listener (${b[1]}-times)`,b[0]);return(((u=this._options)==null?void 0:u.onListenerError)||tc)(S),gt.None}if(this._disposed)return gt.None;t&&(e=e.bind(t));let s=new xd(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=k1.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof xd?(this._deliveryQueue??(this._deliveryQueue=new P1),this._listeners=[this._listeners,s]):this._listeners.push(s):((p=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||p.call(d,this),this._listeners=s,(v=(m=this._options)==null?void 0:m.onDidAddFirstListener)==null||v.call(m,this)),this._size++;let a=Qt(()=>{o==null||o(),this._removeListener(s)});return n instanceof Ys?n.add(a):Array.isArray(n)&&n.push(a),a}),this._event}_removeListener(e){var o,a,u,d;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(d=(u=this._options)==null?void 0:u.onDidRemoveLastListener)==null||d.call(u,this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let s=this._deliveryQueue.current===this;if(this._size*j1<=t.length){let p=0;for(let m=0;m<t.length;m++)t[m]?t[p++]=t[m]:s&&(this._deliveryQueue.end--,p<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=p}}_deliver(e,t){var s;if(!e)return;let n=((s=this._options)==null?void 0:s.onListenerError)||tc;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,n,s,o;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof xd)this._deliver(this._listeners,e);else{let a=this._deliveryQueue;a.enqueue(this,e,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},P1=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Bh=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Pe,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Pe,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Bh.INSTANCE=new Bh;var Xf=Bh;function L1(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Xf.INSTANCE.onDidChangeZoomLevel;function A1(e){return Xf.INSTANCE.getZoomFactor(e)}Xf.INSTANCE.onDidChangeFullscreen;var ko=typeof navigator=="object"?navigator.userAgent:"",zh=ko.indexOf("Firefox")>=0,M1=ko.indexOf("AppleWebKit")>=0,Qf=ko.indexOf("Chrome")>=0,T1=!Qf&&ko.indexOf("Safari")>=0;ko.indexOf("Electron/")>=0;ko.indexOf("Android")>=0;var kd=!1;if(typeof ps.matchMedia=="function"){let e=ps.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=ps.matchMedia("(display-mode: fullscreen)");kd=e.matches,L1(ps,e,({matches:n})=>{kd&&t.matches||(kd=n)})}var ho="en",$h=!1,Fh=!1,nc=!1,Fb=!1,Ul,ic=ho,jv=ho,D1,Oi,kr=globalThis,In,Oy;typeof kr.vscode<"u"&&typeof kr.vscode.process<"u"?In=kr.vscode.process:typeof process<"u"&&typeof((Oy=process==null?void 0:process.versions)==null?void 0:Oy.node)=="string"&&(In=process);var By,I1=typeof((By=In==null?void 0:In.versions)==null?void 0:By.electron)=="string",O1=I1&&(In==null?void 0:In.type)==="renderer",zy;if(typeof In=="object"){$h=In.platform==="win32",Fh=In.platform==="darwin",nc=In.platform==="linux",nc&&In.env.SNAP&&In.env.SNAP_REVISION,In.env.CI||In.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ul=ho,ic=ho;let e=In.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ul=t.userLocale,jv=t.osLocale,ic=t.resolvedLanguage||ho,D1=(zy=t.languagePack)==null?void 0:zy.translationsConfigFile}catch{}Fb=!0}else typeof navigator=="object"&&!O1?(Oi=navigator.userAgent,$h=Oi.indexOf("Windows")>=0,Fh=Oi.indexOf("Macintosh")>=0,(Oi.indexOf("Macintosh")>=0||Oi.indexOf("iPad")>=0||Oi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,nc=Oi.indexOf("Linux")>=0,(Oi==null?void 0:Oi.indexOf("Mobi"))>=0,ic=globalThis._VSCODE_NLS_LANGUAGE||ho,Ul=navigator.language.toLowerCase(),jv=Ul):console.error("Unable to resolve platform.");var Hb=$h,Ji=Fh,B1=nc,Rv=Fb,es=Oi,Bs=ic,z1;(e=>{function t(){return Bs}e.value=t;function n(){return Bs.length===2?Bs==="en":Bs.length>=3?Bs[0]==="e"&&Bs[1]==="n"&&Bs[2]==="-":!1}e.isDefaultVariant=n;function s(){return Bs==="en"}e.isDefault=s})(z1||(z1={}));var $1=typeof kr.postMessage=="function"&&!kr.importScripts;(()=>{if($1){let e=[];kr.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let a=e[s];if(a.id===n.data.vscodeScheduleAsyncWork){e.splice(s,1),a.callback();return}}});let t=0;return n=>{let s=++t;e.push({id:s,callback:n}),kr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var F1=!!(es&&es.indexOf("Chrome")>=0);es&&es.indexOf("Firefox")>=0;!F1&&es&&es.indexOf("Safari")>=0;es&&es.indexOf("Edg/")>=0;es&&es.indexOf("Android")>=0;var ro=typeof navigator=="object"?navigator:{};Rv||document.queryCommandSupported&&document.queryCommandSupported("copy")||ro&&ro.clipboard&&ro.clipboard.writeText,Rv||ro&&ro.clipboard&&ro.clipboard.readText;var Jf=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Cd=new Jf,Pv=new Jf,Lv=new Jf,H1=new Array(230),Ub;(e=>{function t(d){return Cd.keyCodeToStr(d)}e.toString=t;function n(d){return Cd.strToKeyCode(d)}e.fromString=n;function s(d){return Pv.keyCodeToStr(d)}e.toUserSettingsUS=s;function o(d){return Lv.keyCodeToStr(d)}e.toUserSettingsGeneral=o;function a(d){return Pv.strToKeyCode(d)||Lv.strToKeyCode(d)}e.fromUserSettings=a;function u(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 Cd.keyCodeToStr(d)}e.toElectronAccelerator=u})(Ub||(Ub={}));var U1=class Wb{constructor(t,n,s,o,a){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=o,this.keyCode=a}equals(t){return t instanceof Wb&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${n}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new W1([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},W1=class{constructor(e){if(e.length===0)throw m1("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function K1(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return Ub.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(zh)switch(t){case 59:return 85;case 60:if(B1)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Ji)return 57;break}else if(M1&&(Ji&&t===93||!Ji&&t===92))return 57;return H1[t]||0}var q1=Ji?256:2048,V1=512,Y1=1024,G1=Ji?2048:256,Av=class{constructor(e){var n;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(n=t.getModifierState)==null?void 0:n.call(t,"AltGraph"),this.keyCode=K1(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=q1),this.altKey&&(t|=V1),this.shiftKey&&(t|=Y1),this.metaKey&&(t|=G1),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new U1(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Mv=new WeakMap;function X1(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!=="null"&&n.origin!=="null"&&t.origin!==n.origin)return null}catch{return null}return e.parent}var Q1=class{static getSameOriginWindowChain(e){let t=Mv.get(e);if(!t){t=[],Mv.set(e,t);let n=e,s;do s=X1(n),s?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=s;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,s=0,o=this.getSameOriginWindowChain(e);for(let a of o){let u=a.window.deref();if(n+=(u==null?void 0:u.scrollY)??0,s+=(u==null?void 0:u.scrollX)??0,u===t||!a.iframeElement)break;let d=a.iframeElement.getBoundingClientRect();n+=d.top,s+=d.left}return{top:n,left:s}}},Wl=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=Q1.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Tv=class{constructor(e,t=0,n=0){var o;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let s=!1;if(Qf){let a=navigator.userAgent.match(/Chrome\/(\d+)/);s=(a?parseInt(a[1]):123)<=122}if(e){let a=e,u=e,d=((o=e.view)==null?void 0:o.devicePixelRatio)||1;if(typeof a.wheelDeltaY<"u")s?this.deltaY=a.wheelDeltaY/(120*d):this.deltaY=a.wheelDeltaY/120;else if(typeof u.VERTICAL_AXIS<"u"&&u.axis===u.VERTICAL_AXIS)this.deltaY=-u.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?zh&&!Ji?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof a.wheelDeltaX<"u")T1&&Hb?this.deltaX=-(a.wheelDeltaX/120):s?this.deltaX=a.wheelDeltaX/(120*d):this.deltaX=a.wheelDeltaX/120;else if(typeof u.HORIZONTAL_AXIS<"u"&&u.axis===u.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?zh&&!Ji?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*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},Kb=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),J1;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof Z1?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:On.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Kb})})(J1||(J1={}));var Z1=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?Kb:(this._emitter||(this._emitter=new Pe),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Zf=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Mh("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Mh("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},eC=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new Mh("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=Qt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},tC;(e=>{async function t(s){let o,a=await Promise.all(s.map(u=>u.then(d=>d,d=>{o||(o=d)})));if(typeof o<"u")throw o;return a}e.settled=t;function n(s){return new Promise(async(o,a)=>{try{await s(o,a)}catch(u){a(u)}})}e.withAsyncBody=n})(tC||(tC={}));var Dv=class Ni{static fromArray(t){return new Ni(n=>{n.emitMany(t)})}static fromPromise(t){return new Ni(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Ni(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new Ni(async n=>{await Promise.all(t.map(async s=>{for await(let o of s)n.emitOne(o)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new Pe,queueMicrotask(async()=>{let s={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(s)),this.resolve()}catch(o){this.reject(o)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await On.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new Ni(async s=>{for await(let o of t)s.emitOne(n(o))})}map(t){return Ni.map(this,t)}static filter(t,n){return new Ni(async s=>{for await(let o of t)n(o)&&s.emitOne(o)})}filter(t){return Ni.filter(this,t)}static coalesce(t){return Ni.filter(t,n=>!!n)}coalesce(){return Ni.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return Ni.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Dv.EMPTY=Dv.fromArray([]);var{getWindow:Xi,getWindowId:nC,onDidRegisterWindow:iC}=(function(){let e=new Map,t={window:ps,disposables:new Ys};e.set(ps.vscodeWindowId,t);let n=new Pe,s=new Pe,o=new Pe;function a(u,d){return(typeof u=="number"?e.get(u):void 0)??(d?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(u){if(e.has(u.vscodeWindowId))return gt.None;let d=new Ys,p={window:u,disposables:d.add(new Ys)};return e.set(u.vscodeWindowId,p),d.add(Qt(()=>{e.delete(u.vscodeWindowId),s.fire(u)})),d.add(at(u,Nn.BEFORE_UNLOAD,()=>{o.fire(u)})),n.fire(p),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:a,getWindow(u){var m;let d=u;if((m=d==null?void 0:d.ownerDocument)!=null&&m.defaultView)return d.ownerDocument.defaultView.window;let p=u;return p!=null&&p.view?p.view.window:ps},getDocument(u){return Xi(u).document}}})(),sC=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function at(e,t,n,s){return new sC(e,t,n,s)}var Iv=function(e,t,n,s){return at(e,t,n,s)},ep,rC=class extends eC{constructor(e){super(),this.defaultTarget=e&&Xi(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Ov=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){tc(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,o=a=>{n.set(a,!1);let u=e.get(a)??[];for(t.set(a,u),e.set(a,[]),s.set(a,!0);u.length>0;)u.sort(Ov.sort),u.shift().execute();s.set(a,!1)};ep=(a,u,d=0)=>{let p=nC(a),m=new Ov(u,d),v=e.get(p);return v||(v=[],e.set(p,v)),v.push(m),n.get(p)||(n.set(p,!0),a.requestAnimationFrame(()=>o(p))),m}})();function oC(e){let t=e.getBoundingClientRect(),n=Xi(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Nn={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"},aC=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let n=si(t);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let n=si(t);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(t){let n=si(t);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(t){let n=si(t);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(t){let n=si(t);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(t){let n=si(t);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(t){let n=si(t);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(t){let n=si(t);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let n=si(t);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let n=si(t);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let n=si(t);this._paddingRight!==n&&(this._paddingRight=n,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let n=si(t);this._fontSize!==n&&(this._fontSize=n,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let n=si(t);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let n=si(t);this._letterSpacing!==n&&(this._letterSpacing=n,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,n){this.domNode.classList.toggle(t,n),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,n){this.domNode.setAttribute(t,n)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function si(e){return typeof e=="number"?`${e}px`:e}function Sa(e){return new aC(e)}var qb=class{constructor(){this._hooks=new Ys,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let a=e;try{e.setPointerCapture(t),this._hooks.add(Qt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=Xi(e)}this._hooks.add(at(a,Nn.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(at(a,Nn.POINTER_UP,u=>this.stopMonitoring(!0)))}};function lC(e,t,n){let s=null,o=null;if(typeof n.value=="function"?(s="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",o=n.get),!o)throw new Error("not supported");let a=`$memoize$${t}`;n[s]=function(...u){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,u)}),this[a]}}var qi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(qi||(qi={}));var ma=class Un extends gt{constructor(){super(),this.dispatched=!1,this.targets=new Nv,this.ignoreTargets=new Nv,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(On.runAndSubscribe(iC,({window:t,disposables:n})=>{n.add(at(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(at(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(at(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:ps,disposables:this._store}))}static addTarget(t){if(!Un.isTouchDevice())return gt.None;Un.INSTANCE||(Un.INSTANCE=new Un);let n=Un.INSTANCE.targets.push(t);return Qt(n)}static ignoreTarget(t){if(!Un.isTouchDevice())return gt.None;Un.INSTANCE||(Un.INSTANCE=new Un);let n=Un.INSTANCE.ignoreTargets.push(t);return Qt(n)}static isTouchDevice(){return"ontouchstart"in ps||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,o=t.targetTouches.length;s<o;s++){let a=t.targetTouches.item(s);this.activeTouches[a.identifier]={id:a.identifier,initialTarget:a.target,initialTimeStamp:n,initialPageX:a.pageX,initialPageY:a.pageY,rollingTimestamps:[n],rollingPageX:[a.pageX],rollingPageY:[a.pageY]};let u=this.newGestureEvent(qi.Start,a.target);u.pageX=a.pageX,u.pageY=a.pageY,this.dispatchEvent(u)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let a=0,u=n.changedTouches.length;a<u;a++){let d=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("move of an UNKNOWN touch",d);continue}let p=this.activeTouches[d.identifier],m=Date.now()-p.initialTimeStamp;if(m<Un.HOLD_DELAY&&Math.abs(p.initialPageX-fi(p.rollingPageX))<30&&Math.abs(p.initialPageY-fi(p.rollingPageY))<30){let v=this.newGestureEvent(qi.Tap,p.initialTarget);v.pageX=fi(p.rollingPageX),v.pageY=fi(p.rollingPageY),this.dispatchEvent(v)}else if(m>=Un.HOLD_DELAY&&Math.abs(p.initialPageX-fi(p.rollingPageX))<30&&Math.abs(p.initialPageY-fi(p.rollingPageY))<30){let v=this.newGestureEvent(qi.Contextmenu,p.initialTarget);v.pageX=fi(p.rollingPageX),v.pageY=fi(p.rollingPageY),this.dispatchEvent(v)}else if(o===1){let v=fi(p.rollingPageX),y=fi(p.rollingPageY),b=fi(p.rollingTimestamps)-p.rollingTimestamps[0],S=v-p.rollingPageX[0],x=y-p.rollingPageY[0],E=[...this.targets].filter(w=>p.initialTarget instanceof Node&&w.contains(p.initialTarget));this.inertia(t,E,s,Math.abs(S)/b,S>0?1:-1,v,Math.abs(x)/b,x>0?1:-1,y)}this.dispatchEvent(this.newGestureEvent(qi.End,p.initialTarget)),delete this.activeTouches[d.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===qi.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>Un.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===qi.Change||t.type===qi.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let o=0,a=t.initialTarget;for(;a&&a!==s;)o++,a=a.parentElement;n.push([o,s])}n.sort((s,o)=>s[0]-o[0]);for(let[s,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,o,a,u,d,p,m){this.handle=ep(t,()=>{let v=Date.now(),y=v-s,b=0,S=0,x=!0;o+=Un.SCROLL_FRICTION*y,d+=Un.SCROLL_FRICTION*y,o>0&&(x=!1,b=a*o*y),d>0&&(x=!1,S=p*d*y);let E=this.newGestureEvent(qi.Change);E.translationX=b,E.translationY=S,n.forEach(w=>w.dispatchEvent(E)),x||this.inertia(t,n,v,o,a,u+b,d,p,m+S)})}onTouchMove(t){let n=Date.now();for(let s=0,o=t.changedTouches.length;s<o;s++){let a=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("end of an UNKNOWN touch",a);continue}let u=this.activeTouches[a.identifier],d=this.newGestureEvent(qi.Change,u.initialTarget);d.translationX=a.pageX-fi(u.rollingPageX),d.translationY=a.pageY-fi(u.rollingPageY),d.pageX=a.pageX,d.pageY=a.pageY,this.dispatchEvent(d),u.rollingPageX.length>3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(a.pageX),u.rollingPageY.push(a.pageY),u.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};ma.SCROLL_FRICTION=-.005,ma.HOLD_DELAY=700,ma.CLEAR_TAP_COUNT_TIME=400,an([lC],ma,"isTouchDevice",1);var cC=ma,tp=class extends gt{onclick(e,t){this._register(at(e,Nn.CLICK,n=>t(new Wl(Xi(e),n))))}onmousedown(e,t){this._register(at(e,Nn.MOUSE_DOWN,n=>t(new Wl(Xi(e),n))))}onmouseover(e,t){this._register(at(e,Nn.MOUSE_OVER,n=>t(new Wl(Xi(e),n))))}onmouseleave(e,t){this._register(at(e,Nn.MOUSE_LEAVE,n=>t(new Wl(Xi(e),n))))}onkeydown(e,t){this._register(at(e,Nn.KEY_DOWN,n=>t(new Av(n))))}onkeyup(e,t){this._register(at(e,Nn.KEY_UP,n=>t(new Av(n))))}oninput(e,t){this._register(at(e,Nn.INPUT,t))}onblur(e,t){this._register(at(e,Nn.BLUR,t))}onfocus(e,t){this._register(at(e,Nn.FOCUS,t))}onchange(e,t){this._register(at(e,Nn.CHANGE,t))}ignoreGesture(e){return cC.ignoreTarget(e)}},Bv=11,uC=class extends tp{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=Bv+"px",this.domNode.style.height=Bv+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new qb),this._register(Iv(this.bgDomNode,Nn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Iv(this.domNode,Nn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new rC),this._pointerdownScheduleRepeatTimer=this._register(new Zf)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Xi(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},dC=class Hh{constructor(t,n,s,o,a,u,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,o=o|0,a=a|0,u=u|0,d=d|0),this.rawScrollLeft=o,this.rawScrollTop=d,n<0&&(n=0),o+n>s&&(o=s-n),o<0&&(o=0),a<0&&(a=0),d+a>u&&(d=u-a),d<0&&(d=0),this.width=n,this.scrollWidth=s,this.scrollLeft=o,this.height=a,this.scrollHeight=u,this.scrollTop=d}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new Hh(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Hh(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,a=this.scrollLeft!==t.scrollLeft,u=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:o,scrollLeftChanged:a,heightChanged:u,scrollHeightChanged:d,scrollTopChanged:p}}},hC=class extends gt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Pe),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new dC(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new $v(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=$v.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},zv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Ed(e,t){let n=t-e;return function(s){return e+n*mC(s)}}function fC(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var $v=class Uh{constructor(t,n,s,o){this.from=t,this.to=n,this.duration=o,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,n,s){if(Math.abs(t-n)>2.5*s){let o,a;return t<n?(o=t+.75*s,a=n-.75*s):(o=t-.75*s,a=n+.75*s),fC(Ed(t,o),Ed(a,n),.33)}return Ed(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let s=this.scrollLeft(n),o=this.scrollTop(n);return new zv(s,o,!1)}return new zv(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return Uh.start(t,n,s)}static start(t,n,s){s=s+10;let o=Date.now()-10;return new Uh(t,n,o,s)}};function pC(e){return Math.pow(e,3)}function mC(e){return 1-pC(1-e)}var gC=class extends gt{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Zf)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},vC=140,Vb=class extends tp{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 gC(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new qb),this._shouldRender=!0,this.domNode=Sa(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(at(this.domNode.domNode,Nn.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new uC(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=Sa(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(at(this.slider.domNode,Nn.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let o=oC(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let a=this._sliderOrthogonalPointerPosition(o),u=Math.abs(a-n);if(Hb&&u>vC){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let d=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(d))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Yb=class Wh{constructor(t,n,s,o,a,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=a,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Wh(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,o,a){let u=Math.max(0,s-t),d=Math.max(0,u-2*n),p=o>0&&o>s;if(!p)return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let m=Math.round(Math.max(20,Math.floor(s*d/o))),v=(d-m)/(o-s),y=a*v;return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(m),computedSliderRatio:v,computedSliderPosition:Math.round(y)}}_refreshComputedValues(){let t=Wh._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},_C=class extends Vb{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Yb(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,o.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},yC=class extends Vb{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Yb(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,o.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},bC=500,Fv=50,wC=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Kh=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,s=1,o=this._rear;do{let a=o===this._front?t:Math.pow(2,-s);if(t-=a,n+=this._memory[o].score*a,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(Qf){let n=Xi(t.browserEvent),s=A1(n);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,s){let o=null,a=new wC(t,n,s);this._front===-1&&this._rear===-1?(this._memory[0]=a,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=a),a.score=this._computeScore(a,o)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let o=Math.abs(t.deltaX),a=Math.abs(t.deltaY),u=Math.abs(n.deltaX),d=Math.abs(n.deltaY),p=Math.max(Math.min(o,u),1),m=Math.max(Math.min(a,d),1),v=Math.max(o,u),y=Math.max(a,d);v%p===0&&y%m===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Kh.INSTANCE=new Kh;var SC=Kh,xC=class extends tp{constructor(e,t,n){super(),this._onScroll=this._register(new Pe),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Pe),this.onWillScroll=this._onWillScroll.event,this._options=CC(t),this._scrollable=n,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let s={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new yC(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new _C(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Sa(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Sa(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Sa(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,o=>this._onMouseOver(o)),this.onmouseleave(this._listenOnDomNode,o=>this._onMouseLeave(o)),this._hideTimeout=this._register(new Zf),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Cr(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Ji&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Tv(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Cr(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new Tv(n))};this._mouseWheelToDispose.push(at(this._listenOnDomNode,Nn.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=SC.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let a=e.deltaY*this._options.mouseWheelScrollSensitivity,u=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&u+a===0?u=a=0:Math.abs(a)>=Math.abs(u)?u=0:a=0),this._options.flipAxes&&([a,u]=[u,a]);let d=!Ji&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!u&&(u=a,a=0),e.browserEvent&&e.browserEvent.altKey&&(u=u*this._options.fastScrollSensitivity,a=a*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),m={};if(a){let v=Fv*a,y=p.scrollTop-(v<0?Math.floor(v):Math.ceil(v));this._verticalScrollbar.writeScrollPosition(m,y)}if(u){let v=Fv*u,y=p.scrollLeft-(v<0?Math.floor(v):Math.ceil(v));this._horizontalScrollbar.writeScrollPosition(m,y)}m=this._scrollable.validateScrollPosition(m),(p.scrollLeft!==m.scrollLeft||p.scrollTop!==m.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(m):this._scrollable.setScrollPositionNow(m),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,s=n?" left":"",o=t?" top":"",a=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${o}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),bC)}},kC=class extends xC{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function CC(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,Ji&&(t.className+=" mac"),t}var qh=class extends gt{constructor(e,t,n,s,o,a,u,d){super(),this._bufferService=n,this._optionsService=u,this._renderService=d,this._onRequestScrollLines=this._register(new Pe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new hC({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:m=>ep(s.window,m)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new kC(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(m=>{this._scrollableElement.updateOptions({handleMouseWheel:!(m&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(On.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Qt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Qt(()=>this._styleElement.remove())),this._register(On.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${a.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${a.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${a.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
60
- `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(m=>this._handleScroll(m)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};qh=an([Fe(2,Gn),Fe(3,gs),Fe(4,jb),Fe(5,xo),Fe(6,Xn),Fe(7,vs)],qh);var Vh=class extends gt{constructor(e,t,n,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(a=>this._removeDecoration(a))),this._register(Qt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Vh=an([Fe(1,Gn),Fe(2,gs),Fe(3,Aa),Fe(4,vs)],Vh);var EC=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Ui={full:0,left:0,center:0,right:0},zs={full:0,left:0,center:0,right:0},sa={full:0,left:0,center:0,right:0},vc=class extends gt{constructor(e,t,n,s,o,a,u,d){var m;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=o,this._optionsService=a,this._themeService=u,this._coreBrowserService=d,this._colorZoneStore=new EC,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(m=this._viewportElement.parentElement)==null||m.insertBefore(this._canvas,this._viewportElement),this._register(Qt(()=>{var v;return(v=this._canvas)==null?void 0:v.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);zs.full=this._canvas.width,zs.left=e,zs.center=t,zs.right=e,this._refreshDrawHeightConstants(),sa.full=1,sa.left=1,sa.center=1+zs.left,sa.right=1+zs.left+zs.center}_refreshDrawHeightConstants(){Ui.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Ui.left=t,Ui.center=t,Ui.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ui.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ui.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ui.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ui.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(sa[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ui[e.position||"full"]/2),zs[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ui[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};vc=an([Fe(2,Gn),Fe(3,Aa),Fe(4,vs),Fe(5,Xn),Fe(6,xo),Fe(7,gs)],vc);var ge;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
61
- `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(ge||(ge={}));var sc;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(sc||(sc={}));var Gb;(e=>e.ST=`${ge.ESC}\\`)(Gb||(Gb={}));var Yh=class{constructor(e,t,n,s,o,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=o,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${ge.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let a=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(a.width,1)+"px",this._textarea.style.height=Math.max(a.height,1)+"px",this._textarea.style.lineHeight=a.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Yh=an([Fe(2,Gn),Fe(3,Xn),Fe(4,Nr),Fe(5,vs)],Yh);var jn=0,Rn=0,Pn=0,rn=0,Hv={css:"#00000000",rgba:0},mn;(e=>{function t(o,a,u,d){return d!==void 0?`#${gr(o)}${gr(a)}${gr(u)}${gr(d)}`:`#${gr(o)}${gr(a)}${gr(u)}`}e.toCss=t;function n(o,a,u,d=255){return(o<<24|a<<16|u<<8|d)>>>0}e.toRgba=n;function s(o,a,u,d){return{css:e.toCss(o,a,u,d),rgba:e.toRgba(o,a,u,d)}}e.toColor=s})(mn||(mn={}));var Vt;(e=>{function t(p,m){if(rn=(m.rgba&255)/255,rn===1)return{css:m.css,rgba:m.rgba};let v=m.rgba>>24&255,y=m.rgba>>16&255,b=m.rgba>>8&255,S=p.rgba>>24&255,x=p.rgba>>16&255,E=p.rgba>>8&255;jn=S+Math.round((v-S)*rn),Rn=x+Math.round((y-x)*rn),Pn=E+Math.round((b-E)*rn);let w=mn.toCss(jn,Rn,Pn),N=mn.toRgba(jn,Rn,Pn);return{css:w,rgba:N}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,m,v){let y=rc.ensureContrastRatio(p.rgba,m.rgba,v);if(y)return mn.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=s;function o(p){let m=(p.rgba|255)>>>0;return[jn,Rn,Pn]=rc.toChannels(m),{css:mn.toCss(jn,Rn,Pn),rgba:m}}e.opaque=o;function a(p,m){return rn=Math.round(m*255),[jn,Rn,Pn]=rc.toChannels(p.rgba),{css:mn.toCss(jn,Rn,Pn,rn),rgba:mn.toRgba(jn,Rn,Pn,rn)}}e.opacity=a;function u(p,m){return rn=p.rgba&255,a(p,rn*m/255)}e.multiplyOpacity=u;function d(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=d})(Vt||(Vt={}));var tn;(e=>{let t,n;try{let o=document.createElement("canvas");o.width=1,o.height=1;let a=o.getContext("2d",{willReadFrequently:!0});a&&(t=a,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return jn=parseInt(o.slice(1,2).repeat(2),16),Rn=parseInt(o.slice(2,3).repeat(2),16),Pn=parseInt(o.slice(3,4).repeat(2),16),mn.toColor(jn,Rn,Pn);case 5:return jn=parseInt(o.slice(1,2).repeat(2),16),Rn=parseInt(o.slice(2,3).repeat(2),16),Pn=parseInt(o.slice(3,4).repeat(2),16),rn=parseInt(o.slice(4,5).repeat(2),16),mn.toColor(jn,Rn,Pn,rn);case 7:return{css:o,rgba:(parseInt(o.slice(1),16)<<8|255)>>>0};case 9:return{css:o,rgba:parseInt(o.slice(1),16)>>>0}}let a=o.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(a)return jn=parseInt(a[1]),Rn=parseInt(a[2]),Pn=parseInt(a[3]),rn=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),mn.toColor(jn,Rn,Pn,rn);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[jn,Rn,Pn,rn]=t.getImageData(0,0,1,1).data,rn!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:mn.toRgba(jn,Rn,Pn,rn),css:o}}e.toColor=s})(tn||(tn={}));var Vn;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,o,a){let u=s/255,d=o/255,p=a/255,m=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),v=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),y=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return m*.2126+v*.7152+y*.0722}e.relativeLuminance2=n})(Vn||(Vn={}));var rc;(e=>{function t(u,d){if(rn=(d&255)/255,rn===1)return d;let p=d>>24&255,m=d>>16&255,v=d>>8&255,y=u>>24&255,b=u>>16&255,S=u>>8&255;return jn=y+Math.round((p-y)*rn),Rn=b+Math.round((m-b)*rn),Pn=S+Math.round((v-S)*rn),mn.toRgba(jn,Rn,Pn)}e.blend=t;function n(u,d,p){let m=Vn.relativeLuminance(u>>8),v=Vn.relativeLuminance(d>>8);if(ds(m,v)<p){if(v<m){let S=s(u,d,p),x=ds(m,Vn.relativeLuminance(S>>8));if(x<p){let E=o(u,d,p),w=ds(m,Vn.relativeLuminance(E>>8));return x>w?S:E}return S}let y=o(u,d,p),b=ds(m,Vn.relativeLuminance(y>>8));if(b<p){let S=s(u,d,p),x=ds(m,Vn.relativeLuminance(S>>8));return b>x?y:S}return y}}e.ensureContrastRatio=n;function s(u,d,p){let m=u>>24&255,v=u>>16&255,y=u>>8&255,b=d>>24&255,S=d>>16&255,x=d>>8&255,E=ds(Vn.relativeLuminance2(b,S,x),Vn.relativeLuminance2(m,v,y));for(;E<p&&(b>0||S>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),S-=Math.max(0,Math.ceil(S*.1)),x-=Math.max(0,Math.ceil(x*.1)),E=ds(Vn.relativeLuminance2(b,S,x),Vn.relativeLuminance2(m,v,y));return(b<<24|S<<16|x<<8|255)>>>0}e.reduceLuminance=s;function o(u,d,p){let m=u>>24&255,v=u>>16&255,y=u>>8&255,b=d>>24&255,S=d>>16&255,x=d>>8&255,E=ds(Vn.relativeLuminance2(b,S,x),Vn.relativeLuminance2(m,v,y));for(;E<p&&(b<255||S<255||x<255);)b=Math.min(255,b+Math.ceil((255-b)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),E=ds(Vn.relativeLuminance2(b,S,x),Vn.relativeLuminance2(m,v,y));return(b<<24|S<<16|x<<8|255)>>>0}e.increaseLuminance=o;function a(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=a})(rc||(rc={}));function gr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ds(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var NC=class extends La{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},_c=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Ri}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],s=t.translateToString(!0),o=0,a=0,u=0,d=t.getFg(0),p=t.getBg(0);for(let m=0;m<t.getTrimmedLength();m++)if(t.loadCell(m,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==d||this._workCell.bg!==p){if(m-o>1){let v=this._getJoinedRanges(s,u,a,t,o);for(let y=0;y<v.length;y++)n.push(v[y])}o=m,u=a,d=this._workCell.fg,p=this._workCell.bg}a+=this._workCell.getChars().length||Ks.length}if(this._bufferService.cols-o>1){let m=this._getJoinedRanges(s,u,a,t,o);for(let v=0;v<m.length;v++)n.push(m[v])}return n}_getJoinedRanges(e,t,n,s,o){let a=e.substring(t,n),u=[];try{u=this._characterJoiners[0].handler(a)}catch(d){console.error(d)}for(let d=1;d<this._characterJoiners.length;d++)try{let p=this._characterJoiners[d].handler(a);for(let m=0;m<p.length;m++)_c._mergeRanges(u,p[m])}catch(p){console.error(p)}return this._stringRangesToCellRanges(u,s,o),u}_stringRangesToCellRanges(e,t,n){let s=0,o=!1,a=0,u=e[s];if(u){for(let d=n;d<this._bufferService.cols;d++){let p=t.getWidth(d),m=t.getString(d).length||Ks.length;if(p!==0){if(!o&&u[0]<=a&&(u[0]=d,o=!0),u[1]<=a){if(u[1]=d,u=e[++s],!u)break;u[0]<=a?(u[0]=d,o=!0):o=!1}a+=m}}u&&(u[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let s=0;s<e.length;s++){let o=e[s];if(n){if(t[1]<=o[0])return e[s-1][1]=t[1],e;if(t[1]<=o[1])return e[s-1][1]=Math.max(t[1],o[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=o[0])return e.splice(s,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};_c=an([Fe(0,Gn)],_c);function jC(e){return 57508<=e&&e<=57558}function RC(e){return 9472<=e&&e<=9631}function PC(e){return jC(e)||RC(e)}function LC(){return{css:{canvas:Kl(),cell:Kl()},device:{canvas:Kl(),cell:Kl(),char:{width:0,height:0,left:0,top:0}}}}function Kl(){return{width:0,height:0}}var Gh=class{constructor(e,t,n,s,o,a,u){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=s,this._coreService=o,this._decorationService=a,this._themeService=u,this._workCell=new Ri,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,s,o,a,u,d,p,m,v){let y=[],b=this._characterJoinerService.getJoinedCharacters(t),S=this._themeService.colors,x=e.getNoBgTrimmedLength();n&&x<a+1&&(x=a+1);let E,w=0,N="",C=0,L=0,I=0,G=0,K=!1,Y=0,Q=!1,W=0,X=0,H=[],$=m!==-1&&v!==-1;for(let R=0;R<x;R++){e.loadCell(R,this._workCell);let O=this._workCell.getWidth();if(O===0)continue;let F=!1,A=R>=X,T=R,j=this._workCell;if(b.length>0&&R===b[0][0]&&A){let je=b.shift(),Ct=this._isCellInSelection(je[0],t);for(C=je[0]+1;C<je[1];C++)A&&(A=Ct===this._isCellInSelection(C,t));A&&(A=!n||a<je[0]||a>=je[1]),A?(F=!0,j=new NC(this._workCell,e.translateToString(!0,je[0],je[1]),je[1]-je[0]),T=je[1]-1,O=j.getWidth()):X=je[1]}let z=this._isCellInSelection(R,t),M=n&&R===a,D=$&&R>=m&&R<=v,B=!1;this._decorationService.forEachDecorationAtCell(R,t,void 0,je=>{B=!0});let U=j.getChars()||Ks;if(U===" "&&(j.isUnderline()||j.isOverline())&&(U=" "),W=O*d-p.get(U,j.isBold(),j.isItalic()),!E)E=this._document.createElement("span");else if(w&&(z&&Q||!z&&!Q&&j.bg===L)&&(z&&Q&&S.selectionForeground||j.fg===I)&&j.extended.ext===G&&D===K&&W===Y&&!M&&!F&&!B&&A){j.isInvisible()?N+=Ks:N+=U,w++;continue}else w&&(E.textContent=N),E=this._document.createElement("span"),w=0,N="";if(L=j.bg,I=j.fg,G=j.extended.ext,K=D,Y=W,Q=z,F&&a>=R&&a<=T&&(a=R),!this._coreService.isCursorHidden&&M&&this._coreService.isCursorInitialized){if(H.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&H.push("xterm-cursor-blink"),H.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":H.push("xterm-cursor-outline");break;case"block":H.push("xterm-cursor-block");break;case"bar":H.push("xterm-cursor-bar");break;case"underline":H.push("xterm-cursor-underline");break}}if(j.isBold()&&H.push("xterm-bold"),j.isItalic()&&H.push("xterm-italic"),j.isDim()&&H.push("xterm-dim"),j.isInvisible()?N=Ks:N=j.getChars()||Ks,j.isUnderline()&&(H.push(`xterm-underline-${j.extended.underlineStyle}`),N===" "&&(N=" "),!j.isUnderlineColorDefault()))if(j.isUnderlineColorRGB())E.style.textDecorationColor=`rgb(${La.toColorRGB(j.getUnderlineColor()).join(",")})`;else{let je=j.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&j.isBold()&&je<8&&(je+=8),E.style.textDecorationColor=S.ansi[je].css}j.isOverline()&&(H.push("xterm-overline"),N===" "&&(N=" ")),j.isStrikethrough()&&H.push("xterm-strikethrough"),D&&(E.style.textDecoration="underline");let se=j.getFgColor(),ee=j.getFgColorMode(),de=j.getBgColor(),ve=j.getBgColorMode(),fe=!!j.isInverse();if(fe){let je=se;se=de,de=je;let Ct=ee;ee=ve,ve=Ct}let pe,Ve,ut=!1;this._decorationService.forEachDecorationAtCell(R,t,void 0,je=>{je.options.layer!=="top"&&ut||(je.backgroundColorRGB&&(ve=50331648,de=je.backgroundColorRGB.rgba>>8&16777215,pe=je.backgroundColorRGB),je.foregroundColorRGB&&(ee=50331648,se=je.foregroundColorRGB.rgba>>8&16777215,Ve=je.foregroundColorRGB),ut=je.options.layer==="top")}),!ut&&z&&(pe=this._coreBrowserService.isFocused?S.selectionBackgroundOpaque:S.selectionInactiveBackgroundOpaque,de=pe.rgba>>8&16777215,ve=50331648,ut=!0,S.selectionForeground&&(ee=50331648,se=S.selectionForeground.rgba>>8&16777215,Ve=S.selectionForeground)),ut&&H.push("xterm-decoration-top");let vt;switch(ve){case 16777216:case 33554432:vt=S.ansi[de],H.push(`xterm-bg-${de}`);break;case 50331648:vt=mn.toColor(de>>16,de>>8&255,de&255),this._addStyle(E,`background-color:#${Uv((de>>>0).toString(16),"0",6)}`);break;case 0:default:fe?(vt=S.foreground,H.push("xterm-bg-257")):vt=S.background}switch(pe||j.isDim()&&(pe=Vt.multiplyOpacity(vt,.5)),ee){case 16777216:case 33554432:j.isBold()&&se<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(se+=8),this._applyMinimumContrast(E,vt,S.ansi[se],j,pe,void 0)||H.push(`xterm-fg-${se}`);break;case 50331648:let je=mn.toColor(se>>16&255,se>>8&255,se&255);this._applyMinimumContrast(E,vt,je,j,pe,Ve)||this._addStyle(E,`color:#${Uv(se.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(E,vt,S.foreground,j,pe,Ve)||fe&&H.push("xterm-fg-257")}H.length&&(E.className=H.join(" "),H.length=0),!M&&!F&&!B&&A?w++:E.textContent=N,W!==this.defaultSpacing&&(E.style.letterSpacing=`${W}px`),y.push(E),R=T}return E&&w&&(E.textContent=N),y}_applyMinimumContrast(e,t,n,s,o,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||PC(s.getCode()))return!1;let u=this._getContrastCache(s),d;if(!o&&!a&&(d=u.getColor(t.rgba,n.rgba)),d===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);d=Vt.ensureContrastRatio(o||t,a||n,p),u.setColor((o||t).rgba,(a||n).rgba,d??null)}return d?(this._addStyle(e,`color:${d.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e<s[0]&&t<=s[1]:e<n[0]&&t>=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t<s[1]||n[1]===s[1]&&t===n[1]&&e>=n[0]&&e<s[0]||n[1]<s[1]&&t===s[1]&&e<s[0]||n[1]<s[1]&&t===n[1]&&e>=n[0]}};Gh=an([Fe(1,Lb),Fe(2,Xn),Fe(3,gs),Fe(4,Nr),Fe(5,Aa),Fe(6,xo)],Gh);function Uv(e,t,n){for(;e.length<n;)e=t+e;return e}var AC=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontWeight="bold",a.style.fontStyle="italic",this._measureElements=[n,s,o,a],this._container.appendChild(n),this._container.appendChild(s),this._container.appendChild(o),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,s){e===this._font&&t===this._fontSize&&n===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,n){let s=0;if(!t&&!n&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let u=this._measure(e,0);return u>0&&(this._flat[s]=u),u}let o=e;t&&(o+="B"),n&&(o+="I");let a=this._holey.get(o);if(a===void 0){let u=0;t&&(u|=1),n&&(u|=2),a=this._measure(e,u),a>0&&this._holey.set(o,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},MC=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,a=t[1]-o,u=n[1]-o,d=Math.max(a,0),p=Math.min(u,e.rows-1);if(d>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=a,this.viewportEndRow=u,this.viewportCappedStartRow=d,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function TC(){return new MC}var Nd="xterm-dom-renderer-owner-",Ei="xterm-rows",ql="xterm-fg-",Wv="xterm-bg-",ra="xterm-focus",Vl="xterm-selection",DC=1,Xh=class extends gt{constructor(e,t,n,s,o,a,u,d,p,m,v,y,b,S){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=o,this._helperContainer=a,this._linkifier2=u,this._charSizeService=p,this._optionsService=m,this._bufferService=v,this._coreService=y,this._coreBrowserService=b,this._themeService=S,this._terminalClass=DC++,this._rowElements=[],this._selectionRenderModel=TC(),this.onRequestRedraw=this._register(new Pe).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ei),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(Vl),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=LC(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(Gh,document),this._element.classList.add(Nd+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(Qt(()=>{this._element.classList.remove(Nd+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new AC(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Ei} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Ei} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Ei} .xterm-dim { color: ${Vt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Ei}.${ra} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Ei}.${ra} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ei}.${ra} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Ei} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ei} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ei} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ei} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ei} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Vl} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Vl} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Vl} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[a,u]of e.ansi.entries())t+=`${this._terminalSelector} .${ql}${a} { color: ${u.css}; }${this._terminalSelector} .${ql}${a}.xterm-dim { color: ${Vt.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${Wv}${a} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${ql}257 { color: ${Vt.opaque(e.background).css}; }${this._terminalSelector} .${ql}257.xterm-dim { color: ${Vt.multiplyOpacity(Vt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Wv}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(ra),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ra),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(n){let p=e[0]>t[0];d.appendChild(this._createSelectionElement(a,p?t[0]:e[0],p?e[0]:t[0],u-a+1))}else{let p=s===a?e[0]:0,m=a===o?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(a,p,m));let v=u-a-1;if(d.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,v)),a!==u){let y=o===u?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(u,0,y))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,n,s=1){let o=this._document.createElement("div"),a=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return a+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-a),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${a}px`,o.style.width=`${u}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,s=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let m=p+n.ydisp,v=this._rowElements[p],y=n.lines.get(m);if(!v||!y)break;v.replaceChildren(...this._rowFactory.createRow(y,m,m===s,u,d,o,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Nd}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,o,a){n<0&&(e=0),s<0&&(t=0);let u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),s=Math.max(Math.min(s,u),0),o=Math.min(o,this._bufferService.cols);let d=this._bufferService.buffer,p=d.ybase+d.y,m=Math.min(d.x,o-1),v=this._optionsService.rawOptions.cursorBlink,y=this._optionsService.rawOptions.cursorStyle,b=this._optionsService.rawOptions.cursorInactiveStyle;for(let S=n;S<=s;++S){let x=S+d.ydisp,E=this._rowElements[S],w=d.lines.get(x);if(!E||!w)break;E.replaceChildren(...this._rowFactory.createRow(w,x,x===p,y,b,m,v,this.dimensions.css.cell.width,this._widthCache,a?S===n?e:0:-1,a?(S===s?t:o)-1:-1))}}};Xh=an([Fe(7,Yf),Fe(8,Rc),Fe(9,Xn),Fe(10,Gn),Fe(11,Nr),Fe(12,gs),Fe(13,xo)],Xh);var Qh=class extends gt{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Pe),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new OC(this._optionsService))}catch{this._measureStrategy=this._register(new IC(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Qh=an([Fe(2,Xn)],Qh);var Xb=class extends gt{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},IC=class extends Xb{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},OC=class extends Xb{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},BC=class extends gt{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new zC(this._window)),this._onDprChange=this._register(new Pe),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Pe),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(On.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(at(this._textarea,"focus",()=>this._isFocused=!0)),this._register(at(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}},zC=class extends gt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new yo),this._onDprChange=this._register(new Pe),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Qt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=at(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)}},$C=class extends gt{constructor(){super(),this.linkProviders=[],this._register(Qt(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function np(e,t,n){let s=n.getBoundingClientRect(),o=e.getComputedStyle(n),a=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-a,t.clientY-s.top-u]}function FC(e,t,n,s,o,a,u,d,p){if(!a)return;let m=np(e,t,n);if(m)return m[0]=Math.ceil((m[0]+(p?u/2:0))/u),m[1]=Math.ceil(m[1]/d),m[0]=Math.min(Math.max(m[0],1),s+(p?1:0)),m[1]=Math.min(Math.max(m[1],1),o),m}var Jh=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,o){return FC(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=np(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};Jh=an([Fe(0,vs),Fe(1,Rc)],Jh);var HC=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Qb={};Jk(Qb,{getSafariVersion:()=>WC,isChromeOS:()=>tw,isFirefox:()=>Jb,isIpad:()=>KC,isIphone:()=>qC,isLegacyEdge:()=>UC,isLinux:()=>ip,isMac:()=>yc,isNode:()=>Pc,isSafari:()=>Zb,isWindows:()=>ew});var Pc=typeof process<"u"&&"title"in process,Ma=Pc?"node":navigator.userAgent,Ta=Pc?"node":navigator.platform,Jb=Ma.includes("Firefox"),UC=Ma.includes("Edge"),Zb=/^((?!chrome|android).)*safari/i.test(Ma);function WC(){if(!Zb)return 0;let e=Ma.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var yc=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ta),KC=Ta==="iPad",qC=Ta==="iPhone",ew=["Windows","Win16","Win32","WinCE"].includes(Ta),ip=Ta.indexOf("Linux")>=0,tw=/\bCrOS\b/.test(Ma),nw=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,n=0,s=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),o=e.timeRemaining(),n*1.5>o){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=o}this.clear()}},VC=class extends nw{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},YC=class extends nw{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},bc=!Pc&&"requestIdleCallback"in window?YC:VC,GC=class{constructor(){this._queue=new bc}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Zh=class extends gt{constructor(e,t,n,s,o,a,u,d,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=o,this._coreBrowserService=d,this._renderer=this._register(new yo),this._pausedResizeTask=new GC,this._observerDisposable=this._register(new yo),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 Pe),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Pe),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Pe),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Pe),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new HC((m,v)=>this._renderRows(m,v),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new XC(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Qt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>{var m;return(m=this._renderer.value)==null?void 0:m.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(m=>this._registerIntersectionObserver(m,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=Qt(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Zh=an([Fe(2,Xn),Fe(3,Rc),Fe(4,Nr),Fe(5,Aa),Fe(6,Gn),Fe(7,gs),Fe(8,xo)],Zh);var XC=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function QC(e,t,n,s){let o=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return eE(o,a,e,t,n,s)+Lc(a,t,n,s)+tE(o,a,e,t,n,s);let u;if(a===t)return u=o>e?"D":"C",Ea(Math.abs(o-e),Ca(u,s));u=a>t?"D":"C";let d=Math.abs(a-t),p=ZC(a>t?e:o,n)+(d-1)*n.cols+1+JC(a>t?o:e);return Ea(p,Ca(u,s))}function JC(e,t){return e-1}function ZC(e,t){return t.cols-e}function eE(e,t,n,s,o,a){return Lc(t,s,o,a).length===0?"":Ea(sw(e,t,e,t-Er(t,o),!1,o).length,Ca("D",a))}function Lc(e,t,n,s){let o=e-Er(e,n),a=t-Er(t,n),u=Math.abs(o-a)-nE(e,t,n);return Ea(u,Ca(iw(e,t),s))}function tE(e,t,n,s,o,a){let u;Lc(t,s,o,a).length>0?u=s-Er(s,o):u=t;let d=s,p=iE(e,t,n,s,o,a);return Ea(sw(e,u,n,d,p==="C",o).length,Ca(p,a))}function nE(e,t,n){var u;let s=0,o=e-Er(e,n),a=t-Er(t,n);for(let d=0;d<Math.abs(o-a);d++){let p=iw(e,t)==="A"?-1:1;(u=n.buffer.lines.get(o+p*d))!=null&&u.isWrapped&&s++}return s}function Er(e,t){let n=0,s=t.buffer.lines.get(e),o=s==null?void 0:s.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,s=t.buffer.lines.get(--e),o=s==null?void 0:s.isWrapped;return n}function iE(e,t,n,s,o,a){let u;return Lc(n,s,o,a).length>0?u=s-Er(s,o):u=t,e<n&&u<=s||e>=n&&u<s?"C":"D"}function iw(e,t){return e>t?"A":"B"}function sw(e,t,n,s,o,a){let u=e,d=t,p="";for(;(u!==n||d!==s)&&d>=0&&d<a.buffer.lines.length;)u+=o?1:-1,o&&u>a.cols-1?(p+=a.buffer.translateBufferLineToString(d,!1,e,u),u=0,e=0,d++):!o&&u<0&&(p+=a.buffer.translateBufferLineToString(d,!1,0,e+1),u=a.cols-1,e=u,d--);return p+a.buffer.translateBufferLineToString(d,!1,e,u)}function Ca(e,t){let n=t?"O":"[";return ge.ESC+n+e}function Ea(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var sE=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Kv(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var jd=50,rE=15,oE=50,aE=500,lE=" ",cE=new RegExp(lE,"g"),ef=class extends gt{constructor(e,t,n,s,o,a,u,d,p){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=o,this._mouseService=a,this._optionsService=u,this._renderService=d,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ri,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Pe),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Pe),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Pe),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Pe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=m=>this._handleMouseMove(m),this._mouseUpListener=m=>this._handleMouseUp(m),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(m=>this._handleTrim(m)),this._register(this._bufferService.buffers.onBufferActivate(m=>this._handleBufferActivate(m))),this.enable(),this._model=new sE(this._bufferService),this._activeSelectionMode=0,this._register(Qt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(m=>{m.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let u=e[1];u<=t[1];u++){let d=n.translateBufferLineToString(u,!0,o,a);s.push(d)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let a=e[1]+1;a<=t[1]-1;a++){let u=n.lines.get(a),d=n.translateBufferLineToString(a,!0);u!=null&&u.isWrapped?s[s.length-1]+=d:s.push(d)}if(e[1]!==t[1]){let a=n.lines.get(t[1]),u=n.translateBufferLineToString(t[1],!0,0,t[0]);a&&a.isWrapped?s[s.length-1]+=u:s.push(u)}}return s.map(o=>o.replace(cE," ")).join(ew?`\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())),ip&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var o,a;let n=(a=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:a.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Kv(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=np(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-jd),jd),t/=jd,t/Math.abs(t)+Math.round(t*(rE-1)))}shouldForceSelection(e){return yc?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(),oE)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(yc&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let s=n.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<aE&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let s=QC(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==s&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,a=o.lines.get(e[1]);if(!a)return;let u=o.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(a,e[0]),p=d,m=e[0]-d,v=0,y=0,b=0,S=0;if(u.charAt(d)===" "){for(;d>0&&u.charAt(d-1)===" ";)d--;for(;p<u.length&&u.charAt(p+1)===" ";)p++}else{let w=e[0],N=e[0];a.getWidth(w)===0&&(v++,w--),a.getWidth(N)===2&&(y++,N++);let C=a.getString(N).length;for(C>1&&(S+=C-1,p+=C-1);w>0&&d>0&&!this._isCharWordSeparator(a.loadCell(w-1,this._workCell));){a.loadCell(w-1,this._workCell);let L=this._workCell.getChars().length;this._workCell.getWidth()===0?(v++,w--):L>1&&(b+=L-1,d-=L-1),d--,w--}for(;N<a.length&&p+1<u.length&&!this._isCharWordSeparator(a.loadCell(N+1,this._workCell));){a.loadCell(N+1,this._workCell);let L=this._workCell.getChars().length;this._workCell.getWidth()===2?(y++,N++):L>1&&(S+=L-1,p+=L-1),p++,N++}}p++;let x=d+m-v+b,E=Math.min(this._bufferService.cols,p-d+v+y-b-S);if(!(!t&&u.slice(d,p).trim()==="")){if(n&&x===0&&a.getCodePoint(0)!==32){let w=o.lines.get(e[1]-1);if(w&&a.isWrapped&&w.getCodePoint(this._bufferService.cols-1)!==32){let N=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(N){let C=this._bufferService.cols-N.start;x-=C,E+=C}}}if(s&&x+E===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let w=o.lines.get(e[1]+1);if(w!=null&&w.isWrapped&&w.getCodePoint(0)!==32){let N=this._getWordAt([0,e[1]+1],!1,!1,!0);N&&(E+=N.length)}}return{start:x,length:E}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Kv(n,this._bufferService.cols)}};ef=an([Fe(3,Gn),Fe(4,Nr),Fe(5,Gf),Fe(6,Xn),Fe(7,vs),Fe(8,gs)],ef);var qv=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Vv=class{constructor(){this._color=new qv,this._css=new qv}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},yn=Object.freeze((()=>{let e=[tn.toColor("#2e3436"),tn.toColor("#cc0000"),tn.toColor("#4e9a06"),tn.toColor("#c4a000"),tn.toColor("#3465a4"),tn.toColor("#75507b"),tn.toColor("#06989a"),tn.toColor("#d3d7cf"),tn.toColor("#555753"),tn.toColor("#ef2929"),tn.toColor("#8ae234"),tn.toColor("#fce94f"),tn.toColor("#729fcf"),tn.toColor("#ad7fa8"),tn.toColor("#34e2e2"),tn.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],o=t[n/6%6|0],a=t[n%6];e.push({css:mn.toCss(s,o,a),rgba:mn.toRgba(s,o,a)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:mn.toCss(s,s,s),rgba:mn.toRgba(s,s,s)})}return e})()),_r=tn.toColor("#ffffff"),ga=tn.toColor("#000000"),Yv=tn.toColor("#ffffff"),Gv=ga,oa={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},uE=_r,tf=class extends gt{constructor(e){super(),this._optionsService=e,this._contrastCache=new Vv,this._halfContrastCache=new Vv,this._onChangeColors=this._register(new Pe),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:_r,background:ga,cursor:Yv,cursorAccent:Gv,selectionForeground:void 0,selectionBackgroundTransparent:oa,selectionBackgroundOpaque:Vt.blend(ga,oa),selectionInactiveBackgroundTransparent:oa,selectionInactiveBackgroundOpaque:Vt.blend(ga,oa),scrollbarSliderBackground:Vt.opacity(_r,.2),scrollbarSliderHoverBackground:Vt.opacity(_r,.4),scrollbarSliderActiveBackground:Vt.opacity(_r,.5),overviewRulerBorder:_r,ansi:yn.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Bt(e.foreground,_r),t.background=Bt(e.background,ga),t.cursor=Vt.blend(t.background,Bt(e.cursor,Yv)),t.cursorAccent=Vt.blend(t.background,Bt(e.cursorAccent,Gv)),t.selectionBackgroundTransparent=Bt(e.selectionBackground,oa),t.selectionBackgroundOpaque=Vt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Bt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Vt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Bt(e.selectionForeground,Hv):void 0,t.selectionForeground===Hv&&(t.selectionForeground=void 0),Vt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Vt.opacity(t.selectionBackgroundTransparent,.3)),Vt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Vt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Bt(e.scrollbarSliderBackground,Vt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Bt(e.scrollbarSliderHoverBackground,Vt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Bt(e.scrollbarSliderActiveBackground,Vt.opacity(t.foreground,.5)),t.overviewRulerBorder=Bt(e.overviewRulerBorder,uE),t.ansi=yn.slice(),t.ansi[0]=Bt(e.black,yn[0]),t.ansi[1]=Bt(e.red,yn[1]),t.ansi[2]=Bt(e.green,yn[2]),t.ansi[3]=Bt(e.yellow,yn[3]),t.ansi[4]=Bt(e.blue,yn[4]),t.ansi[5]=Bt(e.magenta,yn[5]),t.ansi[6]=Bt(e.cyan,yn[6]),t.ansi[7]=Bt(e.white,yn[7]),t.ansi[8]=Bt(e.brightBlack,yn[8]),t.ansi[9]=Bt(e.brightRed,yn[9]),t.ansi[10]=Bt(e.brightGreen,yn[10]),t.ansi[11]=Bt(e.brightYellow,yn[11]),t.ansi[12]=Bt(e.brightBlue,yn[12]),t.ansi[13]=Bt(e.brightMagenta,yn[13]),t.ansi[14]=Bt(e.brightCyan,yn[14]),t.ansi[15]=Bt(e.brightWhite,yn[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<n;s++)t.ansi[s+16]=Bt(e.extendedAnsi[s],yn[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};tf=an([Fe(0,Xn)],tf);function Bt(e,t){if(e!==void 0)try{return tn.toColor(e)}catch{}return t}var dE=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},hE=class{constructor(){this._services=new dE,this._services.set(Yf,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=r1(e).sort((a,u)=>a.index-u.index),s=[];for(let a of n){let u=this._services.get(a.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${a.id._id}.`);s.push(u)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},fE={trace:0,debug:1,info:2,warn:3,error:4,off:5},pE="xterm.js: ",nf=class extends gt{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=fE[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":pE)+t,...n)}trace(e,...t){var n;this._logLevel<=0&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var n;this._logLevel<=1&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var n;this._logLevel<=2&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var n;this._logLevel<=3&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var n;this._logLevel<=4&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.error.bind(this._optionsService.options.logger))??console.error,e,t)}};nf=an([Fe(0,Xn)],nf);var Xv=class extends gt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Pe),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Pe),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Pe),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<n.length;s++)this._array[this._getCyclicIndex(e+s)]=n[s];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let o=t-1;o>=0;o--)this.set(e+o+n,this.get(e+o));let s=e+t+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+n,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},mt=3,pn=Object.freeze(new La),Yl=0,Rd=2,va=class rw{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*mt);let o=n||Ri.fromCharData([0,kb,1,0]);for(let a=0;a<t;++a)this.setCell(a,o);this.length=t}get(t){let n=this._data[t*mt+0],s=n&2097151;return[this._data[t*mt+1],n&2097152?this._combined[t]:s?Us(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*mt+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*mt+0]=t|2097152|n[2]<<22):this._data[t*mt+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*mt+0]>>22}hasWidth(t){return this._data[t*mt+0]&12582912}getFg(t){return this._data[t*mt+1]}getBg(t){return this._data[t*mt+2]}hasContent(t){return this._data[t*mt+0]&4194303}getCodePoint(t){let n=this._data[t*mt+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*mt+0]&2097152}getString(t){let n=this._data[t*mt+0];return n&2097152?this._combined[t]:n&2097151?Us(n&2097151):""}isProtected(t){return this._data[t*mt+2]&536870912}loadCell(t,n){return Yl=t*mt,n.content=this._data[Yl+0],n.fg=this._data[Yl+1],n.bg=this._data[Yl+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*mt+0]=n.content,this._data[t*mt+1]=n.fg,this._data[t*mt+2]=n.bg}setCellFromCodepoint(t,n,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*mt+0]=n|s<<22,this._data[t*mt+1]=o.fg,this._data[t*mt+2]=o.bg}addCodepointToCell(t,n,s){let o=this._data[t*mt+0];o&2097152?this._combined[t]+=Us(n):o&2097151?(this._combined[t]=Us(o&2097151)+Us(n),o&=-2097152,o|=2097152):o=n|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*mt+0]=o}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length-t){let o=new Ri;for(let a=this.length-t-n-1;a>=0;--a)this.setCell(t+n+a,this.loadCell(t+a,o));for(let a=0;a<n;++a)this.setCell(t+a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,n,s){if(t%=this.length,n<this.length-t){let o=new Ri;for(let a=0;a<this.length-t-n;++a)this.setCell(t+a,this.loadCell(t+n+a,o));for(let a=this.length-n;a<this.length;++a)this.setCell(a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,n,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.setCell(t++,s)}resize(t,n){if(t===this.length)return this._data.length*4*Rd<this._data.buffer.byteLength;let s=t*mt;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let u=0;u<o.length;u++){let d=parseInt(o[u],10);d>=t&&delete this._combined[d]}let a=Object.keys(this._extendedAttrs);for(let u=0;u<a.length;u++){let d=parseInt(a[u],10);d>=t&&delete this._extendedAttrs[d]}}return this.length=t,s*4*Rd<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Rd<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new rw(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*mt+0]&4194303)return t+(this._data[t*mt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*mt+0]&4194303||this._data[t*mt+2]&50331648)return t+(this._data[t*mt+0]>>22);return 0}copyCellsFrom(t,n,s,o,a){let u=t._data;if(a)for(let p=o-1;p>=0;p--){for(let m=0;m<mt;m++)this._data[(s+p)*mt+m]=u[(n+p)*mt+m];u[(n+p)*mt+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[n+p])}else for(let p=0;p<o;p++){for(let m=0;m<mt;m++)this._data[(s+p)*mt+m]=u[(n+p)*mt+m];u[(n+p)*mt+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[n+p])}let d=Object.keys(t._combined);for(let p=0;p<d.length;p++){let m=parseInt(d[p],10);m>=n&&(this._combined[m-n+s]=t._combined[m])}}translateToString(t,n,s,o){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let a="";for(;n<s;){let u=this._data[n*mt+0],d=u&2097151,p=u&2097152?this._combined[n]:d?Us(d):Ks;if(a+=p,o)for(let m=0;m<p.length;++m)o.push(n);n+=u>>22||1}return o&&o.push(n),a}};function mE(e,t,n,s,o,a){let u=[];for(let d=0;d<e.length-1;d++){let p=d,m=e.get(++p);if(!m.isWrapped)continue;let v=[e.get(d)];for(;p<e.length&&m.isWrapped;)v.push(m),m=e.get(++p);if(!a&&s>=d&&s<p){d+=v.length-1;continue}let y=0,b=Na(v,y,t),S=1,x=0;for(;S<v.length;){let w=Na(v,S,t),N=w-x,C=n-b,L=Math.min(N,C);v[y].copyCellsFrom(v[S],x,b,L,!1),b+=L,b===n&&(y++,b=0),x+=L,x===w&&(S++,x=0),b===0&&y!==0&&v[y-1].getWidth(n-1)===2&&(v[y].copyCellsFrom(v[y-1],n-1,b++,1,!1),v[y-1].setCell(n-1,o))}v[y].replaceCells(b,n,o);let E=0;for(let w=v.length-1;w>0&&(w>y||v[w].getTrimmedLength()===0);w--)E++;E>0&&(u.push(d+v.length-E),u.push(E)),d+=v.length-1}return u}function gE(e,t){let n=[],s=0,o=t[s],a=0;for(let u=0;u<e.length;u++)if(o===u){let d=t[++s];e.onDeleteEmitter.fire({index:u-a,amount:d}),u+=d-1,a+=d,o=t[++s]}else n.push(u);return{layout:n,countRemoved:a}}function vE(e,t){let n=[];for(let s=0;s<t.length;s++)n.push(e.get(t[s]));for(let s=0;s<n.length;s++)e.set(s,n[s]);e.length=t.length}function _E(e,t,n){let s=[],o=e.map((p,m)=>Na(e,m,t)).reduce((p,m)=>p+m),a=0,u=0,d=0;for(;d<o;){if(o-d<n){s.push(o-d);break}a+=n;let p=Na(e,u,t);a>p&&(a-=p,u++);let m=e[u].getWidth(a-1)===2;m&&a--;let v=m?n-1:n;s.push(v),d+=v}return s}function Na(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?n-1:n}var ow=class aw{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=aw._nextId++,this._onDispose=this.register(new Pe),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Cr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};ow._nextId=1;var yE=ow,wn={},yr=wn.B;wn[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:"≥","{":"π","|":"≠","}":"£","~":"·"};wn.A={"#":"£"};wn.B=void 0;wn[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};wn.C=wn[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};wn.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};wn.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};wn.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};wn.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};wn.E=wn[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};wn.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};wn.H=wn[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};wn["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Qv=4294967295,Jv=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=pn.clone(),this.savedCharset=yr,this.markers=[],this._nullCell=Ri.fromCharData([0,kb,1,0]),this._whitespaceCell=Ri.fromCharData([0,Ks,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new bc,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Xv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new gc),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new gc),this._whitespaceCell}getBlankLine(e,t){return new va(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>Qv?Qv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=pn);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Xv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(pn),s=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let u=0;u<this.lines.length;u++)s+=+this.lines.get(u).resize(e,n);let a=0;if(this._rows<t)for(let u=this._rows;u<t;u++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new va(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new va(e,n)));else for(let u=this._rows;u>t;u--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let u=this.lines.length-o;u>0&&(this.lines.trimStart(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let a=0;a<this.lines.length;a++)s+=+this.lines.get(a).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=mE(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(pn),n);if(s.length>0){let o=gE(this.lines,s);vE(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(pn),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new va(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(pn),o=[],a=0;for(let u=this.lines.length-1;u>=0;u--){let d=this.lines.get(u);if(!d||!d.isWrapped&&d.getTrimmedLength()<=e)continue;let p=[d];for(;d.isWrapped&&u>0;)d=this.lines.get(--u),p.unshift(d);if(!n){let L=this.ybase+this.y;if(L>=u&&L<u+p.length)continue}let m=p[p.length-1].getTrimmedLength(),v=_E(p,this._cols,e),y=v.length-p.length,b;this.ybase===0&&this.y!==this.lines.length-1?b=Math.max(0,this.y-this.lines.maxLength+y):b=Math.max(0,this.lines.length-this.lines.maxLength+y);let S=[];for(let L=0;L<y;L++){let I=this.getBlankLine(pn,!0);S.push(I)}S.length>0&&(o.push({start:u+p.length+a,newLines:S}),a+=S.length),p.push(...S);let x=v.length-1,E=v[x];E===0&&(x--,E=v[x]);let w=p.length-y-1,N=m;for(;w>=0;){let L=Math.min(N,E);if(p[x]===void 0)break;if(p[x].copyCellsFrom(p[w],N-L,E-L,L,!0),E-=L,E===0&&(x--,E=v[x]),N-=L,N===0){w--;let I=Math.max(w,0);N=Na(p,I,this._cols)}}for(let L=0;L<p.length;L++)v[L]<e&&p[L].setCell(v[L],s);let C=y-b;for(;C-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+y,this.ybase+t-1)}if(o.length>0){let u=[],d=[];for(let E=0;E<this.lines.length;E++)d.push(this.lines.get(E));let p=this.lines.length,m=p-1,v=0,y=o[v];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let b=0;for(let E=Math.min(this.lines.maxLength-1,p+a-1);E>=0;E--)if(y&&y.start>m+b){for(let w=y.newLines.length-1;w>=0;w--)this.lines.set(E--,y.newLines[w]);E++,u.push({index:m+1,amount:y.newLines.length}),b+=y.newLines.length,y=o[++v]}else this.lines.set(E,d[m--]);let S=0;for(let E=u.length-1;E>=0;E--)u[E].index+=S,this.lines.onInsertEmitter.fire(u[E]),S+=u[E].amount;let x=Math.max(0,p+a-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,n=0,s){let o=this.lines.get(e);return o?o.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new yE(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},bE=class extends gt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Pe),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 Jv(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Jv(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},lw=2,cw=1,sf=class extends gt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Pe),this.onResize=this._onResize.event,this._onScroll=this._register(new Pe),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,lw),this.rows=Math.max(e.rawOptions.rows||0,cw),this.buffers=this._register(new bE(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let u=n.lines.isFull;a===n.lines.length-1?u?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(a+1,0,s.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=a-o+1;n.lines.shiftElements(o+1,u-1,-1),n.lines.set(a,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};sf=an([Fe(0,Xn)],sf);var oo={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:yc,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},wE=["normal","bold","100","200","300","400","500","600","700","800","900"],SE=class extends gt{constructor(e){super(),this._onOptionChange=this._register(new Pe),this.onOptionChange=this._onOptionChange.event;let t={...oo};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Qt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in oo))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in oo))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=oo[e]),!xE(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=oo[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=wE.includes(t)?t:oo[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function xE(e){return e==="block"||e==="underline"||e==="bar"}function _a(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&_a(e[s],t-1);return n}var Zv=Object.freeze({insertMode:!1}),e_=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),rf=class extends gt{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Pe),this.onData=this._onData.event,this._onUserInput=this._register(new Pe),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Pe),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Pe),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=_a(Zv),this.decPrivateModes=_a(e_)}reset(){this.modes=_a(Zv),this.decPrivateModes=_a(e_)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};rf=an([Fe(0,Gn),Fe(1,Rb),Fe(2,Xn)],rf);var t_={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Pd(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var Ld=String.fromCharCode,n_={DEFAULT:e=>{let t=[Pd(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Ld(t[0])}${Ld(t[1])}${Ld(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Pd(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Pd(e,!0)};${e.x};${e.y}${t}`}},of=class extends gt{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Pe),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(t_))this.addProtocol(s,t_[s]);for(let s of Object.keys(n_))this.addEncoding(s,n_[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=s+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};of=an([Fe(0,Gn),Fe(1,Nr),Fe(2,Xn)],of);var Ad=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],kE=[[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]],bn;function CE(e,t){let n=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=n;)if(o=n+s>>1,e>t[o][1])n=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var EE=class{constructor(){if(this.version="6",!bn){bn=new Uint8Array(65536),bn.fill(1),bn[0]=0,bn.fill(0,1,32),bn.fill(0,127,160),bn.fill(2,4352,4448),bn[9001]=2,bn[9002]=2,bn.fill(2,11904,42192),bn[12351]=1,bn.fill(2,44032,55204),bn.fill(2,63744,64256),bn.fill(2,65040,65050),bn.fill(2,65072,65136),bn.fill(2,65280,65377),bn.fill(2,65504,65511);for(let e=0;e<Ad.length;++e)bn.fill(0,Ad[e][0],Ad[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?bn[e]:CE(e,kE)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let o=Sr.extractWidth(t);o===0?s=!1:o>n&&(n=o)}return Sr.createPropertyValue(0,n,s)}},Sr=class oc{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Pe,this.onChange=this._onChange.event;let t=new EE;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,s=!1){return(t&16777215)<<3|(n&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,s=0,o=t.length;for(let a=0;a<o;++a){let u=t.charCodeAt(a);if(55296<=u&&u<=56319){if(++a>=o)return n+this.wcwidth(u);let m=t.charCodeAt(a);56320<=m&&m<=57343?u=(u-55296)*1024+m-56320+65536:n+=this.wcwidth(m)}let d=this.charProperties(u,s),p=oc.extractWidth(d);oc.extractShouldJoin(d)&&(p-=oc.extractWidth(s)),n+=p,s=d}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},NE=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function i_(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var aa=2147483647,jE=256,uw=class af{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>jE)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new af;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let a=0;a<o.length;++a)n.addSubParam(o[a]);else n.addParam(o)}return n}clone(){let t=new af(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>aa?aa:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>aa?aa:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&(t[n]=this._subParams.slice(s,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[n-1];s[n-1]=~o?Math.min(o*10+t,aa):t}},la=[],RE=class{constructor(){this._state=0,this._active=la,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=la}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=la,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||la,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",jc(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=la,this._id=-1,this._state=0}}},pi=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=jc(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},ca=[],PE=class{constructor(){this._handlers=Object.create(null),this._active=ca,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ca}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=ca,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||ca,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",jc(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=ca,this._ident=0}},ya=new uw;ya.addParam(0);var s_=class{constructor(e){this._handler=e,this._data="",this._params=ya,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ya,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=jc(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=ya,this._data="",this._hitLimit=!1,n));return this._params=ya,this._data="",this._hitLimit=!1,t}},LE=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|s}},ji=160,AE=(function(){let e=new LE(4095),t=Array.apply(null,Array(256)).map((d,p)=>p),n=(d,p)=>t.slice(d,p),s=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let a=n(0,14),u;e.setDefault(1,0),e.addMany(s,0,2,0);for(u in a)e.addMany([24,26,153,154],u,3,0),e.addMany(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(ji,0,2,0),e.add(ji,8,5,8),e.add(ji,6,0,6),e.add(ji,11,0,11),e.add(ji,13,13,13),e})(),ME=class extends gt{constructor(e=AE){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 uw,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Qt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new RE),this._dcsParser=this._register(new PE),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let a=e.intermediates.charCodeAt(o);if(32>a||a>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=a}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,n){let s=0,o=0,a=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let d=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&p>-1){for(;p>=0&&(u=d[p](this._params),u!==!0);p--)if(u instanceof Promise)return this._parseStack.handlerPos=p,u}this._parseStack.handlers=[];break;case 4:if(n===!1&&p>-1){for(;p>=0&&(u=d[p](),u!==!0);p--)if(u instanceof Promise)return this._parseStack.handlerPos=p,u}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(s!==24&&s!==26,n),u)return u;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],u=this._oscParser.end(s!==24&&s!==26,n),u)return u;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let d=a;d<t;++d){switch(s=e[d],o=this._transitions.table[this.currentState<<8|(s<160?s:ji)],o>>4){case 2:for(let b=d+1;;++b){if(b>=t||(s=e[b])<32||s>126&&s<ji){this._printHandler(e,d,b),d=b-1;break}if(++b>=t||(s=e[b])<32||s>126&&s<ji){this._printHandler(e,d,b),d=b-1;break}if(++b>=t||(s=e[b])<32||s>126&&s<ji){this._printHandler(e,d,b),d=b-1;break}if(++b>=t||(s=e[b])<32||s>126&&s<ji){this._printHandler(e,d,b),d=b-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:d,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let p=this._csiHandlers[this._collect<<8|s],m=p?p.length-1:-1;for(;m>=0&&(u=p[m](this._params),u!==!0);m--)if(u instanceof Promise)return this._preserveStack(3,p,m,o,d),u;m<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++d<t&&(s=e[d])>47&&s<60);d--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let v=this._escHandlers[this._collect<<8|s],y=v?v.length-1:-1;for(;y>=0&&(u=v[y](),u!==!0);y--)if(u instanceof Promise)return this._preserveStack(4,v,y,o,d),u;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 b=d+1;;++b)if(b>=t||(s=e[b])===24||s===26||s===27||s>127&&s<ji){this._dcsParser.put(e,d,b),d=b-1;break}break;case 14:if(u=this._dcsParser.unhook(s!==24&&s!==26),u)return this._preserveStack(6,[],0,o,d),u;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let b=d+1;;b++)if(b>=t||(s=e[b])<32||s>127&&s<ji){this._oscParser.put(e,d,b),d=b-1;break}break;case 6:if(u=this._oscParser.end(s!==24&&s!==26),u)return this._preserveStack(5,[],0,o,d),u;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},TE=/^([\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})$/,DE=/^[\da-f]+$/;function r_(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=TE.exec(t);if(n){let s=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/s*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/s*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),DE.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let a=parseInt(t.slice(n*o,n*o+n),16);s[o]=n===1?a<<4:n===2?a:n===3?a>>4:a>>8}return s}}function Md(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function IE(e,t=16){let[n,s,o]=e;return`rgb:${Md(n,t)}/${Md(s,t)}/${Md(o,t)}`}var OE={"(":0,")":1,"*":2,"+":3,"-":1,".":2},$s=131072,o_=10;function a_(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var l_=5e3,c_=0,BE=class extends gt{constructor(e,t,n,s,o,a,u,d,p=new ME){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=o,this._oscLinkService=a,this._coreMouseService=u,this._unicodeService=d,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new i1,this._utf8Decoder=new s1,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=pn.clone(),this._eraseAttrDataInternal=pn.clone(),this._onRequestBell=this._register(new Pe),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Pe),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Pe),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Pe),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Pe),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Pe),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Pe),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Pe),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Pe),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Pe),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Pe),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Pe),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Pe),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 lf(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(m=>this._activeBuffer=m.activeBuffer)),this._parser.setCsiHandlerFallback((m,v)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(m),params:v.toArray()})}),this._parser.setEscHandlerFallback(m=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(m)})}),this._parser.setExecuteHandlerFallback(m=>{this._logService.debug("Unknown EXECUTE code: ",{code:m})}),this._parser.setOscHandlerFallback((m,v,y)=>{this._logService.debug("Unknown OSC code: ",{identifier:m,action:v,data:y})}),this._parser.setDcsHandlerFallback((m,v,y)=>{v==="HOOK"&&(y=y.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(m),action:v,payload:y})}),this._parser.setPrintHandler((m,v,y)=>this.print(m,v,y)),this._parser.registerCsiHandler({final:"@"},m=>this.insertChars(m)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},m=>this.scrollLeft(m)),this._parser.registerCsiHandler({final:"A"},m=>this.cursorUp(m)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},m=>this.scrollRight(m)),this._parser.registerCsiHandler({final:"B"},m=>this.cursorDown(m)),this._parser.registerCsiHandler({final:"C"},m=>this.cursorForward(m)),this._parser.registerCsiHandler({final:"D"},m=>this.cursorBackward(m)),this._parser.registerCsiHandler({final:"E"},m=>this.cursorNextLine(m)),this._parser.registerCsiHandler({final:"F"},m=>this.cursorPrecedingLine(m)),this._parser.registerCsiHandler({final:"G"},m=>this.cursorCharAbsolute(m)),this._parser.registerCsiHandler({final:"H"},m=>this.cursorPosition(m)),this._parser.registerCsiHandler({final:"I"},m=>this.cursorForwardTab(m)),this._parser.registerCsiHandler({final:"J"},m=>this.eraseInDisplay(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},m=>this.eraseInDisplay(m,!0)),this._parser.registerCsiHandler({final:"K"},m=>this.eraseInLine(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},m=>this.eraseInLine(m,!0)),this._parser.registerCsiHandler({final:"L"},m=>this.insertLines(m)),this._parser.registerCsiHandler({final:"M"},m=>this.deleteLines(m)),this._parser.registerCsiHandler({final:"P"},m=>this.deleteChars(m)),this._parser.registerCsiHandler({final:"S"},m=>this.scrollUp(m)),this._parser.registerCsiHandler({final:"T"},m=>this.scrollDown(m)),this._parser.registerCsiHandler({final:"X"},m=>this.eraseChars(m)),this._parser.registerCsiHandler({final:"Z"},m=>this.cursorBackwardTab(m)),this._parser.registerCsiHandler({final:"`"},m=>this.charPosAbsolute(m)),this._parser.registerCsiHandler({final:"a"},m=>this.hPositionRelative(m)),this._parser.registerCsiHandler({final:"b"},m=>this.repeatPrecedingCharacter(m)),this._parser.registerCsiHandler({final:"c"},m=>this.sendDeviceAttributesPrimary(m)),this._parser.registerCsiHandler({prefix:">",final:"c"},m=>this.sendDeviceAttributesSecondary(m)),this._parser.registerCsiHandler({final:"d"},m=>this.linePosAbsolute(m)),this._parser.registerCsiHandler({final:"e"},m=>this.vPositionRelative(m)),this._parser.registerCsiHandler({final:"f"},m=>this.hVPosition(m)),this._parser.registerCsiHandler({final:"g"},m=>this.tabClear(m)),this._parser.registerCsiHandler({final:"h"},m=>this.setMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"h"},m=>this.setModePrivate(m)),this._parser.registerCsiHandler({final:"l"},m=>this.resetMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"l"},m=>this.resetModePrivate(m)),this._parser.registerCsiHandler({final:"m"},m=>this.charAttributes(m)),this._parser.registerCsiHandler({final:"n"},m=>this.deviceStatus(m)),this._parser.registerCsiHandler({prefix:"?",final:"n"},m=>this.deviceStatusPrivate(m)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},m=>this.softReset(m)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},m=>this.setCursorStyle(m)),this._parser.registerCsiHandler({final:"r"},m=>this.setScrollRegion(m)),this._parser.registerCsiHandler({final:"s"},m=>this.saveCursor(m)),this._parser.registerCsiHandler({final:"t"},m=>this.windowOptions(m)),this._parser.registerCsiHandler({final:"u"},m=>this.restoreCursor(m)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},m=>this.insertColumns(m)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},m=>this.deleteColumns(m)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},m=>this.selectProtected(m)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},m=>this.requestMode(m,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},m=>this.requestMode(m,!1)),this._parser.setExecuteHandler(ge.BEL,()=>this.bell()),this._parser.setExecuteHandler(ge.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(ge.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(ge.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(ge.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(ge.BS,()=>this.backspace()),this._parser.setExecuteHandler(ge.HT,()=>this.tab()),this._parser.setExecuteHandler(ge.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(ge.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(sc.IND,()=>this.index()),this._parser.setExecuteHandler(sc.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(sc.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new pi(m=>(this.setTitle(m),this.setIconName(m),!0))),this._parser.registerOscHandler(1,new pi(m=>this.setIconName(m))),this._parser.registerOscHandler(2,new pi(m=>this.setTitle(m))),this._parser.registerOscHandler(4,new pi(m=>this.setOrReportIndexedColor(m))),this._parser.registerOscHandler(8,new pi(m=>this.setHyperlink(m))),this._parser.registerOscHandler(10,new pi(m=>this.setOrReportFgColor(m))),this._parser.registerOscHandler(11,new pi(m=>this.setOrReportBgColor(m))),this._parser.registerOscHandler(12,new pi(m=>this.setOrReportCursorColor(m))),this._parser.registerOscHandler(104,new pi(m=>this.restoreIndexedColor(m))),this._parser.registerOscHandler(110,new pi(m=>this.restoreFgColor(m))),this._parser.registerOscHandler(111,new pi(m=>this.restoreBgColor(m))),this._parser.registerOscHandler(112,new pi(m=>this.restoreCursorColor(m))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let m in wn)this._parser.registerEscHandler({intermediates:"(",final:m},()=>this.selectCharset("("+m)),this._parser.registerEscHandler({intermediates:")",final:m},()=>this.selectCharset(")"+m)),this._parser.registerEscHandler({intermediates:"*",final:m},()=>this.selectCharset("*"+m)),this._parser.registerEscHandler({intermediates:"+",final:m},()=>this.selectCharset("+"+m)),this._parser.registerEscHandler({intermediates:"-",final:m},()=>this.selectCharset("-"+m)),this._parser.registerEscHandler({intermediates:".",final:m},()=>this.selectCharset("."+m)),this._parser.registerEscHandler({intermediates:"/",final:m},()=>this.selectCharset("/"+m));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(m=>(this._logService.error("Parsing error: ",m),m)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new s_((m,v)=>this.requestStatusString(m,v)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),l_))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${l_} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,o=this._activeBuffer.y,a=0,u=this._parseStack.paused;if(u){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>$s&&(a=this._parseStack.position+$s)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,m=>String.fromCharCode(m)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(m=>m.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<$s&&(this._parseBuffer=new Uint32Array(Math.min(e.length,$s))),u||this._dirtyRowTracker.clearRange(),e.length>$s)for(let m=a;m<e.length;m+=$s){let v=m+$s<e.length?m+$s:e.length,y=typeof e=="string"?this._stringDecoder.decode(e.substring(m,v),this._parseBuffer):this._utf8Decoder.decode(e.subarray(m,v),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,y))return this._preserveStack(s,o,y,m),this._logSlowResolvingAsync(n),n}else if(!u){let m=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,m))return this._preserveStack(s,o,m,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let d=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),p=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);p<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(p,this._bufferService.rows-1),end:Math.min(d,this._bufferService.rows-1)})}print(e,t,n){let s,o,a=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,d=this._bufferService.cols,p=this._coreService.decPrivateModes.wraparound,m=this._coreService.modes.insertMode,v=this._curAttrData,y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&y.getWidth(this._activeBuffer.x-1)===2&&y.setCellFromCodepoint(this._activeBuffer.x-1,0,1,v);let b=this._parser.precedingJoinState;for(let S=t;S<n;++S){if(s=e[S],s<127&&a){let N=a[String.fromCharCode(s)];N&&(s=N.charCodeAt(0))}let x=this._unicodeService.charProperties(s,b);o=Sr.extractWidth(x);let E=Sr.extractShouldJoin(x),w=E?Sr.extractWidth(b):0;if(b=x,u&&this._onA11yChar.fire(Us(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-w>d){if(p){let N=y,C=this._activeBuffer.x-w;for(this._activeBuffer.x=w,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),w>0&&y instanceof va&&y.copyCellsFrom(N,C,0,w,!1);C<d;)N.setCellFromCodepoint(C++,0,1,v)}else if(this._activeBuffer.x=d-1,o===2)continue}if(E&&this._activeBuffer.x){let N=y.getWidth(this._activeBuffer.x-1)?1:2;y.addCodepointToCell(this._activeBuffer.x-N,s,o);for(let C=o-w;--C>=0;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,v);continue}if(m&&(y.insertCells(this._activeBuffer.x,o-w,this._activeBuffer.getNullCell(v)),y.getWidth(d-1)===2&&y.setCellFromCodepoint(d-1,0,1,v)),y.setCellFromCodepoint(this._activeBuffer.x++,s,o,v),o>0)for(;--o;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,v)}this._parser.precedingJoinState=b,this._activeBuffer.x<d&&n-t>0&&y.getWidth(this._activeBuffer.x)===0&&!y.hasContent(this._activeBuffer.x)&&y.setCellFromCodepoint(this._activeBuffer.x,0,1,v),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>a_(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new s_(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new pi(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,o=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&s.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let o=this._activeBuffer.lines.length-this._bufferService.rows;o>0&&(this._activeBuffer.lines.trimStart(o),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-o,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-o,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(pn));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,s=Sr.extractWidth(t),o=this._activeBuffer.x-s,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(a.length*n),d=0;for(let m=0;m<a.length;){let v=a.codePointAt(m)||0;u[d++]=v,m+=v>65535?2:1}let p=d;for(let m=1;m<n;++m)u.copyWithin(p,0,d),p+=d;return this.print(u,0,p),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(ge.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(ge.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(ge.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(ge.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(ge.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,yr),this._charsetService.setgCharset(1,yr),this._charsetService.setgCharset(2,yr),this._charsetService.setgCharset(3,yr);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(E=>(E[E.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",E[E.SET=1]="SET",E[E.RESET=2]="RESET",E[E.PERMANENTLY_SET=3]="PERMANENTLY_SET",E[E.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:a}=this._coreMouseService,u=this._coreService,{buffers:d,cols:p}=this._bufferService,{active:m,alt:v}=d,y=this._optionsService.rawOptions,b=(E,w)=>(u.triggerDataEvent(`${ge.ESC}[${t?"":"?"}${E};${w}$y`),!0),S=E=>E?1:2,x=e.params[0];return t?x===2?b(x,4):x===4?b(x,S(u.modes.insertMode)):x===12?b(x,3):x===20?b(x,S(y.convertEol)):b(x,0):x===1?b(x,S(s.applicationCursorKeys)):x===3?b(x,y.windowOptions.setWinLines?p===80?2:p===132?1:0:0):x===6?b(x,S(s.origin)):x===7?b(x,S(s.wraparound)):x===8?b(x,3):x===9?b(x,S(o==="X10")):x===12?b(x,S(y.cursorBlink)):x===25?b(x,S(!u.isCursorHidden)):x===45?b(x,S(s.reverseWraparound)):x===66?b(x,S(s.applicationKeypad)):x===67?b(x,4):x===1e3?b(x,S(o==="VT200")):x===1002?b(x,S(o==="DRAG")):x===1003?b(x,S(o==="ANY")):x===1004?b(x,S(s.sendFocus)):x===1005?b(x,4):x===1006?b(x,S(a==="SGR")):x===1015?b(x,4):x===1016?b(x,S(a==="SGR_PIXELS")):x===1048?b(x,1):x===47||x===1047||x===1049?b(x,S(m===v)):x===2004?b(x,S(s.bracketedPasteMode)):x===2026?b(x,S(s.synchronizedOutput)):b(x,0)}_updateAttrColor(e,t,n,s,o){return t===2?(e|=50331648,e&=-16777216,e|=La.fromColorRGB([n,s,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],o=0,a=0;do{if(s[a+o]=e.params[t+a],e.hasSubParams(t+a)){let u=e.getSubParams(t+a),d=0;do s[1]===5&&(o=1),s[a+d+1+o]=u[d];while(++d<u.length&&d+a+1+o<s.length);break}if(s[1]===5&&a+o>=2||s[1]===2&&a+o>=5)break;s[1]&&(o=1)}while(++a+t<e.length&&a+o<s.length);for(let u=2;u<s.length;++u)s[u]===-1&&(s[u]=0);switch(s[0]){case 38:n.fg=this._updateAttrColor(n.fg,s[1],s[3],s[4],s[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,s[1],s[3],s[4],s[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,s[1],s[3],s[4],s[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=pn.fg,e.bg=pn.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=pn.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=pn.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=pn.fg&16777215,s.bg&=-67108864,s.bg|=pn.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${ge.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ge.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ge.ESC}[?${t};${n}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=pn.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!a_(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${ge.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>o_&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>o_&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),o=n.shift();if(/^\d+$/.exec(s)){let a=parseInt(s);if(u_(a))if(o==="?")t.push({type:0,index:a});else{let u=r_(o);u&&t.push({type:1,index:a,color:u})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,o=n.findIndex(a=>a.startsWith("id="));return o!==-1&&(s=n[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let s=0;s<n.length&&!(t>=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=r_(n[s]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let s=0;s<n.length;++s)if(/^\d+$/.exec(n[s])){let o=parseInt(n[s]);u_(o)&&t.push({type:2,index:o})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,yr),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(OE[e[0]],wn[e[1]]||yr),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=pn.clone(),this._eraseAttrDataInternal=pn.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Ri;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(n);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=u=>(this._coreService.triggerDataEvent(`${ge.ESC}${u}${ge.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},lf=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(c_=e,e=t,t=c_),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};lf=an([Fe(0,Gn)],lf);function u_(e){return 0<=e&&e<256}var zE=5e7,d_=12,$E=50,FE=class extends gt{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 Pe),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>zE)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let u=d=>performance.now()-n>=d_?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(n,d);o.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(u);return}let a=this._callbacks[this._bufferOffset];if(a&&a(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=d_)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>$E&&(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()}},cf=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let d=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(p,d)),this._dataByLinkId.set(p.id,p),p.id}let n=e,s=this._getEntryIdKey(n),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let a=t.addMarker(t.ybase+t.y),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(u,a)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};cf=an([Fe(0,Gn)],cf);var h_=!1,HE=class extends gt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new yo),this._onBinary=this._register(new Pe),this.onBinary=this._onBinary.event,this._onData=this._register(new Pe),this.onData=this._onData.event,this._onLineFeed=this._register(new Pe),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Pe),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Pe),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Pe),this._instantiationService=new hE,this.optionsService=this._register(new SE(e)),this._instantiationService.setService(Xn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(sf)),this._instantiationService.setService(Gn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(nf)),this._instantiationService.setService(Rb,this._logService),this.coreService=this._register(this._instantiationService.createInstance(rf)),this._instantiationService.setService(Nr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(of)),this._instantiationService.setService(jb,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Sr)),this._instantiationService.setService(l1,this.unicodeService),this._charsetService=this._instantiationService.createInstance(NE),this._instantiationService.setService(a1,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(cf),this._instantiationService.setService(Pb,this._oscLinkService),this._inputHandler=this._register(new BE(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(On.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(On.forward(this._bufferService.onResize,this._onResize)),this._register(On.forward(this.coreService.onData,this._onData)),this._register(On.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 FE((t,n)=>this._inputHandler.parse(t,n))),this._register(On.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Pe),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!h_&&(this._logService.warn("writeSync is unreliable and will be removed soon."),h_=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,lw),t=Math.max(t,cw),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(i_.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(i_(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Qt(()=>{for(let t of e)t.dispose()})}}},UE={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 WE(e,t,n,s){var u;let o={type:0,cancel:!1,key:void 0},a=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?o.key=ge.ESC+"OA":o.key=ge.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=ge.ESC+"OD":o.key=ge.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=ge.ESC+"OC":o.key=ge.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=ge.ESC+"OB":o.key=ge.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":ge.DEL,e.altKey&&(o.key=ge.ESC+o.key);break;case 9:if(e.shiftKey){o.key=ge.ESC+"[Z";break}o.key=ge.HT,o.cancel=!0;break;case 13:o.key=e.altKey?ge.ESC+ge.CR:ge.CR,o.cancel=!0;break;case 27:o.key=ge.ESC,e.altKey&&(o.key=ge.ESC+ge.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;a?o.key=ge.ESC+"[1;"+(a+1)+"D":t?o.key=ge.ESC+"OD":o.key=ge.ESC+"[D";break;case 39:if(e.metaKey)break;a?o.key=ge.ESC+"[1;"+(a+1)+"C":t?o.key=ge.ESC+"OC":o.key=ge.ESC+"[C";break;case 38:if(e.metaKey)break;a?o.key=ge.ESC+"[1;"+(a+1)+"A":t?o.key=ge.ESC+"OA":o.key=ge.ESC+"[A";break;case 40:if(e.metaKey)break;a?o.key=ge.ESC+"[1;"+(a+1)+"B":t?o.key=ge.ESC+"OB":o.key=ge.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=ge.ESC+"[2~");break;case 46:a?o.key=ge.ESC+"[3;"+(a+1)+"~":o.key=ge.ESC+"[3~";break;case 36:a?o.key=ge.ESC+"[1;"+(a+1)+"H":t?o.key=ge.ESC+"OH":o.key=ge.ESC+"[H";break;case 35:a?o.key=ge.ESC+"[1;"+(a+1)+"F":t?o.key=ge.ESC+"OF":o.key=ge.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=ge.ESC+"[5;"+(a+1)+"~":o.key=ge.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=ge.ESC+"[6;"+(a+1)+"~":o.key=ge.ESC+"[6~";break;case 112:a?o.key=ge.ESC+"[1;"+(a+1)+"P":o.key=ge.ESC+"OP";break;case 113:a?o.key=ge.ESC+"[1;"+(a+1)+"Q":o.key=ge.ESC+"OQ";break;case 114:a?o.key=ge.ESC+"[1;"+(a+1)+"R":o.key=ge.ESC+"OR";break;case 115:a?o.key=ge.ESC+"[1;"+(a+1)+"S":o.key=ge.ESC+"OS";break;case 116:a?o.key=ge.ESC+"[15;"+(a+1)+"~":o.key=ge.ESC+"[15~";break;case 117:a?o.key=ge.ESC+"[17;"+(a+1)+"~":o.key=ge.ESC+"[17~";break;case 118:a?o.key=ge.ESC+"[18;"+(a+1)+"~":o.key=ge.ESC+"[18~";break;case 119:a?o.key=ge.ESC+"[19;"+(a+1)+"~":o.key=ge.ESC+"[19~";break;case 120:a?o.key=ge.ESC+"[20;"+(a+1)+"~":o.key=ge.ESC+"[20~";break;case 121:a?o.key=ge.ESC+"[21;"+(a+1)+"~":o.key=ge.ESC+"[21~";break;case 122:a?o.key=ge.ESC+"[23;"+(a+1)+"~":o.key=ge.ESC+"[23~";break;case 123:a?o.key=ge.ESC+"[24;"+(a+1)+"~":o.key=ge.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=ge.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=ge.DEL:e.keyCode===219?o.key=ge.ESC:e.keyCode===220?o.key=ge.FS:e.keyCode===221&&(o.key=ge.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let d=(u=UE[e.keyCode])==null?void 0:u[e.shiftKey?1:0];if(d)o.key=ge.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,m=String.fromCharCode(p);e.shiftKey&&(m=m.toUpperCase()),o.key=ge.ESC+m}else if(e.keyCode===32)o.key=ge.ESC+(e.ctrlKey?ge.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),o.key=ge.ESC+p,o.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=ge.US),e.key==="@"&&(o.key=ge.NUL));break}return o}var cn=0,KE=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new bc,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new bc,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((o,a)=>this._getKey(o)-this._getKey(a)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[o]=e[t],t++):s[o]=this._array[n++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(cn=this._search(t),cn===-1)||this._getKey(this._array[cn])!==t)return!1;do if(this._array[cn]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(cn),!0;while(++cn<this._array.length&&this._getKey(this._array[cn])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,a)=>o-a),t=0,n=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[s++]=this._array[o];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(cn=this._search(e),!(cn<0||cn>=this._array.length)&&this._getKey(this._array[cn])===e))do yield this._array[cn];while(++cn<this._array.length&&this._getKey(this._array[cn])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(cn=this._search(e),!(cn<0||cn>=this._array.length)&&this._getKey(this._array[cn])===e))do t(this._array[cn]);while(++cn<this._array.length&&this._getKey(this._array[cn])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let s=t+n>>1,o=this._getKey(this._array[s]);if(o>e)n=s-1;else if(o<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Td=0,f_=0,qE=class extends gt{constructor(){super(),this._decorations=new KE(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new Pe),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Pe),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Qt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new VE(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let s=0,o=0;for(let a of this._decorations.getKeyIterator(t))s=a.options.x??0,o=s+(a.options.width??1),e>=s&&e<o&&(!n||(a.options.layer??"bottom")===n)&&(yield a)}forEachDecorationAtCell(e,t,n,s){this._decorations.forEachByKey(t,o=>{Td=o.options.x??0,f_=Td+(o.options.width??1),e>=Td&&e<f_&&(!n||(o.options.layer??"bottom")===n)&&s(o)})}},VE=class extends Ys{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Pe),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Pe),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=tn.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=tn.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},YE=1e3,GE=class{constructor(e,t=YE){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=s-this._lastRefreshMs,a=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},a)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},p_=20,wc=class extends gt{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new GE(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(at(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Qt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<p_+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
65
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===p_+1&&(this._liveRegion.textContent+=jh.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let o=e;o<=t;o++){let a=n.lines.get(n.ydisp+o),u=[],d=(a==null?void 0:a.translateToString(!0,void 0,void 0,u))||"",p=(n.ydisp+o+1).toString(),m=this._rowElements[o];m&&(d.length===0?(m.textContent=" ",this._rowColumns.set(m,[0,1])):(m.textContent=d,this._rowColumns.set(m,u)),m.setAttribute("aria-posinset",p),m.setAttribute("aria-setsize",s),this._alignRowWidth(m))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),a=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===a||e.relatedTarget!==s)return;let u,d;if(t===0?(u=n,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(u=this._rowElements.shift(),d=n,this._rowContainer.removeChild(u)),u.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let p=this._createAccessibilityTreeNode();this._rowElements.unshift(p),this._rowContainer.insertAdjacentElement("afterbegin",p)}else{let p=this._createAccessibilityTreeNode();this._rowElements.push(p),this._rowContainer.appendChild(p)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var d;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:((d=s.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(n.node))return;let o=({node:p,offset:m})=>{let v=p instanceof Text?p.parentNode:p,y=parseInt(v==null?void 0:v.getAttribute("aria-posinset"),10)-1;if(isNaN(y))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(v);if(!b)return console.warn("columns is null. Race condition?"),null;let S=m<b.length?b[m]:b.slice(-1)[0]+1;return S>=this._terminal.cols&&(++y,S=0),{row:y,column:S}},a=o(t),u=o(n);if(!(!a||!u)){if(a.row>u.row||a.row===u.row&&a.column>=u.column)throw new Error("invalid range");this._terminal.select(a.column,a.row,(u.row-a.row)*this._terminal.cols-a.column+u.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var o,a;e.style.transform="";let t=e.getBoundingClientRect().width,n=(a=(o=this._rowColumns.get(e))==null?void 0:o.slice(-1))==null?void 0:a[0];if(!n)return;let s=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};wc=an([Fe(1,Yf),Fe(2,gs),Fe(3,vs)],wc);var uf=class extends gt{constructor(e,t,n,s,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Pe),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Pe),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Qt(()=>{var a;Cr(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(at(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(at(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(at(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(at(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s<n.length;s++){let o=n[s];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var s,o;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(a=>{a==null||a.forEach(u=>{u.link.dispose&&u.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[a,u]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(a)&&(n=this._checkLinkProviderResult(a,e,n)):u.provideLinks(e.y,d=>{var m,v;if(this._isMouseOut)return;let p=d==null?void 0:d.map(y=>({link:y}));(m=this._activeProviderReplies)==null||m.set(a,p),n=this._checkLinkProviderResult(a,e,n),((v=this._activeProviderReplies)==null?void 0:v.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let a=0;a<o.length;a++){let u=o[a],d=u.link.range.start.y<e?0:u.link.range.start.x,p=u.link.range.end.y>e?this._bufferService.cols:u.link.range.end.x;for(let m=d;m<=p;m++){if(n.has(m)){o.splice(a--,1);break}n.add(m)}}}}_checkLinkProviderResult(e,t,n){var a;if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),o=!1;for(let u=0;u<e;u++)(!this._activeProviderReplies.has(u)||this._activeProviderReplies.get(u))&&(o=!0);if(!o&&s){let u=s.find(d=>this._linkAtPosition(d.link,t));u&&(n=!0,this._handleNewLink(u))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let u=0;u<this._activeProviderReplies.size;u++){let d=(a=this._activeProviderReplies.get(u))==null?void 0:a.find(p=>this._linkAtPosition(p.link,t));if(d){n=!0,this._handleNewLink(d);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&XE(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Cr(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.pointerCursor},set:n=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.underline},set:n=>{var s,o,a;(s=this._currentLink)!=null&&s.state&&((a=(o=this._currentLink)==null?void 0:o.state)==null?void 0:a.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return n<=o&&o<=s}_positionFromMouseEvent(e,t,n){let s=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,s,o){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:o}}};uf=an([Fe(1,Gf),Fe(2,vs),Fe(3,Gn),Fe(4,Ab)],uf);function XE(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var QE=class extends HE{constructor(e={}){super(e),this._linkifier=this._register(new yo),this.browser=Qb,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new yo),this._onCursorMove=this._register(new Pe),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Pe),this.onKey=this._onKey.event,this._onRender=this._register(new Pe),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Pe),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Pe),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Pe),this.onBell=this._onBell.event,this._onFocus=this._register(new Pe),this._onBlur=this._register(new Pe),this._onA11yCharEmitter=this._register(new Pe),this._onA11yTabEmitter=this._register(new Pe),this._onWillOpen=this._register(new Pe),this._setup(),this._decorationService=this._instantiationService.createInstance(qE),this._instantiationService.setService(Aa,this._decorationService),this._linkProviderService=this._instantiationService.createInstance($C),this._instantiationService.setService(Ab,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Ph)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(On.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(On.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(On.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(On.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Qt(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let o=Vt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${ge.ESC}]${s};${IE(o)}${Gb.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(a=>a.ansi[t.index]=mn.toColor(...t.color));else{let a=n;this._themeService.modifyColors(u=>u[a]=mn.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(wc,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ge.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(ge.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*o,u=this.buffer.y*this._renderService.dimensions.css.cell.height,d=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=d+"px",this.textarea.style.top=u+"px",this.textarea.style.width=a+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(at(this.element,"copy",t=>{this.hasSelection()&&t1(t,this._selectionService)}));let e=t=>n1(t,this.textarea,this.coreService,this.optionsService);this._register(at(this.textarea,"paste",e)),this._register(at(this.element,"paste",e)),Jb?this._register(at(this.element,"mousedown",t=>{t.button===2&&kv(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(at(this.element,"contextmenu",t=>{kv(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),ip&&this._register(at(this.element,"auxclick",t=>{t.button===1&&xb(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(at(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(at(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(at(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(at(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(at(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(at(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(at(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var o;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((o=this.element)==null?void 0:o.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(at(this.screenElement,"mousemove",a=>this.updateCursorStyle(a))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Nh.get()),tw||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(BC,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(gs,this._coreBrowserService),this._register(at(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(at(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Qh,this._document,this._helperContainer),this._instantiationService.setService(Rc,this._charSizeService),this._themeService=this._instantiationService.createInstance(tf),this._instantiationService.setService(xo,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(_c),this._instantiationService.setService(Lb,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Zh,this.rows,this.screenElement)),this._instantiationService.setService(vs,this._renderService),this._register(this._renderService.onRenderedViewportChange(a=>this._onRender.fire(a))),this.onResize(a=>this._renderService.resize(a.cols,a.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Yh,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Jh),this._instantiationService.setService(Gf,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(uf,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(qh,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(a=>{super.scrollLines(a,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(ef,this.element,this.screenElement,s)),this._instantiationService.setService(u1,this._selectionService),this._register(this._selectionService.onRequestScrollLines(a=>this.scrollLines(a.amount,a.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(a=>this._renderService.handleSelectionChanged(a.start,a.end,a.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(a=>{this.textarea.value=a,this.textarea.focus(),this.textarea.select()})),this._register(On.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var a;this._selectionService.refresh(),(a=this._viewport)==null||a.queueSync()})),this._register(this._instantiationService.createInstance(Vh,this.screenElement)),this._register(at(this.element,"mousedown",a=>this._selectionService.handleMouseDown(a))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(wc,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(vc,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(vc,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Xh,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(a){var m,v,y,b,S;let u=e._mouseService.getMouseReportCoords(a,e.screenElement);if(!u)return!1;let d,p;switch(a.overrideType||a.type){case"mousemove":p=32,a.buttons===void 0?(d=3,a.button!==void 0&&(d=a.button<3?a.button:3)):d=a.buttons&1?0:a.buttons&4?1:a.buttons&2?2:3;break;case"mouseup":p=0,d=a.button<3?a.button:3;break;case"mousedown":p=1,d=a.button<3?a.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(a)===!1)return!1;let x=a.deltaY;if(x===0||e.coreMouseService.consumeWheelEvent(a,(b=(y=(v=(m=e._renderService)==null?void 0:m.dimensions)==null?void 0:v.device)==null?void 0:y.cell)==null?void 0:b.height,(S=e._coreBrowserService)==null?void 0:S.dpr)===0)return!1;p=x<0?0:1,d=4;break;default:return!1}return p===void 0||d===void 0||d>4?!1:e.coreMouseService.triggerMouseEvent({col:u.col,row:u.row,x:u.x,y:u.y,button:d,action:p,ctrl:a.ctrlKey,alt:a.altKey,shift:a.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:a=>(n(a),a.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(a)),wheel:a=>(n(a),this.cancel(a,!0)),mousedrag:a=>{a.buttons&&n(a)},mousemove:a=>{a.buttons||n(a)}};this._register(this.coreMouseService.onProtocolChange(a=>{a?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(a)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),a&8?s.mousemove||(t.addEventListener("mousemove",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),a&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),a&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),a&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(at(t,"mousedown",a=>{if(a.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(a)))return n(a),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(a)})),this._register(at(t,"wheel",a=>{var u,d,p,m,v;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(a)===!1)return!1;if(!this.buffer.hasScrollback){if(a.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(a,(m=(p=(d=(u=e._renderService)==null?void 0:u.dimensions)==null?void 0:d.device)==null?void 0:p.cell)==null?void 0:m.height,(v=e._coreBrowserService)==null?void 0:v.dpr)===0)return this.cancel(a,!0);let y=ge.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(a.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(y,!0),this.cancel(a,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Sb(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=WE(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===ge.ETX||n.key===ge.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(JE(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var n;(n=this._charSizeService)==null||n.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(pn));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(ge.ESC+"[I"):this.coreService.triggerDataEvent(ge.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${ge.ESC}[4;${n};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${ge.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function JE(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var ZE=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},eN=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Ri)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},m_=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new eN(t)}getNullCell(){return new Ri}},tN=class extends gt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Pe),this.onBufferChange=this._onBufferChange.event,this._normal=new m_(this._core.buffers.normal,"normal"),this._alternate=new m_(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)}},nN=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},iN=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}},sN=["cols","rows"],Wi=0,rN=class extends gt{constructor(e){super(),this._core=this._register(new QE(e)),this._addonManager=this._register(new ZE),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,o)=>{this._checkReadonlyOptions(s),this._core.options[s]=o};for(let s in this._core.options){let o={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,o)}}_checkReadonlyOptions(e){if(sN.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new nN(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new iN(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 tN(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
66
- `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Nh.get()},set promptLabel(e){Nh.set(e)},get tooMuchOutput(){return jh.get()},set tooMuchOutput(e){jh.set(e)}}}_verifyIntegers(...e){for(Wi of e)if(Wi===1/0||isNaN(Wi)||Wi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Wi of e)if(Wi&&(Wi===1/0||isNaN(Wi)||Wi%1!==0||Wi<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 oN=2,aN=1,lN=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var y;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((y=this._terminal.options.overviewRuler)==null?void 0:y.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),a=window.getComputedStyle(this._terminal.element),u={top:parseInt(a.getPropertyValue("padding-top")),bottom:parseInt(a.getPropertyValue("padding-bottom")),right:parseInt(a.getPropertyValue("padding-right")),left:parseInt(a.getPropertyValue("padding-left"))},d=u.top+u.bottom,p=u.right+u.left,m=s-d,v=o-p-t;return{cols:Math.max(oN,Math.floor(v/e.css.cell.width)),rows:Math.max(aN,Math.floor(m/e.css.cell.height))}}};function cN(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function uN({session:e,node:t,token:n,cols:s,rows:o,readonly:a=!1,takeSize:u,focused:d,onData:p,onExit:m,onFiles:v,retryBaseMs:y=250}){const b=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!b)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const x=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${cN(t,n)}`;let E=null,w=!1,N=!1,C=null,L=0,I=d;const G=()=>{if(w||N||C)return;const Y=Math.min(5e3,Math.max(0,y)*2**Math.min(L++,5));C=setTimeout(()=>{C=null,K()},Y)},K=()=>{if(w||N)return;const Y=new WebSocket(x);E=Y,Y.binaryType="arraybuffer",Y.onopen=()=>{if(E!==Y||w)return;L=0;const Q={type:"attach",session:e,token:n,cols:s,rows:o,readonly:a};u!==void 0&&(Q.takeSize=u),Y.send(JSON.stringify(Q)),I!==void 0&&Y.send(JSON.stringify({type:"focus",on:!!I}))},Y.onmessage=Q=>{if(!(E!==Y||w))if(typeof Q.data=="string"){let W;try{W=JSON.parse(Q.data)}catch{return}W.type==="exit"&&(N=!0,m&&m(W.code)),W.type==="files"&&v&&v(W)}else p&&p(new Uint8Array(Q.data))},Y.onerror=()=>{if(E===Y)try{Y.close()}catch{}},Y.onclose=Q=>{E!==Y||w||N||[1e3,1002,4401,4404].includes(Q==null?void 0:Q.code)||G()}};return K(),{sendInput:Y=>{if(!E||E.readyState!==1)return!1;try{return E.send(typeof Y=="string"?new TextEncoder().encode(Y):Y),!0}catch{try{E.close()}catch{}return!1}},isReady:()=>!!E&&E.readyState===1,resize:(Y,Q)=>{s=Y,o=Q,(E==null?void 0:E.readyState)===1&&E.send(JSON.stringify({type:"resize",cols:Y,rows:Q}))},action:Y=>{(E==null?void 0:E.readyState)===1&&E.send(JSON.stringify({type:"action",name:Y}))},focus:Y=>{I=Y,(E==null?void 0:E.readyState)===1&&E.send(JSON.stringify({type:"focus",on:!!Y}))},close:()=>{if(w=!0,C&&clearTimeout(C),C=null,E)try{E.close()}catch{}},get raw(){return E}}}async function df(e){const t=String(e||"");if(!t)return!1;try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(t),!0}catch{}try{const n=document.createElement("textarea");n.value=t,n.readOnly=!0,n.style.position="fixed",n.style.opacity="0",n.style.pointerEvents="none",document.body.appendChild(n),n.select();const s=document.execCommand&&document.execCommand("copy");if(n.remove(),s)return!0}catch{}return!1}const dN="\r";function hN(e){const t=String(e||"");let n=t.length;for(;n>0;){const s=t.charCodeAt(n-1);if(s===10||s===13)n-=1;else break}return t.slice(0,n)}function fN({isReady:e,paste:t,send:n}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:n(dN)!==!1}catch{return!1}}}function pN(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function mN(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}function gN(e){return/mac|iphone|ipad/i.test(String(e||""))?"⌘C":"Ctrl+Shift+C"}const vN=450,g_=8;function v_(e,t,n,s){return Math.abs(Number(n)-Number(e))>g_||Math.abs(Number(s)-Number(t))>g_}function _N({range:e,cell:t,cols:n}){const s=Number(n),o=Number(e.start.row)*s+Number(e.start.col),a=Number(e.end.row)*s+Number(e.end.col),u=Number(t.row)*s+Number(t.col),d={start:{row:e.start.row,col:e.start.col},end:{row:e.end.row,col:e.end.col},moved:null};if(u<o)d.start={row:Number(t.row),col:Number(t.col)},d.moved="start";else if(u>a)d.end={row:Number(t.row),col:Number(t.col)},d.moved="end";else{if(u===o||u===a)return d;u-o<=a-u?(d.start={row:Number(t.row),col:Number(t.col)},d.moved="start"):(d.end={row:Number(t.row),col:Number(t.col)},d.moved="end")}return d}function yN(e){const t=e!=="mouse";return{handles:t,magnifier:t}}function bN(e,t){if(!e||!e.start||!e.end)return null;const n=Number(t);if(!Number.isFinite(n)||n<=0)return null;const s=Number(e.start.y)*n+Number(e.start.x),o=Number(e.end.y)*n+Number(e.end.x),a=Math.min(s,o),u=Math.max(a,Math.max(s,o)-1);return{start:{row:Math.floor(a/n),col:a%n},end:{row:Math.floor(u/n),col:u%n}}}function __(e,t,n){const s=Number(e.row)*Number(n)+Number(e.col),o=Number(t.row)*Number(n)+Number(t.col);return s<=o?{start:{row:e.row,col:e.col},end:{row:t.row,col:t.col}}:{start:{row:t.row,col:t.col},end:{row:e.row,col:e.col}}}function wN({moving:e,fixed:t,which:n,cols:s,maxRow:o}){const a=Number(s);let u=Math.max(0,Math.min(Number(o),Number(e.row))),d=Math.max(0,Math.min(a-1,Number(e.col)));const p=u*a+d,m=Number(t.row)*a+Number(t.col);return n==="start"&&p>m&&(u=Number(t.row),d=Number(t.col)),n==="end"&&p<m&&(u=Number(t.row),d=Number(t.col)),{row:u,col:d}}function ao({line:e,col:t,side:n,cols:s}){const o=Math.max(0,Math.min(Number(s)-1,Number(t))),a=e&&typeof e.getCell=="function"?e.getCell(o):null;return(a&&typeof a.getWidth=="function"?Number(a.getWidth()):1)!==0?o:n==="end"?Math.min(Number(s)-1,o+1):Math.max(0,o-1)}function y_({line:e,col:t,cols:n}){const s=Math.max(0,Math.min(Number(n)-1,Number(t))),o=d=>{const p=e&&typeof e.getCell=="function"?e.getCell(d):null;return p&&typeof p.getChars=="function"?p.getChars():""};if(o(s)===""||o(s)===" ")return{start:s,end:s};let a=s;for(;a>0;){const d=o(a-1);if(d===""||d===" ")break;a-=1}let u=s;for(;u<Number(n)-1;){const d=o(u+1);if(d===""||d===" ")break;u+=1}return{start:a,end:u}}function SN({startLeft:e,endLeft:t,targetWidth:n=46}){return Math.abs(Number(t)-Number(e))<Number(n)}function xN({anchorLeft:e,anchorTop:t,hostWidth:n,hostHeight:s,bubbleWidth:o,bubbleHeight:a,pinHeight:u=30,margin:d=4,gap:p=8}){const m=Number(o),v=Number(a),y=Number(d),b=Math.max(y,Number(n)-y-m),S=Math.max(y,Math.min(b,Number(e)-Math.round(m/2)));let x=Number(t)-Number(p)-v,E=!1;x<y&&(x=Number(t)+Number(u)+Number(p),E=!0);const w=Math.max(y,Number(s)-y-v);return x>w&&(x=w),{left:S,top:x,flipped:E}}function b_(e,t){const n=Number(t),s=Number(e.start.row)*n+Number(e.start.col),o=Number(e.end.row)*n+Number(e.end.col);return{col:e.start.col,row:e.start.row,length:o-s+1}}const w_=28,kN=50;function CN({range:e,viewportY:t,rows:n,cols:s=0,cellWidth:o,cellHeight:a,screenLeft:u=0,screenTop:d=0}){const p={},m=Number(s)*Number(o);for(const v of["start","end"]){const y=e[v],b=Number(y.row)-Number(t),S=b>=0&&b<Number(n),x=(v==="start"?Number(y.col):Number(y.col)+1)*Number(o),E=v==="start"?x-w_<0:x+w_>m;p[v]={left:Number(u)+x,top:Number(d)+(b+1)*Number(a),visible:S,flip:E}}return p}function EN({visibleRow:e,rows:t}){const n=Number(e);return n<=0?-1:n>=Number(t)-1?1:0}function NN({range:e,side:t,line:n,cols:s}){if(!e||!e.start||!e.end||!n)return null;const o=Math.max(0,Number(s)-1),a=t==="end"?e.end:e.start,u=Number(a.row);let d,p;Number(e.start.row)===Number(e.end.row)?(d=Number(e.start.col),p=Number(e.end.col)):u===Number(e.start.row)?(d=Number(e.start.col),p=o):u===Number(e.end.row)?(d=0,p=Number(e.end.col)):(d=0,p=o),d=Math.max(0,Math.min(o,d)),p=Math.max(d,Math.min(o,p));const m=n.translateToString(!0,0,d);let v=n.translateToString(!1,d,p+1);v.replace(/\s+$/,"")===""&&(v="");const y=n.translateToString(!0,Math.min(o+1,p+1),o+1);return{row:u,before:m,sel:v,after:y}}const hf="(min-width:1024px) and (pointer:fine)";function jN(){const[e,t]=k.useState(()=>window.matchMedia(hf).matches);return k.useEffect(()=>{const n=window.matchMedia(hf),s=o=>t(o.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),e}const RN=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function Dd(e){return e?e.files&&e.files.length>0||Array.from(e.items||[]).some(t=>t&&t.kind==="file")?!0:Array.from(e.types||[]).includes("Files"):!1}function S_(e){if(!e)return[];const t=Array.from(e.files||[]).filter(Boolean);return t.length?t:Array.from(e.items||[]).filter(n=>n&&n.kind==="file"&&typeof n.getAsFile=="function").map(n=>n.getAsFile()).filter(Boolean)}function PN(e,t=0,n=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=RN.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${n}-${t+1}.${o}`}async function ff({files:e,token:t,session:n,node:s="",paste:o=!0,fetchImpl:a=on,onProgress:u=()=>{},now:d=Date.now()}={}){const p=Array.from(e||[]).filter(Boolean),m=[],v=[];if(!n||!p.length)return{paths:m,errors:v};const y=nn(s?String(s).split("/"):[]);for(let b=0;b<p.length;b+=1){const S=p[b],x=PN(S,b,d);u({index:b,total:p.length,name:x,state:"uploading"});try{const E=new FormData;E.append("session",n),E.append("paste",o?"true":"false"),E.append("file",S,x);const w=await a(`${y}/files/upload`,t,{method:"POST",body:E}),N=await w.json().catch(()=>({}));if(!w.ok||N.error)throw new Error(N.error||`HTTP ${w.status}`);m.push(N.path),u({index:b,total:p.length,name:x,state:"done",path:N.path})}catch(E){const w=String((E==null?void 0:E.message)||E);v.push({name:x,message:w}),u({index:b,total:p.length,name:x,state:"error",error:w})}}return{paths:m,errors:v}}const LN=420,AN=32;function MN(e){if(!e||typeof e!="object")return!1;const t=String(e.tagName||"").toLowerCase();return t==="textarea"||t==="input"||e.isContentEditable===!0}function pf({documentRef:e,navigatorRef:t}={}){const n=e||(typeof document<"u"?document:null),s=t||(typeof navigator<"u"?navigator:null);let o=!1;try{s!=null&&s.virtualKeyboard&&typeof s.virtualKeyboard.hide=="function"&&(s.virtualKeyboard.hide(),o=!0)}catch{}const a=n&&n.activeElement;let u=!1;if(MN(a)&&typeof a.blur=="function")try{a.blur(),u=!0}catch{}return{blurred:u,apiRequested:o}}function dw(e,t,n=!1){const s=e&&e.textarea;if(!s)return null;const a=t==="single-tap"||t==="double-tap"&&n?"text":"none";return s.inputMode=a,s.setAttribute("inputmode",a),a}function TN(e,t){if(!e||!e.textarea)return!1;dw(e,"double-tap",!0);try{e.focus()}catch{return!1}const n=typeof navigator<"u"?navigator:null;try{n!=null&&n.virtualKeyboard&&typeof n.virtualKeyboard.show=="function"&&n.virtualKeyboard.show()}catch{}return!0}function DN(e,t,n){return e==="never"?{open:!1,next:null}:e==="single-tap"?{open:!0,next:null}:!n||!Number.isFinite(n.at)||!Number.isFinite(n.x)||!Number.isFinite(n.y)?{open:!1,next:null}:t&&n.at>=t.at&&n.at-t.at<=LN&&Math.hypot(n.x-t.x,n.y-t.y)<=AN?{open:!0,next:null}:{open:!1,next:n}}const IN=24,x_=80,hw=8,ON="\x1B[5~",BN="\x1B[6~",zN=64,$N=65;function FN(e,t,n){const s=e==="up"?zN:$N,o=a=>Math.max(1,Math.min(9999,Number.isFinite(a)?Math.round(a):1));return`\x1B[<${s};${o(t)};${o(n)}M`}function HN({alternateScreen:e=!1,readonly:t=!1,mouseTracking:n=!1}={}){return t?"scroll":n?"mouse":e?"page":"scroll"}function UN(e,t){return e==="page"?Number.isFinite(t)&&t>0?Math.max(x_,t):x_:Number.isFinite(t)&&t>0?t:IN}function WN({mode:e="scroll",accumulated:t=0,threshold:n=0}={}){const s=UN(e,n);if(!Number.isFinite(t))return{mode:e,up:0,down:0,remainder:0};const o=Math.abs(t);if(o<s)return{mode:e,up:0,down:0,remainder:t};const a=Math.floor(o/s),u=Math.min(a,hw),d=(t>=0?1:-1)*(o%s);return{mode:e,up:t>0?u:0,down:t<0?u:0,remainder:d}}function KN(e,t=null){const n=[],s=t&&Number.isFinite(t.col)?t.col:1,o=t&&Number.isFinite(t.row)?t.row:1,a=d=>Math.min(hw,Number.isFinite(d)?Math.max(0,Math.floor(d)):0),u=d=>e.mode==="mouse"?{kind:"input",seq:FN(d,s,o)}:e.mode==="page"?{kind:"input",seq:d==="up"?ON:BN}:{kind:"action",name:d==="up"?"scroll-up":"scroll-down"};for(let d=0;d<a(e.up);d+=1)n.push(u("up"));for(let d=0;d<a(e.down);d+=1)n.push(u("down"));return n}function sp({session:e,node:t,token:n,readonly:s,takeSize:o,focused:a,sendRef:u,composerRef:d,actionRef:p,ctrlRef:m,setCtrlArmed:v,onFiles:y,fontSize:b=13,selectionMode:S=!1,onSelectionModeChange:x,keyboardGesture:E="double-tap"}){const w=k.useRef(null),N=k.useRef(null),C=k.useRef(b);C.current=b;const L=k.useRef(a);L.current=a;const I=k.useRef(S);I.current=S;const G=k.useRef(E);G.current=E;const[K,Y]=k.useState(""),[Q,W]=k.useState(""),[X,H]=k.useState(null),[$,R]=k.useState(null),[O,F]=k.useState(!1),[A,T]=k.useState(null),j=k.useRef(null),[z,M]=k.useState(null),[D,B]=k.useState(0),[U,se]=k.useState(null),[ee,de]=k.useState("start"),[ve,fe]=k.useState(null),[pe,Ve]=k.useState(!1),[ut,vt]=k.useState(null),[je,Ct]=k.useState(null),dn=k.useRef(null),gn=k.useRef(null),[Yt,xt]=k.useState(!1),Ot=async()=>{var me,Ge,ct,oe;const re=((Ge=(me=N.current)==null?void 0:me.term)==null?void 0:Ge.getSelection())||K;if(!re){W(f("copy-empty")),setTimeout(()=>W(""),1500);return}const Qe=await df(re);W(f(Qe?"copied":"copy-manual")),Qe&&((oe=(ct=N.current)==null?void 0:ct.term)==null||oe.clearSelection(),Y(""),F(!1),x==null||x(!1)),setTimeout(()=>W(""),1800)},Ut=k.useRef(Ot);Ut.current=Ot;const Nt=k.useRef({startHandleDrag:()=>{}}),Dt=k.useRef(null);Dt.current=z,k.useEffect(()=>{const re=w.current;re&&(re.dataset.selectionOrigin=je||"")},[je]),k.useEffect(()=>{const re=N.current;re&&re.sock&&re.sock.focus&&re.sock.focus(!!a)},[a]),k.useEffect(()=>{const re=N.current;re&&(re.term.options.fontSize=b,re.fit.fit(),re.sock.resize(re.term.cols,re.term.rows))},[b]),k.useEffect(()=>{var re,Qe;(Qe=(re=N.current)==null?void 0:re.setKeyboardGesture)==null||Qe.call(re,E)},[E]),k.useEffect(()=>{var bs,ir,ai,Pi,li,ws,Ss;const re=new rN({cursorBlink:!0,fontSize:C.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),Qe=new lN;re.loadAddon(Qe),re.open(w.current),Qe.fit();let me=!1,Ge=!1;const ct=le=>Ie=>{for(const Ae of Ie){const $e=Array.isArray(Ae)?Ae[0]:Ae;$e===1006&&(me=le),$e===1016&&(Ge=le)}return!1};(ir=(bs=re.parser)==null?void 0:bs.registerCsiHandler)==null||ir.call(bs,{prefix:"?",final:"h"},ct(!0)),(Pi=(ai=re.parser)==null?void 0:ai.registerCsiHandler)==null||Pi.call(ai,{prefix:"?",final:"l"},ct(!1)),(ws=(li=re.parser)==null?void 0:li.registerEscHandler)==null||ws.call(li,{final:"c"},()=>(me=!1,Ge=!1,!1));const oe=()=>{const le=me&&!Ge&&(re.modes&&re.modes.mouseTrackingMode||"none")!=="none",Ie=w.current;return Ie&&(Ie.dataset.mouseTracking=le?"on":"off"),le},ie=new TextDecoder;let _e=G.current==="single-tap",be=null;const ke=()=>{_e=G.current==="single-tap",dw(re,G.current,_e)},it=le=>{G.current=le,be=null,ke()},ht=()=>G.current==="never"?!1:(_e=!0,TN(re));ke();const dt=re.textarea,Rt=()=>{G.current==="double-tap"&&ke()};dt==null||dt.addEventListener("blur",Rt);let wt;try{wt=uN({session:e,node:t,token:n,readonly:s,takeSize:o,focused:L.current,onFiles:y,cols:re.cols,rows:re.rows,onData:le=>re.write(ie.decode(le)),onExit:()=>re.write(`\r
78
- \x1B[33m[sessione finita]\x1B[0m\r
79
- `)})}catch(le){return re.write(`\r
80
- \x1B[31m${le.message}\x1B[0m\r
81
- `),()=>re.dispose()}N.current={term:re,fit:Qe,sock:wt,setKeyboardGesture:it};let _t=null;const zt=re.onData(le=>{if(s){_t&&(_t.ok=!1);return}if(!_t&&m&&m.current&&le.length===1){const Ae=le.charCodeAt(0);let $e=Ae;Ae>=97&&Ae<=122?$e=Ae-96:Ae>=64&&Ae<=95?$e=Ae-64:Ae===32&&($e=0),le=String.fromCharCode($e),m.current=!1,v&&v(!1)}const Ie=wt.sendInput(le);_t&&(_t.seen=!0,_t.ok=_t.ok&&Ie)});u&&(u.current=le=>wt.sendInput(le)),p&&(p.current=le=>wt.action(le)),d&&(d.current=fN({isReady:()=>!s&&wt.isReady(),paste:le=>{const Ie={seen:!1,ok:!0};_t=Ie;try{re.paste(le)}catch{Ie.ok=!1}finally{_t=null}return Ie.seen&&Ie.ok},send:le=>wt.sendInput(le)}));const Je=le=>{dn.current=le,Ct(le)};let J=null;const Ne=re.onSelectionChange(()=>{const le=re.getSelection();le?(Y(le),F(!1)):F(!0);const Ie=bN(re.getSelectionPosition(),re.cols),Ae=Ie?__(Ie.start,Ie.end,re.cols):null;T(Ae),j.current=Ae,Ae||Je(null),!Ae&&J&&Tr();let $e=null;if(Ae&&typeof re.buffer.active.getLine=="function"){const st=[];for(let rt=Ae.start.row;rt<=Ae.end.row;rt++){const Pt=re.buffer.active.getLine(rt);st.push(Pt?Pt.translateToString():"")}$e={startRow:Ae.start.row,endRow:Ae.end.row,lines:st}}gn.current=$e,xt(!1)}),Ue=re.onRender(le=>{var Ie;if((Ie=re.hasSelection)!=null&&Ie.call(re)){const Ae=gn.current,$e=le&&le.start,st=le&&le.end;if(Ae&&Number.isInteger($e)&&Number.isInteger(st)&&typeof re.buffer.active.getLine=="function"){const rt=Number(re.buffer.active.viewportY)||0,Pt=Math.max(rt+$e,Ae.startRow),Gt=Math.min(rt+st,Ae.endRow);for(let Bn=Pt;Bn<=Gt;Bn++){const Wt=re.buffer.active.getLine(Bn);if((Wt?Wt.translateToString():"")!==Ae.lines[Bn-Ae.startRow]){xt(!0);break}}}B(rt=>rt+1)}}),Oe=re.onScroll(()=>{var le;(le=re.hasSelection)!=null&&le.call(re)&&B(Ie=>Ie+1)});re.attachCustomKeyEventHandler(le=>(le.ctrlKey||le.metaKey)&&le.key.toLowerCase()==="c"&&re.getSelection()?(le.type==="keydown"&&df(re.getSelection()),!1):!0);const Le=w.current;let Et=!1;const kt=async le=>{if(!le.length||Et)return;if(s){H({error:f("settings-readonly")});return}Et=!0,H({current:0,total:le.length,name:""});const Ie=await ff({files:le,token:n,session:e,node:t,paste:!0,onProgress:({index:Ae,total:$e,name:st,state:rt,error:Pt})=>H({current:Ae+1,total:$e,name:st,...rt==="error"?{error:Pt}:{}})});Et=!1,Ie.errors.length?H({error:Ie.errors.map(Ae=>`${Ae.name}: ${Ae.message}`).join(" · ")}):(H({done:!0,total:Ie.paths.length}),setTimeout(()=>H(null),1600))},V=le=>{const Ie=le.clipboardData;if(!Dd(Ie))return;const Ae=S_(Ie);Ae.length&&(le.preventDefault(),le.stopPropagation(),kt(Ae))},ae=le=>{Dd(le.dataTransfer)&&(le.preventDefault(),le.stopPropagation())},ye=le=>{Dd(le.dataTransfer)&&(le.preventDefault(),le.stopPropagation(),kt(S_(le.dataTransfer)))};Le.addEventListener("paste",V,!0),Le.addEventListener("dragenter",ae,!0),Le.addEventListener("dragover",ae,!0),Le.addEventListener("drop",ye,!0);const Me=24,De=(le,Ie)=>{const $e=(Le.querySelector(".xterm-screen")||Le).getBoundingClientRect(),st=Math.floor((le-$e.left)/Math.max(1,$e.width)*re.cols)+1,rt=Math.floor((Ie-$e.top)/Math.max(1,$e.height)*re.rows)+1;return{col:Math.max(1,Math.min(re.cols,st)),row:Math.max(1,Math.min(re.rows,rt))}},Ee=(le,Ie={mode:null,remainder:0},Ae=null,$e=null)=>{const st=w.current,rt=st?st.getBoundingClientRect().height:Me,Pt=HN({alternateScreen:re.buffer.active.type==="alternate",readonly:s,mouseTracking:oe()}),Gt=Pt==="mouse"?"mouse":Ae||Pt,Bn=Ie.mode===Gt?Ie.remainder+le:le,Wt=WN({mode:Gt,accumulated:Bn,threshold:Gt==="page"?rt:Me});for(const xn of KN(Wt,$e))xn.kind==="input"?wt.sendInput(xn.seq):wt.action(xn.name);return{mode:Gt,remainder:Wt.remainder}};let Xe=null,yt=null,$t=null,Be=null,te=!1,Se=!1,Te={mode:null,remainder:0},tt=null,nt=null,St=null,It=!1;const Sn=750;let ri=0;const An=()=>{St&&clearTimeout(St),St=null},Mt=(le,Ie)=>{const $e=(Le.querySelector(".xterm-screen")||Le).getBoundingClientRect(),st=Math.max(0,Math.min(re.cols-1,Math.floor((le-$e.left)/Math.max(1,$e.width)*re.cols))),rt=Math.max(0,Math.min(re.rows-1,Math.floor((Ie-$e.top)/Math.max(1,$e.height)*re.rows)));return{col:st,row:re.buffer.active.viewportY+rt}},zc=()=>{const Ae=(Le.querySelector(".xterm-screen")||Le).getBoundingClientRect().height/Math.max(1,re.rows),$e=Le.querySelector(".nc-sel-handle"),st=$e?$e.getBoundingClientRect().height:0;return-.3*(st>0?st:Ae)},No=(le,Ie)=>Mt(le.clientX,le.clientY+Ie),Qs=le=>{const Ae=(Le.querySelector(".xterm-screen")||Le).getBoundingClientRect(),$e=Le.getBoundingClientRect(),st=Ae.width/Math.max(1,re.cols),rt=Ae.height/Math.max(1,re.rows),Pt=Number(re.buffer.active.viewportY)||0,Gt=Math.max(0,Math.min(re.rows-1,le.row-Pt));R({left:`${Ae.left-$e.left+le.col*st}px`,top:`${Ae.top-$e.top+Gt*rt}px`,width:`${st}px`,height:`${rt}px`})},Js=le=>{if(ri=Date.now(),Je("touch"),An(),It=!1,te=!1,Se||le.touches.length!==1){Se=!0,te=!0,be=null,R(null),Xe=null,yt=null,$t=null,Be=null;return}if(I.current){le.preventDefault(),le.stopPropagation();const Ae=Mt(le.touches[0].clientX,le.touches[0].clientY),$e=re.buffer.active.getLine(Ae.row),st=ao({line:$e,col:Ae.col,side:"start",cols:re.cols}),rt=y_({line:$e,col:st,cols:re.cols});nt={row:Ae.row,col:rt.start};const Pt={row:Ae.row,col:rt.end};re.clearSelection(),Je("touch"),Ve(!0),de("end"),re.select(rt.start,Ae.row,rt.end-rt.start+1),Qs(Pt);return}Xe=le.touches[0].clientY,yt=le.touches[0].clientX,$t=yt,Be=Xe,Te={mode:null,remainder:0},tt=null;const Ie={x:yt,y:Xe};St=setTimeout(()=>{var Gt;St=null,It=!0,te=!0,be=null,I.current=!0,x==null||x(!0);const Ae=Mt(Ie.x,Ie.y),$e=re.buffer.active.getLine(Ae.row),st=ao({line:$e,col:Ae.col,side:"start",cols:re.cols}),rt=y_({line:$e,col:st,cols:re.cols});nt={row:Ae.row,col:rt.start};const Pt={row:Ae.row,col:rt.end};re.clearSelection(),Je("touch"),Ve(!0),de("end"),re.select(rt.start,Ae.row,rt.end-rt.start+1),Qs(Pt);try{(Gt=navigator.vibrate)==null||Gt.call(navigator,10)}catch{}Xe=null,yt=null,tt=null,Te={mode:null,remainder:0}},vN)},Oa=le=>{if(It&&nt&&le.touches.length===1){le.preventDefault(),le.stopPropagation();const $e=Mt(le.touches[0].clientX,le.touches[0].clientY),st=nt.row*re.cols+nt.col,rt=$e.row*re.cols+$e.col,Pt=st<=rt?"end":"start",Gt=re.buffer.active.getLine($e.row),Bn=ao({line:Gt,col:$e.col,side:Pt,cols:re.cols}),Wt={row:$e.row,col:Bn},xn=Wt.row*re.cols+Wt.col,Wn=st<=xn?nt:Wt;de(Pt),re.select(Wn.col,Wn.row,Math.abs(xn-st)+1),Qs(Wt);return}if(I.current&&nt&&le.touches.length===1){le.preventDefault(),le.stopPropagation();const $e=Mt(le.touches[0].clientX,le.touches[0].clientY),st=nt.row*re.cols+nt.col,rt=$e.row*re.cols+$e.col,Pt=st<=rt?"end":"start",Gt=re.buffer.active.getLine($e.row),Bn=ao({line:Gt,col:$e.col,side:Pt,cols:re.cols}),Wt={row:$e.row,col:Bn},xn=Wt.row*re.cols+Wt.col,Wn=st<=xn?nt:Wt;de(Pt),re.select(Wn.col,Wn.row,Math.abs(xn-st)+1),Qs(Wt);return}if(Xe===null||le.touches.length!==1)return;le.preventDefault(),le.stopPropagation();const Ie=le.touches[0];if(v_($t,Be,Ie.clientX,Ie.clientY)&&(te=!0,be=null,St&&An()),tt===null&&(Math.abs(Ie.clientY-Xe)>8||Math.abs(Ie.clientX-yt)>8)&&(tt=Math.abs(Ie.clientY-Xe)>Math.abs(Ie.clientX-yt)),!tt)return;const Ae=Ie.clientY-Xe;Xe=Ie.clientY,Te=Ee(Ae,Te,"scroll",De(Ie.clientX,Ie.clientY))},Pr=()=>{An(),Xe=null,yt=null,$t=null,Be=null,nt=null,It=!1,te=!1,Se=!1,R(null),Ve(!1),Te={mode:null,remainder:0},ri=Date.now()},Zs=le=>{if(Se){be=null,An(),(!le.touches||le.touches.length===0)&&Pr();return}const Ie=le.changedTouches&&le.changedTouches[0];if(!te&&!It&&!I.current&&Ie){const Ae={at:Date.now(),x:Ie.clientX,y:Ie.clientY},$e=DN(G.current,be,Ae);be=$e.next,$e.open&&ht()}Pr()},oi=()=>{be=null,Pr()};let Ba={mode:null,remainder:0};const Qn=le=>{le.preventDefault(),le.stopPropagation(),Ba=Ee(-le.deltaY,Ba,"scroll",De(le.clientX,le.clientY))};Le.addEventListener("touchstart",Js,{passive:!1}),Le.addEventListener("touchmove",Oa,{passive:!1,capture:!0}),Le.addEventListener("touchend",Zs,{passive:!0}),Le.addEventListener("touchcancel",oi,{passive:!0});const za=()=>{typeof window.matchMedia=="function"&&window.matchMedia(hf).matches||!I.current&&G.current==="double-tap"&&ht()};Le.addEventListener("dblclick",za);const $a=le=>{(I.current||It)&&(le.preventDefault(),le.stopPropagation())};Le.addEventListener("contextmenu",$a,!0),Le.addEventListener("wheel",Qn,{passive:!1,capture:!0});let _i=null;const er=le=>{Date.now()-ri>=Sn&&Je("mouse"),pN(le)&&(le.preventDefault(),le.stopPropagation(),_i={cell:Mt(le.clientX,le.clientY),clientX:le.clientX,clientY:le.clientY,extendFrom:j.current,dragged:!1})},tr=le=>{var Pt;if(!_i){(Pt=re.hasSelection)!=null&&Pt.call(re)&&oe()&&(le.preventDefault(),le.stopPropagation());return}if(le.preventDefault(),le.stopPropagation(),!_i.dragged&&!v_(_i.clientX,_i.clientY,le.clientX,le.clientY))return;_i.dragged=!0;const Ie=_i.cell,Ae=Mt(le.clientX,le.clientY),$e=Ie.row*re.cols+Ie.col,st=Ae.row*re.cols+Ae.col,rt=$e<=st?Ie:Ae;re.select(rt.col,rt.row,Math.abs(st-$e)+1)},_s=le=>{if(!_i)return;le.stopPropagation();const{cell:Ie,extendFrom:Ae,dragged:$e}=_i;if(_i=null,$e||!Ae)return;const st=_N({range:Ae,cell:Ie,cols:re.cols});if(!st.moved)return;const rt=st[st.moved],Pt=re.buffer.active.getLine(rt.row);rt.col=ao({line:Pt,col:rt.col,side:st.moved,cols:re.cols});const Gt=b_({start:st.start,end:st.end},re.cols);re.select(Gt.col,Gt.row,Gt.length)};Le.addEventListener("mousedown",er,!0),Le.addEventListener("mousemove",tr,!0),Le.addEventListener("mouseup",_s,!0);let ts=null,ns={x:0,y:0,type:"touch"};const Lr=()=>{ts&&(clearInterval(ts),ts=null)},Ar=(le,Ie,Ae)=>{if(!J||!J.fixed)return;const $e=J.fixed,st=Ae==="mouse"?Mt(le,Ie):No({clientX:le,clientY:Ie},zc()),rt=re.buffer.active.getLine(st.row),Pt={row:st.row,col:ao({line:rt,col:st.col,side:J.which,cols:re.cols})},Gt=Math.max(0,Number(re.buffer.active.baseY||0)+re.rows-1),Bn=wN({moving:Pt,fixed:$e,which:J.which,cols:re.cols,maxRow:Gt}),Wt=b_(__(Bn,$e,re.cols),re.cols);re.select(Wt.col,Wt.row,Wt.length);const xn=Number(re.buffer.active.viewportY)||0,Wn=EN({visibleRow:Bn.row-xn,rows:re.rows});Lr(),!(Wn===0||re.buffer.active.type==="alternate")&&(ts=setInterval(()=>{const Ir=Number(re.buffer.active.viewportY)||0;if(re.scrollLines(Wn),(Number(re.buffer.active.viewportY)||0)===Ir){Lr();return}Ar(ns.x-J.offsetX,ns.y-J.offsetY,ns.type)},130))},Mr=le=>{J&&(le.preventDefault(),ns={x:le.clientX,y:le.clientY,type:le.pointerType||ns.type},Ar(le.clientX-J.offsetX,le.clientY-J.offsetY,ns.type))},Tr=()=>{J=null,Lr(),se(null),window.removeEventListener("pointermove",Mr),window.removeEventListener("pointerup",yi),window.removeEventListener("pointercancel",yi)},yi=()=>Tr();Nt.current={startHandleDrag:(le,Ie)=>{if(!re.getSelectionPosition())return;Ie.preventDefault(),Ie.stopPropagation();const Ae=Dt.current&&Dt.current[le],$e=Le.getBoundingClientRect();J={which:le,offsetX:Ae?Ie.clientX-($e.left+Ae.left):0,offsetY:Ae?Ie.clientY-($e.top+Ae.top):0,fixed:j.current?le==="start"?j.current.end:j.current.start:null},ns={x:Ie.clientX,y:Ie.clientY,type:Ie.pointerType||"touch"},se(le),de(le),window.addEventListener("pointermove",Mr),window.addEventListener("pointerup",yi),window.addEventListener("pointercancel",yi)}};const Fa=le=>{!mN(le)||!(N.current&&N.current.term&&N.current.term.getSelection())||(le.preventDefault(),le.stopPropagation(),Ut.current&&Ut.current())};Le.addEventListener("keydown",Fa,!0);const Bi=()=>{Qe.fit(),wt.resize(re.cols,re.rows)};window.addEventListener("resize",Bi);const ft=window.visualViewport;let Dr=ft&&Number(ft.height);const jo=()=>{const le=ft&&Number(ft.height);_e&&G.current==="double-tap"&&Number.isFinite(Dr)&&Number.isFinite(le)&&le>Dr+80&&ke(),Dr=le,Bi()};ft&&(ft.addEventListener("resize",jo),ft.addEventListener("scroll",Bi));const Mn=typeof navigator<"u"?navigator.virtualKeyboard:null,Ro=()=>{var le;_e&&G.current==="double-tap"&&Number(((le=Mn==null?void 0:Mn.boundingRect)==null?void 0:le.height)||0)===0&&ke()};(Ss=Mn==null?void 0:Mn.addEventListener)==null||Ss.call(Mn,"geometrychange",Ro);let nr=null,ys=0;return typeof ResizeObserver<"u"&&(nr=new ResizeObserver(()=>{ys&&cancelAnimationFrame(ys),ys=requestAnimationFrame(Bi)}),nr.observe(Le)),()=>{var le;N.current=null,u&&(u.current=()=>!1),d&&(d.current=()=>!1),p&&(p.current=()=>!1),zt.dispose(),Ne.dispose(),Ue.dispose(),Oe.dispose(),Lr(),window.removeEventListener("pointermove",Mr),window.removeEventListener("pointerup",yi),window.removeEventListener("pointercancel",yi),Nt.current={startHandleDrag:()=>{}},Le.removeEventListener("touchstart",Js),Le.removeEventListener("touchmove",Oa,{capture:!0}),Le.removeEventListener("touchend",Zs),Le.removeEventListener("touchcancel",oi),Le.removeEventListener("dblclick",za),Le.removeEventListener("contextmenu",$a,!0),An(),Le.removeEventListener("wheel",Qn,{capture:!0}),Le.removeEventListener("mousedown",er,!0),Le.removeEventListener("mousemove",tr,!0),Le.removeEventListener("mouseup",_s,!0),Le.removeEventListener("keydown",Fa,!0),Le.removeEventListener("paste",V,!0),Le.removeEventListener("dragenter",ae,!0),Le.removeEventListener("dragover",ae,!0),Le.removeEventListener("drop",ye,!0),window.removeEventListener("resize",Bi),ft&&(ft.removeEventListener("resize",jo),ft.removeEventListener("scroll",Bi)),(le=Mn==null?void 0:Mn.removeEventListener)==null||le.call(Mn,"geometrychange",Ro),dt==null||dt.removeEventListener("blur",Rt),nr&&nr.disconnect(),ys&&cancelAnimationFrame(ys),wt.close(),re.dispose()}},[e,t,n,s,o,u,d,p,m,v,y]),k.useEffect(()=>{const re=w.current,Qe=N.current?N.current.term:null;if(!re||!Qe||!A){M(null),fe(null),vt(null);return}const Ge=(re.querySelector(".xterm-screen")||re).getBoundingClientRect(),ct=re.getBoundingClientRect(),oe=Ge.width/Math.max(1,Qe.cols),ie=Ge.height/Math.max(1,Qe.rows),_e=CN({range:A,viewportY:Number(Qe.buffer.active.viewportY)||0,rows:Qe.rows,cols:Qe.cols,cellWidth:oe,cellHeight:ie,screenLeft:Ge.left-ct.left,screenTop:Ge.top-ct.top});M(_e);let be=null;const ke=A[ee==="end"?"end":"start"].row;typeof Qe.buffer.active.getLine=="function"&&(be=Qe.buffer.active.getLine(Number(ke)));const it=Math.max(16,Math.round(ie*2)),ht=be?{...NN({range:A,side:ee,line:be,cols:Qe.cols}),fontSize:it}:null;fe(ht);const dt=U!==null||pe,Rt=_e[ee==="end"?"end":"start"];if(!dt||!ht||!Rt||!Rt.visible){vt(null);return}const wt=(ht.before+ht.sel+ht.after).length,_t=oe*(it/Math.max(1,ie)),zt=Math.min(ct.width-8,Math.round(wt*_t)+16),Je=Math.round(it*1.25)+12;vt(xN({anchorLeft:Rt.left,anchorTop:Rt.top,hostWidth:ct.width,hostHeight:ct.height,bubbleWidth:zt,bubbleHeight:Je}))},[A,D,ee,U,pe]);const At=yN(je),jt=k.useRef({}),hn=(re,Qe)=>{if(U!==re)return jt.current[re]={flip:Qe,ts:0},Qe;const me=jt.current[re]||{flip:Qe,ts:0};if(me.flip===Qe)return jt.current[re]=me,Qe;const Ge=Date.now();return Ge-me.ts<kN?me.flip:(jt.current[re]={flip:Qe,ts:Ge},Qe)};return l.jsxs("div",{className:`nc-terminal${S?" selecting":""}`,children:[l.jsx("div",{className:"nc-terminal-host",ref:w}),$&&l.jsx("div",{className:"nc-touch-selection-caret",style:$,"aria-hidden":"true"}),A&&z&&At.handles&&["start","end"].map(re=>z[re].visible&&l.jsx("div",{className:`nc-sel-handle ${re}${U===re?" dragging":""}${hn(re,z[re].flip)?" flip":""}${SN({startLeft:z.start.left,endLeft:z.end.left})?" tight":""}`,style:{left:`${z[re].left}px`,top:`${z[re].top}px`},onPointerDown:Qe=>Nt.current.startHandleDrag(re,Qe),"aria-hidden":"true"},`nc-sel-handle-${re}`)),A&&ve&&At.magnifier&&ut&&l.jsx("div",{className:`nc-zoom-bubble${ut.flipped?" flipped":""}`,style:{left:`${ut.left}px`,top:`${ut.top}px`},"aria-hidden":"true",children:l.jsxs("pre",{className:"nc-zoom-line",style:{fontSize:`${ve.fontSize}px`},children:[l.jsx("span",{children:ve.before}),l.jsx("span",{className:"nc-zoom-sel",children:ve.sel}),l.jsx("span",{children:ve.after})]})}),X&&l.jsx("div",{className:`nc-upload-state${X.error?" error":""}`,role:"status",children:X.error?X.error:X.done?f("attach-uploaded").replace("{n}",String(X.total||0)):f("attach-upload-progress").replace("{n}",String(X.current||0)).replace("{total}",String(X.total||0))}),(K||S)&&l.jsxs("div",{className:"nc-selection-tools",children:[K?l.jsx("button",{type:"button",onClick:Ot,children:Q||`${f("copy")} · ${gN(typeof navigator<"u"?navigator.userAgent:"")}`}):l.jsx("span",{children:f("select-drag")}),K&&O&&l.jsx("span",{className:"nc-selection-held",children:f("selection-held")}),K&&!O&&Yt&&l.jsx("span",{className:"nc-selection-changed",children:f("selection-changed")}),l.jsx("button",{type:"button",onClick:()=>{var re,Qe;(Qe=(re=N.current)==null?void 0:re.term)==null||Qe.clearSelection(),Y(""),F(!1),x==null||x(!1)},children:f("cancel")}),Q===f("copy-manual")&&l.jsx("textarea",{readOnly:!0,value:K,onFocus:re=>re.target.select()})]})]})}const k_="",Ht="\x1B",qN=[{label:"↑",seq:Ht+"[A"},{label:"↓",seq:Ht+"[B"},{label:"PGUP",seq:Ht+"[5~"},{label:"PGDN",seq:Ht+"[6~"}],VN=new Set([Ht+"[A",Ht+"[B",Ht+"[C",Ht+"[D",Ht+"[5~",Ht+"[6~"]),YN=350,GN=55;function XN({send:e,action:t,ctrlArmed:n=!1,onCtrl:s,onKeyboard:o,selectionMode:a=!1,onSelectionMode:u,onCellSwitcher:d,cellSwitcherOpen:p=!1,keepKeyboardClosed:m=!0,showEnter:v=!0,keybarLayout:y="full"}){const[b,S]=k.useState(!1),[x,E]=k.useState(!1),[w,N]=k.useState(!1),[C,L]=k.useState(!1),I=y==="compact"&&!C,G=k.useRef({delay:null,interval:null}),K=k.useRef(()=>{}),Y=()=>{const z=G.current;z.delay!==null&&clearTimeout(z.delay),z.interval!==null&&clearInterval(z.interval),z.delay=null,z.interval=null};K.current=Y,k.useEffect(()=>{const z=()=>{document.visibilityState==="hidden"&&K.current()},M=()=>K.current();return window.addEventListener("blur",M),document.addEventListener("visibilitychange",z),()=>{window.removeEventListener("blur",M),document.removeEventListener("visibilitychange",z),K.current()}},[]),k.useEffect(()=>{y!=="compact"&&L(!1)},[y]);const Q=z=>{w?(e(Ht+z),N(!1)):e(z)},W=z=>{m&&pf(),z()},X=z=>({onPointerDown:M=>{M.preventDefault(),W(z)},onClick:M=>{M.detail===0&&W(z)}}),H=z=>({onPointerDown:M=>{M.preventDefault(),Y(),W(z),!w&&(G.current.delay=setTimeout(()=>{G.current.delay=null,z(),G.current.interval=setInterval(z,GN)},YN))},onPointerUp:Y,onPointerLeave:Y,onPointerCancel:Y,onLostPointerCapture:Y,onTouchCancel:Y,onClick:M=>{M.detail===0&&W(z)}}),$=(z,M,D)=>l.jsx("button",{type:"button",...VN.has(M)&&!D?H(()=>Q(M)):X(()=>{Q(M),D&&D()}),children:z},z),R=(z,M)=>l.jsx("button",{type:"button",...X(()=>{t(M),E(!1)}),children:z},z),O=d?l.jsx("button",{type:"button","aria-label":f("fleet-cells"),title:f("fleet-cells"),"aria-expanded":p,...X(d),children:"◫"},"cells"):l.jsx("button",{type:"button",...X(()=>{o&&o()}),children:"⌨"},"kbd"),F=v&&l.jsx("button",{type:"button",className:"nc-enter-key","aria-label":"ENTER",title:"ENTER",...X(()=>Q("\r")),children:l.jsx(lt,{name:"enter",size:24})}),A=x&&l.jsxs("div",{className:"nc-keymenu",children:[R("←WIN","prev-window"),R("WIN→","next-window"),R("⬅PANE","pane-left"),R("PANE➡","pane-right"),$("SCROLL",k_+"[",()=>{S(!0),E(!1)}),l.jsx("button",{type:"button",className:a?"armed":"",...X(()=>{u==null||u(!a),E(!1)}),children:"SELECT"}),$("⌃C","",()=>E(!1)),$("DETACH",k_+"d",()=>E(!1))]});if(b)return l.jsxs("div",{className:"nc-keybar copy",children:[l.jsx("span",{className:"tag",children:"copy-mode"}),qN.map(z=>$(z.label,z.seq)),$("ESCI (q)","q",()=>S(!1))]});if(I)return l.jsxs("div",{className:"nc-keybar termux",children:[A,l.jsxs("div",{className:`nc-keygrid compact${v?"":" no-enter"}`,children:[l.jsx("div",{className:"nc-keyrows",children:l.jsxs("div",{className:"row",children:[l.jsx("button",{type:"button","aria-label":f("keybar-expand"),title:f("expand"),...X(()=>L(!0)),children:l.jsx(lt,{name:"chevronUp",size:20})},"expand"),O,l.jsx("button",{type:"button",className:x?"armed":"",...X(()=>E(z=>!z)),children:"☰"},"menu"),$("↑",Ht+"[A"),$("↓",Ht+"[B"),$("←",Ht+"[D"),$("→",Ht+"[C"),$("PGUP",Ht+"[5~"),$("PGDN",Ht+"[6~")]})}),F]})]});const T=y==="compact"&&C,j=T&&l.jsx("button",{type:"button",className:"nc-retract-key","aria-label":f("keybar-retract"),title:f("retract"),...X(()=>L(!1)),children:l.jsx(lt,{name:"chevronDown",size:20})});return l.jsxs("div",{className:`nc-keybar termux${T?" expanded":""}`,children:[A,l.jsxs("div",{className:`nc-keygrid${v?"":" no-enter"}${T?" expanded":""}`,children:[j,l.jsxs("div",{className:"nc-keyrows",children:[l.jsxs("div",{className:"row",children:[$("ESC",Ht),l.jsx("button",{type:"button",className:x?"armed":"",...X(()=>E(z=>!z)),children:"☰"},"menu"),$("/","/"),$("—","-"),$("HOME",Ht+"[H"),$("↑",Ht+"[A"),$("END",Ht+"[F"),$("PGUP",Ht+"[5~")]}),l.jsxs("div",{className:"row",children:[$("⇥"," "),O,l.jsx("button",{type:"button",className:n?"armed":"",...X(()=>{s&&s()}),children:"CTRL"},"ctrl"),l.jsx("button",{type:"button",className:w?"armed":"",...X(()=>N(z=>!z)),children:"ALT"},"alt"),$("←",Ht+"[D"),$("↓",Ht+"[B"),$("→",Ht+"[C"),$("PGDN",Ht+"[6~")]})]}),F]})]})}const QN=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function fw({session:e,node:t,token:n,filesEvent:s,onClose:o}){Yn();const a=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",u=t?`${t}:${e}`:e,[d,p]=k.useState("outbox"),[m,v]=k.useState({inbox:[],outbox:[]}),[y,b]=k.useState(""),S=k.useRef(null);async function x(){try{const L=await(await on(`${a}/files?session=${encodeURIComponent(e)}`,n)).json();if(L.error){b(L.error);return}v(L);const I=L.outbox[0]?L.outbox[0].mtime:0;localStorage.setItem($y(u),String(I))}catch(C){b(String(C))}}k.useEffect(()=>{x()},[e,t]),k.useEffect(()=>{s&&s.session===e&&x()},[s]);async function E(C){for(const L of C){b(`carico ${L.name}…`);const I=new FormData;I.append("session",e),I.append("file",L);try{const K=await(await on(`${a}/files/upload`,n,{method:"POST",body:I})).json();b(K.error?`errore: ${K.error}`:"")}catch(G){b(String(G))}}x()}async function w(C){const L=await on(`${a}/files/download?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(C)}`,n);if(!L.ok){const Y=await L.json().catch(()=>({}));b(Y.error?`errore: ${Y.error}`:"errore download");return}const I=await L.blob(),G=URL.createObjectURL(I),K=document.createElement("a");K.href=G,K.download=C,K.click(),URL.revokeObjectURL(G)}async function N(C){const L=await on(`${a}/files?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(C)}`,n,{method:"DELETE"});if(!L.ok){const I=await L.json().catch(()=>({}));b(I.error?`errore: ${I.error}`:"errore delete");return}x()}return l.jsxs("div",{className:"nc-files",children:[l.jsxs("header",{children:[l.jsx("b",{children:t?`${t}:${e}`:e}),l.jsx("button",{onClick:o,title:f("close"),children:l.jsx(lt,{name:"x",size:20})})]}),l.jsxs("nav",{children:[l.jsx("button",{className:d==="outbox"?"on":"",onClick:()=>p("outbox"),children:"outbox"}),l.jsx("button",{className:d==="inbox"?"on":"",onClick:()=>p("inbox"),children:"inbox"}),l.jsxs("button",{className:"up",onClick:()=>S.current&&S.current.click(),children:[l.jsx(lt,{name:"upload",size:18})," ",f("upload")]}),l.jsx("input",{type:"file",multiple:!0,ref:S,style:{display:"none"},onChange:C=>{E(Array.from(C.target.files||[])),C.target.value=""}})]}),y&&l.jsx("div",{className:"nc-busy",children:y}),l.jsxs("ul",{children:[m[d].map(C=>l.jsxs("li",{children:[l.jsx("span",{className:"name",onClick:()=>w(C.name),children:C.name}),l.jsx("small",{children:QN(C.size)}),l.jsx("button",{onClick:()=>N(C.name),title:f("delete"),children:l.jsx(lt,{name:"trash",size:18})})]},C.name)),m[d].length===0&&l.jsx("li",{className:"empty",children:f("empty-files")})]})]})}const Ac="nc_composer_v1",mf="nc-composer-reset",JN=50,pw=256*1024,mw=512*1024,ZN=768*1024,C_=2*1024*1024,gw=720*60*60*1e3,gf=1;function vw(e){const t=Number(e);return Number.isFinite(t)&&t>0?t:0}function rp(e){if(e!==void 0)return e;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Sc(){return{version:gf,cells:{}}}function _w(e){const t=[];for(const s of Array.isArray(e)?e:[]){const o=typeof s=="string"?s:s&&s.text,a=vw(typeof s=="string"?0:s&&s.at);if(!(typeof o!="string"||!o||o.length>pw)&&!(t.length&&t[t.length-1].text===o)&&(t.push({text:o,at:a}),t.length>=JN))break}let n=0;return t.filter(s=>n+s.text.length>ZN?!1:(n+=s.text.length,!0))}function xc(e){if(!e||typeof e!="object")return null;const t=typeof e.draft=="string"&&e.draft.length<=mw?e.draft:"",n=_w(e.history),s=vw(e.updatedAt),o=e.expanded===!0;return!t&&!n.length&&!o?null:{draft:t,history:n,expanded:o,updatedAt:s}}function e2(e){let t;try{t=typeof e=="string"?JSON.parse(e):e}catch{return Sc()}if(!t||typeof t!="object"||t.version!==gf||!t.cells||typeof t.cells!="object")return Sc();const n=Object.create(null);for(const[s,o]of Object.entries(t.cells)){if(!s||typeof s!="string"||s.length>512||s==="__proto__"||s==="constructor"||s==="prototype")continue;const a=xc(o);a&&(n[s]=a)}return{version:gf,cells:n}}function yw(e){const t=rp(e);if(!t)return Sc();try{return e2(t.getItem(Ac))}catch{return Sc()}}function E_(e){try{return JSON.stringify(e).length}catch{return 1/0}}function t2(e,t,n){for(const[s,o]of Object.entries(e.cells))s!==n&&o.updatedAt>0&&t-o.updatedAt>gw&&delete e.cells[s]}function bw(e,t){return Object.entries(e.cells).filter(([n])=>n!==t).sort((n,s)=>n[1].updatedAt-s[1].updatedAt).map(([n])=>n)}function n2(e,t){for(;E_(e)>C_;){const n=Object.entries(e.cells).filter(([,s])=>s.history.length).sort((s,o)=>s[1].updatedAt-o[1].updatedAt);if(!n.length)break;n[0][1].history.pop()}for(const n of bw(e,t)){if(E_(e)<=C_)break;delete e.cells[n]}}function ww(e,t,n){const s=rp(e);if(!s)return!1;n2(t,n);const o=()=>(s.setItem(Ac,JSON.stringify(t)),!0);try{return o()}catch{for(const u of bw(t,n)){delete t.cells[u];try{return o()}catch{}}return!1}}function Da(e,t,n,s){const o=yw(t);t2(o,n,e);const a=xc(o.cells[e])||{draft:"",history:[],expanded:!1,updatedAt:0},u=s({...a,history:[...a.history]}),d=xc(u);return d?o.cells[e]={...d,updatedAt:n}:delete o.cells[e],{ok:ww(t,o,e),cell:o.cells[e]||{draft:"",history:[],expanded:!1,updatedAt:n}}}function i2({ownerId:e,node:t,session:n}){const s=String(n||"");if(!s)return"";const o=vo.test(String(e||""))?String(e):t?`route:${String(t)}`:"local";return`${encodeURIComponent(o)}:${encodeURIComponent(s)}`}function ua(e,t,n=Date.now()){if(!e)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=yw(t),o=xc(s.cells[e]);return!o||o.updatedAt>0&&n-o.updatedAt>gw?(s.cells[e]&&(delete s.cells[e],ww(t,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...o,history:[...o.history]}}function N_(e,t,n,s=Date.now()){const o=String(t||"");return!e||o.length>mw?!1:Da(e,n,s,a=>({...a,draft:o})).ok}function j_(e,t,n=Date.now()){return e?Da(e,t,n,s=>({...s,draft:""})).ok:!1}function s2(e,t,n,s=Date.now()){return e?Da(e,n,s,o=>({...o,expanded:!!t})).ok:!1}function r2(e,t,n,s=Date.now()){const o=String(t||"");return!e||!o||o.length>pw?!1:Da(e,n,s,a=>{const u=a.history.filter(d=>d.text!==o);return u.unshift({text:o,at:s}),{...a,history:_w(u)}}).ok}function o2(e,t,n=Date.now()){return e?Da(e,t,n,s=>({...s,history:[]})).ok:!1}function a2(e){const t=rp(e);if(!t)return!1;try{return t.removeItem(Ac),!0}catch{return!1}}const l2=300;function c2(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function u2({ownerId:e,node:t,session:n,storage:s=c2()}){const o=k.useMemo(()=>i2({ownerId:e,node:t,session:n}),[e,t,n]),a=k.useMemo(()=>ua(o,s),[]),[u,d]=k.useState(a.draft),[p,m]=k.useState(a.expanded),[v,y]=k.useState(a.history),[b,S]=k.useState(-1),x=k.useRef(o),E=k.useRef(a.draft),w=k.useRef(null),N=k.useRef(a.updatedAt||0),C=k.useRef(a.draft),L=k.useCallback(()=>{w.current&&clearTimeout(w.current),w.current=null},[]),I=k.useCallback(()=>{L(),N_(x.current,E.current,s)},[L,s]),G=k.useCallback(()=>{L(),w.current=setTimeout(()=>{w.current=null,N_(x.current,E.current,s)},l2)},[L,s]),K=k.useCallback(O=>{const F=String(typeof O=="function"?O(E.current):O||"");E.current=F,N.current=Date.now(),C.current=F,S(-1),d(F),G()},[G]),Y=k.useCallback((O,F)=>{L(),E.current=O,N.current=Date.now(),d(O),S(F),G()},[L,G]),Q=k.useCallback(()=>{if(!v.length)return!1;const O=Math.min(b+1,v.length-1);return b<0&&(C.current=E.current),Y(v[O].text,O),!0},[Y,v,b]),W=k.useCallback(()=>{if(b<0)return!1;const O=b-1;return Y(O<0?C.current:v[O].text,O),!0},[Y,v,b]),X=k.useCallback(O=>{C.current=E.current;const F=v.findIndex(A=>A.text===O);Y(String(O||""),F)},[Y,v]),H=k.useCallback(()=>{m(O=>{const F=!O;return s2(x.current,F,s),F})},[s]),$=k.useCallback((O,F,A)=>{if(!O)return;if(r2(O,A,s),!(x.current===O)){ua(O,s).draft===F&&j_(O,s);return}y(ua(O,s).history),C.current="",S(-1),E.current===F?(L(),E.current="",N.current=Date.now(),d(""),j_(O,s)):G()},[L,G,s]),R=k.useCallback(()=>{o2(x.current,s),y([]),S(-1),C.current=E.current},[s]);return k.useEffect(()=>{if(x.current===o)return;I(),x.current=o;const O=ua(o,s);E.current=O.draft,N.current=O.updatedAt||0,C.current=O.draft,d(O.draft),m(O.expanded),y(O.history),S(-1)},[o,I,s]),k.useEffect(()=>{const O=()=>I(),F=()=>{document.visibilityState==="hidden"&&I()};return window.addEventListener("pagehide",O),document.addEventListener("visibilitychange",F),()=>{window.removeEventListener("pagehide",O),document.removeEventListener("visibilitychange",F),I()}},[I]),k.useEffect(()=>{const O=()=>{L(),E.current="",N.current=0,C.current="",d(""),m(!1),y([]),S(-1)},F=T=>{if(T.key!==Ac)return;if(T.newValue==null){O();return}const j=ua(x.current,s);j.updatedAt<N.current||(L(),E.current=j.draft,N.current=j.updatedAt,C.current=j.draft,d(j.draft),m(j.expanded),y(j.history),S(-1))},A=()=>O();return window.addEventListener("storage",F),window.addEventListener(mf,A),()=>{window.removeEventListener("storage",F),window.removeEventListener(mf,A)}},[L,s]),{cellKey:o,text:u,setText:K,expanded:p,toggleExpanded:H,history:v,historyCursor:b,recallPrevious:Q,recallNext:W,selectHistory:X,confirmSubmitted:$,clearHistory:R,flush:I}}function Sw({submitText:e,token:t,session:n,node:s,ownerId:o,readonly:a=!1,keepKeyboardClosedOnVoice:u=!0}){Yn();const d=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:p,text:m,setText:v,expanded:y,toggleExpanded:b,history:S,historyCursor:x,recallPrevious:E,recallNext:w,selectHistory:N,confirmSubmitted:C,clearHistory:L,flush:I}=u2({ownerId:o,node:s,session:n}),[G,K]=k.useState(!1),[Y,Q]=k.useState(""),[W,X]=k.useState(""),[H,$]=k.useState(!1),R=k.useRef(null),O=k.useRef(null),F=k.useRef(null),[A,T]=k.useState(!1),[j,z]=k.useState({left:0,bottom:0}),[M,D]=k.useState(!1),[B,U]=k.useState(!1),se=k.useRef(null),ee=k.useRef(null),de=k.useRef(null),ve=k.useRef(null),fe=k.useRef(null),pe=k.useRef(null),Ve=k.useRef(null),ut=k.useRef(null),vt=k.useRef(!1),[je,Ct]=k.useState(!1),[dn,gn]=k.useState({left:0,bottom:0,width:320}),Yt=k.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);k.useEffect(()=>{let ie=!1;if(s){$(!1);return}return on(`${d}/voice/status`,t).then(_e=>_e.json()).then(_e=>{ie||$(!!_e.serverSttConfigured)}).catch(()=>{ie||$(!1)}),()=>{ie=!0}},[t,d]);const Ot=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||H);async function Ut(){const ie=F.current&&typeof F.current.value=="string"?F.current.value:m;pf(),ie!==m&&v(ie);const _e=ie,be=hN(_e);if(!be||B)return;if(a){Q(f("settings-readonly"));return}U(!0),Q("");let ke=!1;try{ke=!!await e(be)}catch{ke=!1}ke?C(p,_e,be):Q(f("composer-send-failed")),U(!1)}function Nt(){const ie=se.current&&se.current.getBoundingClientRect();ie&&z({left:Math.max(6,Math.min(ie.left,window.innerWidth-186)),bottom:window.innerHeight-ie.top+6}),T(!0)}function Dt(ie){T(!1),ie&&se.current&&se.current.focus()}function At(){const ie=de.current&&de.current.getBoundingClientRect();if(ie){const _e=Math.max(220,Math.min(360,window.innerWidth-12));gn({left:Math.max(6,Math.min(ie.right-_e,window.innerWidth-_e-6)),bottom:window.innerHeight-ie.top+6,width:_e})}Ct(!0)}function jt(ie){Ct(!1),ie&&de.current&&de.current.focus()}k.useEffect(()=>{if(!A)return;const ie=be=>{be.key==="Escape"&&Dt(!0)},_e=be=>{const ke=ee.current&&ee.current.contains(be.target),it=se.current&&se.current.contains(be.target);!ke&&!it&&Dt(!1)};return document.addEventListener("keydown",ie),document.addEventListener("pointerdown",_e),()=>{document.removeEventListener("keydown",ie),document.removeEventListener("pointerdown",_e)}},[A]),k.useEffect(()=>{if(!je)return;const ie=be=>{be.key==="Escape"&&jt(!0)},_e=be=>{const ke=ve.current&&ve.current.contains(be.target),it=de.current&&de.current.contains(be.target);!ke&&!it&&jt(!1)};return document.addEventListener("keydown",ie),document.addEventListener("pointerdown",_e),()=>{document.removeEventListener("keydown",ie),document.removeEventListener("pointerdown",_e)}},[je]);function hn(ie){if(!(ie.isComposing||vt.current||ie.altKey||ie.ctrlKey||ie.metaKey)){if(ie.key==="ArrowUp"&&ie.currentTarget.selectionStart===0&&ie.currentTarget.selectionEnd===0){E()&&ie.preventDefault();return}ie.key==="ArrowDown"&&x>=0&&ie.currentTarget.selectionStart===m.length&&ie.currentTarget.selectionEnd===m.length&&w()&&ie.preventDefault()}}function re(ie){Dt(!1),ie.current&&ie.current.click()}async function Qe(ie){if(!ie.length||!n)return;D(!0),Q("");const{paths:_e,errors:be}=await ff({files:ie,token:t,session:n,node:s,paste:!1});be.length&&Q(be.map(ke=>`${ke.name}: ${ke.message}`).join(" · ")),_e.length&&v(ke=>ke+(ke&&!ke.endsWith(" ")?" ":"")+_e.join(" ")),D(!1)}async function me(ie){var ke;if(!ie.length||!n)return;D(!0),Q(""),X("");const{paths:_e,errors:be}=await ff({files:ie,token:t,session:n,node:s,paste:!1});if(be.length&&Q(be.map(it=>`${it.name}: ${it.message}`).join(" · ")),_e.length){X(f("attach-inbox-done").replace("{n}",String(_e.length)));try{(ke=navigator.vibrate)==null||ke.call(navigator,10)}catch{}setTimeout(()=>X(""),2500)}D(!1)}function Ge(){R.current&&R.current.stop(),O.current&&O.current.stop(),K(!1)}async function ct(){Q("");const ie=window.SpeechRecognition||window.webkitSpeechRecognition;if(ie){const _e=new ie;_e.lang="it-IT",_e.continuous=!1,_e.interimResults=!0;const be=m?`${m} `:"";_e.onresult=ke=>{const it=Array.from(ke.results).map(ht=>ht[0].transcript).join("");v(be+it)},_e.onend=()=>K(!1),_e.onerror=ke=>{Q(`voice: ${ke.error||"errore"}`),K(!1)},R.current=_e,_e.start(),K(!0);return}try{const _e=await navigator.mediaDevices.getUserMedia({audio:!0}),be=new MediaRecorder(_e),ke=[];be.ondataavailable=it=>ke.push(it.data),be.onstop=async()=>{_e.getTracks().forEach(it=>it.stop()),K(!1),Q("trascrivo…");try{const it=new Blob(ke,{type:be.mimeType||"audio/webm"}),dt=await(await on(`${d}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:it})).json();dt.error?Q(dt.error):(Q(""),v(Rt=>Rt+(Rt?" ":"")+(dt.text||"")))}catch(it){Q(String(it))}},O.current={stop:()=>be.state!=="inactive"&&be.stop()},be.start(),K(!0)}catch{Q("microfono non disponibile"),K(!1)}}function oe(){u&&pf(),G?Ge():ct()}return l.jsxs("div",{className:"nc-composer",children:[Y&&l.jsx("div",{className:"nc-composer-err",children:Y}),W&&l.jsx("div",{className:"nc-composer-info",children:W}),l.jsxs("div",{className:"nc-composer-row",children:[n&&l.jsx("button",{ref:se,className:M?"attach busy":"attach",disabled:M,onClick:()=>A?Dt(!1):Nt(),title:f(M?"attach-uploading":"attach"),"aria-label":f("attach"),"aria-haspopup":"menu","aria-expanded":A,"aria-controls":Yt.current,children:l.jsx(lt,{name:"attach",size:22})}),A&&l.jsxs("div",{ref:ee,id:Yt.current,role:"menu",className:"nc-attach-menu",style:{left:j.left,bottom:j.bottom},children:[l.jsxs("button",{role:"menuitem",onClick:()=>re(fe),children:[l.jsx(lt,{name:"file",size:18})," ",f("attach-file")]}),l.jsxs("button",{role:"menuitem",onClick:()=>re(pe),children:[l.jsx(lt,{name:"camera",size:18})," ",f("attach-camera")]}),l.jsxs("button",{role:"menuitem",onClick:()=>re(Ve),children:[l.jsx(lt,{name:"image",size:18})," ",f("attach-gallery")]}),l.jsxs("button",{role:"menuitem",onClick:()=>re(ut),children:[l.jsx(lt,{name:"folder",size:18})," ",f("attach-inbox")]})]}),l.jsx("button",{ref:de,type:"button",className:"history",onPointerDown:ie=>ie.preventDefault(),onClick:()=>je?jt(!1):At(),title:f("composer-history-tools"),"aria-label":f("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":je,children:l.jsx(lt,{name:"history",size:21})}),je&&l.jsxs("div",{ref:ve,role:"menu",className:"nc-composer-history-menu",style:{left:dn.left,bottom:dn.bottom,width:dn.width},children:[l.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:ie=>ie.preventDefault(),onClick:()=>{b(),jt(!1)},children:[l.jsx(lt,{name:y?"chevronDown":"chevronUp",size:18}),f(y?"composer-collapse":"composer-expand")]}),l.jsx("div",{className:"nc-composer-history-title",children:f("composer-history")}),S.length===0&&l.jsx("div",{className:"nc-composer-history-empty",children:f("composer-history-empty")}),S.map((ie,_e)=>l.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:be=>be.preventDefault(),onClick:()=>{N(ie.text),jt(!1)},children:[l.jsx("span",{children:ie.text.replace(/\s+/g," ").slice(0,180)}),ie.at>0&&l.jsx("small",{children:new Date(ie.at).toLocaleString()})]},`${ie.at}:${_e}`)),S.length>0&&l.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:ie=>ie.preventDefault(),onClick:()=>{L(),jt(!1)},children:f("composer-history-clear")})]}),l.jsx("input",{ref:fe,type:"file",multiple:!0,hidden:!0,onChange:ie=>{Qe(Array.from(ie.target.files||[])),ie.target.value=""}}),l.jsx("input",{ref:pe,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:ie=>{Qe(Array.from(ie.target.files||[])),ie.target.value=""}}),l.jsx("input",{ref:Ve,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:ie=>{Qe(Array.from(ie.target.files||[])),ie.target.value=""}}),l.jsx("input",{ref:ut,type:"file",multiple:!0,hidden:!0,onChange:ie=>{me(Array.from(ie.target.files||[])),ie.target.value=""}}),l.jsx("textarea",{ref:F,className:y?"expanded":"",rows:y?8:2,value:m,placeholder:f("composer-placeholder"),onChange:ie=>v(ie.target.value),onKeyDown:hn,onCompositionStart:()=>{vt.current=!0},onCompositionEnd:()=>{vt.current=!1},onBlur:I}),Ot&&l.jsx("button",{type:"button",className:G?"mic on":"mic",title:f("voice"),"aria-label":f("voice"),onPointerDown:ie=>{ie.preventDefault(),oe()},onClick:ie=>{ie.detail===0&&oe()},children:l.jsx(lt,{name:"mic",size:22})}),l.jsx("button",{type:"button",className:"go",disabled:B,onPointerDown:ie=>ie.preventDefault(),onClick:Ut,title:f("send"),children:l.jsx(lt,{name:"enter",size:22})})]})]})}const op="nc_popup_assetto",d2=320,h2=240,f2=1100,p2=820,R_=48,m2=44;function xw(){return{vw:window.innerWidth||1024,vh:window.innerHeight||768}}function ba(e){const{vw:t,vh:n}=xw(),s=Math.max(d2,Math.min(e.w,t)),o=Math.max(h2,Math.min(e.h,n)),a=Math.max(-(s-R_),Math.min(e.x,t-R_)),u=Math.max(0,Math.min(e.y,Math.max(0,n-m2)));return{x:a,y:u,w:s,h:o}}function P_(){try{const e=window.localStorage.getItem(op);if(!e)return null;const t=JSON.parse(e);return!t||![t.x,t.y,t.w,t.h].every(n=>typeof n=="number"&&Number.isFinite(n))?null:ba(t)}catch{return null}}function g2(e){try{window.localStorage.setItem(op,JSON.stringify(e))}catch{}}function v2(){const[e,t]=k.useState(()=>typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 720px)").matches);return k.useEffect(()=>{if(typeof window.matchMedia!="function")return;const n=window.matchMedia("(max-width: 720px)"),s=o=>t(!!(o&&o.matches));if(typeof n.addEventListener=="function")return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),e}function kw({title:e,subtitle:t,onClose:n,children:s}){const o=k.useRef(null),a=k.useRef(null),u=v2(),[d,p]=k.useState(()=>u?null:P_()),m=k.useRef(null),[v,y]=k.useState(!1),b=k.useCallback(()=>{n&&n()},[n]);k.useEffect(()=>{const N=C=>{C.key==="Escape"&&(C.stopPropagation(),b())};return document.addEventListener("keydown",N,!0),()=>document.removeEventListener("keydown",N,!0)},[b]),k.useEffect(()=>{const N=a.current;N&&typeof N.focus=="function"&&N.focus()},[]);const S=()=>{const{vw:N,vh:C}=xw(),L=Math.min(f2,Math.floor(N*.96)),I=Math.min(p2,Math.floor(C*.92));return ba({x:Math.round((N-L)/2),y:Math.round((C-I)/2),w:L,h:I})},x=N=>C=>{if(u||C.button!==0||C.target&&typeof C.target.closest=="function"&&C.target.closest(".nc-popup-chiudi"))return;C.preventDefault();const L=d||S();m.current={mode:N,startX:C.clientX,startY:C.clientY,base:L},p(L),y(!0)};k.useEffect(()=>{if(!v)return;const N=L=>{const I=m.current;if(!I)return;const G=L.clientX-I.startX,K=L.clientY-I.startY;I.mode==="move"?p(ba({...I.base,x:I.base.x+G,y:I.base.y+K})):p(ba({...I.base,w:I.base.w+G,h:I.base.h+K}))},C=()=>{m.current=null,y(!1),p(L=>(L&&g2(L),L))};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",C)}},[v]);const E=()=>{if(!u){m.current=null,y(!1),p(null);try{window.localStorage.removeItem(op)}catch{}}};k.useEffect(()=>{if(u)return;const N=()=>p(C=>C&&ba(C));return window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[u]),k.useEffect(()=>{u||p(N=>N||P_())},[u]);const w=!!(d&&!u);return l.jsxs("div",{className:"nc-popup-velo",onMouseDown:N=>{N.target===N.currentTarget&&b()},role:"presentation",children:[l.jsxs("div",{className:w?"nc-popup nc-popup-libera":"nc-popup",style:w?{left:d.x,top:d.y,width:d.w,height:d.h}:void 0,ref:o,role:"dialog","aria-modal":"true","aria-label":e||f("panel"),children:[l.jsxs("header",{className:"nc-popup-testa",onMouseDown:x("move"),onDoubleClick:E,title:f("popup-drag-hint"),children:[l.jsxs("span",{className:"nc-popup-titolo",children:[e,t?l.jsx("small",{className:"nc-popup-sub",children:t}):null]}),l.jsx("button",{type:"button",ref:a,className:"nc-popup-chiudi",onClick:b,title:f("close"),"aria-label":f("close"),children:"✕"})]}),l.jsx("div",{className:"nc-popup-corpo",children:s}),!u&&l.jsx("div",{className:"nc-popup-angolo",onMouseDown:x("resize"),title:f("popup-resize-hint"),role:"presentation"})]}),v&&l.jsx("div",{className:"nc-popup-velo-drag",role:"presentation"})]})}function ap({cellId:e,panelUrl:t,route:n=[],panelPort:s=0,token:o,title:a,requestTimeoutMs:u=4e3}){const[d,p]=k.useState(e&&o?"requesting":"none"),[m,v]=k.useState(""),y=Array.isArray(n)?n.join("\0"):"",b=k.useMemo(()=>Array.isArray(n)?n:[],[y]),S=k.useRef(0),x=k.useCallback(async()=>{if(!e||!o||!t){p("none");return}const L=S.current+=1;p("requesting");const I=new AbortController,G=setTimeout(()=>I.abort(),u);try{const K=await ax(o,b,e,{signal:I.signal});if(clearTimeout(G),L!==S.current)return;if(K.ok){let Y="/";try{Y=new URL(t).pathname||"/"}catch{}const Q=s?`http://127.0.0.1:${s}`:nn(b);v(`${Q}/panel/${encodeURIComponent(e)}${Y}?ticket=${encodeURIComponent(K.ticket)}`),p("ready")}else p(K.cause)}catch(K){if(clearTimeout(G),L!==S.current)return;p(K&&K.name==="AbortError"?"timeout":"unreachable")}},[e,t,b,s,o,u]),E=k.useCallback(()=>{p(L=>L==="ready"?"loaded":L)},[]),w=k.useCallback(()=>{p(L=>L==="ready"||L==="loaded"?"frame-error":L)},[]),N=k.useCallback(L=>{L&&(L.onload=E,L.onerror=w)},[E,w]);k.useEffect(()=>{x()},[x]);const C=(L,I=!0)=>l.jsxs("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:[l.jsx("span",{children:f(L)}),I&&l.jsx("span",{className:"nc-cellpanel-actions",children:l.jsx("button",{type:"button",title:f("panel-retry"),onClick:()=>x(),children:f("panel-retry")})})]});return d==="none"||d==="no-panel"?C("panel-none",!1):d==="requesting"?l.jsx("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:l.jsx("span",{children:f("panel-checking")})}):d==="not-granted"?C("panel-not-granted",!1):d==="node-refused"?C("panel-node-refused",!1):d==="unauthorized"?C("panel-unauthorized",!1):d==="denied"?C("panel-denied"):d==="timeout"?C("panel-timeout"):d==="unreachable"?C("panel-unreachable"):d==="frame-error"?C("panel-frame-error"):l.jsxs(l.Fragment,{children:[d==="ready"&&l.jsx("div",{className:"nc-cellpanel-loading",role:"status",children:f("panel-frame-loading")}),l.jsx("iframe",{ref:N,className:"nc-cellpanel nc-cellpanel-frame","data-frame-state":d,src:m,title:a||f("panel"),allowFullScreen:!0})]})}const _2=1800*1e3;function vf(e,t,n=Date.now()){const s=Number(t);if(!Number.isFinite(s)||s<=0)return"";const o=n-s;if(o<0||o>_2)return"";if(o<60*1e3)return`${e("cell-activity")} ${e("cell-activity-now")}`;const a=Math.floor(o/6e4);return a<60?`${e("cell-activity")} ${a}m`:`${e("cell-activity")} ${Math.floor(a/60)}h`}function _f(e,t){if(!t||typeof t!="object")return"";const n=[];return Number.isInteger(t.contextFreePct)&&n.push(`${e("cell-tele-ctx")} ${t.contextFreePct}% ${e("cell-tele-free")}`),Number.isInteger(t.tier5hUsedPct)&&n.push(`${e("cell-tele-5h")} ${t.tier5hUsedPct}%`),Number.isInteger(t.tier7dUsedPct)&&n.push(`${e("cell-tele-7d")} ${t.tier7dUsedPct}%`),n.join(" · ")}function Cw({row:e,token:t,initialSource:n="preview",panelPort:s=0,onClose:o}){const[a,u]=k.useState(n==="panel"&&!e.panelUrl?"preview":n),d=k.useRef(()=>{}),p=k.useRef(()=>!1),m=k.useRef(()=>{}),v=k.useRef(!1),[y,b]=k.useState(!1),S=[["preview",f("cell-peek-preview")],["stream",f("cell-peek-stream")],...e.panelUrl?[["panel",f("cell-peek-panel")]]:[]];return l.jsxs(kw,{title:e.cellName,subtitle:[e.nodeLabel,e.subtitle].filter(Boolean).join(" · "),onClose:o,children:[l.jsx("div",{className:"nc-peek-sorgenti",role:"tablist",children:S.map(([x,E])=>l.jsx("button",{type:"button",role:"tab","aria-selected":a===x,className:`nc-peek-sorgente${a===x?" attiva":""}`,onClick:()=>u(x),children:E},x))}),a==="stream"?l.jsx("div",{className:"nc-peek-stream",children:l.jsx(sp,{session:e.session,node:e.node||void 0,token:t,readonly:!1,takeSize:!1,focused:!0,sendRef:d,composerRef:p,actionRef:m,ctrlRef:v,setCtrlArmed:b},`peek:${e.key}`)}):a==="panel"?l.jsx(ap,{cellId:e.cellName,panelUrl:e.panelUrl,route:e.route||[],panelPort:s,token:t,title:e.cellName}):l.jsxs(l.Fragment,{children:[l.jsx("pre",{className:"nc-peek-testo",children:e.preview||f("cell-peek-vuoto")}),[vf(f,e.activity),_f(f,e.telemetry)].filter(Boolean).join(" · ")&&l.jsx("small",{className:"nc-cell-switcher-telemetry",children:[vf(f,e.activity),_f(f,e.telemetry)].filter(Boolean).join(" · ")})]})]})}function Id(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const y2=180,b2=480,lo=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function w2({sessions:e=[],cells:t=[],activeSessions:n=[],nodeGroups:s=[],onPick:o,onAddTile:a,onPower:u,onBoot:d,onNodePower:p,onKill:m,onVisibility:v,onNew:y,onNodeRename:b,onSettings:S,onBootError:x,localNodeId:E,fleetCapabilities:w=[],fleetStale:N=!1,fleetOff:C=null,bootSettlement:L=null,hostByRoute:I={},onDesignateCell:G,onClearHostCell:K,onBootSettlementApplied:Y,onOpenVlSession:Q,token:W="",onPeekOpen:X,overlayOpen:H=!1,width:$=240,collapsed:R=!1,onResize:O,onToggleCollapse:F}){const[A,T]=Yn(),{pins:j,orders:z,togglePin:M,removePin:D,pinError:B,retryPinPersist:U,clearPinError:se,viewFor:ee,updateView:de,canMoveRoster:ve,moveRoster:fe,stepRoster:pe}=Ff(),{groupsFor:Ve,moveNode:ut,stepNode:vt,nodeKey:je}=cb(),Ct=V=>I[wa(V)]||{};function dn(V,ae,ye,Me){const De=db(ye);if(De==="addPin"){M(V.key);return}if(De==="designate"){G&&G(ae.cell,Me);return}if(De==="clearAndUnpin"){if(!K)return;Promise.resolve(K(Me)).then(Ee=>{Ee&&D(V.key)})}}const gn=new Set((t||[]).map(V=>V.tmuxSession)),Yt=new Map((e||[]).map(V=>[V.name,V])),xt=(V,ae)=>vk(j,V,ae),Ot=_k,Ut=[...t||[]].sort((V,ae)=>Ot(xt(V.tmuxSession,(Yt.get(V.tmuxSession)||{}).activity),xt(ae.tmuxSession,(Yt.get(ae.tmuxSession)||{}).activity))),Nt=(e||[]).filter(V=>!gn.has(V.name)).sort((V,ae)=>Ot(xt(V.name,V.activity),xt(ae.name,ae.activity))||V.name.localeCompare(ae.name)),Dt=new Set(n||[]),[At,jt]=k.useState(null),[hn,re]=k.useState("preview"),Qe=(V,ae,ye=[],Me="",De=null)=>{const Xe=(ye.length===0?Yt.get(ae.tmuxSession):(De||[]).find(yt=>yt&&yt.name===ae.tmuxSession))||{};return{key:V.key,cellName:ae.cell,subtitle:V.subtitle||"",nodeLabel:Me,node:ye.length?ye.join("/"):"",session:ae.tmuxSession,route:ye,panelUrl:ae.panelUrl||"",telemetry:Xe.telemetry||null,preview:Xe.preview||ae.preview||"",activity:Xe.activity||ae.activity||0}},me=(V,ae,ye=[],Me="",De="preview")=>Ee=>{Ee&&Ee.stopPropagation(),re(De),jt(V.key),typeof X=="function"&&X()};k.useEffect(()=>{H&&(jt(null),re("preview"))},[H]);const Ge=Wf(Ut,Nt,Yt),ct=qs(Ge,j,ee("local").filter,ms(z,"local")),ie=Ve(s||[]).map(V=>{const ae=(V.route&&V.route.length?V.route:[V.name]).join("/"),ye=ee(ae);if(V.kind==="vl")return{g:V,nodeRoute:ae,groupView:ye,rawItems:[],items:[]};const{rawItems:Me}=fc(V),De=qs(Me,j,ye.filter,ms(z,ae));return{g:V,nodeRoute:ae,groupView:ye,rawItems:Me,items:De}}),_e=[...ct,...ie.flatMap(({items:V,nodeRoute:ae,g:ye})=>(V||[]).map(Me=>({...Me,nodeRoute:ae,nodeLabel:ye.label||ye.name})))].filter(V=>V.type==="cell"),be=At?_e.find(V=>V.key===At):null,ke=(V,ae,ye)=>o&&o({session:V,...ae?{node:ae}:{},...vo.test(String(ye||""))?{ownerId:ye}:{}}),it=async V=>{if(!(V!=null&&V.direct)||!b)return;const ae=window.prompt(f("rename-node-prompt"),V.label||V.name);if(ae!==null)try{await b(V,ae)||window.alert(f("rename-node-invalid"))}catch(ye){window.alert(String((ye==null?void 0:ye.message)||ye))}},[ht,dt]=k.useState({}),[Rt,wt]=k.useState(new Set);k.useEffect(()=>{const V=new Map;for(const ae of t||[])V.set(lo(ae.cell),!!ae.boot);for(const ae of s||[]){const ye=ae.route||[ae.name];for(const Me of ae.cells||[])V.set(lo(Me.cell,ye),!!Me.boot)}dt(ae=>{let ye=!1;const Me={...ae};for(const[De,Ee]of Object.entries(ae))V.has(De)&&V.get(De)===Ee&&(delete Me[De],ye=!0);return ye?Me:ae})},[t,s]),k.useEffect(()=>{if(!(L!=null&&L.cell))return;const V=Array.isArray(L.route)?L.route:[],ae=lo(L.cell,V);dt(ye=>({...ye,[ae]:!!L.enabled})),Y&&Y(L.id)},[L,Y]);const _t=(V,ae=[])=>{const ye=lo(V.cell,ae);return Object.prototype.hasOwnProperty.call(ht,ye)?ht[ye]:!!V.boot},zt=async(V,ae,ye=[])=>{if(V.stopPropagation(),!d)return;const Me=lo(ae.cell,ye),De=!_t(ae,ye);dt(Ee=>({...Ee,[Me]:De})),wt(Ee=>new Set(Ee).add(Me));try{await d(ae.cell,De,ye)}catch(Ee){dt(Xe=>{const yt={...Xe};return delete yt[Me],yt}),x&&x(Ee)}finally{wt(Ee=>{const Xe=new Set(Ee);return Xe.delete(Me),Xe})}},Je=(V,ae=[])=>{const ye=lo(V.cell,ae),Me=_t(V,ae),De=`${f(Me?"boot-disable":"boot-enable")} ${V.cell}`;return l.jsx("button",{className:`nc-boot${Me?" on":""}`,disabled:Rt.has(ye),onClick:Ee=>zt(Ee,V,ae),title:De,"aria-label":De,children:l.jsx(lt,{name:"boot",size:14})})},[J,Ne]=k.useState(null),Ue=(V,ae)=>{const ye=V.currentTarget.getBoundingClientRect();Ne({text:ae,y:ye.top+ye.height/2})},Oe=()=>Ne(null),Le=k.useRef(null);k.useEffect(()=>()=>{Le.current&&Le.current()},[]);function Et(V){V.preventDefault(),V.stopPropagation();const ae=V.clientX,ye=$,Me=Ee=>{const Xe=Math.max(y2,Math.min(b2,ye+(Ee.clientX-ae)));O&&O(Xe)},De=()=>{window.removeEventListener("pointermove",Me),window.removeEventListener("pointerup",De),window.removeEventListener("pointercancel",De),window.removeEventListener("blur",De),Le.current=null};window.addEventListener("pointermove",Me),window.addEventListener("pointerup",De),window.addEventListener("pointercancel",De),window.addEventListener("blur",De),Le.current=De}const kt=R?{width:48,flex:"0 0 48px"}:{width:$,flex:`0 0 ${$}px`};return R?l.jsxs("aside",{className:"nc-sidebar mini",style:kt,children:[l.jsx("div",{className:"nc-side-head mini",children:l.jsx("button",{className:"nc-collapse-btn",onClick:F,title:f("expand"),children:"⟩"})}),l.jsx("button",{className:"nc-side-gear mini",onClick:()=>S&&S("nodes",!1),title:f("settings"),onMouseEnter:V=>Ue(V,f("settings")),onMouseLeave:Oe,children:l.jsx(lt,{name:"gear",size:16})}),l.jsx("div",{className:"nc-side-scroll mini",children:l.jsxs("div",{className:"nc-side-group mini",children:[ee("local").open&&ct.map(V=>V.type==="cell"?(()=>{const ae=V.value,ye=ae.degraded?"warn":ae.tmux?"on":"",Me=!!ae.tmux;return l.jsx("button",{type:"button",className:`nc-mini-dot${Dt.has(ae.tmuxSession)?" active":""}`,onMouseEnter:De=>Ue(De,`${ae.cell}: ${V.subtitle}`),onMouseLeave:Oe,draggable:Me,onDragStart:Me?De=>De.dataTransfer.setData("text/nc-session",ae.tmuxSession):void 0,onClick:Me?()=>a&&a(ae.tmuxSession):()=>u&&u(ae),onDoubleClick:Me?()=>ke(ae.tmuxSession,"",E):void 0,children:l.jsx("span",{className:`nc-dot ${ye}${V.working?" working":""}`})},V.key)})():(()=>{const ae=V.value;return l.jsx("button",{type:"button",className:`nc-mini-init${Dt.has(ae.name)?" active":""}`,onMouseEnter:ye=>Ue(ye,ae.name),onMouseLeave:Oe,draggable:!0,onDragStart:ye=>ye.dataTransfer.setData("text/nc-session",ae.name),onClick:()=>a&&a(ae.name),onDoubleClick:()=>ke(ae.name,"",E),children:Id(ae.name)},V.key)})()),ie.flatMap(({g:V,nodeRoute:ae,groupView:ye,items:Me})=>V.kind==="vl"?V.status==="up"&&V.sessions.length?V.sessions.map(De=>l.jsx("button",{type:"button",className:"nc-mini-init",onMouseEnter:Ee=>Ue(Ee,`${V.label||ae}: ${De.name}`),onMouseLeave:Oe,onClick:()=>Q&&Q(V.peer),children:Id(De.name)},De.key)):[l.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:De=>Ue(De,`${V.label||V.name}: ${V.status==="up"?f("no-sessions-short"):fs(V)}`),onMouseLeave:Oe,children:l.jsx("span",{className:`nc-dot${V.status==="up"?" on":" warn"}`})},`nodo-vl-${ae}-${V.name}`)]:V.status==="up"?ye.open?Me.map(De=>De.type==="cell"?(()=>{const Ee=De.value,Xe=!!Ee.tmux;return l.jsx("button",{type:"button",className:`nc-mini-dot${Dt.has(De.key)?" active":""}`,onMouseEnter:yt=>Ue(yt,`${V.label||ae}: ${Ee.cell} · ${De.subtitle}`),onMouseLeave:Oe,draggable:Xe,onDragStart:Xe?yt=>yt.dataTransfer.setData("text/nc-session",De.key):void 0,onClick:Xe?()=>a&&a(De.key):()=>u&&u({...Ee,route:V.route,availableEngines:V.engines||[]}),onDoubleClick:Xe?()=>ke(Ee.tmuxSession,ae,V.instanceId):void 0,children:l.jsx("span",{className:`nc-dot ${Ee.degraded?"warn":Xe?`on${De.working?" working":""}`:""}`})},De.key)})():(()=>{const Ee=De.value;return l.jsx("button",{type:"button",className:`nc-mini-init${Dt.has(De.key)?" active":""}`,onMouseEnter:Xe=>Ue(Xe,`${V.label||ae}: ${Ee.name}`),onMouseLeave:Oe,draggable:!0,onDragStart:Xe=>Xe.dataTransfer.setData("text/nc-session",De.key),onClick:()=>a&&a(De.key),onDoubleClick:()=>ke(Ee.name,ae,V.instanceId),children:Id(Ee.name)},De.key)})()):[]:[l.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:De=>Ue(De,`${V.label||(V.route||[V.name]).join(" › ")}: ${fs(V)}`),onMouseLeave:Oe,children:l.jsx("span",{className:`nc-dot${V.status==="passive"?"":" warn"}`})},`nodo-${(V.route||[V.name]).join("/")}`)])]})}),J&&l.jsx("div",{className:"nc-mini-tip",style:{top:J.y},children:J.text})]}):l.jsxs("aside",{className:"nc-sidebar",style:kt,children:[l.jsxs("div",{className:"nc-side-head",children:[l.jsx("button",{className:"nc-collapse-btn",onClick:F,title:f("collapse"),children:"⟨"}),l.jsx("span",{className:"nc-side-title",children:f("fleet")}),N&&l.jsx("span",{className:"nc-side-fleet-stale",role:"status",title:f("fleet-stale"),"aria-label":f("fleet-stale"),children:"●"}),C!==null&&l.jsx("span",{className:"nc-side-fleet-off",role:"status",title:`${f("fleet-off")}${C?` (${C})`:""}`,"aria-label":`${f("fleet-off")}${C?` (${C})`:""}`,children:"○"}),l.jsxs("button",{className:"nc-new-btn",onClick:y,title:f("fleet-new-cell"),children:["+ ",f("new")]})]}),l.jsxs("button",{className:"nc-side-gear",onClick:()=>S&&S("nodes",!1),title:f("settings"),children:[l.jsx(lt,{name:"gear",size:15})," ",f("settings")]}),l.jsx(hb,{pinError:B,onRetry:U,onDismiss:se}),l.jsxs("div",{className:"nc-side-scroll",children:[l.jsx(S2,{label:f("position-local"),count:ct.length,state:ee("local"),onToggle:()=>de("local",{open:!ee("local").open}),onFilter:V=>de("local",{filter:V})}),ee("local").open&&l.jsxs("div",{className:"nc-side-group",children:[ct.map(V=>V.type==="cell"?(()=>{const ae=V.value,ye=Ct([]),Me=wh({hostCell:ye.hostCell??null,pins:j,item:V}),De=ae.degraded?"warn":ae.tmux?"on":"",Ee=Sh(Me,ye.hostLease??null),Xe=ae.degraded?f("cell-degraded"):V.working?V.subtitle:ae.tmux?f("cell-idle"):f("cell-off"),yt=Ee?`${Xe} · ${f(Ee)}`:Xe,$t=!!ae.tmux;return l.jsxs("div",{"data-roster-key":V.key,"data-position":"local",className:`nc-cell${$t?" live":""}${Dt.has(ae.tmuxSession)?" active":""}`,title:`${ae.cell} · ${V.subtitle}${yt===V.subtitle?"":` · ${yt}`}`,"aria-label":`${ae.cell}, ${V.subtitle}${yt===V.subtitle?"":`, ${yt}`}`,draggable:$t,onDragStart:$t?Be=>Be.dataTransfer.setData("text/nc-session",ae.tmuxSession):void 0,onClick:$t?()=>a&&a(ae.tmuxSession):void 0,onDoubleClick:$t?()=>ke(ae.tmuxSession,"",E):void 0,children:[l.jsx(Yi,{position:"local",itemKey:V.key,label:ae.cell,canMove:ve,onMove:(Be,te)=>fe("local",Be,te,Ge),onStep:Be=>pe("local",V.key,Be,Ge)}),$t?l.jsx("button",{type:"button",className:"nc-side-peek",title:f("cell-peek"),"aria-label":`${f("cell-peek")}: ${ae.cell}`,onClick:me(V,ae,[],""),children:l.jsx("span",{className:`nc-dot ${De}${V.working?" working":""}`})}):l.jsx("span",{className:`nc-dot ${De}${V.working?" working":""}`}),l.jsxs("span",{className:"nc-cell-main",children:[l.jsx("b",{title:ae.cell,children:ae.cell}),l.jsx("small",{title:V.subtitle,children:V.subtitle})]}),l.jsx("button",{className:`nc-pin${Me==="live"?" live":Me==="favorite"?" on":""}`,title:Me==="live"?"live host":f("pin"),onClick:Be=>{Be.stopPropagation(),dn(V,ae,Me,[])},children:Me==="none"?"☆":"★"}),d&&w.includes("boot")&&Je(ae),l.jsx("button",{className:`nc-power${ae.tmux?" on":""}${ae.degraded?" warn":""}`,onClick:Be=>{Be.stopPropagation(),u&&u({...ae,boot:_t(ae)})},title:ae.active?f("power-off"):f("power-on"),children:l.jsx(lt,{name:"power",size:14})})]},V.key)})():(()=>{var ye;const ae=V.value;return l.jsxs("div",{"data-roster-key":V.key,"data-position":"local",className:`nc-side-card${Dt.has(ae.name)?" active":""}`,draggable:!0,onDragStart:Me=>Me.dataTransfer.setData("text/nc-session",ae.name),onClick:()=>a&&a(ae.name),onDoubleClick:()=>ke(ae.name,"",E),children:[l.jsx(Yi,{position:"local",itemKey:V.key,label:ae.name,canMove:ve,onMove:(Me,De)=>fe("local",Me,De,Ge),onStep:Me=>pe("local",V.key,Me,Ge)}),l.jsx("span",{className:ae.attached?"nc-dot on":"nc-dot"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:ae.name}),l.jsxs("small",{children:[ae.preview||ae.cmd||f("windows").replace("{n}",String(ae.windows||0)),((ye=ae.outbox)==null?void 0:ye.count)>0?` · 📦${ae.outbox.count}`:""]})]}),ae.activity?l.jsx("span",{className:"nc-rel",children:go(ae.activity)}):null,l.jsx("button",{className:`nc-pin${j.includes(V.key)?" on":""}`,title:f("pin"),onClick:Me=>{Me.stopPropagation(),M(V.key)},children:j.includes(V.key)?"★":"☆"}),l.jsx("button",{className:`nc-technical${ae.technical?" on":""}`,title:ae.technical?f("mark-normal"):f("mark-technical"),"aria-label":`${ae.technical?f("mark-normal"):f("mark-technical")} ${ae.name}`,onClick:Me=>{Me.stopPropagation(),v&&v(ae.name,!ae.technical,[])},children:"T"}),l.jsx("button",{className:"nc-menu",title:f("terminate"),onClick:Me=>{Me.stopPropagation(),window.confirm(f("terminate-confirm").replace("{name}",ae.name))&&m&&m(ae.name)},children:"⋯"})]},V.key)})()),ct.length===0&&l.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]}),ie.map(({g:V,nodeRoute:ae,groupView:ye,rawItems:Me,items:De})=>{const Ee=fb(V.health),Xe=V.fleetState==="stale"?f("fleet-stale"):V.fleetState==="disabled"?f("fleet-off"):"",yt=V.fleetState==="stale"?"warn":Ee||(V.status==="up"?"on":V.status==="passive"?"":"warn"),$t=[V.health?dc(V.health):"",Xe].filter(Boolean).join(" · ");return V.kind==="vl"?l.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":je(V),children:[l.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>de(ae,{open:!ye.open}),onKeyDown:Be=>{(Be.key==="Enter"||Be.key===" ")&&(Be.preventDefault(),de(ae,{open:!ye.open}))},children:[l.jsx(Yi,{scope:"node",position:"nodes",itemKey:je(V),label:V.label||V.name,onMove:(Be,te)=>ut(Be,te,s||[]),onStep:Be=>vt(je(V),Be,s||[])}),l.jsx("span",{className:"nc-node-chevron",children:ye.open?"⌄":"›"}),l.jsx("span",{className:`nc-dot ${yt}`,title:$t}),l.jsx("b",{children:V.label||V.name}),l.jsxs("small",{children:[" · ",V.status==="up"?[f("node-sessions").replace("{n}",String(V.sessions.length)),Xe].filter(Boolean).join(" · "):fs(V)]})]}),V.status==="up"&&ye.open&&l.jsxs("div",{className:"nc-side-group",children:[V.sessions.map(Be=>l.jsxs("div",{className:"nc-side-card nc-vl-session-row",role:"button",tabIndex:0,onClick:()=>Q&&Q(V.peer),onKeyDown:te=>{(te.key==="Enter"||te.key===" ")&&(te.preventDefault(),Q&&Q(V.peer))},children:[l.jsx("span",{className:"nc-dot on"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:Be.name}),l.jsx("small",{children:f("vl-events-title")})]})]},Be.key)),V.sessions.length===0&&l.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]})]},`nodo-vl-${ae}-${V.name}`):l.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":je(V),children:[l.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:V.direct&&b?Be=>{Be.preventDefault(),it(V)}:void 0,onClick:()=>de(ae,{open:!ye.open}),onKeyDown:Be=>{(Be.key==="Enter"||Be.key===" ")&&(Be.preventDefault(),de(ae,{open:!ye.open}))},children:[l.jsx(Yi,{scope:"node",position:"nodes",itemKey:je(V),label:V.label||V.name,onMove:(Be,te)=>ut(Be,te,s||[]),onStep:Be=>vt(je(V),Be,s||[])}),l.jsx("span",{className:"nc-node-chevron",children:ye.open?"⌄":"›"}),l.jsx("span",{className:`nc-dot ${yt}`,title:$t}),l.jsx("b",{children:V.label||V.name}),l.jsxs("small",{children:[" · ",V.status==="up"?[f("node-sessions").replace("{n}",String(De.length)),Xe].filter(Boolean).join(" · "):V.health&&dc(V.health)||fs(V)]}),l.jsxs("select",{className:"nc-node-filter",value:ye.filter,title:f(`view-${ye.filter}`),onClick:Be=>Be.stopPropagation(),onChange:Be=>de(ae,{filter:Be.target.value}),children:[l.jsx("option",{value:"all",children:f("view-all")}),l.jsx("option",{value:"pinned",children:f("view-pinned")}),l.jsx("option",{value:"active",children:f("view-active")}),l.jsx("option",{value:"off",children:f("view-off")}),l.jsx("option",{value:"technical",children:f("view-technical")})]}),V.direct&&b&&l.jsx("button",{type:"button",className:"nc-node-rename",title:f("rename-node"),"aria-label":`${f("rename-node")} ${V.label||V.name}`,onClick:Be=>{Be.stopPropagation(),it(V)},children:"✎"}),V.direct&&V.health&&V.health.managed!==!1&&l.jsx("button",{type:"button",className:`nc-power${V.tunnelStatus==="up"?" on":""}`,title:V.tunnelStatus==="up"?f("power-off"):f("power-on"),onClick:Be=>{Be.stopPropagation(),p&&p(V)},children:l.jsx(lt,{name:"power",size:14})})]}),(V.status==="up"||V.cellsPreserved)&&ye.open&&l.jsxs("div",{className:"nc-side-group",children:[De.map(Be=>Be.type==="cell"?(()=>{const te=Be.value,Se=V.route||[V.name],Te=Ct(Se),tt=wh({hostCell:Te.hostCell??null,pins:j,item:Be}),nt=Sh(tt,Te.hostLease??null),St=!!te.tmux&&!V.cellsPreserved,It=te.degraded?"warn":te.tmux&&!V.cellsPreserved?"on":"",Sn=V.cellsPreserved?`${f("fleet-stale")}`:Be.working?Be.subtitle:te.tmux?f("cell-idle"):f("cell-off"),ri=nt?`${Sn} · ${f(nt)}`:Sn;return l.jsxs("div",{"data-roster-key":Be.key,"data-position":ae,className:`nc-side-card nc-cell${St?" live":""}${V.cellsPreserved?" preserved":""}${Dt.has(te.key)?" active":""}`,title:ri,draggable:St,onDragStart:St?An=>An.dataTransfer.setData("text/nc-session",te.key):void 0,onClick:St?()=>a&&a(te.key):void 0,onDoubleClick:St?()=>ke(te.tmuxSession,ae,V.instanceId):void 0,children:[l.jsx(Yi,{position:ae,itemKey:Be.key,label:te.cell,canMove:ve,onMove:(An,Mt)=>fe(ae,An,Mt,Me),onStep:An=>pe(ae,Be.key,An,Me)}),St?l.jsx("button",{type:"button",className:"nc-side-peek",title:f("cell-peek"),"aria-label":`${f("cell-peek")}: ${te.cell}`,onClick:me(Be,te,V.route||[V.name],V.label||V.name),children:l.jsx("span",{className:`nc-dot ${It}${Be.working?" working":""}`})}):l.jsx("span",{className:`nc-dot ${It}${Be.working?" working":""}`}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:te.cell}),l.jsx("small",{title:Be.subtitle,children:Be.subtitle})]}),l.jsx("button",{className:`nc-pin${tt==="live"?" live":tt==="favorite"?" on":""}`,title:tt==="live"?"live host":f("pin"),onClick:An=>{An.stopPropagation(),dn(Be,te,tt,Se)},children:tt==="none"?"☆":"★"}),d&&(V.capabilities||[]).includes("boot")&&Je(te,V.route||[]),(V.capabilities||[]).includes(te.active?"down":"up")&&l.jsx("button",{className:`nc-power${te.active?" on":""}${te.degraded?" warn":""}`,onClick:An=>{An.stopPropagation(),u&&u({...te,boot:_t(te,V.route||[]),route:V.route,availableEngines:V.engines||[]})},title:te.active?f("power-off"):f("power-on"),children:l.jsx(lt,{name:"power",size:14})})]},Be.key)})():(()=>{const te=Be.value;return l.jsxs("div",{"data-roster-key":Be.key,"data-position":ae,className:`nc-side-card${Dt.has(te.key)?" active":""}`,draggable:!0,onDragStart:Se=>Se.dataTransfer.setData("text/nc-session",te.key),onClick:()=>a&&a(te.key),onDoubleClick:()=>ke(te.name,te.node||ae,V.instanceId),children:[l.jsx(Yi,{position:ae,itemKey:Be.key,label:te.name,canMove:ve,onMove:(Se,Te)=>fe(ae,Se,Te,Me),onStep:Se=>pe(ae,Be.key,Se,Me)}),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.jsx("small",{children:te.preview?te.preview:te.cmd?te.cmd:f("windows").replace("{n}",String(te.windows||0))})]}),te.activity?l.jsx("span",{className:"nc-rel",children:go(te.activity)}):null,l.jsx("button",{className:`nc-pin${j.includes(Be.key)?" on":""}`,title:f("pin"),onClick:Se=>{Se.stopPropagation(),M(Be.key)},children:j.includes(Be.key)?"★":"☆"}),l.jsx("button",{className:`nc-technical${te.technical?" on":""}`,title:te.technical?f("mark-normal"):f("mark-technical"),"aria-label":`${te.technical?f("mark-normal"):f("mark-technical")} ${te.name}`,onClick:Se=>{Se.stopPropagation(),v&&v(te.name,!te.technical,V.route||[])},children:"T"}),l.jsx("button",{className:"nc-menu",title:f("terminate"),onClick:Se=>{Se.stopPropagation(),window.confirm(f("terminate-confirm").replace("{name}",te.name))&&m&&m(te.name,V.route)},children:"⋯"})]},Be.key)})()),De.length===0&&l.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]})]},`nodo-${(V.route||[V.name]).join("/")}`)})]}),l.jsx("div",{className:"nc-side-lang",children:eb.map((V,ae)=>l.jsxs("span",{children:[ae>0&&" · ",l.jsx("button",{className:`nc-lang-btn${A===V?" on":""}`,onClick:()=>T(V),title:V,children:V.toUpperCase()})]},V))}),l.jsx("div",{className:"nc-side-resize",onPointerDown:Et,title:""}),be&&(()=>{const V=be.value,ae=be.nodeRoute?s.find(Me=>(Me.route||[Me.name]).join("/")===be.nodeRoute)||{}:null,ye=be.nodeRoute?ae.route||[be.nodeRoute]:[];return l.jsx(Cw,{row:Qe(be,V,ye,be.nodeLabel||"",ae&&ae.sessions),token:W,initialSource:hn,onClose:()=>{jt(null),re("preview")}})})()]})}function S2({label:e,count:t,state:n,onToggle:s,onFilter:o}){return l.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:s,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),s())},children:[l.jsx("span",{className:"nc-node-chevron",children:n.open?"⌄":"›"}),l.jsx("span",{className:"nc-dot on"}),l.jsx("b",{children:e}),l.jsxs("small",{children:[" · ",f("node-sessions").replace("{n}",String(t))]}),l.jsxs("select",{className:"nc-node-filter",value:n.filter,title:f(`view-${n.filter}`),onClick:a=>a.stopPropagation(),onChange:a=>o(a.target.value),children:[l.jsx("option",{value:"all",children:f("view-all")}),l.jsx("option",{value:"pinned",children:f("view-pinned")}),l.jsx("option",{value:"active",children:f("view-active")}),l.jsx("option",{value:"off",children:f("view-off")}),l.jsx("option",{value:"technical",children:f("view-technical")})]})]})}function x2(e,t,n){return!e&&t?n+1:n}const lp="nc_input_preferences_v1",Od="nc-input-preferences",Ew=Object.freeze(["double-tap","single-tap","never"]),Nw=Object.freeze(["full","compact"]),Ws=Object.freeze({terminalKeyboardGesture:"double-tap",keybarKeepsKeyboardClosed:!0,voiceKeepsKeyboardClosed:!0,showKeybarEnter:!0,keybarLayout:"full"});function cp(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return{terminalKeyboardGesture:Ew.includes(t.terminalKeyboardGesture)?t.terminalKeyboardGesture:Ws.terminalKeyboardGesture,keybarKeepsKeyboardClosed:typeof t.keybarKeepsKeyboardClosed=="boolean"?t.keybarKeepsKeyboardClosed:Ws.keybarKeepsKeyboardClosed,voiceKeepsKeyboardClosed:typeof t.voiceKeepsKeyboardClosed=="boolean"?t.voiceKeepsKeyboardClosed:Ws.voiceKeepsKeyboardClosed,showKeybarEnter:typeof t.showKeybarEnter=="boolean"?t.showKeybarEnter:Ws.showKeybarEnter,keybarLayout:Nw.includes(t.keybarLayout)?t.keybarLayout:Ws.keybarLayout}}function jw(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function L_(e=jw()){if(!e)return{...Ws};try{return cp(JSON.parse(e.getItem(lp)||"null"))}catch{return{...Ws}}}function k2(e,t=jw()){const n=cp(e);if(t)try{t.setItem(lp,JSON.stringify(n))}catch{}return n}function up(){const[e,t]=k.useState(L_);k.useEffect(()=>{const s=o=>{if((o==null?void 0:o.type)==="storage"&&o.key!==lp&&o.key!==null)return;const a=o!=null&&o.detail?cp(o.detail):L_();t(a)};return window.addEventListener(Od,s),window.addEventListener("storage",s),()=>{window.removeEventListener(Od,s),window.removeEventListener("storage",s)}},[]);const n=k.useCallback(s=>{t(o=>{const a=k2({...o,...s||{}});return window.dispatchEvent(new CustomEvent(Od,{detail:a})),a})},[]);return[e,n]}function C2({session:e,node:t,ownerId:n,cellName:s,token:o,readonly:a=!1,focused:u,onFocus:d,onClose:p,onOpenSingle:m,alive:v=!0,available:y=!0,fontSize:b=Pa,onZoom:S,decks:x=[],currentDeck:E,onSendToDeck:w,panelUrl:N="",panelCellId:C="",panelPort:L=0}){const[I]=up(),G=s||e,K=k.useRef(()=>{}),Y=k.useRef(()=>!1),Q=k.useRef(()=>{}),W=k.useRef(!1),[X,H]=k.useState(!1),[$,R]=k.useState(!1),[O,F]=k.useState(!1),[A,T]=k.useState(!1),[j,z]=k.useState(null),[M,D]=k.useState(0),B=k.useRef(v),U=t?`${t}:${e}`:e,se=x.filter(ee=>ee.id!==E&&ee.available!==!1);return k.useEffect(()=>{const ee=B.current;!ee&&v&&D(de=>x2(ee,v,de)),B.current=v},[v]),l.jsxs("div",{className:`nc-tile${u?" focused":""}`,onMouseDown:()=>d&&d(U),children:[l.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:ee=>{ee.dataTransfer.setData("text/nc-session",U),ee.dataTransfer.effectAllowed="move"},children:[l.jsxs("button",{className:"nc-tile-name",onClick:()=>d&&d(U),title:t?`${G} · ${t}`:G,children:[l.jsx("span",{className:v?"nc-dot on":"nc-dot"}),l.jsx("b",{children:G})]}),l.jsxs("span",{className:"nc-tile-actions",children:[S&&l.jsx("button",{onClick:()=>S(-1),title:f("zoom-out"),children:l.jsx(lt,{name:"zoomOut",size:14})}),S&&l.jsx("button",{onClick:()=>S(1),title:f("zoom-in"),children:l.jsx(lt,{name:"zoomIn",size:14})}),w&&se.length>0&&l.jsxs("select",{className:"nc-tile-deck",title:f("send-to-deck"),value:"",onMouseDown:ee=>ee.stopPropagation(),onChange:ee=>{const de=ee.target.value;de&&w(U,de),ee.target.value=""},children:[l.jsx("option",{value:"",children:f("send-to-deck")}),se.map(ee=>l.jsxs("option",{value:ee.id,children:[ee.ownerLabel," · ",ee.name]},ee.id))]}),l.jsx("button",{onClick:()=>R(ee=>!ee),title:f("composer"),children:"⌨"}),l.jsx("button",{onClick:()=>F(ee=>!ee),title:f("files"),children:"📁"}),N&&l.jsx("button",{onClick:()=>T(ee=>!ee),title:f("panel"),"aria-pressed":A,children:l.jsx(lt,{name:"monitor",size:14})}),m&&l.jsx("button",{onClick:()=>m({session:e,node:t,ownerId:n}),title:f("single-view"),children:"↗"}),p&&l.jsx("button",{className:"nc-tile-close",onClick:()=>p(U),title:f("close"),children:"✕"})]})]}),l.jsxs("div",{className:"nc-tile-body",children:[y?l.jsx(sp,{session:e,node:t,token:o,readonly:a,takeSize:!1,focused:u,sendRef:K,composerRef:Y,actionRef:Q,ctrlRef:W,setCtrlArmed:H,onFiles:z,fontSize:b,keyboardGesture:I.terminalKeyboardGesture},`${U}:${M}`):l.jsx("div",{className:"nc-tile-unavailable",children:f("deck-owner-unavailable")}),y&&O&&l.jsx("div",{className:"nc-tile-files",onMouseDown:ee=>ee.stopPropagation(),children:l.jsx(fw,{session:e,node:t,token:o,filesEvent:j,onClose:()=>F(!1)})})]}),y&&$&&l.jsx("div",{className:"nc-tile-composer",onMouseDown:ee=>ee.stopPropagation(),children:l.jsx(Sw,{submitText:ee=>Y.current(ee),token:o,session:e,node:t,ownerId:n,readonly:a,keepKeyboardClosedOnVoice:I.voiceKeepsKeyboardClosed})}),y&&A&&N&&C&&l.jsx(kw,{title:G,onClose:()=>T(!1),children:l.jsx(ap,{cellId:C,panelUrl:N,route:t?t.split("/"):[],panelPort:L,token:o,title:G})})]})}function Rw({session:e,node:t,ownerId:n,cells:s,nodeGroups:o}={}){const a=typeof e=="string"?e:"";if(!a)return null;if(t){const d=Array.isArray(o)?o:[];for(const p of d){if(!p||(Array.isArray(p.route)?p.route:[]).join("/")!==t||n&&p.instanceId&&String(n)!==String(p.instanceId))continue;const v=(Array.isArray(p.cells)?p.cells:[]).find(y=>y&&y.tmuxSession===a);if(v)return v}return null}return(Array.isArray(s)?s:[]).find(d=>d&&d.tmuxSession===a)||null}function dp({session:e,cell:t,node:n,ownerId:s,cells:o,nodeGroups:a}={}){const u=typeof e=="string"?e:"";if(t&&typeof t.cell=="string"&&t.cell)return t.cell;const d=Rw({session:u,node:n,ownerId:s,cells:o,nodeGroups:a});return d&&d.cell?d.cell:u}function kc(e,t,n){const s=u=>Number.isInteger(u)&&u>0&&u<65536?u:0;if(e==null)return s(n);if(!Array.isArray(e))return 0;if(e.length===0)return s(n);const o=typeof e[0]=="string"?e[0]:null;return o?s((t&&typeof t=="object"?t:{})[o]):0}const A_=.2,M_=.28,Pw=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),Bd=e=>Pw(e,"text/nc-session"),T_=e=>{var t;return Pw(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function E2(e,t,n){const s=(e-n.left)/(n.width||1),o=(t-n.top)/(n.height||1);return s<M_?"left":s>1-M_?"right":o<.5?"top":"bottom"}function N2({layout:e,onLayoutChange:t,token:n,readonly:s=!1,sessionsAlive:o,focusSession:a,onFocus:u,onOpenSingle:d,decks:p=[],currentDeck:m,onSendToDeck:v,cells:y=[],nodeGroups:b=[],panelPort:S=0,nodePanelPorts:x={}}){Yn();const[E,w]=k.useState(null),N=k.useRef(null),C=k.useRef([]),L=k.useRef(null);function I(R,O){const F=()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",F),window.removeEventListener("pointercancel",F),window.removeEventListener("blur",F),L.current=null};window.addEventListener("pointermove",R),window.addEventListener("pointerup",F),window.addEventListener("pointercancel",F),window.addEventListener("blur",F),L.current=F}k.useEffect(()=>()=>{L.current&&L.current()},[]),k.useEffect(()=>{const R=()=>w(null);return window.addEventListener("dragend",R),window.addEventListener("drop",R),()=>{window.removeEventListener("dragend",R),window.removeEventListener("drop",R)}},[]);const G=e.columns.length,K=R=>E&&E.col===R&&E.row===void 0,Y=!!E&&E.col===G,Q=(R,O)=>E&&E.col===R&&E.row===O&&E.quadrant?` drop-${E.quadrant}`:"";function W(R){if(R.preventDefault(),T_(R.dataTransfer)){w(null);return}const O=R.dataTransfer.getData("text/nc-session"),F=E;if(w(null),!O||!F)return;let A;if(F.quadrant){if(A=Ik(e,F.col,F.row,F.quadrant),!A)return}else A={col:F.col};t(Qi(e).includes(O)?Lk(e,O,A):qf(e,O,A))}function X(R,O){R.preventDefault(),R.stopPropagation();const F=R.clientX,A=e.columns[O].width,T=N.current&&N.current.clientWidth||1,j=e.columns[O+1];I(M=>{let D=Math.max(A_,A+(M.clientX-F)/T);if(j){const B=yv(D/(D+j.width));D=B/(1-B)*j.width}t(Mk(e,O,D))})}function H(R,O,F){R.preventDefault(),R.stopPropagation();const A=R.clientY,T=e.columns[O].tiles[F].height,j=C.current[O],z=j&&j.clientHeight||1,M=e.columns[O].tiles[F+1];I(B=>{let U=Math.max(A_,T+(B.clientY-A)/z);if(M){const se=yv(U/(U+M.height));U=se/(1-se)*M.height}t(Tk(e,O,F,U))})}function $(R){t(mc(e,R))}return l.jsxs("div",{className:"nc-grid",ref:N,onDragOver:R=>{if(T_(R.dataTransfer)){R.preventDefault(),w(null);return}Bd(R.dataTransfer)&&(R.preventDefault(),E&&E.col===G||w({col:G}))},onDrop:W,onDragLeave:R=>{const O=R.relatedTarget;(!O||!(N.current&&N.current.contains(O)))&&w(null)},children:[e.columns.flatMap((R,O)=>{const F=[];return F.push(l.jsx("div",{className:`nc-col${K(O)?" drop-newcol":""}`,ref:A=>{C.current[O]=A},style:{flexGrow:R.width,flexBasis:0},onDragOver:A=>{Bd(A.dataTransfer)&&(A.preventDefault(),A.stopPropagation(),E&&E.col===O&&E.row===void 0||w({col:O}))},children:R.tiles.flatMap((A,T)=>{const j=[],z=mi(A),M=Rw({session:A.session,node:A.node,ownerId:A.ownerId,cells:y,nodeGroups:b}),D=dp({session:A.session,cell:M,node:A.node,ownerId:A.ownerId,cells:y,nodeGroups:b}),B=typeof(M==null?void 0:M.panelUrl)=="string"?M.panelUrl.trim():"",U=typeof(M==null?void 0:M.cell)=="string"?M.cell:"";return j.push(l.jsx("div",{className:`nc-tile-slot${Q(O,T)}`,style:{flexGrow:A.height,flexBasis:0},onDragOver:se=>{if(!Bd(se.dataTransfer))return;se.preventDefault(),se.stopPropagation();const ee=E2(se.clientX,se.clientY,se.currentTarget.getBoundingClientRect());E&&E.col===O&&E.row===T&&E.quadrant===ee||w({col:O,row:T,quadrant:ee})},children:l.jsx(C2,{session:A.session,node:A.node,ownerId:A.ownerId,cellName:D,token:n,readonly:s,focused:a===z,onFocus:u,onClose:$,onOpenSingle:d,available:A.unavailable!==!0,alive:A.unavailable!==!0&&(!o||o.has(z)),fontSize:A.fontSize,onZoom:se=>t(Dk(e,O,T,se)),decks:p,currentDeck:m,onSendToDeck:v,panelUrl:B,panelCellId:U,panelPort:kc(A.node?A.node.split("/"):[],x,S)})},z)),T<R.tiles.length-1&&j.push(l.jsx("div",{className:"nc-divider-h",onPointerDown:se=>H(se,O,T)},`h${T}`)),j})},`c${O}`)),O<G-1&&F.push(l.jsx("div",{className:"nc-divider-v",onPointerDown:A=>X(A,O)},`v${O}`)),F}),Y&&l.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),G===0&&l.jsx("div",{className:"nc-grid-empty",children:f("grid-empty")})]})}const Gi="local",gi=/^[a-f0-9]{16,64}$/;function po(e,t){return`${e&&gi.test(e)?e:Gi}:${t}`}function Mc(e){const t=String(e||""),n=t.indexOf(":");if(n<1)return null;const s=t.slice(0,n),o=t.slice(n+1);return s!==Gi&&!gi.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===Gi?null:s,name:o}}function Tc(e){return Array.isArray(e)&&e.length?e.join("/"):""}function hp(e){return{columns:xr(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))}}function j2(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&gi.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(Tc(n.route),n.instanceId);return t}function R2(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&gi.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(n.instanceId,[...n.route]);return t}function yf(e,t,n=[]){const s=hp(e),o=j2(n);for(const a of s.columns)for(const u of a.tiles)u.ownerId||(!u.node&&gi.test(String(t||""))?u.ownerId=t:u.node&&o.has(u.node)&&(u.ownerId=o.get(u.node)));return s}function bf(e,t,n=[]){const s=hp(e),o=new Map;for(const a of n)a&&gi.test(String(a.instanceId||""))&&Array.isArray(a.route)&&o.set(a.instanceId,[...a.route]);for(const a of s.columns)for(const u of a.tiles)u.ownerId&&(u.ownerId===t?(delete u.node,delete u.unavailable):o.has(u.ownerId)?(u.node=Tc(o.get(u.ownerId)),delete u.unavailable):u.unavailable=!0);return s}function D_(e,t,n=[]){const s=hp(e),o=R2(n);for(const a of s.columns)for(const u of a.tiles)delete u.unavailable,u.ownerId&&(u.ownerId===t?delete u.node:o.has(u.ownerId)&&(u.node=Tc(o.get(u.ownerId))));return s}function Lw(e,t,n=[]){const s=Gs(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...gi.test(String(t||""))?{ownerId:t}:{}};const o=n.find(a=>Tc(a&&a.route)===s.node);return{...s,...o&&gi.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const P2=/^[a-z0-9-]{1,32}$/,vi="main",Aw="nc_decks",Mw="nc_deck_order_v1",Tw=24;function I_(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function bo(e){return typeof e=="string"&&P2.test(e)}function L2(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let n;try{n=decodeURIComponent(t[1])}catch{n=t[1]}return bo(n)?n:vi}return vi}function A2(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:po(null,vi),ownerId:null,name:vi}}if(gi.test(s)&&bo(o))return{id:po(s,o),ownerId:s,name:o}}const n=L2(e);return{id:po(null,n),ownerId:null,name:n}}function zd(e,t){const n=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:Mc(e)||{ownerId:null,name:e},s=bo(n.name)?n.name:vi,o=n.ownerId?`/deck/${encodeURIComponent(n.ownerId)}/${encodeURIComponent(s)}`:s===vi?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function Dw(e){return e===vi?"nc_grid_v1":`nc_grid_v1__${e}`}function Iw(e){const t=[vi];if(Array.isArray(e)){for(const n of e)if(bo(n)&&n!==vi&&!t.includes(n)&&t.push(n),t.length>=Tw)break}return t}function Co(){return typeof localStorage<"u"?localStorage:null}function M2(){const e=Co();if(!e)return[vi];try{return Iw(JSON.parse(e.getItem(Aw)||"null"))}catch{return[vi]}}function T2(e){const t=Co();if(t)try{t.setItem(Aw,JSON.stringify(Iw(e)))}catch{}}function Ia(e){return e==="local"||gi.test(String(e||""))}function Dc(e,t){const n=Mc(e);return!!n&&(n.ownerId||"local")===t}function Zi(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,s]of Object.entries(e).slice(0,64)){if(!Ia(n)||!Array.isArray(s))continue;const o=[...new Set(s.filter(a=>typeof a=="string"&&a.length<=100&&Dc(a,n)))].slice(0,Tw);o.length&&(t[n]=o)}return t}function Gl(e=Co()){if(!e)return{};try{return Zi(JSON.parse(e.getItem(Mw)||"null"))}catch{return{}}}function $d(e,t=Co()){const n=Zi(e);if(t)try{t.setItem(Mw,JSON.stringify(n))}catch{}return n}function Ic(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function D2(e,t,n,s,o=[]){if(!Ia(t)||n===s)return Zi(e);const a=[...new Set(o.filter(y=>Dc(y,t)))];if(!a.includes(n)||!a.includes(s))return Zi(e);const u=Ic(e,t).filter(y=>a.includes(y)),d=[...u,...a.filter(y=>!u.includes(y))],p=d.indexOf(n),m=d.indexOf(s);d.splice(p,1);const v=d.indexOf(s);return d.splice(p<m?v+1:v,0,n),Zi({...e,[t]:d})}function I2(e,t,n,s){if(!Ia(t)||!Dc(s,t))return Zi(e);const o=Ic(e,t);return o.includes(n)?Zi({...e,[t]:o.map(a=>a===n?s:a)}):Zi(e)}function O2(e,t,n){return Ia(t)?Zi({...e,[t]:Ic(e,t).filter(s=>s!==n)}):Zi(e)}function O_(e,t={}){const n=new Map;for(const o of Array.isArray(e)?e:[]){const a=o!=null&&o.local?"local":String((o==null?void 0:o.ownerId)||"");!Ia(a)||!Dc(o==null?void 0:o.id,a)||(n.has(a)||n.set(a,[]),n.get(a).push(o))}const s=[];for(const[,o]of n){const a=o[0].local?"local":o[0].ownerId,u=Ic(t,a),d=new Map(u.map((p,m)=>[p,m]));o.sort((p,m)=>{const v=d.has(p.id)?d.get(p.id):Number.MAX_SAFE_INTEGER,y=d.has(m.id)?d.get(m.id):Number.MAX_SAFE_INTEGER;return v-y}),s.push(...o)}return s}function wf(e){const t=Co();if(!t)return null;try{return JSON.parse(t.getItem(Dw(e))||"null")}catch{return null}}function B2(e,t){const n=Co();if(n)try{n.setItem(Dw(e),JSON.stringify(t))}catch{}}const fp="nc_deckbar_collapsed_v1",Ow=64;function pp(e){return e===Gi||gi.test(String(e||""))}function mp(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};let n=0;for(const[s,o]of Object.entries(e)){if(n>=Ow)break;if(pp(s)){if(o===!0)t[s]=!0;else if(o===!1)t[s]=!1;else continue;n+=1}}return t}function Bw(e,t){return pp(t)&&Object.prototype.hasOwnProperty.call(e||{},t)?e[t]===!0:!0}function z2(e,t){const n=mp(e);return pp(t)&&(!Object.prototype.hasOwnProperty.call(n,t)&&Object.keys(n).length>=Ow&&delete n[Object.keys(n)[0]],n[t]=!Bw(n,t)),n}function zw(){return typeof localStorage<"u"?localStorage:null}function B_(e=zw()){if(!e)return{};try{return mp(JSON.parse(e.getItem(fp)||"null"))}catch{return{}}}function $2(e,t=zw()){const n=mp(e);if(t)try{t.setItem(fp,JSON.stringify(n))}catch{}return n}function F2(){const[e,t]=k.useState(B_);k.useEffect(()=>{const o=a=>{(a.key===fp||a.key===null)&&t(B_())};return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]);const n=k.useCallback(o=>Bw(e,o),[e]),s=k.useCallback(o=>{t(a=>$2(z2(a,o)))},[]);return{collapsed:e,isCollapsed:n,toggle:s}}const gp="nc_deck_presence_v1",z_=3e4,H2=18e4,$w=1e4,Fw=32,U2=/^[A-Za-z0-9_-]{1,64}$/,W2=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),$_="working",K2="on",q2="neutral",V2="warn";function vp(e){return typeof e=="string"&&U2.test(e)&&!W2.has(e)}function Hw(e){return typeof e=="string"&&Mc(e)!==null}function _p(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function wo(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};let n=0;for(const[s,o]of Object.entries(e)){if(n>=Fw)break;vp(s)&&(!o||typeof o!="object"||Hw(o.deckId)&&_p(o.ts)&&(t[s]={deckId:o.deckId,ts:o.ts,focus:o.focus===!0,visible:o.visible===!0},n+=1))}return t}function Uw(e,t){const n=wo(e);if(!_p(t))return n;const s={};for(const[o,a]of Object.entries(n)){const u=a.visible?z_:H2,d=t-u;a.ts>=d&&a.ts<=t+z_&&(s[o]=a)}return s}function F_(e,t,n,s){if(!vp(t)||!_p(s))return wo(e);const o=Uw(e,s);if(!Hw(n==null?void 0:n.deckId))return o;if(!Object.prototype.hasOwnProperty.call(o,t)&&Object.keys(o).length>=Fw){let a="",u=1/0;for(const[d,p]of Object.entries(o))p.ts<u&&(a=d,u=p.ts);a&&delete o[a]}return o[t]={deckId:n.deckId,ts:s,focus:(n==null?void 0:n.focus)===!0,visible:(n==null?void 0:n.visible)===!0},wo(o)}function Y2(e,t){const n=wo(e);if(!vp(t))return n;const s={...n};return delete s[t],s}function G2(e,t){const n=Uw(e,t),s={};for(const o of Object.values(n)){const a=o.focus&&o.visible?$_:K2;s[o.deckId]!==$_&&(s[o.deckId]=a)}return s}function Ww(){return typeof localStorage<"u"?localStorage:null}function Xl(e=Ww()){if(!e)return{};try{return wo(JSON.parse(e.getItem(gp)||"null"))}catch{return{}}}function Fd(e,t=Ww()){const n=wo(e);if(t)try{t.setItem(gp,JSON.stringify(n))}catch{}return n}const X2=Math.min($w,5e3);function Q2(){var e,t;try{const n=(t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e);if(n)return`w${n.replaceAll("-","")}`}catch{}return`w${Date.now().toString(36)}${Math.random().toString(36).slice(2,14)}`}const J2=Q2();function H_(){const e=typeof document<"u"&&typeof document.hasFocus=="function"?document.hasFocus():!0,t=typeof document<"u"&&typeof document.visibilityState=="string"?document.visibilityState!=="hidden":!0;return{focus:e,visible:t}}function Z2(e,t=!0){const s=k.useRef(J2).current,o=k.useRef(e);o.current=e;const[a,u]=k.useState(()=>({map:{},now:Date.now()})),d=k.useCallback(()=>{u({map:Xl(),now:Date.now()})},[]);k.useEffect(()=>{if(!t)return;const v=()=>{const w=Date.now(),N=F_(Xl(),s,{deckId:o.current,...H_()},w);return Fd(N),{map:N,now:w}},y=()=>u(v());y();const b=setInterval(v,$w),S=setInterval(d,X2),x=y,E=w=>{(w.key===gp||w.key===null)&&d()};return window.addEventListener("focus",x),window.addEventListener("blur",x),typeof document<"u"&&document.addEventListener("visibilitychange",x),window.addEventListener("storage",E),()=>{clearInterval(b),clearInterval(S),window.removeEventListener("focus",x),window.removeEventListener("blur",x),typeof document<"u"&&document.removeEventListener("visibilitychange",x),window.removeEventListener("storage",E);try{Fd(Y2(Xl(),s))}catch{}}},[t,s,d]),k.useEffect(()=>{if(!t)return;const v=Date.now(),y=F_(Xl(),s,{deckId:e,...H_()},v);Fd(y),u({map:y,now:v})},[e,t,s]);const p=k.useMemo(()=>t?G2(a.map,a.now):{},[t,a]);return{dotFor:k.useCallback((v,y=!1)=>t?y?V2:p[v]||q2:null,[p,t]),windowId:s}}const U_=52,W_=18;function ej({ownerKey:e,deckId:t,label:n,onMove:s,onStep:o}){const a=k.useRef(null),u=k.useRef(0),[d,p]=k.useState(!1),m=()=>{var E,w,N,C;const x=a.current;(w=(E=x==null?void 0:x.over)==null?void 0:E.classList)==null||w.remove("nc-deck-over"),(C=(N=x==null?void 0:x.source)==null?void 0:N.classList)==null||C.remove("nc-deck-dragging"),u.current&&cancelAnimationFrame(u.current),u.current=0},v=(x=!1)=>{const E=a.current;if(!E)return;const w=E.target;m(),a.current=null,p(!1);try{E.handle.releasePointerCapture(E.pointerId)}catch{}x&&w&&w!==t&&s(t,w)},y=(x,E)=>{var I,G,K,Y,Q,W,X,H;const w=a.current;if(!w)return;w.x=x,w.y=E;const N=(G=(I=document.elementFromPoint(x,E))==null?void 0:I.closest)==null?void 0:G.call(I,"[data-deck-id][data-owner-key]"),C=(K=N==null?void 0:N.dataset)==null?void 0:K.deckId,L=((Y=N==null?void 0:N.dataset)==null?void 0:Y.ownerKey)===e&&C&&C!==t;w.over!==(L?N:null)&&((W=(Q=w.over)==null?void 0:Q.classList)==null||W.remove("nc-deck-over"),w.over=L?N:null,(H=(X=w.over)==null?void 0:X.classList)==null||H.add("nc-deck-over")),w.target=L?C:null},b=()=>{var w,N;const x=a.current;if(!x){u.current=0;return}const E=(N=(w=x.container)==null?void 0:w.getBoundingClientRect)==null?void 0:N.call(w);if(E){const C=x.x<E.left+U_?-W_:x.x>E.right-U_?W_:0;C&&(x.container.scrollLeft+=C,y(x.x,x.y))}u.current=requestAnimationFrame(b)};k.useEffect(()=>{const x=w=>{w.key==="Escape"&&a.current&&(w.preventDefault(),v(!1))},E=()=>v(!1);return window.addEventListener("keydown",x),window.addEventListener("blur",E),()=>{window.removeEventListener("keydown",x),window.removeEventListener("blur",E),m(),a.current=null}},[t,e]);const S=x=>{var N;if(x.pointerType==="mouse"&&x.button!==0)return;x.preventDefault(),x.stopPropagation(),x.currentTarget.focus({preventScroll:!0});const E=x.currentTarget.closest("[data-deck-id][data-owner-key]"),w=x.currentTarget.closest(".nc-deckbar");a.current={pointerId:x.pointerId,handle:x.currentTarget,source:E,container:w,target:null,over:null,x:x.clientX,y:x.clientY},(N=E==null?void 0:E.classList)==null||N.add("nc-deck-dragging");try{x.currentTarget.setPointerCapture(x.pointerId)}catch{}p(!0),u.current=requestAnimationFrame(b)};return l.jsx("button",{type:"button",className:`nc-deck-handle${d?" active":""}`,"aria-label":`${f("reorder")} ${n}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:f("reorder-deck-help"),onClick:x=>{x.preventDefault(),x.stopPropagation()},onDragStart:x=>x.preventDefault(),onKeyDown:x=>{x.key!=="ArrowLeft"&&x.key!=="ArrowRight"||(x.preventDefault(),x.stopPropagation(),o(x.key==="ArrowLeft"?-1:1))},onPointerDown:S,onPointerMove:x=>{!a.current||x.pointerId!==a.current.pointerId||(x.preventDefault(),x.stopPropagation(),y(x.clientX,x.clientY))},onPointerUp:x=>{!a.current||x.pointerId!==a.current.pointerId||(x.preventDefault(),x.stopPropagation(),v(!0))},onPointerCancel:()=>v(!1),onLostPointerCapture:()=>{a.current&&v(!1)},children:"↔"})}function tj({decks:e=[],currentDeck:t="local:main",onCreate:n,onRename:s,onDelete:o,onReorder:a,onOpenWindow:u,onNavigate:d,saveState:p="idle",error:m="",sidebarVisible:v,onToggleSidebar:y}){Yn();const{isCollapsed:b,toggle:S}=F2(),{dotFor:x}=Z2(t),[E,w]=k.useState(null),[N,C]=k.useState(""),[L,I]=k.useState(!1),[G,K]=k.useState(""),[Y,Q]=k.useState(""),W=I_(N),X=bo(W),H=[];for(const A of e){const T=A.local?"local":A.ownerId;let j=H.find(z=>z.key===T);j||(j={key:T,label:A.ownerLabel||(A.local?"Local":T),local:!!A.local,decks:[]},H.push(j)),j.decks.push(A)}const $=async()=>{if(X){I(!0),K("");try{n&&await n(W,E),C(""),w(null)}catch(A){K(String(A.message||A))}I(!1)}},R=A=>{Q(""),u&&u(A.id)||Q(A.id)},O=async A=>{if(!(A.id===t||!d||L||A.available===!1)){I(!0),K("");try{await d(A.id)}catch(T){K(String((T==null?void 0:T.message)||T))}I(!1)}},F=(A,T,j)=>{const z=A.decks.findIndex(D=>D.id===T.id),M=A.decks[z+j];z>=0&&M&&a&&!L&&a(T.id,M.id)};return l.jsxs("div",{className:"nc-deckbar",children:[y&&l.jsx("button",{className:"nc-deck-sidebar-toggle",title:f("toggle-sidebar"),onClick:y,children:v?"◀":"☰"}),l.jsx("span",{className:"nc-deckbar-label",children:f("decks")}),l.jsx("div",{className:"nc-deck-chips",children:H.map(A=>{const T=b(A.key),j=`nc-deck-content-${A.key}`,z=A.local?"Local":A.label,M=A.decks.some(U=>U.id===t),D=(A.decks.find(U=>U.id===t)||{}).name,B=f(A.decks.length===1?"owner-deck-count-one":"owner-deck-count-many").replace("{count}",A.decks.length);return l.jsxs("span",{className:`nc-deck-owner-group${T?" collapsed":""}`,"data-owner-key":A.key,"data-collapsed":T?"1":"0",children:[l.jsxs("button",{type:"button",className:"nc-deck-owner-toggle","aria-expanded":!T,"aria-controls":j,title:f(T?"expand-owner":"collapse-owner").replace("{owner}",z),onClick:()=>{!T&&E===A.key&&(C(""),w(null)),S(A.key)},children:[l.jsx("span",{className:"nc-deck-owner-caret","aria-hidden":"true",children:T?"▸":"▾"}),l.jsx("span",{className:"nc-deck-owner",children:z})]}),T&&l.jsxs("span",{className:"nc-deck-summary",title:B,children:[l.jsx("span",{className:"nc-deck-summary-count",children:A.decks.length}),M&&l.jsxs("span",{className:"nc-deck-summary-current",children:["• ",D]})]}),l.jsxs("span",{id:j,className:"nc-deck-owner-content",hidden:T,children:[A.decks.map(U=>{const se=x(U.id,U.available===!1);return l.jsxs("span",{"data-deck-id":U.id,"data-owner-key":A.key,className:`nc-deck-chip${U.id===t?" current":""}${U.available===!1?" offline":""}`,children:[se&&l.jsx(nj,{state:se}),l.jsx(ej,{ownerKey:A.key,deckId:U.id,label:`${A.label} · ${U.name}`,onMove:(ee,de)=>{a&&!L&&a(ee,de)},onStep:ee=>F(A,U,ee)}),l.jsxs("button",{className:"nc-deck-open",title:U.available===!1?`${U.ownerLabel} offline`:U.id===t?f("deck-current"):`${U.ownerLabel} · ${U.name}`,disabled:L||U.available===!1,onClick:()=>O(U),children:[U.name,U.id===t?" •":""]}),l.jsx("button",{className:"nc-deck-mini",disabled:U.available===!1,title:f("detach-deck"),onClick:()=>R(U),children:"↗"}),U.name!==vi&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"nc-deck-mini",disabled:U.available===!1,title:f("rename-deck"),onClick:()=>{const ee=(typeof window<"u"?window.prompt(f("rename-deck"),U.name):"")||"",de=I_(ee);bo(de)&&de!==U.name&&s&&s(U.id,de).catch(ve=>K(String(ve.message||ve)))},children:"✎"}),l.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:U.available===!1,title:f("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(f("delete-deck-confirm").replace("{name}",`${U.ownerLabel} · ${U.name}`)))&&o&&o(U.id).catch(ee=>K(String(ee.message||ee)))},children:"✕"})]})]},U.id)}),E===A.key?l.jsxs("span",{className:"nc-deck-add",children:[l.jsx("input",{autoFocus:!0,className:X||!N?"":"invalid",placeholder:f("deck-name"),value:N,onChange:U=>C(U.target.value),onKeyDown:U=>{U.key==="Enter"&&$(),U.key==="Escape"&&(C(""),w(null))}}),N&&X&&W!==N&&l.jsxs("span",{className:"nc-deck-slug",children:["→ ",W]}),l.jsx("button",{className:"nc-deck-ok",disabled:!X||L,onClick:$,children:f("create")}),l.jsx("button",{className:"nc-deck-cancel",onClick:()=>{C(""),w(null)},children:f("cancel")})]}):l.jsxs("button",{className:"nc-deck-newbtn",disabled:L||A.decks.every(U=>U.available===!1),title:`${f("new-deck")} · ${A.label}`,onClick:()=>{C(""),w(A.key)},children:["+ ",f("new")]})]})]},A.key)})}),l.jsx("span",{className:`nc-deck-state ${p}`,title:f("deck-autosave"),children:f(p==="saving"?"saving":p==="saved"?"saved":"deck-autosave")}),(G||m)&&l.jsx("span",{className:"nc-deck-error",children:G||m}),Y&&l.jsx("button",{className:"nc-deck-fallback",onClick:()=>u&&u(Y),children:f("popup-blocked")})]})}function nj({state:e}){if(!e)return null;const t=f(`dot-${e}`);return l.jsx("span",{className:`nc-deck-dot ${e}`,role:"img","aria-label":t,title:t})}var co={},Hd,K_;function ij(){return K_||(K_=1,Hd=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Hd}var Ud={},Fs={},q_;function jr(){if(q_)return Fs;q_=1;let e;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Fs.getSymbolSize=function(s){if(!s)throw new Error('"version" cannot be null or undefined');if(s<1||s>40)throw new Error('"version" should be in range from 1 to 40');return s*4+17},Fs.getSymbolTotalCodewords=function(s){return t[s]},Fs.getBCHDigit=function(n){let s=0;for(;n!==0;)s++,n>>>=1;return s},Fs.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},Fs.isKanjiModeEnabled=function(){return typeof e<"u"},Fs.toSJIS=function(s){return e(s)},Fs}var Wd={},V_;function yp(){return V_||(V_=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,o){if(e.isValid(s))return s;try{return t(s)}catch{return o}}})(Wd)),Wd}var Kd,Y_;function sj(){if(Y_)return Kd;Y_=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const n=Math.floor(t/8);return(this.buffer[n]>>>7-t%8&1)===1},put:function(t,n){for(let s=0;s<n;s++)this.putBit((t>>>n-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},Kd=e,Kd}var qd,G_;function rj(){if(G_)return qd;G_=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,n,s,o){const a=t*this.size+n;this.data[a]=s,o&&(this.reservedBit[a]=!0)},e.prototype.get=function(t,n){return this.data[t*this.size+n]},e.prototype.xor=function(t,n,s){this.data[t*this.size+n]^=s},e.prototype.isReserved=function(t,n){return this.reservedBit[t*this.size+n]},qd=e,qd}var Vd={},X_;function oj(){return X_||(X_=1,(function(e){const t=jr().getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const o=Math.floor(s/7)+2,a=t(s),u=a===145?26:Math.ceil((a-13)/(2*o-2))*2,d=[a-7];for(let p=1;p<o-1;p++)d[p]=d[p-1]-u;return d.push(6),d.reverse()},e.getPositions=function(s){const o=[],a=e.getRowColCoords(s),u=a.length;for(let d=0;d<u;d++)for(let p=0;p<u;p++)d===0&&p===0||d===0&&p===u-1||d===u-1&&p===0||o.push([a[d],a[p]]);return o}})(Vd)),Vd}var Yd={},Q_;function aj(){if(Q_)return Yd;Q_=1;const e=jr().getSymbolSize,t=7;return Yd.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},Yd}var Gd={},J_;function lj(){return J_||(J_=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.getPenaltyN1=function(o){const a=o.size;let u=0,d=0,p=0,m=null,v=null;for(let y=0;y<a;y++){d=p=0,m=v=null;for(let b=0;b<a;b++){let S=o.get(y,b);S===m?d++:(d>=5&&(u+=t.N1+(d-5)),m=S,d=1),S=o.get(b,y),S===v?p++:(p>=5&&(u+=t.N1+(p-5)),v=S,p=1)}d>=5&&(u+=t.N1+(d-5)),p>=5&&(u+=t.N1+(p-5))}return u},e.getPenaltyN2=function(o){const a=o.size;let u=0;for(let d=0;d<a-1;d++)for(let p=0;p<a-1;p++){const m=o.get(d,p)+o.get(d,p+1)+o.get(d+1,p)+o.get(d+1,p+1);(m===4||m===0)&&u++}return u*t.N2},e.getPenaltyN3=function(o){const a=o.size;let u=0,d=0,p=0;for(let m=0;m<a;m++){d=p=0;for(let v=0;v<a;v++)d=d<<1&2047|o.get(m,v),v>=10&&(d===1488||d===93)&&u++,p=p<<1&2047|o.get(v,m),v>=10&&(p===1488||p===93)&&u++}return u*t.N3},e.getPenaltyN4=function(o){let a=0;const u=o.data.length;for(let p=0;p<u;p++)a+=o.data[p];return Math.abs(Math.ceil(a*100/u/5)-10)*t.N4};function n(s,o,a){switch(s){case e.Patterns.PATTERN000:return(o+a)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return a%3===0;case e.Patterns.PATTERN011:return(o+a)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(a/3))%2===0;case e.Patterns.PATTERN101:return o*a%2+o*a%3===0;case e.Patterns.PATTERN110:return(o*a%2+o*a%3)%2===0;case e.Patterns.PATTERN111:return(o*a%3+(o+a)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}e.applyMask=function(o,a){const u=a.size;for(let d=0;d<u;d++)for(let p=0;p<u;p++)a.isReserved(p,d)||a.xor(p,d,n(o,p,d))},e.getBestMask=function(o,a){const u=Object.keys(e.Patterns).length;let d=0,p=1/0;for(let m=0;m<u;m++){a(m),e.applyMask(m,o);const v=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(m,o),v<p&&(p=v,d=m)}return d}})(Gd)),Gd}var Ql={},Z_;function Kw(){if(Z_)return Ql;Z_=1;const e=yp(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Ql.getBlocksCount=function(o,a){switch(a){case e.L:return t[(o-1)*4+0];case e.M:return t[(o-1)*4+1];case e.Q:return t[(o-1)*4+2];case e.H:return t[(o-1)*4+3];default:return}},Ql.getTotalCodewordsCount=function(o,a){switch(a){case e.L:return n[(o-1)*4+0];case e.M:return n[(o-1)*4+1];case e.Q:return n[(o-1)*4+2];case e.H:return n[(o-1)*4+3];default:return}},Ql}var Xd={},da={},ey;function cj(){if(ey)return da;ey=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let s=1;for(let o=0;o<255;o++)e[o]=s,t[s]=o,s<<=1,s&256&&(s^=285);for(let o=255;o<512;o++)e[o]=e[o-255]})(),da.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},da.exp=function(s){return e[s]},da.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},da}var ty;function uj(){return ty||(ty=1,(function(e){const t=cj();e.mul=function(s,o){const a=new Uint8Array(s.length+o.length-1);for(let u=0;u<s.length;u++)for(let d=0;d<o.length;d++)a[u+d]^=t.mul(s[u],o[d]);return a},e.mod=function(s,o){let a=new Uint8Array(s);for(;a.length-o.length>=0;){const u=a[0];for(let p=0;p<o.length;p++)a[p]^=t.mul(o[p],u);let d=0;for(;d<a.length&&a[d]===0;)d++;a=a.slice(d)}return a},e.generateECPolynomial=function(s){let o=new Uint8Array([1]);for(let a=0;a<s;a++)o=e.mul(o,new Uint8Array([1,t.exp(a)]));return o}})(Xd)),Xd}var Qd,ny;function dj(){if(ny)return Qd;ny=1;const e=uj();function t(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(s){this.degree=s,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(s.length+this.degree);o.set(s);const a=e.mod(o,this.genPoly),u=this.degree-a.length;if(u>0){const d=new Uint8Array(this.degree);return d.set(a,u),d}return a},Qd=t,Qd}var Jd={},Zd={},eh={},iy;function qw(){return iy||(iy=1,eh.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),eh}var Ki={},sy;function Vw(){if(sy)return Ki;sy=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
82
- ]))+`;Ki.KANJI=new RegExp(n,"g"),Ki.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Ki.BYTE=new RegExp(s,"g"),Ki.NUMERIC=new RegExp(e,"g"),Ki.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+n+"$"),a=new RegExp("^"+e+"$"),u=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Ki.testKanji=function(p){return o.test(p)},Ki.testNumeric=function(p){return a.test(p)},Ki.testAlphanumeric=function(p){return u.test(p)},Ki}var ry;function Rr(){return ry||(ry=1,(function(e){const t=qw(),n=Vw();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(a,u){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!t.isValid(u))throw new Error("Invalid version: "+u);return u>=1&&u<10?a.ccBits[0]:u<27?a.ccBits[1]:a.ccBits[2]},e.getBestModeForData=function(a){return n.testNumeric(a)?e.NUMERIC:n.testAlphanumeric(a)?e.ALPHANUMERIC:n.testKanji(a)?e.KANJI:e.BYTE},e.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},e.isValid=function(a){return a&&a.bit&&a.ccBits};function s(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+o)}}e.from=function(a,u){if(e.isValid(a))return a;try{return s(a)}catch{return u}}})(Zd)),Zd}var oy;function hj(){return oy||(oy=1,(function(e){const t=jr(),n=Kw(),s=yp(),o=Rr(),a=qw(),u=7973,d=t.getBCHDigit(u);function p(b,S,x){for(let E=1;E<=40;E++)if(S<=e.getCapacity(E,x,b))return E}function m(b,S){return o.getCharCountIndicator(b,S)+4}function v(b,S){let x=0;return b.forEach(function(E){const w=m(E.mode,S);x+=w+E.getBitsLength()}),x}function y(b,S){for(let x=1;x<=40;x++)if(v(b,x)<=e.getCapacity(x,S,o.MIXED))return x}e.from=function(S,x){return a.isValid(S)?parseInt(S,10):x},e.getCapacity=function(S,x,E){if(!a.isValid(S))throw new Error("Invalid QR Code version");typeof E>"u"&&(E=o.BYTE);const w=t.getSymbolTotalCodewords(S),N=n.getTotalCodewordsCount(S,x),C=(w-N)*8;if(E===o.MIXED)return C;const L=C-m(E,S);switch(E){case o.NUMERIC:return Math.floor(L/10*3);case o.ALPHANUMERIC:return Math.floor(L/11*2);case o.KANJI:return Math.floor(L/13);case o.BYTE:default:return Math.floor(L/8)}},e.getBestVersionForData=function(S,x){let E;const w=s.from(x,s.M);if(Array.isArray(S)){if(S.length>1)return y(S,w);if(S.length===0)return 1;E=S[0]}else E=S;return p(E.mode,E.getLength(),w)},e.getEncodedBits=function(S){if(!a.isValid(S)||S<7)throw new Error("Invalid QR Code version");let x=S<<12;for(;t.getBCHDigit(x)-d>=0;)x^=u<<t.getBCHDigit(x)-d;return S<<12|x}})(Jd)),Jd}var th={},ay;function fj(){if(ay)return th;ay=1;const e=jr(),t=1335,n=21522,s=e.getBCHDigit(t);return th.getEncodedBits=function(a,u){const d=a.bit<<3|u;let p=d<<10;for(;e.getBCHDigit(p)-s>=0;)p^=t<<e.getBCHDigit(p)-s;return(d<<10|p)^n},th}var nh={},ih,ly;function pj(){if(ly)return ih;ly=1;const e=Rr();function t(n){this.mode=e.NUMERIC,this.data=n.toString()}return t.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){let o,a,u;for(o=0;o+3<=this.data.length;o+=3)a=this.data.substr(o,3),u=parseInt(a,10),s.put(u,10);const d=this.data.length-o;d>0&&(a=this.data.substr(o),u=parseInt(a,10),s.put(u,d*3+1))},ih=t,ih}var sh,cy;function mj(){if(cy)return sh;cy=1;const e=Rr(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function n(s){this.mode=e.ALPHANUMERIC,this.data=s}return n.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(o){let a;for(a=0;a+2<=this.data.length;a+=2){let u=t.indexOf(this.data[a])*45;u+=t.indexOf(this.data[a+1]),o.put(u,11)}this.data.length%2&&o.put(t.indexOf(this.data[a]),6)},sh=n,sh}var rh,uy;function gj(){if(uy)return rh;uy=1;const e=Rr();function t(n){this.mode=e.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return t.getBitsLength=function(s){return s*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(n){for(let s=0,o=this.data.length;s<o;s++)n.put(this.data[s],8)},rh=t,rh}var oh,dy;function vj(){if(dy)return oh;dy=1;const e=Rr(),t=jr();function n(s){this.mode=e.KANJI,this.data=s}return n.getBitsLength=function(o){return o*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(s){let o;for(o=0;o<this.data.length;o++){let a=t.toSJIS(this.data[o]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
83
- Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),s.put(a,13)}},oh=n,oh}var ah={exports:{}},hy;function _j(){return hy||(hy=1,(function(e){var t={single_source_shortest_paths:function(n,s,o){var a={},u={};u[s]=0;var d=t.PriorityQueue.make();d.push(s,0);for(var p,m,v,y,b,S,x,E,w;!d.empty();){p=d.pop(),m=p.value,y=p.cost,b=n[m]||{};for(v in b)b.hasOwnProperty(v)&&(S=b[v],x=y+S,E=u[v],w=typeof u[v]>"u",(w||E>x)&&(u[v]=x,d.push(v,x),a[v]=m))}if(typeof o<"u"&&typeof u[o]>"u"){var N=["Could not find a path from ",s," to ",o,"."].join("");throw new Error(N)}return a},extract_shortest_path_from_predecessor_list:function(n,s){for(var o=[],a=s;a;)o.push(a),n[a],a=n[a];return o.reverse(),o},find_path:function(n,s,o){var a=t.single_source_shortest_paths(n,s,o);return t.extract_shortest_path_from_predecessor_list(a,o)},PriorityQueue:{make:function(n){var s=t.PriorityQueue,o={},a;n=n||{};for(a in s)s.hasOwnProperty(a)&&(o[a]=s[a]);return o.queue=[],o.sorter=n.sorter||s.default_sorter,o},default_sorter:function(n,s){return n.cost-s.cost},push:function(n,s){var o={value:n,cost:s};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(ah)),ah.exports}var fy;function yj(){return fy||(fy=1,(function(e){const t=Rr(),n=pj(),s=mj(),o=gj(),a=vj(),u=Vw(),d=jr(),p=_j();function m(N){return unescape(encodeURIComponent(N)).length}function v(N,C,L){const I=[];let G;for(;(G=N.exec(L))!==null;)I.push({data:G[0],index:G.index,mode:C,length:G[0].length});return I}function y(N){const C=v(u.NUMERIC,t.NUMERIC,N),L=v(u.ALPHANUMERIC,t.ALPHANUMERIC,N);let I,G;return d.isKanjiModeEnabled()?(I=v(u.BYTE,t.BYTE,N),G=v(u.KANJI,t.KANJI,N)):(I=v(u.BYTE_KANJI,t.BYTE,N),G=[]),C.concat(L,I,G).sort(function(Y,Q){return Y.index-Q.index}).map(function(Y){return{data:Y.data,mode:Y.mode,length:Y.length}})}function b(N,C){switch(C){case t.NUMERIC:return n.getBitsLength(N);case t.ALPHANUMERIC:return s.getBitsLength(N);case t.KANJI:return a.getBitsLength(N);case t.BYTE:return o.getBitsLength(N)}}function S(N){return N.reduce(function(C,L){const I=C.length-1>=0?C[C.length-1]:null;return I&&I.mode===L.mode?(C[C.length-1].data+=L.data,C):(C.push(L),C)},[])}function x(N){const C=[];for(let L=0;L<N.length;L++){const I=N[L];switch(I.mode){case t.NUMERIC:C.push([I,{data:I.data,mode:t.ALPHANUMERIC,length:I.length},{data:I.data,mode:t.BYTE,length:I.length}]);break;case t.ALPHANUMERIC:C.push([I,{data:I.data,mode:t.BYTE,length:I.length}]);break;case t.KANJI:C.push([I,{data:I.data,mode:t.BYTE,length:m(I.data)}]);break;case t.BYTE:C.push([{data:I.data,mode:t.BYTE,length:m(I.data)}])}}return C}function E(N,C){const L={},I={start:{}};let G=["start"];for(let K=0;K<N.length;K++){const Y=N[K],Q=[];for(let W=0;W<Y.length;W++){const X=Y[W],H=""+K+W;Q.push(H),L[H]={node:X,lastCount:0},I[H]={};for(let $=0;$<G.length;$++){const R=G[$];L[R]&&L[R].node.mode===X.mode?(I[R][H]=b(L[R].lastCount+X.length,X.mode)-b(L[R].lastCount,X.mode),L[R].lastCount+=X.length):(L[R]&&(L[R].lastCount=X.length),I[R][H]=b(X.length,X.mode)+4+t.getCharCountIndicator(X.mode,C))}}G=Q}for(let K=0;K<G.length;K++)I[G[K]].end=0;return{map:I,table:L}}function w(N,C){let L;const I=t.getBestModeForData(N);if(L=t.from(C,I),L!==t.BYTE&&L.bit<I.bit)throw new Error('"'+N+'" cannot be encoded with mode '+t.toString(L)+`.
84
- Suggested mode is: `+t.toString(I));switch(L===t.KANJI&&!d.isKanjiModeEnabled()&&(L=t.BYTE),L){case t.NUMERIC:return new n(N);case t.ALPHANUMERIC:return new s(N);case t.KANJI:return new a(N);case t.BYTE:return new o(N)}}e.fromArray=function(C){return C.reduce(function(L,I){return typeof I=="string"?L.push(w(I,null)):I.data&&L.push(w(I.data,I.mode)),L},[])},e.fromString=function(C,L){const I=y(C,d.isKanjiModeEnabled()),G=x(I),K=E(G,L),Y=p.find_path(K.map,"start","end"),Q=[];for(let W=1;W<Y.length-1;W++)Q.push(K.table[Y[W]].node);return e.fromArray(S(Q))},e.rawSplit=function(C){return e.fromArray(y(C,d.isKanjiModeEnabled()))}})(nh)),nh}var py;function bj(){if(py)return Ud;py=1;const e=jr(),t=yp(),n=sj(),s=rj(),o=oj(),a=aj(),u=lj(),d=Kw(),p=dj(),m=hj(),v=fj(),y=Rr(),b=yj();function S(K,Y){const Q=K.size,W=a.getPositions(Y);for(let X=0;X<W.length;X++){const H=W[X][0],$=W[X][1];for(let R=-1;R<=7;R++)if(!(H+R<=-1||Q<=H+R))for(let O=-1;O<=7;O++)$+O<=-1||Q<=$+O||(R>=0&&R<=6&&(O===0||O===6)||O>=0&&O<=6&&(R===0||R===6)||R>=2&&R<=4&&O>=2&&O<=4?K.set(H+R,$+O,!0,!0):K.set(H+R,$+O,!1,!0))}}function x(K){const Y=K.size;for(let Q=8;Q<Y-8;Q++){const W=Q%2===0;K.set(Q,6,W,!0),K.set(6,Q,W,!0)}}function E(K,Y){const Q=o.getPositions(Y);for(let W=0;W<Q.length;W++){const X=Q[W][0],H=Q[W][1];for(let $=-2;$<=2;$++)for(let R=-2;R<=2;R++)$===-2||$===2||R===-2||R===2||$===0&&R===0?K.set(X+$,H+R,!0,!0):K.set(X+$,H+R,!1,!0)}}function w(K,Y){const Q=K.size,W=m.getEncodedBits(Y);let X,H,$;for(let R=0;R<18;R++)X=Math.floor(R/3),H=R%3+Q-8-3,$=(W>>R&1)===1,K.set(X,H,$,!0),K.set(H,X,$,!0)}function N(K,Y,Q){const W=K.size,X=v.getEncodedBits(Y,Q);let H,$;for(H=0;H<15;H++)$=(X>>H&1)===1,H<6?K.set(H,8,$,!0):H<8?K.set(H+1,8,$,!0):K.set(W-15+H,8,$,!0),H<8?K.set(8,W-H-1,$,!0):H<9?K.set(8,15-H-1+1,$,!0):K.set(8,15-H-1,$,!0);K.set(W-8,8,1,!0)}function C(K,Y){const Q=K.size;let W=-1,X=Q-1,H=7,$=0;for(let R=Q-1;R>0;R-=2)for(R===6&&R--;;){for(let O=0;O<2;O++)if(!K.isReserved(X,R-O)){let F=!1;$<Y.length&&(F=(Y[$]>>>H&1)===1),K.set(X,R-O,F),H--,H===-1&&($++,H=7)}if(X+=W,X<0||Q<=X){X-=W,W=-W;break}}}function L(K,Y,Q){const W=new n;Q.forEach(function(O){W.put(O.mode.bit,4),W.put(O.getLength(),y.getCharCountIndicator(O.mode,K)),O.write(W)});const X=e.getSymbolTotalCodewords(K),H=d.getTotalCodewordsCount(K,Y),$=(X-H)*8;for(W.getLengthInBits()+4<=$&&W.put(0,4);W.getLengthInBits()%8!==0;)W.putBit(0);const R=($-W.getLengthInBits())/8;for(let O=0;O<R;O++)W.put(O%2?17:236,8);return I(W,K,Y)}function I(K,Y,Q){const W=e.getSymbolTotalCodewords(Y),X=d.getTotalCodewordsCount(Y,Q),H=W-X,$=d.getBlocksCount(Y,Q),R=W%$,O=$-R,F=Math.floor(W/$),A=Math.floor(H/$),T=A+1,j=F-A,z=new p(j);let M=0;const D=new Array($),B=new Array($);let U=0;const se=new Uint8Array(K.buffer);for(let pe=0;pe<$;pe++){const Ve=pe<O?A:T;D[pe]=se.slice(M,M+Ve),B[pe]=z.encode(D[pe]),M+=Ve,U=Math.max(U,Ve)}const ee=new Uint8Array(W);let de=0,ve,fe;for(ve=0;ve<U;ve++)for(fe=0;fe<$;fe++)ve<D[fe].length&&(ee[de++]=D[fe][ve]);for(ve=0;ve<j;ve++)for(fe=0;fe<$;fe++)ee[de++]=B[fe][ve];return ee}function G(K,Y,Q,W){let X;if(Array.isArray(K))X=b.fromArray(K);else if(typeof K=="string"){let F=Y;if(!F){const A=b.rawSplit(K);F=m.getBestVersionForData(A,Q)}X=b.fromString(K,F||40)}else throw new Error("Invalid data");const H=m.getBestVersionForData(X,Q);if(!H)throw new Error("The amount of data is too big to be stored in a QR Code");if(!Y)Y=H;else if(Y<H)throw new Error(`
85
- The chosen QR Code version cannot contain this amount of data.
86
- Minimum version required to store current data is: `+H+`.
87
- `);const $=L(Y,Q,X),R=e.getSymbolSize(Y),O=new s(R);return S(O,Y),x(O),E(O,Y),N(O,Q,0),Y>=7&&w(O,Y),C(O,$),isNaN(W)&&(W=u.getBestMask(O,N.bind(null,O,Q))),u.applyMask(W,O),N(O,Q,W),{modules:O,version:Y,errorCorrectionLevel:Q,maskPattern:W,segments:X}}return Ud.create=function(Y,Q){if(typeof Y>"u"||Y==="")throw new Error("No input text");let W=t.M,X,H;return typeof Q<"u"&&(W=t.from(Q.errorCorrectionLevel,t.M),X=m.from(Q.version),H=u.from(Q.maskPattern),Q.toSJISFunc&&e.setToSJISFunction(Q.toSJISFunc)),G(Y,X,W,H)},Ud}var lh={},ch={},my;function Yw(){return my||(my=1,(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let s=n.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+n);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(a){return[a,a]}))),s.length===6&&s.push("F","F");const o=parseInt(s.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+s.slice(0,6).join("")}}e.getOptions=function(s){s||(s={}),s.color||(s.color={});const o=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,a=s.width&&s.width>=21?s.width:void 0,u=s.scale||4;return{width:a,scale:a?4:u,margin:o,color:{dark:t(s.color.dark||"#000000ff"),light:t(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},e.getScale=function(s,o){return o.width&&o.width>=s+o.margin*2?o.width/(s+o.margin*2):o.scale},e.getImageWidth=function(s,o){const a=e.getScale(s,o);return Math.floor((s+o.margin*2)*a)},e.qrToImageData=function(s,o,a){const u=o.modules.size,d=o.modules.data,p=e.getScale(u,a),m=Math.floor((u+a.margin*2)*p),v=a.margin*p,y=[a.color.light,a.color.dark];for(let b=0;b<m;b++)for(let S=0;S<m;S++){let x=(b*m+S)*4,E=a.color.light;if(b>=v&&S>=v&&b<m-v&&S<m-v){const w=Math.floor((b-v)/p),N=Math.floor((S-v)/p);E=y[d[w*u+N]?1:0]}s[x++]=E.r,s[x++]=E.g,s[x++]=E.b,s[x]=E.a}}})(ch)),ch}var gy;function wj(){return gy||(gy=1,(function(e){const t=Yw();function n(o,a,u){o.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=u,a.width=u,a.style.height=u+"px",a.style.width=u+"px"}function s(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(a,u,d){let p=d,m=u;typeof p>"u"&&(!u||!u.getContext)&&(p=u,u=void 0),u||(m=s()),p=t.getOptions(p);const v=t.getImageWidth(a.modules.size,p),y=m.getContext("2d"),b=y.createImageData(v,v);return t.qrToImageData(b.data,a,p),n(y,m,v),y.putImageData(b,0,0),m},e.renderToDataURL=function(a,u,d){let p=d;typeof p>"u"&&(!u||!u.getContext)&&(p=u,u=void 0),p||(p={});const m=e.render(a,u,p),v=p.type||"image/png",y=p.rendererOpts||{};return m.toDataURL(v,y.quality)}})(lh)),lh}var uh={},vy;function Sj(){if(vy)return uh;vy=1;const e=Yw();function t(o,a){const u=o.a/255,d=a+'="'+o.hex+'"';return u<1?d+" "+a+'-opacity="'+u.toFixed(2).slice(1)+'"':d}function n(o,a,u){let d=o+a;return typeof u<"u"&&(d+=" "+u),d}function s(o,a,u){let d="",p=0,m=!1,v=0;for(let y=0;y<o.length;y++){const b=Math.floor(y%a),S=Math.floor(y/a);!b&&!m&&(m=!0),o[y]?(v++,y>0&&b>0&&o[y-1]||(d+=m?n("M",b+u,.5+S+u):n("m",p,0),p=0,m=!1),b+1<a&&o[y+1]||(d+=n("h",v),v=0)):p++}return d}return uh.render=function(a,u,d){const p=e.getOptions(u),m=a.modules.size,v=a.modules.data,y=m+p.margin*2,b=p.color.light.a?"<path "+t(p.color.light,"fill")+' d="M0 0h'+y+"v"+y+'H0z"/>':"",S="<path "+t(p.color.dark,"stroke")+' d="'+s(v,m,p.margin)+'"/>',x='viewBox="0 0 '+y+" "+y+'"',w='<svg xmlns="http://www.w3.org/2000/svg" '+(p.width?'width="'+p.width+'" height="'+p.width+'" ':"")+x+' shape-rendering="crispEdges">'+b+S+`</svg>
88
- `;return typeof d=="function"&&d(null,w),w},uh}var _y;function xj(){if(_y)return co;_y=1;const e=ij(),t=bj(),n=wj(),s=Sj();function o(a,u,d,p,m){const v=[].slice.call(arguments,1),y=v.length,b=typeof v[y-1]=="function";if(!b&&!e())throw new Error("Callback required as last argument");if(b){if(y<2)throw new Error("Too few arguments provided");y===2?(m=d,d=u,u=p=void 0):y===3&&(u.getContext&&typeof m>"u"?(m=p,p=void 0):(m=p,p=d,d=u,u=void 0))}else{if(y<1)throw new Error("Too few arguments provided");return y===1?(d=u,u=p=void 0):y===2&&!u.getContext&&(p=d,d=u,u=void 0),new Promise(function(S,x){try{const E=t.create(d,p);S(a(E,u,p))}catch(E){x(E)}})}try{const S=t.create(d,p);m(null,a(S,u,p))}catch(S){m(S)}}return co.create=t.create,co.toCanvas=o.bind(null,n.render),co.toDataURL=o.bind(null,n.renderToDataURL),co.toString=o.bind(null,function(a,u,d){return s.render(a,d)}),co}var kj=xj();const Cj=Rf(kj);function yy(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function Ej(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const n=qk(t);if(!n||!n.ok)return{kind:"invalid"};const s=[];return n.ssh||s.push("ssh"),n.name||s.push("name"),s.length?{kind:"partial",decoded:n,missing:s}:{kind:"complete",decoded:n}}function Nj(e,t,n=new Set,s=!1){if(!t||!t.ok)return e;const o=Vk(e,t,n);return t.version===2&&t.name&&!n.has("name")&&!s&&(o.name=t.name),!n.has("label")&&!o.label&&t.label&&(o.label=t.label),o}function by(e,t,n=new Set,s=!1){const o=String(t||"").trim(),a=Ej(o);let u={...e,pairingUrl:o};return(a.kind==="complete"||a.kind==="partial")&&(u={...Nj(u,a.decoded,n,s),pairingUrl:o}),{classification:a,form:u}}function ac(e,t){const n=String(t||"").toLowerCase();if(!/^[a-f0-9]{16,64}$/.test(n))return"";const s=String(e||"NexusCrew").replace(/([a-z0-9])([A-Z])/g,"$1 $2");let o=Vs(s);(o==="localhost"||o==="node")&&(o="nexuscrew");const a=n.slice(0,4),u=Math.max(1,32-a.length-1);return`${o.slice(0,u).replace(/-+$/g,"")||"n"}-${a}`}function jj(e,{deviceDefault:t="",localNodeId:n="",localNameDefault:s=""}={}){const o={name:e.name,ssh:e.ssh,pairingUrl:e.pairingUrl,...e.label?{label:e.label}:{},...e.sshPort?{sshPort:Number(e.sshPort)}:{}},a=e.localLabel||t;a&&(o.localLabel=a);const u=String(e.localName||ac(a,n)||s||"").trim();return u&&(o.localName=u),o}function Rj(){const e=new Set;let t=!1;return{canAuto(n){return!t&&!e.has(String(n||""))},start(n){return t?!1:(t=!0,e.add(String(n||"")),!0)},finish(){t=!1},reset(n){e.delete(String(n||""))},isBusy(){return t}}}const Pj=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function Lj(e){const t=e&&e.data||{},n=typeof t.stage=="string"&&t.stage?t.stage:"",s=typeof t.detail=="string"&&t.detail?t.detail:"";return{stage:n,code:typeof t.code=="string"?t.code:"",detail:s,hint:typeof t.hint=="string"?t.hint:"",suggestedName:typeof t.suggestedName=="string"?t.suggestedName:"",retryable:typeof t.retryable=="boolean"?t.retryable:!n,message:s||String(e&&e.message||e)}}const Aj="modulepreload",Mj=function(e){return"/"+e},wy={},Tj=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let u=function(m){return Promise.all(m.map(v=>Promise.resolve(v).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),p=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));o=u(n.map(m=>{if(m=Mj(m),m in wy)return;wy[m]=!0;const v=m.endsWith(".css"),y=v?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${y}`))return;const b=document.createElement("link");if(b.rel=v?"stylesheet":Aj,v||(b.as="script"),b.crossOrigin="",b.href=m,p&&b.setAttribute("nonce",p),document.head.appendChild(b),v)return new Promise((S,x)=>{b.addEventListener("load",S),b.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${m}`)))})}))}function a(u){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=u,window.dispatchEvent(d),!d.defaultPrevented)throw u}return o.then(u=>{for(const d of u||[])d.status==="rejected"&&a(d.reason);return t().catch(a)})};class pt{constructor(t,n,s,o,a){this._legacyCanvasSize=pt.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),s&&typeof s=="object"?this._onDecode=n:(console.warn(s||o||a?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=n),n=typeof s=="object"?s:{},this._onDecodeError=n.onDecodeError||(typeof s=="function"?s:this._onDecodeError),this._calculateScanRegion=n.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||a||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=n.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let u=!1;if(t.hidden&&(t.hidden=!1,u=!0),document.body.contains(t)||(document.body.appendChild(t),u=!0),s=t.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(o=!!n.overlay,this.$overlay=n.overlay||document.createElement("div"),a=this.$overlay.style,a.position="absolute",a.display="none",a.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!o&&n.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}s.insertBefore(this.$overlay,this.$video.nextSibling)}n.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let d=window.getComputedStyle(t);d.display==="none"&&(t.style.setProperty("display","block","important"),u=!0),d.visibility!=="visible"&&(t.style.setProperty("visibility","visible","important"),u=!0),u&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),t.style.opacity="0",t.style.width="0",t.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),t.addEventListener("play",this._onPlay),t.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=pt.createQrEngine()}static set WORKER_PATH(t){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await pt.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let n=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),s;try{t&&(await n()).every(o=>!o.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await n()).map((o,a)=>({id:o.deviceId,label:o.label||(a===0?"Default Camera":`Camera ${a+1}`)}))}finally{s&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),pt._stopVideoStream(s))}}async hasFlash(){let t;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;t=this.$video.srcObject}else t=(await this._getCameraStream()).stream;return"torch"in t.getVideoTracks()[0].getSettings()}catch{return!1}finally{t&&t!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),pt._stopVideoStream(t))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(t){throw this._flashOn=!1,t}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),pt._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:n}=await this._getCameraStream();!this._active||this._paused?pt._stopVideoStream(t):(this._setVideoMirror(n),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(t){if(!this._paused)throw this._active=!1,t}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let n=()=>{this.$video.srcObject instanceof MediaStream&&(pt._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(n(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(n(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,n,s,o,a=!1,u=!1){let d,p=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(d=n.scanRegion,s=n.qrEngine,o=n.canvas,a=n.disallowCanvasResizing||!1,u=n.alsoTryWithoutScanRegion||!1,p=!0):console.warn(n||s||o||a||u?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),n=!!s;try{let m,v;[s,m]=await Promise.all([s||pt.createQrEngine(),pt._loadImage(t)]),[o,v]=pt._drawToCanvas(m,d,o,a);let y;if(s instanceof Worker){let b=s;n||pt._postWorkerMessageSync(b,"inversionMode","both"),y=await new Promise((S,x)=>{let E,w,N,C=-1;w=I=>{I.data.id===C&&(b.removeEventListener("message",w),b.removeEventListener("error",N),clearTimeout(E),I.data.data!==null?S({data:I.data.data,cornerPoints:pt._convertPoints(I.data.cornerPoints,d)}):x(pt.NO_QR_CODE_FOUND))},N=I=>{b.removeEventListener("message",w),b.removeEventListener("error",N),clearTimeout(E),x("Scanner error: "+(I?I.message||I:"Unknown Error"))},b.addEventListener("message",w),b.addEventListener("error",N),E=setTimeout(()=>N("timeout"),1e4);let L=v.getImageData(0,0,o.width,o.height);C=pt._postWorkerMessageSync(b,"decode",L,[L.data.buffer])})}else y=await Promise.race([new Promise((b,S)=>window.setTimeout(()=>S("Scanner error: timeout"),1e4)),(async()=>{try{var[b]=await s.detect(o);if(!b)throw pt.NO_QR_CODE_FOUND;return{data:b.rawValue,cornerPoints:pt._convertPoints(b.cornerPoints,d)}}catch(S){if(b=S.message||S,/not implemented|service unavailable/.test(b))return pt._disableBarcodeDetector=!0,pt.scanImage(t,{scanRegion:d,canvas:o,disallowCanvasResizing:a,alsoTryWithoutScanRegion:u});throw`Scanner error: ${b}`}})()]);return p?y:y.data}catch(m){if(!d||!u)throw m;let v=await pt.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:a});return p?v:v.data}finally{n||pt._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,n,s,o=!0){pt._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:n,blue:s,useIntegerApproximation:o})}setInversionMode(t){pt._postWorkerMessage(this._qrEnginePromise,"inversionMode",t)}static async createQrEngine(t){if(t&&console.warn("Specifying a worker path is not required and not supported anymore."),t=()=>Tj(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!pt._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let n=navigator.userAgentData;return n&&n.brands.some(({brand:s})=>/Chromium/i.test(s))&&/mac ?OS/i.test(n.platform)&&await n.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:s,platformVersion:o})=>/arm/i.test(s||"arm")&&13<=parseInt(o||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let n=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-n)/2),y:Math.round((t.videoHeight-n)/2),width:n,height:n,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,n=t.videoWidth,s=t.videoHeight,o=t.offsetWidth,a=t.offsetHeight,u=t.offsetLeft,d=t.offsetTop,p=window.getComputedStyle(t),m=p.objectFit,v=n/s,y=o/a;switch(m){case"none":var b=n,S=s;break;case"fill":b=o,S=a;break;default:(m==="cover"?v>y:v<y)?(S=a,b=S*v):(b=o,S=b/v),m==="scale-down"&&(b=Math.min(b,n),S=Math.min(S,s))}var[x,E]=p.objectPosition.split(" ").map((N,C)=>{const L=parseFloat(N);return N.endsWith("%")?(C?a-S:o-b)*L/100:L});p=this._scanRegion.width||n,y=this._scanRegion.height||s,m=this._scanRegion.x||0;var w=this._scanRegion.y||0;v=this.$overlay.style,v.width=`${p/n*b}px`,v.height=`${y/s*S}px`,v.top=`${d+E+w/s*S}px`,s=/scaleX\(-1\)/.test(t.style.transform),v.left=`${u+(s?o-x-b:x)+(s?n-m-p:m)/n*b}px`,v.transform=t.style.transform}})}static _convertPoints(t,n){if(!n)return t;let s=n.x||0,o=n.y||0,a=n.width&&n.downScaledWidth?n.width/n.downScaledWidth:1;n=n.height&&n.downScaledHeight?n.height/n.downScaledHeight:1;for(let u of t)u.x=u.x*a+s,u.y=u.y*n+o;return t}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,n=1e3/this._maxScansPerSecond;t<n&&await new Promise(o=>setTimeout(o,n-t)),this._lastScanTimestamp=Date.now();try{var s=await pt.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!pt._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=pt.createQrEngine()),s?(this._onDecode?this._onDecode(s):this._legacyOnDecode&&this._legacyOnDecode(s.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",s.cornerPoints.map(({x:o,y:a})=>`${o},${a}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(t){t!==pt.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",n=[{width:{min:1024}},{width:{min:768}},{}],s=n.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...s,...n])try{let a=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),u=this._getFacingMode(a)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:a,facingMode:u}}catch{}throw"Camera not found."}async _restartVideoStream(){let t=this._paused;await this.pause(!0)&&!t&&this._active&&await this.start()}static _stopVideoStream(t){for(let n of t.getTracks())n.stop(),t.removeTrack(n)}_setVideoMirror(t){this.$video.style.transform="scaleX("+(t==="user"?-1:1)+")"}_getFacingMode(t){return(t=t.getVideoTracks()[0])?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(t,n,s,o=!1){s=s||document.createElement("canvas");let a=n&&n.x?n.x:0,u=n&&n.y?n.y:0,d=n&&n.width?n.width:t.videoWidth||t.width,p=n&&n.height?n.height:t.videoHeight||t.height;return o||(o=n&&n.downScaledWidth?n.downScaledWidth:d,n=n&&n.downScaledHeight?n.downScaledHeight:p,s.width!==o&&(s.width=o),s.height!==n&&(s.height=n)),n=s.getContext("2d",{alpha:!1}),n.imageSmoothingEnabled=!1,n.drawImage(t,a,u,d,p,0,0,s.width,s.height),[s,n]}static async _loadImage(t){if(t instanceof Image)return await pt._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(t instanceof File||t instanceof Blob||t instanceof URL||typeof t=="string"){let n=new Image;n.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await pt._awaitImageLoad(n),n}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(n.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((n,s)=>{let o=a=>{t.removeEventListener("load",o),t.removeEventListener("error",o),a instanceof ErrorEvent?s("Image load error"):n()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,n,s,o){return pt._postWorkerMessageSync(await t,n,s,o)}static _postWorkerMessageSync(t,n,s,o){if(!(t instanceof Worker))return-1;let a=pt._workerMessageId++;return t.postMessage({id:a,type:n,data:s},o),a}}pt.DEFAULT_CANVAS_SIZE=400;pt.NO_QR_CODE_FOUND="No QR code found";pt._disableBarcodeDetector=!1;pt._workerMessageId=0;function Dj({onResult:e,onClose:t}){const n=k.useRef(null),s=k.useRef(null),o=k.useRef(!1),[a,u]=k.useState("");k.useEffect(()=>{let p=!1;const m=n.current,v=y=>{p||o.current||(o.current=!0,e(y))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){u(f("qr-unsupported"));return}let y=!1;try{y=await pt.hasCamera()}catch{y=!1}if(!y){u(f("qr-no-camera"));return}if(p||!m)return;const b=new pt(m,S=>{const x=yy(S);x&&v(x)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:S=>{const x=S.videoWidth||640,E=S.videoHeight||480,w=Math.max(1,Math.round(Math.min(x,E)*.92));return{x:Math.round((x-w)/2),y:Math.round((E-w)/2),width:w,height:w,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=b;try{await b.start()}catch(S){if(p)return;const x=S&&S.name||"";u(f(x==="NotAllowedError"||x==="SecurityError"?"qr-permission":x==="NotFoundError"||x==="OverconstrainedError"||x==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{p=!0;const y=s.current;if(y){try{y.stop()}catch{}try{y.destroy()}catch{}s.current=null}const b=m,S=b&&b.srcObject;if(S&&typeof S.getTracks=="function"){for(const x of S.getTracks())try{x.stop()}catch{}try{b.srcObject=null}catch{}}}},[]);const d=async p=>{const m=p.target.files&&p.target.files[0];if(p.target.value="",!!m)try{const v=await pt.scanImage(m,{returnDetailedScanResult:!0}),y=yy(v);if(!y)throw new Error("empty");o.current||(o.current=!0,e(y))}catch{u(f("pairing-qr-invalid"))}};return l.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:t,children:l.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:p=>p.stopPropagation(),children:[l.jsx("div",{className:"nc-sheet-head",children:l.jsx("b",{children:f("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:[f("qr-upload"),l.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:d})]}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:t,children:f("cancel")})]})]})})}function bp({line:e,note:t}){const[n,s]=k.useState(!1);return e?l.jsxs("div",{className:"nc-authkeys",role:"group",children:[l.jsx("div",{className:"nc-sheet-label",children:f("pair-authkeys-title")}),l.jsx("small",{className:"nc-set-hint",children:t||f("pair-authkeys-hint")}),l.jsx("textarea",{className:"nc-authkeys-line",readOnly:!0,rows:3,value:e,"aria-label":f("pair-authkeys-title"),onFocus:o=>o.target.select()}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:async()=>{s(await df(e))},children:f(n?"pair-authkeys-copied":"pair-authkeys-copy")})]}):null}const Sy=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:"",localName:""});function Gw({token:e,initial:t="",autoStart:n=!1,deviceDefault:s="",localNodeId:o="",localNameDefault:a="",readonly:u=!1,onSuccess:d,onBusyChange:p}){const[m,v]=k.useState(Sy),[y,b]=k.useState(!1),[S,x]=k.useState(!1),[E,w]=k.useState("idle"),[N,C]=k.useState(null),[L,I]=k.useState(""),[G,K]=k.useState(null),[Y,Q]=k.useState(!1),[W,X]=k.useState(!1),H=k.useRef(Rj()),$=k.useRef(new Set),R=E==="busy",O=ac(m.localLabel||s,o)||a,F=W?m.localName:O;k.useEffect(()=>(p&&p(R),()=>{p&&p(!1)}),[R,p]);const A=async B=>{const U=String(B.pairingUrl||"").trim();if(H.current.start(U)){w("busy"),C(null),I("");try{const se=await kx(e,jj({...B,localName:W?B.localName:ac(B.localLabel||s,o)||a},{deviceDefault:s,localNodeId:o,localNameDefault:a}));w("ok"),b(!1),v(Sy()),K(se&&se.authorizedKeys?{line:se.authorizedKeys,note:se.authorizedKeysNote||""}:null),$.current=new Set,Q(!1),X(!1),H.current.finish(),d&&await d(se)}catch(se){const ee=Lj(se);C(ee),w("idle"),H.current.finish(),ee.code==="peer-name-conflict"&&kh(ee.suggestedName)&&(X(!0),$.current.add("localName"),v(de=>({...de,localName:ee.suggestedName}))),(ee.stage==="validation"||ee.stage==="conflict"||ee.stage==="ssh-start"||ee.stage==="ssh-ready"||String(ee.code||"").startsWith("ssh-"))&&b(!0)}}},T=(B,U=!0)=>{const{classification:se,form:ee}=by(m,B,$.current,Y),de=ee.pairingUrl;if(C(null),I(""),E==="ok"&&w("idle"),v(ee),se.kind==="invalid"){C({stage:"validation",code:"bad-link",message:f("pair-invalid-link"),hint:f("pair-invalid-hint"),retryable:!0});return}if(se.kind==="partial"){b(!0),I(se.missing.includes("ssh")?f("pair-missing-ssh"):f("pair-missing-name"));return}se.kind==="complete"&&U&&!u&&H.current.canAuto(de)&&A(ee)};k.useEffect(()=>{t&&T(t,n)},[]);const j=()=>{const B=String(m.pairingUrl||"").trim(),{classification:U,form:se}=by(m,B,$.current,Y);if(v(se),I(""),C(null),U.kind==="empty"){C({stage:"validation",message:f("pairing-required"),retryable:!0});return}if(U.kind==="invalid"){C({stage:"validation",code:"bad-link",message:f("pair-invalid-link"),hint:f("pair-invalid-hint"),retryable:!0});return}if(!se.ssh||!se.name){b(!0),I(se.ssh?f("pair-missing-name"):f("pair-missing-ssh"));return}if(se.label&&!_o(se.label)){C({stage:"validation",message:f("err-label"),retryable:!0});return}if(se.localLabel&&!_o(se.localLabel)){C({stage:"validation",message:f("err-label"),retryable:!0});return}const ee=W?se.localName:ac(se.localLabel||s,o)||a;if(!kh(ee)||ee==="localhost"){b(!0),C({stage:"validation",code:"bad-local-name",message:f("err-local-name"),retryable:!0});return}H.current.reset(B),A(se)},z=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const B=await navigator.clipboard.readText();B&&B.trim()?T(B):I(f("pair-clipboard-empty"))}catch{I(f("pair-clipboard-denied"))}},M=(B,U)=>{$.current.add(B),v(se=>({...se,[B]:U}))},D=N&&N.stage&&(Pj.includes(N.stage)||N.stage==="internal")?f(`pair-stage-${N.stage}`):f("pair-stage-generic");return l.jsxs("div",{className:"nc-set-form nc-pair-card",children:[l.jsx("div",{className:"nc-sheet-label",children:f("pair-card-title")}),l.jsx("div",{className:"nc-set-info",children:f("pair-card-help")}),l.jsx("input",{className:"nc-pair-input",placeholder:f("pair-paste-ph"),value:m.pairingUrl,disabled:u||R,onChange:B=>{v({...m,pairingUrl:B.target.value}),C(null),I("")},onPaste:B=>{const U=B.clipboardData&&B.clipboardData.getData("text")||"";U.trim()&&(B.preventDefault(),T(U))},onKeyDown:B=>{B.key==="Enter"&&(B.preventDefault(),j())}}),l.jsxs("div",{className:"nc-pair-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||R,onClick:z,children:f("pair-paste-btn")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||R,onClick:()=>x(!0),children:f("scan-qr")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:u||R,title:u?f("settings-readonly"):"",onClick:j,children:f("test-and-connect")})]}),l.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[R&&l.jsx("div",{className:"nc-pair-progress",children:f("pair-progress")}),E==="ok"&&l.jsx("div",{className:"nc-set-test ok",children:f("node-connected")}),E==="ok"&&G&&l.jsx(bp,{line:G.line,note:G.note}),L&&l.jsx("div",{className:"nc-set-hint nc-pair-notice",children:L}),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:u||R,onClick:j,children:f("pair-retry")})})]})]}),l.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:R,onClick:()=>b(B=>!B),children:[y?"▾":"▸"," ",f("pair-advanced")]}),y&&l.jsxs("div",{className:"nc-pair-advanced",children:[l.jsxs("label",{className:"nc-field",children:[f("node-display-label"),l.jsx("input",{placeholder:"Home Relay",value:m.label,disabled:u||R,onChange:B=>{$.current.add("label"),v(U=>({...U,label:B.target.value,name:Y?U.name:Vs(B.target.value)}))}})]}),l.jsxs("label",{className:"nc-field",children:[f("node-name-label"),l.jsx("input",{placeholder:f("node-name-ph"),value:m.name,disabled:u||R,onChange:B=>{Q(!0),$.current.add("name"),v(U=>({...U,name:B.target.value?Vs(B.target.value):""}))}})]}),l.jsx("small",{className:"nc-set-hint",children:f("node-slug-hint").replace("{slug}",m.name||"home-relay")}),l.jsxs("label",{className:"nc-field",children:[f("pair-ssh-local-label"),l.jsx("input",{placeholder:"my-relay",value:m.ssh,disabled:u||R,onChange:B=>{$.current.add("ssh"),M("ssh",B.target.value)}}),l.jsx("small",{className:"nc-set-hint",children:f("node-ssh-local-help")})]}),l.jsxs("label",{className:"nc-field",children:[f("node-ssh-port-label"),l.jsx("input",{inputMode:"numeric",placeholder:f("node-ssh-port-help"),value:m.sshPort,disabled:u||R,onChange:B=>M("sshPort",B.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),l.jsxs("label",{className:"nc-field",children:[f("device-name-label"),l.jsx("input",{placeholder:s||"NexusCrew",value:m.localLabel,disabled:u||R,onChange:B=>M("localLabel",B.target.value)}),l.jsx("small",{className:"nc-set-hint",children:f("device-name-hint")})]}),l.jsxs("label",{className:"nc-field",children:[f("local-route-name-label"),l.jsx("input",{placeholder:O||"nexuscrew-5bd6",value:F,disabled:u||R,onChange:B=>{X(!0),$.current.add("localName"),v(U=>({...U,localName:B.target.value?Vs(B.target.value):""}))}}),l.jsx("small",{className:"nc-set-hint",children:f("local-route-name-hint")})]})]}),S&&l.jsx(Dj,{onResult:B=>{x(!1),T(B)},onClose:()=>x(!1)})]})}const Vi={routed:"peer-routed",routedStale:"peer-routed-stale",up:"tunnel-up",down:"tunnel-down",passive:"node-connected-client",vlOnline:"vl-poll-online",vlOffline:"vl-poll-offline"};function wp(e){if(!e||typeof e!="object")return{key:Vi.down,up:!1};if(e.kind==="vl")return e.online?{key:Vi.vlOnline,up:!0}:{key:Vi.vlOffline,up:!1};if(e.kind==="transitive"){const n=e.stale===!0;return{key:n?Vi.routedStale:Vi.routed,up:!n,routed:!0}}const t=e.tunnel&&e.tunnel.status;return t==="up"?{key:Vi.up,up:!0}:t==="passive"?{key:Vi.passive,up:!1,passive:!0}:{key:Vi.down,up:!1}}function Xw(e){if(!e||typeof e!="object")return{key:"peer-private",shortKey:"row-private",shared:!1};if(e.kind==="vl")return{key:"peer-vl-federated",shortKey:"row-vl-federated",shared:!0};if(e.shared!==!0)return{key:"peer-private",shortKey:"row-private",shared:!1};const t=e.visibility||"network";if(t==="relay-only")return{key:"visibility-relay",shortKey:"visibility-relay",shared:!0,visibility:t};if(t==="selected"){const n=Array.isArray(e.selected)?e.selected.length:0;return{key:"visibility-selected",shortKey:"visibility-selected",shared:!0,visibility:t,count:n}}return{key:"visibility-network",shortKey:"visibility-network",shared:!0,visibility:t}}function Ij(e){const n=e.health&&typeof e.health.detail=="string"&&e.health.detail.trim()||f(e.online?Vi.vlOnline:Vi.vlOffline);return e.ownerLabel?`${e.ownerLabel} · ${n}`:n}function Oj(e){if(!e||typeof e!="object")return null;const t=typeof e.name=="string"?e.name:"";if(!t)return null;const n=e.kind==="transitive";return{name:t,title:typeof e.label=="string"&&e.label.trim()||t,subtitle:e.kind==="vl"?Ij(e):t,reach:wp(e),exposure:Xw(e),routed:n,routeLabel:n&&Array.isArray(e.route)?e.route.join(" › "):null}}function Bj(e){if(!e||typeof e!="object"||typeof e.name!="string"||!e.name)return null;const t=e.kind==="transitive";return{name:e.name,title:typeof e.label=="string"&&e.label.trim()||e.name,routed:t,route:t&&Array.isArray(e.route)?[...e.route]:null,ssh:!t&&e.direction==="outbound"&&e.ssh?String(e.ssh):null,inbound:!t&&e.direction==="inbound",transport:e.tunnel&&typeof e.tunnel.transport=="string"&&e.tunnel.transport||null}}function zj(e){return!e||typeof e!="object"?null:e.kind==="transitive"?{key:"authority-routed",ownerEquivalent:!1,grants:[],model:"none"}:{key:"authority-owner-equivalent",ownerEquivalent:!0,grants:[],model:"none"}}function $j(e,t){if(!e||e.visibility!=="selected")return[];const n=[...new Set(Array.isArray(e.selected)?e.selected:[])],s=new Map;for(const o of Array.isArray(t)?t:[])o&&o.nodeId&&!s.has(o.nodeId)&&s.set(o.nodeId,o);return n.map(o=>{const a=s.get(o);return{id:o,label:a?typeof a.label=="string"&&a.label.trim()||a.name:o,known:!!a}})}function Fj(e,t,n=""){if(!e)return[];const s=new Set(Array.isArray(e.selected)?e.selected:[]),o=String(n||"").trim().toLowerCase(),a=new Set,u=[],d=p=>e.nodeId?p.nodeId===e.nodeId:p.name===e.name;for(const p of Array.isArray(t)?t:[]){if(!p||!p.nodeId||d(p)||s.has(p.nodeId)||a.has(p.nodeId))continue;const m=typeof p.label=="string"&&p.label.trim()||p.name;o&&!`${m} ${p.name}`.toLowerCase().includes(o)||(a.add(p.nodeId),u.push({id:p.nodeId,label:m,name:p.name}))}return u.sort((p,m)=>p.label.localeCompare(m.label))}function Hj(e,{readonly:t=!1,busy:n=!1}={}){if(!e||typeof e!="object")return[];const s=e.actions&&typeof e.actions=="object"?e.actions:{},o=wp(e).up,a=[],u=(d,p,{mutating:m=!0,danger:v=!1}={})=>{a.push({key:d,action:p,danger:v,disabled:n||m&&t})};return s.edit&&u("edit","edit"),s.test&&u("node-test","test",{mutating:!1}),s.disconnect&&o&&u("tunnel-stop","down"),s.connect&&!o&&u("tunnel-start","up"),s.restart&&u("tunnel-restart","restart"),s.remove&&u("delete","remove",{danger:!0}),a}function Qw(e){const t=e&&typeof e.cellVisibility=="string"?e.cellVisibility:"all";return["all","none","selected"].includes(t)?t:"all"}function Uj(e,t){if(Qw(e)!=="selected")return[];const n=[...new Set(Array.isArray(e.cells)?e.cells:[])];if(!Array.isArray(t))return n.map(o=>({id:o,label:o,known:!0}));const s=new Set(t.map(o=>typeof o=="string"?o:o&&(o.cell||o.id)).filter(Boolean));return n.map(o=>({id:o,label:o,known:s.has(o)}))}function Wj(e,t,n=""){const s=new Set(Array.isArray(e&&e.cells)?e.cells:[]),o=String(n||"").trim().toLowerCase(),a=new Set,u=[];for(const d of Array.isArray(t)?t:[]){const p=typeof d=="string"?d:d&&(d.cell||d.id);!p||s.has(p)||a.has(p)||o&&!p.toLowerCase().includes(o)||(a.add(p),u.push({id:p,label:p}))}return u.sort((d,p)=>d.label.localeCompare(p.label))}function Kj(e,t,{readonly:n=!1,busy:s=!1}={}){const o=Bj(e);return o?{identity:o,reach:wp(e),authority:zj(e),exposure:Xw(e),grants:$j(e,t),cellScope:Qw(e),actions:Hj(e,{readonly:n,busy:s}),canEditVisibility:!!(e.actions&&e.actions.visibility)&&e.shared===!0&&e.kind!=="transitive",canEditCellScope:!!(e.actions&&e.actions.edit)&&e.kind!=="transitive"}:null}const qj=new Set(["update_candidate"]),xy=4096,Vj=new Set(["prompt"]),ky={logs:{limit:50}};function Yj(e){if(!e||e.kind!=="vl")return[];const t=Array.isArray(e.capabilities)?e.capabilities:[],n=new Set,s=[];for(const o of t)typeof o!="string"||!o||qj.has(o)||Vj.has(o)||n.has(o)||(n.add(o),s.push(o));return s}function Cy(e){return!!(e&&e.kind==="vl"&&Array.isArray(e.capabilities)&&e.capabilities.includes("prompt"))}function Gj(e){return ky[e]?{...ky[e]}:{}}function Xj(e,t){return e?e.inflight&&typeof e.inflight=="object"?{phase:"inflight",kind:e.inflight.kind}:t?e.lastAck&&e.lastAck.id===t.id?{phase:"done",kind:t.kind,status:e.lastAck.status,result:e.lastAck.result,at:e.lastAck.at}:{phase:"submitted",kind:t.kind}:e.lastAck&&typeof e.lastAck=="object"?{phase:"done",kind:null,status:e.lastAck.status,result:e.lastAck.result,at:e.lastAck.at}:null:null}function Qj({title:e,subtitle:t,status:n,footer:s,onClose:o,plain:a=!1,children:u}){const d=k.useRef(null),p=k.useRef(null);return k.useEffect(()=>(p.current=document.activeElement,d.current&&d.current.focus(),()=>{const m=p.current;m&&typeof m.focus=="function"&&document.contains(m)&&m.focus()}),[]),k.useEffect(()=>{const m=v=>{v.key==="Escape"&&(v.stopPropagation(),o&&o())};return document.addEventListener("keydown",m,!0),()=>document.removeEventListener("keydown",m,!0)},[o]),l.jsx("div",{className:"nc-detail-overlay",onMouseDown:m=>{m.target===m.currentTarget&&o&&o()},children:l.jsxs("div",{className:"nc-detail-sheet",ref:d,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":typeof e=="string"?e:void 0,children:[l.jsxs("div",{className:"nc-detail-head",children:[l.jsxs("div",{className:"nc-detail-title",children:[l.jsx("b",{children:e}),t&&l.jsx("small",{children:t})]}),n,l.jsx("button",{type:"button",className:"nc-btn ghost nc-detail-close",onClick:o,"aria-label":f("close"),children:l.jsx(lt,{name:"x",size:14})})]}),l.jsx("div",{className:`nc-detail-body${a?" plain":""}`,children:u}),s&&l.jsx("div",{className:"nc-detail-foot",children:s})]})})}function uo({title:e,hint:t,children:n}){return n==null||n===!1?null:l.jsxs("section",{className:"nc-detail-section",children:[e&&l.jsx("div",{className:"nc-sheet-label",children:e}),t&&l.jsx("small",{className:"nc-set-hint",children:t}),n]})}function Jj({node:e,nodes:t,token:n,readonly:s,refresh:o,onClose:a}){var re,Qe;Yn();const[u,d]=k.useState(null),[p,m]=k.useState(null),[v,y]=k.useState(null),[b,S]=k.useState(null),[x,E]=k.useState(!1),[w,N]=k.useState(""),[C,L]=k.useState(!1),[I,G]=k.useState(null),[K,Y]=k.useState(!1),[Q,W]=k.useState(""),[X,H]=k.useState(!1),[$,R]=k.useState(null),[O,F]=k.useState(!1),[A,T]=k.useState(""),j=k.useMemo(()=>Kj(e,t,{readonly:s,busy:!!u}),[e,t,s,u]);if(!j)return null;const{identity:z,reach:M,authority:D,exposure:B,grants:U,actions:se,canEditVisibility:ee,canEditCellScope:de,cellScope:ve}=j,fe=z.routed?{up:M.up,since:null}:Ch(e.tunnel,Date.now()),pe=async(me,Ge)=>{m(null),d(me);try{await Ge()}catch(ct){m(String(ct&&ct.message||ct))}d(null)},Ve=me=>{if(me==="edit"){S({label:e.label||e.name,ssh:e.ssh||"",sshPort:e.sshPort?String(e.sshPort):"",autostart:e.autostart===!0,visibility:e.visibility||"network"});return}if(me==="remove"){E(!0);return}pe(`${e.name}:${me}`,async()=>{const Ge=await If(n,e.name,me);me==="test"&&y(Ge),await o()})},ut=(me,Ge=Gj(me))=>pe(`${e.nodeId}:${me}`,async()=>{const ct=await ev(n,e.nodeId,me,Ge,e.route||[]);R({id:ct.id,kind:me,submittedAt:Date.now()}),await o()}),vt=()=>{const me=A.trim().slice(0,xy);me&&pe(`${e.nodeId}:prompt`,async()=>{const Ge=await ev(n,e.nodeId,"prompt",{text:me},e.route||[]);R({id:Ge.id,kind:"prompt",submittedAt:Date.now()}),T(""),F(!1),await o()})},je=()=>{if(!_o(b.label)){m(f("err-label"));return}const me=z.inbound?{label:b.label,visibility:b.visibility,selected:b.visibility==="selected"?[...e.selected||[]]:[]}:{label:b.label,ssh:b.ssh,autostart:b.autostart,...b.sshPort?{sshPort:Number(b.sshPort)}:{}};return pe(`${e.name}:edit`,async()=>{await iv(n,e.name,me),S(null),await o()})},Ct=(me,Ge)=>pe(`${e.name}:visibility`,async()=>{await Px(n,e.name,me,Ge),await o()}),dn=ee&&e.visibility==="selected"?Fj(e,t,w):[],gn=(me,Ge)=>pe(`${e.name}:cell-scope`,async()=>{await iv(n,e.name,me==="selected"?{cellVisibility:me,cells:Array.isArray(Ge)?Ge:e.cells||[]}:{cellVisibility:me}),await o()}),Yt=async({retry:me=!1}={})=>{if(me&&K)Y(!1);else if(I!==null||K)return;try{const Ge=await Ec(n);G(Array.isArray(Ge&&Ge.cells)?Ge.cells:[])}catch{Y(!0)}};k.useEffect(()=>{de&&ve==="selected"&&I===null&&Yt()},[de,ve,I]);const xt=Uj(e,I),Ot=ve==="selected"?Wj(e,I,Q):[],Ut=l.jsxs("span",{className:`nc-set-tunnel${M.up?" up":""}`,children:[f(M.key),fe.since?` · ${fe.since}`:""]}),Nt=e.kind==="vl",Dt=Nt?Yj(e):[],At=Nt?Xj(e,$):null,jt=me=>{const Ge=`vl-cmd-${me}`,ct=f(Ge);return ct===Ge?me:ct},hn=Nt?[...Dt.map(me=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u||s,title:s?f("settings-readonly"):void 0,onClick:()=>ut(me),children:jt(me)},me)),...Cy(e)?[l.jsx("button",{type:"button",className:`nc-btn ghost${O?" on":""}`,disabled:!!u||s,title:s?f("settings-readonly"):void 0,onClick:()=>F(me=>!me),children:jt("prompt")},"prompt")]:[]]:se.map(me=>l.jsx("button",{type:"button",className:`nc-btn ${me.danger?"danger":"ghost"}`,disabled:me.disabled,title:me.disabled&&s?f("settings-readonly"):void 0,onClick:()=>Ve(me.action),children:me.action==="remove"?l.jsxs(l.Fragment,{children:[l.jsx(lt,{name:"trash",size:14})," ",f(me.key)]}):f(me.key)},me.action));return l.jsxs(Qj,{title:z.title,subtitle:z.name,status:Ut,footer:hn,onClose:a,children:[l.jsxs(uo,{title:f("node-detail-reach"),children:[l.jsxs("dl",{className:"nc-detail-facts",children:[z.route&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:f("node-detail-route")}),l.jsx("dd",{children:z.route.join(" › ")})]}),z.ssh&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:f("node-detail-ssh")}),l.jsxs("dd",{children:[z.ssh,e.sshPort?`:${e.sshPort}`:""]})]}),z.transport&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:f("node-detail-transport")}),l.jsx("dd",{children:z.transport})]}),Nt&&e.ownerLabel&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:f("node-detail-owner")}),l.jsx("dd",{children:e.ownerLabel})]})]}),((re=e.health)==null?void 0:re.detail)&&l.jsx("div",{className:`nc-set-test${Nt?e.health.state==="running"?" ok":e.health.state==="starting"?"":" ko":e.health.status==="healthy"?" ok":e.health.status==="passive"?"":" ko"}`,children:e.health.detail}),(()=>{const me=Nk(e.health);return me?me.line?l.jsx(bp,{line:me.line,note:me.note}):l.jsx("small",{className:"nc-set-hint",children:me.note}):null})(),v&&l.jsxs("div",{className:`nc-set-test${v.ok?" ok":" ko"}`,children:[v.result,v.detail?` — ${v.detail}`:""]})]}),Nt&&l.jsxs(uo,{title:f("node-detail-command"),children:[Dt.length===0&&!Cy(e)&&l.jsx("small",{className:"nc-set-hint",children:f("vl-no-commands")}),O&&l.jsxs("div",{className:"nc-vl-prompt",children:[l.jsx("textarea",{value:A,maxLength:xy,placeholder:f("vl-prompt-placeholder"),"aria-label":f("vl-prompt-placeholder"),disabled:!!u||s,onChange:me=>T(me.target.value)}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!u||s||!A.trim(),onClick:vt,children:f("vl-prompt-send")})]}),At&&l.jsxs("div",{className:`nc-set-test${At.phase==="done"?At.status==="ok"?" ok":" ko":""}`,children:[At.kind&&`${jt(At.kind)}: `,At.phase==="submitted"&&f("vl-cmd-phase-submitted"),At.phase==="inflight"&&f("vl-cmd-phase-inflight"),At.phase==="done"&&f(At.status==="ok"?"vl-cmd-phase-done-ok":"vl-cmd-phase-done-error"),At.phase==="done"&&((Qe=At.result)!=null&&Qe.detail)?` — ${At.result.detail}`:""]})]}),l.jsxs(uo,{title:f("node-detail-authority"),children:[l.jsx("div",{className:"nc-set-info",children:f(D.key)}),D.grants.length===0&&l.jsx("small",{className:"nc-set-hint",children:f(de?"authority-no-grants":"authority-no-grants-elsewhere")})]}),l.jsxs(uo,{title:f("node-detail-network-view"),children:[l.jsx("div",{className:"nc-set-info",children:f(Nt?B.key:B.shared?"peer-shared":"peer-private")}),ee&&l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"nc-field",children:[f("peer-visibility"),l.jsxs("select",{value:e.visibility||"network",disabled:s||!!u,onChange:me=>Ct(me.target.value),children:[l.jsx("option",{value:"network",children:f("visibility-network")}),l.jsx("option",{value:"relay-only",children:f("visibility-relay")}),l.jsx("option",{value:"selected",children:f("visibility-selected")})]})]}),e.visibility==="selected"&&l.jsxs("div",{className:"nc-detail-grants",children:[U.length===0&&l.jsx("small",{className:"nc-set-hint",children:f("node-grant-none")}),U.map(me=>l.jsxs("div",{className:`nc-detail-grant${me.known?"":" unknown"}`,children:[l.jsxs("span",{children:[me.label,me.known?"":` — ${f("node-grant-unknown")}`]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>Ct("selected",(e.selected||[]).filter(Ge=>Ge!==me.id)),children:f("node-grant-remove")})]},me.id)),!C&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>{L(!0),N("")},children:f("node-grant-add")}),C&&l.jsxs("div",{className:"nc-detail-picker",children:[l.jsx("input",{value:w,placeholder:f("node-grant-search"),disabled:s||!!u,onChange:me=>N(me.target.value)}),l.jsxs("div",{className:"nc-detail-picker-list",children:[dn.length===0&&l.jsx("small",{className:"nc-set-hint",children:f("node-grant-no-candidates")}),dn.map(me=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await Ct("selected",[...e.selected||[],me.id]),L(!1),N("")},children:me.label},me.id))]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{L(!1),N("")},children:f("cancel")})]})]})]})]}),de&&l.jsxs(uo,{title:f("cell-scope"),children:[l.jsx("small",{className:"nc-set-hint",children:f("cell-scope-help")}),l.jsx("label",{className:"nc-field",children:l.jsxs("select",{value:ve,"aria-label":f("cell-scope"),disabled:s||!!u,onChange:me=>{me.target.value==="selected"&&Yt(),gn(me.target.value)},children:[l.jsx("option",{value:"all",children:f("cell-scope-all")}),l.jsx("option",{value:"none",children:f("cell-scope-none")}),l.jsx("option",{value:"selected",children:f("cell-scope-selected")})]})}),ve==="selected"&&xt.length>0&&l.jsx("small",{className:"nc-set-hint",children:f("cell-scope-reset-warning")}),K&&l.jsx("small",{className:"nc-set-hint",children:f("cell-scope-list-unavailable")}),ve==="selected"&&l.jsxs("div",{className:"nc-detail-grants",children:[xt.length===0&&l.jsx("small",{className:"nc-set-hint",children:f("cell-scope-none-granted")}),xt.map(me=>l.jsxs("div",{className:`nc-detail-grant${me.known?"":" unknown"}`,children:[l.jsxs("span",{children:[me.label,me.known?"":` — ${f("cell-scope-unknown")}`]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>gn("selected",(e.cells||[]).filter(Ge=>Ge!==me.id)),children:f("node-grant-remove")})]},me.id)),!X&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await Yt({retry:!0}),H(!0),W("")},children:f("cell-scope-add")}),X&&l.jsxs("div",{className:"nc-detail-picker",children:[l.jsx("input",{value:Q,placeholder:f("cell-scope-search"),disabled:s||!!u,onChange:me=>W(me.target.value)}),l.jsxs("div",{className:"nc-detail-picker-list",children:[Ot.length===0&&l.jsx("small",{className:"nc-set-hint",children:f("cell-scope-no-candidates")}),Ot.map(me=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await gn("selected",[...e.cells||[],me.id]),H(!1),W("")},children:me.label},me.id))]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{H(!1),W("")},children:f("cancel")})]})]})]}),b&&l.jsxs(uo,{title:f("edit"),children:[l.jsxs("label",{className:"nc-field",children:[f("node-display-label"),l.jsx("input",{value:b.label,disabled:!!u,onChange:me=>S({...b,label:me.target.value})})]}),z.inbound?l.jsxs("label",{className:"nc-field",children:[f("peer-visibility"),l.jsxs("select",{value:b.visibility,disabled:!!u,onChange:me=>S({...b,visibility:me.target.value}),children:[l.jsx("option",{value:"network",children:f("visibility-network")}),l.jsx("option",{value:"relay-only",children:f("visibility-relay")}),l.jsx("option",{value:"selected",children:f("visibility-selected")})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"nc-field",children:[f("node-ssh-label"),l.jsx("input",{value:b.ssh,disabled:!!u,onChange:me=>S({...b,ssh:me.target.value})})]}),l.jsxs("label",{className:"nc-field",children:[f("node-ssh-port-label"),l.jsx("input",{inputMode:"numeric",value:b.sshPort,disabled:!!u,onChange:me=>S({...b,sshPort:me.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:b.autostart,disabled:!!u,onChange:me=>S({...b,autostart:me.target.checked})})," ",f("boot-persist")]})]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!u,onClick:je,children:f("save")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>S(null),children:f("cancel")})]})]}),x&&l.jsxs("div",{className:"nc-set-confirm",children:[l.jsx("b",{children:f("node-remove-confirm").replace("{name}",z.title)}),l.jsx("small",{children:f("node-remove-warning")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn danger",disabled:!!u,onClick:()=>pe(`${e.name}:remove`,async()=>{await jx(n,e.name),E(!1),await o(),a&&a()}),children:f("delete")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>E(!1),children:f("cancel")})]})]}),p&&l.jsx("div",{className:"nc-err",children:p})]})}function Sp(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function Zj(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(n),o=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)o[a]=s.charCodeAt(a);return o}async function eR(){if(!Sp())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function tR(e){if(!Sp())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const n=await on("/api/push/vapid",e),{publicKey:s}=await n.json();if(!s)throw new Error("vapid non disponibile");const a=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Zj(s)}),u=await on("/api/push/subscribe",e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:a.toJSON()})});if(!u.ok){try{await a.unsubscribe()}catch{}const d=await u.json().catch(()=>({}));throw new Error(d.error||`HTTP ${u.status}`)}return!0}async function nR(e){if(!Sp())return!1;const n=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!n)return!1;const s=n.endpoint;try{await n.unsubscribe()}catch{}try{await on("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const Sf="nexuscrew.fleet",Jw=3,iR="nexuscrew.cells",Zw=/^[A-Za-z0-9._-]{1,32}$/,Oc=/^[a-z0-9._-]{1,32}$/,eS=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,tS=new Set(["standard","unsafe"]),sR=4096,rR=4096,Cc=256,nS=8192,oR=4096,aR=32,lR=64,cR=24,uR=new Set(["format","version","exportedAt","cells","engines","models"]),dR=new Set(["id","cwdRel","engine","boot","model","models","permissionPolicies","commands","systemPrompt","prompt","label","mcp"]),hR=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]);function br(e){if(typeof e!="string"||e.length>rR)return null;for(let n=0;n<e.length;n+=1){const s=e.charCodeAt(n);if(s<=31||s===127||s===92)return null}if(e==="")return"";if(e.charAt(0)==="/"||/^[A-Za-z]:/.test(e))return null;const t=[];for(const n of e.split("/"))if(!(n===""||n===".")){if(n==="..")return null;t.push(n)}return t.join("/")}const fR=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag","panelUrl"]),pR=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]),mR=new Set(["127.0.0.1","localhost","[::1]"]);function xp(e){if(typeof e!="string"||!e||e.length>512||/[\x00-\x1f\x7f]|\s/.test(e))return!1;let t;try{t=new URL(e)}catch{return!1}return!(t.protocol!=="http:"&&t.protocol!=="https:"||!mR.has(t.hostname))}function hs(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function kp(e){const t=String(e||"");return/(?:bearer\s+|authorization\s*[:=]|(?:api[_-]?key|secret|token)\s*[:=])/i.test(t)||/^-{1,2}(?:api[-_]?key|access[-_]?key|auth(?:orization)?[-_]?token|token|secret|password|credential)(?:$|=)/i.test(t)||/\b(?:sk|fw|fpk|hf|zai)[-_][A-Za-z0-9._-]{8,}\b/i.test(t)||/https?:\/\/[^\s/@:]+:[^\s/@]+@/i.test(t)}function xa(e,t){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))return null;const n=Object.entries(e);if(n.length>128)return null;const s={};for(const[o,a]of n){if(!Oc.test(o)||!t(a))return null;s[o]=a}return s}function iS(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(d=>!dR.has(d))||!Zw.test(String(e.id||""))||typeof e.cwdRel!="string")return null;const t=br(e.cwdRel);if(t===null||!Oc.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>Cc)||e.systemPrompt!==void 0&&e.prompt!==void 0&&e.systemPrompt!==e.prompt)return null;const n=e.systemPrompt===void 0?e.prompt===void 0?"":e.prompt:e.systemPrompt;if(typeof n!="string"||n.length>nS)return null;const s=xa(e.models,d=>typeof d=="string"&&!!d&&d.length<=Cc),o=xa(e.permissionPolicies,d=>tS.has(d)),a=xa(e.commands,d=>hs(d,oR)&&!kp(d));if(s===null||o===null||a===null)return null;const u={id:e.id,cwdRel:t,engine:e.engine,boot:e.boot===!0,systemPrompt:n};if(e.model&&(u.model=e.model),e.label!==void 0){if(!hs(e.label,lR)||!String(e.label).trim())return null;u.label=String(e.label).trim()}return Object.keys(s).length&&(u.models=s),Object.keys(o).length&&(u.permissionPolicies=o),Object.keys(a).length&&(u.commands=a),u}function gR(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(a=>!hR.has(a))||!Zw.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>sR||!Oc.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>Cc)||e.systemPrompt!==void 0&&e.prompt!==void 0&&e.systemPrompt!==e.prompt)return null;const t=e.systemPrompt===void 0?e.prompt===void 0?"":e.prompt:e.systemPrompt;if(typeof t!="string"||t.length>nS)return null;const n=xa(e.models,a=>typeof a=="string"&&!!a&&a.length<=Cc),s=xa(e.permissionPolicies,a=>tS.has(a));if(n===null||s===null)return null;const o={id:e.id,cwd:e.cwd,engine:e.engine,boot:e.boot===!0,systemPrompt:t};return e.model&&(o.model=e.model),Object.keys(n).length&&(o.models=n),Object.keys(s).length&&(o.permissionPolicies=s),o}function vR(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(n=>!pR.has(n)))return null;const t={};for(const[n,s]of Object.entries(e)){if(typeof s!="string"||!hs(s,n==="baseUrl"?512:128)||kp(s))return null;t[n]=s}return!t.client||!t.provider||t.envKey&&!eS.test(t.envKey)?null:t}function sS(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!fR.has(s))||!Oc.test(String(e.id||""))||!hs(e.label||e.id,64)||e.rc!==void 0&&typeof e.rc!="boolean"||e.panelUrl!==void 0&&!xp(e.panelUrl))return null;const t={id:e.id,label:e.label||e.id,rc:e.rc===!0};if(e.panelUrl!==void 0&&(t.panelUrl=e.panelUrl),e.managed!==void 0){const s=vR(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!hs(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!hs(s,1024)||kp(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!hs(e.promptFlag,32)||/\s/.test(e.promptFlag)))return null;if(e.model!==void 0){if(!e.model||typeof e.model!="object"||Array.isArray(e.model)||Object.keys(e.model).some(s=>s!=="flag"&&s!=="value")||!hs(e.model.flag,32)||/\s/.test(e.model.flag)||!hs(e.model.value||"",128))return null;t.model={flag:e.model.flag,value:e.model.value||""}}const n=e.envKeys===void 0?[]:e.envKeys;return!Array.isArray(n)||n.length>32||n.some(s=>!eS.test(s))?null:(Object.assign(t,{command:e.command,args:[...e.args],envKeys:[...new Set(n)].sort(),promptMode:e.promptMode}),e.promptMode==="flag"&&(t.promptFlag=e.promptFlag),t)}function rS(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.managed?{id:e.id,label:e.label,rc:e.rc,managed:e.managed,...e.panelUrl!==void 0?{panelUrl:e.panelUrl}:{}}:{id:e.id,label:e.label,rc:e.rc,command:e.command,args:e.args,envKeys:e.envKeys,model:e.model,promptMode:e.promptMode,promptFlag:e.promptFlag,...e.panelUrl!==void 0?{panelUrl:e.panelUrl}:{}},n=sS(t);return n||null}function _R(e,t,n){const s=new Set;for(const o of Array.isArray(t)?t:[]){if(!n.has(o.id)||!o.managed)continue;const{client:a,provider:u,credentialProfile:d}=o.managed;s.add(d?`${a}.${u}-${d}`:`${a}.${u}`),s.add(`${a}.${u}`)}return(Array.isArray(e)?e:[]).filter(o=>o&&s.has(o.engine))}function yR(e,t,n=[],s=[],o=new Date,a=[]){n instanceof Date&&(o=n,n=[],s=[]);const u=t instanceof Set?t:new Set(t||[]),d=s instanceof Set?s:new Set(s||[]),p=[];for(const y of Array.isArray(e)?e:[]){if(!u.has(y.id))continue;const b=iS({id:y.id,cwdRel:y.cwdRel,engine:y.engine,boot:y.boot===!0,...y.label?{label:y.label}:{},...y.model?{model:y.model}:{},...y.models?{models:y.models}:{},...y.permissionPolicies?{permissionPolicies:y.permissionPolicies}:{},systemPrompt:y.prompt||"",...y.commands?{commands:y.commands}:{}});if(!b)return{ok:!1,error:"invalid-cell",invalidCellIds:[y.id]};p.push(b)}const m=[];for(const y of Array.isArray(n)?n:[]){if(!d.has(y.id))continue;const b=rS(y);b&&m.push(b)}const v=_R(a,n,d);return{format:Sf,version:Jw,exportedAt:o.toISOString(),cells:p,engines:m,...v.length?{models:v}:{}}}function bR(e){let t;try{t=JSON.parse(String(e||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const n=(t==null?void 0:t.format)===iR&&(t==null?void 0:t.version)===1,s=(t==null?void 0:t.format)===Sf&&(t==null?void 0:t.version)===2,o=(t==null?void 0:t.format)===Sf&&(t==null?void 0:t.version)===Jw,a=n||s,u=s||o;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(b=>!uR.has(b))||!n&&!s&&!o||!Array.isArray(t.cells)||t.cells.length>aR||u&&(!Array.isArray(t.engines)||t.engines.length>cR))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const d=[],p=new Set;for(const b of t.cells){const S=a?gR(b):iS(b);if(!S)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(p.has(S.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};p.add(S.id),d.push(S)}const m=[],v=new Set;for(const b of u?t.engines:[]){const S=sS(b);if(!S)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(v.has(S.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};v.add(S.id),m.push(S)}const y=[];if(t.models!==void 0){if(!Array.isArray(t.models)||t.models.length>64)return{ok:!1,error:"invalid-model",cells:[],engines:[]};const b=new Set;for(const S of t.models){if(!S||typeof S!="object"||Array.isArray(S))return{ok:!1,error:"invalid-model",cells:[],engines:[]};const x=new Set(["id","engine","label","contextWindow","maxTokens","reasoning"]);if(Object.keys(S).some(C=>!x.has(C)))return{ok:!1,error:"invalid-model",cells:[],engines:[]};const E=typeof S.id=="string"?S.id.trim():"",w=typeof S.engine=="string"?S.engine.trim():"";if(!E||!w)return{ok:!1,error:"invalid-model",cells:[],engines:[]};const N=`${w}::${E}`;if(b.has(N))return{ok:!1,error:"duplicate-model",cells:[],engines:[]};b.add(N),y.push({...S,id:E,engine:w})}}return{ok:!0,cells:d,engines:m,models:y,legacy:a,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function wR(e,t,n){const s=new Set(n||[]);if(!s.has(t))return null;const o=m=>Object.fromEntries(Object.entries(m||{}).filter(([v])=>s.has(v))),a={id:e.id,engine:t,boot:e.boot===!0,prompt:e.systemPrompt||""};typeof e.label=="string"&&e.label&&(a.label=e.label),typeof e.cwdRel=="string"?a.cwdRel=e.cwdRel:typeof e.cwd=="string"&&e.cwd&&(a.cwd=e.cwd),t===e.engine&&e.model?a.model=e.model:e.models&&e.models[t]&&(a.model=e.models[t]);const u=o(e.models),d=o(e.permissionPolicies),p=o(e.commands);return Object.keys(u).length&&(a.models=u),Object.keys(d).length&&(a.permissionPolicies=d),Object.keys(p).length&&(a.commands=p),a}const SR=()=>({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:""}),Ey=(e="")=>({id:"",cwd:"",engine:e,boot:!1,label:"",model:"",prompt:"",commands:{},command:"",panelUrl:""}),oS=e=>e==="claude"?"unsafe":"standard",ja=(e,t)=>e.find(n=>n.client===t.client&&n.provider===t.provider&&(n.credentialProfile||"")===(t.credentialProfile||"")),xR=(e,t)=>{var n;return((n=ja(e,t))==null?void 0:n.label)||`${t.client} · ${t.provider}`};function kR(e){var t,n,s,o,a,u,d,p,m,v,y,b,S,x,E;return{kind:e.managed?"managed":"custom",id:e.id,label:e.label||"",command:e.command||"",argsText:(e.args||[]).join(`
89
- `),rc:!!e.rc,client:((t=e.managed)==null?void 0:t.client)||"claude",provider:((n=e.managed)==null?void 0:n.provider)||"native",credentialProfile:((s=e.managed)==null?void 0:s.credentialProfile)||"",managedModel:((o=e.managed)==null?void 0:o.model)||"",permissionPolicy:((a=e.managed)==null?void 0:a.permissionPolicy)||oS((u=e.managed)==null?void 0:u.client),credentialSourcePolicy:((d=e.managed)==null?void 0:d.credentialSourcePolicy)||"auto",displayName:((p=e.managed)==null?void 0:p.displayName)||"",protocol:((m=e.managed)==null?void 0:m.protocol)||"",baseUrl:((v=e.managed)==null?void 0:v.baseUrl)||"",envKey:((y=e.managed)==null?void 0:y.envKey)||"",providerId:((b=e.managed)==null?void 0:b.providerId)||"nexuscrew-custom",modelOptions:e.availableModels||((S=e.managedInfo)==null?void 0:S.models)||[],promptMode:e.promptMode||"send-keys",promptFlag:e.promptFlag||"",modelFlag:((x=e.model)==null?void 0:x.flag)||"",modelValue:((E=e.model)==null?void 0:E.value)||"",envRows:(e.envKeys||[]).map(w=>({key:w,value:"",configured:!0,remove:!1})),credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,panelUrl:e.panelUrl||""}}function Ny(e,t,n){const s=(t.panelUrl||"").trim();return n?s&&(e.panelUrl=s):e.panelUrl=s||null,e}function CR(e,t,n=[]){if(e.kind==="managed"){const o={client:e.client,provider:e.provider,model:e.client==="shell"?"":e.managedModel||"",permissionPolicy:e.client==="shell"?"standard":e.permissionPolicy||oS(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile),e.credentialSourcePolicy&&e.credentialSourcePolicy!=="auto"&&(o.credentialSourcePolicy=e.credentialSourcePolicy);const a=ja(n,e);return(a==null?void 0:a.credentialEnv)===!0&&(o.envKey=e.envKey),e.provider==="custom"&&Object.assign(o,{displayName:e.displayName,protocol:e.protocol,baseUrl:e.baseUrl,envKey:e.envKey,providerId:e.providerId}),Ny({...t?{id:e.id}:{},label:e.label||xR(n,e),rc:!!e.rc,managed:o},e,t)}const s={...t?{id:e.id}:{},label:e.label||e.id,rc:!!e.rc,command:e.command,args:e.argsText.split(`
90
- `).filter(o=>o!==""),promptMode:e.promptMode};return e.modelFlag&&(s.model={flag:e.modelFlag,value:e.modelValue||""}),e.promptMode==="flag"&&(s.promptFlag=e.promptFlag),t&&(s.env=Object.fromEntries(e.envRows.filter(o=>!o.remove&&o.key).map(o=>[o.key,o.value]))),Ny(s,e,t)}function Hs({children:e,onClose:t,label:n,error:s=""}){const o=k.useRef(null),a=k.useRef(null),u=k.useRef(t);return u.current=t,k.useEffect(()=>{const d=document.activeElement,p=o.current,m=()=>Array.from((p==null?void 0:p.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))||[]).filter(b=>b.offsetParent!==null),v=requestAnimationFrame(()=>{var b;return(b=m()[0]||p)==null?void 0:b.focus({preventScroll:!0})}),y=b=>{var w;if(b.key==="Escape"){b.preventDefault(),(w=u.current)==null||w.call(u);return}if(b.key!=="Tab")return;const S=m();if(!S.length){b.preventDefault(),p==null||p.focus();return}const x=S[0],E=S[S.length-1];b.shiftKey&&document.activeElement===x?(b.preventDefault(),E.focus()):!b.shiftKey&&document.activeElement===E&&(b.preventDefault(),x.focus())};return document.addEventListener("keydown",y),()=>{cancelAnimationFrame(v),document.removeEventListener("keydown",y),d&&d.isConnected&&typeof d.focus=="function"&&d.focus({preventScroll:!0})}},[]),k.useEffect(()=>{s&&requestAnimationFrame(()=>{var d;return(d=a.current)==null?void 0:d.scrollIntoView({block:"nearest"})})},[s]),l.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:d=>{d.target===d.currentTarget&&t()},children:l.jsxs("div",{ref:o,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":n||f("settings"),tabIndex:-1,children:[e,s&&l.jsx("div",{ref:a,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:s})]})})}function dh({token:e,targets:t=[],readonly:n=!1,onPower:s,onImport:o}){const[a,u]=k.useState([]),[d,p]=k.useState(0);k.useEffect(()=>{let w=!0;async function N(){const L=[{route:[],label:f("local")}].concat((t||[]).map(G=>({route:Array.isArray(G.route)?G.route:[],label:G.label||(G.route||[]).join(" › ")}))),I=await Promise.all(L.map(async G=>{const K={...G,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const Y=await Xs(e,G.route);K.available=!!Y.available,K.capabilities=Y.capabilities||[],K.provider=Y.provider||null,K.cells=(Y.cells||[]).map(Q=>({...Q,route:G.route}));try{K.readonly=!!(await Df(e,G.route)).readonlyDefault}catch{}try{const Q=await Tf(e,G.route),W=new Set(K.cells.map(X=>X.tmuxSession).filter(Boolean));K.unmanaged=(Q.sessions||[]).filter(X=>X&&!W.has(X.name))}catch{}}catch(Y){K.err=String(Y&&Y.message||Y)}return K}));w&&u(I)}N();const C=setInterval(N,6e3);return()=>{w=!1,clearInterval(C)}},[e,t,d]);const m=(w,N)=>Array.isArray(w.capabilities)&&w.capabilities.includes(N)&&!n&&!w.readonly,v=()=>p(w=>w+1),y=(w,N)=>{s&&s({...w,route:N})},b=(w,N)=>{s&&s({...w,route:N})},S=async(w,N)=>{try{await fa(e,w.cell,N)}catch{}v()},x=async(w,N)=>{if(window.confirm(f("fleet-remove-cell").replace("{id}",w.cell))){try{await Uy(e,w.cell,!0,N)}catch{}v()}},E=async(w,N)=>{if(window.confirm(f("terminate-confirm").replace("{name}",w.name))){try{await Af(e,w.name,N)}catch{}v()}};return l.jsxs("div",{className:"nc-fleet-inventory",children:[l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:f("fleet-inventory")}),l.jsx("small",{children:f("fleet-inventory-help")})]}),a.map(w=>{const N=w.route.length?w.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 ${w.available?"on":"warn"}`}),l.jsx("b",{children:w.label}),l.jsx("small",{children:w.available?`${w.cells.length} ${f("fleet-cells")} · ${w.unmanaged.length} ${f("fleet-tmux")}`:w.err||f("fleet-not-available")})]}),w.cells.map(C=>l.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[l.jsxs("span",{children:[l.jsx("b",{children:C.cell}),l.jsx("small",{children:`${C.engine||""}${C.key?`·${C.key}`:""}${C.active?"":` · ${f("cell-off")}`}`})]}),l.jsxs("span",{className:"nc-fleet-cell-actions",children:[C.active&&m(w,"down")&&l.jsx("button",{className:"nc-btn ghost",title:f("power-off"),onClick:()=>b(C,w.route),children:f("stop")}),!C.active&&m(w,"up")&&l.jsx("button",{className:"nc-btn ghost",title:f("power-on"),onClick:()=>y(C,w.route),children:f("start")}),m(w,"restart")&&C.active&&l.jsx("button",{className:"nc-btn ghost",title:f("restart"),onClick:()=>S(C,w.route),children:f("restart")}),m(w,"remove")&&l.jsx("button",{className:"nc-btn danger",title:f("delete"),onClick:()=>x(C,w.route),children:"×"})]})]},`${N}:${C.cell}`)),w.unmanaged.map(C=>l.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[l.jsxs("span",{children:[l.jsx("b",{children:C.name}),l.jsx("small",{children:f("fleet-tmux")})]}),l.jsxs("span",{className:"nc-fleet-cell-actions",children:[m(w,"import")&&o&&l.jsx("button",{className:"nc-btn ghost",title:f("import-as-cell"),onClick:()=>o(C,w.route),children:f("import-as-cell")}),l.jsx("button",{className:"nc-btn danger",title:f("terminate"),onClick:()=>E(C,w.route),children:"×"})]})]},`${N}:u:${C.name}`)),w.available&&w.cells.length===0&&w.unmanaged.length===0&&l.jsx("div",{className:"nc-empty",children:f("fleet-inventory-empty")})]},N)})]})}function ER({cells:e=[],engines:t=[],models:n=[],busy:s,canRestore:o=!1,onRestore:a,onClose:u}){const[d,p]=k.useState("export"),[m,v]=k.useState([]),[y,b]=k.useState(()=>new Set(e.map(A=>A.id))),[S,x]=k.useState(()=>new Set(t.map(A=>A.id))),[E,w]=k.useState([]),[N,C]=k.useState([]),[L,I]=k.useState(""),G=new Set(t.map(A=>A.id)),K=new Set(e.map(A=>A.id)),Y=(A,T)=>A(j=>{const z=new Set(j);return z.has(T)?z.delete(T):z.add(T),z}),Q=()=>{const A=yR(e,y,t,S,new Date,n);if(A.ok===!1){I(f(`fleet-backup-${A.error}`));return}const T=e.filter(B=>y.has(B.id)).length,j=t.filter(B=>S.has(B.id)).length;if(A.cells.length!==T){I(f("fleet-backup-invalid-cell"));return}if(A.engines.length!==j){I(f("fleet-backup-invalid-engine"));return}if(!A.cells.length&&!A.engines.length){I(f("fleet-backup-select-one"));return}const z=new Blob([`${JSON.stringify(A,null,2)}
91
- `],{type:"application/json"}),M=URL.createObjectURL(z),D=document.createElement("a");D.href=M,D.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(D),D.click(),D.remove(),setTimeout(()=>URL.revokeObjectURL(M),0),I("")},W=async A=>{if(I(""),w([]),C([]),!!A){if(A.size>1024*1024){I(f("fleet-backup-too-large"));return}try{const T=bR(await A.text());if(!T.ok){I(f(`fleet-backup-${T.error}`));return}v(Array.isArray(T.models)?T.models:[]);const j=new Set(T.engines.map(z=>z.id));C(T.engines.map(z=>({engine:z,exists:G.has(z.id),selected:!G.has(z.id)}))),w(T.cells.map(z=>{const M=G.has(z.engine)||j.has(z.engine),D=K.has(z.id);return{cell:z,engine:M?z.engine:"",selected:M&&!D,exists:D}}))}catch(T){I(String(T.message||T))}}},X=(A,T)=>w(j=>j.map((z,M)=>M===A?{...z,...T}:z)),H=(A,T)=>C(j=>j.map((z,M)=>M===A?{...z,...T}:z)),$=new Set([...G,...N.filter(A=>A.selected).map(A=>A.engine.id)]),R=E.filter(A=>A.selected&&A.engine&&$.has(A.engine)),O=N.filter(A=>A.selected),F=[...new Map([...t.map(A=>[A.id,A.label||A.id]),...N.filter(A=>A.selected).map(A=>[A.engine.id,A.engine.label||A.engine.id])]).entries()];return l.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[l.jsx("b",{children:f("fleet-backup")}),l.jsx("small",{children:f("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:()=>{p("export"),I("")},children:f("fleet-backup-export")}),l.jsx("button",{type:"button",className:`nc-set-tabbtn${d==="import"?" on":""}`,disabled:!o,title:o?"":f("fleet-backup-restore-unavailable"),onClick:()=>{p("import"),I("")},children:f("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:()=>{b(new Set(e.map(A=>A.id))),x(new Set(t.map(A=>A.id)))},children:f("select-all")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{b(new Set),x(new Set)},children:f("select-none")})]}),l.jsxs("div",{className:"nc-backup-list",children:[l.jsx("b",{children:f("fleet-engines")}),t.map(A=>{var T;return l.jsxs("label",{className:"nc-check nc-backup-row",children:[l.jsx("input",{type:"checkbox",checked:S.has(A.id),onChange:()=>Y(x,A.id)}),l.jsxs("span",{children:[l.jsx("b",{children:A.label||A.id}),l.jsxs("small",{children:[A.id,(T=A.envKeys)!=null&&T.length?` · ${A.envKeys.length} ${f("fleet-backup-env-names")}`:""]})]})]},A.id)}),l.jsx("b",{children:f("fleet-cells")}),e.map(A=>l.jsxs("label",{className:"nc-check nc-backup-row",children:[l.jsx("input",{type:"checkbox",checked:y.has(A.id),onChange:()=>Y(b,A.id)}),l.jsxs("span",{children:[l.jsx("b",{children:A.id}),l.jsxs("small",{children:[A.engine," · ",f("fleet-system-prompt")," ",(A.prompt||"").length," ",f("characters")]})]})]},A.id)),!e.length&&!t.length&&l.jsx("div",{className:"nc-empty",children:f("fleet-backup-empty")})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:u,children:f("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!y.size&&!S.size,onClick:Q,children:f("fleet-backup-download")})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{type:"file",accept:"application/json,.json",disabled:s,onChange:A=>W(A.target.files&&A.target.files[0])}),l.jsx("small",{children:f("fleet-backup-import-help")}),!!(E.length||N.length)&&l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{C(A=>A.map(T=>({...T,selected:!0}))),w(A=>A.map(T=>({...T,selected:!!T.engine})))},children:f("select-all")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{C(A=>A.map(T=>({...T,selected:!1}))),w(A=>A.map(T=>({...T,selected:!1})))},children:f("select-none")})]}),l.jsxs("div",{className:"nc-backup-list",children:[!!N.length&&l.jsx("b",{children:f("fleet-engines")}),N.map((A,T)=>{var j;return l.jsx("div",{className:"nc-backup-import-row",children:l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:A.selected,onChange:z=>H(T,{selected:z.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:A.engine.label||A.engine.id}),l.jsxs("small",{children:[A.engine.id," · ",A.exists?f("fleet-backup-overwrite"):f("fleet-backup-new"),(j=A.engine.envKeys)!=null&&j.length?` · ${f("fleet-backup-env-values-required")}`:""]})]})]})},A.engine.id)}),!!E.length&&l.jsx("b",{children:f("fleet-cells")}),E.map((A,T)=>l.jsxs("div",{className:"nc-backup-import-row",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:A.selected,disabled:!A.engine||!$.has(A.engine),onChange:j=>X(T,{selected:j.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:A.cell.id}),l.jsxs("small",{children:[A.exists?f("fleet-backup-overwrite"):f("fleet-backup-new")," · ",f("fleet-system-prompt")," ",A.cell.systemPrompt.length," ",f("characters")]})]})]}),l.jsxs("select",{value:A.engine,onChange:j=>X(T,{engine:j.target.value,selected:!!j.target.value}),children:[l.jsx("option",{value:"",children:f("fleet-backup-engine-missing")}),F.map(([j,z])=>l.jsx("option",{value:j,children:z},j))]})]},A.cell.id))]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:u,children:f("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:s||!R.length&&!O.length,onClick:()=>a({engineRows:N,cellRows:E,models:m}),children:f("fleet-backup-restore")})]})]}),L&&l.jsx("div",{className:"nc-err",children:L})]})}function NR({state:e,setState:t,busy:n,onSave:s,catalog:o}){var N;const a=e.form,u=C=>t({...e,form:{...a,...C}}),d=a.envRows||[],p=[...new Map(o.map(C=>[C.client,C.clientLabel||C.client])).entries()],m=o.filter(C=>C.client===a.client),v=ja(o,a),y=typeof(v==null?void 0:v.credentialEnv)=="string"?v.credentialEnv:"",b=Array.isArray(v==null?void 0:v.credentialUsedBy)?v.credentialUsedBy:[],S=(v==null?void 0:v.credentialSource)||"missing",x=!!(v!=null&&v.credentialEnv)||a.credentialProfile==="a"||a.credentialProfile==="p",E=!!y&&e.mode==="new"&&(v==null?void 0:v.authConfigured)!==!0&&!a.credentialValue&&!a.allowMissingCredential,w=C=>{C&&u({client:C.client,provider:C.provider,credentialProfile:C.credentialProfile||"",managedModel:C.model||"",protocol:C.protocol||"",permissionPolicy:C.permissionPolicyDefault||"standard",credentialSourcePolicy:"auto",rc:!!C.rc,displayName:C.custom?f("fleet-custom-provider-default"):"",baseUrl:C.custom?"":C.endpoint||"",envKey:C.defaultEnvKey||"",providerId:"nexuscrew-custom",credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,...e.mode==="new"?{id:C.id,label:""}:{}})};return l.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[l.jsx("b",{children:e.mode==="new"?f("fleet-new-engine"):`${f("edit")} ${a.id}`}),l.jsx("input",{value:a.id,disabled:e.mode!=="new",placeholder:"id",onChange:C=>u({id:C.target.value})}),l.jsx("input",{value:a.label,placeholder:f("label"),onChange:C=>u({label:C.target.value})}),l.jsxs("select",{value:a.kind,disabled:e.mode!=="new",onChange:C=>u({kind:C.target.value}),children:[l.jsx("option",{value:"managed",children:f("fleet-managed")}),l.jsx("option",{value:"custom",children:f("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:e.mode!=="new",onChange:C=>w(o.find(L=>L.client===C.target.value&&L.default)||o.find(L=>L.client===C.target.value)),children:p.map(([C,L])=>l.jsx("option",{value:C,children:L},C))}),l.jsx("select",{value:((N=ja(o,a))==null?void 0:N.id)||"",disabled:e.mode!=="new",onChange:C=>w(o.find(L=>L.id===C.target.value)),children:m.map(C=>l.jsx("option",{value:C.id,children:C.label},C.id))})]}),a.client!=="shell"&&l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.managedModel,list:"nc-managed-models",placeholder:f(v!=null&&v.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:C=>u({managedModel:C.target.value})}),l.jsx("datalist",{id:"nc-managed-models",children:[...(v==null?void 0:v.models)||[],...a.modelOptions||[]].filter((C,L,I)=>C&&I.indexOf(C)===L).map(C=>l.jsx("option",{value:C},C))})]}),v!=null&&v.supportsUnsafe?l.jsxs("select",{value:a.permissionPolicy,onChange:C=>u({permissionPolicy:C.target.value}),children:[l.jsx("option",{value:"standard",children:f("fleet-standard-permissions")}),l.jsx("option",{value:"unsafe",children:f("fleet-unsafe-permissions")})]}):l.jsx("small",{children:f("fleet-standard-permissions")}),(v==null?void 0:v.supportsUnsafe)&&a.permissionPolicy==="unsafe"&&l.jsx("small",{className:"nc-err",children:f("fleet-unsafe-warning")}),x&&l.jsxs("select",{"aria-label":f("fleet-credential-source-policy"),value:a.credentialSourcePolicy||"auto",onChange:C=>u({credentialSourcePolicy:C.target.value}),children:[l.jsx("option",{value:"auto",children:f("fleet-credential-source-policy-auto")}),l.jsx("option",{value:"nexuscrew-store",children:f("fleet-credential-source-policy-nexuscrew-store")}),l.jsx("option",{value:"environment",children:f("fleet-credential-source-policy-environment")})]}),(v==null?void 0:v.credentialEnv)===!0&&l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.envKey,placeholder:f("fleet-api-key-env"),onChange:C=>u({envKey:C.target.value})}),l.jsx("small",{children:f("fleet-custom-secret-help")})]}),y&&l.jsxs("section",{className:"nc-fleet-key","aria-label":f("fleet-key-section"),children:[l.jsxs("div",{className:"nc-fleet-key-head",children:[l.jsx("b",{children:f("fleet-key-section")}),l.jsx("span",{children:f(`fleet-credential-source-${S}`)})]}),l.jsxs("label",{className:"nc-field",children:[f("fleet-key-variable"),l.jsx("input",{value:y,readOnly:!0,"aria-label":f("fleet-key-variable")})]}),l.jsx("small",{children:b.length?f("fleet-key-used-by").replace("{engines}",b.join(", ")):f("fleet-key-used-by-none")}),b.length>0&&l.jsx("small",{children:f("fleet-key-shared-impact").replace("{key}",y).replace("{engines}",b.join(", "))}),l.jsxs("div",{className:"nc-fleet-key-input",children:[l.jsx("input",{type:a.credentialReveal?"text":"password",value:a.credentialValue||"","aria-label":f("fleet-key-value").replace("{key}",y),autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:v!=null&&v.authConfigured||e.mode==="edit"?f("fleet-key-blank-keeps"):f("fleet-key-enter"),onChange:C=>u({credentialValue:C.target.value,allowMissingCredential:C.target.value?!1:a.allowMissingCredential})}),l.jsx("button",{type:"button",className:"nc-btn ghost","aria-label":f(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal"),onClick:()=>u({credentialReveal:!a.credentialReveal}),children:f(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal")})]}),l.jsx("small",{children:f("fleet-key-local-help")}),e.mode==="new"&&(v==null?void 0:v.authConfigured)!==!0&&!a.credentialValue&&l.jsxs("label",{className:"nc-check nc-fleet-key-missing",children:[l.jsx("input",{type:"checkbox",checked:!!a.allowMissingCredential,onChange:C=>u({allowMissingCredential:C.target.checked})}),f("fleet-key-create-missing")]}),(v==null?void 0:v.notice)&&l.jsx("small",{className:"nc-fleet-provider-notice",children:f(`fleet-provider-notice-${v.notice}`)})]}),(v==null?void 0:v.notice)&&!y&&l.jsx("small",{className:"nc-fleet-provider-notice",children:f(`fleet-provider-notice-${v.notice}`)}),a.provider==="custom"&&l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.displayName,placeholder:f("fleet-provider-display"),onChange:C=>u({displayName:C.target.value})}),l.jsx("input",{value:a.baseUrl,placeholder:"https://api.example.com/v1",onChange:C=>u({baseUrl:C.target.value})}),((v==null?void 0:v.protocols)||[]).length>1&&l.jsx("select",{value:a.protocol,onChange:C=>u({protocol:C.target.value}),children:v.protocols.map(C=>l.jsx("option",{value:C,children:C},C))}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:a.envKey,placeholder:f("fleet-api-key-env"),onChange:C=>u({envKey:C.target.value})}),l.jsx("input",{value:a.providerId,placeholder:f("fleet-provider-id"),onChange:C=>u({providerId:C.target.value})})]}),l.jsxs("small",{children:[a.protocol," · ",f("fleet-custom-secret-help")]})]}),l.jsx("small",{children:f(a.client==="shell"?"fleet-shell-engine-help":"fleet-managed-help")})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.command,placeholder:f("command-path"),onChange:C=>u({command:C.target.value})}),l.jsx("textarea",{value:a.argsText,placeholder:f("args-lines"),onChange:C=>u({argsText:C.target.value})}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:a.rc,onChange:C=>u({rc:C.target.checked})})," ",f("fleet-remote-control")]}),l.jsxs("select",{value:a.promptMode,onChange:C=>u({promptMode:C.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:C=>u({promptFlag:C.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:a.modelFlag,placeholder:"model flag",onChange:C=>u({modelFlag:C.target.value})}),l.jsx("input",{value:a.modelValue,placeholder:"model default",onChange:C=>u({modelValue:C.target.value})})]}),l.jsx("small",{children:f("env-write-only")}),d.map((C,L)=>l.jsxs("div",{className:"nc-fleet-env",children:[l.jsx("input",{value:C.key,disabled:C.configured,placeholder:"ENV_KEY",onChange:I=>{const G=d.slice();G[L]={...C,key:I.target.value},u({envRows:G})}}),l.jsx("input",{type:"password",value:C.value,placeholder:C.configured?"•••••• (unchanged)":"value",onChange:I=>{const G=d.slice();G[L]={...C,value:I.target.value},u({envRows:G})}}),l.jsx("button",{className:"nc-btn danger",onClick:()=>u({envRows:d.filter((I,G)=>G!==L)}),children:"×"})]},`${C.key}-${L}`)),l.jsx("button",{className:"nc-btn ghost",onClick:()=>u({envRows:[...d,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),l.jsx("input",{value:a.panelUrl||"",maxLength:512,placeholder:f("fleet-panel-url"),onChange:C=>u({panelUrl:C.target.value})}),l.jsx("small",{children:f("fleet-panel-url-help")}),a.panelUrl&&!xp(a.panelUrl)&&l.jsx("small",{className:"nc-err",children:f("fleet-panel-url-invalid")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>t(null),children:f("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:n||!a.id||E||a.kind==="custom"&&!a.command||a.kind==="managed"&&(v==null?void 0:v.requiresModel)&&!a.managedModel||a.kind==="managed"&&(v==null?void 0:v.credentialEnv)===!0&&!a.envKey||a.kind==="managed"&&a.provider==="custom"&&(!a.displayName||!a.baseUrl||!a.envKey||!a.providerId),onClick:s,children:f("save")})]})]})}function jR({state:e,setState:t,busy:n,onSave:s,onTest:o,profiles:a=[],canTest:u=!0}){const[d,p]=k.useState(null),[m,v]=k.useState(!1),y=e.form,b=w=>t({...e,form:{...y,...w}}),S=/^[^\x00-\x1f\x7f]{1,128}$/.test(y.id||""),x=!!(y.id||"").trim()&&!!(y.engine||"").trim()&&S,E=async()=>{p(null),v(!0);try{p(await o(y.engine,y.id))}catch(w){p({outcome:"unverified",detail:String(w&&w.message||w)})}v(!1)};return l.jsxs("div",{className:"nc-fleet-form",children:[l.jsxs("label",{className:"nc-field",children:[f("model-editor-engine"),l.jsxs("select",{value:y.engine||"",disabled:n||e.mode==="edit",onChange:w=>{p(null),b({engine:w.target.value})},children:[l.jsx("option",{value:"",children:"—"}),a.map(w=>l.jsx("option",{value:w.id,children:w.label?`${w.id} · ${w.label}`:w.id},w.id))]})]}),l.jsxs("label",{className:"nc-field",children:[f("model-editor-id"),l.jsx("input",{value:y.id||"",disabled:n||e.mode==="edit",placeholder:"qwen3.9-max",onChange:w=>{p(null),b({id:w.target.value})}})]}),l.jsx("small",{className:"nc-set-hint",children:f("model-editor-id-help")}),l.jsxs("label",{className:"nc-field",children:[f("model-editor-context"),l.jsx("input",{inputMode:"numeric",value:y.contextWindow||"",disabled:n,onChange:w=>b({contextWindow:w.target.value.replace(/[^0-9]/g,"").slice(0,9)})})]}),l.jsxs("label",{className:"nc-field",children:[f("model-editor-max-tokens"),l.jsx("input",{inputMode:"numeric",value:y.maxTokens||"",disabled:n,onChange:w=>b({maxTokens:w.target.value.replace(/[^0-9]/g,"").slice(0,9)})})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:y.reasoning===!0,disabled:n,onChange:w=>b({reasoning:w.target.checked})})," ",f("model-editor-reasoning")]}),l.jsxs("div",{className:"nc-set-row",children:[u&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||m||!x,onClick:E,children:f(m?"model-test-running":"model-test")}),d&&l.jsxs("span",{className:`nc-model-test ${d.outcome}`,children:[f(`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:f("model-test-unverified-help")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>t(null),children:f("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||!x,onClick:()=>s(y),children:f("save")})]})]})}function RR({token:e,route:t,targets:n=[],location:s,setLocation:o,state:a,setState:u,engines:d,mcpServers:p=[],managedCatalog:m=[],busy:v,onSave:y}){var O,F,A;const[b,S]=k.useState(null),[x,E]=k.useState(""),w=a.form,N=T=>u({...a,form:{...w,...T}}),C=d.find(T=>T.id===w.engine),L=((O=C==null?void 0:C.managed)==null?void 0:O.client)==="shell",I=((F=C==null?void 0:C.managed)==null?void 0:F.client)||"",G=((A=m.find(T=>T.client===I))==null?void 0:A.mcpManaged)!==!1,K=T=>{var M,D,B,U;const j=d.find(se=>se.id===T),z={...w.commands||{}};((M=C==null?void 0:C.managed)==null?void 0:M.client)==="shell"&&(w.command?z[w.engine]=w.command:delete z[w.engine]),N({engine:T,model:((D=w.models)==null?void 0:D[T])||((B=j==null?void 0:j.managed)==null?void 0:B.model)||((U=j==null?void 0:j.model)==null?void 0:U.value)||"",commands:z,command:z[T]||""})},Y=T=>{const j={...w.commands||{}};T?j[w.engine]=T:delete j[w.engine],N({command:T,commands:j})},Q=L&&/[|&;<>()`$*?{}\[\]~]/.test(w.command||""),W=[...new Set([...p||[],...Array.isArray(w.mcp)?w.mcp:[]])].sort(),X=Array.isArray(w.mcp)?w.mcp.length?"some":"none":"all",H=T=>{var j;return N({mcp:T==="all"?void 0:T==="none"?[]:(j=w.mcp)!=null&&j.length?w.mcp:[...W]})},$=T=>{const j=Array.isArray(w.mcp)?w.mcp:[];N({mcp:j.includes(T)?j.filter(z=>z!==T):[...j,T].sort()})},R=async T=>{try{const j=await Mf(e,T,t);S(j),N({cwd:j.path}),E("")}catch(j){E(String(j.message||j))}};return l.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[l.jsx("b",{children:a.mode==="new"?f("fleet-new-cell"):`${f("edit")} ${w.id}`}),a.mode==="new"&&l.jsxs("label",{className:"nc-field",children:[f("location"),l.jsx("span",{className:"nc-req",children:" *"}),l.jsxs("select",{value:s,onChange:T=>{o(T.target.value),N({engine:""})},children:[l.jsx("option",{value:"",children:f("local")}),n.map(T=>l.jsxs("option",{value:T.route.join("/"),disabled:T.status&&T.status!=="up",children:[T.label,T.status&&T.status!=="up"?` · ${f("node-offline")}`:""]},T.route.join("/")))]})]}),l.jsx("input",{value:w.id,disabled:a.mode!=="new",placeholder:"id",onChange:T=>N({id:T.target.value})}),l.jsx("input",{value:w.label||"",maxLength:64,placeholder:f("fleet-cell-label"),onChange:T=>N({label:T.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:w.cwd,placeholder:f("cwd"),onChange:T=>N({cwd:T.target.value})}),l.jsx("button",{className:"nc-btn ghost",onClick:()=>b?S(null):R(w.cwd),children:f("browse")})]}),b&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:b.path}),l.jsxs("div",{className:"nc-fs-list",children:[b.parent&&l.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>R(b.parent),children:["↑ ",f("fs-parent")]}),(b.dirs||[]).map(T=>l.jsxs("button",{className:"nc-fs-item",onClick:()=>R(`${b.path.replace(/\/$/,"")}/${T}`),children:["📁 ",T]},T))]})]}),x&&l.jsx("div",{className:"nc-err",children:x}),l.jsx("select",{value:w.engine,onChange:T=>K(T.target.value),children:d.map(T=>l.jsx("option",{value:T.id,children:T.label},T.id))}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:!!w.boot,onChange:T=>N({boot:T.target.checked})})," ",f("fleet-boot")]}),l.jsx("input",{value:w.panelUrl||"",maxLength:512,placeholder:f("fleet-panel-url"),onChange:T=>N({panelUrl:T.target.value})}),l.jsx("small",{children:f("fleet-panel-url-help")}),w.panelUrl&&!xp(w.panelUrl)&&l.jsx("small",{className:"nc-err",children:f("fleet-panel-url-invalid")}),L?l.jsxs(l.Fragment,{children:[l.jsx("input",{value:w.command||"",maxLength:4096,placeholder:f("fleet-shell-command-placeholder"),onChange:T=>Y(T.target.value)}),l.jsx("small",{children:w.command?f("fleet-shell-command-help"):f("fleet-shell-interactive")}),Q&&l.jsx("small",{className:"nc-note",children:f("fleet-shell-command-metachar")})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{value:w.model||"",list:"nc-cell-models",placeholder:f("fleet-model-override"),onChange:T=>N({model:T.target.value})}),l.jsx("datalist",{id:"nc-cell-models",children:((C==null?void 0:C.availableModels)||[]).map(T=>l.jsx("option",{value:T},T))}),l.jsx("textarea",{value:w.prompt||"",placeholder:f("cell-prompt"),onChange:T=>N({prompt:T.target.value})}),l.jsx("small",{children:f("cell-prompt-help")}),l.jsxs("label",{className:"nc-field",children:[f("cell-mcp"),l.jsxs("select",{value:X,onChange:T=>H(T.target.value),children:[l.jsx("option",{value:"all",children:f("cell-mcp-all")}),l.jsx("option",{value:"none",children:f("cell-mcp-none")}),l.jsx("option",{value:"some",children:f("cell-mcp-some")})]})]}),!G&&l.jsx("small",{className:"nc-note",children:f("cell-mcp-inert")}),X==="some"&&l.jsx("div",{className:"nc-fleet-mcp-list",children:W.map(T=>l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:(w.mcp||[]).includes(T),onChange:()=>$(T)})," ",T]},T))}),l.jsx("small",{children:f("cell-mcp-help")})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>u(null),children:f("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:v||!w.id||!w.cwd||!w.engine,onClick:y,children:f("save")})]})]})}function jy({token:e,route:t=[],state:n,setState:s,busy:o,onSave:a}){const[u,d]=k.useState(null),[p,m]=k.useState([]),[v,y]=k.useState(""),b=Array.isArray(t)?t.join("/"):"";k.useEffect(()=>{let N=!0;return Ec(e,b?b.split("/"):[]).then(C=>{N&&(m(C.engines||[]),y(""))}).catch(C=>{N&&(m([]),y(String(C.message||C)))}),()=>{N=!1}},[e,b]);const S=n.form,x=N=>s({...n,form:{...S,...N}}),E=async N=>{try{const C=await Mf(e,N,t);d(C),x({cwd:C.path})}catch{}},w=!S.id&&S.tmuxSession?S.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):S.id;return l.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[l.jsxs("b",{children:[f("import-as-cell")," · ",S.tmuxSession]}),l.jsx("small",{children:f("import-help")}),l.jsx("input",{value:S.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),l.jsx("input",{value:S.id,placeholder:f("name"),onChange:N=>x({id:N.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:S.cwd,placeholder:f("cwd"),onChange:N=>x({cwd:N.target.value})}),l.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>u?d(null):E(S.cwd),children:f("browse")})]}),u&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:u.path}),l.jsxs("div",{className:"nc-fs-list",children:[u.parent&&l.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>E(u.parent),children:["↑ ",f("fs-parent")]}),(u.dirs||[]).map(N=>l.jsxs("button",{className:"nc-fs-item",onClick:()=>E(`${u.path.replace(/\/$/,"")}/${N}`),children:["📁 ",N]},N))]})]}),l.jsxs("select",{value:S.engine,onChange:N=>x({engine:N.target.value}),children:[l.jsx("option",{value:"",children:f("import-engine-required")}),p.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:!!S.boot,onChange:N=>x({boot:N.target.checked})})," ",f("fleet-boot")]}),(n.err||v)&&l.jsx("div",{className:"nc-err",children:n.err||v}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:f("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:o||!S.tmuxSession||!S.engine||!p.length,onClick:a,children:f(w?"import-as-cell":"save")})]})]})}function Jl(e){const t=br(e);return t===null?`~/${e}`:t?`~/${t}`:"~"}function PR(e){if(!e||typeof e.path!="string"||typeof e.home!="string")return"";const{path:t,home:n}=e;return!n||t===n||!t.startsWith(n+"/")?"":t.slice(n.length+1).replace(/\/+$/,"")}function LR({token:e,route:t,cell:n,busy:s=!1,onSaved:o,onClose:a}){const[u,d]=k.useState(""),[p,m]=k.useState(null),[v,y]=k.useState(!1),[b,S]=k.useState(""),x=typeof(n==null?void 0:n.cwdSuggestion)=="string"&&br(n.cwdSuggestion)!==null?br(n.cwdSuggestion):null,[E,w]=k.useState(x),N=n==null?void 0:n.id,C=s||v,L=async W=>{const X=br(W);if(X===null){m({rel:"",dirs:[],loading:!1,err:f("fleet-cwd-repair-invalid")});return}m({rel:X,dirs:[],loading:!0,err:""});try{const H=await Mf(e,X,t),$=PR(H);m({rel:$,dirs:Array.isArray(H.dirs)?H.dirs:[],loading:!1,err:""})}catch(H){m({rel:X,dirs:[],loading:!1,err:String(H&&H.message||H)})}},I=W=>{if(!p)return;const X=p.rel?`${p.rel}/${W}`:W;L(X)},G=()=>{p!=null&&p.rel&&L(p.rel.split("/").slice(0,-1).join("/"))},K=()=>{p&&(d(p.rel||""),m(null),S(""),w(null))},Y=()=>{E!==null&&(d(E),w(null),S(""))},Q=async()=>{if(C)return;const W=br(u);if(W===null){S(f("fleet-cwd-repair-invalid"));return}const X=Jl(W);let H=!0;try{H=window.confirm(f("fleet-cwd-repair-confirm").replace("{id}",String(N||"")).replace("{path}",X))}catch{H=!1}if(H){y(!0),S(""),w(null);try{const $=await Hy(e,N,{cwdRel:W},t);o==null||o($)}catch($){const R=$&&$.data||{};if(R.code==="unportable-cwd"){S(f("fleet-cwd-repair-unportable"));const O=Array.isArray(R.cells)?R.cells.find(A=>A&&A.id===N):null,F=O&&typeof O.suggestion=="string"?O.suggestion:null;F!==null&&br(F)!==null&&w(F)}else S(String($&&$.message||$))}finally{y(!1)}}};return l.jsxs("div",{className:"nc-set-form nc-fleet-form nc-cwd-repair",children:[l.jsx("b",{children:f("fleet-cwd-repair-title").replace("{id}",String(N||""))}),l.jsx("small",{className:"nc-set-info",children:f("fleet-cwd-repair-help")}),l.jsx("small",{className:"nc-cwd-no-source",children:f("fleet-cwd-repair-no-source-path")}),l.jsxs("label",{className:"nc-field",children:[f("cwd"),l.jsxs("div",{className:"nc-cwd-rel-row",children:[l.jsx("span",{className:"nc-cwd-rel-prefix",children:"~/"}),l.jsx("input",{value:u,placeholder:f("fleet-cwd-repair-placeholder"),autoComplete:"off",spellCheck:"false",autoCapitalize:"none",onChange:W=>d(W.target.value)}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:C,onClick:()=>p?m(null):L(""),children:f(p?"close":"fleet-cwd-repair-browse")})]})]}),l.jsx("div",{className:"nc-cwd-preview",children:f("fleet-cwd-repair-preview").replace("{path}",Jl(u))}),p&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:Jl(p.rel)}),l.jsxs("div",{className:"nc-fs-list",children:[p.rel&&l.jsxs("button",{type:"button",className:"nc-fs-item nc-fs-nav",onClick:G,children:["↑ ",f("fs-parent")]}),p.loading&&l.jsx("div",{className:"nc-fs-empty",children:"…"}),!p.loading&&p.dirs.length===0&&l.jsx("div",{className:"nc-fs-empty",children:f("fleet-cwd-repair-fs-empty")}),!p.loading&&p.dirs.map(W=>l.jsxs("button",{type:"button",className:"nc-fs-item",onClick:()=>I(W),children:["📁 ",W]},W))]}),p.err&&l.jsx("div",{className:"nc-err",children:p.err}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{type:"button",className:"nc-btn primary",disabled:C||p.loading||!!p.err,onClick:K,children:f("fleet-cwd-repair-use-current")})})]}),b&&l.jsx("div",{className:"nc-err",role:"alert",children:b}),E!==null&&l.jsxs("div",{className:"nc-cwd-suggestion",role:"status",children:[l.jsx("span",{children:f("fleet-cwd-repair-suggestion")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:Y,children:f("fleet-cwd-repair-use-suggestion").replace("{path}",Jl(E))})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:v,onClick:a,children:f("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:C,onClick:Q,children:v?"…":f("save")})]})]})}function AR({token:e,readonly:t,targets:n=[],startNewCell:s=!1,initialLocation:o=""}){const[a,u]=k.useState({engines:[],cells:[],managedCatalog:[]}),[d,p]=k.useState({available:!1,capabilities:[]}),[m,v]=k.useState(!1),[y,b]=k.useState(null),[S,x]=k.useState(null),[E,w]=k.useState({}),[N,C]=k.useState(null),[L,I]=k.useState(!1),[G,K]=k.useState(""),[Y,Q]=k.useState(""),[W,X]=k.useState(o),[H,$]=k.useState(!1),[R,O]=k.useState(null),[F,A]=k.useState(null),[T,j]=k.useState(null),[z,M]=k.useState(!1),[D,B]=k.useState([]),[U,se]=k.useState(null),[ee,de]=k.useState("manage"),ve=k.useRef(!1),fe=W?W.split("/"):[],pe=k.useCallback(async()=>{try{const oe=await Xs(e,fe);p(oe);try{const ie=await Df(e,fe);$(!!ie.readonlyDefault)}catch{$(!1)}if(oe.provider==="builtin"&&(oe.capabilities||[]).includes("definitions")){const ie=await Ec(e,fe),_e=new Map((oe.engines||[]).map(be=>[be.id,be]));if(ie.engines=(ie.engines||[]).map(be=>{var ke;return{...be,availableModels:((ke=_e.get(be.id))==null?void 0:ke.models)||[]}}),u(ie),(oe.capabilities||[]).includes("credentials"))try{B((await lx(e,fe)).credentials||[])}catch{B([])}else B([])}K("")}catch(oe){K(String(oe.message||oe))}finally{v(!0)}},[e,W]);k.useEffect(()=>{pe();const oe=setInterval(pe,5e3);return()=>clearInterval(oe)},[pe]);const Ve=new Set((d.cells||[]).filter(oe=>oe.active).map(oe=>oe.cell)),ut=d.provider==="builtin"&&(d.capabilities||[]).includes("edit"),vt=(d.capabilities||[]).includes("restore");k.useEffect(()=>{!s||ve.current||!ut||!a.engines.length||(ve.current=!0,C({mode:"new",form:Ey(a.engines[0].id)}))},[s,ut,a.engines]);const je=async oe=>{I(!0),K(""),Q("");try{await oe(),await pe()}catch(ie){K(String(ie.message||ie))}I(!1)},Ct=async(oe,ie)=>{const _e=await mx(e,oe,ie,fe);return w(be=>({...be,[`${oe}::${ie}`]:_e})),_e},dn=oe=>je(async()=>{const ie={id:String(oe.id||"").trim(),engine:String(oe.engine||"").trim()};for(const _e of["contextWindow","maxTokens"]){const be=String(oe[_e]||"").trim();be&&(ie[_e]=Number(be))}oe.reasoning===!0&&(ie.reasoning=!0),await fx(e,ie,fe),x(null),await pe()}),gn=()=>je(async()=>{var zt;const oe=y.mode==="new",ie=y.form,_e=a.managedCatalog||[],be=ie.kind==="managed"?ja(_e,ie):null,ke=typeof(be==null?void 0:be.credentialEnv)=="string"?be.credentialEnv:"",it=ke&&ie.credentialValue||"",ht=CR(ie,oe,_e);!oe&&y.form.kind==="custom"&&!y.form.modelFlag&&(ht.model=null),!oe&&y.form.kind==="custom"&&y.form.promptMode!=="flag"&&(ht.promptFlag=null);let dt;if(oe)dt=await ux(e,ht,fe);else{const Je=y.original,J=new Set(y.form.envRows.filter(Oe=>!Oe.remove).map(Oe=>Oe.key)),Ne=(Je.envKeys||[]).filter(Oe=>!J.has(Oe)),Ue=Object.fromEntries(y.form.envRows.filter(Oe=>!Oe.remove&&Oe.key&&(!Oe.configured||Oe.value!=="")).map(Oe=>[Oe.key,Oe.value]));dt=await dx(e,Je.id,ht,y.form.kind==="custom"?{set:Ue,remove:Ne}:void 0,fe)}let Rt=null;if(ke&&it)try{Rt=await Zg(e,ke,it,fe),B(Rt.credentials||[])}catch{throw await pe(),oe&&b({mode:"edit",original:{...ht,id:ie.id},form:{...ie,credentialReveal:!1}}),new Error(f(oe?"fleet-key-partial-create":"fleet-key-partial-edit"))}await pe(),b(null),Q(f("fleet-saved"));const wt=((zt=((Rt==null?void 0:Rt.credentials)||[]).find(Je=>Je.envKey===ke))==null?void 0:zt.activeCells)||[],_t=[...new Set([...(dt==null?void 0:dt.activeCells)||[],...wt])];if(_t.length&&window.confirm(f("fleet-restart-confirm").replace("{cells}",_t.join(", "))))for(const Je of _t)await fa(e,Je,fe)}),Yt=()=>je(async()=>{var wt,_t,zt,Je,J,Ne;const oe=N.mode==="new",ie=N.form,_e={...oe?{id:ie.id}:{},cwd:ie.cwd,engine:ie.engine,boot:!!ie.boot},be={...ie.commands||{}},ke=a.engines.find(Ue=>Ue.id===ie.engine);((wt=ke==null?void 0:ke.managed)==null?void 0:wt.client)==="shell"&&typeof ie.command=="string"&&ie.command.length?be[ie.engine]=ie.command:((_t=ke==null?void 0:ke.managed)==null?void 0:_t.client)==="shell"&&delete be[ie.engine],(Object.keys(be).length||!oe)&&(_e.commands=be);const it=(ie.label||"").trim();oe?it&&(_e.label=it):_e.label=it||null;const ht=(ie.panelUrl||"").trim();oe?ht&&(_e.panelUrl=ht):_e.panelUrl=ht||null,oe?Array.isArray(ie.mcp)&&(_e.mcp=ie.mcp):_e.mcp=Array.isArray(ie.mcp)?ie.mcp:null,oe?(((zt=ke==null?void 0:ke.managed)==null?void 0:zt.client)!=="shell"&&ie.model&&(_e.model=ie.model),((Je=ke==null?void 0:ke.managed)==null?void 0:Je.client)!=="shell"&&ie.prompt&&(_e.prompt=ie.prompt)):(_e.model=((J=ke==null?void 0:ke.managed)==null?void 0:J.client)==="shell"?null:ie.model||null,((Ne=ke==null?void 0:ke.managed)==null?void 0:Ne.client)!=="shell"&&(_e.prompt=ie.prompt||null));const dt=oe?await gx(e,_e,fe):await Hy(e,N.original.id,_e,fe),Rt=oe?ie.id:N.original.id;C(null),Q(f("fleet-saved")),!oe&&(dt!=null&&dt.active)&&window.confirm(f("fleet-restart-confirm").replace("{cells}",Rt))&&await fa(e,Rt,fe)}),xt=t||H,Ot=d.capabilities||[],Ut=fe.length>0&&xt,Nt=oe=>D.find(ie=>{var _e;return(_e=ie.engines)==null?void 0:_e.includes(oe.id)})||null,Dt=()=>je(async()=>{var _e;const oe=await Zg(e,U.envKey,U.value,fe);B(oe.credentials||[]),se(null),Q(f("fleet-credential-saved"));const ie=((_e=(oe.credentials||[]).find(be=>be.envKey===U.envKey))==null?void 0:_e.activeCells)||[];if(ie.length&&window.confirm(f("fleet-restart-confirm").replace("{cells}",ie.join(", "))))for(const be of ie)await fa(e,be,fe)}),At=oe=>je(async()=>{if(!window.confirm(f("fleet-credential-remove-confirm").replace("{key}",oe.envKey)))return;const ie=await cx(e,oe.envKey,fe);B(ie.credentials||[]),Q(f("fleet-credential-removed"))}),jt=oe=>O({...oe,route:Array.isArray(oe==null?void 0:oe.route)?oe.route:fe}),hn=async oe=>{if(!R)return;const ie=R.cell||R.id,_e=Array.isArray(R.route)?R.route:fe;if(oe.action==="up"){const be=await Lf(e,{cell:ie,boot:!!oe.boot,...oe.engine?{engine:oe.engine}:{},...oe.model!==void 0?{model:oe.model}:{},...oe.permissionPolicy?{permissionPolicy:oe.permissionPolicy}:{}},_e),ke=Vf(be);ke&&Q(ke.text)}else await lc(e,{cell:ie,boot:!!oe.boot},_e)},re=(oe,ie)=>{K(""),A({mode:"new",route:Array.isArray(ie)?ie:fe,form:{tmuxSession:oe.name,id:"",engine:"",cwd:"",boot:!1},err:""})},Qe=()=>je(async()=>{const oe=F.form;if(!oe.engine){A({...F,err:f("import-engine-required")});return}await vx(e,{tmuxSession:oe.tmuxSession,id:oe.id||void 0,engine:oe.engine,cwd:oe.cwd||void 0,boot:!!oe.boot},oe.route||fe),A(null),Q(f("fleet-saved"))}),me=({engineRows:oe=[],cellRows:ie=[],models:_e=[]})=>je(async()=>{const be=oe.filter(Je=>Je.selected),ke=be.map(Je=>rS(Je.engine));if(ke.some(Je=>!Je))throw new Error(f("fleet-backup-invalid-engine"));const it=be.filter(Je=>Je.exists).map(Je=>Je.engine.id);if(it.length&&!window.confirm(f("fleet-backup-confirm-engine-overwrite").replace("{engines}",it.join(", "))))return;const ht=[...new Set([...a.engines.map(Je=>Je.id),...ke.map(Je=>Je.id)])],dt=[];for(const Je of ie.filter(J=>J.selected)){const J=wR(Je.cell,Je.engine,ht);if(!J)throw new Error(`${Je.cell.id}: ${f("fleet-backup-engine-missing")}`);dt.push(J)}const Rt=ie.filter(Je=>Je.selected&&Je.exists).map(Je=>Je.cell.id);if(Rt.length&&!window.confirm(f("fleet-backup-confirm-overwrite").replace("{cells}",Rt.join(", "))))return;const wt=ke.length?await yx(e,ke,it.length>0,fe,_e):{needsRestart:[]},_t=dt.length?await _x(e,dt,fe):{needsRestart:[]},zt=[...new Set([...wt.needsRestart||[],..._t.needsRestart||[]])];M(!1),Q(`${f("fleet-backup-restored").replace("{n}",String(dt.length))}${ke.length?` · ${ke.length} ${f("fleet-engines").toLowerCase()}`:""}${zt.length?` · ${f("fleet-backup-needs-restart").replace("{cells}",zt.join(", "))}`:""}`)}),Ge=l.jsxs("label",{className:"nc-field",children:[f("location"),l.jsxs("select",{value:W,onChange:oe=>{X(oe.target.value),b(null),C(null),K(""),Q(""),$(!1),v(!1),p({available:!1,capabilities:[]}),u({engines:[],cells:[],managedCatalog:[]}),B([]),se(null)},children:[l.jsx("option",{value:"",children:f("local")}),n.map(oe=>l.jsxs("option",{value:oe.route.join("/"),disabled:oe.status&&oe.status!=="up",children:[oe.label,oe.status&&oe.status!=="up"?` · ${f("node-offline")}`:""]},oe.route.join("/")))]})]}),ct=l.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":f("tab-fleet"),children:[l.jsx("button",{type:"button",role:"tab","aria-selected":ee==="manage",className:`nc-set-tabbtn${ee==="manage"?" on":""}`,onClick:()=>de("manage"),children:f("fleet-manage-location")}),l.jsx("button",{type:"button",role:"tab","aria-selected":ee==="overview",className:`nc-set-tabbtn${ee==="overview"?" on":""}`,onClick:()=>de("overview"),children:f("fleet-network-overview")})]});return m?ut?l.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[ct,ee==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:f("fleet-overview-help")}),l.jsx(dh,{token:e,targets:n,readonly:t,onPower:jt,onImport:re})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:f("fleet-manage-help")}),Ge,l.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[l.jsx("button",{className:"nc-btn ghost",disabled:xt||L,onClick:()=>{K(""),M(!0)},children:f("fleet-backup")}),l.jsx("small",{children:f("fleet-backup-help")})]}),l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:f("fleet-cells")}),l.jsx("span",{className:"nc-fleet-head-actions",children:l.jsxs("button",{className:"nc-btn primary",disabled:xt||L||!a.engines.length,onClick:()=>{var oe;K(""),C({mode:"new",form:Ey((oe=a.engines[0])==null?void 0:oe.id)})},children:["+ ",f("add")]})})]}),a.cells.map(oe=>{const ie=Ve.has(oe.id),_e=oe.needsRepair===!0;return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:oe.id}),oe.label?l.jsxs("small",{className:"nc-fleet-label",children:[" ",oe.label]}):null,l.jsxs("small",{children:[oe.engine," · ",_e?l.jsx("span",{className:"nc-fleet-tag nc-fleet-tag-warn",children:f("fleet-cwd-needs-repair")}):oe.cwd,ie?` · ${f("service-active")}`:` · ${f("cell-off")}`]})]}),l.jsxs("span",{children:[ie&&Ot.includes("down")&&l.jsx("button",{className:"nc-btn ghost",disabled:xt||L,onClick:()=>je(()=>lc(e,{cell:oe.id},fe)),children:f("stop")}),!ie&&Ot.includes("up")&&l.jsx("button",{className:"nc-btn primary",disabled:xt||L,onClick:()=>jt({cell:oe.id,id:oe.id,engine:oe.engine,model:oe.model,models:oe.models,permissionPolicies:oe.permissionPolicies,active:!1,boot:oe.boot}),children:f("start")}),ie&&Ot.includes("restart")&&l.jsx("button",{className:"nc-btn ghost",disabled:xt||L,onClick:()=>je(()=>fa(e,oe.id,fe)),children:f("restart")}),_e?l.jsx("button",{className:"nc-btn ghost",disabled:xt||L,onClick:()=>{K(""),j(oe)},children:f("fleet-cwd-repair")}):l.jsx("button",{className:"nc-btn ghost",disabled:xt||L,onClick:()=>{var be;K(""),C({mode:"edit",original:oe,form:{...oe,commands:{...oe.commands||{}},command:((be=oe.commands)==null?void 0:be[oe.engine])||""}})},children:f("edit")}),l.jsx("button",{className:"nc-btn danger",disabled:xt||L,onClick:()=>je(async()=>{window.confirm(f("fleet-remove-cell").replace("{id}",oe.id))&&await Uy(e,oe.id,!0,fe)}),children:"×"})]})]},oe.id)}),l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:f("fleet-engines")}),l.jsxs("button",{className:"nc-btn primary",disabled:xt||L,onClick:()=>{K(""),b({mode:"new",form:SR()})},children:["+ ",f("add")]})]}),a.engines.map(oe=>{var _e,be;const ie=Nt(oe);return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:oe.label}),l.jsx("small",{children:oe.managed?`${oe.id} · ${oe.managed.client} / ${oe.managed.provider} · ${(_e=oe.managedInfo)!=null&&_e.configured?f("fleet-ready"):((be=oe.managedInfo)==null?void 0:be.reason)||f("fleet-not-ready")}`:`${oe.id} · ${oe.command}`}),ie&&l.jsxs("small",{children:[ie.envKey," · ",f(`fleet-credential-source-${ie.source||"missing"}`)]})]}),l.jsxs("span",{children:[ie&&l.jsx("button",{className:"nc-btn ghost",disabled:xt||L,onClick:()=>{K(""),se({envKey:ie.envKey,value:""})},children:ie.configured?f("fleet-credential-change"):f("fleet-credential-set")}),(ie==null?void 0:ie.source)==="local"&&l.jsx("button",{className:"nc-btn danger",disabled:xt||L,onClick:()=>At(ie),children:f("fleet-credential-forget")}),l.jsx("button",{className:"nc-btn ghost",disabled:xt||L,onClick:()=>{K(""),b({mode:"edit",original:oe,form:kR(oe)})},children:f("edit")}),l.jsx("button",{className:"nc-btn danger",disabled:xt||L,onClick:()=>je(async()=>{window.confirm(f("fleet-remove-engine").replace("{id}",oe.id))&&await hx(e,oe.id,fe)}),children:"×"})]})]},oe.id)}),l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:f("fleet-models")}),l.jsxs("button",{className:"nc-btn primary",disabled:xt||L,onClick:()=>{K(""),x({mode:"new",form:{id:"",engine:""}})},children:["+ ",f("add")]})]}),!(a.models||[]).length&&l.jsx("small",{className:"nc-set-hint",children:f("fleet-no-models")}),(a.models||[]).map(oe=>{const ie=`${oe.engine}::${oe.id}`,_e=E[ie],be=(a.engines||[]).some(ke=>ke.managed&&ke.managed.model===oe.id);return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:oe.id}),l.jsxs("small",{children:[oe.engine,oe.contextWindow?` · ${oe.contextWindow}`:"",be?` · ${f("model-in-use")}`:""]}),_e&&l.jsxs("small",{className:`nc-model-test ${_e.outcome}`,children:[f(`model-test-${_e.outcome}`),_e.outcome==="ok"&&Number.isInteger(_e.latencyMs)?` · ${_e.latencyMs}ms`:""]})]}),l.jsxs("span",{children:[Ot.includes("model-test")&&l.jsx("button",{className:"nc-btn ghost",disabled:L||Ut,onClick:()=>je(()=>Ct(oe.engine,oe.id)),children:f("model-test")}),l.jsx("button",{className:"nc-btn danger",disabled:xt||L,onClick:()=>je(()=>px(e,oe.id,oe.engine,fe)),children:"×"})]})]},ie)})]}),S&&l.jsx(Hs,{onClose:()=>x(null),label:f("fleet-models"),error:G,children:l.jsx(jR,{state:S,setState:x,busy:L,onSave:dn,onTest:Ct,profiles:a.managedCatalog||[],canTest:Ot.includes("model-test")&&!Ut})}),y&&l.jsx(Hs,{onClose:()=>b(null),label:f("fleet-new-engine"),error:G,children:l.jsx(NR,{state:y,setState:b,busy:L,onSave:gn,catalog:a.managedCatalog||[]})}),N&&l.jsx(Hs,{onClose:()=>C(null),label:f("fleet-new-cell"),error:G,children:l.jsx(RR,{token:e,route:fe,targets:n,location:W,setLocation:X,state:N,setState:C,engines:a.engines,mcpServers:a.mcpServers||[],managedCatalog:a.managedCatalog||[],busy:L,onSave:Yt})}),T&&l.jsx(Hs,{onClose:()=>j(null),label:f("fleet-cwd-repair-title").replace("{id}",T.id),error:"",children:l.jsx(LR,{token:e,route:fe,cell:T,busy:L,onSaved:async()=>{j(null),Q(f("fleet-cwd-repaired")),await pe()},onClose:()=>j(null)})}),Y&&l.jsx("div",{className:"nc-set-note",children:Y}),G&&l.jsx("div",{className:"nc-err",children:G}),z&&l.jsx(Hs,{onClose:()=>M(!1),label:f("fleet-backup"),error:G,children:l.jsx(ER,{cells:a.cells,engines:a.engines,models:a.models||[],busy:L,canRestore:vt,onRestore:me,onClose:()=>M(!1)})}),U&&l.jsx(Hs,{onClose:()=>se(null),label:f("fleet-credential-title"),error:G,children:l.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[l.jsx("b",{children:f("fleet-credential-title")}),l.jsx("small",{children:f("fleet-credential-help")}),l.jsxs("label",{className:"nc-field",children:[U.envKey,l.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:U.value,onChange:oe=>se({...U,value:oe.target.value})})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>se(null),children:f("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:L||!U.value,onClick:Dt,children:f("save")})]})]})}),F&&l.jsx(Hs,{onClose:()=>A(null),label:f("import-as-cell"),error:G,children:l.jsx(jy,{token:e,route:F.route||fe,state:F,setState:A,busy:L,onSave:Qe})}),R&&l.jsx(uc,{cell:R,token:e,route:Array.isArray(R.route)?R.route:fe,onConfirm:async oe=>{try{await hn(oe)}finally{await pe()}},onClose:()=>O(null)})]}):l.jsxs("div",{className:"nc-set-tab",children:[ct,ee==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:f("fleet-overview-help")}),l.jsx(dh,{token:e,targets:n,readonly:t,onPower:jt,onImport:re})]}):l.jsxs(l.Fragment,{children:[Ge,l.jsxs("div",{className:"nc-set-info",children:[f(G?"fleet-editor-load-error":"fleet-editor-unavailable"),!G&&d.reason?` ${d.reason}`:""]})]}),G&&l.jsx("div",{className:"nc-err",children:G}),F&&l.jsx(Hs,{onClose:()=>A(null),label:f("import-as-cell"),error:G,children:l.jsx(jy,{token:e,route:F.route||fe,state:F,setState:A,busy:L,onSave:Qe})}),R&&l.jsx(uc,{cell:R,token:e,route:Array.isArray(R.route)?R.route:fe,onConfirm:async oe=>{try{await hn(oe)}finally{await pe()}},onClose:()=>O(null)})]}):l.jsxs("div",{className:"nc-set-tab",children:[ct,ee==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:f("fleet-overview-help")}),l.jsx(dh,{token:e,targets:n,readonly:t,onPower:jt,onImport:re})]}):l.jsxs(l.Fragment,{children:[Ge,l.jsx("div",{className:"nc-set-info",children:f("fleet-editor-loading")})]})]})}const Cp="nc_notification_speech_v1",Zl="nc-notification-speech",xf="nc-notification-speech-preview",MR=320,TR=2,DR=3e4,IR=1e4,OR=6e4,BR=64,Ry=Object.freeze({enabled:!1}),zR=Object.freeze({it:"it-IT",en:"en-US",es:"es-ES"}),$R=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"])}),Ep=new WeakSet;function Np(e){return{enabled:(e&&typeof e=="object"&&!Array.isArray(e)?e:{}).enabled===!0}}function aS(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Py(e=aS()){if(!e)return{...Ry};try{return Np(JSON.parse(e.getItem(Cp)||"null"))}catch{return{...Ry}}}function FR(e,t=aS()){const n=Np(e);if(t)try{t.setItem(Cp,JSON.stringify(n))}catch{}return n}function Eo(){try{return typeof window<"u"?window:null}catch{return null}}function Ra(e=Eo()){try{return!!(e&&e.speechSynthesis&&typeof e.speechSynthesis.speak=="function"&&typeof e.SpeechSynthesisUtterance=="function")}catch{return!1}}function lS(e=Eo()){return!!(e&&(typeof e=="object"||typeof e=="function")&&Ep.has(e))}function kf(e=Eo()){e&&(typeof e=="object"||typeof e=="function")&&Ep.delete(e)}function mo(e){const t=String(e||"").trim().toLowerCase().split("-")[0];return zR[t]||""}function Bc(e){return String(e||"").normalize("NFC").replace(/[\p{Cc}\p{Cf}]+/gu," ").replace(/\s+/g," ").trim()}function HR(e){const t=Bc(e).normalize("NFD").replace(new RegExp("\\p{M}+","gu"),"").toLowerCase(),n=new Set(t.match(new RegExp("\\p{L}+","gu"))||[]);if(n.size<4)return"";const s=Object.entries($R).map(([o,a])=>({lang:o,score:[...n].reduce((u,d)=>u+(a.has(d)?1:0),0)})).sort((o,a)=>a.score-o.score);return s[0].score>=3&&s[0].score-s[1].score>=2?s[0].lang:""}function UR(e,t){const n=mo(e&&e.lang);return n||mo(HR(e&&e.body))||mo(t)}function cS(e){try{const t=e&&e.speechSynthesis&&e.speechSynthesis.getVoices;return typeof t=="function"?Array.from(t.call(e.speechSynthesis)||[]).filter(Boolean):[]}catch{return[]}}function uS(e,t){const n=mo(t);if(!n)return null;const s=Array.from(e||[]).filter(d=>d&&typeof d.lang=="string"&&d.lang.trim()),o=s.filter(d=>d.lang.trim().toLowerCase()===n.toLowerCase()),a=n.slice(0,2).toLowerCase(),u=s.filter(d=>d.lang.trim().toLowerCase().split("-")[0]===a);return o.find(d=>d.default===!0)||o[0]||u.find(d=>d.default===!0)||u[0]||null}function Ly(e){return Bc(e).replace(/\bBearer\s+\S+/gi,"Bearer [redacted]").replace(/\b(?:sk|hf|zai|xox[baprs]|gh[pousr]|npm)[_-][A-Za-z0-9._-]{8,}\b/gi,"[redacted]").replace(/\b(?:token|password|secret|credential|api[_-]?key)\s*[=:]\s*(?:"[^"]*"|'[^']*'|\S+)/gi,"[redacted]").replace(/\b[A-Z][A-Z0-9_]{2,}\s*=\s*(?:"[^"]*"|'[^']*'|\S+)/g,"[redacted]").replace(/(?:\/home\/[^/\s]+|\/Users\/[^/\s]+|\/data\/(?:data|user\/\d+)\/[^/\s]+)(?:\/[^\s]*)?/g,"[private path]").replace(/\b[A-Za-z]:\\Users\\[^\\\s]+(?:\\[^\s]*)?/g,"[private path]")}function WR(e,t=MR){const n=Ly(e&&e.title),s=Ly(e&&e.body),o=[n,s&&s!==n?s:""].filter(Boolean).join(". "),a=Array.from(o);return a.length<=t?o:`${a.slice(0,Math.max(0,t-1)).join("").trimEnd()}…`}function KR(e){try{return!!(e&&e.visibilityState==="visible"&&typeof e.hasFocus=="function"&&e.hasFocus())}catch{return!1}}function dS(e=Eo()){if(!Ra(e))return!1;try{return e.speechSynthesis.cancel(),!0}catch{return!1}}function qR(e){try{e&&typeof e.dispatchEvent=="function"&&typeof e.Event=="function"&&e.dispatchEvent(new e.Event(xf))}catch{}}function VR(e,t,n=Eo(),s={}){var m;if(kf(n),!Ra(n))return Promise.resolve(!1);const o=Bc(e);if(!o||(m=s.signal)!=null&&m.aborted)return Promise.resolve(!1);const a=Number.isFinite(s.timeoutMs)&&s.timeoutMs>0?s.timeoutMs:IR,u=s.setTimer||((v,y)=>setTimeout(v,y)),d=s.clearTimer||(v=>clearTimeout(v)),p=s.signal;return qR(n),new Promise(v=>{let y=!1,b=!1,S=null,x=null;const E=w=>{if(!y){if(y=!0,p&&x&&p.removeEventListener("abort",x),S!==null&&d(S),w!==!0)try{n.speechSynthesis.cancel()}catch{}else Ep.add(n);v(w)}};x=()=>E("no-activation"),p&&p.addEventListener("abort",x,{once:!0});try{n.speechSynthesis.cancel();const w=new n.SpeechSynthesisUtterance(o);w.lang=mo(t);const N=uS(cS(n),w.lang);N&&(w.voice=N),w.onstart=()=>{b=!0},w.onend=()=>E(b?!0:"no-activation"),w.onerror=()=>E("voice-error"),S=u(()=>E("timeout"),a),n.speechSynthesis.speak(w)}catch{E("no-activation")}})}function YR(e={}){const t=e.scope||Eo(),n=e.document||t&&t.document,s=Number.isInteger(e.maxPending)&&e.maxPending>=0?e.maxPending:TR,o=Number.isFinite(e.watchdogMs)&&e.watchdogMs>0?e.watchdogMs:DR,a=Number.isFinite(e.dedupWindowMs)&&e.dedupWindowMs>0?e.dedupWindowMs:OR,u=Number.isInteger(e.maxDedup)&&e.maxDedup>0?e.maxDedup:BR,d=e.now||Date.now,p=e.setTimer||((H,$)=>setTimeout(H,$)),m=e.clearTimer||(H=>clearTimeout(H)),v=e.isPrimed||(()=>lS(t)),y=t&&t.speechSynthesis;let b=null,S=null,x=[],E=[],w=()=>{};const N=new Map,C=()=>{E=cS(t)};if(C(),y&&typeof y.addEventListener=="function")y.addEventListener("voiceschanged",C),w=()=>y.removeEventListener("voiceschanged",C);else if(y&&"onvoiceschanged"in y){const H=y.onvoiceschanged,$=(...R)=>{C(),typeof H=="function"&&H.apply(y,R)};y.onvoiceschanged=$,w=()=>{y.onvoiceschanged===$&&(y.onvoiceschanged=H)}}const L=H=>{if(H&&typeof H.id=="string"&&H.id)return`id:${H.id}`;const $=Number(H&&H.ts),R=Bc(H&&H.title);return Number.isFinite($)&&R?`frame:${$}:${R}`:""},I=H=>{if(!H)return!0;const $=d();for(const[R,O]of N)$-O>=a&&N.delete(R);if(N.has(H))return!1;for(N.set(H,$);N.size>u;)N.delete(N.keys().next().value);return!0},G=()=>{S!==null&&m(S),S=null},K=()=>{G(),b&&(b.onend=null,b.onerror=null,b=null),dS(t)},Y=H=>{if(!Ra(t))return x=[],"unsupported";let $;try{$=new t.SpeechSynthesisUtterance(H.text),$.lang=mo(H.lang);const O=uS(E,$.lang);O&&($.voice=O)}catch{return x=[],"error"}b=$;const R=()=>{if(b!==$)return;G(),b=null,$.onend=null,$.onerror=null;const O=x.shift();O&&Y(O)};$.onend=R,$.onerror=R;try{return S=p(()=>{if(b!==$)return;b=null,$.onend=null,$.onerror=null;try{t.speechSynthesis.cancel()}catch{}G();const O=x.shift();O&&Y(O)},o),t.speechSynthesis.speak($),"speaking"}catch{return R(),"error"}},Q=(H,$)=>{if(!Ra(t))return"unsupported";const R=WR(H);if(!R)return"empty";if(!I(L(H)))return"duplicate";if(!KR(n))return"inactive";if(!v())return"unprimed";const O={text:R,lang:$};return H&&H.urgency==="high"?(x=[],K(),Y(O)):b?s===0?"dropped":(x.length>=s&&x.shift(),x.push(O),"queued"):Y(O)},W=()=>{x=[],K()};return{enqueue:Q,stop:W,dispose:()=>{W(),w(),w=()=>{}}}}function hS(){const[e,t]=k.useState(Py);k.useEffect(()=>{const s=o=>{if((o==null?void 0:o.type)==="storage"&&o.key!==Cp&&o.key!==null)return;const a=(o==null?void 0:o.type)===Zl?Np(o.detail):Py();t(a)};return window.addEventListener(Zl,s),window.addEventListener("storage",s),()=>{window.removeEventListener(Zl,s),window.removeEventListener("storage",s)}},[]);const n=k.useCallback(s=>{const o=FR({enabled:s===!0});return t(o),window.dispatchEvent(new CustomEvent(Zl,{detail:o})),o.enabled},[]);return[e.enabled,n]}function GR({text:e}){const[t,n]=k.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return l.jsxs("div",{className:"nc-set-copyline",children:[l.jsx("code",{children:e}),l.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:s,children:[l.jsx(lt,{name:"copy",size:14})," ",f(t?"copied":"copy")]})]})}function XR({value:e}){const[t,n]=k.useState("");return k.useEffect(()=>{let s=!0;return Cj.toDataURL(e,{margin:1,width:220}).then(o=>{s&&n(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?l.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function QR({token:e,nodes:t,roster:n,settings:s,readonly:o,refresh:a,refreshAliases:u,vlUnavailable:d=[]}){const[p,m]=k.useState(null),[v,y]=k.useState(null),[b,S]=k.useState(null),[x,E]=k.useState({ssh:"",sshPort:"",name:""}),[w,N]=k.useState(""),[C,L]=k.useState(""),[I,G]=k.useState(!1),[K,Y]=k.useState(null),Q=Date.now(),W=s&&s.deviceName||"",X=(t||[]).filter(j=>j&&j.direction==="outbound"&&j.name&&j.ssh),H=X.find(j=>j.name===w)||X[0]||null,$=H?Ch(H.tunnel,Q):null,R=H!=null&&H.shared?$!=null&&$.up?"share-local-active":"share-local-pending":$!=null&&$.up?"share-local-private":"share-local-private-down",O=[{key:"peer-group-hubs",rows:(t||[]).filter(j=>j.kind!=="transitive"&&j.kind!=="vl"&&j.relation!=="client")},{key:"peer-group-clients",rows:(t||[]).filter(j=>j.kind!=="transitive"&&j.kind!=="vl"&&j.relation==="client")},{key:"peer-group-routed",rows:(t||[]).filter(j=>j.kind==="transitive")},{key:"peer-group-vl",rows:(t||[]).filter(j=>j.kind==="vl")}],F=K&&(t||[]).find(j=>`${j.kind||"direct"}:${j.nodeId||j.name}`===K)||null,A=async j=>{if(H){m(null),y(`${H.name}:share`);try{const z=await Rx(e,H.name,j);await a(),z&&z.reversePoolPending===!0&&m(`${H.name}: ${f("share-reverse-pool-pending")}`)}catch(z){const M=z!=null&&z.data&&z.data.shared===!1?z.data:null;if(M)try{await a()}catch{}const D=z!=null&&z.data&&typeof z.data.hint=="string"?z.data.hint:"",B=(M==null?void 0:M.revoked)===!0&&(M==null?void 0:M.localReconcilePending)===!0?f("share-off-local-reconcile-pending"):(M==null?void 0:M.revoked)===!1&&(M==null?void 0:M.reconcilePending)===!0?f("share-off-hub-reconcile-pending"):"",U=z!=null&&z.data&&z.data.reversePoolPending===!0?f("share-reverse-pool-pending"):"",se=z!=null&&z.data&&typeof z.data.code=="string"?z.data.code:"",ee=z!=null&&z.data&&typeof z.data.detail=="string"?z.data.detail.trim():"",de=ee&&ee!==String(z.message||"")?ee:"";m(`${H.name}: ${String(z.message||z)}${se?` [${se}]`:""}${de?` — ${de}`:""}${D?` — ${D}`:""}${B?` — ${B}`:""}${U?` — ${U}`:""}`)}y(null)}},T=async()=>{m(null);const j=Vs(x.name||C||W||"NexusCrew"),z=Fk({name:j,ssh:x.ssh,sshPort:x.sshPort});if(!z.ok){m(f(z.error));return}y("invite");try{S(await Cx(e,{...C||W?{label:C||W}:{},name:j,ssh:z.value.ssh,...z.value.sshPort?{sshPort:z.value.sshPort}:{}}))}catch(M){m(String(M.message||M))}y(null)};return l.jsxs("div",{className:"nc-set-tab",children:[l.jsx("div",{className:"nc-sheet-label",children:f("peer-inventory-title")}),(t||[]).length===0&&l.jsx("div",{className:"nc-empty",children:f("no-nodes")}),O.map(j=>j.rows.length>0&&l.jsxs("div",{className:"nc-peer-group",children:[l.jsxs("div",{className:"nc-peer-group-title",children:[f(j.key)," ",l.jsx("span",{children:j.rows.length})]}),j.rows.map(z=>{const M=Oj(z);if(!M)return null;const D=`${z.kind||"direct"}:${z.nodeId||z.name}`,B=M.routed?{up:M.reach.up,since:null}:Ch(z.tunnel,Q);return l.jsxs("button",{type:"button",className:`nc-set-node nc-node-row${M.routed?" routed":""}`,"aria-label":`${M.title} — ${f("node-detail-open")}`,onClick:()=>Y(D),children:[l.jsx("span",{className:`nc-dot ${M.reach.up?"on":""}`}),l.jsxs("span",{className:"nc-node-row-text",children:[l.jsx("b",{children:M.title}),l.jsxs("small",{children:[M.routed?M.routeLabel:`${M.subtitle} · ${f(M.exposure.shortKey)}`,!M.routed&&M.exposure.shortKey==="visibility-selected"?` (${M.exposure.count})`:""]})]}),l.jsxs("span",{className:`nc-set-tunnel${M.reach.up?" up":""}`,children:[f(M.reach.key),B.since?` · ${B.since}`:""]}),l.jsx("span",{className:"nc-node-row-more",children:l.jsx(lt,{name:"chevronDown",size:14})})]},D)})]},j.key)),d.length>0&&l.jsxs("div",{className:"nc-err",children:[f("vl-owners-unavailable"),": ",d.map(j=>j.label||j.route.join("/")).join(", ")]}),F&&l.jsx(Jj,{node:F,nodes:t||[],token:e,readonly:o,refresh:a,onClose:()=>Y(null)}),(n||[]).some(j=>!j.direct&&j.instanceId)&&l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:f("routed-node-aliases")}),l.jsx("small",{className:"nc-set-hint",children:f("routed-node-aliases-help")}),(n||[]).filter(j=>!j.direct&&j.instanceId).map(j=>l.jsxs("div",{className:"nc-set-node",children:[l.jsxs("div",{className:"nc-set-node-head",children:[l.jsx("span",{className:`nc-dot ${j.status==="up"?"on":""}`}),l.jsx("b",{children:j.label||j.name}),l.jsx("small",{children:(j.route||[]).join(" › ")})]}),l.jsxs("div",{className:"nc-set-node-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!v,onClick:async()=>{const z=window.prompt(f("node-local-alias"),j.alias||"");if(z!=null){if(z.trim()&&!_o(z.normalize("NFC"))){m(f("err-label"));return}y(`${j.instanceId}:alias`),m(null);try{z.trim()?await Nx(e,j.instanceId,z):await nv(e,j.instanceId),u()}catch(M){m(String(M.message||M))}y(null)}},children:f("alias-on-device")}),j.alias&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!v,onClick:async()=>{y(`${j.instanceId}:alias-reset`),m(null);try{await nv(e,j.instanceId),u()}catch(z){m(String(z.message||z))}y(null)},children:f("reset-alias")})]})]},j.instanceId))]}),H&&l.jsxs("div",{className:"nc-set-form nc-local-share",children:[l.jsx("div",{className:"nc-sheet-label",children:f("share-local-heading")}),X.length>1&&l.jsxs("label",{className:"nc-field",children:[f("share-local-hub"),l.jsx("select",{value:H.name,disabled:o||!!v,onChange:j=>N(j.target.value),children:X.map(j=>l.jsx("option",{value:j.name,children:j.label||j.name},j.name))})]}),l.jsxs("label",{className:"nc-check nc-node-share",children:[l.jsx("input",{type:"checkbox",checked:H.shared===!0,disabled:o||!!v,onChange:j=>A(j.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:f("share-local-through").replace("{device}",W||f("local")).replace("{hub}",H.label||H.name)}),l.jsx("small",{children:f(H.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),l.jsx("div",{className:`nc-set-test${H.shared&&($!=null&&$.up)?" ok":$!=null&&$.up?"":" ko"}`,children:f(R)}),!($!=null&&$.up)&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!v,onClick:()=>A(H.shared===!0),children:f("share-local-reconnect")})]}),l.jsx(Gw,{token:e,deviceDefault:W,localNodeId:s&&s.nodeId||"",localNameDefault:s&&s.localName||"",readonly:o,onSuccess:a}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:f("invite-node")}),l.jsx("small",{className:"nc-set-hint",children:f("invite-v2-hint")}),l.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[f("invite-target-local"),": ",l.jsx("b",{children:W||f("invite-target-this")})]}),l.jsxs("label",{className:"nc-field",children:[f("invite-endpoint-label"),l.jsx("input",{placeholder:"user@host",value:x.ssh,disabled:o,onChange:j=>E({...x,ssh:j.target.value})}),l.jsx("small",{className:"nc-set-hint",children:f("invite-endpoint-needed")})]}),X.length>0&&l.jsx("small",{className:"nc-set-hint nc-invite-hub-hint",children:f("invite-hub-only")}),I&&l.jsxs("div",{className:"nc-invite-advanced",children:[l.jsxs("label",{className:"nc-field",children:[f("node-ssh-port-label"),l.jsx("input",{inputMode:"numeric",placeholder:"22",value:x.sshPort,disabled:o,onChange:j=>E({...x,sshPort:j.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),l.jsxs("label",{className:"nc-field",children:[f("device-name-label"),l.jsx("input",{placeholder:W||"NexusCrew",value:C,disabled:o,onChange:j=>L(j.target.value)}),l.jsx("small",{className:"nc-set-hint",children:f("device-name-hint")})]}),l.jsxs("label",{className:"nc-field",children:[f("node-name-label"),l.jsx("input",{placeholder:Vs(C||W||f("node-name-ph")),value:x.name,disabled:o,onChange:j=>E({...x,name:j.target.value?Vs(j.target.value):""})})]})]}),l.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||!!v||!x.ssh.trim(),onClick:T,children:f("create-pairing-link")}),l.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!v,onClick:()=>G(j=>!j),children:[I?"▾":"▸"," ",f("pair-advanced")]})]}),b&&l.jsxs(l.Fragment,{children:[l.jsx(XR,{value:b.pairingUrl}),l.jsx(GR,{text:b.pairingUrl}),l.jsx("div",{className:"nc-set-info",children:f("invite-next-steps")})]})]}),p&&l.jsx("div",{className:"nc-err",children:p})]})}function JR({token:e,readonly:t}){const[n,s]=k.useState("idle"),[o,a]=k.useState(!1),[u,d]=k.useState(null);k.useEffect(()=>{let m=!1;return eR().then(v=>{m||s(v)}),()=>{m=!0}},[]);const p=async()=>{d(null),a(!0);try{n==="subscribed"?(await nR(e),s("idle")):(await tR(e),s("subscribed"))}catch(m){const v=String(m.message||m);v==="push-denied"?(s("denied"),d(f("push-denied"))):v==="push-unsupported"?(s("unsupported"),d(f("push-unsupported"))):d(v)}a(!1)};return n==="unsupported"?l.jsx("div",{className:"nc-set-info",children:f("push-unsupported")}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||o||n==="denied",title:t?f("settings-readonly"):"",onClick:p,children:f(n==="subscribed"?"push-disable":"push-enable")}),l.jsx("span",{className:"nc-set-info",children:f(n==="subscribed"?"push-on":n==="denied"?"push-denied":"push-off")})]}),u&&l.jsx("div",{className:"nc-err",children:u})]})}function ZR(){const[e,t]=hS(),[n,s]=k.useState(""),[o,a]=k.useState(""),[u,d]=k.useState(!1),[p,m]=k.useState(lS),v=k.useRef(0),y=k.useRef(!1),b=k.useRef(null),S=Ra();k.useEffect(()=>()=>{var w;v.current+=1,y.current&&((w=b.current)==null||w.abort(),b.current=null,y.current=!1,kf())},[]);const x=async()=>{const w=v.current+=1,N=typeof AbortController=="function"?new AbortController:null;s(""),a(""),d(!0),m(!1),y.current=!0,b.current=N;const C=await VR(f("notification-speech-preview"),cc(),void 0,N?{signal:N.signal}:{});return w!==v.current||(b.current=null,y.current=!1,d(!1),m(C===!0),C===!0?a(f("notification-speech-preview-ok")):s(f(C==="voice-error"?"notification-speech-preview-voice-error":C==="timeout"?"notification-speech-preview-timeout":"notification-speech-preview-failed"))),C},E=w=>{var N;if(t(w),s(""),a(""),w)x();else{v.current+=1;const C=y.current;(N=b.current)==null||N.abort(),b.current=null,y.current=!1,d(!1),m(!1),kf(),C||dS()}};return l.jsxs("div",{className:"nc-set-form",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":f("notification-speech-enable"),checked:e,disabled:!S,onChange:w=>E(w.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:f("notification-speech-enable")}),l.jsx("small",{children:f("notification-speech-help")})]})]}),S?l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!e||u,onClick:()=>{x()},children:f(u?"notification-speech-testing":"notification-speech-test")})}):l.jsx("div",{className:"nc-set-info",children:f("notification-speech-unsupported")}),e&&!p&&!u&&!n&&l.jsx("div",{className:"nc-set-info",children:f("notification-speech-needs-test")}),o&&l.jsx("div",{className:"nc-set-info",role:"status",children:o}),n&&l.jsx("div",{className:"nc-err",children:n})]})}function eP({token:e,readonly:t,nodes:n=[],settings:s=null}){const[o,a]=k.useState(null),[u,d]=k.useState([]),[p,m]=k.useState({name:"",mode:"primary-failover",targets:[]}),[v,y]=k.useState(null),[b,S]=k.useState(!1),[x,E]=k.useState(null),[w,N]=k.useState(""),C=k.useCallback(async()=>{try{const[T,j]=await Promise.all([Lx(e),Dx(e)]);a(T),d(Array.isArray(j==null?void 0:j.groups)?j.groups:[]),N("")}catch(T){N(String(T.message||T))}},[e]);k.useEffect(()=>{C()},[C]);const L=async T=>{S(!0),E(null),N("");try{a(await Ax(e,T))}catch(j){N(String(j.message||j))}S(!1)},I=async()=>{S(!0),E(null),N("");try{E({kind:"test",...await Mx(e)})}catch(T){N(String(T.message||T))}S(!1)},G=async()=>{S(!0),E(null),N("");try{E({kind:"stop",...await Tx(e)})}catch(T){N(String(T.message||T))}S(!1)},K=[],Y=new Set,Q=(T,j)=>{const z=typeof T=="string"?T.toLowerCase():"";!/^[a-f0-9]{32}$/.test(z)||Y.has(z)||(Y.add(z),K.push({id:z,label:j||z}))};Q(s==null?void 0:s.nodeId,f("audio-group-local"));for(const T of n||[])Q((T==null?void 0:T.nodeId)||(T==null?void 0:T.instanceId),(T==null?void 0:T.label)||(T==null?void 0:T.name)||(T==null?void 0:T.nodeId));for(const T of p.targets)Q(T,`${T} (${f("audio-group-unavailable-target")})`);const W=(T=null)=>{N(""),T?(y(T.name),m({name:T.name,mode:T.mode,targets:[...T.targets||[]]})):(y(null),m({name:"",mode:"primary-failover",targets:[]}))},X=(T,j)=>m(z=>({...z,targets:j?[...new Set([...z.targets,T])]:z.targets.filter(M=>M!==T)})),H=async()=>{const T=p.name.trim().toLowerCase();if(!/^[a-z0-9][a-z0-9-]{0,31}$/.test(T)||p.targets.length<1){N(f("audio-group-invalid"));return}S(!0),N("");try{const j=await Ix(e,T,{targets:p.targets,mode:p.mode}),z=j==null?void 0:j.group;if(!z||!z.name)throw new Error(f("audio-group-save-failed"));d(M=>[...M.filter(D=>D.name!==z.name),z].sort((D,B)=>D.name.localeCompare(B.name))),W(null)}catch(j){N(String(j.message||j))}S(!1)},$=async T=>{S(!0),N("");try{await Ox(e,T),d(j=>j.filter(z=>z.name!==T)),v===T&&W(null)}catch(j){N(String(j.message||j))}S(!1)},R=(o==null?void 0:o.installed)===!0,O=(o==null?void 0:o.liveness)==="ready",F=(o==null?void 0:o.consent)===!0&&R&&O,A=x?x.kind==="stop"?f(x.stopped?"audio-stop-stopped":"audio-stop-idle"):x.status==="accepted"||x.status==="spoken"?f("audio-test-accepted"):x.status==="unknown"?f("audio-test-unknown"):`${f("audio-test-refused")}${x.reason?` (${x.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:f("audio-title")}),l.jsx("br",{}),f("audio-help")]}),o?l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":f("audio-consent"),checked:o.consent===!0,disabled:t||b,onChange:T=>{L(T.target.checked)}}),l.jsxs("span",{children:[l.jsx("b",{children:f("audio-consent")}),l.jsx("small",{children:f("audio-consent-help")})]})]}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:f("audio-capability")}),l.jsxs("div",{className:"nc-set-info",children:[f("audio-adapter"),": ",o.adapter||f("audio-adapter-none"),l.jsx("br",{}),f("audio-installed"),": ",f(R?"audio-installed-yes":"audio-installed-no"),l.jsx("br",{}),f("audio-liveness"),": ",f(O?"audio-liveness-ready":"audio-liveness-unavailable"),Array.isArray(o.languages)&&o.languages.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("br",{}),f("audio-languages"),": ",o.languages.join(", ")]})]}),o.limits&&l.jsxs("small",{className:"nc-set-hint",children:[f("audio-limits"),": ",o.limits]})]}),!o.consent&&l.jsx("div",{className:"nc-set-info",children:f("audio-test-needs-consent")}),!R&&l.jsx("div",{className:"nc-set-info",children:f("audio-unavailable")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:t||b||!F,title:t?f("settings-readonly"):"",onClick:()=>{I()},children:f(b?"audio-testing":"audio-test")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:b,onClick:()=>{G()},children:f(b?"audio-stopping":"audio-stop")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:b,onClick:()=>{C()},children:f("refresh")})]}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:f("audio-groups-title")}),l.jsx("small",{className:"nc-set-hint",children:f("audio-groups-help")}),u.length===0&&l.jsx("div",{className:"nc-set-info",children:f("audio-groups-empty")}),u.map(T=>{var j;return l.jsxs("div",{className:"nc-set-row",children:[l.jsxs("span",{children:[l.jsx("b",{children:T.name})," ",l.jsxs("small",{children:["· ",T.mode==="fanout"?f("audio-group-fanout"):f("audio-group-primary")," · ",((j=T.targets)==null?void 0:j.length)||0]})]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||b,onClick:()=>W(T),children:f("audio-group-edit")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||b,onClick:()=>{$(T.name)},children:f("audio-group-delete")})]},T.name)}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||b,onClick:()=>W(null),children:f("audio-group-new")})}),l.jsxs("label",{className:"nc-field",children:[f("audio-group-name"),l.jsx("input",{"aria-label":f("audio-group-name"),value:p.name,maxLength:"32",disabled:t||b,onChange:T=>m(j=>({...j,name:T.target.value}))})]}),l.jsxs("label",{className:"nc-field",children:[f("audio-group-mode"),l.jsxs("select",{"aria-label":f("audio-group-mode"),value:p.mode,disabled:t||b,onChange:T=>m(j=>({...j,mode:T.target.value})),children:[l.jsx("option",{value:"primary-failover",children:f("audio-group-primary")}),l.jsx("option",{value:"fanout",children:f("audio-group-fanout")})]})]}),l.jsx("div",{className:"nc-set-info",children:f("audio-group-targets")}),K.length===0?l.jsx("small",{className:"nc-set-hint",children:f("audio-group-no-targets")}):K.map(T=>l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:p.targets.includes(T.id),disabled:t||b,onChange:j=>X(T.id,j.target.checked)}),l.jsxs("span",{children:[T.label,l.jsx("small",{children:T.id})]})]},T.id)),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:t||b,onClick:()=>{H()},children:f("audio-group-save")}),v&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:b,onClick:()=>W(null),children:f("audio-group-cancel")})]})]})]}):l.jsx("div",{className:"nc-set-info",children:f("audio-loading")}),A&&l.jsx("div",{className:"nc-set-note",role:"status",children:A}),w&&l.jsx("div",{className:"nc-err",children:w})]})}function tP(){const[e,t]=up();return l.jsxs("div",{className:"nc-set-tab nc-input-settings",children:[l.jsx("div",{className:"nc-set-info",children:f("input-settings-local")}),l.jsxs("div",{className:"nc-set-form",children:[l.jsxs("label",{className:"nc-field",children:[f("terminal-keyboard-gesture"),l.jsx("select",{"aria-label":f("terminal-keyboard-gesture"),value:e.terminalKeyboardGesture,onChange:n=>t({terminalKeyboardGesture:n.target.value}),children:Ew.map(n=>l.jsx("option",{value:n,children:f(`terminal-keyboard-${n}`)},n))}),l.jsx("small",{children:f("terminal-keyboard-gesture-help")})]}),l.jsxs("label",{className:"nc-field",children:[f("keybar-layout"),l.jsx("select",{"aria-label":f("keybar-layout"),value:e.keybarLayout,onChange:n=>t({keybarLayout:n.target.value}),children:Nw.map(n=>l.jsx("option",{value:n,children:f(`keybar-layout-${n}`)},n))}),l.jsx("small",{children:f("keybar-layout-help")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:e.keybarKeepsKeyboardClosed,onChange:n=>t({keybarKeepsKeyboardClosed:n.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:f("keybar-ime-lock")}),l.jsx("small",{children:f("keybar-ime-lock-help")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:e.voiceKeepsKeyboardClosed,onChange:n=>t({voiceKeepsKeyboardClosed:n.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:f("voice-ime-lock")}),l.jsx("small",{children:f("voice-ime-lock-help")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:e.showKeybarEnter,onChange:n=>t({showKeybarEnter:n.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:f("keybar-enter-show")}),l.jsx("small",{children:f("keybar-enter-show-help")})]})]}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>t(Ws),children:f("input-settings-reset")})})]})}function nP({token:e,roster:t=[],readonly:n}){const s=[{key:"local",route:[],label:f("diagnostics-local"),status:"up"},...t.filter(F=>Array.isArray(F.route)&&F.route.length).map(F=>({key:F.route.join("/"),route:F.route,label:F.label||F.name,status:F.status}))],[o,a]=k.useState("local"),u=s.find(F=>F.key===o)||s[0],[d,p]=k.useState(null),[m,v]=k.useState([]),[y,b]=k.useState(""),[S,x]=k.useState(!1),[E,w]=k.useState(!0),[N,C]=k.useState(900),[L,I]=k.useState("all"),[G,K]=k.useState(""),Y=k.useRef(0),Q=k.useRef(null),W=k.useCallback(async()=>{try{const F=await Fx(e,u.route);if(p(F),b(""),!S){const A=await Hx(e,{after:Y.current,limit:200},u.route);Array.isArray(A.records)&&A.records.length&&(Y.current=A.cursor,v(T=>[...T,...A.records].slice(-500)))}}catch(F){b(F&&F.status===404?f("diagnostics-unsupported"):String(F.message||F))}},[e,u.key,S]);k.useEffect(()=>{Y.current=0,v([]),p(null),b("")},[u.key]),k.useEffect(()=>{let F=null,A=!0;const T=()=>{!A||document.visibilityState==="hidden"||W()},j=()=>{F&&clearInterval(F),F=document.visibilityState==="hidden"?null:setInterval(T,2e3),document.visibilityState!=="hidden"&&T()};return document.addEventListener("visibilitychange",j),j(),()=>{A=!1,F&&clearInterval(F),document.removeEventListener("visibilitychange",j)}},[W]),k.useEffect(()=>{E&&Q.current&&(Q.current.scrollTop=Q.current.scrollHeight)},[m,E]);const X=m.filter(F=>(L==="all"||F.level===L)&&(!G||String(F.component||"").toLowerCase().includes(G.toLowerCase()))),H=X.map(F=>`${F.ts} ${F.level.toUpperCase()} ${F.component} ${F.code} ${F.message}${Object.keys(F.meta||{}).length?` ${JSON.stringify(F.meta)}`:""}`).join(`
92
- `),$=async F=>{b("");try{const A=await F();p(A),await W()}catch(A){b(String(A.message||A))}},R=async()=>{try{await navigator.clipboard.writeText(H)}catch{b(f("copy-manual"))}},O=()=>{try{const F=new Blob([`${JSON.stringify(X,null,2)}
93
- `],{type:"application/json"}),A=URL.createObjectURL(F),T=document.createElement("a");T.href=A,T.download="nexuscrew-diagnostics.json",T.click(),URL.revokeObjectURL(A)}catch{b(f("diagnostics-export-failed"))}};return l.jsxs("div",{className:"nc-set-tab nc-diagnostics",children:[l.jsxs("label",{className:"nc-field",children:[f("diagnostics-target"),l.jsx("select",{value:u.key,onChange:F=>a(F.target.value),children:s.map(F=>l.jsxs("option",{value:F.key,children:[F.label,F.status!=="up"?` · ${F.status}`:""]},F.key))})]}),l.jsxs("div",{className:"nc-set-form nc-diag-controls",children:[l.jsx("div",{className:"nc-sheet-label",children:f("diagnostics-verbose")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("select",{"aria-label":f("diagnostics-duration"),value:N,onChange:F=>C(Number(F.target.value)),disabled:n,children:[300,900,1800,3600].map(F=>l.jsxs("option",{value:F,children:[F/60," min"]},F))}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||(d==null?void 0:d.verbose)===!0,onClick:()=>$(()=>sv(e,!0,N,u.route)),children:f("enable")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||(d==null?void 0:d.verbose)!==!0,onClick:()=>$(()=>sv(e,!1,N,u.route)),children:f("stop")})]}),l.jsx("small",{className:"nc-set-hint",children:d!=null&&d.verbose?f("diagnostics-expires").replace("{time}",new Date(d.expiresAt).toLocaleTimeString()):f("diagnostics-off")})]}),l.jsxs("div",{className:"nc-diag-filters",children:[l.jsxs("select",{"aria-label":f("diagnostics-level"),value:L,onChange:F=>I(F.target.value),children:[l.jsx("option",{value:"all",children:f("diagnostics-all-levels")}),["debug","info","warn","error"].map(F=>l.jsx("option",{value:F,children:F},F))]}),l.jsx("input",{"aria-label":f("diagnostics-component"),placeholder:f("diagnostics-component"),value:G,onChange:F=>K(F.target.value)})]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:S,onChange:F=>x(F.target.checked)})," ",f("diagnostics-pause")]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:E,onChange:F=>w(F.target.checked)})," ",f("diagnostics-autoscroll")]})]}),l.jsx("pre",{ref:Q,className:"nc-diag-log","aria-label":f("diagnostics-log"),children:H||f("diagnostics-empty")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:R,children:f("copy")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:O,children:f("diagnostics-export")}),l.jsx("button",{type:"button",className:"nc-btn danger",disabled:n,onClick:()=>{window.confirm(f("diagnostics-clear-confirm"))&&$(async()=>{const F=await Ux(e,u.route);return Y.current=0,v([]),F})},children:f("diagnostics-clear")})]}),y&&l.jsx("div",{className:"nc-err",children:y})]})}function iP({token:e,settings:t,readonly:n,refresh:s,roster:o,section:a,setSection:u}){const[d,p]=k.useState(null),[m,v]=k.useState(null),[y,b]=k.useState(!1),[S,x]=k.useState(!1),[E,w]=k.useState(null),[N,C]=k.useState(!0),[L,I]=k.useState(!1);k.useEffect(()=>{w(t&&t.update||null),C(!t||t.autoUpdate!==!1),I(!!(t&&t.alternateScreen))},[t]);const G=async()=>{p(null),v(null),x(!0);try{const R=await xx(e);v(R.note||"ok"),b(!1)}catch(R){p(String(R.message||R))}x(!1)},K=async()=>{p(null),v(null),x(!0);try{const R=await Bx(e);v(`${R.note||"ok"}${R.target?` (${R.target})`:""}`)}catch(R){p(String(R.message||R))}x(!1)},Y=async R=>{p(null),v(null),x(!0);try{await gh(e,{autoUpdate:R}),C(R),s&&await s()}catch(O){p(String(O.message||O))}x(!1)},Q=async R=>{p(null),v(null),x(!0);try{await gh(e,{alternateScreen:R}),I(R),s&&await s()}catch(O){p(String(O.message||O))}x(!1)},W=async()=>{p(null),v(null),x(!0);try{w(await zx(e))}catch(R){p(String(R.message||R))}x(!1)},X=async()=>{p(null),v(null),x(!0);try{const R=await $x(e);w(R),v(f("npm-update-restarting"))}catch(R){p(String(R.message||R))}x(!1)},H=()=>{window.confirm(f("composer-clear-confirm"))&&(p(null),a2()?(window.dispatchEvent(new Event(mf)),v(f("composer-clear-done"))):p(f("composer-clear-failed")))},$=t&&t.service;return l.jsxs("div",{className:"nc-set-tab",children:[l.jsx("div",{className:"nc-system-tabs",role:"tablist","aria-label":f("tab-system"),children:["general","diagnostics"].map(R=>l.jsx("button",{type:"button",role:"tab","aria-selected":a===R,className:`nc-set-tabbtn${a===R?" on":""}`,onClick:()=>u(R),children:f(`system-${R}`)},R))}),a==="general"&&l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:f("system-this-node")}),t&&l.jsxs("div",{className:"nc-set-info",children:["v",t.version," · ",t.platform," · :",t.port,l.jsx("br",{}),$&&$.installed?f("service-installed"):f("service-missing"),$&&$.installed?` · ${$.active?f("service-active"):f("service-inactive")}`:"",$?` · boot ${$.boot?"on":"off"}`:""]}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||S,title:n?f("settings-readonly"):"",onClick:K,children:f("service-regenerate")})}),l.jsx(JR,{token:e,readonly:n}),l.jsx(ZR,{})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:f("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||S||E&&!E.supported,onChange:R=>Y(R.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:f("npm-auto-update")}),l.jsx("small",{children:f("npm-auto-update-help")})]})]}),E&&l.jsxs("div",{className:"nc-set-info",children:[f("npm-update-current")," v",E.current,E.latest?` · ${f("npm-update-latest")} v${E.latest}`:""," · ",f(E.supported?E.phase==="idle"&&E.checked!==!0?"npm-update-never":`npm-update-${E.phase}`:"unsupported")]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||S||!E||!E.supported,onClick:W,children:f("npm-update-check")}),E&&E.available&&l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||S||E.phase==="installing",onClick:X,children:f("npm-update-install")})]}),E&&E.lastError&&l.jsx("div",{className:"nc-err",children:E.lastError})]})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:f("system-security")}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||S,title:n?f("settings-readonly"):"",onClick:()=>{p(null),v(null),b(!0)},children:f("token-rotate")})})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:f("system-local-data")}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:f("composer-clear-data")}),l.jsx("small",{className:"nc-set-hint",children:f("composer-clear-data-help")}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:H,children:f("composer-clear-data")})})]})]})]}),a==="diagnostics"&&l.jsxs("section",{className:"nc-system-group nc-system-diagnostics",children:[l.jsx("h3",{children:f("system-diagnostics")}),l.jsxs("div",{className:"nc-set-form nc-alternate-screen-settings",children:[l.jsx("div",{className:"nc-sheet-label",children:f("system-terminal")}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":f("alternate-screen"),checked:L,disabled:n||S,onChange:R=>Q(R.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:f("alternate-screen")}),l.jsx("small",{children:f("alternate-screen-help")})]})]})]}),l.jsx(nP,{token:e,roster:o,readonly:n})]}),y&&l.jsxs("div",{className:"nc-set-confirm",children:[l.jsx("div",{children:f("token-rotate-explain")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:S,onClick:()=>b(!1),children:f("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:S,onClick:G,children:f("confirm")})]})]}),m&&l.jsx("div",{className:"nc-set-note",children:m}),d&&l.jsx("div",{className:"nc-err",children:d})]})}function sP({token:e,onClose:t,initialTab:n="nodes",initialLocation:s="",startNewCell:o=!1}){Yn();const a=n==="diagnostics"?"diagnostics":"general",[u,d]=k.useState(n==="diagnostics"?"system":n),p=k.useRef(null),m=k.useRef(null),[v,y]=k.useState({start:!1,end:!1}),[b,S]=k.useState(a),[x,E]=k.useState(null),[w,N]=k.useState([]),[C,L]=k.useState([]),[I,G]=k.useState(!1),[K,Y]=k.useState(null),[Q,W]=k.useState(0),X=zf(e,!0,Q),H=k.useCallback(()=>{const R=p.current;if(!R)return;const O=R.scrollWidth>R.clientWidth+1,F={start:O&&R.scrollLeft>1,end:O&&R.scrollLeft+R.clientWidth<R.scrollWidth-1};y(A=>A.start===F.start&&A.end===F.end?A:F)},[]);k.useEffect(()=>{const R=p.current;if(!R)return;const O=typeof ResizeObserver=="function"?new ResizeObserver(H):null;return O==null||O.observe(R),window.addEventListener("resize",H),H(),()=>{O==null||O.disconnect(),window.removeEventListener("resize",H)}},[H]),k.useEffect(()=>{var O,F;(F=(O=m.current)==null?void 0:O.scrollIntoView)==null||F.call(O,{behavior:"smooth",block:"nearest",inline:"nearest"});const R=window.requestAnimationFrame?window.requestAnimationFrame(H):setTimeout(H,0);return()=>{window.cancelAnimationFrame?window.cancelAnimationFrame(R):clearTimeout(R)}},[u,H]);const $=k.useCallback(async()=>{var R;try{const O=await Ky(e);E(O),Y(null)}catch(O){Y(String(O.message||O))}try{const F=(await wx(e)).peers||[];let A=[],T=[];try{const[j,z]=await Promise.all([on("/api/config",e).then(U=>U.json()).catch(()=>null),Vy(e).catch(()=>null)]),M=j&&typeof j.instanceId=="string"?j.instanceId:"",D=[{instanceId:M||null,route:[],label:null},...nb(z,M)],B=await Promise.all(D.map(async U=>{try{return{ok:!0,peers:((await qy(e,U.route)).nodes||[]).map(de=>tb(de,U)).filter(Boolean)}}catch(se){return{ok:!1,owner:U,error:se}}}));for(const U of B){if(U.ok){A.push(...U.peers);continue}U.owner.route.length!==0&&T.push({instanceId:U.owner.instanceId,label:U.owner.label,route:U.owner.route,failure:/timeout/i.test(String(((R=U.error)==null?void 0:R.message)||U.error))?"timeout":"unreachable"})}}catch{}L(T),N([...F,...A])}catch(O){Y(String(O.message||O))}},[e]);return k.useEffect(()=>{$();const R=setInterval($,5e3);return()=>clearInterval(R)},[$]),k.useEffect(()=>{let R=!1;return on("/api/config",e).then(O=>O.json()).then(O=>{R||G(!!O.readonlyDefault)}).catch(()=>{}),()=>{R=!0}},[e]),l.jsx("div",{className:"nc-set-overlay",onClick:t,children:l.jsxs("div",{className:"nc-set-panel",onClick:R=>R.stopPropagation(),children:[l.jsxs("div",{className:"nc-set-head",children:[l.jsx(lt,{name:"gear",size:18}),l.jsx("b",{children:f("settings")}),l.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:f("close"),children:l.jsx(lt,{name:"x",size:18})})]}),I&&l.jsx("div",{className:"nc-set-readonly",children:f("settings-readonly")}),K&&l.jsx("div",{className:"nc-err",children:K}),l.jsx("div",{className:`nc-set-tabs-wrap${v.start?" has-start-overflow":""}${v.end?" has-end-overflow":""}`,children:l.jsx("div",{className:"nc-set-tabs",ref:p,onScroll:H,children:["nodes","fleet","audio","input","system"].map(R=>l.jsx("button",{ref:u===R?m:null,type:"button",className:`nc-set-tabbtn${u===R?" on":""}`,onClick:()=>d(R),children:f(`tab-${R}`)},R))})}),l.jsxs("div",{className:"nc-set-body",children:[u==="nodes"&&l.jsx(QR,{token:e,nodes:w,roster:X,settings:x,readonly:I,vlUnavailable:C,refresh:$,refreshAliases:()=>W(R=>R+1)}),u==="fleet"&&l.jsx(AR,{token:e,readonly:I,startNewCell:o,initialLocation:s,targets:X.map(R=>({route:R.route,label:R.label||R.name,status:R.status}))}),u==="audio"&&l.jsx(eP,{token:e,readonly:I,nodes:w,settings:x}),u==="input"&&l.jsx(tP,{}),u==="system"&&l.jsx(iP,{token:e,settings:x,readonly:I,refresh:$,roster:X,section:b,setSection:S})]})]})})}function rP({token:e,initialPair:t,deviceDefault:n="",localNodeId:s="",localNameDefault:o="",onPairDone:a,onDone:u}){Yn();const[d,p]=k.useState(t?"pair":"welcome"),[m,v]=k.useState(!1),[y,b]=k.useState(null),[S,x]=k.useState(null),E=async()=>{v(!0),b(null);try{await gh(e,{wizardDone:!0}),a&&a(),u()}catch(w){b(String(w.message||w)),v(!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:f("wizard-title")}),l.jsx("small",{children:f("hydra-simple")})]}),d==="welcome"&&l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx("div",{className:"nc-wiz-done",children:f("local-ready")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",disabled:m,onClick:E,children:f("local-only")}),l.jsx("button",{className:"nc-btn primary",disabled:m,onClick:()=>p("pair"),children:f("add-node")})]})]}),d==="pair"&&l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx(Gw,{token:e,initial:t||"",autoStart:!!t,deviceDefault:n,localNodeId:s,localNameDefault:o,onBusyChange:v,onSuccess:async w=>{x(w&&w.authorizedKeys?{line:w.authorizedKeys,note:w.authorizedKeysNote||""}:null),a&&a(),p("done")}}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{className:"nc-btn ghost",disabled:m,onClick:()=>{a&&a(),p("welcome")},children:f("back")})})]}),d==="done"&&l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx("div",{className:"nc-wiz-done",children:f("node-connected")}),S&&l.jsx(bp,{line:S.line,note:S.note}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{className:"nc-btn primary",disabled:m,onClick:E,children:f("finish")})})]}),y&&l.jsx("div",{className:"nc-err",children:y})]})})}function oP(e,t){if(typeof EventSource>"u"||!e)return()=>{};const n=new EventSource(`/api/events?token=${encodeURIComponent(e)}`);return n.onmessage=s=>{try{const o=JSON.parse(s.data);o&&typeof o=="object"&&typeof o.type=="string"&&t(o)}catch{}},()=>{try{n.close()}catch{}}}const aP=6e3,lP=12e3;function cP({n:e,onClose:t}){return l.jsxs("div",{className:`nc-ntf-toast${e.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[l.jsxs("div",{className:"nc-ntf-toast-txt",children:[l.jsx("b",{children:e.title}),e.body&&l.jsx("small",{children:e.body}),e.session&&l.jsx("span",{className:"nc-ntf-from",children:e.session})]}),l.jsx("button",{type:"button",className:"nc-ntf-x",onClick:t,title:f("close"),children:l.jsx(lt,{name:"x",size:14})})]})}function uP({ask:e,token:t,onAnswered:n,onDismiss:s}){const[o,a]=k.useState(""),[u,d]=k.useState(!1),[p,m]=k.useState(null),[v,y]=k.useState(!1),b=async x=>{const E=String(x||"").trim();if(!(!E||u)){m(null),d(!0);try{await Kx(t,e.id,E),n(e.id)}catch(w){m(String(w.message||w))}d(!1)}},S=async()=>{if(!v){y(!0);try{await qx(t,e.id),s(e.id)}catch{y(!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:e.session}),l.jsxs("code",{className:"nc-ask-id",children:["#",e.id]}),l.jsx("button",{type:"button",className:"nc-ask-dismiss",title:f("ask-dismiss"),"aria-label":f("ask-dismiss"),disabled:v,onClick:S,children:l.jsx(lt,{name:"x",size:14})})]}),l.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&l.jsx("div",{className:"nc-ask-opts",children:e.options.map(x=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u,onClick:()=>b(x),children:x},x))}),l.jsxs("div",{className:"nc-ask-reply",children:[l.jsx("textarea",{rows:2,placeholder:f("ask-reply-ph"),value:o,disabled:u,onChange:x=>a(x.target.value)}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:u||!o.trim(),onClick:()=>b(o),children:f("send")})]}),p&&l.jsx("div",{className:"nc-err",children:p})]})}function dP({token:e}){const[t]=Yn(),[n]=hS(),[s,o]=k.useState([]),[a,u]=k.useState([]),[d,p]=k.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),m=k.useRef(0),v=k.useRef(null);v.current||(v.current=YR());const y=k.useRef({enabled:n,lang:t});y.current={enabled:n,lang:t};const b=k.useCallback(w=>{o(N=>N.filter(C=>C.key!==w))},[]),S=k.useCallback(w=>{const N=`t${m.current+=1}`;o(L=>[...L.slice(-3),{...w,key:N}]),setTimeout(()=>b(N),w.urgency==="high"?lP:aP);const C=y.current;if(C.enabled)try{v.current.enqueue(w,UR(w,C.lang))}catch{}},[b]);k.useEffect(()=>{n||v.current.stop()},[n]),k.useEffect(()=>{const w=()=>{(document.visibilityState!=="visible"||!document.hasFocus())&&v.current.stop()},N=()=>v.current.stop();return document.addEventListener("visibilitychange",w),window.addEventListener("blur",w),window.addEventListener(xf,N),()=>{document.removeEventListener("visibilitychange",w),window.removeEventListener("blur",w),window.removeEventListener(xf,N),typeof v.current.dispose=="function"?v.current.dispose():v.current.stop()}},[]),k.useEffect(()=>{if(!e)return;let w=!1;Wx(e).then(C=>{w||u(C.asks||[])}).catch(()=>{});const N=oP(e,C=>{C.type==="notify"?S(C):C.type==="ask"&&C.ask&&C.ask.id?u(L=>L.some(I=>I.id===C.ask.id)?L:[...L,C.ask]):C.type==="ask-answered"&&C.id?u(L=>L.filter(I=>I.id!==C.id)):C.type==="ask-dismissed"&&C.id&&u(L=>L.filter(I=>I.id!==C.id))});return()=>{w=!0,N()}},[e,S]);const x=w=>u(N=>N.filter(C=>C.id!==w)),E=w=>u(N=>N.filter(C=>C.id!==w));return l.jsxs(l.Fragment,{children:[s.length>0&&l.jsx("div",{className:"nc-ntf-toasts",children:s.map(w=>l.jsx(cP,{n:w,onClose:()=>b(w.key)},w.key))}),a.length>0&&!d&&l.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>p(!0),title:f("asks-title"),children:["? ",l.jsx("span",{className:"nc-ask-count",children:a.length})]}),a.length>0&&d&&l.jsxs("div",{className:"nc-ask-panel",children:[l.jsxs("div",{className:"nc-ask-panel-head",children:[l.jsx("b",{children:f("asks-title")}),l.jsx("span",{className:"nc-ask-count",children:a.length}),l.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>p(!1),title:f("close"),children:l.jsx(lt,{name:"x",size:16})})]}),l.jsx("div",{className:"nc-ask-panel-body",children:a.map(w=>l.jsx(uP,{ask:w,token:e,onAnswered:x,onDismiss:E},w.id))})]})]})}const hP=4e3;async function fP(e){const t=await on("/api/sessions",e);if((t==null?void 0:t.ok)===!1)throw new Error(`HTTP ${t.status}`);const n=await t.json();if(!Array.isArray(n==null?void 0:n.sessions))throw new Error("invalid sessions payload");return n.sessions}async function hh(e,t=[]){var d;const[n,s]=await Promise.allSettled([t.length?Tf(e,t):fP(e),Xs(e,t)]),o=n.status==="fulfilled"&&Array.isArray((d=n.value)==null?void 0:d.sessions)?n.value.sessions:Array.isArray(n.value)?n.value:null,a=s.status==="fulfilled"?s.value:null,u=(a==null?void 0:a.available)===!0&&Array.isArray(a.cells)?a.cells:null;return{sessions:o,cells:u,fresh:Array.isArray(o)&&Array.isArray(u)}}function fS(e,t,n){return n===!0&&(e==null?void 0:e.degraded)!==!0&&(e==null?void 0:e.active)===!0&&e.tmux!==!1&&!!e.tmuxSession&&(t||[]).some(s=>(s==null?void 0:s.name)===e.tmuxSession)}function pP(e){const t=new Map((e.sessions||[]).map(o=>[o.name,o])),n=[],s=(o,a,u,d=[],p="")=>{const m=new Map((a||[]).map(v=>[v.name,v]));for(const v of o||[]){const y=m.get(v.tmuxSession)||{},b=Uf(v,y),S=fS(v,a,u);n.push({key:ka(d,v.tmuxSession||v.cell),session:v.tmuxSession,route:d,cellName:v.cell,label:v.cell,node:d.length?d.join("/"):"",nodeLabel:p,live:S,selectable:S,verified:u===!0,working:b.working,degraded:!!v.degraded,active:v.active===!0,activity:y.activity||v.activity||0,subtitle:b.subtitle,preview:y.preview||v.preview||"",telemetry:y.telemetry||null,panelUrl:v.panelUrl||""})}};s(e.cells,[...t.values()],e.localFresh===!0);for(const o of e.nodeGroups||[]){const a=Array.isArray(o.route)?o.route:[];o.kind==="vl"||!a.length||s(o.cells,o.sessions,o.switcherFresh===!0,a,o.label||o.name||"")}return n}function mP(e){const t=new Map,n=Array.isArray(e.sessions)?e.sessions:[],s=Array.isArray(e.cells)?e.cells:[],o=new Map(n.map(u=>[u.name,u])),a=new Set(s.map(u=>u.tmuxSession).filter(Boolean));t.set("local",Wf(s,n.filter(u=>!a.has(u.name)),o));for(const u of e.nodeGroups||[]){const d=Array.isArray(u.route)?u.route:[];if(u.kind==="vl"||!d.length)continue;const p=Array.isArray(u.cells)?u.cells:[],m=Array.isArray(u.sessions)?u.sessions:[],v=new Set(p.map(y=>y.tmuxSession).filter(Boolean));t.set(d.join("/"),fc({...u,route:d,cells:p,sessions:m,unmanaged:m.filter(y=>!v.has(y.name))}).rawItems)}return t}function gP(e,t,n,s){return[...new Set(e.map(a=>a.node||"local"))].flatMap(a=>{const u=e.filter(v=>(v.node||"local")===a),d=new Map((t.get(a)||[]).map(v=>[v.key,v])),p=new Map(u.map(v=>[v.key,v])),m=u.map(v=>{const y=d.get(v.key);return{...v,label:(y==null?void 0:y.label)||v.label,live:(y==null?void 0:y.live)??v.live,fresh:(y==null?void 0:y.fresh)===!0,activity:(y==null?void 0:y.activity)??v.activity}});return qs(m,n,"all",ms(s,a)).map(v=>p.get(v.key))})}function vP({token:e,current:t,onPick:n,onClose:s,panelPort:o=0,nodePanelPorts:a={}}){const[u,d]=k.useState(wv),[p,m]=k.useState(!1),[v,y]=k.useState(!1),[b,S]=k.useState(""),[x,E]=k.useState(null),[w,N]=k.useState(""),[C,L]=k.useState(""),I=k.useRef(null),G=k.useRef(null),K=k.useMemo(()=>pP(u),[u]),Y=k.useMemo(()=>mP(u),[u]),{pins:Q,orders:W,canMoveRoster:X,moveRoster:H,stepRoster:$}=Ff(),R=k.useMemo(()=>gP(K,Y,Q,W),[K,Y,Q,W]),O=k.useMemo(()=>p?R:R.filter(M=>M.selectable||M.degraded&&M.active),[R,p]),F=k.useMemo(()=>K.find(M=>M.key===w&&M.selectable),[K,w]),A=k.useMemo(()=>x?K.find(M=>M.key===x.key):null,[K,x]);k.useEffect(()=>{var B;const M=document.activeElement;(B=G.current)==null||B.focus();const D=U=>{U.key==="Escape"&&s()};return document.addEventListener("keydown",D),()=>{var U;document.removeEventListener("keydown",D),(U=M==null?void 0:M.focus)==null||U.call(M)}},[s]),k.useEffect(()=>{let M=!0,D=!1;const B=async()=>{if(D)return;D=!0;const se=wv(),ee=Array.isArray(se.nodeGroups)?se.nodeGroups:[],de=hh(e),ve=je=>je.kind!=="vl"&&Array.isArray(je.route)&&je.route.length>0,fe=await Promise.all(ee.filter(ve).map(async je=>({group:je,result:await hh(e,je.route)}))),pe=await de;if(!M)return;const Ve=new Map(fe.map(({group:je,result:Ct})=>[JSON.stringify(je.route||[]),Ct])),ut=ee.map(je=>{if(!ve(je))return{...je,switcherFresh:!1};const Ct=Ve.get(JSON.stringify(je.route||[]));return Ct?{...je,sessions:Ct.sessions||je.sessions||[],cells:Ct.cells||je.cells||[],switcherFresh:Ct.fresh}:{...je,switcherFresh:!1}}),vt=bb({...se,sessions:pe.sessions||se.sessions||[],cells:pe.cells||se.cells||[],localFresh:pe.fresh,nodeGroups:ut,refreshedAt:Date.now()});d(vt),y(!0),D=!1};B();const U=setInterval(B,hP);return()=>{M=!1,clearInterval(U)}},[e]);const T=M=>M.degraded?f("cell-degraded"):M.verified?M.selectable?M.working?f("cell-working"):f("cell-idle"):f("cell-off"):f("cell-switcher-not-confirmed"),j=M=>{if(S(""),!M.selectable){S(M.verified?f("cell-switcher-not-active"):f("cell-switcher-not-confirmed"));return}N(M.key)},z=async()=>{const M=F;if(!M){S(f("cell-switcher-select"));return}S(""),L(M.key);try{const D=await hh(e,M.route),B=(D.cells||[]).find(U=>(U==null?void 0:U.cell)===M.cellName&&(U==null?void 0:U.tmuxSession)===M.session);if(D.fresh!==!0){S(f("cell-switcher-verify-failed"));return}if(!fS(B,D.sessions,D.fresh)){S(f("cell-switcher-not-active"));return}n({session:M.session,...M.node?{node:M.node}:{},cellName:M.cellName}),s()}catch{S(f("cell-switcher-verify-failed"))}finally{L("")}};return l.jsx("div",{className:"nc-cell-switcher-backdrop",onClick:s,children:l.jsxs("aside",{ref:I,className:"nc-cell-switcher",role:"dialog","aria-label":f("fleet-cells"),tabIndex:-1,onClick:M=>M.stopPropagation(),children:[l.jsxs("div",{className:"nc-cell-switcher-list",children:[!v&&l.jsx("div",{className:"nc-empty",role:"status",children:f("cell-switcher-refreshing")}),v&&O.length===0&&l.jsx("div",{className:"nc-empty",role:"status",children:f("cell-switcher-empty-active")}),O.map(M=>{const D=(t==null?void 0:t.session)===M.session&&((t==null?void 0:t.node)||"")===M.node,B=w===M.key,U=T(M),se=vf(f,M.activity),ee=_f(f,M.telemetry),de=[se,ee].filter(Boolean).join(" · "),ve=M.node||"local",fe=Y.get(ve)||K.filter(pe=>(pe.node||"local")===ve);return l.jsxs("div",{className:`nc-cell-switcher-row${D?" current":""}${B?" selected":""}${M.selectable?"":" off"}`,"data-roster-key":M.key,"data-position":ve,children:[l.jsx(Yi,{position:ve,itemKey:M.key,label:M.cellName,canMove:X,onMove:(pe,Ve)=>H(ve,pe,Ve,fe),onStep:pe=>$(ve,M.key,pe,fe)}),l.jsx("button",{type:"button",className:"nc-cell-switcher-peek",title:f("cell-peek"),"aria-label":`${f("cell-peek")}: ${M.cellName}`,onClick:pe=>{pe.stopPropagation(),E({key:M.key,source:"preview"})},children:l.jsx("span",{className:`nc-cell-switcher-dot${M.degraded?" warn":M.live?` on${M.working?" working":""}`:""}`})}),l.jsxs("span",{className:"nc-cell-switcher-acts",children:[l.jsx("button",{type:"button",className:"nc-cell-switcher-act",title:f("cell-peek-stream"),"aria-label":`${f("cell-peek-stream")}: ${M.cellName}`,onClick:pe=>{pe.stopPropagation(),E({key:M.key,source:"stream"})},children:"▶"}),M.panelUrl&&l.jsx("button",{type:"button",className:"nc-cell-switcher-act",title:f("cell-peek-panel"),"aria-label":`${f("cell-peek-panel")}: ${M.cellName}`,onClick:pe=>{pe.stopPropagation(),E({key:M.key,source:"panel"})},children:"▣"})]}),l.jsx("button",{type:"button",className:"nc-cell-switcher-row-select","aria-current":D?"true":void 0,"aria-pressed":B,"aria-disabled":!M.selectable,disabled:C===M.key,onClick:()=>j(M),children:l.jsxs("span",{className:"nc-cell-switcher-copy",children:[l.jsx("b",{children:M.cellName}),l.jsx("small",{className:"nc-cell-switcher-state",children:U}),l.jsx("small",{children:[M.nodeLabel,M.subtitle].filter(Boolean).join(" · ")}),de&&l.jsx("small",{className:"nc-cell-switcher-telemetry",children:de})]})})]},M.key)})]}),b&&l.jsx("div",{className:"nc-cell-switcher-notice",role:"status",children:b}),x&&A&&l.jsx(Cw,{row:A,token:e,initialSource:x.source,panelPort:kc(A.route||[],a,o),onClose:()=>E(null)}),l.jsx("div",{className:"nc-cell-switcher-actions",children:l.jsx("button",{type:"button",className:"nc-cell-switcher-open",disabled:!F||!!C,onClick:z,children:F?`${f("cell-switcher-open")}: ${F.cellName}`:f("cell-switcher-select")})}),l.jsxs("div",{className:"nc-cell-switcher-controls",children:[l.jsx("b",{children:f("fleet-cells")}),l.jsx("button",{type:"button",className:"nc-cell-switcher-filter","aria-pressed":p,onClick:()=>{S(""),m(M=>!M)},children:f(p?"cell-switcher-show-active":"cell-switcher-show-all")}),l.jsx("button",{ref:G,type:"button",className:"nc-cell-switcher-close","aria-label":f("cell-switcher-close"),title:f("cell-switcher-close"),onClick:s,children:"×"})]})]})})}const _P=2e3;function yP(e){if(e.kind==="gap")return`${f("vl-events-gap")} ${e.count||"?"}`;if(e.kind==="truncate")return f("vl-events-truncated");if(e.kind==="turn_end")return f("vl-events-turn-end");if(e.kind==="done")return f("vl-events-done");if(e.kind==="writer_epoch")return f("vl-events-writer-epoch");if(e.kind==="tool_start")return`${f("vl-events-tool")} ${e.name||""}`.trim();if(e.kind==="tool_end"){const t=e.isError?f("vl-events-tool-failed"):f("vl-events-tool-ok");return`${f("vl-events-tool")} ${e.name||""} — ${t}`.trim()}return e.kind==="usage"?e.text||f("vl-events-usage"):e.text||""}function bP({token:e,nodeId:t,route:n=[]}){const[s,o]=k.useState([]),[a,u]=k.useState(!1),d=k.useRef(0),p=k.useRef(!1);return k.useEffect(()=>{let m=!0;d.current=0,p.current=!1,o([]);const v=async()=>{if(!p.current){p.current=!0;try{const S=await Sx(e,t,d.current,n);if(!m)return;u(!1);const E=(Array.isArray(S==null?void 0:S.events)?S.events:[]).filter(w=>Number.isSafeInteger(w==null?void 0:w.seq)&&w.seq>d.current);E.length&&(o(w=>w.concat(E).slice(-500)),d.current=E[E.length-1].seq),Number.isSafeInteger(S==null?void 0:S.cursor)&&S.cursor>d.current&&(d.current=S.cursor)}catch{m&&u(!0)}finally{p.current=!1}}},y=()=>{v().catch(()=>{})};y();const b=setInterval(y,_P);return()=>{m=!1,clearInterval(b)}},[e,t,JSON.stringify(n)]),l.jsxs("div",{className:"nc-vl-events",children:[a&&l.jsx("div",{className:"nc-set-hint nc-vl-events-stale",children:f("vl-events-stale")}),s.length===0&&!a&&l.jsx("small",{className:"nc-set-hint","data-testid":"vl-events-empty",children:f("vl-events-empty")}),s.length>0&&l.jsx("ol",{className:"nc-vl-events-list",children:s.map(m=>l.jsx("li",{"data-testid":`vl-ev-${m.seq}`,className:`nc-vl-ev nc-vl-ev-${m.kind}${m.isError?" error":""}${m.kind==="gap"?" gap":""}`,children:yP(m)},`${m.seq}-${m.kind}`))})]})}function Ay({peer:e,token:t,onBack:n}){var s;return Yn(),e?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:f("back"),children:[l.jsx(lt,{name:"chevronLeft",size:18}),l.jsx("span",{className:"nc-bar-label",children:f("back")})]}),l.jsxs("span",{className:"nc-bar-center",children:[l.jsx("b",{title:e.label,children:e.label}),((s=e.session)==null?void 0:s.profile)&&l.jsxs("small",{className:"nc-bar-sub",children:[e.session.profile," · ",f("vl-events-title")]})]}),l.jsx("span",{className:"nc-bar-right"})]}),l.jsx("div",{className:"nc-vl-session-body",children:l.jsx(bP,{token:t,nodeId:e.nodeId,route:e.route||[]})})]}):null}const fh=e=>Qi(xr(e)).length===0,ph=e=>Array.isArray(e)?e.join("/"):"";function wP(e){const t=new Set,n=[];for(const s of Array.isArray(e)?e:[])!s||!gi.test(String(s.instanceId||""))||!Array.isArray(s.route)||!s.route.length||t.has(s.instanceId)||(t.add(s.instanceId),n.push({instanceId:s.instanceId,route:[...s.route],label:String(s.label||s.name||s.route.join(" › ")),status:s.status||"offline"}));return n.sort((s,o)=>s.label.localeCompare(o.label))}function ha(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function vr(e,t,n,s=!1,o=!0){const a=t.instanceId;return{...e,id:po(s?null:a,e.name),ownerId:a,ownerRoute:s?[]:[...t.route],ownerLabel:s?"Local":t.label,local:s,available:o,ownerTopology:Array.isArray(n)?n:[],layout:yf(e.layout,a,n)}}function SP(e,t,n,s,o=[]){const[a,u]=k.useState([]),[d,p]=k.useState(!1),[m,v]=k.useState("idle"),[y,b]=k.useState(""),[S,x]=k.useState(""),E=k.useRef([]),w=k.useRef([]),N=k.useRef(""),C=k.useRef(t),L=k.useRef(n),I=k.useRef(!1),G=k.useRef(!0),K=k.useRef(""),Y=k.useMemo(()=>wP(o),[o]),Q=Y.map(M=>`${M.instanceId}:${ph(M.route)}:${M.status}:${M.label}`).join("|");w.current=Y,L.current=n,C.current=t,E.current=a;const W=k.useCallback(M=>bf(M.layout,N.current,w.current),[]),X=k.useCallback((M,D=!0,B=C.current)=>{const U=O_(M,Gl()),se=E.current.some(de=>de.id===B);E.current=U,u(U);const ee=U.find(de=>de.id===B);if(D&&ee){G.current=!0;const de=W(ee);s(de),ee.local&&B2(ee.name,de)}else se&&!ee&&(G.current=!0,s(fo()),b("deck non più condiviso dal nodo owner"));T2(U.filter(de=>de.local).map(de=>de.name))},[s,W]),H=k.useCallback(async M=>{let D=await $l(e);const B=D.decks.find(U=>U.name==="main");if(D.decks.length===1&&B&&B.revision===0&&fh(B.layout)){const U=M2(),se=xr(wf("main")||fo());if(!fh(se)){const ee=yf(se,M,[]);D.decks[0]=await Fl(e,"main",ee,0,[])}for(const ee of U.filter(de=>de!=="main"))try{let de=await rv(e,ee,[]);const ve=xr(wf(ee)||fo());fh(ve)||(de=await Fl(e,ee,yf(ve,M,[]),de.revision,[]))}catch{}D=await $l(e)}return D},[e]),$=k.useCallback(async({migrate:M=!1}={})=>{const D=await Df(e,[]),B=gi.test(String(D.instanceId||""))?D.instanceId:"";if(!B)throw new Error("instanceId locale non disponibile");N.current=B,x(B);const[U,se]=await Promise.all([M?H(B):$l(e),tv(e,[]).catch(()=>({nodes:[]}))]),ee={instanceId:B,route:[],label:"Local"},de=U.decks.map(fe=>vr(fe,ee,se.nodes,!0,!0)),ve=E.current;return await Promise.all(w.current.map(async fe=>{if(fe.status!=="up"){de.push(...ve.filter(pe=>!pe.local&&pe.ownerId===fe.instanceId).map(pe=>({...pe,ownerRoute:[...fe.route],ownerLabel:fe.label,available:!1})));return}try{const[pe,Ve]=await Promise.all([$l(e,fe.route),tv(e,fe.route).catch(()=>({nodes:[]}))]);de.push(...pe.decks.map(ut=>vr(ut,fe,Ve.nodes,!1,!0)))}catch{de.push(...ve.filter(Ve=>!Ve.local&&Ve.ownerId===fe.instanceId).map(Ve=>({...Ve,ownerRoute:[...fe.route],ownerLabel:fe.label,available:!1})))}})),de.sort((fe,pe)=>fe.local===pe.local?fe.ownerLabel.localeCompare(pe.ownerLabel)||(fe.name==="main"?-1:pe.name==="main"?1:fe.name.localeCompare(pe.name)):fe.local?-1:1),de},[e,H,Q]);k.useEffect(()=>{if(!e)return;let M=!1;const D=K.current!==e;return K.current=e,$({migrate:D}).then(B=>{if(M)return;const U=E.current.find(de=>de.id===C.current),se=B.find(de=>de.id===C.current),ee=se&&(!U||se.revision>U.revision||U.available!==se.available||ph(U.ownerRoute)!==ph(se.ownerRoute));X(B,D||!!ee&&!I.current),p(!0),se&&b("")}).catch(B=>{M||(p(!0),b(String(B.message||B)))}),()=>{M=!0}},[X,$,Q,e]);const R=k.useCallback(async(M=C.current)=>{if(!d||!I.current)return!0;const D=E.current.find(B=>B.id===M);if(!D)return b(`deck inesistente: ${M}`),!1;if(D.available===!1)return b(`nodo owner offline: ${D.ownerLabel}`),!1;v("saving");try{const B=D_(xr(L.current),D.ownerId,D.ownerTopology),U=await Fl(e,D.name,B,D.revision,D.ownerRoute),se=vr(U,ha(D),D.ownerTopology,D.local,!0);return X(E.current.map(ee=>ee.id===M?se:ee),!1),I.current=!1,v("saved"),b(""),setTimeout(()=>v("idle"),1500),!0}catch(B){if(v("error"),b(String(B.message||B)),B.status===409&&B.data&&B.data.current){const U=E.current.find(ee=>ee.id===M),se=vr(B.data.current,ha(U),U.ownerTopology,U.local,!0);X(E.current.map(ee=>ee.id===M?se:ee),!1)}return!1}},[d,e,X]);return k.useEffect(()=>{if(!d)return;if(G.current){G.current=!1;return}I.current=!0,v("saving");const M=setTimeout(R,650);return()=>clearTimeout(M)},[n,d,R]),k.useEffect(()=>{if(!d)return;const M=setInterval(async()=>{try{const D=await $(),B=E.current.find(ee=>ee.id===C.current),U=D.find(ee=>ee.id===C.current),se=U&&(!B||U.revision>B.revision||B.available!==U.available);X(D,se&&!I.current)}catch{}},5e3);return()=>clearInterval(M)},[d,$,X]),{decks:a,records:a,localNodeId:S,ready:d,saveState:m,error:y,setError:b,saveNow:R,select:async M=>{if(I.current&&!await R(C.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const D=E.current.find(B=>B.id===M);if(!D)throw new Error(`deck inesistente: ${M}`);return I.current=!1,G.current=!0,W(D)},add:async(M,D=null)=>{const B=D===Gi?E.current.find(ee=>ee.local):D?E.current.find(ee=>ee.ownerId===D):null;if(!B||B.available===!1)throw new Error("nodo owner non disponibile");const U=await rv(e,M,B.ownerRoute),se=vr(U,ha(B),B.ownerTopology,B.local,!0);return X([...E.current,se],!1),se},rename:async(M,D)=>{const B=E.current.find(ve=>ve.id===M);if(!B)throw new Error("deck inesistente");if(M===C.current&&I.current&&!await R(M))throw new Error(`salvataggio di "${B.name}" fallito: rinomina annullata`);const U=E.current.find(ve=>ve.id===M);if(!U)throw new Error("deck inesistente");const se=await Vx(e,U.name,D,U.revision,U.ownerRoute),ee=vr(se,ha(U),U.ownerTopology,U.local,!0),de=U.local?Gi:U.ownerId;return $d(I2(Gl(),de,M,ee.id)),X(E.current.map(ve=>ve.id===M?ee:ve),!1),ee},remove:async M=>{const D=E.current.find(U=>U.id===M);if(!D)throw new Error("deck inesistente");M===C.current&&(I.current=!1),await Yx(e,D.name,D.revision,D.ownerRoute);const B=D.local?Gi:D.ownerId;$d(O2(Gl(),B,M)),X(E.current.filter(U=>U.id!==M),!1)},reorder:(M,D)=>{const B=E.current.find(fe=>fe.id===M),U=E.current.find(fe=>fe.id===D);if(!B||!U)return!1;const se=B.local?Gi:B.ownerId,ee=U.local?Gi:U.ownerId;if(se!==ee)return!1;const de=E.current.filter(fe=>(fe.local?Gi:fe.ownerId)===se).map(fe=>fe.id),ve=$d(D2(Gl(),se,M,D,de));return X(O_(E.current,ve),!1),!0},addTileTo:async(M,D)=>{const B=E.current.find(fe=>fe.id===M);if(!B)throw new Error("deck inesistente");if(B.available===!1)throw new Error(`nodo owner offline: ${B.ownerLabel}`);const U=Lw(D,N.current,w.current);if(!U)throw new Error("riferimento sessione non valido");const se=W(B),ee=D_(vb(se,U),B.ownerId,B.ownerTopology),de=await Fl(e,B.name,ee,B.revision,B.ownerRoute),ve=vr(de,ha(B),B.ownerTopology,B.local,!0);return X(E.current.map(fe=>fe.id===M?ve:fe),!1),ve},localMainId:po(null,"main"),parseDeckId:Mc}}const xP="/sw.js",Cf="nc-sw-update";let Ef=null,Nf=!1,jf=null,pS=Object.freeze({needed:!1,kind:null,version:""}),mS=!1;function gS(){typeof window<"u"&&window.dispatchEvent(new Event(Cf))}function vS(){const e=jf||(Nf?{kind:"reload",version:""}:null);pS=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function My(){return pS}function kP(e){return typeof window>"u"?()=>{}:(window.addEventListener(Cf,e),()=>window.removeEventListener(Cf,e))}function jp(e){Nf!==e&&(Nf=e,vS(),gS())}const mh="nc-auto-reload";function CP(){try{return typeof sessionStorage<"u"?sessionStorage:null}catch{return null}}function EP(e,t,n,s={}){let o=null;e&&t&&e!==t?o={kind:"install",version:e}:t&&n&&t!==n&&(o={kind:"reload",version:t});const a=JSON.stringify(o)===JSON.stringify(jf);jf=o,vS(),a||gS();const u=s.storage===void 0?CP():s.storage;if(!o){try{u&&u.removeItem(mh)}catch{}return}if(o.kind!=="reload"||!u)return;const d=`${t}|${n}`;try{if(u.getItem(mh)===d)return;u.setItem(mh,d)}catch{return}(s.applyImpl||_S)()}function NP(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&jp(!0)})}function jP(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{mS&&location.reload()}),navigator.serviceWorker.register(xP).then(e=>{Ef=e,e.waiting&&jp(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&NP(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function _S(){mS=!0,jp(!1);const e=Ef&&Ef.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function RP({hash:e="",origin:t="",pathname:n="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),a=`${n||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:a};const u=new URLSearchParams(o),d=u.get("token")||"",p=u.get("pair")||"",m=p?`${t||""}${n||""}#pair=${p}`:"";return{token:d,pair:m,nextUrl:a}}const yS=9,bS=24,wS="nc_side_w",Ty="nc_side_min",PP=240;function LP(){const e=Number(localStorage.getItem(wS));return e>=180&&e<=480?e:PP}function AP(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=yS&&e<=bS?e:13}function MP(){const e={token:"",pair:""};try{const{token:t,pair:n,nextUrl:s}=RP({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(t){e.token=t;try{localStorage.setItem("nc_token",t)}catch{}}if(n){e.pair=n;try{sessionStorage.setItem("nc_pair",n)}catch{}}if(location.hash)try{history.replaceState(null,"",s)}catch{}}catch{}if(e.token||(e.token=sessionStorage.getItem("nc_token")||localStorage.getItem("nc_token")||""),!e.pair){const t=sessionStorage.getItem("nc_pair");t&&(e.pair=t)}return e}function TP(e){try{return xr(wf(e))}catch{return fo()}}function Dy(e){if(!e)return"";const t=Math.floor(Date.now()/1e3)-e;return t<0||t<60?"ora":t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}g`}function Iy({session:e,node:t,ownerId:n,cellName:s,token:o,readonly:a=!1,panelPort:u=0,onBack:d,onCellSwitcher:p,cellSwitcherOpen:m=!1}){Yn();const[v]=up(),[y,b]=k.useState(!1),[S,x]=k.useState(()=>window.matchMedia("(pointer: coarse)").matches),[E,w]=k.useState(null),[N,C]=k.useState(AP),[L,I]=k.useState(s||e),[G,K]=k.useState(""),[Y,Q]=k.useState(""),[W,X]=k.useState(""),[H,$]=k.useState(!1),R=U=>C(se=>{const ee=Math.max(yS,Math.min(bS,se+U));return localStorage.setItem("nc_fontsize",String(ee)),ee}),O=k.useRef(()=>{}),F=k.useRef(()=>!1),A=k.useRef(()=>{}),T=k.useRef(!1),[j,z]=k.useState(!1),[M,D]=k.useState(!1),B=()=>{T.current=!T.current,z(T.current)};return k.useEffect(()=>{I(s||e),$(!1)},[s,e]),k.useEffect(()=>{let U=!0;const se=t?t.split("/"):[],ee=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function de(){let fe=null,pe=null;try{const vt=await(await on(`${ee}/sessions`,o)).json();Array.isArray(vt.sessions)&&(fe=vt.sessions.find(je=>je.name===e))}catch{}try{const ut=await Xs(o,se);ut.available&&Array.isArray(ut.cells)&&(pe=ut.cells.find(vt=>vt.tmuxSession===e))}catch{}if(!U)return;I(dp({session:e,cell:pe||(s?{cell:s}:null)})),Q(typeof(pe==null?void 0:pe.panelUrl)=="string"?pe.panelUrl.trim():""),X(typeof(pe==null?void 0:pe.cell)=="string"?pe.cell:"");let Ve="";pe?Ve=`${pe.engine}${pe.key?`·${pe.key}`:""}`:fe&&(Ve=fe.attached?`attached · ${Dy(fe.activity)}`:fe.activity?Dy(fe.activity):""),K(Ve)}de();const ve=setInterval(de,4e3);return()=>{U=!1,clearInterval(ve)}},[e,t,o]),l.jsxs("div",{className:"nc-app",children:[l.jsxs("header",{className:"nc-bar nc-bar-single",children:[l.jsxs("button",{onClick:d,title:f("sessions"),children:[l.jsx(lt,{name:"chevronLeft",size:18}),l.jsx("span",{className:"nc-bar-label",children:f("sessions")})]}),l.jsxs("span",{className:"nc-bar-center",children:[l.jsx("b",{title:t?`${L} · ${t}`:L,children:L}),G&&l.jsx("small",{className:"nc-bar-sub",children:G})]}),l.jsxs("span",{className:"nc-bar-right",children:[l.jsx("button",{onClick:()=>R(-1),title:f("zoom-out"),children:l.jsx(lt,{name:"zoomOut",size:18})}),l.jsx("button",{onClick:()=>R(1),title:f("zoom-in"),children:l.jsx(lt,{name:"zoomIn",size:18})}),l.jsx("button",{onClick:()=>x(U=>!U),title:f("composer"),children:l.jsx(lt,{name:"keyboard",size:20})}),l.jsx("button",{onClick:()=>b(U=>!U),title:f("files"),children:l.jsx(lt,{name:"folder",size:20})}),Y&&l.jsx("button",{onClick:()=>$(U=>!U),title:f("panel"),"aria-pressed":H,children:l.jsx(lt,{name:"monitor",size:20})})]})]}),l.jsxs("div",{className:"nc-termwrap",children:[l.jsx(sp,{session:e,node:t,token:o,readonly:a,takeSize:!0,sendRef:O,composerRef:F,actionRef:A,ctrlRef:T,setCtrlArmed:z,onFiles:w,fontSize:N,selectionMode:M,onSelectionModeChange:D,keyboardGesture:v.terminalKeyboardGesture}),H&&Y&&W&&l.jsx(ap,{cellId:W,panelUrl:Y,route:t?t.split("/"):[],panelPort:u,token:o,title:L})]}),l.jsx(XN,{onKeyboard:()=>x(U=>!U),onCellSwitcher:p,cellSwitcherOpen:m,send:U=>O.current(U),action:U=>A.current(U),ctrlArmed:j,onCtrl:B,selectionMode:M,onSelectionMode:D,keepKeyboardClosed:v.keybarKeepsKeyboardClosed,showEnter:v.showKeybarEnter,keybarLayout:v.keybarLayout}),S&&l.jsx(Sw,{submitText:U=>F.current(U),token:o,session:e,node:t,ownerId:n,readonly:a,keepKeyboardClosedOnVoice:v.voiceKeepsKeyboardClosed}),y&&l.jsx(fw,{session:e,node:t,token:o,filesEvent:E,onClose:()=>b(!1)})]})}function DP(){Yn();const[e]=k.useState(MP),[t,n]=k.useState(e.token),[s,o]=k.useState(e.pair||""),a=k.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[u,d]=k.useState(!1),p=jN(),[m]=k.useState(()=>A2(typeof location<"u"?location.pathname:"/")),[v,y]=k.useState(m.id),b=v===po(null,vi),[S,x]=k.useState(null),E=te=>{const Se=Gs(te);x(Se?{...Se,...typeof(te==null?void 0:te.cellName)=="string"&&te.cellName?{cellName:te.cellName}:{}}:null)},[w,N]=k.useState([]),[C,L]=k.useState([]),[I,G]=k.useState([]),[K,Y]=k.useState(!1),[Q,W]=k.useState(null),[X,H]=k.useState(()=>m.ownerId?fo():TP(m.name)),[$,R]=k.useState(null),[O,F]=k.useState(null),A=te=>F(Gs(te)),[T,j]=k.useState(null),z=zf(t,p),M=k.useMemo(()=>(z||[]).filter(te=>te.instanceId).map(te=>({instanceId:te.instanceId,route:te.route,label:te.label,status:te.status})),[z]),D=SP(t,v,X,H,M),B=D.decks;k.useEffect(()=>{const te=new Map;for(const Se of z||[]){const Te=(Se.route||[Se.name]).join("/"),tt=new Set((Se.sessions||[]).map(nt=>nt.name));for(const nt of Se.cells||[])!nt.cell||!nt.tmuxSession||nt.cell===nt.tmuxSession||tt.has(nt.cell)||te.set(`${Te}:${nt.cell}`,`${Te}:${nt.tmuxSession}`)}H(Se=>Ak(Se,te))},[z]),k.useEffect(()=>{D.localNodeId&&H(te=>{const Se=bf(te,D.localNodeId,M);return JSON.stringify(Se)===JSON.stringify(te)?te:Se})},[M,D.localNodeId]);const[U,se]=k.useState(null),[ee,de]=k.useState(null),ve=k.useRef(0),[fe,pe]=k.useState(!1),[Ve,ut]=k.useState(LP),[vt,je]=k.useState(!b),[Ct,dn]=k.useState(()=>b?localStorage.getItem(Ty)==="1":!0),[gn,Yt]=k.useState(!1),[xt,Ot]=k.useState("nodes"),[Ut,Nt]=k.useState(!1),[Dt,At]=k.useState(""),[jt,hn]=k.useState(!1),re=(te="nodes",Se=!1,Te="")=>{Ot(te),Nt(Se),At(Te),Yt(!0)},[Qe,me]=k.useState(!1),[Ge,ct]=k.useState({deviceDefault:"",localNodeId:"",localNameDefault:""}),[oe,ie]=k.useState(!1),[_e,be]=k.useState(0),[ke,it]=k.useState({});k.useEffect(()=>{try{localStorage.setItem(wS,String(Ve))}catch{}},[Ve]),k.useEffect(()=>{try{localStorage.setItem(Ty,Ct?"1":"")}catch{}},[Ct]),k.useEffect(()=>{if(!t)return;let te=!1;return Promise.all([Ky(t),on("/api/config",t).then(Se=>Se.json())]).then(([Se,Te])=>{te||(ct({deviceDefault:Se.deviceName||"",localNodeId:Se.nodeId||"",localNameDefault:Se.localName||""}),ie(!!Te.readonlyDefault),be(Number.isInteger(Te.panelPort)?Te.panelPort:0),it(Te.nodePanelPorts&&typeof Te.nodePanelPorts=="object"&&!Array.isArray(Te.nodePanelPorts)?Te.nodePanelPorts:{}),(Se.firstRun===!0&&!Te.readonlyDefault||s)&&me(!0))}).catch(()=>{}),()=>{te=!0}},[t,s]);const[ht,dt]=k.useState({}),Rt=k.useRef(z);k.useEffect(()=>{Rt.current=z},[z]);const wt=k.useCallback(async()=>{try{const nt=await(await on("/api/sessions",t)).json();nt.error||N(nt.sessions||[])}catch{}let te=null,Se=null;try{te=await Xs(t)}catch(tt){Se=tt}const Te=Bf({fs:te,error:Se});Te.kind==="data"?(L(Te.cells),G(Te.capabilities),Y(!1),W(null)):Te.kind==="stale"?(Y(!0),W(null)):(L([]),G([]),Y(!1),W(Te.reason||""))},[t]);k.useEffect(()=>{let te=!1;const Se=async()=>{const tt=[[],...(Rt.current||[]).filter(St=>St.kind!=="vl"&&St.status==="up").map(St=>Array.isArray(St.route)&&St.route.length?St.route:[St.name])],nt=await Promise.all(tt.map(async St=>{try{const It=await Gx(t,St);return[wa(St),{hostCell:It&&typeof It.hostCell=="string"?It.hostCell:null,hostLease:It&&It.host&&typeof It.host.lease=="string"?It.host.lease:null,hostRevision:Number.isInteger(It&&It.revision)?It.revision:0}]}catch{return null}}));te||dt(St=>{let It=!1;const Sn={...St};for(const ri of nt)ri&&(Sn[ri[0]]=ri[1],It=!0);return It?Sn:St})};Se();const Te=setInterval(Se,4e3);return()=>{te=!0,clearInterval(Te)}},[t]),k.useEffect(()=>{if(!p)return;wt();const te=setInterval(wt,4e3);return()=>clearInterval(te)},[p,wt]);const _t=k.useCallback(async(te,Se=[])=>{const Te=wa(Se),tt=ht[Te]&&ht[Te].hostRevision||0;try{const nt=await Xx(t,te,tt,Se);dt(St=>({...St,[Te]:{hostCell:nt.hostCell||null,hostLease:nt.host&&typeof nt.host.lease=="string"?nt.host.lease:null,hostRevision:Number.isInteger(nt.revision)?nt.revision:tt}}))}catch(nt){window.alert(f(_v(nt)))}},[t,ht]),zt=k.useCallback(async(te=[])=>{const Se=wa(te),Te=ht[Se]&&ht[Se].hostRevision||0;try{const tt=await Qx(t,Te,te);return dt(nt=>({...nt,[Se]:{hostCell:tt.hostCell||null,hostLease:null,hostRevision:Number.isInteger(tt.revision)?tt.revision:Te}})),!0}catch(tt){return window.alert(f(_v(tt))),!1}},[t,ht]);k.useEffect(()=>{let te=!1;const Se=()=>{on("/api/config",t).then(tt=>tt.json()).then(tt=>{te||EP(tt.version,tt.uiVersion,"0.9.12")}).catch(()=>{})};Se();const Te=setInterval(Se,6e4);return()=>{te=!0,clearInterval(Te)}},[t]);const Je=new Set([...w.map(te=>te.name),...z.flatMap(te=>te.sessions.map(Se=>Se.key))]),J=Qi(X),Ne=te=>H(Se=>{const Te=Lw(te,D.localNodeId,M)||te,tt=vb(Se,Te);return tt===Se&&Qi(Se).length>=9&&D.setError(f("grid-full")),tt}),Ue=async(te,Se=[])=>{try{await Af(t,te,Se)}catch{return}const Te=Se.length?`${Se.join("/")}:${te}`:te;H(tt=>mc(tt,Te)),wt()},Oe=async(te,Se,Te=[])=>{try{await Wy(t,te,Se,Te)}catch{return}wt()},Le=async(te,Se,Te=[])=>{await Fy(t,{cell:te,enabled:!!Se},Te),wt()},Et=async te=>{if(!U)return;const{cell:Se}=U,Te=Array.isArray(U.route)?U.route:[];if(te.action==="up"){const nt=await Lf(t,{cell:Se,boot:!!te.boot,...te.engine?{engine:te.engine}:{},...te.model!==void 0?{model:te.model}:{},...te.permissionPolicy?{permissionPolicy:te.permissionPolicy}:{}},Te),St=Vf(nt);St&&D.setError(St.text)}else await lc(t,{cell:Se,boot:!!te.boot},Te);const tt=te.action==="up"?!!te.boot:te.boot?!1:!!U.boot;de({id:++ve.current,cell:Se,route:Te,enabled:tt}),wt()},kt=k.useCallback(te=>{de(Se=>(Se==null?void 0:Se.id)===te?null:Se)},[]),V=async te=>{if(!(!(te!=null&&te.direct)||fe)){pe(!0);try{await If(t,te.name,te.tunnelStatus==="up"?"down":"up")}finally{pe(!1)}}},ae=async(te,Se)=>{const Te=String(Se||"").trim();return!(te!=null&&te.direct)||!_o(Te)?!1:(await Yy(t,te.name,Te),!0)},ye=te=>{const Se=B.find(Te=>Te.id===te);if(!Se)return!1;try{const Te=window.open(zd(Se,t),"_blank");return Te&&(Te.opener=null),!!Te}catch{return!1}},Me=async te=>{if(!te||te===v)return;const Se=await D.select(te),Te=D.records.find(tt=>tt.id===te);y(te),H(Se),R(null),F(null);try{history.replaceState(null,"",zd(Te||te,null))}catch{}},De=async(te,Se)=>{const Te=await D.add(te,Se);await Me(Te.id)},Ee=async(te,Se)=>{const Te=await D.rename(te,Se);if(te===v){y(Te.id),H(bf(Te.layout,D.localNodeId,M)),R(null),F(null);try{history.replaceState(null,"",zd(Te,null))}catch{}}},Xe=async te=>{await D.remove(te),te===v&&await Me(D.localMainId)},yt=async(te,Se)=>{!Se||Se===v||(await D.addTileTo(Se,te),H(Te=>mc(Te,te)))};if(!t)return l.jsxs("div",{className:"nc-auth",children:[l.jsx("p",{children:f("auth-prompt")}),l.jsx("input",{onChange:te=>n(te.target.value.trim()),placeholder:"token"}),l.jsxs("label",{children:[l.jsx("input",{type:"checkbox",checked:u,onChange:te=>d(te.target.checked)})," ",f("remember-device")]}),l.jsx("button",{onClick:()=>{(u?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const $t=l.jsxs(l.Fragment,{children:[gn&&l.jsx(sP,{token:t,initialTab:xt,initialLocation:Dt,startNewCell:Ut,onClose:()=>{Yt(!1),Nt(!1),At("")}}),Qe&&l.jsx(rP,{token:t,initialPair:s,...Ge,onPairDone:a,onDone:()=>me(!1)}),l.jsx(dP,{token:t})]});if(!p)return T?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-single-overlay",children:l.jsx(Ay,{peer:T,token:t,onBack:()=>j(null)})}),$t]}):S?l.jsxs(l.Fragment,{children:[l.jsx(Iy,{session:S.session,node:S.node,ownerId:S.ownerId,cellName:S.cellName,token:t,readonly:oe,panelPort:kc(S.node?S.node.split("/"):[],ke,_e),onBack:()=>x(null),onCellSwitcher:()=>hn(!0),cellSwitcherOpen:jt}),jt&&l.jsx(vP,{token:t,current:S,panelPort:_e,nodePanelPorts:ke,onPick:te=>{E(te),hn(!1)},onClose:()=>hn(!1)}),$t]}):l.jsxs(l.Fragment,{children:[l.jsx(Xk,{onPick:E,token:t,onSettings:re,onOpenVlSession:j,hostByRoute:ht,onDesignateCell:_t,onClearHostCell:zt}),$t]});const Be=b||!vt;return l.jsxs("div",{className:"nc-workspace",children:[Be&&l.jsx(w2,{sessions:w,cells:C,activeSessions:J,nodeGroups:z,token:t,onPeekOpen:()=>hn(!1),overlayOpen:jt,fleetCapabilities:I,fleetStale:K,fleetOff:Q,bootSettlement:ee,onBootSettlementApplied:kt,localNodeId:D.localNodeId,hostByRoute:ht,onDesignateCell:_t,onClearHostCell:zt,onPick:A,onAddTile:Ne,onPower:se,onBoot:Le,onBootError:te=>D.setError(String((te==null?void 0:te.message)||te)),onNodePower:V,onNodeRename:ae,onKill:Ue,onVisibility:Oe,onNew:()=>re("fleet",!0),onSettings:re,onOpenVlSession:j,width:Ve,collapsed:Ct,onResize:ut,onToggleCollapse:()=>dn(te=>!te)}),l.jsxs("div",{className:"nc-workspace-main",children:[l.jsx(tj,{decks:B,currentDeck:v,onCreate:De,onRename:Ee,onDelete:Xe,onReorder:D.reorder,onOpenWindow:ye,onNavigate:Me,saveState:D.saveState,error:D.error,sidebarVisible:Be,onToggleSidebar:b?null:()=>je(te=>!te)}),l.jsx(N2,{layout:X,onLayoutChange:H,token:t,readonly:oe,sessionsAlive:Je,focusSession:$,onFocus:R,onOpenSingle:A,decks:B,currentDeck:v,onSendToDeck:yt,cells:C,nodeGroups:z,panelPort:_e,nodePanelPorts:ke})]}),T&&l.jsx("div",{className:"nc-single-overlay",children:l.jsx(Ay,{peer:T,token:t,onBack:()=>j(null)})}),O&&l.jsx("div",{className:"nc-single-overlay",children:l.jsx(Iy,{session:O.session,node:O.node,ownerId:O.ownerId,cellName:dp({session:O.session,node:O.node,ownerId:O.ownerId,cells:C,nodeGroups:z}),token:t,readonly:oe,panelPort:kc(O.node?O.node.split("/"):[],ke,_e),onBack:()=>F(null)})}),U&&l.jsx(uc,{cell:U,token:t,route:Array.isArray(U.route)?U.route:[],onConfirm:Et,onClose:()=>se(null)}),$t]})}function IP(){Yn();const e=k.useSyncExternalStore(kP,My,My);if(!e.needed)return null;const t=e.kind==="install"?f("install-version-mismatch").replace("{v}",e.version):f("update-available").replace("{v}",e.version).replace(" "," ").trim();return l.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"nc-update-msg",children:t}),e.kind==="reload"&&l.jsx("button",{className:"nc-update-btn",onClick:_S,children:f("reload")})]})}jP();ox.createRoot(document.getElementById("root")).render(l.jsxs(Z0.StrictMode,{children:[l.jsx(DP,{}),l.jsx(IP,{})]}));