@mmmbuto/nexuscrew 0.8.27 → 0.8.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,93 +0,0 @@
1
- (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const u of a.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&s(u)}).observe(document,{childList:!0,subtree:!0});function i(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=i(o);fetch(o.href,a)}})();function Zd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var au={exports:{}},eo={},lu={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 am;function Tw(){if(am)return et;am=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),i=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"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),b=Symbol.iterator;function w(M){return M===null||typeof M!="object"?null:(M=b&&M[b]||M["@@iterator"],typeof M=="function"?M:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,k={};function C(M,I,se){this.props=M,this.context=I,this.refs=k,this.updater=se||y}C.prototype.isReactComponent={},C.prototype.setState=function(M,I){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,I,"setState")},C.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function x(){}x.prototype=C.prototype;function R(M,I,se){this.props=M,this.context=I,this.refs=k,this.updater=se||y}var D=R.prototype=new x;D.constructor=R,S(D,C.prototype),D.isPureReactComponent=!0;var T=Array.isArray,ee=Object.prototype.hasOwnProperty,V={current:null},W={key:!0,ref:!0,__self:!0,__source:!0};function te(M,I,se){var ge,de={},fe=null,X=null;if(I!=null)for(ge in I.ref!==void 0&&(X=I.ref),I.key!==void 0&&(fe=""+I.key),I)ee.call(I,ge)&&!W.hasOwnProperty(ge)&&(de[ge]=I[ge]);var Z=arguments.length-2;if(Z===1)de.children=se;else if(1<Z){for(var ye=Array(Z),Ee=0;Ee<Z;Ee++)ye[Ee]=arguments[Ee+2];de.children=ye}if(M&&M.defaultProps)for(ge in Z=M.defaultProps,Z)de[ge]===void 0&&(de[ge]=Z[ge]);return{$$typeof:e,type:M,key:fe,ref:X,props:de,_owner:V.current}}function K(M,I){return{$$typeof:e,type:M.type,key:I,ref:M.ref,props:M.props,_owner:M._owner}}function ie(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function Y(M){var I={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(se){return I[se]})}var A=/\/+/g;function N(M,I){return typeof M=="object"&&M!==null&&M.key!=null?Y(""+M.key):I.toString(36)}function j(M,I,se,ge,de){var fe=typeof M;(fe==="undefined"||fe==="boolean")&&(M=null);var X=!1;if(M===null)X=!0;else switch(fe){case"string":case"number":X=!0;break;case"object":switch(M.$$typeof){case e:case t:X=!0}}if(X)return X=M,de=de(X),M=ge===""?"."+N(X,0):ge,T(de)?(se="",M!=null&&(se=M.replace(A,"$&/")+"/"),j(de,I,se,"",function(Ee){return Ee})):de!=null&&(ie(de)&&(de=K(de,se+(!de.key||X&&X.key===de.key?"":(""+de.key).replace(A,"$&/")+"/")+M)),I.push(de)),1;if(X=0,ge=ge===""?".":ge+":",T(M))for(var Z=0;Z<M.length;Z++){fe=M[Z];var ye=ge+N(fe,Z);X+=j(fe,I,se,ye,de)}else if(ye=w(M),typeof ye=="function")for(M=ye.call(M),Z=0;!(fe=M.next()).done;)fe=fe.value,ye=ge+N(fe,Z++),X+=j(fe,I,se,ye,de);else if(fe==="object")throw I=String(M),Error("Objects are not valid as a React child (found: "+(I==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":I)+"). If you meant to render a collection of children, use an array instead.");return X}function L(M,I,se){if(M==null)return M;var ge=[],de=0;return j(M,ge,"","",function(fe){return I.call(se,fe,de++)}),ge}function $(M){if(M._status===-1){var I=M._result;I=I(),I.then(function(se){(M._status===0||M._status===-1)&&(M._status=1,M._result=se)},function(se){(M._status===0||M._status===-1)&&(M._status=2,M._result=se)}),M._status===-1&&(M._status=0,M._result=I)}if(M._status===1)return M._result.default;throw M._result}var U={current:null},B={transition:null},J={ReactCurrentDispatcher:U,ReactCurrentBatchConfig:B,ReactCurrentOwner:V};function z(){throw Error("act(...) is not supported in production builds of React.")}return et.Children={map:L,forEach:function(M,I,se){L(M,function(){I.apply(this,arguments)},se)},count:function(M){var I=0;return L(M,function(){I++}),I},toArray:function(M){return L(M,function(I){return I})||[]},only:function(M){if(!ie(M))throw Error("React.Children.only expected to receive a single React element child.");return M}},et.Component=C,et.Fragment=i,et.Profiler=o,et.PureComponent=R,et.StrictMode=s,et.Suspense=m,et.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=J,et.act=z,et.cloneElement=function(M,I,se){if(M==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+M+".");var ge=S({},M.props),de=M.key,fe=M.ref,X=M._owner;if(I!=null){if(I.ref!==void 0&&(fe=I.ref,X=V.current),I.key!==void 0&&(de=""+I.key),M.type&&M.type.defaultProps)var Z=M.type.defaultProps;for(ye in I)ee.call(I,ye)&&!W.hasOwnProperty(ye)&&(ge[ye]=I[ye]===void 0&&Z!==void 0?Z[ye]:I[ye])}var ye=arguments.length-2;if(ye===1)ge.children=se;else if(1<ye){Z=Array(ye);for(var Ee=0;Ee<ye;Ee++)Z[Ee]=arguments[Ee+2];ge.children=Z}return{$$typeof:e,type:M.type,key:de,ref:fe,props:ge,_owner:X}},et.createContext=function(M){return M={$$typeof:u,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},M.Provider={$$typeof:a,_context:M},M.Consumer=M},et.createElement=te,et.createFactory=function(M){var I=te.bind(null,M);return I.type=M,I},et.createRef=function(){return{current:null}},et.forwardRef=function(M){return{$$typeof:h,render:M}},et.isValidElement=ie,et.lazy=function(M){return{$$typeof:_,_payload:{_status:-1,_result:M},_init:$}},et.memo=function(M,I){return{$$typeof:f,type:M,compare:I===void 0?null:I}},et.startTransition=function(M){var I=B.transition;B.transition={};try{M()}finally{B.transition=I}},et.unstable_act=z,et.useCallback=function(M,I){return U.current.useCallback(M,I)},et.useContext=function(M){return U.current.useContext(M)},et.useDebugValue=function(){},et.useDeferredValue=function(M){return U.current.useDeferredValue(M)},et.useEffect=function(M,I){return U.current.useEffect(M,I)},et.useId=function(){return U.current.useId()},et.useImperativeHandle=function(M,I,se){return U.current.useImperativeHandle(M,I,se)},et.useInsertionEffect=function(M,I){return U.current.useInsertionEffect(M,I)},et.useLayoutEffect=function(M,I){return U.current.useLayoutEffect(M,I)},et.useMemo=function(M,I){return U.current.useMemo(M,I)},et.useReducer=function(M,I,se){return U.current.useReducer(M,I,se)},et.useRef=function(M){return U.current.useRef(M)},et.useState=function(M){return U.current.useState(M)},et.useSyncExternalStore=function(M,I,se){return U.current.useSyncExternalStore(M,I,se)},et.useTransition=function(){return U.current.useTransition()},et.version="18.3.1",et}var lm;function eh(){return lm||(lm=1,lu.exports=Tw()),lu.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 cm;function Aw(){if(cm)return eo;cm=1;var e=eh(),t=Symbol.for("react.element"),i=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,m,f){var _,b={},w=null,y=null;f!==void 0&&(w=""+f),m.key!==void 0&&(w=""+m.key),m.ref!==void 0&&(y=m.ref);for(_ in m)s.call(m,_)&&!a.hasOwnProperty(_)&&(b[_]=m[_]);if(h&&h.defaultProps)for(_ in m=h.defaultProps,m)b[_]===void 0&&(b[_]=m[_]);return{$$typeof:t,type:h,key:w,ref:y,props:b,_owner:o.current}}return eo.Fragment=i,eo.jsx=u,eo.jsxs=u,eo}var um;function Iw(){return um||(um=1,au.exports=Aw()),au.exports}var c=Iw(),P=eh();const Bw=Zd(P);var Ia={},cu={exports:{}},_i={},uu={exports:{}},du={};/**
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 dm;function Ow(){return dm||(dm=1,(function(e){function t(B,J){var z=B.length;B.push(J);e:for(;0<z;){var M=z-1>>>1,I=B[M];if(0<o(I,J))B[M]=J,B[z]=I,z=M;else break e}}function i(B){return B.length===0?null:B[0]}function s(B){if(B.length===0)return null;var J=B[0],z=B.pop();if(z!==J){B[0]=z;e:for(var M=0,I=B.length,se=I>>>1;M<se;){var ge=2*(M+1)-1,de=B[ge],fe=ge+1,X=B[fe];if(0>o(de,z))fe<I&&0>o(X,de)?(B[M]=X,B[fe]=z,M=fe):(B[M]=de,B[ge]=z,M=ge);else if(fe<I&&0>o(X,z))B[M]=X,B[fe]=z,M=fe;else break e}}return J}function o(B,J){var z=B.sortIndex-J.sortIndex;return z!==0?z:B.id-J.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 m=[],f=[],_=1,b=null,w=3,y=!1,S=!1,k=!1,C=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function D(B){for(var J=i(f);J!==null;){if(J.callback===null)s(f);else if(J.startTime<=B)s(f),J.sortIndex=J.expirationTime,t(m,J);else break;J=i(f)}}function T(B){if(k=!1,D(B),!S)if(i(m)!==null)S=!0,$(ee);else{var J=i(f);J!==null&&U(T,J.startTime-B)}}function ee(B,J){S=!1,k&&(k=!1,x(te),te=-1),y=!0;var z=w;try{for(D(J),b=i(m);b!==null&&(!(b.expirationTime>J)||B&&!Y());){var M=b.callback;if(typeof M=="function"){b.callback=null,w=b.priorityLevel;var I=M(b.expirationTime<=J);J=e.unstable_now(),typeof I=="function"?b.callback=I:b===i(m)&&s(m),D(J)}else s(m);b=i(m)}if(b!==null)var se=!0;else{var ge=i(f);ge!==null&&U(T,ge.startTime-J),se=!1}return se}finally{b=null,w=z,y=!1}}var V=!1,W=null,te=-1,K=5,ie=-1;function Y(){return!(e.unstable_now()-ie<K)}function A(){if(W!==null){var B=e.unstable_now();ie=B;var J=!0;try{J=W(!0,B)}finally{J?N():(V=!1,W=null)}}else V=!1}var N;if(typeof R=="function")N=function(){R(A)};else if(typeof MessageChannel<"u"){var j=new MessageChannel,L=j.port2;j.port1.onmessage=A,N=function(){L.postMessage(null)}}else N=function(){C(A,0)};function $(B){W=B,V||(V=!0,N())}function U(B,J){te=C(function(){B(e.unstable_now())},J)}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(B){B.callback=null},e.unstable_continueExecution=function(){S||y||(S=!0,$(ee))},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):K=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_getFirstCallbackNode=function(){return i(m)},e.unstable_next=function(B){switch(w){case 1:case 2:case 3:var J=3;break;default:J=w}var z=w;w=J;try{return B()}finally{w=z}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(B,J){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var z=w;w=B;try{return J()}finally{w=z}},e.unstable_scheduleCallback=function(B,J,z){var M=e.unstable_now();switch(typeof z=="object"&&z!==null?(z=z.delay,z=typeof z=="number"&&0<z?M+z:M):z=M,B){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=z+I,B={id:_++,callback:J,priorityLevel:B,startTime:z,expirationTime:I,sortIndex:-1},z>M?(B.sortIndex=z,t(f,B),i(m)===null&&B===i(f)&&(k?(x(te),te=-1):k=!0,U(T,z-M))):(B.sortIndex=I,t(m,B),S||y||(S=!0,$(ee))),B},e.unstable_shouldYield=Y,e.unstable_wrapCallback=function(B){var J=w;return function(){var z=w;w=J;try{return B.apply(this,arguments)}finally{w=z}}}})(du)),du}var hm;function zw(){return hm||(hm=1,uu.exports=Ow()),uu.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 fm;function Fw(){if(fm)return _i;fm=1;var e=eh(),t=zw();function i(n){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+n,l=1;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+n+"; 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(n,r){u(n,r),u(n+"Capture",r)}function u(n,r){for(o[n]=r,n=0;n<r.length;n++)s.add(r[n])}var h=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=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 w(n){return m.call(b,n)?!0:m.call(_,n)?!1:f.test(n)?b[n]=!0:(_[n]=!0,!1)}function y(n,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:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function S(n,r,l,d){if(r===null||typeof r>"u"||y(n,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 k(n,r,l,d,p,g,E){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=d,this.attributeNamespace=p,this.mustUseProperty=l,this.propertyName=n,this.type=r,this.sanitizeURL=g,this.removeEmptyString=E}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){C[n]=new k(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var r=n[0];C[r]=new k(r,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){C[n]=new k(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){C[n]=new k(n,2,!1,n,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(n){C[n]=new k(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){C[n]=new k(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){C[n]=new k(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){C[n]=new k(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){C[n]=new k(n,5,!1,n.toLowerCase(),null,!1,!1)});var x=/[\-:]([a-z])/g;function R(n){return n[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(n){var r=n.replace(x,R);C[r]=new k(r,1,!1,n,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var r=n.replace(x,R);C[r]=new k(r,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(n){var r=n.replace(x,R);C[r]=new k(r,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){C[n]=new k(n,1,!1,n.toLowerCase(),null,!1,!1)}),C.xlinkHref=new k("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){C[n]=new k(n,1,!1,n.toLowerCase(),null,!0,!0)});function D(n,r,l,d){var p=C.hasOwnProperty(r)?C[r]:null;(p!==null?p.type!==0:d||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(S(r,l,p,d)&&(l=null),d||p===null?w(r)&&(l===null?n.removeAttribute(r):n.setAttribute(r,""+l)):p.mustUseProperty?n[p.propertyName]=l===null?p.type===3?!1:"":l:(r=p.attributeName,d=p.attributeNamespace,l===null?n.removeAttribute(r):(p=p.type,l=p===3||p===4&&l===!0?"":""+l,d?n.setAttributeNS(d,r,l):n.setAttribute(r,l))))}var T=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,ee=Symbol.for("react.element"),V=Symbol.for("react.portal"),W=Symbol.for("react.fragment"),te=Symbol.for("react.strict_mode"),K=Symbol.for("react.profiler"),ie=Symbol.for("react.provider"),Y=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),U=Symbol.for("react.offscreen"),B=Symbol.iterator;function J(n){return n===null||typeof n!="object"?null:(n=B&&n[B]||n["@@iterator"],typeof n=="function"?n:null)}var z=Object.assign,M;function I(n){if(M===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);M=r&&r[1]||""}return`
34
- `+M+n}var se=!1;function ge(n,r){if(!n||se)return"";se=!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(n,[],r)}else{try{r.call()}catch(ce){d=ce}n.call(r.prototype)}else{try{throw Error()}catch(ce){d=ce}n()}}catch(ce){if(ce&&d&&typeof ce.stack=="string"){for(var p=ce.stack.split(`
35
- `),g=d.stack.split(`
36
- `),E=p.length-1,O=g.length-1;1<=E&&0<=O&&p[E]!==g[O];)O--;for(;1<=E&&0<=O;E--,O--)if(p[E]!==g[O]){if(E!==1||O!==1)do if(E--,O--,0>O||p[E]!==g[O]){var q=`
37
- `+p[E].replace(" at new "," at ");return n.displayName&&q.includes("<anonymous>")&&(q=q.replace("<anonymous>",n.displayName)),q}while(1<=E&&0<=O);break}}}finally{se=!1,Error.prepareStackTrace=l}return(n=n?n.displayName||n.name:"")?I(n):""}function de(n){switch(n.tag){case 5:return I(n.type);case 16:return I("Lazy");case 13:return I("Suspense");case 19:return I("SuspenseList");case 0:case 2:case 15:return n=ge(n.type,!1),n;case 11:return n=ge(n.type.render,!1),n;case 1:return n=ge(n.type,!0),n;default:return""}}function fe(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case W:return"Fragment";case V:return"Portal";case K:return"Profiler";case te:return"StrictMode";case N:return"Suspense";case j:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Y:return(n.displayName||"Context")+".Consumer";case ie:return(n._context.displayName||"Context")+".Provider";case A:var r=n.render;return n=n.displayName,n||(n=r.displayName||r.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case L:return r=n.displayName||null,r!==null?r:fe(n.type)||"Memo";case $:r=n._payload,n=n._init;try{return fe(n(r))}catch{}}return null}function X(n){var r=n.type;switch(n.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 n=r.render,n=n.displayName||n.name||"",r.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return fe(r);case 8:return r===te?"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 Z(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function ye(n){var r=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Ee(n){var r=ye(n)?"checked":"value",l=Object.getOwnPropertyDescriptor(n.constructor.prototype,r),d=""+n[r];if(!n.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var p=l.get,g=l.set;return Object.defineProperty(n,r,{configurable:!0,get:function(){return p.call(this)},set:function(E){d=""+E,g.call(this,E)}}),Object.defineProperty(n,r,{enumerable:l.enumerable}),{getValue:function(){return d},setValue:function(E){d=""+E},stopTracking:function(){n._valueTracker=null,delete n[r]}}}}function tt(n){n._valueTracker||(n._valueTracker=Ee(n))}function Ye(n){if(!n)return!1;var r=n._valueTracker;if(!r)return!0;var l=r.getValue(),d="";return n&&(d=ye(n)?n.checked?"true":"false":n.value),n=d,n!==l?(r.setValue(n),!0):!1}function Be(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function ot(n,r){var l=r.checked;return z({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??n._wrapperState.initialChecked})}function Xe(n,r){var l=r.defaultValue==null?"":r.defaultValue,d=r.checked!=null?r.checked:r.defaultChecked;l=Z(r.value!=null?r.value:l),n._wrapperState={initialChecked:d,initialValue:l,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function _t(n,r){r=r.checked,r!=null&&D(n,"checked",r,!1)}function ut(n,r){_t(n,r);var l=Z(r.value),d=r.type;if(l!=null)d==="number"?(l===0&&n.value===""||n.value!=l)&&(n.value=""+l):n.value!==""+l&&(n.value=""+l);else if(d==="submit"||d==="reset"){n.removeAttribute("value");return}r.hasOwnProperty("value")?rt(n,r.type,l):r.hasOwnProperty("defaultValue")&&rt(n,r.type,Z(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(n.defaultChecked=!!r.defaultChecked)}function ht(n,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=""+n._wrapperState.initialValue,l||r===n.value||(n.value=r),n.defaultValue=r}l=n.name,l!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,l!==""&&(n.name=l)}function rt(n,r,l){(r!=="number"||Be(n.ownerDocument)!==n)&&(l==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+l&&(n.defaultValue=""+l))}var lt=Array.isArray;function le(n,r,l,d){if(n=n.options,r){r={};for(var p=0;p<l.length;p++)r["$"+l[p]]=!0;for(l=0;l<n.length;l++)p=r.hasOwnProperty("$"+n[l].value),n[l].selected!==p&&(n[l].selected=p),p&&d&&(n[l].defaultSelected=!0)}else{for(l=""+Z(l),r=null,p=0;p<n.length;p++){if(n[p].value===l){n[p].selected=!0,d&&(n[p].defaultSelected=!0);return}r!==null||n[p].disabled||(r=n[p])}r!==null&&(r.selected=!0)}}function ke(n,r){if(r.dangerouslySetInnerHTML!=null)throw Error(i(91));return z({},r,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function $e(n,r){var l=r.value;if(l==null){if(l=r.children,r=r.defaultValue,l!=null){if(r!=null)throw Error(i(92));if(lt(l)){if(1<l.length)throw Error(i(93));l=l[0]}r=l}r==null&&(r=""),l=r}n._wrapperState={initialValue:Z(l)}}function We(n,r){var l=Z(r.value),d=Z(r.defaultValue);l!=null&&(l=""+l,l!==n.value&&(n.value=l),r.defaultValue==null&&n.defaultValue!==l&&(n.defaultValue=l)),d!=null&&(n.defaultValue=""+d)}function pe(n){var r=n.textContent;r===n._wrapperState.initialValue&&r!==""&&r!==null&&(n.value=r)}function Oe(n){switch(n){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 Me(n,r){return n==null||n==="http://www.w3.org/1999/xhtml"?Oe(r):n==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var G,re=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,l,d,p){MSApp.execUnsafeLocalFunction(function(){return n(r,l,d,p)})}:n})(function(n,r){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=r;else{for(G=G||document.createElement("div"),G.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=G.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;r.firstChild;)n.appendChild(r.firstChild)}});function F(n,r){if(r){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=r;return}}n.textContent=r}var H={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},oe=["Webkit","ms","Moz","O"];Object.keys(H).forEach(function(n){oe.forEach(function(r){r=r+n.charAt(0).toUpperCase()+n.substring(1),H[r]=H[n]})});function me(n,r,l){return r==null||typeof r=="boolean"||r===""?"":l||typeof r!="number"||r===0||H.hasOwnProperty(n)&&H[n]?(""+r).trim():r+"px"}function Te(n,r){n=n.style;for(var l in r)if(r.hasOwnProperty(l)){var d=l.indexOf("--")===0,p=me(l,r[l],d);l==="float"&&(l="cssFloat"),d?n.setProperty(l,p):n[l]=p}}var we=z({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ce(n,r){if(r){if(we[n]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(i(137,n));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(i(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(i(61))}if(r.style!=null&&typeof r.style!="object")throw Error(i(62))}}function He(n,r){if(n.indexOf("-")===-1)return typeof r.is=="string";switch(n){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 Zt=null;function Qe(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Di=null,Nt=null,qe=null;function ei(n){if(n=zs(n)){if(typeof Di!="function")throw Error(i(280));var r=n.stateNode;r&&(r=Qo(r),Di(n.stateNode,n.type,r))}}function ue(n){Nt?qe?qe.push(n):qe=[n]:Nt=n}function Ne(){if(Nt){var n=Nt,r=qe;if(qe=Nt=null,ei(n),r)for(n=0;n<r.length;n++)ei(r[n])}}function Ve(n,r){return n(r)}function kt(){}var oi=!1;function vs(n,r,l){if(oi)return n(r,l);oi=!0;try{return Ve(n,r,l)}finally{oi=!1,(Nt!==null||qe!==null)&&(kt(),Ne())}}function wi(n,r){var l=n.stateNode;if(l===null)return null;var d=Qo(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)||(n=n.type,d=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!d;break e;default:n=!1}if(n)return null;if(l&&typeof l!="function")throw Error(i(231,r,typeof l));return l}var _s=!1;if(h)try{var ys={};Object.defineProperty(ys,"passive",{get:function(){_s=!0}}),window.addEventListener("test",ys,ys),window.removeEventListener("test",ys,ys)}catch{_s=!1}function Fy(n,r,l,d,p,g,E,O,q){var ce=Array.prototype.slice.call(arguments,3);try{r.apply(l,ce)}catch(_e){this.onError(_e)}}var Ss=!1,Po=null,jo=!1,El=null,$y={onError:function(n){Ss=!0,Po=n}};function Hy(n,r,l,d,p,g,E,O,q){Ss=!1,Po=null,Fy.apply($y,arguments)}function Wy(n,r,l,d,p,g,E,O,q){if(Hy.apply(this,arguments),Ss){if(Ss){var ce=Po;Ss=!1,Po=null}else throw Error(i(198));jo||(jo=!0,El=ce)}}function tr(n){var r=n,l=n;if(n.alternate)for(;r.return;)r=r.return;else{n=r;do r=n,(r.flags&4098)!==0&&(l=r.return),n=r.return;while(n)}return r.tag===3?l:null}function Ph(n){if(n.tag===13){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function jh(n){if(tr(n)!==n)throw Error(i(188))}function Uy(n){var r=n.alternate;if(!r){if(r=tr(n),r===null)throw Error(i(188));return r!==n?null:n}for(var l=n,d=r;;){var p=l.return;if(p===null)break;var g=p.alternate;if(g===null){if(d=p.return,d!==null){l=d;continue}break}if(p.child===g.child){for(g=p.child;g;){if(g===l)return jh(p),n;if(g===d)return jh(p),r;g=g.sibling}throw Error(i(188))}if(l.return!==d.return)l=p,d=g;else{for(var E=!1,O=p.child;O;){if(O===l){E=!0,l=p,d=g;break}if(O===d){E=!0,d=p,l=g;break}O=O.sibling}if(!E){for(O=g.child;O;){if(O===l){E=!0,l=g,d=p;break}if(O===d){E=!0,d=g,l=p;break}O=O.sibling}if(!E)throw Error(i(189))}}if(l.alternate!==d)throw Error(i(190))}if(l.tag!==3)throw Error(i(188));return l.stateNode.current===l?n:r}function Dh(n){return n=Uy(n),n!==null?Lh(n):null}function Lh(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var r=Lh(n);if(r!==null)return r;n=n.sibling}return null}var Mh=t.unstable_scheduleCallback,Th=t.unstable_cancelCallback,Ky=t.unstable_shouldYield,qy=t.unstable_requestPaint,Rt=t.unstable_now,Vy=t.unstable_getCurrentPriorityLevel,Nl=t.unstable_ImmediatePriority,Ah=t.unstable_UserBlockingPriority,Do=t.unstable_NormalPriority,Yy=t.unstable_LowPriority,Ih=t.unstable_IdlePriority,Lo=null,Qi=null;function Xy(n){if(Qi&&typeof Qi.onCommitFiberRoot=="function")try{Qi.onCommitFiberRoot(Lo,n,void 0,(n.current.flags&128)===128)}catch{}}var Wi=Math.clz32?Math.clz32:Jy,Gy=Math.log,Qy=Math.LN2;function Jy(n){return n>>>=0,n===0?32:31-(Gy(n)/Qy|0)|0}var Mo=64,To=4194304;function ws(n){switch(n&-n){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 n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function Ao(n,r){var l=n.pendingLanes;if(l===0)return 0;var d=0,p=n.suspendedLanes,g=n.pingedLanes,E=l&268435455;if(E!==0){var O=E&~p;O!==0?d=ws(O):(g&=E,g!==0&&(d=ws(g)))}else E=l&~p,E!==0?d=ws(E):g!==0&&(d=ws(g));if(d===0)return 0;if(r!==0&&r!==d&&(r&p)===0&&(p=d&-d,g=r&-r,p>=g||p===16&&(g&4194240)!==0))return r;if((d&4)!==0&&(d|=l&16),r=n.entangledLanes,r!==0)for(n=n.entanglements,r&=d;0<r;)l=31-Wi(r),p=1<<l,d|=n[l],r&=~p;return d}function Zy(n,r){switch(n){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 eS(n,r){for(var l=n.suspendedLanes,d=n.pingedLanes,p=n.expirationTimes,g=n.pendingLanes;0<g;){var E=31-Wi(g),O=1<<E,q=p[E];q===-1?((O&l)===0||(O&d)!==0)&&(p[E]=Zy(O,r)):q<=r&&(n.expiredLanes|=O),g&=~O}}function Rl(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function Bh(){var n=Mo;return Mo<<=1,(Mo&4194240)===0&&(Mo=64),n}function Pl(n){for(var r=[],l=0;31>l;l++)r.push(n);return r}function bs(n,r,l){n.pendingLanes|=r,r!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,r=31-Wi(r),n[r]=l}function tS(n,r){var l=n.pendingLanes&~r;n.pendingLanes=r,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=r,n.mutableReadLanes&=r,n.entangledLanes&=r,r=n.entanglements;var d=n.eventTimes;for(n=n.expirationTimes;0<l;){var p=31-Wi(l),g=1<<p;r[p]=0,d[p]=-1,n[p]=-1,l&=~g}}function jl(n,r){var l=n.entangledLanes|=r;for(n=n.entanglements;l;){var d=31-Wi(l),p=1<<d;p&r|n[d]&r&&(n[d]|=r),l&=~p}}var at=0;function Oh(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var zh,Dl,Fh,$h,Hh,Ll=!1,Io=[],Cn=null,En=null,Nn=null,ks=new Map,xs=new Map,Rn=[],iS="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 Wh(n,r){switch(n){case"focusin":case"focusout":Cn=null;break;case"dragenter":case"dragleave":En=null;break;case"mouseover":case"mouseout":Nn=null;break;case"pointerover":case"pointerout":ks.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":xs.delete(r.pointerId)}}function Cs(n,r,l,d,p,g){return n===null||n.nativeEvent!==g?(n={blockedOn:r,domEventName:l,eventSystemFlags:d,nativeEvent:g,targetContainers:[p]},r!==null&&(r=zs(r),r!==null&&Dl(r)),n):(n.eventSystemFlags|=d,r=n.targetContainers,p!==null&&r.indexOf(p)===-1&&r.push(p),n)}function nS(n,r,l,d,p){switch(r){case"focusin":return Cn=Cs(Cn,n,r,l,d,p),!0;case"dragenter":return En=Cs(En,n,r,l,d,p),!0;case"mouseover":return Nn=Cs(Nn,n,r,l,d,p),!0;case"pointerover":var g=p.pointerId;return ks.set(g,Cs(ks.get(g)||null,n,r,l,d,p)),!0;case"gotpointercapture":return g=p.pointerId,xs.set(g,Cs(xs.get(g)||null,n,r,l,d,p)),!0}return!1}function Uh(n){var r=ir(n.target);if(r!==null){var l=tr(r);if(l!==null){if(r=l.tag,r===13){if(r=Ph(l),r!==null){n.blockedOn=r,Hh(n.priority,function(){Fh(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){n.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}n.blockedOn=null}function Bo(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var l=Tl(n.domEventName,n.eventSystemFlags,r[0],n.nativeEvent);if(l===null){l=n.nativeEvent;var d=new l.constructor(l.type,l);Zt=d,l.target.dispatchEvent(d),Zt=null}else return r=zs(l),r!==null&&Dl(r),n.blockedOn=l,!1;r.shift()}return!0}function Kh(n,r,l){Bo(n)&&l.delete(r)}function rS(){Ll=!1,Cn!==null&&Bo(Cn)&&(Cn=null),En!==null&&Bo(En)&&(En=null),Nn!==null&&Bo(Nn)&&(Nn=null),ks.forEach(Kh),xs.forEach(Kh)}function Es(n,r){n.blockedOn===r&&(n.blockedOn=null,Ll||(Ll=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,rS)))}function Ns(n){function r(p){return Es(p,n)}if(0<Io.length){Es(Io[0],n);for(var l=1;l<Io.length;l++){var d=Io[l];d.blockedOn===n&&(d.blockedOn=null)}}for(Cn!==null&&Es(Cn,n),En!==null&&Es(En,n),Nn!==null&&Es(Nn,n),ks.forEach(r),xs.forEach(r),l=0;l<Rn.length;l++)d=Rn[l],d.blockedOn===n&&(d.blockedOn=null);for(;0<Rn.length&&(l=Rn[0],l.blockedOn===null);)Uh(l),l.blockedOn===null&&Rn.shift()}var jr=T.ReactCurrentBatchConfig,Oo=!0;function sS(n,r,l,d){var p=at,g=jr.transition;jr.transition=null;try{at=1,Ml(n,r,l,d)}finally{at=p,jr.transition=g}}function oS(n,r,l,d){var p=at,g=jr.transition;jr.transition=null;try{at=4,Ml(n,r,l,d)}finally{at=p,jr.transition=g}}function Ml(n,r,l,d){if(Oo){var p=Tl(n,r,l,d);if(p===null)Ql(n,r,d,zo,l),Wh(n,d);else if(nS(p,n,r,l,d))d.stopPropagation();else if(Wh(n,d),r&4&&-1<iS.indexOf(n)){for(;p!==null;){var g=zs(p);if(g!==null&&zh(g),g=Tl(n,r,l,d),g===null&&Ql(n,r,d,zo,l),g===p)break;p=g}p!==null&&d.stopPropagation()}else Ql(n,r,d,null,l)}}var zo=null;function Tl(n,r,l,d){if(zo=null,n=Qe(d),n=ir(n),n!==null)if(r=tr(n),r===null)n=null;else if(l=r.tag,l===13){if(n=Ph(r),n!==null)return n;n=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;n=null}else r!==n&&(n=null);return zo=n,null}function qh(n){switch(n){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(Vy()){case Nl:return 1;case Ah:return 4;case Do:case Yy:return 16;case Ih:return 536870912;default:return 16}default:return 16}}var Pn=null,Al=null,Fo=null;function Vh(){if(Fo)return Fo;var n,r=Al,l=r.length,d,p="value"in Pn?Pn.value:Pn.textContent,g=p.length;for(n=0;n<l&&r[n]===p[n];n++);var E=l-n;for(d=1;d<=E&&r[l-d]===p[g-d];d++);return Fo=p.slice(n,1<d?1-d:void 0)}function $o(n){var r=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&r===13&&(n=13)):n=r,n===10&&(n=13),32<=n||n===13?n:0}function Ho(){return!0}function Yh(){return!1}function bi(n){function r(l,d,p,g,E){this._reactName=l,this._targetInst=p,this.type=d,this.nativeEvent=g,this.target=E,this.currentTarget=null;for(var O in n)n.hasOwnProperty(O)&&(l=n[O],this[O]=l?l(g):g[O]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Ho:Yh,this.isPropagationStopped=Yh,this}return z(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=Ho)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Ho)},persist:function(){},isPersistent:Ho}),r}var Dr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Il=bi(Dr),Rs=z({},Dr,{view:0,detail:0}),aS=bi(Rs),Bl,Ol,Ps,Wo=z({},Rs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Fl,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==Ps&&(Ps&&n.type==="mousemove"?(Bl=n.screenX-Ps.screenX,Ol=n.screenY-Ps.screenY):Ol=Bl=0,Ps=n),Bl)},movementY:function(n){return"movementY"in n?n.movementY:Ol}}),Xh=bi(Wo),lS=z({},Wo,{dataTransfer:0}),cS=bi(lS),uS=z({},Rs,{relatedTarget:0}),zl=bi(uS),dS=z({},Dr,{animationName:0,elapsedTime:0,pseudoElement:0}),hS=bi(dS),fS=z({},Dr,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),pS=bi(fS),mS=z({},Dr,{data:0}),Gh=bi(mS),gS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},vS={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"},_S={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function yS(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=_S[n])?!!r[n]:!1}function Fl(){return yS}var SS=z({},Rs,{key:function(n){if(n.key){var r=gS[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=$o(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?vS[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Fl,charCode:function(n){return n.type==="keypress"?$o(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?$o(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),wS=bi(SS),bS=z({},Wo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Qh=bi(bS),kS=z({},Rs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Fl}),xS=bi(kS),CS=z({},Dr,{propertyName:0,elapsedTime:0,pseudoElement:0}),ES=bi(CS),NS=z({},Wo,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),RS=bi(NS),PS=[9,13,27,32],$l=h&&"CompositionEvent"in window,js=null;h&&"documentMode"in document&&(js=document.documentMode);var jS=h&&"TextEvent"in window&&!js,Jh=h&&(!$l||js&&8<js&&11>=js),Zh=" ",ef=!1;function tf(n,r){switch(n){case"keyup":return PS.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function nf(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Lr=!1;function DS(n,r){switch(n){case"compositionend":return nf(r);case"keypress":return r.which!==32?null:(ef=!0,Zh);case"textInput":return n=r.data,n===Zh&&ef?null:n;default:return null}}function LS(n,r){if(Lr)return n==="compositionend"||!$l&&tf(n,r)?(n=Vh(),Fo=Al=Pn=null,Lr=!1,n):null;switch(n){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 Jh&&r.locale!=="ko"?null:r.data;default:return null}}var MS={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 rf(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!MS[n.type]:r==="textarea"}function sf(n,r,l,d){ue(d),r=Yo(r,"onChange"),0<r.length&&(l=new Il("onChange","change",null,l,d),n.push({event:l,listeners:r}))}var Ds=null,Ls=null;function TS(n){kf(n,0)}function Uo(n){var r=Br(n);if(Ye(r))return n}function AS(n,r){if(n==="change")return r}var of=!1;if(h){var Hl;if(h){var Wl="oninput"in document;if(!Wl){var af=document.createElement("div");af.setAttribute("oninput","return;"),Wl=typeof af.oninput=="function"}Hl=Wl}else Hl=!1;of=Hl&&(!document.documentMode||9<document.documentMode)}function lf(){Ds&&(Ds.detachEvent("onpropertychange",cf),Ls=Ds=null)}function cf(n){if(n.propertyName==="value"&&Uo(Ls)){var r=[];sf(r,Ls,n,Qe(n)),vs(TS,r)}}function IS(n,r,l){n==="focusin"?(lf(),Ds=r,Ls=l,Ds.attachEvent("onpropertychange",cf)):n==="focusout"&&lf()}function BS(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Uo(Ls)}function OS(n,r){if(n==="click")return Uo(r)}function zS(n,r){if(n==="input"||n==="change")return Uo(r)}function FS(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var Ui=typeof Object.is=="function"?Object.is:FS;function Ms(n,r){if(Ui(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;var l=Object.keys(n),d=Object.keys(r);if(l.length!==d.length)return!1;for(d=0;d<l.length;d++){var p=l[d];if(!m.call(r,p)||!Ui(n[p],r[p]))return!1}return!0}function uf(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function df(n,r){var l=uf(n);n=0;for(var d;l;){if(l.nodeType===3){if(d=n+l.textContent.length,n<=r&&d>=r)return{node:l,offset:r-n};n=d}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=uf(l)}}function hf(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?hf(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function ff(){for(var n=window,r=Be();r instanceof n.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)n=r.contentWindow;else break;r=Be(n.document)}return r}function Ul(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r&&(r==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||r==="textarea"||n.contentEditable==="true")}function $S(n){var r=ff(),l=n.focusedElem,d=n.selectionRange;if(r!==l&&l&&l.ownerDocument&&hf(l.ownerDocument.documentElement,l)){if(d!==null&&Ul(l)){if(r=d.start,n=d.end,n===void 0&&(n=r),"selectionStart"in l)l.selectionStart=r,l.selectionEnd=Math.min(n,l.value.length);else if(n=(r=l.ownerDocument||document)&&r.defaultView||window,n.getSelection){n=n.getSelection();var p=l.textContent.length,g=Math.min(d.start,p);d=d.end===void 0?g:Math.min(d.end,p),!n.extend&&g>d&&(p=d,d=g,g=p),p=df(l,g);var E=df(l,d);p&&E&&(n.rangeCount!==1||n.anchorNode!==p.node||n.anchorOffset!==p.offset||n.focusNode!==E.node||n.focusOffset!==E.offset)&&(r=r.createRange(),r.setStart(p.node,p.offset),n.removeAllRanges(),g>d?(n.addRange(r),n.extend(E.node,E.offset)):(r.setEnd(E.node,E.offset),n.addRange(r)))}}for(r=[],n=l;n=n.parentNode;)n.nodeType===1&&r.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<r.length;l++)n=r[l],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var HS=h&&"documentMode"in document&&11>=document.documentMode,Mr=null,Kl=null,Ts=null,ql=!1;function pf(n,r,l){var d=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;ql||Mr==null||Mr!==Be(d)||(d=Mr,"selectionStart"in d&&Ul(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}),Ts&&Ms(Ts,d)||(Ts=d,d=Yo(Kl,"onSelect"),0<d.length&&(r=new Il("onSelect","select",null,r,l),n.push({event:r,listeners:d}),r.target=Mr)))}function Ko(n,r){var l={};return l[n.toLowerCase()]=r.toLowerCase(),l["Webkit"+n]="webkit"+r,l["Moz"+n]="moz"+r,l}var Tr={animationend:Ko("Animation","AnimationEnd"),animationiteration:Ko("Animation","AnimationIteration"),animationstart:Ko("Animation","AnimationStart"),transitionend:Ko("Transition","TransitionEnd")},Vl={},mf={};h&&(mf=document.createElement("div").style,"AnimationEvent"in window||(delete Tr.animationend.animation,delete Tr.animationiteration.animation,delete Tr.animationstart.animation),"TransitionEvent"in window||delete Tr.transitionend.transition);function qo(n){if(Vl[n])return Vl[n];if(!Tr[n])return n;var r=Tr[n],l;for(l in r)if(r.hasOwnProperty(l)&&l in mf)return Vl[n]=r[l];return n}var gf=qo("animationend"),vf=qo("animationiteration"),_f=qo("animationstart"),yf=qo("transitionend"),Sf=new Map,wf="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 jn(n,r){Sf.set(n,r),a(r,[n])}for(var Yl=0;Yl<wf.length;Yl++){var Xl=wf[Yl],WS=Xl.toLowerCase(),US=Xl[0].toUpperCase()+Xl.slice(1);jn(WS,"on"+US)}jn(gf,"onAnimationEnd"),jn(vf,"onAnimationIteration"),jn(_f,"onAnimationStart"),jn("dblclick","onDoubleClick"),jn("focusin","onFocus"),jn("focusout","onBlur"),jn(yf,"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 As="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(" "),KS=new Set("cancel close invalid load scroll toggle".split(" ").concat(As));function bf(n,r,l){var d=n.type||"unknown-event";n.currentTarget=l,Wy(d,r,void 0,n),n.currentTarget=null}function kf(n,r){r=(r&4)!==0;for(var l=0;l<n.length;l++){var d=n[l],p=d.event;d=d.listeners;e:{var g=void 0;if(r)for(var E=d.length-1;0<=E;E--){var O=d[E],q=O.instance,ce=O.currentTarget;if(O=O.listener,q!==g&&p.isPropagationStopped())break e;bf(p,O,ce),g=q}else for(E=0;E<d.length;E++){if(O=d[E],q=O.instance,ce=O.currentTarget,O=O.listener,q!==g&&p.isPropagationStopped())break e;bf(p,O,ce),g=q}}}if(jo)throw n=El,jo=!1,El=null,n}function ft(n,r){var l=r[nc];l===void 0&&(l=r[nc]=new Set);var d=n+"__bubble";l.has(d)||(xf(r,n,2,!1),l.add(d))}function Gl(n,r,l){var d=0;r&&(d|=4),xf(l,n,d,r)}var Vo="_reactListening"+Math.random().toString(36).slice(2);function Is(n){if(!n[Vo]){n[Vo]=!0,s.forEach(function(l){l!=="selectionchange"&&(KS.has(l)||Gl(l,!1,n),Gl(l,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Vo]||(r[Vo]=!0,Gl("selectionchange",!1,r))}}function xf(n,r,l,d){switch(qh(r)){case 1:var p=sS;break;case 4:p=oS;break;default:p=Ml}l=p.bind(null,r,l,n),p=void 0,!_s||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(p=!0),d?p!==void 0?n.addEventListener(r,l,{capture:!0,passive:p}):n.addEventListener(r,l,!0):p!==void 0?n.addEventListener(r,l,{passive:p}):n.addEventListener(r,l,!1)}function Ql(n,r,l,d,p){var g=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 O=d.stateNode.containerInfo;if(O===p||O.nodeType===8&&O.parentNode===p)break;if(E===4)for(E=d.return;E!==null;){var q=E.tag;if((q===3||q===4)&&(q=E.stateNode.containerInfo,q===p||q.nodeType===8&&q.parentNode===p))return;E=E.return}for(;O!==null;){if(E=ir(O),E===null)return;if(q=E.tag,q===5||q===6){d=g=E;continue e}O=O.parentNode}}d=d.return}vs(function(){var ce=g,_e=Qe(l),Se=[];e:{var ve=Sf.get(n);if(ve!==void 0){var Pe=Il,De=n;switch(n){case"keypress":if($o(l)===0)break e;case"keydown":case"keyup":Pe=wS;break;case"focusin":De="focus",Pe=zl;break;case"focusout":De="blur",Pe=zl;break;case"beforeblur":case"afterblur":Pe=zl;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":Pe=Xh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Pe=cS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Pe=xS;break;case gf:case vf:case _f:Pe=hS;break;case yf:Pe=ES;break;case"scroll":Pe=aS;break;case"wheel":Pe=RS;break;case"copy":case"cut":case"paste":Pe=pS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Pe=Qh}var Le=(r&4)!==0,Pt=!Le&&n==="scroll",ne=Le?ve!==null?ve+"Capture":null:ve;Le=[];for(var Q=ce,ae;Q!==null;){ae=Q;var be=ae.stateNode;if(ae.tag===5&&be!==null&&(ae=be,ne!==null&&(be=wi(Q,ne),be!=null&&Le.push(Bs(Q,be,ae)))),Pt)break;Q=Q.return}0<Le.length&&(ve=new Pe(ve,De,null,l,_e),Se.push({event:ve,listeners:Le}))}}if((r&7)===0){e:{if(ve=n==="mouseover"||n==="pointerover",Pe=n==="mouseout"||n==="pointerout",ve&&l!==Zt&&(De=l.relatedTarget||l.fromElement)&&(ir(De)||De[hn]))break e;if((Pe||ve)&&(ve=_e.window===_e?_e:(ve=_e.ownerDocument)?ve.defaultView||ve.parentWindow:window,Pe?(De=l.relatedTarget||l.toElement,Pe=ce,De=De?ir(De):null,De!==null&&(Pt=tr(De),De!==Pt||De.tag!==5&&De.tag!==6)&&(De=null)):(Pe=null,De=ce),Pe!==De)){if(Le=Xh,be="onMouseLeave",ne="onMouseEnter",Q="mouse",(n==="pointerout"||n==="pointerover")&&(Le=Qh,be="onPointerLeave",ne="onPointerEnter",Q="pointer"),Pt=Pe==null?ve:Br(Pe),ae=De==null?ve:Br(De),ve=new Le(be,Q+"leave",Pe,l,_e),ve.target=Pt,ve.relatedTarget=ae,be=null,ir(_e)===ce&&(Le=new Le(ne,Q+"enter",De,l,_e),Le.target=ae,Le.relatedTarget=Pt,be=Le),Pt=be,Pe&&De)t:{for(Le=Pe,ne=De,Q=0,ae=Le;ae;ae=Ar(ae))Q++;for(ae=0,be=ne;be;be=Ar(be))ae++;for(;0<Q-ae;)Le=Ar(Le),Q--;for(;0<ae-Q;)ne=Ar(ne),ae--;for(;Q--;){if(Le===ne||ne!==null&&Le===ne.alternate)break t;Le=Ar(Le),ne=Ar(ne)}Le=null}else Le=null;Pe!==null&&Cf(Se,ve,Pe,Le,!1),De!==null&&Pt!==null&&Cf(Se,Pt,De,Le,!0)}}e:{if(ve=ce?Br(ce):window,Pe=ve.nodeName&&ve.nodeName.toLowerCase(),Pe==="select"||Pe==="input"&&ve.type==="file")var Ae=AS;else if(rf(ve))if(of)Ae=zS;else{Ae=BS;var ze=IS}else(Pe=ve.nodeName)&&Pe.toLowerCase()==="input"&&(ve.type==="checkbox"||ve.type==="radio")&&(Ae=OS);if(Ae&&(Ae=Ae(n,ce))){sf(Se,Ae,l,_e);break e}ze&&ze(n,ve,ce),n==="focusout"&&(ze=ve._wrapperState)&&ze.controlled&&ve.type==="number"&&rt(ve,"number",ve.value)}switch(ze=ce?Br(ce):window,n){case"focusin":(rf(ze)||ze.contentEditable==="true")&&(Mr=ze,Kl=ce,Ts=null);break;case"focusout":Ts=Kl=Mr=null;break;case"mousedown":ql=!0;break;case"contextmenu":case"mouseup":case"dragend":ql=!1,pf(Se,l,_e);break;case"selectionchange":if(HS)break;case"keydown":case"keyup":pf(Se,l,_e)}var Fe;if($l)e:{switch(n){case"compositionstart":var Ue="onCompositionStart";break e;case"compositionend":Ue="onCompositionEnd";break e;case"compositionupdate":Ue="onCompositionUpdate";break e}Ue=void 0}else Lr?tf(n,l)&&(Ue="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(Ue="onCompositionStart");Ue&&(Jh&&l.locale!=="ko"&&(Lr||Ue!=="onCompositionStart"?Ue==="onCompositionEnd"&&Lr&&(Fe=Vh()):(Pn=_e,Al="value"in Pn?Pn.value:Pn.textContent,Lr=!0)),ze=Yo(ce,Ue),0<ze.length&&(Ue=new Gh(Ue,n,null,l,_e),Se.push({event:Ue,listeners:ze}),Fe?Ue.data=Fe:(Fe=nf(l),Fe!==null&&(Ue.data=Fe)))),(Fe=jS?DS(n,l):LS(n,l))&&(ce=Yo(ce,"onBeforeInput"),0<ce.length&&(_e=new Gh("onBeforeInput","beforeinput",null,l,_e),Se.push({event:_e,listeners:ce}),_e.data=Fe))}kf(Se,r)})}function Bs(n,r,l){return{instance:n,listener:r,currentTarget:l}}function Yo(n,r){for(var l=r+"Capture",d=[];n!==null;){var p=n,g=p.stateNode;p.tag===5&&g!==null&&(p=g,g=wi(n,l),g!=null&&d.unshift(Bs(n,g,p)),g=wi(n,r),g!=null&&d.push(Bs(n,g,p))),n=n.return}return d}function Ar(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function Cf(n,r,l,d,p){for(var g=r._reactName,E=[];l!==null&&l!==d;){var O=l,q=O.alternate,ce=O.stateNode;if(q!==null&&q===d)break;O.tag===5&&ce!==null&&(O=ce,p?(q=wi(l,g),q!=null&&E.unshift(Bs(l,q,O))):p||(q=wi(l,g),q!=null&&E.push(Bs(l,q,O)))),l=l.return}E.length!==0&&n.push({event:r,listeners:E})}var qS=/\r\n?/g,VS=/\u0000|\uFFFD/g;function Ef(n){return(typeof n=="string"?n:""+n).replace(qS,`
38
- `).replace(VS,"")}function Xo(n,r,l){if(r=Ef(r),Ef(n)!==r&&l)throw Error(i(425))}function Go(){}var Jl=null,Zl=null;function ec(n,r){return n==="textarea"||n==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var tc=typeof setTimeout=="function"?setTimeout:void 0,YS=typeof clearTimeout=="function"?clearTimeout:void 0,Nf=typeof Promise=="function"?Promise:void 0,XS=typeof queueMicrotask=="function"?queueMicrotask:typeof Nf<"u"?function(n){return Nf.resolve(null).then(n).catch(GS)}:tc;function GS(n){setTimeout(function(){throw n})}function ic(n,r){var l=r,d=0;do{var p=l.nextSibling;if(n.removeChild(l),p&&p.nodeType===8)if(l=p.data,l==="/$"){if(d===0){n.removeChild(p),Ns(r);return}d--}else l!=="$"&&l!=="$?"&&l!=="$!"||d++;l=p}while(l);Ns(r)}function Dn(n){for(;n!=null;n=n.nextSibling){var r=n.nodeType;if(r===1||r===3)break;if(r===8){if(r=n.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return n}function Rf(n){n=n.previousSibling;for(var r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="$"||l==="$!"||l==="$?"){if(r===0)return n;r--}else l==="/$"&&r++}n=n.previousSibling}return null}var Ir=Math.random().toString(36).slice(2),Ji="__reactFiber$"+Ir,Os="__reactProps$"+Ir,hn="__reactContainer$"+Ir,nc="__reactEvents$"+Ir,QS="__reactListeners$"+Ir,JS="__reactHandles$"+Ir;function ir(n){var r=n[Ji];if(r)return r;for(var l=n.parentNode;l;){if(r=l[hn]||l[Ji]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(n=Rf(n);n!==null;){if(l=n[Ji])return l;n=Rf(n)}return r}n=l,l=n.parentNode}return null}function zs(n){return n=n[Ji]||n[hn],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function Br(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(i(33))}function Qo(n){return n[Os]||null}var rc=[],Or=-1;function Ln(n){return{current:n}}function pt(n){0>Or||(n.current=rc[Or],rc[Or]=null,Or--)}function dt(n,r){Or++,rc[Or]=n.current,n.current=r}var Mn={},ti=Ln(Mn),fi=Ln(!1),nr=Mn;function zr(n,r){var l=n.type.contextTypes;if(!l)return Mn;var d=n.stateNode;if(d&&d.__reactInternalMemoizedUnmaskedChildContext===r)return d.__reactInternalMemoizedMaskedChildContext;var p={},g;for(g in l)p[g]=r[g];return d&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=r,n.__reactInternalMemoizedMaskedChildContext=p),p}function pi(n){return n=n.childContextTypes,n!=null}function Jo(){pt(fi),pt(ti)}function Pf(n,r,l){if(ti.current!==Mn)throw Error(i(168));dt(ti,r),dt(fi,l)}function jf(n,r,l){var d=n.stateNode;if(r=r.childContextTypes,typeof d.getChildContext!="function")return l;d=d.getChildContext();for(var p in d)if(!(p in r))throw Error(i(108,X(n)||"Unknown",p));return z({},l,d)}function Zo(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Mn,nr=ti.current,dt(ti,n),dt(fi,fi.current),!0}function Df(n,r,l){var d=n.stateNode;if(!d)throw Error(i(169));l?(n=jf(n,r,nr),d.__reactInternalMemoizedMergedChildContext=n,pt(fi),pt(ti),dt(ti,n)):pt(fi),dt(fi,l)}var fn=null,ea=!1,sc=!1;function Lf(n){fn===null?fn=[n]:fn.push(n)}function ZS(n){ea=!0,Lf(n)}function Tn(){if(!sc&&fn!==null){sc=!0;var n=0,r=at;try{var l=fn;for(at=1;n<l.length;n++){var d=l[n];do d=d(!0);while(d!==null)}fn=null,ea=!1}catch(p){throw fn!==null&&(fn=fn.slice(n+1)),Mh(Nl,Tn),p}finally{at=r,sc=!1}}return null}var Fr=[],$r=0,ta=null,ia=0,Li=[],Mi=0,rr=null,pn=1,mn="";function sr(n,r){Fr[$r++]=ia,Fr[$r++]=ta,ta=n,ia=r}function Mf(n,r,l){Li[Mi++]=pn,Li[Mi++]=mn,Li[Mi++]=rr,rr=n;var d=pn;n=mn;var p=32-Wi(d)-1;d&=~(1<<p),l+=1;var g=32-Wi(r)+p;if(30<g){var E=p-p%5;g=(d&(1<<E)-1).toString(32),d>>=E,p-=E,pn=1<<32-Wi(r)+p|l<<p|d,mn=g+n}else pn=1<<g|l<<p|d,mn=n}function oc(n){n.return!==null&&(sr(n,1),Mf(n,1,0))}function ac(n){for(;n===ta;)ta=Fr[--$r],Fr[$r]=null,ia=Fr[--$r],Fr[$r]=null;for(;n===rr;)rr=Li[--Mi],Li[Mi]=null,mn=Li[--Mi],Li[Mi]=null,pn=Li[--Mi],Li[Mi]=null}var ki=null,xi=null,gt=!1,Ki=null;function Tf(n,r){var l=Bi(5,null,null,0);l.elementType="DELETED",l.stateNode=r,l.return=n,r=n.deletions,r===null?(n.deletions=[l],n.flags|=16):r.push(l)}function Af(n,r){switch(n.tag){case 5:var l=n.type;return r=r.nodeType!==1||l.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(n.stateNode=r,ki=n,xi=Dn(r.firstChild),!0):!1;case 6:return r=n.pendingProps===""||r.nodeType!==3?null:r,r!==null?(n.stateNode=r,ki=n,xi=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(l=rr!==null?{id:pn,overflow:mn}:null,n.memoizedState={dehydrated:r,treeContext:l,retryLane:1073741824},l=Bi(18,null,null,0),l.stateNode=r,l.return=n,n.child=l,ki=n,xi=null,!0):!1;default:return!1}}function lc(n){return(n.mode&1)!==0&&(n.flags&128)===0}function cc(n){if(gt){var r=xi;if(r){var l=r;if(!Af(n,r)){if(lc(n))throw Error(i(418));r=Dn(l.nextSibling);var d=ki;r&&Af(n,r)?Tf(d,l):(n.flags=n.flags&-4097|2,gt=!1,ki=n)}}else{if(lc(n))throw Error(i(418));n.flags=n.flags&-4097|2,gt=!1,ki=n}}}function If(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;ki=n}function na(n){if(n!==ki)return!1;if(!gt)return If(n),gt=!0,!1;var r;if((r=n.tag!==3)&&!(r=n.tag!==5)&&(r=n.type,r=r!=="head"&&r!=="body"&&!ec(n.type,n.memoizedProps)),r&&(r=xi)){if(lc(n))throw Bf(),Error(i(418));for(;r;)Tf(n,r),r=Dn(r.nextSibling)}if(If(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(317));e:{for(n=n.nextSibling,r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="/$"){if(r===0){xi=Dn(n.nextSibling);break e}r--}else l!=="$"&&l!=="$!"&&l!=="$?"||r++}n=n.nextSibling}xi=null}}else xi=ki?Dn(n.stateNode.nextSibling):null;return!0}function Bf(){for(var n=xi;n;)n=Dn(n.nextSibling)}function Hr(){xi=ki=null,gt=!1}function uc(n){Ki===null?Ki=[n]:Ki.push(n)}var ew=T.ReactCurrentBatchConfig;function Fs(n,r,l){if(n=l.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(i(309));var d=l.stateNode}if(!d)throw Error(i(147,n));var p=d,g=""+n;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===g?r.ref:(r=function(E){var O=p.refs;E===null?delete O[g]:O[g]=E},r._stringRef=g,r)}if(typeof n!="string")throw Error(i(284));if(!l._owner)throw Error(i(290,n))}return n}function ra(n,r){throw n=Object.prototype.toString.call(r),Error(i(31,n==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":n))}function Of(n){var r=n._init;return r(n._payload)}function zf(n){function r(ne,Q){if(n){var ae=ne.deletions;ae===null?(ne.deletions=[Q],ne.flags|=16):ae.push(Q)}}function l(ne,Q){if(!n)return null;for(;Q!==null;)r(ne,Q),Q=Q.sibling;return null}function d(ne,Q){for(ne=new Map;Q!==null;)Q.key!==null?ne.set(Q.key,Q):ne.set(Q.index,Q),Q=Q.sibling;return ne}function p(ne,Q){return ne=Hn(ne,Q),ne.index=0,ne.sibling=null,ne}function g(ne,Q,ae){return ne.index=ae,n?(ae=ne.alternate,ae!==null?(ae=ae.index,ae<Q?(ne.flags|=2,Q):ae):(ne.flags|=2,Q)):(ne.flags|=1048576,Q)}function E(ne){return n&&ne.alternate===null&&(ne.flags|=2),ne}function O(ne,Q,ae,be){return Q===null||Q.tag!==6?(Q=tu(ae,ne.mode,be),Q.return=ne,Q):(Q=p(Q,ae),Q.return=ne,Q)}function q(ne,Q,ae,be){var Ae=ae.type;return Ae===W?_e(ne,Q,ae.props.children,be,ae.key):Q!==null&&(Q.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===$&&Of(Ae)===Q.type)?(be=p(Q,ae.props),be.ref=Fs(ne,Q,ae),be.return=ne,be):(be=Ra(ae.type,ae.key,ae.props,null,ne.mode,be),be.ref=Fs(ne,Q,ae),be.return=ne,be)}function ce(ne,Q,ae,be){return Q===null||Q.tag!==4||Q.stateNode.containerInfo!==ae.containerInfo||Q.stateNode.implementation!==ae.implementation?(Q=iu(ae,ne.mode,be),Q.return=ne,Q):(Q=p(Q,ae.children||[]),Q.return=ne,Q)}function _e(ne,Q,ae,be,Ae){return Q===null||Q.tag!==7?(Q=fr(ae,ne.mode,be,Ae),Q.return=ne,Q):(Q=p(Q,ae),Q.return=ne,Q)}function Se(ne,Q,ae){if(typeof Q=="string"&&Q!==""||typeof Q=="number")return Q=tu(""+Q,ne.mode,ae),Q.return=ne,Q;if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case ee:return ae=Ra(Q.type,Q.key,Q.props,null,ne.mode,ae),ae.ref=Fs(ne,null,Q),ae.return=ne,ae;case V:return Q=iu(Q,ne.mode,ae),Q.return=ne,Q;case $:var be=Q._init;return Se(ne,be(Q._payload),ae)}if(lt(Q)||J(Q))return Q=fr(Q,ne.mode,ae,null),Q.return=ne,Q;ra(ne,Q)}return null}function ve(ne,Q,ae,be){var Ae=Q!==null?Q.key:null;if(typeof ae=="string"&&ae!==""||typeof ae=="number")return Ae!==null?null:O(ne,Q,""+ae,be);if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case ee:return ae.key===Ae?q(ne,Q,ae,be):null;case V:return ae.key===Ae?ce(ne,Q,ae,be):null;case $:return Ae=ae._init,ve(ne,Q,Ae(ae._payload),be)}if(lt(ae)||J(ae))return Ae!==null?null:_e(ne,Q,ae,be,null);ra(ne,ae)}return null}function Pe(ne,Q,ae,be,Ae){if(typeof be=="string"&&be!==""||typeof be=="number")return ne=ne.get(ae)||null,O(Q,ne,""+be,Ae);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case ee:return ne=ne.get(be.key===null?ae:be.key)||null,q(Q,ne,be,Ae);case V:return ne=ne.get(be.key===null?ae:be.key)||null,ce(Q,ne,be,Ae);case $:var ze=be._init;return Pe(ne,Q,ae,ze(be._payload),Ae)}if(lt(be)||J(be))return ne=ne.get(ae)||null,_e(Q,ne,be,Ae,null);ra(Q,be)}return null}function De(ne,Q,ae,be){for(var Ae=null,ze=null,Fe=Q,Ue=Q=0,$t=null;Fe!==null&&Ue<ae.length;Ue++){Fe.index>Ue?($t=Fe,Fe=null):$t=Fe.sibling;var st=ve(ne,Fe,ae[Ue],be);if(st===null){Fe===null&&(Fe=$t);break}n&&Fe&&st.alternate===null&&r(ne,Fe),Q=g(st,Q,Ue),ze===null?Ae=st:ze.sibling=st,ze=st,Fe=$t}if(Ue===ae.length)return l(ne,Fe),gt&&sr(ne,Ue),Ae;if(Fe===null){for(;Ue<ae.length;Ue++)Fe=Se(ne,ae[Ue],be),Fe!==null&&(Q=g(Fe,Q,Ue),ze===null?Ae=Fe:ze.sibling=Fe,ze=Fe);return gt&&sr(ne,Ue),Ae}for(Fe=d(ne,Fe);Ue<ae.length;Ue++)$t=Pe(Fe,ne,Ue,ae[Ue],be),$t!==null&&(n&&$t.alternate!==null&&Fe.delete($t.key===null?Ue:$t.key),Q=g($t,Q,Ue),ze===null?Ae=$t:ze.sibling=$t,ze=$t);return n&&Fe.forEach(function(Wn){return r(ne,Wn)}),gt&&sr(ne,Ue),Ae}function Le(ne,Q,ae,be){var Ae=J(ae);if(typeof Ae!="function")throw Error(i(150));if(ae=Ae.call(ae),ae==null)throw Error(i(151));for(var ze=Ae=null,Fe=Q,Ue=Q=0,$t=null,st=ae.next();Fe!==null&&!st.done;Ue++,st=ae.next()){Fe.index>Ue?($t=Fe,Fe=null):$t=Fe.sibling;var Wn=ve(ne,Fe,st.value,be);if(Wn===null){Fe===null&&(Fe=$t);break}n&&Fe&&Wn.alternate===null&&r(ne,Fe),Q=g(Wn,Q,Ue),ze===null?Ae=Wn:ze.sibling=Wn,ze=Wn,Fe=$t}if(st.done)return l(ne,Fe),gt&&sr(ne,Ue),Ae;if(Fe===null){for(;!st.done;Ue++,st=ae.next())st=Se(ne,st.value,be),st!==null&&(Q=g(st,Q,Ue),ze===null?Ae=st:ze.sibling=st,ze=st);return gt&&sr(ne,Ue),Ae}for(Fe=d(ne,Fe);!st.done;Ue++,st=ae.next())st=Pe(Fe,ne,Ue,st.value,be),st!==null&&(n&&st.alternate!==null&&Fe.delete(st.key===null?Ue:st.key),Q=g(st,Q,Ue),ze===null?Ae=st:ze.sibling=st,ze=st);return n&&Fe.forEach(function(Mw){return r(ne,Mw)}),gt&&sr(ne,Ue),Ae}function Pt(ne,Q,ae,be){if(typeof ae=="object"&&ae!==null&&ae.type===W&&ae.key===null&&(ae=ae.props.children),typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case ee:e:{for(var Ae=ae.key,ze=Q;ze!==null;){if(ze.key===Ae){if(Ae=ae.type,Ae===W){if(ze.tag===7){l(ne,ze.sibling),Q=p(ze,ae.props.children),Q.return=ne,ne=Q;break e}}else if(ze.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===$&&Of(Ae)===ze.type){l(ne,ze.sibling),Q=p(ze,ae.props),Q.ref=Fs(ne,ze,ae),Q.return=ne,ne=Q;break e}l(ne,ze);break}else r(ne,ze);ze=ze.sibling}ae.type===W?(Q=fr(ae.props.children,ne.mode,be,ae.key),Q.return=ne,ne=Q):(be=Ra(ae.type,ae.key,ae.props,null,ne.mode,be),be.ref=Fs(ne,Q,ae),be.return=ne,ne=be)}return E(ne);case V:e:{for(ze=ae.key;Q!==null;){if(Q.key===ze)if(Q.tag===4&&Q.stateNode.containerInfo===ae.containerInfo&&Q.stateNode.implementation===ae.implementation){l(ne,Q.sibling),Q=p(Q,ae.children||[]),Q.return=ne,ne=Q;break e}else{l(ne,Q);break}else r(ne,Q);Q=Q.sibling}Q=iu(ae,ne.mode,be),Q.return=ne,ne=Q}return E(ne);case $:return ze=ae._init,Pt(ne,Q,ze(ae._payload),be)}if(lt(ae))return De(ne,Q,ae,be);if(J(ae))return Le(ne,Q,ae,be);ra(ne,ae)}return typeof ae=="string"&&ae!==""||typeof ae=="number"?(ae=""+ae,Q!==null&&Q.tag===6?(l(ne,Q.sibling),Q=p(Q,ae),Q.return=ne,ne=Q):(l(ne,Q),Q=tu(ae,ne.mode,be),Q.return=ne,ne=Q),E(ne)):l(ne,Q)}return Pt}var Wr=zf(!0),Ff=zf(!1),sa=Ln(null),oa=null,Ur=null,dc=null;function hc(){dc=Ur=oa=null}function fc(n){var r=sa.current;pt(sa),n._currentValue=r}function pc(n,r,l){for(;n!==null;){var d=n.alternate;if((n.childLanes&r)!==r?(n.childLanes|=r,d!==null&&(d.childLanes|=r)):d!==null&&(d.childLanes&r)!==r&&(d.childLanes|=r),n===l)break;n=n.return}}function Kr(n,r){oa=n,dc=Ur=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&r)!==0&&(mi=!0),n.firstContext=null)}function Ti(n){var r=n._currentValue;if(dc!==n)if(n={context:n,memoizedValue:r,next:null},Ur===null){if(oa===null)throw Error(i(308));Ur=n,oa.dependencies={lanes:0,firstContext:n}}else Ur=Ur.next=n;return r}var or=null;function mc(n){or===null?or=[n]:or.push(n)}function $f(n,r,l,d){var p=r.interleaved;return p===null?(l.next=l,mc(r)):(l.next=p.next,p.next=l),r.interleaved=l,gn(n,d)}function gn(n,r){n.lanes|=r;var l=n.alternate;for(l!==null&&(l.lanes|=r),l=n,n=n.return;n!==null;)n.childLanes|=r,l=n.alternate,l!==null&&(l.childLanes|=r),l=n,n=n.return;return l.tag===3?l.stateNode:null}var An=!1;function gc(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Hf(n,r){n=n.updateQueue,r.updateQueue===n&&(r.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function vn(n,r){return{eventTime:n,lane:r,tag:0,payload:null,callback:null,next:null}}function In(n,r,l){var d=n.updateQueue;if(d===null)return null;if(d=d.shared,(nt&2)!==0){var p=d.pending;return p===null?r.next=r:(r.next=p.next,p.next=r),d.pending=r,gn(n,l)}return p=d.interleaved,p===null?(r.next=r,mc(d)):(r.next=p.next,p.next=r),d.interleaved=r,gn(n,l)}function aa(n,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194240)!==0)){var d=r.lanes;d&=n.pendingLanes,l|=d,r.lanes=l,jl(n,l)}}function Wf(n,r){var l=n.updateQueue,d=n.alternate;if(d!==null&&(d=d.updateQueue,l===d)){var p=null,g=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};g===null?p=g=E:g=g.next=E,l=l.next}while(l!==null);g===null?p=g=r:g=g.next=r}else p=g=r;l={baseState:d.baseState,firstBaseUpdate:p,lastBaseUpdate:g,shared:d.shared,effects:d.effects},n.updateQueue=l;return}n=l.lastBaseUpdate,n===null?l.firstBaseUpdate=r:n.next=r,l.lastBaseUpdate=r}function la(n,r,l,d){var p=n.updateQueue;An=!1;var g=p.firstBaseUpdate,E=p.lastBaseUpdate,O=p.shared.pending;if(O!==null){p.shared.pending=null;var q=O,ce=q.next;q.next=null,E===null?g=ce:E.next=ce,E=q;var _e=n.alternate;_e!==null&&(_e=_e.updateQueue,O=_e.lastBaseUpdate,O!==E&&(O===null?_e.firstBaseUpdate=ce:O.next=ce,_e.lastBaseUpdate=q))}if(g!==null){var Se=p.baseState;E=0,_e=ce=q=null,O=g;do{var ve=O.lane,Pe=O.eventTime;if((d&ve)===ve){_e!==null&&(_e=_e.next={eventTime:Pe,lane:0,tag:O.tag,payload:O.payload,callback:O.callback,next:null});e:{var De=n,Le=O;switch(ve=r,Pe=l,Le.tag){case 1:if(De=Le.payload,typeof De=="function"){Se=De.call(Pe,Se,ve);break e}Se=De;break e;case 3:De.flags=De.flags&-65537|128;case 0:if(De=Le.payload,ve=typeof De=="function"?De.call(Pe,Se,ve):De,ve==null)break e;Se=z({},Se,ve);break e;case 2:An=!0}}O.callback!==null&&O.lane!==0&&(n.flags|=64,ve=p.effects,ve===null?p.effects=[O]:ve.push(O))}else Pe={eventTime:Pe,lane:ve,tag:O.tag,payload:O.payload,callback:O.callback,next:null},_e===null?(ce=_e=Pe,q=Se):_e=_e.next=Pe,E|=ve;if(O=O.next,O===null){if(O=p.shared.pending,O===null)break;ve=O,O=ve.next,ve.next=null,p.lastBaseUpdate=ve,p.shared.pending=null}}while(!0);if(_e===null&&(q=Se),p.baseState=q,p.firstBaseUpdate=ce,p.lastBaseUpdate=_e,r=p.shared.interleaved,r!==null){p=r;do E|=p.lane,p=p.next;while(p!==r)}else g===null&&(p.shared.lanes=0);cr|=E,n.lanes=E,n.memoizedState=Se}}function Uf(n,r,l){if(n=r.effects,r.effects=null,n!==null)for(r=0;r<n.length;r++){var d=n[r],p=d.callback;if(p!==null){if(d.callback=null,d=l,typeof p!="function")throw Error(i(191,p));p.call(d)}}}var $s={},Zi=Ln($s),Hs=Ln($s),Ws=Ln($s);function ar(n){if(n===$s)throw Error(i(174));return n}function vc(n,r){switch(dt(Ws,r),dt(Hs,n),dt(Zi,$s),n=r.nodeType,n){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Me(null,"");break;default:n=n===8?r.parentNode:r,r=n.namespaceURI||null,n=n.tagName,r=Me(r,n)}pt(Zi),dt(Zi,r)}function qr(){pt(Zi),pt(Hs),pt(Ws)}function Kf(n){ar(Ws.current);var r=ar(Zi.current),l=Me(r,n.type);r!==l&&(dt(Hs,n),dt(Zi,l))}function _c(n){Hs.current===n&&(pt(Zi),pt(Hs))}var yt=Ln(0);function ca(n){for(var r=n;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===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var yc=[];function Sc(){for(var n=0;n<yc.length;n++)yc[n]._workInProgressVersionPrimary=null;yc.length=0}var ua=T.ReactCurrentDispatcher,wc=T.ReactCurrentBatchConfig,lr=0,St=null,Tt=null,zt=null,da=!1,Us=!1,Ks=0,tw=0;function ii(){throw Error(i(321))}function bc(n,r){if(r===null)return!1;for(var l=0;l<r.length&&l<n.length;l++)if(!Ui(n[l],r[l]))return!1;return!0}function kc(n,r,l,d,p,g){if(lr=g,St=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,ua.current=n===null||n.memoizedState===null?sw:ow,n=l(d,p),Us){g=0;do{if(Us=!1,Ks=0,25<=g)throw Error(i(301));g+=1,zt=Tt=null,r.updateQueue=null,ua.current=aw,n=l(d,p)}while(Us)}if(ua.current=pa,r=Tt!==null&&Tt.next!==null,lr=0,zt=Tt=St=null,da=!1,r)throw Error(i(300));return n}function xc(){var n=Ks!==0;return Ks=0,n}function en(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return zt===null?St.memoizedState=zt=n:zt=zt.next=n,zt}function Ai(){if(Tt===null){var n=St.alternate;n=n!==null?n.memoizedState:null}else n=Tt.next;var r=zt===null?St.memoizedState:zt.next;if(r!==null)zt=r,Tt=n;else{if(n===null)throw Error(i(310));Tt=n,n={memoizedState:Tt.memoizedState,baseState:Tt.baseState,baseQueue:Tt.baseQueue,queue:Tt.queue,next:null},zt===null?St.memoizedState=zt=n:zt=zt.next=n}return zt}function qs(n,r){return typeof r=="function"?r(n):r}function Cc(n){var r=Ai(),l=r.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=n;var d=Tt,p=d.baseQueue,g=l.pending;if(g!==null){if(p!==null){var E=p.next;p.next=g.next,g.next=E}d.baseQueue=p=g,l.pending=null}if(p!==null){g=p.next,d=d.baseState;var O=E=null,q=null,ce=g;do{var _e=ce.lane;if((lr&_e)===_e)q!==null&&(q=q.next={lane:0,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null}),d=ce.hasEagerState?ce.eagerState:n(d,ce.action);else{var Se={lane:_e,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null};q===null?(O=q=Se,E=d):q=q.next=Se,St.lanes|=_e,cr|=_e}ce=ce.next}while(ce!==null&&ce!==g);q===null?E=d:q.next=O,Ui(d,r.memoizedState)||(mi=!0),r.memoizedState=d,r.baseState=E,r.baseQueue=q,l.lastRenderedState=d}if(n=l.interleaved,n!==null){p=n;do g=p.lane,St.lanes|=g,cr|=g,p=p.next;while(p!==n)}else p===null&&(l.lanes=0);return[r.memoizedState,l.dispatch]}function Ec(n){var r=Ai(),l=r.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=n;var d=l.dispatch,p=l.pending,g=r.memoizedState;if(p!==null){l.pending=null;var E=p=p.next;do g=n(g,E.action),E=E.next;while(E!==p);Ui(g,r.memoizedState)||(mi=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),l.lastRenderedState=g}return[g,d]}function qf(){}function Vf(n,r){var l=St,d=Ai(),p=r(),g=!Ui(d.memoizedState,p);if(g&&(d.memoizedState=p,mi=!0),d=d.queue,Nc(Gf.bind(null,l,d,n),[n]),d.getSnapshot!==r||g||zt!==null&&zt.memoizedState.tag&1){if(l.flags|=2048,Vs(9,Xf.bind(null,l,d,p,r),void 0,null),Ft===null)throw Error(i(349));(lr&30)!==0||Yf(l,r,p)}return p}function Yf(n,r,l){n.flags|=16384,n={getSnapshot:r,value:l},r=St.updateQueue,r===null?(r={lastEffect:null,stores:null},St.updateQueue=r,r.stores=[n]):(l=r.stores,l===null?r.stores=[n]:l.push(n))}function Xf(n,r,l,d){r.value=l,r.getSnapshot=d,Qf(r)&&Jf(n)}function Gf(n,r,l){return l(function(){Qf(r)&&Jf(n)})}function Qf(n){var r=n.getSnapshot;n=n.value;try{var l=r();return!Ui(n,l)}catch{return!0}}function Jf(n){var r=gn(n,1);r!==null&&Xi(r,n,1,-1)}function Zf(n){var r=en();return typeof n=="function"&&(n=n()),r.memoizedState=r.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:qs,lastRenderedState:n},r.queue=n,n=n.dispatch=rw.bind(null,St,n),[r.memoizedState,n]}function Vs(n,r,l,d){return n={tag:n,create:r,destroy:l,deps:d,next:null},r=St.updateQueue,r===null?(r={lastEffect:null,stores:null},St.updateQueue=r,r.lastEffect=n.next=n):(l=r.lastEffect,l===null?r.lastEffect=n.next=n:(d=l.next,l.next=n,n.next=d,r.lastEffect=n)),n}function ep(){return Ai().memoizedState}function ha(n,r,l,d){var p=en();St.flags|=n,p.memoizedState=Vs(1|r,l,void 0,d===void 0?null:d)}function fa(n,r,l,d){var p=Ai();d=d===void 0?null:d;var g=void 0;if(Tt!==null){var E=Tt.memoizedState;if(g=E.destroy,d!==null&&bc(d,E.deps)){p.memoizedState=Vs(r,l,g,d);return}}St.flags|=n,p.memoizedState=Vs(1|r,l,g,d)}function tp(n,r){return ha(8390656,8,n,r)}function Nc(n,r){return fa(2048,8,n,r)}function ip(n,r){return fa(4,2,n,r)}function np(n,r){return fa(4,4,n,r)}function rp(n,r){if(typeof r=="function")return n=n(),r(n),function(){r(null)};if(r!=null)return n=n(),r.current=n,function(){r.current=null}}function sp(n,r,l){return l=l!=null?l.concat([n]):null,fa(4,4,rp.bind(null,r,n),l)}function Rc(){}function op(n,r){var l=Ai();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&bc(r,d[1])?d[0]:(l.memoizedState=[n,r],n)}function ap(n,r){var l=Ai();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&bc(r,d[1])?d[0]:(n=n(),l.memoizedState=[n,r],n)}function lp(n,r,l){return(lr&21)===0?(n.baseState&&(n.baseState=!1,mi=!0),n.memoizedState=l):(Ui(l,r)||(l=Bh(),St.lanes|=l,cr|=l,n.baseState=!0),r)}function iw(n,r){var l=at;at=l!==0&&4>l?l:4,n(!0);var d=wc.transition;wc.transition={};try{n(!1),r()}finally{at=l,wc.transition=d}}function cp(){return Ai().memoizedState}function nw(n,r,l){var d=Fn(n);if(l={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null},up(n))dp(r,l);else if(l=$f(n,r,l,d),l!==null){var p=li();Xi(l,n,d,p),hp(l,r,d)}}function rw(n,r,l){var d=Fn(n),p={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null};if(up(n))dp(r,p);else{var g=n.alternate;if(n.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var E=r.lastRenderedState,O=g(E,l);if(p.hasEagerState=!0,p.eagerState=O,Ui(O,E)){var q=r.interleaved;q===null?(p.next=p,mc(r)):(p.next=q.next,q.next=p),r.interleaved=p;return}}catch{}finally{}l=$f(n,r,p,d),l!==null&&(p=li(),Xi(l,n,d,p),hp(l,r,d))}}function up(n){var r=n.alternate;return n===St||r!==null&&r===St}function dp(n,r){Us=da=!0;var l=n.pending;l===null?r.next=r:(r.next=l.next,l.next=r),n.pending=r}function hp(n,r,l){if((l&4194240)!==0){var d=r.lanes;d&=n.pendingLanes,l|=d,r.lanes=l,jl(n,l)}}var pa={readContext:Ti,useCallback:ii,useContext:ii,useEffect:ii,useImperativeHandle:ii,useInsertionEffect:ii,useLayoutEffect:ii,useMemo:ii,useReducer:ii,useRef:ii,useState:ii,useDebugValue:ii,useDeferredValue:ii,useTransition:ii,useMutableSource:ii,useSyncExternalStore:ii,useId:ii,unstable_isNewReconciler:!1},sw={readContext:Ti,useCallback:function(n,r){return en().memoizedState=[n,r===void 0?null:r],n},useContext:Ti,useEffect:tp,useImperativeHandle:function(n,r,l){return l=l!=null?l.concat([n]):null,ha(4194308,4,rp.bind(null,r,n),l)},useLayoutEffect:function(n,r){return ha(4194308,4,n,r)},useInsertionEffect:function(n,r){return ha(4,2,n,r)},useMemo:function(n,r){var l=en();return r=r===void 0?null:r,n=n(),l.memoizedState=[n,r],n},useReducer:function(n,r,l){var d=en();return r=l!==void 0?l(r):r,d.memoizedState=d.baseState=r,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:r},d.queue=n,n=n.dispatch=nw.bind(null,St,n),[d.memoizedState,n]},useRef:function(n){var r=en();return n={current:n},r.memoizedState=n},useState:Zf,useDebugValue:Rc,useDeferredValue:function(n){return en().memoizedState=n},useTransition:function(){var n=Zf(!1),r=n[0];return n=iw.bind(null,n[1]),en().memoizedState=n,[r,n]},useMutableSource:function(){},useSyncExternalStore:function(n,r,l){var d=St,p=en();if(gt){if(l===void 0)throw Error(i(407));l=l()}else{if(l=r(),Ft===null)throw Error(i(349));(lr&30)!==0||Yf(d,r,l)}p.memoizedState=l;var g={value:l,getSnapshot:r};return p.queue=g,tp(Gf.bind(null,d,g,n),[n]),d.flags|=2048,Vs(9,Xf.bind(null,d,g,l,r),void 0,null),l},useId:function(){var n=en(),r=Ft.identifierPrefix;if(gt){var l=mn,d=pn;l=(d&~(1<<32-Wi(d)-1)).toString(32)+l,r=":"+r+"R"+l,l=Ks++,0<l&&(r+="H"+l.toString(32)),r+=":"}else l=tw++,r=":"+r+"r"+l.toString(32)+":";return n.memoizedState=r},unstable_isNewReconciler:!1},ow={readContext:Ti,useCallback:op,useContext:Ti,useEffect:Nc,useImperativeHandle:sp,useInsertionEffect:ip,useLayoutEffect:np,useMemo:ap,useReducer:Cc,useRef:ep,useState:function(){return Cc(qs)},useDebugValue:Rc,useDeferredValue:function(n){var r=Ai();return lp(r,Tt.memoizedState,n)},useTransition:function(){var n=Cc(qs)[0],r=Ai().memoizedState;return[n,r]},useMutableSource:qf,useSyncExternalStore:Vf,useId:cp,unstable_isNewReconciler:!1},aw={readContext:Ti,useCallback:op,useContext:Ti,useEffect:Nc,useImperativeHandle:sp,useInsertionEffect:ip,useLayoutEffect:np,useMemo:ap,useReducer:Ec,useRef:ep,useState:function(){return Ec(qs)},useDebugValue:Rc,useDeferredValue:function(n){var r=Ai();return Tt===null?r.memoizedState=n:lp(r,Tt.memoizedState,n)},useTransition:function(){var n=Ec(qs)[0],r=Ai().memoizedState;return[n,r]},useMutableSource:qf,useSyncExternalStore:Vf,useId:cp,unstable_isNewReconciler:!1};function qi(n,r){if(n&&n.defaultProps){r=z({},r),n=n.defaultProps;for(var l in n)r[l]===void 0&&(r[l]=n[l]);return r}return r}function Pc(n,r,l,d){r=n.memoizedState,l=l(d,r),l=l==null?r:z({},r,l),n.memoizedState=l,n.lanes===0&&(n.updateQueue.baseState=l)}var ma={isMounted:function(n){return(n=n._reactInternals)?tr(n)===n:!1},enqueueSetState:function(n,r,l){n=n._reactInternals;var d=li(),p=Fn(n),g=vn(d,p);g.payload=r,l!=null&&(g.callback=l),r=In(n,g,p),r!==null&&(Xi(r,n,p,d),aa(r,n,p))},enqueueReplaceState:function(n,r,l){n=n._reactInternals;var d=li(),p=Fn(n),g=vn(d,p);g.tag=1,g.payload=r,l!=null&&(g.callback=l),r=In(n,g,p),r!==null&&(Xi(r,n,p,d),aa(r,n,p))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var l=li(),d=Fn(n),p=vn(l,d);p.tag=2,r!=null&&(p.callback=r),r=In(n,p,d),r!==null&&(Xi(r,n,d,l),aa(r,n,d))}};function fp(n,r,l,d,p,g,E){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(d,g,E):r.prototype&&r.prototype.isPureReactComponent?!Ms(l,d)||!Ms(p,g):!0}function pp(n,r,l){var d=!1,p=Mn,g=r.contextType;return typeof g=="object"&&g!==null?g=Ti(g):(p=pi(r)?nr:ti.current,d=r.contextTypes,g=(d=d!=null)?zr(n,p):Mn),r=new r(l,g),n.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=ma,n.stateNode=r,r._reactInternals=n,d&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=p,n.__reactInternalMemoizedMaskedChildContext=g),r}function mp(n,r,l,d){n=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,d),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,d),r.state!==n&&ma.enqueueReplaceState(r,r.state,null)}function jc(n,r,l,d){var p=n.stateNode;p.props=l,p.state=n.memoizedState,p.refs={},gc(n);var g=r.contextType;typeof g=="object"&&g!==null?p.context=Ti(g):(g=pi(r)?nr:ti.current,p.context=zr(n,g)),p.state=n.memoizedState,g=r.getDerivedStateFromProps,typeof g=="function"&&(Pc(n,r,g,l),p.state=n.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof p.getSnapshotBeforeUpdate=="function"||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(r=p.state,typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount(),r!==p.state&&ma.enqueueReplaceState(p,p.state,null),la(n,l,p,d),p.state=n.memoizedState),typeof p.componentDidMount=="function"&&(n.flags|=4194308)}function Vr(n,r){try{var l="",d=r;do l+=de(d),d=d.return;while(d);var p=l}catch(g){p=`
39
- Error generating stack: `+g.message+`
40
- `+g.stack}return{value:n,source:r,stack:p,digest:null}}function Dc(n,r,l){return{value:n,source:null,stack:l??null,digest:r??null}}function Lc(n,r){try{console.error(r.value)}catch(l){setTimeout(function(){throw l})}}var lw=typeof WeakMap=="function"?WeakMap:Map;function gp(n,r,l){l=vn(-1,l),l.tag=3,l.payload={element:null};var d=r.value;return l.callback=function(){ba||(ba=!0,Vc=d),Lc(n,r)},l}function vp(n,r,l){l=vn(-1,l),l.tag=3;var d=n.type.getDerivedStateFromError;if(typeof d=="function"){var p=r.value;l.payload=function(){return d(p)},l.callback=function(){Lc(n,r)}}var g=n.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(l.callback=function(){Lc(n,r),typeof d!="function"&&(On===null?On=new Set([this]):On.add(this));var E=r.stack;this.componentDidCatch(r.value,{componentStack:E!==null?E:""})}),l}function _p(n,r,l){var d=n.pingCache;if(d===null){d=n.pingCache=new lw;var p=new Set;d.set(r,p)}else p=d.get(r),p===void 0&&(p=new Set,d.set(r,p));p.has(l)||(p.add(l),n=bw.bind(null,n,r,l),r.then(n,n))}function yp(n){do{var r;if((r=n.tag===13)&&(r=n.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return n;n=n.return}while(n!==null);return null}function Sp(n,r,l,d,p){return(n.mode&1)===0?(n===r?n.flags|=65536:(n.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(r=vn(-1,1),r.tag=2,In(l,r,1))),l.lanes|=1),n):(n.flags|=65536,n.lanes=p,n)}var cw=T.ReactCurrentOwner,mi=!1;function ai(n,r,l,d){r.child=n===null?Ff(r,null,l,d):Wr(r,n.child,l,d)}function wp(n,r,l,d,p){l=l.render;var g=r.ref;return Kr(r,p),d=kc(n,r,l,d,g,p),l=xc(),n!==null&&!mi?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~p,_n(n,r,p)):(gt&&l&&oc(r),r.flags|=1,ai(n,r,d,p),r.child)}function bp(n,r,l,d,p){if(n===null){var g=l.type;return typeof g=="function"&&!eu(g)&&g.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(r.tag=15,r.type=g,kp(n,r,g,d,p)):(n=Ra(l.type,null,d,r,r.mode,p),n.ref=r.ref,n.return=r,r.child=n)}if(g=n.child,(n.lanes&p)===0){var E=g.memoizedProps;if(l=l.compare,l=l!==null?l:Ms,l(E,d)&&n.ref===r.ref)return _n(n,r,p)}return r.flags|=1,n=Hn(g,d),n.ref=r.ref,n.return=r,r.child=n}function kp(n,r,l,d,p){if(n!==null){var g=n.memoizedProps;if(Ms(g,d)&&n.ref===r.ref)if(mi=!1,r.pendingProps=d=g,(n.lanes&p)!==0)(n.flags&131072)!==0&&(mi=!0);else return r.lanes=n.lanes,_n(n,r,p)}return Mc(n,r,l,d,p)}function xp(n,r,l){var d=r.pendingProps,p=d.children,g=n!==null?n.memoizedState:null;if(d.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},dt(Xr,Ci),Ci|=l;else{if((l&1073741824)===0)return n=g!==null?g.baseLanes|l:l,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:n,cachePool:null,transitions:null},r.updateQueue=null,dt(Xr,Ci),Ci|=n,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},d=g!==null?g.baseLanes:l,dt(Xr,Ci),Ci|=d}else g!==null?(d=g.baseLanes|l,r.memoizedState=null):d=l,dt(Xr,Ci),Ci|=d;return ai(n,r,p,l),r.child}function Cp(n,r){var l=r.ref;(n===null&&l!==null||n!==null&&n.ref!==l)&&(r.flags|=512,r.flags|=2097152)}function Mc(n,r,l,d,p){var g=pi(l)?nr:ti.current;return g=zr(r,g),Kr(r,p),l=kc(n,r,l,d,g,p),d=xc(),n!==null&&!mi?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~p,_n(n,r,p)):(gt&&d&&oc(r),r.flags|=1,ai(n,r,l,p),r.child)}function Ep(n,r,l,d,p){if(pi(l)){var g=!0;Zo(r)}else g=!1;if(Kr(r,p),r.stateNode===null)va(n,r),pp(r,l,d),jc(r,l,d,p),d=!0;else if(n===null){var E=r.stateNode,O=r.memoizedProps;E.props=O;var q=E.context,ce=l.contextType;typeof ce=="object"&&ce!==null?ce=Ti(ce):(ce=pi(l)?nr:ti.current,ce=zr(r,ce));var _e=l.getDerivedStateFromProps,Se=typeof _e=="function"||typeof E.getSnapshotBeforeUpdate=="function";Se||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(O!==d||q!==ce)&&mp(r,E,d,ce),An=!1;var ve=r.memoizedState;E.state=ve,la(r,d,E,p),q=r.memoizedState,O!==d||ve!==q||fi.current||An?(typeof _e=="function"&&(Pc(r,l,_e,d),q=r.memoizedState),(O=An||fp(r,l,O,d,ve,q,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=q),E.props=d,E.state=q,E.context=ce,d=O):(typeof E.componentDidMount=="function"&&(r.flags|=4194308),d=!1)}else{E=r.stateNode,Hf(n,r),O=r.memoizedProps,ce=r.type===r.elementType?O:qi(r.type,O),E.props=ce,Se=r.pendingProps,ve=E.context,q=l.contextType,typeof q=="object"&&q!==null?q=Ti(q):(q=pi(l)?nr:ti.current,q=zr(r,q));var Pe=l.getDerivedStateFromProps;(_e=typeof Pe=="function"||typeof E.getSnapshotBeforeUpdate=="function")||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(O!==Se||ve!==q)&&mp(r,E,d,q),An=!1,ve=r.memoizedState,E.state=ve,la(r,d,E,p);var De=r.memoizedState;O!==Se||ve!==De||fi.current||An?(typeof Pe=="function"&&(Pc(r,l,Pe,d),De=r.memoizedState),(ce=An||fp(r,l,ce,d,ve,De,q)||!1)?(_e||typeof E.UNSAFE_componentWillUpdate!="function"&&typeof E.componentWillUpdate!="function"||(typeof E.componentWillUpdate=="function"&&E.componentWillUpdate(d,De,q),typeof E.UNSAFE_componentWillUpdate=="function"&&E.UNSAFE_componentWillUpdate(d,De,q)),typeof E.componentDidUpdate=="function"&&(r.flags|=4),typeof E.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof E.componentDidUpdate!="function"||O===n.memoizedProps&&ve===n.memoizedState||(r.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||O===n.memoizedProps&&ve===n.memoizedState||(r.flags|=1024),r.memoizedProps=d,r.memoizedState=De),E.props=d,E.state=De,E.context=q,d=ce):(typeof E.componentDidUpdate!="function"||O===n.memoizedProps&&ve===n.memoizedState||(r.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||O===n.memoizedProps&&ve===n.memoizedState||(r.flags|=1024),d=!1)}return Tc(n,r,l,d,g,p)}function Tc(n,r,l,d,p,g){Cp(n,r);var E=(r.flags&128)!==0;if(!d&&!E)return p&&Df(r,l,!1),_n(n,r,g);d=r.stateNode,cw.current=r;var O=E&&typeof l.getDerivedStateFromError!="function"?null:d.render();return r.flags|=1,n!==null&&E?(r.child=Wr(r,n.child,null,g),r.child=Wr(r,null,O,g)):ai(n,r,O,g),r.memoizedState=d.state,p&&Df(r,l,!0),r.child}function Np(n){var r=n.stateNode;r.pendingContext?Pf(n,r.pendingContext,r.pendingContext!==r.context):r.context&&Pf(n,r.context,!1),vc(n,r.containerInfo)}function Rp(n,r,l,d,p){return Hr(),uc(p),r.flags|=256,ai(n,r,l,d),r.child}var Ac={dehydrated:null,treeContext:null,retryLane:0};function Ic(n){return{baseLanes:n,cachePool:null,transitions:null}}function Pp(n,r,l){var d=r.pendingProps,p=yt.current,g=!1,E=(r.flags&128)!==0,O;if((O=E)||(O=n!==null&&n.memoizedState===null?!1:(p&2)!==0),O?(g=!0,r.flags&=-129):(n===null||n.memoizedState!==null)&&(p|=1),dt(yt,p&1),n===null)return cc(r),n=r.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((r.mode&1)===0?r.lanes=1:n.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(E=d.children,n=d.fallback,g?(d=r.mode,g=r.child,E={mode:"hidden",children:E},(d&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=E):g=Pa(E,d,0,null),n=fr(n,d,l,null),g.return=r,n.return=r,g.sibling=n,r.child=g,r.child.memoizedState=Ic(l),r.memoizedState=Ac,n):Bc(r,E));if(p=n.memoizedState,p!==null&&(O=p.dehydrated,O!==null))return uw(n,r,E,d,O,p,l);if(g){g=d.fallback,E=r.mode,p=n.child,O=p.sibling;var q={mode:"hidden",children:d.children};return(E&1)===0&&r.child!==p?(d=r.child,d.childLanes=0,d.pendingProps=q,r.deletions=null):(d=Hn(p,q),d.subtreeFlags=p.subtreeFlags&14680064),O!==null?g=Hn(O,g):(g=fr(g,E,l,null),g.flags|=2),g.return=r,d.return=r,d.sibling=g,r.child=d,d=g,g=r.child,E=n.child.memoizedState,E=E===null?Ic(l):{baseLanes:E.baseLanes|l,cachePool:null,transitions:E.transitions},g.memoizedState=E,g.childLanes=n.childLanes&~l,r.memoizedState=Ac,d}return g=n.child,n=g.sibling,d=Hn(g,{mode:"visible",children:d.children}),(r.mode&1)===0&&(d.lanes=l),d.return=r,d.sibling=null,n!==null&&(l=r.deletions,l===null?(r.deletions=[n],r.flags|=16):l.push(n)),r.child=d,r.memoizedState=null,d}function Bc(n,r){return r=Pa({mode:"visible",children:r},n.mode,0,null),r.return=n,n.child=r}function ga(n,r,l,d){return d!==null&&uc(d),Wr(r,n.child,null,l),n=Bc(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function uw(n,r,l,d,p,g,E){if(l)return r.flags&256?(r.flags&=-257,d=Dc(Error(i(422))),ga(n,r,E,d)):r.memoizedState!==null?(r.child=n.child,r.flags|=128,null):(g=d.fallback,p=r.mode,d=Pa({mode:"visible",children:d.children},p,0,null),g=fr(g,p,E,null),g.flags|=2,d.return=r,g.return=r,d.sibling=g,r.child=d,(r.mode&1)!==0&&Wr(r,n.child,null,E),r.child.memoizedState=Ic(E),r.memoizedState=Ac,g);if((r.mode&1)===0)return ga(n,r,E,null);if(p.data==="$!"){if(d=p.nextSibling&&p.nextSibling.dataset,d)var O=d.dgst;return d=O,g=Error(i(419)),d=Dc(g,d,void 0),ga(n,r,E,d)}if(O=(E&n.childLanes)!==0,mi||O){if(d=Ft,d!==null){switch(E&-E){case 4:p=2;break;case 16:p=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:p=32;break;case 536870912:p=268435456;break;default:p=0}p=(p&(d.suspendedLanes|E))!==0?0:p,p!==0&&p!==g.retryLane&&(g.retryLane=p,gn(n,p),Xi(d,n,p,-1))}return Zc(),d=Dc(Error(i(421))),ga(n,r,E,d)}return p.data==="$?"?(r.flags|=128,r.child=n.child,r=kw.bind(null,n),p._reactRetry=r,null):(n=g.treeContext,xi=Dn(p.nextSibling),ki=r,gt=!0,Ki=null,n!==null&&(Li[Mi++]=pn,Li[Mi++]=mn,Li[Mi++]=rr,pn=n.id,mn=n.overflow,rr=r),r=Bc(r,d.children),r.flags|=4096,r)}function jp(n,r,l){n.lanes|=r;var d=n.alternate;d!==null&&(d.lanes|=r),pc(n.return,r,l)}function Oc(n,r,l,d,p){var g=n.memoizedState;g===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:d,tail:l,tailMode:p}:(g.isBackwards=r,g.rendering=null,g.renderingStartTime=0,g.last=d,g.tail=l,g.tailMode=p)}function Dp(n,r,l){var d=r.pendingProps,p=d.revealOrder,g=d.tail;if(ai(n,r,d.children,l),d=yt.current,(d&2)!==0)d=d&1|2,r.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&jp(n,l,r);else if(n.tag===19)jp(n,l,r);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break e;for(;n.sibling===null;){if(n.return===null||n.return===r)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}d&=1}if(dt(yt,d),(r.mode&1)===0)r.memoizedState=null;else switch(p){case"forwards":for(l=r.child,p=null;l!==null;)n=l.alternate,n!==null&&ca(n)===null&&(p=l),l=l.sibling;l=p,l===null?(p=r.child,r.child=null):(p=l.sibling,l.sibling=null),Oc(r,!1,p,l,g);break;case"backwards":for(l=null,p=r.child,r.child=null;p!==null;){if(n=p.alternate,n!==null&&ca(n)===null){r.child=p;break}n=p.sibling,p.sibling=l,l=p,p=n}Oc(r,!0,l,null,g);break;case"together":Oc(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function va(n,r){(r.mode&1)===0&&n!==null&&(n.alternate=null,r.alternate=null,r.flags|=2)}function _n(n,r,l){if(n!==null&&(r.dependencies=n.dependencies),cr|=r.lanes,(l&r.childLanes)===0)return null;if(n!==null&&r.child!==n.child)throw Error(i(153));if(r.child!==null){for(n=r.child,l=Hn(n,n.pendingProps),r.child=l,l.return=r;n.sibling!==null;)n=n.sibling,l=l.sibling=Hn(n,n.pendingProps),l.return=r;l.sibling=null}return r.child}function dw(n,r,l){switch(r.tag){case 3:Np(r),Hr();break;case 5:Kf(r);break;case 1:pi(r.type)&&Zo(r);break;case 4:vc(r,r.stateNode.containerInfo);break;case 10:var d=r.type._context,p=r.memoizedProps.value;dt(sa,d._currentValue),d._currentValue=p;break;case 13:if(d=r.memoizedState,d!==null)return d.dehydrated!==null?(dt(yt,yt.current&1),r.flags|=128,null):(l&r.child.childLanes)!==0?Pp(n,r,l):(dt(yt,yt.current&1),n=_n(n,r,l),n!==null?n.sibling:null);dt(yt,yt.current&1);break;case 19:if(d=(l&r.childLanes)!==0,(n.flags&128)!==0){if(d)return Dp(n,r,l);r.flags|=128}if(p=r.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),dt(yt,yt.current),d)break;return null;case 22:case 23:return r.lanes=0,xp(n,r,l)}return _n(n,r,l)}var Lp,zc,Mp,Tp;Lp=function(n,r){for(var l=r.child;l!==null;){if(l.tag===5||l.tag===6)n.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}},zc=function(){},Mp=function(n,r,l,d){var p=n.memoizedProps;if(p!==d){n=r.stateNode,ar(Zi.current);var g=null;switch(l){case"input":p=ot(n,p),d=ot(n,d),g=[];break;case"select":p=z({},p,{value:void 0}),d=z({},d,{value:void 0}),g=[];break;case"textarea":p=ke(n,p),d=ke(n,d),g=[];break;default:typeof p.onClick!="function"&&typeof d.onClick=="function"&&(n.onclick=Go)}Ce(l,d);var E;l=null;for(ce in p)if(!d.hasOwnProperty(ce)&&p.hasOwnProperty(ce)&&p[ce]!=null)if(ce==="style"){var O=p[ce];for(E in O)O.hasOwnProperty(E)&&(l||(l={}),l[E]="")}else ce!=="dangerouslySetInnerHTML"&&ce!=="children"&&ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&ce!=="autoFocus"&&(o.hasOwnProperty(ce)?g||(g=[]):(g=g||[]).push(ce,null));for(ce in d){var q=d[ce];if(O=p!=null?p[ce]:void 0,d.hasOwnProperty(ce)&&q!==O&&(q!=null||O!=null))if(ce==="style")if(O){for(E in O)!O.hasOwnProperty(E)||q&&q.hasOwnProperty(E)||(l||(l={}),l[E]="");for(E in q)q.hasOwnProperty(E)&&O[E]!==q[E]&&(l||(l={}),l[E]=q[E])}else l||(g||(g=[]),g.push(ce,l)),l=q;else ce==="dangerouslySetInnerHTML"?(q=q?q.__html:void 0,O=O?O.__html:void 0,q!=null&&O!==q&&(g=g||[]).push(ce,q)):ce==="children"?typeof q!="string"&&typeof q!="number"||(g=g||[]).push(ce,""+q):ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&(o.hasOwnProperty(ce)?(q!=null&&ce==="onScroll"&&ft("scroll",n),g||O===q||(g=[])):(g=g||[]).push(ce,q))}l&&(g=g||[]).push("style",l);var ce=g;(r.updateQueue=ce)&&(r.flags|=4)}},Tp=function(n,r,l,d){l!==d&&(r.flags|=4)};function Ys(n,r){if(!gt)switch(n.tailMode){case"hidden":r=n.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?n.tail=null:l.sibling=null;break;case"collapsed":l=n.tail;for(var d=null;l!==null;)l.alternate!==null&&(d=l),l=l.sibling;d===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:d.sibling=null}}function ni(n){var r=n.alternate!==null&&n.alternate.child===n.child,l=0,d=0;if(r)for(var p=n.child;p!==null;)l|=p.lanes|p.childLanes,d|=p.subtreeFlags&14680064,d|=p.flags&14680064,p.return=n,p=p.sibling;else for(p=n.child;p!==null;)l|=p.lanes|p.childLanes,d|=p.subtreeFlags,d|=p.flags,p.return=n,p=p.sibling;return n.subtreeFlags|=d,n.childLanes=l,r}function hw(n,r,l){var d=r.pendingProps;switch(ac(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ni(r),null;case 1:return pi(r.type)&&Jo(),ni(r),null;case 3:return d=r.stateNode,qr(),pt(fi),pt(ti),Sc(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(n===null||n.child===null)&&(na(r)?r.flags|=4:n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Ki!==null&&(Gc(Ki),Ki=null))),zc(n,r),ni(r),null;case 5:_c(r);var p=ar(Ws.current);if(l=r.type,n!==null&&r.stateNode!=null)Mp(n,r,l,d,p),n.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!d){if(r.stateNode===null)throw Error(i(166));return ni(r),null}if(n=ar(Zi.current),na(r)){d=r.stateNode,l=r.type;var g=r.memoizedProps;switch(d[Ji]=r,d[Os]=g,n=(r.mode&1)!==0,l){case"dialog":ft("cancel",d),ft("close",d);break;case"iframe":case"object":case"embed":ft("load",d);break;case"video":case"audio":for(p=0;p<As.length;p++)ft(As[p],d);break;case"source":ft("error",d);break;case"img":case"image":case"link":ft("error",d),ft("load",d);break;case"details":ft("toggle",d);break;case"input":Xe(d,g),ft("invalid",d);break;case"select":d._wrapperState={wasMultiple:!!g.multiple},ft("invalid",d);break;case"textarea":$e(d,g),ft("invalid",d)}Ce(l,g),p=null;for(var E in g)if(g.hasOwnProperty(E)){var O=g[E];E==="children"?typeof O=="string"?d.textContent!==O&&(g.suppressHydrationWarning!==!0&&Xo(d.textContent,O,n),p=["children",O]):typeof O=="number"&&d.textContent!==""+O&&(g.suppressHydrationWarning!==!0&&Xo(d.textContent,O,n),p=["children",""+O]):o.hasOwnProperty(E)&&O!=null&&E==="onScroll"&&ft("scroll",d)}switch(l){case"input":tt(d),ht(d,g,!0);break;case"textarea":tt(d),pe(d);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(d.onclick=Go)}d=p,r.updateQueue=d,d!==null&&(r.flags|=4)}else{E=p.nodeType===9?p:p.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=Oe(l)),n==="http://www.w3.org/1999/xhtml"?l==="script"?(n=E.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof d.is=="string"?n=E.createElement(l,{is:d.is}):(n=E.createElement(l),l==="select"&&(E=n,d.multiple?E.multiple=!0:d.size&&(E.size=d.size))):n=E.createElementNS(n,l),n[Ji]=r,n[Os]=d,Lp(n,r,!1,!1),r.stateNode=n;e:{switch(E=He(l,d),l){case"dialog":ft("cancel",n),ft("close",n),p=d;break;case"iframe":case"object":case"embed":ft("load",n),p=d;break;case"video":case"audio":for(p=0;p<As.length;p++)ft(As[p],n);p=d;break;case"source":ft("error",n),p=d;break;case"img":case"image":case"link":ft("error",n),ft("load",n),p=d;break;case"details":ft("toggle",n),p=d;break;case"input":Xe(n,d),p=ot(n,d),ft("invalid",n);break;case"option":p=d;break;case"select":n._wrapperState={wasMultiple:!!d.multiple},p=z({},d,{value:void 0}),ft("invalid",n);break;case"textarea":$e(n,d),p=ke(n,d),ft("invalid",n);break;default:p=d}Ce(l,p),O=p;for(g in O)if(O.hasOwnProperty(g)){var q=O[g];g==="style"?Te(n,q):g==="dangerouslySetInnerHTML"?(q=q?q.__html:void 0,q!=null&&re(n,q)):g==="children"?typeof q=="string"?(l!=="textarea"||q!=="")&&F(n,q):typeof q=="number"&&F(n,""+q):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(o.hasOwnProperty(g)?q!=null&&g==="onScroll"&&ft("scroll",n):q!=null&&D(n,g,q,E))}switch(l){case"input":tt(n),ht(n,d,!1);break;case"textarea":tt(n),pe(n);break;case"option":d.value!=null&&n.setAttribute("value",""+Z(d.value));break;case"select":n.multiple=!!d.multiple,g=d.value,g!=null?le(n,!!d.multiple,g,!1):d.defaultValue!=null&&le(n,!!d.multiple,d.defaultValue,!0);break;default:typeof p.onClick=="function"&&(n.onclick=Go)}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 ni(r),null;case 6:if(n&&r.stateNode!=null)Tp(n,r,n.memoizedProps,d);else{if(typeof d!="string"&&r.stateNode===null)throw Error(i(166));if(l=ar(Ws.current),ar(Zi.current),na(r)){if(d=r.stateNode,l=r.memoizedProps,d[Ji]=r,(g=d.nodeValue!==l)&&(n=ki,n!==null))switch(n.tag){case 3:Xo(d.nodeValue,l,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&Xo(d.nodeValue,l,(n.mode&1)!==0)}g&&(r.flags|=4)}else d=(l.nodeType===9?l:l.ownerDocument).createTextNode(d),d[Ji]=r,r.stateNode=d}return ni(r),null;case 13:if(pt(yt),d=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(gt&&xi!==null&&(r.mode&1)!==0&&(r.flags&128)===0)Bf(),Hr(),r.flags|=98560,g=!1;else if(g=na(r),d!==null&&d.dehydrated!==null){if(n===null){if(!g)throw Error(i(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(i(317));g[Ji]=r}else Hr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ni(r),g=!1}else Ki!==null&&(Gc(Ki),Ki=null),g=!0;if(!g)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=l,r):(d=d!==null,d!==(n!==null&&n.memoizedState!==null)&&d&&(r.child.flags|=8192,(r.mode&1)!==0&&(n===null||(yt.current&1)!==0?At===0&&(At=3):Zc())),r.updateQueue!==null&&(r.flags|=4),ni(r),null);case 4:return qr(),zc(n,r),n===null&&Is(r.stateNode.containerInfo),ni(r),null;case 10:return fc(r.type._context),ni(r),null;case 17:return pi(r.type)&&Jo(),ni(r),null;case 19:if(pt(yt),g=r.memoizedState,g===null)return ni(r),null;if(d=(r.flags&128)!==0,E=g.rendering,E===null)if(d)Ys(g,!1);else{if(At!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(E=ca(n),E!==null){for(r.flags|=128,Ys(g,!1),d=E.updateQueue,d!==null&&(r.updateQueue=d,r.flags|=4),r.subtreeFlags=0,d=l,l=r.child;l!==null;)g=l,n=d,g.flags&=14680066,E=g.alternate,E===null?(g.childLanes=0,g.lanes=n,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=E.childLanes,g.lanes=E.lanes,g.child=E.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=E.memoizedProps,g.memoizedState=E.memoizedState,g.updateQueue=E.updateQueue,g.type=E.type,n=E.dependencies,g.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),l=l.sibling;return dt(yt,yt.current&1|2),r.child}n=n.sibling}g.tail!==null&&Rt()>Gr&&(r.flags|=128,d=!0,Ys(g,!1),r.lanes=4194304)}else{if(!d)if(n=ca(E),n!==null){if(r.flags|=128,d=!0,l=n.updateQueue,l!==null&&(r.updateQueue=l,r.flags|=4),Ys(g,!0),g.tail===null&&g.tailMode==="hidden"&&!E.alternate&&!gt)return ni(r),null}else 2*Rt()-g.renderingStartTime>Gr&&l!==1073741824&&(r.flags|=128,d=!0,Ys(g,!1),r.lanes=4194304);g.isBackwards?(E.sibling=r.child,r.child=E):(l=g.last,l!==null?l.sibling=E:r.child=E,g.last=E)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=Rt(),r.sibling=null,l=yt.current,dt(yt,d?l&1|2:l&1),r):(ni(r),null);case 22:case 23:return Jc(),d=r.memoizedState!==null,n!==null&&n.memoizedState!==null!==d&&(r.flags|=8192),d&&(r.mode&1)!==0?(Ci&1073741824)!==0&&(ni(r),r.subtreeFlags&6&&(r.flags|=8192)):ni(r),null;case 24:return null;case 25:return null}throw Error(i(156,r.tag))}function fw(n,r){switch(ac(r),r.tag){case 1:return pi(r.type)&&Jo(),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return qr(),pt(fi),pt(ti),Sc(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 5:return _c(r),null;case 13:if(pt(yt),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(i(340));Hr()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return pt(yt),null;case 4:return qr(),null;case 10:return fc(r.type._context),null;case 22:case 23:return Jc(),null;case 24:return null;default:return null}}var _a=!1,ri=!1,pw=typeof WeakSet=="function"?WeakSet:Set,je=null;function Yr(n,r){var l=n.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(d){xt(n,r,d)}else l.current=null}function Fc(n,r,l){try{l()}catch(d){xt(n,r,d)}}var Ap=!1;function mw(n,r){if(Jl=Oo,n=ff(),Ul(n)){if("selectionStart"in n)var l={start:n.selectionStart,end:n.selectionEnd};else e:{l=(l=n.ownerDocument)&&l.defaultView||window;var d=l.getSelection&&l.getSelection();if(d&&d.rangeCount!==0){l=d.anchorNode;var p=d.anchorOffset,g=d.focusNode;d=d.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var E=0,O=-1,q=-1,ce=0,_e=0,Se=n,ve=null;t:for(;;){for(var Pe;Se!==l||p!==0&&Se.nodeType!==3||(O=E+p),Se!==g||d!==0&&Se.nodeType!==3||(q=E+d),Se.nodeType===3&&(E+=Se.nodeValue.length),(Pe=Se.firstChild)!==null;)ve=Se,Se=Pe;for(;;){if(Se===n)break t;if(ve===l&&++ce===p&&(O=E),ve===g&&++_e===d&&(q=E),(Pe=Se.nextSibling)!==null)break;Se=ve,ve=Se.parentNode}Se=Pe}l=O===-1||q===-1?null:{start:O,end:q}}else l=null}l=l||{start:0,end:0}}else l=null;for(Zl={focusedElem:n,selectionRange:l},Oo=!1,je=r;je!==null;)if(r=je,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,je=n;else for(;je!==null;){r=je;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 Le=De.memoizedProps,Pt=De.memoizedState,ne=r.stateNode,Q=ne.getSnapshotBeforeUpdate(r.elementType===r.type?Le:qi(r.type,Le),Pt);ne.__reactInternalSnapshotBeforeUpdate=Q}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(i(163))}}catch(be){xt(r,r.return,be)}if(n=r.sibling,n!==null){n.return=r.return,je=n;break}je=r.return}return De=Ap,Ap=!1,De}function Xs(n,r,l){var d=r.updateQueue;if(d=d!==null?d.lastEffect:null,d!==null){var p=d=d.next;do{if((p.tag&n)===n){var g=p.destroy;p.destroy=void 0,g!==void 0&&Fc(r,l,g)}p=p.next}while(p!==d)}}function ya(n,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&n)===n){var d=l.create;l.destroy=d()}l=l.next}while(l!==r)}}function $c(n){var r=n.ref;if(r!==null){var l=n.stateNode;switch(n.tag){case 5:n=l;break;default:n=l}typeof r=="function"?r(n):r.current=n}}function Ip(n){var r=n.alternate;r!==null&&(n.alternate=null,Ip(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&(delete r[Ji],delete r[Os],delete r[nc],delete r[QS],delete r[JS])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function Bp(n){return n.tag===5||n.tag===3||n.tag===4}function Op(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Bp(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function Hc(n,r,l){var d=n.tag;if(d===5||d===6)n=n.stateNode,r?l.nodeType===8?l.parentNode.insertBefore(n,r):l.insertBefore(n,r):(l.nodeType===8?(r=l.parentNode,r.insertBefore(n,l)):(r=l,r.appendChild(n)),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=Go));else if(d!==4&&(n=n.child,n!==null))for(Hc(n,r,l),n=n.sibling;n!==null;)Hc(n,r,l),n=n.sibling}function Wc(n,r,l){var d=n.tag;if(d===5||d===6)n=n.stateNode,r?l.insertBefore(n,r):l.appendChild(n);else if(d!==4&&(n=n.child,n!==null))for(Wc(n,r,l),n=n.sibling;n!==null;)Wc(n,r,l),n=n.sibling}var Xt=null,Vi=!1;function Bn(n,r,l){for(l=l.child;l!==null;)zp(n,r,l),l=l.sibling}function zp(n,r,l){if(Qi&&typeof Qi.onCommitFiberUnmount=="function")try{Qi.onCommitFiberUnmount(Lo,l)}catch{}switch(l.tag){case 5:ri||Yr(l,r);case 6:var d=Xt,p=Vi;Xt=null,Bn(n,r,l),Xt=d,Vi=p,Xt!==null&&(Vi?(n=Xt,l=l.stateNode,n.nodeType===8?n.parentNode.removeChild(l):n.removeChild(l)):Xt.removeChild(l.stateNode));break;case 18:Xt!==null&&(Vi?(n=Xt,l=l.stateNode,n.nodeType===8?ic(n.parentNode,l):n.nodeType===1&&ic(n,l),Ns(n)):ic(Xt,l.stateNode));break;case 4:d=Xt,p=Vi,Xt=l.stateNode.containerInfo,Vi=!0,Bn(n,r,l),Xt=d,Vi=p;break;case 0:case 11:case 14:case 15:if(!ri&&(d=l.updateQueue,d!==null&&(d=d.lastEffect,d!==null))){p=d=d.next;do{var g=p,E=g.destroy;g=g.tag,E!==void 0&&((g&2)!==0||(g&4)!==0)&&Fc(l,r,E),p=p.next}while(p!==d)}Bn(n,r,l);break;case 1:if(!ri&&(Yr(l,r),d=l.stateNode,typeof d.componentWillUnmount=="function"))try{d.props=l.memoizedProps,d.state=l.memoizedState,d.componentWillUnmount()}catch(O){xt(l,r,O)}Bn(n,r,l);break;case 21:Bn(n,r,l);break;case 22:l.mode&1?(ri=(d=ri)||l.memoizedState!==null,Bn(n,r,l),ri=d):Bn(n,r,l);break;default:Bn(n,r,l)}}function Fp(n){var r=n.updateQueue;if(r!==null){n.updateQueue=null;var l=n.stateNode;l===null&&(l=n.stateNode=new pw),r.forEach(function(d){var p=xw.bind(null,n,d);l.has(d)||(l.add(d),d.then(p,p))})}}function Yi(n,r){var l=r.deletions;if(l!==null)for(var d=0;d<l.length;d++){var p=l[d];try{var g=n,E=r,O=E;e:for(;O!==null;){switch(O.tag){case 5:Xt=O.stateNode,Vi=!1;break e;case 3:Xt=O.stateNode.containerInfo,Vi=!0;break e;case 4:Xt=O.stateNode.containerInfo,Vi=!0;break e}O=O.return}if(Xt===null)throw Error(i(160));zp(g,E,p),Xt=null,Vi=!1;var q=p.alternate;q!==null&&(q.return=null),p.return=null}catch(ce){xt(p,r,ce)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)$p(r,n),r=r.sibling}function $p(n,r){var l=n.alternate,d=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Yi(r,n),tn(n),d&4){try{Xs(3,n,n.return),ya(3,n)}catch(Le){xt(n,n.return,Le)}try{Xs(5,n,n.return)}catch(Le){xt(n,n.return,Le)}}break;case 1:Yi(r,n),tn(n),d&512&&l!==null&&Yr(l,l.return);break;case 5:if(Yi(r,n),tn(n),d&512&&l!==null&&Yr(l,l.return),n.flags&32){var p=n.stateNode;try{F(p,"")}catch(Le){xt(n,n.return,Le)}}if(d&4&&(p=n.stateNode,p!=null)){var g=n.memoizedProps,E=l!==null?l.memoizedProps:g,O=n.type,q=n.updateQueue;if(n.updateQueue=null,q!==null)try{O==="input"&&g.type==="radio"&&g.name!=null&&_t(p,g),He(O,E);var ce=He(O,g);for(E=0;E<q.length;E+=2){var _e=q[E],Se=q[E+1];_e==="style"?Te(p,Se):_e==="dangerouslySetInnerHTML"?re(p,Se):_e==="children"?F(p,Se):D(p,_e,Se,ce)}switch(O){case"input":ut(p,g);break;case"textarea":We(p,g);break;case"select":var ve=p._wrapperState.wasMultiple;p._wrapperState.wasMultiple=!!g.multiple;var Pe=g.value;Pe!=null?le(p,!!g.multiple,Pe,!1):ve!==!!g.multiple&&(g.defaultValue!=null?le(p,!!g.multiple,g.defaultValue,!0):le(p,!!g.multiple,g.multiple?[]:"",!1))}p[Os]=g}catch(Le){xt(n,n.return,Le)}}break;case 6:if(Yi(r,n),tn(n),d&4){if(n.stateNode===null)throw Error(i(162));p=n.stateNode,g=n.memoizedProps;try{p.nodeValue=g}catch(Le){xt(n,n.return,Le)}}break;case 3:if(Yi(r,n),tn(n),d&4&&l!==null&&l.memoizedState.isDehydrated)try{Ns(r.containerInfo)}catch(Le){xt(n,n.return,Le)}break;case 4:Yi(r,n),tn(n);break;case 13:Yi(r,n),tn(n),p=n.child,p.flags&8192&&(g=p.memoizedState!==null,p.stateNode.isHidden=g,!g||p.alternate!==null&&p.alternate.memoizedState!==null||(qc=Rt())),d&4&&Fp(n);break;case 22:if(_e=l!==null&&l.memoizedState!==null,n.mode&1?(ri=(ce=ri)||_e,Yi(r,n),ri=ce):Yi(r,n),tn(n),d&8192){if(ce=n.memoizedState!==null,(n.stateNode.isHidden=ce)&&!_e&&(n.mode&1)!==0)for(je=n,_e=n.child;_e!==null;){for(Se=je=_e;je!==null;){switch(ve=je,Pe=ve.child,ve.tag){case 0:case 11:case 14:case 15:Xs(4,ve,ve.return);break;case 1:Yr(ve,ve.return);var De=ve.stateNode;if(typeof De.componentWillUnmount=="function"){d=ve,l=ve.return;try{r=d,De.props=r.memoizedProps,De.state=r.memoizedState,De.componentWillUnmount()}catch(Le){xt(d,l,Le)}}break;case 5:Yr(ve,ve.return);break;case 22:if(ve.memoizedState!==null){Up(Se);continue}}Pe!==null?(Pe.return=ve,je=Pe):Up(Se)}_e=_e.sibling}e:for(_e=null,Se=n;;){if(Se.tag===5){if(_e===null){_e=Se;try{p=Se.stateNode,ce?(g=p.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(O=Se.stateNode,q=Se.memoizedProps.style,E=q!=null&&q.hasOwnProperty("display")?q.display:null,O.style.display=me("display",E))}catch(Le){xt(n,n.return,Le)}}}else if(Se.tag===6){if(_e===null)try{Se.stateNode.nodeValue=ce?"":Se.memoizedProps}catch(Le){xt(n,n.return,Le)}}else if((Se.tag!==22&&Se.tag!==23||Se.memoizedState===null||Se===n)&&Se.child!==null){Se.child.return=Se,Se=Se.child;continue}if(Se===n)break e;for(;Se.sibling===null;){if(Se.return===null||Se.return===n)break e;_e===Se&&(_e=null),Se=Se.return}_e===Se&&(_e=null),Se.sibling.return=Se.return,Se=Se.sibling}}break;case 19:Yi(r,n),tn(n),d&4&&Fp(n);break;case 21:break;default:Yi(r,n),tn(n)}}function tn(n){var r=n.flags;if(r&2){try{e:{for(var l=n.return;l!==null;){if(Bp(l)){var d=l;break e}l=l.return}throw Error(i(160))}switch(d.tag){case 5:var p=d.stateNode;d.flags&32&&(F(p,""),d.flags&=-33);var g=Op(n);Wc(n,g,p);break;case 3:case 4:var E=d.stateNode.containerInfo,O=Op(n);Hc(n,O,E);break;default:throw Error(i(161))}}catch(q){xt(n,n.return,q)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function gw(n,r,l){je=n,Hp(n)}function Hp(n,r,l){for(var d=(n.mode&1)!==0;je!==null;){var p=je,g=p.child;if(p.tag===22&&d){var E=p.memoizedState!==null||_a;if(!E){var O=p.alternate,q=O!==null&&O.memoizedState!==null||ri;O=_a;var ce=ri;if(_a=E,(ri=q)&&!ce)for(je=p;je!==null;)E=je,q=E.child,E.tag===22&&E.memoizedState!==null?Kp(p):q!==null?(q.return=E,je=q):Kp(p);for(;g!==null;)je=g,Hp(g),g=g.sibling;je=p,_a=O,ri=ce}Wp(n)}else(p.subtreeFlags&8772)!==0&&g!==null?(g.return=p,je=g):Wp(n)}}function Wp(n){for(;je!==null;){var r=je;if((r.flags&8772)!==0){var l=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:ri||ya(5,r);break;case 1:var d=r.stateNode;if(r.flags&4&&!ri)if(l===null)d.componentDidMount();else{var p=r.elementType===r.type?l.memoizedProps:qi(r.type,l.memoizedProps);d.componentDidUpdate(p,l.memoizedState,d.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&Uf(r,g,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}Uf(r,E,l)}break;case 5:var O=r.stateNode;if(l===null&&r.flags&4){l=O;var q=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":q.autoFocus&&l.focus();break;case"img":q.src&&(l.src=q.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 _e=ce.memoizedState;if(_e!==null){var Se=_e.dehydrated;Se!==null&&Ns(Se)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(i(163))}ri||r.flags&512&&$c(r)}catch(ve){xt(r,r.return,ve)}}if(r===n){je=null;break}if(l=r.sibling,l!==null){l.return=r.return,je=l;break}je=r.return}}function Up(n){for(;je!==null;){var r=je;if(r===n){je=null;break}var l=r.sibling;if(l!==null){l.return=r.return,je=l;break}je=r.return}}function Kp(n){for(;je!==null;){var r=je;try{switch(r.tag){case 0:case 11:case 15:var l=r.return;try{ya(4,r)}catch(q){xt(r,l,q)}break;case 1:var d=r.stateNode;if(typeof d.componentDidMount=="function"){var p=r.return;try{d.componentDidMount()}catch(q){xt(r,p,q)}}var g=r.return;try{$c(r)}catch(q){xt(r,g,q)}break;case 5:var E=r.return;try{$c(r)}catch(q){xt(r,E,q)}}}catch(q){xt(r,r.return,q)}if(r===n){je=null;break}var O=r.sibling;if(O!==null){O.return=r.return,je=O;break}je=r.return}}var vw=Math.ceil,Sa=T.ReactCurrentDispatcher,Uc=T.ReactCurrentOwner,Ii=T.ReactCurrentBatchConfig,nt=0,Ft=null,Dt=null,Gt=0,Ci=0,Xr=Ln(0),At=0,Gs=null,cr=0,wa=0,Kc=0,Qs=null,gi=null,qc=0,Gr=1/0,yn=null,ba=!1,Vc=null,On=null,ka=!1,zn=null,xa=0,Js=0,Yc=null,Ca=-1,Ea=0;function li(){return(nt&6)!==0?Rt():Ca!==-1?Ca:Ca=Rt()}function Fn(n){return(n.mode&1)===0?1:(nt&2)!==0&&Gt!==0?Gt&-Gt:ew.transition!==null?(Ea===0&&(Ea=Bh()),Ea):(n=at,n!==0||(n=window.event,n=n===void 0?16:qh(n.type)),n)}function Xi(n,r,l,d){if(50<Js)throw Js=0,Yc=null,Error(i(185));bs(n,l,d),((nt&2)===0||n!==Ft)&&(n===Ft&&((nt&2)===0&&(wa|=l),At===4&&$n(n,Gt)),vi(n,d),l===1&&nt===0&&(r.mode&1)===0&&(Gr=Rt()+500,ea&&Tn()))}function vi(n,r){var l=n.callbackNode;eS(n,r);var d=Ao(n,n===Ft?Gt:0);if(d===0)l!==null&&Th(l),n.callbackNode=null,n.callbackPriority=0;else if(r=d&-d,n.callbackPriority!==r){if(l!=null&&Th(l),r===1)n.tag===0?ZS(Vp.bind(null,n)):Lf(Vp.bind(null,n)),XS(function(){(nt&6)===0&&Tn()}),l=null;else{switch(Oh(d)){case 1:l=Nl;break;case 4:l=Ah;break;case 16:l=Do;break;case 536870912:l=Ih;break;default:l=Do}l=tm(l,qp.bind(null,n))}n.callbackPriority=r,n.callbackNode=l}}function qp(n,r){if(Ca=-1,Ea=0,(nt&6)!==0)throw Error(i(327));var l=n.callbackNode;if(Qr()&&n.callbackNode!==l)return null;var d=Ao(n,n===Ft?Gt:0);if(d===0)return null;if((d&30)!==0||(d&n.expiredLanes)!==0||r)r=Na(n,d);else{r=d;var p=nt;nt|=2;var g=Xp();(Ft!==n||Gt!==r)&&(yn=null,Gr=Rt()+500,dr(n,r));do try{Sw();break}catch(O){Yp(n,O)}while(!0);hc(),Sa.current=g,nt=p,Dt!==null?r=0:(Ft=null,Gt=0,r=At)}if(r!==0){if(r===2&&(p=Rl(n),p!==0&&(d=p,r=Xc(n,p))),r===1)throw l=Gs,dr(n,0),$n(n,d),vi(n,Rt()),l;if(r===6)$n(n,d);else{if(p=n.current.alternate,(d&30)===0&&!_w(p)&&(r=Na(n,d),r===2&&(g=Rl(n),g!==0&&(d=g,r=Xc(n,g))),r===1))throw l=Gs,dr(n,0),$n(n,d),vi(n,Rt()),l;switch(n.finishedWork=p,n.finishedLanes=d,r){case 0:case 1:throw Error(i(345));case 2:hr(n,gi,yn);break;case 3:if($n(n,d),(d&130023424)===d&&(r=qc+500-Rt(),10<r)){if(Ao(n,0)!==0)break;if(p=n.suspendedLanes,(p&d)!==d){li(),n.pingedLanes|=n.suspendedLanes&p;break}n.timeoutHandle=tc(hr.bind(null,n,gi,yn),r);break}hr(n,gi,yn);break;case 4:if($n(n,d),(d&4194240)===d)break;for(r=n.eventTimes,p=-1;0<d;){var E=31-Wi(d);g=1<<E,E=r[E],E>p&&(p=E),d&=~g}if(d=p,d=Rt()-d,d=(120>d?120:480>d?480:1080>d?1080:1920>d?1920:3e3>d?3e3:4320>d?4320:1960*vw(d/1960))-d,10<d){n.timeoutHandle=tc(hr.bind(null,n,gi,yn),d);break}hr(n,gi,yn);break;case 5:hr(n,gi,yn);break;default:throw Error(i(329))}}}return vi(n,Rt()),n.callbackNode===l?qp.bind(null,n):null}function Xc(n,r){var l=Qs;return n.current.memoizedState.isDehydrated&&(dr(n,r).flags|=256),n=Na(n,r),n!==2&&(r=gi,gi=l,r!==null&&Gc(r)),n}function Gc(n){gi===null?gi=n:gi.push.apply(gi,n)}function _w(n){for(var r=n;;){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 p=l[d],g=p.getSnapshot;p=p.value;try{if(!Ui(g(),p))return!1}catch{return!1}}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function $n(n,r){for(r&=~Kc,r&=~wa,n.suspendedLanes|=r,n.pingedLanes&=~r,n=n.expirationTimes;0<r;){var l=31-Wi(r),d=1<<l;n[l]=-1,r&=~d}}function Vp(n){if((nt&6)!==0)throw Error(i(327));Qr();var r=Ao(n,0);if((r&1)===0)return vi(n,Rt()),null;var l=Na(n,r);if(n.tag!==0&&l===2){var d=Rl(n);d!==0&&(r=d,l=Xc(n,d))}if(l===1)throw l=Gs,dr(n,0),$n(n,r),vi(n,Rt()),l;if(l===6)throw Error(i(345));return n.finishedWork=n.current.alternate,n.finishedLanes=r,hr(n,gi,yn),vi(n,Rt()),null}function Qc(n,r){var l=nt;nt|=1;try{return n(r)}finally{nt=l,nt===0&&(Gr=Rt()+500,ea&&Tn())}}function ur(n){zn!==null&&zn.tag===0&&(nt&6)===0&&Qr();var r=nt;nt|=1;var l=Ii.transition,d=at;try{if(Ii.transition=null,at=1,n)return n()}finally{at=d,Ii.transition=l,nt=r,(nt&6)===0&&Tn()}}function Jc(){Ci=Xr.current,pt(Xr)}function dr(n,r){n.finishedWork=null,n.finishedLanes=0;var l=n.timeoutHandle;if(l!==-1&&(n.timeoutHandle=-1,YS(l)),Dt!==null)for(l=Dt.return;l!==null;){var d=l;switch(ac(d),d.tag){case 1:d=d.type.childContextTypes,d!=null&&Jo();break;case 3:qr(),pt(fi),pt(ti),Sc();break;case 5:_c(d);break;case 4:qr();break;case 13:pt(yt);break;case 19:pt(yt);break;case 10:fc(d.type._context);break;case 22:case 23:Jc()}l=l.return}if(Ft=n,Dt=n=Hn(n.current,null),Gt=Ci=r,At=0,Gs=null,Kc=wa=cr=0,gi=Qs=null,or!==null){for(r=0;r<or.length;r++)if(l=or[r],d=l.interleaved,d!==null){l.interleaved=null;var p=d.next,g=l.pending;if(g!==null){var E=g.next;g.next=p,d.next=E}l.pending=d}or=null}return n}function Yp(n,r){do{var l=Dt;try{if(hc(),ua.current=pa,da){for(var d=St.memoizedState;d!==null;){var p=d.queue;p!==null&&(p.pending=null),d=d.next}da=!1}if(lr=0,zt=Tt=St=null,Us=!1,Ks=0,Uc.current=null,l===null||l.return===null){At=1,Gs=r,Dt=null;break}e:{var g=n,E=l.return,O=l,q=r;if(r=Gt,O.flags|=32768,q!==null&&typeof q=="object"&&typeof q.then=="function"){var ce=q,_e=O,Se=_e.tag;if((_e.mode&1)===0&&(Se===0||Se===11||Se===15)){var ve=_e.alternate;ve?(_e.updateQueue=ve.updateQueue,_e.memoizedState=ve.memoizedState,_e.lanes=ve.lanes):(_e.updateQueue=null,_e.memoizedState=null)}var Pe=yp(E);if(Pe!==null){Pe.flags&=-257,Sp(Pe,E,O,g,r),Pe.mode&1&&_p(g,ce,r),r=Pe,q=ce;var De=r.updateQueue;if(De===null){var Le=new Set;Le.add(q),r.updateQueue=Le}else De.add(q);break e}else{if((r&1)===0){_p(g,ce,r),Zc();break e}q=Error(i(426))}}else if(gt&&O.mode&1){var Pt=yp(E);if(Pt!==null){(Pt.flags&65536)===0&&(Pt.flags|=256),Sp(Pt,E,O,g,r),uc(Vr(q,O));break e}}g=q=Vr(q,O),At!==4&&(At=2),Qs===null?Qs=[g]:Qs.push(g),g=E;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var ne=gp(g,q,r);Wf(g,ne);break e;case 1:O=q;var Q=g.type,ae=g.stateNode;if((g.flags&128)===0&&(typeof Q.getDerivedStateFromError=="function"||ae!==null&&typeof ae.componentDidCatch=="function"&&(On===null||!On.has(ae)))){g.flags|=65536,r&=-r,g.lanes|=r;var be=vp(g,O,r);Wf(g,be);break e}}g=g.return}while(g!==null)}Qp(l)}catch(Ae){r=Ae,Dt===l&&l!==null&&(Dt=l=l.return);continue}break}while(!0)}function Xp(){var n=Sa.current;return Sa.current=pa,n===null?pa:n}function Zc(){(At===0||At===3||At===2)&&(At=4),Ft===null||(cr&268435455)===0&&(wa&268435455)===0||$n(Ft,Gt)}function Na(n,r){var l=nt;nt|=2;var d=Xp();(Ft!==n||Gt!==r)&&(yn=null,dr(n,r));do try{yw();break}catch(p){Yp(n,p)}while(!0);if(hc(),nt=l,Sa.current=d,Dt!==null)throw Error(i(261));return Ft=null,Gt=0,At}function yw(){for(;Dt!==null;)Gp(Dt)}function Sw(){for(;Dt!==null&&!Ky();)Gp(Dt)}function Gp(n){var r=em(n.alternate,n,Ci);n.memoizedProps=n.pendingProps,r===null?Qp(n):Dt=r,Uc.current=null}function Qp(n){var r=n;do{var l=r.alternate;if(n=r.return,(r.flags&32768)===0){if(l=hw(l,r,Ci),l!==null){Dt=l;return}}else{if(l=fw(l,r),l!==null){l.flags&=32767,Dt=l;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{At=6,Dt=null;return}}if(r=r.sibling,r!==null){Dt=r;return}Dt=r=n}while(r!==null);At===0&&(At=5)}function hr(n,r,l){var d=at,p=Ii.transition;try{Ii.transition=null,at=1,ww(n,r,l,d)}finally{Ii.transition=p,at=d}return null}function ww(n,r,l,d){do Qr();while(zn!==null);if((nt&6)!==0)throw Error(i(327));l=n.finishedWork;var p=n.finishedLanes;if(l===null)return null;if(n.finishedWork=null,n.finishedLanes=0,l===n.current)throw Error(i(177));n.callbackNode=null,n.callbackPriority=0;var g=l.lanes|l.childLanes;if(tS(n,g),n===Ft&&(Dt=Ft=null,Gt=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||ka||(ka=!0,tm(Do,function(){return Qr(),null})),g=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||g){g=Ii.transition,Ii.transition=null;var E=at;at=1;var O=nt;nt|=4,Uc.current=null,mw(n,l),$p(l,n),$S(Zl),Oo=!!Jl,Zl=Jl=null,n.current=l,gw(l),qy(),nt=O,at=E,Ii.transition=g}else n.current=l;if(ka&&(ka=!1,zn=n,xa=p),g=n.pendingLanes,g===0&&(On=null),Xy(l.stateNode),vi(n,Rt()),r!==null)for(d=n.onRecoverableError,l=0;l<r.length;l++)p=r[l],d(p.value,{componentStack:p.stack,digest:p.digest});if(ba)throw ba=!1,n=Vc,Vc=null,n;return(xa&1)!==0&&n.tag!==0&&Qr(),g=n.pendingLanes,(g&1)!==0?n===Yc?Js++:(Js=0,Yc=n):Js=0,Tn(),null}function Qr(){if(zn!==null){var n=Oh(xa),r=Ii.transition,l=at;try{if(Ii.transition=null,at=16>n?16:n,zn===null)var d=!1;else{if(n=zn,zn=null,xa=0,(nt&6)!==0)throw Error(i(331));var p=nt;for(nt|=4,je=n.current;je!==null;){var g=je,E=g.child;if((je.flags&16)!==0){var O=g.deletions;if(O!==null){for(var q=0;q<O.length;q++){var ce=O[q];for(je=ce;je!==null;){var _e=je;switch(_e.tag){case 0:case 11:case 15:Xs(8,_e,g)}var Se=_e.child;if(Se!==null)Se.return=_e,je=Se;else for(;je!==null;){_e=je;var ve=_e.sibling,Pe=_e.return;if(Ip(_e),_e===ce){je=null;break}if(ve!==null){ve.return=Pe,je=ve;break}je=Pe}}}var De=g.alternate;if(De!==null){var Le=De.child;if(Le!==null){De.child=null;do{var Pt=Le.sibling;Le.sibling=null,Le=Pt}while(Le!==null)}}je=g}}if((g.subtreeFlags&2064)!==0&&E!==null)E.return=g,je=E;else e:for(;je!==null;){if(g=je,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:Xs(9,g,g.return)}var ne=g.sibling;if(ne!==null){ne.return=g.return,je=ne;break e}je=g.return}}var Q=n.current;for(je=Q;je!==null;){E=je;var ae=E.child;if((E.subtreeFlags&2064)!==0&&ae!==null)ae.return=E,je=ae;else e:for(E=Q;je!==null;){if(O=je,(O.flags&2048)!==0)try{switch(O.tag){case 0:case 11:case 15:ya(9,O)}}catch(Ae){xt(O,O.return,Ae)}if(O===E){je=null;break e}var be=O.sibling;if(be!==null){be.return=O.return,je=be;break e}je=O.return}}if(nt=p,Tn(),Qi&&typeof Qi.onPostCommitFiberRoot=="function")try{Qi.onPostCommitFiberRoot(Lo,n)}catch{}d=!0}return d}finally{at=l,Ii.transition=r}}return!1}function Jp(n,r,l){r=Vr(l,r),r=gp(n,r,1),n=In(n,r,1),r=li(),n!==null&&(bs(n,1,r),vi(n,r))}function xt(n,r,l){if(n.tag===3)Jp(n,n,l);else for(;r!==null;){if(r.tag===3){Jp(r,n,l);break}else if(r.tag===1){var d=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(On===null||!On.has(d))){n=Vr(l,n),n=vp(r,n,1),r=In(r,n,1),n=li(),r!==null&&(bs(r,1,n),vi(r,n));break}}r=r.return}}function bw(n,r,l){var d=n.pingCache;d!==null&&d.delete(r),r=li(),n.pingedLanes|=n.suspendedLanes&l,Ft===n&&(Gt&l)===l&&(At===4||At===3&&(Gt&130023424)===Gt&&500>Rt()-qc?dr(n,0):Kc|=l),vi(n,r)}function Zp(n,r){r===0&&((n.mode&1)===0?r=1:(r=To,To<<=1,(To&130023424)===0&&(To=4194304)));var l=li();n=gn(n,r),n!==null&&(bs(n,r,l),vi(n,l))}function kw(n){var r=n.memoizedState,l=0;r!==null&&(l=r.retryLane),Zp(n,l)}function xw(n,r){var l=0;switch(n.tag){case 13:var d=n.stateNode,p=n.memoizedState;p!==null&&(l=p.retryLane);break;case 19:d=n.stateNode;break;default:throw Error(i(314))}d!==null&&d.delete(r),Zp(n,l)}var em;em=function(n,r,l){if(n!==null)if(n.memoizedProps!==r.pendingProps||fi.current)mi=!0;else{if((n.lanes&l)===0&&(r.flags&128)===0)return mi=!1,dw(n,r,l);mi=(n.flags&131072)!==0}else mi=!1,gt&&(r.flags&1048576)!==0&&Mf(r,ia,r.index);switch(r.lanes=0,r.tag){case 2:var d=r.type;va(n,r),n=r.pendingProps;var p=zr(r,ti.current);Kr(r,l),p=kc(null,r,d,n,p,l);var g=xc();return r.flags|=1,typeof p=="object"&&p!==null&&typeof p.render=="function"&&p.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,pi(d)?(g=!0,Zo(r)):g=!1,r.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,gc(r),p.updater=ma,r.stateNode=p,p._reactInternals=r,jc(r,d,n,l),r=Tc(null,r,d,!0,g,l)):(r.tag=0,gt&&g&&oc(r),ai(null,r,p,l),r=r.child),r;case 16:d=r.elementType;e:{switch(va(n,r),n=r.pendingProps,p=d._init,d=p(d._payload),r.type=d,p=r.tag=Ew(d),n=qi(d,n),p){case 0:r=Mc(null,r,d,n,l);break e;case 1:r=Ep(null,r,d,n,l);break e;case 11:r=wp(null,r,d,n,l);break e;case 14:r=bp(null,r,d,qi(d.type,n),l);break e}throw Error(i(306,d,""))}return r;case 0:return d=r.type,p=r.pendingProps,p=r.elementType===d?p:qi(d,p),Mc(n,r,d,p,l);case 1:return d=r.type,p=r.pendingProps,p=r.elementType===d?p:qi(d,p),Ep(n,r,d,p,l);case 3:e:{if(Np(r),n===null)throw Error(i(387));d=r.pendingProps,g=r.memoizedState,p=g.element,Hf(n,r),la(r,d,null,l);var E=r.memoizedState;if(d=E.element,g.isDehydrated)if(g={element:d,isDehydrated:!1,cache:E.cache,pendingSuspenseBoundaries:E.pendingSuspenseBoundaries,transitions:E.transitions},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){p=Vr(Error(i(423)),r),r=Rp(n,r,d,l,p);break e}else if(d!==p){p=Vr(Error(i(424)),r),r=Rp(n,r,d,l,p);break e}else for(xi=Dn(r.stateNode.containerInfo.firstChild),ki=r,gt=!0,Ki=null,l=Ff(r,null,d,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Hr(),d===p){r=_n(n,r,l);break e}ai(n,r,d,l)}r=r.child}return r;case 5:return Kf(r),n===null&&cc(r),d=r.type,p=r.pendingProps,g=n!==null?n.memoizedProps:null,E=p.children,ec(d,p)?E=null:g!==null&&ec(d,g)&&(r.flags|=32),Cp(n,r),ai(n,r,E,l),r.child;case 6:return n===null&&cc(r),null;case 13:return Pp(n,r,l);case 4:return vc(r,r.stateNode.containerInfo),d=r.pendingProps,n===null?r.child=Wr(r,null,d,l):ai(n,r,d,l),r.child;case 11:return d=r.type,p=r.pendingProps,p=r.elementType===d?p:qi(d,p),wp(n,r,d,p,l);case 7:return ai(n,r,r.pendingProps,l),r.child;case 8:return ai(n,r,r.pendingProps.children,l),r.child;case 12:return ai(n,r,r.pendingProps.children,l),r.child;case 10:e:{if(d=r.type._context,p=r.pendingProps,g=r.memoizedProps,E=p.value,dt(sa,d._currentValue),d._currentValue=E,g!==null)if(Ui(g.value,E)){if(g.children===p.children&&!fi.current){r=_n(n,r,l);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var O=g.dependencies;if(O!==null){E=g.child;for(var q=O.firstContext;q!==null;){if(q.context===d){if(g.tag===1){q=vn(-1,l&-l),q.tag=2;var ce=g.updateQueue;if(ce!==null){ce=ce.shared;var _e=ce.pending;_e===null?q.next=q:(q.next=_e.next,_e.next=q),ce.pending=q}}g.lanes|=l,q=g.alternate,q!==null&&(q.lanes|=l),pc(g.return,l,r),O.lanes|=l;break}q=q.next}}else if(g.tag===10)E=g.type===r.type?null:g.child;else if(g.tag===18){if(E=g.return,E===null)throw Error(i(341));E.lanes|=l,O=E.alternate,O!==null&&(O.lanes|=l),pc(E,l,r),E=g.sibling}else E=g.child;if(E!==null)E.return=g;else for(E=g;E!==null;){if(E===r){E=null;break}if(g=E.sibling,g!==null){g.return=E.return,E=g;break}E=E.return}g=E}ai(n,r,p.children,l),r=r.child}return r;case 9:return p=r.type,d=r.pendingProps.children,Kr(r,l),p=Ti(p),d=d(p),r.flags|=1,ai(n,r,d,l),r.child;case 14:return d=r.type,p=qi(d,r.pendingProps),p=qi(d.type,p),bp(n,r,d,p,l);case 15:return kp(n,r,r.type,r.pendingProps,l);case 17:return d=r.type,p=r.pendingProps,p=r.elementType===d?p:qi(d,p),va(n,r),r.tag=1,pi(d)?(n=!0,Zo(r)):n=!1,Kr(r,l),pp(r,d,p),jc(r,d,p,l),Tc(null,r,d,!0,n,l);case 19:return Dp(n,r,l);case 22:return xp(n,r,l)}throw Error(i(156,r.tag))};function tm(n,r){return Mh(n,r)}function Cw(n,r,l,d){this.tag=n,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 Bi(n,r,l,d){return new Cw(n,r,l,d)}function eu(n){return n=n.prototype,!(!n||!n.isReactComponent)}function Ew(n){if(typeof n=="function")return eu(n)?1:0;if(n!=null){if(n=n.$$typeof,n===A)return 11;if(n===L)return 14}return 2}function Hn(n,r){var l=n.alternate;return l===null?(l=Bi(n.tag,r,n.key,n.mode),l.elementType=n.elementType,l.type=n.type,l.stateNode=n.stateNode,l.alternate=n,n.alternate=l):(l.pendingProps=r,l.type=n.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=n.flags&14680064,l.childLanes=n.childLanes,l.lanes=n.lanes,l.child=n.child,l.memoizedProps=n.memoizedProps,l.memoizedState=n.memoizedState,l.updateQueue=n.updateQueue,r=n.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=n.sibling,l.index=n.index,l.ref=n.ref,l}function Ra(n,r,l,d,p,g){var E=2;if(d=n,typeof n=="function")eu(n)&&(E=1);else if(typeof n=="string")E=5;else e:switch(n){case W:return fr(l.children,p,g,r);case te:E=8,p|=8;break;case K:return n=Bi(12,l,r,p|2),n.elementType=K,n.lanes=g,n;case N:return n=Bi(13,l,r,p),n.elementType=N,n.lanes=g,n;case j:return n=Bi(19,l,r,p),n.elementType=j,n.lanes=g,n;case U:return Pa(l,p,g,r);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case ie:E=10;break e;case Y:E=9;break e;case A:E=11;break e;case L:E=14;break e;case $:E=16,d=null;break e}throw Error(i(130,n==null?n:typeof n,""))}return r=Bi(E,l,r,p),r.elementType=n,r.type=d,r.lanes=g,r}function fr(n,r,l,d){return n=Bi(7,n,d,r),n.lanes=l,n}function Pa(n,r,l,d){return n=Bi(22,n,d,r),n.elementType=U,n.lanes=l,n.stateNode={isHidden:!1},n}function tu(n,r,l){return n=Bi(6,n,null,r),n.lanes=l,n}function iu(n,r,l){return r=Bi(4,n.children!==null?n.children:[],n.key,r),r.lanes=l,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}function Nw(n,r,l,d,p){this.tag=r,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Pl(0),this.expirationTimes=Pl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pl(0),this.identifierPrefix=d,this.onRecoverableError=p,this.mutableSourceEagerHydrationData=null}function nu(n,r,l,d,p,g,E,O,q){return n=new Nw(n,r,l,O,q),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Bi(3,null,null,r),n.current=g,g.stateNode=n,g.memoizedState={element:d,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},gc(g),n}function Rw(n,r,l){var d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:V,key:d==null?null:""+d,children:n,containerInfo:r,implementation:l}}function im(n){if(!n)return Mn;n=n._reactInternals;e:{if(tr(n)!==n||n.tag!==1)throw Error(i(170));var r=n;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(pi(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(i(171))}if(n.tag===1){var l=n.type;if(pi(l))return jf(n,l,r)}return r}function nm(n,r,l,d,p,g,E,O,q){return n=nu(l,d,!0,n,p,g,E,O,q),n.context=im(null),l=n.current,d=li(),p=Fn(l),g=vn(d,p),g.callback=r??null,In(l,g,p),n.current.lanes=p,bs(n,p,d),vi(n,d),n}function ja(n,r,l,d){var p=r.current,g=li(),E=Fn(p);return l=im(l),r.context===null?r.context=l:r.pendingContext=l,r=vn(g,E),r.payload={element:n},d=d===void 0?null:d,d!==null&&(r.callback=d),n=In(p,r,E),n!==null&&(Xi(n,p,E,g),aa(n,p,E)),E}function Da(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function rm(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<r?l:r}}function ru(n,r){rm(n,r),(n=n.alternate)&&rm(n,r)}function Pw(){return null}var sm=typeof reportError=="function"?reportError:function(n){console.error(n)};function su(n){this._internalRoot=n}La.prototype.render=su.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(i(409));ja(n,r,null,null)},La.prototype.unmount=su.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;ur(function(){ja(null,n,null,null)}),r[hn]=null}};function La(n){this._internalRoot=n}La.prototype.unstable_scheduleHydration=function(n){if(n){var r=$h();n={blockedOn:null,target:n,priority:r};for(var l=0;l<Rn.length&&r!==0&&r<Rn[l].priority;l++);Rn.splice(l,0,n),l===0&&Uh(n)}};function ou(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function Ma(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function om(){}function jw(n,r,l,d,p){if(p){if(typeof d=="function"){var g=d;d=function(){var ce=Da(E);g.call(ce)}}var E=nm(r,d,n,0,null,!1,!1,"",om);return n._reactRootContainer=E,n[hn]=E.current,Is(n.nodeType===8?n.parentNode:n),ur(),E}for(;p=n.lastChild;)n.removeChild(p);if(typeof d=="function"){var O=d;d=function(){var ce=Da(q);O.call(ce)}}var q=nu(n,0,!1,null,null,!1,!1,"",om);return n._reactRootContainer=q,n[hn]=q.current,Is(n.nodeType===8?n.parentNode:n),ur(function(){ja(r,q,l,d)}),q}function Ta(n,r,l,d,p){var g=l._reactRootContainer;if(g){var E=g;if(typeof p=="function"){var O=p;p=function(){var q=Da(E);O.call(q)}}ja(r,E,n,p)}else E=jw(l,r,n,p,d);return Da(E)}zh=function(n){switch(n.tag){case 3:var r=n.stateNode;if(r.current.memoizedState.isDehydrated){var l=ws(r.pendingLanes);l!==0&&(jl(r,l|1),vi(r,Rt()),(nt&6)===0&&(Gr=Rt()+500,Tn()))}break;case 13:ur(function(){var d=gn(n,1);if(d!==null){var p=li();Xi(d,n,1,p)}}),ru(n,1)}},Dl=function(n){if(n.tag===13){var r=gn(n,134217728);if(r!==null){var l=li();Xi(r,n,134217728,l)}ru(n,134217728)}},Fh=function(n){if(n.tag===13){var r=Fn(n),l=gn(n,r);if(l!==null){var d=li();Xi(l,n,r,d)}ru(n,r)}},$h=function(){return at},Hh=function(n,r){var l=at;try{return at=n,r()}finally{at=l}},Di=function(n,r,l){switch(r){case"input":if(ut(n,l),r=l.name,l.type==="radio"&&r!=null){for(l=n;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!==n&&d.form===n.form){var p=Qo(d);if(!p)throw Error(i(90));Ye(d),ut(d,p)}}}break;case"textarea":We(n,l);break;case"select":r=l.value,r!=null&&le(n,!!l.multiple,r,!1)}},Ve=Qc,kt=ur;var Dw={usingClientEntryPoint:!1,Events:[zs,Br,Qo,ue,Ne,Qc]},Zs={findFiberByHostInstance:ir,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Lw={bundleType:Zs.bundleType,version:Zs.version,rendererPackageName:Zs.rendererPackageName,rendererConfig:Zs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=Dh(n),n===null?null:n.stateNode},findFiberByHostInstance:Zs.findFiberByHostInstance||Pw,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 Aa=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Aa.isDisabled&&Aa.supportsFiber)try{Lo=Aa.inject(Lw),Qi=Aa}catch{}}return _i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Dw,_i.createPortal=function(n,r){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!ou(r))throw Error(i(200));return Rw(n,r,null,l)},_i.createRoot=function(n,r){if(!ou(n))throw Error(i(299));var l=!1,d="",p=sm;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onRecoverableError!==void 0&&(p=r.onRecoverableError)),r=nu(n,1,!1,null,null,l,!1,d,p),n[hn]=r.current,Is(n.nodeType===8?n.parentNode:n),new su(r)},_i.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var r=n._reactInternals;if(r===void 0)throw typeof n.render=="function"?Error(i(188)):(n=Object.keys(n).join(","),Error(i(268,n)));return n=Dh(r),n=n===null?null:n.stateNode,n},_i.flushSync=function(n){return ur(n)},_i.hydrate=function(n,r,l){if(!Ma(r))throw Error(i(200));return Ta(null,n,r,!0,l)},_i.hydrateRoot=function(n,r,l){if(!ou(n))throw Error(i(405));var d=l!=null&&l.hydratedSources||null,p=!1,g="",E=sm;if(l!=null&&(l.unstable_strictMode===!0&&(p=!0),l.identifierPrefix!==void 0&&(g=l.identifierPrefix),l.onRecoverableError!==void 0&&(E=l.onRecoverableError)),r=nm(r,null,n,1,l??null,p,!1,g,E),n[hn]=r.current,Is(n),d)for(n=0;n<d.length;n++)l=d[n],p=l._getVersion,p=p(l._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[l,p]:r.mutableSourceEagerHydrationData.push(l,p);return new La(r)},_i.render=function(n,r,l){if(!Ma(r))throw Error(i(200));return Ta(null,n,r,!1,l)},_i.unmountComponentAtNode=function(n){if(!Ma(n))throw Error(i(40));return n._reactRootContainer?(ur(function(){Ta(null,null,n,!1,function(){n._reactRootContainer=null,n[hn]=null})}),!0):!1},_i.unstable_batchedUpdates=Qc,_i.unstable_renderSubtreeIntoContainer=function(n,r,l,d){if(!Ma(l))throw Error(i(200));if(n==null||n._reactInternals===void 0)throw Error(i(38));return Ta(n,r,l,!1,d)},_i.version="18.3.1-next-f1338f8080-20240426",_i}var pm;function $w(){if(pm)return cu.exports;pm=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(),cu.exports=Fw(),cu.exports}var mm;function Hw(){if(mm)return Ia;mm=1;var e=$w();return Ia.createRoot=e.createRoot,Ia.hydrateRoot=e.hydrateRoot,Ia}var Ww=Hw();const Uw=Zd(Ww);function qt(e,t,i={}){return fetch(e,{...i,headers:{...i.headers||{},Authorization:`Bearer ${t}`}})}const Ov=e=>`nc_seen_${e}`;async function Ie(e,t,i={}){const s=await qt(e,t,{method:i.method||"GET",headers:{"content-type":"application/json"},body:i.body?JSON.stringify(i.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 ui=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",Vt=(e,t)=>`${ui(e)}/fleet/${t}`,Er=(e,t)=>Ie(Vt(t,"status"),e),th=(e,t,i)=>Ie(Vt(i,"up"),e,{method:"POST",body:t}),il=(e,t,i)=>Ie(Vt(i,"down"),e,{method:"POST",body:t}),zv=(e,t,i)=>Ie(Vt(i,"boot"),e,{method:"POST",body:t}),uo=(e,t,i)=>Ie(Vt(i,"restart"),e,{method:"POST",body:{cell:t}}),ih=(e,t)=>Ie(Vt(t,"definitions"),e),Kw=(e,t)=>Ie(Vt(t,"credentials/status"),e),gm=(e,t,i,s)=>Ie(Vt(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:i}}),qw=(e,t,i)=>Ie(Vt(i,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),Vw=(e,t,i)=>Ie(Vt(i,"define-engine"),e,{method:"POST",body:{def:t}}),Yw=(e,t,i,s,o)=>Ie(Vt(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:i,envChanges:s}}),Xw=(e,t,i)=>Ie(Vt(i,"remove-engine"),e,{method:"POST",body:{id:t}}),Gw=(e,t,i)=>Ie(Vt(i,"define-cell"),e,{method:"POST",body:{def:t}}),Qw=(e,t,i,s)=>Ie(Vt(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:i}}),Fv=(e,t,i=!1,s)=>Ie(Vt(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:i}}),Jw=(e,t,i)=>Ie(Vt(i,"import-cell"),e,{method:"POST",body:t}),Zw=(e,t,i)=>Ie(Vt(i,"restore-cells"),e,{method:"POST",body:{cells:t}}),e0=(e,t,i,s)=>Ie(Vt(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!i}}),nh=(e,t,i)=>Ie(`${ui(i)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),$v=(e,t,i,s)=>Ie(`${ui(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!i}}),Hv=(e,t,i)=>Ie(`${ui(i)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),Wv=e=>Ie("/api/settings",e),t0=e=>Ie("/api/nodes",e),i0=e=>Ie("/api/peers",e),n0=e=>Ie("/api/topology",e),Uv=(e,t)=>Ie(`${ui(t)}/sessions`,e),rh=(e,t)=>Ie(`${ui(t)}/config`,e),vm=(e,t)=>Ie(`${ui(t)}/topology`,e),Kv=(e,t)=>Ie("/api/settings/config",e,{method:"POST",body:t}),r0=e=>Ie("/api/settings/token/rotate",e,{method:"POST"}),s0=(e,t)=>Ie("/api/settings/nodes/pair",e,{method:"POST",body:t}),_m=(e,t,i=[])=>Ie(`${ui(i)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),qv=(e,t,i)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:i}}),o0=e=>Ie("/api/settings/node-aliases",e),a0=(e,t,i)=>Ie(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{alias:i}}),ym=(e,t)=>Ie(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"DELETE"}),l0=(e,t,i)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"PATCH",body:i}),c0=(e,t)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),sh=(e,t,i)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/${i}`,e,{method:"POST"}),u0=(e,t,i)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:i}}),Sm=(e,t,i,s=[])=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:i,selected:s}}),d0=e=>Ie("/api/settings/service/regenerate",e,{method:"POST"}),h0=e=>Ie("/api/settings/update/check",e,{method:"POST"}),f0=e=>Ie("/api/settings/update/apply",e,{method:"POST"}),vl=(e,t)=>`${ui(e)}/diagnostics/${t}`,p0=(e,t=[])=>Ie(vl(t,"status"),e),m0=(e,{after:t=0,limit:i=200}={},s=[])=>Ie(`${vl(s,"logs")}?after=${encodeURIComponent(t)}&limit=${encodeURIComponent(i)}`,e),wm=(e,t,i,s=[])=>Ie(vl(s,"verbose"),e,{method:"PATCH",body:{enabled:t,durationSeconds:i}}),g0=(e,t=[])=>Ie(vl(t,"logs"),e,{method:"DELETE"}),v0=(e,t=!0)=>Ie(`/api/asks${t?"?open=1":""}`,e),_0=(e,t,i)=>Ie(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:i}}),Ba=(e,t=[])=>Ie(`${ui(t)}/decks`,e),bm=(e,t,i=[])=>Ie(`${ui(i)}/decks`,e,{method:"POST",body:{name:t}}),Oa=(e,t,i,s,o=[])=>Ie(`${ui(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:i,expectedRevision:s}}),y0=(e,t,i,s,o=[])=>Ie(`${ui(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:i,expectedRevision:s}}),S0=(e,t,i,s=[])=>Ie(`${ui(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:i}}),w0={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 it({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:w0[e]||null})}const b0=["all","pinned","active","off","technical"],Vv="nc_sidebar_views_v1",Yv="nc_sidebar_order_v1";function Xv(e){return b0.includes(e)?e:"all"}function k0(e,t=[],i="all"){const s=Xv(i);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 x0(e,t,i=[],s=[]){const o=i.indexOf(e.key),a=i.indexOf(t.key),u=o===-1?Number.MAX_SAFE_INTEGER:o,h=a===-1?Number.MAX_SAFE_INTEGER:a,m=s.indexOf(e.key),f=s.indexOf(t.key),_=m===-1?Number.MAX_SAFE_INTEGER:m,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 C0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Yv));if(!t||typeof t!="object"||Array.isArray(t))return{};const i={};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&&(i[s]=a)}return i}catch{return{}}}function Qn(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function E0(e,t=globalThis.localStorage){try{t.setItem(Yv,JSON.stringify(e))}catch{}return e}function N0(e,t,i,s,o=[]){if(typeof t!="string"||!t||i===s)return e;const a=[...new Set(o.filter(w=>typeof w=="string"&&w))];if(!a.includes(i)||!a.includes(s))return e;const u=Qn(e,t).filter(w=>a.includes(w)),h=[...u,...a.filter(w=>!u.includes(w))],m=h.indexOf(i),f=h.indexOf(s);h.splice(m,1);const _=h.indexOf(s),b=m<f?_+1:_;return h.splice(b,0,i),{...e,[t]:h}}function R0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Vv));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function km(e,t){var i,s;return{open:((i=e==null?void 0:e[t])==null?void 0:i.open)!==!1,filter:Xv((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function P0(e,t=globalThis.localStorage){try{t.setItem(Vv,JSON.stringify(e))}catch{}return e}function xm(e,t=""){const i=String(t||"").trim().toLocaleLowerCase();return i?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(i):!0}function wr(e=[],t=[],i="all",s=[]){return[...e].filter(o=>k0(o,t,i)).sort((o,a)=>x0(o,a,t,s))}const oh=["it","en","es"];function j0(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return oh.includes(t)?t:"en"}catch{return"en"}}const Ya=j0(),Gv="nc_lang",td="nc-lang";function Qv(){return typeof localStorage<"u"?localStorage:null}const za={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","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-diagnostics":"diagnostica","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-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.',"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","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-diagnostics":"diagnostics","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-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.',"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í","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-diagnostics":"diagnóstico","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-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.',"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 id(){const e=Qv(),t=e?e.getItem(Gv):null;return oh.includes(t)?t:Ya}function D0(e){const t=Qv();if(t)try{t.setItem(Gv,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(td))}function v(e){const t=id(),i=za[t]||za[Ya];return Object.prototype.hasOwnProperty.call(i,e)?i[e]:Object.prototype.hasOwnProperty.call(za[Ya],e)?za[Ya][e]:e}function L0(e){return typeof window>"u"?()=>{}:(window.addEventListener(td,e),()=>window.removeEventListener(td,e))}const Jv=oh;function ji(){return[P.useSyncExternalStore(L0,id,id),D0]}function nl({cell:e,token:t,route:i=[],onConfirm:s,onClose:o}){var L,$;ji();const a=!!(e&&e.active),u=Array.isArray(i)?i.join("/"):"",[h,m]=P.useState([]),[f,_]=P.useState(!1);P.useEffect(()=>{let U=!0;return(async()=>{if(t)try{const B=await Er(t,u?u.split("/"):[]);if(!U)return;if(_(B.provider==="builtin"&&(B.capabilities||[]).includes("edit")),B.provider==="builtin"&&(B.capabilities||[]).includes("definitions")){const J=await ih(t,u?u.split("/"):[]);if(!U)return;const z=new Map((B.engines||[]).map(M=>[M.id,M]));m((J.engines||[]).map(M=>{var I,se,ge,de,fe,X,Z;return{id:M.id,label:M.label||M.id,client:((I=M.managed)==null?void 0:I.client)||"",models:[...new Set([...((se=z.get(M.id))==null?void 0:se.models)||[],...((ge=M.managedInfo)==null?void 0:ge.models)||[]])].filter(Boolean),defaultModel:((de=M.managed)==null?void 0:de.model)||((fe=M.managedInfo)==null?void 0:fe.defaultModel)||"",policyDefault:((X=M.managed)==null?void 0:X.permissionPolicy)||((Z=M.managed)!=null&&Z.client&&M.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{U=!1}},[t,u]);const b=(e==null?void 0:e.engine)||((L=h[0])==null?void 0:L.id)||"",w=U=>(e==null?void 0:e.models)&&e.models[U]||"",y=U=>{const B=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[U];if(B==="standard"||B==="unsafe")return B;const J=h.find(z=>z.id===U);return J?J.policyDefault:"standard"},[S,k]=P.useState(b),[C,x]=P.useState((e==null?void 0:e.model)||""),R=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:(($=e==null?void 0:e.permissionPolicies)==null?void 0:$[e==null?void 0:e.engine])||"",[D,T]=P.useState(R),[ee,V]=P.useState((e==null?void 0:e.boot)??!0),[W,te]=P.useState(!1),[K,ie]=P.useState(null);P.useEffect(()=>{h.length&&(k(U=>U||b),x(U=>U||w((e==null?void 0:e.engine)||b)||""),T(U=>U==="standard"||U==="unsafe"?U:y((e==null?void 0:e.engine)||b)))},[h.length]);const Y=P.useMemo(()=>h.find(U=>U.id===S)||null,[h,S]),A=!!(Y&&["claude","codex","codex-vl"].includes(Y.client));function N(U){k(U);const B=h.find(J=>J.id===U);x(w(U)||(B==null?void 0:B.defaultModel)||""),T(y(U))}async function j(U){U.preventDefault(),te(!0),ie(null);try{if(a)await s({action:"down",boot:ee});else{const B=D==="standard"||D==="unsafe"?D:(Y==null?void 0:Y.policyDefault)||"standard";await s({action:"up",...f?{engine:S,model:C||"",...A?{permissionPolicy:B}:(Y==null?void 0:Y.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:ee})}o()}catch(B){ie(String(B&&B.message||B)),te(!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:U=>U.stopPropagation(),onSubmit:j,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:v(a?"state-on":"state-off")})]}),a?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-power-config",children:[c.jsx("span",{children:v("engine")}),c.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&c.jsxs("small",{children:[v("model"),": ",e.model]}),c.jsx("small",{children:v("power-on-hint")})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:ee,onChange:U=>V(U.target.checked)}),v("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:[v("engine"),c.jsx("select",{value:S,onChange:U=>N(U.target.value),children:h.map(U=>c.jsx("option",{value:U.id,children:U.label},U.id))})]}),c.jsxs("label",{className:"nc-field",children:[v("model"),c.jsx("input",{value:C,list:"nc-launch-models",placeholder:v("model-default"),onChange:U=>x(U.target.value)}),c.jsx("datalist",{id:"nc-launch-models",children:((Y==null?void 0:Y.models)||[]).map(U=>c.jsx("option",{value:U},U))})]}),A?c.jsxs("label",{className:"nc-field",children:[v("permissions"),c.jsxs("select",{value:D,onChange:U=>T(U.target.value),children:[c.jsx("option",{value:"standard",children:v("fleet-standard-permissions")}),c.jsx("option",{value:"unsafe",children:v("fleet-unsafe-permissions")})]})]}):c.jsx("small",{className:"nc-note",children:v("fleet-standard-permissions")}),A&&D==="unsafe"&&c.jsx("small",{className:"nc-err",children:v("fleet-unsafe-warning")}),c.jsx("small",{className:"nc-note",children:v("launch-engine-help")})]}):c.jsxs("div",{className:"nc-power-config",children:[c.jsx("span",{children:v("engine")}),c.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&c.jsxs("small",{children:[v("model"),": ",e.model]}),c.jsx("small",{children:v("launch-unavailable-hint")})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:ee,onChange:U=>V(U.target.checked)}),v("boot-persist")]})]}),K&&c.jsx("div",{className:"nc-err",children:K}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:W,children:v("cancel")}),c.jsx("button",{type:"submit",className:"nc-btn primary",disabled:W,children:v(a?"power-off":"save-and-start")})]})]})})}const Cm=/^[a-z0-9-]{1,32}$/;function rl(e,t){const i=Array.isArray(e)?e:[];return i.length?`${i.map(encodeURIComponent).join("/")}:${t}`:String(t)}function M0(e,t,i){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",m=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!h&&!m&&(s[u]=e&&e[u]||i)}return s}function Em(e,t,i){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${i}:${s.tmuxSession||s.cell}`}))}function Nm({nodes:e,topology:t,remote:i,down:s,fleet:o,aliases:a}={}){var f,_,b,w;const u=[],h=new Set,m=new Set;for(const y of Array.isArray(e)?e:[]){if(!y||typeof y.name!="string"||!Cm.test(y.name)||y.direction==="inbound"&&y.shared!==!0)continue;const S=[y.name],k=y.name;h.add(k);const C=((f=y.tunnel)==null?void 0:f.status)||"unknown",x=C==="up",R={name:y.name,label:y.label||y.name,originalLabel:y.label||y.name,alias:null,route:S,direct:!0,instanceId:y.nodeId||null,shared:y.shared===!0,tunnelStatus:C,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:y.health||null,direction:y.direction||"outbound",roles:y.roles||null,rolesKnown:y.rolesKnown===!0};if(y.nodeId&&m.add(y.nodeId),!y.nodeId&&y.paired===!1){u.push({...R,status:"needs-repair",downSince:s&&s[k]||null});continue}if(((_=y.health)==null?void 0:_.auth)==="failed"||C==="degraded"&&((b=y.health)==null?void 0:b.status)==="degraded"){u.push({...R,status:"needs-repair",downSince:s&&s[k]||null});continue}if(C==="passive"||((w=y.health)==null?void 0:w.status)==="passive"){u.push({...R,status:"passive",downSince:null});continue}if(!x){u.push({...R,status:"down",downSince:s&&s[k]||null});continue}const D=i&&(i[k]||i[y.name])||null,T=o&&(o[k]||o[y.name]),ee=!!(D&&!D.error&&Array.isArray(D.sessions)),V=!!(T&&T.available===!0&&Array.isArray(T.cells));if(!ee&&!V){u.push({...R,status:"unreachable"});continue}const W=(ee?D.sessions:[]).filter(ie=>ie&&typeof ie.name=="string"&&ie.name).map(ie=>({...ie,node:k,route:S,key:`${k}:${ie.name}`})),te=Em(T,S,k),K=new Set(te.map(ie=>ie.tmuxSession).filter(Boolean));u.push({...R,status:"up",sessions:W,cells:te,unmanaged:W.filter(ie=>!K.has(ie.name)),fleetAvailable:!!(T&&T.available),capabilities:T&&T.capabilities||[],engines:T&&T.engines||[],fleetProvider:T&&T.provider||null,sessionsAvailable:ee,inventoryPartial:!ee})}for(const y of Array.isArray(t)?t:[]){if(!y||!Array.isArray(y.route)||y.route.length<1||y.route.some(K=>!Cm.test(K)))continue;const S=y.route.join("/");if(h.has(S)||y.instanceId&&m.has(y.instanceId))continue;y.instanceId&&m.add(y.instanceId);const k=y.label||y.route.join(" › "),C=y.instanceId&&a&&typeof a[y.instanceId]=="string"?a[y.instanceId]:null,x={name:y.name,label:C||k,originalLabel:k,alias:C,route:[...y.route],direct:!1,instanceId:y.instanceId||null,shared:!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:y.health||null,lastSeen:y.lastSeen||null};if(y.stale){u.push({...x,status:"offline",downSince:s&&s[S]||y.lastSeen||null});continue}const R=i&&i[S]||null,D=o&&o[S],T=!!(R&&!R.error&&Array.isArray(R.sessions)),ee=!!(D&&D.available===!0&&Array.isArray(D.cells));if(!T&&!ee){u.push({...x,status:"unreachable",downSince:s&&s[S]||null});continue}const V=(T?R.sessions:[]).filter(K=>K&&typeof K.name=="string"&&K.name).map(K=>({...K,node:S,route:y.route,key:`${S}:${K.name}`})),W=Em(D,y.route,S),te=new Set(W.map(K=>K.tmuxSession).filter(Boolean));u.push({...x,status:"up",sessions:V,cells:W,unmanaged:V.filter(K=>!te.has(K.name)),fleetAvailable:!!(D&&D.available),capabilities:D&&D.capabilities||[],engines:D&&D.engines||[],fleetProvider:D&&D.provider||null,lastSeen:y.lastSeen||null,sessionsAvailable:T,inventoryPartial:!T})}return u.sort((y,S)=>y.label.localeCompare(S.label))}const T0=4e3;function ah(e,t=!0,i=0){const[s,o]=P.useState([]),a=P.useRef({});return P.useEffect(()=>{if(!t||!e){o([]);return}let u=!0;async function h(){var x;let f=[],_=[],b={};if(await Promise.all([t0(e).then(R=>{f=Array.isArray(R.nodes)?R.nodes:[]}).catch(()=>{}),n0(e).then(R=>{_=Array.isArray(R.nodes)?R.nodes:[]}).catch(()=>{}),o0(e).then(R=>{b=R&&typeof R.aliasesByInstanceId=="object"?R.aliasesByInstanceId:{}}).catch(()=>{})]),!u)return;const w={},y={},S=new Set(f.map(R=>R.name)),k=[];for(const R of f)((x=R.tunnel)==null?void 0:x.status)==="up"&&(R.nodeId||R.paired!==!1)&&(R.direction!=="inbound"||R.shared===!0)&&k.push([R.name]);for(const R of _)!R.stale&&Array.isArray(R.route)&&!(R.route.length===1&&S.has(R.route[0]))&&k.push(R.route);if(await Promise.all(k.map(async R=>{const D=R.join("/");try{w[D]=await Uv(e,R)}catch{w[D]={error:"unreachable"}}try{y[D]=await Er(e,R)}catch{y[D]={available:!1}}})),!u)return;const C=Nm({nodes:f,topology:_,remote:w,fleet:y,aliases:b,down:a.current});a.current=M0(a.current,C,Math.floor(Date.now()/1e3)),o(Nm({nodes:f,topology:_,remote:w,fleet:y,aliases:b,down:a.current}))}h();const m=setInterval(h,T0);return()=>{u=!1,clearInterval(m)}},[e,t,i]),s}const Rm=52,Pm=14;function Xn({position:e,itemKey:t,label:i,onMove:s,onStep:o,canMove:a=()=>!0,scope:u="roster"}){const h=P.useRef(null),m=P.useRef(0),[f,_]=P.useState(!1),b=()=>{var x,R,D,T;const C=h.current;(R=(x=C==null?void 0:C.over)==null?void 0:x.classList)==null||R.remove("nc-roster-over"),(T=(D=C==null?void 0:C.source)==null?void 0:D.classList)==null||T.remove("nc-roster-dragging"),m.current&&cancelAnimationFrame(m.current),m.current=0},w=(C=!1)=>{const x=h.current;if(!x)return;const R=x.target;b(),h.current=null,_(!1);try{x.handle.releasePointerCapture(x.pointerId)}catch{}C&&R&&R!==t&&a(t,R)&&s(t,R)},y=(C,x)=>{var te,K,ie,Y,A,N,j,L,$;const R=h.current;if(!R)return;R.x=C,R.y=x;const D=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",T=(K=(te=document.elementFromPoint(C,x))==null?void 0:te.closest)==null?void 0:K.call(te,D),ee=u==="node"?(ie=T==null?void 0:T.dataset)==null?void 0:ie.nodeOrderKey:(Y=T==null?void 0:T.dataset)==null?void 0:Y.rosterKey,W=(u==="node"||((A=T==null?void 0:T.dataset)==null?void 0:A.position)===e)&&ee&&ee!==t&&a(t,ee);R.over!==(W?T:null)&&((j=(N=R.over)==null?void 0:N.classList)==null||j.remove("nc-roster-over"),R.over=W?T:null,($=(L=R.over)==null?void 0:L.classList)==null||$.add("nc-roster-over")),R.target=W?ee:null},S=()=>{const C=h.current;if(!C){m.current=0;return}const x=C.container;if(x){const R=x.getBoundingClientRect(),D=C.y<R.top+Rm?-Pm:C.y>R.bottom-Rm?Pm:0;D&&(x.scrollTop+=D,y(C.x,C.y))}m.current=requestAnimationFrame(S)};P.useEffect(()=>{const C=R=>{R.key==="Escape"&&h.current&&(R.preventDefault(),w(!1))},x=()=>w(!1);return window.addEventListener("keydown",C),window.addEventListener("blur",x),()=>{window.removeEventListener("keydown",C),window.removeEventListener("blur",x),b(),h.current=null}},[t,e,u]);const k=C=>{var T;if(C.pointerType==="mouse"&&C.button!==0)return;C.preventDefault(),C.stopPropagation(),C.currentTarget.focus({preventScroll:!0});const x=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",R=C.currentTarget.closest(x),D=C.currentTarget.closest(".nc-side-scroll, .nc-home-scroll");h.current={pointerId:C.pointerId,handle:C.currentTarget,source:R,container:D,target:null,over:null,x:C.clientX,y:C.clientY},(T=R==null?void 0:R.classList)==null||T.add("nc-roster-dragging");try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}_(!0),m.current=requestAnimationFrame(S)};return c.jsx("button",{type:"button",className:`nc-roster-handle${f?" active":""}`,"aria-label":`${v("reorder")} ${i}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:v("reorder-help"),onClick:C=>{C.preventDefault(),C.stopPropagation()},onDragStart:C=>C.preventDefault(),onKeyDown:C=>{C.key!=="ArrowUp"&&C.key!=="ArrowDown"||(C.preventDefault(),C.stopPropagation(),o(C.key==="ArrowUp"?-1:1))},onPointerDown:k,onPointerMove:C=>{!h.current||C.pointerId!==h.current.pointerId||(C.preventDefault(),C.stopPropagation(),y(C.clientX,C.clientY))},onPointerUp:C=>{!h.current||C.pointerId!==h.current.pointerId||(C.preventDefault(),C.stopPropagation(),w(!0))},onPointerCancel:()=>w(!1),onLostPointerCapture:()=>{h.current&&w(!1)},children:"↕"})}const lh="nc_pins";function A0(){try{const e=JSON.parse(localStorage.getItem(lh));return Array.isArray(e)?e:[]}catch{return[]}}function I0(e,t){const i=e.includes(t)?e.filter(s=>s!==t):[...e,t];try{localStorage.setItem(lh,JSON.stringify(i))}catch{}return i}function B0(e,t,i){if(!e.includes(t)||!e.includes(i)||t===i)return e;const s=[...e],o=s.indexOf(t),a=s.indexOf(i);s.splice(o,1);const u=s.indexOf(i);s.splice(o<a?u+1:u,0,t);try{localStorage.setItem(lh,JSON.stringify(s))}catch{}return s}function O0(e,t,i){const s=e.indexOf(t);return[s===-1?1e9:s,-(i||0)]}function z0(e,t){return e[0]-t[0]||e[1]-t[1]}function Zv(){const[e,t]=P.useState(A0),[i,s]=P.useState(R0),[o,a]=P.useState(C0),u=w=>t(y=>I0(y,w)),h=w=>km(i,w),m=(w,y)=>s(S=>{const k={...S,[w]:{...km(S,w),...y}};return P0(k)}),f=(w,y)=>e.includes(w)===e.includes(y);function _(w,y,S,k){const C=e.includes(y),x=e.includes(S);if(C===x){if(C){t(R=>B0(R,y,S));return}a(R=>{var ee;const D=((ee=k.find(V=>V.key===y))==null?void 0:ee.technical)===!0,T=wr(k,e,D?"technical":"all",Qn(R,w)).map(V=>V.key);return E0(N0(R,w,y,S,T))})}}function b(w,y,S,k){var ee;const C=((ee=k.find(V=>V.key===y))==null?void 0:ee.technical)===!0,x=e.includes(y),R=wr(k,e,C?"technical":"all",Qn(o,w)).map(V=>V.key).filter(V=>e.includes(V)===x),D=R.indexOf(y),T=R[D+S];D>=0&&T&&_(w,y,T,k)}return{pins:e,views:i,orders:o,togglePin:u,viewFor:h,updateView:m,canMoveRoster:f,moveRoster:_,stepRoster:b}}const e_="nc_node_order_v1",F0=/^[a-f0-9]{16,64}$/;function yr(e){if(F0.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(i=>typeof i=="string"&&i):[];return t.length?`route:${t.map(encodeURIComponent).join("/")}`:typeof(e==null?void 0:e.name)=="string"&&e.name?`name:${encodeURIComponent(e.name)}`:""}function jm(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(e_));return Array.isArray(t)?[...new Set(t.filter(i=>typeof i=="string"&&i&&i.length<=192))].slice(0,128):[]}catch{return[]}}function $0(e,t=globalThis.localStorage){try{t.setItem(e_,JSON.stringify(e))}catch{}return e}function Dm(e=[],t=[]){const i=new Map(t.map((s,o)=>[s,o]));return e.map((s,o)=>({group:s,index:o})).sort((s,o)=>{const a=i.has(yr(s.group))?i.get(yr(s.group)):Number.MAX_SAFE_INTEGER,u=i.has(yr(o.group))?i.get(yr(o.group)):Number.MAX_SAFE_INTEGER;return a-u||s.index-o.index}).map(({group:s})=>s)}function H0(e,t,i,s=[]){if(!t||!i||t===i)return e;const o=s.map(yr).filter(Boolean);if(!o.includes(t)||!o.includes(i))return e;const a=[...e.filter(f=>o.includes(f)),...o.filter(f=>!e.includes(f))],u=a.indexOf(t),h=a.indexOf(i);a.splice(u,1);const m=a.indexOf(i);return a.splice(u<h?m+1:m,0,t),a}const nd="nexuscrew-node-preferences";function W0(){try{window.dispatchEvent(new Event(nd))}catch{}}function t_(){const[e,t]=P.useState(jm);P.useEffect(()=>{const a=()=>t(jm());return window.addEventListener("storage",a),window.addEventListener(nd,a),()=>{window.removeEventListener("storage",a),window.removeEventListener(nd,a)}},[]);const i=a=>Dm(a,e),s=(a,u,h)=>t(m=>{const f=H0(m,a,u,h);return $0(f),W0(),f});return{order:e,groupsFor:i,moveNode:s,stepNode:(a,u,h)=>{const m=Dm(h,e).map(yr),f=m.indexOf(a),_=m[f+u];f>=0&&_&&s(a,_,h)},nodeKey:yr}}function ls(e,t=Math.floor(Date.now()/1e3)){if(!e)return"";const i=t-e;return i<0||i<60?"ora":i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}g`}function ss(e){return e.status==="passive"?v("node-passive"):e.status==="down"?e.downSince?v("tunnel-down-since").replace("{t}",ls(e.downSince)):v("tunnel-down"):e.status==="unreachable"?v("node-unreachable"):e.status==="offline"?e.lastSeen?v("node-offline-seen").replace("{t}",ls(e.lastSeen)):v("node-offline"):e.status==="needs-repair"?v("node-needs-repair"):""}function i_(e,{passive:t=null}={}){return e?e.status==="passive"?t:e.status==="healthy"?"on":"warn":null}function sl(e){return e&&(e.detail||e.status)||""}function ol(e,t,i=globalThis.localStorage){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const s=Number(i.getItem(Ov(t))||0);return e.outbox.latest>s}function n_(e,t={}){const i=e||{};if(!i.tmux){const s=`${i.engine||""}${i.key?`·${i.key}`:""}`,o=[s,i.model&&i.model!==s?i.model:""].filter(Boolean).join(" · ");return{working:!1,subtitle:String(o||v("cell-off")).trim()}}if(t.working===!0){const s=v("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:v("cell-idle")}:{working:!1,subtitle:String(t.preview||i.preview||v("cell-on")).trim()}}function r_(e,t){return[...new Set([e.engine,e.model,e.key,t.preview,e.preview,t.status].filter(Boolean).map(String))].join(" ")}function s_(e,t,i,s=globalThis.localStorage){return[...(Array.isArray(e)?e:[]).map(o=>{const a=i.get(o.tmuxSession)||{},u=rl([],o.tmuxSession),h=n_(o,a);return{type:"cell",value:o,key:u,label:o.cell,live:!!o.tmux,fresh:ol(a,u,s),activity:a.activity||0,working:h.working,subtitle:h.subtitle,searchText:r_(o,a)}}),...(Array.isArray(t)?t:[]).map(o=>{const a=rl([],o.name);return{type:"session",value:o,key:a,label:o.name,live:!0,technical:o.technical===!0,fresh:ol(o,a,s),activity:o.activity||0,searchText:`${o.preview||""} ${o.cmd||""}`}})]}function rd(e,t=globalThis.localStorage){const i=e||{},s=Array.isArray(i.route)?i.route:[],o=new Map((i.sessions||[]).map(u=>[u.name,u])),a=[...(i.cells||[]).map(u=>{const h=o.get(u.tmuxSession)||{},m=rl(s,u.tmuxSession||u.cell),f=n_(u,h);return{type:"cell",value:u,key:m,label:u.cell,live:!!u.tmux,fresh:ol(h,m,t),activity:h.activity||u.activity||0,working:f.working,subtitle:f.subtitle,searchText:r_(u,h)}}),...(i.unmanaged||[]).map(u=>{const h=rl(s,u.name);return{type:"session",value:u,key:h,label:u.name,live:!0,technical:u.technical===!0,fresh:ol(u,h,t),activity:u.activity||0,searchText:`${u.preview||""} ${u.cmd||""}`}})];return{route:s,rawItems:a}}const ch=9,al=.2,U0=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,cs=/^[a-f0-9]{16,64}$/,sd=e=>U0.test(e)&&new Set(e.split("/")).size===e.split("/").length;function er(e){if(typeof e=="string"&&e){const t=e.indexOf(":");if(t<0)return{session:e};const i=e.slice(0,t),s=e.slice(t+1);return!sd(i)||!s?null:{session:s,node:i}}if(e&&typeof e=="object"&&typeof e.session=="string"&&e.session){const t=e.ownerId===void 0?void 0:typeof e.ownerId=="string"&&cs.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"&&sd(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function Ri(e){const t=er(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const o_=9,a_=24,bo=11,K0=e=>{const t=Number(e);return t>=o_&&t<=a_?t:bo};function os(){return{columns:[]}}function ln(e){return e.columns.flatMap(t=>t.tiles.map(i=>Ri(i)))}function q0(e){const t=[],i=Math.max(0,...e.columns.map(s=>s.tiles.length));for(let s=0;s<i;s+=1)for(const o of e.columns)o.tiles[s]&&t.push(Ri(o.tiles[s]));return t}const fs=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))});function uh(e,t,i,s){const o=er(t);if(!o||ln(e).includes(Ri(o))||ln(e).length>=ch)return e;const a=fs(e),u={session:o.session,height:1,fontSize:bo,...s||{}};if(o.node&&(u.node=o.node),o.ownerId&&(u.ownerId=o.ownerId),i==="end")return a.columns.push({width:1,tiles:[u]}),a;if(i&&typeof i.col=="number"&&typeof i.row=="number"&&a.columns[i.col])return a.columns[i.col].tiles.splice(i.row,0,u),a;if(i&&typeof i.col=="number"){const h=Math.max(0,Math.min(a.columns.length,i.col));return a.columns.splice(h,0,{width:1,tiles:[u]}),a}return a.columns.push({width:1,tiles:[u]}),a}function l_(e,t){const i=Ri(t);if(!i||ln(e).includes(i)||ln(e).length>=ch)return e;const s=ln(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 uh(e,t,{col:_,row:e.columns[_].tiles.length})}const a=[...q0(e),i],u=new Map(e.columns.flatMap(_=>_.tiles.map(b=>[Ri(b),b]))),h=er(t),m=e.columns.length?e.columns.reduce((_,b)=>_+(Number(b.width)||1),0)/e.columns.length:1,f=Array.from({length:o},(_,b)=>{var w;return{width:((w=e.columns[b])==null?void 0:w.width)||m,tiles:[]}});return a.forEach((_,b)=>{const w=er(_);if(!w)return;const y=u.get(_)||(_===i?h:{})||{},S={session:w.session,height:y.height||1,fontSize:y.fontSize||bo};w.node&&(S.node=w.node),y.ownerId&&(S.ownerId=y.ownerId),y.unavailable===!0&&(S.unavailable=!0),f[b%o].tiles.push(S)}),{columns:f.filter(_=>_.tiles.length)}}function ll(e,t){const i=Ri(t),s=fs(e);for(const o of s.columns)o.tiles=o.tiles.filter(a=>Ri(a)!==i);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function V0(e,t,i){const s=Ri(t);if(!ln(e).includes(s))return e;const o=e.columns.flatMap(a=>a.tiles).find(a=>Ri(a)===s);return uh(ll(e,s),s,i,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function Y0(e,t){if(!(t instanceof Map)||t.size===0)return e;let i=!1;const s=fs(e);for(const o of s.columns)for(const a of o.tiles){const u=t.get(Ri(a));if(!u)continue;const h=er(u);h&&(a.session=h.session,h.node?a.node=h.node:delete a.node,h.ownerId&&(a.ownerId=h.ownerId),i=!0)}return i?br(s):e}function X0(e,t,i){const s=fs(e);return s.columns[t]&&(s.columns[t].width=Math.max(al,Number(i)||1)),s}function G0(e,t,i,s){const o=fs(e),a=o.columns[t]&&o.columns[t].tiles[i];return a&&(a.height=Math.max(al,Number(s)||1)),o}function Q0(e,t,i,s){if(!(e.columns[t]&&e.columns[t].tiles[i]))return e;const a=fs(e),u=a.columns[t].tiles[i],h=Number(u.fontSize)||bo;return u.fontSize=Math.max(o_,Math.min(a_,h+(Number(s)||0))),a}function J0(e,t,i,s){const o=e.columns[t];if(!o||!o.tiles[i])return null;switch(s){case"left":return{col:t};case"right":return{col:t+1};case"top":return{col:t,row:i};case"bottom":return{col:t,row:i+1};default:return null}}function Lm(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function br(e){if(!e||!Array.isArray(e.columns))return os();const t=e.columns.map(s=>({width:Math.max(al,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"&&sd(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&cs.test(o.ownerId)).map(o=>{const a={session:o.session,height:Math.max(al,Number(o.height)||1),fontSize:K0(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),i=new Set;for(const s of t)s.tiles=s.tiles.filter(o=>!i.has(Ri(o))&&i.add(Ri(o))&&i.size<=ch);return{columns:t.filter(s=>s.tiles.length>0)}}const c_=/^[a-z0-9-]{1,32}$/,Z0=/^[A-Za-z0-9._-]{1,32}$/,eb=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,tb=320;function od(e){return typeof e=="string"&&c_.test(e)}const ib=64;function us(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=ib&&!/[\x00-\x1f\x7f]/.test(t)}function Jn(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function u_(e){if(typeof e!="string"||!e||e.length>tb||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:Z0.test(e.slice(0,t))&&eb.test(e.slice(t+1))}function Mm(e){if(e===""||e===null||e===void 0)return null;const t=String(e).trim();if(!/^[0-9]{1,5}$/.test(t))return;const i=Number(t);return Number.isInteger(i)&&i>=1&&i<=65535?i:void 0}function Tm({name:e,ssh:t,sshPort:i,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,a=typeof t=="string"?t.trim():t;if(!od(o))return{ok:!1,error:"err-node-name"};if(!u_(a))return{ok:!1,error:"err-ssh"};const u=Mm(i);if(u===void 0)return{ok:!1,error:"err-ssh-port"};const h=Mm(s);if(h===void 0)return{ok:!1,error:"err-node-port"};const m={name:o,ssh:a};return u!==null&&(m.sshPort=u),h!==null&&(m.remotePort=h),{ok:!0,value:m}}function nb(e,t){if(!e||!t||t<e)return null;const i=Math.floor((t-e)/1e3);return i<60?"ora":i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}g`}function Am(e,t){const i=!!(e&&e.status==="up"),s=!!(e&&e.status==="passive");return{up:i,...s?{passive:!0}:{},label:i?"tunnel-up":s?"node-passive":"tunnel-down",since:i?nb(e.since,t):null}}const rb=new Set(["v","instanceId","port","label","invite"]),sb=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function ob(e){const t=String(e).replace(/-/g,"+").replace(/_/g,"/"),i=t+"=".repeat((4-t.length%4)%4),s=typeof atob=="function"?atob(i):Buffer.from(i,"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 ab(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 i;try{i=JSON.parse(ob(t))}catch{return{ok:!1}}if(!i||typeof i!="object"||Array.isArray(i))return{ok:!1};const s=i.v===1?rb:i.v===2?sb:null;if(!s)return{ok:!1};for(const u of Object.keys(i))if(!s.has(u))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(i.instanceId)))return{ok:!1};const o=Number(i.port);if(!Number.isInteger(o)||o<1||o>65535)return{ok:!1};if(typeof i.label!="string")return{ok:!1};if(typeof i.invite!="string"||!i.invite)return{ok:!1};const a={ok:!0,version:i.v,label:i.label,invite:i.invite,instanceId:i.instanceId,port:o};if(i.v===2){if(i.name!==void 0){if(typeof i.name!="string"||!c_.test(i.name))return{ok:!1};a.name=i.name}if(i.ssh!==void 0){if(!u_(i.ssh))return{ok:!1};a.ssh=String(i.ssh).trim()}if(i.sshPort!==void 0){const u=Number(i.sshPort);if(!Number.isInteger(u)||u<1||u>65535)return{ok:!1};a.sshPort=u}}return a}function lb(e,t,i=new Set){if(!t||!t.ok)return e;const s={...e},o=(a,u)=>{u==null||u===""||i.has(a)||(s[a]=u)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?Jn(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}const Jr=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function cb({onPick:e,token:t,onSettings:i}){const[s,o]=ji(),a=ah(t),[u,h]=P.useState(null),[m,f]=P.useState(null),[_,b]=P.useState(""),[w,y]=P.useState(""),[S,k]=P.useState({bind:"127.0.0.1",port:""}),[C,x]=P.useState(""),[R,D]=P.useState([]),[T,ee]=P.useState([]),[V,W]=P.useState({}),[te,K]=P.useState(new Set),[ie,Y]=P.useState(null),[A,N]=P.useState(null),{pins:j,orders:L,togglePin:$,viewFor:U,updateView:B,canMoveRoster:J,moveRoster:z,stepRoster:M}=Zv(),{groupsFor:I,moveNode:se,stepNode:ge,nodeKey:de}=t_(),fe=I(a);P.useEffect(()=>{const F=new Map;for(const H of R)F.set(Jr(H.cell),!!H.boot);for(const H of a){const oe=H.route||[H.name];for(const me of H.cells||[])F.set(Jr(me.cell,oe),!!me.boot)}W(H=>{let oe=!1;const me={...H};for(const[Te,we]of Object.entries(H))F.has(Te)&&F.get(Te)===we&&(delete me[Te],oe=!0);return oe?me:H})},[R,a]);async function X(){try{const H=await(await qt("/api/sessions",t)).json();H.error?(f(H.error),h([])):(f(null),h(H.sessions||[]))}catch(F){f(String(F)),h([])}try{const F=await Er(t);D(F.available?F.cells||[]:[]),ee(F.available?F.capabilities||[]:[])}catch{D([]),ee([])}}P.useEffect(()=>{X(),qt("/api/config",t).then(H=>H.json()).then(H=>{y(H.version||""),k({bind:H.bind||"127.0.0.1",port:H.port||""}),x(cs.test(String(H.instanceId||""))?H.instanceId:"")}).catch(()=>{});const F=setInterval(X,4e3);return()=>clearInterval(F)},[]);async function Z(){if(!S.port)return;const F=`http://${S.bind}:${S.port}/#token=${t}`;try{await navigator.clipboard.writeText(F)}catch{}}function ye(F,H,oe){const me=Jr(F,H);W(Te=>({...Te,[me]:!!oe}))}function Ee(F,H=[]){const oe=Jr(F.cell,H);return Object.prototype.hasOwnProperty.call(V,oe)?V[oe]:!!F.boot}async function tt(F,H,oe=[]){F.stopPropagation();const me=Jr(H.cell,oe),Te=!Ee(H,oe);ye(H.cell,oe,Te),K(we=>new Set(we).add(me));try{await zv(t,{cell:H.cell,enabled:Te},oe),oe.length||D(we=>we.map(Ce=>Ce.cell===H.cell?{...Ce,boot:Te}:Ce))}catch(we){W(Ce=>{const He={...Ce};return delete He[me],He}),f(String((we==null?void 0:we.message)||we))}finally{K(we=>{const Ce=new Set(we);return Ce.delete(me),Ce})}}async function Ye(F){if(!ie)return;const{cell:H}=ie,oe=Array.isArray(ie.route)?ie.route:[];F.action==="up"?(await th(t,{cell:H,boot:!!F.boot,...F.engine?{engine:F.engine}:{},...F.model!==void 0?{model:F.model}:{},...F.permissionPolicy?{permissionPolicy:F.permissionPolicy}:{}},oe),ye(H,oe,!!F.boot)):(await il(t,{cell:H,boot:!!F.boot},oe),F.boot&&ye(H,oe,!1)),X()}async function Be(F,H=[]){try{await nh(t,F,H)}catch{return}X()}async function ot(F,H,oe=[]){try{await $v(t,F,H,oe)}catch{return}X()}async function Xe(F){if(!(!(F!=null&&F.direct)||A)){N(F.name);try{await sh(t,F.name,F.tunnelStatus==="up"?"down":"up")}catch{}N(null)}}async function _t(F){if(!(F!=null&&F.direct))return;const H=window.prompt(v("rename-node-prompt"),F.label||F.name);if(H===null)return;const oe=String(H).trim();if(!us(oe)){window.alert(v("rename-node-invalid"));return}try{await qv(t,F.name,oe)}catch(me){window.alert(String((me==null?void 0:me.message)||me))}}const ut=P.useMemo(()=>new Map((u||[]).map(F=>[F.name,F])),[u]),ht=P.useMemo(()=>new Set(R.map(F=>F.tmuxSession)),[R]),rt=P.useMemo(()=>(u||[]).filter(F=>!ht.has(F.name)),[u,ht]),lt=P.useMemo(()=>s_(R,rt,ut),[R,rt,ut]),le=U("local"),ke=P.useMemo(()=>wr(lt,j,le.filter,Qn(L,"local")).filter(F=>xm(F,_)),[lt,j,le.filter,_,L]),$e=fe.reduce((F,H)=>F+(H.cells||[]).length+(H.unmanaged||[]).filter(oe=>!oe.technical).length,0),We=wr(lt,j,"all",Qn(L,"local")).length+$e,pe=lt.filter(F=>F.live).length+fe.reduce((F,H)=>F+rd(H).rawItems.filter(oe=>oe.live).length,0),Oe=(u||[]).filter(F=>F.attached).length+fe.reduce((F,H)=>F+(H.sessions||[]).filter(oe=>oe.attached).length,0),Me=Math.min(Oe,pe),G=S.port?`${S.bind}:${S.port}`:S.bind;function re(F,H=null,oe=lt){var Di,Nt;const me=Array.isArray(H==null?void 0:H.route)?H.route:[],Te=me.join("/"),we=Te||"local",Ce=me.length?H==null?void 0:H.instanceId:C,He=(qe,ei)=>e({session:qe,...Te?{node:Te}:{},...cs.test(String(Ce||""))?{ownerId:Ce}:{},...typeof ei=="string"&&ei?{cellName:ei}:{}}),Zt=J;if(F.type==="cell"){const qe=F.value,ei=me.length?((H==null?void 0:H.sessions)||[]).find(wi=>wi.name===qe.tmuxSession):ut.get(qe.tmuxSession),ue=qe.degraded?v("cell-degraded"):F.working?F.subtitle:qe.tmux?v("cell-idle"):v("cell-off"),Ne=me.length===0||((H==null?void 0:H.capabilities)||[]).includes(qe.active?"down":"up"),Ve=me.length===0?T.includes("boot"):((H==null?void 0:H.capabilities)||[]).includes("boot"),kt=Ee(qe,me),oi=Jr(qe.cell,me),vs=`${v(kt?"boot-disable":"boot-enable")} ${qe.cell}`;return c.jsxs("div",{className:"nc-mcard","data-roster-key":F.key,"data-position":we,children:[c.jsx(Xn,{position:we,itemKey:F.key,label:qe.cell,canMove:Zt,onMove:(wi,_s)=>z(we,wi,_s,oe),onStep:wi=>M(we,F.key,wi,oe)}),c.jsxs("button",{className:"nc-mcard-main",onClick:()=>qe.tmux&&He(qe.tmuxSession,qe.cell),title:ue,"aria-label":`${qe.cell}, ${ue}`,children:[c.jsx("span",{className:`dot ${qe.degraded?"warn":qe.tmux?`on${F.working?" working":""}`:""}`}),c.jsxs("span",{className:"nc-mcard-text",children:[c.jsx("b",{children:qe.cell}),c.jsx("small",{title:F.subtitle,children:F.subtitle})]})]}),F.activity?c.jsx("span",{className:"nc-rel",children:ls(F.activity)}):null,F.fresh&&((Di=ei==null?void 0:ei.outbox)==null?void 0:Di.count)>0&&c.jsx("span",{className:"nc-badge",title:v("new-files-outbox"),children:ei.outbox.count}),c.jsx("button",{className:`nc-act pin${j.includes(F.key)?" on":""}`,"aria-label":`${v("pin")} ${qe.cell}`,title:v("pin"),onClick:()=>$(F.key),children:j.includes(F.key)?"★":"☆"}),Ve&&c.jsx("button",{className:`nc-act boot${kt?" on":""}`,disabled:te.has(oi),onClick:wi=>tt(wi,qe,me),title:vs,"aria-label":vs,children:c.jsx(it,{name:"boot",size:16})}),Ne&&c.jsx("button",{className:`nc-act power${qe.tmux?" on":""}${qe.degraded?" warn":""}`,onClick:()=>Y(me.length?{...qe,boot:kt,route:me,availableEngines:(H==null?void 0:H.engines)||[]}:{...qe,boot:kt}),title:qe.active?v("power-off"):v("power-on"),"aria-label":`${qe.active?v("power-off"):v("power-on")} ${qe.cell}`,children:c.jsx(it,{name:"power",size:16})})]},F.key)}const Qe=F.value;return c.jsxs("div",{className:"nc-mcard","data-roster-key":F.key,"data-position":we,children:[c.jsx(Xn,{position:we,itemKey:F.key,label:Qe.name,canMove:Zt,onMove:(qe,ei)=>z(we,qe,ei,oe),onStep:qe=>M(we,F.key,qe,oe)}),c.jsxs("button",{className:"nc-mcard-main",onClick:()=>He(Qe.name),children:[c.jsx("span",{className:Qe.attached?"dot on":"dot"}),c.jsxs("span",{className:"nc-mcard-text",children:[c.jsx("b",{children:Qe.name}),c.jsx("small",{children:Qe.preview?Qe.preview:Qe.cmd?Qe.cmd:v("windows").replace("{n}",String(Qe.windows||0))})]})]}),F.activity?c.jsx("span",{className:"nc-rel",children:ls(F.activity)}):null,F.fresh&&((Nt=Qe.outbox)==null?void 0:Nt.count)>0&&c.jsx("span",{className:"nc-badge",title:v("new-files-outbox"),children:Qe.outbox.count}),c.jsx("button",{className:`nc-act pin${j.includes(F.key)?" on":""}`,"aria-label":`${v("pin")} ${Qe.name}`,title:v("pin"),onClick:()=>$(F.key),children:j.includes(F.key)?"★":"☆"}),c.jsx("button",{className:`nc-act technical${Qe.technical?" on":""}`,title:Qe.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${Qe.technical?v("mark-normal"):v("mark-technical")} ${Qe.name}`,onClick:()=>ot(Qe.name,!Qe.technical,me),children:"T"}),c.jsx("button",{className:"nc-menu",title:v("terminate"),"aria-label":`${v("terminate")} ${Qe.name}`,onClick:()=>{window.confirm(v("terminate-confirm").replace("{name}",Qe.name))&&Be(Qe.name,me)},children:"⋯"})]},F.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:[v("fleet-tmux")," · ",pe," ",v("sessions"),Me>0&&` · ${Me} attached`]}),c.jsxs("span",{className:"nc-head-actions",children:[c.jsx("button",{className:"nc-refresh",onClick:()=>i("nodes",!1),title:v("settings"),children:c.jsx(it,{name:"gear",size:18})}),c.jsx("button",{className:"nc-refresh",onClick:X,title:v("refresh"),children:c.jsx(it,{name:"refresh",size:18})})]})]}),c.jsxs("main",{className:"nc-home-scroll",children:[We>8&&c.jsx("input",{className:"nc-filter",type:"search",placeholder:v("filter-placeholder"),"aria-label":v("filter-placeholder"),value:_,onChange:F=>b(F.target.value)}),m&&c.jsx("div",{className:"nc-err",children:m}),c.jsxs("section",{className:"nc-group","data-position":"local",children:[c.jsx(Im,{label:v("position-local"),count:ke.length,state:le,dotClass:"on",onToggle:()=>B("local",{open:!le.open}),onFilter:F=>B("local",{filter:F})}),le.open&&ke.map(F=>re(F,null,lt)),le.open&&u===null&&c.jsx("div",{className:"nc-empty",children:v("loading-fleet")}),le.open&&u!==null&&ke.length===0&&!m&&c.jsx("div",{className:"nc-empty",children:_?v("no-match").replace("{q}",_):v("no-sessions-short")})]}),fe.map(F=>{const oe=i_(F.health,{passive:"warn"})||(F.status==="up"?"on":F.status==="passive"?"":"warn"),me=F.health?sl(F.health):F.status==="up"?"":ss(F),we=(F.route||[F.name]).join("/"),Ce=U(we),{rawItems:He}=rd(F),Zt=wr(He,j,Ce.filter,Qn(L,we)).filter(Nt=>xm(Nt,_)),Qe=F.direct&&F.health&&F.health.managed!==!1?c.jsx("button",{type:"button",className:`nc-act power${F.tunnelStatus==="up"?" on":""}`,disabled:A===F.name,title:F.tunnelStatus==="up"?v("power-off"):v("power-on"),"aria-label":`${F.tunnelStatus==="up"?v("power-off"):v("power-on")} ${F.label||F.name}`,onClick:()=>Xe(F),children:c.jsx(it,{name:"power",size:15})}):null,Di=c.jsxs("span",{className:"nc-node-actions",children:[c.jsx(Xn,{scope:"node",position:"nodes",itemKey:de(F),label:F.label||F.name,onMove:(Nt,qe)=>se(Nt,qe,a),onStep:Nt=>ge(de(F),Nt,a)}),F.direct&&c.jsx("button",{type:"button",className:"nc-node-rename",title:v("rename-node"),"aria-label":`${v("rename-node")} ${F.label||F.name}`,onClick:()=>_t(F),children:"✎"}),Qe]});return c.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":we,"data-node-order-key":de(F),children:[c.jsx(Im,{label:F.label||F.name,count:Zt.length,state:Ce,dotClass:oe,dotTitle:me,detail:F.status==="up"?"":F.health&&sl(F.health)||ss(F),onToggle:()=>B(we,{open:!Ce.open}),onFilter:Nt=>B(we,{filter:Nt}),onRename:F.direct?()=>_t(F):null,action:Di}),F.status==="up"&&Ce.open&&Zt.map(Nt=>re(Nt,F,He)),F.status==="up"&&Ce.open&&Zt.length===0&&c.jsx("div",{className:"nc-empty",children:_?v("no-match").replace("{q}",_):v("no-sessions-short")})]},`nodo-${we}`)}),c.jsxs("footer",{className:"nc-home-foot",onClick:Z,title:v("copy-url"),children:[c.jsxs("span",{className:"nc-home-meta",children:[w&&c.jsxs("span",{className:"nc-home-version",children:["v",w]}),c.jsxs("span",{className:"nc-home-endpoint",children:[G," · ",v("ssh-only")]})]}),c.jsx("span",{className:"nc-lang",onClick:F=>F.stopPropagation(),children:Jv.map((F,H)=>c.jsxs("span",{children:[H>0&&" · ",c.jsx("button",{className:`nc-lang-btn${s===F?" on":""}`,onClick:()=>o(F),title:F,children:F.toUpperCase()})]},F))})]})]}),c.jsx("button",{className:"nc-fab",onClick:()=>i("fleet",!0),title:v("fleet-new-cell"),"aria-label":v("fleet-new-cell"),children:"+"}),ie&&c.jsx(nl,{cell:ie,token:t,route:Array.isArray(ie.route)?ie.route:[],onConfirm:Ye,onClose:()=>Y(null)})]})}function Im({label:e,count:t,state:i,dotClass:s="",dotTitle:o="",detail:a="",onToggle:u,onFilter:h,onRename:m=null,action:f=null}){return c.jsxs("div",{className:"nc-mobile-position-head",onContextMenu:m?_=>{_.preventDefault(),m()}:void 0,children:[c.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:u,"aria-expanded":i.open,"aria-label":`${e} · ${v("node-sessions").replace("{n}",String(t))}`,children:[c.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:i.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||v("node-sessions").replace("{n}",String(t))})]})]}),c.jsxs("select",{className:"nc-mobile-position-filter",value:i.filter,"aria-label":`${e} · ${v("filter-placeholder")}`,title:v(`view-${i.filter}`),onChange:_=>h(_.target.value),children:[c.jsx("option",{value:"all",children:v("view-all")}),c.jsx("option",{value:"pinned",children:v("view-pinned")}),c.jsx("option",{value:"active",children:v("view-active")}),c.jsx("option",{value:"off",children:v("view-off")}),c.jsx("option",{value:"technical",children:v("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 d_=Object.defineProperty,ub=Object.getOwnPropertyDescriptor,db=(e,t)=>{for(var i in t)d_(e,i,{get:t[i],enumerable:!0})},Et=(e,t,i,s)=>{for(var o=s>1?void 0:s?ub(t,i):t,a=e.length-1,u;a>=0;a--)(u=e[a])&&(o=(s?u(t,i,o):u(o))||o);return s&&o&&d_(t,i,o),o},Re=(e,t)=>(i,s)=>t(i,s,e),Bm="Terminal input",ad={get:()=>Bm,set:e=>Bm=e},Om="Too much output to announce, navigate to rows manually to read",ld={get:()=>Om,set:e=>Om=e};function hb(e){return e.replace(/\r?\n/g,"\r")}function fb(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function pb(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function mb(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");h_(o,t,i,s)}}function h_(e,t,i,s){e=hb(e),e=fb(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function f_(e,t,i){let s=i.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 zm(e,t,i,s,o){f_(e,t,i),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Yn(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function _l(e,t=0,i=e.length){let s="";for(let o=t;o<i;++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 gb=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)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<i;++a){let u=e.charCodeAt(a);if(55296<=u&&u<=56319){if(++a>=i)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}},vb=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,o,a,u,h,m=0,f=0;if(this.interim[0]){let w=!1,y=this.interim[0];y&=(y&224)===192?31:(y&240)===224?15:7;let S=0,k;for(;(k=this.interim[++S]&63)&&S<4;)y<<=6,y|=k;let C=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,x=C-S;for(;f<x;){if(f>=i)return 0;if(k=e[f++],(k&192)!==128){f--,w=!0;break}else this.interim[S++]=k,y<<=6,y|=k&63}w||(C===2?y<128?f--:t[s++]=y:C===3?y<2048||y>=55296&&y<=57343||y===65279||(t[s++]=y):y<65536||y>1114111||(t[s++]=y)),this.interim.fill(0)}let _=i-4,b=f;for(;b<i;){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>=i)return this.interim[0]=o,s;if(a=e[b++],(a&192)!==128){b--;continue}if(m=(o&31)<<6|a&63,m<128){b--;continue}t[s++]=m}else if((o&240)===224){if(b>=i)return this.interim[0]=o,s;if(a=e[b++],(a&192)!==128){b--;continue}if(b>=i)return this.interim[0]=o,this.interim[1]=a,s;if(u=e[b++],(u&192)!==128){b--;continue}if(m=(o&15)<<12|(a&63)<<6|u&63,m<2048||m>=55296&&m<=57343||m===65279)continue;t[s++]=m}else if((o&248)===240){if(b>=i)return this.interim[0]=o,s;if(a=e[b++],(a&192)!==128){b--;continue}if(b>=i)return this.interim[0]=o,this.interim[1]=a,s;if(u=e[b++],(u&192)!==128){b--;continue}if(b>=i)return this.interim[0]=o,this.interim[1]=a,this.interim[2]=u,s;if(h=e[b++],(h&192)!==128){b--;continue}if(m=(o&7)<<18|(a&63)<<12|(u&63)<<6|h&63,m<65536||m>1114111)continue;t[s++]=m}}return s}},p_="",Gn=" ",ko=class m_{constructor(){this.fg=0,this.bg=0,this.extended=new cl}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 m_;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}},cl=class g_{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}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 g_(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},$i=class v_ extends ko{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new cl,this.combinedData=""}static fromCharData(t){let i=new v_;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Yn(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 i=!1;if(t[1].length>2)i=!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:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Fm="di$target",cd="di$dependencies",hu=new Map;function _b(e){return e[cd]||[]}function Yt(e){if(hu.has(e))return hu.get(e);let t=function(i,s,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");yb(t,i,o)};return t._id=e,hu.set(e,t),t}function yb(e,t,i){t[Fm]===t?t[cd].push({id:e,index:i}):(t[cd]=[{id:e,index:i}],t[Fm]=t)}var di=Yt("BufferService"),__=Yt("CoreMouseService"),Nr=Yt("CoreService"),Sb=Yt("CharsetService"),dh=Yt("InstantiationService"),y_=Yt("LogService"),hi=Yt("OptionsService"),S_=Yt("OscLinkService"),wb=Yt("UnicodeService"),xo=Yt("DecorationService"),ud=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var _;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,a=new $i,u=i.getTrimmedLength(),h=-1,m=-1,f=!1;for(let b=0;b<u;b++)if(!(m===-1&&!i.hasContent(b))){if(i.loadCell(b,a),a.hasExtendedAttrs()&&a.extended.urlId)if(m===-1){m=b,h=a.extended.urlId;continue}else f=a.extended.urlId!==h;else m!==-1&&(f=!0);if(f||m!==-1&&b===u-1){let w=(_=this._oscLinkService.getLinkData(h))==null?void 0:_.uri;if(w){let y={start:{x:m+1,y:e},end:{x:b+(!f&&b===u-1?1:0),y:e}},S=!1;if(!(o!=null&&o.allowNonHttpProtocols))try{let k=new URL(w);["http:","https:"].includes(k.protocol)||(S=!0)}catch{S=!0}S||s.push({text:w,range:y,activate:(k,C)=>o?o.activate(k,C,y):bb(k,C),hover:(k,C)=>{var x;return(x=o==null?void 0:o.hover)==null?void 0:x.call(o,k,C,y)},leave:(k,C)=>{var x;return(x=o==null?void 0:o.leave)==null?void 0:x.call(o,k,C,y)}})}f=!1,a.hasExtendedAttrs()&&a.extended.urlId?(m=b,h=a.extended.urlId):(m=-1,h=-1)}}t(s)}};ud=Et([Re(0,di),Re(1,hi),Re(2,S_)],ud);function bb(e,t){if(confirm(`Do you want to navigate to ${t}?
52
-
53
- WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var yl=Yt("CharSizeService"),kn=Yt("CoreBrowserService"),hh=Yt("MouseService"),xn=Yt("RenderService"),kb=Yt("SelectionService"),w_=Yt("CharacterJoinerService"),ps=Yt("ThemeService"),b_=Yt("LinkProviderService"),xb=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?$m.isErrorNoTelemetry(e)?new $m(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)}},Cb=new xb;function Xa(e){Eb(e)||Cb.onUnexpectedError(e)}var dd="Canceled";function Eb(e){return e instanceof Nb?!0:e instanceof Error&&e.name===dd&&e.message===dd}var Nb=class extends Error{constructor(){super(dd),this.name=this.message}};function Rb(e){return new Error(`Illegal argument: ${e}`)}var $m=class hd extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof hd)return t;let i=new hd;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},fd=class k_ extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,k_.prototype)}};function Ei(e,t=0){return e[e.length-(1+t)]}var Pb;(e=>{function t(a){return a<0}e.isLessThan=t;function i(a){return a<=0}e.isLessThanOrEqual=i;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})(Pb||(Pb={}));function jb(e,t){let i=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(i,arguments))),o}}var x_;(e=>{function t(T){return T&&typeof T=="object"&&typeof T[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*o(T){yield T}e.single=o;function a(T){return t(T)?T:o(T)}e.wrap=a;function u(T){return T||i}e.from=u;function*h(T){for(let ee=T.length-1;ee>=0;ee--)yield T[ee]}e.reverse=h;function m(T){return!T||T[Symbol.iterator]().next().done===!0}e.isEmpty=m;function f(T){return T[Symbol.iterator]().next().value}e.first=f;function _(T,ee){let V=0;for(let W of T)if(ee(W,V++))return!0;return!1}e.some=_;function b(T,ee){for(let V of T)if(ee(V))return V}e.find=b;function*w(T,ee){for(let V of T)ee(V)&&(yield V)}e.filter=w;function*y(T,ee){let V=0;for(let W of T)yield ee(W,V++)}e.map=y;function*S(T,ee){let V=0;for(let W of T)yield*ee(W,V++)}e.flatMap=S;function*k(...T){for(let ee of T)yield*ee}e.concat=k;function C(T,ee,V){let W=V;for(let te of T)W=ee(W,te);return W}e.reduce=C;function*x(T,ee,V=T.length){for(ee<0&&(ee+=T.length),V<0?V+=T.length:V>T.length&&(V=T.length);ee<V;ee++)yield T[ee]}e.slice=x;function R(T,ee=Number.POSITIVE_INFINITY){let V=[];if(ee===0)return[V,T];let W=T[Symbol.iterator]();for(let te=0;te<ee;te++){let K=W.next();if(K.done)return[V,e.empty()];V.push(K.value)}return[V,{[Symbol.iterator](){return W}}]}e.consume=R;async function D(T){let ee=[];for await(let V of T)ee.push(V);return Promise.resolve(ee)}e.asyncToArray=D})(x_||(x_={}));function xr(e){if(x_.is(e)){let t=[];for(let i of e)if(i)try{i.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 Db(...e){return vt(()=>xr(e))}function vt(e){return{dispose:jb(()=>{e()})}}var C_=class E_{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{xr(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?E_.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)}};C_.DISABLE_DISPOSED_WARNING=!1;var Zn=C_,Ze=class{constructor(){this._store=new Zn,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)}};Ze.None=Object.freeze({dispose(){}});var ds=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}},bn=typeof window=="object"?window:globalThis,pd=class md{constructor(t){this.element=t,this.next=md.Undefined,this.prev=md.Undefined}};pd.Undefined=new pd(void 0);var wt=pd,Hm=class{constructor(){this._first=wt.Undefined,this._last=wt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===wt.Undefined}clear(){let e=this._first;for(;e!==wt.Undefined;){let t=e.next;e.prev=wt.Undefined,e.next=wt.Undefined,e=t}this._first=wt.Undefined,this._last=wt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new wt(e);if(this._first===wt.Undefined)this._first=i,this._last=i;else if(t){let o=this._last;this._last=i,i.prev=o,o.next=i}else{let o=this._first;this._first=i,i.next=o,o.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==wt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==wt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==wt.Undefined&&e.next!==wt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===wt.Undefined&&e.next===wt.Undefined?(this._first=wt.Undefined,this._last=wt.Undefined):e.next===wt.Undefined?(this._last=this._last.prev,this._last.next=wt.Undefined):e.prev===wt.Undefined&&(this._first=this._first.next,this._first.prev=wt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==wt.Undefined;)yield e.element,e=e.next}},Lb=globalThis.performance&&typeof globalThis.performance.now=="function",Mb=class N_{static create(t){return new N_(t)}constructor(t){this._now=Lb&&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}},Jt;(e=>{e.None=()=>Ze.None;function t(A,N){return b(A,()=>{},0,void 0,!0,void 0,N)}e.defer=t;function i(A){return(N,j=null,L)=>{let $=!1,U;return U=A(B=>{if(!$)return U?U.dispose():$=!0,N.call(j,B)},null,L),$&&U.dispose(),U}}e.once=i;function s(A,N,j){return f((L,$=null,U)=>A(B=>L.call($,N(B)),null,U),j)}e.map=s;function o(A,N,j){return f((L,$=null,U)=>A(B=>{N(B),L.call($,B)},null,U),j)}e.forEach=o;function a(A,N,j){return f((L,$=null,U)=>A(B=>N(B)&&L.call($,B),null,U),j)}e.filter=a;function u(A){return A}e.signal=u;function h(...A){return(N,j=null,L)=>{let $=Db(...A.map(U=>U(B=>N.call(j,B))));return _($,L)}}e.any=h;function m(A,N,j,L){let $=j;return s(A,U=>($=N($,U),$),L)}e.reduce=m;function f(A,N){let j,L={onWillAddFirstListener(){j=A($.fire,$)},onDidRemoveLastListener(){j==null||j.dispose()}},$=new xe(L);return N==null||N.add($),$.event}function _(A,N){return N instanceof Array?N.push(A):N&&N.add(A),A}function b(A,N,j=100,L=!1,$=!1,U,B){let J,z,M,I=0,se,ge={leakWarningThreshold:U,onWillAddFirstListener(){J=A(fe=>{I++,z=N(z,fe),L&&!M&&(de.fire(z),z=void 0),se=()=>{let X=z;z=void 0,M=void 0,(!L||I>1)&&de.fire(X),I=0},typeof j=="number"?(clearTimeout(M),M=setTimeout(se,j)):M===void 0&&(M=0,queueMicrotask(se))})},onWillRemoveListener(){$&&I>0&&(se==null||se())},onDidRemoveLastListener(){se=void 0,J.dispose()}},de=new xe(ge);return B==null||B.add(de),de.event}e.debounce=b;function w(A,N=0,j){return e.debounce(A,(L,$)=>L?(L.push($),L):[$],N,void 0,!0,void 0,j)}e.accumulate=w;function y(A,N=(L,$)=>L===$,j){let L=!0,$;return a(A,U=>{let B=L||!N(U,$);return L=!1,$=U,B},j)}e.latch=y;function S(A,N,j){return[e.filter(A,N,j),e.filter(A,L=>!N(L),j)]}e.split=S;function k(A,N=!1,j=[],L){let $=j.slice(),U=A(z=>{$?$.push(z):J.fire(z)});L&&L.add(U);let B=()=>{$==null||$.forEach(z=>J.fire(z)),$=null},J=new xe({onWillAddFirstListener(){U||(U=A(z=>J.fire(z)),L&&L.add(U))},onDidAddFirstListener(){$&&(N?setTimeout(B):B())},onDidRemoveLastListener(){U&&U.dispose(),U=null}});return L&&L.add(J),J.event}e.buffer=k;function C(A,N){return(j,L,$)=>{let U=N(new R);return A(function(B){let J=U.evaluate(B);J!==x&&j.call(L,J)},void 0,$)}}e.chain=C;let x=Symbol("HaltChainable");class R{constructor(){this.steps=[]}map(N){return this.steps.push(N),this}forEach(N){return this.steps.push(j=>(N(j),j)),this}filter(N){return this.steps.push(j=>N(j)?j:x),this}reduce(N,j){let L=j;return this.steps.push($=>(L=N(L,$),L)),this}latch(N=(j,L)=>j===L){let j=!0,L;return this.steps.push($=>{let U=j||!N($,L);return j=!1,L=$,U?$:x}),this}evaluate(N){for(let j of this.steps)if(N=j(N),N===x)break;return N}}function D(A,N,j=L=>L){let L=(...J)=>B.fire(j(...J)),$=()=>A.on(N,L),U=()=>A.removeListener(N,L),B=new xe({onWillAddFirstListener:$,onDidRemoveLastListener:U});return B.event}e.fromNodeEventEmitter=D;function T(A,N,j=L=>L){let L=(...J)=>B.fire(j(...J)),$=()=>A.addEventListener(N,L),U=()=>A.removeEventListener(N,L),B=new xe({onWillAddFirstListener:$,onDidRemoveLastListener:U});return B.event}e.fromDOMEventEmitter=T;function ee(A){return new Promise(N=>i(A)(N))}e.toPromise=ee;function V(A){let N=new xe;return A.then(j=>{N.fire(j)},()=>{N.fire(void 0)}).finally(()=>{N.dispose()}),N.event}e.fromPromise=V;function W(A,N){return A(j=>N.fire(j))}e.forward=W;function te(A,N,j){return N(j),A(L=>N(L))}e.runAndSubscribe=te;class K{constructor(N,j){this._observable=N,this._counter=0,this._hasChanged=!1;let L={onWillAddFirstListener:()=>{N.addObserver(this)},onDidRemoveLastListener:()=>{N.removeObserver(this)}};this.emitter=new xe(L),j&&j.add(this.emitter)}beginUpdate(N){this._counter++}handlePossibleChange(N){}handleChange(N,j){this._hasChanged=!0}endUpdate(N){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ie(A,N){return new K(A,N).emitter.event}e.fromObservable=ie;function Y(A){return(N,j,L)=>{let $=0,U=!1,B={beginUpdate(){$++},endUpdate(){$--,$===0&&(A.reportChanges(),U&&(U=!1,N.call(j)))},handlePossibleChange(){},handleChange(){U=!0}};A.addObserver(B),A.reportChanges();let J={dispose(){A.removeObserver(B)}};return L instanceof Zn?L.add(J):Array.isArray(L)&&L.push(J),J}}e.fromObservableLight=Y})(Jt||(Jt={}));var gd=class vd{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${vd._idPool++}`,vd.all.add(this)}start(t){this._stopWatch=new Mb,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}}};gd.all=new Set,gd._idPool=0;var Tb=gd,Ab=-1,R_=class P_{constructor(t,i,s=(P_._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<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 ${i} listeners already. MOST frequent listener (${u}):`;console.warn(h),console.warn(a);let m=new Ob(h,a);this._errorHandler(m)}return()=>{let a=this._stacks.get(t.value)||0;this._stacks.set(t.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,o]of this._stacks)(!t||i<o)&&(t=[s,o],i=o);return t}};R_._idPool=1;var Ib=R_,Bb=class j_{constructor(t){this.value=t}static create(){let t=new Error;return new j_(t.stack??"")}print(){console.warn(this.value.split(`
58
- `).slice(2).join(`
59
- `))}},Ob=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},zb=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Fb=0,fu=class{constructor(e){this.value=e,this.id=Fb++}},$b=2,Hb,xe=class{constructor(e){var t,i,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new Ib((e==null?void 0:e.onListenerError)??Xa,((i=this._options)==null?void 0:i.leakWarningThreshold)??Ab):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new Tb(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var e,t,i,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),(i=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||i.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var u,h,m,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 w=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],y=new zb(`${b}. HINT: Stack shows most frequent listener (${w[1]}-times)`,w[0]);return(((u=this._options)==null?void 0:u.onListenerError)||Xa)(y),Ze.None}if(this._disposed)return Ze.None;t&&(e=e.bind(t));let s=new fu(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Bb.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof fu?(this._deliveryQueue??(this._deliveryQueue=new Wb),this._listeners=[this._listeners,s]):this._listeners.push(s):((m=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||m.call(h,this),this._listeners=s,(_=(f=this._options)==null?void 0:f.onDidAddFirstListener)==null||_.call(f,this)),this._size++;let a=vt(()=>{o==null||o(),this._removeListener(s)});return i instanceof Zn?i.add(a):Array.isArray(i)&&i.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,i=t.indexOf(e);if(i===-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[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*$b<=t.length){let m=0;for(let f=0;f<t.length;f++)t[f]?t[m++]=t[f]:s&&(this._deliveryQueue.end--,m<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=m}}_deliver(e,t){var s;if(!e)return;let i=((s=this._options)==null?void 0:s.onListenerError)||Xa;if(!i){e.value(t);return}try{e.value(t)}catch(o){i(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,i,s,o;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof fu)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}},Wb=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},_d=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new xe,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new xe,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};_d.INSTANCE=new _d;var fh=_d;function Ub(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}fh.INSTANCE.onDidChangeZoomLevel;function Kb(e){return fh.INSTANCE.getZoomFactor(e)}fh.INSTANCE.onDidChangeFullscreen;var ms=typeof navigator=="object"?navigator.userAgent:"",yd=ms.indexOf("Firefox")>=0,qb=ms.indexOf("AppleWebKit")>=0,ph=ms.indexOf("Chrome")>=0,Vb=!ph&&ms.indexOf("Safari")>=0;ms.indexOf("Electron/")>=0;ms.indexOf("Android")>=0;var pu=!1;if(typeof bn.matchMedia=="function"){let e=bn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=bn.matchMedia("(display-mode: fullscreen)");pu=e.matches,Ub(bn,e,({matches:i})=>{pu&&t.matches||(pu=i)})}var rs="en",Sd=!1,wd=!1,Ga=!1,D_=!1,Fa,Qa=rs,Wm=rs,Yb,Gi,kr=globalThis,Qt,Av;typeof kr.vscode<"u"&&typeof kr.vscode.process<"u"?Qt=kr.vscode.process:typeof process<"u"&&typeof((Av=process==null?void 0:process.versions)==null?void 0:Av.node)=="string"&&(Qt=process);var Iv,Xb=typeof((Iv=Qt==null?void 0:Qt.versions)==null?void 0:Iv.electron)=="string",Gb=Xb&&(Qt==null?void 0:Qt.type)==="renderer",Bv;if(typeof Qt=="object"){Sd=Qt.platform==="win32",wd=Qt.platform==="darwin",Ga=Qt.platform==="linux",Ga&&Qt.env.SNAP&&Qt.env.SNAP_REVISION,Qt.env.CI||Qt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Fa=rs,Qa=rs;let e=Qt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Fa=t.userLocale,Wm=t.osLocale,Qa=t.resolvedLanguage||rs,Yb=(Bv=t.languagePack)==null?void 0:Bv.translationsConfigFile}catch{}D_=!0}else typeof navigator=="object"&&!Gb?(Gi=navigator.userAgent,Sd=Gi.indexOf("Windows")>=0,wd=Gi.indexOf("Macintosh")>=0,(Gi.indexOf("Macintosh")>=0||Gi.indexOf("iPad")>=0||Gi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ga=Gi.indexOf("Linux")>=0,(Gi==null?void 0:Gi.indexOf("Mobi"))>=0,Qa=globalThis._VSCODE_NLS_LANGUAGE||rs,Fa=navigator.language.toLowerCase(),Wm=Fa):console.error("Unable to resolve platform.");var L_=Sd,cn=wd,Qb=Ga,Um=D_,dn=Gi,Un=Qa,Jb;(e=>{function t(){return Un}e.value=t;function i(){return Un.length===2?Un==="en":Un.length>=3?Un[0]==="e"&&Un[1]==="n"&&Un[2]==="-":!1}e.isDefaultVariant=i;function s(){return Un==="en"}e.isDefault=s})(Jb||(Jb={}));var Zb=typeof kr.postMessage=="function"&&!kr.importScripts;(()=>{if(Zb){let e=[];kr.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let a=e[s];if(a.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),a.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),kr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var e1=!!(dn&&dn.indexOf("Chrome")>=0);dn&&dn.indexOf("Firefox")>=0;!e1&&dn&&dn.indexOf("Safari")>=0;dn&&dn.indexOf("Edg/")>=0;dn&&dn.indexOf("Android")>=0;var Zr=typeof navigator=="object"?navigator:{};Um||document.queryCommandSupported&&document.queryCommandSupported("copy")||Zr&&Zr.clipboard&&Zr.clipboard.writeText,Um||Zr&&Zr.clipboard&&Zr.clipboard.readText;var mh=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}},mu=new mh,Km=new mh,qm=new mh,t1=new Array(230),M_;(e=>{function t(h){return mu.keyCodeToStr(h)}e.toString=t;function i(h){return mu.strToKeyCode(h)}e.fromString=i;function s(h){return Km.keyCodeToStr(h)}e.toUserSettingsUS=s;function o(h){return qm.keyCodeToStr(h)}e.toUserSettingsGeneral=o;function a(h){return Km.strToKeyCode(h)||qm.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 mu.keyCodeToStr(h)}e.toElectronAccelerator=u})(M_||(M_={}));var i1=class T_{constructor(t,i,s,o,a){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=o,this.keyCode=a}equals(t){return t instanceof T_&&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",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${i}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new n1([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},n1=class{constructor(e){if(e.length===0)throw Rb("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;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 r1(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return M_.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(yd)switch(t){case 59:return 85;case 60:if(Qb)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(cn)return 57;break}else if(qb&&(cn&&t===93||!cn&&t===92))return 57;return t1[t]||0}var s1=cn?256:2048,o1=512,a1=1024,l1=cn?2048:256,Vm=class{constructor(e){var i;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=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=r1(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|=s1),this.altKey&&(t|=o1),this.shiftKey&&(t|=a1),this.metaKey&&(t|=l1),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new i1(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Ym=new WeakMap;function c1(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var u1=class{static getSameOriginWindowChain(e){let t=Ym.get(e);if(!t){t=[],Ym.set(e,t);let i=e,s;do s=c1(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,o=this.getSameOriginWindowChain(e);for(let a of o){let u=a.window.deref();if(i+=(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();i+=h.top,s+=h.left}return{top:i,left:s}}},$a=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 i=u1.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Xm=class{constructor(e,t=0,i=0){var o;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,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 m=e;m.deltaMode===m.DOM_DELTA_LINE?yd&&!cn?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof a.wheelDeltaX<"u")Vb&&L_?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 m=e;m.deltaMode===m.DOM_DELTA_LINE?yd&&!cn?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()}},A_=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),d1;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof h1?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Jt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:A_})})(d1||(d1={}));var h1=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?A_:(this._emitter||(this._emitter=new xe),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},gh=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 fd("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new fd("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},f1=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,i=globalThis){if(this.isDisposed)throw new fd("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=vt(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},p1;(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 i(s){return new Promise(async(o,a)=>{try{await s(o,a)}catch(u){a(u)}})}e.withAsyncBody=i})(p1||(p1={}));var Gm=class zi{static fromArray(t){return new zi(i=>{i.emitMany(t)})}static fromPromise(t){return new zi(async i=>{i.emitMany(await t)})}static fromPromises(t){return new zi(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new zi(async i=>{await Promise.all(t.map(async s=>{for await(let o of s)i.emitOne(o)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new xe,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 Jt.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new zi(async s=>{for await(let o of t)s.emitOne(i(o))})}map(t){return zi.map(this,t)}static filter(t,i){return new zi(async s=>{for await(let o of t)i(o)&&s.emitOne(o)})}filter(t){return zi.filter(this,t)}static coalesce(t){return zi.filter(t,i=>!!i)}coalesce(){return zi.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return zi.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())}};Gm.EMPTY=Gm.fromArray([]);var{getWindow:an,getWindowId:m1,onDidRegisterWindow:g1}=(function(){let e=new Map,t={window:bn,disposables:new Zn};e.set(bn.vscodeWindowId,t);let i=new xe,s=new xe,o=new xe;function a(u,h){return(typeof u=="number"?e.get(u):void 0)??(h?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(u){if(e.has(u.vscodeWindowId))return Ze.None;let h=new Zn,m={window:u,disposables:h.add(new Zn)};return e.set(u.vscodeWindowId,m),h.add(vt(()=>{e.delete(u.vscodeWindowId),s.fire(u)})),h.add(Ke(u,Ht.BEFORE_UNLOAD,()=>{o.fire(u)})),i.fire(m),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 m=u;return m!=null&&m.view?m.view.window:bn},getDocument(u){return an(u).document}}})(),v1=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ke(e,t,i,s){return new v1(e,t,i,s)}var Qm=function(e,t,i,s){return Ke(e,t,i,s)},vh,_1=class extends f1{constructor(e){super(),this.defaultTarget=e&&an(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Jm=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){Xa(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,o=a=>{i.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(Jm.sort),u.shift().execute();s.set(a,!1)};vh=(a,u,h=0)=>{let m=m1(a),f=new Jm(u,h),_=e.get(m);return _||(_=[],e.set(m,_)),_.push(f),i.get(m)||(i.set(m,!0),a.requestAnimationFrame(()=>o(m))),f}})();function y1(e){let t=e.getBoundingClientRect(),i=an(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var Ht={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"},S1=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 i=yi(t);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let i=yi(t);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(t){let i=yi(t);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(t){let i=yi(t);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(t){let i=yi(t);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(t){let i=yi(t);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(t){let i=yi(t);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(t){let i=yi(t);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let i=yi(t);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let i=yi(t);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let i=yi(t);this._paddingRight!==i&&(this._paddingRight=i,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 i=yi(t);this._fontSize!==i&&(this._fontSize=i,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 i=yi(t);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let i=yi(t);this._letterSpacing!==i&&(this._letterSpacing=i,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,i){this.domNode.classList.toggle(t,i),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,i){this.domNode.setAttribute(t,i)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function yi(e){return typeof e=="number"?`${e}px`:e}function vo(e){return new S1(e)}var I_=class{constructor(){this._hooks=new Zn,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 i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let a=e;try{e.setPointerCapture(t),this._hooks.add(vt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=an(e)}this._hooks.add(Ke(a,Ht.POINTER_MOVE,u=>{if(u.buttons!==i){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(Ke(a,Ht.POINTER_UP,u=>this.stopMonitoring(!0)))}};function w1(e,t,i){let s=null,o=null;if(typeof i.value=="function"?(s="value",o=i.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",o=i.get),!o)throw new Error("not supported");let a=`$memoize$${t}`;i[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 on;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(on||(on={}));var ho=class si extends Ze{constructor(){super(),this.dispatched=!1,this.targets=new Hm,this.ignoreTargets=new Hm,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Jt.runAndSubscribe(g1,({window:t,disposables:i})=>{i.add(Ke(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(Ke(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(Ke(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:bn,disposables:this._store}))}static addTarget(t){if(!si.isTouchDevice())return Ze.None;si.INSTANCE||(si.INSTANCE=new si);let i=si.INSTANCE.targets.push(t);return vt(i)}static ignoreTarget(t){if(!si.isTouchDevice())return Ze.None;si.INSTANCE||(si.INSTANCE=new si);let i=si.INSTANCE.ignoreTargets.push(t);return vt(i)}static isTouchDevice(){return"ontouchstart"in bn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=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:i,initialPageX:a.pageX,initialPageY:a.pageY,rollingTimestamps:[i],rollingPageX:[a.pageX],rollingPageY:[a.pageY]};let u=this.newGestureEvent(on.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,i){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let a=0,u=i.changedTouches.length;a<u;a++){let h=i.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(h.identifier))){console.warn("move of an UNKNOWN touch",h);continue}let m=this.activeTouches[h.identifier],f=Date.now()-m.initialTimeStamp;if(f<si.HOLD_DELAY&&Math.abs(m.initialPageX-Ei(m.rollingPageX))<30&&Math.abs(m.initialPageY-Ei(m.rollingPageY))<30){let _=this.newGestureEvent(on.Tap,m.initialTarget);_.pageX=Ei(m.rollingPageX),_.pageY=Ei(m.rollingPageY),this.dispatchEvent(_)}else if(f>=si.HOLD_DELAY&&Math.abs(m.initialPageX-Ei(m.rollingPageX))<30&&Math.abs(m.initialPageY-Ei(m.rollingPageY))<30){let _=this.newGestureEvent(on.Contextmenu,m.initialTarget);_.pageX=Ei(m.rollingPageX),_.pageY=Ei(m.rollingPageY),this.dispatchEvent(_)}else if(o===1){let _=Ei(m.rollingPageX),b=Ei(m.rollingPageY),w=Ei(m.rollingTimestamps)-m.rollingTimestamps[0],y=_-m.rollingPageX[0],S=b-m.rollingPageY[0],k=[...this.targets].filter(C=>m.initialTarget instanceof Node&&C.contains(m.initialTarget));this.inertia(t,k,s,Math.abs(y)/w,y>0?1:-1,_,Math.abs(S)/w,S>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(on.End,m.initialTarget)),delete this.activeTouches[h.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===on.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>si.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===on.Change||t.type===on.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];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;i.push([o,s])}i.sort((s,o)=>s[0]-o[0]);for(let[s,o]of i)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,o,a,u,h,m,f){this.handle=vh(t,()=>{let _=Date.now(),b=_-s,w=0,y=0,S=!0;o+=si.SCROLL_FRICTION*b,h+=si.SCROLL_FRICTION*b,o>0&&(S=!1,w=a*o*b),h>0&&(S=!1,y=m*h*b);let k=this.newGestureEvent(on.Change);k.translationX=w,k.translationY=y,i.forEach(C=>C.dispatchEvent(k)),S||this.inertia(t,i,_,o,a,u+w,h,m,f+y)})}onTouchMove(t){let i=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(on.Change,u.initialTarget);h.translationX=a.pageX-Ei(u.rollingPageX),h.translationY=a.pageY-Ei(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(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};ho.SCROLL_FRICTION=-.005,ho.HOLD_DELAY=700,ho.CLEAR_TAP_COUNT_TIME=400,Et([w1],ho,"isTouchDevice",1);var b1=ho,_h=class extends Ze{onclick(e,t){this._register(Ke(e,Ht.CLICK,i=>t(new $a(an(e),i))))}onmousedown(e,t){this._register(Ke(e,Ht.MOUSE_DOWN,i=>t(new $a(an(e),i))))}onmouseover(e,t){this._register(Ke(e,Ht.MOUSE_OVER,i=>t(new $a(an(e),i))))}onmouseleave(e,t){this._register(Ke(e,Ht.MOUSE_LEAVE,i=>t(new $a(an(e),i))))}onkeydown(e,t){this._register(Ke(e,Ht.KEY_DOWN,i=>t(new Vm(i))))}onkeyup(e,t){this._register(Ke(e,Ht.KEY_UP,i=>t(new Vm(i))))}oninput(e,t){this._register(Ke(e,Ht.INPUT,t))}onblur(e,t){this._register(Ke(e,Ht.BLUR,t))}onfocus(e,t){this._register(Ke(e,Ht.FOCUS,t))}onchange(e,t){this._register(Ke(e,Ht.CHANGE,t))}ignoreGesture(e){return b1.ignoreTarget(e)}},Zm=11,k1=class extends _h{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=Zm+"px",this.domNode.style.height=Zm+"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 I_),this._register(Qm(this.bgDomNode,Ht.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Qm(this.domNode,Ht.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new _1),this._pointerdownScheduleRepeatTimer=this._register(new gh)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,an(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},x1=class bd{constructor(t,i,s,o,a,u,h){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,o=o|0,a=a|0,u=u|0,h=h|0),this.rawScrollLeft=o,this.rawScrollTop=h,i<0&&(i=0),o+i>s&&(o=s-i),o<0&&(o=0),a<0&&(a=0),h+a>u&&(h=u-a),h<0&&(h=0),this.width=i,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,i){return new bd(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new bd(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,i){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,m=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,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:m}}},C1=class extends Ze{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new x1(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 i=this._state.withScrollDimensions(e,t);this._setState(i,!!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 i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new tg(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=tg.start(this._state,i,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 i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},eg=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function gu(e,t){let i=t-e;return function(s){return e+i*R1(s)}}function E1(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var tg=class kd{constructor(t,i,s,o){this.from=t,this.to=i,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,i,s){if(Math.abs(t-i)>2.5*s){let o,a;return t<i?(o=t+.75*s,a=i-.75*s):(o=t-.75*s,a=i+.75*s),E1(gu(t,o),gu(a,i),.33)}return gu(t,i)}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 i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),o=this.scrollTop(i);return new eg(s,o,!1)}return new eg(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return kd.start(t,i,s)}static start(t,i,s){s=s+10;let o=Date.now()-10;return new kd(t,i,o,s)}};function N1(e){return Math.pow(e,3)}function R1(e){return 1-N1(1-e)}var P1=class extends Ze{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new gh)}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":"")))}},j1=140,B_=class extends _h{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 P1(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new I_),this._shouldRender=!0,this.domNode=vo(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Ke(this.domNode.domNode,Ht.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new k1(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=vo(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ke(this.slider.domNode,Ht.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,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);i<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let o=y1(this.domNode.domNode);t=e.pageX-o.left,i=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let a=this._sliderOrthogonalPointerPosition(o),u=Math.abs(a-i);if(L_&&u>j1){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()}},O_=class xd{constructor(t,i,s,o,a,u){this._scrollbarSize=Math.round(i),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 xd(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,o,a){let u=Math.max(0,s-t),h=Math.max(0,u-2*i),m=o>0&&o>s;if(!m)return{computedAvailableSize:Math.round(u),computedIsNeeded:m,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:m,computedSliderSize:Math.round(f),computedSliderRatio:_,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=xd._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 i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},D1=class extends B_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new O_(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}},L1=class extends B_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new O_(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,o.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},M1=500,ig=50,T1=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},Cd=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,i=0,s=1,o=this._rear;do{let a=o===this._front?t:Math.pow(2,-s);if(t-=a,i+=this._memory[o].score*a,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(ph){let i=an(t.browserEvent),s=Kb(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let o=null,a=new T1(t,i,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,i){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),i){let o=Math.abs(t.deltaX),a=Math.abs(t.deltaY),u=Math.abs(i.deltaX),h=Math.abs(i.deltaY),m=Math.max(Math.min(o,u),1),f=Math.max(Math.min(a,h),1),_=Math.max(o,u),b=Math.max(a,h);_%m===0&&b%f===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Cd.INSTANCE=new Cd;var A1=Cd,I1=class extends _h{constructor(e,t,i){super(),this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new xe),this.onWillScroll=this._onWillScroll.event,this._options=O1(t),this._scrollable=i,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 L1(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new D1(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=vo(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=vo(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=vo(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,o=>this._onMouseOver(o)),this.onmouseleave(this._listenOnDomNode,o=>this._onMouseLeave(o)),this._hideTimeout=this._register(new gh),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=xr(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,cn&&(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 Xm(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=xr(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new Xm(i))};this._mouseWheelToDispose.push(Ke(this._listenOnDomNode,Ht.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=A1.INSTANCE;t.acceptStandardWheelEvent(e);let i=!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=!cn&&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 m=this._scrollable.getFutureScrollPosition(),f={};if(a){let _=ig*a,b=m.scrollTop-(_<0?Math.floor(_):Math.ceil(_));this._verticalScrollbar.writeScrollPosition(f,b)}if(u){let _=ig*u,b=m.scrollLeft-(_<0?Math.floor(_):Math.ceil(_));this._horizontalScrollbar.writeScrollPosition(f,b)}f=this._scrollable.validateScrollPosition(f),(m.scrollLeft!==f.scrollLeft||m.scrollTop!==f.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(f):this._scrollable.setScrollPositionNow(f),i=!0)}let s=i;!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,i=e.scrollLeft>0,s=i?" left":"",o=t?" top":"",a=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${o}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),M1)}},B1=class extends I1{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function O1(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,cn&&(t.className+=" mac"),t}var Ed=class extends Ze{constructor(e,t,i,s,o,a,u,h){super(),this._bufferService=i,this._optionsService=u,this._renderService=h,this._onRequestScrollLines=this._register(new xe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let m=this._register(new C1({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>vh(s.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{m.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new B1(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},m)),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(Jt.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(vt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(vt(()=>this._styleElement.remove())),this._register(Jt.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),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};Ed=Et([Re(2,di),Re(3,kn),Re(4,__),Re(5,ps),Re(6,hi),Re(7,xn)],Ed);var Nd=class extends Ze{constructor(e,t,i,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,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(vt(()=>{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 i=e.options.x??0;return i&&i>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 i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*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()}};Nd=Et([Re(1,di),Re(2,kn),Re(3,xo),Re(4,xn)],Nd);var z1=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,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},nn={full:0,left:0,center:0,right:0},Kn={full:0,left:0,center:0,right:0},to={full:0,left:0,center:0,right:0},ul=class extends Ze{constructor(e,t,i,s,o,a,u,h){var f;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=o,this._optionsService=a,this._themeService=u,this._coreBrowserService=h,this._colorZoneStore=new z1,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(vt(()=>{var _;return(_=this._canvas)==null?void 0:_.remove()}));let m=this._canvas.getContext("2d");if(m)this._ctx=m;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);Kn.full=this._canvas.width,Kn.left=e,Kn.center=t,Kn.right=e,this._refreshDrawHeightConstants(),to.full=1,to.left=1,to.center=1+Kn.left,to.right=1+Kn.left+Kn.center}_refreshDrawHeightConstants(){nn.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);nn.left=t,nn.center=t,nn.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nn.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nn.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nn.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nn.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(to[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-nn[e.position||"full"]/2),Kn[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+nn[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}))}};ul=Et([Re(2,di),Re(3,xo),Re(4,xn),Re(5,hi),Re(6,ps),Re(7,kn)],ul);var he;(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=""))(he||(he={}));var Ja;(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="Ÿ"))(Ja||(Ja={}));var z_;(e=>e.ST=`${he.ESC}\\`)(z_||(z_={}));var Rd=class{constructor(e,t,i,s,o,a){this._textarea=e,this._compositionView=t,this._bufferService=i,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 i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!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,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${he.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),i=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=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let 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)}}};Rd=Et([Re(2,di),Re(3,hi),Re(4,Nr),Re(5,xn)],Rd);var Wt=0,Ut=0,Kt=0,Ct=0,ng={css:"#00000000",rgba:0},Mt;(e=>{function t(o,a,u,h){return h!==void 0?`#${pr(o)}${pr(a)}${pr(u)}${pr(h)}`:`#${pr(o)}${pr(a)}${pr(u)}`}e.toCss=t;function i(o,a,u,h=255){return(o<<24|a<<16|u<<8|h)>>>0}e.toRgba=i;function s(o,a,u,h){return{css:e.toCss(o,a,u,h),rgba:e.toRgba(o,a,u,h)}}e.toColor=s})(Mt||(Mt={}));var mt;(e=>{function t(m,f){if(Ct=(f.rgba&255)/255,Ct===1)return{css:f.css,rgba:f.rgba};let _=f.rgba>>24&255,b=f.rgba>>16&255,w=f.rgba>>8&255,y=m.rgba>>24&255,S=m.rgba>>16&255,k=m.rgba>>8&255;Wt=y+Math.round((_-y)*Ct),Ut=S+Math.round((b-S)*Ct),Kt=k+Math.round((w-k)*Ct);let C=Mt.toCss(Wt,Ut,Kt),x=Mt.toRgba(Wt,Ut,Kt);return{css:C,rgba:x}}e.blend=t;function i(m){return(m.rgba&255)===255}e.isOpaque=i;function s(m,f,_){let b=Za.ensureContrastRatio(m.rgba,f.rgba,_);if(b)return Mt.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=s;function o(m){let f=(m.rgba|255)>>>0;return[Wt,Ut,Kt]=Za.toChannels(f),{css:Mt.toCss(Wt,Ut,Kt),rgba:f}}e.opaque=o;function a(m,f){return Ct=Math.round(f*255),[Wt,Ut,Kt]=Za.toChannels(m.rgba),{css:Mt.toCss(Wt,Ut,Kt,Ct),rgba:Mt.toRgba(Wt,Ut,Kt,Ct)}}e.opacity=a;function u(m,f){return Ct=m.rgba&255,a(m,Ct*f/255)}e.multiplyOpacity=u;function h(m){return[m.rgba>>24&255,m.rgba>>16&255,m.rgba>>8&255]}e.toColorRGB=h})(mt||(mt={}));var bt;(e=>{let t,i;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",i=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return Wt=parseInt(o.slice(1,2).repeat(2),16),Ut=parseInt(o.slice(2,3).repeat(2),16),Kt=parseInt(o.slice(3,4).repeat(2),16),Mt.toColor(Wt,Ut,Kt);case 5:return Wt=parseInt(o.slice(1,2).repeat(2),16),Ut=parseInt(o.slice(2,3).repeat(2),16),Kt=parseInt(o.slice(3,4).repeat(2),16),Ct=parseInt(o.slice(4,5).repeat(2),16),Mt.toColor(Wt,Ut,Kt,Ct);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 Wt=parseInt(a[1]),Ut=parseInt(a[2]),Kt=parseInt(a[3]),Ct=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),Mt.toColor(Wt,Ut,Kt,Ct);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Wt,Ut,Kt,Ct]=t.getImageData(0,0,1,1).data,Ct!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Mt.toRgba(Wt,Ut,Kt,Ct),css:o}}e.toColor=s})(bt||(bt={}));var ci;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,o,a){let u=s/255,h=o/255,m=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=m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4);return f*.2126+_*.7152+b*.0722}e.relativeLuminance2=i})(ci||(ci={}));var Za;(e=>{function t(u,h){if(Ct=(h&255)/255,Ct===1)return h;let m=h>>24&255,f=h>>16&255,_=h>>8&255,b=u>>24&255,w=u>>16&255,y=u>>8&255;return Wt=b+Math.round((m-b)*Ct),Ut=w+Math.round((f-w)*Ct),Kt=y+Math.round((_-y)*Ct),Mt.toRgba(Wt,Ut,Kt)}e.blend=t;function i(u,h,m){let f=ci.relativeLuminance(u>>8),_=ci.relativeLuminance(h>>8);if(Sn(f,_)<m){if(_<f){let y=s(u,h,m),S=Sn(f,ci.relativeLuminance(y>>8));if(S<m){let k=o(u,h,m),C=Sn(f,ci.relativeLuminance(k>>8));return S>C?y:k}return y}let b=o(u,h,m),w=Sn(f,ci.relativeLuminance(b>>8));if(w<m){let y=s(u,h,m),S=Sn(f,ci.relativeLuminance(y>>8));return w>S?b:y}return b}}e.ensureContrastRatio=i;function s(u,h,m){let f=u>>24&255,_=u>>16&255,b=u>>8&255,w=h>>24&255,y=h>>16&255,S=h>>8&255,k=Sn(ci.relativeLuminance2(w,y,S),ci.relativeLuminance2(f,_,b));for(;k<m&&(w>0||y>0||S>0);)w-=Math.max(0,Math.ceil(w*.1)),y-=Math.max(0,Math.ceil(y*.1)),S-=Math.max(0,Math.ceil(S*.1)),k=Sn(ci.relativeLuminance2(w,y,S),ci.relativeLuminance2(f,_,b));return(w<<24|y<<16|S<<8|255)>>>0}e.reduceLuminance=s;function o(u,h,m){let f=u>>24&255,_=u>>16&255,b=u>>8&255,w=h>>24&255,y=h>>16&255,S=h>>8&255,k=Sn(ci.relativeLuminance2(w,y,S),ci.relativeLuminance2(f,_,b));for(;k<m&&(w<255||y<255||S<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),y=Math.min(255,y+Math.ceil((255-y)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),k=Sn(ci.relativeLuminance2(w,y,S),ci.relativeLuminance2(f,_,b));return(w<<24|y<<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})(Za||(Za={}));function pr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Sn(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var F1=class extends ko{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},dl=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new $i}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 i=[],s=t.translateToString(!0),o=0,a=0,u=0,h=t.getFg(0),m=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!==m){if(f-o>1){let _=this._getJoinedRanges(s,u,a,t,o);for(let b=0;b<_.length;b++)i.push(_[b])}o=f,u=a,h=this._workCell.fg,m=this._workCell.bg}a+=this._workCell.getChars().length||Gn.length}if(this._bufferService.cols-o>1){let f=this._getJoinedRanges(s,u,a,t,o);for(let _=0;_<f.length;_++)i.push(f[_])}return i}_getJoinedRanges(e,t,i,s,o){let a=e.substring(t,i),u=[];try{u=this._characterJoiners[0].handler(a)}catch(h){console.error(h)}for(let h=1;h<this._characterJoiners.length;h++)try{let m=this._characterJoiners[h].handler(a);for(let f=0;f<m.length;f++)dl._mergeRanges(u,m[f])}catch(m){console.error(m)}return this._stringRangesToCellRanges(u,s,o),u}_stringRangesToCellRanges(e,t,i){let s=0,o=!1,a=0,u=e[s];if(u){for(let h=i;h<this._bufferService.cols;h++){let m=t.getWidth(h),f=t.getString(h).length||Gn.length;if(m!==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 i=!1;for(let s=0;s<e.length;s++){let o=e[s];if(i){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]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};dl=Et([Re(0,di)],dl);function $1(e){return 57508<=e&&e<=57558}function H1(e){return 9472<=e&&e<=9631}function W1(e){return $1(e)||H1(e)}function U1(){return{css:{canvas:Ha(),cell:Ha()},device:{canvas:Ha(),cell:Ha(),char:{width:0,height:0,left:0,top:0}}}}function Ha(){return{width:0,height:0}}var Pd=class{constructor(e,t,i,s,o,a,u){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=o,this._decorationService=a,this._themeService=u,this._workCell=new $i,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,o,a,u,h,m,f,_){let b=[],w=this._characterJoinerService.getJoinedCharacters(t),y=this._themeService.colors,S=e.getNoBgTrimmedLength();i&&S<a+1&&(S=a+1);let k,C=0,x="",R=0,D=0,T=0,ee=0,V=!1,W=0,te=!1,K=0,ie=0,Y=[],A=f!==-1&&_!==-1;for(let N=0;N<S;N++){e.loadCell(N,this._workCell);let j=this._workCell.getWidth();if(j===0)continue;let L=!1,$=N>=ie,U=N,B=this._workCell;if(w.length>0&&N===w[0][0]&&$){let Be=w.shift(),ot=this._isCellInSelection(Be[0],t);for(R=Be[0]+1;R<Be[1];R++)$&&($=ot===this._isCellInSelection(R,t));$&&($=!i||a<Be[0]||a>=Be[1]),$?(L=!0,B=new F1(this._workCell,e.translateToString(!0,Be[0],Be[1]),Be[1]-Be[0]),U=Be[1]-1,j=B.getWidth()):ie=Be[1]}let J=this._isCellInSelection(N,t),z=i&&N===a,M=A&&N>=f&&N<=_,I=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,Be=>{I=!0});let se=B.getChars()||Gn;if(se===" "&&(B.isUnderline()||B.isOverline())&&(se=" "),K=j*h-m.get(se,B.isBold(),B.isItalic()),!k)k=this._document.createElement("span");else if(C&&(J&&te||!J&&!te&&B.bg===D)&&(J&&te&&y.selectionForeground||B.fg===T)&&B.extended.ext===ee&&M===V&&K===W&&!z&&!L&&!I&&$){B.isInvisible()?x+=Gn:x+=se,C++;continue}else C&&(k.textContent=x),k=this._document.createElement("span"),C=0,x="";if(D=B.bg,T=B.fg,ee=B.extended.ext,V=M,W=K,te=J,L&&a>=N&&a<=U&&(a=N),!this._coreService.isCursorHidden&&z&&this._coreService.isCursorInitialized){if(Y.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&Y.push("xterm-cursor-blink"),Y.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":Y.push("xterm-cursor-outline");break;case"block":Y.push("xterm-cursor-block");break;case"bar":Y.push("xterm-cursor-bar");break;case"underline":Y.push("xterm-cursor-underline");break}}if(B.isBold()&&Y.push("xterm-bold"),B.isItalic()&&Y.push("xterm-italic"),B.isDim()&&Y.push("xterm-dim"),B.isInvisible()?x=Gn:x=B.getChars()||Gn,B.isUnderline()&&(Y.push(`xterm-underline-${B.extended.underlineStyle}`),x===" "&&(x=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())k.style.textDecorationColor=`rgb(${ko.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let Be=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&Be<8&&(Be+=8),k.style.textDecorationColor=y.ansi[Be].css}B.isOverline()&&(Y.push("xterm-overline"),x===" "&&(x=" ")),B.isStrikethrough()&&Y.push("xterm-strikethrough"),M&&(k.style.textDecoration="underline");let ge=B.getFgColor(),de=B.getFgColorMode(),fe=B.getBgColor(),X=B.getBgColorMode(),Z=!!B.isInverse();if(Z){let Be=ge;ge=fe,fe=Be;let ot=de;de=X,X=ot}let ye,Ee,tt=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,Be=>{Be.options.layer!=="top"&&tt||(Be.backgroundColorRGB&&(X=50331648,fe=Be.backgroundColorRGB.rgba>>8&16777215,ye=Be.backgroundColorRGB),Be.foregroundColorRGB&&(de=50331648,ge=Be.foregroundColorRGB.rgba>>8&16777215,Ee=Be.foregroundColorRGB),tt=Be.options.layer==="top")}),!tt&&J&&(ye=this._coreBrowserService.isFocused?y.selectionBackgroundOpaque:y.selectionInactiveBackgroundOpaque,fe=ye.rgba>>8&16777215,X=50331648,tt=!0,y.selectionForeground&&(de=50331648,ge=y.selectionForeground.rgba>>8&16777215,Ee=y.selectionForeground)),tt&&Y.push("xterm-decoration-top");let Ye;switch(X){case 16777216:case 33554432:Ye=y.ansi[fe],Y.push(`xterm-bg-${fe}`);break;case 50331648:Ye=Mt.toColor(fe>>16,fe>>8&255,fe&255),this._addStyle(k,`background-color:#${rg((fe>>>0).toString(16),"0",6)}`);break;case 0:default:Z?(Ye=y.foreground,Y.push("xterm-bg-257")):Ye=y.background}switch(ye||B.isDim()&&(ye=mt.multiplyOpacity(Ye,.5)),de){case 16777216:case 33554432:B.isBold()&&ge<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ge+=8),this._applyMinimumContrast(k,Ye,y.ansi[ge],B,ye,void 0)||Y.push(`xterm-fg-${ge}`);break;case 50331648:let Be=Mt.toColor(ge>>16&255,ge>>8&255,ge&255);this._applyMinimumContrast(k,Ye,Be,B,ye,Ee)||this._addStyle(k,`color:#${rg(ge.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(k,Ye,y.foreground,B,ye,Ee)||Z&&Y.push("xterm-fg-257")}Y.length&&(k.className=Y.join(" "),Y.length=0),!z&&!L&&!I&&$?C++:k.textContent=x,K!==this.defaultSpacing&&(k.style.letterSpacing=`${K}px`),b.push(k),N=U}return k&&C&&(k.textContent=x),b}_applyMinimumContrast(e,t,i,s,o,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||W1(s.getCode()))return!1;let u=this._getContrastCache(s),h;if(!o&&!a&&(h=u.getColor(t.rgba,i.rgba)),h===void 0){let m=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);h=mt.ensureContrastRatio(o||t,a||i,m),u.setColor((o||t).rgba,(a||i).rgba,h??null)}return h?(this._addStyle(e,`color:${h.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};Pd=Et([Re(1,w_),Re(2,hi),Re(3,kn),Re(4,Nr),Re(5,xo),Re(6,ps)],Pd);function rg(e,t,i){for(;e.length<i;)e=t+e;return e}var K1=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 i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let 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=[i,s,o,a],this._container.appendChild(i),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,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&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"),i&&(o+="I");let a=this._holey.get(o);if(a===void 0){let u=0;t&&(u|=1),i&&(u|=2),a=this._measure(e,u),a>0&&this._holey.set(o,a)}return a}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},q1=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,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let o=e.buffers.active.ydisp,a=t[1]-o,u=i[1]-o,h=Math.max(a,0),m=Math.min(u,e.rows-1);if(h>=e.rows||m<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=a,this.viewportEndRow=u,this.viewportCappedStartRow=h,this.viewportCappedEndRow=m,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function V1(){return new q1}var vu="xterm-dom-renderer-owner-",Oi="xterm-rows",Wa="xterm-fg-",sg="xterm-bg-",io="xterm-focus",Ua="xterm-selection",Y1=1,jd=class extends Ze{constructor(e,t,i,s,o,a,u,h,m,f,_,b,w,y){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=o,this._helperContainer=a,this._linkifier2=u,this._charSizeService=m,this._optionsService=f,this._bufferService=_,this._coreService=b,this._coreBrowserService=w,this._themeService=y,this._terminalClass=Y1++,this._rowElements=[],this._selectionRenderModel=V1(),this.onRequestRedraw=this._register(new xe).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Oi),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(Ua),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=U1(),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(Pd,document),this._element.classList.add(vu+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(vt(()=>{this._element.classList.remove(vu+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new K1(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Oi} 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} .${Oi} { 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} .${Oi} .xterm-dim { color: ${mt.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 i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 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} .${Oi}.${io} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Oi}.${io} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Oi}.${io} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Oi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Oi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Oi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Oi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Oi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ua} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ua} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ua} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[a,u]of e.ansi.entries())t+=`${this._terminalSelector} .${Wa}${a} { color: ${u.css}; }${this._terminalSelector} .${Wa}${a}.xterm-dim { color: ${mt.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${sg}${a} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${Wa}257 { color: ${mt.opaque(e.background).css}; }${this._terminalSelector} .${Wa}257.xterm-dim { color: ${mt.multiplyOpacity(mt.opaque(e.background),.5).css}; }${this._terminalSelector} .${sg}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 i=this._rowElements.length;i<=t;i++){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(io),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(io),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!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(i){let m=e[0]>t[0];h.appendChild(this._createSelectionElement(a,m?t[0]:e[0],m?e[0]:t[0],u-a+1))}else{let m=s===a?e[0]:0,f=a===o?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(a,m,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,i,s=1){let o=this._document.createElement("div"),a=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(i-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 i=this._bufferService.buffer,s=i.ybase+i.y,o=Math.min(i.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 m=e;m<=t;m++){let f=m+i.ydisp,_=this._rowElements[m],b=i.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`.${vu}${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,i,s,o,a){i<0&&(e=0),s<0&&(t=0);let u=this._bufferService.rows-1;i=Math.max(Math.min(i,u),0),s=Math.max(Math.min(s,u),0),o=Math.min(o,this._bufferService.cols);let h=this._bufferService.buffer,m=h.ybase+h.y,f=Math.min(h.x,o-1),_=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,w=this._optionsService.rawOptions.cursorInactiveStyle;for(let y=i;y<=s;++y){let S=y+h.ydisp,k=this._rowElements[y],C=h.lines.get(S);if(!k||!C)break;k.replaceChildren(...this._rowFactory.createRow(C,S,S===m,b,w,f,_,this.dimensions.css.cell.width,this._widthCache,a?y===i?e:0:-1,a?(y===s?t:o)-1:-1))}}};jd=Et([Re(7,dh),Re(8,yl),Re(9,hi),Re(10,di),Re(11,Nr),Re(12,kn),Re(13,ps)],jd);var Dd=class extends Ze{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new xe),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new G1(this._optionsService))}catch{this._measureStrategy=this._register(new X1(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())}};Dd=Et([Re(2,hi)],Dd);var F_=class extends Ze{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)}},X1=class extends F_{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,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}},G1=class extends F_{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}},Q1=class extends Ze{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new J1(this._window)),this._onDprChange=this._register(new xe),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new xe),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Jt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ke(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ke(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}},J1=class extends Ze{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ds),this._onDprChange=this._register(new xe),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(vt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ke(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)}},Z1=class extends Ze{constructor(){super(),this.linkProviders=[],this._register(vt(()=>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 yh(e,t,i){let s=i.getBoundingClientRect(),o=e.getComputedStyle(i),a=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-a,t.clientY-s.top-u]}function ek(e,t,i,s,o,a,u,h,m){if(!a)return;let f=yh(e,t,i);if(f)return f[0]=Math.ceil((f[0]+(m?u/2:0))/u),f[1]=Math.ceil(f[1]/h),f[0]=Math.min(Math.max(f[0],1),s+(m?1:0)),f[1]=Math.min(Math.max(f[1],1),o),f}var Ld=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,o){return ek(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let i=yh(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Ld=Et([Re(0,xn),Re(1,yl)],Ld);var tk=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,i){this._rowCount=i,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=[]}},$_={};db($_,{getSafariVersion:()=>nk,isChromeOS:()=>K_,isFirefox:()=>H_,isIpad:()=>rk,isIphone:()=>sk,isLegacyEdge:()=>ik,isLinux:()=>Sh,isMac:()=>hl,isNode:()=>Sl,isSafari:()=>W_,isWindows:()=>U_});var Sl=typeof process<"u"&&"title"in process,Co=Sl?"node":navigator.userAgent,Eo=Sl?"node":navigator.platform,H_=Co.includes("Firefox"),ik=Co.includes("Edge"),W_=/^((?!chrome|android).)*safari/i.test(Co);function nk(){if(!W_)return 0;let e=Co.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var hl=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Eo),rk=Eo==="iPad",sk=Eo==="iPhone",U_=["Windows","Win16","Win32","WinCE"].includes(Eo),Sh=Eo.indexOf("Linux")>=0,K_=/\bCrOS\b/.test(Co),q_=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,i=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),i=Math.max(t,i),o=e.timeRemaining(),i*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()}},ok=class extends q_{_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())}}},ak=class extends q_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},fl=!Sl&&"requestIdleCallback"in window?ak:ok,lk=class{constructor(){this._queue=new fl}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Md=class extends Ze{constructor(e,t,i,s,o,a,u,h,m){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=o,this._coreBrowserService=h,this._renderer=this._register(new ds),this._pausedResizeTask=new lk,this._observerDisposable=this._register(new ds),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 xe),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new xe),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new xe),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new xe),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new tk((f,_)=>this._renderRows(f,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new ck(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(vt(()=>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(m.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 i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=vt(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!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)),i||(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 i;return(i=this._renderer.value)==null?void 0:i.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,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Md=Et([Re(2,hi),Re(3,yl),Re(4,Nr),Re(5,xo),Re(6,di),Re(7,kn),Re(8,ps)],Md);var ck=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,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 uk(e,t,i,s){let o=i.buffer.x,a=i.buffer.y;if(!i.buffer.hasScrollback)return fk(o,a,e,t,i,s)+wl(a,t,i,s)+pk(o,a,e,t,i,s);let u;if(a===t)return u=o>e?"D":"C",yo(Math.abs(o-e),_o(u,s));u=a>t?"D":"C";let h=Math.abs(a-t),m=hk(a>t?e:o,i)+(h-1)*i.cols+1+dk(a>t?o:e);return yo(m,_o(u,s))}function dk(e,t){return e-1}function hk(e,t){return t.cols-e}function fk(e,t,i,s,o,a){return wl(t,s,o,a).length===0?"":yo(Y_(e,t,e,t-Cr(t,o),!1,o).length,_o("D",a))}function wl(e,t,i,s){let o=e-Cr(e,i),a=t-Cr(t,i),u=Math.abs(o-a)-mk(e,t,i);return yo(u,_o(V_(e,t),s))}function pk(e,t,i,s,o,a){let u;wl(t,s,o,a).length>0?u=s-Cr(s,o):u=t;let h=s,m=gk(e,t,i,s,o,a);return yo(Y_(e,u,i,h,m==="C",o).length,_o(m,a))}function mk(e,t,i){var u;let s=0,o=e-Cr(e,i),a=t-Cr(t,i);for(let h=0;h<Math.abs(o-a);h++){let m=V_(e,t)==="A"?-1:1;(u=i.buffer.lines.get(o+m*h))!=null&&u.isWrapped&&s++}return s}function Cr(e,t){let i=0,s=t.buffer.lines.get(e),o=s==null?void 0:s.isWrapped;for(;o&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),o=s==null?void 0:s.isWrapped;return i}function gk(e,t,i,s,o,a){let u;return wl(i,s,o,a).length>0?u=s-Cr(s,o):u=t,e<i&&u<=s||e>=i&&u<s?"C":"D"}function V_(e,t){return e>t?"A":"B"}function Y_(e,t,i,s,o,a){let u=e,h=t,m="";for(;(u!==i||h!==s)&&h>=0&&h<a.buffer.lines.length;)u+=o?1:-1,o&&u>a.cols-1?(m+=a.buffer.translateBufferLineToString(h,!1,e,u),u=0,e=0,h++):!o&&u<0&&(m+=a.buffer.translateBufferLineToString(h,!1,0,e+1),u=a.cols-1,e=u,h--);return m+a.buffer.translateBufferLineToString(h,!1,e,u)}function _o(e,t){let i=t?"O":"[";return he.ESC+i+e}function yo(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var vk=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 og(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 _u=50,_k=15,yk=50,Sk=500,wk=" ",bk=new RegExp(wk,"g"),Td=class extends Ze{constructor(e,t,i,s,o,a,u,h,m){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=o,this._mouseService=a,this._optionsService=u,this._renderService=h,this._coreBrowserService=m,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new $i,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new xe),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new xe),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new xe),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new xe),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 vk(this._bufferService),this._activeSelectionMode=0,this._register(vt(()=>{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 i=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=i.translateBufferLineToString(u,!0,o,a);s.push(h)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],o));for(let a=e[1]+1;a<=t[1]-1;a++){let u=i.lines.get(a),h=i.translateBufferLineToString(a,!0);u!=null&&u.isWrapped?s[s.length-1]+=h:s.push(h)}if(e[1]!==t[1]){let a=i.lines.get(t[1]),u=i.translateBufferLineToString(t[1],!0,0,t[0]);a&&a.isWrapped?s[s.length-1]+=u:s.push(u)}}return s.map(o=>o.replace(bk," ")).join(U_?`\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())),Sh&&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),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var o,a;let i=(a=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:a.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=og(i,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=yh(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-_u),_u),t/=_u,t/Math.abs(t)+Math.round(t*(_k-1)))}shouldForceSelection(e){return hl?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(),yk)}_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&&!(hl&&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 i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!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<Sk&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=uk(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);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,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:o>1&&t!==s&&(i+=o-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!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]),m=h,f=e[0]-h,_=0,b=0,w=0,y=0;if(u.charAt(h)===" "){for(;h>0&&u.charAt(h-1)===" ";)h--;for(;m<u.length&&u.charAt(m+1)===" ";)m++}else{let C=e[0],x=e[0];a.getWidth(C)===0&&(_++,C--),a.getWidth(x)===2&&(b++,x++);let R=a.getString(x).length;for(R>1&&(y+=R-1,m+=R-1);C>0&&h>0&&!this._isCharWordSeparator(a.loadCell(C-1,this._workCell));){a.loadCell(C-1,this._workCell);let D=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,C--):D>1&&(w+=D-1,h-=D-1),h--,C--}for(;x<a.length&&m+1<u.length&&!this._isCharWordSeparator(a.loadCell(x+1,this._workCell));){a.loadCell(x+1,this._workCell);let D=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,x++):D>1&&(y+=D-1,m+=D-1),m++,x++}}m++;let S=h+f-_+w,k=Math.min(this._bufferService.cols,m-h+_+b-w-y);if(!(!t&&u.slice(h,m).trim()==="")){if(i&&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 x=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(x){let R=this._bufferService.cols-x.start;S-=R,k+=R}}}if(s&&S+k===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let C=o.lines.get(e[1]+1);if(C!=null&&C.isWrapped&&C.getCodePoint(0)!==32){let x=this._getWordAt([0,e[1]+1],!1,!1,!0);x&&(k+=x.length)}}return{start:S,length:k}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={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=og(i,this._bufferService.cols)}};Td=Et([Re(3,di),Re(4,Nr),Re(5,hh),Re(6,hi),Re(7,xn),Re(8,kn)],Td);var ag=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},lg=class{constructor(){this._color=new ag,this._css=new ag}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},It=Object.freeze((()=>{let e=[bt.toColor("#2e3436"),bt.toColor("#cc0000"),bt.toColor("#4e9a06"),bt.toColor("#c4a000"),bt.toColor("#3465a4"),bt.toColor("#75507b"),bt.toColor("#06989a"),bt.toColor("#d3d7cf"),bt.toColor("#555753"),bt.toColor("#ef2929"),bt.toColor("#8ae234"),bt.toColor("#fce94f"),bt.toColor("#729fcf"),bt.toColor("#ad7fa8"),bt.toColor("#34e2e2"),bt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],o=t[i/6%6|0],a=t[i%6];e.push({css:Mt.toCss(s,o,a),rgba:Mt.toRgba(s,o,a)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:Mt.toCss(s,s,s),rgba:Mt.toRgba(s,s,s)})}return e})()),gr=bt.toColor("#ffffff"),fo=bt.toColor("#000000"),cg=bt.toColor("#ffffff"),ug=fo,no={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},kk=gr,Ad=class extends Ze{constructor(e){super(),this._optionsService=e,this._contrastCache=new lg,this._halfContrastCache=new lg,this._onChangeColors=this._register(new xe),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:gr,background:fo,cursor:cg,cursorAccent:ug,selectionForeground:void 0,selectionBackgroundTransparent:no,selectionBackgroundOpaque:mt.blend(fo,no),selectionInactiveBackgroundTransparent:no,selectionInactiveBackgroundOpaque:mt.blend(fo,no),scrollbarSliderBackground:mt.opacity(gr,.2),scrollbarSliderHoverBackground:mt.opacity(gr,.4),scrollbarSliderActiveBackground:mt.opacity(gr,.5),overviewRulerBorder:gr,ansi:It.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=ct(e.foreground,gr),t.background=ct(e.background,fo),t.cursor=mt.blend(t.background,ct(e.cursor,cg)),t.cursorAccent=mt.blend(t.background,ct(e.cursorAccent,ug)),t.selectionBackgroundTransparent=ct(e.selectionBackground,no),t.selectionBackgroundOpaque=mt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=ct(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=mt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?ct(e.selectionForeground,ng):void 0,t.selectionForeground===ng&&(t.selectionForeground=void 0),mt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=mt.opacity(t.selectionBackgroundTransparent,.3)),mt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=mt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=ct(e.scrollbarSliderBackground,mt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=ct(e.scrollbarSliderHoverBackground,mt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=ct(e.scrollbarSliderActiveBackground,mt.opacity(t.foreground,.5)),t.overviewRulerBorder=ct(e.overviewRulerBorder,kk),t.ansi=It.slice(),t.ansi[0]=ct(e.black,It[0]),t.ansi[1]=ct(e.red,It[1]),t.ansi[2]=ct(e.green,It[2]),t.ansi[3]=ct(e.yellow,It[3]),t.ansi[4]=ct(e.blue,It[4]),t.ansi[5]=ct(e.magenta,It[5]),t.ansi[6]=ct(e.cyan,It[6]),t.ansi[7]=ct(e.white,It[7]),t.ansi[8]=ct(e.brightBlack,It[8]),t.ansi[9]=ct(e.brightRed,It[9]),t.ansi[10]=ct(e.brightGreen,It[10]),t.ansi[11]=ct(e.brightYellow,It[11]),t.ansi[12]=ct(e.brightBlue,It[12]),t.ansi[13]=ct(e.brightMagenta,It[13]),t.ansi[14]=ct(e.brightCyan,It[14]),t.ansi[15]=ct(e.brightWhite,It[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=ct(e.extendedAnsi[s],It[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()}}};Ad=Et([Re(0,hi)],Ad);function ct(e,t){if(e!==void 0)try{return bt.toColor(e)}catch{}return t}var xk=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Ck=class{constructor(){this._services=new xk,this._services.set(dh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=_b(e).sort((a,u)=>a.index-u.index),s=[];for(let a of i){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=i.length>0?i[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)}},Ek={trace:0,debug:1,info:2,warn:3,error:4,off:5},Nk="xterm.js: ",Id=class extends Ze{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=Ek[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,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":Nk)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Id=Et([Re(0,hi)],Id);var dg=class extends Ze{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new xe),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new xe),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new xe),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 i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];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,...i){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+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let o=t-1;o>=0;o--)this.set(e+o+i,this.get(e+o));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Je=3,Lt=Object.freeze(new ko),Ka=0,yu=2,po=class X_{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Je);let o=i||$i.fromCharData([0,p_,1,0]);for(let a=0;a<t;++a)this.setCell(a,o);this.length=t}get(t){let i=this._data[t*Je+0],s=i&2097151;return[this._data[t*Je+1],i&2097152?this._combined[t]:s?Yn(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*Je+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*Je+0]=t|2097152|i[2]<<22):this._data[t*Je+0]=i[1].charCodeAt(0)|i[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 i=this._data[t*Je+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*Je+0]&2097152}getString(t){let i=this._data[t*Je+0];return i&2097152?this._combined[t]:i&2097151?Yn(i&2097151):""}isProtected(t){return this._data[t*Je+2]&536870912}loadCell(t,i){return Ka=t*Je,i.content=this._data[Ka+0],i.fg=this._data[Ka+1],i.bg=this._data[Ka+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*Je+0]=i.content,this._data[t*Je+1]=i.fg,this._data[t*Je+2]=i.bg}setCellFromCodepoint(t,i,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*Je+0]=i|s<<22,this._data[t*Je+1]=o.fg,this._data[t*Je+2]=o.bg}addCodepointToCell(t,i,s){let o=this._data[t*Je+0];o&2097152?this._combined[t]+=Yn(i):o&2097151?(this._combined[t]=Yn(o&2097151)+Yn(i),o&=-2097152,o|=2097152):o=i|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*Je+0]=o}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let o=new $i;for(let a=this.length-t-i-1;a>=0;--a)this.setCell(t+i+a,this.loadCell(t+a,o));for(let a=0;a<i;++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,i,s){if(t%=this.length,i<this.length-t){let o=new $i;for(let a=0;a<this.length-t-i;++a)this.setCell(t+a,this.loadCell(t+i+a,o));for(let a=this.length-i;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,i,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&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),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*yu<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,i)}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*yu<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*yu<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){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 i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new X_(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];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,i,s,o,a){let u=t._data;if(a)for(let m=o-1;m>=0;m--){for(let f=0;f<Je;f++)this._data[(s+m)*Je+f]=u[(i+m)*Je+f];u[(i+m)*Je+2]&268435456&&(this._extendedAttrs[s+m]=t._extendedAttrs[i+m])}else for(let m=0;m<o;m++){for(let f=0;f<Je;f++)this._data[(s+m)*Je+f]=u[(i+m)*Je+f];u[(i+m)*Je+2]&268435456&&(this._extendedAttrs[s+m]=t._extendedAttrs[i+m])}let h=Object.keys(t._combined);for(let m=0;m<h.length;m++){let f=parseInt(h[m],10);f>=i&&(this._combined[f-i+s]=t._combined[f])}}translateToString(t,i,s,o){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let a="";for(;i<s;){let u=this._data[i*Je+0],h=u&2097151,m=u&2097152?this._combined[i]:h?Yn(h):Gn;if(a+=m,o)for(let f=0;f<m.length;++f)o.push(i);i+=u>>22||1}return o&&o.push(i),a}};function Rk(e,t,i,s,o,a){let u=[];for(let h=0;h<e.length-1;h++){let m=h,f=e.get(++m);if(!f.isWrapped)continue;let _=[e.get(h)];for(;m<e.length&&f.isWrapped;)_.push(f),f=e.get(++m);if(!a&&s>=h&&s<m){h+=_.length-1;continue}let b=0,w=So(_,b,t),y=1,S=0;for(;y<_.length;){let C=So(_,y,t),x=C-S,R=i-w,D=Math.min(x,R);_[b].copyCellsFrom(_[y],S,w,D,!1),w+=D,w===i&&(b++,w=0),S+=D,S===C&&(y++,S=0),w===0&&b!==0&&_[b-1].getWidth(i-1)===2&&(_[b].copyCellsFrom(_[b-1],i-1,w++,1,!1),_[b-1].setCell(i-1,o))}_[b].replaceCells(w,i,o);let k=0;for(let C=_.length-1;C>0&&(C>b||_[C].getTrimmedLength()===0);C--)k++;k>0&&(u.push(h+_.length-k),u.push(k)),h+=_.length-1}return u}function Pk(e,t){let i=[],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 i.push(u);return{layout:i,countRemoved:a}}function jk(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function Dk(e,t,i){let s=[],o=e.map((m,f)=>So(e,f,t)).reduce((m,f)=>m+f),a=0,u=0,h=0;for(;h<o;){if(o-h<i){s.push(o-h);break}a+=i;let m=So(e,u,t);a>m&&(a-=m,u++);let f=e[u].getWidth(a-1)===2;f&&a--;let _=f?i-1:i;s.push(_),h+=_}return s}function So(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?i-1:i}var G_=class Q_{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Q_._nextId++,this._onDispose=this.register(new xe),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),xr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};G_._nextId=1;var Lk=G_,Ot={},vr=Ot.B;Ot[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ot.A={"#":"£"};Ot.B=void 0;Ot[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ot.C=Ot[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ot.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ot.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ot.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ot.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ot.E=Ot[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ot.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ot.H=Ot[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ot["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var hg=4294967295,fg=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Lt.clone(),this.savedCharset=vr,this.markers=[],this._nullCell=$i.fromCharData([0,p_,1,0]),this._whitespaceCell=$i.fromCharData([0,Gn,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new fl,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new dg(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 cl),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 cl),this._whitespaceCell}getBlankLine(e,t){return new po(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>hg?hg:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Lt);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 dg(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(Lt),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,i);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 po(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new po(e,i)));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,i);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 i=this._optionsService.rawOptions.reflowCursorLine,s=Rk(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Lt),i);if(s.length>0){let o=Pk(this.lines,s);jk(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(Lt),o=i;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new po(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Lt),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 m=[h];for(;h.isWrapped&&u>0;)h=this.lines.get(--u),m.unshift(h);if(!i){let D=this.ybase+this.y;if(D>=u&&D<u+m.length)continue}let f=m[m.length-1].getTrimmedLength(),_=Dk(m,this._cols,e),b=_.length-m.length,w;this.ybase===0&&this.y!==this.lines.length-1?w=Math.max(0,this.y-this.lines.maxLength+b):w=Math.max(0,this.lines.length-this.lines.maxLength+b);let y=[];for(let D=0;D<b;D++){let T=this.getBlankLine(Lt,!0);y.push(T)}y.length>0&&(o.push({start:u+m.length+a,newLines:y}),a+=y.length),m.push(...y);let S=_.length-1,k=_[S];k===0&&(S--,k=_[S]);let C=m.length-b-1,x=f;for(;C>=0;){let D=Math.min(x,k);if(m[S]===void 0)break;if(m[S].copyCellsFrom(m[C],x-D,k-D,D,!0),k-=D,k===0&&(S--,k=_[S]),x-=D,x===0){C--;let T=Math.max(C,0);x=So(m,T,this._cols)}}for(let D=0;D<m.length;D++)_[D]<e&&m[D].setCell(_[D],s);let R=b-w;for(;R-- >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 k=0;k<this.lines.length;k++)h.push(this.lines.get(k));let m=this.lines.length,f=m-1,_=0,b=o[_];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let w=0;for(let k=Math.min(this.lines.maxLength-1,m+a-1);k>=0;k--)if(b&&b.start>f+w){for(let C=b.newLines.length-1;C>=0;C--)this.lines.set(k--,b.newLines[C]);k++,u.push({index:f+1,amount:b.newLines.length}),w+=b.newLines.length,b=o[++_]}else this.lines.set(k,h[f--]);let y=0;for(let k=u.length-1;k>=0;k--)u[k].index+=y,this.lines.onInsertEmitter.fire(u[k]),y+=u[k].amount;let S=Math.max(0,m+a-this.lines.maxLength);S>0&&this.lines.onTrimEmitter.fire(S)}}translateBufferLineToString(e,t,i=0,s){let o=this.lines.get(e);return o?o.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}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 Lk(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Mk=class extends Ze{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new xe),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 fg(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new fg(!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)}},J_=2,Z_=1,Bd=class extends Ze{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new xe),this.onResize=this._onResize.event,this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,J_),this.rows=Math.max(e.rawOptions.rows||0,Z_),this.buffers=this._register(new Mk(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=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:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=i.ybase+i.scrollTop,a=i.ybase+i.scrollBottom;if(i.scrollTop===0){let u=i.lines.isFull;a===i.lines.length-1?u?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(a+1,0,s.clone()),u?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let u=a-o+1;i.lines.shiftElements(o+1,u-1,-1),i.lines.set(a,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};Bd=Et([Re(0,hi)],Bd);var es={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:hl,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Tk=["normal","bold","100","200","300","400","500","600","700","800","900"],Ak=class extends Ze{constructor(e){super(),this._onOptionChange=this._register(new xe),this.onOptionChange=this._onOptionChange.event;let t={...es};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(vt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in es))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in es))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=es[e]),!Ik(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=es[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Tk.includes(t)?t:es[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 Ik(e){return e==="block"||e==="underline"||e==="bar"}function mo(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&mo(e[s],t-1);return i}var pg=Object.freeze({insertMode:!1}),mg=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Od=class extends Ze{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new xe),this.onData=this._onData.event,this._onUserInput=this._register(new xe),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new xe),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new xe),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=mo(pg),this.decPrivateModes=mo(mg)}reset(){this.modes=mo(pg),this.decPrivateModes=mo(mg)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.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))}};Od=Et([Re(0,di),Re(1,y_),Re(2,hi)],Od);var gg={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 Su(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var wu=String.fromCharCode,vg={DEFAULT:e=>{let t=[Su(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${wu(t[0])}${wu(t[1])}${wu(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Su(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Su(e,!0)};${e.x};${e.y}${t}`}},zd=class extends Ze{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new xe),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(gg))this.addProtocol(s,gg[s]);for(let s of Object.keys(vg))this.addEncoding(s,vg[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,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,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,i){if(i){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)}};zd=Et([Re(0,di),Re(1,Nr),Re(2,hi)],zd);var bu=[[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]],Bk=[[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]],Bt;function Ok(e,t){let i=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(o=i+s>>1,e>t[o][1])i=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var zk=class{constructor(){if(this.version="6",!Bt){Bt=new Uint8Array(65536),Bt.fill(1),Bt[0]=0,Bt.fill(0,1,32),Bt.fill(0,127,160),Bt.fill(2,4352,4448),Bt[9001]=2,Bt[9002]=2,Bt.fill(2,11904,42192),Bt[12351]=1,Bt.fill(2,44032,55204),Bt.fill(2,63744,64256),Bt.fill(2,65040,65050),Bt.fill(2,65072,65136),Bt.fill(2,65280,65377),Bt.fill(2,65504,65511);for(let e=0;e<bu.length;++e)Bt.fill(0,bu[e][0],bu[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Bt[e]:Ok(e,Bk)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let o=Sr.extractWidth(t);o===0?s=!1:o>i&&(i=o)}return Sr.createPropertyValue(0,i,s)}},Sr=class el{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new xe,this.onChange=this._onChange.event;let t=new zk;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,i,s=!1){return(t&16777215)<<3|(i&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 i=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 i+this.wcwidth(u);let f=t.charCodeAt(a);56320<=f&&f<=57343?u=(u-55296)*1024+f-56320+65536:i+=this.wcwidth(f)}let h=this.charProperties(u,s),m=el.extractWidth(h);el.extractShouldJoin(h)&&(m-=el.extractWidth(s)),i+=m,s=h}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},Fk=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),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var ro=2147483647,$k=256,ey=class Fd{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>$k)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new Fd;if(!t.length)return i;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)i.addSubParam(o[a]);else i.addParam(o)}return i}clone(){let t=new Fd(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 i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,o=this._subParamsIdx[i]&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>ro?ro: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>ro?ro:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,o=this._subParamsIdx[i]&255;o-s>0&&(t[i]=this._subParams.slice(s,o))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[i-1];s[i-1]=~o?Math.min(o*10+t,ro):t}},so=[],Hk=class{constructor(){this._state=0,this._active=so,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 i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=so}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=so,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||so,!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,i){if(!this._active.length)this._handlerFb(this._id,"PUT",_l(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){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&&i-t>0&&this._put(e,t,i)}}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 i=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=so,this._id=-1,this._state=0}}},Ni=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=_l(e,t,i),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(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},oo=[],Wk=class{constructor(){this._handlers=Object.create(null),this._active=oo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=oo}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=oo,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||oo,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",_l(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=oo,this._ident=0}},go=new ey;go.addParam(0);var yg=class{constructor(e){this._handler=e,this._data="",this._params=go,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():go,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=_l(e,t,i),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(i=>(this._params=go,this._data="",this._hitLimit=!1,i));return this._params=go,this._data="",this._hitLimit=!1,t}},Uk=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=i<<4|s}},Fi=160,Kk=(function(){let e=new Uk(4095),t=Array.apply(null,Array(256)).map((h,m)=>m),i=(h,m)=>t.slice(h,m),s=i(32,127),o=i(0,24);o.push(25),o.push.apply(o,i(28,32));let a=i(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(i(128,144),u,3,0),e.addMany(i(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(i(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(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(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(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(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(Fi,0,2,0),e.add(Fi,8,5,8),e.add(Fi,6,0,6),e.add(Fi,11,0,11),e.add(Fi,13,13,13),e})(),qk=class extends Ze{constructor(e=Kk){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 ey,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},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(vt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Hk),this._dcsParser=this._register(new Wk),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let 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");i<<=8,i|=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 i<<=8,i|=s,i}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 i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];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 i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];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,i,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,i){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(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let h=this._parseStack.handlers,m=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&m>-1){for(;m>=0&&(u=h[m](this._params),u!==!0);m--)if(u instanceof Promise)return this._parseStack.handlerPos=m,u}this._parseStack.handlers=[];break;case 4:if(i===!1&&m>-1){for(;m>=0&&(u=h[m](),u!==!0);m--)if(u instanceof Promise)return this._parseStack.handlerPos=m,u}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(s!==24&&s!==26,i),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,i),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:Fi)],o>>4){case 2:for(let w=h+1;;++w){if(w>=t||(s=e[w])<32||s>126&&s<Fi){this._printHandler(e,h,w),h=w-1;break}if(++w>=t||(s=e[w])<32||s>126&&s<Fi){this._printHandler(e,h,w),h=w-1;break}if(++w>=t||(s=e[w])<32||s>126&&s<Fi){this._printHandler(e,h,w),h=w-1;break}if(++w>=t||(s=e[w])<32||s>126&&s<Fi){this._printHandler(e,h,w),h=w-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:h,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let m=this._csiHandlers[this._collect<<8|s],f=m?m.length-1:-1;for(;f>=0&&(u=m[f](this._params),u!==!0);f--)if(u instanceof Promise)return this._preserveStack(3,m,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 w=h+1;;++w)if(w>=t||(s=e[w])===24||s===26||s===27||s>127&&s<Fi){this._dcsParser.put(e,h,w),h=w-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 w=h+1;;w++)if(w>=t||(s=e[w])<32||s>127&&s<Fi){this._oscParser.put(e,h,w),h=w-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}}},Vk=/^([\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})$/,Yk=/^[\da-f]+$/;function Sg(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=Vk.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),Yk.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let a=parseInt(t.slice(i*o,i*o+i),16);s[o]=i===1?a<<4:i===2?a:i===3?a>>4:a>>8}return s}}function ku(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function Xk(e,t=16){let[i,s,o]=e;return`rgb:${ku(i,t)}/${ku(s,t)}/${ku(o,t)}`}var Gk={"(":0,")":1,"*":2,"+":3,"-":1,".":2},qn=131072,wg=10;function bg(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 kg=5e3,xg=0,Qk=class extends Ze{constructor(e,t,i,s,o,a,u,h,m=new qk){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=o,this._oscLinkService=a,this._coreMouseService=u,this._unicodeService=h,this._parser=m,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new gb,this._utf8Decoder=new vb,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Lt.clone(),this._eraseAttrDataInternal=Lt.clone(),this._onRequestBell=this._register(new xe),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new xe),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new xe),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new xe),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new xe),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new xe),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new xe),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new xe),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new xe),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new xe),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new xe),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new xe),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 $d(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(he.BEL,()=>this.bell()),this._parser.setExecuteHandler(he.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(he.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(he.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(he.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(he.BS,()=>this.backspace()),this._parser.setExecuteHandler(he.HT,()=>this.tab()),this._parser.setExecuteHandler(he.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(he.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ja.IND,()=>this.index()),this._parser.setExecuteHandler(Ja.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ja.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ni(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new Ni(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new Ni(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new Ni(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new Ni(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new Ni(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new Ni(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new Ni(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new Ni(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new Ni(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new Ni(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new Ni(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 Ot)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 yg((f,_)=>this.requestStatusString(f,_)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),kg))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${kg} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,o=this._activeBuffer.y,a=0,u=this._parseStack.paused;if(u){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>qn&&(a=this._parseStack.position+qn)}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<qn&&(this._parseBuffer=new Uint32Array(Math.min(e.length,qn))),u||this._dirtyRowTracker.clearRange(),e.length>qn)for(let f=a;f<e.length;f+=qn){let _=f+qn<e.length?f+qn:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(f,_),this._parseBuffer):this._utf8Decoder.decode(e.subarray(f,_),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,b))return this._preserveStack(s,o,b,f),this._logSlowResolvingAsync(i),i}else if(!u){let f=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,f))return this._preserveStack(s,o,f,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let h=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),m=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);m<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(m,this._bufferService.rows-1),end:Math.min(h,this._bufferService.rows-1)})}print(e,t,i){let s,o,a=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,h=this._bufferService.cols,m=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&&i-t>0&&b.getWidth(this._activeBuffer.x-1)===2&&b.setCellFromCodepoint(this._activeBuffer.x-1,0,1,_);let w=this._parser.precedingJoinState;for(let y=t;y<i;++y){if(s=e[y],s<127&&a){let x=a[String.fromCharCode(s)];x&&(s=x.charCodeAt(0))}let S=this._unicodeService.charProperties(s,w);o=Sr.extractWidth(S);let k=Sr.extractShouldJoin(S),C=k?Sr.extractWidth(w):0;if(w=S,u&&this._onA11yChar.fire(Yn(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-C>h){if(m){let x=b,R=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 po&&b.copyCellsFrom(x,R,0,C,!1);R<h;)x.setCellFromCodepoint(R++,0,1,_)}else if(this._activeBuffer.x=h-1,o===2)continue}if(k&&this._activeBuffer.x){let x=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-x,s,o);for(let R=o-C;--R>=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=w,this._activeBuffer.x<h&&i-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,i=>bg(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new yg(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ni(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,i,s=!1,o=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,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 i=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(i,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 i=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(i,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(Lt));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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);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 i=e.params[0]||1,s=Sr.extractWidth(t),o=this._activeBuffer.x-s,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(a.length*i),h=0;for(let f=0;f<a.length;){let _=a.codePointAt(f)||0;u[h++]=_,f+=_>65535?2:1}let m=h;for(let f=1;f<i;++f)u.copyWithin(m,0,h),m+=h;return this.print(u,0,m),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(he.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(he.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(he.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(he.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(he.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,vr),this._charsetService.setgCharset(1,vr),this._charsetService.setgCharset(2,vr),this._charsetService.setgCharset(3,vr);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(k=>(k[k.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",k[k.SET=1]="SET",k[k.RESET=2]="RESET",k[k.PERMANENTLY_SET=3]="PERMANENTLY_SET",k[k.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:a}=this._coreMouseService,u=this._coreService,{buffers:h,cols:m}=this._bufferService,{active:f,alt:_}=h,b=this._optionsService.rawOptions,w=(k,C)=>(u.triggerDataEvent(`${he.ESC}[${t?"":"?"}${k};${C}$y`),!0),y=k=>k?1:2,S=e.params[0];return t?S===2?w(S,4):S===4?w(S,y(u.modes.insertMode)):S===12?w(S,3):S===20?w(S,y(b.convertEol)):w(S,0):S===1?w(S,y(s.applicationCursorKeys)):S===3?w(S,b.windowOptions.setWinLines?m===80?2:m===132?1:0:0):S===6?w(S,y(s.origin)):S===7?w(S,y(s.wraparound)):S===8?w(S,3):S===9?w(S,y(o==="X10")):S===12?w(S,y(b.cursorBlink)):S===25?w(S,y(!u.isCursorHidden)):S===45?w(S,y(s.reverseWraparound)):S===66?w(S,y(s.applicationKeypad)):S===67?w(S,4):S===1e3?w(S,y(o==="VT200")):S===1002?w(S,y(o==="DRAG")):S===1003?w(S,y(o==="ANY")):S===1004?w(S,y(s.sendFocus)):S===1005?w(S,4):S===1006?w(S,y(a==="SGR")):S===1015?w(S,4):S===1016?w(S,y(a==="SGR_PIXELS")):S===1048?w(S,1):S===47||S===1047||S===1049?w(S,y(f===_)):S===2004?w(S,y(s.bracketedPasteMode)):S===2026?w(S,y(s.synchronizedOutput)):w(S,0)}_updateAttrColor(e,t,i,s,o){return t===2?(e|=50331648,e&=-16777216,e|=ko.fromColorRGB([i,s,o])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){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:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.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=Lt.fg,e.bg=Lt.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,i,s=this._curAttrData;for(let o=0;o<t;o++)i=e.params[o],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=Lt.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=Lt.bg&16777215):i===38||i===48||i===58?o+=this._extractColor(e,o,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=Lt.fg&16777215,s.bg&=-67108864,s.bg|=Lt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${he.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${he.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${he.ESC}[?${t};${i}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=Lt.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 i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!bg(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(`${he.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>wg&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>wg&&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=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),o=i.shift();if(/^\d+$/.exec(s)){let a=parseInt(s);if(Cg(a))if(o==="?")t.push({type:0,index:a});else{let u=Sg(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 i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,o=i.findIndex(a=>a.startsWith("id="));return o!==-1&&(s=i[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 i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=Sg(i[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=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let o=parseInt(i[s]);Cg(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,vr),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Gk[e[0]],Ot[e[1]]||vr),!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=Lt.clone(),this._eraseAttrDataInternal=Lt.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 $i;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 i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=u=>(this._coreService.triggerDataEvent(`${he.ESC}${u}${he.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return i(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)}},$d=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&&(xg=e,e=t,t=xg),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};$d=Et([Re(0,di)],$d);function Cg(e){return 0<=e&&e<256}var Jk=5e7,Eg=12,Zk=50,ex=class extends Ze{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 xe),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 i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>Jk)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 i=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()-i>=Eg?setTimeout(()=>this._innerWrite(0,h)):this._innerWrite(i,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()-i>=Eg)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Zk&&(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()}},Hd=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),m={data:e,id:this._nextId++,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(m,h)),this._dataByLinkId.set(m.id,m),m.id}let i=e,s=this._getEntryIdKey(i),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(i),data:i,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 i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,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 i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Hd=Et([Re(0,di)],Hd);var Ng=!1,tx=class extends Ze{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ds),this._onBinary=this._register(new xe),this.onBinary=this._onBinary.event,this._onData=this._register(new xe),this.onData=this._onData.event,this._onLineFeed=this._register(new xe),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new xe),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new xe),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new xe),this._instantiationService=new Ck,this.optionsService=this._register(new Ak(e)),this._instantiationService.setService(hi,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Bd)),this._instantiationService.setService(di,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Id)),this._instantiationService.setService(y_,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Od)),this._instantiationService.setService(Nr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(zd)),this._instantiationService.setService(__,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Sr)),this._instantiationService.setService(wb,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Fk),this._instantiationService.setService(Sb,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Hd),this._instantiationService.setService(S_,this._oscLinkService),this._inputHandler=this._register(new Qk(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Jt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Jt.forward(this._bufferService.onResize,this._onResize)),this._register(Jt.forward(this.coreService.onData,this._onData)),this._register(Jt.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 ex((t,i)=>this._inputHandler.parse(t,i))),this._register(Jt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new xe),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&&!Ng&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Ng=!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,J_),t=Math.max(t,Z_),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=vt(()=>{for(let t of e)t.dispose()})}}},ix={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 nx(e,t,i,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=he.ESC+"OA":o.key=he.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=he.ESC+"OD":o.key=he.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=he.ESC+"OC":o.key=he.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=he.ESC+"OB":o.key=he.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":he.DEL,e.altKey&&(o.key=he.ESC+o.key);break;case 9:if(e.shiftKey){o.key=he.ESC+"[Z";break}o.key=he.HT,o.cancel=!0;break;case 13:o.key=e.altKey?he.ESC+he.CR:he.CR,o.cancel=!0;break;case 27:o.key=he.ESC,e.altKey&&(o.key=he.ESC+he.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;a?o.key=he.ESC+"[1;"+(a+1)+"D":t?o.key=he.ESC+"OD":o.key=he.ESC+"[D";break;case 39:if(e.metaKey)break;a?o.key=he.ESC+"[1;"+(a+1)+"C":t?o.key=he.ESC+"OC":o.key=he.ESC+"[C";break;case 38:if(e.metaKey)break;a?o.key=he.ESC+"[1;"+(a+1)+"A":t?o.key=he.ESC+"OA":o.key=he.ESC+"[A";break;case 40:if(e.metaKey)break;a?o.key=he.ESC+"[1;"+(a+1)+"B":t?o.key=he.ESC+"OB":o.key=he.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=he.ESC+"[2~");break;case 46:a?o.key=he.ESC+"[3;"+(a+1)+"~":o.key=he.ESC+"[3~";break;case 36:a?o.key=he.ESC+"[1;"+(a+1)+"H":t?o.key=he.ESC+"OH":o.key=he.ESC+"[H";break;case 35:a?o.key=he.ESC+"[1;"+(a+1)+"F":t?o.key=he.ESC+"OF":o.key=he.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=he.ESC+"[5;"+(a+1)+"~":o.key=he.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=he.ESC+"[6;"+(a+1)+"~":o.key=he.ESC+"[6~";break;case 112:a?o.key=he.ESC+"[1;"+(a+1)+"P":o.key=he.ESC+"OP";break;case 113:a?o.key=he.ESC+"[1;"+(a+1)+"Q":o.key=he.ESC+"OQ";break;case 114:a?o.key=he.ESC+"[1;"+(a+1)+"R":o.key=he.ESC+"OR";break;case 115:a?o.key=he.ESC+"[1;"+(a+1)+"S":o.key=he.ESC+"OS";break;case 116:a?o.key=he.ESC+"[15;"+(a+1)+"~":o.key=he.ESC+"[15~";break;case 117:a?o.key=he.ESC+"[17;"+(a+1)+"~":o.key=he.ESC+"[17~";break;case 118:a?o.key=he.ESC+"[18;"+(a+1)+"~":o.key=he.ESC+"[18~";break;case 119:a?o.key=he.ESC+"[19;"+(a+1)+"~":o.key=he.ESC+"[19~";break;case 120:a?o.key=he.ESC+"[20;"+(a+1)+"~":o.key=he.ESC+"[20~";break;case 121:a?o.key=he.ESC+"[21;"+(a+1)+"~":o.key=he.ESC+"[21~";break;case 122:a?o.key=he.ESC+"[23;"+(a+1)+"~":o.key=he.ESC+"[23~";break;case 123:a?o.key=he.ESC+"[24;"+(a+1)+"~":o.key=he.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=he.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=he.DEL:e.keyCode===219?o.key=he.ESC:e.keyCode===220?o.key=he.FS:e.keyCode===221&&(o.key=he.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let h=(u=ix[e.keyCode])==null?void 0:u[e.shiftKey?1:0];if(h)o.key=he.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let m=e.ctrlKey?e.keyCode-64:e.keyCode+32,f=String.fromCharCode(m);e.shiftKey&&(f=f.toUpperCase()),o.key=he.ESC+f}else if(e.keyCode===32)o.key=he.ESC+(e.ctrlKey?he.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let m=e.code.slice(3,4);e.shiftKey||(m=m.toLowerCase()),o.key=he.ESC+m,o.cancel=!0}}else i&&!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=he.US),e.key==="@"&&(o.key=he.NUL));break}return o}var jt=0,rx=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new fl,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new fl,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,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[o]=e[t],t++):s[o]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(jt=this._search(t),jt===-1)||this._getKey(this._array[jt])!==t)return!1;do if(this._array[jt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(jt),!0;while(++jt<this._array.length&&this._getKey(this._array[jt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,a)=>o-a),t=0,i=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:i[s++]=this._array[o];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(jt=this._search(e),!(jt<0||jt>=this._array.length)&&this._getKey(this._array[jt])===e))do yield this._array[jt];while(++jt<this._array.length&&this._getKey(this._array[jt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(jt=this._search(e),!(jt<0||jt>=this._array.length)&&this._getKey(this._array[jt])===e))do t(this._array[jt]);while(++jt<this._array.length&&this._getKey(this._array[jt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,o=this._getKey(this._array[s]);if(o>e)i=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}},xu=0,Rg=0,sx=class extends Ze{constructor(){super(),this._decorations=new rx(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new xe),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new xe),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(vt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new ox(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.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,i){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&&(!i||(a.options.layer??"bottom")===i)&&(yield a)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,o=>{xu=o.options.x??0,Rg=xu+(o.options.width??1),e>=xu&&e<Rg&&(!i||(o.options.layer??"bottom")===i)&&s(o)})}},ox=class extends Zn{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new xe),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new xe),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=bt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=bt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},ax=1e3,lx=class{constructor(e,t=ax){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,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)}},Pg=20,pl=class extends Ze{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,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 lx(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(Ke(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(vt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Pg+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
65
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Pg+1&&(this._liveRegion.textContent+=ld.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 i=this._terminal.buffer,s=i.lines.length.toString();for(let o=e;o<=t;o++){let a=i.lines.get(i.ydisp+o),u=[],h=(a==null?void 0:a.translateToString(!0,void 0,void 0,u))||"",m=(i.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",m),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 i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=i.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=i,h=this._rowElements.pop(),this._rowContainer.removeChild(h)):(u=this._rowElements.shift(),h=i,this._rowContainer.removeChild(u)),u.removeEventListener("focus",this._topBoundaryFocusListener),h.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let m=this._createAccessibilityTreeNode();this._rowElements.unshift(m),this._rowContainer.insertAdjacentElement("afterbegin",m)}else{let m=this._createAccessibilityTreeNode();this._rowElements.push(m),this._rowContainer.appendChild(m)}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},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,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(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((h=s.textContent)==null?void 0:h.length)??0}),!this._rowContainer.contains(i.node))return;let o=({node:m,offset:f})=>{let _=m instanceof Text?m.parentNode:m,b=parseInt(_==null?void 0:_.getAttribute("aria-posinset"),10)-1;if(isNaN(b))return console.warn("row is invalid. Race condition?"),null;let w=this._rowColumns.get(_);if(!w)return console.warn("columns is null. Race condition?"),null;let y=f<w.length?w[f]:w.slice(-1)[0]+1;return y>=this._terminal.cols&&(++b,y=0),{row:b,column:y}},a=o(t),u=o(i);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,i=(a=(o=this._rowColumns.get(e))==null?void 0:o.slice(-1))==null?void 0:a[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};pl=Et([Re(1,dh),Re(2,kn),Re(3,xn)],pl);var Wd=class extends Ze{constructor(e,t,i,s,o){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new xe),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new xe),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(vt(()=>{var a;xr(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(Ke(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ke(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ke(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ke(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 i=e.composedPath();for(let s=0;s<i.length;s++){let o=i[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 i=!1;for(let[a,u]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(a)&&(i=this._checkLinkProviderResult(a,e,i)):u.provideLinks(e.y,h=>{var f,_;if(this._isMouseOut)return;let m=h==null?void 0:h.map(b=>({link:b}));(f=this._activeProviderReplies)==null||f.set(a,m),i=this._checkLinkProviderResult(a,e,i),((_=this._activeProviderReplies)==null?void 0:_.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=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,m=u.link.range.end.y>e?this._bufferService.cols:u.link.range.end.x;for(let f=h;f<=m;f++){if(i.has(f)){o.splice(a--,1);break}i.add(f)}}}}_checkLinkProviderResult(e,t,i){var a;if(!this._activeProviderReplies)return i;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&&(i=!0,this._handleNewLink(u))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let u=0;u<this._activeProviderReplies.size;u++){let h=(a=this._activeProviderReplies.get(u))==null?void 0:a.find(m=>this._linkAtPosition(m.link,t));if(h){i=!0,this._handleNewLink(h);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&cx(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,xr(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 i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{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)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+i.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,i){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(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,i){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(i,t.text)}_linkAtPosition(e,t){let i=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 i<=o&&o<=s}_positionFromMouseEvent(e,t,i){let s=i.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,i,s,o){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:o}}};Wd=Et([Re(1,hh),Re(2,xn),Re(3,di),Re(4,b_)],Wd);function cx(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 ux=class extends tx{constructor(e={}){super(e),this._linkifier=this._register(new ds),this.browser=$_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ds),this._onCursorMove=this._register(new xe),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new xe),this.onKey=this._onKey.event,this._onRender=this._register(new xe),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new xe),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new xe),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new xe),this.onBell=this._onBell.event,this._onFocus=this._register(new xe),this._onBlur=this._register(new xe),this._onA11yCharEmitter=this._register(new xe),this._onA11yTabEmitter=this._register(new xe),this._onWillOpen=this._register(new xe),this._setup(),this._decorationService=this._instantiationService.createInstance(sx),this._instantiationService.setService(xo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Z1),this._instantiationService.setService(b_,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ud)),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(Jt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Jt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Jt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Jt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(vt(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let o=mt.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${he.ESC}]${s};${Xk(o)}${z_.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(a=>a.ansi[t.index]=Mt.toColor(...t.color));else{let a=i;this._themeService.modifyColors(u=>u[a]=Mt.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(pl,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(he.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(he.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 i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(i),a=this._renderService.dimensions.css.cell.width*o,u=this.buffer.y*this._renderService.dimensions.css.cell.height,h=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=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(Ke(this.element,"copy",t=>{this.hasSelection()&&pb(t,this._selectionService)}));let e=t=>mb(t,this.textarea,this.coreService,this.optionsService);this._register(Ke(this.textarea,"paste",e)),this._register(Ke(this.element,"paste",e)),H_?this._register(Ke(this.element,"mousedown",t=>{t.button===2&&zm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ke(this.element,"contextmenu",t=>{zm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Sh&&this._register(Ke(this.element,"auxclick",t=>{t.button===1&&f_(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ke(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ke(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ke(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ke(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ke(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ke(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ke(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(Ke(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 i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",ad.get()),K_||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Q1,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(kn,this._coreBrowserService),this._register(Ke(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(Ke(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Dd,this._document,this._helperContainer),this._instantiationService.setService(yl,this._charSizeService),this._themeService=this._instantiationService.createInstance(Ad),this._instantiationService.setService(ps,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(dl),this._instantiationService.setService(w_,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Md,this.rows,this.screenElement)),this._instantiationService.setService(xn,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(Rd,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Ld),this._instantiationService.setService(hh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Wd,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(Ed,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(Td,this.element,this.screenElement,s)),this._instantiationService.setService(kb,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(Jt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var a;this._selectionService.refresh(),(a=this._viewport)==null||a.queueSync()})),this._register(this._instantiationService.createInstance(Nd,this.screenElement)),this._register(Ke(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(pl,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ul,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ul,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(jd,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(a){var f,_,b,w,y;let u=e._mouseService.getMouseReportCoords(a,e.screenElement);if(!u)return!1;let h,m;switch(a.overrideType||a.type){case"mousemove":m=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":m=0,h=a.button<3?a.button:3;break;case"mousedown":m=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,(w=(b=(_=(f=e._renderService)==null?void 0:f.dimensions)==null?void 0:_.device)==null?void 0:b.cell)==null?void 0:w.height,(y=e._coreBrowserService)==null?void 0:y.dpr)===0)return!1;m=S<0?0:1,h=4;break;default:return!1}return m===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:m,ctrl:a.ctrlKey,alt:a.altKey,shift:a.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:a=>(i(a),a.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(a)),wheel:a=>(i(a),this.cancel(a,!0)),mousedrag:a=>{a.buttons&&i(a)},mousemove:a=>{a.buttons||i(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(Ke(t,"mousedown",a=>{if(a.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(a)))return i(a),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(a)})),this._register(Ke(t,"wheel",a=>{var u,h,m,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=(m=(h=(u=e._renderService)==null?void 0:u.dimensions)==null?void 0:h.device)==null?void 0:m.cell)==null?void 0:f.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return this.cancel(a,!0);let b=he.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 i;(i=this._renderService)==null||i.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){h_(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,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.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 i=nx(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===he.ETX||i.key===he.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=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"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(dx(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 i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Lt));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(he.ESC+"[I"):this.coreService.triggerDataEvent(he.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${he.ESC}[4;${i};${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(`${he.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function dx(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var hx=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;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)}},fx=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 $i)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},jg=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 fx(t)}getNullCell(){return new $i}},px=class extends Ze{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new xe),this.onBufferChange=this._onBufferChange.event,this._normal=new jg(this._core.buffers.normal,"normal"),this._alternate=new jg(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)}},mx=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,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)}},gx=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}},vx=["cols","rows"],rn=0,_x=class extends Ze{constructor(e){super(),this._core=this._register(new ux(e)),this._addonManager=this._register(new hx),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(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:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,o)}}_checkReadonlyOptions(e){if(vx.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 mx(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new gx(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 px(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,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}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 ad.get()},set promptLabel(e){ad.set(e)},get tooMuchOutput(){return ld.get()},set tooMuchOutput(e){ld.set(e)}}}_verifyIntegers(...e){for(rn of e)if(rn===1/0||isNaN(rn)||rn%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(rn of e)if(rn&&(rn===1/0||isNaN(rn)||rn%1!==0||rn<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 yx=2,Sx=1,wx=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,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),o=Math.max(0,parseInt(i.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,m=u.right+u.left,f=s-h,_=o-m-t;return{cols:Math.max(yx,Math.floor(_/e.css.cell.width)),rows:Math.max(Sx,Math.floor(f/e.css.cell.height))}}};function bx(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function kx({session:e,node:t,token:i,cols:s,rows:o,readonly:a=!1,takeSize:u,focused:h,onData:m,onExit:f,onFiles:_,retryBaseMs:b=250}){const w=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!w)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}${bx(t,i)}`;let k=null,C=!1,x=!1,R=null,D=0,T=h;const ee=()=>{if(C||x||R)return;const W=Math.min(5e3,Math.max(0,b)*2**Math.min(D++,5));R=setTimeout(()=>{R=null,V()},W)},V=()=>{if(C||x)return;const W=new WebSocket(S);k=W,W.binaryType="arraybuffer",W.onopen=()=>{if(k!==W||C)return;D=0;const te={type:"attach",session:e,token:i,cols:s,rows:o,readonly:a};u!==void 0&&(te.takeSize=u),W.send(JSON.stringify(te)),T!==void 0&&W.send(JSON.stringify({type:"focus",on:!!T}))},W.onmessage=te=>{if(!(k!==W||C))if(typeof te.data=="string"){let K;try{K=JSON.parse(te.data)}catch{return}K.type==="exit"&&(x=!0,f&&f(K.code)),K.type==="files"&&_&&_(K)}else m&&m(new Uint8Array(te.data))},W.onerror=()=>{if(k===W)try{W.close()}catch{}},W.onclose=te=>{k!==W||C||x||[1e3,1002,4401,4404].includes(te==null?void 0:te.code)||ee()}};return V(),{sendInput:W=>{if(!k||k.readyState!==1)return!1;try{return k.send(typeof W=="string"?new TextEncoder().encode(W):W),!0}catch{try{k.close()}catch{}return!1}},isReady:()=>!!k&&k.readyState===1,resize:(W,te)=>{s=W,o=te,(k==null?void 0:k.readyState)===1&&k.send(JSON.stringify({type:"resize",cols:W,rows:te}))},action:W=>{(k==null?void 0:k.readyState)===1&&k.send(JSON.stringify({type:"action",name:W}))},focus:W=>{T=W,(k==null?void 0:k.readyState)===1&&k.send(JSON.stringify({type:"focus",on:!!W}))},close:()=>{if(C=!0,R&&clearTimeout(R),R=null,k)try{k.close()}catch{}},get raw(){return k}}}async function Dg(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 i=document.createElement("textarea");i.value=t,i.readOnly=!0,i.style.position="fixed",i.style.opacity="0",i.style.pointerEvents="none",document.body.appendChild(i),i.select();const s=document.execCommand&&document.execCommand("copy");if(i.remove(),s)return!0}catch{}return!1}const xx="\r";function Cx(e){const t=String(e||"");let i=t.length;for(;i>0;){const s=t.charCodeAt(i-1);if(s===10||s===13)i-=1;else break}return t.slice(0,i)}function Ex({isReady:e,paste:t,send:i}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:i(xx)!==!1}catch{return!1}}}function Nx(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function Rx(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}const Px=450,Lg=8;function jx(e,t,i,s){return Math.abs(Number(i)-Number(e))>Lg||Math.abs(Number(s)-Number(t))>Lg}const Dx=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function Cu(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 Mg(e){if(!e)return[];const t=Array.from(e.files||[]).filter(Boolean);return t.length?t:Array.from(e.items||[]).filter(i=>i&&i.kind==="file"&&typeof i.getAsFile=="function").map(i=>i.getAsFile()).filter(Boolean)}function Lx(e,t=0,i=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=Dx.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${i}-${t+1}.${o}`}async function ty({files:e,token:t,session:i,node:s="",paste:o=!0,fetchImpl:a=qt,onProgress:u=()=>{},now:h=Date.now()}={}){const m=Array.from(e||[]).filter(Boolean),f=[],_=[];if(!i||!m.length)return{paths:f,errors:_};const b=ui(s?String(s).split("/"):[]);for(let w=0;w<m.length;w+=1){const y=m[w],S=Lx(y,w,h);u({index:w,total:m.length,name:S,state:"uploading"});try{const k=new FormData;k.append("session",i),k.append("paste",o?"true":"false"),k.append("file",y,S);const C=await a(`${b}/files/upload`,t,{method:"POST",body:k}),x=await C.json().catch(()=>({}));if(!C.ok||x.error)throw new Error(x.error||`HTTP ${C.status}`);f.push(x.path),u({index:w,total:m.length,name:S,state:"done",path:x.path})}catch(k){const C=String((k==null?void 0:k.message)||k);_.push({name:S,message:C}),u({index:w,total:m.length,name:S,state:"error",error:C})}}return{paths:f,errors:_}}function iy({session:e,node:t,token:i,readonly:s,takeSize:o,focused:a,sendRef:u,composerRef:h,actionRef:m,ctrlRef:f,setCtrlArmed:_,onFiles:b,fontSize:w=13,selectionMode:y=!1,onSelectionModeChange:S}){const k=P.useRef(null),C=P.useRef(null),x=P.useRef(w);x.current=w;const R=P.useRef(a);R.current=a;const D=P.useRef(y);D.current=y;const[T,ee]=P.useState(""),[V,W]=P.useState(""),[te,K]=P.useState(null),ie=async()=>{var j,L,$,U;const A=((L=(j=C.current)==null?void 0:j.term)==null?void 0:L.getSelection())||T;if(!A){W(v("copy-empty")),setTimeout(()=>W(""),1500);return}const N=await Dg(A);W(v(N?"copied":"copy-manual")),N&&((U=($=C.current)==null?void 0:$.term)==null||U.clearSelection(),S==null||S(!1)),setTimeout(()=>W(""),1800)},Y=P.useRef(ie);return Y.current=ie,P.useEffect(()=>{const A=C.current;A&&A.sock&&A.sock.focus&&A.sock.focus(!!a)},[a]),P.useEffect(()=>{const A=C.current;A&&(A.term.options.fontSize=w,A.fit.fit(),A.sock.resize(A.term.cols,A.term.rows))},[w]),P.useEffect(()=>{const A=new _x({cursorBlink:!0,fontSize:x.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),N=new wx;A.loadAddon(N),A.open(k.current),N.fit();const j=new TextDecoder;let L;try{L=kx({session:e,node:t,token:i,readonly:s,takeSize:o,focused:R.current,onFiles:b,cols:A.cols,rows:A.rows,onData:H=>A.write(j.decode(H)),onExit:()=>A.write(`\r
78
- \x1B[33m[sessione finita]\x1B[0m\r
79
- `)})}catch(H){return A.write(`\r
80
- \x1B[31m${H.message}\x1B[0m\r
81
- `),()=>A.dispose()}C.current={term:A,fit:N,sock:L};let $=null;const U=A.onData(H=>{if(s){$&&($.ok=!1);return}if(!$&&f&&f.current&&H.length===1){const me=H.charCodeAt(0);let Te=me;me>=97&&me<=122?Te=me-96:me>=64&&me<=95?Te=me-64:me===32&&(Te=0),H=String.fromCharCode(Te),f.current=!1,_&&_(!1)}const oe=L.sendInput(H);$&&($.seen=!0,$.ok=$.ok&&oe)});u&&(u.current=H=>L.sendInput(H)),m&&(m.current=H=>L.action(H)),h&&(h.current=Ex({isReady:()=>!s&&L.isReady(),paste:H=>{const oe={seen:!1,ok:!0};$=oe;try{A.paste(H)}catch{oe.ok=!1}finally{$=null}return oe.seen&&oe.ok},send:H=>L.sendInput(H)}));const B=A.onSelectionChange(()=>ee(A.getSelection()));A.attachCustomKeyEventHandler(H=>(H.ctrlKey||H.metaKey)&&H.key.toLowerCase()==="c"&&A.getSelection()?(H.type==="keydown"&&Dg(A.getSelection()),!1):!0);const J=k.current;let z=!1;const M=async H=>{if(!H.length||z)return;if(s){K({error:v("settings-readonly")});return}z=!0,K({current:0,total:H.length,name:""});const oe=await ty({files:H,token:i,session:e,node:t,paste:!0,onProgress:({index:me,total:Te,name:we,state:Ce,error:He})=>K({current:me+1,total:Te,name:we,...Ce==="error"?{error:He}:{}})});z=!1,oe.errors.length?K({error:oe.errors.map(me=>`${me.name}: ${me.message}`).join(" · ")}):(K({done:!0,total:oe.paths.length}),setTimeout(()=>K(null),1600))},I=H=>{const oe=H.clipboardData;if(!Cu(oe))return;const me=Mg(oe);me.length&&(H.preventDefault(),H.stopPropagation(),M(me))},se=H=>{Cu(H.dataTransfer)&&(H.preventDefault(),H.stopPropagation())},ge=H=>{Cu(H.dataTransfer)&&(H.preventDefault(),H.stopPropagation(),M(Mg(H.dataTransfer)))};J.addEventListener("paste",I,!0),J.addEventListener("dragenter",se,!0),J.addEventListener("dragover",se,!0),J.addEventListener("drop",ge,!0);const de=24;let fe=null,X=null,Z=0,ye=null,Ee=null,tt=null,Ye=!1;const Be=()=>{tt&&clearTimeout(tt),tt=null},ot=(H,oe)=>{const Te=(J.querySelector(".xterm-screen")||J).getBoundingClientRect(),we=Math.max(0,Math.min(A.cols-1,Math.floor((H-Te.left)/Math.max(1,Te.width)*A.cols))),Ce=Math.max(0,Math.min(A.rows-1,Math.floor((oe-Te.top)/Math.max(1,Te.height)*A.rows)));return{col:we,row:A.buffer.active.viewportY+Ce}},Xe=H=>ot(H.clientX,H.clientY),_t=H=>{if(Be(),Ye=!1,H.touches.length!==1){fe=null;return}if(D.current){H.preventDefault(),H.stopPropagation(),Ee=Xe(H.touches[0]),A.clearSelection();return}fe=H.touches[0].clientY,X=H.touches[0].clientX,Z=0,ye=null;const oe={x:X,y:fe};tt=setTimeout(()=>{tt=null,Ye=!0,D.current=!0,S==null||S(!0),Ee=ot(oe.x,oe.y),A.clearSelection(),A.select(Ee.col,Ee.row,1),fe=null,X=null,ye=null,Z=0},Px)},ut=H=>{if((D.current||Ye)&&Ee&&H.touches.length===1){H.preventDefault(),H.stopPropagation();const me=Xe(H.touches[0]),Te=Ee.row*A.cols+Ee.col,we=me.row*A.cols+me.col,Ce=Te<=we?Ee:me;A.select(Ce.col,Ce.row,Math.abs(we-Te)+1);return}if(fe===null||H.touches.length!==1)return;H.preventDefault(),H.stopPropagation();const oe=H.touches[0];if(tt&&jx(X,fe,oe.clientX,oe.clientY)&&Be(),ye===null&&(Math.abs(oe.clientY-fe)>8||Math.abs(oe.clientX-X)>8)&&(ye=Math.abs(oe.clientY-fe)>Math.abs(oe.clientX-X)),!!ye){for(Z+=oe.clientY-fe,fe=oe.clientY;Z>=de;)L.action("scroll-up"),Z-=de;for(;Z<=-de;)L.action("scroll-down"),Z+=de}},ht=()=>{Be(),fe=null,X=null,Ee=null,Ye=!1};let rt=0;const lt=H=>{for(H.preventDefault(),H.stopPropagation(),rt+=H.deltaY;rt<=-de;)L.action("scroll-up"),rt+=de;for(;rt>=de;)L.action("scroll-down"),rt-=de};J.addEventListener("touchstart",_t,{passive:!1}),J.addEventListener("touchmove",ut,{passive:!1,capture:!0}),J.addEventListener("touchend",ht,{passive:!0}),J.addEventListener("touchcancel",ht,{passive:!0});const le=H=>{(D.current||Ye)&&(H.preventDefault(),H.stopPropagation())};J.addEventListener("contextmenu",le,!0),J.addEventListener("wheel",lt,{passive:!1,capture:!0});let ke=null;const $e=H=>{Nx(H)&&(H.preventDefault(),H.stopPropagation(),ke=ot(H.clientX,H.clientY),A.clearSelection())},We=H=>{if(!ke)return;H.preventDefault(),H.stopPropagation();const oe=ot(H.clientX,H.clientY),me=ke.row*A.cols+ke.col,Te=oe.row*A.cols+oe.col,we=me<=Te?ke:oe;A.select(we.col,we.row,Math.abs(Te-me)+1)},pe=H=>{ke&&(H.stopPropagation(),ke=null)};J.addEventListener("mousedown",$e,!0),J.addEventListener("mousemove",We,!0),J.addEventListener("mouseup",pe,!0);const Oe=H=>{!Rx(H)||!(C.current&&C.current.term&&C.current.term.getSelection())||(H.preventDefault(),H.stopPropagation(),Y.current&&Y.current())};J.addEventListener("keydown",Oe,!0);const Me=()=>{N.fit(),L.resize(A.cols,A.rows)};window.addEventListener("resize",Me);const G=window.visualViewport;G&&(G.addEventListener("resize",Me),G.addEventListener("scroll",Me));let re=null,F=0;return typeof ResizeObserver<"u"&&(re=new ResizeObserver(()=>{F&&cancelAnimationFrame(F),F=requestAnimationFrame(Me)}),re.observe(J)),()=>{C.current=null,u&&(u.current=()=>!1),h&&(h.current=()=>!1),m&&(m.current=()=>!1),U.dispose(),B.dispose(),J.removeEventListener("touchstart",_t),J.removeEventListener("touchmove",ut,{capture:!0}),J.removeEventListener("touchend",ht),J.removeEventListener("touchcancel",ht),J.removeEventListener("contextmenu",le,!0),Be(),J.removeEventListener("wheel",lt,{capture:!0}),J.removeEventListener("mousedown",$e,!0),J.removeEventListener("mousemove",We,!0),J.removeEventListener("mouseup",pe,!0),J.removeEventListener("keydown",Oe,!0),J.removeEventListener("paste",I,!0),J.removeEventListener("dragenter",se,!0),J.removeEventListener("dragover",se,!0),J.removeEventListener("drop",ge,!0),window.removeEventListener("resize",Me),G&&(G.removeEventListener("resize",Me),G.removeEventListener("scroll",Me)),re&&re.disconnect(),F&&cancelAnimationFrame(F),L.close(),A.dispose()}},[e,t,i,s,o,u,h,m,f,_,b]),c.jsxs("div",{className:`nc-terminal${y?" selecting":""}`,children:[c.jsx("div",{className:"nc-terminal-host",ref:k}),te&&c.jsx("div",{className:`nc-upload-state${te.error?" error":""}`,role:"status",children:te.error?te.error:te.done?v("attach-uploaded").replace("{n}",String(te.total||0)):v("attach-upload-progress").replace("{n}",String(te.current||0)).replace("{total}",String(te.total||0))}),(T||y)&&c.jsxs("div",{className:"nc-selection-tools",children:[T?c.jsx("button",{type:"button",onClick:ie,children:V||v("copy")}):c.jsx("span",{children:v("select-drag")}),c.jsx("button",{type:"button",onClick:()=>{var A,N;(N=(A=C.current)==null?void 0:A.term)==null||N.clearSelection(),ee(""),S==null||S(!1)},children:v("cancel")}),V===v("copy-manual")&&c.jsx("textarea",{readOnly:!0,value:T,onFocus:A=>A.target.select()})]})]})}const Tg="",Si="\x1B",Mx=[{label:"↑",seq:Si+"[A"},{label:"↓",seq:Si+"[B"},{label:"PGUP",seq:Si+"[5~"},{label:"PGDN",seq:Si+"[6~"}];function Tx({send:e,action:t,ctrlArmed:i=!1,onCtrl:s,onKeyboard:o,selectionMode:a=!1,onSelectionMode:u}){const[h,m]=P.useState(!1),[f,_]=P.useState(!1),[b,w]=P.useState(!1),y=C=>{b?(e(Si+C),w(!1)):e(C)},S=(C,x,R)=>c.jsx("button",{onMouseDown:D=>{D.preventDefault(),y(x),R&&R()},children:C},C),k=(C,x)=>c.jsx("button",{onMouseDown:R=>{R.preventDefault(),t(x),_(!1)},children:C},C);return h?c.jsxs("div",{className:"nc-keybar copy",children:[c.jsx("span",{className:"tag",children:"copy-mode"}),Mx.map(C=>S(C.label,C.seq)),S("ESCI (q)","q",()=>m(!1))]}):c.jsxs("div",{className:"nc-keybar termux",children:[f&&c.jsxs("div",{className:"nc-keymenu",children:[k("←WIN","prev-window"),k("WIN→","next-window"),k("⬅PANE","pane-left"),k("PANE➡","pane-right"),S("SCROLL",Tg+"[",()=>{m(!0),_(!1)}),c.jsx("button",{className:a?"armed":"",onMouseDown:C=>{C.preventDefault(),u==null||u(!a),_(!1)},children:"SELECT"}),S("⌃C","",()=>_(!1)),S("DETACH",Tg+"d",()=>_(!1))]}),c.jsxs("div",{className:"row",children:[S("ESC",Si),c.jsx("button",{className:f?"armed":"",onMouseDown:C=>{C.preventDefault(),_(x=>!x)},children:"☰"},"menu"),S("/","/"),S("—","-"),S("HOME",Si+"[H"),S("↑",Si+"[A"),S("END",Si+"[F"),S("PGUP",Si+"[5~")]}),c.jsxs("div",{className:"row",children:[S("⇥"," "),c.jsx("button",{onMouseDown:C=>{C.preventDefault(),o&&o()},children:"⌨"},"kbd"),c.jsx("button",{className:i?"armed":"",onMouseDown:C=>{C.preventDefault(),s&&s()},children:"CTRL"},"ctrl"),c.jsx("button",{className:b?"armed":"",onMouseDown:C=>{C.preventDefault(),w(x=>!x)},children:"ALT"},"alt"),S("←",Si+"[D"),S("↓",Si+"[B"),S("→",Si+"[C"),S("PGDN",Si+"[6~")]})]})}const Ax=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function ny({session:e,node:t,token:i,filesEvent:s,onClose:o}){ji();const a=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",u=t?`${t}:${e}`:e,[h,m]=P.useState("outbox"),[f,_]=P.useState({inbox:[],outbox:[]}),[b,w]=P.useState(""),y=P.useRef(null);async function S(){try{const D=await(await qt(`${a}/files?session=${encodeURIComponent(e)}`,i)).json();if(D.error){w(D.error);return}_(D);const T=D.outbox[0]?D.outbox[0].mtime:0;localStorage.setItem(Ov(u),String(T))}catch(R){w(String(R))}}P.useEffect(()=>{S()},[e,t]),P.useEffect(()=>{s&&s.session===e&&S()},[s]);async function k(R){for(const D of R){w(`carico ${D.name}…`);const T=new FormData;T.append("session",e),T.append("file",D);try{const V=await(await qt(`${a}/files/upload`,i,{method:"POST",body:T})).json();w(V.error?`errore: ${V.error}`:"")}catch(ee){w(String(ee))}}S()}async function C(R){const D=await qt(`${a}/files/download?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(R)}`,i);if(!D.ok){w("errore download");return}const T=await D.blob(),ee=URL.createObjectURL(T),V=document.createElement("a");V.href=ee,V.download=R,V.click(),URL.revokeObjectURL(ee)}async function x(R){await qt(`${a}/files?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(R)}`,i,{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:v("close"),children:c.jsx(it,{name:"x",size:20})})]}),c.jsxs("nav",{children:[c.jsx("button",{className:h==="outbox"?"on":"",onClick:()=>m("outbox"),children:"outbox"}),c.jsx("button",{className:h==="inbox"?"on":"",onClick:()=>m("inbox"),children:"inbox"}),c.jsxs("button",{className:"up",onClick:()=>y.current&&y.current.click(),children:[c.jsx(it,{name:"upload",size:18})," ",v("upload")]}),c.jsx("input",{type:"file",multiple:!0,ref:y,style:{display:"none"},onChange:R=>{k(Array.from(R.target.files||[])),R.target.value=""}})]}),b&&c.jsx("div",{className:"nc-busy",children:b}),c.jsxs("ul",{children:[f[h].map(R=>c.jsxs("li",{children:[c.jsx("span",{className:"name",onClick:()=>C(R.name),children:R.name}),c.jsx("small",{children:Ax(R.size)}),c.jsx("button",{onClick:()=>x(R.name),title:"elimina",children:c.jsx(it,{name:"trash",size:18})})]},R.name)),f[h].length===0&&c.jsx("li",{className:"empty",children:v("empty-files")})]})]})}const bl="nc_composer_v1",Ud="nc-composer-reset",Ix=50,ry=256*1024,sy=512*1024,Bx=768*1024,Ag=2*1024*1024,oy=720*60*60*1e3,Kd=1;function ay(e){const t=Number(e);return Number.isFinite(t)&&t>0?t:0}function wh(e){if(e!==void 0)return e;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function ml(){return{version:Kd,cells:{}}}function ly(e){const t=[];for(const s of Array.isArray(e)?e:[]){const o=typeof s=="string"?s:s&&s.text,a=ay(typeof s=="string"?0:s&&s.at);if(!(typeof o!="string"||!o||o.length>ry)&&!(t.length&&t[t.length-1].text===o)&&(t.push({text:o,at:a}),t.length>=Ix))break}let i=0;return t.filter(s=>i+s.text.length>Bx?!1:(i+=s.text.length,!0))}function gl(e){if(!e||typeof e!="object")return null;const t=typeof e.draft=="string"&&e.draft.length<=sy?e.draft:"",i=ly(e.history),s=ay(e.updatedAt),o=e.expanded===!0;return!t&&!i.length&&!o?null:{draft:t,history:i,expanded:o,updatedAt:s}}function Ox(e){let t;try{t=typeof e=="string"?JSON.parse(e):e}catch{return ml()}if(!t||typeof t!="object"||t.version!==Kd||!t.cells||typeof t.cells!="object")return ml();const i=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=gl(o);a&&(i[s]=a)}return{version:Kd,cells:i}}function cy(e){const t=wh(e);if(!t)return ml();try{return Ox(t.getItem(bl))}catch{return ml()}}function Ig(e){try{return JSON.stringify(e).length}catch{return 1/0}}function zx(e,t,i){for(const[s,o]of Object.entries(e.cells))s!==i&&o.updatedAt>0&&t-o.updatedAt>oy&&delete e.cells[s]}function uy(e,t){return Object.entries(e.cells).filter(([i])=>i!==t).sort((i,s)=>i[1].updatedAt-s[1].updatedAt).map(([i])=>i)}function Fx(e,t){for(;Ig(e)>Ag;){const i=Object.entries(e.cells).filter(([,s])=>s.history.length).sort((s,o)=>s[1].updatedAt-o[1].updatedAt);if(!i.length)break;i[0][1].history.pop()}for(const i of uy(e,t)){if(Ig(e)<=Ag)break;delete e.cells[i]}}function dy(e,t,i){const s=wh(e);if(!s)return!1;Fx(t,i);const o=()=>(s.setItem(bl,JSON.stringify(t)),!0);try{return o()}catch{for(const u of uy(t,i)){delete t.cells[u];try{return o()}catch{}}return!1}}function No(e,t,i,s){const o=cy(t);zx(o,i,e);const a=gl(o.cells[e])||{draft:"",history:[],expanded:!1,updatedAt:0},u=s({...a,history:[...a.history]}),h=gl(u);return h?o.cells[e]={...h,updatedAt:i}:delete o.cells[e],{ok:dy(t,o,e),cell:o.cells[e]||{draft:"",history:[],expanded:!1,updatedAt:i}}}function $x({ownerId:e,node:t,session:i}){const s=String(i||"");if(!s)return"";const o=cs.test(String(e||""))?String(e):t?`route:${String(t)}`:"local";return`${encodeURIComponent(o)}:${encodeURIComponent(s)}`}function ao(e,t,i=Date.now()){if(!e)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=cy(t),o=gl(s.cells[e]);return!o||o.updatedAt>0&&i-o.updatedAt>oy?(s.cells[e]&&(delete s.cells[e],dy(t,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...o,history:[...o.history]}}function Bg(e,t,i,s=Date.now()){const o=String(t||"");return!e||o.length>sy?!1:No(e,i,s,a=>({...a,draft:o})).ok}function Og(e,t,i=Date.now()){return e?No(e,t,i,s=>({...s,draft:""})).ok:!1}function Hx(e,t,i,s=Date.now()){return e?No(e,i,s,o=>({...o,expanded:!!t})).ok:!1}function Wx(e,t,i,s=Date.now()){const o=String(t||"");return!e||!o||o.length>ry?!1:No(e,i,s,a=>{const u=a.history.filter(h=>h.text!==o);return u.unshift({text:o,at:s}),{...a,history:ly(u)}}).ok}function Ux(e,t,i=Date.now()){return e?No(e,t,i,s=>({...s,history:[]})).ok:!1}function Kx(e){const t=wh(e);if(!t)return!1;try{return t.removeItem(bl),!0}catch{return!1}}const qx=300;function Vx(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Yx({ownerId:e,node:t,session:i,storage:s=Vx()}){const o=P.useMemo(()=>$x({ownerId:e,node:t,session:i}),[e,t,i]),a=P.useMemo(()=>ao(o,s),[]),[u,h]=P.useState(a.draft),[m,f]=P.useState(a.expanded),[_,b]=P.useState(a.history),[w,y]=P.useState(-1),S=P.useRef(o),k=P.useRef(a.draft),C=P.useRef(null),x=P.useRef(a.updatedAt||0),R=P.useRef(a.draft),D=P.useCallback(()=>{C.current&&clearTimeout(C.current),C.current=null},[]),T=P.useCallback(()=>{D(),Bg(S.current,k.current,s)},[D,s]),ee=P.useCallback(()=>{D(),C.current=setTimeout(()=>{C.current=null,Bg(S.current,k.current,s)},qx)},[D,s]),V=P.useCallback(j=>{const L=String(typeof j=="function"?j(k.current):j||"");k.current=L,x.current=Date.now(),R.current=L,y(-1),h(L),ee()},[ee]),W=P.useCallback((j,L)=>{D(),k.current=j,x.current=Date.now(),h(j),y(L),ee()},[D,ee]),te=P.useCallback(()=>{if(!_.length)return!1;const j=Math.min(w+1,_.length-1);return w<0&&(R.current=k.current),W(_[j].text,j),!0},[W,_,w]),K=P.useCallback(()=>{if(w<0)return!1;const j=w-1;return W(j<0?R.current:_[j].text,j),!0},[W,_,w]),ie=P.useCallback(j=>{R.current=k.current;const L=_.findIndex($=>$.text===j);W(String(j||""),L)},[W,_]),Y=P.useCallback(()=>{f(j=>{const L=!j;return Hx(S.current,L,s),L})},[s]),A=P.useCallback((j,L,$)=>{if(!j)return;if(Wx(j,$,s),!(S.current===j)){ao(j,s).draft===L&&Og(j,s);return}b(ao(j,s).history),R.current="",y(-1),k.current===L?(D(),k.current="",x.current=Date.now(),h(""),Og(j,s)):ee()},[D,ee,s]),N=P.useCallback(()=>{Ux(S.current,s),b([]),y(-1),R.current=k.current},[s]);return P.useEffect(()=>{if(S.current===o)return;T(),S.current=o;const j=ao(o,s);k.current=j.draft,x.current=j.updatedAt||0,R.current=j.draft,h(j.draft),f(j.expanded),b(j.history),y(-1)},[o,T,s]),P.useEffect(()=>{const j=()=>T(),L=()=>{document.visibilityState==="hidden"&&T()};return window.addEventListener("pagehide",j),document.addEventListener("visibilitychange",L),()=>{window.removeEventListener("pagehide",j),document.removeEventListener("visibilitychange",L),T()}},[T]),P.useEffect(()=>{const j=()=>{D(),k.current="",x.current=0,R.current="",h(""),f(!1),b([]),y(-1)},L=U=>{if(U.key!==bl)return;if(U.newValue==null){j();return}const B=ao(S.current,s);B.updatedAt<x.current||(D(),k.current=B.draft,x.current=B.updatedAt,R.current=B.draft,h(B.draft),f(B.expanded),b(B.history),y(-1))},$=()=>j();return window.addEventListener("storage",L),window.addEventListener(Ud,$),()=>{window.removeEventListener("storage",L),window.removeEventListener(Ud,$)}},[D,s]),{cellKey:o,text:u,setText:V,expanded:m,toggleExpanded:Y,history:_,historyCursor:w,recallPrevious:te,recallNext:K,selectHistory:ie,confirmSubmitted:A,clearHistory:N,flush:T}}function hy({submitText:e,token:t,session:i,node:s,ownerId:o}){ji();const a=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:u,text:h,setText:m,expanded:f,toggleExpanded:_,history:b,historyCursor:w,recallPrevious:y,recallNext:S,selectHistory:k,confirmSubmitted:C,clearHistory:x,flush:R}=Yx({ownerId:o,node:s,session:i}),[D,T]=P.useState(!1),[ee,V]=P.useState(""),[W,te]=P.useState(!1),K=P.useRef(null),ie=P.useRef(null),Y=P.useRef(null),[A,N]=P.useState(!1),[j,L]=P.useState({left:0,bottom:0}),[$,U]=P.useState(!1),[B,J]=P.useState(!1),z=P.useRef(null),M=P.useRef(null),I=P.useRef(null),se=P.useRef(null),ge=P.useRef(null),de=P.useRef(null),fe=P.useRef(null),X=P.useRef(!1),[Z,ye]=P.useState(!1),[Ee,tt]=P.useState({left:0,bottom:0,width:320}),Ye=P.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);P.useEffect(()=>{let pe=!1;if(s){te(!1);return}return qt(`${a}/voice/status`,t).then(Oe=>Oe.json()).then(Oe=>{pe||te(!!Oe.serverSttConfigured)}).catch(()=>{pe||te(!1)}),()=>{pe=!0}},[t,a]);const ot=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||W);async function Xe(){const pe=h,Oe=Cx(pe);if(!Oe||B)return;J(!0),V("");let Me=!1;try{Me=!!await e(Oe)}catch{Me=!1}Me?C(u,pe,Oe):V(v("composer-send-failed")),J(!1),requestAnimationFrame(()=>{var G;return(G=Y.current)==null?void 0:G.focus({preventScroll:!0})})}function _t(){const pe=z.current&&z.current.getBoundingClientRect();pe&&L({left:Math.max(6,Math.min(pe.left,window.innerWidth-186)),bottom:window.innerHeight-pe.top+6}),N(!0)}function ut(pe){N(!1),pe&&z.current&&z.current.focus()}function ht(){const pe=I.current&&I.current.getBoundingClientRect();if(pe){const Oe=Math.max(220,Math.min(360,window.innerWidth-12));tt({left:Math.max(6,Math.min(pe.right-Oe,window.innerWidth-Oe-6)),bottom:window.innerHeight-pe.top+6,width:Oe})}ye(!0)}function rt(pe){ye(!1),pe&&I.current&&I.current.focus()}P.useEffect(()=>{if(!A)return;const pe=Me=>{Me.key==="Escape"&&ut(!0)},Oe=Me=>{const G=M.current&&M.current.contains(Me.target),re=z.current&&z.current.contains(Me.target);!G&&!re&&ut(!1)};return document.addEventListener("keydown",pe),document.addEventListener("pointerdown",Oe),()=>{document.removeEventListener("keydown",pe),document.removeEventListener("pointerdown",Oe)}},[A]),P.useEffect(()=>{if(!Z)return;const pe=Me=>{Me.key==="Escape"&&rt(!0)},Oe=Me=>{const G=se.current&&se.current.contains(Me.target),re=I.current&&I.current.contains(Me.target);!G&&!re&&rt(!1)};return document.addEventListener("keydown",pe),document.addEventListener("pointerdown",Oe),()=>{document.removeEventListener("keydown",pe),document.removeEventListener("pointerdown",Oe)}},[Z]);function lt(pe){if(!(pe.isComposing||X.current||pe.altKey||pe.ctrlKey||pe.metaKey)){if(pe.key==="ArrowUp"&&pe.currentTarget.selectionStart===0&&pe.currentTarget.selectionEnd===0){y()&&pe.preventDefault();return}pe.key==="ArrowDown"&&w>=0&&pe.currentTarget.selectionStart===h.length&&pe.currentTarget.selectionEnd===h.length&&S()&&pe.preventDefault()}}function le(pe){ut(!1),pe.current&&pe.current.click()}async function ke(pe){if(!pe.length||!i)return;U(!0),V("");const{paths:Oe,errors:Me}=await ty({files:pe,token:t,session:i,node:s,paste:!1});Me.length&&V(Me.map(G=>`${G.name}: ${G.message}`).join(" · ")),Oe.length&&m(G=>G+(G&&!G.endsWith(" ")?" ":"")+Oe.join(" ")),U(!1)}function $e(){K.current&&K.current.stop(),ie.current&&ie.current.stop(),T(!1)}async function We(){V("");const pe=window.SpeechRecognition||window.webkitSpeechRecognition;if(pe){const Oe=new pe;Oe.lang="it-IT",Oe.continuous=!1,Oe.interimResults=!0;const Me=h?`${h} `:"";Oe.onresult=G=>{const re=Array.from(G.results).map(F=>F[0].transcript).join("");m(Me+re)},Oe.onend=()=>T(!1),Oe.onerror=G=>{V(`voice: ${G.error||"errore"}`),T(!1)},K.current=Oe,Oe.start(),T(!0);return}try{const Oe=await navigator.mediaDevices.getUserMedia({audio:!0}),Me=new MediaRecorder(Oe),G=[];Me.ondataavailable=re=>G.push(re.data),Me.onstop=async()=>{Oe.getTracks().forEach(re=>re.stop()),T(!1),V("trascrivo…");try{const re=new Blob(G,{type:Me.mimeType||"audio/webm"}),H=await(await qt(`${a}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:re})).json();H.error?V(H.error):(V(""),m(oe=>oe+(oe?" ":"")+(H.text||"")))}catch(re){V(String(re))}},ie.current={stop:()=>Me.state!=="inactive"&&Me.stop()},Me.start(),T(!0)}catch{V("microfono non disponibile"),T(!1)}}return c.jsxs("div",{className:"nc-composer",children:[ee&&c.jsx("div",{className:"nc-composer-err",children:ee}),c.jsxs("div",{className:"nc-composer-row",children:[i&&c.jsx("button",{ref:z,className:$?"attach busy":"attach",disabled:$,onClick:()=>A?ut(!1):_t(),title:v($?"attach-uploading":"attach"),"aria-label":v("attach"),"aria-haspopup":"menu","aria-expanded":A,"aria-controls":Ye.current,children:c.jsx(it,{name:"attach",size:22})}),A&&c.jsxs("div",{ref:M,id:Ye.current,role:"menu",className:"nc-attach-menu",style:{left:j.left,bottom:j.bottom},children:[c.jsxs("button",{role:"menuitem",onClick:()=>le(ge),children:[c.jsx(it,{name:"file",size:18})," ",v("attach-file")]}),c.jsxs("button",{role:"menuitem",onClick:()=>le(de),children:[c.jsx(it,{name:"camera",size:18})," ",v("attach-camera")]}),c.jsxs("button",{role:"menuitem",onClick:()=>le(fe),children:[c.jsx(it,{name:"image",size:18})," ",v("attach-gallery")]})]}),c.jsx("button",{ref:I,type:"button",className:"history",onPointerDown:pe=>pe.preventDefault(),onClick:()=>Z?rt(!1):ht(),title:v("composer-history-tools"),"aria-label":v("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":Z,children:c.jsx(it,{name:"history",size:21})}),Z&&c.jsxs("div",{ref:se,role:"menu",className:"nc-composer-history-menu",style:{left:Ee.left,bottom:Ee.bottom,width:Ee.width},children:[c.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:pe=>pe.preventDefault(),onClick:()=>{_(),rt(!1),requestAnimationFrame(()=>{var pe;return(pe=Y.current)==null?void 0:pe.focus({preventScroll:!0})})},children:[c.jsx(it,{name:f?"chevronDown":"chevronUp",size:18}),v(f?"composer-collapse":"composer-expand")]}),c.jsx("div",{className:"nc-composer-history-title",children:v("composer-history")}),b.length===0&&c.jsx("div",{className:"nc-composer-history-empty",children:v("composer-history-empty")}),b.map((pe,Oe)=>c.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:Me=>Me.preventDefault(),onClick:()=>{k(pe.text),rt(!1),requestAnimationFrame(()=>{var Me;return(Me=Y.current)==null?void 0:Me.focus({preventScroll:!0})})},children:[c.jsx("span",{children:pe.text.replace(/\s+/g," ").slice(0,180)}),pe.at>0&&c.jsx("small",{children:new Date(pe.at).toLocaleString()})]},`${pe.at}:${Oe}`)),b.length>0&&c.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:pe=>pe.preventDefault(),onClick:()=>{x(),rt(!1)},children:v("composer-history-clear")})]}),c.jsx("input",{ref:ge,type:"file",multiple:!0,hidden:!0,onChange:pe=>{ke(Array.from(pe.target.files||[])),pe.target.value=""}}),c.jsx("input",{ref:de,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:pe=>{ke(Array.from(pe.target.files||[])),pe.target.value=""}}),c.jsx("input",{ref:fe,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:pe=>{ke(Array.from(pe.target.files||[])),pe.target.value=""}}),c.jsx("textarea",{ref:Y,className:f?"expanded":"",rows:f?8:2,value:h,placeholder:v("composer-placeholder"),onChange:pe=>m(pe.target.value),onKeyDown:lt,onCompositionStart:()=>{X.current=!0},onCompositionEnd:()=>{X.current=!1},onBlur:R}),ot&&c.jsx("button",{className:D?"mic on":"mic",onClick:D?$e:We,title:v("voice"),children:c.jsx(it,{name:"mic",size:22})}),c.jsx("button",{type:"button",className:"go",disabled:B,onPointerDown:pe=>pe.preventDefault(),onClick:Xe,title:v("send"),children:c.jsx(it,{name:"enter",size:22})})]})]})}function zg(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const Xx=180,Gx=480,ts=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function Qx({sessions:e=[],cells:t=[],activeSessions:i=[],nodeGroups:s=[],onPick:o,onAddTile:a,onPower:u,onBoot:h,onNodePower:m,onKill:f,onVisibility:_,onNew:b,onNodeRename:w,onSettings:y,onBootError:S,localNodeId:k,fleetCapabilities:C=[],bootSettlement:x=null,onBootSettlementApplied:R,width:D=240,collapsed:T=!1,onResize:ee,onToggleCollapse:V}){const[W,te]=ji(),{pins:K,orders:ie,togglePin:Y,viewFor:A,updateView:N,canMoveRoster:j,moveRoster:L,stepRoster:$}=Zv(),{groupsFor:U,moveNode:B,stepNode:J,nodeKey:z}=t_(),M=new Set((t||[]).map(G=>G.tmuxSession)),I=new Map((e||[]).map(G=>[G.name,G])),se=(G,re)=>O0(K,G,re),ge=z0,de=[...t||[]].sort((G,re)=>ge(se(G.tmuxSession,(I.get(G.tmuxSession)||{}).activity),se(re.tmuxSession,(I.get(re.tmuxSession)||{}).activity))),fe=(e||[]).filter(G=>!M.has(G.name)).sort((G,re)=>ge(se(G.name,G.activity),se(re.name,re.activity))||G.name.localeCompare(re.name)),X=new Set(i||[]),Z=s_(de,fe,I),ye=wr(Z,K,A("local").filter,Qn(ie,"local")),tt=U(s||[]).map(G=>{const re=(G.route||[G.name]).join("/"),F=A(re),{rawItems:H}=rd(G),oe=wr(H,K,F.filter,Qn(ie,re));return{g:G,nodeRoute:re,groupView:F,rawItems:H,items:oe}}),Ye=(G,re,F)=>o&&o({session:G,...re?{node:re}:{},...cs.test(String(F||""))?{ownerId:F}:{}}),Be=async G=>{if(!(G!=null&&G.direct)||!w)return;const re=window.prompt(v("rename-node-prompt"),G.label||G.name);if(re!==null)try{await w(G,re)||window.alert(v("rename-node-invalid"))}catch(F){window.alert(String((F==null?void 0:F.message)||F))}},[ot,Xe]=P.useState({}),[_t,ut]=P.useState(new Set);P.useEffect(()=>{const G=new Map;for(const re of t||[])G.set(ts(re.cell),!!re.boot);for(const re of s||[]){const F=re.route||[re.name];for(const H of re.cells||[])G.set(ts(H.cell,F),!!H.boot)}Xe(re=>{let F=!1;const H={...re};for(const[oe,me]of Object.entries(re))G.has(oe)&&G.get(oe)===me&&(delete H[oe],F=!0);return F?H:re})},[t,s]),P.useEffect(()=>{if(!(x!=null&&x.cell))return;const G=Array.isArray(x.route)?x.route:[],re=ts(x.cell,G);Xe(F=>({...F,[re]:!!x.enabled})),R&&R(x.id)},[x,R]);const ht=(G,re=[])=>{const F=ts(G.cell,re);return Object.prototype.hasOwnProperty.call(ot,F)?ot[F]:!!G.boot},rt=async(G,re,F=[])=>{if(G.stopPropagation(),!h)return;const H=ts(re.cell,F),oe=!ht(re,F);Xe(me=>({...me,[H]:oe})),ut(me=>new Set(me).add(H));try{await h(re.cell,oe,F)}catch(me){Xe(Te=>{const we={...Te};return delete we[H],we}),S&&S(me)}finally{ut(me=>{const Te=new Set(me);return Te.delete(H),Te})}},lt=(G,re=[])=>{const F=ts(G.cell,re),H=ht(G,re),oe=`${v(H?"boot-disable":"boot-enable")} ${G.cell}`;return c.jsx("button",{className:`nc-boot${H?" on":""}`,disabled:_t.has(F),onClick:me=>rt(me,G,re),title:oe,"aria-label":oe,children:c.jsx(it,{name:"boot",size:14})})},[le,ke]=P.useState(null),$e=(G,re)=>{const F=G.currentTarget.getBoundingClientRect();ke({text:re,y:F.top+F.height/2})},We=()=>ke(null),pe=P.useRef(null);P.useEffect(()=>()=>{pe.current&&pe.current()},[]);function Oe(G){G.preventDefault(),G.stopPropagation();const re=G.clientX,F=D,H=me=>{const Te=Math.max(Xx,Math.min(Gx,F+(me.clientX-re)));ee&&ee(Te)},oe=()=>{window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",oe),window.removeEventListener("pointercancel",oe),window.removeEventListener("blur",oe),pe.current=null};window.addEventListener("pointermove",H),window.addEventListener("pointerup",oe),window.addEventListener("pointercancel",oe),window.addEventListener("blur",oe),pe.current=oe}const Me=T?{width:48,flex:"0 0 48px"}:{width:D,flex:`0 0 ${D}px`};return T?c.jsxs("aside",{className:"nc-sidebar mini",style:Me,children:[c.jsx("div",{className:"nc-side-head mini",children:c.jsx("button",{className:"nc-collapse-btn",onClick:V,title:v("expand"),children:"⟩"})}),c.jsx("button",{className:"nc-side-gear mini",onClick:()=>y&&y("nodes",!1),title:v("settings"),onMouseEnter:G=>$e(G,v("settings")),onMouseLeave:We,children:c.jsx(it,{name:"gear",size:16})}),c.jsx("div",{className:"nc-side-scroll mini",children:c.jsxs("div",{className:"nc-side-group mini",children:[A("local").open&&ye.map(G=>G.type==="cell"?(()=>{const re=G.value,F=re.degraded?"warn":re.tmux?"on":"",H=!!re.tmux;return c.jsx("button",{type:"button",className:`nc-mini-dot${X.has(re.tmuxSession)?" active":""}`,onMouseEnter:oe=>$e(oe,`${re.cell}: ${G.subtitle}`),onMouseLeave:We,draggable:H,onDragStart:H?oe=>oe.dataTransfer.setData("text/nc-session",re.tmuxSession):void 0,onClick:H?()=>a&&a(re.tmuxSession):()=>u&&u(re),onDoubleClick:H?()=>Ye(re.tmuxSession,"",k):void 0,children:c.jsx("span",{className:`nc-dot ${F}${G.working?" working":""}`})},G.key)})():(()=>{const re=G.value;return c.jsx("button",{type:"button",className:`nc-mini-init${X.has(re.name)?" active":""}`,onMouseEnter:F=>$e(F,re.name),onMouseLeave:We,draggable:!0,onDragStart:F=>F.dataTransfer.setData("text/nc-session",re.name),onClick:()=>a&&a(re.name),onDoubleClick:()=>Ye(re.name,"",k),children:zg(re.name)},G.key)})()),tt.flatMap(({g:G,nodeRoute:re,groupView:F,items:H})=>G.status==="up"?F.open?H.map(oe=>oe.type==="cell"?(()=>{const me=oe.value,Te=!!me.tmux;return c.jsx("button",{type:"button",className:`nc-mini-dot${X.has(oe.key)?" active":""}`,onMouseEnter:we=>$e(we,`${G.label||re}: ${me.cell} · ${oe.subtitle}`),onMouseLeave:We,draggable:Te,onDragStart:Te?we=>we.dataTransfer.setData("text/nc-session",oe.key):void 0,onClick:Te?()=>a&&a(oe.key):()=>u&&u({...me,route:G.route,availableEngines:G.engines||[]}),onDoubleClick:Te?()=>Ye(me.tmuxSession,re,G.instanceId):void 0,children:c.jsx("span",{className:`nc-dot ${me.degraded?"warn":Te?`on${oe.working?" working":""}`:""}`})},oe.key)})():(()=>{const me=oe.value;return c.jsx("button",{type:"button",className:`nc-mini-init${X.has(oe.key)?" active":""}`,onMouseEnter:Te=>$e(Te,`${G.label||re}: ${me.name}`),onMouseLeave:We,draggable:!0,onDragStart:Te=>Te.dataTransfer.setData("text/nc-session",oe.key),onClick:()=>a&&a(oe.key),onDoubleClick:()=>Ye(me.name,re,G.instanceId),children:zg(me.name)},oe.key)})()):[]:[c.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:oe=>$e(oe,`${G.label||(G.route||[G.name]).join(" › ")}: ${ss(G)}`),onMouseLeave:We,children:c.jsx("span",{className:`nc-dot${G.status==="passive"?"":" warn"}`})},`nodo-${(G.route||[G.name]).join("/")}`)])]})}),le&&c.jsx("div",{className:"nc-mini-tip",style:{top:le.y},children:le.text})]}):c.jsxs("aside",{className:"nc-sidebar",style:Me,children:[c.jsxs("div",{className:"nc-side-head",children:[c.jsx("button",{className:"nc-collapse-btn",onClick:V,title:v("collapse"),children:"⟨"}),c.jsx("span",{className:"nc-side-title",children:v("fleet")}),c.jsxs("button",{className:"nc-new-btn",onClick:b,title:v("fleet-new-cell"),children:["+ ",v("new")]})]}),c.jsxs("button",{className:"nc-side-gear",onClick:()=>y&&y("nodes",!1),title:v("settings"),children:[c.jsx(it,{name:"gear",size:15})," ",v("settings")]}),c.jsxs("div",{className:"nc-side-scroll",children:[c.jsx(Jx,{label:v("position-local"),count:ye.length,state:A("local"),onToggle:()=>N("local",{open:!A("local").open}),onFilter:G=>N("local",{filter:G})}),A("local").open&&c.jsxs("div",{className:"nc-side-group",children:[ye.map(G=>G.type==="cell"?(()=>{const re=G.value,F=re.degraded?"warn":re.tmux?"on":"",H=re.degraded?v("cell-degraded"):G.working?G.subtitle:re.tmux?v("cell-idle"):v("cell-off"),oe=!!re.tmux;return c.jsxs("div",{"data-roster-key":G.key,"data-position":"local",className:`nc-cell${oe?" live":""}${X.has(re.tmuxSession)?" active":""}`,title:`${re.cell} · ${G.subtitle}${H===G.subtitle?"":` · ${H}`}`,"aria-label":`${re.cell}, ${G.subtitle}${H===G.subtitle?"":`, ${H}`}`,draggable:oe,onDragStart:oe?me=>me.dataTransfer.setData("text/nc-session",re.tmuxSession):void 0,onClick:oe?()=>a&&a(re.tmuxSession):void 0,onDoubleClick:oe?()=>Ye(re.tmuxSession,"",k):void 0,children:[c.jsx(Xn,{position:"local",itemKey:G.key,label:re.cell,canMove:j,onMove:(me,Te)=>L("local",me,Te,Z),onStep:me=>$("local",G.key,me,Z)}),c.jsx("span",{className:`nc-dot ${F}${G.working?" working":""}`}),c.jsxs("span",{className:"nc-cell-main",children:[c.jsx("b",{title:re.cell,children:re.cell}),c.jsx("small",{title:G.subtitle,children:G.subtitle})]}),c.jsx("button",{className:`nc-pin${K.includes(G.key)?" on":""}`,title:v("pin"),onClick:me=>{me.stopPropagation(),Y(G.key)},children:K.includes(G.key)?"★":"☆"}),h&&C.includes("boot")&&lt(re),c.jsx("button",{className:`nc-power${re.tmux?" on":""}${re.degraded?" warn":""}`,onClick:me=>{me.stopPropagation(),u&&u({...re,boot:ht(re)})},title:re.active?v("power-off"):v("power-on"),children:c.jsx(it,{name:"power",size:14})})]},G.key)})():(()=>{var F;const re=G.value;return c.jsxs("div",{"data-roster-key":G.key,"data-position":"local",className:`nc-side-card${X.has(re.name)?" active":""}`,draggable:!0,onDragStart:H=>H.dataTransfer.setData("text/nc-session",re.name),onClick:()=>a&&a(re.name),onDoubleClick:()=>Ye(re.name,"",k),children:[c.jsx(Xn,{position:"local",itemKey:G.key,label:re.name,canMove:j,onMove:(H,oe)=>L("local",H,oe,Z),onStep:H=>$("local",G.key,H,Z)}),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.jsxs("small",{children:[re.preview||re.cmd||v("windows").replace("{n}",String(re.windows||0)),((F=re.outbox)==null?void 0:F.count)>0?` · 📦${re.outbox.count}`:""]})]}),re.activity?c.jsx("span",{className:"nc-rel",children:ls(re.activity)}):null,c.jsx("button",{className:`nc-pin${K.includes(G.key)?" on":""}`,title:v("pin"),onClick:H=>{H.stopPropagation(),Y(G.key)},children:K.includes(G.key)?"★":"☆"}),c.jsx("button",{className:`nc-technical${re.technical?" on":""}`,title:re.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${re.technical?v("mark-normal"):v("mark-technical")} ${re.name}`,onClick:H=>{H.stopPropagation(),_&&_(re.name,!re.technical,[])},children:"T"}),c.jsx("button",{className:"nc-menu",title:v("terminate"),onClick:H=>{H.stopPropagation(),window.confirm(v("terminate-confirm").replace("{name}",re.name))&&f&&f(re.name)},children:"⋯"})]},G.key)})()),ye.length===0&&c.jsx("div",{className:"nc-empty",children:v("no-sessions-short")})]}),tt.map(({g:G,nodeRoute:re,groupView:F,rawItems:H,items:oe})=>{const Te=i_(G.health)||(G.status==="up"?"on":G.status==="passive"?"":"warn");return c.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":z(G),children:[c.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:G.direct&&w?we=>{we.preventDefault(),Be(G)}:void 0,onClick:()=>N(re,{open:!F.open}),onKeyDown:we=>{(we.key==="Enter"||we.key===" ")&&(we.preventDefault(),N(re,{open:!F.open}))},children:[c.jsx(Xn,{scope:"node",position:"nodes",itemKey:z(G),label:G.label||G.name,onMove:(we,Ce)=>B(we,Ce,s||[]),onStep:we=>J(z(G),we,s||[])}),c.jsx("span",{className:"nc-node-chevron",children:F.open?"⌄":"›"}),c.jsx("span",{className:`nc-dot ${Te}`,title:G.health?sl(G.health):""}),c.jsx("b",{children:G.label||G.name}),c.jsxs("small",{children:[" · ",G.status==="up"?v("node-sessions").replace("{n}",String(oe.length)):G.health&&sl(G.health)||ss(G)]}),c.jsxs("select",{className:"nc-node-filter",value:F.filter,title:v(`view-${F.filter}`),onClick:we=>we.stopPropagation(),onChange:we=>N(re,{filter:we.target.value}),children:[c.jsx("option",{value:"all",children:v("view-all")}),c.jsx("option",{value:"pinned",children:v("view-pinned")}),c.jsx("option",{value:"active",children:v("view-active")}),c.jsx("option",{value:"off",children:v("view-off")}),c.jsx("option",{value:"technical",children:v("view-technical")})]}),G.direct&&w&&c.jsx("button",{type:"button",className:"nc-node-rename",title:v("rename-node"),"aria-label":`${v("rename-node")} ${G.label||G.name}`,onClick:we=>{we.stopPropagation(),Be(G)},children:"✎"}),G.direct&&G.health&&G.health.managed!==!1&&c.jsx("button",{type:"button",className:`nc-power${G.tunnelStatus==="up"?" on":""}`,title:G.tunnelStatus==="up"?v("power-off"):v("power-on"),onClick:we=>{we.stopPropagation(),m&&m(G)},children:c.jsx(it,{name:"power",size:14})})]}),G.status==="up"&&F.open&&c.jsxs("div",{className:"nc-side-group",children:[oe.map(we=>we.type==="cell"?(()=>{const Ce=we.value,He=!!Ce.tmux,Zt=Ce.degraded?"warn":Ce.tmux?"on":"";return c.jsxs("div",{"data-roster-key":we.key,"data-position":re,className:`nc-side-card nc-cell${He?" live":""}${X.has(Ce.key)?" active":""}`,title:we.working?we.subtitle:Ce.tmux?v("cell-idle"):v("cell-off"),draggable:He,onDragStart:He?Qe=>Qe.dataTransfer.setData("text/nc-session",Ce.key):void 0,onClick:He?()=>a&&a(Ce.key):void 0,onDoubleClick:He?()=>Ye(Ce.tmuxSession,re,G.instanceId):void 0,children:[c.jsx(Xn,{position:re,itemKey:we.key,label:Ce.cell,canMove:j,onMove:(Qe,Di)=>L(re,Qe,Di,H),onStep:Qe=>$(re,we.key,Qe,H)}),c.jsx("span",{className:`nc-dot ${Zt}${we.working?" working":""}`}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:Ce.cell}),c.jsx("small",{title:we.subtitle,children:we.subtitle})]}),c.jsx("button",{className:`nc-pin${K.includes(we.key)?" on":""}`,title:v("pin"),onClick:Qe=>{Qe.stopPropagation(),Y(we.key)},children:K.includes(we.key)?"★":"☆"}),h&&(G.capabilities||[]).includes("boot")&&lt(Ce,G.route||[]),(G.capabilities||[]).includes(Ce.active?"down":"up")&&c.jsx("button",{className:`nc-power${Ce.active?" on":""}${Ce.degraded?" warn":""}`,onClick:Qe=>{Qe.stopPropagation(),u&&u({...Ce,boot:ht(Ce,G.route||[]),route:G.route,availableEngines:G.engines||[]})},title:Ce.active?v("power-off"):v("power-on"),children:c.jsx(it,{name:"power",size:14})})]},we.key)})():(()=>{const Ce=we.value;return c.jsxs("div",{"data-roster-key":we.key,"data-position":re,className:`nc-side-card${X.has(Ce.key)?" active":""}`,draggable:!0,onDragStart:He=>He.dataTransfer.setData("text/nc-session",Ce.key),onClick:()=>a&&a(Ce.key),onDoubleClick:()=>Ye(Ce.name,Ce.node||re,G.instanceId),children:[c.jsx(Xn,{position:re,itemKey:we.key,label:Ce.name,canMove:j,onMove:(He,Zt)=>L(re,He,Zt,H),onStep:He=>$(re,we.key,He,H)}),c.jsx("span",{className:Ce.attached?"nc-dot on":"nc-dot"}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:Ce.name}),c.jsx("small",{children:Ce.preview?Ce.preview:Ce.cmd?Ce.cmd:v("windows").replace("{n}",String(Ce.windows||0))})]}),Ce.activity?c.jsx("span",{className:"nc-rel",children:ls(Ce.activity)}):null,c.jsx("button",{className:`nc-pin${K.includes(we.key)?" on":""}`,title:v("pin"),onClick:He=>{He.stopPropagation(),Y(we.key)},children:K.includes(we.key)?"★":"☆"}),c.jsx("button",{className:`nc-technical${Ce.technical?" on":""}`,title:Ce.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${Ce.technical?v("mark-normal"):v("mark-technical")} ${Ce.name}`,onClick:He=>{He.stopPropagation(),_&&_(Ce.name,!Ce.technical,G.route||[])},children:"T"}),c.jsx("button",{className:"nc-menu",title:v("terminate"),onClick:He=>{He.stopPropagation(),window.confirm(v("terminate-confirm").replace("{name}",Ce.name))&&f&&f(Ce.name,G.route)},children:"⋯"})]},we.key)})()),oe.length===0&&c.jsx("div",{className:"nc-empty",children:v("no-sessions-short")})]})]},`nodo-${(G.route||[G.name]).join("/")}`)})]}),c.jsx("div",{className:"nc-side-lang",children:Jv.map((G,re)=>c.jsxs("span",{children:[re>0&&" · ",c.jsx("button",{className:`nc-lang-btn${W===G?" on":""}`,onClick:()=>te(G),title:G,children:G.toUpperCase()})]},G))}),c.jsx("div",{className:"nc-side-resize",onPointerDown:Oe,title:""})]})}function Jx({label:e,count:t,state:i,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:i.open?"⌄":"›"}),c.jsx("span",{className:"nc-dot on"}),c.jsx("b",{children:e}),c.jsxs("small",{children:[" · ",v("node-sessions").replace("{n}",String(t))]}),c.jsxs("select",{className:"nc-node-filter",value:i.filter,title:v(`view-${i.filter}`),onClick:a=>a.stopPropagation(),onChange:a=>o(a.target.value),children:[c.jsx("option",{value:"all",children:v("view-all")}),c.jsx("option",{value:"pinned",children:v("view-pinned")}),c.jsx("option",{value:"active",children:v("view-active")}),c.jsx("option",{value:"off",children:v("view-off")}),c.jsx("option",{value:"technical",children:v("view-technical")})]})]})}function Zx(e,t,i){return!e&&t?i+1:i}function eC({session:e,node:t,ownerId:i,cellName:s,token:o,readonly:a=!1,focused:u,onFocus:h,onClose:m,onOpenSingle:f,alive:_=!0,available:b=!0,fontSize:w=bo,onZoom:y,decks:S=[],currentDeck:k,onSendToDeck:C}){const x=s||e,R=P.useRef(()=>{}),D=P.useRef(()=>!1),T=P.useRef(()=>{}),ee=P.useRef(!1),[V,W]=P.useState(!1),[te,K]=P.useState(!1),[ie,Y]=P.useState(!1),[A,N]=P.useState(null),[j,L]=P.useState(0),$=P.useRef(_),U=t?`${t}:${e}`:e,B=S.filter(J=>J.id!==k&&J.available!==!1);return P.useEffect(()=>{const J=$.current;!J&&_&&L(z=>Zx(J,_,z)),$.current=_},[_]),c.jsxs("div",{className:`nc-tile${u?" focused":""}`,onMouseDown:()=>h&&h(U),children:[c.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:J=>{J.dataTransfer.setData("text/nc-session",U),J.dataTransfer.effectAllowed="move"},children:[c.jsxs("button",{className:"nc-tile-name",onClick:()=>h&&h(U),title:t?`${x} · ${t}`:x,children:[c.jsx("span",{className:_?"nc-dot on":"nc-dot"}),c.jsx("b",{children:x})]}),c.jsxs("span",{className:"nc-tile-actions",children:[y&&c.jsx("button",{onClick:()=>y(-1),title:v("zoom-out"),children:c.jsx(it,{name:"zoomOut",size:14})}),y&&c.jsx("button",{onClick:()=>y(1),title:v("zoom-in"),children:c.jsx(it,{name:"zoomIn",size:14})}),C&&B.length>0&&c.jsxs("select",{className:"nc-tile-deck",title:v("send-to-deck"),value:"",onMouseDown:J=>J.stopPropagation(),onChange:J=>{const z=J.target.value;z&&C(U,z),J.target.value=""},children:[c.jsx("option",{value:"",children:v("send-to-deck")}),B.map(J=>c.jsxs("option",{value:J.id,children:[J.ownerLabel," · ",J.name]},J.id))]}),c.jsx("button",{onClick:()=>K(J=>!J),title:"composer",children:"⌨"}),c.jsx("button",{onClick:()=>Y(J=>!J),title:"file",children:"📁"}),f&&c.jsx("button",{onClick:()=>f({session:e,node:t,ownerId:i}),title:"vista singola",children:"↗"}),m&&c.jsx("button",{className:"nc-tile-close",onClick:()=>m(U),title:"chiudi",children:"✕"})]})]}),c.jsxs("div",{className:"nc-tile-body",children:[b?c.jsx(iy,{session:e,node:t,token:o,readonly:a,takeSize:!1,focused:u,sendRef:R,composerRef:D,actionRef:T,ctrlRef:ee,setCtrlArmed:W,onFiles:N,fontSize:w},`${U}:${j}`):c.jsx("div",{className:"nc-tile-unavailable",children:v("deck-owner-unavailable")}),b&&ie&&c.jsx("div",{className:"nc-tile-files",onMouseDown:J=>J.stopPropagation(),children:c.jsx(ny,{session:e,node:t,token:o,filesEvent:A,onClose:()=>Y(!1)})})]}),b&&te&&c.jsx("div",{className:"nc-tile-composer",onMouseDown:J=>J.stopPropagation(),children:c.jsx(hy,{submitText:J=>D.current(J),token:o,session:e,node:t,ownerId:i})})]})}function tC({session:e,node:t,ownerId:i,cells:s,nodeGroups:o}={}){const a=typeof e=="string"?e:"";if(!a)return null;if(t){const h=Array.isArray(o)?o:[];for(const m of h){if(!m||(Array.isArray(m.route)?m.route:[]).join("/")!==t||i&&m.instanceId&&String(i)!==String(m.instanceId))continue;const _=(Array.isArray(m.cells)?m.cells:[]).find(b=>b&&b.tmuxSession===a);if(_)return _}return null}return(Array.isArray(s)?s:[]).find(h=>h&&h.tmuxSession===a)||null}function bh({session:e,cell:t,node:i,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=tC({session:u,node:i,ownerId:s,cells:o,nodeGroups:a});return h&&h.cell?h.cell:u}const Fg=.2,$g=.28,fy=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),Eu=e=>fy(e,"text/nc-session"),Hg=e=>{var t;return fy(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function iC(e,t,i){const s=(e-i.left)/(i.width||1),o=(t-i.top)/(i.height||1);return s<$g?"left":s>1-$g?"right":o<.5?"top":"bottom"}function nC({layout:e,onLayoutChange:t,token:i,readonly:s=!1,sessionsAlive:o,focusSession:a,onFocus:u,onOpenSingle:h,decks:m=[],currentDeck:f,onSendToDeck:_,cells:b=[],nodeGroups:w=[]}){ji();const[y,S]=P.useState(null),k=P.useRef(null),C=P.useRef([]),x=P.useRef(null);function R(Y,A){const N=()=>{window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",N),window.removeEventListener("pointercancel",N),window.removeEventListener("blur",N),x.current=null};window.addEventListener("pointermove",Y),window.addEventListener("pointerup",N),window.addEventListener("pointercancel",N),window.addEventListener("blur",N),x.current=N}P.useEffect(()=>()=>{x.current&&x.current()},[]),P.useEffect(()=>{const Y=()=>S(null);return window.addEventListener("dragend",Y),window.addEventListener("drop",Y),()=>{window.removeEventListener("dragend",Y),window.removeEventListener("drop",Y)}},[]);const D=e.columns.length,T=Y=>y&&y.col===Y&&y.row===void 0,ee=!!y&&y.col===D,V=(Y,A)=>y&&y.col===Y&&y.row===A&&y.quadrant?` drop-${y.quadrant}`:"";function W(Y){if(Y.preventDefault(),Hg(Y.dataTransfer)){S(null);return}const A=Y.dataTransfer.getData("text/nc-session"),N=y;if(S(null),!A||!N)return;let j;if(N.quadrant){if(j=J0(e,N.col,N.row,N.quadrant),!j)return}else j={col:N.col};t(ln(e).includes(A)?V0(e,A,j):uh(e,A,j))}function te(Y,A){Y.preventDefault(),Y.stopPropagation();const N=Y.clientX,j=e.columns[A].width,L=k.current&&k.current.clientWidth||1,$=e.columns[A+1];R(B=>{let J=Math.max(Fg,j+(B.clientX-N)/L);if($){const z=Lm(J/(J+$.width));J=z/(1-z)*$.width}t(X0(e,A,J))})}function K(Y,A,N){Y.preventDefault(),Y.stopPropagation();const j=Y.clientY,L=e.columns[A].tiles[N].height,$=C.current[A],U=$&&$.clientHeight||1,B=e.columns[A].tiles[N+1];R(z=>{let M=Math.max(Fg,L+(z.clientY-j)/U);if(B){const I=Lm(M/(M+B.height));M=I/(1-I)*B.height}t(G0(e,A,N,M))})}function ie(Y){t(ll(e,Y))}return c.jsxs("div",{className:"nc-grid",ref:k,onDragOver:Y=>{if(Hg(Y.dataTransfer)){Y.preventDefault(),S(null);return}Eu(Y.dataTransfer)&&(Y.preventDefault(),y&&y.col===D||S({col:D}))},onDrop:W,onDragLeave:Y=>{const A=Y.relatedTarget;(!A||!(k.current&&k.current.contains(A)))&&S(null)},children:[e.columns.flatMap((Y,A)=>{const N=[];return N.push(c.jsx("div",{className:`nc-col${T(A)?" drop-newcol":""}`,ref:j=>{C.current[A]=j},style:{flexGrow:Y.width,flexBasis:0},onDragOver:j=>{Eu(j.dataTransfer)&&(j.preventDefault(),j.stopPropagation(),y&&y.col===A&&y.row===void 0||S({col:A}))},children:Y.tiles.flatMap((j,L)=>{const $=[],U=Ri(j),B=bh({session:j.session,node:j.node,ownerId:j.ownerId,cells:b,nodeGroups:w});return $.push(c.jsx("div",{className:`nc-tile-slot${V(A,L)}`,style:{flexGrow:j.height,flexBasis:0},onDragOver:J=>{if(!Eu(J.dataTransfer))return;J.preventDefault(),J.stopPropagation();const z=iC(J.clientX,J.clientY,J.currentTarget.getBoundingClientRect());y&&y.col===A&&y.row===L&&y.quadrant===z||S({col:A,row:L,quadrant:z})},children:c.jsx(eC,{session:j.session,node:j.node,ownerId:j.ownerId,cellName:B,token:i,readonly:s,focused:a===U,onFocus:u,onClose:ie,onOpenSingle:h,available:j.unavailable!==!0,alive:j.unavailable!==!0&&(!o||o.has(U)),fontSize:j.fontSize,onZoom:J=>t(Q0(e,A,L,J)),decks:m,currentDeck:f,onSendToDeck:_})},U)),L<Y.tiles.length-1&&$.push(c.jsx("div",{className:"nc-divider-h",onPointerDown:J=>K(J,A,L)},`h${L}`)),$})},`c${A}`)),A<D-1&&N.push(c.jsx("div",{className:"nc-divider-v",onPointerDown:j=>te(j,A)},`v${A}`)),N}),ee&&c.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),D===0&&c.jsx("div",{className:"nc-grid-empty",children:v("grid-empty")})]})}const wn="local",Hi=/^[a-f0-9]{16,64}$/;function as(e,t){return`${e&&Hi.test(e)?e:wn}:${t}`}function kh(e){const t=String(e||""),i=t.indexOf(":");if(i<1)return null;const s=t.slice(0,i),o=t.slice(i+1);return s!==wn&&!Hi.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===wn?null:s,name:o}}function kl(e){return Array.isArray(e)&&e.length?e.join("/"):""}function xh(e){return{columns:br(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))}}function rC(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&Hi.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(kl(i.route),i.instanceId);return t}function sC(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&Hi.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(i.instanceId,[...i.route]);return t}function qd(e,t,i=[]){const s=xh(e),o=rC(i);for(const a of s.columns)for(const u of a.tiles)u.ownerId||(!u.node&&Hi.test(String(t||""))?u.ownerId=t:u.node&&o.has(u.node)&&(u.ownerId=o.get(u.node)));return s}function Vd(e,t,i=[]){const s=xh(e),o=new Map;for(const a of i)a&&Hi.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=kl(o.get(u.ownerId)),delete u.unavailable):u.unavailable=!0);return s}function Wg(e,t,i=[]){const s=xh(e),o=sC(i);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=kl(o.get(u.ownerId))));return s}function py(e,t,i=[]){const s=er(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...Hi.test(String(t||""))?{ownerId:t}:{}};const o=i.find(a=>kl(a&&a.route)===s.node);return{...s,...o&&Hi.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const oC=/^[a-z0-9-]{1,32}$/,Pi="main",my="nc_decks",gy="nc_deck_order_v1",vy=24;function Ug(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function hs(e){return typeof e=="string"&&oC.test(e)}function aC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let i;try{i=decodeURIComponent(t[1])}catch{i=t[1]}return hs(i)?i:Pi}return Pi}function lC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:as(null,Pi),ownerId:null,name:Pi}}if(Hi.test(s)&&hs(o))return{id:as(s,o),ownerId:s,name:o}}const i=aC(e);return{id:as(null,i),ownerId:null,name:i}}function Nu(e,t){const i=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:kh(e)||{ownerId:null,name:e},s=hs(i.name)?i.name:Pi,o=i.ownerId?`/deck/${encodeURIComponent(i.ownerId)}/${encodeURIComponent(s)}`:s===Pi?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function _y(e){return e===Pi?"nc_grid_v1":`nc_grid_v1__${e}`}function yy(e){const t=[Pi];if(Array.isArray(e)){for(const i of e)if(hs(i)&&i!==Pi&&!t.includes(i)&&t.push(i),t.length>=vy)break}return t}function gs(){return typeof localStorage<"u"?localStorage:null}function cC(){const e=gs();if(!e)return[Pi];try{return yy(JSON.parse(e.getItem(my)||"null"))}catch{return[Pi]}}function uC(e){const t=gs();if(t)try{t.setItem(my,JSON.stringify(yy(e)))}catch{}}function Ro(e){return e==="local"||Hi.test(String(e||""))}function xl(e,t){const i=kh(e);return!!i&&(i.ownerId||"local")===t}function un(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[i,s]of Object.entries(e).slice(0,64)){if(!Ro(i)||!Array.isArray(s))continue;const o=[...new Set(s.filter(a=>typeof a=="string"&&a.length<=100&&xl(a,i)))].slice(0,vy);o.length&&(t[i]=o)}return t}function qa(e=gs()){if(!e)return{};try{return un(JSON.parse(e.getItem(gy)||"null"))}catch{return{}}}function Ru(e,t=gs()){const i=un(e);if(t)try{t.setItem(gy,JSON.stringify(i))}catch{}return i}function Cl(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function dC(e,t,i,s,o=[]){if(!Ro(t)||i===s)return un(e);const a=[...new Set(o.filter(b=>xl(b,t)))];if(!a.includes(i)||!a.includes(s))return un(e);const u=Cl(e,t).filter(b=>a.includes(b)),h=[...u,...a.filter(b=>!u.includes(b))],m=h.indexOf(i),f=h.indexOf(s);h.splice(m,1);const _=h.indexOf(s);return h.splice(m<f?_+1:_,0,i),un({...e,[t]:h})}function hC(e,t,i,s){if(!Ro(t)||!xl(s,t))return un(e);const o=Cl(e,t);return o.includes(i)?un({...e,[t]:o.map(a=>a===i?s:a)}):un(e)}function fC(e,t,i){return Ro(t)?un({...e,[t]:Cl(e,t).filter(s=>s!==i)}):un(e)}function Kg(e,t={}){const i=new Map;for(const o of Array.isArray(e)?e:[]){const a=o!=null&&o.local?"local":String((o==null?void 0:o.ownerId)||"");!Ro(a)||!xl(o==null?void 0:o.id,a)||(i.has(a)||i.set(a,[]),i.get(a).push(o))}const s=[];for(const[,o]of i){const a=o[0].local?"local":o[0].ownerId,u=Cl(t,a),h=new Map(u.map((m,f)=>[m,f]));o.sort((m,f)=>{const _=h.has(m.id)?h.get(m.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 Yd(e){const t=gs();if(!t)return null;try{return JSON.parse(t.getItem(_y(e))||"null")}catch{return null}}function pC(e,t){const i=gs();if(i)try{i.setItem(_y(e),JSON.stringify(t))}catch{}}const qg=52,Vg=18;function mC({ownerKey:e,deckId:t,label:i,onMove:s,onStep:o}){const a=P.useRef(null),u=P.useRef(0),[h,m]=P.useState(!1),f=()=>{var k,C,x,R;const S=a.current;(C=(k=S==null?void 0:S.over)==null?void 0:k.classList)==null||C.remove("nc-deck-over"),(R=(x=S==null?void 0:S.source)==null?void 0:x.classList)==null||R.remove("nc-deck-dragging"),u.current&&cancelAnimationFrame(u.current),u.current=0},_=(S=!1)=>{const k=a.current;if(!k)return;const C=k.target;f(),a.current=null,m(!1);try{k.handle.releasePointerCapture(k.pointerId)}catch{}S&&C&&C!==t&&s(t,C)},b=(S,k)=>{var T,ee,V,W,te,K,ie,Y;const C=a.current;if(!C)return;C.x=S,C.y=k;const x=(ee=(T=document.elementFromPoint(S,k))==null?void 0:T.closest)==null?void 0:ee.call(T,"[data-deck-id][data-owner-key]"),R=(V=x==null?void 0:x.dataset)==null?void 0:V.deckId,D=((W=x==null?void 0:x.dataset)==null?void 0:W.ownerKey)===e&&R&&R!==t;C.over!==(D?x:null)&&((K=(te=C.over)==null?void 0:te.classList)==null||K.remove("nc-deck-over"),C.over=D?x:null,(Y=(ie=C.over)==null?void 0:ie.classList)==null||Y.add("nc-deck-over")),C.target=D?R:null},w=()=>{var C,x;const S=a.current;if(!S){u.current=0;return}const k=(x=(C=S.container)==null?void 0:C.getBoundingClientRect)==null?void 0:x.call(C);if(k){const R=S.x<k.left+qg?-Vg:S.x>k.right-qg?Vg:0;R&&(S.container.scrollLeft+=R,b(S.x,S.y))}u.current=requestAnimationFrame(w)};P.useEffect(()=>{const S=C=>{C.key==="Escape"&&a.current&&(C.preventDefault(),_(!1))},k=()=>_(!1);return window.addEventListener("keydown",S),window.addEventListener("blur",k),()=>{window.removeEventListener("keydown",S),window.removeEventListener("blur",k),f(),a.current=null}},[t,e]);const y=S=>{var x;if(S.pointerType==="mouse"&&S.button!==0)return;S.preventDefault(),S.stopPropagation(),S.currentTarget.focus({preventScroll:!0});const k=S.currentTarget.closest("[data-deck-id][data-owner-key]"),C=S.currentTarget.closest(".nc-deckbar");a.current={pointerId:S.pointerId,handle:S.currentTarget,source:k,container:C,target:null,over:null,x:S.clientX,y:S.clientY},(x=k==null?void 0:k.classList)==null||x.add("nc-deck-dragging");try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}m(!0),u.current=requestAnimationFrame(w)};return c.jsx("button",{type:"button",className:`nc-deck-handle${h?" active":""}`,"aria-label":`${v("reorder")} ${i}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:v("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:y,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 gC({decks:e=[],currentDeck:t="local:main",onCreate:i,onRename:s,onDelete:o,onReorder:a,onOpenWindow:u,onNavigate:h,saveState:m="idle",error:f="",sidebarVisible:_,onToggleSidebar:b}){ji();const[w,y]=P.useState(null),[S,k]=P.useState(""),[C,x]=P.useState(!1),[R,D]=P.useState(""),[T,ee]=P.useState(""),V=Ug(S),W=hs(V),te=[];for(const N of e){const j=N.local?"local":N.ownerId;let L=te.find($=>$.key===j);L||(L={key:j,label:N.ownerLabel||(N.local?"Local":j),local:!!N.local,decks:[]},te.push(L)),L.decks.push(N)}const K=async()=>{if(W){x(!0),D("");try{i&&await i(V,w),k(""),y(null)}catch(N){D(String(N.message||N))}x(!1)}},ie=N=>{ee(""),u&&u(N.id)||ee(N.id)},Y=async N=>{if(!(N.id===t||!h||C||N.available===!1)){x(!0),D("");try{await h(N.id)}catch(j){D(String((j==null?void 0:j.message)||j))}x(!1)}},A=(N,j,L)=>{const $=N.decks.findIndex(B=>B.id===j.id),U=N.decks[$+L];$>=0&&U&&a&&!C&&a(j.id,U.id)};return c.jsxs("div",{className:"nc-deckbar",children:[b&&c.jsx("button",{className:"nc-deck-sidebar-toggle",title:v("toggle-sidebar"),onClick:b,children:_?"◀":"☰"}),c.jsx("span",{className:"nc-deckbar-label",children:v("decks")}),c.jsx("div",{className:"nc-deck-chips",children:te.map(N=>c.jsxs("span",{className:"nc-deck-owner-group",children:[c.jsx("span",{className:"nc-deck-owner",children:N.local?"Local":N.label}),N.decks.map(j=>c.jsxs("span",{"data-deck-id":j.id,"data-owner-key":N.key,className:`nc-deck-chip${j.id===t?" current":""}${j.available===!1?" offline":""}`,children:[c.jsx(mC,{ownerKey:N.key,deckId:j.id,label:`${N.label} · ${j.name}`,onMove:(L,$)=>{a&&!C&&a(L,$)},onStep:L=>A(N,j,L)}),c.jsxs("button",{className:"nc-deck-open",title:j.available===!1?`${j.ownerLabel} offline`:j.id===t?v("deck-current"):`${j.ownerLabel} · ${j.name}`,disabled:C||j.available===!1,onClick:()=>Y(j),children:[j.name,j.id===t?" •":""]}),c.jsx("button",{className:"nc-deck-mini",disabled:j.available===!1,title:v("detach-deck"),onClick:()=>ie(j),children:"↗"}),j.name!==Pi&&c.jsxs(c.Fragment,{children:[c.jsx("button",{className:"nc-deck-mini",disabled:j.available===!1,title:v("rename-deck"),onClick:()=>{const L=(typeof window<"u"?window.prompt(v("rename-deck"),j.name):"")||"",$=Ug(L);hs($)&&$!==j.name&&s&&s(j.id,$).catch(U=>D(String(U.message||U)))},children:"✎"}),c.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:j.available===!1,title:v("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(v("delete-deck-confirm").replace("{name}",`${j.ownerLabel} · ${j.name}`)))&&o&&o(j.id).catch(L=>D(String(L.message||L)))},children:"✕"})]})]},j.id)),w===N.key?c.jsxs("span",{className:"nc-deck-add",children:[c.jsx("input",{autoFocus:!0,className:W||!S?"":"invalid",placeholder:v("deck-name"),value:S,onChange:j=>k(j.target.value),onKeyDown:j=>{j.key==="Enter"&&K(),j.key==="Escape"&&(k(""),y(null))}}),S&&W&&V!==S&&c.jsxs("span",{className:"nc-deck-slug",children:["→ ",V]}),c.jsx("button",{className:"nc-deck-ok",disabled:!W||C,onClick:K,children:v("create")}),c.jsx("button",{className:"nc-deck-cancel",onClick:()=>{k(""),y(null)},children:v("cancel")})]}):c.jsxs("button",{className:"nc-deck-newbtn",disabled:C||N.decks.every(j=>j.available===!1),title:`${v("new-deck")} · ${N.label}`,onClick:()=>{k(""),y(N.key)},children:["+ ",v("new")]})]},N.key))}),c.jsx("span",{className:`nc-deck-state ${m}`,title:v("deck-autosave"),children:v(m==="saving"?"saving":m==="saved"?"saved":"deck-autosave")}),(R||f)&&c.jsx("span",{className:"nc-deck-error",children:R||f}),T&&c.jsx("button",{className:"nc-deck-fallback",onClick:()=>u&&u(T),children:v("popup-blocked")})]})}var is={},Pu,Yg;function vC(){return Yg||(Yg=1,Pu=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Pu}var ju={},Vn={},Xg;function Rr(){if(Xg)return Vn;Xg=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 Vn.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},Vn.getSymbolTotalCodewords=function(s){return t[s]},Vn.getBCHDigit=function(i){let s=0;for(;i!==0;)s++,i>>>=1;return s},Vn.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},Vn.isKanjiModeEnabled=function(){return typeof e<"u"},Vn.toSJIS=function(s){return e(s)},Vn}var Du={},Gg;function Ch(){return Gg||(Gg=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.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: "+i)}}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}}})(Du)),Du}var Lu,Qg;function _C(){if(Qg)return Lu;Qg=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const i=Math.floor(t/8);return(this.buffer[i]>>>7-t%8&1)===1},put:function(t,i){for(let s=0;s<i;s++)this.putBit((t>>>i-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const i=Math.floor(this.length/8);this.buffer.length<=i&&this.buffer.push(0),t&&(this.buffer[i]|=128>>>this.length%8),this.length++}},Lu=e,Lu}var Mu,Jg;function yC(){if(Jg)return Mu;Jg=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,i,s,o){const a=t*this.size+i;this.data[a]=s,o&&(this.reservedBit[a]=!0)},e.prototype.get=function(t,i){return this.data[t*this.size+i]},e.prototype.xor=function(t,i,s){this.data[t*this.size+i]^=s},e.prototype.isReserved=function(t,i){return this.reservedBit[t*this.size+i]},Mu=e,Mu}var Tu={},Zg;function SC(){return Zg||(Zg=1,(function(e){const t=Rr().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 m=1;m<o-1;m++)h[m]=h[m-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 m=0;m<u;m++)h===0&&m===0||h===0&&m===u-1||h===u-1&&m===0||o.push([a[h],a[m]]);return o}})(Tu)),Tu}var Au={},ev;function wC(){if(ev)return Au;ev=1;const e=Rr().getSymbolSize,t=7;return Au.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},Au}var Iu={},tv;function bC(){return tv||(tv=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,m=0,f=null,_=null;for(let b=0;b<a;b++){h=m=0,f=_=null;for(let w=0;w<a;w++){let y=o.get(b,w);y===f?h++:(h>=5&&(u+=t.N1+(h-5)),f=y,h=1),y=o.get(w,b),y===_?m++:(m>=5&&(u+=t.N1+(m-5)),_=y,m=1)}h>=5&&(u+=t.N1+(h-5)),m>=5&&(u+=t.N1+(m-5))}return u},e.getPenaltyN2=function(o){const a=o.size;let u=0;for(let h=0;h<a-1;h++)for(let m=0;m<a-1;m++){const f=o.get(h,m)+o.get(h,m+1)+o.get(h+1,m)+o.get(h+1,m+1);(f===4||f===0)&&u++}return u*t.N2},e.getPenaltyN3=function(o){const a=o.size;let u=0,h=0,m=0;for(let f=0;f<a;f++){h=m=0;for(let _=0;_<a;_++)h=h<<1&2047|o.get(f,_),_>=10&&(h===1488||h===93)&&u++,m=m<<1&2047|o.get(_,f),_>=10&&(m===1488||m===93)&&u++}return u*t.N3},e.getPenaltyN4=function(o){let a=0;const u=o.data.length;for(let m=0;m<u;m++)a+=o.data[m];return Math.abs(Math.ceil(a*100/u/5)-10)*t.N4};function i(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 m=0;m<u;m++)a.isReserved(m,h)||a.xor(m,h,i(o,m,h))},e.getBestMask=function(o,a){const u=Object.keys(e.Patterns).length;let h=0,m=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),_<m&&(m=_,h=f)}return h}})(Iu)),Iu}var Va={},iv;function Sy(){if(iv)return Va;iv=1;const e=Ch(),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],i=[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 Va.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}},Va.getTotalCodewordsCount=function(o,a){switch(a){case e.L:return i[(o-1)*4+0];case e.M:return i[(o-1)*4+1];case e.Q:return i[(o-1)*4+2];case e.H:return i[(o-1)*4+3];default:return}},Va}var Bu={},lo={},nv;function kC(){if(nv)return lo;nv=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]})(),lo.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},lo.exp=function(s){return e[s]},lo.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},lo}var rv;function xC(){return rv||(rv=1,(function(e){const t=kC();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 m=0;m<o.length;m++)a[m]^=t.mul(o[m],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}})(Bu)),Bu}var Ou,sv;function CC(){if(sv)return Ou;sv=1;const e=xC();function t(i){this.genPoly=void 0,this.degree=i,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},Ou=t,Ou}var zu={},Fu={},$u={},ov;function wy(){return ov||(ov=1,$u.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),$u}var sn={},av;function by(){if(av)return sn;av=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+`)(?:.|[\r
82
- ]))+`;sn.KANJI=new RegExp(i,"g"),sn.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),sn.BYTE=new RegExp(s,"g"),sn.NUMERIC=new RegExp(e,"g"),sn.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+i+"$"),a=new RegExp("^"+e+"$"),u=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return sn.testKanji=function(m){return o.test(m)},sn.testNumeric=function(m){return a.test(m)},sn.testAlphanumeric=function(m){return u.test(m)},sn}var lv;function Pr(){return lv||(lv=1,(function(e){const t=wy(),i=by();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 i.testNumeric(a)?e.NUMERIC:i.testAlphanumeric(a)?e.ALPHANUMERIC:i.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}}})(Fu)),Fu}var cv;function EC(){return cv||(cv=1,(function(e){const t=Rr(),i=Sy(),s=Ch(),o=Pr(),a=wy(),u=7973,h=t.getBCHDigit(u);function m(w,y,S){for(let k=1;k<=40;k++)if(y<=e.getCapacity(k,S,w))return k}function f(w,y){return o.getCharCountIndicator(w,y)+4}function _(w,y){let S=0;return w.forEach(function(k){const C=f(k.mode,y);S+=C+k.getBitsLength()}),S}function b(w,y){for(let S=1;S<=40;S++)if(_(w,S)<=e.getCapacity(S,y,o.MIXED))return S}e.from=function(y,S){return a.isValid(y)?parseInt(y,10):S},e.getCapacity=function(y,S,k){if(!a.isValid(y))throw new Error("Invalid QR Code version");typeof k>"u"&&(k=o.BYTE);const C=t.getSymbolTotalCodewords(y),x=i.getTotalCodewordsCount(y,S),R=(C-x)*8;if(k===o.MIXED)return R;const D=R-f(k,y);switch(k){case o.NUMERIC:return Math.floor(D/10*3);case o.ALPHANUMERIC:return Math.floor(D/11*2);case o.KANJI:return Math.floor(D/13);case o.BYTE:default:return Math.floor(D/8)}},e.getBestVersionForData=function(y,S){let k;const C=s.from(S,s.M);if(Array.isArray(y)){if(y.length>1)return b(y,C);if(y.length===0)return 1;k=y[0]}else k=y;return m(k.mode,k.getLength(),C)},e.getEncodedBits=function(y){if(!a.isValid(y)||y<7)throw new Error("Invalid QR Code version");let S=y<<12;for(;t.getBCHDigit(S)-h>=0;)S^=u<<t.getBCHDigit(S)-h;return y<<12|S}})(zu)),zu}var Hu={},uv;function NC(){if(uv)return Hu;uv=1;const e=Rr(),t=1335,i=21522,s=e.getBCHDigit(t);return Hu.getEncodedBits=function(a,u){const h=a.bit<<3|u;let m=h<<10;for(;e.getBCHDigit(m)-s>=0;)m^=t<<e.getBCHDigit(m)-s;return(h<<10|m)^i},Hu}var Wu={},Uu,dv;function RC(){if(dv)return Uu;dv=1;const e=Pr();function t(i){this.mode=e.NUMERIC,this.data=i.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))},Uu=t,Uu}var Ku,hv;function PC(){if(hv)return Ku;hv=1;const e=Pr(),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 i(s){this.mode=e.ALPHANUMERIC,this.data=s}return i.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.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)},Ku=i,Ku}var qu,fv;function jC(){if(fv)return qu;fv=1;const e=Pr();function t(i){this.mode=e.BYTE,typeof i=="string"?this.data=new TextEncoder().encode(i):this.data=new Uint8Array(i)}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(i){for(let s=0,o=this.data.length;s<o;s++)i.put(this.data[s],8)},qu=t,qu}var Vu,pv;function DC(){if(pv)return Vu;pv=1;const e=Pr(),t=Rr();function i(s){this.mode=e.KANJI,this.data=s}return i.getBitsLength=function(o){return o*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.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)}},Vu=i,Vu}var Yu={exports:{}},mv;function LC(){return mv||(mv=1,(function(e){var t={single_source_shortest_paths:function(i,s,o){var a={},u={};u[s]=0;var h=t.PriorityQueue.make();h.push(s,0);for(var m,f,_,b,w,y,S,k,C;!h.empty();){m=h.pop(),f=m.value,b=m.cost,w=i[f]||{};for(_ in w)w.hasOwnProperty(_)&&(y=w[_],S=b+y,k=u[_],C=typeof u[_]>"u",(C||k>S)&&(u[_]=S,h.push(_,S),a[_]=f))}if(typeof o<"u"&&typeof u[o]>"u"){var x=["Could not find a path from ",s," to ",o,"."].join("");throw new Error(x)}return a},extract_shortest_path_from_predecessor_list:function(i,s){for(var o=[],a=s;a;)o.push(a),i[a],a=i[a];return o.reverse(),o},find_path:function(i,s,o){var a=t.single_source_shortest_paths(i,s,o);return t.extract_shortest_path_from_predecessor_list(a,o)},PriorityQueue:{make:function(i){var s=t.PriorityQueue,o={},a;i=i||{};for(a in s)s.hasOwnProperty(a)&&(o[a]=s[a]);return o.queue=[],o.sorter=i.sorter||s.default_sorter,o},default_sorter:function(i,s){return i.cost-s.cost},push:function(i,s){var o={value:i,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})(Yu)),Yu.exports}var gv;function MC(){return gv||(gv=1,(function(e){const t=Pr(),i=RC(),s=PC(),o=jC(),a=DC(),u=by(),h=Rr(),m=LC();function f(x){return unescape(encodeURIComponent(x)).length}function _(x,R,D){const T=[];let ee;for(;(ee=x.exec(D))!==null;)T.push({data:ee[0],index:ee.index,mode:R,length:ee[0].length});return T}function b(x){const R=_(u.NUMERIC,t.NUMERIC,x),D=_(u.ALPHANUMERIC,t.ALPHANUMERIC,x);let T,ee;return h.isKanjiModeEnabled()?(T=_(u.BYTE,t.BYTE,x),ee=_(u.KANJI,t.KANJI,x)):(T=_(u.BYTE_KANJI,t.BYTE,x),ee=[]),R.concat(D,T,ee).sort(function(W,te){return W.index-te.index}).map(function(W){return{data:W.data,mode:W.mode,length:W.length}})}function w(x,R){switch(R){case t.NUMERIC:return i.getBitsLength(x);case t.ALPHANUMERIC:return s.getBitsLength(x);case t.KANJI:return a.getBitsLength(x);case t.BYTE:return o.getBitsLength(x)}}function y(x){return x.reduce(function(R,D){const T=R.length-1>=0?R[R.length-1]:null;return T&&T.mode===D.mode?(R[R.length-1].data+=D.data,R):(R.push(D),R)},[])}function S(x){const R=[];for(let D=0;D<x.length;D++){const T=x[D];switch(T.mode){case t.NUMERIC:R.push([T,{data:T.data,mode:t.ALPHANUMERIC,length:T.length},{data:T.data,mode:t.BYTE,length:T.length}]);break;case t.ALPHANUMERIC:R.push([T,{data:T.data,mode:t.BYTE,length:T.length}]);break;case t.KANJI:R.push([T,{data:T.data,mode:t.BYTE,length:f(T.data)}]);break;case t.BYTE:R.push([{data:T.data,mode:t.BYTE,length:f(T.data)}])}}return R}function k(x,R){const D={},T={start:{}};let ee=["start"];for(let V=0;V<x.length;V++){const W=x[V],te=[];for(let K=0;K<W.length;K++){const ie=W[K],Y=""+V+K;te.push(Y),D[Y]={node:ie,lastCount:0},T[Y]={};for(let A=0;A<ee.length;A++){const N=ee[A];D[N]&&D[N].node.mode===ie.mode?(T[N][Y]=w(D[N].lastCount+ie.length,ie.mode)-w(D[N].lastCount,ie.mode),D[N].lastCount+=ie.length):(D[N]&&(D[N].lastCount=ie.length),T[N][Y]=w(ie.length,ie.mode)+4+t.getCharCountIndicator(ie.mode,R))}}ee=te}for(let V=0;V<ee.length;V++)T[ee[V]].end=0;return{map:T,table:D}}function C(x,R){let D;const T=t.getBestModeForData(x);if(D=t.from(R,T),D!==t.BYTE&&D.bit<T.bit)throw new Error('"'+x+'" cannot be encoded with mode '+t.toString(D)+`.
84
- Suggested mode is: `+t.toString(T));switch(D===t.KANJI&&!h.isKanjiModeEnabled()&&(D=t.BYTE),D){case t.NUMERIC:return new i(x);case t.ALPHANUMERIC:return new s(x);case t.KANJI:return new a(x);case t.BYTE:return new o(x)}}e.fromArray=function(R){return R.reduce(function(D,T){return typeof T=="string"?D.push(C(T,null)):T.data&&D.push(C(T.data,T.mode)),D},[])},e.fromString=function(R,D){const T=b(R,h.isKanjiModeEnabled()),ee=S(T),V=k(ee,D),W=m.find_path(V.map,"start","end"),te=[];for(let K=1;K<W.length-1;K++)te.push(V.table[W[K]].node);return e.fromArray(y(te))},e.rawSplit=function(R){return e.fromArray(b(R,h.isKanjiModeEnabled()))}})(Wu)),Wu}var vv;function TC(){if(vv)return ju;vv=1;const e=Rr(),t=Ch(),i=_C(),s=yC(),o=SC(),a=wC(),u=bC(),h=Sy(),m=CC(),f=EC(),_=NC(),b=Pr(),w=MC();function y(V,W){const te=V.size,K=a.getPositions(W);for(let ie=0;ie<K.length;ie++){const Y=K[ie][0],A=K[ie][1];for(let N=-1;N<=7;N++)if(!(Y+N<=-1||te<=Y+N))for(let j=-1;j<=7;j++)A+j<=-1||te<=A+j||(N>=0&&N<=6&&(j===0||j===6)||j>=0&&j<=6&&(N===0||N===6)||N>=2&&N<=4&&j>=2&&j<=4?V.set(Y+N,A+j,!0,!0):V.set(Y+N,A+j,!1,!0))}}function S(V){const W=V.size;for(let te=8;te<W-8;te++){const K=te%2===0;V.set(te,6,K,!0),V.set(6,te,K,!0)}}function k(V,W){const te=o.getPositions(W);for(let K=0;K<te.length;K++){const ie=te[K][0],Y=te[K][1];for(let A=-2;A<=2;A++)for(let N=-2;N<=2;N++)A===-2||A===2||N===-2||N===2||A===0&&N===0?V.set(ie+A,Y+N,!0,!0):V.set(ie+A,Y+N,!1,!0)}}function C(V,W){const te=V.size,K=f.getEncodedBits(W);let ie,Y,A;for(let N=0;N<18;N++)ie=Math.floor(N/3),Y=N%3+te-8-3,A=(K>>N&1)===1,V.set(ie,Y,A,!0),V.set(Y,ie,A,!0)}function x(V,W,te){const K=V.size,ie=_.getEncodedBits(W,te);let Y,A;for(Y=0;Y<15;Y++)A=(ie>>Y&1)===1,Y<6?V.set(Y,8,A,!0):Y<8?V.set(Y+1,8,A,!0):V.set(K-15+Y,8,A,!0),Y<8?V.set(8,K-Y-1,A,!0):Y<9?V.set(8,15-Y-1+1,A,!0):V.set(8,15-Y-1,A,!0);V.set(K-8,8,1,!0)}function R(V,W){const te=V.size;let K=-1,ie=te-1,Y=7,A=0;for(let N=te-1;N>0;N-=2)for(N===6&&N--;;){for(let j=0;j<2;j++)if(!V.isReserved(ie,N-j)){let L=!1;A<W.length&&(L=(W[A]>>>Y&1)===1),V.set(ie,N-j,L),Y--,Y===-1&&(A++,Y=7)}if(ie+=K,ie<0||te<=ie){ie-=K,K=-K;break}}}function D(V,W,te){const K=new i;te.forEach(function(j){K.put(j.mode.bit,4),K.put(j.getLength(),b.getCharCountIndicator(j.mode,V)),j.write(K)});const ie=e.getSymbolTotalCodewords(V),Y=h.getTotalCodewordsCount(V,W),A=(ie-Y)*8;for(K.getLengthInBits()+4<=A&&K.put(0,4);K.getLengthInBits()%8!==0;)K.putBit(0);const N=(A-K.getLengthInBits())/8;for(let j=0;j<N;j++)K.put(j%2?17:236,8);return T(K,V,W)}function T(V,W,te){const K=e.getSymbolTotalCodewords(W),ie=h.getTotalCodewordsCount(W,te),Y=K-ie,A=h.getBlocksCount(W,te),N=K%A,j=A-N,L=Math.floor(K/A),$=Math.floor(Y/A),U=$+1,B=L-$,J=new m(B);let z=0;const M=new Array(A),I=new Array(A);let se=0;const ge=new Uint8Array(V.buffer);for(let ye=0;ye<A;ye++){const Ee=ye<j?$:U;M[ye]=ge.slice(z,z+Ee),I[ye]=J.encode(M[ye]),z+=Ee,se=Math.max(se,Ee)}const de=new Uint8Array(K);let fe=0,X,Z;for(X=0;X<se;X++)for(Z=0;Z<A;Z++)X<M[Z].length&&(de[fe++]=M[Z][X]);for(X=0;X<B;X++)for(Z=0;Z<A;Z++)de[fe++]=I[Z][X];return de}function ee(V,W,te,K){let ie;if(Array.isArray(V))ie=w.fromArray(V);else if(typeof V=="string"){let L=W;if(!L){const $=w.rawSplit(V);L=f.getBestVersionForData($,te)}ie=w.fromString(V,L||40)}else throw new Error("Invalid data");const Y=f.getBestVersionForData(ie,te);if(!Y)throw new Error("The amount of data is too big to be stored in a QR Code");if(!W)W=Y;else if(W<Y)throw new Error(`
85
- The chosen QR Code version cannot contain this amount of data.
86
- Minimum version required to store current data is: `+Y+`.
87
- `);const A=D(W,te,ie),N=e.getSymbolSize(W),j=new s(N);return y(j,W),S(j),k(j,W),x(j,te,0),W>=7&&C(j,W),R(j,A),isNaN(K)&&(K=u.getBestMask(j,x.bind(null,j,te))),u.applyMask(K,j),x(j,te,K),{modules:j,version:W,errorCorrectionLevel:te,maskPattern:K,segments:ie}}return ju.create=function(W,te){if(typeof W>"u"||W==="")throw new Error("No input text");let K=t.M,ie,Y;return typeof te<"u"&&(K=t.from(te.errorCorrectionLevel,t.M),ie=f.from(te.version),Y=u.from(te.maskPattern),te.toSJISFunc&&e.setToSJISFunction(te.toSJISFunc)),ee(W,ie,K,Y)},ju}var Xu={},Gu={},_v;function ky(){return _v||(_v=1,(function(e){function t(i){if(typeof i=="number"&&(i=i.toString()),typeof i!="string")throw new Error("Color should be defined as hex string");let s=i.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+i);(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,m=e.getScale(u,a),f=Math.floor((u+a.margin*2)*m),_=a.margin*m,b=[a.color.light,a.color.dark];for(let w=0;w<f;w++)for(let y=0;y<f;y++){let S=(w*f+y)*4,k=a.color.light;if(w>=_&&y>=_&&w<f-_&&y<f-_){const C=Math.floor((w-_)/m),x=Math.floor((y-_)/m);k=b[h[C*u+x]?1:0]}s[S++]=k.r,s[S++]=k.g,s[S++]=k.b,s[S]=k.a}}})(Gu)),Gu}var yv;function AC(){return yv||(yv=1,(function(e){const t=ky();function i(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 m=h,f=u;typeof m>"u"&&(!u||!u.getContext)&&(m=u,u=void 0),u||(f=s()),m=t.getOptions(m);const _=t.getImageWidth(a.modules.size,m),b=f.getContext("2d"),w=b.createImageData(_,_);return t.qrToImageData(w.data,a,m),i(b,f,_),b.putImageData(w,0,0),f},e.renderToDataURL=function(a,u,h){let m=h;typeof m>"u"&&(!u||!u.getContext)&&(m=u,u=void 0),m||(m={});const f=e.render(a,u,m),_=m.type||"image/png",b=m.rendererOpts||{};return f.toDataURL(_,b.quality)}})(Xu)),Xu}var Qu={},Sv;function IC(){if(Sv)return Qu;Sv=1;const e=ky();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 i(o,a,u){let h=o+a;return typeof u<"u"&&(h+=" "+u),h}function s(o,a,u){let h="",m=0,f=!1,_=0;for(let b=0;b<o.length;b++){const w=Math.floor(b%a),y=Math.floor(b/a);!w&&!f&&(f=!0),o[b]?(_++,b>0&&w>0&&o[b-1]||(h+=f?i("M",w+u,.5+y+u):i("m",m,0),m=0,f=!1),w+1<a&&o[b+1]||(h+=i("h",_),_=0)):m++}return h}return Qu.render=function(a,u,h){const m=e.getOptions(u),f=a.modules.size,_=a.modules.data,b=f+m.margin*2,w=m.color.light.a?"<path "+t(m.color.light,"fill")+' d="M0 0h'+b+"v"+b+'H0z"/>':"",y="<path "+t(m.color.dark,"stroke")+' d="'+s(_,f,m.margin)+'"/>',S='viewBox="0 0 '+b+" "+b+'"',C='<svg xmlns="http://www.w3.org/2000/svg" '+(m.width?'width="'+m.width+'" height="'+m.width+'" ':"")+S+' shape-rendering="crispEdges">'+w+y+`</svg>
88
- `;return typeof h=="function"&&h(null,C),C},Qu}var wv;function BC(){if(wv)return is;wv=1;const e=vC(),t=TC(),i=AC(),s=IC();function o(a,u,h,m,f){const _=[].slice.call(arguments,1),b=_.length,w=typeof _[b-1]=="function";if(!w&&!e())throw new Error("Callback required as last argument");if(w){if(b<2)throw new Error("Too few arguments provided");b===2?(f=h,h=u,u=m=void 0):b===3&&(u.getContext&&typeof f>"u"?(f=m,m=void 0):(f=m,m=h,h=u,u=void 0))}else{if(b<1)throw new Error("Too few arguments provided");return b===1?(h=u,u=m=void 0):b===2&&!u.getContext&&(m=h,h=u,u=void 0),new Promise(function(y,S){try{const k=t.create(h,m);y(a(k,u,m))}catch(k){S(k)}})}try{const y=t.create(h,m);f(null,a(y,u,m))}catch(y){f(y)}}return is.create=t.create,is.toCanvas=o.bind(null,i.render),is.toDataURL=o.bind(null,i.renderToDataURL),is.toString=o.bind(null,function(a,u,h){return s.render(a,h)}),is}var OC=BC();const zC=Zd(OC);function bv(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function FC(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const i=ab(t);if(!i||!i.ok)return{kind:"invalid"};const s=[];return i.ssh||s.push("ssh"),i.name||s.push("name"),s.length?{kind:"partial",decoded:i,missing:s}:{kind:"complete",decoded:i}}function $C(e,t,i=new Set,s=!1){if(!t||!t.ok)return e;const o=lb(e,t,i);return t.version===2&&t.name&&!i.has("name")&&!s&&(o.name=t.name),!i.has("label")&&!o.label&&t.label&&(o.label=t.label),o}function kv(e,t,i=new Set,s=!1){const o=String(t||"").trim(),a=FC(o);let u={...e,pairingUrl:o};return(a.kind==="complete"||a.kind==="partial")&&(u={...$C(u,a.decoded,i,s),pairingUrl:o}),{classification:a,form:u}}function tl(e,t){const i=String(t||"").toLowerCase();if(!/^[a-f0-9]{16,64}$/.test(i))return"";const s=String(e||"NexusCrew").replace(/([a-z0-9])([A-Z])/g,"$1 $2");let o=Jn(s);(o==="localhost"||o==="node")&&(o="nexuscrew");const a=i.slice(0,4),u=Math.max(1,32-a.length-1);return`${o.slice(0,u).replace(/-+$/g,"")||"n"}-${a}`}function HC(e,{deviceDefault:t="",localNodeId:i="",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||tl(a,i)||s||"").trim();return u&&(o.localName=u),o}function WC(){const e=new Set;let t=!1;return{canAuto(i){return!t&&!e.has(String(i||""))},start(i){return t?!1:(t=!0,e.add(String(i||"")),!0)},finish(){t=!1},reset(i){e.delete(String(i||""))},isBusy(){return t}}}const UC=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function KC(e){const t=e&&e.data||{},i=typeof t.stage=="string"&&t.stage?t.stage:"",s=typeof t.detail=="string"&&t.detail?t.detail:"";return{stage:i,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:!i,message:s||String(e&&e.message||e)}}const qC="modulepreload",VC=function(e){return"/"+e},xv={},YC=function(t,i,s){let o=Promise.resolve();if(i&&i.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]"),m=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));o=u(i.map(f=>{if(f=VC(f),f in xv)return;xv[f]=!0;const _=f.endsWith(".css"),b=_?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${b}`))return;const w=document.createElement("link");if(w.rel=_?"stylesheet":qC,_||(w.as="script"),w.crossOrigin="",w.href=f,m&&w.setAttribute("nonce",m),document.head.appendChild(w),_)return new Promise((y,S)=>{w.addEventListener("load",y),w.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 Ge{constructor(t,i,s,o,a){this._legacyCanvasSize=Ge.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=i:(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=i),i=typeof s=="object"?s:{},this._onDecodeError=i.onDecodeError||(typeof s=="function"?s:this._onDecodeError),this._calculateScanRegion=i.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=i.preferredCamera||a||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=i.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,i.highlightScanRegion||i.highlightCodeOutline){if(o=!!i.overlay,this.$overlay=i.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&&i.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)}i.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=Ge.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 Ge.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let i=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),s;try{t&&(await i()).every(o=>!o.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await i()).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"),Ge._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"),Ge._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(),Ge._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:i}=await this._getCameraStream();!this._active||this._paused?Ge._stopVideoStream(t):(this._setVideoMirror(i),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 i=()=>{this.$video.srcObject instanceof MediaStream&&(Ge._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(i(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(i(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,i,s,o,a=!1,u=!1){let h,m=!1;i&&("scanRegion"in i||"qrEngine"in i||"canvas"in i||"disallowCanvasResizing"in i||"alsoTryWithoutScanRegion"in i||"returnDetailedScanResult"in i)?(h=i.scanRegion,s=i.qrEngine,o=i.canvas,a=i.disallowCanvasResizing||!1,u=i.alsoTryWithoutScanRegion||!1,m=!0):console.warn(i||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."),i=!!s;try{let f,_;[s,f]=await Promise.all([s||Ge.createQrEngine(),Ge._loadImage(t)]),[o,_]=Ge._drawToCanvas(f,h,o,a);let b;if(s instanceof Worker){let w=s;i||Ge._postWorkerMessageSync(w,"inversionMode","both"),b=await new Promise((y,S)=>{let k,C,x,R=-1;C=T=>{T.data.id===R&&(w.removeEventListener("message",C),w.removeEventListener("error",x),clearTimeout(k),T.data.data!==null?y({data:T.data.data,cornerPoints:Ge._convertPoints(T.data.cornerPoints,h)}):S(Ge.NO_QR_CODE_FOUND))},x=T=>{w.removeEventListener("message",C),w.removeEventListener("error",x),clearTimeout(k),S("Scanner error: "+(T?T.message||T:"Unknown Error"))},w.addEventListener("message",C),w.addEventListener("error",x),k=setTimeout(()=>x("timeout"),1e4);let D=_.getImageData(0,0,o.width,o.height);R=Ge._postWorkerMessageSync(w,"decode",D,[D.data.buffer])})}else b=await Promise.race([new Promise((w,y)=>window.setTimeout(()=>y("Scanner error: timeout"),1e4)),(async()=>{try{var[w]=await s.detect(o);if(!w)throw Ge.NO_QR_CODE_FOUND;return{data:w.rawValue,cornerPoints:Ge._convertPoints(w.cornerPoints,h)}}catch(y){if(w=y.message||y,/not implemented|service unavailable/.test(w))return Ge._disableBarcodeDetector=!0,Ge.scanImage(t,{scanRegion:h,canvas:o,disallowCanvasResizing:a,alsoTryWithoutScanRegion:u});throw`Scanner error: ${w}`}})()]);return m?b:b.data}catch(f){if(!h||!u)throw f;let _=await Ge.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:a});return m?_:_.data}finally{i||Ge._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,i,s,o=!0){Ge._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:i,blue:s,useIntegerApproximation:o})}setInversionMode(t){Ge._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=()=>YC(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!Ge._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let i=navigator.userAgentData;return i&&i.brands.some(({brand:s})=>/Chromium/i.test(s))&&/mac ?OS/i.test(i.platform)&&await i.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 i=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-i)/2),y:Math.round((t.videoHeight-i)/2),width:i,height:i,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,i=t.videoWidth,s=t.videoHeight,o=t.offsetWidth,a=t.offsetHeight,u=t.offsetLeft,h=t.offsetTop,m=window.getComputedStyle(t),f=m.objectFit,_=i/s,b=o/a;switch(f){case"none":var w=i,y=s;break;case"fill":w=o,y=a;break;default:(f==="cover"?_>b:_<b)?(y=a,w=y*_):(w=o,y=w/_),f==="scale-down"&&(w=Math.min(w,i),y=Math.min(y,s))}var[S,k]=m.objectPosition.split(" ").map((x,R)=>{const D=parseFloat(x);return x.endsWith("%")?(R?a-y:o-w)*D/100:D});m=this._scanRegion.width||i,b=this._scanRegion.height||s,f=this._scanRegion.x||0;var C=this._scanRegion.y||0;_=this.$overlay.style,_.width=`${m/i*w}px`,_.height=`${b/s*y}px`,_.top=`${h+k+C/s*y}px`,s=/scaleX\(-1\)/.test(t.style.transform),_.left=`${u+(s?o-S-w:S)+(s?i-f-m:f)/i*w}px`,_.transform=t.style.transform}})}static _convertPoints(t,i){if(!i)return t;let s=i.x||0,o=i.y||0,a=i.width&&i.downScaledWidth?i.width/i.downScaledWidth:1;i=i.height&&i.downScaledHeight?i.height/i.downScaledHeight:1;for(let u of t)u.x=u.x*a+s,u.y=u.y*i+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,i=1e3/this._maxScansPerSecond;t<i&&await new Promise(o=>setTimeout(o,i-t)),this._lastScanTimestamp=Date.now();try{var s=await Ge.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!Ge._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=Ge.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!==Ge.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",i=[{width:{min:1024}},{width:{min:768}},{}],s=i.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...s,...i])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 i of t.getTracks())i.stop(),t.removeTrack(i)}_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,i,s,o=!1){s=s||document.createElement("canvas");let a=i&&i.x?i.x:0,u=i&&i.y?i.y:0,h=i&&i.width?i.width:t.videoWidth||t.width,m=i&&i.height?i.height:t.videoHeight||t.height;return o||(o=i&&i.downScaledWidth?i.downScaledWidth:h,i=i&&i.downScaledHeight?i.downScaledHeight:m,s.width!==o&&(s.width=o),s.height!==i&&(s.height=i)),i=s.getContext("2d",{alpha:!1}),i.imageSmoothingEnabled=!1,i.drawImage(t,a,u,h,m,0,0,s.width,s.height),[s,i]}static async _loadImage(t){if(t instanceof Image)return await Ge._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 i=new Image;i.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await Ge._awaitImageLoad(i),i}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(i.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((i,s)=>{let o=a=>{t.removeEventListener("load",o),t.removeEventListener("error",o),a instanceof ErrorEvent?s("Image load error"):i()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,i,s,o){return Ge._postWorkerMessageSync(await t,i,s,o)}static _postWorkerMessageSync(t,i,s,o){if(!(t instanceof Worker))return-1;let a=Ge._workerMessageId++;return t.postMessage({id:a,type:i,data:s},o),a}}Ge.DEFAULT_CANVAS_SIZE=400;Ge.NO_QR_CODE_FOUND="No QR code found";Ge._disableBarcodeDetector=!1;Ge._workerMessageId=0;function XC({onResult:e,onClose:t}){const i=P.useRef(null),s=P.useRef(null),o=P.useRef(!1),[a,u]=P.useState("");P.useEffect(()=>{let m=!1;const f=i.current,_=b=>{m||o.current||(o.current=!0,e(b))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){u(v("qr-unsupported"));return}let b=!1;try{b=await Ge.hasCamera()}catch{b=!1}if(!b){u(v("qr-no-camera"));return}if(m||!f)return;const w=new Ge(f,y=>{const S=bv(y);S&&_(S)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:y=>{const S=y.videoWidth||640,k=y.videoHeight||480,C=Math.max(1,Math.round(Math.min(S,k)*.92));return{x:Math.round((S-C)/2),y:Math.round((k-C)/2),width:C,height:C,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=w;try{await w.start()}catch(y){if(m)return;const S=y&&y.name||"";u(v(S==="NotAllowedError"||S==="SecurityError"?"qr-permission":S==="NotFoundError"||S==="OverconstrainedError"||S==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{m=!0;const b=s.current;if(b){try{b.stop()}catch{}try{b.destroy()}catch{}s.current=null}const w=f,y=w&&w.srcObject;if(y&&typeof y.getTracks=="function"){for(const S of y.getTracks())try{S.stop()}catch{}try{w.srcObject=null}catch{}}}},[]);const h=async m=>{const f=m.target.files&&m.target.files[0];if(m.target.value="",!!f)try{const _=await Ge.scanImage(f,{returnDetailedScanResult:!0}),b=bv(_);if(!b)throw new Error("empty");o.current||(o.current=!0,e(b))}catch{u(v("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:m=>m.stopPropagation(),children:[c.jsx("div",{className:"nc-sheet-head",children:c.jsx("b",{children:v("scan-qr")})}),c.jsx("video",{ref:i,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:[v("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:v("cancel")})]})]})})}const Cv=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:"",localName:""});function xy({token:e,initial:t="",autoStart:i=!1,deviceDefault:s="",localNodeId:o="",localNameDefault:a="",readonly:u=!1,onSuccess:h,onBusyChange:m}){const[f,_]=P.useState(Cv),[b,w]=P.useState(!1),[y,S]=P.useState(!1),[k,C]=P.useState("idle"),[x,R]=P.useState(null),[D,T]=P.useState(""),[ee,V]=P.useState(!1),[W,te]=P.useState(!1),K=P.useRef(WC()),ie=P.useRef(new Set),Y=k==="busy",A=tl(f.localLabel||s,o)||a,N=W?f.localName:A;P.useEffect(()=>(m&&m(Y),()=>{m&&m(!1)}),[Y,m]);const j=async z=>{const M=String(z.pairingUrl||"").trim();if(K.current.start(M)){C("busy"),R(null),T("");try{await s0(e,HC({...z,localName:W?z.localName:tl(z.localLabel||s,o)||a},{deviceDefault:s,localNodeId:o,localNameDefault:a})),C("ok"),w(!1),_(Cv()),ie.current=new Set,V(!1),te(!1),K.current.finish(),h&&await h()}catch(I){const se=KC(I);R(se),C("idle"),K.current.finish(),se.code==="peer-name-conflict"&&od(se.suggestedName)&&(te(!0),ie.current.add("localName"),_(ge=>({...ge,localName:se.suggestedName}))),(se.stage==="validation"||se.stage==="conflict"||se.stage==="ssh-start"||se.stage==="ssh-ready"||String(se.code||"").startsWith("ssh-"))&&w(!0)}}},L=(z,M=!0)=>{const{classification:I,form:se}=kv(f,z,ie.current,ee),ge=se.pairingUrl;if(R(null),T(""),k==="ok"&&C("idle"),_(se),I.kind==="invalid"){R({stage:"validation",code:"bad-link",message:v("pair-invalid-link"),hint:v("pair-invalid-hint"),retryable:!0});return}if(I.kind==="partial"){w(!0),T(I.missing.includes("ssh")?v("pair-missing-ssh"):v("pair-missing-name"));return}I.kind==="complete"&&M&&!u&&K.current.canAuto(ge)&&j(se)};P.useEffect(()=>{t&&L(t,i)},[]);const $=()=>{const z=String(f.pairingUrl||"").trim(),{classification:M,form:I}=kv(f,z,ie.current,ee);if(_(I),T(""),R(null),M.kind==="empty"){R({stage:"validation",message:v("pairing-required"),retryable:!0});return}if(M.kind==="invalid"){R({stage:"validation",code:"bad-link",message:v("pair-invalid-link"),hint:v("pair-invalid-hint"),retryable:!0});return}if(!I.ssh||!I.name){w(!0),T(I.ssh?v("pair-missing-name"):v("pair-missing-ssh"));return}if(I.label&&!us(I.label)){R({stage:"validation",message:v("err-label"),retryable:!0});return}if(I.localLabel&&!us(I.localLabel)){R({stage:"validation",message:v("err-label"),retryable:!0});return}const se=W?I.localName:tl(I.localLabel||s,o)||a;if(!od(se)||se==="localhost"){w(!0),R({stage:"validation",code:"bad-local-name",message:v("err-local-name"),retryable:!0});return}K.current.reset(z),j(I)},U=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const z=await navigator.clipboard.readText();z&&z.trim()?L(z):T(v("pair-clipboard-empty"))}catch{T(v("pair-clipboard-denied"))}},B=(z,M)=>{ie.current.add(z),_(I=>({...I,[z]:M}))},J=x&&x.stage&&(UC.includes(x.stage)||x.stage==="internal")?v(`pair-stage-${x.stage}`):v("pair-stage-generic");return c.jsxs("div",{className:"nc-set-form nc-pair-card",children:[c.jsx("div",{className:"nc-sheet-label",children:v("pair-card-title")}),c.jsx("div",{className:"nc-set-info",children:v("pair-card-help")}),c.jsx("input",{className:"nc-pair-input",placeholder:v("pair-paste-ph"),value:f.pairingUrl,disabled:u||Y,onChange:z=>{_({...f,pairingUrl:z.target.value}),R(null),T("")},onPaste:z=>{const M=z.clipboardData&&z.clipboardData.getData("text")||"";M.trim()&&(z.preventDefault(),L(M))},onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),$())}}),c.jsxs("div",{className:"nc-pair-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||Y,onClick:U,children:v("pair-paste-btn")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||Y,onClick:()=>S(!0),children:v("scan-qr")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:u||Y,title:u?v("settings-readonly"):"",onClick:$,children:v("test-and-connect")})]}),c.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[Y&&c.jsx("div",{className:"nc-pair-progress",children:v("pair-progress")}),k==="ok"&&c.jsx("div",{className:"nc-set-test ok",children:v("node-connected")}),D&&c.jsx("div",{className:"nc-set-hint nc-pair-notice",children:D}),x&&c.jsxs("div",{className:"nc-err",role:"alert",children:[c.jsx("b",{children:J})," — ",x.message,x.hint&&c.jsx("div",{className:"nc-pair-hint",children:x.hint}),x.retryable&&c.jsx("div",{children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||Y,onClick:$,children:v("pair-retry")})})]})]}),c.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:Y,onClick:()=>w(z=>!z),children:[b?"▾":"▸"," ",v("pair-advanced")]}),b&&c.jsxs("div",{className:"nc-pair-advanced",children:[c.jsxs("label",{className:"nc-field",children:[v("node-display-label"),c.jsx("input",{placeholder:"Home Relay",value:f.label,disabled:u||Y,onChange:z=>{ie.current.add("label"),_(M=>({...M,label:z.target.value,name:ee?M.name:Jn(z.target.value)}))}})]}),c.jsxs("label",{className:"nc-field",children:[v("node-name-label"),c.jsx("input",{placeholder:v("node-name-ph"),value:f.name,disabled:u||Y,onChange:z=>{V(!0),ie.current.add("name"),_(M=>({...M,name:z.target.value?Jn(z.target.value):""}))}})]}),c.jsx("small",{className:"nc-set-hint",children:v("node-slug-hint").replace("{slug}",f.name||"home-relay")}),c.jsxs("label",{className:"nc-field",children:[v("pair-ssh-local-label"),c.jsx("input",{placeholder:"my-relay",value:f.ssh,disabled:u||Y,onChange:z=>{ie.current.add("ssh"),B("ssh",z.target.value)}}),c.jsx("small",{className:"nc-set-hint",children:v("node-ssh-local-help")})]}),c.jsxs("label",{className:"nc-field",children:[v("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",placeholder:v("node-ssh-port-help"),value:f.sshPort,disabled:u||Y,onChange:z=>B("sshPort",z.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),c.jsxs("label",{className:"nc-field",children:[v("device-name-label"),c.jsx("input",{placeholder:s||"NexusCrew",value:f.localLabel,disabled:u||Y,onChange:z=>B("localLabel",z.target.value)}),c.jsx("small",{className:"nc-set-hint",children:v("device-name-hint")})]}),c.jsxs("label",{className:"nc-field",children:[v("local-route-name-label"),c.jsx("input",{placeholder:A||"nexuscrew-5bd6",value:N,disabled:u||Y,onChange:z=>{te(!0),ie.current.add("localName"),_(M=>({...M,localName:z.target.value?Jn(z.target.value):""}))}}),c.jsx("small",{className:"nc-set-hint",children:v("local-route-name-hint")})]})]}),y&&c.jsx(XC,{onResult:z=>{S(!1),L(z)},onClose:()=>S(!1)})]})}function Eh(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function GC(e){const t="=".repeat((4-e.length%4)%4),i=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(i),o=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)o[a]=s.charCodeAt(a);return o}async function QC(){if(!Eh())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function JC(e){if(!Eh())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const i=await qt("/api/push/vapid",e),{publicKey:s}=await i.json();if(!s)throw new Error("vapid non disponibile");const a=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:GC(s)}),u=await qt("/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 ZC(e){if(!Eh())return!1;const i=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!i)return!1;const s=i.endpoint;try{await i.unsubscribe()}catch{}try{await qt("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const Cy="nexuscrew.fleet",Ey=2,eE="nexuscrew.cells",tE=/^[A-Za-z0-9._-]{1,32}$/,Nh=/^[a-z0-9._-]{1,32}$/,Ny=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,iE=new Set(["standard","unsafe"]),nE=4096,Ev=256,rE=8192,sE=32,oE=24,aE=new Set(["format","version","exportedAt","cells","engines"]),lE=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]),cE=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag"]),uE=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]);function _r(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function Ry(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 Nv(e,t){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))return null;const i=Object.entries(e);if(i.length>128)return null;const s={};for(const[o,a]of i){if(!Nh.test(o)||!t(a))return null;s[o]=a}return s}function Py(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(a=>!lE.has(a))||!tE.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>nE||!Nh.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>Ev)||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>rE)return null;const i=Nv(e.models,a=>typeof a=="string"&&!!a&&a.length<=Ev),s=Nv(e.permissionPolicies,a=>iE.has(a));if(i===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(i).length&&(o.models=i),Object.keys(s).length&&(o.permissionPolicies=s),o}function dE(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(i=>!uE.has(i)))return null;const t={};for(const[i,s]of Object.entries(e)){if(typeof s!="string"||!_r(s,i==="baseUrl"?512:128)||Ry(s))return null;t[i]=s}return!t.client||!t.provider||t.envKey&&!Ny.test(t.envKey)?null:t}function jy(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!cE.has(s))||!Nh.test(String(e.id||""))||!_r(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=dE(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!_r(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!_r(s,1024)||Ry(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!_r(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")||!_r(e.model.flag,32)||/\s/.test(e.model.flag)||!_r(e.model.value||"",128))return null;t.model={flag:e.model.flag,value:e.model.value||""}}const i=e.envKeys===void 0?[]:e.envKeys;return!Array.isArray(i)||i.length>32||i.some(s=>!Ny.test(s))?null:(Object.assign(t,{command:e.command,args:[...e.args],envKeys:[...new Set(i)].sort(),promptMode:e.promptMode}),e.promptMode==="flag"&&(t.promptFlag=e.promptFlag),t)}function Dy(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},i=jy(t);return i||null}function hE(e,t,i=[],s=[],o=new Date){i instanceof Date&&(o=i,i=[],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 _=Py({id:f.id,cwd:f.cwd,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||""});_&&h.push(_)}const m=[];for(const f of Array.isArray(i)?i:[]){if(!u.has(f.id))continue;const _=Dy(f);_&&m.push(_)}return{format:Cy,version:Ey,exportedAt:o.toISOString(),cells:h,engines:m}}function fE(e){let t;try{t=JSON.parse(String(e||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const i=(t==null?void 0:t.format)===eE&&(t==null?void 0:t.version)===1;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(h=>!aE.has(h))||!i&&(t.format!==Cy||t.version!==Ey)||!Array.isArray(t.cells)||t.cells.length>sE||!i&&(!Array.isArray(t.engines)||t.engines.length>oE))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const s=[],o=new Set;for(const h of t.cells){const m=Py(h);if(!m)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(o.has(m.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};o.add(m.id),s.push(m)}const a=[],u=new Set;for(const h of i?[]:t.engines){const m=jy(h);if(!m)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(u.has(m.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};u.add(m.id),a.push(m)}return{ok:!0,cells:s,engines:a,legacy:i,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function pE(e,t,i){const s=new Set(i||[]);if(!s.has(t))return null;const o=m=>Object.fromEntries(Object.entries(m||{}).filter(([f])=>s.has(f))),a={id:e.id,cwd:e.cwd,engine:t,boot:e.boot===!0,prompt:e.systemPrompt||""};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);return Object.keys(u).length&&(a.models=u),Object.keys(h).length&&(a.permissionPolicies=h),a}const mE=()=>({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}),Rv=(e="")=>({id:"",cwd:"",engine:e,boot:!1,model:"",prompt:""}),Ly=e=>e==="claude"?"unsafe":"standard",wo=(e,t)=>e.find(i=>i.client===t.client&&i.provider===t.provider&&(i.credentialProfile||"")===(t.credentialProfile||"")),gE=(e,t)=>{var i;return((i=wo(e,t))==null?void 0:i.label)||`${t.client} · ${t.provider}`};function vE(e){var t,i,s,o,a,u,h,m,f,_,b,w,y,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:((i=e.managed)==null?void 0:i.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)||Ly((u=e.managed)==null?void 0:u.client),displayName:((h=e.managed)==null?void 0:h.displayName)||"",protocol:((m=e.managed)==null?void 0:m.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||((w=e.managedInfo)==null?void 0:w.models)||[],promptMode:e.promptMode||"send-keys",promptFlag:e.promptFlag||"",modelFlag:((y=e.model)==null?void 0:y.flag)||"",modelValue:((S=e.model)==null?void 0:S.value)||"",envRows:(e.envKeys||[]).map(k=>({key:k,value:"",configured:!0,remove:!1})),credentialValue:"",credentialReveal:!1,allowMissingCredential:!1}}function _E(e,t,i=[]){if(e.kind==="managed"){const o={client:e.client,provider:e.provider,model:e.managedModel||"",permissionPolicy:e.permissionPolicy||Ly(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile);const a=wo(i,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||gE(i,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 ns({children:e,onClose:t,label:i,error:s=""}){const o=P.useRef(null),a=P.useRef(null),u=P.useRef(t);return u.current=t,P.useEffect(()=>{const h=document.activeElement,m=o.current,f=()=>Array.from((m==null?void 0:m.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))||[]).filter(w=>w.offsetParent!==null),_=requestAnimationFrame(()=>{var w;return(w=f()[0]||m)==null?void 0:w.focus({preventScroll:!0})}),b=w=>{var C;if(w.key==="Escape"){w.preventDefault(),(C=u.current)==null||C.call(u);return}if(w.key!=="Tab")return;const y=f();if(!y.length){w.preventDefault(),m==null||m.focus();return}const S=y[0],k=y[y.length-1];w.shiftKey&&document.activeElement===S?(w.preventDefault(),k.focus()):!w.shiftKey&&document.activeElement===k&&(w.preventDefault(),S.focus())};return document.addEventListener("keydown",b),()=>{cancelAnimationFrame(_),document.removeEventListener("keydown",b),h&&h.isConnected&&typeof h.focus=="function"&&h.focus({preventScroll:!0})}},[]),P.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":i||v("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 Ju({token:e,targets:t=[],readonly:i=!1,onPower:s,onImport:o}){const[a,u]=P.useState([]),[h,m]=P.useState(0);P.useEffect(()=>{let C=!0;async function x(){const D=[{route:[],label:v("local")}].concat((t||[]).map(ee=>({route:Array.isArray(ee.route)?ee.route:[],label:ee.label||(ee.route||[]).join(" › ")}))),T=await Promise.all(D.map(async ee=>{const V={...ee,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const W=await Er(e,ee.route);V.available=!!W.available,V.capabilities=W.capabilities||[],V.provider=W.provider||null,V.cells=(W.cells||[]).map(te=>({...te,route:ee.route}));try{V.readonly=!!(await rh(e,ee.route)).readonlyDefault}catch{}try{const te=await Uv(e,ee.route),K=new Set(V.cells.map(ie=>ie.tmuxSession).filter(Boolean));V.unmanaged=(te.sessions||[]).filter(ie=>ie&&!K.has(ie.name))}catch{}}catch(W){V.err=String(W&&W.message||W)}return V}));C&&u(T)}x();const R=setInterval(x,6e3);return()=>{C=!1,clearInterval(R)}},[e,t,h]);const f=(C,x)=>Array.isArray(C.capabilities)&&C.capabilities.includes(x)&&!i&&!C.readonly,_=()=>m(C=>C+1),b=(C,x)=>{s&&s({...C,route:x})},w=(C,x)=>{s&&s({...C,route:x})},y=async(C,x)=>{try{await uo(e,C.cell,x)}catch{}_()},S=async(C,x)=>{if(window.confirm(v("fleet-remove-cell").replace("{id}",C.cell))){try{await Fv(e,C.cell,!0,x)}catch{}_()}},k=async(C,x)=>{if(window.confirm(v("terminate-confirm").replace("{name}",C.name))){try{await nh(e,C.name,x)}catch{}_()}};return c.jsxs("div",{className:"nc-fleet-inventory",children:[c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:v("fleet-inventory")}),c.jsx("small",{children:v("fleet-inventory-help")})]}),a.map(C=>{const x=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} ${v("fleet-cells")} · ${C.unmanaged.length} ${v("fleet-tmux")}`:C.err||v("fleet-not-available")})]}),C.cells.map(R=>c.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[c.jsxs("span",{children:[c.jsx("b",{children:R.cell}),c.jsx("small",{children:`${R.engine||""}${R.key?`·${R.key}`:""}${R.active?"":` · ${v("cell-off")}`}`})]}),c.jsxs("span",{className:"nc-fleet-cell-actions",children:[R.active&&f(C,"down")&&c.jsx("button",{className:"nc-btn ghost",title:v("power-off"),onClick:()=>w(R,C.route),children:v("stop")}),!R.active&&f(C,"up")&&c.jsx("button",{className:"nc-btn ghost",title:v("power-on"),onClick:()=>b(R,C.route),children:v("start")}),f(C,"restart")&&R.active&&c.jsx("button",{className:"nc-btn ghost",title:v("restart"),onClick:()=>y(R,C.route),children:v("restart")}),f(C,"remove")&&c.jsx("button",{className:"nc-btn danger",title:v("delete"),onClick:()=>S(R,C.route),children:"×"})]})]},`${x}:${R.cell}`)),C.unmanaged.map(R=>c.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[c.jsxs("span",{children:[c.jsx("b",{children:R.name}),c.jsx("small",{children:v("fleet-tmux")})]}),c.jsxs("span",{className:"nc-fleet-cell-actions",children:[f(C,"import")&&o&&c.jsx("button",{className:"nc-btn ghost",title:v("import-as-cell"),onClick:()=>o(R,C.route),children:v("import-as-cell")}),c.jsx("button",{className:"nc-btn danger",title:v("terminate"),onClick:()=>k(R,C.route),children:"×"})]})]},`${x}:u:${R.name}`)),C.available&&C.cells.length===0&&C.unmanaged.length===0&&c.jsx("div",{className:"nc-empty",children:v("fleet-inventory-empty")})]},x)})]})}function yE({cells:e=[],engines:t=[],busy:i,canRestore:s=!1,onRestore:o,onClose:a}){const[u,h]=P.useState("export"),[m,f]=P.useState(()=>new Set(e.map(N=>N.id))),[_,b]=P.useState(()=>new Set(t.map(N=>N.id))),[w,y]=P.useState([]),[S,k]=P.useState([]),[C,x]=P.useState(""),R=new Set(t.map(N=>N.id)),D=new Set(e.map(N=>N.id)),T=(N,j)=>N(L=>{const $=new Set(L);return $.has(j)?$.delete(j):$.add(j),$}),ee=()=>{const N=hE(e,m,t,_),j=t.filter(B=>_.has(B.id)).length;if(N.engines.length!==j){x(v("fleet-backup-invalid-engine"));return}if(!N.cells.length&&!N.engines.length){x(v("fleet-backup-select-one"));return}const L=new Blob([`${JSON.stringify(N,null,2)}
91
- `],{type:"application/json"}),$=URL.createObjectURL(L),U=document.createElement("a");U.href=$,U.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(U),U.click(),U.remove(),setTimeout(()=>URL.revokeObjectURL($),0),x("")},V=async N=>{if(x(""),y([]),k([]),!!N){if(N.size>1024*1024){x(v("fleet-backup-too-large"));return}try{const j=fE(await N.text());if(!j.ok){x(v(`fleet-backup-${j.error}`));return}const L=new Set(j.engines.map($=>$.id));k(j.engines.map($=>({engine:$,exists:R.has($.id),selected:!R.has($.id)}))),y(j.cells.map($=>{const U=R.has($.engine)||L.has($.engine),B=D.has($.id);return{cell:$,engine:U?$.engine:"",selected:U&&!B,exists:B}}))}catch(j){x(String(j.message||j))}}},W=(N,j)=>y(L=>L.map(($,U)=>U===N?{...$,...j}:$)),te=(N,j)=>k(L=>L.map(($,U)=>U===N?{...$,...j}:$)),K=new Set([...R,...S.filter(N=>N.selected).map(N=>N.engine.id)]),ie=w.filter(N=>N.selected&&N.engine&&K.has(N.engine)),Y=S.filter(N=>N.selected),A=[...new Map([...t.map(N=>[N.id,N.label||N.id]),...S.filter(N=>N.selected).map(N=>[N.engine.id,N.engine.label||N.engine.id])]).entries()];return c.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[c.jsx("b",{children:v("fleet-backup")}),c.jsx("small",{children:v("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"),x("")},children:v("fleet-backup-export")}),c.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="import"?" on":""}`,disabled:!s,title:s?"":v("fleet-backup-restore-unavailable"),onClick:()=>{h("import"),x("")},children:v("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(N=>N.id))),b(new Set(t.map(N=>N.id)))},children:v("select-all")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{f(new Set),b(new Set)},children:v("select-none")})]}),c.jsxs("div",{className:"nc-backup-list",children:[c.jsx("b",{children:v("fleet-engines")}),t.map(N=>{var j;return c.jsxs("label",{className:"nc-check nc-backup-row",children:[c.jsx("input",{type:"checkbox",checked:_.has(N.id),onChange:()=>T(b,N.id)}),c.jsxs("span",{children:[c.jsx("b",{children:N.label||N.id}),c.jsxs("small",{children:[N.id,(j=N.envKeys)!=null&&j.length?` · ${N.envKeys.length} ${v("fleet-backup-env-names")}`:""]})]})]},N.id)}),c.jsx("b",{children:v("fleet-cells")}),e.map(N=>c.jsxs("label",{className:"nc-check nc-backup-row",children:[c.jsx("input",{type:"checkbox",checked:m.has(N.id),onChange:()=>T(f,N.id)}),c.jsxs("span",{children:[c.jsx("b",{children:N.id}),c.jsxs("small",{children:[N.engine," · ",v("fleet-system-prompt")," ",(N.prompt||"").length," ",v("characters")]})]})]},N.id)),!e.length&&!t.length&&c.jsx("div",{className:"nc-empty",children:v("fleet-backup-empty")})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:v("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:!m.size&&!_.size,onClick:ee,children:v("fleet-backup-download")})]})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"file",accept:"application/json,.json",disabled:i,onChange:N=>V(N.target.files&&N.target.files[0])}),c.jsx("small",{children:v("fleet-backup-import-help")}),!!(w.length||S.length)&&c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{k(N=>N.map(j=>({...j,selected:!0}))),y(N=>N.map(j=>({...j,selected:!!j.engine})))},children:v("select-all")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{k(N=>N.map(j=>({...j,selected:!1}))),y(N=>N.map(j=>({...j,selected:!1})))},children:v("select-none")})]}),c.jsxs("div",{className:"nc-backup-list",children:[!!S.length&&c.jsx("b",{children:v("fleet-engines")}),S.map((N,j)=>{var L;return c.jsx("div",{className:"nc-backup-import-row",children:c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:N.selected,onChange:$=>te(j,{selected:$.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:N.engine.label||N.engine.id}),c.jsxs("small",{children:[N.engine.id," · ",N.exists?v("fleet-backup-overwrite"):v("fleet-backup-new"),(L=N.engine.envKeys)!=null&&L.length?` · ${v("fleet-backup-env-values-required")}`:""]})]})]})},N.engine.id)}),!!w.length&&c.jsx("b",{children:v("fleet-cells")}),w.map((N,j)=>c.jsxs("div",{className:"nc-backup-import-row",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:N.selected,disabled:!N.engine||!K.has(N.engine),onChange:L=>W(j,{selected:L.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:N.cell.id}),c.jsxs("small",{children:[N.exists?v("fleet-backup-overwrite"):v("fleet-backup-new")," · ",v("fleet-system-prompt")," ",N.cell.systemPrompt.length," ",v("characters")]})]})]}),c.jsxs("select",{value:N.engine,onChange:L=>W(j,{engine:L.target.value,selected:!!L.target.value}),children:[c.jsx("option",{value:"",children:v("fleet-backup-engine-missing")}),A.map(([L,$])=>c.jsx("option",{value:L,children:$},L))]})]},N.cell.id))]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:v("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||!ie.length&&!Y.length,onClick:()=>o({engineRows:S,cellRows:w}),children:v("fleet-backup-restore")})]})]}),C&&c.jsx("div",{className:"nc-err",children:C})]})}function SE({state:e,setState:t,busy:i,onSave:s,catalog:o}){var C;const a=e.form,u=x=>t({...e,form:{...a,...x}}),h=a.envRows||[],m=[...new Map(o.map(x=>[x.client,x.clientLabel||x.client])).entries()],f=o.filter(x=>x.client===a.client),_=wo(o,a),b=typeof(_==null?void 0:_.credentialEnv)=="string"?_.credentialEnv:"",w=Array.isArray(_==null?void 0:_.credentialUsedBy)?_.credentialUsedBy:[],y=(_==null?void 0:_.credentialSource)||"missing",S=!!b&&e.mode==="new"&&(_==null?void 0:_.authConfigured)!==!0&&!a.credentialValue&&!a.allowMissingCredential,k=x=>{x&&u({client:x.client,provider:x.provider,credentialProfile:x.credentialProfile||"",managedModel:x.model||"",protocol:x.protocol||"",permissionPolicy:x.permissionPolicyDefault||"standard",rc:!!x.rc,displayName:x.custom?v("fleet-custom-provider-default"):"",baseUrl:x.custom?"":x.endpoint||"",envKey:x.defaultEnvKey||"",providerId:"nexuscrew-custom",credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,...e.mode==="new"?{id:x.id,label:""}:{}})};return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsx("b",{children:e.mode==="new"?v("fleet-new-engine"):`${v("edit")} ${a.id}`}),c.jsx("input",{value:a.id,disabled:e.mode!=="new",placeholder:"id",onChange:x=>u({id:x.target.value})}),c.jsx("input",{value:a.label,placeholder:v("label"),onChange:x=>u({label:x.target.value})}),c.jsxs("select",{value:a.kind,disabled:e.mode!=="new",onChange:x=>u({kind:x.target.value}),children:[c.jsx("option",{value:"managed",children:v("fleet-managed")}),c.jsx("option",{value:"custom",children:v("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:x=>k(o.find(R=>R.client===x.target.value&&R.default)||o.find(R=>R.client===x.target.value)),children:m.map(([x,R])=>c.jsx("option",{value:x,children:R},x))}),c.jsx("select",{value:((C=wo(o,a))==null?void 0:C.id)||"",disabled:e.mode!=="new",onChange:x=>k(o.find(R=>R.id===x.target.value)),children:f.map(x=>c.jsx("option",{value:x.id,children:x.label},x.id))})]}),c.jsx("input",{value:a.managedModel,list:"nc-managed-models",placeholder:v(_!=null&&_.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:x=>u({managedModel:x.target.value})}),c.jsx("datalist",{id:"nc-managed-models",children:[...(_==null?void 0:_.models)||[],...a.modelOptions||[]].filter((x,R,D)=>x&&D.indexOf(x)===R).map(x=>c.jsx("option",{value:x},x))}),_!=null&&_.supportsUnsafe?c.jsxs("select",{value:a.permissionPolicy,onChange:x=>u({permissionPolicy:x.target.value}),children:[c.jsx("option",{value:"standard",children:v("fleet-standard-permissions")}),c.jsx("option",{value:"unsafe",children:v("fleet-unsafe-permissions")})]}):c.jsx("small",{children:v("fleet-standard-permissions")}),(_==null?void 0:_.supportsUnsafe)&&a.permissionPolicy==="unsafe"&&c.jsx("small",{className:"nc-err",children:v("fleet-unsafe-warning")}),(_==null?void 0:_.credentialEnv)===!0&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.envKey,placeholder:v("fleet-api-key-env"),onChange:x=>u({envKey:x.target.value})}),c.jsx("small",{children:v("fleet-custom-secret-help")})]}),b&&c.jsxs("section",{className:"nc-fleet-key","aria-label":v("fleet-key-section"),children:[c.jsxs("div",{className:"nc-fleet-key-head",children:[c.jsx("b",{children:v("fleet-key-section")}),c.jsx("span",{children:v(`fleet-credential-source-${y}`)})]}),c.jsxs("label",{className:"nc-field",children:[v("fleet-key-variable"),c.jsx("input",{value:b,readOnly:!0,"aria-label":v("fleet-key-variable")})]}),c.jsx("small",{children:w.length?v("fleet-key-used-by").replace("{engines}",w.join(", ")):v("fleet-key-used-by-none")}),w.length>0&&c.jsx("small",{children:v("fleet-key-shared-impact").replace("{key}",b).replace("{engines}",w.join(", "))}),c.jsxs("div",{className:"nc-fleet-key-input",children:[c.jsx("input",{type:a.credentialReveal?"text":"password",value:a.credentialValue||"","aria-label":v("fleet-key-value").replace("{key}",b),autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:_!=null&&_.authConfigured||e.mode==="edit"?v("fleet-key-blank-keeps"):v("fleet-key-enter"),onChange:x=>u({credentialValue:x.target.value,allowMissingCredential:x.target.value?!1:a.allowMissingCredential})}),c.jsx("button",{type:"button",className:"nc-btn ghost","aria-label":v(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal"),onClick:()=>u({credentialReveal:!a.credentialReveal}),children:v(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal")})]}),c.jsx("small",{children:v("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:x=>u({allowMissingCredential:x.target.checked})}),v("fleet-key-create-missing")]}),(_==null?void 0:_.notice)&&c.jsx("small",{className:"nc-fleet-provider-notice",children:v(`fleet-provider-notice-${_.notice}`)})]}),a.provider==="custom"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.displayName,placeholder:v("fleet-provider-display"),onChange:x=>u({displayName:x.target.value})}),c.jsx("input",{value:a.baseUrl,placeholder:"https://api.example.com/v1",onChange:x=>u({baseUrl:x.target.value})}),((_==null?void 0:_.protocols)||[]).length>1&&c.jsx("select",{value:a.protocol,onChange:x=>u({protocol:x.target.value}),children:_.protocols.map(x=>c.jsx("option",{value:x,children:x},x))}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:a.envKey,placeholder:v("fleet-api-key-env"),onChange:x=>u({envKey:x.target.value})}),c.jsx("input",{value:a.providerId,placeholder:v("fleet-provider-id"),onChange:x=>u({providerId:x.target.value})})]}),c.jsxs("small",{children:[a.protocol," · ",v("fleet-custom-secret-help")]})]}),c.jsx("small",{children:v("fleet-managed-help")})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.command,placeholder:v("command-path"),onChange:x=>u({command:x.target.value})}),c.jsx("textarea",{value:a.argsText,placeholder:v("args-lines"),onChange:x=>u({argsText:x.target.value})}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:a.rc,onChange:x=>u({rc:x.target.checked})})," remote control"]}),c.jsxs("select",{value:a.promptMode,onChange:x=>u({promptMode:x.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:x=>u({promptFlag:x.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:a.modelFlag,placeholder:"model flag",onChange:x=>u({modelFlag:x.target.value})}),c.jsx("input",{value:a.modelValue,placeholder:"model default",onChange:x=>u({modelValue:x.target.value})})]}),c.jsx("small",{children:v("env-write-only")}),h.map((x,R)=>c.jsxs("div",{className:"nc-fleet-env",children:[c.jsx("input",{value:x.key,disabled:x.configured,placeholder:"ENV_KEY",onChange:D=>{const T=h.slice();T[R]={...x,key:D.target.value},u({envRows:T})}}),c.jsx("input",{type:"password",value:x.value,placeholder:x.configured?"•••••• (unchanged)":"value",onChange:D=>{const T=h.slice();T[R]={...x,value:D.target.value},u({envRows:T})}}),c.jsx("button",{className:"nc-btn danger",onClick:()=>u({envRows:h.filter((D,T)=>T!==R)}),children:"×"})]},`${x.key}-${R}`)),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:v("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:i||!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:v("save")})]})]})}function wE({token:e,route:t,targets:i=[],location:s,setLocation:o,state:a,setState:u,engines:h,busy:m,onSave:f}){const[_,b]=P.useState(null),[w,y]=P.useState(""),S=a.form,k=D=>u({...a,form:{...S,...D}}),C=h.find(D=>D.id===S.engine),x=D=>{var ee,V,W;const T=h.find(te=>te.id===D);k({engine:D,model:((ee=S.models)==null?void 0:ee[D])||((V=T==null?void 0:T.managed)==null?void 0:V.model)||((W=T==null?void 0:T.model)==null?void 0:W.value)||""})},R=async D=>{try{const T=await Hv(e,D,t);b(T),k({cwd:T.path}),y("")}catch(T){y(String(T.message||T))}};return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsx("b",{children:a.mode==="new"?v("fleet-new-cell"):`${v("edit")} ${S.id}`}),a.mode==="new"&&c.jsxs("label",{className:"nc-field",children:[v("location"),c.jsx("span",{className:"nc-req",children:" *"}),c.jsxs("select",{value:s,onChange:D=>{o(D.target.value),k({engine:""})},children:[c.jsx("option",{value:"",children:v("local")}),i.map(D=>c.jsxs("option",{value:D.route.join("/"),disabled:D.status&&D.status!=="up",children:[D.label,D.status&&D.status!=="up"?` · ${v("node-offline")}`:""]},D.route.join("/")))]})]}),c.jsx("input",{value:S.id,disabled:a.mode!=="new",placeholder:"id",onChange:D=>k({id:D.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:S.cwd,placeholder:v("cwd"),onChange:D=>k({cwd:D.target.value})}),c.jsx("button",{className:"nc-btn ghost",onClick:()=>_?b(null):R(S.cwd),children:v("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:()=>R(_.parent),children:["↑ ",v("fs-parent")]}),(_.dirs||[]).map(D=>c.jsxs("button",{className:"nc-fs-item",onClick:()=>R(`${_.path.replace(/\/$/,"")}/${D}`),children:["📁 ",D]},D))]})]}),w&&c.jsx("div",{className:"nc-err",children:w}),c.jsx("select",{value:S.engine,onChange:D=>x(D.target.value),children:h.map(D=>c.jsx("option",{value:D.id,children:D.label},D.id))}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:!!S.boot,onChange:D=>k({boot:D.target.checked})})," boot"]}),c.jsx("input",{value:S.model||"",list:"nc-cell-models",placeholder:v("fleet-model-override"),onChange:D=>k({model:D.target.value})}),c.jsx("datalist",{id:"nc-cell-models",children:((C==null?void 0:C.availableModels)||[]).map(D=>c.jsx("option",{value:D},D))}),c.jsx("textarea",{value:S.prompt||"",placeholder:"prompt",onChange:D=>k({prompt:D.target.value})}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>u(null),children:v("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:m||!S.id||!S.cwd||!S.engine,onClick:f,children:v("save")})]})]})}function Pv({token:e,route:t=[],state:i,setState:s,busy:o,onSave:a}){const[u,h]=P.useState(null),[m,f]=P.useState([]),[_,b]=P.useState(""),w=Array.isArray(t)?t.join("/"):"";P.useEffect(()=>{let x=!0;return ih(e,w?w.split("/"):[]).then(R=>{x&&(f(R.engines||[]),b(""))}).catch(R=>{x&&(f([]),b(String(R.message||R)))}),()=>{x=!1}},[e,w]);const y=i.form,S=x=>s({...i,form:{...y,...x}}),k=async x=>{try{const R=await Hv(e,x,t);h(R),S({cwd:R.path})}catch{}},C=!y.id&&y.tmuxSession?y.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):y.id;return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsxs("b",{children:[v("import-as-cell")," · ",y.tmuxSession]}),c.jsx("small",{children:v("import-help")}),c.jsx("input",{value:y.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),c.jsx("input",{value:y.id,placeholder:v("name"),onChange:x=>S({id:x.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:y.cwd,placeholder:v("cwd"),onChange:x=>S({cwd:x.target.value})}),c.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>u?h(null):k(y.cwd),children:v("browse")})]}),u&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:u.path}),c.jsxs("div",{className:"nc-fs-list",children:[u.parent&&c.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>k(u.parent),children:["↑ ",v("fs-parent")]}),(u.dirs||[]).map(x=>c.jsxs("button",{className:"nc-fs-item",onClick:()=>k(`${u.path.replace(/\/$/,"")}/${x}`),children:["📁 ",x]},x))]})]}),c.jsxs("select",{value:y.engine,onChange:x=>S({engine:x.target.value}),children:[c.jsx("option",{value:"",children:v("import-engine-required")}),m.map(x=>c.jsx("option",{value:x.id,children:x.label},x.id))]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:!!y.boot,onChange:x=>S({boot:x.target.checked})})," boot"]}),(i.err||_)&&c.jsx("div",{className:"nc-err",children:i.err||_}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:v("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:o||!y.tmuxSession||!y.engine||!m.length,onClick:a,children:v(C?"import-as-cell":"save")})]})]})}function bE({token:e,readonly:t,targets:i=[],startNewCell:s=!1,initialLocation:o=""}){const[a,u]=P.useState({engines:[],cells:[],managedCatalog:[]}),[h,m]=P.useState({available:!1,capabilities:[]}),[f,_]=P.useState(!1),[b,w]=P.useState(null),[y,S]=P.useState(null),[k,C]=P.useState(!1),[x,R]=P.useState(""),[D,T]=P.useState(""),[ee,V]=P.useState(o),[W,te]=P.useState(!1),[K,ie]=P.useState(null),[Y,A]=P.useState(null),[N,j]=P.useState(!1),[L,$]=P.useState([]),[U,B]=P.useState(null),[J,z]=P.useState("manage"),M=P.useRef(!1),I=ee?ee.split("/"):[],se=P.useCallback(async()=>{try{const le=await Er(e,I);m(le);try{const ke=await rh(e,I);te(!!ke.readonlyDefault)}catch{te(!1)}if(le.provider==="builtin"&&(le.capabilities||[]).includes("definitions")){const ke=await ih(e,I),$e=new Map((le.engines||[]).map(We=>[We.id,We]));if(ke.engines=(ke.engines||[]).map(We=>{var pe;return{...We,availableModels:((pe=$e.get(We.id))==null?void 0:pe.models)||[]}}),u(ke),(le.capabilities||[]).includes("credentials"))try{$((await Kw(e,I)).credentials||[])}catch{$([])}else $([])}R("")}catch(le){R(String(le.message||le))}finally{_(!0)}},[e,ee]);P.useEffect(()=>{se();const le=setInterval(se,5e3);return()=>clearInterval(le)},[se]);const ge=new Set((h.cells||[]).filter(le=>le.active).map(le=>le.cell)),de=h.provider==="builtin"&&(h.capabilities||[]).includes("edit"),fe=(h.capabilities||[]).includes("restore");P.useEffect(()=>{!s||M.current||!de||!a.engines.length||(M.current=!0,S({mode:"new",form:Rv(a.engines[0].id)}))},[s,de,a.engines]);const X=async le=>{C(!0),R(""),T("");try{await le(),await se()}catch(ke){R(String(ke.message||ke))}C(!1)},Z=()=>X(async()=>{var oe;const le=b.mode==="new",ke=b.form,$e=a.managedCatalog||[],We=ke.kind==="managed"?wo($e,ke):null,pe=typeof(We==null?void 0:We.credentialEnv)=="string"?We.credentialEnv:"",Oe=pe&&ke.credentialValue||"",Me=_E(ke,le,$e);!le&&b.form.kind==="custom"&&!b.form.modelFlag&&(Me.model=null),!le&&b.form.kind==="custom"&&b.form.promptMode!=="flag"&&(Me.promptFlag=null);let G;if(le)G=await Vw(e,Me,I);else{const me=b.original,Te=new Set(b.form.envRows.filter(He=>!He.remove).map(He=>He.key)),we=(me.envKeys||[]).filter(He=>!Te.has(He)),Ce=Object.fromEntries(b.form.envRows.filter(He=>!He.remove&&He.key&&(!He.configured||He.value!=="")).map(He=>[He.key,He.value]));G=await Yw(e,me.id,Me,b.form.kind==="custom"?{set:Ce,remove:we}:void 0,I)}let re=null;if(pe&&Oe)try{re=await gm(e,pe,Oe,I),$(re.credentials||[])}catch{throw await se(),le&&w({mode:"edit",original:{...Me,id:ke.id},form:{...ke,credentialReveal:!1}}),new Error(v(le?"fleet-key-partial-create":"fleet-key-partial-edit"))}await se(),w(null),T(v("fleet-saved"));const F=((oe=((re==null?void 0:re.credentials)||[]).find(me=>me.envKey===pe))==null?void 0:oe.activeCells)||[],H=[...new Set([...(G==null?void 0:G.activeCells)||[],...F])];if(H.length&&window.confirm(v("fleet-restart-confirm").replace("{cells}",H.join(", "))))for(const me of H)await uo(e,me,I)}),ye=()=>X(async()=>{const le=y.mode==="new",ke=y.form,$e={...le?{id:ke.id}:{},cwd:ke.cwd,engine:ke.engine,boot:!!ke.boot};le?(ke.model&&($e.model=ke.model),ke.prompt&&($e.prompt=ke.prompt)):($e.model=ke.model||null,$e.prompt=ke.prompt||null);const We=le?await Gw(e,$e,I):await Qw(e,y.original.id,$e,I),pe=le?ke.id:y.original.id;S(null),T(v("fleet-saved")),!le&&(We!=null&&We.active)&&window.confirm(v("fleet-restart-confirm").replace("{cells}",pe))&&await uo(e,pe,I)}),Ee=t||W,tt=le=>L.find(ke=>{var $e;return($e=ke.engines)==null?void 0:$e.includes(le.id)})||null,Ye=()=>X(async()=>{var $e;const le=await gm(e,U.envKey,U.value,I);$(le.credentials||[]),B(null),T(v("fleet-credential-saved"));const ke=(($e=(le.credentials||[]).find(We=>We.envKey===U.envKey))==null?void 0:$e.activeCells)||[];if(ke.length&&window.confirm(v("fleet-restart-confirm").replace("{cells}",ke.join(", "))))for(const We of ke)await uo(e,We,I)}),Be=le=>X(async()=>{if(!window.confirm(v("fleet-credential-remove-confirm").replace("{key}",le.envKey)))return;const ke=await qw(e,le.envKey,I);$(ke.credentials||[]),T(v("fleet-credential-removed"))}),ot=le=>ie({...le,route:Array.isArray(le==null?void 0:le.route)?le.route:I}),Xe=async le=>{if(!K)return;const ke=K.cell||K.id,$e=Array.isArray(K.route)?K.route:I;le.action==="up"?await th(e,{cell:ke,boot:!!le.boot,...le.engine?{engine:le.engine}:{},...le.model!==void 0?{model:le.model}:{},...le.permissionPolicy?{permissionPolicy:le.permissionPolicy}:{}},$e):await il(e,{cell:ke,boot:!!le.boot},$e)},_t=(le,ke)=>{R(""),A({mode:"new",route:Array.isArray(ke)?ke:I,form:{tmuxSession:le.name,id:"",engine:"",cwd:"",boot:!1},err:""})},ut=()=>X(async()=>{const le=Y.form;if(!le.engine){A({...Y,err:v("import-engine-required")});return}await Jw(e,{tmuxSession:le.tmuxSession,id:le.id||void 0,engine:le.engine,cwd:le.cwd||void 0,boot:!!le.boot},le.route||I),A(null),T(v("fleet-saved"))}),ht=({engineRows:le=[],cellRows:ke=[]})=>X(async()=>{const $e=le.filter(oe=>oe.selected),We=$e.map(oe=>Dy(oe.engine));if(We.some(oe=>!oe))throw new Error(v("fleet-backup-invalid-engine"));const pe=$e.filter(oe=>oe.exists).map(oe=>oe.engine.id);if(pe.length&&!window.confirm(v("fleet-backup-confirm-engine-overwrite").replace("{engines}",pe.join(", "))))return;const Oe=[...new Set([...a.engines.map(oe=>oe.id),...We.map(oe=>oe.id)])],Me=[];for(const oe of ke.filter(me=>me.selected)){const me=pE(oe.cell,oe.engine,Oe);if(!me)throw new Error(`${oe.cell.id}: ${v("fleet-backup-engine-missing")}`);Me.push(me)}const G=ke.filter(oe=>oe.selected&&oe.exists).map(oe=>oe.cell.id);if(G.length&&!window.confirm(v("fleet-backup-confirm-overwrite").replace("{cells}",G.join(", "))))return;const re=We.length?await e0(e,We,pe.length>0,I):{needsRestart:[]},F=Me.length?await Zw(e,Me,I):{needsRestart:[]},H=[...new Set([...re.needsRestart||[],...F.needsRestart||[]])];j(!1),T(`${v("fleet-backup-restored").replace("{n}",String(Me.length))}${We.length?` · ${We.length} ${v("fleet-engines").toLowerCase()}`:""}${H.length?` · ${v("fleet-backup-needs-restart").replace("{cells}",H.join(", "))}`:""}`)}),rt=c.jsxs("label",{className:"nc-field",children:[v("location"),c.jsxs("select",{value:ee,onChange:le=>{V(le.target.value),w(null),S(null),R(""),T(""),te(!1),_(!1),m({available:!1,capabilities:[]}),u({engines:[],cells:[],managedCatalog:[]}),$([]),B(null)},children:[c.jsx("option",{value:"",children:v("local")}),i.map(le=>c.jsxs("option",{value:le.route.join("/"),disabled:le.status&&le.status!=="up",children:[le.label,le.status&&le.status!=="up"?` · ${v("node-offline")}`:""]},le.route.join("/")))]})]}),lt=c.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":v("tab-fleet"),children:[c.jsx("button",{type:"button",role:"tab","aria-selected":J==="manage",className:`nc-set-tabbtn${J==="manage"?" on":""}`,onClick:()=>z("manage"),children:v("fleet-manage-location")}),c.jsx("button",{type:"button",role:"tab","aria-selected":J==="overview",className:`nc-set-tabbtn${J==="overview"?" on":""}`,onClick:()=>z("overview"),children:v("fleet-network-overview")})]});return f?de?c.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[lt,J==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:v("fleet-overview-help")}),c.jsx(Ju,{token:e,targets:i,readonly:t,onPower:ot,onImport:_t})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:v("fleet-manage-help")}),rt,c.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[c.jsx("button",{className:"nc-btn ghost",disabled:Ee||k,onClick:()=>{R(""),j(!0)},children:v("fleet-backup")}),c.jsx("small",{children:v("fleet-backup-help")})]}),c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:v("fleet-cells")}),c.jsx("span",{className:"nc-fleet-head-actions",children:c.jsxs("button",{className:"nc-btn primary",disabled:Ee||k||!a.engines.length,onClick:()=>{var le;R(""),S({mode:"new",form:Rv((le=a.engines[0])==null?void 0:le.id)})},children:["+ ",v("add")]})})]}),a.cells.map(le=>{const ke=ge.has(le.id),$e=h.capabilities||[];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," · ",le.cwd,ke?` · ${v("service-active")}`:` · ${v("cell-off")}`]})]}),c.jsxs("span",{children:[ke&&$e.includes("down")&&c.jsx("button",{className:"nc-btn ghost",disabled:Ee||k,onClick:()=>X(()=>il(e,{cell:le.id},I)),children:v("stop")}),!ke&&$e.includes("up")&&c.jsx("button",{className:"nc-btn primary",disabled:Ee||k,onClick:()=>ot({cell:le.id,id:le.id,engine:le.engine,model:le.model,models:le.models,permissionPolicies:le.permissionPolicies,active:!1,boot:le.boot}),children:v("start")}),ke&&$e.includes("restart")&&c.jsx("button",{className:"nc-btn ghost",disabled:Ee||k,onClick:()=>X(()=>uo(e,le.id,I)),children:v("restart")}),c.jsx("button",{className:"nc-btn ghost",disabled:Ee||k,onClick:()=>{R(""),S({mode:"edit",original:le,form:{...le}})},children:v("edit")}),c.jsx("button",{className:"nc-btn danger",disabled:Ee||k,onClick:()=>X(async()=>{window.confirm(v("fleet-remove-cell").replace("{id}",le.id))&&await Fv(e,le.id,!0,I)}),children:"×"})]})]},le.id)}),c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:v("fleet-engines")}),c.jsxs("button",{className:"nc-btn primary",disabled:Ee||k,onClick:()=>{R(""),w({mode:"new",form:mE()})},children:["+ ",v("add")]})]}),a.engines.map(le=>{var $e,We;const ke=tt(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} · ${($e=le.managedInfo)!=null&&$e.configured?v("fleet-ready"):((We=le.managedInfo)==null?void 0:We.reason)||v("fleet-not-ready")}`:`${le.id} · ${le.command}`}),ke&&c.jsxs("small",{children:[ke.envKey," · ",v(`fleet-credential-source-${ke.source||"missing"}`)]})]}),c.jsxs("span",{children:[ke&&c.jsx("button",{className:"nc-btn ghost",disabled:Ee||k,onClick:()=>{R(""),B({envKey:ke.envKey,value:""})},children:ke.configured?v("fleet-credential-change"):v("fleet-credential-set")}),(ke==null?void 0:ke.source)==="local"&&c.jsx("button",{className:"nc-btn danger",disabled:Ee||k,onClick:()=>Be(ke),children:v("fleet-credential-forget")}),c.jsx("button",{className:"nc-btn ghost",disabled:Ee||k,onClick:()=>{R(""),w({mode:"edit",original:le,form:vE(le)})},children:v("edit")}),c.jsx("button",{className:"nc-btn danger",disabled:Ee||k,onClick:()=>X(async()=>{window.confirm(v("fleet-remove-engine").replace("{id}",le.id))&&await Xw(e,le.id,I)}),children:"×"})]})]},le.id)})]}),b&&c.jsx(ns,{onClose:()=>w(null),label:v("fleet-new-engine"),error:x,children:c.jsx(SE,{state:b,setState:w,busy:k,onSave:Z,catalog:a.managedCatalog||[]})}),y&&c.jsx(ns,{onClose:()=>S(null),label:v("fleet-new-cell"),error:x,children:c.jsx(wE,{token:e,route:I,targets:i,location:ee,setLocation:V,state:y,setState:S,engines:a.engines,busy:k,onSave:ye})}),D&&c.jsx("div",{className:"nc-set-note",children:D}),x&&c.jsx("div",{className:"nc-err",children:x}),N&&c.jsx(ns,{onClose:()=>j(!1),label:v("fleet-backup"),error:x,children:c.jsx(yE,{cells:a.cells,engines:a.engines,busy:k,canRestore:fe,onRestore:ht,onClose:()=>j(!1)})}),U&&c.jsx(ns,{onClose:()=>B(null),label:v("fleet-credential-title"),error:x,children:c.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[c.jsx("b",{children:v("fleet-credential-title")}),c.jsx("small",{children:v("fleet-credential-help")}),c.jsxs("label",{className:"nc-field",children:[U.envKey,c.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:U.value,onChange:le=>B({...U,value:le.target.value})})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>B(null),children:v("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:k||!U.value,onClick:Ye,children:v("save")})]})]})}),Y&&c.jsx(ns,{onClose:()=>A(null),label:v("import-as-cell"),error:x,children:c.jsx(Pv,{token:e,route:Y.route||I,state:Y,setState:A,busy:k,onSave:ut})}),K&&c.jsx(nl,{cell:K,token:e,route:Array.isArray(K.route)?K.route:I,onConfirm:async le=>{try{await Xe(le)}finally{await se()}},onClose:()=>ie(null)})]}):c.jsxs("div",{className:"nc-set-tab",children:[lt,J==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:v("fleet-overview-help")}),c.jsx(Ju,{token:e,targets:i,readonly:t,onPower:ot,onImport:_t})]}):c.jsxs(c.Fragment,{children:[rt,c.jsxs("div",{className:"nc-set-info",children:[v(x?"fleet-editor-load-error":"fleet-editor-unavailable"),!x&&h.reason?` ${h.reason}`:""]})]}),x&&c.jsx("div",{className:"nc-err",children:x}),Y&&c.jsx(ns,{onClose:()=>A(null),label:v("import-as-cell"),error:x,children:c.jsx(Pv,{token:e,route:Y.route||I,state:Y,setState:A,busy:k,onSave:ut})}),K&&c.jsx(nl,{cell:K,token:e,route:Array.isArray(K.route)?K.route:I,onConfirm:async le=>{try{await Xe(le)}finally{await se()}},onClose:()=>ie(null)})]}):c.jsxs("div",{className:"nc-set-tab",children:[lt,J==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:v("fleet-overview-help")}),c.jsx(Ju,{token:e,targets:i,readonly:t,onPower:ot,onImport:_t})]}):c.jsxs(c.Fragment,{children:[rt,c.jsx("div",{className:"nc-set-info",children:v("fleet-editor-loading")})]})]})}function kE({text:e}){const[t,i]=P.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!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(it,{name:"copy",size:14})," ",v(t?"copied":"copy")]})]})}function xE({value:e}){const[t,i]=P.useState("");return P.useEffect(()=>{let s=!0;return zC.toDataURL(e,{margin:1,width:220}).then(o=>{s&&i(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?c.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function CE({token:e,nodes:t,roster:i,settings:s,readonly:o,refresh:a,refreshAliases:u}){const[h,m]=P.useState(null),[f,_]=P.useState(null),[b,w]=P.useState({}),[y,S]=P.useState(null),[k,C]=P.useState({ssh:"",sshPort:"",name:""}),[x,R]=P.useState(""),[D,T]=P.useState(""),[ee,V]=P.useState(""),[W,te]=P.useState(!1),[K,ie]=P.useState(null),[Y,A]=P.useState(null),N=Date.now(),j=s&&s.deviceName||"",L=(t||[]).filter(X=>X&&X.direction==="outbound"&&X.name&&X.ssh),$=L.find(X=>X.name===x)||L[0]||null,U=L.find(X=>X.name===D)||L[0]||null,B=U?Am(U.tunnel,N):null,J=U!=null&&U.shared?B!=null&&B.up?"share-local-active":"share-local-pending":B!=null&&B.up?"share-local-private":"share-local-private-down",z=[{key:"peer-group-hubs",rows:(t||[]).filter(X=>X.kind!=="transitive"&&X.relation!=="client")},{key:"peer-group-clients",rows:(t||[]).filter(X=>X.kind!=="transitive"&&X.relation==="client")},{key:"peer-group-routed",rows:(t||[]).filter(X=>X.kind==="transitive")}],M=async(X,Z)=>{m(null),_(`${X}:${Z}`);try{const ye=await sh(e,X,Z);Z==="test"&&w(Ee=>({...Ee,[X]:ye})),await a()}catch(ye){m(`${X}: ${String(ye.message||ye)}`)}_(null)},I=async X=>{m(null),_(`${X}:remove`);try{await c0(e,X),A(null),await a()}catch(Z){m(`${X}: ${String(Z.message||Z)}`)}_(null)},se=X=>ie({name:X.name,direction:X.direction,label:X.label||X.name,ssh:X.ssh||"",sshPort:X.sshPort?String(X.sshPort):"",autostart:X.autostart===!0,visibility:X.visibility||"network",selected:[...X.selected||[]]}),ge=async()=>{if(!K||!us(K.label)){m(v("err-label"));return}const X=K.direction==="inbound"?{label:K.label,visibility:K.visibility,selected:K.visibility==="selected"?K.selected:[]}:{label:K.label,ssh:K.ssh,autostart:K.autostart,...K.sshPort?{sshPort:Number(K.sshPort)}:{}};m(null),_(`${K.name}:edit`);try{await l0(e,K.name,X),ie(null),await a()}catch(Z){m(`${K.name}: ${String(Z.message||Z)}`)}_(null)},de=async X=>{if(U){m(null),_(`${U.name}:share`);try{await u0(e,U.name,X),await a()}catch(Z){const ye=Z!=null&&Z.data&&typeof Z.data.hint=="string"?Z.data.hint:"";m(`${U.name}: ${String(Z.message||Z)}${ye?` — ${ye}`:""}`)}_(null)}},fe=async()=>{if(m(null),$){const ye=Tm({name:$.name,ssh:$.ssh,sshPort:$.sshPort||""});if(!ye.ok){m(v(ye.error));return}_("invite");try{S(await _m(e,{ssh:ye.value.ssh,...ye.value.sshPort?{sshPort:ye.value.sshPort}:{}},[$.name]))}catch(Ee){m(String(Ee.message||Ee))}_(null);return}const X=Jn(k.name||ee||j||"NexusCrew"),Z=Tm({name:X,ssh:k.ssh,sshPort:k.sshPort});if(!Z.ok){m(v(Z.error));return}_("invite");try{S(await _m(e,{...ee||j?{label:ee||j}:{},name:X,ssh:Z.value.ssh,...Z.value.sshPort?{sshPort:Z.value.sshPort}:{}}))}catch(ye){m(String(ye.message||ye))}_(null)};return c.jsxs("div",{className:"nc-set-tab",children:[c.jsx("div",{className:"nc-sheet-label",children:v("peer-inventory-title")}),(t||[]).length===0&&c.jsx("div",{className:"nc-empty",children:v("no-nodes")}),z.map(X=>X.rows.length>0&&c.jsxs("div",{className:"nc-peer-group",children:[c.jsxs("div",{className:"nc-peer-group-title",children:[v(X.key)," ",c.jsx("span",{children:X.rows.length})]}),X.rows.map(Z=>{var Be,ot;const ye=Z.kind==="transitive",Ee=ye?{up:Z.stale!==!0,label:Z.stale===!0?"peer-routed-stale":"peer-routed"}:Am(Z.tunnel,N),tt=b[Z.name],Ye=Z.actions||{};return c.jsxs("div",{className:`nc-set-node${ye?" routed":""}`,children:[c.jsxs("div",{className:"nc-set-node-head",children:[c.jsx("span",{className:`nc-dot ${Ee.up?"on":""}`}),c.jsx("b",{children:Z.label||Z.name}),c.jsxs("small",{children:[Z.name,ye?` · ${Z.route.join(" → ")}`:Z.direction==="outbound"?` · SSH ${Z.ssh||""}`:` · ${v("node-connected-client")}`,(Be=Z.tunnel)!=null&&Be.transport?` · ${Z.tunnel.transport} ${v("transport-used")}`:""]}),c.jsxs("span",{className:`nc-set-tunnel${Ee.up?" up":""}`,children:[v(Ee.label),Ee.since?` · ${Ee.since}`:""]})]}),!ye&&Z.direction==="inbound"&&c.jsx("div",{className:"nc-set-info",children:v(Z.shared?"peer-shared":"peer-private")}),Ye.visibility&&Z.shared&&c.jsxs(c.Fragment,{children:[c.jsxs("select",{value:Z.visibility||"network",disabled:o||!!f,onChange:async Xe=>{_(`${Z.name}:visibility`);try{await Sm(e,Z.name,Xe.target.value),await a()}catch(_t){m(String(_t.message||_t))}_(null)},children:[c.jsx("option",{value:"network",children:v("visibility-network")}),c.jsx("option",{value:"relay-only",children:v("visibility-relay")}),c.jsx("option",{value:"selected",children:v("visibility-selected")})]}),Z.visibility==="selected"&&c.jsx("div",{className:"nc-set-row",children:(t||[]).filter(Xe=>Xe.name!==Z.name&&Xe.nodeId).map(Xe=>{const _t=(Z.selected||[]).includes(Xe.nodeId);return c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:_t,disabled:o||!!f,onChange:async ut=>{const ht=ut.target.checked?[...Z.selected||[],Xe.nodeId]:(Z.selected||[]).filter(rt=>rt!==Xe.nodeId);_(`${Z.name}:visibility`);try{await Sm(e,Z.name,"selected",ht),await a()}catch(rt){m(String(rt.message||rt))}_(null)}})," ",Xe.label||Xe.name]},Xe.nodeId)})})]}),c.jsxs("div",{className:"nc-set-node-actions",children:[Ye.edit&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:()=>se(Z),children:v("edit")}),Ye.test&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>M(Z.name,"test"),children:v("node-test")}),Ye.disconnect&&Ee.up&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:()=>M(Z.name,"down"),children:v("tunnel-stop")}),Ye.connect&&!Ee.up&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:()=>M(Z.name,"up"),children:v("tunnel-start")}),Ye.restart&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:()=>M(Z.name,"restart"),children:v("tunnel-restart")}),Ye.remove&&c.jsxs("button",{type:"button",className:"nc-btn danger",disabled:o||!!f,title:v(o?"settings-readonly":"delete"),onClick:()=>A(Z.name),children:[c.jsx(it,{name:"trash",size:14})," ",v("delete")]})]}),(K==null?void 0:K.name)===Z.name&&c.jsxs("div",{className:"nc-set-form nc-node-editor",children:[c.jsxs("label",{className:"nc-field",children:[v("node-display-label"),c.jsx("input",{value:K.label,disabled:!!f,onChange:Xe=>ie({...K,label:Xe.target.value})})]}),K.direction==="outbound"?c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"nc-field",children:[v("node-ssh-label"),c.jsx("input",{value:K.ssh,disabled:!!f,onChange:Xe=>ie({...K,ssh:Xe.target.value})})]}),c.jsxs("label",{className:"nc-field",children:[v("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",value:K.sshPort,disabled:!!f,onChange:Xe=>ie({...K,sshPort:Xe.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:K.autostart,disabled:!!f,onChange:Xe=>ie({...K,autostart:Xe.target.checked})})," ",v("boot-persist")]})]}):c.jsxs("label",{className:"nc-field",children:[v("peer-visibility"),c.jsxs("select",{value:K.visibility,disabled:!!f,onChange:Xe=>ie({...K,visibility:Xe.target.value}),children:[c.jsx("option",{value:"network",children:v("visibility-network")}),c.jsx("option",{value:"relay-only",children:v("visibility-relay")}),c.jsx("option",{value:"selected",children:v("visibility-selected")})]})]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!f,onClick:ge,children:v("save")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>ie(null),children:v("cancel")})]})]}),Y===Z.name&&c.jsxs("div",{className:"nc-set-confirm",children:[c.jsx("b",{children:v("node-remove-confirm").replace("{name}",Z.label||Z.name)}),c.jsx("small",{children:v("node-remove-warning")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn danger",disabled:!!f,onClick:()=>I(Z.name),children:v("delete")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>A(null),children:v("cancel")})]})]}),((ot=Z.health)==null?void 0:ot.detail)&&c.jsx("div",{className:`nc-set-test${Z.health.status==="healthy"?" ok":Z.health.status==="passive"?"":" ko"}`,children:Z.health.detail}),tt&&c.jsxs("div",{className:`nc-set-test${tt.ok?" ok":" ko"}`,children:[tt.result,tt.detail?` — ${tt.detail}`:""]})]},`${Z.kind||"direct"}:${Z.nodeId||Z.name}`)})]},X.key)),(i||[]).some(X=>!X.direct&&X.instanceId)&&c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:v("routed-node-aliases")}),c.jsx("small",{className:"nc-set-hint",children:v("routed-node-aliases-help")}),(i||[]).filter(X=>!X.direct&&X.instanceId).map(X=>c.jsxs("div",{className:"nc-set-node",children:[c.jsxs("div",{className:"nc-set-node-head",children:[c.jsx("span",{className:`nc-dot ${X.status==="up"?"on":""}`}),c.jsx("b",{children:X.label||X.name}),c.jsx("small",{children:(X.route||[]).join(" › ")})]}),c.jsxs("div",{className:"nc-set-node-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:async()=>{const Z=window.prompt(v("node-local-alias"),X.alias||"");if(Z!=null){if(Z.trim()&&!us(Z.normalize("NFC"))){m(v("err-label"));return}_(`${X.instanceId}:alias`),m(null);try{Z.trim()?await a0(e,X.instanceId,Z):await ym(e,X.instanceId),u()}catch(ye){m(String(ye.message||ye))}_(null)}},children:v("alias-on-device")}),X.alias&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:async()=>{_(`${X.instanceId}:alias-reset`),m(null);try{await ym(e,X.instanceId),u()}catch(Z){m(String(Z.message||Z))}_(null)},children:v("reset-alias")})]})]},X.instanceId))]}),U&&c.jsxs("div",{className:"nc-set-form nc-local-share",children:[c.jsx("div",{className:"nc-sheet-label",children:v("share-local-heading")}),L.length>1&&c.jsxs("label",{className:"nc-field",children:[v("share-local-hub"),c.jsx("select",{value:U.name,disabled:o||!!f,onChange:X=>T(X.target.value),children:L.map(X=>c.jsx("option",{value:X.name,children:X.label||X.name},X.name))})]}),c.jsxs("label",{className:"nc-check nc-node-share",children:[c.jsx("input",{type:"checkbox",checked:U.shared===!0,disabled:o||!!f,onChange:X=>de(X.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:v("share-local-through").replace("{device}",j||v("local")).replace("{hub}",U.label||U.name)}),c.jsx("small",{children:v(U.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),c.jsx("div",{className:`nc-set-test${U.shared&&(B!=null&&B.up)?" ok":B!=null&&B.up?"":" ko"}`,children:v(J)}),!(B!=null&&B.up)&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:()=>de(U.shared===!0),children:v("share-local-reconnect")})]}),c.jsx(xy,{token:e,deviceDefault:j,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:v("invite-node")}),c.jsx("small",{className:"nc-set-hint",children:v($?"invite-network-hint":"invite-v2-hint")}),$?c.jsxs(c.Fragment,{children:[L.length>1&&c.jsxs("label",{className:"nc-field",children:[v("invite-network-label"),c.jsx("select",{value:$.name,disabled:o||!!f,onChange:X=>{R(X.target.value),S(null)},children:L.map(X=>c.jsx("option",{value:X.name,children:X.label||X.name},X.name))})]}),c.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[v("invite-network-via"),": ",c.jsx("b",{children:$.label||$.name})," · ",$.ssh,$.sshPort?`:${$.sshPort}`:""]}),c.jsx("small",{className:"nc-set-hint",children:v("invite-network-route")})]}):c.jsxs("label",{className:"nc-field",children:[v("invite-endpoint-label"),c.jsx("input",{placeholder:"user@host",value:k.ssh,disabled:o,onChange:X=>C({...k,ssh:X.target.value})}),c.jsx("small",{className:"nc-set-hint",children:v("invite-endpoint-needed")})]}),!$&&W&&c.jsxs("div",{className:"nc-invite-advanced",children:[c.jsxs("label",{className:"nc-field",children:[v("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",placeholder:"22",value:k.sshPort,disabled:o,onChange:X=>C({...k,sshPort:X.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),c.jsxs("label",{className:"nc-field",children:[v("device-name-label"),c.jsx("input",{placeholder:j||"NexusCrew",value:ee,disabled:o,onChange:X=>V(X.target.value)}),c.jsx("small",{className:"nc-set-hint",children:v("device-name-hint")})]}),c.jsxs("label",{className:"nc-field",children:[v("node-name-label"),c.jsx("input",{placeholder:Jn(ee||j||v("node-name-ph")),value:k.name,disabled:o,onChange:X=>C({...k,name:X.target.value?Jn(X.target.value):""})})]})]}),c.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||!!f||!$&&!k.ssh.trim(),onClick:fe,children:v("create-pairing-link")}),!$&&c.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>te(X=>!X),children:[W?"▾":"▸"," ",v("pair-advanced")]})]}),y&&c.jsxs(c.Fragment,{children:[c.jsx(xE,{value:y.pairingUrl}),c.jsx(kE,{text:y.pairingUrl}),c.jsx("div",{className:"nc-set-info",children:v("invite-next-steps")})]})]}),h&&c.jsx("div",{className:"nc-err",children:h})]})}function EE({token:e,readonly:t}){const[i,s]=P.useState("idle"),[o,a]=P.useState(!1),[u,h]=P.useState(null);P.useEffect(()=>{let f=!1;return QC().then(_=>{f||s(_)}),()=>{f=!0}},[]);const m=async()=>{h(null),a(!0);try{i==="subscribed"?(await ZC(e),s("idle")):(await JC(e),s("subscribed"))}catch(f){const _=String(f.message||f);_==="push-denied"?(s("denied"),h(v("push-denied"))):_==="push-unsupported"?(s("unsupported"),h(v("push-unsupported"))):h(_)}a(!1)};return i==="unsupported"?c.jsx("div",{className:"nc-set-info",children:v("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||i==="denied",title:t?v("settings-readonly"):"",onClick:m,children:v(i==="subscribed"?"push-disable":"push-enable")}),c.jsx("span",{className:"nc-set-info",children:v(i==="subscribed"?"push-on":i==="denied"?"push-denied":"push-off")})]}),u&&c.jsx("div",{className:"nc-err",children:u})]})}function NE({token:e,roster:t=[],readonly:i}){const s=[{key:"local",route:[],label:v("diagnostics-local"),status:"up"},...t.filter(L=>Array.isArray(L.route)&&L.route.length).map(L=>({key:L.route.join("/"),route:L.route,label:L.label||L.name,status:L.status}))],[o,a]=P.useState("local"),u=s.find(L=>L.key===o)||s[0],[h,m]=P.useState(null),[f,_]=P.useState([]),[b,w]=P.useState(""),[y,S]=P.useState(!1),[k,C]=P.useState(!0),[x,R]=P.useState(900),[D,T]=P.useState("all"),[ee,V]=P.useState(""),W=P.useRef(0),te=P.useRef(null),K=P.useCallback(async()=>{try{const L=await p0(e,u.route);if(m(L),w(""),!y){const $=await m0(e,{after:W.current,limit:200},u.route);Array.isArray($.records)&&$.records.length&&(W.current=$.cursor,_(U=>[...U,...$.records].slice(-500)))}}catch(L){w(L&&L.status===404?v("diagnostics-unsupported"):String(L.message||L))}},[e,u.key,y]);P.useEffect(()=>{W.current=0,_([]),m(null),w("")},[u.key]),P.useEffect(()=>{let L=null,$=!0;const U=()=>{!$||document.visibilityState==="hidden"||K()},B=()=>{L&&clearInterval(L),L=document.visibilityState==="hidden"?null:setInterval(U,2e3),document.visibilityState!=="hidden"&&U()};return document.addEventListener("visibilitychange",B),B(),()=>{$=!1,L&&clearInterval(L),document.removeEventListener("visibilitychange",B)}},[K]),P.useEffect(()=>{k&&te.current&&(te.current.scrollTop=te.current.scrollHeight)},[f,k]);const ie=f.filter(L=>(D==="all"||L.level===D)&&(!ee||String(L.component||"").toLowerCase().includes(ee.toLowerCase()))),Y=ie.map(L=>`${L.ts} ${L.level.toUpperCase()} ${L.component} ${L.code} ${L.message}${Object.keys(L.meta||{}).length?` ${JSON.stringify(L.meta)}`:""}`).join(`
92
- `),A=async L=>{w("");try{const $=await L();m($),await K()}catch($){w(String($.message||$))}},N=async()=>{try{await navigator.clipboard.writeText(Y)}catch{w(v("copy-manual"))}},j=()=>{try{const L=new Blob([`${JSON.stringify(ie,null,2)}
93
- `],{type:"application/json"}),$=URL.createObjectURL(L),U=document.createElement("a");U.href=$,U.download="nexuscrew-diagnostics.json",U.click(),URL.revokeObjectURL($)}catch{w(v("diagnostics-export-failed"))}};return c.jsxs("div",{className:"nc-set-tab nc-diagnostics",children:[c.jsxs("label",{className:"nc-field",children:[v("diagnostics-target"),c.jsx("select",{value:u.key,onChange:L=>a(L.target.value),children:s.map(L=>c.jsxs("option",{value:L.key,children:[L.label,L.status!=="up"?` · ${L.status}`:""]},L.key))})]}),c.jsxs("div",{className:"nc-set-form nc-diag-controls",children:[c.jsx("div",{className:"nc-sheet-label",children:v("diagnostics-verbose")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("select",{"aria-label":v("diagnostics-duration"),value:x,onChange:L=>R(Number(L.target.value)),disabled:i,children:[300,900,1800,3600].map(L=>c.jsxs("option",{value:L,children:[L/60," min"]},L))}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||(h==null?void 0:h.verbose)===!0,onClick:()=>A(()=>wm(e,!0,x,u.route)),children:v("enable")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||(h==null?void 0:h.verbose)!==!0,onClick:()=>A(()=>wm(e,!1,x,u.route)),children:v("stop")})]}),c.jsx("small",{className:"nc-set-hint",children:h!=null&&h.verbose?v("diagnostics-expires").replace("{time}",new Date(h.expiresAt).toLocaleTimeString()):v("diagnostics-off")})]}),c.jsxs("div",{className:"nc-diag-filters",children:[c.jsxs("select",{"aria-label":v("diagnostics-level"),value:D,onChange:L=>T(L.target.value),children:[c.jsx("option",{value:"all",children:v("diagnostics-all-levels")}),["debug","info","warn","error"].map(L=>c.jsx("option",{value:L,children:L},L))]}),c.jsx("input",{"aria-label":v("diagnostics-component"),placeholder:v("diagnostics-component"),value:ee,onChange:L=>V(L.target.value)})]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:y,onChange:L=>S(L.target.checked)})," ",v("diagnostics-pause")]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:k,onChange:L=>C(L.target.checked)})," ",v("diagnostics-autoscroll")]})]}),c.jsx("pre",{ref:te,className:"nc-diag-log","aria-label":v("diagnostics-log"),children:Y||v("diagnostics-empty")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:N,children:v("copy")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:j,children:v("diagnostics-export")}),c.jsx("button",{type:"button",className:"nc-btn danger",disabled:i,onClick:()=>{window.confirm(v("diagnostics-clear-confirm"))&&A(async()=>{const L=await g0(e,u.route);return W.current=0,_([]),L})},children:v("diagnostics-clear")})]}),b&&c.jsx("div",{className:"nc-err",children:b})]})}function RE({token:e,settings:t,readonly:i,refresh:s}){const[o,a]=P.useState(null),[u,h]=P.useState(null),[m,f]=P.useState(!1),[_,b]=P.useState(!1),[w,y]=P.useState(null),[S,k]=P.useState(!0);P.useEffect(()=>{y(t&&t.update||null),k(!t||t.autoUpdate!==!1)},[t]);const C=async()=>{a(null),h(null),b(!0);try{const W=await r0(e);h(W.note||"ok"),f(!1)}catch(W){a(String(W.message||W))}b(!1)},x=async()=>{a(null),h(null),b(!0);try{const W=await d0(e);h(`${W.note||"ok"}${W.target?` (${W.target})`:""}`)}catch(W){a(String(W.message||W))}b(!1)},R=async W=>{a(null),h(null),b(!0);try{await Kv(e,{autoUpdate:W}),k(W),s&&await s()}catch(te){a(String(te.message||te))}b(!1)},D=async()=>{a(null),h(null),b(!0);try{y(await h0(e))}catch(W){a(String(W.message||W))}b(!1)},T=async()=>{a(null),h(null),b(!0);try{const W=await f0(e);y(W),h(v("npm-update-restarting"))}catch(W){a(String(W.message||W))}b(!1)},ee=()=>{window.confirm(v("composer-clear-confirm"))&&(a(null),Kx()?(window.dispatchEvent(new Event(Ud)),h(v("composer-clear-done"))):a(v("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?v("service-installed"):v("service-missing"),V&&V.installed?` · ${V.active?v("service-active"):v("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:i||_,title:i?v("settings-readonly"):"",onClick:()=>{a(null),h(null),f(!0)},children:v("token-rotate")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||_,title:i?v("settings-readonly"):"",onClick:x,children:v("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:i||_||w&&!w.supported,onChange:W=>R(W.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:v("npm-auto-update")}),c.jsx("small",{children:v("npm-auto-update-help")})]})]}),w&&c.jsxs("div",{className:"nc-set-info",children:[v("npm-update-current")," v",w.current,w.latest?` · ${v("npm-update-latest")} v${w.latest}`:""," · ",v(`npm-update-${w.supported?w.phase:"unsupported"}`)]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||_||!w||!w.supported,onClick:D,children:v("npm-update-check")}),w&&w.available&&c.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||_||w.phase==="installing",onClick:T,children:v("npm-update-install")})]}),w&&w.lastError&&c.jsx("div",{className:"nc-err",children:w.lastError})]}),c.jsx(EE,{token:e,readonly:i}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:v("composer-clear-data")}),c.jsx("small",{className:"nc-set-hint",children:v("composer-clear-data-help")}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:ee,children:v("composer-clear-data")})})]}),m&&c.jsxs("div",{className:"nc-set-confirm",children:[c.jsx("div",{children:v("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:v("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:_,onClick:C,children:v("confirm")})]})]}),u&&c.jsx("div",{className:"nc-set-note",children:u}),o&&c.jsx("div",{className:"nc-err",children:o})]})}function PE({token:e,onClose:t,initialTab:i="nodes",initialLocation:s="",startNewCell:o=!1}){ji();const[a,u]=P.useState(i),[h,m]=P.useState(null),[f,_]=P.useState([]),[b,w]=P.useState(!1),[y,S]=P.useState(null),[k,C]=P.useState(0),x=ah(e,!0,k),R=P.useCallback(async()=>{try{const D=await Wv(e);m(D),S(null)}catch(D){S(String(D.message||D))}try{const D=await i0(e);_(D.peers||[])}catch(D){S(String(D.message||D))}},[e]);return P.useEffect(()=>{R();const D=setInterval(R,5e3);return()=>clearInterval(D)},[R]),P.useEffect(()=>{let D=!1;return qt("/api/config",e).then(T=>T.json()).then(T=>{D||w(!!T.readonlyDefault)}).catch(()=>{}),()=>{D=!0}},[e]),c.jsx("div",{className:"nc-set-overlay",onClick:t,children:c.jsxs("div",{className:"nc-set-panel",onClick:D=>D.stopPropagation(),children:[c.jsxs("div",{className:"nc-set-head",children:[c.jsx(it,{name:"gear",size:18}),c.jsx("b",{children:v("settings")}),c.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:v("close"),children:c.jsx(it,{name:"x",size:18})})]}),b&&c.jsx("div",{className:"nc-set-readonly",children:v("settings-readonly")}),y&&c.jsx("div",{className:"nc-err",children:y}),c.jsx("div",{className:"nc-set-tabs",children:["nodes","fleet","diagnostics","system"].map(D=>c.jsx("button",{type:"button",className:`nc-set-tabbtn${a===D?" on":""}`,onClick:()=>u(D),children:v(`tab-${D}`)},D))}),c.jsxs("div",{className:"nc-set-body",children:[a==="nodes"&&c.jsx(CE,{token:e,nodes:f,roster:x,settings:h,readonly:b,refresh:R,refreshAliases:()=>C(D=>D+1)}),a==="fleet"&&c.jsx(bE,{token:e,readonly:b,startNewCell:o,initialLocation:s,targets:x.map(D=>({route:D.route,label:D.label||D.name,status:D.status}))}),a==="diagnostics"&&c.jsx(NE,{token:e,roster:x,readonly:b}),a==="system"&&c.jsx(RE,{token:e,settings:h,readonly:b,refresh:R})]})]})})}function jE({token:e,initialPair:t,deviceDefault:i="",localNodeId:s="",localNameDefault:o="",onPairDone:a,onDone:u}){ji();const[h,m]=P.useState(t?"pair":"welcome"),[f,_]=P.useState(!1),[b,w]=P.useState(null),y=async()=>{_(!0),w(null);try{await Kv(e,{wizardDone:!0}),a&&a(),u()}catch(S){w(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:v("wizard-title")}),c.jsx("small",{children:v("hydra-simple")})]}),h==="welcome"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx("div",{className:"nc-wiz-done",children:v("local-ready")}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",disabled:f,onClick:y,children:v("local-only")}),c.jsx("button",{className:"nc-btn primary",disabled:f,onClick:()=>m("pair"),children:v("add-node")})]})]}),h==="pair"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx(xy,{token:e,initial:t||"",autoStart:!!t,deviceDefault:i,localNodeId:s,localNameDefault:o,onBusyChange:_,onSuccess:async()=>{a&&a(),m("done")}}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{className:"nc-btn ghost",disabled:f,onClick:()=>{a&&a(),m("welcome")},children:v("back")})})]}),h==="done"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx("div",{className:"nc-wiz-done",children:v("node-connected")}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{className:"nc-btn primary",disabled:f,onClick:y,children:v("finish")})})]}),b&&c.jsx("div",{className:"nc-err",children:b})]})})}function DE(e,t){if(typeof EventSource>"u"||!e)return()=>{};const i=new EventSource(`/api/events?token=${encodeURIComponent(e)}`);return i.onmessage=s=>{try{const o=JSON.parse(s.data);o&&typeof o=="object"&&typeof o.type=="string"&&t(o)}catch{}},()=>{try{i.close()}catch{}}}const LE=6e3,ME=12e3;function TE({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:v("close"),children:c.jsx(it,{name:"x",size:14})})]})}function AE({ask:e,token:t,onAnswered:i}){const[s,o]=P.useState(""),[a,u]=P.useState(!1),[h,m]=P.useState(null),f=async _=>{const b=String(_||"").trim();if(!(!b||a)){m(null),u(!0);try{await _0(t,e.id,b),i(e.id)}catch(w){m(String(w.message||w))}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:v("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:v("send")})]}),h&&c.jsx("div",{className:"nc-err",children:h})]})}function IE({token:e}){ji();const[t,i]=P.useState([]),[s,o]=P.useState([]),[a,u]=P.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),h=P.useRef(0),m=P.useCallback(b=>{i(w=>w.filter(y=>y.key!==b))},[]),f=P.useCallback(b=>{const w=`t${h.current+=1}`;i(y=>[...y.slice(-3),{...b,key:w}]),setTimeout(()=>m(w),b.urgency==="high"?ME:LE)},[m]);P.useEffect(()=>{if(!e)return;let b=!1;v0(e).then(y=>{b||o(y.asks||[])}).catch(()=>{});const w=DE(e,y=>{y.type==="notify"?f(y):y.type==="ask"&&y.ask&&y.ask.id?o(S=>S.some(k=>k.id===y.ask.id)?S:[...S,y.ask]):y.type==="ask-answered"&&y.id&&o(S=>S.filter(k=>k.id!==y.id))});return()=>{b=!0,w()}},[e,f]);const _=b=>o(w=>w.filter(y=>y.id!==b));return c.jsxs(c.Fragment,{children:[t.length>0&&c.jsx("div",{className:"nc-ntf-toasts",children:t.map(b=>c.jsx(TE,{n:b,onClose:()=>m(b.key)},b.key))}),s.length>0&&!a&&c.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>u(!0),title:v("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:v("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:v("close"),children:c.jsx(it,{name:"x",size:16})})]}),c.jsx("div",{className:"nc-ask-panel-body",children:s.map(b=>c.jsx(AE,{ask:b,token:e,onAnswered:_},b.id))})]})]})}const Zu=e=>ln(br(e)).length===0,ed=e=>Array.isArray(e)?e.join("/"):"";function BE(e){const t=new Set,i=[];for(const s of Array.isArray(e)?e:[])!s||!Hi.test(String(s.instanceId||""))||!Array.isArray(s.route)||!s.route.length||t.has(s.instanceId)||(t.add(s.instanceId),i.push({instanceId:s.instanceId,route:[...s.route],label:String(s.label||s.name||s.route.join(" › ")),status:s.status||"offline"}));return i.sort((s,o)=>s.label.localeCompare(o.label))}function co(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function mr(e,t,i,s=!1,o=!0){const a=t.instanceId;return{...e,id:as(s?null:a,e.name),ownerId:a,ownerRoute:s?[]:[...t.route],ownerLabel:s?"Local":t.label,local:s,available:o,ownerTopology:Array.isArray(i)?i:[],layout:qd(e.layout,a,i)}}function OE(e,t,i,s,o=[]){const[a,u]=P.useState([]),[h,m]=P.useState(!1),[f,_]=P.useState("idle"),[b,w]=P.useState(""),[y,S]=P.useState(""),k=P.useRef([]),C=P.useRef([]),x=P.useRef(""),R=P.useRef(t),D=P.useRef(i),T=P.useRef(!1),ee=P.useRef(!0),V=P.useRef(""),W=P.useMemo(()=>BE(o),[o]),te=W.map(z=>`${z.instanceId}:${ed(z.route)}:${z.status}:${z.label}`).join("|");C.current=W,D.current=i,R.current=t,k.current=a;const K=P.useCallback(z=>Vd(z.layout,x.current,C.current),[]),ie=P.useCallback((z,M=!0,I=R.current)=>{const se=Kg(z,qa()),ge=k.current.some(fe=>fe.id===I);k.current=se,u(se);const de=se.find(fe=>fe.id===I);if(M&&de){ee.current=!0;const fe=K(de);s(fe),de.local&&pC(de.name,fe)}else ge&&!de&&(ee.current=!0,s(os()),w("deck non più condiviso dal nodo owner"));uC(se.filter(fe=>fe.local).map(fe=>fe.name))},[s,K]),Y=P.useCallback(async z=>{let M=await Ba(e);const I=M.decks.find(se=>se.name==="main");if(M.decks.length===1&&I&&I.revision===0&&Zu(I.layout)){const se=cC(),ge=br(Yd("main")||os());if(!Zu(ge)){const de=qd(ge,z,[]);M.decks[0]=await Oa(e,"main",de,0,[])}for(const de of se.filter(fe=>fe!=="main"))try{let fe=await bm(e,de,[]);const X=br(Yd(de)||os());Zu(X)||(fe=await Oa(e,de,qd(X,z,[]),fe.revision,[]))}catch{}M=await Ba(e)}return M},[e]),A=P.useCallback(async({migrate:z=!1}={})=>{const M=await rh(e,[]),I=Hi.test(String(M.instanceId||""))?M.instanceId:"";if(!I)throw new Error("instanceId locale non disponibile");x.current=I,S(I);const[se,ge]=await Promise.all([z?Y(I):Ba(e),vm(e,[]).catch(()=>({nodes:[]}))]),de={instanceId:I,route:[],label:"Local"},fe=se.decks.map(Z=>mr(Z,de,ge.nodes,!0,!0)),X=k.current;return await Promise.all(C.current.map(async Z=>{if(Z.status!=="up"){fe.push(...X.filter(ye=>!ye.local&&ye.ownerId===Z.instanceId).map(ye=>({...ye,ownerRoute:[...Z.route],ownerLabel:Z.label,available:!1})));return}try{const[ye,Ee]=await Promise.all([Ba(e,Z.route),vm(e,Z.route).catch(()=>({nodes:[]}))]);fe.push(...ye.decks.map(tt=>mr(tt,Z,Ee.nodes,!1,!0)))}catch{fe.push(...X.filter(Ee=>!Ee.local&&Ee.ownerId===Z.instanceId).map(Ee=>({...Ee,ownerRoute:[...Z.route],ownerLabel:Z.label,available:!1})))}})),fe.sort((Z,ye)=>Z.local===ye.local?Z.ownerLabel.localeCompare(ye.ownerLabel)||(Z.name==="main"?-1:ye.name==="main"?1:Z.name.localeCompare(ye.name)):Z.local?-1:1),fe},[e,Y,te]);P.useEffect(()=>{if(!e)return;let z=!1;const M=V.current!==e;return V.current=e,A({migrate:M}).then(I=>{if(z)return;const se=k.current.find(fe=>fe.id===R.current),ge=I.find(fe=>fe.id===R.current),de=ge&&(!se||ge.revision>se.revision||se.available!==ge.available||ed(se.ownerRoute)!==ed(ge.ownerRoute));ie(I,M||!!de&&!T.current),m(!0),ge&&w("")}).catch(I=>{z||(m(!0),w(String(I.message||I)))}),()=>{z=!0}},[ie,A,te,e]);const N=P.useCallback(async(z=R.current)=>{if(!h||!T.current)return!0;const M=k.current.find(I=>I.id===z);if(!M)return w(`deck inesistente: ${z}`),!1;if(M.available===!1)return w(`nodo owner offline: ${M.ownerLabel}`),!1;_("saving");try{const I=Wg(br(D.current),M.ownerId,M.ownerTopology),se=await Oa(e,M.name,I,M.revision,M.ownerRoute),ge=mr(se,co(M),M.ownerTopology,M.local,!0);return ie(k.current.map(de=>de.id===z?ge:de),!1),T.current=!1,_("saved"),w(""),setTimeout(()=>_("idle"),1500),!0}catch(I){if(_("error"),w(String(I.message||I)),I.status===409&&I.data&&I.data.current){const se=k.current.find(de=>de.id===z),ge=mr(I.data.current,co(se),se.ownerTopology,se.local,!0);ie(k.current.map(de=>de.id===z?ge:de),!1)}return!1}},[h,e,ie]);return P.useEffect(()=>{if(!h)return;if(ee.current){ee.current=!1;return}T.current=!0,_("saving");const z=setTimeout(N,650);return()=>clearTimeout(z)},[i,h,N]),P.useEffect(()=>{if(!h)return;const z=setInterval(async()=>{try{const M=await A(),I=k.current.find(de=>de.id===R.current),se=M.find(de=>de.id===R.current),ge=se&&(!I||se.revision>I.revision||I.available!==se.available);ie(M,ge&&!T.current)}catch{}},5e3);return()=>clearInterval(z)},[h,A,ie]),{decks:a,records:a,localNodeId:y,ready:h,saveState:f,error:b,setError:w,saveNow:N,select:async z=>{if(T.current&&!await N(R.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const M=k.current.find(I=>I.id===z);if(!M)throw new Error(`deck inesistente: ${z}`);return T.current=!1,ee.current=!0,K(M)},add:async(z,M=null)=>{const I=M===wn?k.current.find(de=>de.local):M?k.current.find(de=>de.ownerId===M):null;if(!I||I.available===!1)throw new Error("nodo owner non disponibile");const se=await bm(e,z,I.ownerRoute),ge=mr(se,co(I),I.ownerTopology,I.local,!0);return ie([...k.current,ge],!1),ge},rename:async(z,M)=>{const I=k.current.find(X=>X.id===z);if(!I)throw new Error("deck inesistente");if(z===R.current&&T.current&&!await N(z))throw new Error(`salvataggio di "${I.name}" fallito: rinomina annullata`);const se=k.current.find(X=>X.id===z);if(!se)throw new Error("deck inesistente");const ge=await y0(e,se.name,M,se.revision,se.ownerRoute),de=mr(ge,co(se),se.ownerTopology,se.local,!0),fe=se.local?wn:se.ownerId;return Ru(hC(qa(),fe,z,de.id)),ie(k.current.map(X=>X.id===z?de:X),!1),de},remove:async z=>{const M=k.current.find(se=>se.id===z);if(!M)throw new Error("deck inesistente");z===R.current&&(T.current=!1),await S0(e,M.name,M.revision,M.ownerRoute);const I=M.local?wn:M.ownerId;Ru(fC(qa(),I,z)),ie(k.current.filter(se=>se.id!==z),!1)},reorder:(z,M)=>{const I=k.current.find(Z=>Z.id===z),se=k.current.find(Z=>Z.id===M);if(!I||!se)return!1;const ge=I.local?wn:I.ownerId,de=se.local?wn:se.ownerId;if(ge!==de)return!1;const fe=k.current.filter(Z=>(Z.local?wn:Z.ownerId)===ge).map(Z=>Z.id),X=Ru(dC(qa(),ge,z,M,fe));return ie(Kg(k.current,X),!1),!0},addTileTo:async(z,M)=>{const I=k.current.find(Z=>Z.id===z);if(!I)throw new Error("deck inesistente");if(I.available===!1)throw new Error(`nodo owner offline: ${I.ownerLabel}`);const se=py(M,x.current,C.current);if(!se)throw new Error("riferimento sessione non valido");const ge=K(I),de=Wg(l_(ge,se),I.ownerId,I.ownerTopology),fe=await Oa(e,I.name,de,I.revision,I.ownerRoute),X=mr(fe,co(I),I.ownerTopology,I.local,!0);return ie(k.current.map(Z=>Z.id===z?X:Z),!1),X},localMainId:as(null,"main"),parseDeckId:kh}}const zE="/sw.js",Xd="nc-sw-update";let Gd=null,Qd=!1,Jd=null,My=Object.freeze({needed:!1,kind:null,version:""}),Ty=!1;function Ay(){typeof window<"u"&&window.dispatchEvent(new Event(Xd))}function Iy(){const e=Jd||(Qd?{kind:"reload",version:""}:null);My=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function jv(){return My}function FE(e){return typeof window>"u"?()=>{}:(window.addEventListener(Xd,e),()=>window.removeEventListener(Xd,e))}function Rh(e){Qd!==e&&(Qd=e,Iy(),Ay())}function $E(e,t,i){let s=null;e&&t&&e!==t?s={kind:"install",version:e}:t&&i&&t!==i&&(s={kind:"reload",version:t});const o=JSON.stringify(s)===JSON.stringify(Jd);Jd=s,Iy(),o||Ay()}function HE(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&Rh(!0)})}function WE(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{Ty&&location.reload()}),navigator.serviceWorker.register(zE).then(e=>{Gd=e,e.waiting&&Rh(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&HE(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function UE(){Ty=!0,Rh(!1);const e=Gd&&Gd.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function KE({hash:e="",origin:t="",pathname:i="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),a=`${i||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:a};const u=new URLSearchParams(o),h=u.get("token")||"",m=u.get("pair")||"",f=m?`${t||""}${i||""}#pair=${m}`:"";return{token:h,pair:f,nextUrl:a}}const By=9,Oy=24,zy="nc_side_w",Dv="nc_side_min",qE=240,Lv="(min-width:1024px) and (pointer:fine)";function VE(){const e=Number(localStorage.getItem(zy));return e>=180&&e<=480?e:qE}function YE(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=By&&e<=Oy?e:13}function XE(){const e={token:"",pair:""};try{const{token:t,pair:i,nextUrl:s}=KE({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(i){e.pair=i;try{sessionStorage.setItem("nc_pair",i)}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 GE(e){try{return br(Yd(e))}catch{return os()}}function Mv(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 QE(){const[e,t]=P.useState(()=>window.matchMedia(Lv).matches);return P.useEffect(()=>{const i=window.matchMedia(Lv),s=o=>t(o.matches);return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[]),e}function Tv({session:e,node:t,ownerId:i,cellName:s,token:o,readonly:a=!1,onBack:u}){ji();const[h,m]=P.useState(!1),[f,_]=P.useState(()=>window.matchMedia("(pointer: coarse)").matches),[b,w]=P.useState(null),[y,S]=P.useState(YE),[k,C]=P.useState(s||e),[x,R]=P.useState(""),D=N=>S(j=>{const L=Math.max(By,Math.min(Oy,j+N));return localStorage.setItem("nc_fontsize",String(L)),L}),T=P.useRef(()=>{}),ee=P.useRef(()=>!1),V=P.useRef(()=>{}),W=P.useRef(!1),[te,K]=P.useState(!1),[ie,Y]=P.useState(!1),A=()=>{W.current=!W.current,K(W.current)};return P.useEffect(()=>{C(s||e)},[s,e]),P.useEffect(()=>{let N=!0;const j=t?t.split("/"):[],L=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function $(){let B=null,J=null;try{const I=await(await qt(`${L}/sessions`,o)).json();Array.isArray(I.sessions)&&(B=I.sessions.find(se=>se.name===e))}catch{}try{const M=await Er(o,j);M.available&&Array.isArray(M.cells)&&(J=M.cells.find(I=>I.tmuxSession===e))}catch{}if(!N)return;C(bh({session:e,cell:J||(s?{cell:s}:null)}));let z="";J?z=`${J.engine}${J.key?`·${J.key}`:""}`:B&&(z=B.attached?`attached · ${Mv(B.activity)}`:B.activity?Mv(B.activity):""),R(z)}$();const U=setInterval($,4e3);return()=>{N=!1,clearInterval(U)}},[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:v("sessions"),children:[c.jsx(it,{name:"chevronLeft",size:18}),c.jsx("span",{className:"nc-bar-label",children:v("sessions")})]}),c.jsxs("span",{className:"nc-bar-center",children:[c.jsx("b",{title:t?`${k} · ${t}`:k,children:k}),x&&c.jsx("small",{className:"nc-bar-sub",children:x})]}),c.jsxs("span",{className:"nc-bar-right",children:[c.jsx("button",{onClick:()=>D(-1),title:v("zoom-out"),children:c.jsx(it,{name:"zoomOut",size:18})}),c.jsx("button",{onClick:()=>D(1),title:v("zoom-in"),children:c.jsx(it,{name:"zoomIn",size:18})}),c.jsx("button",{onClick:()=>_(N=>!N),title:v("composer"),children:c.jsx(it,{name:"keyboard",size:20})}),c.jsx("button",{onClick:()=>m(N=>!N),title:v("files"),children:c.jsx(it,{name:"folder",size:20})})]})]}),c.jsx("div",{className:"nc-termwrap",children:c.jsx(iy,{session:e,node:t,token:o,readonly:a,takeSize:!0,sendRef:T,composerRef:ee,actionRef:V,ctrlRef:W,setCtrlArmed:K,onFiles:w,fontSize:y,selectionMode:ie,onSelectionModeChange:Y})}),c.jsx(Tx,{onKeyboard:()=>_(N=>!N),send:N=>T.current(N),action:N=>V.current(N),ctrlArmed:te,onCtrl:A,selectionMode:ie,onSelectionMode:Y}),f&&c.jsx(hy,{submitText:N=>ee.current(N),token:o,session:e,node:t,ownerId:i}),h&&c.jsx(ny,{session:e,node:t,token:o,filesEvent:b,onClose:()=>m(!1)})]})}function JE(){ji();const[e]=P.useState(XE),[t,i]=P.useState(e.token),[s,o]=P.useState(e.pair||""),a=P.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[u,h]=P.useState(!1),m=QE(),[f]=P.useState(()=>lC(typeof location<"u"?location.pathname:"/")),[_,b]=P.useState(f.id),w=_===as(null,Pi),[y,S]=P.useState(null),k=ue=>{const Ne=er(ue);S(Ne?{...Ne,...typeof(ue==null?void 0:ue.cellName)=="string"&&ue.cellName?{cellName:ue.cellName}:{}}:null)},[C,x]=P.useState([]),[R,D]=P.useState([]),[T,ee]=P.useState([]),[V,W]=P.useState(()=>f.ownerId?os():GE(f.name)),[te,K]=P.useState(null),[ie,Y]=P.useState(null),A=ue=>Y(er(ue)),N=ah(t,m),j=P.useMemo(()=>(N||[]).filter(ue=>ue.instanceId).map(ue=>({instanceId:ue.instanceId,route:ue.route,label:ue.label,status:ue.status})),[N]),L=OE(t,_,V,W,j),$=L.decks;P.useEffect(()=>{const ue=new Map;for(const Ne of N||[]){const Ve=(Ne.route||[Ne.name]).join("/"),kt=new Set((Ne.sessions||[]).map(oi=>oi.name));for(const oi of Ne.cells||[])!oi.cell||!oi.tmuxSession||oi.cell===oi.tmuxSession||kt.has(oi.cell)||ue.set(`${Ve}:${oi.cell}`,`${Ve}:${oi.tmuxSession}`)}W(Ne=>Y0(Ne,ue))},[N]),P.useEffect(()=>{L.localNodeId&&W(ue=>{const Ne=Vd(ue,L.localNodeId,j);return JSON.stringify(Ne)===JSON.stringify(ue)?ue:Ne})},[j,L.localNodeId]);const[U,B]=P.useState(null),[J,z]=P.useState(null),M=P.useRef(0),[I,se]=P.useState(!1),[ge,de]=P.useState(VE),[fe,X]=P.useState(!w),[Z,ye]=P.useState(()=>w?localStorage.getItem(Dv)==="1":!0),[Ee,tt]=P.useState(!1),[Ye,Be]=P.useState("nodes"),[ot,Xe]=P.useState(!1),[_t,ut]=P.useState(""),ht=(ue="nodes",Ne=!1,Ve="")=>{Be(ue),Xe(Ne),ut(Ve),tt(!0)},[rt,lt]=P.useState(!1),[le,ke]=P.useState({deviceDefault:"",localNodeId:"",localNameDefault:""}),[$e,We]=P.useState(!1);P.useEffect(()=>{try{localStorage.setItem(zy,String(ge))}catch{}},[ge]),P.useEffect(()=>{try{localStorage.setItem(Dv,Z?"1":"")}catch{}},[Z]),P.useEffect(()=>{if(!t)return;let ue=!1;return Promise.all([Wv(t),qt("/api/config",t).then(Ne=>Ne.json())]).then(([Ne,Ve])=>{ue||(ke({deviceDefault:Ne.deviceName||"",localNodeId:Ne.nodeId||"",localNameDefault:Ne.localName||""}),We(!!Ve.readonlyDefault),(Ne.firstRun===!0&&!Ve.readonlyDefault||s)&&lt(!0))}).catch(()=>{}),()=>{ue=!0}},[t,s]);const pe=P.useCallback(async()=>{try{const Ne=await(await qt("/api/sessions",t)).json();Ne.error||x(Ne.sessions||[])}catch{}try{const ue=await Er(t);D(ue.available?ue.cells||[]:[]),ee(ue.available?ue.capabilities||[]:[])}catch{D([]),ee([])}},[t]);P.useEffect(()=>{if(!m)return;pe();const ue=setInterval(pe,4e3);return()=>clearInterval(ue)},[m,pe]),P.useEffect(()=>{let ue=!1;return qt("/api/config",t).then(Ne=>Ne.json()).then(Ne=>{ue||$E(Ne.version,Ne.uiVersion,"0.8.27")}).catch(()=>{}),()=>{ue=!0}},[t]);const Oe=new Set([...C.map(ue=>ue.name),...N.flatMap(ue=>ue.sessions.map(Ne=>Ne.key))]),Me=ln(V),G=ue=>W(Ne=>{const Ve=py(ue,L.localNodeId,j)||ue,kt=l_(Ne,Ve);return kt===Ne&&ln(Ne).length>=9&&L.setError(v("grid-full")),kt}),re=async(ue,Ne=[])=>{try{await nh(t,ue,Ne)}catch{return}const Ve=Ne.length?`${Ne.join("/")}:${ue}`:ue;W(kt=>ll(kt,Ve)),pe()},F=async(ue,Ne,Ve=[])=>{try{await $v(t,ue,Ne,Ve)}catch{return}pe()},H=async(ue,Ne,Ve=[])=>{await zv(t,{cell:ue,enabled:!!Ne},Ve),pe()},oe=async ue=>{if(!U)return;const{cell:Ne}=U,Ve=Array.isArray(U.route)?U.route:[];ue.action==="up"?await th(t,{cell:Ne,boot:!!ue.boot,...ue.engine?{engine:ue.engine}:{},...ue.model!==void 0?{model:ue.model}:{},...ue.permissionPolicy?{permissionPolicy:ue.permissionPolicy}:{}},Ve):await il(t,{cell:Ne,boot:!!ue.boot},Ve);const kt=ue.action==="up"?!!ue.boot:ue.boot?!1:!!U.boot;z({id:++M.current,cell:Ne,route:Ve,enabled:kt}),pe()},me=P.useCallback(ue=>{z(Ne=>(Ne==null?void 0:Ne.id)===ue?null:Ne)},[]),Te=async ue=>{if(!(!(ue!=null&&ue.direct)||I)){se(!0);try{await sh(t,ue.name,ue.tunnelStatus==="up"?"down":"up")}finally{se(!1)}}},we=async(ue,Ne)=>{const Ve=String(Ne||"").trim();return!(ue!=null&&ue.direct)||!us(Ve)?!1:(await qv(t,ue.name,Ve),!0)},Ce=ue=>{const Ne=$.find(Ve=>Ve.id===ue);if(!Ne)return!1;try{const Ve=window.open(Nu(Ne,t),"_blank");return Ve&&(Ve.opener=null),!!Ve}catch{return!1}},He=async ue=>{if(!ue||ue===_)return;const Ne=await L.select(ue),Ve=L.records.find(kt=>kt.id===ue);b(ue),W(Ne),K(null),Y(null);try{history.replaceState(null,"",Nu(Ve||ue,null))}catch{}},Zt=async(ue,Ne)=>{const Ve=await L.add(ue,Ne);await He(Ve.id)},Qe=async(ue,Ne)=>{const Ve=await L.rename(ue,Ne);if(ue===_){b(Ve.id),W(Vd(Ve.layout,L.localNodeId,j)),K(null),Y(null);try{history.replaceState(null,"",Nu(Ve,null))}catch{}}},Di=async ue=>{await L.remove(ue),ue===_&&await He(L.localMainId)},Nt=async(ue,Ne)=>{!Ne||Ne===_||(await L.addTileTo(Ne,ue),W(Ve=>ll(Ve,ue)))};if(!t)return c.jsxs("div",{className:"nc-auth",children:[c.jsx("p",{children:v("auth-prompt")}),c.jsx("input",{onChange:ue=>i(ue.target.value.trim()),placeholder:"token"}),c.jsxs("label",{children:[c.jsx("input",{type:"checkbox",checked:u,onChange:ue=>h(ue.target.checked)})," ",v("remember-device")]}),c.jsx("button",{onClick:()=>{(u?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const qe=c.jsxs(c.Fragment,{children:[Ee&&c.jsx(PE,{token:t,initialTab:Ye,initialLocation:_t,startNewCell:ot,onClose:()=>{tt(!1),Xe(!1),ut("")}}),rt&&c.jsx(jE,{token:t,initialPair:s,...le,onPairDone:a,onDone:()=>lt(!1)}),c.jsx(IE,{token:t})]});if(!m)return y?c.jsxs(c.Fragment,{children:[c.jsx(Tv,{session:y.session,node:y.node,ownerId:y.ownerId,cellName:y.cellName,token:t,readonly:$e,onBack:()=>S(null)}),qe]}):c.jsxs(c.Fragment,{children:[c.jsx(cb,{onPick:k,token:t,onSettings:ht}),qe]});const ei=w||!fe;return c.jsxs("div",{className:"nc-workspace",children:[ei&&c.jsx(Qx,{sessions:C,cells:R,activeSessions:Me,nodeGroups:N,fleetCapabilities:T,bootSettlement:J,onBootSettlementApplied:me,localNodeId:L.localNodeId,onPick:A,onAddTile:G,onPower:B,onBoot:H,onBootError:ue=>L.setError(String((ue==null?void 0:ue.message)||ue)),onNodePower:Te,onNodeRename:we,onKill:re,onVisibility:F,onNew:()=>ht("fleet",!0),onSettings:ht,width:ge,collapsed:Z,onResize:de,onToggleCollapse:()=>ye(ue=>!ue)}),c.jsxs("div",{className:"nc-workspace-main",children:[c.jsx(gC,{decks:$,currentDeck:_,onCreate:Zt,onRename:Qe,onDelete:Di,onReorder:L.reorder,onOpenWindow:Ce,onNavigate:He,saveState:L.saveState,error:L.error,sidebarVisible:ei,onToggleSidebar:w?null:()=>X(ue=>!ue)}),c.jsx(nC,{layout:V,onLayoutChange:W,token:t,readonly:$e,sessionsAlive:Oe,focusSession:te,onFocus:K,onOpenSingle:A,decks:$,currentDeck:_,onSendToDeck:Nt,cells:R,nodeGroups:N})]}),ie&&c.jsx("div",{className:"nc-single-overlay",children:c.jsx(Tv,{session:ie.session,node:ie.node,ownerId:ie.ownerId,cellName:bh({session:ie.session,node:ie.node,ownerId:ie.ownerId,cells:R,nodeGroups:N}),token:t,readonly:$e,onBack:()=>Y(null)})}),U&&c.jsx(nl,{cell:U,token:t,route:Array.isArray(U.route)?U.route:[],onConfirm:oe,onClose:()=>B(null)}),qe]})}function ZE(){ji();const e=P.useSyncExternalStore(FE,jv,jv);if(!e.needed)return null;const t=e.kind==="install"?v("install-version-mismatch").replace("{v}",e.version):v("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:UE,children:v("reload")})]})}WE();Uw.createRoot(document.getElementById("root")).render(c.jsxs(Bw.StrictMode,{children:[c.jsx(JE,{}),c.jsx(ZE,{})]}));