@mmmbuto/nexuscrew 0.8.29 → 0.8.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,93 @@
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 fh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _u={exports:{}},ao={},yu={exports:{}},et={};/**
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 jm;function _b(){if(jm)return et;jm=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),u=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),b=Symbol.iterator;function y(L){return L===null||typeof L!="object"?null:(L=b&&L[b]||L["@@iterator"],typeof L=="function"?L:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,x={};function C(L,z,G){this.props=L,this.context=z,this.refs=x,this.updater=G||w}C.prototype.isReactComponent={},C.prototype.setState=function(L,z){if(typeof L!="object"&&typeof L!="function"&&L!=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,L,z,"setState")},C.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function k(){}k.prototype=C.prototype;function N(L,z,G){this.props=L,this.context=z,this.refs=x,this.updater=G||w}var I=N.prototype=new k;I.constructor=N,S(I,C.prototype),I.isPureReactComponent=!0;var D=Array.isArray,X=Object.prototype.hasOwnProperty,V={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function ne(L,z,G){var oe,de={},me=null,Q=null;if(z!=null)for(oe in z.ref!==void 0&&(Q=z.ref),z.key!==void 0&&(me=""+z.key),z)X.call(z,oe)&&!A.hasOwnProperty(oe)&&(de[oe]=z[oe]);var q=arguments.length-2;if(q===1)de.children=G;else if(1<q){for(var pe=Array(q),Ie=0;Ie<q;Ie++)pe[Ie]=arguments[Ie+2];de.children=pe}if(L&&L.defaultProps)for(oe in q=L.defaultProps,q)de[oe]===void 0&&(de[oe]=q[oe]);return{$$typeof:e,type:L,key:me,ref:Q,props:de,_owner:V.current}}function W(L,z){return{$$typeof:e,type:L.type,key:z,ref:L.ref,props:L.props,_owner:L._owner}}function Z(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function U(L){var z={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(G){return z[G]})}var H=/\/+/g;function j(L,z){return typeof L=="object"&&L!==null&&L.key!=null?U(""+L.key):z.toString(36)}function P(L,z,G,oe,de){var me=typeof L;(me==="undefined"||me==="boolean")&&(L=null);var Q=!1;if(L===null)Q=!0;else switch(me){case"string":case"number":Q=!0;break;case"object":switch(L.$$typeof){case e:case t:Q=!0}}if(Q)return Q=L,de=de(Q),L=oe===""?"."+j(Q,0):oe,D(de)?(G="",L!=null&&(G=L.replace(H,"$&/")+"/"),P(de,z,G,"",function(Ie){return Ie})):de!=null&&(Z(de)&&(de=W(de,G+(!de.key||Q&&Q.key===de.key?"":(""+de.key).replace(H,"$&/")+"/")+L)),z.push(de)),1;if(Q=0,oe=oe===""?".":oe+":",D(L))for(var q=0;q<L.length;q++){me=L[q];var pe=oe+j(me,q);Q+=P(me,z,G,pe,de)}else if(pe=y(L),typeof pe=="function")for(L=pe.call(L),q=0;!(me=L.next()).done;)me=me.value,pe=oe+j(me,q++),Q+=P(me,z,G,pe,de);else if(me==="object")throw z=String(L),Error("Objects are not valid as a React child (found: "+(z==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":z)+"). If you meant to render a collection of children, use an array instead.");return Q}function T(L,z,G){if(L==null)return L;var oe=[],de=0;return P(L,oe,"","",function(me){return z.call(G,me,de++)}),oe}function F(L){if(L._status===-1){var z=L._result;z=z(),z.then(function(G){(L._status===0||L._status===-1)&&(L._status=1,L._result=G)},function(G){(L._status===0||L._status===-1)&&(L._status=2,L._result=G)}),L._status===-1&&(L._status=0,L._result=z)}if(L._status===1)return L._result.default;throw L._result}var te={current:null},M={transition:null},ie={ReactCurrentDispatcher:te,ReactCurrentBatchConfig:M,ReactCurrentOwner:V};function B(){throw Error("act(...) is not supported in production builds of React.")}return et.Children={map:T,forEach:function(L,z,G){T(L,function(){z.apply(this,arguments)},G)},count:function(L){var z=0;return T(L,function(){z++}),z},toArray:function(L){return T(L,function(z){return z})||[]},only:function(L){if(!Z(L))throw Error("React.Children.only expected to receive a single React element child.");return L}},et.Component=C,et.Fragment=n,et.Profiler=o,et.PureComponent=N,et.StrictMode=s,et.Suspense=p,et.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ie,et.act=B,et.cloneElement=function(L,z,G){if(L==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+L+".");var oe=S({},L.props),de=L.key,me=L.ref,Q=L._owner;if(z!=null){if(z.ref!==void 0&&(me=z.ref,Q=V.current),z.key!==void 0&&(de=""+z.key),L.type&&L.type.defaultProps)var q=L.type.defaultProps;for(pe in z)X.call(z,pe)&&!A.hasOwnProperty(pe)&&(oe[pe]=z[pe]===void 0&&q!==void 0?q[pe]:z[pe])}var pe=arguments.length-2;if(pe===1)oe.children=G;else if(1<pe){q=Array(pe);for(var Ie=0;Ie<pe;Ie++)q[Ie]=arguments[Ie+2];oe.children=q}return{$$typeof:e,type:L.type,key:de,ref:me,props:oe,_owner:Q}},et.createContext=function(L){return L={$$typeof:u,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},L.Provider={$$typeof:a,_context:L},L.Consumer=L},et.createElement=ne,et.createFactory=function(L){var z=ne.bind(null,L);return z.type=L,z},et.createRef=function(){return{current:null}},et.forwardRef=function(L){return{$$typeof:h,render:L}},et.isValidElement=Z,et.lazy=function(L){return{$$typeof:_,_payload:{_status:-1,_result:L},_init:F}},et.memo=function(L,z){return{$$typeof:f,type:L,compare:z===void 0?null:z}},et.startTransition=function(L){var z=M.transition;M.transition={};try{L()}finally{M.transition=z}},et.unstable_act=B,et.useCallback=function(L,z){return te.current.useCallback(L,z)},et.useContext=function(L){return te.current.useContext(L)},et.useDebugValue=function(){},et.useDeferredValue=function(L){return te.current.useDeferredValue(L)},et.useEffect=function(L,z){return te.current.useEffect(L,z)},et.useId=function(){return te.current.useId()},et.useImperativeHandle=function(L,z,G){return te.current.useImperativeHandle(L,z,G)},et.useInsertionEffect=function(L,z){return te.current.useInsertionEffect(L,z)},et.useLayoutEffect=function(L,z){return te.current.useLayoutEffect(L,z)},et.useMemo=function(L,z){return te.current.useMemo(L,z)},et.useReducer=function(L,z,G){return te.current.useReducer(L,z,G)},et.useRef=function(L){return te.current.useRef(L)},et.useState=function(L){return te.current.useState(L)},et.useSyncExternalStore=function(L,z,G){return te.current.useSyncExternalStore(L,z,G)},et.useTransition=function(){return te.current.useTransition()},et.version="18.3.1",et}var Lm;function ph(){return Lm||(Lm=1,yu.exports=_b()),yu.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 Dm;function yb(){if(Dm)return ao;Dm=1;var e=ph(),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(h,p,f){var _,b={},y=null,w=null;f!==void 0&&(y=""+f),p.key!==void 0&&(y=""+p.key),p.ref!==void 0&&(w=p.ref);for(_ in p)s.call(p,_)&&!a.hasOwnProperty(_)&&(b[_]=p[_]);if(h&&h.defaultProps)for(_ in p=h.defaultProps,p)b[_]===void 0&&(b[_]=p[_]);return{$$typeof:t,type:h,key:y,ref:w,props:b,_owner:o.current}}return ao.Fragment=n,ao.jsx=u,ao.jsxs=u,ao}var Mm;function wb(){return Mm||(Mm=1,_u.exports=yb()),_u.exports}var c=wb(),R=ph();const Sb=fh(R);var Ha={},wu={exports:{}},En={},Su={exports:{}},bu={};/**
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 Tm;function bb(){return Tm||(Tm=1,(function(e){function t(M,ie){var B=M.length;M.push(ie);e:for(;0<B;){var L=B-1>>>1,z=M[L];if(0<o(z,ie))M[L]=ie,M[B]=z,B=L;else break e}}function n(M){return M.length===0?null:M[0]}function s(M){if(M.length===0)return null;var ie=M[0],B=M.pop();if(B!==ie){M[0]=B;e:for(var L=0,z=M.length,G=z>>>1;L<G;){var oe=2*(L+1)-1,de=M[oe],me=oe+1,Q=M[me];if(0>o(de,B))me<z&&0>o(Q,de)?(M[L]=Q,M[me]=B,L=me):(M[L]=de,M[oe]=B,L=oe);else if(me<z&&0>o(Q,B))M[L]=Q,M[me]=B,L=me;else break e}}return ie}function o(M,ie){var B=M.sortIndex-ie.sortIndex;return B!==0?B:M.id-ie.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var u=Date,h=u.now();e.unstable_now=function(){return u.now()-h}}var p=[],f=[],_=1,b=null,y=3,w=!1,S=!1,x=!1,C=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function I(M){for(var ie=n(f);ie!==null;){if(ie.callback===null)s(f);else if(ie.startTime<=M)s(f),ie.sortIndex=ie.expirationTime,t(p,ie);else break;ie=n(f)}}function D(M){if(x=!1,I(M),!S)if(n(p)!==null)S=!0,F(X);else{var ie=n(f);ie!==null&&te(D,ie.startTime-M)}}function X(M,ie){S=!1,x&&(x=!1,k(ne),ne=-1),w=!0;var B=y;try{for(I(ie),b=n(p);b!==null&&(!(b.expirationTime>ie)||M&&!U());){var L=b.callback;if(typeof L=="function"){b.callback=null,y=b.priorityLevel;var z=L(b.expirationTime<=ie);ie=e.unstable_now(),typeof z=="function"?b.callback=z:b===n(p)&&s(p),I(ie)}else s(p);b=n(p)}if(b!==null)var G=!0;else{var oe=n(f);oe!==null&&te(D,oe.startTime-ie),G=!1}return G}finally{b=null,y=B,w=!1}}var V=!1,A=null,ne=-1,W=5,Z=-1;function U(){return!(e.unstable_now()-Z<W)}function H(){if(A!==null){var M=e.unstable_now();Z=M;var ie=!0;try{ie=A(!0,M)}finally{ie?j():(V=!1,A=null)}}else V=!1}var j;if(typeof N=="function")j=function(){N(H)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,T=P.port2;P.port1.onmessage=H,j=function(){T.postMessage(null)}}else j=function(){C(H,0)};function F(M){A=M,V||(V=!0,j())}function te(M,ie){ne=C(function(){M(e.unstable_now())},ie)}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(M){M.callback=null},e.unstable_continueExecution=function(){S||w||(S=!0,F(X))},e.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):W=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_getFirstCallbackNode=function(){return n(p)},e.unstable_next=function(M){switch(y){case 1:case 2:case 3:var ie=3;break;default:ie=y}var B=y;y=ie;try{return M()}finally{y=B}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(M,ie){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var B=y;y=M;try{return ie()}finally{y=B}},e.unstable_scheduleCallback=function(M,ie,B){var L=e.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?L+B:L):B=L,M){case 1:var z=-1;break;case 2:z=250;break;case 5:z=1073741823;break;case 4:z=1e4;break;default:z=5e3}return z=B+z,M={id:_++,callback:ie,priorityLevel:M,startTime:B,expirationTime:z,sortIndex:-1},B>L?(M.sortIndex=B,t(f,M),n(p)===null&&M===n(f)&&(x?(k(ne),ne=-1):x=!0,te(D,B-L))):(M.sortIndex=z,t(p,M),S||w||(S=!0,F(X))),M},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(M){var ie=y;return function(){var B=y;y=ie;try{return M.apply(this,arguments)}finally{y=B}}}})(bu)),bu}var Am;function kb(){return Am||(Am=1,Su.exports=bb()),Su.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 Im;function xb(){if(Im)return En;Im=1;var e=ph(),t=kb();function n(i){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+i,l=1;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l]);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 h=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,_={},b={};function y(i){return p.call(b,i)?!0:p.call(_,i)?!1:f.test(i)?b[i]=!0:(_[i]=!0,!1)}function w(i,r,l,d){if(l!==null&&l.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return d?!1:l!==null?!l.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function S(i,r,l,d){if(r===null||typeof r>"u"||w(i,r,l,d))return!0;if(d)return!1;if(l!==null)switch(l.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 x(i,r,l,d,m,v,E){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=d,this.attributeNamespace=m,this.mustUseProperty=l,this.propertyName=i,this.type=r,this.sanitizeURL=v,this.removeEmptyString=E}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){C[i]=new x(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var r=i[0];C[r]=new x(r,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){C[i]=new x(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){C[i]=new x(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){C[i]=new x(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){C[i]=new x(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){C[i]=new x(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){C[i]=new x(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){C[i]=new x(i,5,!1,i.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function N(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(k,N);C[r]=new x(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(k,N);C[r]=new x(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(k,N);C[r]=new x(r,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){C[i]=new x(i,1,!1,i.toLowerCase(),null,!1,!1)}),C.xlinkHref=new x("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){C[i]=new x(i,1,!1,i.toLowerCase(),null,!0,!0)});function I(i,r,l,d){var m=C.hasOwnProperty(r)?C[r]:null;(m!==null?m.type!==0:d||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(S(r,l,m,d)&&(l=null),d||m===null?y(r)&&(l===null?i.removeAttribute(r):i.setAttribute(r,""+l)):m.mustUseProperty?i[m.propertyName]=l===null?m.type===3?!1:"":l:(r=m.attributeName,d=m.attributeNamespace,l===null?i.removeAttribute(r):(m=m.type,l=m===3||m===4&&l===!0?"":""+l,d?i.setAttributeNS(d,r,l):i.setAttribute(r,l))))}var D=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,X=Symbol.for("react.element"),V=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),ne=Symbol.for("react.strict_mode"),W=Symbol.for("react.profiler"),Z=Symbol.for("react.provider"),U=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),te=Symbol.for("react.offscreen"),M=Symbol.iterator;function ie(i){return i===null||typeof i!="object"?null:(i=M&&i[M]||i["@@iterator"],typeof i=="function"?i:null)}var B=Object.assign,L;function z(i){if(L===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);L=r&&r[1]||""}return`
34
+ `+L+i}var G=!1;function oe(i,r){if(!i||G)return"";G=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(ce){var d=ce}Reflect.construct(i,[],r)}else{try{r.call()}catch(ce){d=ce}i.call(r.prototype)}else{try{throw Error()}catch(ce){d=ce}i()}}catch(ce){if(ce&&d&&typeof ce.stack=="string"){for(var m=ce.stack.split(`
35
+ `),v=d.stack.split(`
36
+ `),E=m.length-1,$=v.length-1;1<=E&&0<=$&&m[E]!==v[$];)$--;for(;1<=E&&0<=$;E--,$--)if(m[E]!==v[$]){if(E!==1||$!==1)do if(E--,$--,0>$||m[E]!==v[$]){var Y=`
37
+ `+m[E].replace(" at new "," at ");return i.displayName&&Y.includes("<anonymous>")&&(Y=Y.replace("<anonymous>",i.displayName)),Y}while(1<=E&&0<=$);break}}}finally{G=!1,Error.prepareStackTrace=l}return(i=i?i.displayName||i.name:"")?z(i):""}function de(i){switch(i.tag){case 5:return z(i.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return i=oe(i.type,!1),i;case 11:return i=oe(i.type.render,!1),i;case 1:return i=oe(i.type,!0),i;default:return""}}function me(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 A:return"Fragment";case V:return"Portal";case W:return"Profiler";case ne:return"StrictMode";case j:return"Suspense";case P:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case U:return(i.displayName||"Context")+".Consumer";case Z:return(i._context.displayName||"Context")+".Provider";case H:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case T:return r=i.displayName||null,r!==null?r:me(i.type)||"Memo";case F:r=i._payload,i=i._init;try{return me(i(r))}catch{}}return null}function Q(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 me(r);case 8:return r===ne?"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 q(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 Ie(i){var r=pe(i)?"checked":"value",l=Object.getOwnPropertyDescriptor(i.constructor.prototype,r),d=""+i[r];if(!i.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var m=l.get,v=l.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return m.call(this)},set:function(E){d=""+E,v.call(this,E)}}),Object.defineProperty(i,r,{enumerable:l.enumerable}),{getValue:function(){return d},setValue:function(E){d=""+E},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function it(i){i._valueTracker||(i._valueTracker=Ie(i))}function ze(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var l=r.getValue(),d="";return i&&(d=pe(i)?i.checked?"true":"false":i.value),i=d,i!==l?(r.setValue(i),!0):!1}function Fe(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 dt(i,r){var l=r.checked;return B({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??i._wrapperState.initialChecked})}function Ue(i,r){var l=r.defaultValue==null?"":r.defaultValue,d=r.checked!=null?r.checked:r.defaultChecked;l=q(r.value!=null?r.value:l),i._wrapperState={initialChecked:d,initialValue:l,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function ct(i,r){r=r.checked,r!=null&&I(i,"checked",r,!1)}function _t(i,r){ct(i,r);var l=q(r.value),d=r.type;if(l!=null)d==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+l):i.value!==""+l&&(i.value=""+l);else if(d==="submit"||d==="reset"){i.removeAttribute("value");return}r.hasOwnProperty("value")?pt(i,r.type,l):r.hasOwnProperty("defaultValue")&&pt(i,r.type,q(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(i.defaultChecked=!!r.defaultChecked)}function ut(i,r,l){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var d=r.type;if(!(d!=="submit"&&d!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+i._wrapperState.initialValue,l||r===i.value||(i.value=r),i.defaultValue=r}l=i.name,l!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,l!==""&&(i.name=l)}function pt(i,r,l){(r!=="number"||Fe(i.ownerDocument)!==i)&&(l==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+l&&(i.defaultValue=""+l))}var st=Array.isArray;function rt(i,r,l,d){if(i=i.options,r){r={};for(var m=0;m<l.length;m++)r["$"+l[m]]=!0;for(l=0;l<i.length;l++)m=r.hasOwnProperty("$"+i[l].value),i[l].selected!==m&&(i[l].selected=m),m&&d&&(i[l].defaultSelected=!0)}else{for(l=""+q(l),r=null,m=0;m<i.length;m++){if(i[m].value===l){i[m].selected=!0,d&&(i[m].defaultSelected=!0);return}r!==null||i[m].disabled||(r=i[m])}r!==null&&(r.selected=!0)}}function mt(i,r){if(r.dangerouslySetInnerHTML!=null)throw Error(n(91));return B({},r,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function le(i,r){var l=r.value;if(l==null){if(l=r.children,r=r.defaultValue,l!=null){if(r!=null)throw Error(n(92));if(st(l)){if(1<l.length)throw Error(n(93));l=l[0]}r=l}r==null&&(r=""),l=r}i._wrapperState={initialValue:q(l)}}function be(i,r){var l=q(r.value),d=q(r.defaultValue);l!=null&&(l=""+l,l!==i.value&&(i.value=l),r.defaultValue==null&&i.defaultValue!==l&&(i.defaultValue=l)),d!=null&&(i.defaultValue=""+d)}function Ae(i){var r=i.textContent;r===i._wrapperState.initialValue&&r!==""&&r!==null&&(i.value=r)}function We(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 he(i,r){return i==null||i==="http://www.w3.org/1999/xhtml"?We(r):i==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var K,ee=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,l,d,m){MSApp.execUnsafeLocalFunction(function(){return i(r,l,d,m)})}:i})(function(i,r){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=r;else{for(K=K||document.createElement("div"),K.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=K.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;r.firstChild;)i.appendChild(r.firstChild)}});function O(i,r){if(r){var l=i.firstChild;if(l&&l===i.lastChild&&l.nodeType===3){l.nodeValue=r;return}}i.textContent=r}var se={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},ge=["Webkit","ms","Moz","O"];Object.keys(se).forEach(function(i){ge.forEach(function(r){r=r+i.charAt(0).toUpperCase()+i.substring(1),se[r]=se[i]})});function ke(i,r,l){return r==null||typeof r=="boolean"||r===""?"":l||typeof r!="number"||r===0||se.hasOwnProperty(i)&&se[i]?(""+r).trim():r+"px"}function Ee(i,r){i=i.style;for(var l in r)if(r.hasOwnProperty(l)){var d=l.indexOf("--")===0,m=ke(l,r[l],d);l==="float"&&(l="cssFloat"),d?i.setProperty(l,m):i[l]=m}}var we=B({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 Re(i,r){if(r){if(we[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 Ge(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 gt=null;function Be(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var fn=null,kt=null,Ke=null;function Et(i){if(i=qs(i)){if(typeof fn!="function")throw Error(n(280));var r=i.stateNode;r&&(r=ia(r),fn(i.stateNode,i.type,r))}}function ue(i){kt?Ke?Ke.push(i):Ke=[i]:kt=i}function Ne(){if(kt){var i=kt,r=Ke;if(Ke=kt=null,Et(i),r)for(i=0;i<r.length;i++)Et(r[i])}}function qe(i,r){return i(r)}function tt(){}var qt=!1;function ii(i,r,l){if(qt)return i(r,l);qt=!0;try{return qe(i,r,l)}finally{qt=!1,(kt!==null||Ke!==null)&&(tt(),Ne())}}function Ft(i,r){var l=i.stateNode;if(l===null)return null;var d=ia(l);if(d===null)return null;l=d[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(d=!d.disabled)||(i=i.type,d=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!d;break e;default:i=!1}if(i)return null;if(l&&typeof l!="function")throw Error(n(231,r,typeof l));return l}var Di=!1;if(h)try{var ve={};Object.defineProperty(ve,"passive",{get:function(){Di=!0}}),window.addEventListener("test",ve,ve),window.removeEventListener("test",ve,ve)}catch{Di=!1}function Ze(i,r,l,d,m,v,E,$,Y){var ce=Array.prototype.slice.call(arguments,3);try{r.apply(l,ce)}catch(ye){this.onError(ye)}}var ot=!1,yt=null,wn=!1,ri=null,Bl={onError:function(i){ot=!0,yt=i}};function Ew(i,r,l,d,m,v,E,$,Y){ot=!1,yt=null,Ze.apply(Bl,arguments)}function Nw(i,r,l,d,m,v,E,$,Y){if(Ew.apply(this,arguments),ot){if(ot){var ce=yt;ot=!1,yt=null}else throw Error(n(198));wn||(wn=!0,ri=ce)}}function ur(i){var r=i,l=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(l=r.return),i=r.return;while(i)}return r.tag===3?l:null}function Qh(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 Zh(i){if(ur(i)!==i)throw Error(n(188))}function Rw(i){var r=i.alternate;if(!r){if(r=ur(i),r===null)throw Error(n(188));return r!==i?null:i}for(var l=i,d=r;;){var m=l.return;if(m===null)break;var v=m.alternate;if(v===null){if(d=m.return,d!==null){l=d;continue}break}if(m.child===v.child){for(v=m.child;v;){if(v===l)return Zh(m),i;if(v===d)return Zh(m),r;v=v.sibling}throw Error(n(188))}if(l.return!==d.return)l=m,d=v;else{for(var E=!1,$=m.child;$;){if($===l){E=!0,l=m,d=v;break}if($===d){E=!0,d=m,l=v;break}$=$.sibling}if(!E){for($=v.child;$;){if($===l){E=!0,l=v,d=m;break}if($===d){E=!0,d=v,l=m;break}$=$.sibling}if(!E)throw Error(n(189))}}if(l.alternate!==d)throw Error(n(190))}if(l.tag!==3)throw Error(n(188));return l.stateNode.current===l?i:r}function ef(i){return i=Rw(i),i!==null?tf(i):null}function tf(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var r=tf(i);if(r!==null)return r;i=i.sibling}return null}var nf=t.unstable_scheduleCallback,rf=t.unstable_cancelCallback,Pw=t.unstable_shouldYield,jw=t.unstable_requestPaint,Tt=t.unstable_now,Lw=t.unstable_getCurrentPriorityLevel,Ol=t.unstable_ImmediatePriority,sf=t.unstable_UserBlockingPriority,Bo=t.unstable_NormalPriority,Dw=t.unstable_LowPriority,of=t.unstable_IdlePriority,Oo=null,si=null;function Mw(i){if(si&&typeof si.onCommitFiberRoot=="function")try{si.onCommitFiberRoot(Oo,i,void 0,(i.current.flags&128)===128)}catch{}}var Xn=Math.clz32?Math.clz32:Iw,Tw=Math.log,Aw=Math.LN2;function Iw(i){return i>>>=0,i===0?32:31-(Tw(i)/Aw|0)|0}var zo=64,Fo=4194304;function Rs(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 $o(i,r){var l=i.pendingLanes;if(l===0)return 0;var d=0,m=i.suspendedLanes,v=i.pingedLanes,E=l&268435455;if(E!==0){var $=E&~m;$!==0?d=Rs($):(v&=E,v!==0&&(d=Rs(v)))}else E=l&~m,E!==0?d=Rs(E):v!==0&&(d=Rs(v));if(d===0)return 0;if(r!==0&&r!==d&&(r&m)===0&&(m=d&-d,v=r&-r,m>=v||m===16&&(v&4194240)!==0))return r;if((d&4)!==0&&(d|=l&16),r=i.entangledLanes,r!==0)for(i=i.entanglements,r&=d;0<r;)l=31-Xn(r),m=1<<l,d|=i[l],r&=~m;return d}function Bw(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 Ow(i,r){for(var l=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,v=i.pendingLanes;0<v;){var E=31-Xn(v),$=1<<E,Y=m[E];Y===-1?(($&l)===0||($&d)!==0)&&(m[E]=Bw($,r)):Y<=r&&(i.expiredLanes|=$),v&=~$}}function zl(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function af(){var i=zo;return zo<<=1,(zo&4194240)===0&&(zo=64),i}function Fl(i){for(var r=[],l=0;31>l;l++)r.push(i);return r}function Ps(i,r,l){i.pendingLanes|=r,r!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,r=31-Xn(r),i[r]=l}function zw(i,r){var l=i.pendingLanes&~r;i.pendingLanes=r,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=r,i.mutableReadLanes&=r,i.entangledLanes&=r,r=i.entanglements;var d=i.eventTimes;for(i=i.expirationTimes;0<l;){var m=31-Xn(l),v=1<<m;r[m]=0,d[m]=-1,i[m]=-1,l&=~v}}function $l(i,r){var l=i.entangledLanes|=r;for(i=i.entanglements;l;){var d=31-Xn(l),m=1<<d;m&r|i[d]&r&&(i[d]|=r),l&=~m}}var ht=0;function lf(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var cf,Hl,uf,df,hf,Wl=!1,Ho=[],Mi=null,Ti=null,Ai=null,js=new Map,Ls=new Map,Ii=[],Fw="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 ff(i,r){switch(i){case"focusin":case"focusout":Mi=null;break;case"dragenter":case"dragleave":Ti=null;break;case"mouseover":case"mouseout":Ai=null;break;case"pointerover":case"pointerout":js.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ls.delete(r.pointerId)}}function Ds(i,r,l,d,m,v){return i===null||i.nativeEvent!==v?(i={blockedOn:r,domEventName:l,eventSystemFlags:d,nativeEvent:v,targetContainers:[m]},r!==null&&(r=qs(r),r!==null&&Hl(r)),i):(i.eventSystemFlags|=d,r=i.targetContainers,m!==null&&r.indexOf(m)===-1&&r.push(m),i)}function $w(i,r,l,d,m){switch(r){case"focusin":return Mi=Ds(Mi,i,r,l,d,m),!0;case"dragenter":return Ti=Ds(Ti,i,r,l,d,m),!0;case"mouseover":return Ai=Ds(Ai,i,r,l,d,m),!0;case"pointerover":var v=m.pointerId;return js.set(v,Ds(js.get(v)||null,i,r,l,d,m)),!0;case"gotpointercapture":return v=m.pointerId,Ls.set(v,Ds(Ls.get(v)||null,i,r,l,d,m)),!0}return!1}function pf(i){var r=dr(i.target);if(r!==null){var l=ur(r);if(l!==null){if(r=l.tag,r===13){if(r=Qh(l),r!==null){i.blockedOn=r,hf(i.priority,function(){uf(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){i.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Wo(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var l=Kl(i.domEventName,i.eventSystemFlags,r[0],i.nativeEvent);if(l===null){l=i.nativeEvent;var d=new l.constructor(l.type,l);gt=d,l.target.dispatchEvent(d),gt=null}else return r=qs(l),r!==null&&Hl(r),i.blockedOn=l,!1;r.shift()}return!0}function mf(i,r,l){Wo(i)&&l.delete(r)}function Hw(){Wl=!1,Mi!==null&&Wo(Mi)&&(Mi=null),Ti!==null&&Wo(Ti)&&(Ti=null),Ai!==null&&Wo(Ai)&&(Ai=null),js.forEach(mf),Ls.forEach(mf)}function Ms(i,r){i.blockedOn===r&&(i.blockedOn=null,Wl||(Wl=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Hw)))}function Ts(i){function r(m){return Ms(m,i)}if(0<Ho.length){Ms(Ho[0],i);for(var l=1;l<Ho.length;l++){var d=Ho[l];d.blockedOn===i&&(d.blockedOn=null)}}for(Mi!==null&&Ms(Mi,i),Ti!==null&&Ms(Ti,i),Ai!==null&&Ms(Ai,i),js.forEach(r),Ls.forEach(r),l=0;l<Ii.length;l++)d=Ii[l],d.blockedOn===i&&(d.blockedOn=null);for(;0<Ii.length&&(l=Ii[0],l.blockedOn===null);)pf(l),l.blockedOn===null&&Ii.shift()}var $r=D.ReactCurrentBatchConfig,Uo=!0;function Ww(i,r,l,d){var m=ht,v=$r.transition;$r.transition=null;try{ht=1,Ul(i,r,l,d)}finally{ht=m,$r.transition=v}}function Uw(i,r,l,d){var m=ht,v=$r.transition;$r.transition=null;try{ht=4,Ul(i,r,l,d)}finally{ht=m,$r.transition=v}}function Ul(i,r,l,d){if(Uo){var m=Kl(i,r,l,d);if(m===null)lc(i,r,d,Ko,l),ff(i,d);else if($w(m,i,r,l,d))d.stopPropagation();else if(ff(i,d),r&4&&-1<Fw.indexOf(i)){for(;m!==null;){var v=qs(m);if(v!==null&&cf(v),v=Kl(i,r,l,d),v===null&&lc(i,r,d,Ko,l),v===m)break;m=v}m!==null&&d.stopPropagation()}else lc(i,r,d,null,l)}}var Ko=null;function Kl(i,r,l,d){if(Ko=null,i=Be(d),i=dr(i),i!==null)if(r=ur(i),r===null)i=null;else if(l=r.tag,l===13){if(i=Qh(r),i!==null)return i;i=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null);return Ko=i,null}function gf(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(Lw()){case Ol:return 1;case sf:return 4;case Bo:case Dw:return 16;case of:return 536870912;default:return 16}default:return 16}}var Bi=null,ql=null,qo=null;function vf(){if(qo)return qo;var i,r=ql,l=r.length,d,m="value"in Bi?Bi.value:Bi.textContent,v=m.length;for(i=0;i<l&&r[i]===m[i];i++);var E=l-i;for(d=1;d<=E&&r[l-d]===m[v-d];d++);return qo=m.slice(i,1<d?1-d:void 0)}function Vo(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 Yo(){return!0}function _f(){return!1}function Pn(i){function r(l,d,m,v,E){this._reactName=l,this._targetInst=m,this.type=d,this.nativeEvent=v,this.target=E,this.currentTarget=null;for(var $ in i)i.hasOwnProperty($)&&(l=i[$],this[$]=l?l(v):v[$]);return this.isDefaultPrevented=(v.defaultPrevented!=null?v.defaultPrevented:v.returnValue===!1)?Yo:_f,this.isPropagationStopped=_f,this}return B(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Yo)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Yo)},persist:function(){},isPersistent:Yo}),r}var Hr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vl=Pn(Hr),As=B({},Hr,{view:0,detail:0}),Kw=Pn(As),Yl,Xl,Is,Xo=B({},As,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Jl,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!==Is&&(Is&&i.type==="mousemove"?(Yl=i.screenX-Is.screenX,Xl=i.screenY-Is.screenY):Xl=Yl=0,Is=i),Yl)},movementY:function(i){return"movementY"in i?i.movementY:Xl}}),yf=Pn(Xo),qw=B({},Xo,{dataTransfer:0}),Vw=Pn(qw),Yw=B({},As,{relatedTarget:0}),Gl=Pn(Yw),Xw=B({},Hr,{animationName:0,elapsedTime:0,pseudoElement:0}),Gw=Pn(Xw),Jw=B({},Hr,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Qw=Pn(Jw),Zw=B({},Hr,{data:0}),wf=Pn(Zw),eS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},tS={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"},nS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function iS(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=nS[i])?!!r[i]:!1}function Jl(){return iS}var rS=B({},As,{key:function(i){if(i.key){var r=eS[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=Vo(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?tS[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Jl,charCode:function(i){return i.type==="keypress"?Vo(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Vo(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),sS=Pn(rS),oS=B({},Xo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Sf=Pn(oS),aS=B({},As,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Jl}),lS=Pn(aS),cS=B({},Hr,{propertyName:0,elapsedTime:0,pseudoElement:0}),uS=Pn(cS),dS=B({},Xo,{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}),hS=Pn(dS),fS=[9,13,27,32],Ql=h&&"CompositionEvent"in window,Bs=null;h&&"documentMode"in document&&(Bs=document.documentMode);var pS=h&&"TextEvent"in window&&!Bs,bf=h&&(!Ql||Bs&&8<Bs&&11>=Bs),kf=" ",xf=!1;function Cf(i,r){switch(i){case"keyup":return fS.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ef(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Wr=!1;function mS(i,r){switch(i){case"compositionend":return Ef(r);case"keypress":return r.which!==32?null:(xf=!0,kf);case"textInput":return i=r.data,i===kf&&xf?null:i;default:return null}}function gS(i,r){if(Wr)return i==="compositionend"||!Ql&&Cf(i,r)?(i=vf(),qo=ql=Bi=null,Wr=!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 bf&&r.locale!=="ko"?null:r.data;default:return null}}var vS={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 Nf(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!vS[i.type]:r==="textarea"}function Rf(i,r,l,d){ue(d),r=ea(r,"onChange"),0<r.length&&(l=new Vl("onChange","change",null,l,d),i.push({event:l,listeners:r}))}var Os=null,zs=null;function _S(i){qf(i,0)}function Go(i){var r=Yr(i);if(ze(r))return i}function yS(i,r){if(i==="change")return r}var Pf=!1;if(h){var Zl;if(h){var ec="oninput"in document;if(!ec){var jf=document.createElement("div");jf.setAttribute("oninput","return;"),ec=typeof jf.oninput=="function"}Zl=ec}else Zl=!1;Pf=Zl&&(!document.documentMode||9<document.documentMode)}function Lf(){Os&&(Os.detachEvent("onpropertychange",Df),zs=Os=null)}function Df(i){if(i.propertyName==="value"&&Go(zs)){var r=[];Rf(r,zs,i,Be(i)),ii(_S,r)}}function wS(i,r,l){i==="focusin"?(Lf(),Os=r,zs=l,Os.attachEvent("onpropertychange",Df)):i==="focusout"&&Lf()}function SS(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Go(zs)}function bS(i,r){if(i==="click")return Go(r)}function kS(i,r){if(i==="input"||i==="change")return Go(r)}function xS(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var Gn=typeof Object.is=="function"?Object.is:xS;function Fs(i,r){if(Gn(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var l=Object.keys(i),d=Object.keys(r);if(l.length!==d.length)return!1;for(d=0;d<l.length;d++){var m=l[d];if(!p.call(r,m)||!Gn(i[m],r[m]))return!1}return!0}function Mf(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Tf(i,r){var l=Mf(i);i=0;for(var d;l;){if(l.nodeType===3){if(d=i+l.textContent.length,i<=r&&d>=r)return{node:l,offset:r-i};i=d}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Mf(l)}}function Af(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Af(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function If(){for(var i=window,r=Fe();r instanceof i.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)i=r.contentWindow;else break;r=Fe(i.document)}return r}function tc(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 CS(i){var r=If(),l=i.focusedElem,d=i.selectionRange;if(r!==l&&l&&l.ownerDocument&&Af(l.ownerDocument.documentElement,l)){if(d!==null&&tc(l)){if(r=d.start,i=d.end,i===void 0&&(i=r),"selectionStart"in l)l.selectionStart=r,l.selectionEnd=Math.min(i,l.value.length);else if(i=(r=l.ownerDocument||document)&&r.defaultView||window,i.getSelection){i=i.getSelection();var m=l.textContent.length,v=Math.min(d.start,m);d=d.end===void 0?v:Math.min(d.end,m),!i.extend&&v>d&&(m=d,d=v,v=m),m=Tf(l,v);var E=Tf(l,d);m&&E&&(i.rangeCount!==1||i.anchorNode!==m.node||i.anchorOffset!==m.offset||i.focusNode!==E.node||i.focusOffset!==E.offset)&&(r=r.createRange(),r.setStart(m.node,m.offset),i.removeAllRanges(),v>d?(i.addRange(r),i.extend(E.node,E.offset)):(r.setEnd(E.node,E.offset),i.addRange(r)))}}for(r=[],i=l;i=i.parentNode;)i.nodeType===1&&r.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<r.length;l++)i=r[l],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var ES=h&&"documentMode"in document&&11>=document.documentMode,Ur=null,nc=null,$s=null,ic=!1;function Bf(i,r,l){var d=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;ic||Ur==null||Ur!==Fe(d)||(d=Ur,"selectionStart"in d&&tc(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),$s&&Fs($s,d)||($s=d,d=ea(nc,"onSelect"),0<d.length&&(r=new Vl("onSelect","select",null,r,l),i.push({event:r,listeners:d}),r.target=Ur)))}function Jo(i,r){var l={};return l[i.toLowerCase()]=r.toLowerCase(),l["Webkit"+i]="webkit"+r,l["Moz"+i]="moz"+r,l}var Kr={animationend:Jo("Animation","AnimationEnd"),animationiteration:Jo("Animation","AnimationIteration"),animationstart:Jo("Animation","AnimationStart"),transitionend:Jo("Transition","TransitionEnd")},rc={},Of={};h&&(Of=document.createElement("div").style,"AnimationEvent"in window||(delete Kr.animationend.animation,delete Kr.animationiteration.animation,delete Kr.animationstart.animation),"TransitionEvent"in window||delete Kr.transitionend.transition);function Qo(i){if(rc[i])return rc[i];if(!Kr[i])return i;var r=Kr[i],l;for(l in r)if(r.hasOwnProperty(l)&&l in Of)return rc[i]=r[l];return i}var zf=Qo("animationend"),Ff=Qo("animationiteration"),$f=Qo("animationstart"),Hf=Qo("transitionend"),Wf=new Map,Uf="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 Oi(i,r){Wf.set(i,r),a(r,[i])}for(var sc=0;sc<Uf.length;sc++){var oc=Uf[sc],NS=oc.toLowerCase(),RS=oc[0].toUpperCase()+oc.slice(1);Oi(NS,"on"+RS)}Oi(zf,"onAnimationEnd"),Oi(Ff,"onAnimationIteration"),Oi($f,"onAnimationStart"),Oi("dblclick","onDoubleClick"),Oi("focusin","onFocus"),Oi("focusout","onBlur"),Oi(Hf,"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 Hs="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(" "),PS=new Set("cancel close invalid load scroll toggle".split(" ").concat(Hs));function Kf(i,r,l){var d=i.type||"unknown-event";i.currentTarget=l,Nw(d,r,void 0,i),i.currentTarget=null}function qf(i,r){r=(r&4)!==0;for(var l=0;l<i.length;l++){var d=i[l],m=d.event;d=d.listeners;e:{var v=void 0;if(r)for(var E=d.length-1;0<=E;E--){var $=d[E],Y=$.instance,ce=$.currentTarget;if($=$.listener,Y!==v&&m.isPropagationStopped())break e;Kf(m,$,ce),v=Y}else for(E=0;E<d.length;E++){if($=d[E],Y=$.instance,ce=$.currentTarget,$=$.listener,Y!==v&&m.isPropagationStopped())break e;Kf(m,$,ce),v=Y}}}if(wn)throw i=ri,wn=!1,ri=null,i}function wt(i,r){var l=r[pc];l===void 0&&(l=r[pc]=new Set);var d=i+"__bubble";l.has(d)||(Vf(r,i,2,!1),l.add(d))}function ac(i,r,l){var d=0;r&&(d|=4),Vf(l,i,d,r)}var Zo="_reactListening"+Math.random().toString(36).slice(2);function Ws(i){if(!i[Zo]){i[Zo]=!0,s.forEach(function(l){l!=="selectionchange"&&(PS.has(l)||ac(l,!1,i),ac(l,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[Zo]||(r[Zo]=!0,ac("selectionchange",!1,r))}}function Vf(i,r,l,d){switch(gf(r)){case 1:var m=Ww;break;case 4:m=Uw;break;default:m=Ul}l=m.bind(null,r,l,i),m=void 0,!Di||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(m=!0),d?m!==void 0?i.addEventListener(r,l,{capture:!0,passive:m}):i.addEventListener(r,l,!0):m!==void 0?i.addEventListener(r,l,{passive:m}):i.addEventListener(r,l,!1)}function lc(i,r,l,d,m){var v=d;if((r&1)===0&&(r&2)===0&&d!==null)e:for(;;){if(d===null)return;var E=d.tag;if(E===3||E===4){var $=d.stateNode.containerInfo;if($===m||$.nodeType===8&&$.parentNode===m)break;if(E===4)for(E=d.return;E!==null;){var Y=E.tag;if((Y===3||Y===4)&&(Y=E.stateNode.containerInfo,Y===m||Y.nodeType===8&&Y.parentNode===m))return;E=E.return}for(;$!==null;){if(E=dr($),E===null)return;if(Y=E.tag,Y===5||Y===6){d=v=E;continue e}$=$.parentNode}}d=d.return}ii(function(){var ce=v,ye=Be(l),Se=[];e:{var _e=Wf.get(i);if(_e!==void 0){var je=Vl,De=i;switch(i){case"keypress":if(Vo(l)===0)break e;case"keydown":case"keyup":je=sS;break;case"focusin":De="focus",je=Gl;break;case"focusout":De="blur",je=Gl;break;case"beforeblur":case"afterblur":je=Gl;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":je=yf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":je=Vw;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":je=lS;break;case zf:case Ff:case $f:je=Gw;break;case Hf:je=uS;break;case"scroll":je=Kw;break;case"wheel":je=hS;break;case"copy":case"cut":case"paste":je=Qw;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":je=Sf}var Me=(r&4)!==0,At=!Me&&i==="scroll",re=Me?_e!==null?_e+"Capture":null:_e;Me=[];for(var J=ce,ae;J!==null;){ae=J;var xe=ae.stateNode;if(ae.tag===5&&xe!==null&&(ae=xe,re!==null&&(xe=Ft(J,re),xe!=null&&Me.push(Us(J,xe,ae)))),At)break;J=J.return}0<Me.length&&(_e=new je(_e,De,null,l,ye),Se.push({event:_e,listeners:Me}))}}if((r&7)===0){e:{if(_e=i==="mouseover"||i==="pointerover",je=i==="mouseout"||i==="pointerout",_e&&l!==gt&&(De=l.relatedTarget||l.fromElement)&&(dr(De)||De[wi]))break e;if((je||_e)&&(_e=ye.window===ye?ye:(_e=ye.ownerDocument)?_e.defaultView||_e.parentWindow:window,je?(De=l.relatedTarget||l.toElement,je=ce,De=De?dr(De):null,De!==null&&(At=ur(De),De!==At||De.tag!==5&&De.tag!==6)&&(De=null)):(je=null,De=ce),je!==De)){if(Me=yf,xe="onMouseLeave",re="onMouseEnter",J="mouse",(i==="pointerout"||i==="pointerover")&&(Me=Sf,xe="onPointerLeave",re="onPointerEnter",J="pointer"),At=je==null?_e:Yr(je),ae=De==null?_e:Yr(De),_e=new Me(xe,J+"leave",je,l,ye),_e.target=At,_e.relatedTarget=ae,xe=null,dr(ye)===ce&&(Me=new Me(re,J+"enter",De,l,ye),Me.target=ae,Me.relatedTarget=At,xe=Me),At=xe,je&&De)t:{for(Me=je,re=De,J=0,ae=Me;ae;ae=qr(ae))J++;for(ae=0,xe=re;xe;xe=qr(xe))ae++;for(;0<J-ae;)Me=qr(Me),J--;for(;0<ae-J;)re=qr(re),ae--;for(;J--;){if(Me===re||re!==null&&Me===re.alternate)break t;Me=qr(Me),re=qr(re)}Me=null}else Me=null;je!==null&&Yf(Se,_e,je,Me,!1),De!==null&&At!==null&&Yf(Se,At,De,Me,!0)}}e:{if(_e=ce?Yr(ce):window,je=_e.nodeName&&_e.nodeName.toLowerCase(),je==="select"||je==="input"&&_e.type==="file")var Te=yS;else if(Nf(_e))if(Pf)Te=kS;else{Te=SS;var $e=wS}else(je=_e.nodeName)&&je.toLowerCase()==="input"&&(_e.type==="checkbox"||_e.type==="radio")&&(Te=bS);if(Te&&(Te=Te(i,ce))){Rf(Se,Te,l,ye);break e}$e&&$e(i,_e,ce),i==="focusout"&&($e=_e._wrapperState)&&$e.controlled&&_e.type==="number"&&pt(_e,"number",_e.value)}switch($e=ce?Yr(ce):window,i){case"focusin":(Nf($e)||$e.contentEditable==="true")&&(Ur=$e,nc=ce,$s=null);break;case"focusout":$s=nc=Ur=null;break;case"mousedown":ic=!0;break;case"contextmenu":case"mouseup":case"dragend":ic=!1,Bf(Se,l,ye);break;case"selectionchange":if(ES)break;case"keydown":case"keyup":Bf(Se,l,ye)}var He;if(Ql)e:{switch(i){case"compositionstart":var Ve="onCompositionStart";break e;case"compositionend":Ve="onCompositionEnd";break e;case"compositionupdate":Ve="onCompositionUpdate";break e}Ve=void 0}else Wr?Cf(i,l)&&(Ve="onCompositionEnd"):i==="keydown"&&l.keyCode===229&&(Ve="onCompositionStart");Ve&&(bf&&l.locale!=="ko"&&(Wr||Ve!=="onCompositionStart"?Ve==="onCompositionEnd"&&Wr&&(He=vf()):(Bi=ye,ql="value"in Bi?Bi.value:Bi.textContent,Wr=!0)),$e=ea(ce,Ve),0<$e.length&&(Ve=new wf(Ve,i,null,l,ye),Se.push({event:Ve,listeners:$e}),He?Ve.data=He:(He=Ef(l),He!==null&&(Ve.data=He)))),(He=pS?mS(i,l):gS(i,l))&&(ce=ea(ce,"onBeforeInput"),0<ce.length&&(ye=new wf("onBeforeInput","beforeinput",null,l,ye),Se.push({event:ye,listeners:ce}),ye.data=He))}qf(Se,r)})}function Us(i,r,l){return{instance:i,listener:r,currentTarget:l}}function ea(i,r){for(var l=r+"Capture",d=[];i!==null;){var m=i,v=m.stateNode;m.tag===5&&v!==null&&(m=v,v=Ft(i,l),v!=null&&d.unshift(Us(i,v,m)),v=Ft(i,r),v!=null&&d.push(Us(i,v,m))),i=i.return}return d}function qr(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function Yf(i,r,l,d,m){for(var v=r._reactName,E=[];l!==null&&l!==d;){var $=l,Y=$.alternate,ce=$.stateNode;if(Y!==null&&Y===d)break;$.tag===5&&ce!==null&&($=ce,m?(Y=Ft(l,v),Y!=null&&E.unshift(Us(l,Y,$))):m||(Y=Ft(l,v),Y!=null&&E.push(Us(l,Y,$)))),l=l.return}E.length!==0&&i.push({event:r,listeners:E})}var jS=/\r\n?/g,LS=/\u0000|\uFFFD/g;function Xf(i){return(typeof i=="string"?i:""+i).replace(jS,`
38
+ `).replace(LS,"")}function ta(i,r,l){if(r=Xf(r),Xf(i)!==r&&l)throw Error(n(425))}function na(){}var cc=null,uc=null;function dc(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 hc=typeof setTimeout=="function"?setTimeout:void 0,DS=typeof clearTimeout=="function"?clearTimeout:void 0,Gf=typeof Promise=="function"?Promise:void 0,MS=typeof queueMicrotask=="function"?queueMicrotask:typeof Gf<"u"?function(i){return Gf.resolve(null).then(i).catch(TS)}:hc;function TS(i){setTimeout(function(){throw i})}function fc(i,r){var l=r,d=0;do{var m=l.nextSibling;if(i.removeChild(l),m&&m.nodeType===8)if(l=m.data,l==="/$"){if(d===0){i.removeChild(m),Ts(r);return}d--}else l!=="$"&&l!=="$?"&&l!=="$!"||d++;l=m}while(l);Ts(r)}function zi(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 Jf(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var l=i.data;if(l==="$"||l==="$!"||l==="$?"){if(r===0)return i;r--}else l==="/$"&&r++}i=i.previousSibling}return null}var Vr=Math.random().toString(36).slice(2),oi="__reactFiber$"+Vr,Ks="__reactProps$"+Vr,wi="__reactContainer$"+Vr,pc="__reactEvents$"+Vr,AS="__reactListeners$"+Vr,IS="__reactHandles$"+Vr;function dr(i){var r=i[oi];if(r)return r;for(var l=i.parentNode;l;){if(r=l[wi]||l[oi]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(i=Jf(i);i!==null;){if(l=i[oi])return l;i=Jf(i)}return r}i=l,l=i.parentNode}return null}function qs(i){return i=i[oi]||i[wi],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function Yr(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function ia(i){return i[Ks]||null}var mc=[],Xr=-1;function Fi(i){return{current:i}}function St(i){0>Xr||(i.current=mc[Xr],mc[Xr]=null,Xr--)}function vt(i,r){Xr++,mc[Xr]=i.current,i.current=r}var $i={},ln=Fi($i),Sn=Fi(!1),hr=$i;function Gr(i,r){var l=i.type.contextTypes;if(!l)return $i;var d=i.stateNode;if(d&&d.__reactInternalMemoizedUnmaskedChildContext===r)return d.__reactInternalMemoizedMaskedChildContext;var m={},v;for(v in l)m[v]=r[v];return d&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=r,i.__reactInternalMemoizedMaskedChildContext=m),m}function bn(i){return i=i.childContextTypes,i!=null}function ra(){St(Sn),St(ln)}function Qf(i,r,l){if(ln.current!==$i)throw Error(n(168));vt(ln,r),vt(Sn,l)}function Zf(i,r,l){var d=i.stateNode;if(r=r.childContextTypes,typeof d.getChildContext!="function")return l;d=d.getChildContext();for(var m in d)if(!(m in r))throw Error(n(108,Q(i)||"Unknown",m));return B({},l,d)}function sa(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||$i,hr=ln.current,vt(ln,i),vt(Sn,Sn.current),!0}function ep(i,r,l){var d=i.stateNode;if(!d)throw Error(n(169));l?(i=Zf(i,r,hr),d.__reactInternalMemoizedMergedChildContext=i,St(Sn),St(ln),vt(ln,i)):St(Sn),vt(Sn,l)}var Si=null,oa=!1,gc=!1;function tp(i){Si===null?Si=[i]:Si.push(i)}function BS(i){oa=!0,tp(i)}function Hi(){if(!gc&&Si!==null){gc=!0;var i=0,r=ht;try{var l=Si;for(ht=1;i<l.length;i++){var d=l[i];do d=d(!0);while(d!==null)}Si=null,oa=!1}catch(m){throw Si!==null&&(Si=Si.slice(i+1)),nf(Ol,Hi),m}finally{ht=r,gc=!1}}return null}var Jr=[],Qr=0,aa=null,la=0,zn=[],Fn=0,fr=null,bi=1,ki="";function pr(i,r){Jr[Qr++]=la,Jr[Qr++]=aa,aa=i,la=r}function np(i,r,l){zn[Fn++]=bi,zn[Fn++]=ki,zn[Fn++]=fr,fr=i;var d=bi;i=ki;var m=32-Xn(d)-1;d&=~(1<<m),l+=1;var v=32-Xn(r)+m;if(30<v){var E=m-m%5;v=(d&(1<<E)-1).toString(32),d>>=E,m-=E,bi=1<<32-Xn(r)+m|l<<m|d,ki=v+i}else bi=1<<v|l<<m|d,ki=i}function vc(i){i.return!==null&&(pr(i,1),np(i,1,0))}function _c(i){for(;i===aa;)aa=Jr[--Qr],Jr[Qr]=null,la=Jr[--Qr],Jr[Qr]=null;for(;i===fr;)fr=zn[--Fn],zn[Fn]=null,ki=zn[--Fn],zn[Fn]=null,bi=zn[--Fn],zn[Fn]=null}var jn=null,Ln=null,xt=!1,Jn=null;function ip(i,r){var l=Un(5,null,null,0);l.elementType="DELETED",l.stateNode=r,l.return=i,r=i.deletions,r===null?(i.deletions=[l],i.flags|=16):r.push(l)}function rp(i,r){switch(i.tag){case 5:var l=i.type;return r=r.nodeType!==1||l.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(i.stateNode=r,jn=i,Ln=zi(r.firstChild),!0):!1;case 6:return r=i.pendingProps===""||r.nodeType!==3?null:r,r!==null?(i.stateNode=r,jn=i,Ln=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(l=fr!==null?{id:bi,overflow:ki}:null,i.memoizedState={dehydrated:r,treeContext:l,retryLane:1073741824},l=Un(18,null,null,0),l.stateNode=r,l.return=i,i.child=l,jn=i,Ln=null,!0):!1;default:return!1}}function yc(i){return(i.mode&1)!==0&&(i.flags&128)===0}function wc(i){if(xt){var r=Ln;if(r){var l=r;if(!rp(i,r)){if(yc(i))throw Error(n(418));r=zi(l.nextSibling);var d=jn;r&&rp(i,r)?ip(d,l):(i.flags=i.flags&-4097|2,xt=!1,jn=i)}}else{if(yc(i))throw Error(n(418));i.flags=i.flags&-4097|2,xt=!1,jn=i}}}function sp(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;jn=i}function ca(i){if(i!==jn)return!1;if(!xt)return sp(i),xt=!0,!1;var r;if((r=i.tag!==3)&&!(r=i.tag!==5)&&(r=i.type,r=r!=="head"&&r!=="body"&&!dc(i.type,i.memoizedProps)),r&&(r=Ln)){if(yc(i))throw op(),Error(n(418));for(;r;)ip(i,r),r=zi(r.nextSibling)}if(sp(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,r=0;i;){if(i.nodeType===8){var l=i.data;if(l==="/$"){if(r===0){Ln=zi(i.nextSibling);break e}r--}else l!=="$"&&l!=="$!"&&l!=="$?"||r++}i=i.nextSibling}Ln=null}}else Ln=jn?zi(i.stateNode.nextSibling):null;return!0}function op(){for(var i=Ln;i;)i=zi(i.nextSibling)}function Zr(){Ln=jn=null,xt=!1}function Sc(i){Jn===null?Jn=[i]:Jn.push(i)}var OS=D.ReactCurrentBatchConfig;function Vs(i,r,l){if(i=l.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(n(309));var d=l.stateNode}if(!d)throw Error(n(147,i));var m=d,v=""+i;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===v?r.ref:(r=function(E){var $=m.refs;E===null?delete $[v]:$[v]=E},r._stringRef=v,r)}if(typeof i!="string")throw Error(n(284));if(!l._owner)throw Error(n(290,i))}return i}function ua(i,r){throw i=Object.prototype.toString.call(r),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i))}function ap(i){var r=i._init;return r(i._payload)}function lp(i){function r(re,J){if(i){var ae=re.deletions;ae===null?(re.deletions=[J],re.flags|=16):ae.push(J)}}function l(re,J){if(!i)return null;for(;J!==null;)r(re,J),J=J.sibling;return null}function d(re,J){for(re=new Map;J!==null;)J.key!==null?re.set(J.key,J):re.set(J.index,J),J=J.sibling;return re}function m(re,J){return re=Gi(re,J),re.index=0,re.sibling=null,re}function v(re,J,ae){return re.index=ae,i?(ae=re.alternate,ae!==null?(ae=ae.index,ae<J?(re.flags|=2,J):ae):(re.flags|=2,J)):(re.flags|=1048576,J)}function E(re){return i&&re.alternate===null&&(re.flags|=2),re}function $(re,J,ae,xe){return J===null||J.tag!==6?(J=hu(ae,re.mode,xe),J.return=re,J):(J=m(J,ae),J.return=re,J)}function Y(re,J,ae,xe){var Te=ae.type;return Te===A?ye(re,J,ae.props.children,xe,ae.key):J!==null&&(J.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===F&&ap(Te)===J.type)?(xe=m(J,ae.props),xe.ref=Vs(re,J,ae),xe.return=re,xe):(xe=Ta(ae.type,ae.key,ae.props,null,re.mode,xe),xe.ref=Vs(re,J,ae),xe.return=re,xe)}function ce(re,J,ae,xe){return J===null||J.tag!==4||J.stateNode.containerInfo!==ae.containerInfo||J.stateNode.implementation!==ae.implementation?(J=fu(ae,re.mode,xe),J.return=re,J):(J=m(J,ae.children||[]),J.return=re,J)}function ye(re,J,ae,xe,Te){return J===null||J.tag!==7?(J=br(ae,re.mode,xe,Te),J.return=re,J):(J=m(J,ae),J.return=re,J)}function Se(re,J,ae){if(typeof J=="string"&&J!==""||typeof J=="number")return J=hu(""+J,re.mode,ae),J.return=re,J;if(typeof J=="object"&&J!==null){switch(J.$$typeof){case X:return ae=Ta(J.type,J.key,J.props,null,re.mode,ae),ae.ref=Vs(re,null,J),ae.return=re,ae;case V:return J=fu(J,re.mode,ae),J.return=re,J;case F:var xe=J._init;return Se(re,xe(J._payload),ae)}if(st(J)||ie(J))return J=br(J,re.mode,ae,null),J.return=re,J;ua(re,J)}return null}function _e(re,J,ae,xe){var Te=J!==null?J.key:null;if(typeof ae=="string"&&ae!==""||typeof ae=="number")return Te!==null?null:$(re,J,""+ae,xe);if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case X:return ae.key===Te?Y(re,J,ae,xe):null;case V:return ae.key===Te?ce(re,J,ae,xe):null;case F:return Te=ae._init,_e(re,J,Te(ae._payload),xe)}if(st(ae)||ie(ae))return Te!==null?null:ye(re,J,ae,xe,null);ua(re,ae)}return null}function je(re,J,ae,xe,Te){if(typeof xe=="string"&&xe!==""||typeof xe=="number")return re=re.get(ae)||null,$(J,re,""+xe,Te);if(typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case X:return re=re.get(xe.key===null?ae:xe.key)||null,Y(J,re,xe,Te);case V:return re=re.get(xe.key===null?ae:xe.key)||null,ce(J,re,xe,Te);case F:var $e=xe._init;return je(re,J,ae,$e(xe._payload),Te)}if(st(xe)||ie(xe))return re=re.get(ae)||null,ye(J,re,xe,Te,null);ua(J,xe)}return null}function De(re,J,ae,xe){for(var Te=null,$e=null,He=J,Ve=J=0,Xt=null;He!==null&&Ve<ae.length;Ve++){He.index>Ve?(Xt=He,He=null):Xt=He.sibling;var lt=_e(re,He,ae[Ve],xe);if(lt===null){He===null&&(He=Xt);break}i&&He&&lt.alternate===null&&r(re,He),J=v(lt,J,Ve),$e===null?Te=lt:$e.sibling=lt,$e=lt,He=Xt}if(Ve===ae.length)return l(re,He),xt&&pr(re,Ve),Te;if(He===null){for(;Ve<ae.length;Ve++)He=Se(re,ae[Ve],xe),He!==null&&(J=v(He,J,Ve),$e===null?Te=He:$e.sibling=He,$e=He);return xt&&pr(re,Ve),Te}for(He=d(re,He);Ve<ae.length;Ve++)Xt=je(He,re,Ve,ae[Ve],xe),Xt!==null&&(i&&Xt.alternate!==null&&He.delete(Xt.key===null?Ve:Xt.key),J=v(Xt,J,Ve),$e===null?Te=Xt:$e.sibling=Xt,$e=Xt);return i&&He.forEach(function(Ji){return r(re,Ji)}),xt&&pr(re,Ve),Te}function Me(re,J,ae,xe){var Te=ie(ae);if(typeof Te!="function")throw Error(n(150));if(ae=Te.call(ae),ae==null)throw Error(n(151));for(var $e=Te=null,He=J,Ve=J=0,Xt=null,lt=ae.next();He!==null&&!lt.done;Ve++,lt=ae.next()){He.index>Ve?(Xt=He,He=null):Xt=He.sibling;var Ji=_e(re,He,lt.value,xe);if(Ji===null){He===null&&(He=Xt);break}i&&He&&Ji.alternate===null&&r(re,He),J=v(Ji,J,Ve),$e===null?Te=Ji:$e.sibling=Ji,$e=Ji,He=Xt}if(lt.done)return l(re,He),xt&&pr(re,Ve),Te;if(He===null){for(;!lt.done;Ve++,lt=ae.next())lt=Se(re,lt.value,xe),lt!==null&&(J=v(lt,J,Ve),$e===null?Te=lt:$e.sibling=lt,$e=lt);return xt&&pr(re,Ve),Te}for(He=d(re,He);!lt.done;Ve++,lt=ae.next())lt=je(He,re,Ve,lt.value,xe),lt!==null&&(i&&lt.alternate!==null&&He.delete(lt.key===null?Ve:lt.key),J=v(lt,J,Ve),$e===null?Te=lt:$e.sibling=lt,$e=lt);return i&&He.forEach(function(vb){return r(re,vb)}),xt&&pr(re,Ve),Te}function At(re,J,ae,xe){if(typeof ae=="object"&&ae!==null&&ae.type===A&&ae.key===null&&(ae=ae.props.children),typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case X:e:{for(var Te=ae.key,$e=J;$e!==null;){if($e.key===Te){if(Te=ae.type,Te===A){if($e.tag===7){l(re,$e.sibling),J=m($e,ae.props.children),J.return=re,re=J;break e}}else if($e.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===F&&ap(Te)===$e.type){l(re,$e.sibling),J=m($e,ae.props),J.ref=Vs(re,$e,ae),J.return=re,re=J;break e}l(re,$e);break}else r(re,$e);$e=$e.sibling}ae.type===A?(J=br(ae.props.children,re.mode,xe,ae.key),J.return=re,re=J):(xe=Ta(ae.type,ae.key,ae.props,null,re.mode,xe),xe.ref=Vs(re,J,ae),xe.return=re,re=xe)}return E(re);case V:e:{for($e=ae.key;J!==null;){if(J.key===$e)if(J.tag===4&&J.stateNode.containerInfo===ae.containerInfo&&J.stateNode.implementation===ae.implementation){l(re,J.sibling),J=m(J,ae.children||[]),J.return=re,re=J;break e}else{l(re,J);break}else r(re,J);J=J.sibling}J=fu(ae,re.mode,xe),J.return=re,re=J}return E(re);case F:return $e=ae._init,At(re,J,$e(ae._payload),xe)}if(st(ae))return De(re,J,ae,xe);if(ie(ae))return Me(re,J,ae,xe);ua(re,ae)}return typeof ae=="string"&&ae!==""||typeof ae=="number"?(ae=""+ae,J!==null&&J.tag===6?(l(re,J.sibling),J=m(J,ae),J.return=re,re=J):(l(re,J),J=hu(ae,re.mode,xe),J.return=re,re=J),E(re)):l(re,J)}return At}var es=lp(!0),cp=lp(!1),da=Fi(null),ha=null,ts=null,bc=null;function kc(){bc=ts=ha=null}function xc(i){var r=da.current;St(da),i._currentValue=r}function Cc(i,r,l){for(;i!==null;){var d=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,d!==null&&(d.childLanes|=r)):d!==null&&(d.childLanes&r)!==r&&(d.childLanes|=r),i===l)break;i=i.return}}function ns(i,r){ha=i,bc=ts=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&r)!==0&&(kn=!0),i.firstContext=null)}function $n(i){var r=i._currentValue;if(bc!==i)if(i={context:i,memoizedValue:r,next:null},ts===null){if(ha===null)throw Error(n(308));ts=i,ha.dependencies={lanes:0,firstContext:i}}else ts=ts.next=i;return r}var mr=null;function Ec(i){mr===null?mr=[i]:mr.push(i)}function up(i,r,l,d){var m=r.interleaved;return m===null?(l.next=l,Ec(r)):(l.next=m.next,m.next=l),r.interleaved=l,xi(i,d)}function xi(i,r){i.lanes|=r;var l=i.alternate;for(l!==null&&(l.lanes|=r),l=i,i=i.return;i!==null;)i.childLanes|=r,l=i.alternate,l!==null&&(l.childLanes|=r),l=i,i=i.return;return l.tag===3?l.stateNode:null}var Wi=!1;function Nc(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function dp(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 Ci(i,r){return{eventTime:i,lane:r,tag:0,payload:null,callback:null,next:null}}function Ui(i,r,l){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(at&2)!==0){var m=d.pending;return m===null?r.next=r:(r.next=m.next,m.next=r),d.pending=r,xi(i,l)}return m=d.interleaved,m===null?(r.next=r,Ec(d)):(r.next=m.next,m.next=r),d.interleaved=r,xi(i,l)}function fa(i,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194240)!==0)){var d=r.lanes;d&=i.pendingLanes,l|=d,r.lanes=l,$l(i,l)}}function hp(i,r){var l=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,l===d)){var m=null,v=null;if(l=l.firstBaseUpdate,l!==null){do{var E={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};v===null?m=v=E:v=v.next=E,l=l.next}while(l!==null);v===null?m=v=r:v=v.next=r}else m=v=r;l={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:v,shared:d.shared,effects:d.effects},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=r:i.next=r,l.lastBaseUpdate=r}function pa(i,r,l,d){var m=i.updateQueue;Wi=!1;var v=m.firstBaseUpdate,E=m.lastBaseUpdate,$=m.shared.pending;if($!==null){m.shared.pending=null;var Y=$,ce=Y.next;Y.next=null,E===null?v=ce:E.next=ce,E=Y;var ye=i.alternate;ye!==null&&(ye=ye.updateQueue,$=ye.lastBaseUpdate,$!==E&&($===null?ye.firstBaseUpdate=ce:$.next=ce,ye.lastBaseUpdate=Y))}if(v!==null){var Se=m.baseState;E=0,ye=ce=Y=null,$=v;do{var _e=$.lane,je=$.eventTime;if((d&_e)===_e){ye!==null&&(ye=ye.next={eventTime:je,lane:0,tag:$.tag,payload:$.payload,callback:$.callback,next:null});e:{var De=i,Me=$;switch(_e=r,je=l,Me.tag){case 1:if(De=Me.payload,typeof De=="function"){Se=De.call(je,Se,_e);break e}Se=De;break e;case 3:De.flags=De.flags&-65537|128;case 0:if(De=Me.payload,_e=typeof De=="function"?De.call(je,Se,_e):De,_e==null)break e;Se=B({},Se,_e);break e;case 2:Wi=!0}}$.callback!==null&&$.lane!==0&&(i.flags|=64,_e=m.effects,_e===null?m.effects=[$]:_e.push($))}else je={eventTime:je,lane:_e,tag:$.tag,payload:$.payload,callback:$.callback,next:null},ye===null?(ce=ye=je,Y=Se):ye=ye.next=je,E|=_e;if($=$.next,$===null){if($=m.shared.pending,$===null)break;_e=$,$=_e.next,_e.next=null,m.lastBaseUpdate=_e,m.shared.pending=null}}while(!0);if(ye===null&&(Y=Se),m.baseState=Y,m.firstBaseUpdate=ce,m.lastBaseUpdate=ye,r=m.shared.interleaved,r!==null){m=r;do E|=m.lane,m=m.next;while(m!==r)}else v===null&&(m.shared.lanes=0);_r|=E,i.lanes=E,i.memoizedState=Se}}function fp(i,r,l){if(i=r.effects,r.effects=null,i!==null)for(r=0;r<i.length;r++){var d=i[r],m=d.callback;if(m!==null){if(d.callback=null,d=l,typeof m!="function")throw Error(n(191,m));m.call(d)}}}var Ys={},ai=Fi(Ys),Xs=Fi(Ys),Gs=Fi(Ys);function gr(i){if(i===Ys)throw Error(n(174));return i}function Rc(i,r){switch(vt(Gs,r),vt(Xs,i),vt(ai,Ys),i=r.nodeType,i){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:he(null,"");break;default:i=i===8?r.parentNode:r,r=i.namespaceURI||null,i=i.tagName,r=he(r,i)}St(ai),vt(ai,r)}function is(){St(ai),St(Xs),St(Gs)}function pp(i){gr(Gs.current);var r=gr(ai.current),l=he(r,i.type);r!==l&&(vt(Xs,i),vt(ai,l))}function Pc(i){Xs.current===i&&(St(ai),St(Xs))}var Nt=Fi(0);function ma(i){for(var r=i;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var jc=[];function Lc(){for(var i=0;i<jc.length;i++)jc[i]._workInProgressVersionPrimary=null;jc.length=0}var ga=D.ReactCurrentDispatcher,Dc=D.ReactCurrentBatchConfig,vr=0,Rt=null,$t=null,Vt=null,va=!1,Js=!1,Qs=0,zS=0;function cn(){throw Error(n(321))}function Mc(i,r){if(r===null)return!1;for(var l=0;l<r.length&&l<i.length;l++)if(!Gn(i[l],r[l]))return!1;return!0}function Tc(i,r,l,d,m,v){if(vr=v,Rt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,ga.current=i===null||i.memoizedState===null?WS:US,i=l(d,m),Js){v=0;do{if(Js=!1,Qs=0,25<=v)throw Error(n(301));v+=1,Vt=$t=null,r.updateQueue=null,ga.current=KS,i=l(d,m)}while(Js)}if(ga.current=wa,r=$t!==null&&$t.next!==null,vr=0,Vt=$t=Rt=null,va=!1,r)throw Error(n(300));return i}function Ac(){var i=Qs!==0;return Qs=0,i}function li(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Vt===null?Rt.memoizedState=Vt=i:Vt=Vt.next=i,Vt}function Hn(){if($t===null){var i=Rt.alternate;i=i!==null?i.memoizedState:null}else i=$t.next;var r=Vt===null?Rt.memoizedState:Vt.next;if(r!==null)Vt=r,$t=i;else{if(i===null)throw Error(n(310));$t=i,i={memoizedState:$t.memoizedState,baseState:$t.baseState,baseQueue:$t.baseQueue,queue:$t.queue,next:null},Vt===null?Rt.memoizedState=Vt=i:Vt=Vt.next=i}return Vt}function Zs(i,r){return typeof r=="function"?r(i):r}function Ic(i){var r=Hn(),l=r.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=i;var d=$t,m=d.baseQueue,v=l.pending;if(v!==null){if(m!==null){var E=m.next;m.next=v.next,v.next=E}d.baseQueue=m=v,l.pending=null}if(m!==null){v=m.next,d=d.baseState;var $=E=null,Y=null,ce=v;do{var ye=ce.lane;if((vr&ye)===ye)Y!==null&&(Y=Y.next={lane:0,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null}),d=ce.hasEagerState?ce.eagerState:i(d,ce.action);else{var Se={lane:ye,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null};Y===null?($=Y=Se,E=d):Y=Y.next=Se,Rt.lanes|=ye,_r|=ye}ce=ce.next}while(ce!==null&&ce!==v);Y===null?E=d:Y.next=$,Gn(d,r.memoizedState)||(kn=!0),r.memoizedState=d,r.baseState=E,r.baseQueue=Y,l.lastRenderedState=d}if(i=l.interleaved,i!==null){m=i;do v=m.lane,Rt.lanes|=v,_r|=v,m=m.next;while(m!==i)}else m===null&&(l.lanes=0);return[r.memoizedState,l.dispatch]}function Bc(i){var r=Hn(),l=r.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=i;var d=l.dispatch,m=l.pending,v=r.memoizedState;if(m!==null){l.pending=null;var E=m=m.next;do v=i(v,E.action),E=E.next;while(E!==m);Gn(v,r.memoizedState)||(kn=!0),r.memoizedState=v,r.baseQueue===null&&(r.baseState=v),l.lastRenderedState=v}return[v,d]}function mp(){}function gp(i,r){var l=Rt,d=Hn(),m=r(),v=!Gn(d.memoizedState,m);if(v&&(d.memoizedState=m,kn=!0),d=d.queue,Oc(yp.bind(null,l,d,i),[i]),d.getSnapshot!==r||v||Vt!==null&&Vt.memoizedState.tag&1){if(l.flags|=2048,eo(9,_p.bind(null,l,d,m,r),void 0,null),Yt===null)throw Error(n(349));(vr&30)!==0||vp(l,r,m)}return m}function vp(i,r,l){i.flags|=16384,i={getSnapshot:r,value:l},r=Rt.updateQueue,r===null?(r={lastEffect:null,stores:null},Rt.updateQueue=r,r.stores=[i]):(l=r.stores,l===null?r.stores=[i]:l.push(i))}function _p(i,r,l,d){r.value=l,r.getSnapshot=d,wp(r)&&Sp(i)}function yp(i,r,l){return l(function(){wp(r)&&Sp(i)})}function wp(i){var r=i.getSnapshot;i=i.value;try{var l=r();return!Gn(i,l)}catch{return!0}}function Sp(i){var r=xi(i,1);r!==null&&ti(r,i,1,-1)}function bp(i){var r=li();return typeof i=="function"&&(i=i()),r.memoizedState=r.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Zs,lastRenderedState:i},r.queue=i,i=i.dispatch=HS.bind(null,Rt,i),[r.memoizedState,i]}function eo(i,r,l,d){return i={tag:i,create:r,destroy:l,deps:d,next:null},r=Rt.updateQueue,r===null?(r={lastEffect:null,stores:null},Rt.updateQueue=r,r.lastEffect=i.next=i):(l=r.lastEffect,l===null?r.lastEffect=i.next=i:(d=l.next,l.next=i,i.next=d,r.lastEffect=i)),i}function kp(){return Hn().memoizedState}function _a(i,r,l,d){var m=li();Rt.flags|=i,m.memoizedState=eo(1|r,l,void 0,d===void 0?null:d)}function ya(i,r,l,d){var m=Hn();d=d===void 0?null:d;var v=void 0;if($t!==null){var E=$t.memoizedState;if(v=E.destroy,d!==null&&Mc(d,E.deps)){m.memoizedState=eo(r,l,v,d);return}}Rt.flags|=i,m.memoizedState=eo(1|r,l,v,d)}function xp(i,r){return _a(8390656,8,i,r)}function Oc(i,r){return ya(2048,8,i,r)}function Cp(i,r){return ya(4,2,i,r)}function Ep(i,r){return ya(4,4,i,r)}function Np(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 Rp(i,r,l){return l=l!=null?l.concat([i]):null,ya(4,4,Np.bind(null,r,i),l)}function zc(){}function Pp(i,r){var l=Hn();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&Mc(r,d[1])?d[0]:(l.memoizedState=[i,r],i)}function jp(i,r){var l=Hn();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&Mc(r,d[1])?d[0]:(i=i(),l.memoizedState=[i,r],i)}function Lp(i,r,l){return(vr&21)===0?(i.baseState&&(i.baseState=!1,kn=!0),i.memoizedState=l):(Gn(l,r)||(l=af(),Rt.lanes|=l,_r|=l,i.baseState=!0),r)}function FS(i,r){var l=ht;ht=l!==0&&4>l?l:4,i(!0);var d=Dc.transition;Dc.transition={};try{i(!1),r()}finally{ht=l,Dc.transition=d}}function Dp(){return Hn().memoizedState}function $S(i,r,l){var d=Yi(i);if(l={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null},Mp(i))Tp(r,l);else if(l=up(i,r,l,d),l!==null){var m=mn();ti(l,i,d,m),Ap(l,r,d)}}function HS(i,r,l){var d=Yi(i),m={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null};if(Mp(i))Tp(r,m);else{var v=i.alternate;if(i.lanes===0&&(v===null||v.lanes===0)&&(v=r.lastRenderedReducer,v!==null))try{var E=r.lastRenderedState,$=v(E,l);if(m.hasEagerState=!0,m.eagerState=$,Gn($,E)){var Y=r.interleaved;Y===null?(m.next=m,Ec(r)):(m.next=Y.next,Y.next=m),r.interleaved=m;return}}catch{}finally{}l=up(i,r,m,d),l!==null&&(m=mn(),ti(l,i,d,m),Ap(l,r,d))}}function Mp(i){var r=i.alternate;return i===Rt||r!==null&&r===Rt}function Tp(i,r){Js=va=!0;var l=i.pending;l===null?r.next=r:(r.next=l.next,l.next=r),i.pending=r}function Ap(i,r,l){if((l&4194240)!==0){var d=r.lanes;d&=i.pendingLanes,l|=d,r.lanes=l,$l(i,l)}}var wa={readContext:$n,useCallback:cn,useContext:cn,useEffect:cn,useImperativeHandle:cn,useInsertionEffect:cn,useLayoutEffect:cn,useMemo:cn,useReducer:cn,useRef:cn,useState:cn,useDebugValue:cn,useDeferredValue:cn,useTransition:cn,useMutableSource:cn,useSyncExternalStore:cn,useId:cn,unstable_isNewReconciler:!1},WS={readContext:$n,useCallback:function(i,r){return li().memoizedState=[i,r===void 0?null:r],i},useContext:$n,useEffect:xp,useImperativeHandle:function(i,r,l){return l=l!=null?l.concat([i]):null,_a(4194308,4,Np.bind(null,r,i),l)},useLayoutEffect:function(i,r){return _a(4194308,4,i,r)},useInsertionEffect:function(i,r){return _a(4,2,i,r)},useMemo:function(i,r){var l=li();return r=r===void 0?null:r,i=i(),l.memoizedState=[i,r],i},useReducer:function(i,r,l){var d=li();return r=l!==void 0?l(r):r,d.memoizedState=d.baseState=r,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:r},d.queue=i,i=i.dispatch=$S.bind(null,Rt,i),[d.memoizedState,i]},useRef:function(i){var r=li();return i={current:i},r.memoizedState=i},useState:bp,useDebugValue:zc,useDeferredValue:function(i){return li().memoizedState=i},useTransition:function(){var i=bp(!1),r=i[0];return i=FS.bind(null,i[1]),li().memoizedState=i,[r,i]},useMutableSource:function(){},useSyncExternalStore:function(i,r,l){var d=Rt,m=li();if(xt){if(l===void 0)throw Error(n(407));l=l()}else{if(l=r(),Yt===null)throw Error(n(349));(vr&30)!==0||vp(d,r,l)}m.memoizedState=l;var v={value:l,getSnapshot:r};return m.queue=v,xp(yp.bind(null,d,v,i),[i]),d.flags|=2048,eo(9,_p.bind(null,d,v,l,r),void 0,null),l},useId:function(){var i=li(),r=Yt.identifierPrefix;if(xt){var l=ki,d=bi;l=(d&~(1<<32-Xn(d)-1)).toString(32)+l,r=":"+r+"R"+l,l=Qs++,0<l&&(r+="H"+l.toString(32)),r+=":"}else l=zS++,r=":"+r+"r"+l.toString(32)+":";return i.memoizedState=r},unstable_isNewReconciler:!1},US={readContext:$n,useCallback:Pp,useContext:$n,useEffect:Oc,useImperativeHandle:Rp,useInsertionEffect:Cp,useLayoutEffect:Ep,useMemo:jp,useReducer:Ic,useRef:kp,useState:function(){return Ic(Zs)},useDebugValue:zc,useDeferredValue:function(i){var r=Hn();return Lp(r,$t.memoizedState,i)},useTransition:function(){var i=Ic(Zs)[0],r=Hn().memoizedState;return[i,r]},useMutableSource:mp,useSyncExternalStore:gp,useId:Dp,unstable_isNewReconciler:!1},KS={readContext:$n,useCallback:Pp,useContext:$n,useEffect:Oc,useImperativeHandle:Rp,useInsertionEffect:Cp,useLayoutEffect:Ep,useMemo:jp,useReducer:Bc,useRef:kp,useState:function(){return Bc(Zs)},useDebugValue:zc,useDeferredValue:function(i){var r=Hn();return $t===null?r.memoizedState=i:Lp(r,$t.memoizedState,i)},useTransition:function(){var i=Bc(Zs)[0],r=Hn().memoizedState;return[i,r]},useMutableSource:mp,useSyncExternalStore:gp,useId:Dp,unstable_isNewReconciler:!1};function Qn(i,r){if(i&&i.defaultProps){r=B({},r),i=i.defaultProps;for(var l in i)r[l]===void 0&&(r[l]=i[l]);return r}return r}function Fc(i,r,l,d){r=i.memoizedState,l=l(d,r),l=l==null?r:B({},r,l),i.memoizedState=l,i.lanes===0&&(i.updateQueue.baseState=l)}var Sa={isMounted:function(i){return(i=i._reactInternals)?ur(i)===i:!1},enqueueSetState:function(i,r,l){i=i._reactInternals;var d=mn(),m=Yi(i),v=Ci(d,m);v.payload=r,l!=null&&(v.callback=l),r=Ui(i,v,m),r!==null&&(ti(r,i,m,d),fa(r,i,m))},enqueueReplaceState:function(i,r,l){i=i._reactInternals;var d=mn(),m=Yi(i),v=Ci(d,m);v.tag=1,v.payload=r,l!=null&&(v.callback=l),r=Ui(i,v,m),r!==null&&(ti(r,i,m,d),fa(r,i,m))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var l=mn(),d=Yi(i),m=Ci(l,d);m.tag=2,r!=null&&(m.callback=r),r=Ui(i,m,d),r!==null&&(ti(r,i,d,l),fa(r,i,d))}};function Ip(i,r,l,d,m,v,E){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(d,v,E):r.prototype&&r.prototype.isPureReactComponent?!Fs(l,d)||!Fs(m,v):!0}function Bp(i,r,l){var d=!1,m=$i,v=r.contextType;return typeof v=="object"&&v!==null?v=$n(v):(m=bn(r)?hr:ln.current,d=r.contextTypes,v=(d=d!=null)?Gr(i,m):$i),r=new r(l,v),i.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=Sa,i.stateNode=r,r._reactInternals=i,d&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=m,i.__reactInternalMemoizedMaskedChildContext=v),r}function Op(i,r,l,d){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,d),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,d),r.state!==i&&Sa.enqueueReplaceState(r,r.state,null)}function $c(i,r,l,d){var m=i.stateNode;m.props=l,m.state=i.memoizedState,m.refs={},Nc(i);var v=r.contextType;typeof v=="object"&&v!==null?m.context=$n(v):(v=bn(r)?hr:ln.current,m.context=Gr(i,v)),m.state=i.memoizedState,v=r.getDerivedStateFromProps,typeof v=="function"&&(Fc(i,r,v,l),m.state=i.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof m.getSnapshotBeforeUpdate=="function"||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(r=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),r!==m.state&&Sa.enqueueReplaceState(m,m.state,null),pa(i,l,m,d),m.state=i.memoizedState),typeof m.componentDidMount=="function"&&(i.flags|=4194308)}function rs(i,r){try{var l="",d=r;do l+=de(d),d=d.return;while(d);var m=l}catch(v){m=`
39
+ Error generating stack: `+v.message+`
40
+ `+v.stack}return{value:i,source:r,stack:m,digest:null}}function Hc(i,r,l){return{value:i,source:null,stack:l??null,digest:r??null}}function Wc(i,r){try{console.error(r.value)}catch(l){setTimeout(function(){throw l})}}var qS=typeof WeakMap=="function"?WeakMap:Map;function zp(i,r,l){l=Ci(-1,l),l.tag=3,l.payload={element:null};var d=r.value;return l.callback=function(){Ra||(Ra=!0,ru=d),Wc(i,r)},l}function Fp(i,r,l){l=Ci(-1,l),l.tag=3;var d=i.type.getDerivedStateFromError;if(typeof d=="function"){var m=r.value;l.payload=function(){return d(m)},l.callback=function(){Wc(i,r)}}var v=i.stateNode;return v!==null&&typeof v.componentDidCatch=="function"&&(l.callback=function(){Wc(i,r),typeof d!="function"&&(qi===null?qi=new Set([this]):qi.add(this));var E=r.stack;this.componentDidCatch(r.value,{componentStack:E!==null?E:""})}),l}function $p(i,r,l){var d=i.pingCache;if(d===null){d=i.pingCache=new qS;var m=new Set;d.set(r,m)}else m=d.get(r),m===void 0&&(m=new Set,d.set(r,m));m.has(l)||(m.add(l),i=ob.bind(null,i,r,l),r.then(i,i))}function Hp(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 Wp(i,r,l,d,m){return(i.mode&1)===0?(i===r?i.flags|=65536:(i.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(r=Ci(-1,1),r.tag=2,Ui(l,r,1))),l.lanes|=1),i):(i.flags|=65536,i.lanes=m,i)}var VS=D.ReactCurrentOwner,kn=!1;function pn(i,r,l,d){r.child=i===null?cp(r,null,l,d):es(r,i.child,l,d)}function Up(i,r,l,d,m){l=l.render;var v=r.ref;return ns(r,m),d=Tc(i,r,l,d,v,m),l=Ac(),i!==null&&!kn?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~m,Ei(i,r,m)):(xt&&l&&vc(r),r.flags|=1,pn(i,r,d,m),r.child)}function Kp(i,r,l,d,m){if(i===null){var v=l.type;return typeof v=="function"&&!du(v)&&v.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(r.tag=15,r.type=v,qp(i,r,v,d,m)):(i=Ta(l.type,null,d,r,r.mode,m),i.ref=r.ref,i.return=r,r.child=i)}if(v=i.child,(i.lanes&m)===0){var E=v.memoizedProps;if(l=l.compare,l=l!==null?l:Fs,l(E,d)&&i.ref===r.ref)return Ei(i,r,m)}return r.flags|=1,i=Gi(v,d),i.ref=r.ref,i.return=r,r.child=i}function qp(i,r,l,d,m){if(i!==null){var v=i.memoizedProps;if(Fs(v,d)&&i.ref===r.ref)if(kn=!1,r.pendingProps=d=v,(i.lanes&m)!==0)(i.flags&131072)!==0&&(kn=!0);else return r.lanes=i.lanes,Ei(i,r,m)}return Uc(i,r,l,d,m)}function Vp(i,r,l){var d=r.pendingProps,m=d.children,v=i!==null?i.memoizedState:null;if(d.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},vt(os,Dn),Dn|=l;else{if((l&1073741824)===0)return i=v!==null?v.baseLanes|l:l,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:i,cachePool:null,transitions:null},r.updateQueue=null,vt(os,Dn),Dn|=i,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},d=v!==null?v.baseLanes:l,vt(os,Dn),Dn|=d}else v!==null?(d=v.baseLanes|l,r.memoizedState=null):d=l,vt(os,Dn),Dn|=d;return pn(i,r,m,l),r.child}function Yp(i,r){var l=r.ref;(i===null&&l!==null||i!==null&&i.ref!==l)&&(r.flags|=512,r.flags|=2097152)}function Uc(i,r,l,d,m){var v=bn(l)?hr:ln.current;return v=Gr(r,v),ns(r,m),l=Tc(i,r,l,d,v,m),d=Ac(),i!==null&&!kn?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~m,Ei(i,r,m)):(xt&&d&&vc(r),r.flags|=1,pn(i,r,l,m),r.child)}function Xp(i,r,l,d,m){if(bn(l)){var v=!0;sa(r)}else v=!1;if(ns(r,m),r.stateNode===null)ka(i,r),Bp(r,l,d),$c(r,l,d,m),d=!0;else if(i===null){var E=r.stateNode,$=r.memoizedProps;E.props=$;var Y=E.context,ce=l.contextType;typeof ce=="object"&&ce!==null?ce=$n(ce):(ce=bn(l)?hr:ln.current,ce=Gr(r,ce));var ye=l.getDerivedStateFromProps,Se=typeof ye=="function"||typeof E.getSnapshotBeforeUpdate=="function";Se||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||($!==d||Y!==ce)&&Op(r,E,d,ce),Wi=!1;var _e=r.memoizedState;E.state=_e,pa(r,d,E,m),Y=r.memoizedState,$!==d||_e!==Y||Sn.current||Wi?(typeof ye=="function"&&(Fc(r,l,ye,d),Y=r.memoizedState),($=Wi||Ip(r,l,$,d,_e,Y,ce))?(Se||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount()),typeof E.componentDidMount=="function"&&(r.flags|=4194308)):(typeof E.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=d,r.memoizedState=Y),E.props=d,E.state=Y,E.context=ce,d=$):(typeof E.componentDidMount=="function"&&(r.flags|=4194308),d=!1)}else{E=r.stateNode,dp(i,r),$=r.memoizedProps,ce=r.type===r.elementType?$:Qn(r.type,$),E.props=ce,Se=r.pendingProps,_e=E.context,Y=l.contextType,typeof Y=="object"&&Y!==null?Y=$n(Y):(Y=bn(l)?hr:ln.current,Y=Gr(r,Y));var je=l.getDerivedStateFromProps;(ye=typeof je=="function"||typeof E.getSnapshotBeforeUpdate=="function")||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||($!==Se||_e!==Y)&&Op(r,E,d,Y),Wi=!1,_e=r.memoizedState,E.state=_e,pa(r,d,E,m);var De=r.memoizedState;$!==Se||_e!==De||Sn.current||Wi?(typeof je=="function"&&(Fc(r,l,je,d),De=r.memoizedState),(ce=Wi||Ip(r,l,ce,d,_e,De,Y)||!1)?(ye||typeof E.UNSAFE_componentWillUpdate!="function"&&typeof E.componentWillUpdate!="function"||(typeof E.componentWillUpdate=="function"&&E.componentWillUpdate(d,De,Y),typeof E.UNSAFE_componentWillUpdate=="function"&&E.UNSAFE_componentWillUpdate(d,De,Y)),typeof E.componentDidUpdate=="function"&&(r.flags|=4),typeof E.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof E.componentDidUpdate!="function"||$===i.memoizedProps&&_e===i.memoizedState||(r.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||$===i.memoizedProps&&_e===i.memoizedState||(r.flags|=1024),r.memoizedProps=d,r.memoizedState=De),E.props=d,E.state=De,E.context=Y,d=ce):(typeof E.componentDidUpdate!="function"||$===i.memoizedProps&&_e===i.memoizedState||(r.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||$===i.memoizedProps&&_e===i.memoizedState||(r.flags|=1024),d=!1)}return Kc(i,r,l,d,v,m)}function Kc(i,r,l,d,m,v){Yp(i,r);var E=(r.flags&128)!==0;if(!d&&!E)return m&&ep(r,l,!1),Ei(i,r,v);d=r.stateNode,VS.current=r;var $=E&&typeof l.getDerivedStateFromError!="function"?null:d.render();return r.flags|=1,i!==null&&E?(r.child=es(r,i.child,null,v),r.child=es(r,null,$,v)):pn(i,r,$,v),r.memoizedState=d.state,m&&ep(r,l,!0),r.child}function Gp(i){var r=i.stateNode;r.pendingContext?Qf(i,r.pendingContext,r.pendingContext!==r.context):r.context&&Qf(i,r.context,!1),Rc(i,r.containerInfo)}function Jp(i,r,l,d,m){return Zr(),Sc(m),r.flags|=256,pn(i,r,l,d),r.child}var qc={dehydrated:null,treeContext:null,retryLane:0};function Vc(i){return{baseLanes:i,cachePool:null,transitions:null}}function Qp(i,r,l){var d=r.pendingProps,m=Nt.current,v=!1,E=(r.flags&128)!==0,$;if(($=E)||($=i!==null&&i.memoizedState===null?!1:(m&2)!==0),$?(v=!0,r.flags&=-129):(i===null||i.memoizedState!==null)&&(m|=1),vt(Nt,m&1),i===null)return wc(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):(E=d.children,i=d.fallback,v?(d=r.mode,v=r.child,E={mode:"hidden",children:E},(d&1)===0&&v!==null?(v.childLanes=0,v.pendingProps=E):v=Aa(E,d,0,null),i=br(i,d,l,null),v.return=r,i.return=r,v.sibling=i,r.child=v,r.child.memoizedState=Vc(l),r.memoizedState=qc,i):Yc(r,E));if(m=i.memoizedState,m!==null&&($=m.dehydrated,$!==null))return YS(i,r,E,d,$,m,l);if(v){v=d.fallback,E=r.mode,m=i.child,$=m.sibling;var Y={mode:"hidden",children:d.children};return(E&1)===0&&r.child!==m?(d=r.child,d.childLanes=0,d.pendingProps=Y,r.deletions=null):(d=Gi(m,Y),d.subtreeFlags=m.subtreeFlags&14680064),$!==null?v=Gi($,v):(v=br(v,E,l,null),v.flags|=2),v.return=r,d.return=r,d.sibling=v,r.child=d,d=v,v=r.child,E=i.child.memoizedState,E=E===null?Vc(l):{baseLanes:E.baseLanes|l,cachePool:null,transitions:E.transitions},v.memoizedState=E,v.childLanes=i.childLanes&~l,r.memoizedState=qc,d}return v=i.child,i=v.sibling,d=Gi(v,{mode:"visible",children:d.children}),(r.mode&1)===0&&(d.lanes=l),d.return=r,d.sibling=null,i!==null&&(l=r.deletions,l===null?(r.deletions=[i],r.flags|=16):l.push(i)),r.child=d,r.memoizedState=null,d}function Yc(i,r){return r=Aa({mode:"visible",children:r},i.mode,0,null),r.return=i,i.child=r}function ba(i,r,l,d){return d!==null&&Sc(d),es(r,i.child,null,l),i=Yc(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function YS(i,r,l,d,m,v,E){if(l)return r.flags&256?(r.flags&=-257,d=Hc(Error(n(422))),ba(i,r,E,d)):r.memoizedState!==null?(r.child=i.child,r.flags|=128,null):(v=d.fallback,m=r.mode,d=Aa({mode:"visible",children:d.children},m,0,null),v=br(v,m,E,null),v.flags|=2,d.return=r,v.return=r,d.sibling=v,r.child=d,(r.mode&1)!==0&&es(r,i.child,null,E),r.child.memoizedState=Vc(E),r.memoizedState=qc,v);if((r.mode&1)===0)return ba(i,r,E,null);if(m.data==="$!"){if(d=m.nextSibling&&m.nextSibling.dataset,d)var $=d.dgst;return d=$,v=Error(n(419)),d=Hc(v,d,void 0),ba(i,r,E,d)}if($=(E&i.childLanes)!==0,kn||$){if(d=Yt,d!==null){switch(E&-E){case 4:m=2;break;case 16:m=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:m=32;break;case 536870912:m=268435456;break;default:m=0}m=(m&(d.suspendedLanes|E))!==0?0:m,m!==0&&m!==v.retryLane&&(v.retryLane=m,xi(i,m),ti(d,i,m,-1))}return uu(),d=Hc(Error(n(421))),ba(i,r,E,d)}return m.data==="$?"?(r.flags|=128,r.child=i.child,r=ab.bind(null,i),m._reactRetry=r,null):(i=v.treeContext,Ln=zi(m.nextSibling),jn=r,xt=!0,Jn=null,i!==null&&(zn[Fn++]=bi,zn[Fn++]=ki,zn[Fn++]=fr,bi=i.id,ki=i.overflow,fr=r),r=Yc(r,d.children),r.flags|=4096,r)}function Zp(i,r,l){i.lanes|=r;var d=i.alternate;d!==null&&(d.lanes|=r),Cc(i.return,r,l)}function Xc(i,r,l,d,m){var v=i.memoizedState;v===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:d,tail:l,tailMode:m}:(v.isBackwards=r,v.rendering=null,v.renderingStartTime=0,v.last=d,v.tail=l,v.tailMode=m)}function em(i,r,l){var d=r.pendingProps,m=d.revealOrder,v=d.tail;if(pn(i,r,d.children,l),d=Nt.current,(d&2)!==0)d=d&1|2,r.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Zp(i,l,r);else if(i.tag===19)Zp(i,l,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}d&=1}if(vt(Nt,d),(r.mode&1)===0)r.memoizedState=null;else switch(m){case"forwards":for(l=r.child,m=null;l!==null;)i=l.alternate,i!==null&&ma(i)===null&&(m=l),l=l.sibling;l=m,l===null?(m=r.child,r.child=null):(m=l.sibling,l.sibling=null),Xc(r,!1,m,l,v);break;case"backwards":for(l=null,m=r.child,r.child=null;m!==null;){if(i=m.alternate,i!==null&&ma(i)===null){r.child=m;break}i=m.sibling,m.sibling=l,l=m,m=i}Xc(r,!0,l,null,v);break;case"together":Xc(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function ka(i,r){(r.mode&1)===0&&i!==null&&(i.alternate=null,r.alternate=null,r.flags|=2)}function Ei(i,r,l){if(i!==null&&(r.dependencies=i.dependencies),_r|=r.lanes,(l&r.childLanes)===0)return null;if(i!==null&&r.child!==i.child)throw Error(n(153));if(r.child!==null){for(i=r.child,l=Gi(i,i.pendingProps),r.child=l,l.return=r;i.sibling!==null;)i=i.sibling,l=l.sibling=Gi(i,i.pendingProps),l.return=r;l.sibling=null}return r.child}function XS(i,r,l){switch(r.tag){case 3:Gp(r),Zr();break;case 5:pp(r);break;case 1:bn(r.type)&&sa(r);break;case 4:Rc(r,r.stateNode.containerInfo);break;case 10:var d=r.type._context,m=r.memoizedProps.value;vt(da,d._currentValue),d._currentValue=m;break;case 13:if(d=r.memoizedState,d!==null)return d.dehydrated!==null?(vt(Nt,Nt.current&1),r.flags|=128,null):(l&r.child.childLanes)!==0?Qp(i,r,l):(vt(Nt,Nt.current&1),i=Ei(i,r,l),i!==null?i.sibling:null);vt(Nt,Nt.current&1);break;case 19:if(d=(l&r.childLanes)!==0,(i.flags&128)!==0){if(d)return em(i,r,l);r.flags|=128}if(m=r.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),vt(Nt,Nt.current),d)break;return null;case 22:case 23:return r.lanes=0,Vp(i,r,l)}return Ei(i,r,l)}var tm,Gc,nm,im;tm=function(i,r){for(var l=r.child;l!==null;){if(l.tag===5||l.tag===6)i.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===r)break;for(;l.sibling===null;){if(l.return===null||l.return===r)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},Gc=function(){},nm=function(i,r,l,d){var m=i.memoizedProps;if(m!==d){i=r.stateNode,gr(ai.current);var v=null;switch(l){case"input":m=dt(i,m),d=dt(i,d),v=[];break;case"select":m=B({},m,{value:void 0}),d=B({},d,{value:void 0}),v=[];break;case"textarea":m=mt(i,m),d=mt(i,d),v=[];break;default:typeof m.onClick!="function"&&typeof d.onClick=="function"&&(i.onclick=na)}Re(l,d);var E;l=null;for(ce in m)if(!d.hasOwnProperty(ce)&&m.hasOwnProperty(ce)&&m[ce]!=null)if(ce==="style"){var $=m[ce];for(E in $)$.hasOwnProperty(E)&&(l||(l={}),l[E]="")}else ce!=="dangerouslySetInnerHTML"&&ce!=="children"&&ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&ce!=="autoFocus"&&(o.hasOwnProperty(ce)?v||(v=[]):(v=v||[]).push(ce,null));for(ce in d){var Y=d[ce];if($=m!=null?m[ce]:void 0,d.hasOwnProperty(ce)&&Y!==$&&(Y!=null||$!=null))if(ce==="style")if($){for(E in $)!$.hasOwnProperty(E)||Y&&Y.hasOwnProperty(E)||(l||(l={}),l[E]="");for(E in Y)Y.hasOwnProperty(E)&&$[E]!==Y[E]&&(l||(l={}),l[E]=Y[E])}else l||(v||(v=[]),v.push(ce,l)),l=Y;else ce==="dangerouslySetInnerHTML"?(Y=Y?Y.__html:void 0,$=$?$.__html:void 0,Y!=null&&$!==Y&&(v=v||[]).push(ce,Y)):ce==="children"?typeof Y!="string"&&typeof Y!="number"||(v=v||[]).push(ce,""+Y):ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&(o.hasOwnProperty(ce)?(Y!=null&&ce==="onScroll"&&wt("scroll",i),v||$===Y||(v=[])):(v=v||[]).push(ce,Y))}l&&(v=v||[]).push("style",l);var ce=v;(r.updateQueue=ce)&&(r.flags|=4)}},im=function(i,r,l,d){l!==d&&(r.flags|=4)};function to(i,r){if(!xt)switch(i.tailMode){case"hidden":r=i.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?i.tail=null:l.sibling=null;break;case"collapsed":l=i.tail;for(var d=null;l!==null;)l.alternate!==null&&(d=l),l=l.sibling;d===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:d.sibling=null}}function un(i){var r=i.alternate!==null&&i.alternate.child===i.child,l=0,d=0;if(r)for(var m=i.child;m!==null;)l|=m.lanes|m.childLanes,d|=m.subtreeFlags&14680064,d|=m.flags&14680064,m.return=i,m=m.sibling;else for(m=i.child;m!==null;)l|=m.lanes|m.childLanes,d|=m.subtreeFlags,d|=m.flags,m.return=i,m=m.sibling;return i.subtreeFlags|=d,i.childLanes=l,r}function GS(i,r,l){var d=r.pendingProps;switch(_c(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return un(r),null;case 1:return bn(r.type)&&ra(),un(r),null;case 3:return d=r.stateNode,is(),St(Sn),St(ln),Lc(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(i===null||i.child===null)&&(ca(r)?r.flags|=4:i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Jn!==null&&(au(Jn),Jn=null))),Gc(i,r),un(r),null;case 5:Pc(r);var m=gr(Gs.current);if(l=r.type,i!==null&&r.stateNode!=null)nm(i,r,l,d,m),i.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!d){if(r.stateNode===null)throw Error(n(166));return un(r),null}if(i=gr(ai.current),ca(r)){d=r.stateNode,l=r.type;var v=r.memoizedProps;switch(d[oi]=r,d[Ks]=v,i=(r.mode&1)!==0,l){case"dialog":wt("cancel",d),wt("close",d);break;case"iframe":case"object":case"embed":wt("load",d);break;case"video":case"audio":for(m=0;m<Hs.length;m++)wt(Hs[m],d);break;case"source":wt("error",d);break;case"img":case"image":case"link":wt("error",d),wt("load",d);break;case"details":wt("toggle",d);break;case"input":Ue(d,v),wt("invalid",d);break;case"select":d._wrapperState={wasMultiple:!!v.multiple},wt("invalid",d);break;case"textarea":le(d,v),wt("invalid",d)}Re(l,v),m=null;for(var E in v)if(v.hasOwnProperty(E)){var $=v[E];E==="children"?typeof $=="string"?d.textContent!==$&&(v.suppressHydrationWarning!==!0&&ta(d.textContent,$,i),m=["children",$]):typeof $=="number"&&d.textContent!==""+$&&(v.suppressHydrationWarning!==!0&&ta(d.textContent,$,i),m=["children",""+$]):o.hasOwnProperty(E)&&$!=null&&E==="onScroll"&&wt("scroll",d)}switch(l){case"input":it(d),ut(d,v,!0);break;case"textarea":it(d),Ae(d);break;case"select":case"option":break;default:typeof v.onClick=="function"&&(d.onclick=na)}d=m,r.updateQueue=d,d!==null&&(r.flags|=4)}else{E=m.nodeType===9?m:m.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=We(l)),i==="http://www.w3.org/1999/xhtml"?l==="script"?(i=E.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof d.is=="string"?i=E.createElement(l,{is:d.is}):(i=E.createElement(l),l==="select"&&(E=i,d.multiple?E.multiple=!0:d.size&&(E.size=d.size))):i=E.createElementNS(i,l),i[oi]=r,i[Ks]=d,tm(i,r,!1,!1),r.stateNode=i;e:{switch(E=Ge(l,d),l){case"dialog":wt("cancel",i),wt("close",i),m=d;break;case"iframe":case"object":case"embed":wt("load",i),m=d;break;case"video":case"audio":for(m=0;m<Hs.length;m++)wt(Hs[m],i);m=d;break;case"source":wt("error",i),m=d;break;case"img":case"image":case"link":wt("error",i),wt("load",i),m=d;break;case"details":wt("toggle",i),m=d;break;case"input":Ue(i,d),m=dt(i,d),wt("invalid",i);break;case"option":m=d;break;case"select":i._wrapperState={wasMultiple:!!d.multiple},m=B({},d,{value:void 0}),wt("invalid",i);break;case"textarea":le(i,d),m=mt(i,d),wt("invalid",i);break;default:m=d}Re(l,m),$=m;for(v in $)if($.hasOwnProperty(v)){var Y=$[v];v==="style"?Ee(i,Y):v==="dangerouslySetInnerHTML"?(Y=Y?Y.__html:void 0,Y!=null&&ee(i,Y)):v==="children"?typeof Y=="string"?(l!=="textarea"||Y!=="")&&O(i,Y):typeof Y=="number"&&O(i,""+Y):v!=="suppressContentEditableWarning"&&v!=="suppressHydrationWarning"&&v!=="autoFocus"&&(o.hasOwnProperty(v)?Y!=null&&v==="onScroll"&&wt("scroll",i):Y!=null&&I(i,v,Y,E))}switch(l){case"input":it(i),ut(i,d,!1);break;case"textarea":it(i),Ae(i);break;case"option":d.value!=null&&i.setAttribute("value",""+q(d.value));break;case"select":i.multiple=!!d.multiple,v=d.value,v!=null?rt(i,!!d.multiple,v,!1):d.defaultValue!=null&&rt(i,!!d.multiple,d.defaultValue,!0);break;default:typeof m.onClick=="function"&&(i.onclick=na)}switch(l){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}}d&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return un(r),null;case 6:if(i&&r.stateNode!=null)im(i,r,i.memoizedProps,d);else{if(typeof d!="string"&&r.stateNode===null)throw Error(n(166));if(l=gr(Gs.current),gr(ai.current),ca(r)){if(d=r.stateNode,l=r.memoizedProps,d[oi]=r,(v=d.nodeValue!==l)&&(i=jn,i!==null))switch(i.tag){case 3:ta(d.nodeValue,l,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&ta(d.nodeValue,l,(i.mode&1)!==0)}v&&(r.flags|=4)}else d=(l.nodeType===9?l:l.ownerDocument).createTextNode(d),d[oi]=r,r.stateNode=d}return un(r),null;case 13:if(St(Nt),d=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(xt&&Ln!==null&&(r.mode&1)!==0&&(r.flags&128)===0)op(),Zr(),r.flags|=98560,v=!1;else if(v=ca(r),d!==null&&d.dehydrated!==null){if(i===null){if(!v)throw Error(n(318));if(v=r.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(n(317));v[oi]=r}else Zr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;un(r),v=!1}else Jn!==null&&(au(Jn),Jn=null),v=!0;if(!v)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=l,r):(d=d!==null,d!==(i!==null&&i.memoizedState!==null)&&d&&(r.child.flags|=8192,(r.mode&1)!==0&&(i===null||(Nt.current&1)!==0?Ht===0&&(Ht=3):uu())),r.updateQueue!==null&&(r.flags|=4),un(r),null);case 4:return is(),Gc(i,r),i===null&&Ws(r.stateNode.containerInfo),un(r),null;case 10:return xc(r.type._context),un(r),null;case 17:return bn(r.type)&&ra(),un(r),null;case 19:if(St(Nt),v=r.memoizedState,v===null)return un(r),null;if(d=(r.flags&128)!==0,E=v.rendering,E===null)if(d)to(v,!1);else{if(Ht!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(E=ma(i),E!==null){for(r.flags|=128,to(v,!1),d=E.updateQueue,d!==null&&(r.updateQueue=d,r.flags|=4),r.subtreeFlags=0,d=l,l=r.child;l!==null;)v=l,i=d,v.flags&=14680066,E=v.alternate,E===null?(v.childLanes=0,v.lanes=i,v.child=null,v.subtreeFlags=0,v.memoizedProps=null,v.memoizedState=null,v.updateQueue=null,v.dependencies=null,v.stateNode=null):(v.childLanes=E.childLanes,v.lanes=E.lanes,v.child=E.child,v.subtreeFlags=0,v.deletions=null,v.memoizedProps=E.memoizedProps,v.memoizedState=E.memoizedState,v.updateQueue=E.updateQueue,v.type=E.type,i=E.dependencies,v.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),l=l.sibling;return vt(Nt,Nt.current&1|2),r.child}i=i.sibling}v.tail!==null&&Tt()>as&&(r.flags|=128,d=!0,to(v,!1),r.lanes=4194304)}else{if(!d)if(i=ma(E),i!==null){if(r.flags|=128,d=!0,l=i.updateQueue,l!==null&&(r.updateQueue=l,r.flags|=4),to(v,!0),v.tail===null&&v.tailMode==="hidden"&&!E.alternate&&!xt)return un(r),null}else 2*Tt()-v.renderingStartTime>as&&l!==1073741824&&(r.flags|=128,d=!0,to(v,!1),r.lanes=4194304);v.isBackwards?(E.sibling=r.child,r.child=E):(l=v.last,l!==null?l.sibling=E:r.child=E,v.last=E)}return v.tail!==null?(r=v.tail,v.rendering=r,v.tail=r.sibling,v.renderingStartTime=Tt(),r.sibling=null,l=Nt.current,vt(Nt,d?l&1|2:l&1),r):(un(r),null);case 22:case 23:return cu(),d=r.memoizedState!==null,i!==null&&i.memoizedState!==null!==d&&(r.flags|=8192),d&&(r.mode&1)!==0?(Dn&1073741824)!==0&&(un(r),r.subtreeFlags&6&&(r.flags|=8192)):un(r),null;case 24:return null;case 25:return null}throw Error(n(156,r.tag))}function JS(i,r){switch(_c(r),r.tag){case 1:return bn(r.type)&&ra(),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return is(),St(Sn),St(ln),Lc(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 5:return Pc(r),null;case 13:if(St(Nt),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(n(340));Zr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return St(Nt),null;case 4:return is(),null;case 10:return xc(r.type._context),null;case 22:case 23:return cu(),null;case 24:return null;default:return null}}var xa=!1,dn=!1,QS=typeof WeakSet=="function"?WeakSet:Set,Le=null;function ss(i,r){var l=i.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(d){Lt(i,r,d)}else l.current=null}function Jc(i,r,l){try{l()}catch(d){Lt(i,r,d)}}var rm=!1;function ZS(i,r){if(cc=Uo,i=If(),tc(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var d=l.getSelection&&l.getSelection();if(d&&d.rangeCount!==0){l=d.anchorNode;var m=d.anchorOffset,v=d.focusNode;d=d.focusOffset;try{l.nodeType,v.nodeType}catch{l=null;break e}var E=0,$=-1,Y=-1,ce=0,ye=0,Se=i,_e=null;t:for(;;){for(var je;Se!==l||m!==0&&Se.nodeType!==3||($=E+m),Se!==v||d!==0&&Se.nodeType!==3||(Y=E+d),Se.nodeType===3&&(E+=Se.nodeValue.length),(je=Se.firstChild)!==null;)_e=Se,Se=je;for(;;){if(Se===i)break t;if(_e===l&&++ce===m&&($=E),_e===v&&++ye===d&&(Y=E),(je=Se.nextSibling)!==null)break;Se=_e,_e=Se.parentNode}Se=je}l=$===-1||Y===-1?null:{start:$,end:Y}}else l=null}l=l||{start:0,end:0}}else l=null;for(uc={focusedElem:i,selectionRange:l},Uo=!1,Le=r;Le!==null;)if(r=Le,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Le=i;else for(;Le!==null;){r=Le;try{var De=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(De!==null){var Me=De.memoizedProps,At=De.memoizedState,re=r.stateNode,J=re.getSnapshotBeforeUpdate(r.elementType===r.type?Me:Qn(r.type,Me),At);re.__reactInternalSnapshotBeforeUpdate=J}break;case 3:var ae=r.stateNode.containerInfo;ae.nodeType===1?ae.textContent="":ae.nodeType===9&&ae.documentElement&&ae.removeChild(ae.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(xe){Lt(r,r.return,xe)}if(i=r.sibling,i!==null){i.return=r.return,Le=i;break}Le=r.return}return De=rm,rm=!1,De}function no(i,r,l){var d=r.updateQueue;if(d=d!==null?d.lastEffect:null,d!==null){var m=d=d.next;do{if((m.tag&i)===i){var v=m.destroy;m.destroy=void 0,v!==void 0&&Jc(r,l,v)}m=m.next}while(m!==d)}}function Ca(i,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&i)===i){var d=l.create;l.destroy=d()}l=l.next}while(l!==r)}}function Qc(i){var r=i.ref;if(r!==null){var l=i.stateNode;switch(i.tag){case 5:i=l;break;default:i=l}typeof r=="function"?r(i):r.current=i}}function sm(i){var r=i.alternate;r!==null&&(i.alternate=null,sm(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&(delete r[oi],delete r[Ks],delete r[pc],delete r[AS],delete r[IS])),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 om(i){return i.tag===5||i.tag===3||i.tag===4}function am(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||om(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 Zc(i,r,l){var d=i.tag;if(d===5||d===6)i=i.stateNode,r?l.nodeType===8?l.parentNode.insertBefore(i,r):l.insertBefore(i,r):(l.nodeType===8?(r=l.parentNode,r.insertBefore(i,l)):(r=l,r.appendChild(i)),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=na));else if(d!==4&&(i=i.child,i!==null))for(Zc(i,r,l),i=i.sibling;i!==null;)Zc(i,r,l),i=i.sibling}function eu(i,r,l){var d=i.tag;if(d===5||d===6)i=i.stateNode,r?l.insertBefore(i,r):l.appendChild(i);else if(d!==4&&(i=i.child,i!==null))for(eu(i,r,l),i=i.sibling;i!==null;)eu(i,r,l),i=i.sibling}var rn=null,Zn=!1;function Ki(i,r,l){for(l=l.child;l!==null;)lm(i,r,l),l=l.sibling}function lm(i,r,l){if(si&&typeof si.onCommitFiberUnmount=="function")try{si.onCommitFiberUnmount(Oo,l)}catch{}switch(l.tag){case 5:dn||ss(l,r);case 6:var d=rn,m=Zn;rn=null,Ki(i,r,l),rn=d,Zn=m,rn!==null&&(Zn?(i=rn,l=l.stateNode,i.nodeType===8?i.parentNode.removeChild(l):i.removeChild(l)):rn.removeChild(l.stateNode));break;case 18:rn!==null&&(Zn?(i=rn,l=l.stateNode,i.nodeType===8?fc(i.parentNode,l):i.nodeType===1&&fc(i,l),Ts(i)):fc(rn,l.stateNode));break;case 4:d=rn,m=Zn,rn=l.stateNode.containerInfo,Zn=!0,Ki(i,r,l),rn=d,Zn=m;break;case 0:case 11:case 14:case 15:if(!dn&&(d=l.updateQueue,d!==null&&(d=d.lastEffect,d!==null))){m=d=d.next;do{var v=m,E=v.destroy;v=v.tag,E!==void 0&&((v&2)!==0||(v&4)!==0)&&Jc(l,r,E),m=m.next}while(m!==d)}Ki(i,r,l);break;case 1:if(!dn&&(ss(l,r),d=l.stateNode,typeof d.componentWillUnmount=="function"))try{d.props=l.memoizedProps,d.state=l.memoizedState,d.componentWillUnmount()}catch($){Lt(l,r,$)}Ki(i,r,l);break;case 21:Ki(i,r,l);break;case 22:l.mode&1?(dn=(d=dn)||l.memoizedState!==null,Ki(i,r,l),dn=d):Ki(i,r,l);break;default:Ki(i,r,l)}}function cm(i){var r=i.updateQueue;if(r!==null){i.updateQueue=null;var l=i.stateNode;l===null&&(l=i.stateNode=new QS),r.forEach(function(d){var m=lb.bind(null,i,d);l.has(d)||(l.add(d),d.then(m,m))})}}function ei(i,r){var l=r.deletions;if(l!==null)for(var d=0;d<l.length;d++){var m=l[d];try{var v=i,E=r,$=E;e:for(;$!==null;){switch($.tag){case 5:rn=$.stateNode,Zn=!1;break e;case 3:rn=$.stateNode.containerInfo,Zn=!0;break e;case 4:rn=$.stateNode.containerInfo,Zn=!0;break e}$=$.return}if(rn===null)throw Error(n(160));lm(v,E,m),rn=null,Zn=!1;var Y=m.alternate;Y!==null&&(Y.return=null),m.return=null}catch(ce){Lt(m,r,ce)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)um(r,i),r=r.sibling}function um(i,r){var l=i.alternate,d=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(ei(r,i),ci(i),d&4){try{no(3,i,i.return),Ca(3,i)}catch(Me){Lt(i,i.return,Me)}try{no(5,i,i.return)}catch(Me){Lt(i,i.return,Me)}}break;case 1:ei(r,i),ci(i),d&512&&l!==null&&ss(l,l.return);break;case 5:if(ei(r,i),ci(i),d&512&&l!==null&&ss(l,l.return),i.flags&32){var m=i.stateNode;try{O(m,"")}catch(Me){Lt(i,i.return,Me)}}if(d&4&&(m=i.stateNode,m!=null)){var v=i.memoizedProps,E=l!==null?l.memoizedProps:v,$=i.type,Y=i.updateQueue;if(i.updateQueue=null,Y!==null)try{$==="input"&&v.type==="radio"&&v.name!=null&&ct(m,v),Ge($,E);var ce=Ge($,v);for(E=0;E<Y.length;E+=2){var ye=Y[E],Se=Y[E+1];ye==="style"?Ee(m,Se):ye==="dangerouslySetInnerHTML"?ee(m,Se):ye==="children"?O(m,Se):I(m,ye,Se,ce)}switch($){case"input":_t(m,v);break;case"textarea":be(m,v);break;case"select":var _e=m._wrapperState.wasMultiple;m._wrapperState.wasMultiple=!!v.multiple;var je=v.value;je!=null?rt(m,!!v.multiple,je,!1):_e!==!!v.multiple&&(v.defaultValue!=null?rt(m,!!v.multiple,v.defaultValue,!0):rt(m,!!v.multiple,v.multiple?[]:"",!1))}m[Ks]=v}catch(Me){Lt(i,i.return,Me)}}break;case 6:if(ei(r,i),ci(i),d&4){if(i.stateNode===null)throw Error(n(162));m=i.stateNode,v=i.memoizedProps;try{m.nodeValue=v}catch(Me){Lt(i,i.return,Me)}}break;case 3:if(ei(r,i),ci(i),d&4&&l!==null&&l.memoizedState.isDehydrated)try{Ts(r.containerInfo)}catch(Me){Lt(i,i.return,Me)}break;case 4:ei(r,i),ci(i);break;case 13:ei(r,i),ci(i),m=i.child,m.flags&8192&&(v=m.memoizedState!==null,m.stateNode.isHidden=v,!v||m.alternate!==null&&m.alternate.memoizedState!==null||(iu=Tt())),d&4&&cm(i);break;case 22:if(ye=l!==null&&l.memoizedState!==null,i.mode&1?(dn=(ce=dn)||ye,ei(r,i),dn=ce):ei(r,i),ci(i),d&8192){if(ce=i.memoizedState!==null,(i.stateNode.isHidden=ce)&&!ye&&(i.mode&1)!==0)for(Le=i,ye=i.child;ye!==null;){for(Se=Le=ye;Le!==null;){switch(_e=Le,je=_e.child,_e.tag){case 0:case 11:case 14:case 15:no(4,_e,_e.return);break;case 1:ss(_e,_e.return);var De=_e.stateNode;if(typeof De.componentWillUnmount=="function"){d=_e,l=_e.return;try{r=d,De.props=r.memoizedProps,De.state=r.memoizedState,De.componentWillUnmount()}catch(Me){Lt(d,l,Me)}}break;case 5:ss(_e,_e.return);break;case 22:if(_e.memoizedState!==null){fm(Se);continue}}je!==null?(je.return=_e,Le=je):fm(Se)}ye=ye.sibling}e:for(ye=null,Se=i;;){if(Se.tag===5){if(ye===null){ye=Se;try{m=Se.stateNode,ce?(v=m.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none"):($=Se.stateNode,Y=Se.memoizedProps.style,E=Y!=null&&Y.hasOwnProperty("display")?Y.display:null,$.style.display=ke("display",E))}catch(Me){Lt(i,i.return,Me)}}}else if(Se.tag===6){if(ye===null)try{Se.stateNode.nodeValue=ce?"":Se.memoizedProps}catch(Me){Lt(i,i.return,Me)}}else if((Se.tag!==22&&Se.tag!==23||Se.memoizedState===null||Se===i)&&Se.child!==null){Se.child.return=Se,Se=Se.child;continue}if(Se===i)break e;for(;Se.sibling===null;){if(Se.return===null||Se.return===i)break e;ye===Se&&(ye=null),Se=Se.return}ye===Se&&(ye=null),Se.sibling.return=Se.return,Se=Se.sibling}}break;case 19:ei(r,i),ci(i),d&4&&cm(i);break;case 21:break;default:ei(r,i),ci(i)}}function ci(i){var r=i.flags;if(r&2){try{e:{for(var l=i.return;l!==null;){if(om(l)){var d=l;break e}l=l.return}throw Error(n(160))}switch(d.tag){case 5:var m=d.stateNode;d.flags&32&&(O(m,""),d.flags&=-33);var v=am(i);eu(i,v,m);break;case 3:case 4:var E=d.stateNode.containerInfo,$=am(i);Zc(i,$,E);break;default:throw Error(n(161))}}catch(Y){Lt(i,i.return,Y)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function eb(i,r,l){Le=i,dm(i)}function dm(i,r,l){for(var d=(i.mode&1)!==0;Le!==null;){var m=Le,v=m.child;if(m.tag===22&&d){var E=m.memoizedState!==null||xa;if(!E){var $=m.alternate,Y=$!==null&&$.memoizedState!==null||dn;$=xa;var ce=dn;if(xa=E,(dn=Y)&&!ce)for(Le=m;Le!==null;)E=Le,Y=E.child,E.tag===22&&E.memoizedState!==null?pm(m):Y!==null?(Y.return=E,Le=Y):pm(m);for(;v!==null;)Le=v,dm(v),v=v.sibling;Le=m,xa=$,dn=ce}hm(i)}else(m.subtreeFlags&8772)!==0&&v!==null?(v.return=m,Le=v):hm(i)}}function hm(i){for(;Le!==null;){var r=Le;if((r.flags&8772)!==0){var l=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:dn||Ca(5,r);break;case 1:var d=r.stateNode;if(r.flags&4&&!dn)if(l===null)d.componentDidMount();else{var m=r.elementType===r.type?l.memoizedProps:Qn(r.type,l.memoizedProps);d.componentDidUpdate(m,l.memoizedState,d.__reactInternalSnapshotBeforeUpdate)}var v=r.updateQueue;v!==null&&fp(r,v,d);break;case 3:var E=r.updateQueue;if(E!==null){if(l=null,r.child!==null)switch(r.child.tag){case 5:l=r.child.stateNode;break;case 1:l=r.child.stateNode}fp(r,E,l)}break;case 5:var $=r.stateNode;if(l===null&&r.flags&4){l=$;var Y=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":Y.autoFocus&&l.focus();break;case"img":Y.src&&(l.src=Y.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var ce=r.alternate;if(ce!==null){var ye=ce.memoizedState;if(ye!==null){var Se=ye.dehydrated;Se!==null&&Ts(Se)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}dn||r.flags&512&&Qc(r)}catch(_e){Lt(r,r.return,_e)}}if(r===i){Le=null;break}if(l=r.sibling,l!==null){l.return=r.return,Le=l;break}Le=r.return}}function fm(i){for(;Le!==null;){var r=Le;if(r===i){Le=null;break}var l=r.sibling;if(l!==null){l.return=r.return,Le=l;break}Le=r.return}}function pm(i){for(;Le!==null;){var r=Le;try{switch(r.tag){case 0:case 11:case 15:var l=r.return;try{Ca(4,r)}catch(Y){Lt(r,l,Y)}break;case 1:var d=r.stateNode;if(typeof d.componentDidMount=="function"){var m=r.return;try{d.componentDidMount()}catch(Y){Lt(r,m,Y)}}var v=r.return;try{Qc(r)}catch(Y){Lt(r,v,Y)}break;case 5:var E=r.return;try{Qc(r)}catch(Y){Lt(r,E,Y)}}}catch(Y){Lt(r,r.return,Y)}if(r===i){Le=null;break}var $=r.sibling;if($!==null){$.return=r.return,Le=$;break}Le=r.return}}var tb=Math.ceil,Ea=D.ReactCurrentDispatcher,tu=D.ReactCurrentOwner,Wn=D.ReactCurrentBatchConfig,at=0,Yt=null,Bt=null,sn=0,Dn=0,os=Fi(0),Ht=0,io=null,_r=0,Na=0,nu=0,ro=null,xn=null,iu=0,as=1/0,Ni=null,Ra=!1,ru=null,qi=null,Pa=!1,Vi=null,ja=0,so=0,su=null,La=-1,Da=0;function mn(){return(at&6)!==0?Tt():La!==-1?La:La=Tt()}function Yi(i){return(i.mode&1)===0?1:(at&2)!==0&&sn!==0?sn&-sn:OS.transition!==null?(Da===0&&(Da=af()),Da):(i=ht,i!==0||(i=window.event,i=i===void 0?16:gf(i.type)),i)}function ti(i,r,l,d){if(50<so)throw so=0,su=null,Error(n(185));Ps(i,l,d),((at&2)===0||i!==Yt)&&(i===Yt&&((at&2)===0&&(Na|=l),Ht===4&&Xi(i,sn)),Cn(i,d),l===1&&at===0&&(r.mode&1)===0&&(as=Tt()+500,oa&&Hi()))}function Cn(i,r){var l=i.callbackNode;Ow(i,r);var d=$o(i,i===Yt?sn:0);if(d===0)l!==null&&rf(l),i.callbackNode=null,i.callbackPriority=0;else if(r=d&-d,i.callbackPriority!==r){if(l!=null&&rf(l),r===1)i.tag===0?BS(gm.bind(null,i)):tp(gm.bind(null,i)),MS(function(){(at&6)===0&&Hi()}),l=null;else{switch(lf(d)){case 1:l=Ol;break;case 4:l=sf;break;case 16:l=Bo;break;case 536870912:l=of;break;default:l=Bo}l=xm(l,mm.bind(null,i))}i.callbackPriority=r,i.callbackNode=l}}function mm(i,r){if(La=-1,Da=0,(at&6)!==0)throw Error(n(327));var l=i.callbackNode;if(ls()&&i.callbackNode!==l)return null;var d=$o(i,i===Yt?sn:0);if(d===0)return null;if((d&30)!==0||(d&i.expiredLanes)!==0||r)r=Ma(i,d);else{r=d;var m=at;at|=2;var v=_m();(Yt!==i||sn!==r)&&(Ni=null,as=Tt()+500,wr(i,r));do try{rb();break}catch($){vm(i,$)}while(!0);kc(),Ea.current=v,at=m,Bt!==null?r=0:(Yt=null,sn=0,r=Ht)}if(r!==0){if(r===2&&(m=zl(i),m!==0&&(d=m,r=ou(i,m))),r===1)throw l=io,wr(i,0),Xi(i,d),Cn(i,Tt()),l;if(r===6)Xi(i,d);else{if(m=i.current.alternate,(d&30)===0&&!nb(m)&&(r=Ma(i,d),r===2&&(v=zl(i),v!==0&&(d=v,r=ou(i,v))),r===1))throw l=io,wr(i,0),Xi(i,d),Cn(i,Tt()),l;switch(i.finishedWork=m,i.finishedLanes=d,r){case 0:case 1:throw Error(n(345));case 2:Sr(i,xn,Ni);break;case 3:if(Xi(i,d),(d&130023424)===d&&(r=iu+500-Tt(),10<r)){if($o(i,0)!==0)break;if(m=i.suspendedLanes,(m&d)!==d){mn(),i.pingedLanes|=i.suspendedLanes&m;break}i.timeoutHandle=hc(Sr.bind(null,i,xn,Ni),r);break}Sr(i,xn,Ni);break;case 4:if(Xi(i,d),(d&4194240)===d)break;for(r=i.eventTimes,m=-1;0<d;){var E=31-Xn(d);v=1<<E,E=r[E],E>m&&(m=E),d&=~v}if(d=m,d=Tt()-d,d=(120>d?120:480>d?480:1080>d?1080:1920>d?1920:3e3>d?3e3:4320>d?4320:1960*tb(d/1960))-d,10<d){i.timeoutHandle=hc(Sr.bind(null,i,xn,Ni),d);break}Sr(i,xn,Ni);break;case 5:Sr(i,xn,Ni);break;default:throw Error(n(329))}}}return Cn(i,Tt()),i.callbackNode===l?mm.bind(null,i):null}function ou(i,r){var l=ro;return i.current.memoizedState.isDehydrated&&(wr(i,r).flags|=256),i=Ma(i,r),i!==2&&(r=xn,xn=l,r!==null&&au(r)),i}function au(i){xn===null?xn=i:xn.push.apply(xn,i)}function nb(i){for(var r=i;;){if(r.flags&16384){var l=r.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var d=0;d<l.length;d++){var m=l[d],v=m.getSnapshot;m=m.value;try{if(!Gn(v(),m))return!1}catch{return!1}}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Xi(i,r){for(r&=~nu,r&=~Na,i.suspendedLanes|=r,i.pingedLanes&=~r,i=i.expirationTimes;0<r;){var l=31-Xn(r),d=1<<l;i[l]=-1,r&=~d}}function gm(i){if((at&6)!==0)throw Error(n(327));ls();var r=$o(i,0);if((r&1)===0)return Cn(i,Tt()),null;var l=Ma(i,r);if(i.tag!==0&&l===2){var d=zl(i);d!==0&&(r=d,l=ou(i,d))}if(l===1)throw l=io,wr(i,0),Xi(i,r),Cn(i,Tt()),l;if(l===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=r,Sr(i,xn,Ni),Cn(i,Tt()),null}function lu(i,r){var l=at;at|=1;try{return i(r)}finally{at=l,at===0&&(as=Tt()+500,oa&&Hi())}}function yr(i){Vi!==null&&Vi.tag===0&&(at&6)===0&&ls();var r=at;at|=1;var l=Wn.transition,d=ht;try{if(Wn.transition=null,ht=1,i)return i()}finally{ht=d,Wn.transition=l,at=r,(at&6)===0&&Hi()}}function cu(){Dn=os.current,St(os)}function wr(i,r){i.finishedWork=null,i.finishedLanes=0;var l=i.timeoutHandle;if(l!==-1&&(i.timeoutHandle=-1,DS(l)),Bt!==null)for(l=Bt.return;l!==null;){var d=l;switch(_c(d),d.tag){case 1:d=d.type.childContextTypes,d!=null&&ra();break;case 3:is(),St(Sn),St(ln),Lc();break;case 5:Pc(d);break;case 4:is();break;case 13:St(Nt);break;case 19:St(Nt);break;case 10:xc(d.type._context);break;case 22:case 23:cu()}l=l.return}if(Yt=i,Bt=i=Gi(i.current,null),sn=Dn=r,Ht=0,io=null,nu=Na=_r=0,xn=ro=null,mr!==null){for(r=0;r<mr.length;r++)if(l=mr[r],d=l.interleaved,d!==null){l.interleaved=null;var m=d.next,v=l.pending;if(v!==null){var E=v.next;v.next=m,d.next=E}l.pending=d}mr=null}return i}function vm(i,r){do{var l=Bt;try{if(kc(),ga.current=wa,va){for(var d=Rt.memoizedState;d!==null;){var m=d.queue;m!==null&&(m.pending=null),d=d.next}va=!1}if(vr=0,Vt=$t=Rt=null,Js=!1,Qs=0,tu.current=null,l===null||l.return===null){Ht=1,io=r,Bt=null;break}e:{var v=i,E=l.return,$=l,Y=r;if(r=sn,$.flags|=32768,Y!==null&&typeof Y=="object"&&typeof Y.then=="function"){var ce=Y,ye=$,Se=ye.tag;if((ye.mode&1)===0&&(Se===0||Se===11||Se===15)){var _e=ye.alternate;_e?(ye.updateQueue=_e.updateQueue,ye.memoizedState=_e.memoizedState,ye.lanes=_e.lanes):(ye.updateQueue=null,ye.memoizedState=null)}var je=Hp(E);if(je!==null){je.flags&=-257,Wp(je,E,$,v,r),je.mode&1&&$p(v,ce,r),r=je,Y=ce;var De=r.updateQueue;if(De===null){var Me=new Set;Me.add(Y),r.updateQueue=Me}else De.add(Y);break e}else{if((r&1)===0){$p(v,ce,r),uu();break e}Y=Error(n(426))}}else if(xt&&$.mode&1){var At=Hp(E);if(At!==null){(At.flags&65536)===0&&(At.flags|=256),Wp(At,E,$,v,r),Sc(rs(Y,$));break e}}v=Y=rs(Y,$),Ht!==4&&(Ht=2),ro===null?ro=[v]:ro.push(v),v=E;do{switch(v.tag){case 3:v.flags|=65536,r&=-r,v.lanes|=r;var re=zp(v,Y,r);hp(v,re);break e;case 1:$=Y;var J=v.type,ae=v.stateNode;if((v.flags&128)===0&&(typeof J.getDerivedStateFromError=="function"||ae!==null&&typeof ae.componentDidCatch=="function"&&(qi===null||!qi.has(ae)))){v.flags|=65536,r&=-r,v.lanes|=r;var xe=Fp(v,$,r);hp(v,xe);break e}}v=v.return}while(v!==null)}wm(l)}catch(Te){r=Te,Bt===l&&l!==null&&(Bt=l=l.return);continue}break}while(!0)}function _m(){var i=Ea.current;return Ea.current=wa,i===null?wa:i}function uu(){(Ht===0||Ht===3||Ht===2)&&(Ht=4),Yt===null||(_r&268435455)===0&&(Na&268435455)===0||Xi(Yt,sn)}function Ma(i,r){var l=at;at|=2;var d=_m();(Yt!==i||sn!==r)&&(Ni=null,wr(i,r));do try{ib();break}catch(m){vm(i,m)}while(!0);if(kc(),at=l,Ea.current=d,Bt!==null)throw Error(n(261));return Yt=null,sn=0,Ht}function ib(){for(;Bt!==null;)ym(Bt)}function rb(){for(;Bt!==null&&!Pw();)ym(Bt)}function ym(i){var r=km(i.alternate,i,Dn);i.memoizedProps=i.pendingProps,r===null?wm(i):Bt=r,tu.current=null}function wm(i){var r=i;do{var l=r.alternate;if(i=r.return,(r.flags&32768)===0){if(l=GS(l,r,Dn),l!==null){Bt=l;return}}else{if(l=JS(l,r),l!==null){l.flags&=32767,Bt=l;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{Ht=6,Bt=null;return}}if(r=r.sibling,r!==null){Bt=r;return}Bt=r=i}while(r!==null);Ht===0&&(Ht=5)}function Sr(i,r,l){var d=ht,m=Wn.transition;try{Wn.transition=null,ht=1,sb(i,r,l,d)}finally{Wn.transition=m,ht=d}return null}function sb(i,r,l,d){do ls();while(Vi!==null);if((at&6)!==0)throw Error(n(327));l=i.finishedWork;var m=i.finishedLanes;if(l===null)return null;if(i.finishedWork=null,i.finishedLanes=0,l===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var v=l.lanes|l.childLanes;if(zw(i,v),i===Yt&&(Bt=Yt=null,sn=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||Pa||(Pa=!0,xm(Bo,function(){return ls(),null})),v=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||v){v=Wn.transition,Wn.transition=null;var E=ht;ht=1;var $=at;at|=4,tu.current=null,ZS(i,l),um(l,i),CS(uc),Uo=!!cc,uc=cc=null,i.current=l,eb(l),jw(),at=$,ht=E,Wn.transition=v}else i.current=l;if(Pa&&(Pa=!1,Vi=i,ja=m),v=i.pendingLanes,v===0&&(qi=null),Mw(l.stateNode),Cn(i,Tt()),r!==null)for(d=i.onRecoverableError,l=0;l<r.length;l++)m=r[l],d(m.value,{componentStack:m.stack,digest:m.digest});if(Ra)throw Ra=!1,i=ru,ru=null,i;return(ja&1)!==0&&i.tag!==0&&ls(),v=i.pendingLanes,(v&1)!==0?i===su?so++:(so=0,su=i):so=0,Hi(),null}function ls(){if(Vi!==null){var i=lf(ja),r=Wn.transition,l=ht;try{if(Wn.transition=null,ht=16>i?16:i,Vi===null)var d=!1;else{if(i=Vi,Vi=null,ja=0,(at&6)!==0)throw Error(n(331));var m=at;for(at|=4,Le=i.current;Le!==null;){var v=Le,E=v.child;if((Le.flags&16)!==0){var $=v.deletions;if($!==null){for(var Y=0;Y<$.length;Y++){var ce=$[Y];for(Le=ce;Le!==null;){var ye=Le;switch(ye.tag){case 0:case 11:case 15:no(8,ye,v)}var Se=ye.child;if(Se!==null)Se.return=ye,Le=Se;else for(;Le!==null;){ye=Le;var _e=ye.sibling,je=ye.return;if(sm(ye),ye===ce){Le=null;break}if(_e!==null){_e.return=je,Le=_e;break}Le=je}}}var De=v.alternate;if(De!==null){var Me=De.child;if(Me!==null){De.child=null;do{var At=Me.sibling;Me.sibling=null,Me=At}while(Me!==null)}}Le=v}}if((v.subtreeFlags&2064)!==0&&E!==null)E.return=v,Le=E;else e:for(;Le!==null;){if(v=Le,(v.flags&2048)!==0)switch(v.tag){case 0:case 11:case 15:no(9,v,v.return)}var re=v.sibling;if(re!==null){re.return=v.return,Le=re;break e}Le=v.return}}var J=i.current;for(Le=J;Le!==null;){E=Le;var ae=E.child;if((E.subtreeFlags&2064)!==0&&ae!==null)ae.return=E,Le=ae;else e:for(E=J;Le!==null;){if($=Le,($.flags&2048)!==0)try{switch($.tag){case 0:case 11:case 15:Ca(9,$)}}catch(Te){Lt($,$.return,Te)}if($===E){Le=null;break e}var xe=$.sibling;if(xe!==null){xe.return=$.return,Le=xe;break e}Le=$.return}}if(at=m,Hi(),si&&typeof si.onPostCommitFiberRoot=="function")try{si.onPostCommitFiberRoot(Oo,i)}catch{}d=!0}return d}finally{ht=l,Wn.transition=r}}return!1}function Sm(i,r,l){r=rs(l,r),r=zp(i,r,1),i=Ui(i,r,1),r=mn(),i!==null&&(Ps(i,1,r),Cn(i,r))}function Lt(i,r,l){if(i.tag===3)Sm(i,i,l);else for(;r!==null;){if(r.tag===3){Sm(r,i,l);break}else if(r.tag===1){var d=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(qi===null||!qi.has(d))){i=rs(l,i),i=Fp(r,i,1),r=Ui(r,i,1),i=mn(),r!==null&&(Ps(r,1,i),Cn(r,i));break}}r=r.return}}function ob(i,r,l){var d=i.pingCache;d!==null&&d.delete(r),r=mn(),i.pingedLanes|=i.suspendedLanes&l,Yt===i&&(sn&l)===l&&(Ht===4||Ht===3&&(sn&130023424)===sn&&500>Tt()-iu?wr(i,0):nu|=l),Cn(i,r)}function bm(i,r){r===0&&((i.mode&1)===0?r=1:(r=Fo,Fo<<=1,(Fo&130023424)===0&&(Fo=4194304)));var l=mn();i=xi(i,r),i!==null&&(Ps(i,r,l),Cn(i,l))}function ab(i){var r=i.memoizedState,l=0;r!==null&&(l=r.retryLane),bm(i,l)}function lb(i,r){var l=0;switch(i.tag){case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(l=m.retryLane);break;case 19:d=i.stateNode;break;default:throw Error(n(314))}d!==null&&d.delete(r),bm(i,l)}var km;km=function(i,r,l){if(i!==null)if(i.memoizedProps!==r.pendingProps||Sn.current)kn=!0;else{if((i.lanes&l)===0&&(r.flags&128)===0)return kn=!1,XS(i,r,l);kn=(i.flags&131072)!==0}else kn=!1,xt&&(r.flags&1048576)!==0&&np(r,la,r.index);switch(r.lanes=0,r.tag){case 2:var d=r.type;ka(i,r),i=r.pendingProps;var m=Gr(r,ln.current);ns(r,l),m=Tc(null,r,d,i,m,l);var v=Ac();return r.flags|=1,typeof m=="object"&&m!==null&&typeof m.render=="function"&&m.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,bn(d)?(v=!0,sa(r)):v=!1,r.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,Nc(r),m.updater=Sa,r.stateNode=m,m._reactInternals=r,$c(r,d,i,l),r=Kc(null,r,d,!0,v,l)):(r.tag=0,xt&&v&&vc(r),pn(null,r,m,l),r=r.child),r;case 16:d=r.elementType;e:{switch(ka(i,r),i=r.pendingProps,m=d._init,d=m(d._payload),r.type=d,m=r.tag=ub(d),i=Qn(d,i),m){case 0:r=Uc(null,r,d,i,l);break e;case 1:r=Xp(null,r,d,i,l);break e;case 11:r=Up(null,r,d,i,l);break e;case 14:r=Kp(null,r,d,Qn(d.type,i),l);break e}throw Error(n(306,d,""))}return r;case 0:return d=r.type,m=r.pendingProps,m=r.elementType===d?m:Qn(d,m),Uc(i,r,d,m,l);case 1:return d=r.type,m=r.pendingProps,m=r.elementType===d?m:Qn(d,m),Xp(i,r,d,m,l);case 3:e:{if(Gp(r),i===null)throw Error(n(387));d=r.pendingProps,v=r.memoizedState,m=v.element,dp(i,r),pa(r,d,null,l);var E=r.memoizedState;if(d=E.element,v.isDehydrated)if(v={element:d,isDehydrated:!1,cache:E.cache,pendingSuspenseBoundaries:E.pendingSuspenseBoundaries,transitions:E.transitions},r.updateQueue.baseState=v,r.memoizedState=v,r.flags&256){m=rs(Error(n(423)),r),r=Jp(i,r,d,l,m);break e}else if(d!==m){m=rs(Error(n(424)),r),r=Jp(i,r,d,l,m);break e}else for(Ln=zi(r.stateNode.containerInfo.firstChild),jn=r,xt=!0,Jn=null,l=cp(r,null,d,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Zr(),d===m){r=Ei(i,r,l);break e}pn(i,r,d,l)}r=r.child}return r;case 5:return pp(r),i===null&&wc(r),d=r.type,m=r.pendingProps,v=i!==null?i.memoizedProps:null,E=m.children,dc(d,m)?E=null:v!==null&&dc(d,v)&&(r.flags|=32),Yp(i,r),pn(i,r,E,l),r.child;case 6:return i===null&&wc(r),null;case 13:return Qp(i,r,l);case 4:return Rc(r,r.stateNode.containerInfo),d=r.pendingProps,i===null?r.child=es(r,null,d,l):pn(i,r,d,l),r.child;case 11:return d=r.type,m=r.pendingProps,m=r.elementType===d?m:Qn(d,m),Up(i,r,d,m,l);case 7:return pn(i,r,r.pendingProps,l),r.child;case 8:return pn(i,r,r.pendingProps.children,l),r.child;case 12:return pn(i,r,r.pendingProps.children,l),r.child;case 10:e:{if(d=r.type._context,m=r.pendingProps,v=r.memoizedProps,E=m.value,vt(da,d._currentValue),d._currentValue=E,v!==null)if(Gn(v.value,E)){if(v.children===m.children&&!Sn.current){r=Ei(i,r,l);break e}}else for(v=r.child,v!==null&&(v.return=r);v!==null;){var $=v.dependencies;if($!==null){E=v.child;for(var Y=$.firstContext;Y!==null;){if(Y.context===d){if(v.tag===1){Y=Ci(-1,l&-l),Y.tag=2;var ce=v.updateQueue;if(ce!==null){ce=ce.shared;var ye=ce.pending;ye===null?Y.next=Y:(Y.next=ye.next,ye.next=Y),ce.pending=Y}}v.lanes|=l,Y=v.alternate,Y!==null&&(Y.lanes|=l),Cc(v.return,l,r),$.lanes|=l;break}Y=Y.next}}else if(v.tag===10)E=v.type===r.type?null:v.child;else if(v.tag===18){if(E=v.return,E===null)throw Error(n(341));E.lanes|=l,$=E.alternate,$!==null&&($.lanes|=l),Cc(E,l,r),E=v.sibling}else E=v.child;if(E!==null)E.return=v;else for(E=v;E!==null;){if(E===r){E=null;break}if(v=E.sibling,v!==null){v.return=E.return,E=v;break}E=E.return}v=E}pn(i,r,m.children,l),r=r.child}return r;case 9:return m=r.type,d=r.pendingProps.children,ns(r,l),m=$n(m),d=d(m),r.flags|=1,pn(i,r,d,l),r.child;case 14:return d=r.type,m=Qn(d,r.pendingProps),m=Qn(d.type,m),Kp(i,r,d,m,l);case 15:return qp(i,r,r.type,r.pendingProps,l);case 17:return d=r.type,m=r.pendingProps,m=r.elementType===d?m:Qn(d,m),ka(i,r),r.tag=1,bn(d)?(i=!0,sa(r)):i=!1,ns(r,l),Bp(r,d,m),$c(r,d,m,l),Kc(null,r,d,!0,i,l);case 19:return em(i,r,l);case 22:return Vp(i,r,l)}throw Error(n(156,r.tag))};function xm(i,r){return nf(i,r)}function cb(i,r,l,d){this.tag=i,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=d,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Un(i,r,l,d){return new cb(i,r,l,d)}function du(i){return i=i.prototype,!(!i||!i.isReactComponent)}function ub(i){if(typeof i=="function")return du(i)?1:0;if(i!=null){if(i=i.$$typeof,i===H)return 11;if(i===T)return 14}return 2}function Gi(i,r){var l=i.alternate;return l===null?(l=Un(i.tag,r,i.key,i.mode),l.elementType=i.elementType,l.type=i.type,l.stateNode=i.stateNode,l.alternate=i,i.alternate=l):(l.pendingProps=r,l.type=i.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=i.flags&14680064,l.childLanes=i.childLanes,l.lanes=i.lanes,l.child=i.child,l.memoizedProps=i.memoizedProps,l.memoizedState=i.memoizedState,l.updateQueue=i.updateQueue,r=i.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=i.sibling,l.index=i.index,l.ref=i.ref,l}function Ta(i,r,l,d,m,v){var E=2;if(d=i,typeof i=="function")du(i)&&(E=1);else if(typeof i=="string")E=5;else e:switch(i){case A:return br(l.children,m,v,r);case ne:E=8,m|=8;break;case W:return i=Un(12,l,r,m|2),i.elementType=W,i.lanes=v,i;case j:return i=Un(13,l,r,m),i.elementType=j,i.lanes=v,i;case P:return i=Un(19,l,r,m),i.elementType=P,i.lanes=v,i;case te:return Aa(l,m,v,r);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case Z:E=10;break e;case U:E=9;break e;case H:E=11;break e;case T:E=14;break e;case F:E=16,d=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return r=Un(E,l,r,m),r.elementType=i,r.type=d,r.lanes=v,r}function br(i,r,l,d){return i=Un(7,i,d,r),i.lanes=l,i}function Aa(i,r,l,d){return i=Un(22,i,d,r),i.elementType=te,i.lanes=l,i.stateNode={isHidden:!1},i}function hu(i,r,l){return i=Un(6,i,null,r),i.lanes=l,i}function fu(i,r,l){return r=Un(4,i.children!==null?i.children:[],i.key,r),r.lanes=l,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}function db(i,r,l,d,m){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=Fl(0),this.expirationTimes=Fl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Fl(0),this.identifierPrefix=d,this.onRecoverableError=m,this.mutableSourceEagerHydrationData=null}function pu(i,r,l,d,m,v,E,$,Y){return i=new db(i,r,l,$,Y),r===1?(r=1,v===!0&&(r|=8)):r=0,v=Un(3,null,null,r),i.current=v,v.stateNode=i,v.memoizedState={element:d,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},Nc(v),i}function hb(i,r,l){var d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:V,key:d==null?null:""+d,children:i,containerInfo:r,implementation:l}}function Cm(i){if(!i)return $i;i=i._reactInternals;e:{if(ur(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(bn(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(n(171))}if(i.tag===1){var l=i.type;if(bn(l))return Zf(i,l,r)}return r}function Em(i,r,l,d,m,v,E,$,Y){return i=pu(l,d,!0,i,m,v,E,$,Y),i.context=Cm(null),l=i.current,d=mn(),m=Yi(l),v=Ci(d,m),v.callback=r??null,Ui(l,v,m),i.current.lanes=m,Ps(i,m,d),Cn(i,d),i}function Ia(i,r,l,d){var m=r.current,v=mn(),E=Yi(m);return l=Cm(l),r.context===null?r.context=l:r.pendingContext=l,r=Ci(v,E),r.payload={element:i},d=d===void 0?null:d,d!==null&&(r.callback=d),i=Ui(m,r,E),i!==null&&(ti(i,m,E,v),fa(i,m,E)),E}function Ba(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 Nm(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var l=i.retryLane;i.retryLane=l!==0&&l<r?l:r}}function mu(i,r){Nm(i,r),(i=i.alternate)&&Nm(i,r)}function fb(){return null}var Rm=typeof reportError=="function"?reportError:function(i){console.error(i)};function gu(i){this._internalRoot=i}Oa.prototype.render=gu.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(n(409));Ia(i,r,null,null)},Oa.prototype.unmount=gu.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;yr(function(){Ia(null,i,null,null)}),r[wi]=null}};function Oa(i){this._internalRoot=i}Oa.prototype.unstable_scheduleHydration=function(i){if(i){var r=df();i={blockedOn:null,target:i,priority:r};for(var l=0;l<Ii.length&&r!==0&&r<Ii[l].priority;l++);Ii.splice(l,0,i),l===0&&pf(i)}};function vu(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function za(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function Pm(){}function pb(i,r,l,d,m){if(m){if(typeof d=="function"){var v=d;d=function(){var ce=Ba(E);v.call(ce)}}var E=Em(r,d,i,0,null,!1,!1,"",Pm);return i._reactRootContainer=E,i[wi]=E.current,Ws(i.nodeType===8?i.parentNode:i),yr(),E}for(;m=i.lastChild;)i.removeChild(m);if(typeof d=="function"){var $=d;d=function(){var ce=Ba(Y);$.call(ce)}}var Y=pu(i,0,!1,null,null,!1,!1,"",Pm);return i._reactRootContainer=Y,i[wi]=Y.current,Ws(i.nodeType===8?i.parentNode:i),yr(function(){Ia(r,Y,l,d)}),Y}function Fa(i,r,l,d,m){var v=l._reactRootContainer;if(v){var E=v;if(typeof m=="function"){var $=m;m=function(){var Y=Ba(E);$.call(Y)}}Ia(r,E,i,m)}else E=pb(l,r,i,m,d);return Ba(E)}cf=function(i){switch(i.tag){case 3:var r=i.stateNode;if(r.current.memoizedState.isDehydrated){var l=Rs(r.pendingLanes);l!==0&&($l(r,l|1),Cn(r,Tt()),(at&6)===0&&(as=Tt()+500,Hi()))}break;case 13:yr(function(){var d=xi(i,1);if(d!==null){var m=mn();ti(d,i,1,m)}}),mu(i,1)}},Hl=function(i){if(i.tag===13){var r=xi(i,134217728);if(r!==null){var l=mn();ti(r,i,134217728,l)}mu(i,134217728)}},uf=function(i){if(i.tag===13){var r=Yi(i),l=xi(i,r);if(l!==null){var d=mn();ti(l,i,r,d)}mu(i,r)}},df=function(){return ht},hf=function(i,r){var l=ht;try{return ht=i,r()}finally{ht=l}},fn=function(i,r,l){switch(r){case"input":if(_t(i,l),r=l.name,l.type==="radio"&&r!=null){for(l=i;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<l.length;r++){var d=l[r];if(d!==i&&d.form===i.form){var m=ia(d);if(!m)throw Error(n(90));ze(d),_t(d,m)}}}break;case"textarea":be(i,l);break;case"select":r=l.value,r!=null&&rt(i,!!l.multiple,r,!1)}},qe=lu,tt=yr;var mb={usingClientEntryPoint:!1,Events:[qs,Yr,ia,ue,Ne,lu]},oo={findFiberByHostInstance:dr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},gb={bundleType:oo.bundleType,version:oo.version,rendererPackageName:oo.rendererPackageName,rendererConfig:oo.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:D.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=ef(i),i===null?null:i.stateNode},findFiberByHostInstance:oo.findFiberByHostInstance||fb,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 $a=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!$a.isDisabled&&$a.supportsFiber)try{Oo=$a.inject(gb),si=$a}catch{}}return En.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=mb,En.createPortal=function(i,r){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!vu(r))throw Error(n(200));return hb(i,r,null,l)},En.createRoot=function(i,r){if(!vu(i))throw Error(n(299));var l=!1,d="",m=Rm;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onRecoverableError!==void 0&&(m=r.onRecoverableError)),r=pu(i,1,!1,null,null,l,!1,d,m),i[wi]=r.current,Ws(i.nodeType===8?i.parentNode:i),new gu(r)},En.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=ef(r),i=i===null?null:i.stateNode,i},En.flushSync=function(i){return yr(i)},En.hydrate=function(i,r,l){if(!za(r))throw Error(n(200));return Fa(null,i,r,!0,l)},En.hydrateRoot=function(i,r,l){if(!vu(i))throw Error(n(405));var d=l!=null&&l.hydratedSources||null,m=!1,v="",E=Rm;if(l!=null&&(l.unstable_strictMode===!0&&(m=!0),l.identifierPrefix!==void 0&&(v=l.identifierPrefix),l.onRecoverableError!==void 0&&(E=l.onRecoverableError)),r=Em(r,null,i,1,l??null,m,!1,v,E),i[wi]=r.current,Ws(i),d)for(i=0;i<d.length;i++)l=d[i],m=l._getVersion,m=m(l._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[l,m]:r.mutableSourceEagerHydrationData.push(l,m);return new Oa(r)},En.render=function(i,r,l){if(!za(r))throw Error(n(200));return Fa(null,i,r,!1,l)},En.unmountComponentAtNode=function(i){if(!za(i))throw Error(n(40));return i._reactRootContainer?(yr(function(){Fa(null,null,i,!1,function(){i._reactRootContainer=null,i[wi]=null})}),!0):!1},En.unstable_batchedUpdates=lu,En.unstable_renderSubtreeIntoContainer=function(i,r,l,d){if(!za(l))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return Fa(i,r,l,!1,d)},En.version="18.3.1-next-f1338f8080-20240426",En}var Bm;function Cb(){if(Bm)return wu.exports;Bm=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(),wu.exports=xb(),wu.exports}var Om;function Eb(){if(Om)return Ha;Om=1;var e=Cb();return Ha.createRoot=e.createRoot,Ha.hydrateRoot=e.hydrateRoot,Ha}var Nb=Eb();const Rb=fh(Nb);function en(e,t,n={}){return fetch(e,{...n,headers:{...n.headers||{},Authorization:`Bearer ${t}`}})}const d_=e=>`nc_seen_${e}`;async function Oe(e,t,n={}){const s=await en(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 vn=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",tn=(e,t)=>`${vn(e)}/fleet/${t}`,Br=(e,t)=>Oe(tn(t,"status"),e),mh=(e,t,n)=>Oe(tn(n,"up"),e,{method:"POST",body:t}),ul=(e,t,n)=>Oe(tn(n,"down"),e,{method:"POST",body:t}),h_=(e,t,n)=>Oe(tn(n,"boot"),e,{method:"POST",body:t}),_o=(e,t,n)=>Oe(tn(n,"restart"),e,{method:"POST",body:{cell:t}}),gh=(e,t)=>Oe(tn(t,"definitions"),e),Pb=(e,t)=>Oe(tn(t,"credentials/status"),e),zm=(e,t,n,s)=>Oe(tn(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:n}}),jb=(e,t,n)=>Oe(tn(n,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),Lb=(e,t,n)=>Oe(tn(n,"define-engine"),e,{method:"POST",body:{def:t}}),Db=(e,t,n,s,o)=>Oe(tn(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:n,envChanges:s}}),Mb=(e,t,n)=>Oe(tn(n,"remove-engine"),e,{method:"POST",body:{id:t}}),Tb=(e,t,n)=>Oe(tn(n,"define-cell"),e,{method:"POST",body:{def:t}}),f_=(e,t,n,s)=>Oe(tn(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:n}}),p_=(e,t,n=!1,s)=>Oe(tn(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:n}}),Ab=(e,t,n)=>Oe(tn(n,"import-cell"),e,{method:"POST",body:t}),Ib=(e,t,n)=>Oe(tn(n,"restore-cells"),e,{method:"POST",body:{cells:t}}),Bb=(e,t,n,s)=>Oe(tn(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!n}}),vh=(e,t,n)=>Oe(`${vn(n)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),m_=(e,t,n,s)=>Oe(`${vn(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!n}}),_h=(e,t,n)=>Oe(`${vn(n)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),g_=e=>Oe("/api/settings",e),Ob=e=>Oe("/api/nodes",e),zb=e=>Oe("/api/peers",e),Fb=e=>Oe("/api/topology",e),v_=(e,t)=>Oe(`${vn(t)}/sessions`,e),yh=(e,t)=>Oe(`${vn(t)}/config`,e),Fm=(e,t)=>Oe(`${vn(t)}/topology`,e),__=(e,t)=>Oe("/api/settings/config",e,{method:"POST",body:t}),$b=e=>Oe("/api/settings/token/rotate",e,{method:"POST"}),Hb=(e,t)=>Oe("/api/settings/nodes/pair",e,{method:"POST",body:t}),$m=(e,t,n=[])=>Oe(`${vn(n)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),y_=(e,t,n)=>Oe(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:n}}),Wb=e=>Oe("/api/settings/node-aliases",e),Ub=(e,t,n)=>Oe(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{alias:n}}),Hm=(e,t)=>Oe(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Kb=(e,t,n)=>Oe(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"PATCH",body:n}),qb=(e,t)=>Oe(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),wh=(e,t,n)=>Oe(`/api/settings/nodes/${encodeURIComponent(t)}/${n}`,e,{method:"POST"}),Vb=(e,t,n)=>Oe(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:n}}),Wm=(e,t,n,s=[])=>Oe(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:n,selected:s}}),Yb=e=>Oe("/api/settings/service/regenerate",e,{method:"POST"}),Xb=e=>Oe("/api/settings/update/check",e,{method:"POST"}),Gb=e=>Oe("/api/settings/update/apply",e,{method:"POST"}),El=(e,t)=>`${vn(e)}/diagnostics/${t}`,Jb=(e,t=[])=>Oe(El(t,"status"),e),Qb=(e,{after:t=0,limit:n=200}={},s=[])=>Oe(`${El(s,"logs")}?after=${encodeURIComponent(t)}&limit=${encodeURIComponent(n)}`,e),Um=(e,t,n,s=[])=>Oe(El(s,"verbose"),e,{method:"PATCH",body:{enabled:t,durationSeconds:n}}),Zb=(e,t=[])=>Oe(El(t,"logs"),e,{method:"DELETE"}),e0=(e,t=!0)=>Oe(`/api/asks${t?"?open=1":""}`,e),t0=(e,t,n)=>Oe(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:n}}),Wa=(e,t=[])=>Oe(`${vn(t)}/decks`,e),Km=(e,t,n=[])=>Oe(`${vn(n)}/decks`,e,{method:"POST",body:{name:t}}),Ua=(e,t,n,s,o=[])=>Oe(`${vn(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:n,expectedRevision:s}}),n0=(e,t,n,s,o=[])=>Oe(`${vn(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:n,expectedRevision:s}}),i0=(e,t,n,s=[])=>Oe(`${vn(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:n}}),r0={power:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M12 3v8"}),c.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:c.jsx("path",{d:"M4 6a2 2 0 0 1 2-2h3.6a2 2 0 0 1 1.4.6L12.4 6H18a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z"}),keyboard:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),c.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),c.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),c.jsx("path",{d:"M12 18v3"})]}),enter:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),c.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),c.jsx("path",{d:"M22 2 11 13"})]}),trash:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M4 7h16"}),c.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),c.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),c.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:c.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),refresh:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),c.jsx("polyline",{points:"21 3 21 8 16 8"})]}),boot:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),c.jsx("path",{d:"M8 21h8M12 17v4M12 12V7"}),c.jsx("polyline",{points:"9 10 12 7 15 10"})]}),upload:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M12 16V5"}),c.jsx("polyline",{points:"8 9 12 5 16 9"}),c.jsx("path",{d:"M5 20h14"})]}),chevronLeft:c.jsx("polyline",{points:"14 6 8 12 14 18"}),chevronUp:c.jsx("polyline",{points:"6 14 12 8 18 14"}),chevronDown:c.jsx("polyline",{points:"6 10 12 16 18 10"}),history:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),c.jsx("polyline",{points:"3 3 3 8 8 8"}),c.jsx("path",{d:"M12 7v5l3 2"})]}),attach:c.jsx("path",{d:"M21.44 11.05 12.25 20.24a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"}),file:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M14.5 4h-5L7.5 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.5z"}),c.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),c.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),c.jsx("path",{d:"M21 15l-5-5L5 21"})]}),zoomIn:c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:"11",cy:"11",r:"7"}),c.jsx("path",{d:"M21 21l-4.35-4.35"}),c.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:"11",cy:"11",r:"7"}),c.jsx("path",{d:"M21 21l-4.35-4.35"}),c.jsx("path",{d:"M8 11h6"})]}),gear:c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:"12",cy:"12",r:"3"}),c.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),copy:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),c.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})};function nt({name:e,size:t=20}){return c.jsx("svg",{className:"nc-icon",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r0[e]||null})}const s0=["all","pinned","active","off","technical"],w_="nc_sidebar_views_v1",S_="nc_sidebar_order_v1";function b_(e){return s0.includes(e)?e:"all"}function o0(e,t=[],n="all"){const s=b_(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 a0(e,t,n=[],s=[]){const o=n.indexOf(e.key),a=n.indexOf(t.key),u=o===-1?Number.MAX_SAFE_INTEGER:o,h=a===-1?Number.MAX_SAFE_INTEGER:a,p=s.indexOf(e.key),f=s.indexOf(t.key),_=p===-1?Number.MAX_SAFE_INTEGER:p,b=f===-1?Number.MAX_SAFE_INTEGER:f;return u-h||_-b||+!!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 l0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(S_));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 or(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function c0(e,t=globalThis.localStorage){try{t.setItem(S_,JSON.stringify(e))}catch{}return e}function u0(e,t,n,s,o=[]){if(typeof t!="string"||!t||n===s)return e;const a=[...new Set(o.filter(y=>typeof y=="string"&&y))];if(!a.includes(n)||!a.includes(s))return e;const u=or(e,t).filter(y=>a.includes(y)),h=[...u,...a.filter(y=>!u.includes(y))],p=h.indexOf(n),f=h.indexOf(s);h.splice(p,1);const _=h.indexOf(s),b=p<f?_+1:_;return h.splice(b,0,n),{...e,[t]:h}}function d0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(w_));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function qm(e,t){var n,s;return{open:((n=e==null?void 0:e[t])==null?void 0:n.open)!==!1,filter:b_((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function h0(e,t=globalThis.localStorage){try{t.setItem(w_,JSON.stringify(e))}catch{}return e}function Vm(e,t=""){const n=String(t||"").trim().toLocaleLowerCase();return n?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(n):!0}function Dr(e=[],t=[],n="all",s=[]){return[...e].filter(o=>o0(o,t,n)).sort((o,a)=>a0(o,a,t,s))}const Sh=["it","en","es"];function f0(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return Sh.includes(t)?t:"en"}catch{return"en"}}const nl=f0(),k_="nc_lang",pd="nc-lang";function x_(){return typeof localStorage<"u"?localStorage:null}const Ka={it:{"update-available":"nuova versione {v} disponibile","install-version-mismatch":"installazione incompleta: frontend e server non coincidono (v{v})",reload:"ricarica","grid-empty":"trascina qui una sessione dalla sidebar, o doppio-clic per la vista singola","grid-full":"il deck può mostrare al massimo 9 sessioni",pin:"fissa in cima",reorder:"riordina","reorder-help":"trascina la maniglia; frecce su/giu da tastiera","rename-node":"rinomina nodo","rename-node-prompt":"Nuovo nome del nodo in NexusCrew","rename-node-invalid":"Nome non valido: massimo 64 caratteri, senza a capo.","reorder-deck-help":"trascina il deck; frecce sinistra/destra da tastiera",sessions:"sessioni","new-session":"nuova sessione",new:"nuova",fleet:"Flotta","fleet-tmux":"flotta tmux","other-sessions":"Altre sessioni","view-all":"tutte","view-pinned":"fissate","view-active":"attive","view-off":"spente","view-technical":"tecniche","mark-technical":"nascondi come sessione tecnica","mark-normal":"mostra come sessione normale","position-local":"Locale",files:"file",refresh:"aggiorna","filter-placeholder":"filtra sessioni…","loading-fleet":"carico la flotta…","no-sessions":"nessuna sessione tmux viva — la flotta parte al boot (systemd)","no-match":'nessuna sessione contiene "{q}"',"copy-url":"clicca per copiare l'URL","ssh-only":"solo tunnel SSH/VPN","new-files-outbox":"nuovi file in outbox",terminate:"termina","terminate-confirm":'Terminare la sessione "{name}"?',"cell-on":"tmux vivo","cell-off":"spenta","cell-working":"al lavoro","cell-idle":"in attesa","cell-degraded":"degradata: unit attiva, tmux morto","power-on":"accendi","power-off":"spegni","boot-enable":"attiva al boot","boot-disable":"disattiva al boot","state-on":"accesa","state-off":"spenta",engine:"Engine",model:"Modello","model-default":"Modello predefinito del provider","model-remembered":"Ultimo modello usato con questo engine","boot-persist":"avvia al boot","remove-boot":"togli anche dal boot","power-config-in-settings":"Engine, provider, profilo, modello e permessi si modificano in Impostazioni → Flotta.","no-remote-control":"⚠ engine non-native: niente RC da app claude.ai (da qui la piloti comunque)",cancel:"annulla",name:"nome","name-invalid":"nome non valido: a-zA-Z0-9._- max 64, senza '-' iniziale",cwd:"cartella",browse:"sfoglia","fs-home":"home","fs-parent":".. su",preset:"preset","preset-2x2":"griglia 2×2","preset-columns":"colonne","preset-equalize":"equalizza",collapse:"comprimi",expand:"espandi",create:"crea","auth-prompt":"Incolla il token (stampato dal server):","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande",composer:"composer",windows:"{n} finestre","empty-files":"vuota",upload:"carica","no-sessions-short":"nessuna sessione","composer-placeholder":"scrivi o detta…","composer-history-tools":"cronologia e dimensione input","composer-history":"cronologia della cella","composer-history-empty":"nessun input inviato","composer-history-clear":"cancella cronologia di questa cella","composer-expand":"espandi input","composer-collapse":"riduci input","composer-clear-data":"cancella bozze e cronologia","composer-clear-data-help":"Rimuove da questo browser tutte le bozze e la cronologia input delle celle.","composer-clear-confirm":"Cancellare tutte le bozze e la cronologia input salvate in questo browser?","composer-clear-done":"Bozze e cronologia cancellate.","composer-clear-failed":"Impossibile cancellare i dati del composer in questo browser.",attach:"allega","attach-file":"File","attach-camera":"Fotocamera","attach-gallery":"Galleria","attach-uploading":"carico…","attach-upload-progress":"allegato {n}/{total}…","attach-uploaded":"{n} allegati caricati",voice:"voice",send:"invia","composer-send-failed":"connessione non pronta — testo conservato, riprova",close:"chiudi","lang-label":"lingua",decks:"deck","new-deck":"nuovo deck","deck-name":"nome deck","open-deck-window":"apri in una nuova finestra","detach-deck":"stacca in una nuova finestra","deck-current":"questo deck (finestra corrente)","deck-owner-unavailable":"nodo owner non condiviso o non raggiungibile","rename-deck":"rinomina deck","delete-deck":"elimina deck","delete-deck-confirm":'Eliminare il deck "{name}"?',"send-to-deck":"manda al deck…","deck-autosave":"salvataggio automatico",saving:"salvataggio…",saved:"salvato","popup-blocked":"popup bloccato: apri qui","expand-owner":"espandi i deck di {owner}","collapse-owner":"comprimi i deck di {owner}","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} deck","dot-working":"in uso (finestra attiva)","dot-on":"aperta in background","dot-neutral":"non aperta","dot-warn":"nodo offline","select-drag":"trascina per selezionare","copy-manual":"seleziona e copia manualmente","toggle-sidebar":"mostra/nascondi la barra laterale",settings:"impostazioni","tab-roles":"ruoli","tab-nodes":"nodi",local:"Locale",location:"Dove","pairing-link":"link di pairing","pairing-required":"nome, alias SSH e link di pairing sono obbligatori","pairing-connect-help":"Per collegare un nodo servono: nome, Host SSH già funzionante e link/QR creato sull’altra installazione NexusCrew.","pairing-localhost-hint":"127.0.0.1 nel link è corretto: non aprirlo qui. NexusCrew usa invito e porta attraverso l’Host SSH.","scan-qr":"scansiona QR","pairing-qr-invalid":"QR di pairing non valido","invite-node":"invita un nodo","create-pairing-link":"crea link / QR","visibility-network":"tutta la rete","visibility-relay":"solo relay","visibility-selected":"nodi selezionati","hydra-simple":"locale + nodi, una sola rete","local-ready":"Questo dispositivo è pronto. Puoi usarlo da solo o collegarlo a un nodo.","local-only":"solo locale","add-node":"aggiungi nodo",connect:"collega","node-connected":"Nodo collegato. La rete verrà sincronizzata automaticamente.","tab-system":"sistema","tab-fleet":"flotta","tab-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.","input-settings-reset":"ripristina predefiniti input","diagnostics-local":"Questo nodo","diagnostics-target":"Nodo da diagnosticare","diagnostics-verbose":"Log verbosi temporanei","diagnostics-duration":"Durata verbose","diagnostics-expires":"Verbose attivo fino alle {time}","diagnostics-off":"Verbose spento; warning ed errori operativi restano disponibili.","diagnostics-level":"Livello","diagnostics-all-levels":"tutti i livelli","diagnostics-component":"componente","diagnostics-pause":"pausa","diagnostics-autoscroll":"scorrimento automatico","diagnostics-log":"Log diagnostico sanitizzato","diagnostics-empty":"Nessun evento diagnostico.","diagnostics-export":"esporta JSON","diagnostics-export-failed":"Esportazione non disponibile in questo browser.","diagnostics-clear":"svuota","diagnostics-clear-confirm":"Svuotare il buffer diagnostico di questo nodo?","diagnostics-unsupported":"Questo peer è offline o non supporta la diagnostica strutturata.","fleet-editor-loading":"Caricamento dell'editor Fleet…","fleet-editor-load-error":"Impossibile caricare l'editor Fleet.","fleet-editor-unavailable":"Editor Fleet non disponibile in questa posizione.","fleet-managed":"gestito da NexusCrew","fleet-custom":"comando personalizzato","fleet-managed-help":"Client, provider e avvio sono gestiti internamente; i segreti non vengono mostrati.","fleet-shell-engine-help":"Shell locale risolta sul dispositivo al momento dell’avvio; nessun percorso viene salvato nel backup.","fleet-shell-command-placeholder":"comando opzionale, es. npm test","fleet-shell-command-help":"Esecuzione tramite shell login interattiva (-lic), con PATH e alias utente. La cella si ferma quando il comando termina; gli errori immediati vengono segnalati.","fleet-shell-command-metachar":"Pipe, redirect, variabili e altri metacaratteri vengono interpretati dalla shell del dispositivo.","fleet-shell-interactive":"Vuoto: apre una shell interattiva locale e mantiene la cella attiva.","fleet-shell-launch-help":"Il comando Shell si configura nella cella da Impostazioni → Flotta.","fleet-credential-title":"API key su questo dispositivo","fleet-credential-help":"La key resta solo sul nodo selezionato, non viene mostrata, esportata o condivisa con la rete.","fleet-credential-set":"imposta key","fleet-credential-change":"cambia key","fleet-credential-forget":"dimentica","fleet-credential-saved":"Key salvata localmente.","fleet-credential-removed":"Key locale rimossa.","fleet-credential-remove-confirm":"Rimuovere la key locale {key}?","fleet-credential-source-environment":"ambiente","fleet-credential-source-local":"store locale","fleet-credential-source-compatibility":"config compatibile","fleet-credential-source-missing":"mancante","fleet-key-section":"KEY","fleet-key-variable":"Variabile","fleet-key-value":"Valore per {key}","fleet-key-used-by":"Usata da: {engines}","fleet-key-used-by-none":"Non ancora usata da engine configurati su questo nodo.","fleet-key-shared-impact":"Sostituire o rimuovere {key} interessa tutti gli engine elencati: {engines}.","fleet-key-enter":"inserisci la key","fleet-key-blank-keeps":"vuoto = mantieni la fonte attuale","fleet-key-reveal":"mostra","fleet-key-hide":"nascondi","fleet-key-local-help":"Il valore resta write-only sul nodo selezionato e non entra in engine, backup o federazione.","fleet-key-create-missing":"Crea esplicitamente l’engine senza key (resterà “key richiesta”).","fleet-key-partial-create":"Engine creato; la key non è stata salvata. Puoi riprovare senza creare duplicati.","fleet-key-partial-edit":"Engine aggiornato; la key non è stata salvata. Le modifiche all’engine restano applicate.","fleet-provider-notice-claude-openrouter":"Claude Code è ottimizzato per modelli Anthropic: altri provider potrebbero non funzionare correttamente. Fast mode richiede il provider Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses è beta e stateless; Codex-VL non usa fallback Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configurazione Claude isolata con onboarding e fast mode dedicati; la configurazione Claude nativa non viene modificata.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY dal credential layer locale; qwen3.8-max-preview è il modello predefinito e non viene usato alcun fallback OpenAI/PAYG.","fleet-model-default":"modello predefinito (opzionale)","fleet-model-required":"modello (obbligatorio)","fleet-standard-permissions":"permessi standard","fleet-unsafe-permissions":"non sicuro · ignora approvazioni/sandbox","fleet-unsafe-warning":"Modalità non sicura esplicita: il worker può agire senza le normali approvazioni o protezioni sandbox.","fleet-provider-display":"nome visualizzato del provider","fleet-custom-provider-default":"Provider personalizzato","fleet-api-key-env":"NOME_VARIABILE_API_KEY","fleet-provider-id":"id-provider","fleet-custom-secret-help":"NexusCrew salva solo il nome della variabile d’ambiente, mai il suo valore.","fleet-model-override":"modello alternativo","fleet-ready":"pronto","fleet-not-ready":"non configurato","fleet-engines":"Engine","fleet-cells":"Celle / sessioni cloud","fleet-backup":"backup / ripristino","fleet-backup-help":"Esporta o ripristina selettivamente engine, celle e system prompt. Token, API key e segreti provider non entrano mai nel file.","fleet-backup-export":"esporta","fleet-backup-import":"importa","fleet-backup-download":"scarica backup","fleet-backup-restore":"ripristina selezionate","fleet-backup-import-help":"Scegli un backup JSON, controlla le celle e seleziona l’engine di destinazione prima del ripristino.","fleet-backup-overwrite":"sovrascrive la cella esistente","fleet-backup-new":"nuova cella","fleet-backup-engine-missing":"scegli un engine disponibile","fleet-backup-restore-unavailable":"Il nodo selezionato supporta solo l’esportazione; aggiornalo per ripristinare backup.","fleet-backup-restored":"{n} celle ripristinate","fleet-backup-confirm-overwrite":"Sovrascrivere queste celle? {cells}","fleet-backup-needs-restart":"riavvio necessario: {cells}","fleet-backup-empty":"nessuna cella da esportare","fleet-backup-select-one":"seleziona almeno una cella","fleet-backup-too-large":"backup troppo grande (massimo 1 MB)","fleet-backup-invalid-json":"il file non contiene JSON valido","fleet-backup-invalid-format":"formato o versione del backup non supportati","fleet-backup-invalid-cell":"il backup contiene una cella non valida","fleet-backup-duplicate-cell":"il backup contiene ID cella duplicati","fleet-backup-invalid-engine":"il backup contiene un engine non valido","fleet-backup-duplicate-engine":"il backup contiene ID engine duplicati","fleet-backup-confirm-engine-overwrite":"Sovrascrivere questi engine? I valori ambiente già configurati sul target restano invariati. {engines}","fleet-backup-env-names":"nomi ambiente","fleet-backup-env-values-required":"i valori ambiente vanno configurati sul dispositivo","fleet-system-prompt":"system prompt",characters:"caratteri","select-all":"seleziona tutte","select-none":"nessuna",edit:"modifica",save:"salva",label:"etichetta","command-path":"path assoluto del comando","args-lines":"argomenti, uno per riga","env-write-only":"I valori env sono write-only: vuoto mantiene il valore esistente.","fleet-new-engine":"Nuovo engine","fleet-new-cell":"Nuova cella","fleet-saved":"Definizione salvata.","fleet-restart-confirm":"Modifica salvata. Riavviare ora: {cells}?","fleet-remove-engine":'Eliminare l’engine "{id}"?',"fleet-remove-cell":'Eliminare la cella "{id}"? Se è attiva verrà prima fermata.',"fleet-cwd-needs-repair":"cartella da riparare","fleet-cwd-repair":"ripara","fleet-cwd-repair-title":"Ripara cartella cella {id}","fleet-cwd-repair-help":"La cartella attuale non è portabile su questo dispositivo: appartiene a un altro dispositivo o non esiste sotto la home. Scegli una cartella home-relative (~) sul dispositivo target; il backend ricalcolerà il percorso assoluto.","fleet-cwd-repair-no-source-path":"Il percorso originale non viene mostrato: è specifico del dispositivo di origine.","fleet-cwd-repair-placeholder":"es. Dev","fleet-cwd-repair-preview":"Nuova cartella: {path}","fleet-cwd-repair-browse":"sfoglia sotto ~","fleet-cwd-repair-fs-empty":"nessuna sottocartella","fleet-cwd-repair-use-current":"usa questa cartella","fleet-cwd-repair-invalid":'percorso non valido: niente assoluto, "..", barra rovesciata o lettera disco',"fleet-cwd-repair-confirm":"Impostare la cartella della cella {id} su {path}? Verrà ricalcolata sul dispositivo target.","fleet-cwd-repair-unportable":"Il percorso scelto non è portabile su questo dispositivo: deve esistere sotto la home.","fleet-cwd-repair-suggestion":"Suggerimento dal dispositivo:","fleet-cwd-repair-use-suggestion":"usa {path}","fleet-cwd-repaired":"Cartella della cella riparata.","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-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-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","node-connected-client":"client collegato","transport-used":"in uso","tunnel-up":"tunnel su","tunnel-down":"tunnel giù","authorized-keys-hint":"incolla questa riga in ~/.ssh/authorized_keys sull'host remoto:",copy:"copia",copied:"copiato","token-rotate":"ruota token","token-rotate-explain":"Il nuovo token NON verrà mostrato: recuperalo con `nexuscrew show token`. La sessione corrente verrà invalidata.","service-regenerate":"rigenera service","npm-auto-update":"aggiornamenti automatici da npm","npm-auto-update-help":"Controlla periodicamente latest e installa solo versioni più recenti. Mai downgrade.","npm-update-current":"installata","npm-update-latest":"npm latest","npm-update-check":"controlla ora","npm-update-install":"aggiorna ora","npm-update-restarting":"Aggiornamento avviato; NexusCrew si riaprirà dopo il riavvio del servizio.","npm-update-idle":"aggiornato","npm-update-checking":"controllo in corso","npm-update-available":"aggiornamento disponibile","npm-update-installing":"installazione in corso","npm-update-installed":"installato, riavvio in corso","npm-update-error":"controllo fallito","npm-update-unsupported":"disponibile solo con installazione npm globale","service-installed":"service installato","service-missing":"service non installato","service-active":"attivo","service-inactive":"non attivo",confirm:"conferma",add:"aggiungi",enable:"attiva","wizard-title":"benvenuto in NexusCrew","wizard-skip":"configura dopo dai settings","wizard-step-roles":"ruoli di questa installazione","wizard-step-node":"primo nodo remoto (opzionale)","wizard-done":"tutto pronto","wizard-done-desc":"setup completato — puoi cambiare tutto dai settings",next:"continua",back:"indietro",skip:"salta",finish:"fine","err-node-name":"nome non valido (a-z, 0-9, -, max 32)","err-local-name":"nome locale non valido: usa uno slug univoco, non “localhost”","err-ssh":"ssh non valido (atteso user@host o alias)","err-port":"porta non valida (1–65535)","err-ssh-port":"porta SSH non valida (1–65535)","err-node-port":"porta NexusCrew non valida (1–65535)","node-sessions":"{n} sessioni","tunnel-down-since":"tunnel giù da {t}","node-unreachable":"nodo non raggiungibile","node-passive":"client offline · stato normale","node-offline":"nodo offline","node-offline-seen":"offline · visto {t} fa","node-needs-repair":"legacy · ripeti il pairing","asks-title":"domande dalle celle","ask-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","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","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","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 completo. Se sei già collegato a un hub, viene usato automaticamente; altrimenti serve solo il suo indirizzo SSH raggiungibile.","invite-network-hint":"Crea un invito per la rete a cui sei già collegato. Il nuovo dispositivo entrerà attraverso l’hub, non si collegherà direttamente a questo dispositivo.","invite-network-label":"Rete di destinazione","invite-network-via":"Hub","invite-network-route":"Un solo collegamento verso l’hub; nodi, celle e deck vengono smistati internamente.","invite-endpoint-label":"Indirizzo SSH di questo hub visto dagli altri dispositivi","invite-endpoint-auto":"Endpoint già configurato","invite-endpoint-needed":"Inserisci user@host o un alias SSH condiviso. Non è 127.0.0.1 e non è l’URL HTTP NexusCrew.","invite-ssh-hint":"Il target SSH con cui L’ALTRO dispositivo raggiunge QUESTA installazione (user@host o alias). Obbligatorio: viene incluso nel link.","invite-next-steps":"copia questo link, apri NexusCrew sull’altro dispositivo e incollalo in Impostazioni → Nodi (o scansiona il QR): al resto pensa NexusCrew","pair-card-title":"collega con un solo link","pair-card-help":"Incolla il link di pairing generato sull’altro dispositivo (o scansiona il suo QR): NexusCrew decodifica, prova la connessione SSH e collega da solo.","pair-paste-ph":"incolla qui il link di pairing","pair-paste-btn":"incolla","pair-advanced":"avanzate / modifica","pair-progress":"collegamento in corso: SSH → invito → conferma → verifica…","pair-retry":"riprova","pair-invalid-link":"questo non è un link di pairing valido","pair-invalid-hint":"serve il link completo (http://…#pair=…) generato dall’altro NexusCrew: non aprirlo, incollalo qui","pair-missing-ssh":"il link non include il target SSH (formato v1): indica in “avanzate” come questo dispositivo raggiunge l’altro via SSH — non viene mai inventato","pair-missing-name":"manca il nome del nodo: completalo in “avanzate”","pair-clipboard-denied":"lettura degli appunti non consentita: incolla manualmente nel campo","pair-clipboard-empty":"appunti vuoti: copia prima il link di pairing","pair-stage-validation":"dati non validi","pair-stage-conflict":"nome già in uso","pair-stage-ssh-start":"avvio del tunnel SSH fallito","pair-stage-ssh-ready":"peer non raggiungibile via SSH","pair-stage-join":"scambio dell’invito fallito","pair-stage-tunnel-final":"tunnel negoziato fallito","pair-stage-confirm":"conferma del pairing fallita","pair-stage-health":"verifica finale della federazione fallita","pair-stage-internal":"errore interno","pair-stage-generic":"connessione fallita","qr-no-camera":"nessuna camera disponibile su questo dispositivo: usa una foto del QR","qr-permission":"permesso camera negato: consentilo nel browser o usa una foto del QR","qr-unsupported":"scanner live non supportato qui: carica una foto del QR","qr-upload":"usa una foto"},en:{"update-available":"new version {v} available","install-version-mismatch":"incomplete installation: frontend and server do not match (v{v})",reload:"reload","grid-empty":"drag a session here from the sidebar, or double-click for single view","grid-full":"a deck can show at most 9 sessions",pin:"pin to top",reorder:"reorder","reorder-help":"drag the handle; keyboard up/down arrows","rename-node":"rename node","rename-node-prompt":"New node name in NexusCrew","rename-node-invalid":"Invalid name: maximum 64 characters, no line breaks.","reorder-deck-help":"drag the deck; keyboard left/right arrows",sessions:"sessions","new-session":"new session",new:"new",fleet:"Fleet","fleet-tmux":"tmux fleet","other-sessions":"Other sessions","view-all":"all","view-pinned":"pinned","view-active":"active","view-off":"off","view-technical":"technical","mark-technical":"hide as technical session","mark-normal":"show as normal session","position-local":"Local",files:"files",refresh:"refresh","filter-placeholder":"filter sessions…","loading-fleet":"loading fleet…","no-sessions":"no live tmux sessions — the fleet starts at boot (systemd)","no-match":'no session matches "{q}"',"copy-url":"click to copy URL","ssh-only":"SSH/VPN tunnel only","new-files-outbox":"new files in outbox",terminate:"terminate","terminate-confirm":'Terminate session "{name}"?',"cell-on":"tmux alive","cell-off":"off","cell-working":"working","cell-idle":"idle","cell-degraded":"degraded: unit active, tmux dead","power-on":"power on","power-off":"power off","boot-enable":"enable at boot","boot-disable":"disable at boot","state-on":"running","state-off":"stopped",engine:"Engine",model:"Model","model-default":"Provider default model","model-remembered":"Last model used with this engine","boot-persist":"start at boot","remove-boot":"also remove from boot","power-config-in-settings":"Edit engine, provider, profile, model and permissions in Settings → Fleet.","no-remote-control":"⚠ non-native engine: no claude.ai app RC (you can still drive it from here)",cancel:"cancel",name:"name","name-invalid":"invalid name: a-zA-Z0-9._- max 64, no leading '-'",cwd:"folder",browse:"browse","fs-home":"home","fs-parent":".. up",preset:"preset","preset-2x2":"2×2 grid","preset-columns":"columns","preset-equalize":"equalize",collapse:"collapse",expand:"expand",create:"create","auth-prompt":"Paste the token (printed by the server):","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text",composer:"composer",windows:"{n} windows","empty-files":"empty",upload:"upload","no-sessions-short":"no sessions","composer-placeholder":"type or dictate…","composer-history-tools":"input history and size","composer-history":"cell history","composer-history-empty":"no submitted input","composer-history-clear":"clear this cell history","composer-expand":"expand input","composer-collapse":"collapse input","composer-clear-data":"clear drafts and history","composer-clear-data-help":"Removes every saved cell draft and input-history entry from this browser.","composer-clear-confirm":"Clear every saved draft and input-history entry from this browser?","composer-clear-done":"Drafts and history cleared.","composer-clear-failed":"Could not clear composer data in this browser.",attach:"attach","attach-file":"File","attach-camera":"Camera","attach-gallery":"Gallery","attach-uploading":"uploading…","attach-upload-progress":"attachment {n}/{total}…","attach-uploaded":"{n} attachments uploaded",voice:"voice",send:"send","composer-send-failed":"connection not ready — text kept, try again",close:"close","lang-label":"language",decks:"decks","new-deck":"new deck","deck-name":"deck name","open-deck-window":"open in a new window","detach-deck":"detach into a new window","deck-current":"this deck (current window)","deck-owner-unavailable":"owner node is not shared or reachable","rename-deck":"rename deck","delete-deck":"delete deck","delete-deck-confirm":'Delete deck "{name}"?',"send-to-deck":"send to deck…","deck-autosave":"autosave",saving:"saving…",saved:"saved","popup-blocked":"popup blocked: open here","expand-owner":"expand {owner} decks","collapse-owner":"collapse {owner} decks","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} decks","dot-working":"in use (active window)","dot-on":"open in background","dot-neutral":"not open","dot-warn":"owner offline","select-drag":"drag to select","copy-manual":"select and copy manually","toggle-sidebar":"show/hide the sidebar",settings:"settings","tab-roles":"roles","tab-nodes":"nodes",local:"Local",location:"Location","pairing-link":"pairing link","pairing-required":"name, SSH alias and pairing link are required","pairing-connect-help":"Connecting a node requires a name, a working SSH Host, and a link/QR created by the other NexusCrew installation.","pairing-localhost-hint":"127.0.0.1 in the link is correct: do not open it here. NexusCrew carries the invite and port through the SSH Host.","scan-qr":"scan QR","pairing-qr-invalid":"invalid pairing QR","invite-node":"invite a node","create-pairing-link":"create link / QR","visibility-network":"whole network","visibility-relay":"relay only","visibility-selected":"selected nodes","hydra-simple":"local + nodes, one network","local-ready":"This device is ready. Use it alone or connect it to a node.","local-only":"local only","add-node":"add node",connect:"connect","node-connected":"Node connected. The network will synchronize automatically.","tab-system":"system","tab-fleet":"fleet","tab-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.","input-settings-reset":"restore input defaults","diagnostics-local":"This node","diagnostics-target":"Node to diagnose","diagnostics-verbose":"Temporary verbose logs","diagnostics-duration":"Verbose duration","diagnostics-expires":"Verbose enabled until {time}","diagnostics-off":"Verbose is off; operational warnings and errors remain available.","diagnostics-level":"Level","diagnostics-all-levels":"all levels","diagnostics-component":"component","diagnostics-pause":"pause","diagnostics-autoscroll":"autoscroll","diagnostics-log":"Sanitized diagnostic log","diagnostics-empty":"No diagnostic events.","diagnostics-export":"export JSON","diagnostics-export-failed":"Export is not available in this browser.","diagnostics-clear":"clear","diagnostics-clear-confirm":"Clear this node diagnostic buffer?","diagnostics-unsupported":"This peer is offline or does not support structured diagnostics.","fleet-editor-loading":"Loading the Fleet editor…","fleet-editor-load-error":"Unable to load the Fleet editor.","fleet-editor-unavailable":"The Fleet editor is unavailable at this location.","fleet-managed":"managed by NexusCrew","fleet-custom":"custom command","fleet-managed-help":"Client, provider and launch are managed internally; secrets are never displayed.","fleet-shell-engine-help":"The local shell is resolved on the device at launch time; no executable path is stored in backups.","fleet-shell-command-placeholder":"optional command, e.g. npm test","fleet-shell-command-help":"Runs through an interactive login shell (-lic), with the user PATH and aliases. The cell stops when the command finishes; immediate failures are reported.","fleet-shell-command-metachar":"Pipes, redirects, variables, and other metacharacters are interpreted by the device shell.","fleet-shell-interactive":"Empty: opens a local interactive shell and keeps the cell active.","fleet-shell-launch-help":"Configure the Shell command on the cell in Settings → Fleet.","fleet-credential-title":"API key on this device","fleet-credential-help":"The key stays only on the selected node and is never displayed, exported or shared with the network.","fleet-credential-set":"set key","fleet-credential-change":"change key","fleet-credential-forget":"forget","fleet-credential-saved":"Key saved locally.","fleet-credential-removed":"Local key removed.","fleet-credential-remove-confirm":"Remove the local {key} key?","fleet-credential-source-environment":"environment","fleet-credential-source-local":"local store","fleet-credential-source-compatibility":"compatible config","fleet-credential-source-missing":"missing","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Value for {key}","fleet-key-used-by":"Used by: {engines}","fleet-key-used-by-none":"Not yet used by configured engines on this node.","fleet-key-shared-impact":"Replacing or removing {key} affects every listed engine: {engines}.","fleet-key-enter":"enter the key","fleet-key-blank-keeps":"blank = keep the current source","fleet-key-reveal":"reveal","fleet-key-hide":"hide","fleet-key-local-help":"The value stays write-only on the selected node and never enters engines, backups or federation.","fleet-key-create-missing":"Explicitly create the engine without a key (it will remain “key required”).","fleet-key-partial-create":"Engine created; the key was not saved. Retry without creating a duplicate.","fleet-key-partial-edit":"Engine updated; the key was not saved. The engine changes remain applied.","fleet-provider-notice-claude-openrouter":"Claude Code is optimized for Anthropic models; other providers may not work correctly. Fast mode requires the first-party Anthropic provider.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses is beta and stateless; Codex-VL has no Chat Completions fallback.","fleet-provider-notice-claude-kimi-code":"Kimi Code uses isolated Claude configuration with dedicated onboarding and fast-mode flags; native Claude configuration is not modified.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal uses only ALIBABA_CODE_API_KEY from the local credential layer; qwen3.8-max-preview is the default and no OpenAI/PAYG fallback is used.","fleet-model-default":"default model (optional)","fleet-model-required":"model (required)","fleet-standard-permissions":"standard permissions","fleet-unsafe-permissions":"unsafe · bypass approvals/sandbox","fleet-unsafe-warning":"Explicit unsafe mode: the worker can act without normal approval or sandbox gates.","fleet-provider-display":"provider display name","fleet-custom-provider-default":"Custom provider","fleet-api-key-env":"API_KEY_ENV_NAME","fleet-provider-id":"provider-id","fleet-custom-secret-help":"NexusCrew stores only the environment-variable name, never its value.","fleet-model-override":"model override","fleet-ready":"ready","fleet-not-ready":"not configured","fleet-engines":"Engines","fleet-cells":"Cells / cloud sessions","fleet-backup":"backup / restore","fleet-backup-help":"Selectively export or restore engines, cells, and system prompts. Tokens, API keys, and provider secrets never enter the file.","fleet-backup-export":"export","fleet-backup-import":"import","fleet-backup-download":"download backup","fleet-backup-restore":"restore selected","fleet-backup-import-help":"Choose a JSON backup, review the cells and select a destination engine before restoring.","fleet-backup-overwrite":"overwrites existing cell","fleet-backup-new":"new cell","fleet-backup-engine-missing":"choose an available engine","fleet-backup-restore-unavailable":"The selected node supports export only; update it to restore backups.","fleet-backup-restored":"{n} cells restored","fleet-backup-confirm-overwrite":"Overwrite these cells? {cells}","fleet-backup-needs-restart":"restart required: {cells}","fleet-backup-empty":"no cells to export","fleet-backup-select-one":"select at least one cell","fleet-backup-too-large":"backup is too large (1 MB maximum)","fleet-backup-invalid-json":"the file does not contain valid JSON","fleet-backup-invalid-format":"unsupported backup format or version","fleet-backup-invalid-cell":"the backup contains an invalid cell","fleet-backup-duplicate-cell":"the backup contains duplicate cell IDs","fleet-backup-invalid-engine":"the backup contains an invalid engine","fleet-backup-duplicate-engine":"the backup contains duplicate engine IDs","fleet-backup-confirm-engine-overwrite":"Overwrite these engines? Environment values already configured on the target stay unchanged. {engines}","fleet-backup-env-names":"environment names","fleet-backup-env-values-required":"environment values must be configured on this device","fleet-system-prompt":"system prompt",characters:"characters","select-all":"select all","select-none":"select none",edit:"edit",save:"save",label:"label","command-path":"absolute command path","args-lines":"arguments, one per line","env-write-only":"Environment values are write-only: blank keeps the existing value.","fleet-new-engine":"New engine","fleet-new-cell":"New cell","fleet-saved":"Definition saved.","fleet-restart-confirm":"Change saved. Restart now: {cells}?","fleet-remove-engine":'Delete engine "{id}"?',"fleet-remove-cell":'Delete cell "{id}"? If active it will be stopped first.',"fleet-cwd-needs-repair":"folder needs repair","fleet-cwd-repair":"repair","fleet-cwd-repair-title":"Repair cell folder {id}","fleet-cwd-repair-help":"The current folder is not portable on this device: it belongs to another device or does not exist under the home directory. Choose a home-relative (~) folder on the target device; the backend will recompute the absolute path.","fleet-cwd-repair-no-source-path":"The original path is not shown: it is specific to the source device.","fleet-cwd-repair-placeholder":"e.g. Dev","fleet-cwd-repair-preview":"New folder: {path}","fleet-cwd-repair-browse":"browse under ~","fleet-cwd-repair-fs-empty":"no subfolders","fleet-cwd-repair-use-current":"use this folder","fleet-cwd-repair-invalid":'invalid path: no absolute path, "..", backslash or drive letter',"fleet-cwd-repair-confirm":"Set the folder of cell {id} to {path}? It will be recomputed on the target device.","fleet-cwd-repair-unportable":"The chosen path is not portable on this device: it must exist under the home directory.","fleet-cwd-repair-suggestion":"Suggestion from device:","fleet-cwd-repair-use-suggestion":"use {path}","fleet-cwd-repaired":"Cell folder repaired.","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-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-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","node-connected-client":"connected client","transport-used":"in use","tunnel-up":"tunnel up","tunnel-down":"tunnel down","authorized-keys-hint":"paste this line into ~/.ssh/authorized_keys on the remote host:",copy:"copy",copied:"copied","token-rotate":"rotate token","token-rotate-explain":"The new token will NOT be shown: retrieve it with `nexuscrew show token`. The current session will be invalidated.","service-regenerate":"regenerate service","npm-auto-update":"automatic updates from npm","npm-auto-update-help":"Periodically checks latest and installs only newer versions. Never downgrades.","npm-update-current":"installed","npm-update-latest":"npm latest","npm-update-check":"check now","npm-update-install":"update now","npm-update-restarting":"Update started; NexusCrew will return after the service restarts.","npm-update-idle":"up to date","npm-update-checking":"checking","npm-update-available":"update available","npm-update-installing":"installing","npm-update-installed":"installed, restarting","npm-update-error":"check failed","npm-update-unsupported":"available only for global npm installations","service-installed":"service installed","service-missing":"service not installed","service-active":"active","service-inactive":"not active",confirm:"confirm",add:"add",enable:"enable","wizard-title":"welcome to NexusCrew","wizard-skip":"configure later from settings","wizard-step-roles":"roles of this install","wizard-step-node":"first remote node (optional)","wizard-done":"all set","wizard-done-desc":"setup complete — you can change everything from settings",next:"continue",back:"back",skip:"skip",finish:"finish","err-node-name":"invalid name (a-z, 0-9, -, max 32)","err-local-name":"invalid local name: use a unique slug, not “localhost”","err-ssh":"invalid ssh (expected user@host or alias)","err-port":"invalid port (1–65535)","err-ssh-port":"invalid SSH port (1–65535)","err-node-port":"invalid NexusCrew port (1–65535)","node-sessions":"{n} sessions","tunnel-down-since":"tunnel down for {t}","node-unreachable":"node unreachable","node-passive":"client offline · expected","node-offline":"node offline","node-offline-seen":"offline · seen {t} ago","node-needs-repair":"legacy · pair again","asks-title":"questions from the cells","ask-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","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","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","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 complete one-time invitation. If this device already joined a hub, that hub is used automatically; otherwise only its reachable SSH address is required.","invite-network-hint":"Create an invitation for the network you already joined. The new device enters through the hub instead of connecting directly to this device.","invite-network-label":"Destination network","invite-network-via":"Hub","invite-network-route":"One connection to the hub; nodes, cells and decks are routed internally.","invite-endpoint-label":"This hub’s SSH address as seen by other devices","invite-endpoint-auto":"Configured endpoint","invite-endpoint-needed":"Enter user@host or a shared SSH alias. This is not 127.0.0.1 and not the NexusCrew HTTP URL.","invite-ssh-hint":"The SSH target the OTHER device uses to reach THIS installation (user@host or alias). Required: it is included in the link.","invite-next-steps":"copy this link, open NexusCrew on the other device and paste it in Settings → Nodes (or scan the QR): NexusCrew does the rest","pair-card-title":"connect with one link","pair-card-help":"Paste the pairing link generated on the other device (or scan its QR): NexusCrew decodes it, tests the SSH connection and connects on its own.","pair-paste-ph":"paste the pairing link here","pair-paste-btn":"paste","pair-advanced":"advanced / edit","pair-progress":"connecting: SSH → invite → confirm → verify…","pair-retry":"retry","pair-invalid-link":"this is not a valid pairing link","pair-invalid-hint":"you need the full link (http://…#pair=…) generated by the other NexusCrew: don’t open it, paste it here","pair-missing-ssh":"the link carries no SSH target (v1 format): set in “advanced” how this device reaches the other one over SSH — it is never invented","pair-missing-name":"the node name is missing: fill it in “advanced”","pair-clipboard-denied":"clipboard read not allowed: paste manually into the field","pair-clipboard-empty":"clipboard is empty: copy the pairing link first","pair-stage-validation":"invalid data","pair-stage-conflict":"name already in use","pair-stage-ssh-start":"SSH tunnel start failed","pair-stage-ssh-ready":"peer unreachable over SSH","pair-stage-join":"invite exchange failed","pair-stage-tunnel-final":"negotiated tunnel failed","pair-stage-confirm":"pairing confirmation failed","pair-stage-health":"final federation check failed","pair-stage-internal":"internal error","pair-stage-generic":"connection failed","qr-no-camera":"no camera available on this device: use a photo of the QR","qr-permission":"camera permission denied: allow it in the browser or use a photo of the QR","qr-unsupported":"live scanner not supported here: upload a photo of the QR","qr-upload":"use a photo"},es:{"update-available":"nueva versión {v} disponible","install-version-mismatch":"instalación incompleta: frontend y servidor no coinciden (v{v})",reload:"recargar","grid-empty":"arrastra aquí una sesión desde la barra lateral, o doble clic para vista única","grid-full":"un deck puede mostrar como máximo 9 sesiones",pin:"fijar arriba",reorder:"reordenar","reorder-help":"arrastra el control; flechas arriba/abajo","rename-node":"renombrar nodo","rename-node-prompt":"Nuevo nombre del nodo en NexusCrew","rename-node-invalid":"Nombre no válido: máximo 64 caracteres, sin saltos de línea.","reorder-deck-help":"arrastra el deck; flechas izquierda/derecha",sessions:"sesiones","new-session":"nueva sesión",new:"nueva",fleet:"Flota","fleet-tmux":"flota tmux","other-sessions":"Otras sesiones","view-all":"todas","view-pinned":"fijadas","view-active":"activas","view-off":"apagadas","view-technical":"técnicas","mark-technical":"ocultar como sesión técnica","mark-normal":"mostrar como sesión normal","position-local":"Local",files:"archivos",refresh:"actualizar","filter-placeholder":"filtrar sesiones…","loading-fleet":"cargando flota…","no-sessions":"sin sesiones tmux vivas — la flota arranca en el boot (systemd)","no-match":"ninguna sesión coincide con «{q}»","copy-url":"clic para copiar la URL","ssh-only":"solo túnel SSH/VPN","new-files-outbox":"archivos nuevos en outbox",terminate:"terminar","terminate-confirm":"¿Terminar la sesión «{name}»?","cell-on":"tmux activo","cell-off":"apagada","cell-working":"trabajando","cell-idle":"en espera","cell-degraded":"degradada: unit activa, tmux muerto","power-on":"encender","power-off":"apagar","boot-enable":"activar al iniciar","boot-disable":"desactivar al iniciar","state-on":"encendida","state-off":"apagada",engine:"Motor",model:"Modelo","model-default":"Modelo predeterminado del proveedor","model-remembered":"Último modelo usado con este motor","boot-persist":"iniciar en el boot","remove-boot":"quitar también del boot","power-config-in-settings":"Modifica motor, proveedor, perfil, modelo y permisos en Ajustes → Flota.","no-remote-control":"⚠ motor no nativo: sin RC de la app claude.ai (aquí puedes pilotarla igual)",cancel:"cancelar",name:"nombre","name-invalid":"nombre inválido: a-zA-Z0-9._- máx 64, sin '-' inicial",cwd:"carpeta",browse:"explorar","fs-home":"home","fs-parent":".. arriba",preset:"preset","preset-2x2":"cuadrícula 2×2","preset-columns":"columnas","preset-equalize":"igualar",collapse:"contraer",expand:"expandir",create:"crear","auth-prompt":"Pega el token (impreso por el servidor):","remember-device":"recordar en este dispositivo","zoom-out":"texto más pequeño","zoom-in":"texto más grande",composer:"composer",windows:"{n} ventanas","empty-files":"vacía",upload:"subir","no-sessions-short":"sin sesiones","composer-placeholder":"escribe o dicta…","composer-history-tools":"historial y tamaño de entrada","composer-history":"historial de la celda","composer-history-empty":"ninguna entrada enviada","composer-history-clear":"borrar historial de esta celda","composer-expand":"ampliar entrada","composer-collapse":"reducir entrada","composer-clear-data":"borrar borradores e historial","composer-clear-data-help":"Elimina de este navegador todos los borradores y el historial de entrada de las celdas.","composer-clear-confirm":"¿Borrar todos los borradores y el historial de entrada guardados en este navegador?","composer-clear-done":"Borradores e historial eliminados.","composer-clear-failed":"No se pudieron borrar los datos del composer en este navegador.",attach:"adjuntar","attach-file":"Archivo","attach-camera":"Cámara","attach-gallery":"Galería","attach-uploading":"subiendo…","attach-upload-progress":"adjunto {n}/{total}…","attach-uploaded":"{n} adjuntos subidos",voice:"voz",send:"enviar","composer-send-failed":"conexión no disponible — texto conservado, inténtalo de nuevo",close:"cerrar","lang-label":"idioma",decks:"decks","new-deck":"nuevo deck","deck-name":"nombre del deck","open-deck-window":"abrir en una ventana nueva","detach-deck":"separar en una ventana nueva","deck-current":"este deck (ventana actual)","deck-owner-unavailable":"el nodo propietario no está compartido o accesible","rename-deck":"renombrar deck","delete-deck":"eliminar deck","delete-deck-confirm":"¿Eliminar el deck «{name}»?","send-to-deck":"enviar al deck…","deck-autosave":"guardado automático",saving:"guardando…",saved:"guardado","popup-blocked":"ventana bloqueada: abrir aquí","expand-owner":"expandir decks de {owner}","collapse-owner":"comprimir decks de {owner}","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} decks","dot-working":"en uso (ventana activa)","dot-on":"abierta en segundo plano","dot-neutral":"no abierta","dot-warn":"nodo sin conexión","select-drag":"arrastra para seleccionar","copy-manual":"selecciona y copia manualmente","toggle-sidebar":"mostrar/ocultar la barra lateral",settings:"ajustes","tab-roles":"roles","tab-nodes":"nodos",local:"Local",location:"Ubicación","pairing-link":"enlace de emparejamiento","pairing-required":"nombre, alias SSH y enlace son obligatorios","pairing-connect-help":"Para conectar un nodo necesitas un nombre, un Host SSH funcional y el enlace/QR creado por la otra instalación NexusCrew.","pairing-localhost-hint":"127.0.0.1 en el enlace es correcto: no lo abras aquí. NexusCrew usa la invitación y el puerto mediante el Host SSH.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","invite-node":"invitar un nodo","create-pairing-link":"crear enlace / QR","visibility-network":"toda la red","visibility-relay":"solo relay","visibility-selected":"nodos seleccionados","hydra-simple":"local + nodos, una red","local-ready":"Este dispositivo está listo. Úsalo solo o conéctalo a un nodo.","local-only":"solo local","add-node":"añadir nodo",connect:"conectar","node-connected":"Nodo conectado. La red se sincronizará automáticamente.","tab-system":"sistema","tab-fleet":"flota","tab-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.","input-settings-reset":"restaurar valores de entrada","diagnostics-local":"Este nodo","diagnostics-target":"Nodo a diagnosticar","diagnostics-verbose":"Logs detallados temporales","diagnostics-duration":"Duración detallada","diagnostics-expires":"Log detallado activo hasta las {time}","diagnostics-off":"El log detallado está apagado; los avisos y errores operativos siguen disponibles.","diagnostics-level":"Nivel","diagnostics-all-levels":"todos los niveles","diagnostics-component":"componente","diagnostics-pause":"pausa","diagnostics-autoscroll":"desplazamiento automático","diagnostics-log":"Log de diagnóstico sanitizado","diagnostics-empty":"No hay eventos de diagnóstico.","diagnostics-export":"exportar JSON","diagnostics-export-failed":"La exportación no está disponible en este navegador.","diagnostics-clear":"vaciar","diagnostics-clear-confirm":"¿Vaciar el búfer de diagnóstico de este nodo?","diagnostics-unsupported":"Este par está desconectado o no admite diagnósticos estructurados.","fleet-editor-loading":"Cargando el editor de Fleet…","fleet-editor-load-error":"No se puede cargar el editor de Fleet.","fleet-editor-unavailable":"El editor de Fleet no está disponible en esta ubicación.","fleet-managed":"gestionado por NexusCrew","fleet-custom":"comando personalizado","fleet-managed-help":"Cliente, proveedor e inicio se gestionan internamente; los secretos nunca se muestran.","fleet-shell-engine-help":"La shell local se resuelve en el dispositivo al iniciar; no se guarda ninguna ruta ejecutable en las copias.","fleet-shell-command-placeholder":"comando opcional, p. ej. npm test","fleet-shell-command-help":"Se ejecuta mediante una shell de inicio interactiva (-lic), con PATH y alias del usuario. La celda se detiene al terminar; los fallos inmediatos se notifican.","fleet-shell-command-metachar":"Pipes, redirecciones, variables y otros metacaracteres son interpretados por la shell del dispositivo.","fleet-shell-interactive":"Vacío: abre una shell local interactiva y mantiene la celda activa.","fleet-shell-launch-help":"Configura el comando Shell de la celda en Ajustes → Flota.","fleet-credential-title":"Clave API en este dispositivo","fleet-credential-help":"La clave permanece solo en el nodo seleccionado y nunca se muestra, exporta ni comparte con la red.","fleet-credential-set":"poner clave","fleet-credential-change":"cambiar clave","fleet-credential-forget":"olvidar","fleet-credential-saved":"Clave guardada localmente.","fleet-credential-removed":"Clave local eliminada.","fleet-credential-remove-confirm":"¿Eliminar la clave local {key}?","fleet-credential-source-environment":"entorno","fleet-credential-source-local":"almacén local","fleet-credential-source-compatibility":"config compatible","fleet-credential-source-missing":"ausente","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Valor para {key}","fleet-key-used-by":"Usada por: {engines}","fleet-key-used-by-none":"Aún no la usa ningún motor configurado en este nodo.","fleet-key-shared-impact":"Sustituir o eliminar {key} afecta a todos los motores listados: {engines}.","fleet-key-enter":"introduce la clave","fleet-key-blank-keeps":"vacío = mantener la fuente actual","fleet-key-reveal":"mostrar","fleet-key-hide":"ocultar","fleet-key-local-help":"El valor permanece write-only en el nodo seleccionado y nunca entra en motores, copias ni federación.","fleet-key-create-missing":"Crear explícitamente el motor sin clave (seguirá como “clave requerida”).","fleet-key-partial-create":"Motor creado; la clave no se guardó. Puedes reintentar sin crear un duplicado.","fleet-key-partial-edit":"Motor actualizado; la clave no se guardó. Los cambios del motor siguen aplicados.","fleet-provider-notice-claude-openrouter":"Claude Code está optimizado para modelos Anthropic; otros proveedores podrían no funcionar correctamente. Fast mode requiere el proveedor Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses es beta y stateless; Codex-VL no usa fallback de Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configuración Claude aislada con onboarding y fast mode dedicados; la configuración Claude nativa no se modifica.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY de la capa local de credenciales; qwen3.8-max-preview es el modelo predeterminado y no se usa fallback OpenAI/PAYG.","fleet-model-default":"modelo predeterminado (opcional)","fleet-model-required":"modelo (obligatorio)","fleet-standard-permissions":"permisos estándar","fleet-unsafe-permissions":"inseguro · omitir aprobaciones/sandbox","fleet-unsafe-warning":"Modo inseguro explícito: el worker puede actuar sin las aprobaciones normales ni las protecciones del sandbox.","fleet-provider-display":"nombre visible del proveedor","fleet-custom-provider-default":"Proveedor personalizado","fleet-api-key-env":"NOMBRE_VARIABLE_API_KEY","fleet-provider-id":"id-proveedor","fleet-custom-secret-help":"NexusCrew guarda solo el nombre de la variable de entorno, nunca su valor.","fleet-model-override":"modelo alternativo","fleet-ready":"listo","fleet-not-ready":"no configurado","fleet-engines":"Motores","fleet-cells":"Celdas / sesiones cloud","fleet-backup":"copia / restauración","fleet-backup-help":"Exporta o restaura selectivamente motores, celdas y system prompts. Tokens, claves API y secretos del proveedor nunca entran en el archivo.","fleet-backup-export":"exportar","fleet-backup-import":"importar","fleet-backup-download":"descargar copia","fleet-backup-restore":"restaurar seleccionadas","fleet-backup-import-help":"Elige una copia JSON, revisa las celdas y selecciona un motor de destino antes de restaurar.","fleet-backup-overwrite":"sobrescribe la celda existente","fleet-backup-new":"celda nueva","fleet-backup-engine-missing":"elige un motor disponible","fleet-backup-restore-unavailable":"El nodo seleccionado solo admite exportación; actualízalo para restaurar copias.","fleet-backup-restored":"{n} celdas restauradas","fleet-backup-confirm-overwrite":"¿Sobrescribir estas celdas? {cells}","fleet-backup-needs-restart":"reinicio necesario: {cells}","fleet-backup-empty":"no hay celdas para exportar","fleet-backup-select-one":"selecciona al menos una celda","fleet-backup-too-large":"copia demasiado grande (máximo 1 MB)","fleet-backup-invalid-json":"el archivo no contiene JSON válido","fleet-backup-invalid-format":"formato o versión de copia no compatible","fleet-backup-invalid-cell":"la copia contiene una celda no válida","fleet-backup-duplicate-cell":"la copia contiene IDs de celda duplicados","fleet-backup-invalid-engine":"la copia contiene un motor no válido","fleet-backup-duplicate-engine":"la copia contiene IDs de motor duplicados","fleet-backup-confirm-engine-overwrite":"¿Sobrescribir estos motores? Los valores de entorno ya configurados en el destino no cambian. {engines}","fleet-backup-env-names":"nombres de entorno","fleet-backup-env-values-required":"los valores de entorno deben configurarse en este dispositivo","fleet-system-prompt":"system prompt",characters:"caracteres","select-all":"seleccionar todas","select-none":"ninguna",edit:"editar",save:"guardar",label:"etiqueta","command-path":"ruta absoluta del comando","args-lines":"argumentos, uno por línea","env-write-only":"Los valores env son de solo escritura: vacío conserva el valor existente.","fleet-new-engine":"Nuevo motor","fleet-new-cell":"Nueva celda","fleet-saved":"Definición guardada.","fleet-restart-confirm":"Cambio guardado. ¿Reiniciar ahora: {cells}?","fleet-remove-engine":'¿Eliminar el motor "{id}"?',"fleet-remove-cell":'¿Eliminar la celda "{id}"? Si está activa se detendrá primero.',"fleet-cwd-needs-repair":"carpeta a reparar","fleet-cwd-repair":"reparar","fleet-cwd-repair-title":"Reparar carpeta de celda {id}","fleet-cwd-repair-help":"La carpeta actual no es portátil en este dispositivo: pertenece a otro dispositivo o no existe bajo el directorio home. Elige una carpeta relativa a home (~) en el dispositivo destino; el backend recalculará la ruta absoluta.","fleet-cwd-repair-no-source-path":"La ruta original no se muestra: es específica del dispositivo de origen.","fleet-cwd-repair-placeholder":"p. ej. Dev","fleet-cwd-repair-preview":"Nueva carpeta: {path}","fleet-cwd-repair-browse":"examinar bajo ~","fleet-cwd-repair-fs-empty":"sin subcarpetas","fleet-cwd-repair-use-current":"usar esta carpeta","fleet-cwd-repair-invalid":'ruta no válida: nada de ruta absoluta, "..", barra invertida ni letra de unidad',"fleet-cwd-repair-confirm":"¿Establecer la carpeta de la celda {id} a {path}? Se recalculará en el dispositivo destino.","fleet-cwd-repair-unportable":"La ruta elegida no es portátil en este dispositivo: debe existir bajo el directorio home.","fleet-cwd-repair-suggestion":"Sugerencia del dispositivo:","fleet-cwd-repair-use-suggestion":"usar {path}","fleet-cwd-repaired":"Carpeta de la celda reparada.","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-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-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","node-connected-client":"cliente conectado","transport-used":"en uso","tunnel-up":"túnel activo","tunnel-down":"túnel caído","authorized-keys-hint":"pega esta línea en ~/.ssh/authorized_keys del host remoto:",copy:"copiar",copied:"copiado","token-rotate":"rotar token","token-rotate-explain":"El nuevo token NO se mostrará: recupéralo con `nexuscrew show token`. La sesión actual quedará invalidada.","service-regenerate":"regenerar service","npm-auto-update":"actualizaciones automáticas desde npm","npm-auto-update-help":"Comprueba latest periódicamente e instala solo versiones más recientes. Nunca baja de versión.","npm-update-current":"instalada","npm-update-latest":"npm latest","npm-update-check":"comprobar ahora","npm-update-install":"actualizar ahora","npm-update-restarting":"Actualización iniciada; NexusCrew volverá después de reiniciar el servicio.","npm-update-idle":"actualizado","npm-update-checking":"comprobando","npm-update-available":"actualización disponible","npm-update-installing":"instalando","npm-update-installed":"instalada, reiniciando","npm-update-error":"comprobación fallida","npm-update-unsupported":"disponible solo con instalación npm global","service-installed":"service instalado","service-missing":"service no instalado","service-active":"activo","service-inactive":"no activo",confirm:"confirmar",add:"añadir",enable:"activar","wizard-title":"bienvenido a NexusCrew","wizard-skip":"configura después desde ajustes","wizard-step-roles":"roles de esta instalación","wizard-step-node":"primer nodo remoto (opcional)","wizard-done":"todo listo","wizard-done-desc":"configuración completa — puedes cambiarlo todo desde ajustes",next:"continuar",back:"atrás",skip:"omitir",finish:"terminar","err-node-name":"nombre inválido (a-z, 0-9, -, máx 32)","err-local-name":"nombre local inválido: usa un slug único, no “localhost”","err-ssh":"ssh inválido (se espera user@host o alias)","err-port":"puerto inválido (1–65535)","err-ssh-port":"puerto SSH inválido (1–65535)","err-node-port":"puerto NexusCrew inválido (1–65535)","node-sessions":"{n} sesiones","tunnel-down-since":"túnel caído desde hace {t}","node-unreachable":"nodo inalcanzable","node-passive":"cliente desconectado · estado normal","node-offline":"nodo desconectado","node-offline-seen":"sin conexión · visto hace {t}","node-needs-repair":"legacy · vuelve a enlazar","asks-title":"preguntas de las celdas","ask-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","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","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","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 completa de un solo uso. Si este dispositivo ya está unido a un hub, se usa automáticamente; si no, solo hace falta su dirección SSH alcanzable.","invite-network-hint":"Crea una invitación para la red a la que ya estás conectado. El nuevo dispositivo entra por el hub y no se conecta directamente a este dispositivo.","invite-network-label":"Red de destino","invite-network-via":"Hub","invite-network-route":"Una sola conexión al hub; nodos, celdas y decks se enrutan internamente.","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 md(){const e=x_(),t=e?e.getItem(k_):null;return Sh.includes(t)?t:nl}function p0(e){const t=x_();if(t)try{t.setItem(k_,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(pd))}function g(e){const t=md(),n=Ka[t]||Ka[nl];return Object.prototype.hasOwnProperty.call(n,e)?n[e]:Object.prototype.hasOwnProperty.call(Ka[nl],e)?Ka[nl][e]:e}function m0(e){return typeof window>"u"?()=>{}:(window.addEventListener(pd,e),()=>window.removeEventListener(pd,e))}const C_=Sh;function On(){return[R.useSyncExternalStore(m0,md,md),p0]}function dl({cell:e,token:t,route:n=[],onConfirm:s,onClose:o}){var F,te;On();const a=!!(e&&e.active),u=Array.isArray(n)?n.join("/"):"",[h,p]=R.useState([]),[f,_]=R.useState(!1);R.useEffect(()=>{let M=!0;return(async()=>{if(t)try{const ie=await Br(t,u?u.split("/"):[]);if(!M)return;if(_(ie.provider==="builtin"&&(ie.capabilities||[]).includes("edit")),ie.provider==="builtin"&&(ie.capabilities||[]).includes("definitions")){const B=await gh(t,u?u.split("/"):[]);if(!M)return;const L=new Map((ie.engines||[]).map(z=>[z.id,z]));p((B.engines||[]).map(z=>{var G,oe,de,me,Q,q,pe;return{id:z.id,label:z.label||z.id,client:((G=z.managed)==null?void 0:G.client)||"",models:[...new Set([...((oe=L.get(z.id))==null?void 0:oe.models)||[],...((de=z.managedInfo)==null?void 0:de.models)||[]])].filter(Boolean),defaultModel:((me=z.managed)==null?void 0:me.model)||((Q=z.managedInfo)==null?void 0:Q.defaultModel)||"",policyDefault:((q=z.managed)==null?void 0:q.permissionPolicy)||((pe=z.managed)!=null&&pe.client&&z.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{M=!1}},[t,u]);const b=(e==null?void 0:e.engine)||((F=h[0])==null?void 0:F.id)||"",y=M=>(e==null?void 0:e.models)&&e.models[M]||"",w=M=>{const ie=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[M];if(ie==="standard"||ie==="unsafe")return ie;const B=h.find(L=>L.id===M);return B?B.policyDefault:"standard"},[S,x]=R.useState(b),[C,k]=R.useState((e==null?void 0:e.model)||""),N=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((te=e==null?void 0:e.permissionPolicies)==null?void 0:te[e==null?void 0:e.engine])||"",[I,D]=R.useState(N),[X,V]=R.useState((e==null?void 0:e.boot)??!0),[A,ne]=R.useState(!1),[W,Z]=R.useState(null);R.useEffect(()=>{h.length&&(x(M=>M||b),k(M=>M||y((e==null?void 0:e.engine)||b)||""),D(M=>M==="standard"||M==="unsafe"?M:w((e==null?void 0:e.engine)||b)))},[h.length]);const U=R.useMemo(()=>h.find(M=>M.id===S)||null,[h,S]),H=!!(U&&["claude","codex","codex-vl"].includes(U.client)),j=(U==null?void 0:U.client)==="shell";function P(M){x(M);const ie=h.find(B=>B.id===M);k(y(M)||(ie==null?void 0:ie.defaultModel)||""),D(w(M))}async function T(M){M.preventDefault(),ne(!0),Z(null);try{if(a)await s({action:"down",boot:X});else{const ie=I==="standard"||I==="unsafe"?I:(U==null?void 0:U.policyDefault)||"standard";await s({action:"up",...f?{engine:S,model:C||"",...H?{permissionPolicy:ie}:(U==null?void 0:U.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:X})}o()}catch(ie){Z(String(ie&&ie.message||ie)),ne(!1)}}return c.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:o,children:c.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:M=>M.stopPropagation(),onSubmit:T,children:[c.jsxs("div",{className:"nc-sheet-head",children:[c.jsx("b",{children:e==null?void 0:e.cell}),c.jsx("span",{className:"nc-sheet-state",children:g(a?"state-on":"state-off")})]}),a?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-power-config",children:[c.jsx("span",{children:g("engine")}),c.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&c.jsxs("small",{children:[g("model"),": ",e.model]}),c.jsx("small",{children:g("power-on-hint")})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:X,onChange:M=>V(M.target.checked)}),g("remove-boot")]})]}):c.jsxs(c.Fragment,{children:[f&&h.length>0?c.jsxs("div",{className:"nc-launch-fields",children:[c.jsxs("label",{className:"nc-field",children:[g("engine"),c.jsx("select",{value:S,onChange:M=>P(M.target.value),children:h.map(M=>c.jsx("option",{value:M.id,children:M.label},M.id))})]}),!j&&c.jsxs("label",{className:"nc-field",children:[g("model"),c.jsx("input",{value:C,list:"nc-launch-models",placeholder:g("model-default"),onChange:M=>k(M.target.value)}),c.jsx("datalist",{id:"nc-launch-models",children:((U==null?void 0:U.models)||[]).map(M=>c.jsx("option",{value:M},M))})]}),H?c.jsxs("label",{className:"nc-field",children:[g("permissions"),c.jsxs("select",{value:I,onChange:M=>D(M.target.value),children:[c.jsx("option",{value:"standard",children:g("fleet-standard-permissions")}),c.jsx("option",{value:"unsafe",children:g("fleet-unsafe-permissions")})]})]}):c.jsx("small",{className:"nc-note",children:g("fleet-standard-permissions")}),H&&I==="unsafe"&&c.jsx("small",{className:"nc-err",children:g("fleet-unsafe-warning")}),c.jsx("small",{className:"nc-note",children:g(j?"fleet-shell-launch-help":"launch-engine-help")})]}):c.jsxs("div",{className:"nc-power-config",children:[c.jsx("span",{children:g("engine")}),c.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&c.jsxs("small",{children:[g("model"),": ",e.model]}),c.jsx("small",{children:g("launch-unavailable-hint")})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:X,onChange:M=>V(M.target.checked)}),g("boot-persist")]})]}),W&&c.jsx("div",{className:"nc-err",children:W}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:A,children:g("cancel")}),c.jsx("button",{type:"submit",className:"nc-btn primary",disabled:A,children:g(a?"power-off":"save-and-start")})]})]})})}const Ym=/^[a-z0-9-]{1,32}$/;function hl(e,t){const n=Array.isArray(e)?e:[];return n.length?`${n.map(encodeURIComponent).join("/")}:${t}`:String(t)}function g0(e,t,n){const s={};for(const o of Array.isArray(t)?t:[]){const a=Array.isArray(o==null?void 0:o.route)?o.route:typeof(o==null?void 0:o.name)=="string"?[o.name]:[];if(!a.length)continue;const u=a.join("/"),h=o.status==="up"||o.tunnel&&o.tunnel.status==="up",p=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!h&&!p&&(s[u]=e&&e[u]||n)}return s}function Xm(e,t,n){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${n}:${s.tmuxSession||s.cell}`}))}function Gm({nodes:e,topology:t,remote:n,down:s,fleet:o,aliases:a}={}){var f,_,b,y;const u=[],h=new Set,p=new Set;for(const w of Array.isArray(e)?e:[]){if(!w||typeof w.name!="string"||!Ym.test(w.name)||w.direction==="inbound"&&w.shared!==!0)continue;const S=[w.name],x=w.name;h.add(x);const C=((f=w.tunnel)==null?void 0:f.status)||"unknown",k=C==="up",N={name:w.name,label:w.label||w.name,originalLabel:w.label||w.name,alias:null,route:S,direct:!0,instanceId:w.nodeId||null,shared:w.shared===!0,tunnelStatus:C,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:w.health||null,direction:w.direction||"outbound",roles:w.roles||null,rolesKnown:w.rolesKnown===!0};if(w.nodeId&&p.add(w.nodeId),!w.nodeId&&w.paired===!1){u.push({...N,status:"needs-repair",downSince:s&&s[x]||null});continue}if(((_=w.health)==null?void 0:_.auth)==="failed"||C==="degraded"&&((b=w.health)==null?void 0:b.status)==="degraded"){u.push({...N,status:"needs-repair",downSince:s&&s[x]||null});continue}if(C==="passive"||((y=w.health)==null?void 0:y.status)==="passive"){u.push({...N,status:"passive",downSince:null});continue}if(!k){u.push({...N,status:"down",downSince:s&&s[x]||null});continue}const I=n&&(n[x]||n[w.name])||null,D=o&&(o[x]||o[w.name]),X=!!(I&&!I.error&&Array.isArray(I.sessions)),V=!!(D&&D.available===!0&&Array.isArray(D.cells));if(!X&&!V){u.push({...N,status:"unreachable"});continue}const A=(X?I.sessions:[]).filter(Z=>Z&&typeof Z.name=="string"&&Z.name).map(Z=>({...Z,node:x,route:S,key:`${x}:${Z.name}`})),ne=Xm(D,S,x),W=new Set(ne.map(Z=>Z.tmuxSession).filter(Boolean));u.push({...N,status:"up",sessions:A,cells:ne,unmanaged:A.filter(Z=>!W.has(Z.name)),fleetAvailable:!!(D&&D.available),capabilities:D&&D.capabilities||[],engines:D&&D.engines||[],fleetProvider:D&&D.provider||null,sessionsAvailable:X,inventoryPartial:!X})}for(const w of Array.isArray(t)?t:[]){if(!w||!Array.isArray(w.route)||w.route.length<1||w.route.some(W=>!Ym.test(W)))continue;const S=w.route.join("/");if(h.has(S)||w.instanceId&&p.has(w.instanceId))continue;w.instanceId&&p.add(w.instanceId);const x=w.label||w.route.join(" › "),C=w.instanceId&&a&&typeof a[w.instanceId]=="string"?a[w.instanceId]:null,k={name:w.name,label:C||x,originalLabel:x,alias:C,route:[...w.route],direct:!1,instanceId:w.instanceId||null,shared:!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:w.health||null,lastSeen:w.lastSeen||null};if(w.stale){u.push({...k,status:"offline",downSince:s&&s[S]||w.lastSeen||null});continue}const N=n&&n[S]||null,I=o&&o[S],D=!!(N&&!N.error&&Array.isArray(N.sessions)),X=!!(I&&I.available===!0&&Array.isArray(I.cells));if(!D&&!X){u.push({...k,status:"unreachable",downSince:s&&s[S]||null});continue}const V=(D?N.sessions:[]).filter(W=>W&&typeof W.name=="string"&&W.name).map(W=>({...W,node:S,route:w.route,key:`${S}:${W.name}`})),A=Xm(I,w.route,S),ne=new Set(A.map(W=>W.tmuxSession).filter(Boolean));u.push({...k,status:"up",sessions:V,cells:A,unmanaged:V.filter(W=>!ne.has(W.name)),fleetAvailable:!!(I&&I.available),capabilities:I&&I.capabilities||[],engines:I&&I.engines||[],fleetProvider:I&&I.provider||null,lastSeen:w.lastSeen||null,sessionsAvailable:D,inventoryPartial:!D})}return u.sort((w,S)=>w.label.localeCompare(S.label))}const v0=4e3;function bh(e,t=!0,n=0){const[s,o]=R.useState([]),a=R.useRef({});return R.useEffect(()=>{if(!t||!e){o([]);return}let u=!0;async function h(){var k;let f=[],_=[],b={};if(await Promise.all([Ob(e).then(N=>{f=Array.isArray(N.nodes)?N.nodes:[]}).catch(()=>{}),Fb(e).then(N=>{_=Array.isArray(N.nodes)?N.nodes:[]}).catch(()=>{}),Wb(e).then(N=>{b=N&&typeof N.aliasesByInstanceId=="object"?N.aliasesByInstanceId:{}}).catch(()=>{})]),!u)return;const y={},w={},S=new Set(f.map(N=>N.name)),x=[];for(const N of f)((k=N.tunnel)==null?void 0:k.status)==="up"&&(N.nodeId||N.paired!==!1)&&(N.direction!=="inbound"||N.shared===!0)&&x.push([N.name]);for(const N of _)!N.stale&&Array.isArray(N.route)&&!(N.route.length===1&&S.has(N.route[0]))&&x.push(N.route);if(await Promise.all(x.map(async N=>{const I=N.join("/");try{y[I]=await v_(e,N)}catch{y[I]={error:"unreachable"}}try{w[I]=await Br(e,N)}catch{w[I]={available:!1}}})),!u)return;const C=Gm({nodes:f,topology:_,remote:y,fleet:w,aliases:b,down:a.current});a.current=g0(a.current,C,Math.floor(Date.now()/1e3)),o(Gm({nodes:f,topology:_,remote:y,fleet:w,aliases:b,down:a.current}))}h();const p=setInterval(h,v0);return()=>{u=!1,clearInterval(p)}},[e,t,n]),s}const Jm=52,Qm=14;function rr({position:e,itemKey:t,label:n,onMove:s,onStep:o,canMove:a=()=>!0,scope:u="roster"}){const h=R.useRef(null),p=R.useRef(0),[f,_]=R.useState(!1),b=()=>{var k,N,I,D;const C=h.current;(N=(k=C==null?void 0:C.over)==null?void 0:k.classList)==null||N.remove("nc-roster-over"),(D=(I=C==null?void 0:C.source)==null?void 0:I.classList)==null||D.remove("nc-roster-dragging"),p.current&&cancelAnimationFrame(p.current),p.current=0},y=(C=!1)=>{const k=h.current;if(!k)return;const N=k.target;b(),h.current=null,_(!1);try{k.handle.releasePointerCapture(k.pointerId)}catch{}C&&N&&N!==t&&a(t,N)&&s(t,N)},w=(C,k)=>{var ne,W,Z,U,H,j,P,T,F;const N=h.current;if(!N)return;N.x=C,N.y=k;const I=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",D=(W=(ne=document.elementFromPoint(C,k))==null?void 0:ne.closest)==null?void 0:W.call(ne,I),X=u==="node"?(Z=D==null?void 0:D.dataset)==null?void 0:Z.nodeOrderKey:(U=D==null?void 0:D.dataset)==null?void 0:U.rosterKey,A=(u==="node"||((H=D==null?void 0:D.dataset)==null?void 0:H.position)===e)&&X&&X!==t&&a(t,X);N.over!==(A?D:null)&&((P=(j=N.over)==null?void 0:j.classList)==null||P.remove("nc-roster-over"),N.over=A?D:null,(F=(T=N.over)==null?void 0:T.classList)==null||F.add("nc-roster-over")),N.target=A?X:null},S=()=>{const C=h.current;if(!C){p.current=0;return}const k=C.container;if(k){const N=k.getBoundingClientRect(),I=C.y<N.top+Jm?-Qm:C.y>N.bottom-Jm?Qm:0;I&&(k.scrollTop+=I,w(C.x,C.y))}p.current=requestAnimationFrame(S)};R.useEffect(()=>{const C=N=>{N.key==="Escape"&&h.current&&(N.preventDefault(),y(!1))},k=()=>y(!1);return window.addEventListener("keydown",C),window.addEventListener("blur",k),()=>{window.removeEventListener("keydown",C),window.removeEventListener("blur",k),b(),h.current=null}},[t,e,u]);const x=C=>{var D;if(C.pointerType==="mouse"&&C.button!==0)return;C.preventDefault(),C.stopPropagation(),C.currentTarget.focus({preventScroll:!0});const k=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",N=C.currentTarget.closest(k),I=C.currentTarget.closest(".nc-side-scroll, .nc-home-scroll");h.current={pointerId:C.pointerId,handle:C.currentTarget,source:N,container:I,target:null,over:null,x:C.clientX,y:C.clientY},(D=N==null?void 0:N.classList)==null||D.add("nc-roster-dragging");try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}_(!0),p.current=requestAnimationFrame(S)};return c.jsx("button",{type:"button",className:`nc-roster-handle${f?" active":""}`,"aria-label":`${g("reorder")} ${n}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:g("reorder-help"),onClick:C=>{C.preventDefault(),C.stopPropagation()},onDragStart:C=>C.preventDefault(),onKeyDown:C=>{C.key!=="ArrowUp"&&C.key!=="ArrowDown"||(C.preventDefault(),C.stopPropagation(),o(C.key==="ArrowUp"?-1:1))},onPointerDown:x,onPointerMove:C=>{!h.current||C.pointerId!==h.current.pointerId||(C.preventDefault(),C.stopPropagation(),w(C.clientX,C.clientY))},onPointerUp:C=>{!h.current||C.pointerId!==h.current.pointerId||(C.preventDefault(),C.stopPropagation(),y(!0))},onPointerCancel:()=>y(!1),onLostPointerCapture:()=>{h.current&&y(!1)},children:"↕"})}const kh="nc_pins";function _0(){try{const e=JSON.parse(localStorage.getItem(kh));return Array.isArray(e)?e:[]}catch{return[]}}function y0(e,t){const n=e.includes(t)?e.filter(s=>s!==t):[...e,t];try{localStorage.setItem(kh,JSON.stringify(n))}catch{}return n}function w0(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(kh,JSON.stringify(s))}catch{}return s}function S0(e,t,n){const s=e.indexOf(t);return[s===-1?1e9:s,-(n||0)]}function b0(e,t){return e[0]-t[0]||e[1]-t[1]}function E_(){const[e,t]=R.useState(_0),[n,s]=R.useState(d0),[o,a]=R.useState(l0),u=y=>t(w=>y0(w,y)),h=y=>qm(n,y),p=(y,w)=>s(S=>{const x={...S,[y]:{...qm(S,y),...w}};return h0(x)}),f=(y,w)=>e.includes(y)===e.includes(w);function _(y,w,S,x){const C=e.includes(w),k=e.includes(S);if(C===k){if(C){t(N=>w0(N,w,S));return}a(N=>{var X;const I=((X=x.find(V=>V.key===w))==null?void 0:X.technical)===!0,D=Dr(x,e,I?"technical":"all",or(N,y)).map(V=>V.key);return c0(u0(N,y,w,S,D))})}}function b(y,w,S,x){var X;const C=((X=x.find(V=>V.key===w))==null?void 0:X.technical)===!0,k=e.includes(w),N=Dr(x,e,C?"technical":"all",or(o,y)).map(V=>V.key).filter(V=>e.includes(V)===k),I=N.indexOf(w),D=N[I+S];I>=0&&D&&_(y,w,D,x)}return{pins:e,views:n,orders:o,togglePin:u,viewFor:h,updateView:p,canMoveRoster:f,moveRoster:_,stepRoster:b}}const N_="nc_node_order_v1",k0=/^[a-f0-9]{16,64}$/;function Pr(e){if(k0.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 Zm(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(N_));return Array.isArray(t)?[...new Set(t.filter(n=>typeof n=="string"&&n&&n.length<=192))].slice(0,128):[]}catch{return[]}}function x0(e,t=globalThis.localStorage){try{t.setItem(N_,JSON.stringify(e))}catch{}return e}function eg(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(Pr(s.group))?n.get(Pr(s.group)):Number.MAX_SAFE_INTEGER,u=n.has(Pr(o.group))?n.get(Pr(o.group)):Number.MAX_SAFE_INTEGER;return a-u||s.index-o.index}).map(({group:s})=>s)}function C0(e,t,n,s=[]){if(!t||!n||t===n)return e;const o=s.map(Pr).filter(Boolean);if(!o.includes(t)||!o.includes(n))return e;const a=[...e.filter(f=>o.includes(f)),...o.filter(f=>!e.includes(f))],u=a.indexOf(t),h=a.indexOf(n);a.splice(u,1);const p=a.indexOf(n);return a.splice(u<h?p+1:p,0,t),a}const gd="nexuscrew-node-preferences";function E0(){try{window.dispatchEvent(new Event(gd))}catch{}}function R_(){const[e,t]=R.useState(Zm);R.useEffect(()=>{const a=()=>t(Zm());return window.addEventListener("storage",a),window.addEventListener(gd,a),()=>{window.removeEventListener("storage",a),window.removeEventListener(gd,a)}},[]);const n=a=>eg(a,e),s=(a,u,h)=>t(p=>{const f=C0(p,a,u,h);return x0(f),E0(),f});return{order:e,groupsFor:n,moveNode:s,stepNode:(a,u,h)=>{const p=eg(h,e).map(Pr),f=p.indexOf(a),_=p[f+u];f>=0&&_&&s(a,_,h)},nodeKey:Pr}}function _s(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 ms(e){return e.status==="passive"?g("node-passive"):e.status==="down"?e.downSince?g("tunnel-down-since").replace("{t}",_s(e.downSince)):g("tunnel-down"):e.status==="unreachable"?g("node-unreachable"):e.status==="offline"?e.lastSeen?g("node-offline-seen").replace("{t}",_s(e.lastSeen)):g("node-offline"):e.status==="needs-repair"?g("node-needs-repair"):""}function P_(e,{passive:t=null}={}){return e?e.status==="passive"?t:e.status==="healthy"?"on":"warn":null}function fl(e){return e&&(e.detail||e.status)||""}function pl(e,t,n=globalThis.localStorage){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const s=Number(n.getItem(d_(t))||0);return e.outbox.latest>s}function j_(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||g("cell-off")).trim()}}if(t.working===!0){const s=g("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:g("cell-idle")}:{working:!1,subtitle:String(t.preview||n.preview||g("cell-on")).trim()}}function L_(e,t){return[...new Set([e.engine,e.model,e.key,t.preview,e.preview,t.status].filter(Boolean).map(String))].join(" ")}function D_(e,t,n,s=globalThis.localStorage){return[...(Array.isArray(e)?e:[]).map(o=>{const a=n.get(o.tmuxSession)||{},u=hl([],o.tmuxSession),h=j_(o,a);return{type:"cell",value:o,key:u,label:o.cell,live:!!o.tmux,fresh:pl(a,u,s),activity:a.activity||0,working:h.working,subtitle:h.subtitle,searchText:L_(o,a)}}),...(Array.isArray(t)?t:[]).map(o=>{const a=hl([],o.name);return{type:"session",value:o,key:a,label:o.name,live:!0,technical:o.technical===!0,fresh:pl(o,a,s),activity:o.activity||0,searchText:`${o.preview||""} ${o.cmd||""}`}})]}function vd(e,t=globalThis.localStorage){const n=e||{},s=Array.isArray(n.route)?n.route:[],o=new Map((n.sessions||[]).map(u=>[u.name,u])),a=[...(n.cells||[]).map(u=>{const h=o.get(u.tmuxSession)||{},p=hl(s,u.tmuxSession||u.cell),f=j_(u,h);return{type:"cell",value:u,key:p,label:u.cell,live:!!u.tmux,fresh:pl(h,p,t),activity:h.activity||u.activity||0,working:f.working,subtitle:f.subtitle,searchText:L_(u,h)}}),...(n.unmanaged||[]).map(u=>{const h=hl(s,u.name);return{type:"session",value:u,key:h,label:u.name,live:!0,technical:u.technical===!0,fresh:pl(u,h,t),activity:u.activity||0,searchText:`${u.preview||""} ${u.cmd||""}`}})];return{route:s,rawItems:a}}const xh=9,ml=.2,N0=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,ys=/^[a-f0-9]{16,64}$/,_d=e=>N0.test(e)&&new Set(e.split("/")).size===e.split("/").length;function cr(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!_d(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"&&ys.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"&&_d(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function An(e){const t=cr(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const M_=9,T_=24,jo=11,R0=e=>{const t=Number(e);return t>=M_&&t<=T_?t:jo};function gs(){return{columns:[]}}function gi(e){return e.columns.flatMap(t=>t.tiles.map(n=>An(n)))}function P0(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(An(o.tiles[s]));return t}const xs=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))});function Ch(e,t,n,s){const o=cr(t);if(!o||gi(e).includes(An(o))||gi(e).length>=xh)return e;const a=xs(e),u={session:o.session,height:1,fontSize:jo,...s||{}};if(o.node&&(u.node=o.node),o.ownerId&&(u.ownerId=o.ownerId),n==="end")return a.columns.push({width:1,tiles:[u]}),a;if(n&&typeof n.col=="number"&&typeof n.row=="number"&&a.columns[n.col])return a.columns[n.col].tiles.splice(n.row,0,u),a;if(n&&typeof n.col=="number"){const h=Math.max(0,Math.min(a.columns.length,n.col));return a.columns.splice(h,0,{width:1,tiles:[u]}),a}return a.columns.push({width:1,tiles:[u]}),a}function A_(e,t){const n=An(t);if(!n||gi(e).includes(n)||gi(e).length>=xh)return e;const s=gi(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let _=0;for(let b=1;b<e.columns.length;b+=1)e.columns[b].tiles.length<e.columns[_].tiles.length&&(_=b);return Ch(e,t,{col:_,row:e.columns[_].tiles.length})}const a=[...P0(e),n],u=new Map(e.columns.flatMap(_=>_.tiles.map(b=>[An(b),b]))),h=cr(t),p=e.columns.length?e.columns.reduce((_,b)=>_+(Number(b.width)||1),0)/e.columns.length:1,f=Array.from({length:o},(_,b)=>{var y;return{width:((y=e.columns[b])==null?void 0:y.width)||p,tiles:[]}});return a.forEach((_,b)=>{const y=cr(_);if(!y)return;const w=u.get(_)||(_===n?h:{})||{},S={session:y.session,height:w.height||1,fontSize:w.fontSize||jo};y.node&&(S.node=y.node),w.ownerId&&(S.ownerId=w.ownerId),w.unavailable===!0&&(S.unavailable=!0),f[b%o].tiles.push(S)}),{columns:f.filter(_=>_.tiles.length)}}function gl(e,t){const n=An(t),s=xs(e);for(const o of s.columns)o.tiles=o.tiles.filter(a=>An(a)!==n);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function j0(e,t,n){const s=An(t);if(!gi(e).includes(s))return e;const o=e.columns.flatMap(a=>a.tiles).find(a=>An(a)===s);return Ch(gl(e,s),s,n,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function L0(e,t){if(!(t instanceof Map)||t.size===0)return e;let n=!1;const s=xs(e);for(const o of s.columns)for(const a of o.tiles){const u=t.get(An(a));if(!u)continue;const h=cr(u);h&&(a.session=h.session,h.node?a.node=h.node:delete a.node,h.ownerId&&(a.ownerId=h.ownerId),n=!0)}return n?Mr(s):e}function D0(e,t,n){const s=xs(e);return s.columns[t]&&(s.columns[t].width=Math.max(ml,Number(n)||1)),s}function M0(e,t,n,s){const o=xs(e),a=o.columns[t]&&o.columns[t].tiles[n];return a&&(a.height=Math.max(ml,Number(s)||1)),o}function T0(e,t,n,s){if(!(e.columns[t]&&e.columns[t].tiles[n]))return e;const a=xs(e),u=a.columns[t].tiles[n],h=Number(u.fontSize)||jo;return u.fontSize=Math.max(M_,Math.min(T_,h+(Number(s)||0))),a}function A0(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 tg(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function Mr(e){if(!e||!Array.isArray(e.columns))return gs();const t=e.columns.map(s=>({width:Math.max(ml,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"&&_d(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&ys.test(o.ownerId)).map(o=>{const a={session:o.session,height:Math.max(ml,Number(o.height)||1),fontSize:R0(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(An(o))&&n.add(An(o))&&n.size<=xh);return{columns:t.filter(s=>s.tiles.length>0)}}const I_=/^[a-z0-9-]{1,32}$/,I0=/^[A-Za-z0-9._-]{1,32}$/,B0=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,O0=320;function yd(e){return typeof e=="string"&&I_.test(e)}const z0=64;function ws(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=z0&&!/[\x00-\x1f\x7f]/.test(t)}function ar(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function B_(e){if(typeof e!="string"||!e||e.length>O0||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:I0.test(e.slice(0,t))&&B0.test(e.slice(t+1))}function ng(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 ig({name:e,ssh:t,sshPort:n,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,a=typeof t=="string"?t.trim():t;if(!yd(o))return{ok:!1,error:"err-node-name"};if(!B_(a))return{ok:!1,error:"err-ssh"};const u=ng(n);if(u===void 0)return{ok:!1,error:"err-ssh-port"};const h=ng(s);if(h===void 0)return{ok:!1,error:"err-node-port"};const p={name:o,ssh:a};return u!==null&&(p.sshPort=u),h!==null&&(p.remotePort=h),{ok:!0,value:p}}function F0(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 rg(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?F0(e.since,t):null}}const $0=new Set(["v","instanceId","port","label","invite"]),H0=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function W0(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 U0(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(W0(t))}catch{return{ok:!1}}if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1};const s=n.v===1?$0:n.v===2?H0: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"||!I_.test(n.name))return{ok:!1};a.name=n.name}if(n.ssh!==void 0){if(!B_(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 K0(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?ar(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}const cs=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function q0({onPick:e,token:t,onSettings:n}){const[s,o]=On(),a=bh(t),[u,h]=R.useState(null),[p,f]=R.useState(null),[_,b]=R.useState(""),[y,w]=R.useState(""),[S,x]=R.useState({bind:"127.0.0.1",port:""}),[C,k]=R.useState(""),[N,I]=R.useState([]),[D,X]=R.useState([]),[V,A]=R.useState({}),[ne,W]=R.useState(new Set),[Z,U]=R.useState(null),[H,j]=R.useState(null),{pins:P,orders:T,togglePin:F,viewFor:te,updateView:M,canMoveRoster:ie,moveRoster:B,stepRoster:L}=E_(),{groupsFor:z,moveNode:G,stepNode:oe,nodeKey:de}=R_(),me=z(a);R.useEffect(()=>{const O=new Map;for(const se of N)O.set(cs(se.cell),!!se.boot);for(const se of a){const ge=se.route||[se.name];for(const ke of se.cells||[])O.set(cs(ke.cell,ge),!!ke.boot)}A(se=>{let ge=!1;const ke={...se};for(const[Ee,we]of Object.entries(se))O.has(Ee)&&O.get(Ee)===we&&(delete ke[Ee],ge=!0);return ge?ke:se})},[N,a]);async function Q(){try{const se=await(await en("/api/sessions",t)).json();se.error?(f(se.error),h([])):(f(null),h(se.sessions||[]))}catch(O){f(String(O)),h([])}try{const O=await Br(t);I(O.available?O.cells||[]:[]),X(O.available?O.capabilities||[]:[])}catch{I([]),X([])}}R.useEffect(()=>{Q(),en("/api/config",t).then(se=>se.json()).then(se=>{w(se.version||""),x({bind:se.bind||"127.0.0.1",port:se.port||""}),k(ys.test(String(se.instanceId||""))?se.instanceId:"")}).catch(()=>{});const O=setInterval(Q,4e3);return()=>clearInterval(O)},[]);async function q(){if(!S.port)return;const O=`http://${S.bind}:${S.port}/#token=${t}`;try{await navigator.clipboard.writeText(O)}catch{}}function pe(O,se,ge){const ke=cs(O,se);A(Ee=>({...Ee,[ke]:!!ge}))}function Ie(O,se=[]){const ge=cs(O.cell,se);return Object.prototype.hasOwnProperty.call(V,ge)?V[ge]:!!O.boot}async function it(O,se,ge=[]){O.stopPropagation();const ke=cs(se.cell,ge),Ee=!Ie(se,ge);pe(se.cell,ge,Ee),W(we=>new Set(we).add(ke));try{await h_(t,{cell:se.cell,enabled:Ee},ge),ge.length||I(we=>we.map(Re=>Re.cell===se.cell?{...Re,boot:Ee}:Re))}catch(we){A(Re=>{const Ge={...Re};return delete Ge[ke],Ge}),f(String((we==null?void 0:we.message)||we))}finally{W(we=>{const Re=new Set(we);return Re.delete(ke),Re})}}async function ze(O){if(!Z)return;const{cell:se}=Z,ge=Array.isArray(Z.route)?Z.route:[];O.action==="up"?(await mh(t,{cell:se,boot:!!O.boot,...O.engine?{engine:O.engine}:{},...O.model!==void 0?{model:O.model}:{},...O.permissionPolicy?{permissionPolicy:O.permissionPolicy}:{}},ge),pe(se,ge,!!O.boot)):(await ul(t,{cell:se,boot:!!O.boot},ge),O.boot&&pe(se,ge,!1)),Q()}async function Fe(O,se=[]){try{await vh(t,O,se)}catch{return}Q()}async function dt(O,se,ge=[]){try{await m_(t,O,se,ge)}catch{return}Q()}async function Ue(O){if(!(!(O!=null&&O.direct)||H)){j(O.name);try{await wh(t,O.name,O.tunnelStatus==="up"?"down":"up")}catch{}j(null)}}async function ct(O){if(!(O!=null&&O.direct))return;const se=window.prompt(g("rename-node-prompt"),O.label||O.name);if(se===null)return;const ge=String(se).trim();if(!ws(ge)){window.alert(g("rename-node-invalid"));return}try{await y_(t,O.name,ge)}catch(ke){window.alert(String((ke==null?void 0:ke.message)||ke))}}const _t=R.useMemo(()=>new Map((u||[]).map(O=>[O.name,O])),[u]),ut=R.useMemo(()=>new Set(N.map(O=>O.tmuxSession)),[N]),pt=R.useMemo(()=>(u||[]).filter(O=>!ut.has(O.name)),[u,ut]),st=R.useMemo(()=>D_(N,pt,_t),[N,pt,_t]),rt=te("local"),mt=R.useMemo(()=>Dr(st,P,rt.filter,or(T,"local")).filter(O=>Vm(O,_)),[st,P,rt.filter,_,T]),le=me.reduce((O,se)=>O+(se.cells||[]).length+(se.unmanaged||[]).filter(ge=>!ge.technical).length,0),be=Dr(st,P,"all",or(T,"local")).length+le,Ae=st.filter(O=>O.live).length+me.reduce((O,se)=>O+vd(se).rawItems.filter(ge=>ge.live).length,0),We=(u||[]).filter(O=>O.attached).length+me.reduce((O,se)=>O+(se.sessions||[]).filter(ge=>ge.attached).length,0),he=Math.min(We,Ae),K=S.port?`${S.bind}:${S.port}`:S.bind;function ee(O,se=null,ge=st){var fn,kt;const ke=Array.isArray(se==null?void 0:se.route)?se.route:[],Ee=ke.join("/"),we=Ee||"local",Re=ke.length?se==null?void 0:se.instanceId:C,Ge=(Ke,Et)=>e({session:Ke,...Ee?{node:Ee}:{},...ys.test(String(Re||""))?{ownerId:Re}:{},...typeof Et=="string"&&Et?{cellName:Et}:{}}),gt=ie;if(O.type==="cell"){const Ke=O.value,Et=ke.length?((se==null?void 0:se.sessions)||[]).find(Ft=>Ft.name===Ke.tmuxSession):_t.get(Ke.tmuxSession),ue=Ke.degraded?g("cell-degraded"):O.working?O.subtitle:Ke.tmux?g("cell-idle"):g("cell-off"),Ne=ke.length===0||((se==null?void 0:se.capabilities)||[]).includes(Ke.active?"down":"up"),qe=ke.length===0?D.includes("boot"):((se==null?void 0:se.capabilities)||[]).includes("boot"),tt=Ie(Ke,ke),qt=cs(Ke.cell,ke),ii=`${g(tt?"boot-disable":"boot-enable")} ${Ke.cell}`;return c.jsxs("div",{className:"nc-mcard","data-roster-key":O.key,"data-position":we,children:[c.jsx(rr,{position:we,itemKey:O.key,label:Ke.cell,canMove:gt,onMove:(Ft,Di)=>B(we,Ft,Di,ge),onStep:Ft=>L(we,O.key,Ft,ge)}),c.jsxs("button",{className:"nc-mcard-main",onClick:()=>Ke.tmux&&Ge(Ke.tmuxSession,Ke.cell),title:ue,"aria-label":`${Ke.cell}, ${ue}`,children:[c.jsx("span",{className:`dot ${Ke.degraded?"warn":Ke.tmux?`on${O.working?" working":""}`:""}`}),c.jsxs("span",{className:"nc-mcard-text",children:[c.jsx("b",{children:Ke.cell}),c.jsx("small",{title:O.subtitle,children:O.subtitle})]})]}),O.activity?c.jsx("span",{className:"nc-rel",children:_s(O.activity)}):null,O.fresh&&((fn=Et==null?void 0:Et.outbox)==null?void 0:fn.count)>0&&c.jsx("span",{className:"nc-badge",title:g("new-files-outbox"),children:Et.outbox.count}),c.jsx("button",{className:`nc-act pin${P.includes(O.key)?" on":""}`,"aria-label":`${g("pin")} ${Ke.cell}`,title:g("pin"),onClick:()=>F(O.key),children:P.includes(O.key)?"★":"☆"}),qe&&c.jsx("button",{className:`nc-act boot${tt?" on":""}`,disabled:ne.has(qt),onClick:Ft=>it(Ft,Ke,ke),title:ii,"aria-label":ii,children:c.jsx(nt,{name:"boot",size:16})}),Ne&&c.jsx("button",{className:`nc-act power${Ke.tmux?" on":""}${Ke.degraded?" warn":""}`,onClick:()=>U(ke.length?{...Ke,boot:tt,route:ke,availableEngines:(se==null?void 0:se.engines)||[]}:{...Ke,boot:tt}),title:Ke.active?g("power-off"):g("power-on"),"aria-label":`${Ke.active?g("power-off"):g("power-on")} ${Ke.cell}`,children:c.jsx(nt,{name:"power",size:16})})]},O.key)}const Be=O.value;return c.jsxs("div",{className:"nc-mcard","data-roster-key":O.key,"data-position":we,children:[c.jsx(rr,{position:we,itemKey:O.key,label:Be.name,canMove:gt,onMove:(Ke,Et)=>B(we,Ke,Et,ge),onStep:Ke=>L(we,O.key,Ke,ge)}),c.jsxs("button",{className:"nc-mcard-main",onClick:()=>Ge(Be.name),children:[c.jsx("span",{className:Be.attached?"dot on":"dot"}),c.jsxs("span",{className:"nc-mcard-text",children:[c.jsx("b",{children:Be.name}),c.jsx("small",{children:Be.preview?Be.preview:Be.cmd?Be.cmd:g("windows").replace("{n}",String(Be.windows||0))})]})]}),O.activity?c.jsx("span",{className:"nc-rel",children:_s(O.activity)}):null,O.fresh&&((kt=Be.outbox)==null?void 0:kt.count)>0&&c.jsx("span",{className:"nc-badge",title:g("new-files-outbox"),children:Be.outbox.count}),c.jsx("button",{className:`nc-act pin${P.includes(O.key)?" on":""}`,"aria-label":`${g("pin")} ${Be.name}`,title:g("pin"),onClick:()=>F(O.key),children:P.includes(O.key)?"★":"☆"}),c.jsx("button",{className:`nc-act technical${Be.technical?" on":""}`,title:Be.technical?g("mark-normal"):g("mark-technical"),"aria-label":`${Be.technical?g("mark-normal"):g("mark-technical")} ${Be.name}`,onClick:()=>dt(Be.name,!Be.technical,ke),children:"T"}),c.jsx("button",{className:"nc-menu",title:g("terminate"),"aria-label":`${g("terminate")} ${Be.name}`,onClick:()=>{window.confirm(g("terminate-confirm").replace("{name}",Be.name))&&Fe(Be.name,ke)},children:"⋯"})]},O.key)}return c.jsxs("div",{className:"nc-home",children:[c.jsxs("header",{className:"nc-home-head",children:[c.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",c.jsx("span",{className:"nc-cursor"})]}),c.jsxs("div",{className:"nc-home-sub",children:[g("fleet-tmux")," · ",Ae," ",g("sessions"),he>0&&` · ${he} attached`]}),c.jsxs("span",{className:"nc-head-actions",children:[c.jsx("button",{className:"nc-refresh",onClick:()=>n("nodes",!1),title:g("settings"),children:c.jsx(nt,{name:"gear",size:18})}),c.jsx("button",{className:"nc-refresh",onClick:Q,title:g("refresh"),children:c.jsx(nt,{name:"refresh",size:18})})]})]}),c.jsxs("main",{className:"nc-home-scroll",children:[be>8&&c.jsx("input",{className:"nc-filter",type:"search",placeholder:g("filter-placeholder"),"aria-label":g("filter-placeholder"),value:_,onChange:O=>b(O.target.value)}),p&&c.jsx("div",{className:"nc-err",children:p}),c.jsxs("section",{className:"nc-group","data-position":"local",children:[c.jsx(sg,{label:g("position-local"),count:mt.length,state:rt,dotClass:"on",onToggle:()=>M("local",{open:!rt.open}),onFilter:O=>M("local",{filter:O})}),rt.open&&mt.map(O=>ee(O,null,st)),rt.open&&u===null&&c.jsx("div",{className:"nc-empty",children:g("loading-fleet")}),rt.open&&u!==null&&mt.length===0&&!p&&c.jsx("div",{className:"nc-empty",children:_?g("no-match").replace("{q}",_):g("no-sessions-short")})]}),me.map(O=>{const ge=P_(O.health,{passive:"warn"})||(O.status==="up"?"on":O.status==="passive"?"":"warn"),ke=O.health?fl(O.health):O.status==="up"?"":ms(O),we=(O.route||[O.name]).join("/"),Re=te(we),{rawItems:Ge}=vd(O),gt=Dr(Ge,P,Re.filter,or(T,we)).filter(kt=>Vm(kt,_)),Be=O.direct&&O.health&&O.health.managed!==!1?c.jsx("button",{type:"button",className:`nc-act power${O.tunnelStatus==="up"?" on":""}`,disabled:H===O.name,title:O.tunnelStatus==="up"?g("power-off"):g("power-on"),"aria-label":`${O.tunnelStatus==="up"?g("power-off"):g("power-on")} ${O.label||O.name}`,onClick:()=>Ue(O),children:c.jsx(nt,{name:"power",size:15})}):null,fn=c.jsxs("span",{className:"nc-node-actions",children:[c.jsx(rr,{scope:"node",position:"nodes",itemKey:de(O),label:O.label||O.name,onMove:(kt,Ke)=>G(kt,Ke,a),onStep:kt=>oe(de(O),kt,a)}),O.direct&&c.jsx("button",{type:"button",className:"nc-node-rename",title:g("rename-node"),"aria-label":`${g("rename-node")} ${O.label||O.name}`,onClick:()=>ct(O),children:"✎"}),Be]});return c.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":we,"data-node-order-key":de(O),children:[c.jsx(sg,{label:O.label||O.name,count:gt.length,state:Re,dotClass:ge,dotTitle:ke,detail:O.status==="up"?"":O.health&&fl(O.health)||ms(O),onToggle:()=>M(we,{open:!Re.open}),onFilter:kt=>M(we,{filter:kt}),onRename:O.direct?()=>ct(O):null,action:fn}),O.status==="up"&&Re.open&&gt.map(kt=>ee(kt,O,Ge)),O.status==="up"&&Re.open&&gt.length===0&&c.jsx("div",{className:"nc-empty",children:_?g("no-match").replace("{q}",_):g("no-sessions-short")})]},`nodo-${we}`)}),c.jsxs("footer",{className:"nc-home-foot",onClick:q,title:g("copy-url"),children:[c.jsxs("span",{className:"nc-home-meta",children:[y&&c.jsxs("span",{className:"nc-home-version",children:["v",y]}),c.jsxs("span",{className:"nc-home-endpoint",children:[K," · ",g("ssh-only")]})]}),c.jsx("span",{className:"nc-lang",onClick:O=>O.stopPropagation(),children:C_.map((O,se)=>c.jsxs("span",{children:[se>0&&" · ",c.jsx("button",{className:`nc-lang-btn${s===O?" on":""}`,onClick:()=>o(O),title:O,children:O.toUpperCase()})]},O))})]})]}),c.jsx("button",{className:"nc-fab",onClick:()=>n("fleet",!0),title:g("fleet-new-cell"),"aria-label":g("fleet-new-cell"),children:"+"}),Z&&c.jsx(dl,{cell:Z,token:t,route:Array.isArray(Z.route)?Z.route:[],onConfirm:ze,onClose:()=>U(null)})]})}function sg({label:e,count:t,state:n,dotClass:s="",dotTitle:o="",detail:a="",onToggle:u,onFilter:h,onRename:p=null,action:f=null}){return c.jsxs("div",{className:"nc-mobile-position-head",onContextMenu:p?_=>{_.preventDefault(),p()}:void 0,children:[c.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:u,"aria-expanded":n.open,"aria-label":`${e} · ${g("node-sessions").replace("{n}",String(t))}`,children:[c.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:n.open?"⌄":"›"}),c.jsx("span",{className:`dot ${s}`,title:o}),c.jsxs("span",{className:"nc-mobile-position-copy",children:[c.jsx("b",{children:e}),c.jsx("small",{children:a||g("node-sessions").replace("{n}",String(t))})]})]}),c.jsxs("select",{className:"nc-mobile-position-filter",value:n.filter,"aria-label":`${e} · ${g("filter-placeholder")}`,title:g(`view-${n.filter}`),onChange:_=>h(_.target.value),children:[c.jsx("option",{value:"all",children:g("view-all")}),c.jsx("option",{value:"pinned",children:g("view-pinned")}),c.jsx("option",{value:"active",children:g("view-active")}),c.jsx("option",{value:"off",children:g("view-off")}),c.jsx("option",{value:"technical",children:g("view-technical")})]}),f]})}/**
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 O_=Object.defineProperty,V0=Object.getOwnPropertyDescriptor,Y0=(e,t)=>{for(var n in t)O_(e,n,{get:t[n],enumerable:!0})},Mt=(e,t,n,s)=>{for(var o=s>1?void 0:s?V0(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&&O_(t,n,o),o},Pe=(e,t)=>(n,s)=>t(n,s,e),og="Terminal input",wd={get:()=>og,set:e=>og=e},ag="Too much output to announce, navigate to rows manually to read",Sd={get:()=>ag,set:e=>ag=e};function X0(e){return e.replace(/\r?\n/g,"\r")}function G0(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function J0(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Q0(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");z_(o,t,n,s)}}function z_(e,t,n,s){e=X0(e),e=G0(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function F_(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 lg(e,t,n,s,o){F_(e,t,n),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function nr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Nl(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 Z0=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 h=e.charCodeAt(a);56320<=h&&h<=57343?t[s++]=(u-55296)*1024+h-56320+65536:(t[s++]=u,t[s++]=h);continue}u!==65279&&(t[s++]=u)}return s}},e1=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,h,p=0,f=0;if(this.interim[0]){let y=!1,w=this.interim[0];w&=(w&224)===192?31:(w&240)===224?15:7;let S=0,x;for(;(x=this.interim[++S]&63)&&S<4;)w<<=6,w|=x;let C=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,k=C-S;for(;f<k;){if(f>=n)return 0;if(x=e[f++],(x&192)!==128){f--,y=!0;break}else this.interim[S++]=x,w<<=6,w|=x&63}y||(C===2?w<128?f--:t[s++]=w:C===3?w<2048||w>=55296&&w<=57343||w===65279||(t[s++]=w):w<65536||w>1114111||(t[s++]=w)),this.interim.fill(0)}let _=n-4,b=f;for(;b<n;){for(;b<_&&!((o=e[b])&128)&&!((a=e[b+1])&128)&&!((u=e[b+2])&128)&&!((h=e[b+3])&128);)t[s++]=o,t[s++]=a,t[s++]=u,t[s++]=h,b+=4;if(o=e[b++],o<128)t[s++]=o;else if((o&224)===192){if(b>=n)return this.interim[0]=o,s;if(a=e[b++],(a&192)!==128){b--;continue}if(p=(o&31)<<6|a&63,p<128){b--;continue}t[s++]=p}else if((o&240)===224){if(b>=n)return this.interim[0]=o,s;if(a=e[b++],(a&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=a,s;if(u=e[b++],(u&192)!==128){b--;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(b>=n)return this.interim[0]=o,s;if(a=e[b++],(a&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=a,s;if(u=e[b++],(u&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=a,this.interim[2]=u,s;if(h=e[b++],(h&192)!==128){b--;continue}if(p=(o&7)<<18|(a&63)<<12|(u&63)<<6|h&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},$_="",sr=" ",Lo=class H_{constructor(){this.fg=0,this.bg=0,this.extended=new vl}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 H_;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}},vl=class W_{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 W_(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Yn=class U_ extends Lo{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new vl,this.combinedData=""}static fromCharData(t){let n=new U_;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?nr(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()]}},cg="di$target",bd="di$dependencies",ku=new Map;function t1(e){return e[bd]||[]}function nn(e){if(ku.has(e))return ku.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");n1(t,n,o)};return t._id=e,ku.set(e,t),t}function n1(e,t,n){t[cg]===t?t[bd].push({id:e,index:n}):(t[bd]=[{id:e,index:n}],t[cg]=t)}var _n=nn("BufferService"),K_=nn("CoreMouseService"),Or=nn("CoreService"),i1=nn("CharsetService"),Eh=nn("InstantiationService"),q_=nn("LogService"),yn=nn("OptionsService"),V_=nn("OscLinkService"),r1=nn("UnicodeService"),Do=nn("DecorationService"),kd=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var _;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,a=new Yn,u=n.getTrimmedLength(),h=-1,p=-1,f=!1;for(let b=0;b<u;b++)if(!(p===-1&&!n.hasContent(b))){if(n.loadCell(b,a),a.hasExtendedAttrs()&&a.extended.urlId)if(p===-1){p=b,h=a.extended.urlId;continue}else f=a.extended.urlId!==h;else p!==-1&&(f=!0);if(f||p!==-1&&b===u-1){let y=(_=this._oscLinkService.getLinkData(h))==null?void 0:_.uri;if(y){let w={start:{x:p+1,y:e},end:{x:b+(!f&&b===u-1?1:0),y:e}},S=!1;if(!(o!=null&&o.allowNonHttpProtocols))try{let x=new URL(y);["http:","https:"].includes(x.protocol)||(S=!0)}catch{S=!0}S||s.push({text:y,range:w,activate:(x,C)=>o?o.activate(x,C,w):s1(x,C),hover:(x,C)=>{var k;return(k=o==null?void 0:o.hover)==null?void 0:k.call(o,x,C,w)},leave:(x,C)=>{var k;return(k=o==null?void 0:o.leave)==null?void 0:k.call(o,x,C,w)}})}f=!1,a.hasExtendedAttrs()&&a.extended.urlId?(p=b,h=a.extended.urlId):(p=-1,h=-1)}}t(s)}};kd=Mt([Pe(0,_n),Pe(1,yn),Pe(2,V_)],kd);function s1(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 Rl=nn("CharSizeService"),ji=nn("CoreBrowserService"),Nh=nn("MouseService"),Li=nn("RenderService"),o1=nn("SelectionService"),Y_=nn("CharacterJoinerService"),Cs=nn("ThemeService"),X_=nn("LinkProviderService"),a1=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ug.isErrorNoTelemetry(e)?new ug(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)}},l1=new a1;function il(e){c1(e)||l1.onUnexpectedError(e)}var xd="Canceled";function c1(e){return e instanceof u1?!0:e instanceof Error&&e.name===xd&&e.message===xd}var u1=class extends Error{constructor(){super(xd),this.name=this.message}};function d1(e){return new Error(`Illegal argument: ${e}`)}var ug=class Cd extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Cd)return t;let n=new Cd;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Ed=class G_ extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,G_.prototype)}};function Mn(e,t=0){return e[e.length-(1+t)]}var h1;(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})(h1||(h1={}));function f1(e,t){let n=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(n,arguments))),o}}var J_;(e=>{function t(D){return D&&typeof D=="object"&&typeof D[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*o(D){yield D}e.single=o;function a(D){return t(D)?D:o(D)}e.wrap=a;function u(D){return D||n}e.from=u;function*h(D){for(let X=D.length-1;X>=0;X--)yield D[X]}e.reverse=h;function p(D){return!D||D[Symbol.iterator]().next().done===!0}e.isEmpty=p;function f(D){return D[Symbol.iterator]().next().value}e.first=f;function _(D,X){let V=0;for(let A of D)if(X(A,V++))return!0;return!1}e.some=_;function b(D,X){for(let V of D)if(X(V))return V}e.find=b;function*y(D,X){for(let V of D)X(V)&&(yield V)}e.filter=y;function*w(D,X){let V=0;for(let A of D)yield X(A,V++)}e.map=w;function*S(D,X){let V=0;for(let A of D)yield*X(A,V++)}e.flatMap=S;function*x(...D){for(let X of D)yield*X}e.concat=x;function C(D,X,V){let A=V;for(let ne of D)A=X(A,ne);return A}e.reduce=C;function*k(D,X,V=D.length){for(X<0&&(X+=D.length),V<0?V+=D.length:V>D.length&&(V=D.length);X<V;X++)yield D[X]}e.slice=k;function N(D,X=Number.POSITIVE_INFINITY){let V=[];if(X===0)return[V,D];let A=D[Symbol.iterator]();for(let ne=0;ne<X;ne++){let W=A.next();if(W.done)return[V,e.empty()];V.push(W.value)}return[V,{[Symbol.iterator](){return A}}]}e.consume=N;async function I(D){let X=[];for await(let V of D)X.push(V);return Promise.resolve(X)}e.asyncToArray=I})(J_||(J_={}));function Ar(e){if(J_.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 p1(...e){return Ct(()=>Ar(e))}function Ct(e){return{dispose:f1(()=>{e()})}}var Q_=class Z_{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{Ar(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?Z_.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)}};Q_.DISABLE_DISPOSED_WARNING=!1;var lr=Q_,Qe=class{constructor(){this._store=new lr,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)}};Qe.None=Object.freeze({dispose(){}});var Ss=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}},Pi=typeof window=="object"?window:globalThis,Nd=class Rd{constructor(t){this.element=t,this.next=Rd.Undefined,this.prev=Rd.Undefined}};Nd.Undefined=new Nd(void 0);var Pt=Nd,dg=class{constructor(){this._first=Pt.Undefined,this._last=Pt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Pt.Undefined}clear(){let e=this._first;for(;e!==Pt.Undefined;){let t=e.next;e.prev=Pt.Undefined,e.next=Pt.Undefined,e=t}this._first=Pt.Undefined,this._last=Pt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new Pt(e);if(this._first===Pt.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!==Pt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Pt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Pt.Undefined&&e.next!==Pt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Pt.Undefined&&e.next===Pt.Undefined?(this._first=Pt.Undefined,this._last=Pt.Undefined):e.next===Pt.Undefined?(this._last=this._last.prev,this._last.next=Pt.Undefined):e.prev===Pt.Undefined&&(this._first=this._first.next,this._first.prev=Pt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Pt.Undefined;)yield e.element,e=e.next}},m1=globalThis.performance&&typeof globalThis.performance.now=="function",g1=class ey{static create(t){return new ey(t)}constructor(t){this._now=m1&&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}},an;(e=>{e.None=()=>Qe.None;function t(H,j){return b(H,()=>{},0,void 0,!0,void 0,j)}e.defer=t;function n(H){return(j,P=null,T)=>{let F=!1,te;return te=H(M=>{if(!F)return te?te.dispose():F=!0,j.call(P,M)},null,T),F&&te.dispose(),te}}e.once=n;function s(H,j,P){return f((T,F=null,te)=>H(M=>T.call(F,j(M)),null,te),P)}e.map=s;function o(H,j,P){return f((T,F=null,te)=>H(M=>{j(M),T.call(F,M)},null,te),P)}e.forEach=o;function a(H,j,P){return f((T,F=null,te)=>H(M=>j(M)&&T.call(F,M),null,te),P)}e.filter=a;function u(H){return H}e.signal=u;function h(...H){return(j,P=null,T)=>{let F=p1(...H.map(te=>te(M=>j.call(P,M))));return _(F,T)}}e.any=h;function p(H,j,P,T){let F=P;return s(H,te=>(F=j(F,te),F),T)}e.reduce=p;function f(H,j){let P,T={onWillAddFirstListener(){P=H(F.fire,F)},onDidRemoveLastListener(){P==null||P.dispose()}},F=new Ce(T);return j==null||j.add(F),F.event}function _(H,j){return j instanceof Array?j.push(H):j&&j.add(H),H}function b(H,j,P=100,T=!1,F=!1,te,M){let ie,B,L,z=0,G,oe={leakWarningThreshold:te,onWillAddFirstListener(){ie=H(me=>{z++,B=j(B,me),T&&!L&&(de.fire(B),B=void 0),G=()=>{let Q=B;B=void 0,L=void 0,(!T||z>1)&&de.fire(Q),z=0},typeof P=="number"?(clearTimeout(L),L=setTimeout(G,P)):L===void 0&&(L=0,queueMicrotask(G))})},onWillRemoveListener(){F&&z>0&&(G==null||G())},onDidRemoveLastListener(){G=void 0,ie.dispose()}},de=new Ce(oe);return M==null||M.add(de),de.event}e.debounce=b;function y(H,j=0,P){return e.debounce(H,(T,F)=>T?(T.push(F),T):[F],j,void 0,!0,void 0,P)}e.accumulate=y;function w(H,j=(T,F)=>T===F,P){let T=!0,F;return a(H,te=>{let M=T||!j(te,F);return T=!1,F=te,M},P)}e.latch=w;function S(H,j,P){return[e.filter(H,j,P),e.filter(H,T=>!j(T),P)]}e.split=S;function x(H,j=!1,P=[],T){let F=P.slice(),te=H(B=>{F?F.push(B):ie.fire(B)});T&&T.add(te);let M=()=>{F==null||F.forEach(B=>ie.fire(B)),F=null},ie=new Ce({onWillAddFirstListener(){te||(te=H(B=>ie.fire(B)),T&&T.add(te))},onDidAddFirstListener(){F&&(j?setTimeout(M):M())},onDidRemoveLastListener(){te&&te.dispose(),te=null}});return T&&T.add(ie),ie.event}e.buffer=x;function C(H,j){return(P,T,F)=>{let te=j(new N);return H(function(M){let ie=te.evaluate(M);ie!==k&&P.call(T,ie)},void 0,F)}}e.chain=C;let k=Symbol("HaltChainable");class N{constructor(){this.steps=[]}map(j){return this.steps.push(j),this}forEach(j){return this.steps.push(P=>(j(P),P)),this}filter(j){return this.steps.push(P=>j(P)?P:k),this}reduce(j,P){let T=P;return this.steps.push(F=>(T=j(T,F),T)),this}latch(j=(P,T)=>P===T){let P=!0,T;return this.steps.push(F=>{let te=P||!j(F,T);return P=!1,T=F,te?F:k}),this}evaluate(j){for(let P of this.steps)if(j=P(j),j===k)break;return j}}function I(H,j,P=T=>T){let T=(...ie)=>M.fire(P(...ie)),F=()=>H.on(j,T),te=()=>H.removeListener(j,T),M=new Ce({onWillAddFirstListener:F,onDidRemoveLastListener:te});return M.event}e.fromNodeEventEmitter=I;function D(H,j,P=T=>T){let T=(...ie)=>M.fire(P(...ie)),F=()=>H.addEventListener(j,T),te=()=>H.removeEventListener(j,T),M=new Ce({onWillAddFirstListener:F,onDidRemoveLastListener:te});return M.event}e.fromDOMEventEmitter=D;function X(H){return new Promise(j=>n(H)(j))}e.toPromise=X;function V(H){let j=new Ce;return H.then(P=>{j.fire(P)},()=>{j.fire(void 0)}).finally(()=>{j.dispose()}),j.event}e.fromPromise=V;function A(H,j){return H(P=>j.fire(P))}e.forward=A;function ne(H,j,P){return j(P),H(T=>j(T))}e.runAndSubscribe=ne;class W{constructor(j,P){this._observable=j,this._counter=0,this._hasChanged=!1;let T={onWillAddFirstListener:()=>{j.addObserver(this)},onDidRemoveLastListener:()=>{j.removeObserver(this)}};this.emitter=new Ce(T),P&&P.add(this.emitter)}beginUpdate(j){this._counter++}handlePossibleChange(j){}handleChange(j,P){this._hasChanged=!0}endUpdate(j){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Z(H,j){return new W(H,j).emitter.event}e.fromObservable=Z;function U(H){return(j,P,T)=>{let F=0,te=!1,M={beginUpdate(){F++},endUpdate(){F--,F===0&&(H.reportChanges(),te&&(te=!1,j.call(P)))},handlePossibleChange(){},handleChange(){te=!0}};H.addObserver(M),H.reportChanges();let ie={dispose(){H.removeObserver(M)}};return T instanceof lr?T.add(ie):Array.isArray(T)&&T.push(ie),ie}}e.fromObservableLight=U})(an||(an={}));var Pd=class jd{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${jd._idPool++}`,jd.all.add(this)}start(t){this._stopWatch=new g1,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}}};Pd.all=new Set,Pd._idPool=0;var v1=Pd,_1=-1,ty=class ny{constructor(t,n,s=(ny._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n<s)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[a,u]=this.getMostFrequentStack(),h=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${u}):`;console.warn(h),console.warn(a);let p=new S1(h,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}};ty._idPool=1;var y1=ty,w1=class iy{constructor(t){this.value=t}static create(){let t=new Error;return new iy(t.stack??"")}print(){console.warn(this.value.split(`
58
+ `).slice(2).join(`
59
+ `))}},S1=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},b1=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},k1=0,xu=class{constructor(e){this.value=e,this.id=k1++}},x1=2,C1,Ce=class{constructor(e){var t,n,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new y1((e==null?void 0:e.onListenerError)??il,((n=this._options)==null?void 0:n.leakWarningThreshold)??_1):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new v1(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var e,t,n,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||n.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,n)=>{var u,h,p,f,_;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let b=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(b);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],w=new b1(`${b}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((u=this._options)==null?void 0:u.onListenerError)||il)(w),Qe.None}if(this._disposed)return Qe.None;t&&(e=e.bind(t));let s=new xu(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=w1.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof xu?(this._deliveryQueue??(this._deliveryQueue=new E1),this._listeners=[this._listeners,s]):this._listeners.push(s):((p=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||p.call(h,this),this._listeners=s,(_=(f=this._options)==null?void 0:f.onDidAddFirstListener)==null||_.call(f,this)),this._size++;let a=Ct(()=>{o==null||o(),this._removeListener(s)});return n instanceof lr?n.add(a):Array.isArray(n)&&n.push(a),a}),this._event}_removeListener(e){var o,a,u,h;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(u=this._options)==null?void 0:u.onDidRemoveLastListener)==null||h.call(u,this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let s=this._deliveryQueue.current===this;if(this._size*x1<=t.length){let p=0;for(let f=0;f<t.length;f++)t[f]?t[p++]=t[f]: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)||il;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 xu)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}},E1=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}},Ld=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Ce,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Ce,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}};Ld.INSTANCE=new Ld;var Rh=Ld;function N1(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Rh.INSTANCE.onDidChangeZoomLevel;function R1(e){return Rh.INSTANCE.getZoomFactor(e)}Rh.INSTANCE.onDidChangeFullscreen;var Es=typeof navigator=="object"?navigator.userAgent:"",Dd=Es.indexOf("Firefox")>=0,P1=Es.indexOf("AppleWebKit")>=0,Ph=Es.indexOf("Chrome")>=0,j1=!Ph&&Es.indexOf("Safari")>=0;Es.indexOf("Electron/")>=0;Es.indexOf("Android")>=0;var Cu=!1;if(typeof Pi.matchMedia=="function"){let e=Pi.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Pi.matchMedia("(display-mode: fullscreen)");Cu=e.matches,N1(Pi,e,({matches:n})=>{Cu&&t.matches||(Cu=n)})}var ps="en",Md=!1,Td=!1,rl=!1,ry=!1,qa,sl=ps,hg=ps,L1,ni,Tr=globalThis,on,l_;typeof Tr.vscode<"u"&&typeof Tr.vscode.process<"u"?on=Tr.vscode.process:typeof process<"u"&&typeof((l_=process==null?void 0:process.versions)==null?void 0:l_.node)=="string"&&(on=process);var c_,D1=typeof((c_=on==null?void 0:on.versions)==null?void 0:c_.electron)=="string",M1=D1&&(on==null?void 0:on.type)==="renderer",u_;if(typeof on=="object"){Md=on.platform==="win32",Td=on.platform==="darwin",rl=on.platform==="linux",rl&&on.env.SNAP&&on.env.SNAP_REVISION,on.env.CI||on.env.BUILD_ARTIFACTSTAGINGDIRECTORY,qa=ps,sl=ps;let e=on.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);qa=t.userLocale,hg=t.osLocale,sl=t.resolvedLanguage||ps,L1=(u_=t.languagePack)==null?void 0:u_.translationsConfigFile}catch{}ry=!0}else typeof navigator=="object"&&!M1?(ni=navigator.userAgent,Md=ni.indexOf("Windows")>=0,Td=ni.indexOf("Macintosh")>=0,(ni.indexOf("Macintosh")>=0||ni.indexOf("iPad")>=0||ni.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,rl=ni.indexOf("Linux")>=0,(ni==null?void 0:ni.indexOf("Mobi"))>=0,sl=globalThis._VSCODE_NLS_LANGUAGE||ps,qa=navigator.language.toLowerCase(),hg=qa):console.error("Unable to resolve platform.");var sy=Md,vi=Td,T1=rl,fg=ry,yi=ni,Qi=sl,A1;(e=>{function t(){return Qi}e.value=t;function n(){return Qi.length===2?Qi==="en":Qi.length>=3?Qi[0]==="e"&&Qi[1]==="n"&&Qi[2]==="-":!1}e.isDefaultVariant=n;function s(){return Qi==="en"}e.isDefault=s})(A1||(A1={}));var I1=typeof Tr.postMessage=="function"&&!Tr.importScripts;(()=>{if(I1){let e=[];Tr.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}),Tr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var B1=!!(yi&&yi.indexOf("Chrome")>=0);yi&&yi.indexOf("Firefox")>=0;!B1&&yi&&yi.indexOf("Safari")>=0;yi&&yi.indexOf("Edg/")>=0;yi&&yi.indexOf("Android")>=0;var us=typeof navigator=="object"?navigator:{};fg||document.queryCommandSupported&&document.queryCommandSupported("copy")||us&&us.clipboard&&us.clipboard.writeText,fg||us&&us.clipboard&&us.clipboard.readText;var jh=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}},Eu=new jh,pg=new jh,mg=new jh,O1=new Array(230),oy;(e=>{function t(h){return Eu.keyCodeToStr(h)}e.toString=t;function n(h){return Eu.strToKeyCode(h)}e.fromString=n;function s(h){return pg.keyCodeToStr(h)}e.toUserSettingsUS=s;function o(h){return mg.keyCodeToStr(h)}e.toUserSettingsGeneral=o;function a(h){return pg.strToKeyCode(h)||mg.strToKeyCode(h)}e.fromUserSettings=a;function u(h){if(h>=98&&h<=113)return null;switch(h){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Eu.keyCodeToStr(h)}e.toElectronAccelerator=u})(oy||(oy={}));var z1=class ay{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 ay&&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 F1([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},F1=class{constructor(e){if(e.length===0)throw d1("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 $1(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return oy.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(Dd)switch(t){case 59:return 85;case 60:if(T1)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(vi)return 57;break}else if(P1&&(vi&&t===93||!vi&&t===92))return 57;return O1[t]||0}var H1=vi?256:2048,W1=512,U1=1024,K1=vi?2048:256,gg=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=$1(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|=H1),this.altKey&&(t|=W1),this.shiftKey&&(t|=U1),this.metaKey&&(t|=K1),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new z1(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},vg=new WeakMap;function q1(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 V1=class{static getSameOriginWindowChain(e){let t=vg.get(e);if(!t){t=[],vg.set(e,t);let n=e,s;do s=q1(n),s?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=s;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,s=0,o=this.getSameOriginWindowChain(e);for(let a of o){let u=a.window.deref();if(n+=(u==null?void 0:u.scrollY)??0,s+=(u==null?void 0:u.scrollX)??0,u===t||!a.iframeElement)break;let h=a.iframeElement.getBoundingClientRect();n+=h.top,s+=h.left}return{top:n,left:s}}},Va=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=V1.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},_g=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(Ph){let a=navigator.userAgent.match(/Chrome\/(\d+)/);s=(a?parseInt(a[1]):123)<=122}if(e){let a=e,u=e,h=((o=e.view)==null?void 0:o.devicePixelRatio)||1;if(typeof a.wheelDeltaY<"u")s?this.deltaY=a.wheelDeltaY/(120*h):this.deltaY=a.wheelDeltaY/120;else if(typeof u.VERTICAL_AXIS<"u"&&u.axis===u.VERTICAL_AXIS)this.deltaY=-u.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Dd&&!vi?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof a.wheelDeltaX<"u")j1&&sy?this.deltaX=-(a.wheelDeltaX/120):s?this.deltaX=a.wheelDeltaX/(120*h):this.deltaX=a.wheelDeltaX/120;else if(typeof u.HORIZONTAL_AXIS<"u"&&u.axis===u.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Dd&&!vi?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},ly=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Y1;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof X1?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:an.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ly})})(Y1||(Y1={}));var X1=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?ly:(this._emitter||(this._emitter=new Ce),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Lh=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 Ed("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Ed("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},G1=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 Ed("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=Ct(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},J1;(e=>{async function t(s){let o,a=await Promise.all(s.map(u=>u.then(h=>h,h=>{o||(o=h)})));if(typeof o<"u")throw o;return a}e.settled=t;function n(s){return new Promise(async(o,a)=>{try{await s(o,a)}catch(u){a(u)}})}e.withAsyncBody=n})(J1||(J1={}));var yg=class qn{static fromArray(t){return new qn(n=>{n.emitMany(t)})}static fromPromise(t){return new qn(async n=>{n.emitMany(await t)})}static fromPromises(t){return new qn(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new qn(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 Ce,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 an.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 qn(async s=>{for await(let o of t)s.emitOne(n(o))})}map(t){return qn.map(this,t)}static filter(t,n){return new qn(async s=>{for await(let o of t)n(o)&&s.emitOne(o)})}filter(t){return qn.filter(this,t)}static coalesce(t){return qn.filter(t,n=>!!n)}coalesce(){return qn.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return qn.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};yg.EMPTY=yg.fromArray([]);var{getWindow:mi,getWindowId:Q1,onDidRegisterWindow:Z1}=(function(){let e=new Map,t={window:Pi,disposables:new lr};e.set(Pi.vscodeWindowId,t);let n=new Ce,s=new Ce,o=new Ce;function a(u,h){return(typeof u=="number"?e.get(u):void 0)??(h?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(u){if(e.has(u.vscodeWindowId))return Qe.None;let h=new lr,p={window:u,disposables:h.add(new lr)};return e.set(u.vscodeWindowId,p),h.add(Ct(()=>{e.delete(u.vscodeWindowId),s.fire(u)})),h.add(Ye(u,Gt.BEFORE_UNLOAD,()=>{o.fire(u)})),n.fire(p),h},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:a,getWindow(u){var f;let h=u;if((f=h==null?void 0:h.ownerDocument)!=null&&f.defaultView)return h.ownerDocument.defaultView.window;let p=u;return p!=null&&p.view?p.view.window:Pi},getDocument(u){return mi(u).document}}})(),ek=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 Ye(e,t,n,s){return new ek(e,t,n,s)}var wg=function(e,t,n,s){return Ye(e,t,n,s)},Dh,tk=class extends G1{constructor(e){super(),this.defaultTarget=e&&mi(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Sg=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){il(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(Sg.sort),u.shift().execute();s.set(a,!1)};Dh=(a,u,h=0)=>{let p=Q1(a),f=new Sg(u,h),_=e.get(p);return _||(_=[],e.set(p,_)),_.push(f),n.get(p)||(n.set(p,!0),a.requestAnimationFrame(()=>o(p))),f}})();function nk(e){let t=e.getBoundingClientRect(),n=mi(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Gt={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"},ik=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=Nn(t);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let n=Nn(t);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(t){let n=Nn(t);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(t){let n=Nn(t);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(t){let n=Nn(t);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(t){let n=Nn(t);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(t){let n=Nn(t);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(t){let n=Nn(t);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let n=Nn(t);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let n=Nn(t);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let n=Nn(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=Nn(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=Nn(t);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let n=Nn(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 Nn(e){return typeof e=="number"?`${e}px`:e}function xo(e){return new ik(e)}var cy=class{constructor(){this._hooks=new lr,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(Ct(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=mi(e)}this._hooks.add(Ye(a,Gt.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(Ye(a,Gt.POINTER_UP,u=>this.stopMonitoring(!0)))}};function rk(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 fi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(fi||(fi={}));var yo=class hn extends Qe{constructor(){super(),this.dispatched=!1,this.targets=new dg,this.ignoreTargets=new dg,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(an.runAndSubscribe(Z1,({window:t,disposables:n})=>{n.add(Ye(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Ye(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(Ye(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Pi,disposables:this._store}))}static addTarget(t){if(!hn.isTouchDevice())return Qe.None;hn.INSTANCE||(hn.INSTANCE=new hn);let n=hn.INSTANCE.targets.push(t);return Ct(n)}static ignoreTarget(t){if(!hn.isTouchDevice())return Qe.None;hn.INSTANCE||(hn.INSTANCE=new hn);let n=hn.INSTANCE.ignoreTargets.push(t);return Ct(n)}static isTouchDevice(){return"ontouchstart"in Pi||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(fi.Start,a.target);u.pageX=a.pageX,u.pageY=a.pageY,this.dispatchEvent(u)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let a=0,u=n.changedTouches.length;a<u;a++){let h=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(h.identifier))){console.warn("move of an UNKNOWN touch",h);continue}let p=this.activeTouches[h.identifier],f=Date.now()-p.initialTimeStamp;if(f<hn.HOLD_DELAY&&Math.abs(p.initialPageX-Mn(p.rollingPageX))<30&&Math.abs(p.initialPageY-Mn(p.rollingPageY))<30){let _=this.newGestureEvent(fi.Tap,p.initialTarget);_.pageX=Mn(p.rollingPageX),_.pageY=Mn(p.rollingPageY),this.dispatchEvent(_)}else if(f>=hn.HOLD_DELAY&&Math.abs(p.initialPageX-Mn(p.rollingPageX))<30&&Math.abs(p.initialPageY-Mn(p.rollingPageY))<30){let _=this.newGestureEvent(fi.Contextmenu,p.initialTarget);_.pageX=Mn(p.rollingPageX),_.pageY=Mn(p.rollingPageY),this.dispatchEvent(_)}else if(o===1){let _=Mn(p.rollingPageX),b=Mn(p.rollingPageY),y=Mn(p.rollingTimestamps)-p.rollingTimestamps[0],w=_-p.rollingPageX[0],S=b-p.rollingPageY[0],x=[...this.targets].filter(C=>p.initialTarget instanceof Node&&C.contains(p.initialTarget));this.inertia(t,x,s,Math.abs(w)/y,w>0?1:-1,_,Math.abs(S)/y,S>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(fi.End,p.initialTarget)),delete this.activeTouches[h.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===fi.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>hn.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===fi.Change||t.type===fi.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let o=0,a=t.initialTarget;for(;a&&a!==s;)o++,a=a.parentElement;n.push([o,s])}n.sort((s,o)=>s[0]-o[0]);for(let[s,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,o,a,u,h,p,f){this.handle=Dh(t,()=>{let _=Date.now(),b=_-s,y=0,w=0,S=!0;o+=hn.SCROLL_FRICTION*b,h+=hn.SCROLL_FRICTION*b,o>0&&(S=!1,y=a*o*b),h>0&&(S=!1,w=p*h*b);let x=this.newGestureEvent(fi.Change);x.translationX=y,x.translationY=w,n.forEach(C=>C.dispatchEvent(x)),S||this.inertia(t,n,_,o,a,u+y,h,p,f+w)})}onTouchMove(t){let n=Date.now();for(let s=0,o=t.changedTouches.length;s<o;s++){let a=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("end of an UNKNOWN touch",a);continue}let u=this.activeTouches[a.identifier],h=this.newGestureEvent(fi.Change,u.initialTarget);h.translationX=a.pageX-Mn(u.rollingPageX),h.translationY=a.pageY-Mn(u.rollingPageY),h.pageX=a.pageX,h.pageY=a.pageY,this.dispatchEvent(h),u.rollingPageX.length>3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(a.pageX),u.rollingPageY.push(a.pageY),u.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};yo.SCROLL_FRICTION=-.005,yo.HOLD_DELAY=700,yo.CLEAR_TAP_COUNT_TIME=400,Mt([rk],yo,"isTouchDevice",1);var sk=yo,Mh=class extends Qe{onclick(e,t){this._register(Ye(e,Gt.CLICK,n=>t(new Va(mi(e),n))))}onmousedown(e,t){this._register(Ye(e,Gt.MOUSE_DOWN,n=>t(new Va(mi(e),n))))}onmouseover(e,t){this._register(Ye(e,Gt.MOUSE_OVER,n=>t(new Va(mi(e),n))))}onmouseleave(e,t){this._register(Ye(e,Gt.MOUSE_LEAVE,n=>t(new Va(mi(e),n))))}onkeydown(e,t){this._register(Ye(e,Gt.KEY_DOWN,n=>t(new gg(n))))}onkeyup(e,t){this._register(Ye(e,Gt.KEY_UP,n=>t(new gg(n))))}oninput(e,t){this._register(Ye(e,Gt.INPUT,t))}onblur(e,t){this._register(Ye(e,Gt.BLUR,t))}onfocus(e,t){this._register(Ye(e,Gt.FOCUS,t))}onchange(e,t){this._register(Ye(e,Gt.CHANGE,t))}ignoreGesture(e){return sk.ignoreTarget(e)}},bg=11,ok=class extends Mh{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=bg+"px",this.domNode.style.height=bg+"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 cy),this._register(wg(this.bgDomNode,Gt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(wg(this.domNode,Gt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new tk),this._pointerdownScheduleRepeatTimer=this._register(new Lh)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,mi(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()}},ak=class Ad{constructor(t,n,s,o,a,u,h){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,o=o|0,a=a|0,u=u|0,h=h|0),this.rawScrollLeft=o,this.rawScrollTop=h,n<0&&(n=0),o+n>s&&(o=s-n),o<0&&(o=0),a<0&&(a=0),h+a>u&&(h=u-a),h<0&&(h=0),this.width=n,this.scrollWidth=s,this.scrollLeft=o,this.height=a,this.scrollHeight=u,this.scrollTop=h}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new Ad(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 Ad(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,a=this.scrollLeft!==t.scrollLeft,u=this.height!==t.height,h=this.scrollHeight!==t.scrollHeight,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:h,scrollTopChanged:p}}},lk=class extends Qe{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Ce),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new ak(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 xg(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=xg.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)))}},kg=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Nu(e,t){let n=t-e;return function(s){return e+n*dk(s)}}function ck(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var xg=class Id{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),ck(Nu(t,o),Nu(a,n),.33)}return Nu(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 kg(s,o,!1)}return new kg(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return Id.start(t,n,s)}static start(t,n,s){s=s+10;let o=Date.now()-10;return new Id(t,n,o,s)}};function uk(e){return Math.pow(e,3)}function dk(e){return 1-uk(1-e)}var hk=class extends Qe{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 Lh)}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":"")))}},fk=140,uy=class extends Mh{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 hk(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new cy),this._shouldRender=!0,this.domNode=xo(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Ye(this.domNode.domNode,Gt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new ok(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=xo(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(Ye(this.slider.domNode,Gt.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=nk(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(sy&&u>fk){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let h=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(h))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},dy=class Bd{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 Bd(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,o,a){let u=Math.max(0,s-t),h=Math.max(0,u-2*n),p=o>0&&o>s;if(!p)return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(h),computedSliderRatio:0,computedSliderPosition:0};let f=Math.round(Math.max(20,Math.floor(s*h/o))),_=(h-f)/(o-s),b=a*_;return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(f),computedSliderRatio:_,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=Bd._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)}},pk=class extends uy{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new dy(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}},mk=class extends uy{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new dy(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}},gk=500,Cg=50,vk=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Od=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(Ph){let n=mi(t.browserEvent),s=R1(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 vk(t,n,s);this._front===-1&&this._rear===-1?(this._memory[0]=a,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=a),a.score=this._computeScore(a,o)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let o=Math.abs(t.deltaX),a=Math.abs(t.deltaY),u=Math.abs(n.deltaX),h=Math.abs(n.deltaY),p=Math.max(Math.min(o,u),1),f=Math.max(Math.min(a,h),1),_=Math.max(o,u),b=Math.max(a,h);_%p===0&&b%f===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Od.INSTANCE=new Od;var _k=Od,yk=class extends Mh{constructor(e,t,n){super(),this._onScroll=this._register(new Ce),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Ce),this.onWillScroll=this._onWillScroll.event,this._options=Sk(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 mk(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new pk(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=xo(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=xo(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=xo(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,o=>this._onMouseOver(o)),this.onmouseleave(this._listenOnDomNode,o=>this._onMouseLeave(o)),this._hideTimeout=this._register(new Lh),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Ar(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,vi&&(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 _g(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Ar(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new _g(n))};this._mouseWheelToDispose.push(Ye(this._listenOnDomNode,Gt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=_k.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let a=e.deltaY*this._options.mouseWheelScrollSensitivity,u=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&u+a===0?u=a=0:Math.abs(a)>=Math.abs(u)?u=0:a=0),this._options.flipAxes&&([a,u]=[u,a]);let h=!vi&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!u&&(u=a,a=0),e.browserEvent&&e.browserEvent.altKey&&(u=u*this._options.fastScrollSensitivity,a=a*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),f={};if(a){let _=Cg*a,b=p.scrollTop-(_<0?Math.floor(_):Math.ceil(_));this._verticalScrollbar.writeScrollPosition(f,b)}if(u){let _=Cg*u,b=p.scrollLeft-(_<0?Math.floor(_):Math.ceil(_));this._horizontalScrollbar.writeScrollPosition(f,b)}f=this._scrollable.validateScrollPosition(f),(p.scrollLeft!==f.scrollLeft||p.scrollTop!==f.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(f):this._scrollable.setScrollPositionNow(f),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(),gk)}},wk=class extends yk{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 Sk(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,vi&&(t.className+=" mac"),t}var zd=class extends Qe{constructor(e,t,n,s,o,a,u,h){super(),this._bufferService=n,this._optionsService=u,this._renderService=h,this._onRequestScrollLines=this._register(new Ce),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new lk({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>Dh(s.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new wk(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(f=>{this._scrollableElement.updateOptions({handleMouseWheel:!(f&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(an.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Ct(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Ct(()=>this._styleElement.remove())),this._register(an.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(f=>this._handleScroll(f)))}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}};zd=Mt([Pe(2,_n),Pe(3,ji),Pe(4,K_),Pe(5,Cs),Pe(6,yn),Pe(7,Li)],zd);var Fd=class extends Qe{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(Ct(()=>{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()}};Fd=Mt([Pe(1,_n),Pe(2,ji),Pe(3,Do),Pe(4,Li)],Fd);var bk=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},Zi={full:0,left:0,center:0,right:0},lo={full:0,left:0,center:0,right:0},_l=class extends Qe{constructor(e,t,n,s,o,a,u,h){var f;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=o,this._optionsService=a,this._themeService=u,this._coreBrowserService=h,this._colorZoneStore=new bk,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(),(f=this._viewportElement.parentElement)==null||f.insertBefore(this._canvas,this._viewportElement),this._register(Ct(()=>{var _;return(_=this._canvas)==null?void 0:_.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Zi.full=this._canvas.width,Zi.left=e,Zi.center=t,Zi.right=e,this._refreshDrawHeightConstants(),lo.full=1,lo.left=1,lo.center=1+Zi.left,lo.right=1+Zi.left+Zi.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(lo[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ui[e.position||"full"]/2),Zi[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}))}};_l=Mt([Pe(2,_n),Pe(3,Do),Pe(4,Li),Pe(5,yn),Pe(6,Cs),Pe(7,ji)],_l);var fe;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
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=""))(fe||(fe={}));var ol;(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="Ÿ"))(ol||(ol={}));var hy;(e=>e.ST=`${fe.ESC}\\`)(hy||(hy={}));var $d=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(`${fe.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),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)}}};$d=Mt([Pe(2,_n),Pe(3,yn),Pe(4,Or),Pe(5,Li)],$d);var Jt=0,Qt=0,Zt=0,Dt=0,Eg={css:"#00000000",rgba:0},zt;(e=>{function t(o,a,u,h){return h!==void 0?`#${kr(o)}${kr(a)}${kr(u)}${kr(h)}`:`#${kr(o)}${kr(a)}${kr(u)}`}e.toCss=t;function n(o,a,u,h=255){return(o<<24|a<<16|u<<8|h)>>>0}e.toRgba=n;function s(o,a,u,h){return{css:e.toCss(o,a,u,h),rgba:e.toRgba(o,a,u,h)}}e.toColor=s})(zt||(zt={}));var bt;(e=>{function t(p,f){if(Dt=(f.rgba&255)/255,Dt===1)return{css:f.css,rgba:f.rgba};let _=f.rgba>>24&255,b=f.rgba>>16&255,y=f.rgba>>8&255,w=p.rgba>>24&255,S=p.rgba>>16&255,x=p.rgba>>8&255;Jt=w+Math.round((_-w)*Dt),Qt=S+Math.round((b-S)*Dt),Zt=x+Math.round((y-x)*Dt);let C=zt.toCss(Jt,Qt,Zt),k=zt.toRgba(Jt,Qt,Zt);return{css:C,rgba:k}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,f,_){let b=al.ensureContrastRatio(p.rgba,f.rgba,_);if(b)return zt.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=s;function o(p){let f=(p.rgba|255)>>>0;return[Jt,Qt,Zt]=al.toChannels(f),{css:zt.toCss(Jt,Qt,Zt),rgba:f}}e.opaque=o;function a(p,f){return Dt=Math.round(f*255),[Jt,Qt,Zt]=al.toChannels(p.rgba),{css:zt.toCss(Jt,Qt,Zt,Dt),rgba:zt.toRgba(Jt,Qt,Zt,Dt)}}e.opacity=a;function u(p,f){return Dt=p.rgba&255,a(p,Dt*f/255)}e.multiplyOpacity=u;function h(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=h})(bt||(bt={}));var jt;(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 Jt=parseInt(o.slice(1,2).repeat(2),16),Qt=parseInt(o.slice(2,3).repeat(2),16),Zt=parseInt(o.slice(3,4).repeat(2),16),zt.toColor(Jt,Qt,Zt);case 5:return Jt=parseInt(o.slice(1,2).repeat(2),16),Qt=parseInt(o.slice(2,3).repeat(2),16),Zt=parseInt(o.slice(3,4).repeat(2),16),Dt=parseInt(o.slice(4,5).repeat(2),16),zt.toColor(Jt,Qt,Zt,Dt);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 Jt=parseInt(a[1]),Qt=parseInt(a[2]),Zt=parseInt(a[3]),Dt=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),zt.toColor(Jt,Qt,Zt,Dt);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),[Jt,Qt,Zt,Dt]=t.getImageData(0,0,1,1).data,Dt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:zt.toRgba(Jt,Qt,Zt,Dt),css:o}}e.toColor=s})(jt||(jt={}));var gn;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,o,a){let u=s/255,h=o/255,p=a/255,f=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),_=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),b=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return f*.2126+_*.7152+b*.0722}e.relativeLuminance2=n})(gn||(gn={}));var al;(e=>{function t(u,h){if(Dt=(h&255)/255,Dt===1)return h;let p=h>>24&255,f=h>>16&255,_=h>>8&255,b=u>>24&255,y=u>>16&255,w=u>>8&255;return Jt=b+Math.round((p-b)*Dt),Qt=y+Math.round((f-y)*Dt),Zt=w+Math.round((_-w)*Dt),zt.toRgba(Jt,Qt,Zt)}e.blend=t;function n(u,h,p){let f=gn.relativeLuminance(u>>8),_=gn.relativeLuminance(h>>8);if(Ri(f,_)<p){if(_<f){let w=s(u,h,p),S=Ri(f,gn.relativeLuminance(w>>8));if(S<p){let x=o(u,h,p),C=Ri(f,gn.relativeLuminance(x>>8));return S>C?w:x}return w}let b=o(u,h,p),y=Ri(f,gn.relativeLuminance(b>>8));if(y<p){let w=s(u,h,p),S=Ri(f,gn.relativeLuminance(w>>8));return y>S?b:w}return b}}e.ensureContrastRatio=n;function s(u,h,p){let f=u>>24&255,_=u>>16&255,b=u>>8&255,y=h>>24&255,w=h>>16&255,S=h>>8&255,x=Ri(gn.relativeLuminance2(y,w,S),gn.relativeLuminance2(f,_,b));for(;x<p&&(y>0||w>0||S>0);)y-=Math.max(0,Math.ceil(y*.1)),w-=Math.max(0,Math.ceil(w*.1)),S-=Math.max(0,Math.ceil(S*.1)),x=Ri(gn.relativeLuminance2(y,w,S),gn.relativeLuminance2(f,_,b));return(y<<24|w<<16|S<<8|255)>>>0}e.reduceLuminance=s;function o(u,h,p){let f=u>>24&255,_=u>>16&255,b=u>>8&255,y=h>>24&255,w=h>>16&255,S=h>>8&255,x=Ri(gn.relativeLuminance2(y,w,S),gn.relativeLuminance2(f,_,b));for(;x<p&&(y<255||w<255||S<255);)y=Math.min(255,y+Math.ceil((255-y)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),x=Ri(gn.relativeLuminance2(y,w,S),gn.relativeLuminance2(f,_,b));return(y<<24|w<<16|S<<8|255)>>>0}e.increaseLuminance=o;function a(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=a})(al||(al={}));function kr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ri(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var kk=class extends Lo{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()]}},yl=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Yn}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],s=t.translateToString(!0),o=0,a=0,u=0,h=t.getFg(0),p=t.getBg(0);for(let f=0;f<t.getTrimmedLength();f++)if(t.loadCell(f,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==h||this._workCell.bg!==p){if(f-o>1){let _=this._getJoinedRanges(s,u,a,t,o);for(let b=0;b<_.length;b++)n.push(_[b])}o=f,u=a,h=this._workCell.fg,p=this._workCell.bg}a+=this._workCell.getChars().length||sr.length}if(this._bufferService.cols-o>1){let f=this._getJoinedRanges(s,u,a,t,o);for(let _=0;_<f.length;_++)n.push(f[_])}return n}_getJoinedRanges(e,t,n,s,o){let a=e.substring(t,n),u=[];try{u=this._characterJoiners[0].handler(a)}catch(h){console.error(h)}for(let h=1;h<this._characterJoiners.length;h++)try{let p=this._characterJoiners[h].handler(a);for(let f=0;f<p.length;f++)yl._mergeRanges(u,p[f])}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 h=n;h<this._bufferService.cols;h++){let p=t.getWidth(h),f=t.getString(h).length||sr.length;if(p!==0){if(!o&&u[0]<=a&&(u[0]=h,o=!0),u[1]<=a){if(u[1]=h,u=e[++s],!u)break;u[0]<=a?(u[0]=h,o=!0):o=!1}a+=f}}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}};yl=Mt([Pe(0,_n)],yl);function xk(e){return 57508<=e&&e<=57558}function Ck(e){return 9472<=e&&e<=9631}function Ek(e){return xk(e)||Ck(e)}function Nk(){return{css:{canvas:Ya(),cell:Ya()},device:{canvas:Ya(),cell:Ya(),char:{width:0,height:0,left:0,top:0}}}}function Ya(){return{width:0,height:0}}var Hd=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 Yn,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,s,o,a,u,h,p,f,_){let b=[],y=this._characterJoinerService.getJoinedCharacters(t),w=this._themeService.colors,S=e.getNoBgTrimmedLength();n&&S<a+1&&(S=a+1);let x,C=0,k="",N=0,I=0,D=0,X=0,V=!1,A=0,ne=!1,W=0,Z=0,U=[],H=f!==-1&&_!==-1;for(let j=0;j<S;j++){e.loadCell(j,this._workCell);let P=this._workCell.getWidth();if(P===0)continue;let T=!1,F=j>=Z,te=j,M=this._workCell;if(y.length>0&&j===y[0][0]&&F){let Fe=y.shift(),dt=this._isCellInSelection(Fe[0],t);for(N=Fe[0]+1;N<Fe[1];N++)F&&(F=dt===this._isCellInSelection(N,t));F&&(F=!n||a<Fe[0]||a>=Fe[1]),F?(T=!0,M=new kk(this._workCell,e.translateToString(!0,Fe[0],Fe[1]),Fe[1]-Fe[0]),te=Fe[1]-1,P=M.getWidth()):Z=Fe[1]}let ie=this._isCellInSelection(j,t),B=n&&j===a,L=H&&j>=f&&j<=_,z=!1;this._decorationService.forEachDecorationAtCell(j,t,void 0,Fe=>{z=!0});let G=M.getChars()||sr;if(G===" "&&(M.isUnderline()||M.isOverline())&&(G=" "),W=P*h-p.get(G,M.isBold(),M.isItalic()),!x)x=this._document.createElement("span");else if(C&&(ie&&ne||!ie&&!ne&&M.bg===I)&&(ie&&ne&&w.selectionForeground||M.fg===D)&&M.extended.ext===X&&L===V&&W===A&&!B&&!T&&!z&&F){M.isInvisible()?k+=sr:k+=G,C++;continue}else C&&(x.textContent=k),x=this._document.createElement("span"),C=0,k="";if(I=M.bg,D=M.fg,X=M.extended.ext,V=L,A=W,ne=ie,T&&a>=j&&a<=te&&(a=j),!this._coreService.isCursorHidden&&B&&this._coreService.isCursorInitialized){if(U.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&U.push("xterm-cursor-blink"),U.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":U.push("xterm-cursor-outline");break;case"block":U.push("xterm-cursor-block");break;case"bar":U.push("xterm-cursor-bar");break;case"underline":U.push("xterm-cursor-underline");break}}if(M.isBold()&&U.push("xterm-bold"),M.isItalic()&&U.push("xterm-italic"),M.isDim()&&U.push("xterm-dim"),M.isInvisible()?k=sr:k=M.getChars()||sr,M.isUnderline()&&(U.push(`xterm-underline-${M.extended.underlineStyle}`),k===" "&&(k=" "),!M.isUnderlineColorDefault()))if(M.isUnderlineColorRGB())x.style.textDecorationColor=`rgb(${Lo.toColorRGB(M.getUnderlineColor()).join(",")})`;else{let Fe=M.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&M.isBold()&&Fe<8&&(Fe+=8),x.style.textDecorationColor=w.ansi[Fe].css}M.isOverline()&&(U.push("xterm-overline"),k===" "&&(k=" ")),M.isStrikethrough()&&U.push("xterm-strikethrough"),L&&(x.style.textDecoration="underline");let oe=M.getFgColor(),de=M.getFgColorMode(),me=M.getBgColor(),Q=M.getBgColorMode(),q=!!M.isInverse();if(q){let Fe=oe;oe=me,me=Fe;let dt=de;de=Q,Q=dt}let pe,Ie,it=!1;this._decorationService.forEachDecorationAtCell(j,t,void 0,Fe=>{Fe.options.layer!=="top"&&it||(Fe.backgroundColorRGB&&(Q=50331648,me=Fe.backgroundColorRGB.rgba>>8&16777215,pe=Fe.backgroundColorRGB),Fe.foregroundColorRGB&&(de=50331648,oe=Fe.foregroundColorRGB.rgba>>8&16777215,Ie=Fe.foregroundColorRGB),it=Fe.options.layer==="top")}),!it&&ie&&(pe=this._coreBrowserService.isFocused?w.selectionBackgroundOpaque:w.selectionInactiveBackgroundOpaque,me=pe.rgba>>8&16777215,Q=50331648,it=!0,w.selectionForeground&&(de=50331648,oe=w.selectionForeground.rgba>>8&16777215,Ie=w.selectionForeground)),it&&U.push("xterm-decoration-top");let ze;switch(Q){case 16777216:case 33554432:ze=w.ansi[me],U.push(`xterm-bg-${me}`);break;case 50331648:ze=zt.toColor(me>>16,me>>8&255,me&255),this._addStyle(x,`background-color:#${Ng((me>>>0).toString(16),"0",6)}`);break;case 0:default:q?(ze=w.foreground,U.push("xterm-bg-257")):ze=w.background}switch(pe||M.isDim()&&(pe=bt.multiplyOpacity(ze,.5)),de){case 16777216:case 33554432:M.isBold()&&oe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(oe+=8),this._applyMinimumContrast(x,ze,w.ansi[oe],M,pe,void 0)||U.push(`xterm-fg-${oe}`);break;case 50331648:let Fe=zt.toColor(oe>>16&255,oe>>8&255,oe&255);this._applyMinimumContrast(x,ze,Fe,M,pe,Ie)||this._addStyle(x,`color:#${Ng(oe.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(x,ze,w.foreground,M,pe,Ie)||q&&U.push("xterm-fg-257")}U.length&&(x.className=U.join(" "),U.length=0),!B&&!T&&!z&&F?C++:x.textContent=k,W!==this.defaultSpacing&&(x.style.letterSpacing=`${W}px`),b.push(x),j=te}return x&&C&&(x.textContent=k),b}_applyMinimumContrast(e,t,n,s,o,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||Ek(s.getCode()))return!1;let u=this._getContrastCache(s),h;if(!o&&!a&&(h=u.getColor(t.rgba,n.rgba)),h===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);h=bt.ensureContrastRatio(o||t,a||n,p),u.setColor((o||t).rgba,(a||n).rgba,h??null)}return h?(this._addStyle(e,`color:${h.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e<s[0]&&t<=s[1]:e<n[0]&&t>=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t<s[1]||n[1]===s[1]&&t===n[1]&&e>=n[0]&&e<s[0]||n[1]<s[1]&&t===s[1]&&e<s[0]||n[1]<s[1]&&t===n[1]&&e>=n[0]}};Hd=Mt([Pe(1,Y_),Pe(2,yn),Pe(3,ji),Pe(4,Or),Pe(5,Do),Pe(6,Cs)],Hd);function Ng(e,t,n){for(;e.length<n;)e=t+e;return e}var Rk=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}},Pk=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,a=t[1]-o,u=n[1]-o,h=Math.max(a,0),p=Math.min(u,e.rows-1);if(h>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=a,this.viewportEndRow=u,this.viewportCappedStartRow=h,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 jk(){return new Pk}var Ru="xterm-dom-renderer-owner-",Kn="xterm-rows",Xa="xterm-fg-",Rg="xterm-bg-",co="xterm-focus",Ga="xterm-selection",Lk=1,Wd=class extends Qe{constructor(e,t,n,s,o,a,u,h,p,f,_,b,y,w){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=f,this._bufferService=_,this._coreService=b,this._coreBrowserService=y,this._themeService=w,this._terminalClass=Lk++,this._rowElements=[],this._selectionRenderModel=jk(),this.onRequestRedraw=this._register(new Ce).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Kn),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(Ga),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Nk(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(S=>this._injectCss(S))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance(Hd,document),this._element.classList.add(Ru+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(S=>this._handleLinkHover(S))),this._register(this._linkifier2.onHideLinkUnderline(S=>this._handleLinkLeave(S))),this._register(Ct(()=>{this._element.classList.remove(Ru+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Rk(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} .${Kn} 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} .${Kn} { 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} .${Kn} .xterm-dim { color: ${bt.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} .${Kn}.${co} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Kn}.${co} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Kn}.${co} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Kn} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Kn} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Kn} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Kn} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Kn} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ga} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ga} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ga} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[a,u]of e.ansi.entries())t+=`${this._terminalSelector} .${Xa}${a} { color: ${u.css}; }${this._terminalSelector} .${Xa}${a}.xterm-dim { color: ${bt.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${Rg}${a} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${Xa}257 { color: ${bt.opaque(e.background).css}; }${this._terminalSelector} .${Xa}257.xterm-dim { color: ${bt.multiplyOpacity(bt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Rg}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(co),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(co),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(n){let p=e[0]>t[0];h.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,f=a===o?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(a,p,f));let _=u-a-1;if(h.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,_)),a!==u){let b=o===u?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(u,0,b))}}this._selectionContainer.appendChild(h)}_createSelectionElement(e,t,n,s=1){let o=this._document.createElement("div"),a=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return a+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-a),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${a}px`,o.style.width=`${u}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,s=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let f=p+n.ydisp,_=this._rowElements[p],b=n.lines.get(f);if(!_||!b)break;_.replaceChildren(...this._rowFactory.createRow(b,f,f===s,u,h,o,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ru}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,o,a){n<0&&(e=0),s<0&&(t=0);let u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),s=Math.max(Math.min(s,u),0),o=Math.min(o,this._bufferService.cols);let h=this._bufferService.buffer,p=h.ybase+h.y,f=Math.min(h.x,o-1),_=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,y=this._optionsService.rawOptions.cursorInactiveStyle;for(let w=n;w<=s;++w){let S=w+h.ydisp,x=this._rowElements[w],C=h.lines.get(S);if(!x||!C)break;x.replaceChildren(...this._rowFactory.createRow(C,S,S===p,b,y,f,_,this.dimensions.css.cell.width,this._widthCache,a?w===n?e:0:-1,a?(w===s?t:o)-1:-1))}}};Wd=Mt([Pe(7,Eh),Pe(8,Rl),Pe(9,yn),Pe(10,_n),Pe(11,Or),Pe(12,ji),Pe(13,Cs)],Wd);var Ud=class extends Qe{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Ce),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Mk(this._optionsService))}catch{this._measureStrategy=this._register(new Dk(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())}};Ud=Mt([Pe(2,yn)],Ud);var fy=class extends Qe{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)}},Dk=class extends fy{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}},Mk=class extends fy{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}},Tk=class extends Qe{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 Ak(this._window)),this._onDprChange=this._register(new Ce),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Ce),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(an.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ye(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ye(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}},Ak=class extends Qe{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ss),this._onDprChange=this._register(new Ce),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Ct(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ye(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)}},Ik=class extends Qe{constructor(){super(),this.linkProviders=[],this._register(Ct(()=>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 Th(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 Bk(e,t,n,s,o,a,u,h,p){if(!a)return;let f=Th(e,t,n);if(f)return f[0]=Math.ceil((f[0]+(p?u/2:0))/u),f[1]=Math.ceil(f[1]/h),f[0]=Math.min(Math.max(f[0],1),s+(p?1:0)),f[1]=Math.min(Math.max(f[1],1),o),f}var Kd=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,o){return Bk(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=Th(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])}}};Kd=Mt([Pe(0,Li),Pe(1,Rl)],Kd);var Ok=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=[]}},py={};Y0(py,{getSafariVersion:()=>Fk,isChromeOS:()=>_y,isFirefox:()=>my,isIpad:()=>$k,isIphone:()=>Hk,isLegacyEdge:()=>zk,isLinux:()=>Ah,isMac:()=>wl,isNode:()=>Pl,isSafari:()=>gy,isWindows:()=>vy});var Pl=typeof process<"u"&&"title"in process,Mo=Pl?"node":navigator.userAgent,To=Pl?"node":navigator.platform,my=Mo.includes("Firefox"),zk=Mo.includes("Edge"),gy=/^((?!chrome|android).)*safari/i.test(Mo);function Fk(){if(!gy)return 0;let e=Mo.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var wl=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(To),$k=To==="iPad",Hk=To==="iPhone",vy=["Windows","Win16","Win32","WinCE"].includes(To),Ah=To.indexOf("Linux")>=0,_y=/\bCrOS\b/.test(Mo),yy=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()}},Wk=class extends yy{_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())}}},Uk=class extends yy{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Sl=!Pl&&"requestIdleCallback"in window?Uk:Wk,Kk=class{constructor(){this._queue=new Sl}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},qd=class extends Qe{constructor(e,t,n,s,o,a,u,h,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=o,this._coreBrowserService=h,this._renderer=this._register(new Ss),this._pausedResizeTask=new Kk,this._observerDisposable=this._register(new Ss),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 Ce),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Ce),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Ce),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Ce),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Ok((f,_)=>this._renderRows(f,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new qk(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Ct(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>{var f;return(f=this._renderer.value)==null?void 0:f.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(f=>this._registerIntersectionObserver(f,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=Ct(()=>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()}};qd=Mt([Pe(2,yn),Pe(3,Rl),Pe(4,Or),Pe(5,Do),Pe(6,_n),Pe(7,ji),Pe(8,Cs)],qd);var qk=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 Vk(e,t,n,s){let o=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return Gk(o,a,e,t,n,s)+jl(a,t,n,s)+Jk(o,a,e,t,n,s);let u;if(a===t)return u=o>e?"D":"C",No(Math.abs(o-e),Eo(u,s));u=a>t?"D":"C";let h=Math.abs(a-t),p=Xk(a>t?e:o,n)+(h-1)*n.cols+1+Yk(a>t?o:e);return No(p,Eo(u,s))}function Yk(e,t){return e-1}function Xk(e,t){return t.cols-e}function Gk(e,t,n,s,o,a){return jl(t,s,o,a).length===0?"":No(Sy(e,t,e,t-Ir(t,o),!1,o).length,Eo("D",a))}function jl(e,t,n,s){let o=e-Ir(e,n),a=t-Ir(t,n),u=Math.abs(o-a)-Qk(e,t,n);return No(u,Eo(wy(e,t),s))}function Jk(e,t,n,s,o,a){let u;jl(t,s,o,a).length>0?u=s-Ir(s,o):u=t;let h=s,p=Zk(e,t,n,s,o,a);return No(Sy(e,u,n,h,p==="C",o).length,Eo(p,a))}function Qk(e,t,n){var u;let s=0,o=e-Ir(e,n),a=t-Ir(t,n);for(let h=0;h<Math.abs(o-a);h++){let p=wy(e,t)==="A"?-1:1;(u=n.buffer.lines.get(o+p*h))!=null&&u.isWrapped&&s++}return s}function Ir(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 Zk(e,t,n,s,o,a){let u;return jl(n,s,o,a).length>0?u=s-Ir(s,o):u=t,e<n&&u<=s||e>=n&&u<s?"C":"D"}function wy(e,t){return e>t?"A":"B"}function Sy(e,t,n,s,o,a){let u=e,h=t,p="";for(;(u!==n||h!==s)&&h>=0&&h<a.buffer.lines.length;)u+=o?1:-1,o&&u>a.cols-1?(p+=a.buffer.translateBufferLineToString(h,!1,e,u),u=0,e=0,h++):!o&&u<0&&(p+=a.buffer.translateBufferLineToString(h,!1,0,e+1),u=a.cols-1,e=u,h--);return p+a.buffer.translateBufferLineToString(h,!1,e,u)}function Eo(e,t){let n=t?"O":"[";return fe.ESC+n+e}function No(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var ex=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 Pg(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 Pu=50,tx=15,nx=50,ix=500,rx=" ",sx=new RegExp(rx,"g"),Vd=class extends Qe{constructor(e,t,n,s,o,a,u,h,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=h,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Yn,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Ce),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Ce),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Ce),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Ce),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=f=>this._handleMouseMove(f),this._mouseUpListener=f=>this._handleMouseUp(f),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(f=>this._handleTrim(f)),this._register(this._bufferService.buffers.onBufferActivate(f=>this._handleBufferActivate(f))),this.enable(),this._model=new ex(this._bufferService),this._activeSelectionMode=0,this._register(Ct(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(f=>{f.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let u=e[1];u<=t[1];u++){let h=n.translateBufferLineToString(u,!0,o,a);s.push(h)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let a=e[1]+1;a<=t[1]-1;a++){let u=n.lines.get(a),h=n.translateBufferLineToString(a,!0);u!=null&&u.isWrapped?s[s.length-1]+=h:s.push(h)}if(e[1]!==t[1]){let a=n.lines.get(t[1]),u=n.translateBufferLineToString(t[1],!0,0,t[0]);a&&a.isWrapped?s[s.length-1]+=u:s.push(u)}}return s.map(o=>o.replace(sx," ")).join(vy?`\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())),Ah&&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=Pg(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=Th(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,-Pu),Pu),t/=Pu,t/Math.abs(t)+Math.round(t*(tx-1)))}shouldForceSelection(e){return wl?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(),nx)}_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&&!(wl&&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<ix&&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=Vk(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==s&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,a=o.lines.get(e[1]);if(!a)return;let u=o.translateBufferLineToString(e[1],!1),h=this._convertViewportColToCharacterIndex(a,e[0]),p=h,f=e[0]-h,_=0,b=0,y=0,w=0;if(u.charAt(h)===" "){for(;h>0&&u.charAt(h-1)===" ";)h--;for(;p<u.length&&u.charAt(p+1)===" ";)p++}else{let C=e[0],k=e[0];a.getWidth(C)===0&&(_++,C--),a.getWidth(k)===2&&(b++,k++);let N=a.getString(k).length;for(N>1&&(w+=N-1,p+=N-1);C>0&&h>0&&!this._isCharWordSeparator(a.loadCell(C-1,this._workCell));){a.loadCell(C-1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,C--):I>1&&(y+=I-1,h-=I-1),h--,C--}for(;k<a.length&&p+1<u.length&&!this._isCharWordSeparator(a.loadCell(k+1,this._workCell));){a.loadCell(k+1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,k++):I>1&&(w+=I-1,p+=I-1),p++,k++}}p++;let S=h+f-_+y,x=Math.min(this._bufferService.cols,p-h+_+b-y-w);if(!(!t&&u.slice(h,p).trim()==="")){if(n&&S===0&&a.getCodePoint(0)!==32){let C=o.lines.get(e[1]-1);if(C&&a.isWrapped&&C.getCodePoint(this._bufferService.cols-1)!==32){let k=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(k){let N=this._bufferService.cols-k.start;S-=N,x+=N}}}if(s&&S+x===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let C=o.lines.get(e[1]+1);if(C!=null&&C.isWrapped&&C.getCodePoint(0)!==32){let k=this._getWordAt([0,e[1]+1],!1,!1,!0);k&&(x+=k.length)}}return{start:S,length:x}}}_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=Pg(n,this._bufferService.cols)}};Vd=Mt([Pe(3,_n),Pe(4,Or),Pe(5,Nh),Pe(6,yn),Pe(7,Li),Pe(8,ji)],Vd);var jg=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={}}},Lg=class{constructor(){this._color=new jg,this._css=new jg}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()}},Wt=Object.freeze((()=>{let e=[jt.toColor("#2e3436"),jt.toColor("#cc0000"),jt.toColor("#4e9a06"),jt.toColor("#c4a000"),jt.toColor("#3465a4"),jt.toColor("#75507b"),jt.toColor("#06989a"),jt.toColor("#d3d7cf"),jt.toColor("#555753"),jt.toColor("#ef2929"),jt.toColor("#8ae234"),jt.toColor("#fce94f"),jt.toColor("#729fcf"),jt.toColor("#ad7fa8"),jt.toColor("#34e2e2"),jt.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:zt.toCss(s,o,a),rgba:zt.toRgba(s,o,a)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:zt.toCss(s,s,s),rgba:zt.toRgba(s,s,s)})}return e})()),Er=jt.toColor("#ffffff"),wo=jt.toColor("#000000"),Dg=jt.toColor("#ffffff"),Mg=wo,uo={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},ox=Er,Yd=class extends Qe{constructor(e){super(),this._optionsService=e,this._contrastCache=new Lg,this._halfContrastCache=new Lg,this._onChangeColors=this._register(new Ce),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Er,background:wo,cursor:Dg,cursorAccent:Mg,selectionForeground:void 0,selectionBackgroundTransparent:uo,selectionBackgroundOpaque:bt.blend(wo,uo),selectionInactiveBackgroundTransparent:uo,selectionInactiveBackgroundOpaque:bt.blend(wo,uo),scrollbarSliderBackground:bt.opacity(Er,.2),scrollbarSliderHoverBackground:bt.opacity(Er,.4),scrollbarSliderActiveBackground:bt.opacity(Er,.5),overviewRulerBorder:Er,ansi:Wt.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=ft(e.foreground,Er),t.background=ft(e.background,wo),t.cursor=bt.blend(t.background,ft(e.cursor,Dg)),t.cursorAccent=bt.blend(t.background,ft(e.cursorAccent,Mg)),t.selectionBackgroundTransparent=ft(e.selectionBackground,uo),t.selectionBackgroundOpaque=bt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=ft(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=bt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?ft(e.selectionForeground,Eg):void 0,t.selectionForeground===Eg&&(t.selectionForeground=void 0),bt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=bt.opacity(t.selectionBackgroundTransparent,.3)),bt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=bt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=ft(e.scrollbarSliderBackground,bt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=ft(e.scrollbarSliderHoverBackground,bt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=ft(e.scrollbarSliderActiveBackground,bt.opacity(t.foreground,.5)),t.overviewRulerBorder=ft(e.overviewRulerBorder,ox),t.ansi=Wt.slice(),t.ansi[0]=ft(e.black,Wt[0]),t.ansi[1]=ft(e.red,Wt[1]),t.ansi[2]=ft(e.green,Wt[2]),t.ansi[3]=ft(e.yellow,Wt[3]),t.ansi[4]=ft(e.blue,Wt[4]),t.ansi[5]=ft(e.magenta,Wt[5]),t.ansi[6]=ft(e.cyan,Wt[6]),t.ansi[7]=ft(e.white,Wt[7]),t.ansi[8]=ft(e.brightBlack,Wt[8]),t.ansi[9]=ft(e.brightRed,Wt[9]),t.ansi[10]=ft(e.brightGreen,Wt[10]),t.ansi[11]=ft(e.brightYellow,Wt[11]),t.ansi[12]=ft(e.brightBlue,Wt[12]),t.ansi[13]=ft(e.brightMagenta,Wt[13]),t.ansi[14]=ft(e.brightCyan,Wt[14]),t.ansi[15]=ft(e.brightWhite,Wt[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]=ft(e.extendedAnsi[s],Wt[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()}}};Yd=Mt([Pe(0,yn)],Yd);function ft(e,t){if(e!==void 0)try{return jt.toColor(e)}catch{}return t}var ax=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)}},lx=class{constructor(){this._services=new ax,this._services.set(Eh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=t1(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)}},cx={trace:0,debug:1,info:2,warn:3,error:4,off:5},ux="xterm.js: ",Xd=class extends Qe{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=cx[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?"":ux)+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)}};Xd=Mt([Pe(0,yn)],Xd);var Tg=class extends Qe{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Ce),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Ce),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Ce),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}},Je=3,Ot=Object.freeze(new Lo),Ja=0,ju=2,So=class by{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Je);let o=n||Yn.fromCharData([0,$_,1,0]);for(let a=0;a<t;++a)this.setCell(a,o);this.length=t}get(t){let n=this._data[t*Je+0],s=n&2097151;return[this._data[t*Je+1],n&2097152?this._combined[t]:s?nr(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*Je+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Je+0]=t|2097152|n[2]<<22):this._data[t*Je+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Je+0]>>22}hasWidth(t){return this._data[t*Je+0]&12582912}getFg(t){return this._data[t*Je+1]}getBg(t){return this._data[t*Je+2]}hasContent(t){return this._data[t*Je+0]&4194303}getCodePoint(t){let n=this._data[t*Je+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Je+0]&2097152}getString(t){let n=this._data[t*Je+0];return n&2097152?this._combined[t]:n&2097151?nr(n&2097151):""}isProtected(t){return this._data[t*Je+2]&536870912}loadCell(t,n){return Ja=t*Je,n.content=this._data[Ja+0],n.fg=this._data[Ja+1],n.bg=this._data[Ja+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*Je+0]=n.content,this._data[t*Je+1]=n.fg,this._data[t*Je+2]=n.bg}setCellFromCodepoint(t,n,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*Je+0]=n|s<<22,this._data[t*Je+1]=o.fg,this._data[t*Je+2]=o.bg}addCodepointToCell(t,n,s){let o=this._data[t*Je+0];o&2097152?this._combined[t]+=nr(n):o&2097151?(this._combined[t]=nr(o&2097151)+nr(n),o&=-2097152,o|=2097152):o=n|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*Je+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 Yn;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 Yn;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*ju<this._data.buffer.byteLength;let s=t*Je;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let u=0;u<o.length;u++){let h=parseInt(o[u],10);h>=t&&delete this._combined[h]}let a=Object.keys(this._extendedAttrs);for(let u=0;u<a.length;u++){let h=parseInt(a[u],10);h>=t&&delete this._extendedAttrs[h]}}return this.length=t,s*4*ju<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*ju<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 by(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*Je+0]&4194303)return t+(this._data[t*Je+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Je+0]&4194303||this._data[t*Je+2]&50331648)return t+(this._data[t*Je+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 f=0;f<Je;f++)this._data[(s+p)*Je+f]=u[(n+p)*Je+f];u[(n+p)*Je+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[n+p])}else for(let p=0;p<o;p++){for(let f=0;f<Je;f++)this._data[(s+p)*Je+f]=u[(n+p)*Je+f];u[(n+p)*Je+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[n+p])}let h=Object.keys(t._combined);for(let p=0;p<h.length;p++){let f=parseInt(h[p],10);f>=n&&(this._combined[f-n+s]=t._combined[f])}}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*Je+0],h=u&2097151,p=u&2097152?this._combined[n]:h?nr(h):sr;if(a+=p,o)for(let f=0;f<p.length;++f)o.push(n);n+=u>>22||1}return o&&o.push(n),a}};function dx(e,t,n,s,o,a){let u=[];for(let h=0;h<e.length-1;h++){let p=h,f=e.get(++p);if(!f.isWrapped)continue;let _=[e.get(h)];for(;p<e.length&&f.isWrapped;)_.push(f),f=e.get(++p);if(!a&&s>=h&&s<p){h+=_.length-1;continue}let b=0,y=Ro(_,b,t),w=1,S=0;for(;w<_.length;){let C=Ro(_,w,t),k=C-S,N=n-y,I=Math.min(k,N);_[b].copyCellsFrom(_[w],S,y,I,!1),y+=I,y===n&&(b++,y=0),S+=I,S===C&&(w++,S=0),y===0&&b!==0&&_[b-1].getWidth(n-1)===2&&(_[b].copyCellsFrom(_[b-1],n-1,y++,1,!1),_[b-1].setCell(n-1,o))}_[b].replaceCells(y,n,o);let x=0;for(let C=_.length-1;C>0&&(C>b||_[C].getTrimmedLength()===0);C--)x++;x>0&&(u.push(h+_.length-x),u.push(x)),h+=_.length-1}return u}function hx(e,t){let n=[],s=0,o=t[s],a=0;for(let u=0;u<e.length;u++)if(o===u){let h=t[++s];e.onDeleteEmitter.fire({index:u-a,amount:h}),u+=h-1,a+=h,o=t[++s]}else n.push(u);return{layout:n,countRemoved:a}}function fx(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 px(e,t,n){let s=[],o=e.map((p,f)=>Ro(e,f,t)).reduce((p,f)=>p+f),a=0,u=0,h=0;for(;h<o;){if(o-h<n){s.push(o-h);break}a+=n;let p=Ro(e,u,t);a>p&&(a-=p,u++);let f=e[u].getWidth(a-1)===2;f&&a--;let _=f?n-1:n;s.push(_),h+=_}return s}function Ro(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 ky=class xy{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=xy._nextId++,this._onDispose=this.register(new Ce),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Ar(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};ky._nextId=1;var mx=ky,Kt={},Nr=Kt.B;Kt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Kt.A={"#":"£"};Kt.B=void 0;Kt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Kt.C=Kt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Kt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Kt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Kt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Kt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Kt.E=Kt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Kt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Kt.H=Kt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Kt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Ag=4294967295,Ig=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=Ot.clone(),this.savedCharset=Nr,this.markers=[],this._nullCell=Yn.fromCharData([0,$_,1,0]),this._whitespaceCell=Yn.fromCharData([0,sr,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Sl,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Tg(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 vl),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 vl),this._whitespaceCell}getBlankLine(e,t){return new So(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>Ag?Ag:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ot);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 Tg(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ot),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 So(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 So(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=dx(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ot),n);if(s.length>0){let o=hx(this.lines,s);fx(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(Ot),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new So(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(Ot),o=[],a=0;for(let u=this.lines.length-1;u>=0;u--){let h=this.lines.get(u);if(!h||!h.isWrapped&&h.getTrimmedLength()<=e)continue;let p=[h];for(;h.isWrapped&&u>0;)h=this.lines.get(--u),p.unshift(h);if(!n){let I=this.ybase+this.y;if(I>=u&&I<u+p.length)continue}let f=p[p.length-1].getTrimmedLength(),_=px(p,this._cols,e),b=_.length-p.length,y;this.ybase===0&&this.y!==this.lines.length-1?y=Math.max(0,this.y-this.lines.maxLength+b):y=Math.max(0,this.lines.length-this.lines.maxLength+b);let w=[];for(let I=0;I<b;I++){let D=this.getBlankLine(Ot,!0);w.push(D)}w.length>0&&(o.push({start:u+p.length+a,newLines:w}),a+=w.length),p.push(...w);let S=_.length-1,x=_[S];x===0&&(S--,x=_[S]);let C=p.length-b-1,k=f;for(;C>=0;){let I=Math.min(k,x);if(p[S]===void 0)break;if(p[S].copyCellsFrom(p[C],k-I,x-I,I,!0),x-=I,x===0&&(S--,x=_[S]),k-=I,k===0){C--;let D=Math.max(C,0);k=Ro(p,D,this._cols)}}for(let I=0;I<p.length;I++)_[I]<e&&p[I].setCell(_[I],s);let N=b-y;for(;N-- >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+b,this.ybase+t-1)}if(o.length>0){let u=[],h=[];for(let x=0;x<this.lines.length;x++)h.push(this.lines.get(x));let p=this.lines.length,f=p-1,_=0,b=o[_];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let y=0;for(let x=Math.min(this.lines.maxLength-1,p+a-1);x>=0;x--)if(b&&b.start>f+y){for(let C=b.newLines.length-1;C>=0;C--)this.lines.set(x--,b.newLines[C]);x++,u.push({index:f+1,amount:b.newLines.length}),y+=b.newLines.length,b=o[++_]}else this.lines.set(x,h[f--]);let w=0;for(let x=u.length-1;x>=0;x--)u[x].index+=w,this.lines.onInsertEmitter.fire(u[x]),w+=u[x].amount;let S=Math.max(0,p+a-this.lines.maxLength);S>0&&this.lines.onTrimEmitter.fire(S)}}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 mx(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)}},gx=class extends Qe{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Ce),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 Ig(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Ig(!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)}},Cy=2,Ey=1,Gd=class extends Qe{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Ce),this.onResize=this._onResize.event,this._onScroll=this._register(new Ce),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Cy),this.rows=Math.max(e.rawOptions.rows||0,Ey),this.buffers=this._register(new gx(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))}};Gd=Mt([Pe(0,yn)],Gd);var ds={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:wl,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},vx=["normal","bold","100","200","300","400","500","600","700","800","900"],_x=class extends Qe{constructor(e){super(),this._onOptionChange=this._register(new Ce),this.onOptionChange=this._onOptionChange.event;let t={...ds};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(Ct(()=>{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 ds))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in ds))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=ds[e]),!yx(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=ds[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=vx.includes(t)?t:ds[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 yx(e){return e==="block"||e==="underline"||e==="bar"}function bo(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]&&bo(e[s],t-1);return n}var Bg=Object.freeze({insertMode:!1}),Og=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Jd=class extends Qe{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 Ce),this.onData=this._onData.event,this._onUserInput=this._register(new Ce),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Ce),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Ce),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=bo(Bg),this.decPrivateModes=bo(Og)}reset(){this.modes=bo(Bg),this.decPrivateModes=bo(Og)}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))}};Jd=Mt([Pe(0,_n),Pe(1,q_),Pe(2,yn)],Jd);var zg={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 Lu(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 Du=String.fromCharCode,Fg={DEFAULT:e=>{let t=[Lu(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Du(t[0])}${Du(t[1])}${Du(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Lu(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Lu(e,!0)};${e.x};${e.y}${t}`}},Qd=class extends Qe{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 Ce),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(zg))this.addProtocol(s,zg[s]);for(let s of Object.keys(Fg))this.addEncoding(s,Fg[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)}};Qd=Mt([Pe(0,_n),Pe(1,Or),Pe(2,yn)],Qd);var Mu=[[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]],wx=[[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]],Ut;function Sx(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 bx=class{constructor(){if(this.version="6",!Ut){Ut=new Uint8Array(65536),Ut.fill(1),Ut[0]=0,Ut.fill(0,1,32),Ut.fill(0,127,160),Ut.fill(2,4352,4448),Ut[9001]=2,Ut[9002]=2,Ut.fill(2,11904,42192),Ut[12351]=1,Ut.fill(2,44032,55204),Ut.fill(2,63744,64256),Ut.fill(2,65040,65050),Ut.fill(2,65072,65136),Ut.fill(2,65280,65377),Ut.fill(2,65504,65511);for(let e=0;e<Mu.length;++e)Ut.fill(0,Mu[e][0],Mu[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ut[e]:Sx(e,wx)?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=jr.extractWidth(t);o===0?s=!1:o>n&&(n=o)}return jr.createPropertyValue(0,n,s)}},jr=class ll{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Ce,this.onChange=this._onChange.event;let t=new bx;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 f=t.charCodeAt(a);56320<=f&&f<=57343?u=(u-55296)*1024+f-56320+65536:n+=this.wcwidth(f)}let h=this.charProperties(u,s),p=ll.extractWidth(h);ll.extractShouldJoin(h)&&(p-=ll.extractWidth(s)),n+=p,s=h}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},kx=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 $g(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 ho=2147483647,xx=256,Ny=class Zd{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>xx)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 Zd;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 Zd(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>ho?ho: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>ho?ho: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,ho):t}},fo=[],Cx=class{constructor(){this._state=0,this._active=fo,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=fo}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=fo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||fo,!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",Nl(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=fo,this._id=-1,this._state=0}}},Tn=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+=Nl(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}},po=[],Ex=class{constructor(){this._handlers=Object.create(null),this._active=po,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=po}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=po,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||po,!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",Nl(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=po,this._ident=0}},ko=new Ny;ko.addParam(0);var Hg=class{constructor(e){this._handler=e,this._data="",this._params=ko,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ko,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Nl(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=ko,this._data="",this._hitLimit=!1,n));return this._params=ko,this._data="",this._hitLimit=!1,t}},Nx=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}},Vn=160,Rx=(function(){let e=new Nx(4095),t=Array.apply(null,Array(256)).map((h,p)=>p),n=(h,p)=>t.slice(h,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(Vn,0,2,0),e.add(Vn,8,5,8),e.add(Vn,6,0,6),e.add(Vn,11,0,11),e.add(Vn,13,13,13),e})(),Px=class extends Qe{constructor(e=Rx){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 Ny,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(Ct(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Cx),this._dcsParser=this._register(new Ex),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let a=e.intermediates.charCodeAt(o);if(32>a||a>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=a}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,n){let s=0,o=0,a=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let h=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&p>-1){for(;p>=0&&(u=h[p](this._params),u!==!0);p--)if(u instanceof Promise)return this._parseStack.handlerPos=p,u}this._parseStack.handlers=[];break;case 4:if(n===!1&&p>-1){for(;p>=0&&(u=h[p](),u!==!0);p--)if(u instanceof Promise)return this._parseStack.handlerPos=p,u}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(s!==24&&s!==26,n),u)return u;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],u=this._oscParser.end(s!==24&&s!==26,n),u)return u;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let h=a;h<t;++h){switch(s=e[h],o=this._transitions.table[this.currentState<<8|(s<160?s:Vn)],o>>4){case 2:for(let y=h+1;;++y){if(y>=t||(s=e[y])<32||s>126&&s<Vn){this._printHandler(e,h,y),h=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<Vn){this._printHandler(e,h,y),h=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<Vn){this._printHandler(e,h,y),h=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<Vn){this._printHandler(e,h,y),h=y-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:h,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let p=this._csiHandlers[this._collect<<8|s],f=p?p.length-1:-1;for(;f>=0&&(u=p[f](this._params),u!==!0);f--)if(u instanceof Promise)return this._preserveStack(3,p,f,o,h),u;f<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++h<t&&(s=e[h])>47&&s<60);h--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let _=this._escHandlers[this._collect<<8|s],b=_?_.length-1:-1;for(;b>=0&&(u=_[b](),u!==!0);b--)if(u instanceof Promise)return this._preserveStack(4,_,b,o,h),u;b<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let y=h+1;;++y)if(y>=t||(s=e[y])===24||s===26||s===27||s>127&&s<Vn){this._dcsParser.put(e,h,y),h=y-1;break}break;case 14:if(u=this._dcsParser.unhook(s!==24&&s!==26),u)return this._preserveStack(6,[],0,o,h),u;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let y=h+1;;y++)if(y>=t||(s=e[y])<32||s>127&&s<Vn){this._oscParser.put(e,h,y),h=y-1;break}break;case 6:if(u=this._oscParser.end(s!==24&&s!==26),u)return this._preserveStack(5,[],0,o,h),u;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},jx=/^([\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})$/,Lx=/^[\da-f]+$/;function Wg(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=jx.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),Lx.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 Tu(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 Dx(e,t=16){let[n,s,o]=e;return`rgb:${Tu(n,t)}/${Tu(s,t)}/${Tu(o,t)}`}var Mx={"(":0,")":1,"*":2,"+":3,"-":1,".":2},er=131072,Ug=10;function Kg(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 qg=5e3,Vg=0,Tx=class extends Qe{constructor(e,t,n,s,o,a,u,h,p=new Px){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=o,this._oscLinkService=a,this._coreMouseService=u,this._unicodeService=h,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Z0,this._utf8Decoder=new e1,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ot.clone(),this._eraseAttrDataInternal=Ot.clone(),this._onRequestBell=this._register(new Ce),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Ce),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Ce),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Ce),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Ce),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Ce),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Ce),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Ce),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Ce),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Ce),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Ce),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Ce),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Ce),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 eh(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,_)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:_.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,_,b)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:_,data:b})}),this._parser.setDcsHandlerFallback((f,_,b)=>{_==="HOOK"&&(b=b.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:_,payload:b})}),this._parser.setPrintHandler((f,_,b)=>this.print(f,_,b)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(fe.BEL,()=>this.bell()),this._parser.setExecuteHandler(fe.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(fe.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(fe.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(fe.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(fe.BS,()=>this.backspace()),this._parser.setExecuteHandler(fe.HT,()=>this.tab()),this._parser.setExecuteHandler(fe.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(fe.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ol.IND,()=>this.index()),this._parser.setExecuteHandler(ol.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ol.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Tn(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new Tn(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new Tn(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new Tn(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new Tn(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new Tn(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new Tn(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new Tn(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new Tn(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new Tn(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new Tn(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new Tn(f=>this.restoreCursorColor(f))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let f in Kt)this._parser.registerEscHandler({intermediates:"(",final:f},()=>this.selectCharset("("+f)),this._parser.registerEscHandler({intermediates:")",final:f},()=>this.selectCharset(")"+f)),this._parser.registerEscHandler({intermediates:"*",final:f},()=>this.selectCharset("*"+f)),this._parser.registerEscHandler({intermediates:"+",final:f},()=>this.selectCharset("+"+f)),this._parser.registerEscHandler({intermediates:"-",final:f},()=>this.selectCharset("-"+f)),this._parser.registerEscHandler({intermediates:".",final:f},()=>this.selectCharset("."+f)),this._parser.registerEscHandler({intermediates:"/",final:f},()=>this.selectCharset("/"+f));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(f=>(this._logService.error("Parsing error: ",f),f)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Hg((f,_)=>this.requestStatusString(f,_)))}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"),qg))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${qg} 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>er&&(a=this._parseStack.position+er)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,f=>String.fromCharCode(f)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(f=>f.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<er&&(this._parseBuffer=new Uint32Array(Math.min(e.length,er))),u||this._dirtyRowTracker.clearRange(),e.length>er)for(let f=a;f<e.length;f+=er){let _=f+er<e.length?f+er:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(f,_),this._parseBuffer):this._utf8Decoder.decode(e.subarray(f,_),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,b))return this._preserveStack(s,o,b,f),this._logSlowResolvingAsync(n),n}else if(!u){let f=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,f))return this._preserveStack(s,o,f,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let h=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),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(h,this._bufferService.rows-1)})}print(e,t,n){let s,o,a=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,h=this._bufferService.cols,p=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,_=this._curAttrData,b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&b.getWidth(this._activeBuffer.x-1)===2&&b.setCellFromCodepoint(this._activeBuffer.x-1,0,1,_);let y=this._parser.precedingJoinState;for(let w=t;w<n;++w){if(s=e[w],s<127&&a){let k=a[String.fromCharCode(s)];k&&(s=k.charCodeAt(0))}let S=this._unicodeService.charProperties(s,y);o=jr.extractWidth(S);let x=jr.extractShouldJoin(S),C=x?jr.extractWidth(y):0;if(y=S,u&&this._onA11yChar.fire(nr(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-C>h){if(p){let k=b,N=this._activeBuffer.x-C;for(this._activeBuffer.x=C,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),C>0&&b instanceof So&&b.copyCellsFrom(k,N,0,C,!1);N<h;)k.setCellFromCodepoint(N++,0,1,_)}else if(this._activeBuffer.x=h-1,o===2)continue}if(x&&this._activeBuffer.x){let k=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-k,s,o);for(let N=o-C;--N>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,_);continue}if(f&&(b.insertCells(this._activeBuffer.x,o-C,this._activeBuffer.getNullCell(_)),b.getWidth(h-1)===2&&b.setCellFromCodepoint(h-1,0,1,_)),b.setCellFromCodepoint(this._activeBuffer.x++,s,o,_),o>0)for(;--o;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,_)}this._parser.precedingJoinState=y,this._activeBuffer.x<h&&n-t>0&&b.getWidth(this._activeBuffer.x)===0&&!b.hasContent(this._activeBuffer.x)&&b.setCellFromCodepoint(this._activeBuffer.x,0,1,_),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>Kg(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Hg(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Tn(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(Ot));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=jr.extractWidth(t),o=this._activeBuffer.x-s,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(a.length*n),h=0;for(let f=0;f<a.length;){let _=a.codePointAt(f)||0;u[h++]=_,f+=_>65535?2:1}let p=h;for(let f=1;f<n;++f)u.copyWithin(p,0,h),p+=h;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(fe.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(fe.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(fe.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(fe.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(fe.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Nr),this._charsetService.setgCharset(1,Nr),this._charsetService.setgCharset(2,Nr),this._charsetService.setgCharset(3,Nr);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){(x=>(x[x.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",x[x.SET=1]="SET",x[x.RESET=2]="RESET",x[x.PERMANENTLY_SET=3]="PERMANENTLY_SET",x[x.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:a}=this._coreMouseService,u=this._coreService,{buffers:h,cols:p}=this._bufferService,{active:f,alt:_}=h,b=this._optionsService.rawOptions,y=(x,C)=>(u.triggerDataEvent(`${fe.ESC}[${t?"":"?"}${x};${C}$y`),!0),w=x=>x?1:2,S=e.params[0];return t?S===2?y(S,4):S===4?y(S,w(u.modes.insertMode)):S===12?y(S,3):S===20?y(S,w(b.convertEol)):y(S,0):S===1?y(S,w(s.applicationCursorKeys)):S===3?y(S,b.windowOptions.setWinLines?p===80?2:p===132?1:0:0):S===6?y(S,w(s.origin)):S===7?y(S,w(s.wraparound)):S===8?y(S,3):S===9?y(S,w(o==="X10")):S===12?y(S,w(b.cursorBlink)):S===25?y(S,w(!u.isCursorHidden)):S===45?y(S,w(s.reverseWraparound)):S===66?y(S,w(s.applicationKeypad)):S===67?y(S,4):S===1e3?y(S,w(o==="VT200")):S===1002?y(S,w(o==="DRAG")):S===1003?y(S,w(o==="ANY")):S===1004?y(S,w(s.sendFocus)):S===1005?y(S,4):S===1006?y(S,w(a==="SGR")):S===1015?y(S,4):S===1016?y(S,w(a==="SGR_PIXELS")):S===1048?y(S,1):S===47||S===1047||S===1049?y(S,w(f===_)):S===2004?y(S,w(s.bracketedPasteMode)):S===2026?y(S,w(s.synchronizedOutput)):y(S,0)}_updateAttrColor(e,t,n,s,o){return t===2?(e|=50331648,e&=-16777216,e|=Lo.fromColorRGB([n,s,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],o=0,a=0;do{if(s[a+o]=e.params[t+a],e.hasSubParams(t+a)){let u=e.getSubParams(t+a),h=0;do s[1]===5&&(o=1),s[a+h+1+o]=u[h];while(++h<u.length&&h+a+1+o<s.length);break}if(s[1]===5&&a+o>=2||s[1]===2&&a+o>=5)break;s[1]&&(o=1)}while(++a+t<e.length&&a+o<s.length);for(let u=2;u<s.length;++u)s[u]===-1&&(s[u]=0);switch(s[0]){case 38:n.fg=this._updateAttrColor(n.fg,s[1],s[3],s[4],s[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,s[1],s[3],s[4],s[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,s[1],s[3],s[4],s[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Ot.fg,e.bg=Ot.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|=Ot.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=Ot.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|=Ot.fg&16777215,s.bg&=-67108864,s.bg|=Ot.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${fe.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${fe.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(`${fe.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=Ot.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(!Kg(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${fe.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Ug&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Ug&&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(Yg(a))if(o==="?")t.push({type:0,index:a});else{let u=Wg(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=Wg(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]);Yg(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,Nr),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Mx[e[0]],Kt[e[1]]||Nr),!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=Ot.clone(),this._eraseAttrDataInternal=Ot.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 Yn;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(`${fe.ESC}${u}${fe.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)}},eh=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&&(Vg=e,e=t,t=Vg),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};eh=Mt([Pe(0,_n)],eh);function Yg(e){return 0<=e&&e<256}var Ax=5e7,Xg=12,Ix=50,Bx=class extends Qe{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 Ce),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>Ax)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let u=h=>performance.now()-n>=Xg?setTimeout(()=>this._innerWrite(0,h)):this._innerWrite(n,h);o.catch(h=>(queueMicrotask(()=>{throw h}),Promise.resolve(!1))).then(u);return}let a=this._callbacks[this._bufferOffset];if(a&&a(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=Xg)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Ix&&(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()}},th=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let h=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(p,h)),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)))}};th=Mt([Pe(0,_n)],th);var Gg=!1,Ox=class extends Qe{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ss),this._onBinary=this._register(new Ce),this.onBinary=this._onBinary.event,this._onData=this._register(new Ce),this.onData=this._onData.event,this._onLineFeed=this._register(new Ce),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Ce),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Ce),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Ce),this._instantiationService=new lx,this.optionsService=this._register(new _x(e)),this._instantiationService.setService(yn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Gd)),this._instantiationService.setService(_n,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Xd)),this._instantiationService.setService(q_,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Jd)),this._instantiationService.setService(Or,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Qd)),this._instantiationService.setService(K_,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(jr)),this._instantiationService.setService(r1,this.unicodeService),this._charsetService=this._instantiationService.createInstance(kx),this._instantiationService.setService(i1,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(th),this._instantiationService.setService(V_,this._oscLinkService),this._inputHandler=this._register(new Tx(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(an.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(an.forward(this._bufferService.onResize,this._onResize)),this._register(an.forward(this.coreService.onData,this._onData)),this._register(an.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 Bx((t,n)=>this._inputHandler.parse(t,n))),this._register(an.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Ce),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&&!Gg&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Gg=!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,Cy),t=Math.max(t,Ey),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($g.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>($g(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ct(()=>{for(let t of e)t.dispose()})}}},zx={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 Fx(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=fe.ESC+"OA":o.key=fe.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=fe.ESC+"OD":o.key=fe.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=fe.ESC+"OC":o.key=fe.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=fe.ESC+"OB":o.key=fe.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":fe.DEL,e.altKey&&(o.key=fe.ESC+o.key);break;case 9:if(e.shiftKey){o.key=fe.ESC+"[Z";break}o.key=fe.HT,o.cancel=!0;break;case 13:o.key=e.altKey?fe.ESC+fe.CR:fe.CR,o.cancel=!0;break;case 27:o.key=fe.ESC,e.altKey&&(o.key=fe.ESC+fe.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;a?o.key=fe.ESC+"[1;"+(a+1)+"D":t?o.key=fe.ESC+"OD":o.key=fe.ESC+"[D";break;case 39:if(e.metaKey)break;a?o.key=fe.ESC+"[1;"+(a+1)+"C":t?o.key=fe.ESC+"OC":o.key=fe.ESC+"[C";break;case 38:if(e.metaKey)break;a?o.key=fe.ESC+"[1;"+(a+1)+"A":t?o.key=fe.ESC+"OA":o.key=fe.ESC+"[A";break;case 40:if(e.metaKey)break;a?o.key=fe.ESC+"[1;"+(a+1)+"B":t?o.key=fe.ESC+"OB":o.key=fe.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=fe.ESC+"[2~");break;case 46:a?o.key=fe.ESC+"[3;"+(a+1)+"~":o.key=fe.ESC+"[3~";break;case 36:a?o.key=fe.ESC+"[1;"+(a+1)+"H":t?o.key=fe.ESC+"OH":o.key=fe.ESC+"[H";break;case 35:a?o.key=fe.ESC+"[1;"+(a+1)+"F":t?o.key=fe.ESC+"OF":o.key=fe.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=fe.ESC+"[5;"+(a+1)+"~":o.key=fe.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=fe.ESC+"[6;"+(a+1)+"~":o.key=fe.ESC+"[6~";break;case 112:a?o.key=fe.ESC+"[1;"+(a+1)+"P":o.key=fe.ESC+"OP";break;case 113:a?o.key=fe.ESC+"[1;"+(a+1)+"Q":o.key=fe.ESC+"OQ";break;case 114:a?o.key=fe.ESC+"[1;"+(a+1)+"R":o.key=fe.ESC+"OR";break;case 115:a?o.key=fe.ESC+"[1;"+(a+1)+"S":o.key=fe.ESC+"OS";break;case 116:a?o.key=fe.ESC+"[15;"+(a+1)+"~":o.key=fe.ESC+"[15~";break;case 117:a?o.key=fe.ESC+"[17;"+(a+1)+"~":o.key=fe.ESC+"[17~";break;case 118:a?o.key=fe.ESC+"[18;"+(a+1)+"~":o.key=fe.ESC+"[18~";break;case 119:a?o.key=fe.ESC+"[19;"+(a+1)+"~":o.key=fe.ESC+"[19~";break;case 120:a?o.key=fe.ESC+"[20;"+(a+1)+"~":o.key=fe.ESC+"[20~";break;case 121:a?o.key=fe.ESC+"[21;"+(a+1)+"~":o.key=fe.ESC+"[21~";break;case 122:a?o.key=fe.ESC+"[23;"+(a+1)+"~":o.key=fe.ESC+"[23~";break;case 123:a?o.key=fe.ESC+"[24;"+(a+1)+"~":o.key=fe.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=fe.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=fe.DEL:e.keyCode===219?o.key=fe.ESC:e.keyCode===220?o.key=fe.FS:e.keyCode===221&&(o.key=fe.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let h=(u=zx[e.keyCode])==null?void 0:u[e.shiftKey?1:0];if(h)o.key=fe.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,f=String.fromCharCode(p);e.shiftKey&&(f=f.toUpperCase()),o.key=fe.ESC+f}else if(e.keyCode===32)o.key=fe.ESC+(e.ctrlKey?fe.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),o.key=fe.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=fe.US),e.key==="@"&&(o.key=fe.NUL));break}return o}var It=0,$x=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Sl,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Sl,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||(It=this._search(t),It===-1)||this._getKey(this._array[It])!==t)return!1;do if(this._array[It]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(It),!0;while(++It<this._array.length&&this._getKey(this._array[It])===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&&(It=this._search(e),!(It<0||It>=this._array.length)&&this._getKey(this._array[It])===e))do yield this._array[It];while(++It<this._array.length&&this._getKey(this._array[It])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(It=this._search(e),!(It<0||It>=this._array.length)&&this._getKey(this._array[It])===e))do t(this._array[It]);while(++It<this._array.length&&this._getKey(this._array[It])===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}},Au=0,Jg=0,Hx=class extends Qe{constructor(){super(),this._decorations=new $x(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new Ce),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Ce),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ct(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Wx(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=>{Au=o.options.x??0,Jg=Au+(o.options.width??1),e>=Au&&e<Jg&&(!n||(o.options.layer??"bottom")===n)&&s(o)})}},Wx=class extends lr{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Ce),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Ce),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=jt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=jt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Ux=1e3,Kx=class{constructor(e,t=Ux){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)}},Qg=20,bl=class extends Qe{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 Kx(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(Ye(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Ct(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Qg+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
65
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Qg+1&&(this._liveRegion.textContent+=Sd.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let o=e;o<=t;o++){let a=n.lines.get(n.ydisp+o),u=[],h=(a==null?void 0:a.translateToString(!0,void 0,void 0,u))||"",p=(n.ydisp+o+1).toString(),f=this._rowElements[o];f&&(h.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=h,this._rowColumns.set(f,u)),f.setAttribute("aria-posinset",p),f.setAttribute("aria-setsize",s),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),a=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===a||e.relatedTarget!==s)return;let u,h;if(t===0?(u=n,h=this._rowElements.pop(),this._rowContainer.removeChild(h)):(u=this._rowElements.shift(),h=n,this._rowContainer.removeChild(u)),u.removeEventListener("focus",this._topBoundaryFocusListener),h.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let 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 h;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:((h=s.textContent)==null?void 0:h.length)??0}),!this._rowContainer.contains(n.node))return;let o=({node:p,offset:f})=>{let _=p instanceof Text?p.parentNode:p,b=parseInt(_==null?void 0:_.getAttribute("aria-posinset"),10)-1;if(isNaN(b))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(_);if(!y)return console.warn("columns is null. Race condition?"),null;let w=f<y.length?y[f]:y.slice(-1)[0]+1;return w>=this._terminal.cols&&(++b,w=0),{row:b,column:w}},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})`}};bl=Mt([Pe(1,Eh),Pe(2,ji),Pe(3,Li)],bl);var nh=class extends Qe{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 Ce),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Ce),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Ct(()=>{var a;Ar(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(Ye(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ye(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ye(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ye(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s<n.length;s++){let o=n[s];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var s,o;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(a=>{a==null||a.forEach(u=>{u.link.dispose&&u.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[a,u]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(a)&&(n=this._checkLinkProviderResult(a,e,n)):u.provideLinks(e.y,h=>{var f,_;if(this._isMouseOut)return;let p=h==null?void 0:h.map(b=>({link:b}));(f=this._activeProviderReplies)==null||f.set(a,p),n=this._checkLinkProviderResult(a,e,n),((_=this._activeProviderReplies)==null?void 0:_.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let a=0;a<o.length;a++){let u=o[a],h=u.link.range.start.y<e?0:u.link.range.start.x,p=u.link.range.end.y>e?this._bufferService.cols:u.link.range.end.x;for(let f=h;f<=p;f++){if(n.has(f)){o.splice(a--,1);break}n.add(f)}}}}_checkLinkProviderResult(e,t,n){var a;if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),o=!1;for(let u=0;u<e;u++)(!this._activeProviderReplies.has(u)||this._activeProviderReplies.get(u))&&(o=!0);if(!o&&s){let u=s.find(h=>this._linkAtPosition(h.link,t));u&&(n=!0,this._handleNewLink(u))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let u=0;u<this._activeProviderReplies.size;u++){let h=(a=this._activeProviderReplies.get(u))==null?void 0:a.find(p=>this._linkAtPosition(p.link,t));if(h){n=!0,this._handleNewLink(h);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&qx(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,Ar(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}}};nh=Mt([Pe(1,Nh),Pe(2,Li),Pe(3,_n),Pe(4,X_)],nh);function qx(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 Vx=class extends Ox{constructor(e={}){super(e),this._linkifier=this._register(new Ss),this.browser=py,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ss),this._onCursorMove=this._register(new Ce),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Ce),this.onKey=this._onKey.event,this._onRender=this._register(new Ce),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Ce),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Ce),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Ce),this.onBell=this._onBell.event,this._onFocus=this._register(new Ce),this._onBlur=this._register(new Ce),this._onA11yCharEmitter=this._register(new Ce),this._onA11yTabEmitter=this._register(new Ce),this._onWillOpen=this._register(new Ce),this._setup(),this._decorationService=this._instantiationService.createInstance(Hx),this._instantiationService.setService(Do,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Ik),this._instantiationService.setService(X_,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(kd)),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(an.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(an.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(an.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(an.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Ct(()=>{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=bt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${fe.ESC}]${s};${Dx(o)}${hy.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(a=>a.ansi[t.index]=zt.toColor(...t.color));else{let a=n;this._themeService.modifyColors(u=>u[a]=zt.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(bl,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(fe.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){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(fe.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*o,u=this.buffer.y*this._renderService.dimensions.css.cell.height,h=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=u+"px",this.textarea.style.width=a+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ye(this.element,"copy",t=>{this.hasSelection()&&J0(t,this._selectionService)}));let e=t=>Q0(t,this.textarea,this.coreService,this.optionsService);this._register(Ye(this.textarea,"paste",e)),this._register(Ye(this.element,"paste",e)),my?this._register(Ye(this.element,"mousedown",t=>{t.button===2&&lg(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ye(this.element,"contextmenu",t=>{lg(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Ah&&this._register(Ye(this.element,"auxclick",t=>{t.button===1&&F_(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ye(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ye(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ye(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ye(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ye(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ye(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ye(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(Ye(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",wd.get()),_y||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(Tk,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ji,this._coreBrowserService),this._register(Ye(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(Ye(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Ud,this._document,this._helperContainer),this._instantiationService.setService(Rl,this._charSizeService),this._themeService=this._instantiationService.createInstance(Yd),this._instantiationService.setService(Cs,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(yl),this._instantiationService.setService(Y_,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(qd,this.rows,this.screenElement)),this._instantiationService.setService(Li,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($d,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Kd),this._instantiationService.setService(Nh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(nh,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(zd,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(Vd,this.element,this.screenElement,s)),this._instantiationService.setService(o1,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(an.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var a;this._selectionService.refresh(),(a=this._viewport)==null||a.queueSync()})),this._register(this._instantiationService.createInstance(Fd,this.screenElement)),this._register(Ye(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(bl,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_l,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_l,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Wd,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(a){var f,_,b,y,w;let u=e._mouseService.getMouseReportCoords(a,e.screenElement);if(!u)return!1;let h,p;switch(a.overrideType||a.type){case"mousemove":p=32,a.buttons===void 0?(h=3,a.button!==void 0&&(h=a.button<3?a.button:3)):h=a.buttons&1?0:a.buttons&4?1:a.buttons&2?2:3;break;case"mouseup":p=0,h=a.button<3?a.button:3;break;case"mousedown":p=1,h=a.button<3?a.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(a)===!1)return!1;let S=a.deltaY;if(S===0||e.coreMouseService.consumeWheelEvent(a,(y=(b=(_=(f=e._renderService)==null?void 0:f.dimensions)==null?void 0:_.device)==null?void 0:b.cell)==null?void 0:y.height,(w=e._coreBrowserService)==null?void 0:w.dpr)===0)return!1;p=S<0?0:1,h=4;break;default:return!1}return p===void 0||h===void 0||h>4?!1:e.coreMouseService.triggerMouseEvent({col:u.col,row:u.row,x:u.x,y:u.y,button:h,action:p,ctrl: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(Ye(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(Ye(t,"wheel",a=>{var u,h,p,f,_;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,(f=(p=(h=(u=e._renderService)==null?void 0:u.dimensions)==null?void 0:h.device)==null?void 0:p.cell)==null?void 0:f.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return this.cancel(a,!0);let b=fe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(a.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(b,!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){z_(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=Fx(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===fe.ETX||n.key===fe.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)&&(Yx(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(Ot));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(fe.ESC+"[I"):this.coreService.triggerDataEvent(fe.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${fe.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(`${fe.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function Yx(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Xx=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)}},Gx=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 Yn)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Zg=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 Gx(t)}getNullCell(){return new Yn}},Jx=class extends Qe{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Ce),this.onBufferChange=this._onBufferChange.event,this._normal=new Zg(this._core.buffers.normal,"normal"),this._alternate=new Zg(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)}},Qx=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)}},Zx=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}},eC=["cols","rows"],di=0,tC=class extends Qe{constructor(e){super(),this._core=this._register(new Vx(e)),this._addonManager=this._register(new Xx),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(eC.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 Qx(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Zx(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 Jx(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 wd.get()},set promptLabel(e){wd.set(e)},get tooMuchOutput(){return Sd.get()},set tooMuchOutput(e){Sd.set(e)}}}_verifyIntegers(...e){for(di of e)if(di===1/0||isNaN(di)||di%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(di of e)if(di&&(di===1/0||isNaN(di)||di%1!==0||di<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 nC=2,iC=1,rC=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 b;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:((b=this._terminal.options.overviewRuler)==null?void 0:b.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),a=window.getComputedStyle(this._terminal.element),u={top:parseInt(a.getPropertyValue("padding-top")),bottom:parseInt(a.getPropertyValue("padding-bottom")),right:parseInt(a.getPropertyValue("padding-right")),left:parseInt(a.getPropertyValue("padding-left"))},h=u.top+u.bottom,p=u.right+u.left,f=s-h,_=o-p-t;return{cols:Math.max(nC,Math.floor(_/e.css.cell.width)),rows:Math.max(iC,Math.floor(f/e.css.cell.height))}}};function sC(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function oC({session:e,node:t,token:n,cols:s,rows:o,readonly:a=!1,takeSize:u,focused:h,onData:p,onExit:f,onFiles:_,retryBaseMs:b=250}){const y=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!y)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const S=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${sC(t,n)}`;let x=null,C=!1,k=!1,N=null,I=0,D=h;const X=()=>{if(C||k||N)return;const A=Math.min(5e3,Math.max(0,b)*2**Math.min(I++,5));N=setTimeout(()=>{N=null,V()},A)},V=()=>{if(C||k)return;const A=new WebSocket(S);x=A,A.binaryType="arraybuffer",A.onopen=()=>{if(x!==A||C)return;I=0;const ne={type:"attach",session:e,token:n,cols:s,rows:o,readonly:a};u!==void 0&&(ne.takeSize=u),A.send(JSON.stringify(ne)),D!==void 0&&A.send(JSON.stringify({type:"focus",on:!!D}))},A.onmessage=ne=>{if(!(x!==A||C))if(typeof ne.data=="string"){let W;try{W=JSON.parse(ne.data)}catch{return}W.type==="exit"&&(k=!0,f&&f(W.code)),W.type==="files"&&_&&_(W)}else p&&p(new Uint8Array(ne.data))},A.onerror=()=>{if(x===A)try{A.close()}catch{}},A.onclose=ne=>{x!==A||C||k||[1e3,1002,4401,4404].includes(ne==null?void 0:ne.code)||X()}};return V(),{sendInput:A=>{if(!x||x.readyState!==1)return!1;try{return x.send(typeof A=="string"?new TextEncoder().encode(A):A),!0}catch{try{x.close()}catch{}return!1}},isReady:()=>!!x&&x.readyState===1,resize:(A,ne)=>{s=A,o=ne,(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"resize",cols:A,rows:ne}))},action:A=>{(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"action",name:A}))},focus:A=>{D=A,(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"focus",on:!!A}))},close:()=>{if(C=!0,N&&clearTimeout(N),N=null,x)try{x.close()}catch{}},get raw(){return x}}}async function ev(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 aC="\r";function lC(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 cC({isReady:e,paste:t,send:n}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:n(aC)!==!1}catch{return!1}}}function uC(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function dC(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}const hC=450,tv=8;function fC(e,t,n,s){return Math.abs(Number(n)-Number(e))>tv||Math.abs(Number(s)-Number(t))>tv}const pC=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function Iu(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 nv(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 mC(e,t=0,n=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=pC.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${n}-${t+1}.${o}`}async function Ry({files:e,token:t,session:n,node:s="",paste:o=!0,fetchImpl:a=en,onProgress:u=()=>{},now:h=Date.now()}={}){const p=Array.from(e||[]).filter(Boolean),f=[],_=[];if(!n||!p.length)return{paths:f,errors:_};const b=vn(s?String(s).split("/"):[]);for(let y=0;y<p.length;y+=1){const w=p[y],S=mC(w,y,h);u({index:y,total:p.length,name:S,state:"uploading"});try{const x=new FormData;x.append("session",n),x.append("paste",o?"true":"false"),x.append("file",w,S);const C=await a(`${b}/files/upload`,t,{method:"POST",body:x}),k=await C.json().catch(()=>({}));if(!C.ok||k.error)throw new Error(k.error||`HTTP ${C.status}`);f.push(k.path),u({index:y,total:p.length,name:S,state:"done",path:k.path})}catch(x){const C=String((x==null?void 0:x.message)||x);_.push({name:S,message:C}),u({index:y,total:p.length,name:S,state:"error",error:C})}}return{paths:f,errors:_}}const gC=420,vC=32;function _C(e){if(!e||typeof e!="object")return!1;const t=String(e.tagName||"").toLowerCase();return t==="textarea"||t==="input"||e.isContentEditable===!0}function Py({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(_C(a)&&typeof a.blur=="function")try{a.blur(),u=!0}catch{}return{blurred:u,apiRequested:o}}function jy(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 yC(e,t){if(!e||!e.textarea)return!1;jy(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 wC(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<=gC&&Math.hypot(n.x-t.x,n.y-t.y)<=vC?{open:!0,next:null}:{open:!1,next:n}}function Ly({session:e,node:t,token:n,readonly:s,takeSize:o,focused:a,sendRef:u,composerRef:h,actionRef:p,ctrlRef:f,setCtrlArmed:_,onFiles:b,fontSize:y=13,selectionMode:w=!1,onSelectionModeChange:S,keyboardGesture:x="double-tap"}){const C=R.useRef(null),k=R.useRef(null),N=R.useRef(y);N.current=y;const I=R.useRef(a);I.current=a;const D=R.useRef(w);D.current=w;const X=R.useRef(x);X.current=x;const[V,A]=R.useState(""),[ne,W]=R.useState(""),[Z,U]=R.useState(null),H=async()=>{var F,te,M,ie;const P=((te=(F=k.current)==null?void 0:F.term)==null?void 0:te.getSelection())||V;if(!P){W(g("copy-empty")),setTimeout(()=>W(""),1500);return}const T=await ev(P);W(g(T?"copied":"copy-manual")),T&&((ie=(M=k.current)==null?void 0:M.term)==null||ie.clearSelection(),S==null||S(!1)),setTimeout(()=>W(""),1800)},j=R.useRef(H);return j.current=H,R.useEffect(()=>{const P=k.current;P&&P.sock&&P.sock.focus&&P.sock.focus(!!a)},[a]),R.useEffect(()=>{const P=k.current;P&&(P.term.options.fontSize=y,P.fit.fit(),P.sock.resize(P.term.cols,P.term.rows))},[y]),R.useEffect(()=>{var P,T;(T=(P=k.current)==null?void 0:P.setKeyboardGesture)==null||T.call(P,x)},[x]),R.useEffect(()=>{var Di;const P=new tC({cursorBlink:!0,fontSize:N.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),T=new rC;P.loadAddon(T),P.open(C.current),T.fit();const F=new TextDecoder;let te=X.current==="single-tap",M=null;const ie=()=>{te=X.current==="single-tap",jy(P,X.current,te)},B=ve=>{X.current=ve,M=null,ie()},L=()=>X.current==="never"?!1:(te=!0,yC(P));ie();const z=P.textarea,G=()=>{X.current==="double-tap"&&ie()};z==null||z.addEventListener("blur",G);let oe;try{oe=oC({session:e,node:t,token:n,readonly:s,takeSize:o,focused:I.current,onFiles:b,cols:P.cols,rows:P.rows,onData:ve=>P.write(F.decode(ve)),onExit:()=>P.write(`\r
78
+ \x1B[33m[sessione finita]\x1B[0m\r
79
+ `)})}catch(ve){return P.write(`\r
80
+ \x1B[31m${ve.message}\x1B[0m\r
81
+ `),()=>P.dispose()}k.current={term:P,fit:T,sock:oe,setKeyboardGesture:B};let de=null;const me=P.onData(ve=>{if(s){de&&(de.ok=!1);return}if(!de&&f&&f.current&&ve.length===1){const ot=ve.charCodeAt(0);let yt=ot;ot>=97&&ot<=122?yt=ot-96:ot>=64&&ot<=95?yt=ot-64:ot===32&&(yt=0),ve=String.fromCharCode(yt),f.current=!1,_&&_(!1)}const Ze=oe.sendInput(ve);de&&(de.seen=!0,de.ok=de.ok&&Ze)});u&&(u.current=ve=>oe.sendInput(ve)),p&&(p.current=ve=>oe.action(ve)),h&&(h.current=cC({isReady:()=>!s&&oe.isReady(),paste:ve=>{const Ze={seen:!1,ok:!0};de=Ze;try{P.paste(ve)}catch{Ze.ok=!1}finally{de=null}return Ze.seen&&Ze.ok},send:ve=>oe.sendInput(ve)}));const Q=P.onSelectionChange(()=>A(P.getSelection()));P.attachCustomKeyEventHandler(ve=>(ve.ctrlKey||ve.metaKey)&&ve.key.toLowerCase()==="c"&&P.getSelection()?(ve.type==="keydown"&&ev(P.getSelection()),!1):!0);const q=C.current;let pe=!1;const Ie=async ve=>{if(!ve.length||pe)return;if(s){U({error:g("settings-readonly")});return}pe=!0,U({current:0,total:ve.length,name:""});const Ze=await Ry({files:ve,token:n,session:e,node:t,paste:!0,onProgress:({index:ot,total:yt,name:wn,state:ri,error:Bl})=>U({current:ot+1,total:yt,name:wn,...ri==="error"?{error:Bl}:{}})});pe=!1,Ze.errors.length?U({error:Ze.errors.map(ot=>`${ot.name}: ${ot.message}`).join(" · ")}):(U({done:!0,total:Ze.paths.length}),setTimeout(()=>U(null),1600))},it=ve=>{const Ze=ve.clipboardData;if(!Iu(Ze))return;const ot=nv(Ze);ot.length&&(ve.preventDefault(),ve.stopPropagation(),Ie(ot))},ze=ve=>{Iu(ve.dataTransfer)&&(ve.preventDefault(),ve.stopPropagation())},Fe=ve=>{Iu(ve.dataTransfer)&&(ve.preventDefault(),ve.stopPropagation(),Ie(nv(ve.dataTransfer)))};q.addEventListener("paste",it,!0),q.addEventListener("dragenter",ze,!0),q.addEventListener("dragover",ze,!0),q.addEventListener("drop",Fe,!0);const dt=24;let Ue=null,ct=null,_t=null,ut=null,pt=!1,st=!1,rt=0,mt=null,le=null,be=null,Ae=!1;const We=()=>{be&&clearTimeout(be),be=null},he=(ve,Ze)=>{const yt=(q.querySelector(".xterm-screen")||q).getBoundingClientRect(),wn=Math.max(0,Math.min(P.cols-1,Math.floor((ve-yt.left)/Math.max(1,yt.width)*P.cols))),ri=Math.max(0,Math.min(P.rows-1,Math.floor((Ze-yt.top)/Math.max(1,yt.height)*P.rows)));return{col:wn,row:P.buffer.active.viewportY+ri}},K=ve=>he(ve.clientX,ve.clientY),ee=ve=>{if(We(),Ae=!1,pt=!1,st||ve.touches.length!==1){st=!0,pt=!0,M=null,Ue=null,ct=null,_t=null,ut=null;return}if(D.current){ve.preventDefault(),ve.stopPropagation(),le=K(ve.touches[0]),P.clearSelection();return}Ue=ve.touches[0].clientY,ct=ve.touches[0].clientX,_t=ct,ut=Ue,rt=0,mt=null;const Ze={x:ct,y:Ue};be=setTimeout(()=>{be=null,Ae=!0,pt=!0,M=null,D.current=!0,S==null||S(!0),le=he(Ze.x,Ze.y),P.clearSelection(),P.select(le.col,le.row,1),Ue=null,ct=null,mt=null,rt=0},hC)},O=ve=>{if((D.current||Ae)&&le&&ve.touches.length===1){ve.preventDefault(),ve.stopPropagation();const ot=K(ve.touches[0]),yt=le.row*P.cols+le.col,wn=ot.row*P.cols+ot.col,ri=yt<=wn?le:ot;P.select(ri.col,ri.row,Math.abs(wn-yt)+1);return}if(Ue===null||ve.touches.length!==1)return;ve.preventDefault(),ve.stopPropagation();const Ze=ve.touches[0];if(fC(_t,ut,Ze.clientX,Ze.clientY)&&(pt=!0,M=null,be&&We()),mt===null&&(Math.abs(Ze.clientY-Ue)>8||Math.abs(Ze.clientX-ct)>8)&&(mt=Math.abs(Ze.clientY-Ue)>Math.abs(Ze.clientX-ct)),!!mt){for(rt+=Ze.clientY-Ue,Ue=Ze.clientY;rt>=dt;)oe.action("scroll-up"),rt-=dt;for(;rt<=-dt;)oe.action("scroll-down"),rt+=dt}},se=()=>{We(),Ue=null,ct=null,_t=null,ut=null,le=null,Ae=!1,pt=!1,st=!1},ge=ve=>{if(st){M=null,We(),(!ve.touches||ve.touches.length===0)&&se();return}const Ze=ve.changedTouches&&ve.changedTouches[0];if(!pt&&!Ae&&!D.current&&Ze){const ot={at:Date.now(),x:Ze.clientX,y:Ze.clientY},yt=wC(X.current,M,ot);M=yt.next,yt.open&&L()}se()},ke=()=>{M=null,se()};let Ee=0;const we=ve=>{for(ve.preventDefault(),ve.stopPropagation(),Ee+=ve.deltaY;Ee<=-dt;)oe.action("scroll-up"),Ee+=dt;for(;Ee>=dt;)oe.action("scroll-down"),Ee-=dt};q.addEventListener("touchstart",ee,{passive:!1}),q.addEventListener("touchmove",O,{passive:!1,capture:!0}),q.addEventListener("touchend",ge,{passive:!0}),q.addEventListener("touchcancel",ke,{passive:!0});const Re=()=>{!D.current&&X.current==="double-tap"&&L()};q.addEventListener("dblclick",Re);const Ge=ve=>{(D.current||Ae)&&(ve.preventDefault(),ve.stopPropagation())};q.addEventListener("contextmenu",Ge,!0),q.addEventListener("wheel",we,{passive:!1,capture:!0});let gt=null;const Be=ve=>{uC(ve)&&(ve.preventDefault(),ve.stopPropagation(),gt=he(ve.clientX,ve.clientY),P.clearSelection())},fn=ve=>{if(!gt)return;ve.preventDefault(),ve.stopPropagation();const Ze=he(ve.clientX,ve.clientY),ot=gt.row*P.cols+gt.col,yt=Ze.row*P.cols+Ze.col,wn=ot<=yt?gt:Ze;P.select(wn.col,wn.row,Math.abs(yt-ot)+1)},kt=ve=>{gt&&(ve.stopPropagation(),gt=null)};q.addEventListener("mousedown",Be,!0),q.addEventListener("mousemove",fn,!0),q.addEventListener("mouseup",kt,!0);const Ke=ve=>{!dC(ve)||!(k.current&&k.current.term&&k.current.term.getSelection())||(ve.preventDefault(),ve.stopPropagation(),j.current&&j.current())};q.addEventListener("keydown",Ke,!0);const Et=()=>{T.fit(),oe.resize(P.cols,P.rows)};window.addEventListener("resize",Et);const ue=window.visualViewport;let Ne=ue&&Number(ue.height);const qe=()=>{const ve=ue&&Number(ue.height);te&&X.current==="double-tap"&&Number.isFinite(Ne)&&Number.isFinite(ve)&&ve>Ne+80&&ie(),Ne=ve,Et()};ue&&(ue.addEventListener("resize",qe),ue.addEventListener("scroll",Et));const tt=typeof navigator<"u"?navigator.virtualKeyboard:null,qt=()=>{var ve;te&&X.current==="double-tap"&&Number(((ve=tt==null?void 0:tt.boundingRect)==null?void 0:ve.height)||0)===0&&ie()};(Di=tt==null?void 0:tt.addEventListener)==null||Di.call(tt,"geometrychange",qt);let ii=null,Ft=0;return typeof ResizeObserver<"u"&&(ii=new ResizeObserver(()=>{Ft&&cancelAnimationFrame(Ft),Ft=requestAnimationFrame(Et)}),ii.observe(q)),()=>{var ve;k.current=null,u&&(u.current=()=>!1),h&&(h.current=()=>!1),p&&(p.current=()=>!1),me.dispose(),Q.dispose(),q.removeEventListener("touchstart",ee),q.removeEventListener("touchmove",O,{capture:!0}),q.removeEventListener("touchend",ge),q.removeEventListener("touchcancel",ke),q.removeEventListener("dblclick",Re),q.removeEventListener("contextmenu",Ge,!0),We(),q.removeEventListener("wheel",we,{capture:!0}),q.removeEventListener("mousedown",Be,!0),q.removeEventListener("mousemove",fn,!0),q.removeEventListener("mouseup",kt,!0),q.removeEventListener("keydown",Ke,!0),q.removeEventListener("paste",it,!0),q.removeEventListener("dragenter",ze,!0),q.removeEventListener("dragover",ze,!0),q.removeEventListener("drop",Fe,!0),window.removeEventListener("resize",Et),ue&&(ue.removeEventListener("resize",qe),ue.removeEventListener("scroll",Et)),(ve=tt==null?void 0:tt.removeEventListener)==null||ve.call(tt,"geometrychange",qt),z==null||z.removeEventListener("blur",G),ii&&ii.disconnect(),Ft&&cancelAnimationFrame(Ft),oe.close(),P.dispose()}},[e,t,n,s,o,u,h,p,f,_,b]),c.jsxs("div",{className:`nc-terminal${w?" selecting":""}`,children:[c.jsx("div",{className:"nc-terminal-host",ref:C}),Z&&c.jsx("div",{className:`nc-upload-state${Z.error?" error":""}`,role:"status",children:Z.error?Z.error:Z.done?g("attach-uploaded").replace("{n}",String(Z.total||0)):g("attach-upload-progress").replace("{n}",String(Z.current||0)).replace("{total}",String(Z.total||0))}),(V||w)&&c.jsxs("div",{className:"nc-selection-tools",children:[V?c.jsx("button",{type:"button",onClick:H,children:ne||g("copy")}):c.jsx("span",{children:g("select-drag")}),c.jsx("button",{type:"button",onClick:()=>{var P,T;(T=(P=k.current)==null?void 0:P.term)==null||T.clearSelection(),A(""),S==null||S(!1)},children:g("cancel")}),ne===g("copy-manual")&&c.jsx("textarea",{readOnly:!0,value:V,onFocus:P=>P.target.select()})]})]})}const iv="",Rn="\x1B",SC=[{label:"↑",seq:Rn+"[A"},{label:"↓",seq:Rn+"[B"},{label:"PGUP",seq:Rn+"[5~"},{label:"PGDN",seq:Rn+"[6~"}];function bC({send:e,action:t,ctrlArmed:n=!1,onCtrl:s,onKeyboard:o,selectionMode:a=!1,onSelectionMode:u,keepKeyboardClosed:h=!0,showEnter:p=!0}){const[f,_]=R.useState(!1),[b,y]=R.useState(!1),[w,S]=R.useState(!1),x=D=>{w?(e(Rn+D),S(!1)):e(D)},C=D=>{h&&Py(),D()},k=D=>({onPointerDown:X=>{X.preventDefault(),C(D)},onClick:X=>{X.detail===0&&C(D)}}),N=(D,X,V)=>c.jsx("button",{type:"button",...k(()=>{x(X),V&&V()}),children:D},D),I=(D,X)=>c.jsx("button",{type:"button",...k(()=>{t(X),y(!1)}),children:D},D);return f?c.jsxs("div",{className:"nc-keybar copy",children:[c.jsx("span",{className:"tag",children:"copy-mode"}),SC.map(D=>N(D.label,D.seq)),N("ESCI (q)","q",()=>_(!1))]}):c.jsxs("div",{className:"nc-keybar termux",children:[b&&c.jsxs("div",{className:"nc-keymenu",children:[I("←WIN","prev-window"),I("WIN→","next-window"),I("⬅PANE","pane-left"),I("PANE➡","pane-right"),N("SCROLL",iv+"[",()=>{_(!0),y(!1)}),c.jsx("button",{type:"button",className:a?"armed":"",...k(()=>{u==null||u(!a),y(!1)}),children:"SELECT"}),N("⌃C","",()=>y(!1)),N("DETACH",iv+"d",()=>y(!1))]}),c.jsxs("div",{className:`nc-keygrid${p?"":" no-enter"}`,children:[c.jsxs("div",{className:"nc-keyrows",children:[c.jsxs("div",{className:"row",children:[N("ESC",Rn),c.jsx("button",{type:"button",className:b?"armed":"",...k(()=>y(D=>!D)),children:"☰"},"menu"),N("/","/"),N("—","-"),N("HOME",Rn+"[H"),N("↑",Rn+"[A"),N("END",Rn+"[F"),N("PGUP",Rn+"[5~")]}),c.jsxs("div",{className:"row",children:[N("⇥"," "),c.jsx("button",{type:"button",...k(()=>{o&&o()}),children:"⌨"},"kbd"),c.jsx("button",{type:"button",className:n?"armed":"",...k(()=>{s&&s()}),children:"CTRL"},"ctrl"),c.jsx("button",{type:"button",className:w?"armed":"",...k(()=>S(D=>!D)),children:"ALT"},"alt"),N("←",Rn+"[D"),N("↓",Rn+"[B"),N("→",Rn+"[C"),N("PGDN",Rn+"[6~")]})]}),p&&c.jsx("button",{type:"button",className:"nc-enter-key","aria-label":"ENTER",title:"ENTER",...k(()=>x("\r")),children:c.jsx(nt,{name:"enter",size:24})})]})]})}const kC=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function Dy({session:e,node:t,token:n,filesEvent:s,onClose:o}){On();const a=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",u=t?`${t}:${e}`:e,[h,p]=R.useState("outbox"),[f,_]=R.useState({inbox:[],outbox:[]}),[b,y]=R.useState(""),w=R.useRef(null);async function S(){try{const I=await(await en(`${a}/files?session=${encodeURIComponent(e)}`,n)).json();if(I.error){y(I.error);return}_(I);const D=I.outbox[0]?I.outbox[0].mtime:0;localStorage.setItem(d_(u),String(D))}catch(N){y(String(N))}}R.useEffect(()=>{S()},[e,t]),R.useEffect(()=>{s&&s.session===e&&S()},[s]);async function x(N){for(const I of N){y(`carico ${I.name}…`);const D=new FormData;D.append("session",e),D.append("file",I);try{const V=await(await en(`${a}/files/upload`,n,{method:"POST",body:D})).json();y(V.error?`errore: ${V.error}`:"")}catch(X){y(String(X))}}S()}async function C(N){const I=await en(`${a}/files/download?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(N)}`,n);if(!I.ok){y("errore download");return}const D=await I.blob(),X=URL.createObjectURL(D),V=document.createElement("a");V.href=X,V.download=N,V.click(),URL.revokeObjectURL(X)}async function k(N){await en(`${a}/files?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(N)}`,n,{method:"DELETE"}),S()}return c.jsxs("div",{className:"nc-files",children:[c.jsxs("header",{children:[c.jsx("b",{children:t?`${t}:${e}`:e}),c.jsx("button",{onClick:o,title:g("close"),children:c.jsx(nt,{name:"x",size:20})})]}),c.jsxs("nav",{children:[c.jsx("button",{className:h==="outbox"?"on":"",onClick:()=>p("outbox"),children:"outbox"}),c.jsx("button",{className:h==="inbox"?"on":"",onClick:()=>p("inbox"),children:"inbox"}),c.jsxs("button",{className:"up",onClick:()=>w.current&&w.current.click(),children:[c.jsx(nt,{name:"upload",size:18})," ",g("upload")]}),c.jsx("input",{type:"file",multiple:!0,ref:w,style:{display:"none"},onChange:N=>{x(Array.from(N.target.files||[])),N.target.value=""}})]}),b&&c.jsx("div",{className:"nc-busy",children:b}),c.jsxs("ul",{children:[f[h].map(N=>c.jsxs("li",{children:[c.jsx("span",{className:"name",onClick:()=>C(N.name),children:N.name}),c.jsx("small",{children:kC(N.size)}),c.jsx("button",{onClick:()=>k(N.name),title:"elimina",children:c.jsx(nt,{name:"trash",size:18})})]},N.name)),f[h].length===0&&c.jsx("li",{className:"empty",children:g("empty-files")})]})]})}const Ll="nc_composer_v1",ih="nc-composer-reset",xC=50,My=256*1024,Ty=512*1024,CC=768*1024,rv=2*1024*1024,Ay=720*60*60*1e3,rh=1;function Iy(e){const t=Number(e);return Number.isFinite(t)&&t>0?t:0}function Ih(e){if(e!==void 0)return e;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function kl(){return{version:rh,cells:{}}}function By(e){const t=[];for(const s of Array.isArray(e)?e:[]){const o=typeof s=="string"?s:s&&s.text,a=Iy(typeof s=="string"?0:s&&s.at);if(!(typeof o!="string"||!o||o.length>My)&&!(t.length&&t[t.length-1].text===o)&&(t.push({text:o,at:a}),t.length>=xC))break}let n=0;return t.filter(s=>n+s.text.length>CC?!1:(n+=s.text.length,!0))}function xl(e){if(!e||typeof e!="object")return null;const t=typeof e.draft=="string"&&e.draft.length<=Ty?e.draft:"",n=By(e.history),s=Iy(e.updatedAt),o=e.expanded===!0;return!t&&!n.length&&!o?null:{draft:t,history:n,expanded:o,updatedAt:s}}function EC(e){let t;try{t=typeof e=="string"?JSON.parse(e):e}catch{return kl()}if(!t||typeof t!="object"||t.version!==rh||!t.cells||typeof t.cells!="object")return kl();const n=Object.create(null);for(const[s,o]of Object.entries(t.cells)){if(!s||typeof s!="string"||s.length>512||s==="__proto__"||s==="constructor"||s==="prototype")continue;const a=xl(o);a&&(n[s]=a)}return{version:rh,cells:n}}function Oy(e){const t=Ih(e);if(!t)return kl();try{return EC(t.getItem(Ll))}catch{return kl()}}function sv(e){try{return JSON.stringify(e).length}catch{return 1/0}}function NC(e,t,n){for(const[s,o]of Object.entries(e.cells))s!==n&&o.updatedAt>0&&t-o.updatedAt>Ay&&delete e.cells[s]}function zy(e,t){return Object.entries(e.cells).filter(([n])=>n!==t).sort((n,s)=>n[1].updatedAt-s[1].updatedAt).map(([n])=>n)}function RC(e,t){for(;sv(e)>rv;){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 zy(e,t)){if(sv(e)<=rv)break;delete e.cells[n]}}function Fy(e,t,n){const s=Ih(e);if(!s)return!1;RC(t,n);const o=()=>(s.setItem(Ll,JSON.stringify(t)),!0);try{return o()}catch{for(const u of zy(t,n)){delete t.cells[u];try{return o()}catch{}}return!1}}function Ao(e,t,n,s){const o=Oy(t);NC(o,n,e);const a=xl(o.cells[e])||{draft:"",history:[],expanded:!1,updatedAt:0},u=s({...a,history:[...a.history]}),h=xl(u);return h?o.cells[e]={...h,updatedAt:n}:delete o.cells[e],{ok:Fy(t,o,e),cell:o.cells[e]||{draft:"",history:[],expanded:!1,updatedAt:n}}}function PC({ownerId:e,node:t,session:n}){const s=String(n||"");if(!s)return"";const o=ys.test(String(e||""))?String(e):t?`route:${String(t)}`:"local";return`${encodeURIComponent(o)}:${encodeURIComponent(s)}`}function mo(e,t,n=Date.now()){if(!e)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=Oy(t),o=xl(s.cells[e]);return!o||o.updatedAt>0&&n-o.updatedAt>Ay?(s.cells[e]&&(delete s.cells[e],Fy(t,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...o,history:[...o.history]}}function ov(e,t,n,s=Date.now()){const o=String(t||"");return!e||o.length>Ty?!1:Ao(e,n,s,a=>({...a,draft:o})).ok}function av(e,t,n=Date.now()){return e?Ao(e,t,n,s=>({...s,draft:""})).ok:!1}function jC(e,t,n,s=Date.now()){return e?Ao(e,n,s,o=>({...o,expanded:!!t})).ok:!1}function LC(e,t,n,s=Date.now()){const o=String(t||"");return!e||!o||o.length>My?!1:Ao(e,n,s,a=>{const u=a.history.filter(h=>h.text!==o);return u.unshift({text:o,at:s}),{...a,history:By(u)}}).ok}function DC(e,t,n=Date.now()){return e?Ao(e,t,n,s=>({...s,history:[]})).ok:!1}function MC(e){const t=Ih(e);if(!t)return!1;try{return t.removeItem(Ll),!0}catch{return!1}}const TC=300;function AC(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function IC({ownerId:e,node:t,session:n,storage:s=AC()}){const o=R.useMemo(()=>PC({ownerId:e,node:t,session:n}),[e,t,n]),a=R.useMemo(()=>mo(o,s),[]),[u,h]=R.useState(a.draft),[p,f]=R.useState(a.expanded),[_,b]=R.useState(a.history),[y,w]=R.useState(-1),S=R.useRef(o),x=R.useRef(a.draft),C=R.useRef(null),k=R.useRef(a.updatedAt||0),N=R.useRef(a.draft),I=R.useCallback(()=>{C.current&&clearTimeout(C.current),C.current=null},[]),D=R.useCallback(()=>{I(),ov(S.current,x.current,s)},[I,s]),X=R.useCallback(()=>{I(),C.current=setTimeout(()=>{C.current=null,ov(S.current,x.current,s)},TC)},[I,s]),V=R.useCallback(P=>{const T=String(typeof P=="function"?P(x.current):P||"");x.current=T,k.current=Date.now(),N.current=T,w(-1),h(T),X()},[X]),A=R.useCallback((P,T)=>{I(),x.current=P,k.current=Date.now(),h(P),w(T),X()},[I,X]),ne=R.useCallback(()=>{if(!_.length)return!1;const P=Math.min(y+1,_.length-1);return y<0&&(N.current=x.current),A(_[P].text,P),!0},[A,_,y]),W=R.useCallback(()=>{if(y<0)return!1;const P=y-1;return A(P<0?N.current:_[P].text,P),!0},[A,_,y]),Z=R.useCallback(P=>{N.current=x.current;const T=_.findIndex(F=>F.text===P);A(String(P||""),T)},[A,_]),U=R.useCallback(()=>{f(P=>{const T=!P;return jC(S.current,T,s),T})},[s]),H=R.useCallback((P,T,F)=>{if(!P)return;if(LC(P,F,s),!(S.current===P)){mo(P,s).draft===T&&av(P,s);return}b(mo(P,s).history),N.current="",w(-1),x.current===T?(I(),x.current="",k.current=Date.now(),h(""),av(P,s)):X()},[I,X,s]),j=R.useCallback(()=>{DC(S.current,s),b([]),w(-1),N.current=x.current},[s]);return R.useEffect(()=>{if(S.current===o)return;D(),S.current=o;const P=mo(o,s);x.current=P.draft,k.current=P.updatedAt||0,N.current=P.draft,h(P.draft),f(P.expanded),b(P.history),w(-1)},[o,D,s]),R.useEffect(()=>{const P=()=>D(),T=()=>{document.visibilityState==="hidden"&&D()};return window.addEventListener("pagehide",P),document.addEventListener("visibilitychange",T),()=>{window.removeEventListener("pagehide",P),document.removeEventListener("visibilitychange",T),D()}},[D]),R.useEffect(()=>{const P=()=>{I(),x.current="",k.current=0,N.current="",h(""),f(!1),b([]),w(-1)},T=te=>{if(te.key!==Ll)return;if(te.newValue==null){P();return}const M=mo(S.current,s);M.updatedAt<k.current||(I(),x.current=M.draft,k.current=M.updatedAt,N.current=M.draft,h(M.draft),f(M.expanded),b(M.history),w(-1))},F=()=>P();return window.addEventListener("storage",T),window.addEventListener(ih,F),()=>{window.removeEventListener("storage",T),window.removeEventListener(ih,F)}},[I,s]),{cellKey:o,text:u,setText:V,expanded:p,toggleExpanded:U,history:_,historyCursor:y,recallPrevious:ne,recallNext:W,selectHistory:Z,confirmSubmitted:H,clearHistory:j,flush:D}}function $y({submitText:e,token:t,session:n,node:s,ownerId:o,keepKeyboardClosedOnVoice:a=!0}){On();const u=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:h,text:p,setText:f,expanded:_,toggleExpanded:b,history:y,historyCursor:w,recallPrevious:S,recallNext:x,selectHistory:C,confirmSubmitted:k,clearHistory:N,flush:I}=IC({ownerId:o,node:s,session:n}),[D,X]=R.useState(!1),[V,A]=R.useState(""),[ne,W]=R.useState(!1),Z=R.useRef(null),U=R.useRef(null),H=R.useRef(null),[j,P]=R.useState(!1),[T,F]=R.useState({left:0,bottom:0}),[te,M]=R.useState(!1),[ie,B]=R.useState(!1),L=R.useRef(null),z=R.useRef(null),G=R.useRef(null),oe=R.useRef(null),de=R.useRef(null),me=R.useRef(null),Q=R.useRef(null),q=R.useRef(!1),[pe,Ie]=R.useState(!1),[it,ze]=R.useState({left:0,bottom:0,width:320}),Fe=R.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);R.useEffect(()=>{let he=!1;if(s){W(!1);return}return en(`${u}/voice/status`,t).then(K=>K.json()).then(K=>{he||W(!!K.serverSttConfigured)}).catch(()=>{he||W(!1)}),()=>{he=!0}},[t,u]);const Ue=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||ne);async function ct(){const he=p,K=lC(he);if(!K||ie)return;B(!0),A("");let ee=!1;try{ee=!!await e(K)}catch{ee=!1}ee?k(h,he,K):A(g("composer-send-failed")),B(!1),requestAnimationFrame(()=>{var O;return(O=H.current)==null?void 0:O.focus({preventScroll:!0})})}function _t(){const he=L.current&&L.current.getBoundingClientRect();he&&F({left:Math.max(6,Math.min(he.left,window.innerWidth-186)),bottom:window.innerHeight-he.top+6}),P(!0)}function ut(he){P(!1),he&&L.current&&L.current.focus()}function pt(){const he=G.current&&G.current.getBoundingClientRect();if(he){const K=Math.max(220,Math.min(360,window.innerWidth-12));ze({left:Math.max(6,Math.min(he.right-K,window.innerWidth-K-6)),bottom:window.innerHeight-he.top+6,width:K})}Ie(!0)}function st(he){Ie(!1),he&&G.current&&G.current.focus()}R.useEffect(()=>{if(!j)return;const he=ee=>{ee.key==="Escape"&&ut(!0)},K=ee=>{const O=z.current&&z.current.contains(ee.target),se=L.current&&L.current.contains(ee.target);!O&&!se&&ut(!1)};return document.addEventListener("keydown",he),document.addEventListener("pointerdown",K),()=>{document.removeEventListener("keydown",he),document.removeEventListener("pointerdown",K)}},[j]),R.useEffect(()=>{if(!pe)return;const he=ee=>{ee.key==="Escape"&&st(!0)},K=ee=>{const O=oe.current&&oe.current.contains(ee.target),se=G.current&&G.current.contains(ee.target);!O&&!se&&st(!1)};return document.addEventListener("keydown",he),document.addEventListener("pointerdown",K),()=>{document.removeEventListener("keydown",he),document.removeEventListener("pointerdown",K)}},[pe]);function rt(he){if(!(he.isComposing||q.current||he.altKey||he.ctrlKey||he.metaKey)){if(he.key==="ArrowUp"&&he.currentTarget.selectionStart===0&&he.currentTarget.selectionEnd===0){S()&&he.preventDefault();return}he.key==="ArrowDown"&&w>=0&&he.currentTarget.selectionStart===p.length&&he.currentTarget.selectionEnd===p.length&&x()&&he.preventDefault()}}function mt(he){ut(!1),he.current&&he.current.click()}async function le(he){if(!he.length||!n)return;M(!0),A("");const{paths:K,errors:ee}=await Ry({files:he,token:t,session:n,node:s,paste:!1});ee.length&&A(ee.map(O=>`${O.name}: ${O.message}`).join(" · ")),K.length&&f(O=>O+(O&&!O.endsWith(" ")?" ":"")+K.join(" ")),M(!1)}function be(){Z.current&&Z.current.stop(),U.current&&U.current.stop(),X(!1)}async function Ae(){A("");const he=window.SpeechRecognition||window.webkitSpeechRecognition;if(he){const K=new he;K.lang="it-IT",K.continuous=!1,K.interimResults=!0;const ee=p?`${p} `:"";K.onresult=O=>{const se=Array.from(O.results).map(ge=>ge[0].transcript).join("");f(ee+se)},K.onend=()=>X(!1),K.onerror=O=>{A(`voice: ${O.error||"errore"}`),X(!1)},Z.current=K,K.start(),X(!0);return}try{const K=await navigator.mediaDevices.getUserMedia({audio:!0}),ee=new MediaRecorder(K),O=[];ee.ondataavailable=se=>O.push(se.data),ee.onstop=async()=>{K.getTracks().forEach(se=>se.stop()),X(!1),A("trascrivo…");try{const se=new Blob(O,{type:ee.mimeType||"audio/webm"}),ke=await(await en(`${u}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:se})).json();ke.error?A(ke.error):(A(""),f(Ee=>Ee+(Ee?" ":"")+(ke.text||"")))}catch(se){A(String(se))}},U.current={stop:()=>ee.state!=="inactive"&&ee.stop()},ee.start(),X(!0)}catch{A("microfono non disponibile"),X(!1)}}function We(){a&&Py(),D?be():Ae()}return c.jsxs("div",{className:"nc-composer",children:[V&&c.jsx("div",{className:"nc-composer-err",children:V}),c.jsxs("div",{className:"nc-composer-row",children:[n&&c.jsx("button",{ref:L,className:te?"attach busy":"attach",disabled:te,onClick:()=>j?ut(!1):_t(),title:g(te?"attach-uploading":"attach"),"aria-label":g("attach"),"aria-haspopup":"menu","aria-expanded":j,"aria-controls":Fe.current,children:c.jsx(nt,{name:"attach",size:22})}),j&&c.jsxs("div",{ref:z,id:Fe.current,role:"menu",className:"nc-attach-menu",style:{left:T.left,bottom:T.bottom},children:[c.jsxs("button",{role:"menuitem",onClick:()=>mt(de),children:[c.jsx(nt,{name:"file",size:18})," ",g("attach-file")]}),c.jsxs("button",{role:"menuitem",onClick:()=>mt(me),children:[c.jsx(nt,{name:"camera",size:18})," ",g("attach-camera")]}),c.jsxs("button",{role:"menuitem",onClick:()=>mt(Q),children:[c.jsx(nt,{name:"image",size:18})," ",g("attach-gallery")]})]}),c.jsx("button",{ref:G,type:"button",className:"history",onPointerDown:he=>he.preventDefault(),onClick:()=>pe?st(!1):pt(),title:g("composer-history-tools"),"aria-label":g("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":pe,children:c.jsx(nt,{name:"history",size:21})}),pe&&c.jsxs("div",{ref:oe,role:"menu",className:"nc-composer-history-menu",style:{left:it.left,bottom:it.bottom,width:it.width},children:[c.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:he=>he.preventDefault(),onClick:()=>{b(),st(!1),requestAnimationFrame(()=>{var he;return(he=H.current)==null?void 0:he.focus({preventScroll:!0})})},children:[c.jsx(nt,{name:_?"chevronDown":"chevronUp",size:18}),g(_?"composer-collapse":"composer-expand")]}),c.jsx("div",{className:"nc-composer-history-title",children:g("composer-history")}),y.length===0&&c.jsx("div",{className:"nc-composer-history-empty",children:g("composer-history-empty")}),y.map((he,K)=>c.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:ee=>ee.preventDefault(),onClick:()=>{C(he.text),st(!1),requestAnimationFrame(()=>{var ee;return(ee=H.current)==null?void 0:ee.focus({preventScroll:!0})})},children:[c.jsx("span",{children:he.text.replace(/\s+/g," ").slice(0,180)}),he.at>0&&c.jsx("small",{children:new Date(he.at).toLocaleString()})]},`${he.at}:${K}`)),y.length>0&&c.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:he=>he.preventDefault(),onClick:()=>{N(),st(!1)},children:g("composer-history-clear")})]}),c.jsx("input",{ref:de,type:"file",multiple:!0,hidden:!0,onChange:he=>{le(Array.from(he.target.files||[])),he.target.value=""}}),c.jsx("input",{ref:me,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:he=>{le(Array.from(he.target.files||[])),he.target.value=""}}),c.jsx("input",{ref:Q,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:he=>{le(Array.from(he.target.files||[])),he.target.value=""}}),c.jsx("textarea",{ref:H,className:_?"expanded":"",rows:_?8:2,value:p,placeholder:g("composer-placeholder"),onChange:he=>f(he.target.value),onKeyDown:rt,onCompositionStart:()=>{q.current=!0},onCompositionEnd:()=>{q.current=!1},onBlur:I}),Ue&&c.jsx("button",{type:"button",className:D?"mic on":"mic",title:g("voice"),"aria-label":g("voice"),onPointerDown:he=>{he.preventDefault(),We()},onClick:he=>{he.detail===0&&We()},children:c.jsx(nt,{name:"mic",size:22})}),c.jsx("button",{type:"button",className:"go",disabled:ie,onPointerDown:he=>he.preventDefault(),onClick:ct,title:g("send"),children:c.jsx(nt,{name:"enter",size:22})})]})]})}function lv(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const BC=180,OC=480,hs=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function zC({sessions:e=[],cells:t=[],activeSessions:n=[],nodeGroups:s=[],onPick:o,onAddTile:a,onPower:u,onBoot:h,onNodePower:p,onKill:f,onVisibility:_,onNew:b,onNodeRename:y,onSettings:w,onBootError:S,localNodeId:x,fleetCapabilities:C=[],bootSettlement:k=null,onBootSettlementApplied:N,width:I=240,collapsed:D=!1,onResize:X,onToggleCollapse:V}){const[A,ne]=On(),{pins:W,orders:Z,togglePin:U,viewFor:H,updateView:j,canMoveRoster:P,moveRoster:T,stepRoster:F}=E_(),{groupsFor:te,moveNode:M,stepNode:ie,nodeKey:B}=R_(),L=new Set((t||[]).map(K=>K.tmuxSession)),z=new Map((e||[]).map(K=>[K.name,K])),G=(K,ee)=>S0(W,K,ee),oe=b0,de=[...t||[]].sort((K,ee)=>oe(G(K.tmuxSession,(z.get(K.tmuxSession)||{}).activity),G(ee.tmuxSession,(z.get(ee.tmuxSession)||{}).activity))),me=(e||[]).filter(K=>!L.has(K.name)).sort((K,ee)=>oe(G(K.name,K.activity),G(ee.name,ee.activity))||K.name.localeCompare(ee.name)),Q=new Set(n||[]),q=D_(de,me,z),pe=Dr(q,W,H("local").filter,or(Z,"local")),it=te(s||[]).map(K=>{const ee=(K.route||[K.name]).join("/"),O=H(ee),{rawItems:se}=vd(K),ge=Dr(se,W,O.filter,or(Z,ee));return{g:K,nodeRoute:ee,groupView:O,rawItems:se,items:ge}}),ze=(K,ee,O)=>o&&o({session:K,...ee?{node:ee}:{},...ys.test(String(O||""))?{ownerId:O}:{}}),Fe=async K=>{if(!(K!=null&&K.direct)||!y)return;const ee=window.prompt(g("rename-node-prompt"),K.label||K.name);if(ee!==null)try{await y(K,ee)||window.alert(g("rename-node-invalid"))}catch(O){window.alert(String((O==null?void 0:O.message)||O))}},[dt,Ue]=R.useState({}),[ct,_t]=R.useState(new Set);R.useEffect(()=>{const K=new Map;for(const ee of t||[])K.set(hs(ee.cell),!!ee.boot);for(const ee of s||[]){const O=ee.route||[ee.name];for(const se of ee.cells||[])K.set(hs(se.cell,O),!!se.boot)}Ue(ee=>{let O=!1;const se={...ee};for(const[ge,ke]of Object.entries(ee))K.has(ge)&&K.get(ge)===ke&&(delete se[ge],O=!0);return O?se:ee})},[t,s]),R.useEffect(()=>{if(!(k!=null&&k.cell))return;const K=Array.isArray(k.route)?k.route:[],ee=hs(k.cell,K);Ue(O=>({...O,[ee]:!!k.enabled})),N&&N(k.id)},[k,N]);const ut=(K,ee=[])=>{const O=hs(K.cell,ee);return Object.prototype.hasOwnProperty.call(dt,O)?dt[O]:!!K.boot},pt=async(K,ee,O=[])=>{if(K.stopPropagation(),!h)return;const se=hs(ee.cell,O),ge=!ut(ee,O);Ue(ke=>({...ke,[se]:ge})),_t(ke=>new Set(ke).add(se));try{await h(ee.cell,ge,O)}catch(ke){Ue(Ee=>{const we={...Ee};return delete we[se],we}),S&&S(ke)}finally{_t(ke=>{const Ee=new Set(ke);return Ee.delete(se),Ee})}},st=(K,ee=[])=>{const O=hs(K.cell,ee),se=ut(K,ee),ge=`${g(se?"boot-disable":"boot-enable")} ${K.cell}`;return c.jsx("button",{className:`nc-boot${se?" on":""}`,disabled:ct.has(O),onClick:ke=>pt(ke,K,ee),title:ge,"aria-label":ge,children:c.jsx(nt,{name:"boot",size:14})})},[rt,mt]=R.useState(null),le=(K,ee)=>{const O=K.currentTarget.getBoundingClientRect();mt({text:ee,y:O.top+O.height/2})},be=()=>mt(null),Ae=R.useRef(null);R.useEffect(()=>()=>{Ae.current&&Ae.current()},[]);function We(K){K.preventDefault(),K.stopPropagation();const ee=K.clientX,O=I,se=ke=>{const Ee=Math.max(BC,Math.min(OC,O+(ke.clientX-ee)));X&&X(Ee)},ge=()=>{window.removeEventListener("pointermove",se),window.removeEventListener("pointerup",ge),window.removeEventListener("pointercancel",ge),window.removeEventListener("blur",ge),Ae.current=null};window.addEventListener("pointermove",se),window.addEventListener("pointerup",ge),window.addEventListener("pointercancel",ge),window.addEventListener("blur",ge),Ae.current=ge}const he=D?{width:48,flex:"0 0 48px"}:{width:I,flex:`0 0 ${I}px`};return D?c.jsxs("aside",{className:"nc-sidebar mini",style:he,children:[c.jsx("div",{className:"nc-side-head mini",children:c.jsx("button",{className:"nc-collapse-btn",onClick:V,title:g("expand"),children:"⟩"})}),c.jsx("button",{className:"nc-side-gear mini",onClick:()=>w&&w("nodes",!1),title:g("settings"),onMouseEnter:K=>le(K,g("settings")),onMouseLeave:be,children:c.jsx(nt,{name:"gear",size:16})}),c.jsx("div",{className:"nc-side-scroll mini",children:c.jsxs("div",{className:"nc-side-group mini",children:[H("local").open&&pe.map(K=>K.type==="cell"?(()=>{const ee=K.value,O=ee.degraded?"warn":ee.tmux?"on":"",se=!!ee.tmux;return c.jsx("button",{type:"button",className:`nc-mini-dot${Q.has(ee.tmuxSession)?" active":""}`,onMouseEnter:ge=>le(ge,`${ee.cell}: ${K.subtitle}`),onMouseLeave:be,draggable:se,onDragStart:se?ge=>ge.dataTransfer.setData("text/nc-session",ee.tmuxSession):void 0,onClick:se?()=>a&&a(ee.tmuxSession):()=>u&&u(ee),onDoubleClick:se?()=>ze(ee.tmuxSession,"",x):void 0,children:c.jsx("span",{className:`nc-dot ${O}${K.working?" working":""}`})},K.key)})():(()=>{const ee=K.value;return c.jsx("button",{type:"button",className:`nc-mini-init${Q.has(ee.name)?" active":""}`,onMouseEnter:O=>le(O,ee.name),onMouseLeave:be,draggable:!0,onDragStart:O=>O.dataTransfer.setData("text/nc-session",ee.name),onClick:()=>a&&a(ee.name),onDoubleClick:()=>ze(ee.name,"",x),children:lv(ee.name)},K.key)})()),it.flatMap(({g:K,nodeRoute:ee,groupView:O,items:se})=>K.status==="up"?O.open?se.map(ge=>ge.type==="cell"?(()=>{const ke=ge.value,Ee=!!ke.tmux;return c.jsx("button",{type:"button",className:`nc-mini-dot${Q.has(ge.key)?" active":""}`,onMouseEnter:we=>le(we,`${K.label||ee}: ${ke.cell} · ${ge.subtitle}`),onMouseLeave:be,draggable:Ee,onDragStart:Ee?we=>we.dataTransfer.setData("text/nc-session",ge.key):void 0,onClick:Ee?()=>a&&a(ge.key):()=>u&&u({...ke,route:K.route,availableEngines:K.engines||[]}),onDoubleClick:Ee?()=>ze(ke.tmuxSession,ee,K.instanceId):void 0,children:c.jsx("span",{className:`nc-dot ${ke.degraded?"warn":Ee?`on${ge.working?" working":""}`:""}`})},ge.key)})():(()=>{const ke=ge.value;return c.jsx("button",{type:"button",className:`nc-mini-init${Q.has(ge.key)?" active":""}`,onMouseEnter:Ee=>le(Ee,`${K.label||ee}: ${ke.name}`),onMouseLeave:be,draggable:!0,onDragStart:Ee=>Ee.dataTransfer.setData("text/nc-session",ge.key),onClick:()=>a&&a(ge.key),onDoubleClick:()=>ze(ke.name,ee,K.instanceId),children:lv(ke.name)},ge.key)})()):[]:[c.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:ge=>le(ge,`${K.label||(K.route||[K.name]).join(" › ")}: ${ms(K)}`),onMouseLeave:be,children:c.jsx("span",{className:`nc-dot${K.status==="passive"?"":" warn"}`})},`nodo-${(K.route||[K.name]).join("/")}`)])]})}),rt&&c.jsx("div",{className:"nc-mini-tip",style:{top:rt.y},children:rt.text})]}):c.jsxs("aside",{className:"nc-sidebar",style:he,children:[c.jsxs("div",{className:"nc-side-head",children:[c.jsx("button",{className:"nc-collapse-btn",onClick:V,title:g("collapse"),children:"⟨"}),c.jsx("span",{className:"nc-side-title",children:g("fleet")}),c.jsxs("button",{className:"nc-new-btn",onClick:b,title:g("fleet-new-cell"),children:["+ ",g("new")]})]}),c.jsxs("button",{className:"nc-side-gear",onClick:()=>w&&w("nodes",!1),title:g("settings"),children:[c.jsx(nt,{name:"gear",size:15})," ",g("settings")]}),c.jsxs("div",{className:"nc-side-scroll",children:[c.jsx(FC,{label:g("position-local"),count:pe.length,state:H("local"),onToggle:()=>j("local",{open:!H("local").open}),onFilter:K=>j("local",{filter:K})}),H("local").open&&c.jsxs("div",{className:"nc-side-group",children:[pe.map(K=>K.type==="cell"?(()=>{const ee=K.value,O=ee.degraded?"warn":ee.tmux?"on":"",se=ee.degraded?g("cell-degraded"):K.working?K.subtitle:ee.tmux?g("cell-idle"):g("cell-off"),ge=!!ee.tmux;return c.jsxs("div",{"data-roster-key":K.key,"data-position":"local",className:`nc-cell${ge?" live":""}${Q.has(ee.tmuxSession)?" active":""}`,title:`${ee.cell} · ${K.subtitle}${se===K.subtitle?"":` · ${se}`}`,"aria-label":`${ee.cell}, ${K.subtitle}${se===K.subtitle?"":`, ${se}`}`,draggable:ge,onDragStart:ge?ke=>ke.dataTransfer.setData("text/nc-session",ee.tmuxSession):void 0,onClick:ge?()=>a&&a(ee.tmuxSession):void 0,onDoubleClick:ge?()=>ze(ee.tmuxSession,"",x):void 0,children:[c.jsx(rr,{position:"local",itemKey:K.key,label:ee.cell,canMove:P,onMove:(ke,Ee)=>T("local",ke,Ee,q),onStep:ke=>F("local",K.key,ke,q)}),c.jsx("span",{className:`nc-dot ${O}${K.working?" working":""}`}),c.jsxs("span",{className:"nc-cell-main",children:[c.jsx("b",{title:ee.cell,children:ee.cell}),c.jsx("small",{title:K.subtitle,children:K.subtitle})]}),c.jsx("button",{className:`nc-pin${W.includes(K.key)?" on":""}`,title:g("pin"),onClick:ke=>{ke.stopPropagation(),U(K.key)},children:W.includes(K.key)?"★":"☆"}),h&&C.includes("boot")&&st(ee),c.jsx("button",{className:`nc-power${ee.tmux?" on":""}${ee.degraded?" warn":""}`,onClick:ke=>{ke.stopPropagation(),u&&u({...ee,boot:ut(ee)})},title:ee.active?g("power-off"):g("power-on"),children:c.jsx(nt,{name:"power",size:14})})]},K.key)})():(()=>{var O;const ee=K.value;return c.jsxs("div",{"data-roster-key":K.key,"data-position":"local",className:`nc-side-card${Q.has(ee.name)?" active":""}`,draggable:!0,onDragStart:se=>se.dataTransfer.setData("text/nc-session",ee.name),onClick:()=>a&&a(ee.name),onDoubleClick:()=>ze(ee.name,"",x),children:[c.jsx(rr,{position:"local",itemKey:K.key,label:ee.name,canMove:P,onMove:(se,ge)=>T("local",se,ge,q),onStep:se=>F("local",K.key,se,q)}),c.jsx("span",{className:ee.attached?"nc-dot on":"nc-dot"}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:ee.name}),c.jsxs("small",{children:[ee.preview||ee.cmd||g("windows").replace("{n}",String(ee.windows||0)),((O=ee.outbox)==null?void 0:O.count)>0?` · 📦${ee.outbox.count}`:""]})]}),ee.activity?c.jsx("span",{className:"nc-rel",children:_s(ee.activity)}):null,c.jsx("button",{className:`nc-pin${W.includes(K.key)?" on":""}`,title:g("pin"),onClick:se=>{se.stopPropagation(),U(K.key)},children:W.includes(K.key)?"★":"☆"}),c.jsx("button",{className:`nc-technical${ee.technical?" on":""}`,title:ee.technical?g("mark-normal"):g("mark-technical"),"aria-label":`${ee.technical?g("mark-normal"):g("mark-technical")} ${ee.name}`,onClick:se=>{se.stopPropagation(),_&&_(ee.name,!ee.technical,[])},children:"T"}),c.jsx("button",{className:"nc-menu",title:g("terminate"),onClick:se=>{se.stopPropagation(),window.confirm(g("terminate-confirm").replace("{name}",ee.name))&&f&&f(ee.name)},children:"⋯"})]},K.key)})()),pe.length===0&&c.jsx("div",{className:"nc-empty",children:g("no-sessions-short")})]}),it.map(({g:K,nodeRoute:ee,groupView:O,rawItems:se,items:ge})=>{const Ee=P_(K.health)||(K.status==="up"?"on":K.status==="passive"?"":"warn");return c.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":B(K),children:[c.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:K.direct&&y?we=>{we.preventDefault(),Fe(K)}:void 0,onClick:()=>j(ee,{open:!O.open}),onKeyDown:we=>{(we.key==="Enter"||we.key===" ")&&(we.preventDefault(),j(ee,{open:!O.open}))},children:[c.jsx(rr,{scope:"node",position:"nodes",itemKey:B(K),label:K.label||K.name,onMove:(we,Re)=>M(we,Re,s||[]),onStep:we=>ie(B(K),we,s||[])}),c.jsx("span",{className:"nc-node-chevron",children:O.open?"⌄":"›"}),c.jsx("span",{className:`nc-dot ${Ee}`,title:K.health?fl(K.health):""}),c.jsx("b",{children:K.label||K.name}),c.jsxs("small",{children:[" · ",K.status==="up"?g("node-sessions").replace("{n}",String(ge.length)):K.health&&fl(K.health)||ms(K)]}),c.jsxs("select",{className:"nc-node-filter",value:O.filter,title:g(`view-${O.filter}`),onClick:we=>we.stopPropagation(),onChange:we=>j(ee,{filter:we.target.value}),children:[c.jsx("option",{value:"all",children:g("view-all")}),c.jsx("option",{value:"pinned",children:g("view-pinned")}),c.jsx("option",{value:"active",children:g("view-active")}),c.jsx("option",{value:"off",children:g("view-off")}),c.jsx("option",{value:"technical",children:g("view-technical")})]}),K.direct&&y&&c.jsx("button",{type:"button",className:"nc-node-rename",title:g("rename-node"),"aria-label":`${g("rename-node")} ${K.label||K.name}`,onClick:we=>{we.stopPropagation(),Fe(K)},children:"✎"}),K.direct&&K.health&&K.health.managed!==!1&&c.jsx("button",{type:"button",className:`nc-power${K.tunnelStatus==="up"?" on":""}`,title:K.tunnelStatus==="up"?g("power-off"):g("power-on"),onClick:we=>{we.stopPropagation(),p&&p(K)},children:c.jsx(nt,{name:"power",size:14})})]}),K.status==="up"&&O.open&&c.jsxs("div",{className:"nc-side-group",children:[ge.map(we=>we.type==="cell"?(()=>{const Re=we.value,Ge=!!Re.tmux,gt=Re.degraded?"warn":Re.tmux?"on":"";return c.jsxs("div",{"data-roster-key":we.key,"data-position":ee,className:`nc-side-card nc-cell${Ge?" live":""}${Q.has(Re.key)?" active":""}`,title:we.working?we.subtitle:Re.tmux?g("cell-idle"):g("cell-off"),draggable:Ge,onDragStart:Ge?Be=>Be.dataTransfer.setData("text/nc-session",Re.key):void 0,onClick:Ge?()=>a&&a(Re.key):void 0,onDoubleClick:Ge?()=>ze(Re.tmuxSession,ee,K.instanceId):void 0,children:[c.jsx(rr,{position:ee,itemKey:we.key,label:Re.cell,canMove:P,onMove:(Be,fn)=>T(ee,Be,fn,se),onStep:Be=>F(ee,we.key,Be,se)}),c.jsx("span",{className:`nc-dot ${gt}${we.working?" working":""}`}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:Re.cell}),c.jsx("small",{title:we.subtitle,children:we.subtitle})]}),c.jsx("button",{className:`nc-pin${W.includes(we.key)?" on":""}`,title:g("pin"),onClick:Be=>{Be.stopPropagation(),U(we.key)},children:W.includes(we.key)?"★":"☆"}),h&&(K.capabilities||[]).includes("boot")&&st(Re,K.route||[]),(K.capabilities||[]).includes(Re.active?"down":"up")&&c.jsx("button",{className:`nc-power${Re.active?" on":""}${Re.degraded?" warn":""}`,onClick:Be=>{Be.stopPropagation(),u&&u({...Re,boot:ut(Re,K.route||[]),route:K.route,availableEngines:K.engines||[]})},title:Re.active?g("power-off"):g("power-on"),children:c.jsx(nt,{name:"power",size:14})})]},we.key)})():(()=>{const Re=we.value;return c.jsxs("div",{"data-roster-key":we.key,"data-position":ee,className:`nc-side-card${Q.has(Re.key)?" active":""}`,draggable:!0,onDragStart:Ge=>Ge.dataTransfer.setData("text/nc-session",Re.key),onClick:()=>a&&a(Re.key),onDoubleClick:()=>ze(Re.name,Re.node||ee,K.instanceId),children:[c.jsx(rr,{position:ee,itemKey:we.key,label:Re.name,canMove:P,onMove:(Ge,gt)=>T(ee,Ge,gt,se),onStep:Ge=>F(ee,we.key,Ge,se)}),c.jsx("span",{className:Re.attached?"nc-dot on":"nc-dot"}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:Re.name}),c.jsx("small",{children:Re.preview?Re.preview:Re.cmd?Re.cmd:g("windows").replace("{n}",String(Re.windows||0))})]}),Re.activity?c.jsx("span",{className:"nc-rel",children:_s(Re.activity)}):null,c.jsx("button",{className:`nc-pin${W.includes(we.key)?" on":""}`,title:g("pin"),onClick:Ge=>{Ge.stopPropagation(),U(we.key)},children:W.includes(we.key)?"★":"☆"}),c.jsx("button",{className:`nc-technical${Re.technical?" on":""}`,title:Re.technical?g("mark-normal"):g("mark-technical"),"aria-label":`${Re.technical?g("mark-normal"):g("mark-technical")} ${Re.name}`,onClick:Ge=>{Ge.stopPropagation(),_&&_(Re.name,!Re.technical,K.route||[])},children:"T"}),c.jsx("button",{className:"nc-menu",title:g("terminate"),onClick:Ge=>{Ge.stopPropagation(),window.confirm(g("terminate-confirm").replace("{name}",Re.name))&&f&&f(Re.name,K.route)},children:"⋯"})]},we.key)})()),ge.length===0&&c.jsx("div",{className:"nc-empty",children:g("no-sessions-short")})]})]},`nodo-${(K.route||[K.name]).join("/")}`)})]}),c.jsx("div",{className:"nc-side-lang",children:C_.map((K,ee)=>c.jsxs("span",{children:[ee>0&&" · ",c.jsx("button",{className:`nc-lang-btn${A===K?" on":""}`,onClick:()=>ne(K),title:K,children:K.toUpperCase()})]},K))}),c.jsx("div",{className:"nc-side-resize",onPointerDown:We,title:""})]})}function FC({label:e,count:t,state:n,onToggle:s,onFilter:o}){return c.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:s,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),s())},children:[c.jsx("span",{className:"nc-node-chevron",children:n.open?"⌄":"›"}),c.jsx("span",{className:"nc-dot on"}),c.jsx("b",{children:e}),c.jsxs("small",{children:[" · ",g("node-sessions").replace("{n}",String(t))]}),c.jsxs("select",{className:"nc-node-filter",value:n.filter,title:g(`view-${n.filter}`),onClick:a=>a.stopPropagation(),onChange:a=>o(a.target.value),children:[c.jsx("option",{value:"all",children:g("view-all")}),c.jsx("option",{value:"pinned",children:g("view-pinned")}),c.jsx("option",{value:"active",children:g("view-active")}),c.jsx("option",{value:"off",children:g("view-off")}),c.jsx("option",{value:"technical",children:g("view-technical")})]})]})}function $C(e,t,n){return!e&&t?n+1:n}const Bh="nc_input_preferences_v1",Bu="nc-input-preferences",Hy=Object.freeze(["double-tap","single-tap","never"]),Lr=Object.freeze({terminalKeyboardGesture:"double-tap",keybarKeepsKeyboardClosed:!0,voiceKeepsKeyboardClosed:!0,showKeybarEnter:!0});function Oh(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return{terminalKeyboardGesture:Hy.includes(t.terminalKeyboardGesture)?t.terminalKeyboardGesture:Lr.terminalKeyboardGesture,keybarKeepsKeyboardClosed:typeof t.keybarKeepsKeyboardClosed=="boolean"?t.keybarKeepsKeyboardClosed:Lr.keybarKeepsKeyboardClosed,voiceKeepsKeyboardClosed:typeof t.voiceKeepsKeyboardClosed=="boolean"?t.voiceKeepsKeyboardClosed:Lr.voiceKeepsKeyboardClosed,showKeybarEnter:typeof t.showKeybarEnter=="boolean"?t.showKeybarEnter:Lr.showKeybarEnter}}function Wy(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function cv(e=Wy()){if(!e)return{...Lr};try{return Oh(JSON.parse(e.getItem(Bh)||"null"))}catch{return{...Lr}}}function HC(e,t=Wy()){const n=Oh(e);if(t)try{t.setItem(Bh,JSON.stringify(n))}catch{}return n}function zh(){const[e,t]=R.useState(cv);R.useEffect(()=>{const s=o=>{if((o==null?void 0:o.type)==="storage"&&o.key!==Bh&&o.key!==null)return;const a=o!=null&&o.detail?Oh(o.detail):cv();t(a)};return window.addEventListener(Bu,s),window.addEventListener("storage",s),()=>{window.removeEventListener(Bu,s),window.removeEventListener("storage",s)}},[]);const n=R.useCallback(s=>{t(o=>{const a=HC({...o,...s||{}});return window.dispatchEvent(new CustomEvent(Bu,{detail:a})),a})},[]);return[e,n]}function WC({session:e,node:t,ownerId:n,cellName:s,token:o,readonly:a=!1,focused:u,onFocus:h,onClose:p,onOpenSingle:f,alive:_=!0,available:b=!0,fontSize:y=jo,onZoom:w,decks:S=[],currentDeck:x,onSendToDeck:C}){const[k]=zh(),N=s||e,I=R.useRef(()=>{}),D=R.useRef(()=>!1),X=R.useRef(()=>{}),V=R.useRef(!1),[A,ne]=R.useState(!1),[W,Z]=R.useState(!1),[U,H]=R.useState(!1),[j,P]=R.useState(null),[T,F]=R.useState(0),te=R.useRef(_),M=t?`${t}:${e}`:e,ie=S.filter(B=>B.id!==x&&B.available!==!1);return R.useEffect(()=>{const B=te.current;!B&&_&&F(L=>$C(B,_,L)),te.current=_},[_]),c.jsxs("div",{className:`nc-tile${u?" focused":""}`,onMouseDown:()=>h&&h(M),children:[c.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:B=>{B.dataTransfer.setData("text/nc-session",M),B.dataTransfer.effectAllowed="move"},children:[c.jsxs("button",{className:"nc-tile-name",onClick:()=>h&&h(M),title:t?`${N} · ${t}`:N,children:[c.jsx("span",{className:_?"nc-dot on":"nc-dot"}),c.jsx("b",{children:N})]}),c.jsxs("span",{className:"nc-tile-actions",children:[w&&c.jsx("button",{onClick:()=>w(-1),title:g("zoom-out"),children:c.jsx(nt,{name:"zoomOut",size:14})}),w&&c.jsx("button",{onClick:()=>w(1),title:g("zoom-in"),children:c.jsx(nt,{name:"zoomIn",size:14})}),C&&ie.length>0&&c.jsxs("select",{className:"nc-tile-deck",title:g("send-to-deck"),value:"",onMouseDown:B=>B.stopPropagation(),onChange:B=>{const L=B.target.value;L&&C(M,L),B.target.value=""},children:[c.jsx("option",{value:"",children:g("send-to-deck")}),ie.map(B=>c.jsxs("option",{value:B.id,children:[B.ownerLabel," · ",B.name]},B.id))]}),c.jsx("button",{onClick:()=>Z(B=>!B),title:"composer",children:"⌨"}),c.jsx("button",{onClick:()=>H(B=>!B),title:"file",children:"📁"}),f&&c.jsx("button",{onClick:()=>f({session:e,node:t,ownerId:n}),title:"vista singola",children:"↗"}),p&&c.jsx("button",{className:"nc-tile-close",onClick:()=>p(M),title:"chiudi",children:"✕"})]})]}),c.jsxs("div",{className:"nc-tile-body",children:[b?c.jsx(Ly,{session:e,node:t,token:o,readonly:a,takeSize:!1,focused:u,sendRef:I,composerRef:D,actionRef:X,ctrlRef:V,setCtrlArmed:ne,onFiles:P,fontSize:y,keyboardGesture:k.terminalKeyboardGesture},`${M}:${T}`):c.jsx("div",{className:"nc-tile-unavailable",children:g("deck-owner-unavailable")}),b&&U&&c.jsx("div",{className:"nc-tile-files",onMouseDown:B=>B.stopPropagation(),children:c.jsx(Dy,{session:e,node:t,token:o,filesEvent:j,onClose:()=>H(!1)})})]}),b&&W&&c.jsx("div",{className:"nc-tile-composer",onMouseDown:B=>B.stopPropagation(),children:c.jsx($y,{submitText:B=>D.current(B),token:o,session:e,node:t,ownerId:n,keepKeyboardClosedOnVoice:k.voiceKeepsKeyboardClosed})})]})}function UC({session:e,node:t,ownerId:n,cells:s,nodeGroups:o}={}){const a=typeof e=="string"?e:"";if(!a)return null;if(t){const h=Array.isArray(o)?o:[];for(const p of h){if(!p||(Array.isArray(p.route)?p.route:[]).join("/")!==t||n&&p.instanceId&&String(n)!==String(p.instanceId))continue;const _=(Array.isArray(p.cells)?p.cells:[]).find(b=>b&&b.tmuxSession===a);if(_)return _}return null}return(Array.isArray(s)?s:[]).find(h=>h&&h.tmuxSession===a)||null}function Fh({session:e,cell:t,node:n,ownerId:s,cells:o,nodeGroups:a}={}){const u=typeof e=="string"?e:"";if(t&&typeof t.cell=="string"&&t.cell)return t.cell;const h=UC({session:u,node:n,ownerId:s,cells:o,nodeGroups:a});return h&&h.cell?h.cell:u}const uv=.2,dv=.28,Uy=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),Ou=e=>Uy(e,"text/nc-session"),hv=e=>{var t;return Uy(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function KC(e,t,n){const s=(e-n.left)/(n.width||1),o=(t-n.top)/(n.height||1);return s<dv?"left":s>1-dv?"right":o<.5?"top":"bottom"}function qC({layout:e,onLayoutChange:t,token:n,readonly:s=!1,sessionsAlive:o,focusSession:a,onFocus:u,onOpenSingle:h,decks:p=[],currentDeck:f,onSendToDeck:_,cells:b=[],nodeGroups:y=[]}){On();const[w,S]=R.useState(null),x=R.useRef(null),C=R.useRef([]),k=R.useRef(null);function N(U,H){const j=()=>{window.removeEventListener("pointermove",U),window.removeEventListener("pointerup",j),window.removeEventListener("pointercancel",j),window.removeEventListener("blur",j),k.current=null};window.addEventListener("pointermove",U),window.addEventListener("pointerup",j),window.addEventListener("pointercancel",j),window.addEventListener("blur",j),k.current=j}R.useEffect(()=>()=>{k.current&&k.current()},[]),R.useEffect(()=>{const U=()=>S(null);return window.addEventListener("dragend",U),window.addEventListener("drop",U),()=>{window.removeEventListener("dragend",U),window.removeEventListener("drop",U)}},[]);const I=e.columns.length,D=U=>w&&w.col===U&&w.row===void 0,X=!!w&&w.col===I,V=(U,H)=>w&&w.col===U&&w.row===H&&w.quadrant?` drop-${w.quadrant}`:"";function A(U){if(U.preventDefault(),hv(U.dataTransfer)){S(null);return}const H=U.dataTransfer.getData("text/nc-session"),j=w;if(S(null),!H||!j)return;let P;if(j.quadrant){if(P=A0(e,j.col,j.row,j.quadrant),!P)return}else P={col:j.col};t(gi(e).includes(H)?j0(e,H,P):Ch(e,H,P))}function ne(U,H){U.preventDefault(),U.stopPropagation();const j=U.clientX,P=e.columns[H].width,T=x.current&&x.current.clientWidth||1,F=e.columns[H+1];N(M=>{let ie=Math.max(uv,P+(M.clientX-j)/T);if(F){const B=tg(ie/(ie+F.width));ie=B/(1-B)*F.width}t(D0(e,H,ie))})}function W(U,H,j){U.preventDefault(),U.stopPropagation();const P=U.clientY,T=e.columns[H].tiles[j].height,F=C.current[H],te=F&&F.clientHeight||1,M=e.columns[H].tiles[j+1];N(B=>{let L=Math.max(uv,T+(B.clientY-P)/te);if(M){const z=tg(L/(L+M.height));L=z/(1-z)*M.height}t(M0(e,H,j,L))})}function Z(U){t(gl(e,U))}return c.jsxs("div",{className:"nc-grid",ref:x,onDragOver:U=>{if(hv(U.dataTransfer)){U.preventDefault(),S(null);return}Ou(U.dataTransfer)&&(U.preventDefault(),w&&w.col===I||S({col:I}))},onDrop:A,onDragLeave:U=>{const H=U.relatedTarget;(!H||!(x.current&&x.current.contains(H)))&&S(null)},children:[e.columns.flatMap((U,H)=>{const j=[];return j.push(c.jsx("div",{className:`nc-col${D(H)?" drop-newcol":""}`,ref:P=>{C.current[H]=P},style:{flexGrow:U.width,flexBasis:0},onDragOver:P=>{Ou(P.dataTransfer)&&(P.preventDefault(),P.stopPropagation(),w&&w.col===H&&w.row===void 0||S({col:H}))},children:U.tiles.flatMap((P,T)=>{const F=[],te=An(P),M=Fh({session:P.session,node:P.node,ownerId:P.ownerId,cells:b,nodeGroups:y});return F.push(c.jsx("div",{className:`nc-tile-slot${V(H,T)}`,style:{flexGrow:P.height,flexBasis:0},onDragOver:ie=>{if(!Ou(ie.dataTransfer))return;ie.preventDefault(),ie.stopPropagation();const B=KC(ie.clientX,ie.clientY,ie.currentTarget.getBoundingClientRect());w&&w.col===H&&w.row===T&&w.quadrant===B||S({col:H,row:T,quadrant:B})},children:c.jsx(WC,{session:P.session,node:P.node,ownerId:P.ownerId,cellName:M,token:n,readonly:s,focused:a===te,onFocus:u,onClose:Z,onOpenSingle:h,available:P.unavailable!==!0,alive:P.unavailable!==!0&&(!o||o.has(te)),fontSize:P.fontSize,onZoom:ie=>t(T0(e,H,T,ie)),decks:p,currentDeck:f,onSendToDeck:_})},te)),T<U.tiles.length-1&&F.push(c.jsx("div",{className:"nc-divider-h",onPointerDown:ie=>W(ie,H,T)},`h${T}`)),F})},`c${H}`)),H<I-1&&j.push(c.jsx("div",{className:"nc-divider-v",onPointerDown:P=>ne(P,H)},`v${H}`)),j}),X&&c.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),I===0&&c.jsx("div",{className:"nc-grid-empty",children:g("grid-empty")})]})}const pi="local",In=/^[a-f0-9]{16,64}$/;function vs(e,t){return`${e&&In.test(e)?e:pi}:${t}`}function Dl(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!==pi&&!In.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===pi?null:s,name:o}}function Ml(e){return Array.isArray(e)&&e.length?e.join("/"):""}function $h(e){return{columns:Mr(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))}}function VC(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&In.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(Ml(n.route),n.instanceId);return t}function YC(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&In.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(n.instanceId,[...n.route]);return t}function sh(e,t,n=[]){const s=$h(e),o=VC(n);for(const a of s.columns)for(const u of a.tiles)u.ownerId||(!u.node&&In.test(String(t||""))?u.ownerId=t:u.node&&o.has(u.node)&&(u.ownerId=o.get(u.node)));return s}function oh(e,t,n=[]){const s=$h(e),o=new Map;for(const a of n)a&&In.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=Ml(o.get(u.ownerId)),delete u.unavailable):u.unavailable=!0);return s}function fv(e,t,n=[]){const s=$h(e),o=YC(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=Ml(o.get(u.ownerId))));return s}function Ky(e,t,n=[]){const s=cr(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...In.test(String(t||""))?{ownerId:t}:{}};const o=n.find(a=>Ml(a&&a.route)===s.node);return{...s,...o&&In.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const XC=/^[a-z0-9-]{1,32}$/,Bn="main",qy="nc_decks",Vy="nc_deck_order_v1",Yy=24;function pv(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function bs(e){return typeof e=="string"&&XC.test(e)}function GC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let n;try{n=decodeURIComponent(t[1])}catch{n=t[1]}return bs(n)?n:Bn}return Bn}function JC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:vs(null,Bn),ownerId:null,name:Bn}}if(In.test(s)&&bs(o))return{id:vs(s,o),ownerId:s,name:o}}const n=GC(e);return{id:vs(null,n),ownerId:null,name:n}}function zu(e,t){const n=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:Dl(e)||{ownerId:null,name:e},s=bs(n.name)?n.name:Bn,o=n.ownerId?`/deck/${encodeURIComponent(n.ownerId)}/${encodeURIComponent(s)}`:s===Bn?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function Xy(e){return e===Bn?"nc_grid_v1":`nc_grid_v1__${e}`}function Gy(e){const t=[Bn];if(Array.isArray(e)){for(const n of e)if(bs(n)&&n!==Bn&&!t.includes(n)&&t.push(n),t.length>=Yy)break}return t}function Ns(){return typeof localStorage<"u"?localStorage:null}function QC(){const e=Ns();if(!e)return[Bn];try{return Gy(JSON.parse(e.getItem(qy)||"null"))}catch{return[Bn]}}function ZC(e){const t=Ns();if(t)try{t.setItem(qy,JSON.stringify(Gy(e)))}catch{}}function Io(e){return e==="local"||In.test(String(e||""))}function Tl(e,t){const n=Dl(e);return!!n&&(n.ownerId||"local")===t}function _i(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,s]of Object.entries(e).slice(0,64)){if(!Io(n)||!Array.isArray(s))continue;const o=[...new Set(s.filter(a=>typeof a=="string"&&a.length<=100&&Tl(a,n)))].slice(0,Yy);o.length&&(t[n]=o)}return t}function Qa(e=Ns()){if(!e)return{};try{return _i(JSON.parse(e.getItem(Vy)||"null"))}catch{return{}}}function Fu(e,t=Ns()){const n=_i(e);if(t)try{t.setItem(Vy,JSON.stringify(n))}catch{}return n}function Al(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function eE(e,t,n,s,o=[]){if(!Io(t)||n===s)return _i(e);const a=[...new Set(o.filter(b=>Tl(b,t)))];if(!a.includes(n)||!a.includes(s))return _i(e);const u=Al(e,t).filter(b=>a.includes(b)),h=[...u,...a.filter(b=>!u.includes(b))],p=h.indexOf(n),f=h.indexOf(s);h.splice(p,1);const _=h.indexOf(s);return h.splice(p<f?_+1:_,0,n),_i({...e,[t]:h})}function tE(e,t,n,s){if(!Io(t)||!Tl(s,t))return _i(e);const o=Al(e,t);return o.includes(n)?_i({...e,[t]:o.map(a=>a===n?s:a)}):_i(e)}function nE(e,t,n){return Io(t)?_i({...e,[t]:Al(e,t).filter(s=>s!==n)}):_i(e)}function mv(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)||"");!Io(a)||!Tl(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=Al(t,a),h=new Map(u.map((p,f)=>[p,f]));o.sort((p,f)=>{const _=h.has(p.id)?h.get(p.id):Number.MAX_SAFE_INTEGER,b=h.has(f.id)?h.get(f.id):Number.MAX_SAFE_INTEGER;return _-b}),s.push(...o)}return s}function ah(e){const t=Ns();if(!t)return null;try{return JSON.parse(t.getItem(Xy(e))||"null")}catch{return null}}function iE(e,t){const n=Ns();if(n)try{n.setItem(Xy(e),JSON.stringify(t))}catch{}}const Hh="nc_deckbar_collapsed_v1",Jy=64;function Wh(e){return e===pi||In.test(String(e||""))}function Uh(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>=Jy)break;if(Wh(s)){if(o===!0)t[s]=!0;else if(o===!1)t[s]=!1;else continue;n+=1}}return t}function Qy(e,t){return Wh(t)&&Object.prototype.hasOwnProperty.call(e||{},t)?e[t]===!0:!0}function rE(e,t){const n=Uh(e);return Wh(t)&&(!Object.prototype.hasOwnProperty.call(n,t)&&Object.keys(n).length>=Jy&&delete n[Object.keys(n)[0]],n[t]=!Qy(n,t)),n}function Zy(){return typeof localStorage<"u"?localStorage:null}function gv(e=Zy()){if(!e)return{};try{return Uh(JSON.parse(e.getItem(Hh)||"null"))}catch{return{}}}function sE(e,t=Zy()){const n=Uh(e);if(t)try{t.setItem(Hh,JSON.stringify(n))}catch{}return n}function oE(){const[e,t]=R.useState(gv);R.useEffect(()=>{const o=a=>{(a.key===Hh||a.key===null)&&t(gv())};return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]);const n=R.useCallback(o=>Qy(e,o),[e]),s=R.useCallback(o=>{t(a=>sE(rE(a,o)))},[]);return{collapsed:e,isCollapsed:n,toggle:s}}const Kh="nc_deck_presence_v1",vv=3e4,aE=18e4,ew=1e4,tw=32,lE=/^[A-Za-z0-9_-]{1,64}$/,cE=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),_v="working",uE="on",dE="neutral",hE="warn";function qh(e){return typeof e=="string"&&lE.test(e)&&!cE.has(e)}function nw(e){return typeof e=="string"&&Dl(e)!==null}function Vh(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function ks(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>=tw)break;qh(s)&&(!o||typeof o!="object"||nw(o.deckId)&&Vh(o.ts)&&(t[s]={deckId:o.deckId,ts:o.ts,focus:o.focus===!0,visible:o.visible===!0},n+=1))}return t}function iw(e,t){const n=ks(e);if(!Vh(t))return n;const s={};for(const[o,a]of Object.entries(n)){const u=a.visible?vv:aE,h=t-u;a.ts>=h&&a.ts<=t+vv&&(s[o]=a)}return s}function yv(e,t,n,s){if(!qh(t)||!Vh(s))return ks(e);const o=iw(e,s);if(!nw(n==null?void 0:n.deckId))return o;if(!Object.prototype.hasOwnProperty.call(o,t)&&Object.keys(o).length>=tw){let a="",u=1/0;for(const[h,p]of Object.entries(o))p.ts<u&&(a=h,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},ks(o)}function fE(e,t){const n=ks(e);if(!qh(t))return n;const s={...n};return delete s[t],s}function pE(e,t){const n=iw(e,t),s={};for(const o of Object.values(n)){const a=o.focus&&o.visible?_v:uE;s[o.deckId]!==_v&&(s[o.deckId]=a)}return s}function rw(){return typeof localStorage<"u"?localStorage:null}function Za(e=rw()){if(!e)return{};try{return ks(JSON.parse(e.getItem(Kh)||"null"))}catch{return{}}}function $u(e,t=rw()){const n=ks(e);if(t)try{t.setItem(Kh,JSON.stringify(n))}catch{}return n}const mE=Math.min(ew,5e3);function gE(){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 vE=gE();function wv(){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 _E(e,t=!0){const s=R.useRef(vE).current,o=R.useRef(e);o.current=e;const[a,u]=R.useState(()=>({map:{},now:Date.now()})),h=R.useCallback(()=>{u({map:Za(),now:Date.now()})},[]);R.useEffect(()=>{if(!t)return;const _=()=>{const C=Date.now(),k=yv(Za(),s,{deckId:o.current,...wv()},C);return $u(k),{map:k,now:C}},b=()=>u(_());b();const y=setInterval(_,ew),w=setInterval(h,mE),S=b,x=C=>{(C.key===Kh||C.key===null)&&h()};return window.addEventListener("focus",S),window.addEventListener("blur",S),typeof document<"u"&&document.addEventListener("visibilitychange",S),window.addEventListener("storage",x),()=>{clearInterval(y),clearInterval(w),window.removeEventListener("focus",S),window.removeEventListener("blur",S),typeof document<"u"&&document.removeEventListener("visibilitychange",S),window.removeEventListener("storage",x);try{$u(fE(Za(),s))}catch{}}},[t,s,h]),R.useEffect(()=>{if(!t)return;const _=Date.now(),b=yv(Za(),s,{deckId:e,...wv()},_);$u(b),u({map:b,now:_})},[e,t,s]);const p=R.useMemo(()=>t?pE(a.map,a.now):{},[t,a]);return{dotFor:R.useCallback((_,b=!1)=>t?b?hE:p[_]||dE:null,[p,t]),windowId:s}}const Sv=52,bv=18;function yE({ownerKey:e,deckId:t,label:n,onMove:s,onStep:o}){const a=R.useRef(null),u=R.useRef(0),[h,p]=R.useState(!1),f=()=>{var x,C,k,N;const S=a.current;(C=(x=S==null?void 0:S.over)==null?void 0:x.classList)==null||C.remove("nc-deck-over"),(N=(k=S==null?void 0:S.source)==null?void 0:k.classList)==null||N.remove("nc-deck-dragging"),u.current&&cancelAnimationFrame(u.current),u.current=0},_=(S=!1)=>{const x=a.current;if(!x)return;const C=x.target;f(),a.current=null,p(!1);try{x.handle.releasePointerCapture(x.pointerId)}catch{}S&&C&&C!==t&&s(t,C)},b=(S,x)=>{var D,X,V,A,ne,W,Z,U;const C=a.current;if(!C)return;C.x=S,C.y=x;const k=(X=(D=document.elementFromPoint(S,x))==null?void 0:D.closest)==null?void 0:X.call(D,"[data-deck-id][data-owner-key]"),N=(V=k==null?void 0:k.dataset)==null?void 0:V.deckId,I=((A=k==null?void 0:k.dataset)==null?void 0:A.ownerKey)===e&&N&&N!==t;C.over!==(I?k:null)&&((W=(ne=C.over)==null?void 0:ne.classList)==null||W.remove("nc-deck-over"),C.over=I?k:null,(U=(Z=C.over)==null?void 0:Z.classList)==null||U.add("nc-deck-over")),C.target=I?N:null},y=()=>{var C,k;const S=a.current;if(!S){u.current=0;return}const x=(k=(C=S.container)==null?void 0:C.getBoundingClientRect)==null?void 0:k.call(C);if(x){const N=S.x<x.left+Sv?-bv:S.x>x.right-Sv?bv:0;N&&(S.container.scrollLeft+=N,b(S.x,S.y))}u.current=requestAnimationFrame(y)};R.useEffect(()=>{const S=C=>{C.key==="Escape"&&a.current&&(C.preventDefault(),_(!1))},x=()=>_(!1);return window.addEventListener("keydown",S),window.addEventListener("blur",x),()=>{window.removeEventListener("keydown",S),window.removeEventListener("blur",x),f(),a.current=null}},[t,e]);const w=S=>{var k;if(S.pointerType==="mouse"&&S.button!==0)return;S.preventDefault(),S.stopPropagation(),S.currentTarget.focus({preventScroll:!0});const x=S.currentTarget.closest("[data-deck-id][data-owner-key]"),C=S.currentTarget.closest(".nc-deckbar");a.current={pointerId:S.pointerId,handle:S.currentTarget,source:x,container:C,target:null,over:null,x:S.clientX,y:S.clientY},(k=x==null?void 0:x.classList)==null||k.add("nc-deck-dragging");try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}p(!0),u.current=requestAnimationFrame(y)};return c.jsx("button",{type:"button",className:`nc-deck-handle${h?" active":""}`,"aria-label":`${g("reorder")} ${n}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:g("reorder-deck-help"),onClick:S=>{S.preventDefault(),S.stopPropagation()},onDragStart:S=>S.preventDefault(),onKeyDown:S=>{S.key!=="ArrowLeft"&&S.key!=="ArrowRight"||(S.preventDefault(),S.stopPropagation(),o(S.key==="ArrowLeft"?-1:1))},onPointerDown:w,onPointerMove:S=>{!a.current||S.pointerId!==a.current.pointerId||(S.preventDefault(),S.stopPropagation(),b(S.clientX,S.clientY))},onPointerUp:S=>{!a.current||S.pointerId!==a.current.pointerId||(S.preventDefault(),S.stopPropagation(),_(!0))},onPointerCancel:()=>_(!1),onLostPointerCapture:()=>{a.current&&_(!1)},children:"↔"})}function wE({decks:e=[],currentDeck:t="local:main",onCreate:n,onRename:s,onDelete:o,onReorder:a,onOpenWindow:u,onNavigate:h,saveState:p="idle",error:f="",sidebarVisible:_,onToggleSidebar:b}){On();const{isCollapsed:y,toggle:w}=oE(),{dotFor:S}=_E(t),[x,C]=R.useState(null),[k,N]=R.useState(""),[I,D]=R.useState(!1),[X,V]=R.useState(""),[A,ne]=R.useState(""),W=pv(k),Z=bs(W),U=[];for(const F of e){const te=F.local?"local":F.ownerId;let M=U.find(ie=>ie.key===te);M||(M={key:te,label:F.ownerLabel||(F.local?"Local":te),local:!!F.local,decks:[]},U.push(M)),M.decks.push(F)}const H=async()=>{if(Z){D(!0),V("");try{n&&await n(W,x),N(""),C(null)}catch(F){V(String(F.message||F))}D(!1)}},j=F=>{ne(""),u&&u(F.id)||ne(F.id)},P=async F=>{if(!(F.id===t||!h||I||F.available===!1)){D(!0),V("");try{await h(F.id)}catch(te){V(String((te==null?void 0:te.message)||te))}D(!1)}},T=(F,te,M)=>{const ie=F.decks.findIndex(L=>L.id===te.id),B=F.decks[ie+M];ie>=0&&B&&a&&!I&&a(te.id,B.id)};return c.jsxs("div",{className:"nc-deckbar",children:[b&&c.jsx("button",{className:"nc-deck-sidebar-toggle",title:g("toggle-sidebar"),onClick:b,children:_?"◀":"☰"}),c.jsx("span",{className:"nc-deckbar-label",children:g("decks")}),c.jsx("div",{className:"nc-deck-chips",children:U.map(F=>{const te=y(F.key),M=`nc-deck-content-${F.key}`,ie=F.local?"Local":F.label,B=F.decks.some(G=>G.id===t),L=(F.decks.find(G=>G.id===t)||{}).name,z=g(F.decks.length===1?"owner-deck-count-one":"owner-deck-count-many").replace("{count}",F.decks.length);return c.jsxs("span",{className:`nc-deck-owner-group${te?" collapsed":""}`,"data-owner-key":F.key,"data-collapsed":te?"1":"0",children:[c.jsxs("button",{type:"button",className:"nc-deck-owner-toggle","aria-expanded":!te,"aria-controls":M,title:g(te?"expand-owner":"collapse-owner").replace("{owner}",ie),onClick:()=>{!te&&x===F.key&&(N(""),C(null)),w(F.key)},children:[c.jsx("span",{className:"nc-deck-owner-caret","aria-hidden":"true",children:te?"▸":"▾"}),c.jsx("span",{className:"nc-deck-owner",children:ie})]}),te&&c.jsxs("span",{className:"nc-deck-summary",title:z,children:[c.jsx("span",{className:"nc-deck-summary-count",children:F.decks.length}),B&&c.jsxs("span",{className:"nc-deck-summary-current",children:["• ",L]})]}),c.jsxs("span",{id:M,className:"nc-deck-owner-content",hidden:te,children:[F.decks.map(G=>{const oe=S(G.id,G.available===!1);return c.jsxs("span",{"data-deck-id":G.id,"data-owner-key":F.key,className:`nc-deck-chip${G.id===t?" current":""}${G.available===!1?" offline":""}`,children:[oe&&c.jsx(SE,{state:oe}),c.jsx(yE,{ownerKey:F.key,deckId:G.id,label:`${F.label} · ${G.name}`,onMove:(de,me)=>{a&&!I&&a(de,me)},onStep:de=>T(F,G,de)}),c.jsxs("button",{className:"nc-deck-open",title:G.available===!1?`${G.ownerLabel} offline`:G.id===t?g("deck-current"):`${G.ownerLabel} · ${G.name}`,disabled:I||G.available===!1,onClick:()=>P(G),children:[G.name,G.id===t?" •":""]}),c.jsx("button",{className:"nc-deck-mini",disabled:G.available===!1,title:g("detach-deck"),onClick:()=>j(G),children:"↗"}),G.name!==Bn&&c.jsxs(c.Fragment,{children:[c.jsx("button",{className:"nc-deck-mini",disabled:G.available===!1,title:g("rename-deck"),onClick:()=>{const de=(typeof window<"u"?window.prompt(g("rename-deck"),G.name):"")||"",me=pv(de);bs(me)&&me!==G.name&&s&&s(G.id,me).catch(Q=>V(String(Q.message||Q)))},children:"✎"}),c.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:G.available===!1,title:g("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(g("delete-deck-confirm").replace("{name}",`${G.ownerLabel} · ${G.name}`)))&&o&&o(G.id).catch(de=>V(String(de.message||de)))},children:"✕"})]})]},G.id)}),x===F.key?c.jsxs("span",{className:"nc-deck-add",children:[c.jsx("input",{autoFocus:!0,className:Z||!k?"":"invalid",placeholder:g("deck-name"),value:k,onChange:G=>N(G.target.value),onKeyDown:G=>{G.key==="Enter"&&H(),G.key==="Escape"&&(N(""),C(null))}}),k&&Z&&W!==k&&c.jsxs("span",{className:"nc-deck-slug",children:["→ ",W]}),c.jsx("button",{className:"nc-deck-ok",disabled:!Z||I,onClick:H,children:g("create")}),c.jsx("button",{className:"nc-deck-cancel",onClick:()=>{N(""),C(null)},children:g("cancel")})]}):c.jsxs("button",{className:"nc-deck-newbtn",disabled:I||F.decks.every(G=>G.available===!1),title:`${g("new-deck")} · ${F.label}`,onClick:()=>{N(""),C(F.key)},children:["+ ",g("new")]})]})]},F.key)})}),c.jsx("span",{className:`nc-deck-state ${p}`,title:g("deck-autosave"),children:g(p==="saving"?"saving":p==="saved"?"saved":"deck-autosave")}),(X||f)&&c.jsx("span",{className:"nc-deck-error",children:X||f}),A&&c.jsx("button",{className:"nc-deck-fallback",onClick:()=>u&&u(A),children:g("popup-blocked")})]})}function SE({state:e}){if(!e)return null;const t=g(`dot-${e}`);return c.jsx("span",{className:`nc-deck-dot ${e}`,role:"img","aria-label":t,title:t})}var fs={},Hu,kv;function bE(){return kv||(kv=1,Hu=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Hu}var Wu={},tr={},xv;function zr(){if(xv)return tr;xv=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 tr.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},tr.getSymbolTotalCodewords=function(s){return t[s]},tr.getBCHDigit=function(n){let s=0;for(;n!==0;)s++,n>>>=1;return s},tr.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},tr.isKanjiModeEnabled=function(){return typeof e<"u"},tr.toSJIS=function(s){return e(s)},tr}var Uu={},Cv;function Yh(){return Cv||(Cv=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}}})(Uu)),Uu}var Ku,Ev;function kE(){if(Ev)return Ku;Ev=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++}},Ku=e,Ku}var qu,Nv;function xE(){if(Nv)return qu;Nv=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]},qu=e,qu}var Vu={},Rv;function CE(){return Rv||(Rv=1,(function(e){const t=zr().getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const o=Math.floor(s/7)+2,a=t(s),u=a===145?26:Math.ceil((a-13)/(2*o-2))*2,h=[a-7];for(let p=1;p<o-1;p++)h[p]=h[p-1]-u;return h.push(6),h.reverse()},e.getPositions=function(s){const o=[],a=e.getRowColCoords(s),u=a.length;for(let h=0;h<u;h++)for(let p=0;p<u;p++)h===0&&p===0||h===0&&p===u-1||h===u-1&&p===0||o.push([a[h],a[p]]);return o}})(Vu)),Vu}var Yu={},Pv;function EE(){if(Pv)return Yu;Pv=1;const e=zr().getSymbolSize,t=7;return Yu.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},Yu}var Xu={},jv;function NE(){return jv||(jv=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.getPenaltyN1=function(o){const a=o.size;let u=0,h=0,p=0,f=null,_=null;for(let b=0;b<a;b++){h=p=0,f=_=null;for(let y=0;y<a;y++){let w=o.get(b,y);w===f?h++:(h>=5&&(u+=t.N1+(h-5)),f=w,h=1),w=o.get(y,b),w===_?p++:(p>=5&&(u+=t.N1+(p-5)),_=w,p=1)}h>=5&&(u+=t.N1+(h-5)),p>=5&&(u+=t.N1+(p-5))}return u},e.getPenaltyN2=function(o){const a=o.size;let u=0;for(let h=0;h<a-1;h++)for(let p=0;p<a-1;p++){const f=o.get(h,p)+o.get(h,p+1)+o.get(h+1,p)+o.get(h+1,p+1);(f===4||f===0)&&u++}return u*t.N2},e.getPenaltyN3=function(o){const a=o.size;let u=0,h=0,p=0;for(let f=0;f<a;f++){h=p=0;for(let _=0;_<a;_++)h=h<<1&2047|o.get(f,_),_>=10&&(h===1488||h===93)&&u++,p=p<<1&2047|o.get(_,f),_>=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 h=0;h<u;h++)for(let p=0;p<u;p++)a.isReserved(p,h)||a.xor(p,h,n(o,p,h))},e.getBestMask=function(o,a){const u=Object.keys(e.Patterns).length;let h=0,p=1/0;for(let f=0;f<u;f++){a(f),e.applyMask(f,o);const _=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(f,o),_<p&&(p=_,h=f)}return h}})(Xu)),Xu}var el={},Lv;function sw(){if(Lv)return el;Lv=1;const e=Yh(),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 el.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}},el.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}},el}var Gu={},go={},Dv;function RE(){if(Dv)return go;Dv=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]})(),go.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},go.exp=function(s){return e[s]},go.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},go}var Mv;function PE(){return Mv||(Mv=1,(function(e){const t=RE();e.mul=function(s,o){const a=new Uint8Array(s.length+o.length-1);for(let u=0;u<s.length;u++)for(let h=0;h<o.length;h++)a[u+h]^=t.mul(s[u],o[h]);return a},e.mod=function(s,o){let a=new Uint8Array(s);for(;a.length-o.length>=0;){const u=a[0];for(let p=0;p<o.length;p++)a[p]^=t.mul(o[p],u);let h=0;for(;h<a.length&&a[h]===0;)h++;a=a.slice(h)}return a},e.generateECPolynomial=function(s){let o=new Uint8Array([1]);for(let a=0;a<s;a++)o=e.mul(o,new Uint8Array([1,t.exp(a)]));return o}})(Gu)),Gu}var Ju,Tv;function jE(){if(Tv)return Ju;Tv=1;const e=PE();function t(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(s){this.degree=s,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(s.length+this.degree);o.set(s);const a=e.mod(o,this.genPoly),u=this.degree-a.length;if(u>0){const h=new Uint8Array(this.degree);return h.set(a,u),h}return a},Ju=t,Ju}var Qu={},Zu={},ed={},Av;function ow(){return Av||(Av=1,ed.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),ed}var hi={},Iv;function aw(){if(Iv)return hi;Iv=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
+ ]))+`;hi.KANJI=new RegExp(n,"g"),hi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),hi.BYTE=new RegExp(s,"g"),hi.NUMERIC=new RegExp(e,"g"),hi.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+n+"$"),a=new RegExp("^"+e+"$"),u=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return hi.testKanji=function(p){return o.test(p)},hi.testNumeric=function(p){return a.test(p)},hi.testAlphanumeric=function(p){return u.test(p)},hi}var Bv;function Fr(){return Bv||(Bv=1,(function(e){const t=ow(),n=aw();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}}})(Zu)),Zu}var Ov;function LE(){return Ov||(Ov=1,(function(e){const t=zr(),n=sw(),s=Yh(),o=Fr(),a=ow(),u=7973,h=t.getBCHDigit(u);function p(y,w,S){for(let x=1;x<=40;x++)if(w<=e.getCapacity(x,S,y))return x}function f(y,w){return o.getCharCountIndicator(y,w)+4}function _(y,w){let S=0;return y.forEach(function(x){const C=f(x.mode,w);S+=C+x.getBitsLength()}),S}function b(y,w){for(let S=1;S<=40;S++)if(_(y,S)<=e.getCapacity(S,w,o.MIXED))return S}e.from=function(w,S){return a.isValid(w)?parseInt(w,10):S},e.getCapacity=function(w,S,x){if(!a.isValid(w))throw new Error("Invalid QR Code version");typeof x>"u"&&(x=o.BYTE);const C=t.getSymbolTotalCodewords(w),k=n.getTotalCodewordsCount(w,S),N=(C-k)*8;if(x===o.MIXED)return N;const I=N-f(x,w);switch(x){case o.NUMERIC:return Math.floor(I/10*3);case o.ALPHANUMERIC:return Math.floor(I/11*2);case o.KANJI:return Math.floor(I/13);case o.BYTE:default:return Math.floor(I/8)}},e.getBestVersionForData=function(w,S){let x;const C=s.from(S,s.M);if(Array.isArray(w)){if(w.length>1)return b(w,C);if(w.length===0)return 1;x=w[0]}else x=w;return p(x.mode,x.getLength(),C)},e.getEncodedBits=function(w){if(!a.isValid(w)||w<7)throw new Error("Invalid QR Code version");let S=w<<12;for(;t.getBCHDigit(S)-h>=0;)S^=u<<t.getBCHDigit(S)-h;return w<<12|S}})(Qu)),Qu}var td={},zv;function DE(){if(zv)return td;zv=1;const e=zr(),t=1335,n=21522,s=e.getBCHDigit(t);return td.getEncodedBits=function(a,u){const h=a.bit<<3|u;let p=h<<10;for(;e.getBCHDigit(p)-s>=0;)p^=t<<e.getBCHDigit(p)-s;return(h<<10|p)^n},td}var nd={},id,Fv;function ME(){if(Fv)return id;Fv=1;const e=Fr();function t(n){this.mode=e.NUMERIC,this.data=n.toString()}return t.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){let o,a,u;for(o=0;o+3<=this.data.length;o+=3)a=this.data.substr(o,3),u=parseInt(a,10),s.put(u,10);const h=this.data.length-o;h>0&&(a=this.data.substr(o),u=parseInt(a,10),s.put(u,h*3+1))},id=t,id}var rd,$v;function TE(){if($v)return rd;$v=1;const e=Fr(),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)},rd=n,rd}var sd,Hv;function AE(){if(Hv)return sd;Hv=1;const e=Fr();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)},sd=t,sd}var od,Wv;function IE(){if(Wv)return od;Wv=1;const e=Fr(),t=zr();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)}},od=n,od}var ad={exports:{}},Uv;function BE(){return Uv||(Uv=1,(function(e){var t={single_source_shortest_paths:function(n,s,o){var a={},u={};u[s]=0;var h=t.PriorityQueue.make();h.push(s,0);for(var p,f,_,b,y,w,S,x,C;!h.empty();){p=h.pop(),f=p.value,b=p.cost,y=n[f]||{};for(_ in y)y.hasOwnProperty(_)&&(w=y[_],S=b+w,x=u[_],C=typeof u[_]>"u",(C||x>S)&&(u[_]=S,h.push(_,S),a[_]=f))}if(typeof o<"u"&&typeof u[o]>"u"){var k=["Could not find a path from ",s," to ",o,"."].join("");throw new Error(k)}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})(ad)),ad.exports}var Kv;function OE(){return Kv||(Kv=1,(function(e){const t=Fr(),n=ME(),s=TE(),o=AE(),a=IE(),u=aw(),h=zr(),p=BE();function f(k){return unescape(encodeURIComponent(k)).length}function _(k,N,I){const D=[];let X;for(;(X=k.exec(I))!==null;)D.push({data:X[0],index:X.index,mode:N,length:X[0].length});return D}function b(k){const N=_(u.NUMERIC,t.NUMERIC,k),I=_(u.ALPHANUMERIC,t.ALPHANUMERIC,k);let D,X;return h.isKanjiModeEnabled()?(D=_(u.BYTE,t.BYTE,k),X=_(u.KANJI,t.KANJI,k)):(D=_(u.BYTE_KANJI,t.BYTE,k),X=[]),N.concat(I,D,X).sort(function(A,ne){return A.index-ne.index}).map(function(A){return{data:A.data,mode:A.mode,length:A.length}})}function y(k,N){switch(N){case t.NUMERIC:return n.getBitsLength(k);case t.ALPHANUMERIC:return s.getBitsLength(k);case t.KANJI:return a.getBitsLength(k);case t.BYTE:return o.getBitsLength(k)}}function w(k){return k.reduce(function(N,I){const D=N.length-1>=0?N[N.length-1]:null;return D&&D.mode===I.mode?(N[N.length-1].data+=I.data,N):(N.push(I),N)},[])}function S(k){const N=[];for(let I=0;I<k.length;I++){const D=k[I];switch(D.mode){case t.NUMERIC:N.push([D,{data:D.data,mode:t.ALPHANUMERIC,length:D.length},{data:D.data,mode:t.BYTE,length:D.length}]);break;case t.ALPHANUMERIC:N.push([D,{data:D.data,mode:t.BYTE,length:D.length}]);break;case t.KANJI:N.push([D,{data:D.data,mode:t.BYTE,length:f(D.data)}]);break;case t.BYTE:N.push([{data:D.data,mode:t.BYTE,length:f(D.data)}])}}return N}function x(k,N){const I={},D={start:{}};let X=["start"];for(let V=0;V<k.length;V++){const A=k[V],ne=[];for(let W=0;W<A.length;W++){const Z=A[W],U=""+V+W;ne.push(U),I[U]={node:Z,lastCount:0},D[U]={};for(let H=0;H<X.length;H++){const j=X[H];I[j]&&I[j].node.mode===Z.mode?(D[j][U]=y(I[j].lastCount+Z.length,Z.mode)-y(I[j].lastCount,Z.mode),I[j].lastCount+=Z.length):(I[j]&&(I[j].lastCount=Z.length),D[j][U]=y(Z.length,Z.mode)+4+t.getCharCountIndicator(Z.mode,N))}}X=ne}for(let V=0;V<X.length;V++)D[X[V]].end=0;return{map:D,table:I}}function C(k,N){let I;const D=t.getBestModeForData(k);if(I=t.from(N,D),I!==t.BYTE&&I.bit<D.bit)throw new Error('"'+k+'" cannot be encoded with mode '+t.toString(I)+`.
84
+ Suggested mode is: `+t.toString(D));switch(I===t.KANJI&&!h.isKanjiModeEnabled()&&(I=t.BYTE),I){case t.NUMERIC:return new n(k);case t.ALPHANUMERIC:return new s(k);case t.KANJI:return new a(k);case t.BYTE:return new o(k)}}e.fromArray=function(N){return N.reduce(function(I,D){return typeof D=="string"?I.push(C(D,null)):D.data&&I.push(C(D.data,D.mode)),I},[])},e.fromString=function(N,I){const D=b(N,h.isKanjiModeEnabled()),X=S(D),V=x(X,I),A=p.find_path(V.map,"start","end"),ne=[];for(let W=1;W<A.length-1;W++)ne.push(V.table[A[W]].node);return e.fromArray(w(ne))},e.rawSplit=function(N){return e.fromArray(b(N,h.isKanjiModeEnabled()))}})(nd)),nd}var qv;function zE(){if(qv)return Wu;qv=1;const e=zr(),t=Yh(),n=kE(),s=xE(),o=CE(),a=EE(),u=NE(),h=sw(),p=jE(),f=LE(),_=DE(),b=Fr(),y=OE();function w(V,A){const ne=V.size,W=a.getPositions(A);for(let Z=0;Z<W.length;Z++){const U=W[Z][0],H=W[Z][1];for(let j=-1;j<=7;j++)if(!(U+j<=-1||ne<=U+j))for(let P=-1;P<=7;P++)H+P<=-1||ne<=H+P||(j>=0&&j<=6&&(P===0||P===6)||P>=0&&P<=6&&(j===0||j===6)||j>=2&&j<=4&&P>=2&&P<=4?V.set(U+j,H+P,!0,!0):V.set(U+j,H+P,!1,!0))}}function S(V){const A=V.size;for(let ne=8;ne<A-8;ne++){const W=ne%2===0;V.set(ne,6,W,!0),V.set(6,ne,W,!0)}}function x(V,A){const ne=o.getPositions(A);for(let W=0;W<ne.length;W++){const Z=ne[W][0],U=ne[W][1];for(let H=-2;H<=2;H++)for(let j=-2;j<=2;j++)H===-2||H===2||j===-2||j===2||H===0&&j===0?V.set(Z+H,U+j,!0,!0):V.set(Z+H,U+j,!1,!0)}}function C(V,A){const ne=V.size,W=f.getEncodedBits(A);let Z,U,H;for(let j=0;j<18;j++)Z=Math.floor(j/3),U=j%3+ne-8-3,H=(W>>j&1)===1,V.set(Z,U,H,!0),V.set(U,Z,H,!0)}function k(V,A,ne){const W=V.size,Z=_.getEncodedBits(A,ne);let U,H;for(U=0;U<15;U++)H=(Z>>U&1)===1,U<6?V.set(U,8,H,!0):U<8?V.set(U+1,8,H,!0):V.set(W-15+U,8,H,!0),U<8?V.set(8,W-U-1,H,!0):U<9?V.set(8,15-U-1+1,H,!0):V.set(8,15-U-1,H,!0);V.set(W-8,8,1,!0)}function N(V,A){const ne=V.size;let W=-1,Z=ne-1,U=7,H=0;for(let j=ne-1;j>0;j-=2)for(j===6&&j--;;){for(let P=0;P<2;P++)if(!V.isReserved(Z,j-P)){let T=!1;H<A.length&&(T=(A[H]>>>U&1)===1),V.set(Z,j-P,T),U--,U===-1&&(H++,U=7)}if(Z+=W,Z<0||ne<=Z){Z-=W,W=-W;break}}}function I(V,A,ne){const W=new n;ne.forEach(function(P){W.put(P.mode.bit,4),W.put(P.getLength(),b.getCharCountIndicator(P.mode,V)),P.write(W)});const Z=e.getSymbolTotalCodewords(V),U=h.getTotalCodewordsCount(V,A),H=(Z-U)*8;for(W.getLengthInBits()+4<=H&&W.put(0,4);W.getLengthInBits()%8!==0;)W.putBit(0);const j=(H-W.getLengthInBits())/8;for(let P=0;P<j;P++)W.put(P%2?17:236,8);return D(W,V,A)}function D(V,A,ne){const W=e.getSymbolTotalCodewords(A),Z=h.getTotalCodewordsCount(A,ne),U=W-Z,H=h.getBlocksCount(A,ne),j=W%H,P=H-j,T=Math.floor(W/H),F=Math.floor(U/H),te=F+1,M=T-F,ie=new p(M);let B=0;const L=new Array(H),z=new Array(H);let G=0;const oe=new Uint8Array(V.buffer);for(let pe=0;pe<H;pe++){const Ie=pe<P?F:te;L[pe]=oe.slice(B,B+Ie),z[pe]=ie.encode(L[pe]),B+=Ie,G=Math.max(G,Ie)}const de=new Uint8Array(W);let me=0,Q,q;for(Q=0;Q<G;Q++)for(q=0;q<H;q++)Q<L[q].length&&(de[me++]=L[q][Q]);for(Q=0;Q<M;Q++)for(q=0;q<H;q++)de[me++]=z[q][Q];return de}function X(V,A,ne,W){let Z;if(Array.isArray(V))Z=y.fromArray(V);else if(typeof V=="string"){let T=A;if(!T){const F=y.rawSplit(V);T=f.getBestVersionForData(F,ne)}Z=y.fromString(V,T||40)}else throw new Error("Invalid data");const U=f.getBestVersionForData(Z,ne);if(!U)throw new Error("The amount of data is too big to be stored in a QR Code");if(!A)A=U;else if(A<U)throw new Error(`
85
+ The chosen QR Code version cannot contain this amount of data.
86
+ Minimum version required to store current data is: `+U+`.
87
+ `);const H=I(A,ne,Z),j=e.getSymbolSize(A),P=new s(j);return w(P,A),S(P),x(P,A),k(P,ne,0),A>=7&&C(P,A),N(P,H),isNaN(W)&&(W=u.getBestMask(P,k.bind(null,P,ne))),u.applyMask(W,P),k(P,ne,W),{modules:P,version:A,errorCorrectionLevel:ne,maskPattern:W,segments:Z}}return Wu.create=function(A,ne){if(typeof A>"u"||A==="")throw new Error("No input text");let W=t.M,Z,U;return typeof ne<"u"&&(W=t.from(ne.errorCorrectionLevel,t.M),Z=f.from(ne.version),U=u.from(ne.maskPattern),ne.toSJISFunc&&e.setToSJISFunction(ne.toSJISFunc)),X(A,Z,W,U)},Wu}var ld={},cd={},Vv;function lw(){return Vv||(Vv=1,(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let s=n.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+n);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(a){return[a,a]}))),s.length===6&&s.push("F","F");const o=parseInt(s.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+s.slice(0,6).join("")}}e.getOptions=function(s){s||(s={}),s.color||(s.color={});const o=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,a=s.width&&s.width>=21?s.width:void 0,u=s.scale||4;return{width:a,scale:a?4:u,margin:o,color:{dark:t(s.color.dark||"#000000ff"),light:t(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},e.getScale=function(s,o){return o.width&&o.width>=s+o.margin*2?o.width/(s+o.margin*2):o.scale},e.getImageWidth=function(s,o){const a=e.getScale(s,o);return Math.floor((s+o.margin*2)*a)},e.qrToImageData=function(s,o,a){const u=o.modules.size,h=o.modules.data,p=e.getScale(u,a),f=Math.floor((u+a.margin*2)*p),_=a.margin*p,b=[a.color.light,a.color.dark];for(let y=0;y<f;y++)for(let w=0;w<f;w++){let S=(y*f+w)*4,x=a.color.light;if(y>=_&&w>=_&&y<f-_&&w<f-_){const C=Math.floor((y-_)/p),k=Math.floor((w-_)/p);x=b[h[C*u+k]?1:0]}s[S++]=x.r,s[S++]=x.g,s[S++]=x.b,s[S]=x.a}}})(cd)),cd}var Yv;function FE(){return Yv||(Yv=1,(function(e){const t=lw();function n(o,a,u){o.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=u,a.width=u,a.style.height=u+"px",a.style.width=u+"px"}function s(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(a,u,h){let p=h,f=u;typeof p>"u"&&(!u||!u.getContext)&&(p=u,u=void 0),u||(f=s()),p=t.getOptions(p);const _=t.getImageWidth(a.modules.size,p),b=f.getContext("2d"),y=b.createImageData(_,_);return t.qrToImageData(y.data,a,p),n(b,f,_),b.putImageData(y,0,0),f},e.renderToDataURL=function(a,u,h){let p=h;typeof p>"u"&&(!u||!u.getContext)&&(p=u,u=void 0),p||(p={});const f=e.render(a,u,p),_=p.type||"image/png",b=p.rendererOpts||{};return f.toDataURL(_,b.quality)}})(ld)),ld}var ud={},Xv;function $E(){if(Xv)return ud;Xv=1;const e=lw();function t(o,a){const u=o.a/255,h=a+'="'+o.hex+'"';return u<1?h+" "+a+'-opacity="'+u.toFixed(2).slice(1)+'"':h}function n(o,a,u){let h=o+a;return typeof u<"u"&&(h+=" "+u),h}function s(o,a,u){let h="",p=0,f=!1,_=0;for(let b=0;b<o.length;b++){const y=Math.floor(b%a),w=Math.floor(b/a);!y&&!f&&(f=!0),o[b]?(_++,b>0&&y>0&&o[b-1]||(h+=f?n("M",y+u,.5+w+u):n("m",p,0),p=0,f=!1),y+1<a&&o[b+1]||(h+=n("h",_),_=0)):p++}return h}return ud.render=function(a,u,h){const p=e.getOptions(u),f=a.modules.size,_=a.modules.data,b=f+p.margin*2,y=p.color.light.a?"<path "+t(p.color.light,"fill")+' d="M0 0h'+b+"v"+b+'H0z"/>':"",w="<path "+t(p.color.dark,"stroke")+' d="'+s(_,f,p.margin)+'"/>',S='viewBox="0 0 '+b+" "+b+'"',C='<svg xmlns="http://www.w3.org/2000/svg" '+(p.width?'width="'+p.width+'" height="'+p.width+'" ':"")+S+' shape-rendering="crispEdges">'+y+w+`</svg>
88
+ `;return typeof h=="function"&&h(null,C),C},ud}var Gv;function HE(){if(Gv)return fs;Gv=1;const e=bE(),t=zE(),n=FE(),s=$E();function o(a,u,h,p,f){const _=[].slice.call(arguments,1),b=_.length,y=typeof _[b-1]=="function";if(!y&&!e())throw new Error("Callback required as last argument");if(y){if(b<2)throw new Error("Too few arguments provided");b===2?(f=h,h=u,u=p=void 0):b===3&&(u.getContext&&typeof f>"u"?(f=p,p=void 0):(f=p,p=h,h=u,u=void 0))}else{if(b<1)throw new Error("Too few arguments provided");return b===1?(h=u,u=p=void 0):b===2&&!u.getContext&&(p=h,h=u,u=void 0),new Promise(function(w,S){try{const x=t.create(h,p);w(a(x,u,p))}catch(x){S(x)}})}try{const w=t.create(h,p);f(null,a(w,u,p))}catch(w){f(w)}}return fs.create=t.create,fs.toCanvas=o.bind(null,n.render),fs.toDataURL=o.bind(null,n.renderToDataURL),fs.toString=o.bind(null,function(a,u,h){return s.render(a,h)}),fs}var WE=HE();const UE=fh(WE);function Jv(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function KE(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const n=U0(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 qE(e,t,n=new Set,s=!1){if(!t||!t.ok)return e;const o=K0(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 Qv(e,t,n=new Set,s=!1){const o=String(t||"").trim(),a=KE(o);let u={...e,pairingUrl:o};return(a.kind==="complete"||a.kind==="partial")&&(u={...qE(u,a.decoded,n,s),pairingUrl:o}),{classification:a,form:u}}function cl(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=ar(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 VE(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||cl(a,n)||s||"").trim();return u&&(o.localName=u),o}function YE(){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 XE=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function GE(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 JE="modulepreload",QE=function(e){return"/"+e},Zv={},ZE=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let u=function(f){return Promise.all(f.map(_=>Promise.resolve(_).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),p=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));o=u(n.map(f=>{if(f=QE(f),f in Zv)return;Zv[f]=!0;const _=f.endsWith(".css"),b=_?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${b}`))return;const y=document.createElement("link");if(y.rel=_?"stylesheet":JE,_||(y.as="script"),y.crossOrigin="",y.href=f,p&&y.setAttribute("nonce",p),document.head.appendChild(y),_)return new Promise((w,S)=>{y.addEventListener("load",w),y.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${f}`)))})}))}function a(u){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=u,window.dispatchEvent(h),!h.defaultPrevented)throw u}return o.then(u=>{for(const h of u||[])h.status==="rejected"&&a(h.reason);return t().catch(a)})};class Xe{constructor(t,n,s,o,a){this._legacyCanvasSize=Xe.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),s&&typeof s=="object"?this._onDecode=n:(console.warn(s||o||a?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=n),n=typeof s=="object"?s:{},this._onDecodeError=n.onDecodeError||(typeof s=="function"?s:this._onDecodeError),this._calculateScanRegion=n.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||a||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=n.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let u=!1;if(t.hidden&&(t.hidden=!1,u=!0),document.body.contains(t)||(document.body.appendChild(t),u=!0),s=t.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(o=!!n.overlay,this.$overlay=n.overlay||document.createElement("div"),a=this.$overlay.style,a.position="absolute",a.display="none",a.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!o&&n.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}s.insertBefore(this.$overlay,this.$video.nextSibling)}n.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let h=window.getComputedStyle(t);h.display==="none"&&(t.style.setProperty("display","block","important"),u=!0),h.visibility!=="visible"&&(t.style.setProperty("visibility","visible","important"),u=!0),u&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),t.style.opacity="0",t.style.width="0",t.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),t.addEventListener("play",this._onPlay),t.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=Xe.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 Xe.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"),Xe._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"),Xe._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(),Xe._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?Xe._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&&(Xe._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(n(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(n(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,n,s,o,a=!1,u=!1){let h,p=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(h=n.scanRegion,s=n.qrEngine,o=n.canvas,a=n.disallowCanvasResizing||!1,u=n.alsoTryWithoutScanRegion||!1,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 f,_;[s,f]=await Promise.all([s||Xe.createQrEngine(),Xe._loadImage(t)]),[o,_]=Xe._drawToCanvas(f,h,o,a);let b;if(s instanceof Worker){let y=s;n||Xe._postWorkerMessageSync(y,"inversionMode","both"),b=await new Promise((w,S)=>{let x,C,k,N=-1;C=D=>{D.data.id===N&&(y.removeEventListener("message",C),y.removeEventListener("error",k),clearTimeout(x),D.data.data!==null?w({data:D.data.data,cornerPoints:Xe._convertPoints(D.data.cornerPoints,h)}):S(Xe.NO_QR_CODE_FOUND))},k=D=>{y.removeEventListener("message",C),y.removeEventListener("error",k),clearTimeout(x),S("Scanner error: "+(D?D.message||D:"Unknown Error"))},y.addEventListener("message",C),y.addEventListener("error",k),x=setTimeout(()=>k("timeout"),1e4);let I=_.getImageData(0,0,o.width,o.height);N=Xe._postWorkerMessageSync(y,"decode",I,[I.data.buffer])})}else b=await Promise.race([new Promise((y,w)=>window.setTimeout(()=>w("Scanner error: timeout"),1e4)),(async()=>{try{var[y]=await s.detect(o);if(!y)throw Xe.NO_QR_CODE_FOUND;return{data:y.rawValue,cornerPoints:Xe._convertPoints(y.cornerPoints,h)}}catch(w){if(y=w.message||w,/not implemented|service unavailable/.test(y))return Xe._disableBarcodeDetector=!0,Xe.scanImage(t,{scanRegion:h,canvas:o,disallowCanvasResizing:a,alsoTryWithoutScanRegion:u});throw`Scanner error: ${y}`}})()]);return p?b:b.data}catch(f){if(!h||!u)throw f;let _=await Xe.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:a});return p?_:_.data}finally{n||Xe._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,n,s,o=!0){Xe._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:n,blue:s,useIntegerApproximation:o})}setInversionMode(t){Xe._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=()=>ZE(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!Xe._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let n=navigator.userAgentData;return n&&n.brands.some(({brand:s})=>/Chromium/i.test(s))&&/mac ?OS/i.test(n.platform)&&await n.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:s,platformVersion:o})=>/arm/i.test(s||"arm")&&13<=parseInt(o||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let n=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-n)/2),y:Math.round((t.videoHeight-n)/2),width:n,height:n,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,n=t.videoWidth,s=t.videoHeight,o=t.offsetWidth,a=t.offsetHeight,u=t.offsetLeft,h=t.offsetTop,p=window.getComputedStyle(t),f=p.objectFit,_=n/s,b=o/a;switch(f){case"none":var y=n,w=s;break;case"fill":y=o,w=a;break;default:(f==="cover"?_>b:_<b)?(w=a,y=w*_):(y=o,w=y/_),f==="scale-down"&&(y=Math.min(y,n),w=Math.min(w,s))}var[S,x]=p.objectPosition.split(" ").map((k,N)=>{const I=parseFloat(k);return k.endsWith("%")?(N?a-w:o-y)*I/100:I});p=this._scanRegion.width||n,b=this._scanRegion.height||s,f=this._scanRegion.x||0;var C=this._scanRegion.y||0;_=this.$overlay.style,_.width=`${p/n*y}px`,_.height=`${b/s*w}px`,_.top=`${h+x+C/s*w}px`,s=/scaleX\(-1\)/.test(t.style.transform),_.left=`${u+(s?o-S-y:S)+(s?n-f-p:f)/n*y}px`,_.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 Xe.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!Xe._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=Xe.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!==Xe.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",n=[{width:{min:1024}},{width:{min:768}},{}],s=n.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...s,...n])try{let a=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),u=this._getFacingMode(a)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:a,facingMode:u}}catch{}throw"Camera not found."}async _restartVideoStream(){let t=this._paused;await this.pause(!0)&&!t&&this._active&&await this.start()}static _stopVideoStream(t){for(let n of t.getTracks())n.stop(),t.removeTrack(n)}_setVideoMirror(t){this.$video.style.transform="scaleX("+(t==="user"?-1:1)+")"}_getFacingMode(t){return(t=t.getVideoTracks()[0])?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(t,n,s,o=!1){s=s||document.createElement("canvas");let a=n&&n.x?n.x:0,u=n&&n.y?n.y:0,h=n&&n.width?n.width:t.videoWidth||t.width,p=n&&n.height?n.height:t.videoHeight||t.height;return o||(o=n&&n.downScaledWidth?n.downScaledWidth:h,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,h,p,0,0,s.width,s.height),[s,n]}static async _loadImage(t){if(t instanceof Image)return await Xe._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 Xe._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 Xe._postWorkerMessageSync(await t,n,s,o)}static _postWorkerMessageSync(t,n,s,o){if(!(t instanceof Worker))return-1;let a=Xe._workerMessageId++;return t.postMessage({id:a,type:n,data:s},o),a}}Xe.DEFAULT_CANVAS_SIZE=400;Xe.NO_QR_CODE_FOUND="No QR code found";Xe._disableBarcodeDetector=!1;Xe._workerMessageId=0;function e2({onResult:e,onClose:t}){const n=R.useRef(null),s=R.useRef(null),o=R.useRef(!1),[a,u]=R.useState("");R.useEffect(()=>{let p=!1;const f=n.current,_=b=>{p||o.current||(o.current=!0,e(b))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){u(g("qr-unsupported"));return}let b=!1;try{b=await Xe.hasCamera()}catch{b=!1}if(!b){u(g("qr-no-camera"));return}if(p||!f)return;const y=new Xe(f,w=>{const S=Jv(w);S&&_(S)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:w=>{const S=w.videoWidth||640,x=w.videoHeight||480,C=Math.max(1,Math.round(Math.min(S,x)*.92));return{x:Math.round((S-C)/2),y:Math.round((x-C)/2),width:C,height:C,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=y;try{await y.start()}catch(w){if(p)return;const S=w&&w.name||"";u(g(S==="NotAllowedError"||S==="SecurityError"?"qr-permission":S==="NotFoundError"||S==="OverconstrainedError"||S==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{p=!0;const b=s.current;if(b){try{b.stop()}catch{}try{b.destroy()}catch{}s.current=null}const y=f,w=y&&y.srcObject;if(w&&typeof w.getTracks=="function"){for(const S of w.getTracks())try{S.stop()}catch{}try{y.srcObject=null}catch{}}}},[]);const h=async p=>{const f=p.target.files&&p.target.files[0];if(p.target.value="",!!f)try{const _=await Xe.scanImage(f,{returnDetailedScanResult:!0}),b=Jv(_);if(!b)throw new Error("empty");o.current||(o.current=!0,e(b))}catch{u(g("pairing-qr-invalid"))}};return c.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:t,children:c.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:p=>p.stopPropagation(),children:[c.jsx("div",{className:"nc-sheet-head",children:c.jsx("b",{children:g("scan-qr")})}),c.jsx("video",{ref:n,className:"nc-qr-video",playsInline:!0,muted:!0}),a&&c.jsx("div",{className:"nc-err",role:"alert",children:a}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[g("qr-upload"),c.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:h})]}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:t,children:g("cancel")})]})]})})}const e_=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:"",localName:""});function cw({token:e,initial:t="",autoStart:n=!1,deviceDefault:s="",localNodeId:o="",localNameDefault:a="",readonly:u=!1,onSuccess:h,onBusyChange:p}){const[f,_]=R.useState(e_),[b,y]=R.useState(!1),[w,S]=R.useState(!1),[x,C]=R.useState("idle"),[k,N]=R.useState(null),[I,D]=R.useState(""),[X,V]=R.useState(!1),[A,ne]=R.useState(!1),W=R.useRef(YE()),Z=R.useRef(new Set),U=x==="busy",H=cl(f.localLabel||s,o)||a,j=A?f.localName:H;R.useEffect(()=>(p&&p(U),()=>{p&&p(!1)}),[U,p]);const P=async B=>{const L=String(B.pairingUrl||"").trim();if(W.current.start(L)){C("busy"),N(null),D("");try{await Hb(e,VE({...B,localName:A?B.localName:cl(B.localLabel||s,o)||a},{deviceDefault:s,localNodeId:o,localNameDefault:a})),C("ok"),y(!1),_(e_()),Z.current=new Set,V(!1),ne(!1),W.current.finish(),h&&await h()}catch(z){const G=GE(z);N(G),C("idle"),W.current.finish(),G.code==="peer-name-conflict"&&yd(G.suggestedName)&&(ne(!0),Z.current.add("localName"),_(oe=>({...oe,localName:G.suggestedName}))),(G.stage==="validation"||G.stage==="conflict"||G.stage==="ssh-start"||G.stage==="ssh-ready"||String(G.code||"").startsWith("ssh-"))&&y(!0)}}},T=(B,L=!0)=>{const{classification:z,form:G}=Qv(f,B,Z.current,X),oe=G.pairingUrl;if(N(null),D(""),x==="ok"&&C("idle"),_(G),z.kind==="invalid"){N({stage:"validation",code:"bad-link",message:g("pair-invalid-link"),hint:g("pair-invalid-hint"),retryable:!0});return}if(z.kind==="partial"){y(!0),D(z.missing.includes("ssh")?g("pair-missing-ssh"):g("pair-missing-name"));return}z.kind==="complete"&&L&&!u&&W.current.canAuto(oe)&&P(G)};R.useEffect(()=>{t&&T(t,n)},[]);const F=()=>{const B=String(f.pairingUrl||"").trim(),{classification:L,form:z}=Qv(f,B,Z.current,X);if(_(z),D(""),N(null),L.kind==="empty"){N({stage:"validation",message:g("pairing-required"),retryable:!0});return}if(L.kind==="invalid"){N({stage:"validation",code:"bad-link",message:g("pair-invalid-link"),hint:g("pair-invalid-hint"),retryable:!0});return}if(!z.ssh||!z.name){y(!0),D(z.ssh?g("pair-missing-name"):g("pair-missing-ssh"));return}if(z.label&&!ws(z.label)){N({stage:"validation",message:g("err-label"),retryable:!0});return}if(z.localLabel&&!ws(z.localLabel)){N({stage:"validation",message:g("err-label"),retryable:!0});return}const G=A?z.localName:cl(z.localLabel||s,o)||a;if(!yd(G)||G==="localhost"){y(!0),N({stage:"validation",code:"bad-local-name",message:g("err-local-name"),retryable:!0});return}W.current.reset(B),P(z)},te=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):D(g("pair-clipboard-empty"))}catch{D(g("pair-clipboard-denied"))}},M=(B,L)=>{Z.current.add(B),_(z=>({...z,[B]:L}))},ie=k&&k.stage&&(XE.includes(k.stage)||k.stage==="internal")?g(`pair-stage-${k.stage}`):g("pair-stage-generic");return c.jsxs("div",{className:"nc-set-form nc-pair-card",children:[c.jsx("div",{className:"nc-sheet-label",children:g("pair-card-title")}),c.jsx("div",{className:"nc-set-info",children:g("pair-card-help")}),c.jsx("input",{className:"nc-pair-input",placeholder:g("pair-paste-ph"),value:f.pairingUrl,disabled:u||U,onChange:B=>{_({...f,pairingUrl:B.target.value}),N(null),D("")},onPaste:B=>{const L=B.clipboardData&&B.clipboardData.getData("text")||"";L.trim()&&(B.preventDefault(),T(L))},onKeyDown:B=>{B.key==="Enter"&&(B.preventDefault(),F())}}),c.jsxs("div",{className:"nc-pair-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||U,onClick:te,children:g("pair-paste-btn")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||U,onClick:()=>S(!0),children:g("scan-qr")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:u||U,title:u?g("settings-readonly"):"",onClick:F,children:g("test-and-connect")})]}),c.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[U&&c.jsx("div",{className:"nc-pair-progress",children:g("pair-progress")}),x==="ok"&&c.jsx("div",{className:"nc-set-test ok",children:g("node-connected")}),I&&c.jsx("div",{className:"nc-set-hint nc-pair-notice",children:I}),k&&c.jsxs("div",{className:"nc-err",role:"alert",children:[c.jsx("b",{children:ie})," — ",k.message,k.hint&&c.jsx("div",{className:"nc-pair-hint",children:k.hint}),k.retryable&&c.jsx("div",{children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||U,onClick:F,children:g("pair-retry")})})]})]}),c.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:U,onClick:()=>y(B=>!B),children:[b?"▾":"▸"," ",g("pair-advanced")]}),b&&c.jsxs("div",{className:"nc-pair-advanced",children:[c.jsxs("label",{className:"nc-field",children:[g("node-display-label"),c.jsx("input",{placeholder:"Home Relay",value:f.label,disabled:u||U,onChange:B=>{Z.current.add("label"),_(L=>({...L,label:B.target.value,name:X?L.name:ar(B.target.value)}))}})]}),c.jsxs("label",{className:"nc-field",children:[g("node-name-label"),c.jsx("input",{placeholder:g("node-name-ph"),value:f.name,disabled:u||U,onChange:B=>{V(!0),Z.current.add("name"),_(L=>({...L,name:B.target.value?ar(B.target.value):""}))}})]}),c.jsx("small",{className:"nc-set-hint",children:g("node-slug-hint").replace("{slug}",f.name||"home-relay")}),c.jsxs("label",{className:"nc-field",children:[g("pair-ssh-local-label"),c.jsx("input",{placeholder:"my-relay",value:f.ssh,disabled:u||U,onChange:B=>{Z.current.add("ssh"),M("ssh",B.target.value)}}),c.jsx("small",{className:"nc-set-hint",children:g("node-ssh-local-help")})]}),c.jsxs("label",{className:"nc-field",children:[g("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",placeholder:g("node-ssh-port-help"),value:f.sshPort,disabled:u||U,onChange:B=>M("sshPort",B.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),c.jsxs("label",{className:"nc-field",children:[g("device-name-label"),c.jsx("input",{placeholder:s||"NexusCrew",value:f.localLabel,disabled:u||U,onChange:B=>M("localLabel",B.target.value)}),c.jsx("small",{className:"nc-set-hint",children:g("device-name-hint")})]}),c.jsxs("label",{className:"nc-field",children:[g("local-route-name-label"),c.jsx("input",{placeholder:H||"nexuscrew-5bd6",value:j,disabled:u||U,onChange:B=>{ne(!0),Z.current.add("localName"),_(L=>({...L,localName:B.target.value?ar(B.target.value):""}))}}),c.jsx("small",{className:"nc-set-hint",children:g("local-route-name-hint")})]})]}),w&&c.jsx(e2,{onResult:B=>{S(!1),T(B)},onClose:()=>S(!1)})]})}function Xh(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function t2(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 n2(){if(!Xh())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function i2(e){if(!Xh())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const n=await en("/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:t2(s)}),u=await en("/api/push/subscribe",e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:a.toJSON()})});if(!u.ok){try{await a.unsubscribe()}catch{}const h=await u.json().catch(()=>({}));throw new Error(h.error||`HTTP ${u.status}`)}return!0}async function r2(e){if(!Xh())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 en("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const lh="nexuscrew.fleet",uw=3,s2="nexuscrew.cells",dw=/^[A-Za-z0-9._-]{1,32}$/,Il=/^[a-z0-9._-]{1,32}$/,hw=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,fw=new Set(["standard","unsafe"]),o2=4096,a2=4096,Cl=256,pw=8192,l2=4096,c2=32,u2=24,d2=new Set(["format","version","exportedAt","cells","engines"]),h2=new Set(["id","cwdRel","engine","boot","model","models","permissionPolicies","commands","systemPrompt","prompt"]),f2=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]);function Rr(e){if(typeof e!="string"||e.length>a2)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 p2=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag"]),m2=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]);function ir(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function Gh(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 Co(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(!Il.test(o)||!t(a))return null;s[o]=a}return s}function mw(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(h=>!h2.has(h))||!dw.test(String(e.id||""))||typeof e.cwdRel!="string")return null;const t=Rr(e.cwdRel);if(t===null||!Il.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>Cl)||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>pw)return null;const s=Co(e.models,h=>typeof h=="string"&&!!h&&h.length<=Cl),o=Co(e.permissionPolicies,h=>fw.has(h)),a=Co(e.commands,h=>ir(h,l2)&&!Gh(h));if(s===null||o===null||a===null)return null;const u={id:e.id,cwdRel:t,engine:e.engine,boot:e.boot===!0,systemPrompt:n};return e.model&&(u.model=e.model),Object.keys(s).length&&(u.models=s),Object.keys(o).length&&(u.permissionPolicies=o),Object.keys(a).length&&(u.commands=a),u}function g2(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(a=>!f2.has(a))||!dw.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>o2||!Il.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>Cl)||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>pw)return null;const n=Co(e.models,a=>typeof a=="string"&&!!a&&a.length<=Cl),s=Co(e.permissionPolicies,a=>fw.has(a));if(n===null||s===null)return null;const o={id:e.id,cwd:e.cwd,engine:e.engine,boot:e.boot===!0,systemPrompt:t};return e.model&&(o.model=e.model),Object.keys(n).length&&(o.models=n),Object.keys(s).length&&(o.permissionPolicies=s),o}function v2(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(n=>!m2.has(n)))return null;const t={};for(const[n,s]of Object.entries(e)){if(typeof s!="string"||!ir(s,n==="baseUrl"?512:128)||Gh(s))return null;t[n]=s}return!t.client||!t.provider||t.envKey&&!hw.test(t.envKey)?null:t}function gw(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!p2.has(s))||!Il.test(String(e.id||""))||!ir(e.label||e.id,64)||e.rc!==void 0&&typeof e.rc!="boolean")return null;const t={id:e.id,label:e.label||e.id,rc:e.rc===!0};if(e.managed!==void 0){const s=v2(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!ir(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!ir(s,1024)||Gh(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!ir(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")||!ir(e.model.flag,32)||/\s/.test(e.model.flag)||!ir(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=>!hw.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 vw(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.managed?{id:e.id,label:e.label,rc:e.rc,managed:e.managed}:{id:e.id,label:e.label,rc:e.rc,command:e.command,args:e.args,envKeys:e.envKeys,model:e.model,promptMode:e.promptMode,promptFlag:e.promptFlag},n=gw(t);return n||null}function _2(e,t,n=[],s=[],o=new Date){n instanceof Date&&(o=n,n=[],s=[]);const a=t instanceof Set?t:new Set(t||[]),u=s instanceof Set?s:new Set(s||[]),h=[];for(const f of Array.isArray(e)?e:[]){if(!a.has(f.id))continue;const _=mw({id:f.id,cwdRel:f.cwdRel,engine:f.engine,boot:f.boot===!0,...f.model?{model:f.model}:{},...f.models?{models:f.models}:{},...f.permissionPolicies?{permissionPolicies:f.permissionPolicies}:{},systemPrompt:f.prompt||"",...f.commands?{commands:f.commands}:{}});if(!_)return{ok:!1,error:"invalid-cell",invalidCellIds:[f.id]};h.push(_)}const p=[];for(const f of Array.isArray(n)?n:[]){if(!u.has(f.id))continue;const _=vw(f);_&&p.push(_)}return{format:lh,version:uw,exportedAt:o.toISOString(),cells:h,engines:p}}function y2(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)===s2&&(t==null?void 0:t.version)===1,s=(t==null?void 0:t.format)===lh&&(t==null?void 0:t.version)===2,o=(t==null?void 0:t.format)===lh&&(t==null?void 0:t.version)===uw,a=n||s,u=s||o;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(b=>!d2.has(b))||!n&&!s&&!o||!Array.isArray(t.cells)||t.cells.length>c2||u&&(!Array.isArray(t.engines)||t.engines.length>u2))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const h=[],p=new Set;for(const b of t.cells){const y=a?g2(b):mw(b);if(!y)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(p.has(y.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};p.add(y.id),h.push(y)}const f=[],_=new Set;for(const b of u?t.engines:[]){const y=gw(b);if(!y)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(_.has(y.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};_.add(y.id),f.push(y)}return{ok:!0,cells:h,engines:f,legacy:a,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function w2(e,t,n){const s=new Set(n||[]);if(!s.has(t))return null;const o=f=>Object.fromEntries(Object.entries(f||{}).filter(([_])=>s.has(_))),a={id:e.id,engine:t,boot:e.boot===!0,prompt:e.systemPrompt||""};typeof e.cwdRel=="string"?a.cwdRel=e.cwdRel:typeof e.cwd=="string"&&e.cwd&&(a.cwd=e.cwd),t===e.engine&&e.model?a.model=e.model:e.models&&e.models[t]&&(a.model=e.models[t]);const u=o(e.models),h=o(e.permissionPolicies),p=o(e.commands);return Object.keys(u).length&&(a.models=u),Object.keys(h).length&&(a.permissionPolicies=h),Object.keys(p).length&&(a.commands=p),a}const S2=()=>({kind:"managed",id:"claude.native",label:"",client:"claude",provider:"native",credentialProfile:"",managedModel:"",permissionPolicy:"unsafe",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}),t_=(e="")=>({id:"",cwd:"",engine:e,boot:!1,model:"",prompt:"",commands:{},command:""}),_w=e=>e==="claude"?"unsafe":"standard",Po=(e,t)=>e.find(n=>n.client===t.client&&n.provider===t.provider&&(n.credentialProfile||"")===(t.credentialProfile||"")),b2=(e,t)=>{var n;return((n=Po(e,t))==null?void 0:n.label)||`${t.client} · ${t.provider}`};function k2(e){var t,n,s,o,a,u,h,p,f,_,b,y,w,S;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)||_w((u=e.managed)==null?void 0:u.client),displayName:((h=e.managed)==null?void 0:h.displayName)||"",protocol:((p=e.managed)==null?void 0:p.protocol)||"",baseUrl:((f=e.managed)==null?void 0:f.baseUrl)||"",envKey:((_=e.managed)==null?void 0:_.envKey)||"",providerId:((b=e.managed)==null?void 0:b.providerId)||"nexuscrew-custom",modelOptions:e.availableModels||((y=e.managedInfo)==null?void 0:y.models)||[],promptMode:e.promptMode||"send-keys",promptFlag:e.promptFlag||"",modelFlag:((w=e.model)==null?void 0:w.flag)||"",modelValue:((S=e.model)==null?void 0:S.value)||"",envRows:(e.envKeys||[]).map(x=>({key:x,value:"",configured:!0,remove:!1})),credentialValue:"",credentialReveal:!1,allowMissingCredential:!1}}function x2(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||_w(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile);const a=Po(n,e);return(a==null?void 0:a.credentialEnv)===!0&&(o.envKey=e.envKey),e.provider==="custom"&&Object.assign(o,{displayName:e.displayName,protocol:e.protocol,baseUrl:e.baseUrl,envKey:e.envKey,providerId:e.providerId}),{...t?{id:e.id}:{},label:e.label||b2(n,e),rc:!!e.rc,managed:o}}const s={...t?{id:e.id}:{},label:e.label||e.id,rc:!!e.rc,command:e.command,args:e.argsText.split(`
90
+ `).filter(o=>o!==""),promptMode:e.promptMode};return e.modelFlag&&(s.model={flag:e.modelFlag,value:e.modelValue||""}),e.promptMode==="flag"&&(s.promptFlag=e.promptFlag),t&&(s.env=Object.fromEntries(e.envRows.filter(o=>!o.remove&&o.key).map(o=>[o.key,o.value]))),s}function xr({children:e,onClose:t,label:n,error:s=""}){const o=R.useRef(null),a=R.useRef(null),u=R.useRef(t);return u.current=t,R.useEffect(()=>{const h=document.activeElement,p=o.current,f=()=>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(y=>y.offsetParent!==null),_=requestAnimationFrame(()=>{var y;return(y=f()[0]||p)==null?void 0:y.focus({preventScroll:!0})}),b=y=>{var C;if(y.key==="Escape"){y.preventDefault(),(C=u.current)==null||C.call(u);return}if(y.key!=="Tab")return;const w=f();if(!w.length){y.preventDefault(),p==null||p.focus();return}const S=w[0],x=w[w.length-1];y.shiftKey&&document.activeElement===S?(y.preventDefault(),x.focus()):!y.shiftKey&&document.activeElement===x&&(y.preventDefault(),S.focus())};return document.addEventListener("keydown",b),()=>{cancelAnimationFrame(_),document.removeEventListener("keydown",b),h&&h.isConnected&&typeof h.focus=="function"&&h.focus({preventScroll:!0})}},[]),R.useEffect(()=>{s&&requestAnimationFrame(()=>{var h;return(h=a.current)==null?void 0:h.scrollIntoView({block:"nearest"})})},[s]),c.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:h=>{h.target===h.currentTarget&&t()},children:c.jsxs("div",{ref:o,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":n||g("settings"),tabIndex:-1,children:[e,s&&c.jsx("div",{ref:a,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:s})]})})}function dd({token:e,targets:t=[],readonly:n=!1,onPower:s,onImport:o}){const[a,u]=R.useState([]),[h,p]=R.useState(0);R.useEffect(()=>{let C=!0;async function k(){const I=[{route:[],label:g("local")}].concat((t||[]).map(X=>({route:Array.isArray(X.route)?X.route:[],label:X.label||(X.route||[]).join(" › ")}))),D=await Promise.all(I.map(async X=>{const V={...X,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const A=await Br(e,X.route);V.available=!!A.available,V.capabilities=A.capabilities||[],V.provider=A.provider||null,V.cells=(A.cells||[]).map(ne=>({...ne,route:X.route}));try{V.readonly=!!(await yh(e,X.route)).readonlyDefault}catch{}try{const ne=await v_(e,X.route),W=new Set(V.cells.map(Z=>Z.tmuxSession).filter(Boolean));V.unmanaged=(ne.sessions||[]).filter(Z=>Z&&!W.has(Z.name))}catch{}}catch(A){V.err=String(A&&A.message||A)}return V}));C&&u(D)}k();const N=setInterval(k,6e3);return()=>{C=!1,clearInterval(N)}},[e,t,h]);const f=(C,k)=>Array.isArray(C.capabilities)&&C.capabilities.includes(k)&&!n&&!C.readonly,_=()=>p(C=>C+1),b=(C,k)=>{s&&s({...C,route:k})},y=(C,k)=>{s&&s({...C,route:k})},w=async(C,k)=>{try{await _o(e,C.cell,k)}catch{}_()},S=async(C,k)=>{if(window.confirm(g("fleet-remove-cell").replace("{id}",C.cell))){try{await p_(e,C.cell,!0,k)}catch{}_()}},x=async(C,k)=>{if(window.confirm(g("terminate-confirm").replace("{name}",C.name))){try{await vh(e,C.name,k)}catch{}_()}};return c.jsxs("div",{className:"nc-fleet-inventory",children:[c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:g("fleet-inventory")}),c.jsx("small",{children:g("fleet-inventory-help")})]}),a.map(C=>{const k=C.route.length?C.route.join("/"):"local";return c.jsxs("div",{className:"nc-fleet-pos",children:[c.jsxs("div",{className:"nc-fleet-pos-title",children:[c.jsx("span",{className:`dot ${C.available?"on":"warn"}`}),c.jsx("b",{children:C.label}),c.jsx("small",{children:C.available?`${C.cells.length} ${g("fleet-cells")} · ${C.unmanaged.length} ${g("fleet-tmux")}`:C.err||g("fleet-not-available")})]}),C.cells.map(N=>c.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[c.jsxs("span",{children:[c.jsx("b",{children:N.cell}),c.jsx("small",{children:`${N.engine||""}${N.key?`·${N.key}`:""}${N.active?"":` · ${g("cell-off")}`}`})]}),c.jsxs("span",{className:"nc-fleet-cell-actions",children:[N.active&&f(C,"down")&&c.jsx("button",{className:"nc-btn ghost",title:g("power-off"),onClick:()=>y(N,C.route),children:g("stop")}),!N.active&&f(C,"up")&&c.jsx("button",{className:"nc-btn ghost",title:g("power-on"),onClick:()=>b(N,C.route),children:g("start")}),f(C,"restart")&&N.active&&c.jsx("button",{className:"nc-btn ghost",title:g("restart"),onClick:()=>w(N,C.route),children:g("restart")}),f(C,"remove")&&c.jsx("button",{className:"nc-btn danger",title:g("delete"),onClick:()=>S(N,C.route),children:"×"})]})]},`${k}:${N.cell}`)),C.unmanaged.map(N=>c.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[c.jsxs("span",{children:[c.jsx("b",{children:N.name}),c.jsx("small",{children:g("fleet-tmux")})]}),c.jsxs("span",{className:"nc-fleet-cell-actions",children:[f(C,"import")&&o&&c.jsx("button",{className:"nc-btn ghost",title:g("import-as-cell"),onClick:()=>o(N,C.route),children:g("import-as-cell")}),c.jsx("button",{className:"nc-btn danger",title:g("terminate"),onClick:()=>x(N,C.route),children:"×"})]})]},`${k}:u:${N.name}`)),C.available&&C.cells.length===0&&C.unmanaged.length===0&&c.jsx("div",{className:"nc-empty",children:g("fleet-inventory-empty")})]},k)})]})}function C2({cells:e=[],engines:t=[],busy:n,canRestore:s=!1,onRestore:o,onClose:a}){const[u,h]=R.useState("export"),[p,f]=R.useState(()=>new Set(e.map(j=>j.id))),[_,b]=R.useState(()=>new Set(t.map(j=>j.id))),[y,w]=R.useState([]),[S,x]=R.useState([]),[C,k]=R.useState(""),N=new Set(t.map(j=>j.id)),I=new Set(e.map(j=>j.id)),D=(j,P)=>j(T=>{const F=new Set(T);return F.has(P)?F.delete(P):F.add(P),F}),X=()=>{const j=_2(e,p,t,_);if(j.ok===!1){k(g(`fleet-backup-${j.error}`));return}const P=e.filter(ie=>p.has(ie.id)).length,T=t.filter(ie=>_.has(ie.id)).length;if(j.cells.length!==P){k(g("fleet-backup-invalid-cell"));return}if(j.engines.length!==T){k(g("fleet-backup-invalid-engine"));return}if(!j.cells.length&&!j.engines.length){k(g("fleet-backup-select-one"));return}const F=new Blob([`${JSON.stringify(j,null,2)}
91
+ `],{type:"application/json"}),te=URL.createObjectURL(F),M=document.createElement("a");M.href=te,M.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(M),M.click(),M.remove(),setTimeout(()=>URL.revokeObjectURL(te),0),k("")},V=async j=>{if(k(""),w([]),x([]),!!j){if(j.size>1024*1024){k(g("fleet-backup-too-large"));return}try{const P=y2(await j.text());if(!P.ok){k(g(`fleet-backup-${P.error}`));return}const T=new Set(P.engines.map(F=>F.id));x(P.engines.map(F=>({engine:F,exists:N.has(F.id),selected:!N.has(F.id)}))),w(P.cells.map(F=>{const te=N.has(F.engine)||T.has(F.engine),M=I.has(F.id);return{cell:F,engine:te?F.engine:"",selected:te&&!M,exists:M}}))}catch(P){k(String(P.message||P))}}},A=(j,P)=>w(T=>T.map((F,te)=>te===j?{...F,...P}:F)),ne=(j,P)=>x(T=>T.map((F,te)=>te===j?{...F,...P}:F)),W=new Set([...N,...S.filter(j=>j.selected).map(j=>j.engine.id)]),Z=y.filter(j=>j.selected&&j.engine&&W.has(j.engine)),U=S.filter(j=>j.selected),H=[...new Map([...t.map(j=>[j.id,j.label||j.id]),...S.filter(j=>j.selected).map(j=>[j.engine.id,j.engine.label||j.engine.id])]).entries()];return c.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[c.jsx("b",{children:g("fleet-backup")}),c.jsx("small",{children:g("fleet-backup-help")}),c.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[c.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="export"?" on":""}`,onClick:()=>{h("export"),k("")},children:g("fleet-backup-export")}),c.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="import"?" on":""}`,disabled:!s,title:s?"":g("fleet-backup-restore-unavailable"),onClick:()=>{h("import"),k("")},children:g("fleet-backup-import")})]}),u==="export"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{f(new Set(e.map(j=>j.id))),b(new Set(t.map(j=>j.id)))},children:g("select-all")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{f(new Set),b(new Set)},children:g("select-none")})]}),c.jsxs("div",{className:"nc-backup-list",children:[c.jsx("b",{children:g("fleet-engines")}),t.map(j=>{var P;return c.jsxs("label",{className:"nc-check nc-backup-row",children:[c.jsx("input",{type:"checkbox",checked:_.has(j.id),onChange:()=>D(b,j.id)}),c.jsxs("span",{children:[c.jsx("b",{children:j.label||j.id}),c.jsxs("small",{children:[j.id,(P=j.envKeys)!=null&&P.length?` · ${j.envKeys.length} ${g("fleet-backup-env-names")}`:""]})]})]},j.id)}),c.jsx("b",{children:g("fleet-cells")}),e.map(j=>c.jsxs("label",{className:"nc-check nc-backup-row",children:[c.jsx("input",{type:"checkbox",checked:p.has(j.id),onChange:()=>D(f,j.id)}),c.jsxs("span",{children:[c.jsx("b",{children:j.id}),c.jsxs("small",{children:[j.engine," · ",g("fleet-system-prompt")," ",(j.prompt||"").length," ",g("characters")]})]})]},j.id)),!e.length&&!t.length&&c.jsx("div",{className:"nc-empty",children:g("fleet-backup-empty")})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:g("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:!p.size&&!_.size,onClick:X,children:g("fleet-backup-download")})]})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"file",accept:"application/json,.json",disabled:n,onChange:j=>V(j.target.files&&j.target.files[0])}),c.jsx("small",{children:g("fleet-backup-import-help")}),!!(y.length||S.length)&&c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{x(j=>j.map(P=>({...P,selected:!0}))),w(j=>j.map(P=>({...P,selected:!!P.engine})))},children:g("select-all")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{x(j=>j.map(P=>({...P,selected:!1}))),w(j=>j.map(P=>({...P,selected:!1})))},children:g("select-none")})]}),c.jsxs("div",{className:"nc-backup-list",children:[!!S.length&&c.jsx("b",{children:g("fleet-engines")}),S.map((j,P)=>{var T;return c.jsx("div",{className:"nc-backup-import-row",children:c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:j.selected,onChange:F=>ne(P,{selected:F.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:j.engine.label||j.engine.id}),c.jsxs("small",{children:[j.engine.id," · ",j.exists?g("fleet-backup-overwrite"):g("fleet-backup-new"),(T=j.engine.envKeys)!=null&&T.length?` · ${g("fleet-backup-env-values-required")}`:""]})]})]})},j.engine.id)}),!!y.length&&c.jsx("b",{children:g("fleet-cells")}),y.map((j,P)=>c.jsxs("div",{className:"nc-backup-import-row",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:j.selected,disabled:!j.engine||!W.has(j.engine),onChange:T=>A(P,{selected:T.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:j.cell.id}),c.jsxs("small",{children:[j.exists?g("fleet-backup-overwrite"):g("fleet-backup-new")," · ",g("fleet-system-prompt")," ",j.cell.systemPrompt.length," ",g("characters")]})]})]}),c.jsxs("select",{value:j.engine,onChange:T=>A(P,{engine:T.target.value,selected:!!T.target.value}),children:[c.jsx("option",{value:"",children:g("fleet-backup-engine-missing")}),H.map(([T,F])=>c.jsx("option",{value:T,children:F},T))]})]},j.cell.id))]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:g("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||!Z.length&&!U.length,onClick:()=>o({engineRows:S,cellRows:y}),children:g("fleet-backup-restore")})]})]}),C&&c.jsx("div",{className:"nc-err",children:C})]})}function E2({state:e,setState:t,busy:n,onSave:s,catalog:o}){var C;const a=e.form,u=k=>t({...e,form:{...a,...k}}),h=a.envRows||[],p=[...new Map(o.map(k=>[k.client,k.clientLabel||k.client])).entries()],f=o.filter(k=>k.client===a.client),_=Po(o,a),b=typeof(_==null?void 0:_.credentialEnv)=="string"?_.credentialEnv:"",y=Array.isArray(_==null?void 0:_.credentialUsedBy)?_.credentialUsedBy:[],w=(_==null?void 0:_.credentialSource)||"missing",S=!!b&&e.mode==="new"&&(_==null?void 0:_.authConfigured)!==!0&&!a.credentialValue&&!a.allowMissingCredential,x=k=>{k&&u({client:k.client,provider:k.provider,credentialProfile:k.credentialProfile||"",managedModel:k.model||"",protocol:k.protocol||"",permissionPolicy:k.permissionPolicyDefault||"standard",rc:!!k.rc,displayName:k.custom?g("fleet-custom-provider-default"):"",baseUrl:k.custom?"":k.endpoint||"",envKey:k.defaultEnvKey||"",providerId:"nexuscrew-custom",credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,...e.mode==="new"?{id:k.id,label:""}:{}})};return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsx("b",{children:e.mode==="new"?g("fleet-new-engine"):`${g("edit")} ${a.id}`}),c.jsx("input",{value:a.id,disabled:e.mode!=="new",placeholder:"id",onChange:k=>u({id:k.target.value})}),c.jsx("input",{value:a.label,placeholder:g("label"),onChange:k=>u({label:k.target.value})}),c.jsxs("select",{value:a.kind,disabled:e.mode!=="new",onChange:k=>u({kind:k.target.value}),children:[c.jsx("option",{value:"managed",children:g("fleet-managed")}),c.jsx("option",{value:"custom",children:g("fleet-custom")})]}),a.kind==="managed"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("select",{value:a.client,disabled:e.mode!=="new",onChange:k=>x(o.find(N=>N.client===k.target.value&&N.default)||o.find(N=>N.client===k.target.value)),children:p.map(([k,N])=>c.jsx("option",{value:k,children:N},k))}),c.jsx("select",{value:((C=Po(o,a))==null?void 0:C.id)||"",disabled:e.mode!=="new",onChange:k=>x(o.find(N=>N.id===k.target.value)),children:f.map(k=>c.jsx("option",{value:k.id,children:k.label},k.id))})]}),a.client!=="shell"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.managedModel,list:"nc-managed-models",placeholder:g(_!=null&&_.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:k=>u({managedModel:k.target.value})}),c.jsx("datalist",{id:"nc-managed-models",children:[...(_==null?void 0:_.models)||[],...a.modelOptions||[]].filter((k,N,I)=>k&&I.indexOf(k)===N).map(k=>c.jsx("option",{value:k},k))})]}),_!=null&&_.supportsUnsafe?c.jsxs("select",{value:a.permissionPolicy,onChange:k=>u({permissionPolicy:k.target.value}),children:[c.jsx("option",{value:"standard",children:g("fleet-standard-permissions")}),c.jsx("option",{value:"unsafe",children:g("fleet-unsafe-permissions")})]}):c.jsx("small",{children:g("fleet-standard-permissions")}),(_==null?void 0:_.supportsUnsafe)&&a.permissionPolicy==="unsafe"&&c.jsx("small",{className:"nc-err",children:g("fleet-unsafe-warning")}),(_==null?void 0:_.credentialEnv)===!0&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.envKey,placeholder:g("fleet-api-key-env"),onChange:k=>u({envKey:k.target.value})}),c.jsx("small",{children:g("fleet-custom-secret-help")})]}),b&&c.jsxs("section",{className:"nc-fleet-key","aria-label":g("fleet-key-section"),children:[c.jsxs("div",{className:"nc-fleet-key-head",children:[c.jsx("b",{children:g("fleet-key-section")}),c.jsx("span",{children:g(`fleet-credential-source-${w}`)})]}),c.jsxs("label",{className:"nc-field",children:[g("fleet-key-variable"),c.jsx("input",{value:b,readOnly:!0,"aria-label":g("fleet-key-variable")})]}),c.jsx("small",{children:y.length?g("fleet-key-used-by").replace("{engines}",y.join(", ")):g("fleet-key-used-by-none")}),y.length>0&&c.jsx("small",{children:g("fleet-key-shared-impact").replace("{key}",b).replace("{engines}",y.join(", "))}),c.jsxs("div",{className:"nc-fleet-key-input",children:[c.jsx("input",{type:a.credentialReveal?"text":"password",value:a.credentialValue||"","aria-label":g("fleet-key-value").replace("{key}",b),autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:_!=null&&_.authConfigured||e.mode==="edit"?g("fleet-key-blank-keeps"):g("fleet-key-enter"),onChange:k=>u({credentialValue:k.target.value,allowMissingCredential:k.target.value?!1:a.allowMissingCredential})}),c.jsx("button",{type:"button",className:"nc-btn ghost","aria-label":g(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal"),onClick:()=>u({credentialReveal:!a.credentialReveal}),children:g(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal")})]}),c.jsx("small",{children:g("fleet-key-local-help")}),e.mode==="new"&&(_==null?void 0:_.authConfigured)!==!0&&!a.credentialValue&&c.jsxs("label",{className:"nc-check nc-fleet-key-missing",children:[c.jsx("input",{type:"checkbox",checked:!!a.allowMissingCredential,onChange:k=>u({allowMissingCredential:k.target.checked})}),g("fleet-key-create-missing")]}),(_==null?void 0:_.notice)&&c.jsx("small",{className:"nc-fleet-provider-notice",children:g(`fleet-provider-notice-${_.notice}`)})]}),a.provider==="custom"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.displayName,placeholder:g("fleet-provider-display"),onChange:k=>u({displayName:k.target.value})}),c.jsx("input",{value:a.baseUrl,placeholder:"https://api.example.com/v1",onChange:k=>u({baseUrl:k.target.value})}),((_==null?void 0:_.protocols)||[]).length>1&&c.jsx("select",{value:a.protocol,onChange:k=>u({protocol:k.target.value}),children:_.protocols.map(k=>c.jsx("option",{value:k,children:k},k))}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:a.envKey,placeholder:g("fleet-api-key-env"),onChange:k=>u({envKey:k.target.value})}),c.jsx("input",{value:a.providerId,placeholder:g("fleet-provider-id"),onChange:k=>u({providerId:k.target.value})})]}),c.jsxs("small",{children:[a.protocol," · ",g("fleet-custom-secret-help")]})]}),c.jsx("small",{children:g(a.client==="shell"?"fleet-shell-engine-help":"fleet-managed-help")})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.command,placeholder:g("command-path"),onChange:k=>u({command:k.target.value})}),c.jsx("textarea",{value:a.argsText,placeholder:g("args-lines"),onChange:k=>u({argsText:k.target.value})}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:a.rc,onChange:k=>u({rc:k.target.checked})})," remote control"]}),c.jsxs("select",{value:a.promptMode,onChange:k=>u({promptMode:k.target.value}),children:[c.jsx("option",{value:"send-keys",children:"send-keys"}),c.jsx("option",{value:"flag",children:"flag"})]}),a.promptMode==="flag"&&c.jsx("input",{value:a.promptFlag,placeholder:"prompt flag",onChange:k=>u({promptFlag:k.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:a.modelFlag,placeholder:"model flag",onChange:k=>u({modelFlag:k.target.value})}),c.jsx("input",{value:a.modelValue,placeholder:"model default",onChange:k=>u({modelValue:k.target.value})})]}),c.jsx("small",{children:g("env-write-only")}),h.map((k,N)=>c.jsxs("div",{className:"nc-fleet-env",children:[c.jsx("input",{value:k.key,disabled:k.configured,placeholder:"ENV_KEY",onChange:I=>{const D=h.slice();D[N]={...k,key:I.target.value},u({envRows:D})}}),c.jsx("input",{type:"password",value:k.value,placeholder:k.configured?"•••••• (unchanged)":"value",onChange:I=>{const D=h.slice();D[N]={...k,value:I.target.value},u({envRows:D})}}),c.jsx("button",{className:"nc-btn danger",onClick:()=>u({envRows:h.filter((I,D)=>D!==N)}),children:"×"})]},`${k.key}-${N}`)),c.jsx("button",{className:"nc-btn ghost",onClick:()=>u({envRows:[...h,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>t(null),children:g("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:n||!a.id||S||a.kind==="custom"&&!a.command||a.kind==="managed"&&(_==null?void 0:_.requiresModel)&&!a.managedModel||a.kind==="managed"&&(_==null?void 0:_.credentialEnv)===!0&&!a.envKey||a.kind==="managed"&&a.provider==="custom"&&(!a.displayName||!a.baseUrl||!a.envKey||!a.providerId),onClick:s,children:g("save")})]})]})}function N2({token:e,route:t,targets:n=[],location:s,setLocation:o,state:a,setState:u,engines:h,busy:p,onSave:f}){var V;const[_,b]=R.useState(null),[y,w]=R.useState(""),S=a.form,x=A=>u({...a,form:{...S,...A}}),C=h.find(A=>A.id===S.engine),k=((V=C==null?void 0:C.managed)==null?void 0:V.client)==="shell",N=A=>{var Z,U,H,j;const ne=h.find(P=>P.id===A),W={...S.commands||{}};((Z=C==null?void 0:C.managed)==null?void 0:Z.client)==="shell"&&(S.command?W[S.engine]=S.command:delete W[S.engine]),x({engine:A,model:((U=S.models)==null?void 0:U[A])||((H=ne==null?void 0:ne.managed)==null?void 0:H.model)||((j=ne==null?void 0:ne.model)==null?void 0:j.value)||"",commands:W,command:W[A]||""})},I=A=>{const ne={...S.commands||{}};A?ne[S.engine]=A:delete ne[S.engine],x({command:A,commands:ne})},D=k&&/[|&;<>()`$*?{}\[\]~]/.test(S.command||""),X=async A=>{try{const ne=await _h(e,A,t);b(ne),x({cwd:ne.path}),w("")}catch(ne){w(String(ne.message||ne))}};return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsx("b",{children:a.mode==="new"?g("fleet-new-cell"):`${g("edit")} ${S.id}`}),a.mode==="new"&&c.jsxs("label",{className:"nc-field",children:[g("location"),c.jsx("span",{className:"nc-req",children:" *"}),c.jsxs("select",{value:s,onChange:A=>{o(A.target.value),x({engine:""})},children:[c.jsx("option",{value:"",children:g("local")}),n.map(A=>c.jsxs("option",{value:A.route.join("/"),disabled:A.status&&A.status!=="up",children:[A.label,A.status&&A.status!=="up"?` · ${g("node-offline")}`:""]},A.route.join("/")))]})]}),c.jsx("input",{value:S.id,disabled:a.mode!=="new",placeholder:"id",onChange:A=>x({id:A.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:S.cwd,placeholder:g("cwd"),onChange:A=>x({cwd:A.target.value})}),c.jsx("button",{className:"nc-btn ghost",onClick:()=>_?b(null):X(S.cwd),children:g("browse")})]}),_&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:_.path}),c.jsxs("div",{className:"nc-fs-list",children:[_.parent&&c.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>X(_.parent),children:["↑ ",g("fs-parent")]}),(_.dirs||[]).map(A=>c.jsxs("button",{className:"nc-fs-item",onClick:()=>X(`${_.path.replace(/\/$/,"")}/${A}`),children:["📁 ",A]},A))]})]}),y&&c.jsx("div",{className:"nc-err",children:y}),c.jsx("select",{value:S.engine,onChange:A=>N(A.target.value),children:h.map(A=>c.jsx("option",{value:A.id,children:A.label},A.id))}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:!!S.boot,onChange:A=>x({boot:A.target.checked})})," boot"]}),k?c.jsxs(c.Fragment,{children:[c.jsx("input",{value:S.command||"",maxLength:4096,placeholder:g("fleet-shell-command-placeholder"),onChange:A=>I(A.target.value)}),c.jsx("small",{children:S.command?g("fleet-shell-command-help"):g("fleet-shell-interactive")}),D&&c.jsx("small",{className:"nc-note",children:g("fleet-shell-command-metachar")})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{value:S.model||"",list:"nc-cell-models",placeholder:g("fleet-model-override"),onChange:A=>x({model:A.target.value})}),c.jsx("datalist",{id:"nc-cell-models",children:((C==null?void 0:C.availableModels)||[]).map(A=>c.jsx("option",{value:A},A))}),c.jsx("textarea",{value:S.prompt||"",placeholder:"prompt",onChange:A=>x({prompt:A.target.value})})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>u(null),children:g("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:p||!S.id||!S.cwd||!S.engine,onClick:f,children:g("save")})]})]})}function n_({token:e,route:t=[],state:n,setState:s,busy:o,onSave:a}){const[u,h]=R.useState(null),[p,f]=R.useState([]),[_,b]=R.useState(""),y=Array.isArray(t)?t.join("/"):"";R.useEffect(()=>{let k=!0;return gh(e,y?y.split("/"):[]).then(N=>{k&&(f(N.engines||[]),b(""))}).catch(N=>{k&&(f([]),b(String(N.message||N)))}),()=>{k=!1}},[e,y]);const w=n.form,S=k=>s({...n,form:{...w,...k}}),x=async k=>{try{const N=await _h(e,k,t);h(N),S({cwd:N.path})}catch{}},C=!w.id&&w.tmuxSession?w.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):w.id;return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsxs("b",{children:[g("import-as-cell")," · ",w.tmuxSession]}),c.jsx("small",{children:g("import-help")}),c.jsx("input",{value:w.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),c.jsx("input",{value:w.id,placeholder:g("name"),onChange:k=>S({id:k.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:w.cwd,placeholder:g("cwd"),onChange:k=>S({cwd:k.target.value})}),c.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>u?h(null):x(w.cwd),children:g("browse")})]}),u&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:u.path}),c.jsxs("div",{className:"nc-fs-list",children:[u.parent&&c.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>x(u.parent),children:["↑ ",g("fs-parent")]}),(u.dirs||[]).map(k=>c.jsxs("button",{className:"nc-fs-item",onClick:()=>x(`${u.path.replace(/\/$/,"")}/${k}`),children:["📁 ",k]},k))]})]}),c.jsxs("select",{value:w.engine,onChange:k=>S({engine:k.target.value}),children:[c.jsx("option",{value:"",children:g("import-engine-required")}),p.map(k=>c.jsx("option",{value:k.id,children:k.label},k.id))]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:!!w.boot,onChange:k=>S({boot:k.target.checked})})," boot"]}),(n.err||_)&&c.jsx("div",{className:"nc-err",children:n.err||_}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:g("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:o||!w.tmuxSession||!w.engine||!p.length,onClick:a,children:g(C?"import-as-cell":"save")})]})]})}function tl(e){const t=Rr(e);return t===null?`~/${e}`:t?`~/${t}`:"~"}function R2(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 P2({token:e,route:t,cell:n,busy:s=!1,onSaved:o,onClose:a}){const[u,h]=R.useState(""),[p,f]=R.useState(null),[_,b]=R.useState(!1),[y,w]=R.useState(""),S=typeof(n==null?void 0:n.cwdSuggestion)=="string"&&Rr(n.cwdSuggestion)!==null?Rr(n.cwdSuggestion):null,[x,C]=R.useState(S),k=n==null?void 0:n.id,N=s||_,I=async W=>{const Z=Rr(W);if(Z===null){f({rel:"",dirs:[],loading:!1,err:g("fleet-cwd-repair-invalid")});return}f({rel:Z,dirs:[],loading:!0,err:""});try{const U=await _h(e,Z,t),H=R2(U);f({rel:H,dirs:Array.isArray(U.dirs)?U.dirs:[],loading:!1,err:""})}catch(U){f({rel:Z,dirs:[],loading:!1,err:String(U&&U.message||U)})}},D=W=>{if(!p)return;const Z=p.rel?`${p.rel}/${W}`:W;I(Z)},X=()=>{p!=null&&p.rel&&I(p.rel.split("/").slice(0,-1).join("/"))},V=()=>{p&&(h(p.rel||""),f(null),w(""),C(null))},A=()=>{x!==null&&(h(x),C(null),w(""))},ne=async()=>{if(N)return;const W=Rr(u);if(W===null){w(g("fleet-cwd-repair-invalid"));return}const Z=tl(W);let U=!0;try{U=window.confirm(g("fleet-cwd-repair-confirm").replace("{id}",String(k||"")).replace("{path}",Z))}catch{U=!1}if(U){b(!0),w(""),C(null);try{const H=await f_(e,k,{cwdRel:W},t);o==null||o(H)}catch(H){const j=H&&H.data||{};if(j.code==="unportable-cwd"){w(g("fleet-cwd-repair-unportable"));const P=Array.isArray(j.cells)?j.cells.find(F=>F&&F.id===k):null,T=P&&typeof P.suggestion=="string"?P.suggestion:null;T!==null&&Rr(T)!==null&&C(T)}else w(String(H&&H.message||H))}finally{b(!1)}}};return c.jsxs("div",{className:"nc-set-form nc-fleet-form nc-cwd-repair",children:[c.jsx("b",{children:g("fleet-cwd-repair-title").replace("{id}",String(k||""))}),c.jsx("small",{className:"nc-set-info",children:g("fleet-cwd-repair-help")}),c.jsx("small",{className:"nc-cwd-no-source",children:g("fleet-cwd-repair-no-source-path")}),c.jsxs("label",{className:"nc-field",children:[g("cwd"),c.jsxs("div",{className:"nc-cwd-rel-row",children:[c.jsx("span",{className:"nc-cwd-rel-prefix",children:"~/"}),c.jsx("input",{value:u,placeholder:g("fleet-cwd-repair-placeholder"),autoComplete:"off",spellCheck:"false",autoCapitalize:"none",onChange:W=>h(W.target.value)}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:N,onClick:()=>p?f(null):I(""),children:g(p?"close":"fleet-cwd-repair-browse")})]})]}),c.jsx("div",{className:"nc-cwd-preview",children:g("fleet-cwd-repair-preview").replace("{path}",tl(u))}),p&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:tl(p.rel)}),c.jsxs("div",{className:"nc-fs-list",children:[p.rel&&c.jsxs("button",{type:"button",className:"nc-fs-item nc-fs-nav",onClick:X,children:["↑ ",g("fs-parent")]}),p.loading&&c.jsx("div",{className:"nc-fs-empty",children:"…"}),!p.loading&&p.dirs.length===0&&c.jsx("div",{className:"nc-fs-empty",children:g("fleet-cwd-repair-fs-empty")}),!p.loading&&p.dirs.map(W=>c.jsxs("button",{type:"button",className:"nc-fs-item",onClick:()=>D(W),children:["📁 ",W]},W))]}),p.err&&c.jsx("div",{className:"nc-err",children:p.err}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{type:"button",className:"nc-btn primary",disabled:N||p.loading||!!p.err,onClick:V,children:g("fleet-cwd-repair-use-current")})})]}),y&&c.jsx("div",{className:"nc-err",role:"alert",children:y}),x!==null&&c.jsxs("div",{className:"nc-cwd-suggestion",role:"status",children:[c.jsx("span",{children:g("fleet-cwd-repair-suggestion")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:A,children:g("fleet-cwd-repair-use-suggestion").replace("{path}",tl(x))})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:_,onClick:a,children:g("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:N,onClick:ne,children:_?"…":g("save")})]})]})}function j2({token:e,readonly:t,targets:n=[],startNewCell:s=!1,initialLocation:o=""}){const[a,u]=R.useState({engines:[],cells:[],managedCatalog:[]}),[h,p]=R.useState({available:!1,capabilities:[]}),[f,_]=R.useState(!1),[b,y]=R.useState(null),[w,S]=R.useState(null),[x,C]=R.useState(!1),[k,N]=R.useState(""),[I,D]=R.useState(""),[X,V]=R.useState(o),[A,ne]=R.useState(!1),[W,Z]=R.useState(null),[U,H]=R.useState(null),[j,P]=R.useState(null),[T,F]=R.useState(!1),[te,M]=R.useState([]),[ie,B]=R.useState(null),[L,z]=R.useState("manage"),G=R.useRef(!1),oe=X?X.split("/"):[],de=R.useCallback(async()=>{try{const le=await Br(e,oe);p(le);try{const be=await yh(e,oe);ne(!!be.readonlyDefault)}catch{ne(!1)}if(le.provider==="builtin"&&(le.capabilities||[]).includes("definitions")){const be=await gh(e,oe),Ae=new Map((le.engines||[]).map(We=>[We.id,We]));if(be.engines=(be.engines||[]).map(We=>{var he;return{...We,availableModels:((he=Ae.get(We.id))==null?void 0:he.models)||[]}}),u(be),(le.capabilities||[]).includes("credentials"))try{M((await Pb(e,oe)).credentials||[])}catch{M([])}else M([])}N("")}catch(le){N(String(le.message||le))}finally{_(!0)}},[e,X]);R.useEffect(()=>{de();const le=setInterval(de,5e3);return()=>clearInterval(le)},[de]);const me=new Set((h.cells||[]).filter(le=>le.active).map(le=>le.cell)),Q=h.provider==="builtin"&&(h.capabilities||[]).includes("edit"),q=(h.capabilities||[]).includes("restore");R.useEffect(()=>{!s||G.current||!Q||!a.engines.length||(G.current=!0,S({mode:"new",form:t_(a.engines[0].id)}))},[s,Q,a.engines]);const pe=async le=>{C(!0),N(""),D("");try{await le(),await de()}catch(be){N(String(be.message||be))}C(!1)},Ie=()=>pe(async()=>{var Ee;const le=b.mode==="new",be=b.form,Ae=a.managedCatalog||[],We=be.kind==="managed"?Po(Ae,be):null,he=typeof(We==null?void 0:We.credentialEnv)=="string"?We.credentialEnv:"",K=he&&be.credentialValue||"",ee=x2(be,le,Ae);!le&&b.form.kind==="custom"&&!b.form.modelFlag&&(ee.model=null),!le&&b.form.kind==="custom"&&b.form.promptMode!=="flag"&&(ee.promptFlag=null);let O;if(le)O=await Lb(e,ee,oe);else{const we=b.original,Re=new Set(b.form.envRows.filter(Be=>!Be.remove).map(Be=>Be.key)),Ge=(we.envKeys||[]).filter(Be=>!Re.has(Be)),gt=Object.fromEntries(b.form.envRows.filter(Be=>!Be.remove&&Be.key&&(!Be.configured||Be.value!=="")).map(Be=>[Be.key,Be.value]));O=await Db(e,we.id,ee,b.form.kind==="custom"?{set:gt,remove:Ge}:void 0,oe)}let se=null;if(he&&K)try{se=await zm(e,he,K,oe),M(se.credentials||[])}catch{throw await de(),le&&y({mode:"edit",original:{...ee,id:be.id},form:{...be,credentialReveal:!1}}),new Error(g(le?"fleet-key-partial-create":"fleet-key-partial-edit"))}await de(),y(null),D(g("fleet-saved"));const ge=((Ee=((se==null?void 0:se.credentials)||[]).find(we=>we.envKey===he))==null?void 0:Ee.activeCells)||[],ke=[...new Set([...(O==null?void 0:O.activeCells)||[],...ge])];if(ke.length&&window.confirm(g("fleet-restart-confirm").replace("{cells}",ke.join(", "))))for(const we of ke)await _o(e,we,oe)}),it=()=>pe(async()=>{var O,se,ge,ke,Ee,we;const le=w.mode==="new",be=w.form,Ae={...le?{id:be.id}:{},cwd:be.cwd,engine:be.engine,boot:!!be.boot},We={...be.commands||{}},he=a.engines.find(Re=>Re.id===be.engine);((O=he==null?void 0:he.managed)==null?void 0:O.client)==="shell"&&typeof be.command=="string"&&be.command.length?We[be.engine]=be.command:((se=he==null?void 0:he.managed)==null?void 0:se.client)==="shell"&&delete We[be.engine],(Object.keys(We).length||!le)&&(Ae.commands=We),le?(((ge=he==null?void 0:he.managed)==null?void 0:ge.client)!=="shell"&&be.model&&(Ae.model=be.model),((ke=he==null?void 0:he.managed)==null?void 0:ke.client)!=="shell"&&be.prompt&&(Ae.prompt=be.prompt)):(Ae.model=((Ee=he==null?void 0:he.managed)==null?void 0:Ee.client)==="shell"?null:be.model||null,((we=he==null?void 0:he.managed)==null?void 0:we.client)!=="shell"&&(Ae.prompt=be.prompt||null));const K=le?await Tb(e,Ae,oe):await f_(e,w.original.id,Ae,oe),ee=le?be.id:w.original.id;S(null),D(g("fleet-saved")),!le&&(K!=null&&K.active)&&window.confirm(g("fleet-restart-confirm").replace("{cells}",ee))&&await _o(e,ee,oe)}),ze=t||A,Fe=le=>te.find(be=>{var Ae;return(Ae=be.engines)==null?void 0:Ae.includes(le.id)})||null,dt=()=>pe(async()=>{var Ae;const le=await zm(e,ie.envKey,ie.value,oe);M(le.credentials||[]),B(null),D(g("fleet-credential-saved"));const be=((Ae=(le.credentials||[]).find(We=>We.envKey===ie.envKey))==null?void 0:Ae.activeCells)||[];if(be.length&&window.confirm(g("fleet-restart-confirm").replace("{cells}",be.join(", "))))for(const We of be)await _o(e,We,oe)}),Ue=le=>pe(async()=>{if(!window.confirm(g("fleet-credential-remove-confirm").replace("{key}",le.envKey)))return;const be=await jb(e,le.envKey,oe);M(be.credentials||[]),D(g("fleet-credential-removed"))}),ct=le=>Z({...le,route:Array.isArray(le==null?void 0:le.route)?le.route:oe}),_t=async le=>{if(!W)return;const be=W.cell||W.id,Ae=Array.isArray(W.route)?W.route:oe;le.action==="up"?await mh(e,{cell:be,boot:!!le.boot,...le.engine?{engine:le.engine}:{},...le.model!==void 0?{model:le.model}:{},...le.permissionPolicy?{permissionPolicy:le.permissionPolicy}:{}},Ae):await ul(e,{cell:be,boot:!!le.boot},Ae)},ut=(le,be)=>{N(""),H({mode:"new",route:Array.isArray(be)?be:oe,form:{tmuxSession:le.name,id:"",engine:"",cwd:"",boot:!1},err:""})},pt=()=>pe(async()=>{const le=U.form;if(!le.engine){H({...U,err:g("import-engine-required")});return}await Ab(e,{tmuxSession:le.tmuxSession,id:le.id||void 0,engine:le.engine,cwd:le.cwd||void 0,boot:!!le.boot},le.route||oe),H(null),D(g("fleet-saved"))}),st=({engineRows:le=[],cellRows:be=[]})=>pe(async()=>{const Ae=le.filter(Ee=>Ee.selected),We=Ae.map(Ee=>vw(Ee.engine));if(We.some(Ee=>!Ee))throw new Error(g("fleet-backup-invalid-engine"));const he=Ae.filter(Ee=>Ee.exists).map(Ee=>Ee.engine.id);if(he.length&&!window.confirm(g("fleet-backup-confirm-engine-overwrite").replace("{engines}",he.join(", "))))return;const K=[...new Set([...a.engines.map(Ee=>Ee.id),...We.map(Ee=>Ee.id)])],ee=[];for(const Ee of be.filter(we=>we.selected)){const we=w2(Ee.cell,Ee.engine,K);if(!we)throw new Error(`${Ee.cell.id}: ${g("fleet-backup-engine-missing")}`);ee.push(we)}const O=be.filter(Ee=>Ee.selected&&Ee.exists).map(Ee=>Ee.cell.id);if(O.length&&!window.confirm(g("fleet-backup-confirm-overwrite").replace("{cells}",O.join(", "))))return;const se=We.length?await Bb(e,We,he.length>0,oe):{needsRestart:[]},ge=ee.length?await Ib(e,ee,oe):{needsRestart:[]},ke=[...new Set([...se.needsRestart||[],...ge.needsRestart||[]])];F(!1),D(`${g("fleet-backup-restored").replace("{n}",String(ee.length))}${We.length?` · ${We.length} ${g("fleet-engines").toLowerCase()}`:""}${ke.length?` · ${g("fleet-backup-needs-restart").replace("{cells}",ke.join(", "))}`:""}`)}),rt=c.jsxs("label",{className:"nc-field",children:[g("location"),c.jsxs("select",{value:X,onChange:le=>{V(le.target.value),y(null),S(null),N(""),D(""),ne(!1),_(!1),p({available:!1,capabilities:[]}),u({engines:[],cells:[],managedCatalog:[]}),M([]),B(null)},children:[c.jsx("option",{value:"",children:g("local")}),n.map(le=>c.jsxs("option",{value:le.route.join("/"),disabled:le.status&&le.status!=="up",children:[le.label,le.status&&le.status!=="up"?` · ${g("node-offline")}`:""]},le.route.join("/")))]})]}),mt=c.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":g("tab-fleet"),children:[c.jsx("button",{type:"button",role:"tab","aria-selected":L==="manage",className:`nc-set-tabbtn${L==="manage"?" on":""}`,onClick:()=>z("manage"),children:g("fleet-manage-location")}),c.jsx("button",{type:"button",role:"tab","aria-selected":L==="overview",className:`nc-set-tabbtn${L==="overview"?" on":""}`,onClick:()=>z("overview"),children:g("fleet-network-overview")})]});return f?Q?c.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[mt,L==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:g("fleet-overview-help")}),c.jsx(dd,{token:e,targets:n,readonly:t,onPower:ct,onImport:ut})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:g("fleet-manage-help")}),rt,c.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[c.jsx("button",{className:"nc-btn ghost",disabled:ze||x,onClick:()=>{N(""),F(!0)},children:g("fleet-backup")}),c.jsx("small",{children:g("fleet-backup-help")})]}),c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:g("fleet-cells")}),c.jsx("span",{className:"nc-fleet-head-actions",children:c.jsxs("button",{className:"nc-btn primary",disabled:ze||x||!a.engines.length,onClick:()=>{var le;N(""),S({mode:"new",form:t_((le=a.engines[0])==null?void 0:le.id)})},children:["+ ",g("add")]})})]}),a.cells.map(le=>{const be=me.has(le.id),Ae=h.capabilities||[],We=le.needsRepair===!0;return c.jsxs("div",{className:"nc-fleet-item",children:[c.jsxs("span",{children:[c.jsx("b",{children:le.id}),c.jsxs("small",{children:[le.engine," · ",We?c.jsx("span",{className:"nc-fleet-tag nc-fleet-tag-warn",children:g("fleet-cwd-needs-repair")}):le.cwd,be?` · ${g("service-active")}`:` · ${g("cell-off")}`]})]}),c.jsxs("span",{children:[be&&Ae.includes("down")&&c.jsx("button",{className:"nc-btn ghost",disabled:ze||x,onClick:()=>pe(()=>ul(e,{cell:le.id},oe)),children:g("stop")}),!be&&Ae.includes("up")&&c.jsx("button",{className:"nc-btn primary",disabled:ze||x,onClick:()=>ct({cell:le.id,id:le.id,engine:le.engine,model:le.model,models:le.models,permissionPolicies:le.permissionPolicies,active:!1,boot:le.boot}),children:g("start")}),be&&Ae.includes("restart")&&c.jsx("button",{className:"nc-btn ghost",disabled:ze||x,onClick:()=>pe(()=>_o(e,le.id,oe)),children:g("restart")}),We?c.jsx("button",{className:"nc-btn ghost",disabled:ze||x,onClick:()=>{N(""),P(le)},children:g("fleet-cwd-repair")}):c.jsx("button",{className:"nc-btn ghost",disabled:ze||x,onClick:()=>{var he;N(""),S({mode:"edit",original:le,form:{...le,commands:{...le.commands||{}},command:((he=le.commands)==null?void 0:he[le.engine])||""}})},children:g("edit")}),c.jsx("button",{className:"nc-btn danger",disabled:ze||x,onClick:()=>pe(async()=>{window.confirm(g("fleet-remove-cell").replace("{id}",le.id))&&await p_(e,le.id,!0,oe)}),children:"×"})]})]},le.id)}),c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:g("fleet-engines")}),c.jsxs("button",{className:"nc-btn primary",disabled:ze||x,onClick:()=>{N(""),y({mode:"new",form:S2()})},children:["+ ",g("add")]})]}),a.engines.map(le=>{var Ae,We;const be=Fe(le);return c.jsxs("div",{className:"nc-fleet-item",children:[c.jsxs("span",{children:[c.jsx("b",{children:le.label}),c.jsx("small",{children:le.managed?`${le.id} · ${le.managed.client} / ${le.managed.provider} · ${(Ae=le.managedInfo)!=null&&Ae.configured?g("fleet-ready"):((We=le.managedInfo)==null?void 0:We.reason)||g("fleet-not-ready")}`:`${le.id} · ${le.command}`}),be&&c.jsxs("small",{children:[be.envKey," · ",g(`fleet-credential-source-${be.source||"missing"}`)]})]}),c.jsxs("span",{children:[be&&c.jsx("button",{className:"nc-btn ghost",disabled:ze||x,onClick:()=>{N(""),B({envKey:be.envKey,value:""})},children:be.configured?g("fleet-credential-change"):g("fleet-credential-set")}),(be==null?void 0:be.source)==="local"&&c.jsx("button",{className:"nc-btn danger",disabled:ze||x,onClick:()=>Ue(be),children:g("fleet-credential-forget")}),c.jsx("button",{className:"nc-btn ghost",disabled:ze||x,onClick:()=>{N(""),y({mode:"edit",original:le,form:k2(le)})},children:g("edit")}),c.jsx("button",{className:"nc-btn danger",disabled:ze||x,onClick:()=>pe(async()=>{window.confirm(g("fleet-remove-engine").replace("{id}",le.id))&&await Mb(e,le.id,oe)}),children:"×"})]})]},le.id)})]}),b&&c.jsx(xr,{onClose:()=>y(null),label:g("fleet-new-engine"),error:k,children:c.jsx(E2,{state:b,setState:y,busy:x,onSave:Ie,catalog:a.managedCatalog||[]})}),w&&c.jsx(xr,{onClose:()=>S(null),label:g("fleet-new-cell"),error:k,children:c.jsx(N2,{token:e,route:oe,targets:n,location:X,setLocation:V,state:w,setState:S,engines:a.engines,busy:x,onSave:it})}),j&&c.jsx(xr,{onClose:()=>P(null),label:g("fleet-cwd-repair-title").replace("{id}",j.id),error:"",children:c.jsx(P2,{token:e,route:oe,cell:j,busy:x,onSaved:async()=>{P(null),D(g("fleet-cwd-repaired")),await de()},onClose:()=>P(null)})}),I&&c.jsx("div",{className:"nc-set-note",children:I}),k&&c.jsx("div",{className:"nc-err",children:k}),T&&c.jsx(xr,{onClose:()=>F(!1),label:g("fleet-backup"),error:k,children:c.jsx(C2,{cells:a.cells,engines:a.engines,busy:x,canRestore:q,onRestore:st,onClose:()=>F(!1)})}),ie&&c.jsx(xr,{onClose:()=>B(null),label:g("fleet-credential-title"),error:k,children:c.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[c.jsx("b",{children:g("fleet-credential-title")}),c.jsx("small",{children:g("fleet-credential-help")}),c.jsxs("label",{className:"nc-field",children:[ie.envKey,c.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:ie.value,onChange:le=>B({...ie,value:le.target.value})})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>B(null),children:g("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:x||!ie.value,onClick:dt,children:g("save")})]})]})}),U&&c.jsx(xr,{onClose:()=>H(null),label:g("import-as-cell"),error:k,children:c.jsx(n_,{token:e,route:U.route||oe,state:U,setState:H,busy:x,onSave:pt})}),W&&c.jsx(dl,{cell:W,token:e,route:Array.isArray(W.route)?W.route:oe,onConfirm:async le=>{try{await _t(le)}finally{await de()}},onClose:()=>Z(null)})]}):c.jsxs("div",{className:"nc-set-tab",children:[mt,L==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:g("fleet-overview-help")}),c.jsx(dd,{token:e,targets:n,readonly:t,onPower:ct,onImport:ut})]}):c.jsxs(c.Fragment,{children:[rt,c.jsxs("div",{className:"nc-set-info",children:[g(k?"fleet-editor-load-error":"fleet-editor-unavailable"),!k&&h.reason?` ${h.reason}`:""]})]}),k&&c.jsx("div",{className:"nc-err",children:k}),U&&c.jsx(xr,{onClose:()=>H(null),label:g("import-as-cell"),error:k,children:c.jsx(n_,{token:e,route:U.route||oe,state:U,setState:H,busy:x,onSave:pt})}),W&&c.jsx(dl,{cell:W,token:e,route:Array.isArray(W.route)?W.route:oe,onConfirm:async le=>{try{await _t(le)}finally{await de()}},onClose:()=>Z(null)})]}):c.jsxs("div",{className:"nc-set-tab",children:[mt,L==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:g("fleet-overview-help")}),c.jsx(dd,{token:e,targets:n,readonly:t,onPower:ct,onImport:ut})]}):c.jsxs(c.Fragment,{children:[rt,c.jsx("div",{className:"nc-set-info",children:g("fleet-editor-loading")})]})]})}function L2({text:e}){const[t,n]=R.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return c.jsxs("div",{className:"nc-set-copyline",children:[c.jsx("code",{children:e}),c.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:s,children:[c.jsx(nt,{name:"copy",size:14})," ",g(t?"copied":"copy")]})]})}function D2({value:e}){const[t,n]=R.useState("");return R.useEffect(()=>{let s=!0;return UE.toDataURL(e,{margin:1,width:220}).then(o=>{s&&n(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?c.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function M2({token:e,nodes:t,roster:n,settings:s,readonly:o,refresh:a,refreshAliases:u}){const[h,p]=R.useState(null),[f,_]=R.useState(null),[b,y]=R.useState({}),[w,S]=R.useState(null),[x,C]=R.useState({ssh:"",sshPort:"",name:""}),[k,N]=R.useState(""),[I,D]=R.useState(""),[X,V]=R.useState(""),[A,ne]=R.useState(!1),[W,Z]=R.useState(null),[U,H]=R.useState(null),j=Date.now(),P=s&&s.deviceName||"",T=(t||[]).filter(Q=>Q&&Q.direction==="outbound"&&Q.name&&Q.ssh),F=T.find(Q=>Q.name===k)||T[0]||null,te=T.find(Q=>Q.name===I)||T[0]||null,M=te?rg(te.tunnel,j):null,ie=te!=null&&te.shared?M!=null&&M.up?"share-local-active":"share-local-pending":M!=null&&M.up?"share-local-private":"share-local-private-down",B=[{key:"peer-group-hubs",rows:(t||[]).filter(Q=>Q.kind!=="transitive"&&Q.relation!=="client")},{key:"peer-group-clients",rows:(t||[]).filter(Q=>Q.kind!=="transitive"&&Q.relation==="client")},{key:"peer-group-routed",rows:(t||[]).filter(Q=>Q.kind==="transitive")}],L=async(Q,q)=>{p(null),_(`${Q}:${q}`);try{const pe=await wh(e,Q,q);q==="test"&&y(Ie=>({...Ie,[Q]:pe})),await a()}catch(pe){p(`${Q}: ${String(pe.message||pe)}`)}_(null)},z=async Q=>{p(null),_(`${Q}:remove`);try{await qb(e,Q),H(null),await a()}catch(q){p(`${Q}: ${String(q.message||q)}`)}_(null)},G=Q=>Z({name:Q.name,direction:Q.direction,label:Q.label||Q.name,ssh:Q.ssh||"",sshPort:Q.sshPort?String(Q.sshPort):"",autostart:Q.autostart===!0,visibility:Q.visibility||"network",selected:[...Q.selected||[]]}),oe=async()=>{if(!W||!ws(W.label)){p(g("err-label"));return}const Q=W.direction==="inbound"?{label:W.label,visibility:W.visibility,selected:W.visibility==="selected"?W.selected:[]}:{label:W.label,ssh:W.ssh,autostart:W.autostart,...W.sshPort?{sshPort:Number(W.sshPort)}:{}};p(null),_(`${W.name}:edit`);try{await Kb(e,W.name,Q),Z(null),await a()}catch(q){p(`${W.name}: ${String(q.message||q)}`)}_(null)},de=async Q=>{if(te){p(null),_(`${te.name}:share`);try{await Vb(e,te.name,Q),await a()}catch(q){const pe=q!=null&&q.data&&typeof q.data.hint=="string"?q.data.hint:"";p(`${te.name}: ${String(q.message||q)}${pe?` — ${pe}`:""}`)}_(null)}},me=async()=>{if(p(null),F){const pe=ig({name:F.name,ssh:F.ssh,sshPort:F.sshPort||""});if(!pe.ok){p(g(pe.error));return}_("invite");try{S(await $m(e,{ssh:pe.value.ssh,...pe.value.sshPort?{sshPort:pe.value.sshPort}:{}},[F.name]))}catch(Ie){p(String(Ie.message||Ie))}_(null);return}const Q=ar(x.name||X||P||"NexusCrew"),q=ig({name:Q,ssh:x.ssh,sshPort:x.sshPort});if(!q.ok){p(g(q.error));return}_("invite");try{S(await $m(e,{...X||P?{label:X||P}:{},name:Q,ssh:q.value.ssh,...q.value.sshPort?{sshPort:q.value.sshPort}:{}}))}catch(pe){p(String(pe.message||pe))}_(null)};return c.jsxs("div",{className:"nc-set-tab",children:[c.jsx("div",{className:"nc-sheet-label",children:g("peer-inventory-title")}),(t||[]).length===0&&c.jsx("div",{className:"nc-empty",children:g("no-nodes")}),B.map(Q=>Q.rows.length>0&&c.jsxs("div",{className:"nc-peer-group",children:[c.jsxs("div",{className:"nc-peer-group-title",children:[g(Q.key)," ",c.jsx("span",{children:Q.rows.length})]}),Q.rows.map(q=>{var Fe,dt;const pe=q.kind==="transitive",Ie=pe?{up:q.stale!==!0,label:q.stale===!0?"peer-routed-stale":"peer-routed"}:rg(q.tunnel,j),it=b[q.name],ze=q.actions||{};return c.jsxs("div",{className:`nc-set-node${pe?" routed":""}`,children:[c.jsxs("div",{className:"nc-set-node-head",children:[c.jsx("span",{className:`nc-dot ${Ie.up?"on":""}`}),c.jsx("b",{children:q.label||q.name}),c.jsxs("small",{children:[q.name,pe?` · ${q.route.join(" → ")}`:q.direction==="outbound"?` · SSH ${q.ssh||""}`:` · ${g("node-connected-client")}`,(Fe=q.tunnel)!=null&&Fe.transport?` · ${q.tunnel.transport} ${g("transport-used")}`:""]}),c.jsxs("span",{className:`nc-set-tunnel${Ie.up?" up":""}`,children:[g(Ie.label),Ie.since?` · ${Ie.since}`:""]})]}),!pe&&q.direction==="inbound"&&c.jsx("div",{className:"nc-set-info",children:g(q.shared?"peer-shared":"peer-private")}),ze.visibility&&q.shared&&c.jsxs(c.Fragment,{children:[c.jsxs("select",{value:q.visibility||"network",disabled:o||!!f,onChange:async Ue=>{_(`${q.name}:visibility`);try{await Wm(e,q.name,Ue.target.value),await a()}catch(ct){p(String(ct.message||ct))}_(null)},children:[c.jsx("option",{value:"network",children:g("visibility-network")}),c.jsx("option",{value:"relay-only",children:g("visibility-relay")}),c.jsx("option",{value:"selected",children:g("visibility-selected")})]}),q.visibility==="selected"&&c.jsx("div",{className:"nc-set-row",children:(t||[]).filter(Ue=>Ue.name!==q.name&&Ue.nodeId).map(Ue=>{const ct=(q.selected||[]).includes(Ue.nodeId);return c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:ct,disabled:o||!!f,onChange:async _t=>{const ut=_t.target.checked?[...q.selected||[],Ue.nodeId]:(q.selected||[]).filter(pt=>pt!==Ue.nodeId);_(`${q.name}:visibility`);try{await Wm(e,q.name,"selected",ut),await a()}catch(pt){p(String(pt.message||pt))}_(null)}})," ",Ue.label||Ue.name]},Ue.nodeId)})})]}),c.jsxs("div",{className:"nc-set-node-actions",children:[ze.edit&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:()=>G(q),children:g("edit")}),ze.test&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>L(q.name,"test"),children:g("node-test")}),ze.disconnect&&Ie.up&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:()=>L(q.name,"down"),children:g("tunnel-stop")}),ze.connect&&!Ie.up&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:()=>L(q.name,"up"),children:g("tunnel-start")}),ze.restart&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:()=>L(q.name,"restart"),children:g("tunnel-restart")}),ze.remove&&c.jsxs("button",{type:"button",className:"nc-btn danger",disabled:o||!!f,title:g(o?"settings-readonly":"delete"),onClick:()=>H(q.name),children:[c.jsx(nt,{name:"trash",size:14})," ",g("delete")]})]}),(W==null?void 0:W.name)===q.name&&c.jsxs("div",{className:"nc-set-form nc-node-editor",children:[c.jsxs("label",{className:"nc-field",children:[g("node-display-label"),c.jsx("input",{value:W.label,disabled:!!f,onChange:Ue=>Z({...W,label:Ue.target.value})})]}),W.direction==="outbound"?c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"nc-field",children:[g("node-ssh-label"),c.jsx("input",{value:W.ssh,disabled:!!f,onChange:Ue=>Z({...W,ssh:Ue.target.value})})]}),c.jsxs("label",{className:"nc-field",children:[g("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",value:W.sshPort,disabled:!!f,onChange:Ue=>Z({...W,sshPort:Ue.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:W.autostart,disabled:!!f,onChange:Ue=>Z({...W,autostart:Ue.target.checked})})," ",g("boot-persist")]})]}):c.jsxs("label",{className:"nc-field",children:[g("peer-visibility"),c.jsxs("select",{value:W.visibility,disabled:!!f,onChange:Ue=>Z({...W,visibility:Ue.target.value}),children:[c.jsx("option",{value:"network",children:g("visibility-network")}),c.jsx("option",{value:"relay-only",children:g("visibility-relay")}),c.jsx("option",{value:"selected",children:g("visibility-selected")})]})]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!f,onClick:oe,children:g("save")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>Z(null),children:g("cancel")})]})]}),U===q.name&&c.jsxs("div",{className:"nc-set-confirm",children:[c.jsx("b",{children:g("node-remove-confirm").replace("{name}",q.label||q.name)}),c.jsx("small",{children:g("node-remove-warning")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn danger",disabled:!!f,onClick:()=>z(q.name),children:g("delete")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>H(null),children:g("cancel")})]})]}),((dt=q.health)==null?void 0:dt.detail)&&c.jsx("div",{className:`nc-set-test${q.health.status==="healthy"?" ok":q.health.status==="passive"?"":" ko"}`,children:q.health.detail}),it&&c.jsxs("div",{className:`nc-set-test${it.ok?" ok":" ko"}`,children:[it.result,it.detail?` — ${it.detail}`:""]})]},`${q.kind||"direct"}:${q.nodeId||q.name}`)})]},Q.key)),(n||[]).some(Q=>!Q.direct&&Q.instanceId)&&c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:g("routed-node-aliases")}),c.jsx("small",{className:"nc-set-hint",children:g("routed-node-aliases-help")}),(n||[]).filter(Q=>!Q.direct&&Q.instanceId).map(Q=>c.jsxs("div",{className:"nc-set-node",children:[c.jsxs("div",{className:"nc-set-node-head",children:[c.jsx("span",{className:`nc-dot ${Q.status==="up"?"on":""}`}),c.jsx("b",{children:Q.label||Q.name}),c.jsx("small",{children:(Q.route||[]).join(" › ")})]}),c.jsxs("div",{className:"nc-set-node-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:async()=>{const q=window.prompt(g("node-local-alias"),Q.alias||"");if(q!=null){if(q.trim()&&!ws(q.normalize("NFC"))){p(g("err-label"));return}_(`${Q.instanceId}:alias`),p(null);try{q.trim()?await Ub(e,Q.instanceId,q):await Hm(e,Q.instanceId),u()}catch(pe){p(String(pe.message||pe))}_(null)}},children:g("alias-on-device")}),Q.alias&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:async()=>{_(`${Q.instanceId}:alias-reset`),p(null);try{await Hm(e,Q.instanceId),u()}catch(q){p(String(q.message||q))}_(null)},children:g("reset-alias")})]})]},Q.instanceId))]}),te&&c.jsxs("div",{className:"nc-set-form nc-local-share",children:[c.jsx("div",{className:"nc-sheet-label",children:g("share-local-heading")}),T.length>1&&c.jsxs("label",{className:"nc-field",children:[g("share-local-hub"),c.jsx("select",{value:te.name,disabled:o||!!f,onChange:Q=>D(Q.target.value),children:T.map(Q=>c.jsx("option",{value:Q.name,children:Q.label||Q.name},Q.name))})]}),c.jsxs("label",{className:"nc-check nc-node-share",children:[c.jsx("input",{type:"checkbox",checked:te.shared===!0,disabled:o||!!f,onChange:Q=>de(Q.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:g("share-local-through").replace("{device}",P||g("local")).replace("{hub}",te.label||te.name)}),c.jsx("small",{children:g(te.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),c.jsx("div",{className:`nc-set-test${te.shared&&(M!=null&&M.up)?" ok":M!=null&&M.up?"":" ko"}`,children:g(ie)}),!(M!=null&&M.up)&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:()=>de(te.shared===!0),children:g("share-local-reconnect")})]}),c.jsx(cw,{token:e,deviceDefault:P,localNodeId:s&&s.nodeId||"",localNameDefault:s&&s.localName||"",readonly:o,onSuccess:a}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:g("invite-node")}),c.jsx("small",{className:"nc-set-hint",children:g(F?"invite-network-hint":"invite-v2-hint")}),F?c.jsxs(c.Fragment,{children:[T.length>1&&c.jsxs("label",{className:"nc-field",children:[g("invite-network-label"),c.jsx("select",{value:F.name,disabled:o||!!f,onChange:Q=>{N(Q.target.value),S(null)},children:T.map(Q=>c.jsx("option",{value:Q.name,children:Q.label||Q.name},Q.name))})]}),c.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[g("invite-network-via"),": ",c.jsx("b",{children:F.label||F.name})," · ",F.ssh,F.sshPort?`:${F.sshPort}`:""]}),c.jsx("small",{className:"nc-set-hint",children:g("invite-network-route")})]}):c.jsxs("label",{className:"nc-field",children:[g("invite-endpoint-label"),c.jsx("input",{placeholder:"user@host",value:x.ssh,disabled:o,onChange:Q=>C({...x,ssh:Q.target.value})}),c.jsx("small",{className:"nc-set-hint",children:g("invite-endpoint-needed")})]}),!F&&A&&c.jsxs("div",{className:"nc-invite-advanced",children:[c.jsxs("label",{className:"nc-field",children:[g("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",placeholder:"22",value:x.sshPort,disabled:o,onChange:Q=>C({...x,sshPort:Q.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),c.jsxs("label",{className:"nc-field",children:[g("device-name-label"),c.jsx("input",{placeholder:P||"NexusCrew",value:X,disabled:o,onChange:Q=>V(Q.target.value)}),c.jsx("small",{className:"nc-set-hint",children:g("device-name-hint")})]}),c.jsxs("label",{className:"nc-field",children:[g("node-name-label"),c.jsx("input",{placeholder:ar(X||P||g("node-name-ph")),value:x.name,disabled:o,onChange:Q=>C({...x,name:Q.target.value?ar(Q.target.value):""})})]})]}),c.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||!!f||!F&&!x.ssh.trim(),onClick:me,children:g("create-pairing-link")}),!F&&c.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>ne(Q=>!Q),children:[A?"▾":"▸"," ",g("pair-advanced")]})]}),w&&c.jsxs(c.Fragment,{children:[c.jsx(D2,{value:w.pairingUrl}),c.jsx(L2,{text:w.pairingUrl}),c.jsx("div",{className:"nc-set-info",children:g("invite-next-steps")})]})]}),h&&c.jsx("div",{className:"nc-err",children:h})]})}function T2({token:e,readonly:t}){const[n,s]=R.useState("idle"),[o,a]=R.useState(!1),[u,h]=R.useState(null);R.useEffect(()=>{let f=!1;return n2().then(_=>{f||s(_)}),()=>{f=!0}},[]);const p=async()=>{h(null),a(!0);try{n==="subscribed"?(await r2(e),s("idle")):(await i2(e),s("subscribed"))}catch(f){const _=String(f.message||f);_==="push-denied"?(s("denied"),h(g("push-denied"))):_==="push-unsupported"?(s("unsupported"),h(g("push-unsupported"))):h(_)}a(!1)};return n==="unsupported"?c.jsx("div",{className:"nc-set-info",children:g("push-unsupported")}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||o||n==="denied",title:t?g("settings-readonly"):"",onClick:p,children:g(n==="subscribed"?"push-disable":"push-enable")}),c.jsx("span",{className:"nc-set-info",children:g(n==="subscribed"?"push-on":n==="denied"?"push-denied":"push-off")})]}),u&&c.jsx("div",{className:"nc-err",children:u})]})}function A2(){const[e,t]=zh();return c.jsxs("div",{className:"nc-set-tab nc-input-settings",children:[c.jsx("div",{className:"nc-set-info",children:g("input-settings-local")}),c.jsx("div",{className:"nc-set-form",children:c.jsxs("label",{className:"nc-field",children:[g("terminal-keyboard-gesture"),c.jsx("select",{"aria-label":g("terminal-keyboard-gesture"),value:e.terminalKeyboardGesture,onChange:n=>t({terminalKeyboardGesture:n.target.value}),children:Hy.map(n=>c.jsx("option",{value:n,children:g(`terminal-keyboard-${n}`)},n))}),c.jsx("small",{children:g("terminal-keyboard-gesture-help")})]})}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:e.keybarKeepsKeyboardClosed,onChange:n=>t({keybarKeepsKeyboardClosed:n.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:g("keybar-ime-lock")}),c.jsx("small",{children:g("keybar-ime-lock-help")})]})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:e.voiceKeepsKeyboardClosed,onChange:n=>t({voiceKeepsKeyboardClosed:n.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:g("voice-ime-lock")}),c.jsx("small",{children:g("voice-ime-lock-help")})]})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:e.showKeybarEnter,onChange:n=>t({showKeybarEnter:n.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:g("keybar-enter-show")}),c.jsx("small",{children:g("keybar-enter-show-help")})]})]}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>t(Lr),children:g("input-settings-reset")})})]})}function I2({token:e,roster:t=[],readonly:n}){const s=[{key:"local",route:[],label:g("diagnostics-local"),status:"up"},...t.filter(T=>Array.isArray(T.route)&&T.route.length).map(T=>({key:T.route.join("/"),route:T.route,label:T.label||T.name,status:T.status}))],[o,a]=R.useState("local"),u=s.find(T=>T.key===o)||s[0],[h,p]=R.useState(null),[f,_]=R.useState([]),[b,y]=R.useState(""),[w,S]=R.useState(!1),[x,C]=R.useState(!0),[k,N]=R.useState(900),[I,D]=R.useState("all"),[X,V]=R.useState(""),A=R.useRef(0),ne=R.useRef(null),W=R.useCallback(async()=>{try{const T=await Jb(e,u.route);if(p(T),y(""),!w){const F=await Qb(e,{after:A.current,limit:200},u.route);Array.isArray(F.records)&&F.records.length&&(A.current=F.cursor,_(te=>[...te,...F.records].slice(-500)))}}catch(T){y(T&&T.status===404?g("diagnostics-unsupported"):String(T.message||T))}},[e,u.key,w]);R.useEffect(()=>{A.current=0,_([]),p(null),y("")},[u.key]),R.useEffect(()=>{let T=null,F=!0;const te=()=>{!F||document.visibilityState==="hidden"||W()},M=()=>{T&&clearInterval(T),T=document.visibilityState==="hidden"?null:setInterval(te,2e3),document.visibilityState!=="hidden"&&te()};return document.addEventListener("visibilitychange",M),M(),()=>{F=!1,T&&clearInterval(T),document.removeEventListener("visibilitychange",M)}},[W]),R.useEffect(()=>{x&&ne.current&&(ne.current.scrollTop=ne.current.scrollHeight)},[f,x]);const Z=f.filter(T=>(I==="all"||T.level===I)&&(!X||String(T.component||"").toLowerCase().includes(X.toLowerCase()))),U=Z.map(T=>`${T.ts} ${T.level.toUpperCase()} ${T.component} ${T.code} ${T.message}${Object.keys(T.meta||{}).length?` ${JSON.stringify(T.meta)}`:""}`).join(`
92
+ `),H=async T=>{y("");try{const F=await T();p(F),await W()}catch(F){y(String(F.message||F))}},j=async()=>{try{await navigator.clipboard.writeText(U)}catch{y(g("copy-manual"))}},P=()=>{try{const T=new Blob([`${JSON.stringify(Z,null,2)}
93
+ `],{type:"application/json"}),F=URL.createObjectURL(T),te=document.createElement("a");te.href=F,te.download="nexuscrew-diagnostics.json",te.click(),URL.revokeObjectURL(F)}catch{y(g("diagnostics-export-failed"))}};return c.jsxs("div",{className:"nc-set-tab nc-diagnostics",children:[c.jsxs("label",{className:"nc-field",children:[g("diagnostics-target"),c.jsx("select",{value:u.key,onChange:T=>a(T.target.value),children:s.map(T=>c.jsxs("option",{value:T.key,children:[T.label,T.status!=="up"?` · ${T.status}`:""]},T.key))})]}),c.jsxs("div",{className:"nc-set-form nc-diag-controls",children:[c.jsx("div",{className:"nc-sheet-label",children:g("diagnostics-verbose")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("select",{"aria-label":g("diagnostics-duration"),value:k,onChange:T=>N(Number(T.target.value)),disabled:n,children:[300,900,1800,3600].map(T=>c.jsxs("option",{value:T,children:[T/60," min"]},T))}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||(h==null?void 0:h.verbose)===!0,onClick:()=>H(()=>Um(e,!0,k,u.route)),children:g("enable")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||(h==null?void 0:h.verbose)!==!0,onClick:()=>H(()=>Um(e,!1,k,u.route)),children:g("stop")})]}),c.jsx("small",{className:"nc-set-hint",children:h!=null&&h.verbose?g("diagnostics-expires").replace("{time}",new Date(h.expiresAt).toLocaleTimeString()):g("diagnostics-off")})]}),c.jsxs("div",{className:"nc-diag-filters",children:[c.jsxs("select",{"aria-label":g("diagnostics-level"),value:I,onChange:T=>D(T.target.value),children:[c.jsx("option",{value:"all",children:g("diagnostics-all-levels")}),["debug","info","warn","error"].map(T=>c.jsx("option",{value:T,children:T},T))]}),c.jsx("input",{"aria-label":g("diagnostics-component"),placeholder:g("diagnostics-component"),value:X,onChange:T=>V(T.target.value)})]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:w,onChange:T=>S(T.target.checked)})," ",g("diagnostics-pause")]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:x,onChange:T=>C(T.target.checked)})," ",g("diagnostics-autoscroll")]})]}),c.jsx("pre",{ref:ne,className:"nc-diag-log","aria-label":g("diagnostics-log"),children:U||g("diagnostics-empty")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:j,children:g("copy")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:P,children:g("diagnostics-export")}),c.jsx("button",{type:"button",className:"nc-btn danger",disabled:n,onClick:()=>{window.confirm(g("diagnostics-clear-confirm"))&&H(async()=>{const T=await Zb(e,u.route);return A.current=0,_([]),T})},children:g("diagnostics-clear")})]}),b&&c.jsx("div",{className:"nc-err",children:b})]})}function B2({token:e,settings:t,readonly:n,refresh:s}){const[o,a]=R.useState(null),[u,h]=R.useState(null),[p,f]=R.useState(!1),[_,b]=R.useState(!1),[y,w]=R.useState(null),[S,x]=R.useState(!0);R.useEffect(()=>{w(t&&t.update||null),x(!t||t.autoUpdate!==!1)},[t]);const C=async()=>{a(null),h(null),b(!0);try{const A=await $b(e);h(A.note||"ok"),f(!1)}catch(A){a(String(A.message||A))}b(!1)},k=async()=>{a(null),h(null),b(!0);try{const A=await Yb(e);h(`${A.note||"ok"}${A.target?` (${A.target})`:""}`)}catch(A){a(String(A.message||A))}b(!1)},N=async A=>{a(null),h(null),b(!0);try{await __(e,{autoUpdate:A}),x(A),s&&await s()}catch(ne){a(String(ne.message||ne))}b(!1)},I=async()=>{a(null),h(null),b(!0);try{w(await Xb(e))}catch(A){a(String(A.message||A))}b(!1)},D=async()=>{a(null),h(null),b(!0);try{const A=await Gb(e);w(A),h(g("npm-update-restarting"))}catch(A){a(String(A.message||A))}b(!1)},X=()=>{window.confirm(g("composer-clear-confirm"))&&(a(null),MC()?(window.dispatchEvent(new Event(ih)),h(g("composer-clear-done"))):a(g("composer-clear-failed")))},V=t&&t.service;return c.jsxs("div",{className:"nc-set-tab",children:[t&&c.jsxs("div",{className:"nc-set-info",children:["v",t.version," · ",t.platform," · :",t.port,c.jsx("br",{}),V&&V.installed?g("service-installed"):g("service-missing"),V&&V.installed?` · ${V.active?g("service-active"):g("service-inactive")}`:"",V?` · boot ${V.boot?"on":"off"}`:""]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||_,title:n?g("settings-readonly"):"",onClick:()=>{a(null),h(null),f(!0)},children:g("token-rotate")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||_,title:n?g("settings-readonly"):"",onClick:k,children:g("service-regenerate")})]}),c.jsxs("div",{className:"nc-set-form nc-update-settings",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:S,disabled:n||_||y&&!y.supported,onChange:A=>N(A.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:g("npm-auto-update")}),c.jsx("small",{children:g("npm-auto-update-help")})]})]}),y&&c.jsxs("div",{className:"nc-set-info",children:[g("npm-update-current")," v",y.current,y.latest?` · ${g("npm-update-latest")} v${y.latest}`:""," · ",g(`npm-update-${y.supported?y.phase:"unsupported"}`)]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||_||!y||!y.supported,onClick:I,children:g("npm-update-check")}),y&&y.available&&c.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||_||y.phase==="installing",onClick:D,children:g("npm-update-install")})]}),y&&y.lastError&&c.jsx("div",{className:"nc-err",children:y.lastError})]}),c.jsx(T2,{token:e,readonly:n}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:g("composer-clear-data")}),c.jsx("small",{className:"nc-set-hint",children:g("composer-clear-data-help")}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:X,children:g("composer-clear-data")})})]}),p&&c.jsxs("div",{className:"nc-set-confirm",children:[c.jsx("div",{children:g("token-rotate-explain")}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:_,onClick:()=>f(!1),children:g("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:_,onClick:C,children:g("confirm")})]})]}),u&&c.jsx("div",{className:"nc-set-note",children:u}),o&&c.jsx("div",{className:"nc-err",children:o})]})}function O2({token:e,onClose:t,initialTab:n="nodes",initialLocation:s="",startNewCell:o=!1}){On();const[a,u]=R.useState(n),[h,p]=R.useState(null),[f,_]=R.useState([]),[b,y]=R.useState(!1),[w,S]=R.useState(null),[x,C]=R.useState(0),k=bh(e,!0,x),N=R.useCallback(async()=>{try{const I=await g_(e);p(I),S(null)}catch(I){S(String(I.message||I))}try{const I=await zb(e);_(I.peers||[])}catch(I){S(String(I.message||I))}},[e]);return R.useEffect(()=>{N();const I=setInterval(N,5e3);return()=>clearInterval(I)},[N]),R.useEffect(()=>{let I=!1;return en("/api/config",e).then(D=>D.json()).then(D=>{I||y(!!D.readonlyDefault)}).catch(()=>{}),()=>{I=!0}},[e]),c.jsx("div",{className:"nc-set-overlay",onClick:t,children:c.jsxs("div",{className:"nc-set-panel",onClick:I=>I.stopPropagation(),children:[c.jsxs("div",{className:"nc-set-head",children:[c.jsx(nt,{name:"gear",size:18}),c.jsx("b",{children:g("settings")}),c.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:g("close"),children:c.jsx(nt,{name:"x",size:18})})]}),b&&c.jsx("div",{className:"nc-set-readonly",children:g("settings-readonly")}),w&&c.jsx("div",{className:"nc-err",children:w}),c.jsx("div",{className:"nc-set-tabs",children:["nodes","fleet","input","diagnostics","system"].map(I=>c.jsx("button",{type:"button",className:`nc-set-tabbtn${a===I?" on":""}`,onClick:()=>u(I),children:g(`tab-${I}`)},I))}),c.jsxs("div",{className:"nc-set-body",children:[a==="nodes"&&c.jsx(M2,{token:e,nodes:f,roster:k,settings:h,readonly:b,refresh:N,refreshAliases:()=>C(I=>I+1)}),a==="fleet"&&c.jsx(j2,{token:e,readonly:b,startNewCell:o,initialLocation:s,targets:k.map(I=>({route:I.route,label:I.label||I.name,status:I.status}))}),a==="input"&&c.jsx(A2,{}),a==="diagnostics"&&c.jsx(I2,{token:e,roster:k,readonly:b}),a==="system"&&c.jsx(B2,{token:e,settings:h,readonly:b,refresh:N})]})]})})}function z2({token:e,initialPair:t,deviceDefault:n="",localNodeId:s="",localNameDefault:o="",onPairDone:a,onDone:u}){On();const[h,p]=R.useState(t?"pair":"welcome"),[f,_]=R.useState(!1),[b,y]=R.useState(null),w=async()=>{_(!0),y(null);try{await __(e,{wizardDone:!0}),a&&a(),u()}catch(S){y(String(S.message||S)),_(!1)}};return c.jsx("div",{className:"nc-wiz-overlay",children:c.jsxs("div",{className:"nc-wiz",children:[c.jsxs("div",{className:"nc-wiz-head",children:[c.jsx("b",{children:g("wizard-title")}),c.jsx("small",{children:g("hydra-simple")})]}),h==="welcome"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx("div",{className:"nc-wiz-done",children:g("local-ready")}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",disabled:f,onClick:w,children:g("local-only")}),c.jsx("button",{className:"nc-btn primary",disabled:f,onClick:()=>p("pair"),children:g("add-node")})]})]}),h==="pair"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx(cw,{token:e,initial:t||"",autoStart:!!t,deviceDefault:n,localNodeId:s,localNameDefault:o,onBusyChange:_,onSuccess:async()=>{a&&a(),p("done")}}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{className:"nc-btn ghost",disabled:f,onClick:()=>{a&&a(),p("welcome")},children:g("back")})})]}),h==="done"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx("div",{className:"nc-wiz-done",children:g("node-connected")}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{className:"nc-btn primary",disabled:f,onClick:w,children:g("finish")})})]}),b&&c.jsx("div",{className:"nc-err",children:b})]})})}function F2(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 $2=6e3,H2=12e3;function W2({n:e,onClose:t}){return c.jsxs("div",{className:`nc-ntf-toast${e.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[c.jsxs("div",{className:"nc-ntf-toast-txt",children:[c.jsx("b",{children:e.title}),e.body&&c.jsx("small",{children:e.body}),e.session&&c.jsx("span",{className:"nc-ntf-from",children:e.session})]}),c.jsx("button",{type:"button",className:"nc-ntf-x",onClick:t,title:g("close"),children:c.jsx(nt,{name:"x",size:14})})]})}function U2({ask:e,token:t,onAnswered:n}){const[s,o]=R.useState(""),[a,u]=R.useState(!1),[h,p]=R.useState(null),f=async _=>{const b=String(_||"").trim();if(!(!b||a)){p(null),u(!0);try{await t0(t,e.id,b),n(e.id)}catch(y){p(String(y.message||y))}u(!1)}};return c.jsxs("div",{className:"nc-ask-card",children:[c.jsxs("div",{className:"nc-ask-head",children:[c.jsx("span",{className:"nc-ntf-from",children:e.session}),c.jsxs("code",{className:"nc-ask-id",children:["#",e.id]})]}),c.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&c.jsx("div",{className:"nc-ask-opts",children:e.options.map(_=>c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:a,onClick:()=>f(_),children:_},_))}),c.jsxs("div",{className:"nc-ask-reply",children:[c.jsx("textarea",{rows:2,placeholder:g("ask-reply-ph"),value:s,disabled:a,onChange:_=>o(_.target.value)}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:a||!s.trim(),onClick:()=>f(s),children:g("send")})]}),h&&c.jsx("div",{className:"nc-err",children:h})]})}function K2({token:e}){On();const[t,n]=R.useState([]),[s,o]=R.useState([]),[a,u]=R.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),h=R.useRef(0),p=R.useCallback(b=>{n(y=>y.filter(w=>w.key!==b))},[]),f=R.useCallback(b=>{const y=`t${h.current+=1}`;n(w=>[...w.slice(-3),{...b,key:y}]),setTimeout(()=>p(y),b.urgency==="high"?H2:$2)},[p]);R.useEffect(()=>{if(!e)return;let b=!1;e0(e).then(w=>{b||o(w.asks||[])}).catch(()=>{});const y=F2(e,w=>{w.type==="notify"?f(w):w.type==="ask"&&w.ask&&w.ask.id?o(S=>S.some(x=>x.id===w.ask.id)?S:[...S,w.ask]):w.type==="ask-answered"&&w.id&&o(S=>S.filter(x=>x.id!==w.id))});return()=>{b=!0,y()}},[e,f]);const _=b=>o(y=>y.filter(w=>w.id!==b));return c.jsxs(c.Fragment,{children:[t.length>0&&c.jsx("div",{className:"nc-ntf-toasts",children:t.map(b=>c.jsx(W2,{n:b,onClose:()=>p(b.key)},b.key))}),s.length>0&&!a&&c.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>u(!0),title:g("asks-title"),children:["? ",c.jsx("span",{className:"nc-ask-count",children:s.length})]}),s.length>0&&a&&c.jsxs("div",{className:"nc-ask-panel",children:[c.jsxs("div",{className:"nc-ask-panel-head",children:[c.jsx("b",{children:g("asks-title")}),c.jsx("span",{className:"nc-ask-count",children:s.length}),c.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>u(!1),title:g("close"),children:c.jsx(nt,{name:"x",size:16})})]}),c.jsx("div",{className:"nc-ask-panel-body",children:s.map(b=>c.jsx(U2,{ask:b,token:e,onAnswered:_},b.id))})]})]})}const hd=e=>gi(Mr(e)).length===0,fd=e=>Array.isArray(e)?e.join("/"):"";function q2(e){const t=new Set,n=[];for(const s of Array.isArray(e)?e:[])!s||!In.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 vo(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function Cr(e,t,n,s=!1,o=!0){const a=t.instanceId;return{...e,id:vs(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:sh(e.layout,a,n)}}function V2(e,t,n,s,o=[]){const[a,u]=R.useState([]),[h,p]=R.useState(!1),[f,_]=R.useState("idle"),[b,y]=R.useState(""),[w,S]=R.useState(""),x=R.useRef([]),C=R.useRef([]),k=R.useRef(""),N=R.useRef(t),I=R.useRef(n),D=R.useRef(!1),X=R.useRef(!0),V=R.useRef(""),A=R.useMemo(()=>q2(o),[o]),ne=A.map(B=>`${B.instanceId}:${fd(B.route)}:${B.status}:${B.label}`).join("|");C.current=A,I.current=n,N.current=t,x.current=a;const W=R.useCallback(B=>oh(B.layout,k.current,C.current),[]),Z=R.useCallback((B,L=!0,z=N.current)=>{const G=mv(B,Qa()),oe=x.current.some(me=>me.id===z);x.current=G,u(G);const de=G.find(me=>me.id===z);if(L&&de){X.current=!0;const me=W(de);s(me),de.local&&iE(de.name,me)}else oe&&!de&&(X.current=!0,s(gs()),y("deck non più condiviso dal nodo owner"));ZC(G.filter(me=>me.local).map(me=>me.name))},[s,W]),U=R.useCallback(async B=>{let L=await Wa(e);const z=L.decks.find(G=>G.name==="main");if(L.decks.length===1&&z&&z.revision===0&&hd(z.layout)){const G=QC(),oe=Mr(ah("main")||gs());if(!hd(oe)){const de=sh(oe,B,[]);L.decks[0]=await Ua(e,"main",de,0,[])}for(const de of G.filter(me=>me!=="main"))try{let me=await Km(e,de,[]);const Q=Mr(ah(de)||gs());hd(Q)||(me=await Ua(e,de,sh(Q,B,[]),me.revision,[]))}catch{}L=await Wa(e)}return L},[e]),H=R.useCallback(async({migrate:B=!1}={})=>{const L=await yh(e,[]),z=In.test(String(L.instanceId||""))?L.instanceId:"";if(!z)throw new Error("instanceId locale non disponibile");k.current=z,S(z);const[G,oe]=await Promise.all([B?U(z):Wa(e),Fm(e,[]).catch(()=>({nodes:[]}))]),de={instanceId:z,route:[],label:"Local"},me=G.decks.map(q=>Cr(q,de,oe.nodes,!0,!0)),Q=x.current;return await Promise.all(C.current.map(async q=>{if(q.status!=="up"){me.push(...Q.filter(pe=>!pe.local&&pe.ownerId===q.instanceId).map(pe=>({...pe,ownerRoute:[...q.route],ownerLabel:q.label,available:!1})));return}try{const[pe,Ie]=await Promise.all([Wa(e,q.route),Fm(e,q.route).catch(()=>({nodes:[]}))]);me.push(...pe.decks.map(it=>Cr(it,q,Ie.nodes,!1,!0)))}catch{me.push(...Q.filter(Ie=>!Ie.local&&Ie.ownerId===q.instanceId).map(Ie=>({...Ie,ownerRoute:[...q.route],ownerLabel:q.label,available:!1})))}})),me.sort((q,pe)=>q.local===pe.local?q.ownerLabel.localeCompare(pe.ownerLabel)||(q.name==="main"?-1:pe.name==="main"?1:q.name.localeCompare(pe.name)):q.local?-1:1),me},[e,U,ne]);R.useEffect(()=>{if(!e)return;let B=!1;const L=V.current!==e;return V.current=e,H({migrate:L}).then(z=>{if(B)return;const G=x.current.find(me=>me.id===N.current),oe=z.find(me=>me.id===N.current),de=oe&&(!G||oe.revision>G.revision||G.available!==oe.available||fd(G.ownerRoute)!==fd(oe.ownerRoute));Z(z,L||!!de&&!D.current),p(!0),oe&&y("")}).catch(z=>{B||(p(!0),y(String(z.message||z)))}),()=>{B=!0}},[Z,H,ne,e]);const j=R.useCallback(async(B=N.current)=>{if(!h||!D.current)return!0;const L=x.current.find(z=>z.id===B);if(!L)return y(`deck inesistente: ${B}`),!1;if(L.available===!1)return y(`nodo owner offline: ${L.ownerLabel}`),!1;_("saving");try{const z=fv(Mr(I.current),L.ownerId,L.ownerTopology),G=await Ua(e,L.name,z,L.revision,L.ownerRoute),oe=Cr(G,vo(L),L.ownerTopology,L.local,!0);return Z(x.current.map(de=>de.id===B?oe:de),!1),D.current=!1,_("saved"),y(""),setTimeout(()=>_("idle"),1500),!0}catch(z){if(_("error"),y(String(z.message||z)),z.status===409&&z.data&&z.data.current){const G=x.current.find(de=>de.id===B),oe=Cr(z.data.current,vo(G),G.ownerTopology,G.local,!0);Z(x.current.map(de=>de.id===B?oe:de),!1)}return!1}},[h,e,Z]);return R.useEffect(()=>{if(!h)return;if(X.current){X.current=!1;return}D.current=!0,_("saving");const B=setTimeout(j,650);return()=>clearTimeout(B)},[n,h,j]),R.useEffect(()=>{if(!h)return;const B=setInterval(async()=>{try{const L=await H(),z=x.current.find(de=>de.id===N.current),G=L.find(de=>de.id===N.current),oe=G&&(!z||G.revision>z.revision||z.available!==G.available);Z(L,oe&&!D.current)}catch{}},5e3);return()=>clearInterval(B)},[h,H,Z]),{decks:a,records:a,localNodeId:w,ready:h,saveState:f,error:b,setError:y,saveNow:j,select:async B=>{if(D.current&&!await j(N.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const L=x.current.find(z=>z.id===B);if(!L)throw new Error(`deck inesistente: ${B}`);return D.current=!1,X.current=!0,W(L)},add:async(B,L=null)=>{const z=L===pi?x.current.find(de=>de.local):L?x.current.find(de=>de.ownerId===L):null;if(!z||z.available===!1)throw new Error("nodo owner non disponibile");const G=await Km(e,B,z.ownerRoute),oe=Cr(G,vo(z),z.ownerTopology,z.local,!0);return Z([...x.current,oe],!1),oe},rename:async(B,L)=>{const z=x.current.find(Q=>Q.id===B);if(!z)throw new Error("deck inesistente");if(B===N.current&&D.current&&!await j(B))throw new Error(`salvataggio di "${z.name}" fallito: rinomina annullata`);const G=x.current.find(Q=>Q.id===B);if(!G)throw new Error("deck inesistente");const oe=await n0(e,G.name,L,G.revision,G.ownerRoute),de=Cr(oe,vo(G),G.ownerTopology,G.local,!0),me=G.local?pi:G.ownerId;return Fu(tE(Qa(),me,B,de.id)),Z(x.current.map(Q=>Q.id===B?de:Q),!1),de},remove:async B=>{const L=x.current.find(G=>G.id===B);if(!L)throw new Error("deck inesistente");B===N.current&&(D.current=!1),await i0(e,L.name,L.revision,L.ownerRoute);const z=L.local?pi:L.ownerId;Fu(nE(Qa(),z,B)),Z(x.current.filter(G=>G.id!==B),!1)},reorder:(B,L)=>{const z=x.current.find(q=>q.id===B),G=x.current.find(q=>q.id===L);if(!z||!G)return!1;const oe=z.local?pi:z.ownerId,de=G.local?pi:G.ownerId;if(oe!==de)return!1;const me=x.current.filter(q=>(q.local?pi:q.ownerId)===oe).map(q=>q.id),Q=Fu(eE(Qa(),oe,B,L,me));return Z(mv(x.current,Q),!1),!0},addTileTo:async(B,L)=>{const z=x.current.find(q=>q.id===B);if(!z)throw new Error("deck inesistente");if(z.available===!1)throw new Error(`nodo owner offline: ${z.ownerLabel}`);const G=Ky(L,k.current,C.current);if(!G)throw new Error("riferimento sessione non valido");const oe=W(z),de=fv(A_(oe,G),z.ownerId,z.ownerTopology),me=await Ua(e,z.name,de,z.revision,z.ownerRoute),Q=Cr(me,vo(z),z.ownerTopology,z.local,!0);return Z(x.current.map(q=>q.id===B?Q:q),!1),Q},localMainId:vs(null,"main"),parseDeckId:Dl}}const Y2="/sw.js",ch="nc-sw-update";let uh=null,dh=!1,hh=null,yw=Object.freeze({needed:!1,kind:null,version:""}),ww=!1;function Sw(){typeof window<"u"&&window.dispatchEvent(new Event(ch))}function bw(){const e=hh||(dh?{kind:"reload",version:""}:null);yw=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function i_(){return yw}function X2(e){return typeof window>"u"?()=>{}:(window.addEventListener(ch,e),()=>window.removeEventListener(ch,e))}function Jh(e){dh!==e&&(dh=e,bw(),Sw())}function G2(e,t,n){let s=null;e&&t&&e!==t?s={kind:"install",version:e}:t&&n&&t!==n&&(s={kind:"reload",version:t});const o=JSON.stringify(s)===JSON.stringify(hh);hh=s,bw(),o||Sw()}function J2(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&Jh(!0)})}function Q2(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{ww&&location.reload()}),navigator.serviceWorker.register(Y2).then(e=>{uh=e,e.waiting&&Jh(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&J2(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function Z2(){ww=!0,Jh(!1);const e=uh&&uh.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function eN({hash:e="",origin:t="",pathname:n="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),a=`${n||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:a};const u=new URLSearchParams(o),h=u.get("token")||"",p=u.get("pair")||"",f=p?`${t||""}${n||""}#pair=${p}`:"";return{token:h,pair:f,nextUrl:a}}const kw=9,xw=24,Cw="nc_side_w",r_="nc_side_min",tN=240,s_="(min-width:1024px) and (pointer:fine)";function nN(){const e=Number(localStorage.getItem(Cw));return e>=180&&e<=480?e:tN}function iN(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=kw&&e<=xw?e:13}function rN(){const e={token:"",pair:""};try{const{token:t,pair:n,nextUrl:s}=eN({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 sN(e){try{return Mr(ah(e))}catch{return gs()}}function o_(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 oN(){const[e,t]=R.useState(()=>window.matchMedia(s_).matches);return R.useEffect(()=>{const n=window.matchMedia(s_),s=o=>t(o.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),e}function a_({session:e,node:t,ownerId:n,cellName:s,token:o,readonly:a=!1,onBack:u}){On();const[h]=zh(),[p,f]=R.useState(!1),[_,b]=R.useState(()=>window.matchMedia("(pointer: coarse)").matches),[y,w]=R.useState(null),[S,x]=R.useState(iN),[C,k]=R.useState(s||e),[N,I]=R.useState(""),D=P=>x(T=>{const F=Math.max(kw,Math.min(xw,T+P));return localStorage.setItem("nc_fontsize",String(F)),F}),X=R.useRef(()=>{}),V=R.useRef(()=>!1),A=R.useRef(()=>{}),ne=R.useRef(!1),[W,Z]=R.useState(!1),[U,H]=R.useState(!1),j=()=>{ne.current=!ne.current,Z(ne.current)};return R.useEffect(()=>{k(s||e)},[s,e]),R.useEffect(()=>{let P=!0;const T=t?t.split("/"):[],F=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function te(){let ie=null,B=null;try{const G=await(await en(`${F}/sessions`,o)).json();Array.isArray(G.sessions)&&(ie=G.sessions.find(oe=>oe.name===e))}catch{}try{const z=await Br(o,T);z.available&&Array.isArray(z.cells)&&(B=z.cells.find(G=>G.tmuxSession===e))}catch{}if(!P)return;k(Fh({session:e,cell:B||(s?{cell:s}:null)}));let L="";B?L=`${B.engine}${B.key?`·${B.key}`:""}`:ie&&(L=ie.attached?`attached · ${o_(ie.activity)}`:ie.activity?o_(ie.activity):""),I(L)}te();const M=setInterval(te,4e3);return()=>{P=!1,clearInterval(M)}},[e,t,o]),c.jsxs("div",{className:"nc-app",children:[c.jsxs("header",{className:"nc-bar nc-bar-single",children:[c.jsxs("button",{onClick:u,title:g("sessions"),children:[c.jsx(nt,{name:"chevronLeft",size:18}),c.jsx("span",{className:"nc-bar-label",children:g("sessions")})]}),c.jsxs("span",{className:"nc-bar-center",children:[c.jsx("b",{title:t?`${C} · ${t}`:C,children:C}),N&&c.jsx("small",{className:"nc-bar-sub",children:N})]}),c.jsxs("span",{className:"nc-bar-right",children:[c.jsx("button",{onClick:()=>D(-1),title:g("zoom-out"),children:c.jsx(nt,{name:"zoomOut",size:18})}),c.jsx("button",{onClick:()=>D(1),title:g("zoom-in"),children:c.jsx(nt,{name:"zoomIn",size:18})}),c.jsx("button",{onClick:()=>b(P=>!P),title:g("composer"),children:c.jsx(nt,{name:"keyboard",size:20})}),c.jsx("button",{onClick:()=>f(P=>!P),title:g("files"),children:c.jsx(nt,{name:"folder",size:20})})]})]}),c.jsx("div",{className:"nc-termwrap",children:c.jsx(Ly,{session:e,node:t,token:o,readonly:a,takeSize:!0,sendRef:X,composerRef:V,actionRef:A,ctrlRef:ne,setCtrlArmed:Z,onFiles:w,fontSize:S,selectionMode:U,onSelectionModeChange:H,keyboardGesture:h.terminalKeyboardGesture})}),c.jsx(bC,{onKeyboard:()=>b(P=>!P),send:P=>X.current(P),action:P=>A.current(P),ctrlArmed:W,onCtrl:j,selectionMode:U,onSelectionMode:H,keepKeyboardClosed:h.keybarKeepsKeyboardClosed,showEnter:h.showKeybarEnter}),_&&c.jsx($y,{submitText:P=>V.current(P),token:o,session:e,node:t,ownerId:n,keepKeyboardClosedOnVoice:h.voiceKeepsKeyboardClosed}),p&&c.jsx(Dy,{session:e,node:t,token:o,filesEvent:y,onClose:()=>f(!1)})]})}function aN(){On();const[e]=R.useState(rN),[t,n]=R.useState(e.token),[s,o]=R.useState(e.pair||""),a=R.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[u,h]=R.useState(!1),p=oN(),[f]=R.useState(()=>JC(typeof location<"u"?location.pathname:"/")),[_,b]=R.useState(f.id),y=_===vs(null,Bn),[w,S]=R.useState(null),x=ue=>{const Ne=cr(ue);S(Ne?{...Ne,...typeof(ue==null?void 0:ue.cellName)=="string"&&ue.cellName?{cellName:ue.cellName}:{}}:null)},[C,k]=R.useState([]),[N,I]=R.useState([]),[D,X]=R.useState([]),[V,A]=R.useState(()=>f.ownerId?gs():sN(f.name)),[ne,W]=R.useState(null),[Z,U]=R.useState(null),H=ue=>U(cr(ue)),j=bh(t,p),P=R.useMemo(()=>(j||[]).filter(ue=>ue.instanceId).map(ue=>({instanceId:ue.instanceId,route:ue.route,label:ue.label,status:ue.status})),[j]),T=V2(t,_,V,A,P),F=T.decks;R.useEffect(()=>{const ue=new Map;for(const Ne of j||[]){const qe=(Ne.route||[Ne.name]).join("/"),tt=new Set((Ne.sessions||[]).map(qt=>qt.name));for(const qt of Ne.cells||[])!qt.cell||!qt.tmuxSession||qt.cell===qt.tmuxSession||tt.has(qt.cell)||ue.set(`${qe}:${qt.cell}`,`${qe}:${qt.tmuxSession}`)}A(Ne=>L0(Ne,ue))},[j]),R.useEffect(()=>{T.localNodeId&&A(ue=>{const Ne=oh(ue,T.localNodeId,P);return JSON.stringify(Ne)===JSON.stringify(ue)?ue:Ne})},[P,T.localNodeId]);const[te,M]=R.useState(null),[ie,B]=R.useState(null),L=R.useRef(0),[z,G]=R.useState(!1),[oe,de]=R.useState(nN),[me,Q]=R.useState(!y),[q,pe]=R.useState(()=>y?localStorage.getItem(r_)==="1":!0),[Ie,it]=R.useState(!1),[ze,Fe]=R.useState("nodes"),[dt,Ue]=R.useState(!1),[ct,_t]=R.useState(""),ut=(ue="nodes",Ne=!1,qe="")=>{Fe(ue),Ue(Ne),_t(qe),it(!0)},[pt,st]=R.useState(!1),[rt,mt]=R.useState({deviceDefault:"",localNodeId:"",localNameDefault:""}),[le,be]=R.useState(!1);R.useEffect(()=>{try{localStorage.setItem(Cw,String(oe))}catch{}},[oe]),R.useEffect(()=>{try{localStorage.setItem(r_,q?"1":"")}catch{}},[q]),R.useEffect(()=>{if(!t)return;let ue=!1;return Promise.all([g_(t),en("/api/config",t).then(Ne=>Ne.json())]).then(([Ne,qe])=>{ue||(mt({deviceDefault:Ne.deviceName||"",localNodeId:Ne.nodeId||"",localNameDefault:Ne.localName||""}),be(!!qe.readonlyDefault),(Ne.firstRun===!0&&!qe.readonlyDefault||s)&&st(!0))}).catch(()=>{}),()=>{ue=!0}},[t,s]);const Ae=R.useCallback(async()=>{try{const Ne=await(await en("/api/sessions",t)).json();Ne.error||k(Ne.sessions||[])}catch{}try{const ue=await Br(t);I(ue.available?ue.cells||[]:[]),X(ue.available?ue.capabilities||[]:[])}catch{I([]),X([])}},[t]);R.useEffect(()=>{if(!p)return;Ae();const ue=setInterval(Ae,4e3);return()=>clearInterval(ue)},[p,Ae]),R.useEffect(()=>{let ue=!1;return en("/api/config",t).then(Ne=>Ne.json()).then(Ne=>{ue||G2(Ne.version,Ne.uiVersion,"0.8.30")}).catch(()=>{}),()=>{ue=!0}},[t]);const We=new Set([...C.map(ue=>ue.name),...j.flatMap(ue=>ue.sessions.map(Ne=>Ne.key))]),he=gi(V),K=ue=>A(Ne=>{const qe=Ky(ue,T.localNodeId,P)||ue,tt=A_(Ne,qe);return tt===Ne&&gi(Ne).length>=9&&T.setError(g("grid-full")),tt}),ee=async(ue,Ne=[])=>{try{await vh(t,ue,Ne)}catch{return}const qe=Ne.length?`${Ne.join("/")}:${ue}`:ue;A(tt=>gl(tt,qe)),Ae()},O=async(ue,Ne,qe=[])=>{try{await m_(t,ue,Ne,qe)}catch{return}Ae()},se=async(ue,Ne,qe=[])=>{await h_(t,{cell:ue,enabled:!!Ne},qe),Ae()},ge=async ue=>{if(!te)return;const{cell:Ne}=te,qe=Array.isArray(te.route)?te.route:[];ue.action==="up"?await mh(t,{cell:Ne,boot:!!ue.boot,...ue.engine?{engine:ue.engine}:{},...ue.model!==void 0?{model:ue.model}:{},...ue.permissionPolicy?{permissionPolicy:ue.permissionPolicy}:{}},qe):await ul(t,{cell:Ne,boot:!!ue.boot},qe);const tt=ue.action==="up"?!!ue.boot:ue.boot?!1:!!te.boot;B({id:++L.current,cell:Ne,route:qe,enabled:tt}),Ae()},ke=R.useCallback(ue=>{B(Ne=>(Ne==null?void 0:Ne.id)===ue?null:Ne)},[]),Ee=async ue=>{if(!(!(ue!=null&&ue.direct)||z)){G(!0);try{await wh(t,ue.name,ue.tunnelStatus==="up"?"down":"up")}finally{G(!1)}}},we=async(ue,Ne)=>{const qe=String(Ne||"").trim();return!(ue!=null&&ue.direct)||!ws(qe)?!1:(await y_(t,ue.name,qe),!0)},Re=ue=>{const Ne=F.find(qe=>qe.id===ue);if(!Ne)return!1;try{const qe=window.open(zu(Ne,t),"_blank");return qe&&(qe.opener=null),!!qe}catch{return!1}},Ge=async ue=>{if(!ue||ue===_)return;const Ne=await T.select(ue),qe=T.records.find(tt=>tt.id===ue);b(ue),A(Ne),W(null),U(null);try{history.replaceState(null,"",zu(qe||ue,null))}catch{}},gt=async(ue,Ne)=>{const qe=await T.add(ue,Ne);await Ge(qe.id)},Be=async(ue,Ne)=>{const qe=await T.rename(ue,Ne);if(ue===_){b(qe.id),A(oh(qe.layout,T.localNodeId,P)),W(null),U(null);try{history.replaceState(null,"",zu(qe,null))}catch{}}},fn=async ue=>{await T.remove(ue),ue===_&&await Ge(T.localMainId)},kt=async(ue,Ne)=>{!Ne||Ne===_||(await T.addTileTo(Ne,ue),A(qe=>gl(qe,ue)))};if(!t)return c.jsxs("div",{className:"nc-auth",children:[c.jsx("p",{children:g("auth-prompt")}),c.jsx("input",{onChange:ue=>n(ue.target.value.trim()),placeholder:"token"}),c.jsxs("label",{children:[c.jsx("input",{type:"checkbox",checked:u,onChange:ue=>h(ue.target.checked)})," ",g("remember-device")]}),c.jsx("button",{onClick:()=>{(u?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const Ke=c.jsxs(c.Fragment,{children:[Ie&&c.jsx(O2,{token:t,initialTab:ze,initialLocation:ct,startNewCell:dt,onClose:()=>{it(!1),Ue(!1),_t("")}}),pt&&c.jsx(z2,{token:t,initialPair:s,...rt,onPairDone:a,onDone:()=>st(!1)}),c.jsx(K2,{token:t})]});if(!p)return w?c.jsxs(c.Fragment,{children:[c.jsx(a_,{session:w.session,node:w.node,ownerId:w.ownerId,cellName:w.cellName,token:t,readonly:le,onBack:()=>S(null)}),Ke]}):c.jsxs(c.Fragment,{children:[c.jsx(q0,{onPick:x,token:t,onSettings:ut}),Ke]});const Et=y||!me;return c.jsxs("div",{className:"nc-workspace",children:[Et&&c.jsx(zC,{sessions:C,cells:N,activeSessions:he,nodeGroups:j,fleetCapabilities:D,bootSettlement:ie,onBootSettlementApplied:ke,localNodeId:T.localNodeId,onPick:H,onAddTile:K,onPower:M,onBoot:se,onBootError:ue=>T.setError(String((ue==null?void 0:ue.message)||ue)),onNodePower:Ee,onNodeRename:we,onKill:ee,onVisibility:O,onNew:()=>ut("fleet",!0),onSettings:ut,width:oe,collapsed:q,onResize:de,onToggleCollapse:()=>pe(ue=>!ue)}),c.jsxs("div",{className:"nc-workspace-main",children:[c.jsx(wE,{decks:F,currentDeck:_,onCreate:gt,onRename:Be,onDelete:fn,onReorder:T.reorder,onOpenWindow:Re,onNavigate:Ge,saveState:T.saveState,error:T.error,sidebarVisible:Et,onToggleSidebar:y?null:()=>Q(ue=>!ue)}),c.jsx(qC,{layout:V,onLayoutChange:A,token:t,readonly:le,sessionsAlive:We,focusSession:ne,onFocus:W,onOpenSingle:H,decks:F,currentDeck:_,onSendToDeck:kt,cells:N,nodeGroups:j})]}),Z&&c.jsx("div",{className:"nc-single-overlay",children:c.jsx(a_,{session:Z.session,node:Z.node,ownerId:Z.ownerId,cellName:Fh({session:Z.session,node:Z.node,ownerId:Z.ownerId,cells:N,nodeGroups:j}),token:t,readonly:le,onBack:()=>U(null)})}),te&&c.jsx(dl,{cell:te,token:t,route:Array.isArray(te.route)?te.route:[],onConfirm:ge,onClose:()=>M(null)}),Ke]})}function lN(){On();const e=R.useSyncExternalStore(X2,i_,i_);if(!e.needed)return null;const t=e.kind==="install"?g("install-version-mismatch").replace("{v}",e.version):g("update-available").replace("{v}",e.version).replace(" "," ").trim();return c.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[c.jsx("span",{className:"nc-update-msg",children:t}),e.kind==="reload"&&c.jsx("button",{className:"nc-update-btn",onClick:Z2,children:g("reload")})]})}Q2();Rb.createRoot(document.getElementById("root")).render(c.jsxs(Sb.StrictMode,{children:[c.jsx(aN,{}),c.jsx(lN,{})]}));