@mmmbuto/nexuscrew 0.8.14 → 0.8.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -3
- package/frontend/dist/assets/index-BD-7qEsn.js +91 -0
- package/frontend/dist/assets/{index-CopPQTMk.css → index-C-JOkuIc.css} +1 -1
- package/frontend/dist/index.html +2 -2
- package/frontend/dist/version.json +1 -1
- package/lib/nodes/peering.js +24 -7
- package/lib/nodes/tunnel-supervisor.js +10 -0
- package/lib/nodes/tunnel.js +9 -0
- package/package.json +1 -1
- package/frontend/dist/assets/index-BR2Qfqi2.js +0 -91
|
@@ -1,91 +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 l of o)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&s(u)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();function Nh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var zc={exports:{}},Bs={},Fc={exports:{}},Qe={};/**
|
|
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 Op;function qS(){if(Op)return Qe;Op=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),w=Symbol.iterator;function y(D){return D===null||typeof D!="object"?null:(D=w&&D[w]||D["@@iterator"],typeof D=="function"?D:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,b={};function k(D,Q,se){this.props=D,this.context=Q,this.refs=b,this.updater=se||v}k.prototype.isReactComponent={},k.prototype.setState=function(D,Q){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,Q,"setState")},k.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function N(){}N.prototype=k.prototype;function L(D,Q,se){this.props=D,this.context=Q,this.refs=b,this.updater=se||v}var A=L.prototype=new N;A.constructor=L,C(A,k.prototype),A.isPureReactComponent=!0;var B=Array.isArray,ee=Object.prototype.hasOwnProperty,O={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function Z(D,Q,se){var re,ae={},le=null,de=null;if(Q!=null)for(re in Q.ref!==void 0&&(de=Q.ref),Q.key!==void 0&&(le=""+Q.key),Q)ee.call(Q,re)&&!F.hasOwnProperty(re)&&(ae[re]=Q[re]);var ve=arguments.length-2;if(ve===1)ae.children=se;else if(1<ve){for(var Re=Array(ve),Fe=0;Fe<ve;Fe++)Re[Fe]=arguments[Fe+2];ae.children=Re}if(D&&D.defaultProps)for(re in ve=D.defaultProps,ve)ae[re]===void 0&&(ae[re]=ve[re]);return{$$typeof:e,type:D,key:le,ref:de,props:ae,_owner:O.current}}function W(D,Q){return{$$typeof:e,type:D.type,key:Q,ref:D.ref,props:D.props,_owner:D._owner}}function G(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function K(D){var Q={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(se){return Q[se]})}var P=/\/+/g;function E(D,Q){return typeof D=="object"&&D!==null&&D.key!=null?K(""+D.key):Q.toString(36)}function j(D,Q,se,re,ae){var le=typeof D;(le==="undefined"||le==="boolean")&&(D=null);var de=!1;if(D===null)de=!0;else switch(le){case"string":case"number":de=!0;break;case"object":switch(D.$$typeof){case e:case t:de=!0}}if(de)return de=D,ae=ae(de),D=re===""?"."+E(de,0):re,B(ae)?(se="",D!=null&&(se=D.replace(P,"$&/")+"/"),j(ae,Q,se,"",function(Fe){return Fe})):ae!=null&&(G(ae)&&(ae=W(ae,se+(!ae.key||de&&de.key===ae.key?"":(""+ae.key).replace(P,"$&/")+"/")+D)),Q.push(ae)),1;if(de=0,re=re===""?".":re+":",B(D))for(var ve=0;ve<D.length;ve++){le=D[ve];var Re=re+E(le,ve);de+=j(le,Q,se,Re,ae)}else if(Re=y(D),typeof Re=="function")for(D=Re.call(D),ve=0;!(le=D.next()).done;)le=le.value,Re=re+E(le,ve++),de+=j(le,Q,se,Re,ae);else if(le==="object")throw Q=String(D),Error("Objects are not valid as a React child (found: "+(Q==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":Q)+"). If you meant to render a collection of children, use an array instead.");return de}function U(D,Q,se){if(D==null)return D;var re=[],ae=0;return j(D,re,"","",function(le){return Q.call(se,le,ae++)}),re}function R(D){if(D._status===-1){var Q=D._result;Q=Q(),Q.then(function(se){(D._status===0||D._status===-1)&&(D._status=1,D._result=se)},function(se){(D._status===0||D._status===-1)&&(D._status=2,D._result=se)}),D._status===-1&&(D._status=0,D._result=Q)}if(D._status===1)return D._result.default;throw D._result}var H={current:null},I={transition:null},q={ReactCurrentDispatcher:H,ReactCurrentBatchConfig:I,ReactCurrentOwner:O};function X(){throw Error("act(...) is not supported in production builds of React.")}return Qe.Children={map:U,forEach:function(D,Q,se){U(D,function(){Q.apply(this,arguments)},se)},count:function(D){var Q=0;return U(D,function(){Q++}),Q},toArray:function(D){return U(D,function(Q){return Q})||[]},only:function(D){if(!G(D))throw Error("React.Children.only expected to receive a single React element child.");return D}},Qe.Component=k,Qe.Fragment=n,Qe.Profiler=o,Qe.PureComponent=L,Qe.StrictMode=s,Qe.Suspense=p,Qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=q,Qe.act=X,Qe.cloneElement=function(D,Q,se){if(D==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+D+".");var re=C({},D.props),ae=D.key,le=D.ref,de=D._owner;if(Q!=null){if(Q.ref!==void 0&&(le=Q.ref,de=O.current),Q.key!==void 0&&(ae=""+Q.key),D.type&&D.type.defaultProps)var ve=D.type.defaultProps;for(Re in Q)ee.call(Q,Re)&&!F.hasOwnProperty(Re)&&(re[Re]=Q[Re]===void 0&&ve!==void 0?ve[Re]:Q[Re])}var Re=arguments.length-2;if(Re===1)re.children=se;else if(1<Re){ve=Array(Re);for(var Fe=0;Fe<Re;Fe++)ve[Fe]=arguments[Fe+2];re.children=ve}return{$$typeof:e,type:D.type,key:ae,ref:le,props:re,_owner:de}},Qe.createContext=function(D){return D={$$typeof:u,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},D.Provider={$$typeof:l,_context:D},D.Consumer=D},Qe.createElement=Z,Qe.createFactory=function(D){var Q=Z.bind(null,D);return Q.type=D,Q},Qe.createRef=function(){return{current:null}},Qe.forwardRef=function(D){return{$$typeof:d,render:D}},Qe.isValidElement=G,Qe.lazy=function(D){return{$$typeof:S,_payload:{_status:-1,_result:D},_init:R}},Qe.memo=function(D,Q){return{$$typeof:m,type:D,compare:Q===void 0?null:Q}},Qe.startTransition=function(D){var Q=I.transition;I.transition={};try{D()}finally{I.transition=Q}},Qe.unstable_act=X,Qe.useCallback=function(D,Q){return H.current.useCallback(D,Q)},Qe.useContext=function(D){return H.current.useContext(D)},Qe.useDebugValue=function(){},Qe.useDeferredValue=function(D){return H.current.useDeferredValue(D)},Qe.useEffect=function(D,Q){return H.current.useEffect(D,Q)},Qe.useId=function(){return H.current.useId()},Qe.useImperativeHandle=function(D,Q,se){return H.current.useImperativeHandle(D,Q,se)},Qe.useInsertionEffect=function(D,Q){return H.current.useInsertionEffect(D,Q)},Qe.useLayoutEffect=function(D,Q){return H.current.useLayoutEffect(D,Q)},Qe.useMemo=function(D,Q){return H.current.useMemo(D,Q)},Qe.useReducer=function(D,Q,se){return H.current.useReducer(D,Q,se)},Qe.useRef=function(D){return H.current.useRef(D)},Qe.useState=function(D){return H.current.useState(D)},Qe.useSyncExternalStore=function(D,Q,se){return H.current.useSyncExternalStore(D,Q,se)},Qe.useTransition=function(){return H.current.useTransition()},Qe.version="18.3.1",Qe}var zp;function Rh(){return zp||(zp=1,Fc.exports=qS()),Fc.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 Fp;function VS(){if(Fp)return Bs;Fp=1;var e=Rh(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function u(d,p,m){var S,w={},y=null,v=null;m!==void 0&&(y=""+m),p.key!==void 0&&(y=""+p.key),p.ref!==void 0&&(v=p.ref);for(S in p)s.call(p,S)&&!l.hasOwnProperty(S)&&(w[S]=p[S]);if(d&&d.defaultProps)for(S in p=d.defaultProps,p)w[S]===void 0&&(w[S]=p[S]);return{$$typeof:t,type:d,key:y,ref:v,props:w,_owner:o.current}}return Bs.Fragment=n,Bs.jsx=u,Bs.jsxs=u,Bs}var Hp;function YS(){return Hp||(Hp=1,zc.exports=VS()),zc.exports}var h=YS(),M=Rh();const XS=Nh(M);var fa={},Hc={exports:{}},ai={},$c={exports:{}},Wc={};/**
|
|
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 $p;function GS(){return $p||($p=1,(function(e){function t(I,q){var X=I.length;I.push(q);e:for(;0<X;){var D=X-1>>>1,Q=I[D];if(0<o(Q,q))I[D]=q,I[X]=Q,X=D;else break e}}function n(I){return I.length===0?null:I[0]}function s(I){if(I.length===0)return null;var q=I[0],X=I.pop();if(X!==q){I[0]=X;e:for(var D=0,Q=I.length,se=Q>>>1;D<se;){var re=2*(D+1)-1,ae=I[re],le=re+1,de=I[le];if(0>o(ae,X))le<Q&&0>o(de,ae)?(I[D]=de,I[le]=X,D=le):(I[D]=ae,I[re]=X,D=re);else if(le<Q&&0>o(de,X))I[D]=de,I[le]=X,D=le;else break e}}return q}function o(I,q){var X=I.sortIndex-q.sortIndex;return X!==0?X:I.id-q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var u=Date,d=u.now();e.unstable_now=function(){return u.now()-d}}var p=[],m=[],S=1,w=null,y=3,v=!1,C=!1,b=!1,k=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function A(I){for(var q=n(m);q!==null;){if(q.callback===null)s(m);else if(q.startTime<=I)s(m),q.sortIndex=q.expirationTime,t(p,q);else break;q=n(m)}}function B(I){if(b=!1,A(I),!C)if(n(p)!==null)C=!0,R(ee);else{var q=n(m);q!==null&&H(B,q.startTime-I)}}function ee(I,q){C=!1,b&&(b=!1,N(Z),Z=-1),v=!0;var X=y;try{for(A(q),w=n(p);w!==null&&(!(w.expirationTime>q)||I&&!K());){var D=w.callback;if(typeof D=="function"){w.callback=null,y=w.priorityLevel;var Q=D(w.expirationTime<=q);q=e.unstable_now(),typeof Q=="function"?w.callback=Q:w===n(p)&&s(p),A(q)}else s(p);w=n(p)}if(w!==null)var se=!0;else{var re=n(m);re!==null&&H(B,re.startTime-q),se=!1}return se}finally{w=null,y=X,v=!1}}var O=!1,F=null,Z=-1,W=5,G=-1;function K(){return!(e.unstable_now()-G<W)}function P(){if(F!==null){var I=e.unstable_now();G=I;var q=!0;try{q=F(!0,I)}finally{q?E():(O=!1,F=null)}}else O=!1}var E;if(typeof L=="function")E=function(){L(P)};else if(typeof MessageChannel<"u"){var j=new MessageChannel,U=j.port2;j.port1.onmessage=P,E=function(){U.postMessage(null)}}else E=function(){k(P,0)};function R(I){F=I,O||(O=!0,E())}function H(I,q){Z=k(function(){I(e.unstable_now())},q)}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(I){I.callback=null},e.unstable_continueExecution=function(){C||v||(C=!0,R(ee))},e.unstable_forceFrameRate=function(I){0>I||125<I?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):W=0<I?Math.floor(1e3/I):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_getFirstCallbackNode=function(){return n(p)},e.unstable_next=function(I){switch(y){case 1:case 2:case 3:var q=3;break;default:q=y}var X=y;y=q;try{return I()}finally{y=X}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(I,q){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var X=y;y=I;try{return q()}finally{y=X}},e.unstable_scheduleCallback=function(I,q,X){var D=e.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?D+X:D):X=D,I){case 1:var Q=-1;break;case 2:Q=250;break;case 5:Q=1073741823;break;case 4:Q=1e4;break;default:Q=5e3}return Q=X+Q,I={id:S++,callback:q,priorityLevel:I,startTime:X,expirationTime:Q,sortIndex:-1},X>D?(I.sortIndex=X,t(m,I),n(p)===null&&I===n(m)&&(b?(N(Z),Z=-1):b=!0,H(B,X-D))):(I.sortIndex=Q,t(p,I),C||v||(C=!0,R(ee))),I},e.unstable_shouldYield=K,e.unstable_wrapCallback=function(I){var q=y;return function(){var X=y;y=q;try{return I.apply(this,arguments)}finally{y=X}}}})(Wc)),Wc}var Wp;function QS(){return Wp||(Wp=1,$c.exports=GS()),$c.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 Up;function JS(){if(Up)return ai;Up=1;var e=Rh(),t=QS();function n(i){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+i,a=1;a<arguments.length;a++)r+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+i+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,o={};function l(i,r){u(i,r),u(i+"Capture",r)}function u(i,r){for(o[i]=r,i=0;i<r.length;i++)s.add(r[i])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,m=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,S={},w={};function y(i){return p.call(w,i)?!0:p.call(S,i)?!1:m.test(i)?w[i]=!0:(S[i]=!0,!1)}function v(i,r,a,c){if(a!==null&&a.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return c?!1:a!==null?!a.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function C(i,r,a,c){if(r===null||typeof r>"u"||v(i,r,a,c))return!0;if(c)return!1;if(a!==null)switch(a.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 b(i,r,a,c,f,g,x){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=c,this.attributeNamespace=f,this.mustUseProperty=a,this.propertyName=i,this.type=r,this.sanitizeURL=g,this.removeEmptyString=x}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){k[i]=new b(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var r=i[0];k[r]=new b(r,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){k[i]=new b(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){k[i]=new b(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){k[i]=new b(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){k[i]=new b(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){k[i]=new b(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){k[i]=new b(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){k[i]=new b(i,5,!1,i.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function L(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var r=i.replace(N,L);k[r]=new b(r,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var r=i.replace(N,L);k[r]=new b(r,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var r=i.replace(N,L);k[r]=new b(r,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){k[i]=new b(i,1,!1,i.toLowerCase(),null,!1,!1)}),k.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){k[i]=new b(i,1,!1,i.toLowerCase(),null,!0,!0)});function A(i,r,a,c){var f=k.hasOwnProperty(r)?k[r]:null;(f!==null?f.type!==0:c||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(C(r,a,f,c)&&(a=null),c||f===null?y(r)&&(a===null?i.removeAttribute(r):i.setAttribute(r,""+a)):f.mustUseProperty?i[f.propertyName]=a===null?f.type===3?!1:"":a:(r=f.attributeName,c=f.attributeNamespace,a===null?i.removeAttribute(r):(f=f.type,a=f===3||f===4&&a===!0?"":""+a,c?i.setAttributeNS(c,r,a):i.setAttribute(r,a))))}var B=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,ee=Symbol.for("react.element"),O=Symbol.for("react.portal"),F=Symbol.for("react.fragment"),Z=Symbol.for("react.strict_mode"),W=Symbol.for("react.profiler"),G=Symbol.for("react.provider"),K=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),H=Symbol.for("react.offscreen"),I=Symbol.iterator;function q(i){return i===null||typeof i!="object"?null:(i=I&&i[I]||i["@@iterator"],typeof i=="function"?i:null)}var X=Object.assign,D;function Q(i){if(D===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);D=r&&r[1]||""}return`
|
|
34
|
-
`+D+i}var se=!1;function re(i,r){if(!i||se)return"";se=!0;var a=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(oe){var c=oe}Reflect.construct(i,[],r)}else{try{r.call()}catch(oe){c=oe}i.call(r.prototype)}else{try{throw Error()}catch(oe){c=oe}i()}}catch(oe){if(oe&&c&&typeof oe.stack=="string"){for(var f=oe.stack.split(`
|
|
35
|
-
`),g=c.stack.split(`
|
|
36
|
-
`),x=f.length-1,T=g.length-1;1<=x&&0<=T&&f[x]!==g[T];)T--;for(;1<=x&&0<=T;x--,T--)if(f[x]!==g[T]){if(x!==1||T!==1)do if(x--,T--,0>T||f[x]!==g[T]){var z=`
|
|
37
|
-
`+f[x].replace(" at new "," at ");return i.displayName&&z.includes("<anonymous>")&&(z=z.replace("<anonymous>",i.displayName)),z}while(1<=x&&0<=T);break}}}finally{se=!1,Error.prepareStackTrace=a}return(i=i?i.displayName||i.name:"")?Q(i):""}function ae(i){switch(i.tag){case 5:return Q(i.type);case 16:return Q("Lazy");case 13:return Q("Suspense");case 19:return Q("SuspenseList");case 0:case 2:case 15:return i=re(i.type,!1),i;case 11:return i=re(i.type.render,!1),i;case 1:return i=re(i.type,!0),i;default:return""}}function le(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case F:return"Fragment";case O:return"Portal";case W:return"Profiler";case Z:return"StrictMode";case E:return"Suspense";case j:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case K:return(i.displayName||"Context")+".Consumer";case G:return(i._context.displayName||"Context")+".Provider";case P:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case U:return r=i.displayName||null,r!==null?r:le(i.type)||"Memo";case R:r=i._payload,i=i._init;try{return le(i(r))}catch{}}return null}function de(i){var r=i.type;switch(i.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=r.render,i=i.displayName||i.name||"",r.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return le(r);case 8:return r===Z?"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 ve(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Re(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Fe(i){var r=Re(i)?"checked":"value",a=Object.getOwnPropertyDescriptor(i.constructor.prototype,r),c=""+i[r];if(!i.hasOwnProperty(r)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var f=a.get,g=a.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return f.call(this)},set:function(x){c=""+x,g.call(this,x)}}),Object.defineProperty(i,r,{enumerable:a.enumerable}),{getValue:function(){return c},setValue:function(x){c=""+x},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function te(i){i._valueTracker||(i._valueTracker=Fe(i))}function ie(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var a=r.getValue(),c="";return i&&(c=Re(i)?i.checked?"true":"false":i.value),i=c,i!==a?(r.setValue(i),!0):!1}function ye(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}function Le(i,r){var a=r.checked;return X({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??i._wrapperState.initialChecked})}function je(i,r){var a=r.defaultValue==null?"":r.defaultValue,c=r.checked!=null?r.checked:r.defaultChecked;a=ve(r.value!=null?r.value:a),i._wrapperState={initialChecked:c,initialValue:a,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Y(i,r){r=r.checked,r!=null&&A(i,"checked",r,!1)}function he(i,r){Y(i,r);var a=ve(r.value),c=r.type;if(a!=null)c==="number"?(a===0&&i.value===""||i.value!=a)&&(i.value=""+a):i.value!==""+a&&(i.value=""+a);else if(c==="submit"||c==="reset"){i.removeAttribute("value");return}r.hasOwnProperty("value")?$(i,r.type,a):r.hasOwnProperty("defaultValue")&&$(i,r.type,ve(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(i.defaultChecked=!!r.defaultChecked)}function we(i,r,a){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var c=r.type;if(!(c!=="submit"&&c!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+i._wrapperState.initialValue,a||r===i.value||(i.value=r),i.defaultValue=r}a=i.name,a!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,a!==""&&(i.name=a)}function $(i,r,a){(r!=="number"||ye(i.ownerDocument)!==i)&&(a==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+a&&(i.defaultValue=""+a))}var fe=Array.isArray;function Ce(i,r,a,c){if(i=i.options,r){r={};for(var f=0;f<a.length;f++)r["$"+a[f]]=!0;for(a=0;a<i.length;a++)f=r.hasOwnProperty("$"+i[a].value),i[a].selected!==f&&(i[a].selected=f),f&&c&&(i[a].defaultSelected=!0)}else{for(a=""+ve(a),r=null,f=0;f<i.length;f++){if(i[f].value===a){i[f].selected=!0,c&&(i[f].defaultSelected=!0);return}r!==null||i[f].disabled||(r=i[f])}r!==null&&(r.selected=!0)}}function Ee(i,r){if(r.dangerouslySetInnerHTML!=null)throw Error(n(91));return X({},r,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function Ae(i,r){var a=r.value;if(a==null){if(a=r.children,r=r.defaultValue,a!=null){if(r!=null)throw Error(n(92));if(fe(a)){if(1<a.length)throw Error(n(93));a=a[0]}r=a}r==null&&(r=""),a=r}i._wrapperState={initialValue:ve(a)}}function mt(i,r){var a=ve(r.value),c=ve(r.defaultValue);a!=null&&(a=""+a,a!==i.value&&(i.value=a),r.defaultValue==null&&i.defaultValue!==a&&(i.defaultValue=a)),c!=null&&(i.defaultValue=""+c)}function rt(i){var r=i.textContent;r===i._wrapperState.initialValue&&r!==""&&r!==null&&(i.value=r)}function Be(i){switch(i){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function We(i,r){return i==null||i==="http://www.w3.org/1999/xhtml"?Be(r):i==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var Ie,bt=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,a,c,f){MSApp.execUnsafeLocalFunction(function(){return i(r,a,c,f)})}:i})(function(i,r){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=r;else{for(Ie=Ie||document.createElement("div"),Ie.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=Ie.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;r.firstChild;)i.appendChild(r.firstChild)}});function Ge(i,r){if(r){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=r;return}}i.textContent=r}var me={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},qe=["Webkit","ms","Moz","O"];Object.keys(me).forEach(function(i){qe.forEach(function(r){r=r+i.charAt(0).toUpperCase()+i.substring(1),me[r]=me[i]})});function et(i,r,a){return r==null||typeof r=="boolean"||r===""?"":a||typeof r!="number"||r===0||me.hasOwnProperty(i)&&me[i]?(""+r).trim():r+"px"}function ce(i,r){i=i.style;for(var a in r)if(r.hasOwnProperty(a)){var c=a.indexOf("--")===0,f=et(a,r[a],c);a==="float"&&(a="cssFloat"),c?i.setProperty(a,f):i[a]=f}}var De=X({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 Ke(i,r){if(r){if(De[i]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(n(137,i));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(n(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(n(61))}if(r.style!=null&&typeof r.style!="object")throw Error(n(62))}}function Mt(i,r){if(i.indexOf("-")===-1)return typeof r.is=="string";switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var hi=null;function el(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var tl=null,mr=null,gr=null;function ed(i){if(i=Ss(i)){if(typeof tl!="function")throw Error(n(280));var r=i.stateNode;r&&(r=Ro(r),tl(i.stateNode,i.type,r))}}function td(i){mr?gr?gr.push(i):gr=[i]:mr=i}function id(){if(mr){var i=mr,r=gr;if(gr=mr=null,ed(i),r)for(i=0;i<r.length;i++)ed(r[i])}}function nd(i,r){return i(r)}function rd(){}var il=!1;function sd(i,r,a){if(il)return i(r,a);il=!0;try{return nd(i,r,a)}finally{il=!1,(mr!==null||gr!==null)&&(rd(),id())}}function Zr(i,r){var a=i.stateNode;if(a===null)return null;var c=Ro(a);if(c===null)return null;a=c[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":(c=!c.disabled)||(i=i.type,c=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!c;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(n(231,r,typeof a));return a}var nl=!1;if(d)try{var es={};Object.defineProperty(es,"passive",{get:function(){nl=!0}}),window.addEventListener("test",es,es),window.removeEventListener("test",es,es)}catch{nl=!1}function J_(i,r,a,c,f,g,x,T,z){var oe=Array.prototype.slice.call(arguments,3);try{r.apply(a,oe)}catch(ge){this.onError(ge)}}var ts=!1,so=null,oo=!1,rl=null,Z_={onError:function(i){ts=!0,so=i}};function ey(i,r,a,c,f,g,x,T,z){ts=!1,so=null,J_.apply(Z_,arguments)}function ty(i,r,a,c,f,g,x,T,z){if(ey.apply(this,arguments),ts){if(ts){var oe=so;ts=!1,so=null}else throw Error(n(198));oo||(oo=!0,rl=oe)}}function $n(i){var r=i,a=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(a=r.return),i=r.return;while(i)}return r.tag===3?a:null}function od(i){if(i.tag===13){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function ad(i){if($n(i)!==i)throw Error(n(188))}function iy(i){var r=i.alternate;if(!r){if(r=$n(i),r===null)throw Error(n(188));return r!==i?null:i}for(var a=i,c=r;;){var f=a.return;if(f===null)break;var g=f.alternate;if(g===null){if(c=f.return,c!==null){a=c;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===a)return ad(f),i;if(g===c)return ad(f),r;g=g.sibling}throw Error(n(188))}if(a.return!==c.return)a=f,c=g;else{for(var x=!1,T=f.child;T;){if(T===a){x=!0,a=f,c=g;break}if(T===c){x=!0,c=f,a=g;break}T=T.sibling}if(!x){for(T=g.child;T;){if(T===a){x=!0,a=g,c=f;break}if(T===c){x=!0,c=g,a=f;break}T=T.sibling}if(!x)throw Error(n(189))}}if(a.alternate!==c)throw Error(n(190))}if(a.tag!==3)throw Error(n(188));return a.stateNode.current===a?i:r}function ld(i){return i=iy(i),i!==null?cd(i):null}function cd(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var r=cd(i);if(r!==null)return r;i=i.sibling}return null}var ud=t.unstable_scheduleCallback,hd=t.unstable_cancelCallback,ny=t.unstable_shouldYield,ry=t.unstable_requestPaint,yt=t.unstable_now,sy=t.unstable_getCurrentPriorityLevel,sl=t.unstable_ImmediatePriority,dd=t.unstable_UserBlockingPriority,ao=t.unstable_NormalPriority,oy=t.unstable_LowPriority,fd=t.unstable_IdlePriority,lo=null,Fi=null;function ay(i){if(Fi&&typeof Fi.onCommitFiberRoot=="function")try{Fi.onCommitFiberRoot(lo,i,void 0,(i.current.flags&128)===128)}catch{}}var Mi=Math.clz32?Math.clz32:uy,ly=Math.log,cy=Math.LN2;function uy(i){return i>>>=0,i===0?32:31-(ly(i)/cy|0)|0}var co=64,uo=4194304;function is(i){switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function ho(i,r){var a=i.pendingLanes;if(a===0)return 0;var c=0,f=i.suspendedLanes,g=i.pingedLanes,x=a&268435455;if(x!==0){var T=x&~f;T!==0?c=is(T):(g&=x,g!==0&&(c=is(g)))}else x=a&~f,x!==0?c=is(x):g!==0&&(c=is(g));if(c===0)return 0;if(r!==0&&r!==c&&(r&f)===0&&(f=c&-c,g=r&-r,f>=g||f===16&&(g&4194240)!==0))return r;if((c&4)!==0&&(c|=a&16),r=i.entangledLanes,r!==0)for(i=i.entanglements,r&=c;0<r;)a=31-Mi(r),f=1<<a,c|=i[a],r&=~f;return c}function hy(i,r){switch(i){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function dy(i,r){for(var a=i.suspendedLanes,c=i.pingedLanes,f=i.expirationTimes,g=i.pendingLanes;0<g;){var x=31-Mi(g),T=1<<x,z=f[x];z===-1?((T&a)===0||(T&c)!==0)&&(f[x]=hy(T,r)):z<=r&&(i.expiredLanes|=T),g&=~T}}function ol(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function pd(){var i=co;return co<<=1,(co&4194240)===0&&(co=64),i}function al(i){for(var r=[],a=0;31>a;a++)r.push(i);return r}function ns(i,r,a){i.pendingLanes|=r,r!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,r=31-Mi(r),i[r]=a}function fy(i,r){var a=i.pendingLanes&~r;i.pendingLanes=r,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=r,i.mutableReadLanes&=r,i.entangledLanes&=r,r=i.entanglements;var c=i.eventTimes;for(i=i.expirationTimes;0<a;){var f=31-Mi(a),g=1<<f;r[f]=0,c[f]=-1,i[f]=-1,a&=~g}}function ll(i,r){var a=i.entangledLanes|=r;for(i=i.entanglements;a;){var c=31-Mi(a),f=1<<c;f&r|i[c]&r&&(i[c]|=r),a&=~f}}var it=0;function md(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var gd,cl,vd,_d,yd,ul=!1,fo=[],mn=null,gn=null,vn=null,rs=new Map,ss=new Map,_n=[],py="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 Sd(i,r){switch(i){case"focusin":case"focusout":mn=null;break;case"dragenter":case"dragleave":gn=null;break;case"mouseover":case"mouseout":vn=null;break;case"pointerover":case"pointerout":rs.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":ss.delete(r.pointerId)}}function os(i,r,a,c,f,g){return i===null||i.nativeEvent!==g?(i={blockedOn:r,domEventName:a,eventSystemFlags:c,nativeEvent:g,targetContainers:[f]},r!==null&&(r=Ss(r),r!==null&&cl(r)),i):(i.eventSystemFlags|=c,r=i.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),i)}function my(i,r,a,c,f){switch(r){case"focusin":return mn=os(mn,i,r,a,c,f),!0;case"dragenter":return gn=os(gn,i,r,a,c,f),!0;case"mouseover":return vn=os(vn,i,r,a,c,f),!0;case"pointerover":var g=f.pointerId;return rs.set(g,os(rs.get(g)||null,i,r,a,c,f)),!0;case"gotpointercapture":return g=f.pointerId,ss.set(g,os(ss.get(g)||null,i,r,a,c,f)),!0}return!1}function wd(i){var r=Wn(i.target);if(r!==null){var a=$n(r);if(a!==null){if(r=a.tag,r===13){if(r=od(a),r!==null){i.blockedOn=r,yd(i.priority,function(){vd(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function po(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var a=dl(i.domEventName,i.eventSystemFlags,r[0],i.nativeEvent);if(a===null){a=i.nativeEvent;var c=new a.constructor(a.type,a);hi=c,a.target.dispatchEvent(c),hi=null}else return r=Ss(a),r!==null&&cl(r),i.blockedOn=a,!1;r.shift()}return!0}function bd(i,r,a){po(i)&&a.delete(r)}function gy(){ul=!1,mn!==null&&po(mn)&&(mn=null),gn!==null&&po(gn)&&(gn=null),vn!==null&&po(vn)&&(vn=null),rs.forEach(bd),ss.forEach(bd)}function as(i,r){i.blockedOn===r&&(i.blockedOn=null,ul||(ul=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,gy)))}function ls(i){function r(f){return as(f,i)}if(0<fo.length){as(fo[0],i);for(var a=1;a<fo.length;a++){var c=fo[a];c.blockedOn===i&&(c.blockedOn=null)}}for(mn!==null&&as(mn,i),gn!==null&&as(gn,i),vn!==null&&as(vn,i),rs.forEach(r),ss.forEach(r),a=0;a<_n.length;a++)c=_n[a],c.blockedOn===i&&(c.blockedOn=null);for(;0<_n.length&&(a=_n[0],a.blockedOn===null);)wd(a),a.blockedOn===null&&_n.shift()}var vr=B.ReactCurrentBatchConfig,mo=!0;function vy(i,r,a,c){var f=it,g=vr.transition;vr.transition=null;try{it=1,hl(i,r,a,c)}finally{it=f,vr.transition=g}}function _y(i,r,a,c){var f=it,g=vr.transition;vr.transition=null;try{it=4,hl(i,r,a,c)}finally{it=f,vr.transition=g}}function hl(i,r,a,c){if(mo){var f=dl(i,r,a,c);if(f===null)Pl(i,r,c,go,a),Sd(i,c);else if(my(f,i,r,a,c))c.stopPropagation();else if(Sd(i,c),r&4&&-1<py.indexOf(i)){for(;f!==null;){var g=Ss(f);if(g!==null&&gd(g),g=dl(i,r,a,c),g===null&&Pl(i,r,c,go,a),g===f)break;f=g}f!==null&&c.stopPropagation()}else Pl(i,r,c,null,a)}}var go=null;function dl(i,r,a,c){if(go=null,i=el(c),i=Wn(i),i!==null)if(r=$n(i),r===null)i=null;else if(a=r.tag,a===13){if(i=od(r),i!==null)return i;i=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null);return go=i,null}function Cd(i){switch(i){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(sy()){case sl:return 1;case dd:return 4;case ao:case oy:return 16;case fd:return 536870912;default:return 16}default:return 16}}var yn=null,fl=null,vo=null;function xd(){if(vo)return vo;var i,r=fl,a=r.length,c,f="value"in yn?yn.value:yn.textContent,g=f.length;for(i=0;i<a&&r[i]===f[i];i++);var x=a-i;for(c=1;c<=x&&r[a-c]===f[g-c];c++);return vo=f.slice(i,1<c?1-c:void 0)}function _o(i){var r=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&r===13&&(i=13)):i=r,i===10&&(i=13),32<=i||i===13?i:0}function yo(){return!0}function kd(){return!1}function di(i){function r(a,c,f,g,x){this._reactName=a,this._targetInst=f,this.type=c,this.nativeEvent=g,this.target=x,this.currentTarget=null;for(var T in i)i.hasOwnProperty(T)&&(a=i[T],this[T]=a?a(g):g[T]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?yo:kd,this.isPropagationStopped=kd,this}return X(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=yo)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=yo)},persist:function(){},isPersistent:yo}),r}var _r={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},pl=di(_r),cs=X({},_r,{view:0,detail:0}),yy=di(cs),ml,gl,us,So=X({},cs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:_l,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==us&&(us&&i.type==="mousemove"?(ml=i.screenX-us.screenX,gl=i.screenY-us.screenY):gl=ml=0,us=i),ml)},movementY:function(i){return"movementY"in i?i.movementY:gl}}),Ed=di(So),Sy=X({},So,{dataTransfer:0}),wy=di(Sy),by=X({},cs,{relatedTarget:0}),vl=di(by),Cy=X({},_r,{animationName:0,elapsedTime:0,pseudoElement:0}),xy=di(Cy),ky=X({},_r,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Ey=di(ky),Ny=X({},_r,{data:0}),Nd=di(Ny),Ry={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Py={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"},Dy={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function My(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=Dy[i])?!!r[i]:!1}function _l(){return My}var Ly=X({},cs,{key:function(i){if(i.key){var r=Ry[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=_o(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Py[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:_l,charCode:function(i){return i.type==="keypress"?_o(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?_o(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),jy=di(Ly),Ty=X({},So,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Rd=di(Ty),By=X({},cs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:_l}),Ay=di(By),Iy=X({},_r,{propertyName:0,elapsedTime:0,pseudoElement:0}),Oy=di(Iy),zy=X({},So,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),Fy=di(zy),Hy=[9,13,27,32],yl=d&&"CompositionEvent"in window,hs=null;d&&"documentMode"in document&&(hs=document.documentMode);var $y=d&&"TextEvent"in window&&!hs,Pd=d&&(!yl||hs&&8<hs&&11>=hs),Dd=" ",Md=!1;function Ld(i,r){switch(i){case"keyup":return Hy.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function jd(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var yr=!1;function Wy(i,r){switch(i){case"compositionend":return jd(r);case"keypress":return r.which!==32?null:(Md=!0,Dd);case"textInput":return i=r.data,i===Dd&&Md?null:i;default:return null}}function Uy(i,r){if(yr)return i==="compositionend"||!yl&&Ld(i,r)?(i=xd(),vo=fl=yn=null,yr=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Pd&&r.locale!=="ko"?null:r.data;default:return null}}var Ky={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 Td(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!Ky[i.type]:r==="textarea"}function Bd(i,r,a,c){td(c),r=ko(r,"onChange"),0<r.length&&(a=new pl("onChange","change",null,a,c),i.push({event:a,listeners:r}))}var ds=null,fs=null;function qy(i){Zd(i,0)}function wo(i){var r=xr(i);if(ie(r))return i}function Vy(i,r){if(i==="change")return r}var Ad=!1;if(d){var Sl;if(d){var wl="oninput"in document;if(!wl){var Id=document.createElement("div");Id.setAttribute("oninput","return;"),wl=typeof Id.oninput=="function"}Sl=wl}else Sl=!1;Ad=Sl&&(!document.documentMode||9<document.documentMode)}function Od(){ds&&(ds.detachEvent("onpropertychange",zd),fs=ds=null)}function zd(i){if(i.propertyName==="value"&&wo(fs)){var r=[];Bd(r,fs,i,el(i)),sd(qy,r)}}function Yy(i,r,a){i==="focusin"?(Od(),ds=r,fs=a,ds.attachEvent("onpropertychange",zd)):i==="focusout"&&Od()}function Xy(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return wo(fs)}function Gy(i,r){if(i==="click")return wo(r)}function Qy(i,r){if(i==="input"||i==="change")return wo(r)}function Jy(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var Li=typeof Object.is=="function"?Object.is:Jy;function ps(i,r){if(Li(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var a=Object.keys(i),c=Object.keys(r);if(a.length!==c.length)return!1;for(c=0;c<a.length;c++){var f=a[c];if(!p.call(r,f)||!Li(i[f],r[f]))return!1}return!0}function Fd(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Hd(i,r){var a=Fd(i);i=0;for(var c;a;){if(a.nodeType===3){if(c=i+a.textContent.length,i<=r&&c>=r)return{node:a,offset:r-i};i=c}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Fd(a)}}function $d(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?$d(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Wd(){for(var i=window,r=ye();r instanceof i.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)i=r.contentWindow;else break;r=ye(i.document)}return r}function bl(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}function Zy(i){var r=Wd(),a=i.focusedElem,c=i.selectionRange;if(r!==a&&a&&a.ownerDocument&&$d(a.ownerDocument.documentElement,a)){if(c!==null&&bl(a)){if(r=c.start,i=c.end,i===void 0&&(i=r),"selectionStart"in a)a.selectionStart=r,a.selectionEnd=Math.min(i,a.value.length);else if(i=(r=a.ownerDocument||document)&&r.defaultView||window,i.getSelection){i=i.getSelection();var f=a.textContent.length,g=Math.min(c.start,f);c=c.end===void 0?g:Math.min(c.end,f),!i.extend&&g>c&&(f=c,c=g,g=f),f=Hd(a,g);var x=Hd(a,c);f&&x&&(i.rangeCount!==1||i.anchorNode!==f.node||i.anchorOffset!==f.offset||i.focusNode!==x.node||i.focusOffset!==x.offset)&&(r=r.createRange(),r.setStart(f.node,f.offset),i.removeAllRanges(),g>c?(i.addRange(r),i.extend(x.node,x.offset)):(r.setEnd(x.node,x.offset),i.addRange(r)))}}for(r=[],i=a;i=i.parentNode;)i.nodeType===1&&r.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<r.length;a++)i=r[a],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var eS=d&&"documentMode"in document&&11>=document.documentMode,Sr=null,Cl=null,ms=null,xl=!1;function Ud(i,r,a){var c=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;xl||Sr==null||Sr!==ye(c)||(c=Sr,"selectionStart"in c&&bl(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),ms&&ps(ms,c)||(ms=c,c=ko(Cl,"onSelect"),0<c.length&&(r=new pl("onSelect","select",null,r,a),i.push({event:r,listeners:c}),r.target=Sr)))}function bo(i,r){var a={};return a[i.toLowerCase()]=r.toLowerCase(),a["Webkit"+i]="webkit"+r,a["Moz"+i]="moz"+r,a}var wr={animationend:bo("Animation","AnimationEnd"),animationiteration:bo("Animation","AnimationIteration"),animationstart:bo("Animation","AnimationStart"),transitionend:bo("Transition","TransitionEnd")},kl={},Kd={};d&&(Kd=document.createElement("div").style,"AnimationEvent"in window||(delete wr.animationend.animation,delete wr.animationiteration.animation,delete wr.animationstart.animation),"TransitionEvent"in window||delete wr.transitionend.transition);function Co(i){if(kl[i])return kl[i];if(!wr[i])return i;var r=wr[i],a;for(a in r)if(r.hasOwnProperty(a)&&a in Kd)return kl[i]=r[a];return i}var qd=Co("animationend"),Vd=Co("animationiteration"),Yd=Co("animationstart"),Xd=Co("transitionend"),Gd=new Map,Qd="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 Sn(i,r){Gd.set(i,r),l(r,[i])}for(var El=0;El<Qd.length;El++){var Nl=Qd[El],tS=Nl.toLowerCase(),iS=Nl[0].toUpperCase()+Nl.slice(1);Sn(tS,"on"+iS)}Sn(qd,"onAnimationEnd"),Sn(Vd,"onAnimationIteration"),Sn(Yd,"onAnimationStart"),Sn("dblclick","onDoubleClick"),Sn("focusin","onFocus"),Sn("focusout","onBlur"),Sn(Xd,"onTransitionEnd"),u("onMouseEnter",["mouseout","mouseover"]),u("onMouseLeave",["mouseout","mouseover"]),u("onPointerEnter",["pointerout","pointerover"]),u("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var gs="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(" "),nS=new Set("cancel close invalid load scroll toggle".split(" ").concat(gs));function Jd(i,r,a){var c=i.type||"unknown-event";i.currentTarget=a,ty(c,r,void 0,i),i.currentTarget=null}function Zd(i,r){r=(r&4)!==0;for(var a=0;a<i.length;a++){var c=i[a],f=c.event;c=c.listeners;e:{var g=void 0;if(r)for(var x=c.length-1;0<=x;x--){var T=c[x],z=T.instance,oe=T.currentTarget;if(T=T.listener,z!==g&&f.isPropagationStopped())break e;Jd(f,T,oe),g=z}else for(x=0;x<c.length;x++){if(T=c[x],z=T.instance,oe=T.currentTarget,T=T.listener,z!==g&&f.isPropagationStopped())break e;Jd(f,T,oe),g=z}}}if(oo)throw i=rl,oo=!1,rl=null,i}function ot(i,r){var a=r[Bl];a===void 0&&(a=r[Bl]=new Set);var c=i+"__bubble";a.has(c)||(ef(r,i,2,!1),a.add(c))}function Rl(i,r,a){var c=0;r&&(c|=4),ef(a,i,c,r)}var xo="_reactListening"+Math.random().toString(36).slice(2);function vs(i){if(!i[xo]){i[xo]=!0,s.forEach(function(a){a!=="selectionchange"&&(nS.has(a)||Rl(a,!1,i),Rl(a,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[xo]||(r[xo]=!0,Rl("selectionchange",!1,r))}}function ef(i,r,a,c){switch(Cd(r)){case 1:var f=vy;break;case 4:f=_y;break;default:f=hl}a=f.bind(null,r,a,i),f=void 0,!nl||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),c?f!==void 0?i.addEventListener(r,a,{capture:!0,passive:f}):i.addEventListener(r,a,!0):f!==void 0?i.addEventListener(r,a,{passive:f}):i.addEventListener(r,a,!1)}function Pl(i,r,a,c,f){var g=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var x=c.tag;if(x===3||x===4){var T=c.stateNode.containerInfo;if(T===f||T.nodeType===8&&T.parentNode===f)break;if(x===4)for(x=c.return;x!==null;){var z=x.tag;if((z===3||z===4)&&(z=x.stateNode.containerInfo,z===f||z.nodeType===8&&z.parentNode===f))return;x=x.return}for(;T!==null;){if(x=Wn(T),x===null)return;if(z=x.tag,z===5||z===6){c=g=x;continue e}T=T.parentNode}}c=c.return}sd(function(){var oe=g,ge=el(a),_e=[];e:{var pe=Gd.get(i);if(pe!==void 0){var ke=pl,Pe=i;switch(i){case"keypress":if(_o(a)===0)break e;case"keydown":case"keyup":ke=jy;break;case"focusin":Pe="focus",ke=vl;break;case"focusout":Pe="blur",ke=vl;break;case"beforeblur":case"afterblur":ke=vl;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ke=Ed;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ke=wy;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ke=Ay;break;case qd:case Vd:case Yd:ke=xy;break;case Xd:ke=Oy;break;case"scroll":ke=yy;break;case"wheel":ke=Fy;break;case"copy":case"cut":case"paste":ke=Ey;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ke=Rd}var Me=(r&4)!==0,St=!Me&&i==="scroll",J=Me?pe!==null?pe+"Capture":null:pe;Me=[];for(var V=oe,ne;V!==null;){ne=V;var Se=ne.stateNode;if(ne.tag===5&&Se!==null&&(ne=Se,J!==null&&(Se=Zr(V,J),Se!=null&&Me.push(_s(V,Se,ne)))),St)break;V=V.return}0<Me.length&&(pe=new ke(pe,Pe,null,a,ge),_e.push({event:pe,listeners:Me}))}}if((r&7)===0){e:{if(pe=i==="mouseover"||i==="pointerover",ke=i==="mouseout"||i==="pointerout",pe&&a!==hi&&(Pe=a.relatedTarget||a.fromElement)&&(Wn(Pe)||Pe[en]))break e;if((ke||pe)&&(pe=ge.window===ge?ge:(pe=ge.ownerDocument)?pe.defaultView||pe.parentWindow:window,ke?(Pe=a.relatedTarget||a.toElement,ke=oe,Pe=Pe?Wn(Pe):null,Pe!==null&&(St=$n(Pe),Pe!==St||Pe.tag!==5&&Pe.tag!==6)&&(Pe=null)):(ke=null,Pe=oe),ke!==Pe)){if(Me=Ed,Se="onMouseLeave",J="onMouseEnter",V="mouse",(i==="pointerout"||i==="pointerover")&&(Me=Rd,Se="onPointerLeave",J="onPointerEnter",V="pointer"),St=ke==null?pe:xr(ke),ne=Pe==null?pe:xr(Pe),pe=new Me(Se,V+"leave",ke,a,ge),pe.target=St,pe.relatedTarget=ne,Se=null,Wn(ge)===oe&&(Me=new Me(J,V+"enter",Pe,a,ge),Me.target=ne,Me.relatedTarget=St,Se=Me),St=Se,ke&&Pe)t:{for(Me=ke,J=Pe,V=0,ne=Me;ne;ne=br(ne))V++;for(ne=0,Se=J;Se;Se=br(Se))ne++;for(;0<V-ne;)Me=br(Me),V--;for(;0<ne-V;)J=br(J),ne--;for(;V--;){if(Me===J||J!==null&&Me===J.alternate)break t;Me=br(Me),J=br(J)}Me=null}else Me=null;ke!==null&&tf(_e,pe,ke,Me,!1),Pe!==null&&St!==null&&tf(_e,St,Pe,Me,!0)}}e:{if(pe=oe?xr(oe):window,ke=pe.nodeName&&pe.nodeName.toLowerCase(),ke==="select"||ke==="input"&&pe.type==="file")var Te=Vy;else if(Td(pe))if(Ad)Te=Qy;else{Te=Xy;var Oe=Yy}else(ke=pe.nodeName)&&ke.toLowerCase()==="input"&&(pe.type==="checkbox"||pe.type==="radio")&&(Te=Gy);if(Te&&(Te=Te(i,oe))){Bd(_e,Te,a,ge);break e}Oe&&Oe(i,pe,oe),i==="focusout"&&(Oe=pe._wrapperState)&&Oe.controlled&&pe.type==="number"&&$(pe,"number",pe.value)}switch(Oe=oe?xr(oe):window,i){case"focusin":(Td(Oe)||Oe.contentEditable==="true")&&(Sr=Oe,Cl=oe,ms=null);break;case"focusout":ms=Cl=Sr=null;break;case"mousedown":xl=!0;break;case"contextmenu":case"mouseup":case"dragend":xl=!1,Ud(_e,a,ge);break;case"selectionchange":if(eS)break;case"keydown":case"keyup":Ud(_e,a,ge)}var ze;if(yl)e:{switch(i){case"compositionstart":var He="onCompositionStart";break e;case"compositionend":He="onCompositionEnd";break e;case"compositionupdate":He="onCompositionUpdate";break e}He=void 0}else yr?Ld(i,a)&&(He="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(He="onCompositionStart");He&&(Pd&&a.locale!=="ko"&&(yr||He!=="onCompositionStart"?He==="onCompositionEnd"&&yr&&(ze=xd()):(yn=ge,fl="value"in yn?yn.value:yn.textContent,yr=!0)),Oe=ko(oe,He),0<Oe.length&&(He=new Nd(He,i,null,a,ge),_e.push({event:He,listeners:Oe}),ze?He.data=ze:(ze=jd(a),ze!==null&&(He.data=ze)))),(ze=$y?Wy(i,a):Uy(i,a))&&(oe=ko(oe,"onBeforeInput"),0<oe.length&&(ge=new Nd("onBeforeInput","beforeinput",null,a,ge),_e.push({event:ge,listeners:oe}),ge.data=ze))}Zd(_e,r)})}function _s(i,r,a){return{instance:i,listener:r,currentTarget:a}}function ko(i,r){for(var a=r+"Capture",c=[];i!==null;){var f=i,g=f.stateNode;f.tag===5&&g!==null&&(f=g,g=Zr(i,a),g!=null&&c.unshift(_s(i,g,f)),g=Zr(i,r),g!=null&&c.push(_s(i,g,f))),i=i.return}return c}function br(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function tf(i,r,a,c,f){for(var g=r._reactName,x=[];a!==null&&a!==c;){var T=a,z=T.alternate,oe=T.stateNode;if(z!==null&&z===c)break;T.tag===5&&oe!==null&&(T=oe,f?(z=Zr(a,g),z!=null&&x.unshift(_s(a,z,T))):f||(z=Zr(a,g),z!=null&&x.push(_s(a,z,T)))),a=a.return}x.length!==0&&i.push({event:r,listeners:x})}var rS=/\r\n?/g,sS=/\u0000|\uFFFD/g;function nf(i){return(typeof i=="string"?i:""+i).replace(rS,`
|
|
38
|
-
`).replace(sS,"")}function Eo(i,r,a){if(r=nf(r),nf(i)!==r&&a)throw Error(n(425))}function No(){}var Dl=null,Ml=null;function Ll(i,r){return i==="textarea"||i==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var jl=typeof setTimeout=="function"?setTimeout:void 0,oS=typeof clearTimeout=="function"?clearTimeout:void 0,rf=typeof Promise=="function"?Promise:void 0,aS=typeof queueMicrotask=="function"?queueMicrotask:typeof rf<"u"?function(i){return rf.resolve(null).then(i).catch(lS)}:jl;function lS(i){setTimeout(function(){throw i})}function Tl(i,r){var a=r,c=0;do{var f=a.nextSibling;if(i.removeChild(a),f&&f.nodeType===8)if(a=f.data,a==="/$"){if(c===0){i.removeChild(f),ls(r);return}c--}else a!=="$"&&a!=="$?"&&a!=="$!"||c++;a=f}while(a);ls(r)}function wn(i){for(;i!=null;i=i.nextSibling){var r=i.nodeType;if(r===1||r===3)break;if(r===8){if(r=i.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return i}function sf(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"){if(r===0)return i;r--}else a==="/$"&&r++}i=i.previousSibling}return null}var Cr=Math.random().toString(36).slice(2),Hi="__reactFiber$"+Cr,ys="__reactProps$"+Cr,en="__reactContainer$"+Cr,Bl="__reactEvents$"+Cr,cS="__reactListeners$"+Cr,uS="__reactHandles$"+Cr;function Wn(i){var r=i[Hi];if(r)return r;for(var a=i.parentNode;a;){if(r=a[en]||a[Hi]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(i=sf(i);i!==null;){if(a=i[Hi])return a;i=sf(i)}return r}i=a,a=i.parentNode}return null}function Ss(i){return i=i[Hi]||i[en],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function xr(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function Ro(i){return i[ys]||null}var Al=[],kr=-1;function bn(i){return{current:i}}function at(i){0>kr||(i.current=Al[kr],Al[kr]=null,kr--)}function st(i,r){kr++,Al[kr]=i.current,i.current=r}var Cn={},qt=bn(Cn),ii=bn(!1),Un=Cn;function Er(i,r){var a=i.type.contextTypes;if(!a)return Cn;var c=i.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===r)return c.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in a)f[g]=r[g];return c&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=r,i.__reactInternalMemoizedMaskedChildContext=f),f}function ni(i){return i=i.childContextTypes,i!=null}function Po(){at(ii),at(qt)}function of(i,r,a){if(qt.current!==Cn)throw Error(n(168));st(qt,r),st(ii,a)}function af(i,r,a){var c=i.stateNode;if(r=r.childContextTypes,typeof c.getChildContext!="function")return a;c=c.getChildContext();for(var f in c)if(!(f in r))throw Error(n(108,de(i)||"Unknown",f));return X({},a,c)}function Do(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||Cn,Un=qt.current,st(qt,i),st(ii,ii.current),!0}function lf(i,r,a){var c=i.stateNode;if(!c)throw Error(n(169));a?(i=af(i,r,Un),c.__reactInternalMemoizedMergedChildContext=i,at(ii),at(qt),st(qt,i)):at(ii),st(ii,a)}var tn=null,Mo=!1,Il=!1;function cf(i){tn===null?tn=[i]:tn.push(i)}function hS(i){Mo=!0,cf(i)}function xn(){if(!Il&&tn!==null){Il=!0;var i=0,r=it;try{var a=tn;for(it=1;i<a.length;i++){var c=a[i];do c=c(!0);while(c!==null)}tn=null,Mo=!1}catch(f){throw tn!==null&&(tn=tn.slice(i+1)),ud(sl,xn),f}finally{it=r,Il=!1}}return null}var Nr=[],Rr=0,Lo=null,jo=0,wi=[],bi=0,Kn=null,nn=1,rn="";function qn(i,r){Nr[Rr++]=jo,Nr[Rr++]=Lo,Lo=i,jo=r}function uf(i,r,a){wi[bi++]=nn,wi[bi++]=rn,wi[bi++]=Kn,Kn=i;var c=nn;i=rn;var f=32-Mi(c)-1;c&=~(1<<f),a+=1;var g=32-Mi(r)+f;if(30<g){var x=f-f%5;g=(c&(1<<x)-1).toString(32),c>>=x,f-=x,nn=1<<32-Mi(r)+f|a<<f|c,rn=g+i}else nn=1<<g|a<<f|c,rn=i}function Ol(i){i.return!==null&&(qn(i,1),uf(i,1,0))}function zl(i){for(;i===Lo;)Lo=Nr[--Rr],Nr[Rr]=null,jo=Nr[--Rr],Nr[Rr]=null;for(;i===Kn;)Kn=wi[--bi],wi[bi]=null,rn=wi[--bi],wi[bi]=null,nn=wi[--bi],wi[bi]=null}var fi=null,pi=null,ct=!1,ji=null;function hf(i,r){var a=Ei(5,null,null,0);a.elementType="DELETED",a.stateNode=r,a.return=i,r=i.deletions,r===null?(i.deletions=[a],i.flags|=16):r.push(a)}function df(i,r){switch(i.tag){case 5:var a=i.type;return r=r.nodeType!==1||a.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(i.stateNode=r,fi=i,pi=wn(r.firstChild),!0):!1;case 6:return r=i.pendingProps===""||r.nodeType!==3?null:r,r!==null?(i.stateNode=r,fi=i,pi=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(a=Kn!==null?{id:nn,overflow:rn}:null,i.memoizedState={dehydrated:r,treeContext:a,retryLane:1073741824},a=Ei(18,null,null,0),a.stateNode=r,a.return=i,i.child=a,fi=i,pi=null,!0):!1;default:return!1}}function Fl(i){return(i.mode&1)!==0&&(i.flags&128)===0}function Hl(i){if(ct){var r=pi;if(r){var a=r;if(!df(i,r)){if(Fl(i))throw Error(n(418));r=wn(a.nextSibling);var c=fi;r&&df(i,r)?hf(c,a):(i.flags=i.flags&-4097|2,ct=!1,fi=i)}}else{if(Fl(i))throw Error(n(418));i.flags=i.flags&-4097|2,ct=!1,fi=i}}}function ff(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;fi=i}function To(i){if(i!==fi)return!1;if(!ct)return ff(i),ct=!0,!1;var r;if((r=i.tag!==3)&&!(r=i.tag!==5)&&(r=i.type,r=r!=="head"&&r!=="body"&&!Ll(i.type,i.memoizedProps)),r&&(r=pi)){if(Fl(i))throw pf(),Error(n(418));for(;r;)hf(i,r),r=wn(r.nextSibling)}if(ff(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"){if(r===0){pi=wn(i.nextSibling);break e}r--}else a!=="$"&&a!=="$!"&&a!=="$?"||r++}i=i.nextSibling}pi=null}}else pi=fi?wn(i.stateNode.nextSibling):null;return!0}function pf(){for(var i=pi;i;)i=wn(i.nextSibling)}function Pr(){pi=fi=null,ct=!1}function $l(i){ji===null?ji=[i]:ji.push(i)}var dS=B.ReactCurrentBatchConfig;function ws(i,r,a){if(i=a.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(a._owner){if(a=a._owner,a){if(a.tag!==1)throw Error(n(309));var c=a.stateNode}if(!c)throw Error(n(147,i));var f=c,g=""+i;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===g?r.ref:(r=function(x){var T=f.refs;x===null?delete T[g]:T[g]=x},r._stringRef=g,r)}if(typeof i!="string")throw Error(n(284));if(!a._owner)throw Error(n(290,i))}return i}function Bo(i,r){throw i=Object.prototype.toString.call(r),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i))}function mf(i){var r=i._init;return r(i._payload)}function gf(i){function r(J,V){if(i){var ne=J.deletions;ne===null?(J.deletions=[V],J.flags|=16):ne.push(V)}}function a(J,V){if(!i)return null;for(;V!==null;)r(J,V),V=V.sibling;return null}function c(J,V){for(J=new Map;V!==null;)V.key!==null?J.set(V.key,V):J.set(V.index,V),V=V.sibling;return J}function f(J,V){return J=Ln(J,V),J.index=0,J.sibling=null,J}function g(J,V,ne){return J.index=ne,i?(ne=J.alternate,ne!==null?(ne=ne.index,ne<V?(J.flags|=2,V):ne):(J.flags|=2,V)):(J.flags|=1048576,V)}function x(J){return i&&J.alternate===null&&(J.flags|=2),J}function T(J,V,ne,Se){return V===null||V.tag!==6?(V=jc(ne,J.mode,Se),V.return=J,V):(V=f(V,ne),V.return=J,V)}function z(J,V,ne,Se){var Te=ne.type;return Te===F?ge(J,V,ne.props.children,Se,ne.key):V!==null&&(V.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===R&&mf(Te)===V.type)?(Se=f(V,ne.props),Se.ref=ws(J,V,ne),Se.return=J,Se):(Se=sa(ne.type,ne.key,ne.props,null,J.mode,Se),Se.ref=ws(J,V,ne),Se.return=J,Se)}function oe(J,V,ne,Se){return V===null||V.tag!==4||V.stateNode.containerInfo!==ne.containerInfo||V.stateNode.implementation!==ne.implementation?(V=Tc(ne,J.mode,Se),V.return=J,V):(V=f(V,ne.children||[]),V.return=J,V)}function ge(J,V,ne,Se,Te){return V===null||V.tag!==7?(V=er(ne,J.mode,Se,Te),V.return=J,V):(V=f(V,ne),V.return=J,V)}function _e(J,V,ne){if(typeof V=="string"&&V!==""||typeof V=="number")return V=jc(""+V,J.mode,ne),V.return=J,V;if(typeof V=="object"&&V!==null){switch(V.$$typeof){case ee:return ne=sa(V.type,V.key,V.props,null,J.mode,ne),ne.ref=ws(J,null,V),ne.return=J,ne;case O:return V=Tc(V,J.mode,ne),V.return=J,V;case R:var Se=V._init;return _e(J,Se(V._payload),ne)}if(fe(V)||q(V))return V=er(V,J.mode,ne,null),V.return=J,V;Bo(J,V)}return null}function pe(J,V,ne,Se){var Te=V!==null?V.key:null;if(typeof ne=="string"&&ne!==""||typeof ne=="number")return Te!==null?null:T(J,V,""+ne,Se);if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case ee:return ne.key===Te?z(J,V,ne,Se):null;case O:return ne.key===Te?oe(J,V,ne,Se):null;case R:return Te=ne._init,pe(J,V,Te(ne._payload),Se)}if(fe(ne)||q(ne))return Te!==null?null:ge(J,V,ne,Se,null);Bo(J,ne)}return null}function ke(J,V,ne,Se,Te){if(typeof Se=="string"&&Se!==""||typeof Se=="number")return J=J.get(ne)||null,T(V,J,""+Se,Te);if(typeof Se=="object"&&Se!==null){switch(Se.$$typeof){case ee:return J=J.get(Se.key===null?ne:Se.key)||null,z(V,J,Se,Te);case O:return J=J.get(Se.key===null?ne:Se.key)||null,oe(V,J,Se,Te);case R:var Oe=Se._init;return ke(J,V,ne,Oe(Se._payload),Te)}if(fe(Se)||q(Se))return J=J.get(ne)||null,ge(V,J,Se,Te,null);Bo(V,Se)}return null}function Pe(J,V,ne,Se){for(var Te=null,Oe=null,ze=V,He=V=0,Tt=null;ze!==null&&He<ne.length;He++){ze.index>He?(Tt=ze,ze=null):Tt=ze.sibling;var Ze=pe(J,ze,ne[He],Se);if(Ze===null){ze===null&&(ze=Tt);break}i&&ze&&Ze.alternate===null&&r(J,ze),V=g(Ze,V,He),Oe===null?Te=Ze:Oe.sibling=Ze,Oe=Ze,ze=Tt}if(He===ne.length)return a(J,ze),ct&&qn(J,He),Te;if(ze===null){for(;He<ne.length;He++)ze=_e(J,ne[He],Se),ze!==null&&(V=g(ze,V,He),Oe===null?Te=ze:Oe.sibling=ze,Oe=ze);return ct&&qn(J,He),Te}for(ze=c(J,ze);He<ne.length;He++)Tt=ke(ze,J,He,ne[He],Se),Tt!==null&&(i&&Tt.alternate!==null&&ze.delete(Tt.key===null?He:Tt.key),V=g(Tt,V,He),Oe===null?Te=Tt:Oe.sibling=Tt,Oe=Tt);return i&&ze.forEach(function(jn){return r(J,jn)}),ct&&qn(J,He),Te}function Me(J,V,ne,Se){var Te=q(ne);if(typeof Te!="function")throw Error(n(150));if(ne=Te.call(ne),ne==null)throw Error(n(151));for(var Oe=Te=null,ze=V,He=V=0,Tt=null,Ze=ne.next();ze!==null&&!Ze.done;He++,Ze=ne.next()){ze.index>He?(Tt=ze,ze=null):Tt=ze.sibling;var jn=pe(J,ze,Ze.value,Se);if(jn===null){ze===null&&(ze=Tt);break}i&&ze&&jn.alternate===null&&r(J,ze),V=g(jn,V,He),Oe===null?Te=jn:Oe.sibling=jn,Oe=jn,ze=Tt}if(Ze.done)return a(J,ze),ct&&qn(J,He),Te;if(ze===null){for(;!Ze.done;He++,Ze=ne.next())Ze=_e(J,Ze.value,Se),Ze!==null&&(V=g(Ze,V,He),Oe===null?Te=Ze:Oe.sibling=Ze,Oe=Ze);return ct&&qn(J,He),Te}for(ze=c(J,ze);!Ze.done;He++,Ze=ne.next())Ze=ke(ze,J,He,Ze.value,Se),Ze!==null&&(i&&Ze.alternate!==null&&ze.delete(Ze.key===null?He:Ze.key),V=g(Ze,V,He),Oe===null?Te=Ze:Oe.sibling=Ze,Oe=Ze);return i&&ze.forEach(function(KS){return r(J,KS)}),ct&&qn(J,He),Te}function St(J,V,ne,Se){if(typeof ne=="object"&&ne!==null&&ne.type===F&&ne.key===null&&(ne=ne.props.children),typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case ee:e:{for(var Te=ne.key,Oe=V;Oe!==null;){if(Oe.key===Te){if(Te=ne.type,Te===F){if(Oe.tag===7){a(J,Oe.sibling),V=f(Oe,ne.props.children),V.return=J,J=V;break e}}else if(Oe.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===R&&mf(Te)===Oe.type){a(J,Oe.sibling),V=f(Oe,ne.props),V.ref=ws(J,Oe,ne),V.return=J,J=V;break e}a(J,Oe);break}else r(J,Oe);Oe=Oe.sibling}ne.type===F?(V=er(ne.props.children,J.mode,Se,ne.key),V.return=J,J=V):(Se=sa(ne.type,ne.key,ne.props,null,J.mode,Se),Se.ref=ws(J,V,ne),Se.return=J,J=Se)}return x(J);case O:e:{for(Oe=ne.key;V!==null;){if(V.key===Oe)if(V.tag===4&&V.stateNode.containerInfo===ne.containerInfo&&V.stateNode.implementation===ne.implementation){a(J,V.sibling),V=f(V,ne.children||[]),V.return=J,J=V;break e}else{a(J,V);break}else r(J,V);V=V.sibling}V=Tc(ne,J.mode,Se),V.return=J,J=V}return x(J);case R:return Oe=ne._init,St(J,V,Oe(ne._payload),Se)}if(fe(ne))return Pe(J,V,ne,Se);if(q(ne))return Me(J,V,ne,Se);Bo(J,ne)}return typeof ne=="string"&&ne!==""||typeof ne=="number"?(ne=""+ne,V!==null&&V.tag===6?(a(J,V.sibling),V=f(V,ne),V.return=J,J=V):(a(J,V),V=jc(ne,J.mode,Se),V.return=J,J=V),x(J)):a(J,V)}return St}var Dr=gf(!0),vf=gf(!1),Ao=bn(null),Io=null,Mr=null,Wl=null;function Ul(){Wl=Mr=Io=null}function Kl(i){var r=Ao.current;at(Ao),i._currentValue=r}function ql(i,r,a){for(;i!==null;){var c=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),i===a)break;i=i.return}}function Lr(i,r){Io=i,Wl=Mr=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&r)!==0&&(ri=!0),i.firstContext=null)}function Ci(i){var r=i._currentValue;if(Wl!==i)if(i={context:i,memoizedValue:r,next:null},Mr===null){if(Io===null)throw Error(n(308));Mr=i,Io.dependencies={lanes:0,firstContext:i}}else Mr=Mr.next=i;return r}var Vn=null;function Vl(i){Vn===null?Vn=[i]:Vn.push(i)}function _f(i,r,a,c){var f=r.interleaved;return f===null?(a.next=a,Vl(r)):(a.next=f.next,f.next=a),r.interleaved=a,sn(i,c)}function sn(i,r){i.lanes|=r;var a=i.alternate;for(a!==null&&(a.lanes|=r),a=i,i=i.return;i!==null;)i.childLanes|=r,a=i.alternate,a!==null&&(a.childLanes|=r),a=i,i=i.return;return a.tag===3?a.stateNode:null}var kn=!1;function Yl(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function yf(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function on(i,r){return{eventTime:i,lane:r,tag:0,payload:null,callback:null,next:null}}function En(i,r,a){var c=i.updateQueue;if(c===null)return null;if(c=c.shared,(Je&2)!==0){var f=c.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),c.pending=r,sn(i,a)}return f=c.interleaved,f===null?(r.next=r,Vl(c)):(r.next=f.next,f.next=r),c.interleaved=r,sn(i,a)}function Oo(i,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194240)!==0)){var c=r.lanes;c&=i.pendingLanes,a|=c,r.lanes=a,ll(i,a)}}function Sf(i,r){var a=i.updateQueue,c=i.alternate;if(c!==null&&(c=c.updateQueue,a===c)){var f=null,g=null;if(a=a.firstBaseUpdate,a!==null){do{var x={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};g===null?f=g=x:g=g.next=x,a=a.next}while(a!==null);g===null?f=g=r:g=g.next=r}else f=g=r;a={baseState:c.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:c.shared,effects:c.effects},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=r:i.next=r,a.lastBaseUpdate=r}function zo(i,r,a,c){var f=i.updateQueue;kn=!1;var g=f.firstBaseUpdate,x=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var z=T,oe=z.next;z.next=null,x===null?g=oe:x.next=oe,x=z;var ge=i.alternate;ge!==null&&(ge=ge.updateQueue,T=ge.lastBaseUpdate,T!==x&&(T===null?ge.firstBaseUpdate=oe:T.next=oe,ge.lastBaseUpdate=z))}if(g!==null){var _e=f.baseState;x=0,ge=oe=z=null,T=g;do{var pe=T.lane,ke=T.eventTime;if((c&pe)===pe){ge!==null&&(ge=ge.next={eventTime:ke,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var Pe=i,Me=T;switch(pe=r,ke=a,Me.tag){case 1:if(Pe=Me.payload,typeof Pe=="function"){_e=Pe.call(ke,_e,pe);break e}_e=Pe;break e;case 3:Pe.flags=Pe.flags&-65537|128;case 0:if(Pe=Me.payload,pe=typeof Pe=="function"?Pe.call(ke,_e,pe):Pe,pe==null)break e;_e=X({},_e,pe);break e;case 2:kn=!0}}T.callback!==null&&T.lane!==0&&(i.flags|=64,pe=f.effects,pe===null?f.effects=[T]:pe.push(T))}else ke={eventTime:ke,lane:pe,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ge===null?(oe=ge=ke,z=_e):ge=ge.next=ke,x|=pe;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;pe=T,T=pe.next,pe.next=null,f.lastBaseUpdate=pe,f.shared.pending=null}}while(!0);if(ge===null&&(z=_e),f.baseState=z,f.firstBaseUpdate=oe,f.lastBaseUpdate=ge,r=f.shared.interleaved,r!==null){f=r;do x|=f.lane,f=f.next;while(f!==r)}else g===null&&(f.shared.lanes=0);Gn|=x,i.lanes=x,i.memoizedState=_e}}function wf(i,r,a){if(i=r.effects,r.effects=null,i!==null)for(r=0;r<i.length;r++){var c=i[r],f=c.callback;if(f!==null){if(c.callback=null,c=a,typeof f!="function")throw Error(n(191,f));f.call(c)}}}var bs={},$i=bn(bs),Cs=bn(bs),xs=bn(bs);function Yn(i){if(i===bs)throw Error(n(174));return i}function Xl(i,r){switch(st(xs,r),st(Cs,i),st($i,bs),i=r.nodeType,i){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:We(null,"");break;default:i=i===8?r.parentNode:r,r=i.namespaceURI||null,i=i.tagName,r=We(r,i)}at($i),st($i,r)}function jr(){at($i),at(Cs),at(xs)}function bf(i){Yn(xs.current);var r=Yn($i.current),a=We(r,i.type);r!==a&&(st(Cs,i),st($i,a))}function Gl(i){Cs.current===i&&(at($i),at(Cs))}var ht=bn(0);function Fo(i){for(var r=i;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||a.data==="$?"||a.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Ql=[];function Jl(){for(var i=0;i<Ql.length;i++)Ql[i]._workInProgressVersionPrimary=null;Ql.length=0}var Ho=B.ReactCurrentDispatcher,Zl=B.ReactCurrentBatchConfig,Xn=0,dt=null,Et=null,Lt=null,$o=!1,ks=!1,Es=0,fS=0;function Vt(){throw Error(n(321))}function ec(i,r){if(r===null)return!1;for(var a=0;a<r.length&&a<i.length;a++)if(!Li(i[a],r[a]))return!1;return!0}function tc(i,r,a,c,f,g){if(Xn=g,dt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Ho.current=i===null||i.memoizedState===null?vS:_S,i=a(c,f),ks){g=0;do{if(ks=!1,Es=0,25<=g)throw Error(n(301));g+=1,Lt=Et=null,r.updateQueue=null,Ho.current=yS,i=a(c,f)}while(ks)}if(Ho.current=Ko,r=Et!==null&&Et.next!==null,Xn=0,Lt=Et=dt=null,$o=!1,r)throw Error(n(300));return i}function ic(){var i=Es!==0;return Es=0,i}function Wi(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Lt===null?dt.memoizedState=Lt=i:Lt=Lt.next=i,Lt}function xi(){if(Et===null){var i=dt.alternate;i=i!==null?i.memoizedState:null}else i=Et.next;var r=Lt===null?dt.memoizedState:Lt.next;if(r!==null)Lt=r,Et=i;else{if(i===null)throw Error(n(310));Et=i,i={memoizedState:Et.memoizedState,baseState:Et.baseState,baseQueue:Et.baseQueue,queue:Et.queue,next:null},Lt===null?dt.memoizedState=Lt=i:Lt=Lt.next=i}return Lt}function Ns(i,r){return typeof r=="function"?r(i):r}function nc(i){var r=xi(),a=r.queue;if(a===null)throw Error(n(311));a.lastRenderedReducer=i;var c=Et,f=c.baseQueue,g=a.pending;if(g!==null){if(f!==null){var x=f.next;f.next=g.next,g.next=x}c.baseQueue=f=g,a.pending=null}if(f!==null){g=f.next,c=c.baseState;var T=x=null,z=null,oe=g;do{var ge=oe.lane;if((Xn&ge)===ge)z!==null&&(z=z.next={lane:0,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null}),c=oe.hasEagerState?oe.eagerState:i(c,oe.action);else{var _e={lane:ge,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null};z===null?(T=z=_e,x=c):z=z.next=_e,dt.lanes|=ge,Gn|=ge}oe=oe.next}while(oe!==null&&oe!==g);z===null?x=c:z.next=T,Li(c,r.memoizedState)||(ri=!0),r.memoizedState=c,r.baseState=x,r.baseQueue=z,a.lastRenderedState=c}if(i=a.interleaved,i!==null){f=i;do g=f.lane,dt.lanes|=g,Gn|=g,f=f.next;while(f!==i)}else f===null&&(a.lanes=0);return[r.memoizedState,a.dispatch]}function rc(i){var r=xi(),a=r.queue;if(a===null)throw Error(n(311));a.lastRenderedReducer=i;var c=a.dispatch,f=a.pending,g=r.memoizedState;if(f!==null){a.pending=null;var x=f=f.next;do g=i(g,x.action),x=x.next;while(x!==f);Li(g,r.memoizedState)||(ri=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),a.lastRenderedState=g}return[g,c]}function Cf(){}function xf(i,r){var a=dt,c=xi(),f=r(),g=!Li(c.memoizedState,f);if(g&&(c.memoizedState=f,ri=!0),c=c.queue,sc(Nf.bind(null,a,c,i),[i]),c.getSnapshot!==r||g||Lt!==null&&Lt.memoizedState.tag&1){if(a.flags|=2048,Rs(9,Ef.bind(null,a,c,f,r),void 0,null),jt===null)throw Error(n(349));(Xn&30)!==0||kf(a,r,f)}return f}function kf(i,r,a){i.flags|=16384,i={getSnapshot:r,value:a},r=dt.updateQueue,r===null?(r={lastEffect:null,stores:null},dt.updateQueue=r,r.stores=[i]):(a=r.stores,a===null?r.stores=[i]:a.push(i))}function Ef(i,r,a,c){r.value=a,r.getSnapshot=c,Rf(r)&&Pf(i)}function Nf(i,r,a){return a(function(){Rf(r)&&Pf(i)})}function Rf(i){var r=i.getSnapshot;i=i.value;try{var a=r();return!Li(i,a)}catch{return!0}}function Pf(i){var r=sn(i,1);r!==null&&Ii(r,i,1,-1)}function Df(i){var r=Wi();return typeof i=="function"&&(i=i()),r.memoizedState=r.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ns,lastRenderedState:i},r.queue=i,i=i.dispatch=gS.bind(null,dt,i),[r.memoizedState,i]}function Rs(i,r,a,c){return i={tag:i,create:r,destroy:a,deps:c,next:null},r=dt.updateQueue,r===null?(r={lastEffect:null,stores:null},dt.updateQueue=r,r.lastEffect=i.next=i):(a=r.lastEffect,a===null?r.lastEffect=i.next=i:(c=a.next,a.next=i,i.next=c,r.lastEffect=i)),i}function Mf(){return xi().memoizedState}function Wo(i,r,a,c){var f=Wi();dt.flags|=i,f.memoizedState=Rs(1|r,a,void 0,c===void 0?null:c)}function Uo(i,r,a,c){var f=xi();c=c===void 0?null:c;var g=void 0;if(Et!==null){var x=Et.memoizedState;if(g=x.destroy,c!==null&&ec(c,x.deps)){f.memoizedState=Rs(r,a,g,c);return}}dt.flags|=i,f.memoizedState=Rs(1|r,a,g,c)}function Lf(i,r){return Wo(8390656,8,i,r)}function sc(i,r){return Uo(2048,8,i,r)}function jf(i,r){return Uo(4,2,i,r)}function Tf(i,r){return Uo(4,4,i,r)}function Bf(i,r){if(typeof r=="function")return i=i(),r(i),function(){r(null)};if(r!=null)return i=i(),r.current=i,function(){r.current=null}}function Af(i,r,a){return a=a!=null?a.concat([i]):null,Uo(4,4,Bf.bind(null,r,i),a)}function oc(){}function If(i,r){var a=xi();r=r===void 0?null:r;var c=a.memoizedState;return c!==null&&r!==null&&ec(r,c[1])?c[0]:(a.memoizedState=[i,r],i)}function Of(i,r){var a=xi();r=r===void 0?null:r;var c=a.memoizedState;return c!==null&&r!==null&&ec(r,c[1])?c[0]:(i=i(),a.memoizedState=[i,r],i)}function zf(i,r,a){return(Xn&21)===0?(i.baseState&&(i.baseState=!1,ri=!0),i.memoizedState=a):(Li(a,r)||(a=pd(),dt.lanes|=a,Gn|=a,i.baseState=!0),r)}function pS(i,r){var a=it;it=a!==0&&4>a?a:4,i(!0);var c=Zl.transition;Zl.transition={};try{i(!1),r()}finally{it=a,Zl.transition=c}}function Ff(){return xi().memoizedState}function mS(i,r,a){var c=Dn(i);if(a={lane:c,action:a,hasEagerState:!1,eagerState:null,next:null},Hf(i))$f(r,a);else if(a=_f(i,r,a,c),a!==null){var f=Jt();Ii(a,i,c,f),Wf(a,r,c)}}function gS(i,r,a){var c=Dn(i),f={lane:c,action:a,hasEagerState:!1,eagerState:null,next:null};if(Hf(i))$f(r,f);else{var g=i.alternate;if(i.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var x=r.lastRenderedState,T=g(x,a);if(f.hasEagerState=!0,f.eagerState=T,Li(T,x)){var z=r.interleaved;z===null?(f.next=f,Vl(r)):(f.next=z.next,z.next=f),r.interleaved=f;return}}catch{}finally{}a=_f(i,r,f,c),a!==null&&(f=Jt(),Ii(a,i,c,f),Wf(a,r,c))}}function Hf(i){var r=i.alternate;return i===dt||r!==null&&r===dt}function $f(i,r){ks=$o=!0;var a=i.pending;a===null?r.next=r:(r.next=a.next,a.next=r),i.pending=r}function Wf(i,r,a){if((a&4194240)!==0){var c=r.lanes;c&=i.pendingLanes,a|=c,r.lanes=a,ll(i,a)}}var Ko={readContext:Ci,useCallback:Vt,useContext:Vt,useEffect:Vt,useImperativeHandle:Vt,useInsertionEffect:Vt,useLayoutEffect:Vt,useMemo:Vt,useReducer:Vt,useRef:Vt,useState:Vt,useDebugValue:Vt,useDeferredValue:Vt,useTransition:Vt,useMutableSource:Vt,useSyncExternalStore:Vt,useId:Vt,unstable_isNewReconciler:!1},vS={readContext:Ci,useCallback:function(i,r){return Wi().memoizedState=[i,r===void 0?null:r],i},useContext:Ci,useEffect:Lf,useImperativeHandle:function(i,r,a){return a=a!=null?a.concat([i]):null,Wo(4194308,4,Bf.bind(null,r,i),a)},useLayoutEffect:function(i,r){return Wo(4194308,4,i,r)},useInsertionEffect:function(i,r){return Wo(4,2,i,r)},useMemo:function(i,r){var a=Wi();return r=r===void 0?null:r,i=i(),a.memoizedState=[i,r],i},useReducer:function(i,r,a){var c=Wi();return r=a!==void 0?a(r):r,c.memoizedState=c.baseState=r,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:r},c.queue=i,i=i.dispatch=mS.bind(null,dt,i),[c.memoizedState,i]},useRef:function(i){var r=Wi();return i={current:i},r.memoizedState=i},useState:Df,useDebugValue:oc,useDeferredValue:function(i){return Wi().memoizedState=i},useTransition:function(){var i=Df(!1),r=i[0];return i=pS.bind(null,i[1]),Wi().memoizedState=i,[r,i]},useMutableSource:function(){},useSyncExternalStore:function(i,r,a){var c=dt,f=Wi();if(ct){if(a===void 0)throw Error(n(407));a=a()}else{if(a=r(),jt===null)throw Error(n(349));(Xn&30)!==0||kf(c,r,a)}f.memoizedState=a;var g={value:a,getSnapshot:r};return f.queue=g,Lf(Nf.bind(null,c,g,i),[i]),c.flags|=2048,Rs(9,Ef.bind(null,c,g,a,r),void 0,null),a},useId:function(){var i=Wi(),r=jt.identifierPrefix;if(ct){var a=rn,c=nn;a=(c&~(1<<32-Mi(c)-1)).toString(32)+a,r=":"+r+"R"+a,a=Es++,0<a&&(r+="H"+a.toString(32)),r+=":"}else a=fS++,r=":"+r+"r"+a.toString(32)+":";return i.memoizedState=r},unstable_isNewReconciler:!1},_S={readContext:Ci,useCallback:If,useContext:Ci,useEffect:sc,useImperativeHandle:Af,useInsertionEffect:jf,useLayoutEffect:Tf,useMemo:Of,useReducer:nc,useRef:Mf,useState:function(){return nc(Ns)},useDebugValue:oc,useDeferredValue:function(i){var r=xi();return zf(r,Et.memoizedState,i)},useTransition:function(){var i=nc(Ns)[0],r=xi().memoizedState;return[i,r]},useMutableSource:Cf,useSyncExternalStore:xf,useId:Ff,unstable_isNewReconciler:!1},yS={readContext:Ci,useCallback:If,useContext:Ci,useEffect:sc,useImperativeHandle:Af,useInsertionEffect:jf,useLayoutEffect:Tf,useMemo:Of,useReducer:rc,useRef:Mf,useState:function(){return rc(Ns)},useDebugValue:oc,useDeferredValue:function(i){var r=xi();return Et===null?r.memoizedState=i:zf(r,Et.memoizedState,i)},useTransition:function(){var i=rc(Ns)[0],r=xi().memoizedState;return[i,r]},useMutableSource:Cf,useSyncExternalStore:xf,useId:Ff,unstable_isNewReconciler:!1};function Ti(i,r){if(i&&i.defaultProps){r=X({},r),i=i.defaultProps;for(var a in i)r[a]===void 0&&(r[a]=i[a]);return r}return r}function ac(i,r,a,c){r=i.memoizedState,a=a(c,r),a=a==null?r:X({},r,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var qo={isMounted:function(i){return(i=i._reactInternals)?$n(i)===i:!1},enqueueSetState:function(i,r,a){i=i._reactInternals;var c=Jt(),f=Dn(i),g=on(c,f);g.payload=r,a!=null&&(g.callback=a),r=En(i,g,f),r!==null&&(Ii(r,i,f,c),Oo(r,i,f))},enqueueReplaceState:function(i,r,a){i=i._reactInternals;var c=Jt(),f=Dn(i),g=on(c,f);g.tag=1,g.payload=r,a!=null&&(g.callback=a),r=En(i,g,f),r!==null&&(Ii(r,i,f,c),Oo(r,i,f))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var a=Jt(),c=Dn(i),f=on(a,c);f.tag=2,r!=null&&(f.callback=r),r=En(i,f,c),r!==null&&(Ii(r,i,c,a),Oo(r,i,c))}};function Uf(i,r,a,c,f,g,x){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(c,g,x):r.prototype&&r.prototype.isPureReactComponent?!ps(a,c)||!ps(f,g):!0}function Kf(i,r,a){var c=!1,f=Cn,g=r.contextType;return typeof g=="object"&&g!==null?g=Ci(g):(f=ni(r)?Un:qt.current,c=r.contextTypes,g=(c=c!=null)?Er(i,f):Cn),r=new r(a,g),i.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=qo,i.stateNode=r,r._reactInternals=i,c&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=f,i.__reactInternalMemoizedMaskedChildContext=g),r}function qf(i,r,a,c){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,c),r.state!==i&&qo.enqueueReplaceState(r,r.state,null)}function lc(i,r,a,c){var f=i.stateNode;f.props=a,f.state=i.memoizedState,f.refs={},Yl(i);var g=r.contextType;typeof g=="object"&&g!==null?f.context=Ci(g):(g=ni(r)?Un:qt.current,f.context=Er(i,g)),f.state=i.memoizedState,g=r.getDerivedStateFromProps,typeof g=="function"&&(ac(i,r,g,a),f.state=i.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(r=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),r!==f.state&&qo.enqueueReplaceState(f,f.state,null),zo(i,a,f,c),f.state=i.memoizedState),typeof f.componentDidMount=="function"&&(i.flags|=4194308)}function Tr(i,r){try{var a="",c=r;do a+=ae(c),c=c.return;while(c);var f=a}catch(g){f=`
|
|
39
|
-
Error generating stack: `+g.message+`
|
|
40
|
-
`+g.stack}return{value:i,source:r,stack:f,digest:null}}function cc(i,r,a){return{value:i,source:null,stack:a??null,digest:r??null}}function uc(i,r){try{console.error(r.value)}catch(a){setTimeout(function(){throw a})}}var SS=typeof WeakMap=="function"?WeakMap:Map;function Vf(i,r,a){a=on(-1,a),a.tag=3,a.payload={element:null};var c=r.value;return a.callback=function(){Zo||(Zo=!0,kc=c),uc(i,r)},a}function Yf(i,r,a){a=on(-1,a),a.tag=3;var c=i.type.getDerivedStateFromError;if(typeof c=="function"){var f=r.value;a.payload=function(){return c(f)},a.callback=function(){uc(i,r)}}var g=i.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(a.callback=function(){uc(i,r),typeof c!="function"&&(Rn===null?Rn=new Set([this]):Rn.add(this));var x=r.stack;this.componentDidCatch(r.value,{componentStack:x!==null?x:""})}),a}function Xf(i,r,a){var c=i.pingCache;if(c===null){c=i.pingCache=new SS;var f=new Set;c.set(r,f)}else f=c.get(r),f===void 0&&(f=new Set,c.set(r,f));f.has(a)||(f.add(a),i=TS.bind(null,i,r,a),r.then(i,i))}function Gf(i){do{var r;if((r=i.tag===13)&&(r=i.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return i;i=i.return}while(i!==null);return null}function Qf(i,r,a,c,f){return(i.mode&1)===0?(i===r?i.flags|=65536:(i.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(r=on(-1,1),r.tag=2,En(a,r,1))),a.lanes|=1),i):(i.flags|=65536,i.lanes=f,i)}var wS=B.ReactCurrentOwner,ri=!1;function Qt(i,r,a,c){r.child=i===null?vf(r,null,a,c):Dr(r,i.child,a,c)}function Jf(i,r,a,c,f){a=a.render;var g=r.ref;return Lr(r,f),c=tc(i,r,a,c,g,f),a=ic(),i!==null&&!ri?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~f,an(i,r,f)):(ct&&a&&Ol(r),r.flags|=1,Qt(i,r,c,f),r.child)}function Zf(i,r,a,c,f){if(i===null){var g=a.type;return typeof g=="function"&&!Lc(g)&&g.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(r.tag=15,r.type=g,ep(i,r,g,c,f)):(i=sa(a.type,null,c,r,r.mode,f),i.ref=r.ref,i.return=r,r.child=i)}if(g=i.child,(i.lanes&f)===0){var x=g.memoizedProps;if(a=a.compare,a=a!==null?a:ps,a(x,c)&&i.ref===r.ref)return an(i,r,f)}return r.flags|=1,i=Ln(g,c),i.ref=r.ref,i.return=r,r.child=i}function ep(i,r,a,c,f){if(i!==null){var g=i.memoizedProps;if(ps(g,c)&&i.ref===r.ref)if(ri=!1,r.pendingProps=c=g,(i.lanes&f)!==0)(i.flags&131072)!==0&&(ri=!0);else return r.lanes=i.lanes,an(i,r,f)}return hc(i,r,a,c,f)}function tp(i,r,a){var c=r.pendingProps,f=c.children,g=i!==null?i.memoizedState:null;if(c.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},st(Ar,mi),mi|=a;else{if((a&1073741824)===0)return i=g!==null?g.baseLanes|a:a,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:i,cachePool:null,transitions:null},r.updateQueue=null,st(Ar,mi),mi|=i,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=g!==null?g.baseLanes:a,st(Ar,mi),mi|=c}else g!==null?(c=g.baseLanes|a,r.memoizedState=null):c=a,st(Ar,mi),mi|=c;return Qt(i,r,f,a),r.child}function ip(i,r){var a=r.ref;(i===null&&a!==null||i!==null&&i.ref!==a)&&(r.flags|=512,r.flags|=2097152)}function hc(i,r,a,c,f){var g=ni(a)?Un:qt.current;return g=Er(r,g),Lr(r,f),a=tc(i,r,a,c,g,f),c=ic(),i!==null&&!ri?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~f,an(i,r,f)):(ct&&c&&Ol(r),r.flags|=1,Qt(i,r,a,f),r.child)}function np(i,r,a,c,f){if(ni(a)){var g=!0;Do(r)}else g=!1;if(Lr(r,f),r.stateNode===null)Yo(i,r),Kf(r,a,c),lc(r,a,c,f),c=!0;else if(i===null){var x=r.stateNode,T=r.memoizedProps;x.props=T;var z=x.context,oe=a.contextType;typeof oe=="object"&&oe!==null?oe=Ci(oe):(oe=ni(a)?Un:qt.current,oe=Er(r,oe));var ge=a.getDerivedStateFromProps,_e=typeof ge=="function"||typeof x.getSnapshotBeforeUpdate=="function";_e||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(T!==c||z!==oe)&&qf(r,x,c,oe),kn=!1;var pe=r.memoizedState;x.state=pe,zo(r,c,x,f),z=r.memoizedState,T!==c||pe!==z||ii.current||kn?(typeof ge=="function"&&(ac(r,a,ge,c),z=r.memoizedState),(T=kn||Uf(r,a,T,c,pe,z,oe))?(_e||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(r.flags|=4194308)):(typeof x.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=z),x.props=c,x.state=z,x.context=oe,c=T):(typeof x.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{x=r.stateNode,yf(i,r),T=r.memoizedProps,oe=r.type===r.elementType?T:Ti(r.type,T),x.props=oe,_e=r.pendingProps,pe=x.context,z=a.contextType,typeof z=="object"&&z!==null?z=Ci(z):(z=ni(a)?Un:qt.current,z=Er(r,z));var ke=a.getDerivedStateFromProps;(ge=typeof ke=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(T!==_e||pe!==z)&&qf(r,x,c,z),kn=!1,pe=r.memoizedState,x.state=pe,zo(r,c,x,f);var Pe=r.memoizedState;T!==_e||pe!==Pe||ii.current||kn?(typeof ke=="function"&&(ac(r,a,ke,c),Pe=r.memoizedState),(oe=kn||Uf(r,a,oe,c,pe,Pe,z)||!1)?(ge||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(c,Pe,z),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(c,Pe,z)),typeof x.componentDidUpdate=="function"&&(r.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof x.componentDidUpdate!="function"||T===i.memoizedProps&&pe===i.memoizedState||(r.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||T===i.memoizedProps&&pe===i.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=Pe),x.props=c,x.state=Pe,x.context=z,c=oe):(typeof x.componentDidUpdate!="function"||T===i.memoizedProps&&pe===i.memoizedState||(r.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||T===i.memoizedProps&&pe===i.memoizedState||(r.flags|=1024),c=!1)}return dc(i,r,a,c,g,f)}function dc(i,r,a,c,f,g){ip(i,r);var x=(r.flags&128)!==0;if(!c&&!x)return f&&lf(r,a,!1),an(i,r,g);c=r.stateNode,wS.current=r;var T=x&&typeof a.getDerivedStateFromError!="function"?null:c.render();return r.flags|=1,i!==null&&x?(r.child=Dr(r,i.child,null,g),r.child=Dr(r,null,T,g)):Qt(i,r,T,g),r.memoizedState=c.state,f&&lf(r,a,!0),r.child}function rp(i){var r=i.stateNode;r.pendingContext?of(i,r.pendingContext,r.pendingContext!==r.context):r.context&&of(i,r.context,!1),Xl(i,r.containerInfo)}function sp(i,r,a,c,f){return Pr(),$l(f),r.flags|=256,Qt(i,r,a,c),r.child}var fc={dehydrated:null,treeContext:null,retryLane:0};function pc(i){return{baseLanes:i,cachePool:null,transitions:null}}function op(i,r,a){var c=r.pendingProps,f=ht.current,g=!1,x=(r.flags&128)!==0,T;if((T=x)||(T=i!==null&&i.memoizedState===null?!1:(f&2)!==0),T?(g=!0,r.flags&=-129):(i===null||i.memoizedState!==null)&&(f|=1),st(ht,f&1),i===null)return Hl(r),i=r.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((r.mode&1)===0?r.lanes=1:i.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(x=c.children,i=c.fallback,g?(c=r.mode,g=r.child,x={mode:"hidden",children:x},(c&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=x):g=oa(x,c,0,null),i=er(i,c,a,null),g.return=r,i.return=r,g.sibling=i,r.child=g,r.child.memoizedState=pc(a),r.memoizedState=fc,i):mc(r,x));if(f=i.memoizedState,f!==null&&(T=f.dehydrated,T!==null))return bS(i,r,x,c,T,f,a);if(g){g=c.fallback,x=r.mode,f=i.child,T=f.sibling;var z={mode:"hidden",children:c.children};return(x&1)===0&&r.child!==f?(c=r.child,c.childLanes=0,c.pendingProps=z,r.deletions=null):(c=Ln(f,z),c.subtreeFlags=f.subtreeFlags&14680064),T!==null?g=Ln(T,g):(g=er(g,x,a,null),g.flags|=2),g.return=r,c.return=r,c.sibling=g,r.child=c,c=g,g=r.child,x=i.child.memoizedState,x=x===null?pc(a):{baseLanes:x.baseLanes|a,cachePool:null,transitions:x.transitions},g.memoizedState=x,g.childLanes=i.childLanes&~a,r.memoizedState=fc,c}return g=i.child,i=g.sibling,c=Ln(g,{mode:"visible",children:c.children}),(r.mode&1)===0&&(c.lanes=a),c.return=r,c.sibling=null,i!==null&&(a=r.deletions,a===null?(r.deletions=[i],r.flags|=16):a.push(i)),r.child=c,r.memoizedState=null,c}function mc(i,r){return r=oa({mode:"visible",children:r},i.mode,0,null),r.return=i,i.child=r}function Vo(i,r,a,c){return c!==null&&$l(c),Dr(r,i.child,null,a),i=mc(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function bS(i,r,a,c,f,g,x){if(a)return r.flags&256?(r.flags&=-257,c=cc(Error(n(422))),Vo(i,r,x,c)):r.memoizedState!==null?(r.child=i.child,r.flags|=128,null):(g=c.fallback,f=r.mode,c=oa({mode:"visible",children:c.children},f,0,null),g=er(g,f,x,null),g.flags|=2,c.return=r,g.return=r,c.sibling=g,r.child=c,(r.mode&1)!==0&&Dr(r,i.child,null,x),r.child.memoizedState=pc(x),r.memoizedState=fc,g);if((r.mode&1)===0)return Vo(i,r,x,null);if(f.data==="$!"){if(c=f.nextSibling&&f.nextSibling.dataset,c)var T=c.dgst;return c=T,g=Error(n(419)),c=cc(g,c,void 0),Vo(i,r,x,c)}if(T=(x&i.childLanes)!==0,ri||T){if(c=jt,c!==null){switch(x&-x){case 4:f=2;break;case 16:f=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:f=32;break;case 536870912:f=268435456;break;default:f=0}f=(f&(c.suspendedLanes|x))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,sn(i,f),Ii(c,i,f,-1))}return Mc(),c=cc(Error(n(421))),Vo(i,r,x,c)}return f.data==="$?"?(r.flags|=128,r.child=i.child,r=BS.bind(null,i),f._reactRetry=r,null):(i=g.treeContext,pi=wn(f.nextSibling),fi=r,ct=!0,ji=null,i!==null&&(wi[bi++]=nn,wi[bi++]=rn,wi[bi++]=Kn,nn=i.id,rn=i.overflow,Kn=r),r=mc(r,c.children),r.flags|=4096,r)}function ap(i,r,a){i.lanes|=r;var c=i.alternate;c!==null&&(c.lanes|=r),ql(i.return,r,a)}function gc(i,r,a,c,f){var g=i.memoizedState;g===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:a,tailMode:f}:(g.isBackwards=r,g.rendering=null,g.renderingStartTime=0,g.last=c,g.tail=a,g.tailMode=f)}function lp(i,r,a){var c=r.pendingProps,f=c.revealOrder,g=c.tail;if(Qt(i,r,c.children,a),c=ht.current,(c&2)!==0)c=c&1|2,r.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&ap(i,a,r);else if(i.tag===19)ap(i,a,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}c&=1}if(st(ht,c),(r.mode&1)===0)r.memoizedState=null;else switch(f){case"forwards":for(a=r.child,f=null;a!==null;)i=a.alternate,i!==null&&Fo(i)===null&&(f=a),a=a.sibling;a=f,a===null?(f=r.child,r.child=null):(f=a.sibling,a.sibling=null),gc(r,!1,f,a,g);break;case"backwards":for(a=null,f=r.child,r.child=null;f!==null;){if(i=f.alternate,i!==null&&Fo(i)===null){r.child=f;break}i=f.sibling,f.sibling=a,a=f,f=i}gc(r,!0,a,null,g);break;case"together":gc(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function Yo(i,r){(r.mode&1)===0&&i!==null&&(i.alternate=null,r.alternate=null,r.flags|=2)}function an(i,r,a){if(i!==null&&(r.dependencies=i.dependencies),Gn|=r.lanes,(a&r.childLanes)===0)return null;if(i!==null&&r.child!==i.child)throw Error(n(153));if(r.child!==null){for(i=r.child,a=Ln(i,i.pendingProps),r.child=a,a.return=r;i.sibling!==null;)i=i.sibling,a=a.sibling=Ln(i,i.pendingProps),a.return=r;a.sibling=null}return r.child}function CS(i,r,a){switch(r.tag){case 3:rp(r),Pr();break;case 5:bf(r);break;case 1:ni(r.type)&&Do(r);break;case 4:Xl(r,r.stateNode.containerInfo);break;case 10:var c=r.type._context,f=r.memoizedProps.value;st(Ao,c._currentValue),c._currentValue=f;break;case 13:if(c=r.memoizedState,c!==null)return c.dehydrated!==null?(st(ht,ht.current&1),r.flags|=128,null):(a&r.child.childLanes)!==0?op(i,r,a):(st(ht,ht.current&1),i=an(i,r,a),i!==null?i.sibling:null);st(ht,ht.current&1);break;case 19:if(c=(a&r.childLanes)!==0,(i.flags&128)!==0){if(c)return lp(i,r,a);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),st(ht,ht.current),c)break;return null;case 22:case 23:return r.lanes=0,tp(i,r,a)}return an(i,r,a)}var cp,vc,up,hp;cp=function(i,r){for(var a=r.child;a!==null;){if(a.tag===5||a.tag===6)i.appendChild(a.stateNode);else if(a.tag!==4&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return;a=a.return}a.sibling.return=a.return,a=a.sibling}},vc=function(){},up=function(i,r,a,c){var f=i.memoizedProps;if(f!==c){i=r.stateNode,Yn($i.current);var g=null;switch(a){case"input":f=Le(i,f),c=Le(i,c),g=[];break;case"select":f=X({},f,{value:void 0}),c=X({},c,{value:void 0}),g=[];break;case"textarea":f=Ee(i,f),c=Ee(i,c),g=[];break;default:typeof f.onClick!="function"&&typeof c.onClick=="function"&&(i.onclick=No)}Ke(a,c);var x;a=null;for(oe in f)if(!c.hasOwnProperty(oe)&&f.hasOwnProperty(oe)&&f[oe]!=null)if(oe==="style"){var T=f[oe];for(x in T)T.hasOwnProperty(x)&&(a||(a={}),a[x]="")}else oe!=="dangerouslySetInnerHTML"&&oe!=="children"&&oe!=="suppressContentEditableWarning"&&oe!=="suppressHydrationWarning"&&oe!=="autoFocus"&&(o.hasOwnProperty(oe)?g||(g=[]):(g=g||[]).push(oe,null));for(oe in c){var z=c[oe];if(T=f!=null?f[oe]:void 0,c.hasOwnProperty(oe)&&z!==T&&(z!=null||T!=null))if(oe==="style")if(T){for(x in T)!T.hasOwnProperty(x)||z&&z.hasOwnProperty(x)||(a||(a={}),a[x]="");for(x in z)z.hasOwnProperty(x)&&T[x]!==z[x]&&(a||(a={}),a[x]=z[x])}else a||(g||(g=[]),g.push(oe,a)),a=z;else oe==="dangerouslySetInnerHTML"?(z=z?z.__html:void 0,T=T?T.__html:void 0,z!=null&&T!==z&&(g=g||[]).push(oe,z)):oe==="children"?typeof z!="string"&&typeof z!="number"||(g=g||[]).push(oe,""+z):oe!=="suppressContentEditableWarning"&&oe!=="suppressHydrationWarning"&&(o.hasOwnProperty(oe)?(z!=null&&oe==="onScroll"&&ot("scroll",i),g||T===z||(g=[])):(g=g||[]).push(oe,z))}a&&(g=g||[]).push("style",a);var oe=g;(r.updateQueue=oe)&&(r.flags|=4)}},hp=function(i,r,a,c){a!==c&&(r.flags|=4)};function Ps(i,r){if(!ct)switch(i.tailMode){case"hidden":r=i.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var c=null;a!==null;)a.alternate!==null&&(c=a),a=a.sibling;c===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:c.sibling=null}}function Yt(i){var r=i.alternate!==null&&i.alternate.child===i.child,a=0,c=0;if(r)for(var f=i.child;f!==null;)a|=f.lanes|f.childLanes,c|=f.subtreeFlags&14680064,c|=f.flags&14680064,f.return=i,f=f.sibling;else for(f=i.child;f!==null;)a|=f.lanes|f.childLanes,c|=f.subtreeFlags,c|=f.flags,f.return=i,f=f.sibling;return i.subtreeFlags|=c,i.childLanes=a,r}function xS(i,r,a){var c=r.pendingProps;switch(zl(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Yt(r),null;case 1:return ni(r.type)&&Po(),Yt(r),null;case 3:return c=r.stateNode,jr(),at(ii),at(qt),Jl(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(i===null||i.child===null)&&(To(r)?r.flags|=4:i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,ji!==null&&(Rc(ji),ji=null))),vc(i,r),Yt(r),null;case 5:Gl(r);var f=Yn(xs.current);if(a=r.type,i!==null&&r.stateNode!=null)up(i,r,a,c,f),i.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!c){if(r.stateNode===null)throw Error(n(166));return Yt(r),null}if(i=Yn($i.current),To(r)){c=r.stateNode,a=r.type;var g=r.memoizedProps;switch(c[Hi]=r,c[ys]=g,i=(r.mode&1)!==0,a){case"dialog":ot("cancel",c),ot("close",c);break;case"iframe":case"object":case"embed":ot("load",c);break;case"video":case"audio":for(f=0;f<gs.length;f++)ot(gs[f],c);break;case"source":ot("error",c);break;case"img":case"image":case"link":ot("error",c),ot("load",c);break;case"details":ot("toggle",c);break;case"input":je(c,g),ot("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!g.multiple},ot("invalid",c);break;case"textarea":Ae(c,g),ot("invalid",c)}Ke(a,g),f=null;for(var x in g)if(g.hasOwnProperty(x)){var T=g[x];x==="children"?typeof T=="string"?c.textContent!==T&&(g.suppressHydrationWarning!==!0&&Eo(c.textContent,T,i),f=["children",T]):typeof T=="number"&&c.textContent!==""+T&&(g.suppressHydrationWarning!==!0&&Eo(c.textContent,T,i),f=["children",""+T]):o.hasOwnProperty(x)&&T!=null&&x==="onScroll"&&ot("scroll",c)}switch(a){case"input":te(c),we(c,g,!0);break;case"textarea":te(c),rt(c);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(c.onclick=No)}c=f,r.updateQueue=c,c!==null&&(r.flags|=4)}else{x=f.nodeType===9?f:f.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=Be(a)),i==="http://www.w3.org/1999/xhtml"?a==="script"?(i=x.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof c.is=="string"?i=x.createElement(a,{is:c.is}):(i=x.createElement(a),a==="select"&&(x=i,c.multiple?x.multiple=!0:c.size&&(x.size=c.size))):i=x.createElementNS(i,a),i[Hi]=r,i[ys]=c,cp(i,r,!1,!1),r.stateNode=i;e:{switch(x=Mt(a,c),a){case"dialog":ot("cancel",i),ot("close",i),f=c;break;case"iframe":case"object":case"embed":ot("load",i),f=c;break;case"video":case"audio":for(f=0;f<gs.length;f++)ot(gs[f],i);f=c;break;case"source":ot("error",i),f=c;break;case"img":case"image":case"link":ot("error",i),ot("load",i),f=c;break;case"details":ot("toggle",i),f=c;break;case"input":je(i,c),f=Le(i,c),ot("invalid",i);break;case"option":f=c;break;case"select":i._wrapperState={wasMultiple:!!c.multiple},f=X({},c,{value:void 0}),ot("invalid",i);break;case"textarea":Ae(i,c),f=Ee(i,c),ot("invalid",i);break;default:f=c}Ke(a,f),T=f;for(g in T)if(T.hasOwnProperty(g)){var z=T[g];g==="style"?ce(i,z):g==="dangerouslySetInnerHTML"?(z=z?z.__html:void 0,z!=null&&bt(i,z)):g==="children"?typeof z=="string"?(a!=="textarea"||z!=="")&&Ge(i,z):typeof z=="number"&&Ge(i,""+z):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(o.hasOwnProperty(g)?z!=null&&g==="onScroll"&&ot("scroll",i):z!=null&&A(i,g,z,x))}switch(a){case"input":te(i),we(i,c,!1);break;case"textarea":te(i),rt(i);break;case"option":c.value!=null&&i.setAttribute("value",""+ve(c.value));break;case"select":i.multiple=!!c.multiple,g=c.value,g!=null?Ce(i,!!c.multiple,g,!1):c.defaultValue!=null&&Ce(i,!!c.multiple,c.defaultValue,!0);break;default:typeof f.onClick=="function"&&(i.onclick=No)}switch(a){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return Yt(r),null;case 6:if(i&&r.stateNode!=null)hp(i,r,i.memoizedProps,c);else{if(typeof c!="string"&&r.stateNode===null)throw Error(n(166));if(a=Yn(xs.current),Yn($i.current),To(r)){if(c=r.stateNode,a=r.memoizedProps,c[Hi]=r,(g=c.nodeValue!==a)&&(i=fi,i!==null))switch(i.tag){case 3:Eo(c.nodeValue,a,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Eo(c.nodeValue,a,(i.mode&1)!==0)}g&&(r.flags|=4)}else c=(a.nodeType===9?a:a.ownerDocument).createTextNode(c),c[Hi]=r,r.stateNode=c}return Yt(r),null;case 13:if(at(ht),c=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(ct&&pi!==null&&(r.mode&1)!==0&&(r.flags&128)===0)pf(),Pr(),r.flags|=98560,g=!1;else if(g=To(r),c!==null&&c.dehydrated!==null){if(i===null){if(!g)throw Error(n(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(n(317));g[Hi]=r}else Pr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Yt(r),g=!1}else ji!==null&&(Rc(ji),ji=null),g=!0;if(!g)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=a,r):(c=c!==null,c!==(i!==null&&i.memoizedState!==null)&&c&&(r.child.flags|=8192,(r.mode&1)!==0&&(i===null||(ht.current&1)!==0?Nt===0&&(Nt=3):Mc())),r.updateQueue!==null&&(r.flags|=4),Yt(r),null);case 4:return jr(),vc(i,r),i===null&&vs(r.stateNode.containerInfo),Yt(r),null;case 10:return Kl(r.type._context),Yt(r),null;case 17:return ni(r.type)&&Po(),Yt(r),null;case 19:if(at(ht),g=r.memoizedState,g===null)return Yt(r),null;if(c=(r.flags&128)!==0,x=g.rendering,x===null)if(c)Ps(g,!1);else{if(Nt!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(x=Fo(i),x!==null){for(r.flags|=128,Ps(g,!1),c=x.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),r.subtreeFlags=0,c=a,a=r.child;a!==null;)g=a,i=c,g.flags&=14680066,x=g.alternate,x===null?(g.childLanes=0,g.lanes=i,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=x.childLanes,g.lanes=x.lanes,g.child=x.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=x.memoizedProps,g.memoizedState=x.memoizedState,g.updateQueue=x.updateQueue,g.type=x.type,i=x.dependencies,g.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),a=a.sibling;return st(ht,ht.current&1|2),r.child}i=i.sibling}g.tail!==null&&yt()>Ir&&(r.flags|=128,c=!0,Ps(g,!1),r.lanes=4194304)}else{if(!c)if(i=Fo(x),i!==null){if(r.flags|=128,c=!0,a=i.updateQueue,a!==null&&(r.updateQueue=a,r.flags|=4),Ps(g,!0),g.tail===null&&g.tailMode==="hidden"&&!x.alternate&&!ct)return Yt(r),null}else 2*yt()-g.renderingStartTime>Ir&&a!==1073741824&&(r.flags|=128,c=!0,Ps(g,!1),r.lanes=4194304);g.isBackwards?(x.sibling=r.child,r.child=x):(a=g.last,a!==null?a.sibling=x:r.child=x,g.last=x)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=yt(),r.sibling=null,a=ht.current,st(ht,c?a&1|2:a&1),r):(Yt(r),null);case 22:case 23:return Dc(),c=r.memoizedState!==null,i!==null&&i.memoizedState!==null!==c&&(r.flags|=8192),c&&(r.mode&1)!==0?(mi&1073741824)!==0&&(Yt(r),r.subtreeFlags&6&&(r.flags|=8192)):Yt(r),null;case 24:return null;case 25:return null}throw Error(n(156,r.tag))}function kS(i,r){switch(zl(r),r.tag){case 1:return ni(r.type)&&Po(),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return jr(),at(ii),at(qt),Jl(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 5:return Gl(r),null;case 13:if(at(ht),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(n(340));Pr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return at(ht),null;case 4:return jr(),null;case 10:return Kl(r.type._context),null;case 22:case 23:return Dc(),null;case 24:return null;default:return null}}var Xo=!1,Xt=!1,ES=typeof WeakSet=="function"?WeakSet:Set,Ne=null;function Br(i,r){var a=i.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(c){gt(i,r,c)}else a.current=null}function _c(i,r,a){try{a()}catch(c){gt(i,r,c)}}var dp=!1;function NS(i,r){if(Dl=mo,i=Wd(),bl(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var c=a.getSelection&&a.getSelection();if(c&&c.rangeCount!==0){a=c.anchorNode;var f=c.anchorOffset,g=c.focusNode;c=c.focusOffset;try{a.nodeType,g.nodeType}catch{a=null;break e}var x=0,T=-1,z=-1,oe=0,ge=0,_e=i,pe=null;t:for(;;){for(var ke;_e!==a||f!==0&&_e.nodeType!==3||(T=x+f),_e!==g||c!==0&&_e.nodeType!==3||(z=x+c),_e.nodeType===3&&(x+=_e.nodeValue.length),(ke=_e.firstChild)!==null;)pe=_e,_e=ke;for(;;){if(_e===i)break t;if(pe===a&&++oe===f&&(T=x),pe===g&&++ge===c&&(z=x),(ke=_e.nextSibling)!==null)break;_e=pe,pe=_e.parentNode}_e=ke}a=T===-1||z===-1?null:{start:T,end:z}}else a=null}a=a||{start:0,end:0}}else a=null;for(Ml={focusedElem:i,selectionRange:a},mo=!1,Ne=r;Ne!==null;)if(r=Ne,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Ne=i;else for(;Ne!==null;){r=Ne;try{var Pe=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Pe!==null){var Me=Pe.memoizedProps,St=Pe.memoizedState,J=r.stateNode,V=J.getSnapshotBeforeUpdate(r.elementType===r.type?Me:Ti(r.type,Me),St);J.__reactInternalSnapshotBeforeUpdate=V}break;case 3:var ne=r.stateNode.containerInfo;ne.nodeType===1?ne.textContent="":ne.nodeType===9&&ne.documentElement&&ne.removeChild(ne.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Se){gt(r,r.return,Se)}if(i=r.sibling,i!==null){i.return=r.return,Ne=i;break}Ne=r.return}return Pe=dp,dp=!1,Pe}function Ds(i,r,a){var c=r.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var f=c=c.next;do{if((f.tag&i)===i){var g=f.destroy;f.destroy=void 0,g!==void 0&&_c(r,a,g)}f=f.next}while(f!==c)}}function Go(i,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var a=r=r.next;do{if((a.tag&i)===i){var c=a.create;a.destroy=c()}a=a.next}while(a!==r)}}function yc(i){var r=i.ref;if(r!==null){var a=i.stateNode;switch(i.tag){case 5:i=a;break;default:i=a}typeof r=="function"?r(i):r.current=i}}function fp(i){var r=i.alternate;r!==null&&(i.alternate=null,fp(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&(delete r[Hi],delete r[ys],delete r[Bl],delete r[cS],delete r[uS])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function pp(i){return i.tag===5||i.tag===3||i.tag===4}function mp(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||pp(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function Sc(i,r,a){var c=i.tag;if(c===5||c===6)i=i.stateNode,r?a.nodeType===8?a.parentNode.insertBefore(i,r):a.insertBefore(i,r):(a.nodeType===8?(r=a.parentNode,r.insertBefore(i,a)):(r=a,r.appendChild(i)),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=No));else if(c!==4&&(i=i.child,i!==null))for(Sc(i,r,a),i=i.sibling;i!==null;)Sc(i,r,a),i=i.sibling}function wc(i,r,a){var c=i.tag;if(c===5||c===6)i=i.stateNode,r?a.insertBefore(i,r):a.appendChild(i);else if(c!==4&&(i=i.child,i!==null))for(wc(i,r,a),i=i.sibling;i!==null;)wc(i,r,a),i=i.sibling}var Ht=null,Bi=!1;function Nn(i,r,a){for(a=a.child;a!==null;)gp(i,r,a),a=a.sibling}function gp(i,r,a){if(Fi&&typeof Fi.onCommitFiberUnmount=="function")try{Fi.onCommitFiberUnmount(lo,a)}catch{}switch(a.tag){case 5:Xt||Br(a,r);case 6:var c=Ht,f=Bi;Ht=null,Nn(i,r,a),Ht=c,Bi=f,Ht!==null&&(Bi?(i=Ht,a=a.stateNode,i.nodeType===8?i.parentNode.removeChild(a):i.removeChild(a)):Ht.removeChild(a.stateNode));break;case 18:Ht!==null&&(Bi?(i=Ht,a=a.stateNode,i.nodeType===8?Tl(i.parentNode,a):i.nodeType===1&&Tl(i,a),ls(i)):Tl(Ht,a.stateNode));break;case 4:c=Ht,f=Bi,Ht=a.stateNode.containerInfo,Bi=!0,Nn(i,r,a),Ht=c,Bi=f;break;case 0:case 11:case 14:case 15:if(!Xt&&(c=a.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){f=c=c.next;do{var g=f,x=g.destroy;g=g.tag,x!==void 0&&((g&2)!==0||(g&4)!==0)&&_c(a,r,x),f=f.next}while(f!==c)}Nn(i,r,a);break;case 1:if(!Xt&&(Br(a,r),c=a.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=a.memoizedProps,c.state=a.memoizedState,c.componentWillUnmount()}catch(T){gt(a,r,T)}Nn(i,r,a);break;case 21:Nn(i,r,a);break;case 22:a.mode&1?(Xt=(c=Xt)||a.memoizedState!==null,Nn(i,r,a),Xt=c):Nn(i,r,a);break;default:Nn(i,r,a)}}function vp(i){var r=i.updateQueue;if(r!==null){i.updateQueue=null;var a=i.stateNode;a===null&&(a=i.stateNode=new ES),r.forEach(function(c){var f=AS.bind(null,i,c);a.has(c)||(a.add(c),c.then(f,f))})}}function Ai(i,r){var a=r.deletions;if(a!==null)for(var c=0;c<a.length;c++){var f=a[c];try{var g=i,x=r,T=x;e:for(;T!==null;){switch(T.tag){case 5:Ht=T.stateNode,Bi=!1;break e;case 3:Ht=T.stateNode.containerInfo,Bi=!0;break e;case 4:Ht=T.stateNode.containerInfo,Bi=!0;break e}T=T.return}if(Ht===null)throw Error(n(160));gp(g,x,f),Ht=null,Bi=!1;var z=f.alternate;z!==null&&(z.return=null),f.return=null}catch(oe){gt(f,r,oe)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)_p(r,i),r=r.sibling}function _p(i,r){var a=i.alternate,c=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(Ai(r,i),Ui(i),c&4){try{Ds(3,i,i.return),Go(3,i)}catch(Me){gt(i,i.return,Me)}try{Ds(5,i,i.return)}catch(Me){gt(i,i.return,Me)}}break;case 1:Ai(r,i),Ui(i),c&512&&a!==null&&Br(a,a.return);break;case 5:if(Ai(r,i),Ui(i),c&512&&a!==null&&Br(a,a.return),i.flags&32){var f=i.stateNode;try{Ge(f,"")}catch(Me){gt(i,i.return,Me)}}if(c&4&&(f=i.stateNode,f!=null)){var g=i.memoizedProps,x=a!==null?a.memoizedProps:g,T=i.type,z=i.updateQueue;if(i.updateQueue=null,z!==null)try{T==="input"&&g.type==="radio"&&g.name!=null&&Y(f,g),Mt(T,x);var oe=Mt(T,g);for(x=0;x<z.length;x+=2){var ge=z[x],_e=z[x+1];ge==="style"?ce(f,_e):ge==="dangerouslySetInnerHTML"?bt(f,_e):ge==="children"?Ge(f,_e):A(f,ge,_e,oe)}switch(T){case"input":he(f,g);break;case"textarea":mt(f,g);break;case"select":var pe=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!g.multiple;var ke=g.value;ke!=null?Ce(f,!!g.multiple,ke,!1):pe!==!!g.multiple&&(g.defaultValue!=null?Ce(f,!!g.multiple,g.defaultValue,!0):Ce(f,!!g.multiple,g.multiple?[]:"",!1))}f[ys]=g}catch(Me){gt(i,i.return,Me)}}break;case 6:if(Ai(r,i),Ui(i),c&4){if(i.stateNode===null)throw Error(n(162));f=i.stateNode,g=i.memoizedProps;try{f.nodeValue=g}catch(Me){gt(i,i.return,Me)}}break;case 3:if(Ai(r,i),Ui(i),c&4&&a!==null&&a.memoizedState.isDehydrated)try{ls(r.containerInfo)}catch(Me){gt(i,i.return,Me)}break;case 4:Ai(r,i),Ui(i);break;case 13:Ai(r,i),Ui(i),f=i.child,f.flags&8192&&(g=f.memoizedState!==null,f.stateNode.isHidden=g,!g||f.alternate!==null&&f.alternate.memoizedState!==null||(xc=yt())),c&4&&vp(i);break;case 22:if(ge=a!==null&&a.memoizedState!==null,i.mode&1?(Xt=(oe=Xt)||ge,Ai(r,i),Xt=oe):Ai(r,i),Ui(i),c&8192){if(oe=i.memoizedState!==null,(i.stateNode.isHidden=oe)&&!ge&&(i.mode&1)!==0)for(Ne=i,ge=i.child;ge!==null;){for(_e=Ne=ge;Ne!==null;){switch(pe=Ne,ke=pe.child,pe.tag){case 0:case 11:case 14:case 15:Ds(4,pe,pe.return);break;case 1:Br(pe,pe.return);var Pe=pe.stateNode;if(typeof Pe.componentWillUnmount=="function"){c=pe,a=pe.return;try{r=c,Pe.props=r.memoizedProps,Pe.state=r.memoizedState,Pe.componentWillUnmount()}catch(Me){gt(c,a,Me)}}break;case 5:Br(pe,pe.return);break;case 22:if(pe.memoizedState!==null){wp(_e);continue}}ke!==null?(ke.return=pe,Ne=ke):wp(_e)}ge=ge.sibling}e:for(ge=null,_e=i;;){if(_e.tag===5){if(ge===null){ge=_e;try{f=_e.stateNode,oe?(g=f.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(T=_e.stateNode,z=_e.memoizedProps.style,x=z!=null&&z.hasOwnProperty("display")?z.display:null,T.style.display=et("display",x))}catch(Me){gt(i,i.return,Me)}}}else if(_e.tag===6){if(ge===null)try{_e.stateNode.nodeValue=oe?"":_e.memoizedProps}catch(Me){gt(i,i.return,Me)}}else if((_e.tag!==22&&_e.tag!==23||_e.memoizedState===null||_e===i)&&_e.child!==null){_e.child.return=_e,_e=_e.child;continue}if(_e===i)break e;for(;_e.sibling===null;){if(_e.return===null||_e.return===i)break e;ge===_e&&(ge=null),_e=_e.return}ge===_e&&(ge=null),_e.sibling.return=_e.return,_e=_e.sibling}}break;case 19:Ai(r,i),Ui(i),c&4&&vp(i);break;case 21:break;default:Ai(r,i),Ui(i)}}function Ui(i){var r=i.flags;if(r&2){try{e:{for(var a=i.return;a!==null;){if(pp(a)){var c=a;break e}a=a.return}throw Error(n(160))}switch(c.tag){case 5:var f=c.stateNode;c.flags&32&&(Ge(f,""),c.flags&=-33);var g=mp(i);wc(i,g,f);break;case 3:case 4:var x=c.stateNode.containerInfo,T=mp(i);Sc(i,T,x);break;default:throw Error(n(161))}}catch(z){gt(i,i.return,z)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function RS(i,r,a){Ne=i,yp(i)}function yp(i,r,a){for(var c=(i.mode&1)!==0;Ne!==null;){var f=Ne,g=f.child;if(f.tag===22&&c){var x=f.memoizedState!==null||Xo;if(!x){var T=f.alternate,z=T!==null&&T.memoizedState!==null||Xt;T=Xo;var oe=Xt;if(Xo=x,(Xt=z)&&!oe)for(Ne=f;Ne!==null;)x=Ne,z=x.child,x.tag===22&&x.memoizedState!==null?bp(f):z!==null?(z.return=x,Ne=z):bp(f);for(;g!==null;)Ne=g,yp(g),g=g.sibling;Ne=f,Xo=T,Xt=oe}Sp(i)}else(f.subtreeFlags&8772)!==0&&g!==null?(g.return=f,Ne=g):Sp(i)}}function Sp(i){for(;Ne!==null;){var r=Ne;if((r.flags&8772)!==0){var a=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Xt||Go(5,r);break;case 1:var c=r.stateNode;if(r.flags&4&&!Xt)if(a===null)c.componentDidMount();else{var f=r.elementType===r.type?a.memoizedProps:Ti(r.type,a.memoizedProps);c.componentDidUpdate(f,a.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&wf(r,g,c);break;case 3:var x=r.updateQueue;if(x!==null){if(a=null,r.child!==null)switch(r.child.tag){case 5:a=r.child.stateNode;break;case 1:a=r.child.stateNode}wf(r,x,a)}break;case 5:var T=r.stateNode;if(a===null&&r.flags&4){a=T;var z=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":z.autoFocus&&a.focus();break;case"img":z.src&&(a.src=z.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var oe=r.alternate;if(oe!==null){var ge=oe.memoizedState;if(ge!==null){var _e=ge.dehydrated;_e!==null&&ls(_e)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Xt||r.flags&512&&yc(r)}catch(pe){gt(r,r.return,pe)}}if(r===i){Ne=null;break}if(a=r.sibling,a!==null){a.return=r.return,Ne=a;break}Ne=r.return}}function wp(i){for(;Ne!==null;){var r=Ne;if(r===i){Ne=null;break}var a=r.sibling;if(a!==null){a.return=r.return,Ne=a;break}Ne=r.return}}function bp(i){for(;Ne!==null;){var r=Ne;try{switch(r.tag){case 0:case 11:case 15:var a=r.return;try{Go(4,r)}catch(z){gt(r,a,z)}break;case 1:var c=r.stateNode;if(typeof c.componentDidMount=="function"){var f=r.return;try{c.componentDidMount()}catch(z){gt(r,f,z)}}var g=r.return;try{yc(r)}catch(z){gt(r,g,z)}break;case 5:var x=r.return;try{yc(r)}catch(z){gt(r,x,z)}}}catch(z){gt(r,r.return,z)}if(r===i){Ne=null;break}var T=r.sibling;if(T!==null){T.return=r.return,Ne=T;break}Ne=r.return}}var PS=Math.ceil,Qo=B.ReactCurrentDispatcher,bc=B.ReactCurrentOwner,ki=B.ReactCurrentBatchConfig,Je=0,jt=null,Ct=null,$t=0,mi=0,Ar=bn(0),Nt=0,Ms=null,Gn=0,Jo=0,Cc=0,Ls=null,si=null,xc=0,Ir=1/0,ln=null,Zo=!1,kc=null,Rn=null,ea=!1,Pn=null,ta=0,js=0,Ec=null,ia=-1,na=0;function Jt(){return(Je&6)!==0?yt():ia!==-1?ia:ia=yt()}function Dn(i){return(i.mode&1)===0?1:(Je&2)!==0&&$t!==0?$t&-$t:dS.transition!==null?(na===0&&(na=pd()),na):(i=it,i!==0||(i=window.event,i=i===void 0?16:Cd(i.type)),i)}function Ii(i,r,a,c){if(50<js)throw js=0,Ec=null,Error(n(185));ns(i,a,c),((Je&2)===0||i!==jt)&&(i===jt&&((Je&2)===0&&(Jo|=a),Nt===4&&Mn(i,$t)),oi(i,c),a===1&&Je===0&&(r.mode&1)===0&&(Ir=yt()+500,Mo&&xn()))}function oi(i,r){var a=i.callbackNode;dy(i,r);var c=ho(i,i===jt?$t:0);if(c===0)a!==null&&hd(a),i.callbackNode=null,i.callbackPriority=0;else if(r=c&-c,i.callbackPriority!==r){if(a!=null&&hd(a),r===1)i.tag===0?hS(xp.bind(null,i)):cf(xp.bind(null,i)),aS(function(){(Je&6)===0&&xn()}),a=null;else{switch(md(c)){case 1:a=sl;break;case 4:a=dd;break;case 16:a=ao;break;case 536870912:a=fd;break;default:a=ao}a=Lp(a,Cp.bind(null,i))}i.callbackPriority=r,i.callbackNode=a}}function Cp(i,r){if(ia=-1,na=0,(Je&6)!==0)throw Error(n(327));var a=i.callbackNode;if(Or()&&i.callbackNode!==a)return null;var c=ho(i,i===jt?$t:0);if(c===0)return null;if((c&30)!==0||(c&i.expiredLanes)!==0||r)r=ra(i,c);else{r=c;var f=Je;Je|=2;var g=Ep();(jt!==i||$t!==r)&&(ln=null,Ir=yt()+500,Jn(i,r));do try{LS();break}catch(T){kp(i,T)}while(!0);Ul(),Qo.current=g,Je=f,Ct!==null?r=0:(jt=null,$t=0,r=Nt)}if(r!==0){if(r===2&&(f=ol(i),f!==0&&(c=f,r=Nc(i,f))),r===1)throw a=Ms,Jn(i,0),Mn(i,c),oi(i,yt()),a;if(r===6)Mn(i,c);else{if(f=i.current.alternate,(c&30)===0&&!DS(f)&&(r=ra(i,c),r===2&&(g=ol(i),g!==0&&(c=g,r=Nc(i,g))),r===1))throw a=Ms,Jn(i,0),Mn(i,c),oi(i,yt()),a;switch(i.finishedWork=f,i.finishedLanes=c,r){case 0:case 1:throw Error(n(345));case 2:Zn(i,si,ln);break;case 3:if(Mn(i,c),(c&130023424)===c&&(r=xc+500-yt(),10<r)){if(ho(i,0)!==0)break;if(f=i.suspendedLanes,(f&c)!==c){Jt(),i.pingedLanes|=i.suspendedLanes&f;break}i.timeoutHandle=jl(Zn.bind(null,i,si,ln),r);break}Zn(i,si,ln);break;case 4:if(Mn(i,c),(c&4194240)===c)break;for(r=i.eventTimes,f=-1;0<c;){var x=31-Mi(c);g=1<<x,x=r[x],x>f&&(f=x),c&=~g}if(c=f,c=yt()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*PS(c/1960))-c,10<c){i.timeoutHandle=jl(Zn.bind(null,i,si,ln),c);break}Zn(i,si,ln);break;case 5:Zn(i,si,ln);break;default:throw Error(n(329))}}}return oi(i,yt()),i.callbackNode===a?Cp.bind(null,i):null}function Nc(i,r){var a=Ls;return i.current.memoizedState.isDehydrated&&(Jn(i,r).flags|=256),i=ra(i,r),i!==2&&(r=si,si=a,r!==null&&Rc(r)),i}function Rc(i){si===null?si=i:si.push.apply(si,i)}function DS(i){for(var r=i;;){if(r.flags&16384){var a=r.updateQueue;if(a!==null&&(a=a.stores,a!==null))for(var c=0;c<a.length;c++){var f=a[c],g=f.getSnapshot;f=f.value;try{if(!Li(g(),f))return!1}catch{return!1}}}if(a=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;else{if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Mn(i,r){for(r&=~Cc,r&=~Jo,i.suspendedLanes|=r,i.pingedLanes&=~r,i=i.expirationTimes;0<r;){var a=31-Mi(r),c=1<<a;i[a]=-1,r&=~c}}function xp(i){if((Je&6)!==0)throw Error(n(327));Or();var r=ho(i,0);if((r&1)===0)return oi(i,yt()),null;var a=ra(i,r);if(i.tag!==0&&a===2){var c=ol(i);c!==0&&(r=c,a=Nc(i,c))}if(a===1)throw a=Ms,Jn(i,0),Mn(i,r),oi(i,yt()),a;if(a===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=r,Zn(i,si,ln),oi(i,yt()),null}function Pc(i,r){var a=Je;Je|=1;try{return i(r)}finally{Je=a,Je===0&&(Ir=yt()+500,Mo&&xn())}}function Qn(i){Pn!==null&&Pn.tag===0&&(Je&6)===0&&Or();var r=Je;Je|=1;var a=ki.transition,c=it;try{if(ki.transition=null,it=1,i)return i()}finally{it=c,ki.transition=a,Je=r,(Je&6)===0&&xn()}}function Dc(){mi=Ar.current,at(Ar)}function Jn(i,r){i.finishedWork=null,i.finishedLanes=0;var a=i.timeoutHandle;if(a!==-1&&(i.timeoutHandle=-1,oS(a)),Ct!==null)for(a=Ct.return;a!==null;){var c=a;switch(zl(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Po();break;case 3:jr(),at(ii),at(qt),Jl();break;case 5:Gl(c);break;case 4:jr();break;case 13:at(ht);break;case 19:at(ht);break;case 10:Kl(c.type._context);break;case 22:case 23:Dc()}a=a.return}if(jt=i,Ct=i=Ln(i.current,null),$t=mi=r,Nt=0,Ms=null,Cc=Jo=Gn=0,si=Ls=null,Vn!==null){for(r=0;r<Vn.length;r++)if(a=Vn[r],c=a.interleaved,c!==null){a.interleaved=null;var f=c.next,g=a.pending;if(g!==null){var x=g.next;g.next=f,c.next=x}a.pending=c}Vn=null}return i}function kp(i,r){do{var a=Ct;try{if(Ul(),Ho.current=Ko,$o){for(var c=dt.memoizedState;c!==null;){var f=c.queue;f!==null&&(f.pending=null),c=c.next}$o=!1}if(Xn=0,Lt=Et=dt=null,ks=!1,Es=0,bc.current=null,a===null||a.return===null){Nt=1,Ms=r,Ct=null;break}e:{var g=i,x=a.return,T=a,z=r;if(r=$t,T.flags|=32768,z!==null&&typeof z=="object"&&typeof z.then=="function"){var oe=z,ge=T,_e=ge.tag;if((ge.mode&1)===0&&(_e===0||_e===11||_e===15)){var pe=ge.alternate;pe?(ge.updateQueue=pe.updateQueue,ge.memoizedState=pe.memoizedState,ge.lanes=pe.lanes):(ge.updateQueue=null,ge.memoizedState=null)}var ke=Gf(x);if(ke!==null){ke.flags&=-257,Qf(ke,x,T,g,r),ke.mode&1&&Xf(g,oe,r),r=ke,z=oe;var Pe=r.updateQueue;if(Pe===null){var Me=new Set;Me.add(z),r.updateQueue=Me}else Pe.add(z);break e}else{if((r&1)===0){Xf(g,oe,r),Mc();break e}z=Error(n(426))}}else if(ct&&T.mode&1){var St=Gf(x);if(St!==null){(St.flags&65536)===0&&(St.flags|=256),Qf(St,x,T,g,r),$l(Tr(z,T));break e}}g=z=Tr(z,T),Nt!==4&&(Nt=2),Ls===null?Ls=[g]:Ls.push(g),g=x;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var J=Vf(g,z,r);Sf(g,J);break e;case 1:T=z;var V=g.type,ne=g.stateNode;if((g.flags&128)===0&&(typeof V.getDerivedStateFromError=="function"||ne!==null&&typeof ne.componentDidCatch=="function"&&(Rn===null||!Rn.has(ne)))){g.flags|=65536,r&=-r,g.lanes|=r;var Se=Yf(g,T,r);Sf(g,Se);break e}}g=g.return}while(g!==null)}Rp(a)}catch(Te){r=Te,Ct===a&&a!==null&&(Ct=a=a.return);continue}break}while(!0)}function Ep(){var i=Qo.current;return Qo.current=Ko,i===null?Ko:i}function Mc(){(Nt===0||Nt===3||Nt===2)&&(Nt=4),jt===null||(Gn&268435455)===0&&(Jo&268435455)===0||Mn(jt,$t)}function ra(i,r){var a=Je;Je|=2;var c=Ep();(jt!==i||$t!==r)&&(ln=null,Jn(i,r));do try{MS();break}catch(f){kp(i,f)}while(!0);if(Ul(),Je=a,Qo.current=c,Ct!==null)throw Error(n(261));return jt=null,$t=0,Nt}function MS(){for(;Ct!==null;)Np(Ct)}function LS(){for(;Ct!==null&&!ny();)Np(Ct)}function Np(i){var r=Mp(i.alternate,i,mi);i.memoizedProps=i.pendingProps,r===null?Rp(i):Ct=r,bc.current=null}function Rp(i){var r=i;do{var a=r.alternate;if(i=r.return,(r.flags&32768)===0){if(a=xS(a,r,mi),a!==null){Ct=a;return}}else{if(a=kS(a,r),a!==null){a.flags&=32767,Ct=a;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{Nt=6,Ct=null;return}}if(r=r.sibling,r!==null){Ct=r;return}Ct=r=i}while(r!==null);Nt===0&&(Nt=5)}function Zn(i,r,a){var c=it,f=ki.transition;try{ki.transition=null,it=1,jS(i,r,a,c)}finally{ki.transition=f,it=c}return null}function jS(i,r,a,c){do Or();while(Pn!==null);if((Je&6)!==0)throw Error(n(327));a=i.finishedWork;var f=i.finishedLanes;if(a===null)return null;if(i.finishedWork=null,i.finishedLanes=0,a===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var g=a.lanes|a.childLanes;if(fy(i,g),i===jt&&(Ct=jt=null,$t=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||ea||(ea=!0,Lp(ao,function(){return Or(),null})),g=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||g){g=ki.transition,ki.transition=null;var x=it;it=1;var T=Je;Je|=4,bc.current=null,NS(i,a),_p(a,i),Zy(Ml),mo=!!Dl,Ml=Dl=null,i.current=a,RS(a),ry(),Je=T,it=x,ki.transition=g}else i.current=a;if(ea&&(ea=!1,Pn=i,ta=f),g=i.pendingLanes,g===0&&(Rn=null),ay(a.stateNode),oi(i,yt()),r!==null)for(c=i.onRecoverableError,a=0;a<r.length;a++)f=r[a],c(f.value,{componentStack:f.stack,digest:f.digest});if(Zo)throw Zo=!1,i=kc,kc=null,i;return(ta&1)!==0&&i.tag!==0&&Or(),g=i.pendingLanes,(g&1)!==0?i===Ec?js++:(js=0,Ec=i):js=0,xn(),null}function Or(){if(Pn!==null){var i=md(ta),r=ki.transition,a=it;try{if(ki.transition=null,it=16>i?16:i,Pn===null)var c=!1;else{if(i=Pn,Pn=null,ta=0,(Je&6)!==0)throw Error(n(331));var f=Je;for(Je|=4,Ne=i.current;Ne!==null;){var g=Ne,x=g.child;if((Ne.flags&16)!==0){var T=g.deletions;if(T!==null){for(var z=0;z<T.length;z++){var oe=T[z];for(Ne=oe;Ne!==null;){var ge=Ne;switch(ge.tag){case 0:case 11:case 15:Ds(8,ge,g)}var _e=ge.child;if(_e!==null)_e.return=ge,Ne=_e;else for(;Ne!==null;){ge=Ne;var pe=ge.sibling,ke=ge.return;if(fp(ge),ge===oe){Ne=null;break}if(pe!==null){pe.return=ke,Ne=pe;break}Ne=ke}}}var Pe=g.alternate;if(Pe!==null){var Me=Pe.child;if(Me!==null){Pe.child=null;do{var St=Me.sibling;Me.sibling=null,Me=St}while(Me!==null)}}Ne=g}}if((g.subtreeFlags&2064)!==0&&x!==null)x.return=g,Ne=x;else e:for(;Ne!==null;){if(g=Ne,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:Ds(9,g,g.return)}var J=g.sibling;if(J!==null){J.return=g.return,Ne=J;break e}Ne=g.return}}var V=i.current;for(Ne=V;Ne!==null;){x=Ne;var ne=x.child;if((x.subtreeFlags&2064)!==0&&ne!==null)ne.return=x,Ne=ne;else e:for(x=V;Ne!==null;){if(T=Ne,(T.flags&2048)!==0)try{switch(T.tag){case 0:case 11:case 15:Go(9,T)}}catch(Te){gt(T,T.return,Te)}if(T===x){Ne=null;break e}var Se=T.sibling;if(Se!==null){Se.return=T.return,Ne=Se;break e}Ne=T.return}}if(Je=f,xn(),Fi&&typeof Fi.onPostCommitFiberRoot=="function")try{Fi.onPostCommitFiberRoot(lo,i)}catch{}c=!0}return c}finally{it=a,ki.transition=r}}return!1}function Pp(i,r,a){r=Tr(a,r),r=Vf(i,r,1),i=En(i,r,1),r=Jt(),i!==null&&(ns(i,1,r),oi(i,r))}function gt(i,r,a){if(i.tag===3)Pp(i,i,a);else for(;r!==null;){if(r.tag===3){Pp(r,i,a);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Rn===null||!Rn.has(c))){i=Tr(a,i),i=Yf(r,i,1),r=En(r,i,1),i=Jt(),r!==null&&(ns(r,1,i),oi(r,i));break}}r=r.return}}function TS(i,r,a){var c=i.pingCache;c!==null&&c.delete(r),r=Jt(),i.pingedLanes|=i.suspendedLanes&a,jt===i&&($t&a)===a&&(Nt===4||Nt===3&&($t&130023424)===$t&&500>yt()-xc?Jn(i,0):Cc|=a),oi(i,r)}function Dp(i,r){r===0&&((i.mode&1)===0?r=1:(r=uo,uo<<=1,(uo&130023424)===0&&(uo=4194304)));var a=Jt();i=sn(i,r),i!==null&&(ns(i,r,a),oi(i,a))}function BS(i){var r=i.memoizedState,a=0;r!==null&&(a=r.retryLane),Dp(i,a)}function AS(i,r){var a=0;switch(i.tag){case 13:var c=i.stateNode,f=i.memoizedState;f!==null&&(a=f.retryLane);break;case 19:c=i.stateNode;break;default:throw Error(n(314))}c!==null&&c.delete(r),Dp(i,a)}var Mp;Mp=function(i,r,a){if(i!==null)if(i.memoizedProps!==r.pendingProps||ii.current)ri=!0;else{if((i.lanes&a)===0&&(r.flags&128)===0)return ri=!1,CS(i,r,a);ri=(i.flags&131072)!==0}else ri=!1,ct&&(r.flags&1048576)!==0&&uf(r,jo,r.index);switch(r.lanes=0,r.tag){case 2:var c=r.type;Yo(i,r),i=r.pendingProps;var f=Er(r,qt.current);Lr(r,a),f=tc(null,r,c,i,f,a);var g=ic();return r.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,ni(c)?(g=!0,Do(r)):g=!1,r.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Yl(r),f.updater=qo,r.stateNode=f,f._reactInternals=r,lc(r,c,i,a),r=dc(null,r,c,!0,g,a)):(r.tag=0,ct&&g&&Ol(r),Qt(null,r,f,a),r=r.child),r;case 16:c=r.elementType;e:{switch(Yo(i,r),i=r.pendingProps,f=c._init,c=f(c._payload),r.type=c,f=r.tag=OS(c),i=Ti(c,i),f){case 0:r=hc(null,r,c,i,a);break e;case 1:r=np(null,r,c,i,a);break e;case 11:r=Jf(null,r,c,i,a);break e;case 14:r=Zf(null,r,c,Ti(c.type,i),a);break e}throw Error(n(306,c,""))}return r;case 0:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Ti(c,f),hc(i,r,c,f,a);case 1:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Ti(c,f),np(i,r,c,f,a);case 3:e:{if(rp(r),i===null)throw Error(n(387));c=r.pendingProps,g=r.memoizedState,f=g.element,yf(i,r),zo(r,c,null,a);var x=r.memoizedState;if(c=x.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:x.cache,pendingSuspenseBoundaries:x.pendingSuspenseBoundaries,transitions:x.transitions},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){f=Tr(Error(n(423)),r),r=sp(i,r,c,a,f);break e}else if(c!==f){f=Tr(Error(n(424)),r),r=sp(i,r,c,a,f);break e}else for(pi=wn(r.stateNode.containerInfo.firstChild),fi=r,ct=!0,ji=null,a=vf(r,null,c,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Pr(),c===f){r=an(i,r,a);break e}Qt(i,r,c,a)}r=r.child}return r;case 5:return bf(r),i===null&&Hl(r),c=r.type,f=r.pendingProps,g=i!==null?i.memoizedProps:null,x=f.children,Ll(c,f)?x=null:g!==null&&Ll(c,g)&&(r.flags|=32),ip(i,r),Qt(i,r,x,a),r.child;case 6:return i===null&&Hl(r),null;case 13:return op(i,r,a);case 4:return Xl(r,r.stateNode.containerInfo),c=r.pendingProps,i===null?r.child=Dr(r,null,c,a):Qt(i,r,c,a),r.child;case 11:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Ti(c,f),Jf(i,r,c,f,a);case 7:return Qt(i,r,r.pendingProps,a),r.child;case 8:return Qt(i,r,r.pendingProps.children,a),r.child;case 12:return Qt(i,r,r.pendingProps.children,a),r.child;case 10:e:{if(c=r.type._context,f=r.pendingProps,g=r.memoizedProps,x=f.value,st(Ao,c._currentValue),c._currentValue=x,g!==null)if(Li(g.value,x)){if(g.children===f.children&&!ii.current){r=an(i,r,a);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var T=g.dependencies;if(T!==null){x=g.child;for(var z=T.firstContext;z!==null;){if(z.context===c){if(g.tag===1){z=on(-1,a&-a),z.tag=2;var oe=g.updateQueue;if(oe!==null){oe=oe.shared;var ge=oe.pending;ge===null?z.next=z:(z.next=ge.next,ge.next=z),oe.pending=z}}g.lanes|=a,z=g.alternate,z!==null&&(z.lanes|=a),ql(g.return,a,r),T.lanes|=a;break}z=z.next}}else if(g.tag===10)x=g.type===r.type?null:g.child;else if(g.tag===18){if(x=g.return,x===null)throw Error(n(341));x.lanes|=a,T=x.alternate,T!==null&&(T.lanes|=a),ql(x,a,r),x=g.sibling}else x=g.child;if(x!==null)x.return=g;else for(x=g;x!==null;){if(x===r){x=null;break}if(g=x.sibling,g!==null){g.return=x.return,x=g;break}x=x.return}g=x}Qt(i,r,f.children,a),r=r.child}return r;case 9:return f=r.type,c=r.pendingProps.children,Lr(r,a),f=Ci(f),c=c(f),r.flags|=1,Qt(i,r,c,a),r.child;case 14:return c=r.type,f=Ti(c,r.pendingProps),f=Ti(c.type,f),Zf(i,r,c,f,a);case 15:return ep(i,r,r.type,r.pendingProps,a);case 17:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Ti(c,f),Yo(i,r),r.tag=1,ni(c)?(i=!0,Do(r)):i=!1,Lr(r,a),Kf(r,c,f),lc(r,c,f,a),dc(null,r,c,!0,i,a);case 19:return lp(i,r,a);case 22:return tp(i,r,a)}throw Error(n(156,r.tag))};function Lp(i,r){return ud(i,r)}function IS(i,r,a,c){this.tag=i,this.key=a,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=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ei(i,r,a,c){return new IS(i,r,a,c)}function Lc(i){return i=i.prototype,!(!i||!i.isReactComponent)}function OS(i){if(typeof i=="function")return Lc(i)?1:0;if(i!=null){if(i=i.$$typeof,i===P)return 11;if(i===U)return 14}return 2}function Ln(i,r){var a=i.alternate;return a===null?(a=Ei(i.tag,r,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=r,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&14680064,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,r=i.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a}function sa(i,r,a,c,f,g){var x=2;if(c=i,typeof i=="function")Lc(i)&&(x=1);else if(typeof i=="string")x=5;else e:switch(i){case F:return er(a.children,f,g,r);case Z:x=8,f|=8;break;case W:return i=Ei(12,a,r,f|2),i.elementType=W,i.lanes=g,i;case E:return i=Ei(13,a,r,f),i.elementType=E,i.lanes=g,i;case j:return i=Ei(19,a,r,f),i.elementType=j,i.lanes=g,i;case H:return oa(a,f,g,r);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case G:x=10;break e;case K:x=9;break e;case P:x=11;break e;case U:x=14;break e;case R:x=16,c=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return r=Ei(x,a,r,f),r.elementType=i,r.type=c,r.lanes=g,r}function er(i,r,a,c){return i=Ei(7,i,c,r),i.lanes=a,i}function oa(i,r,a,c){return i=Ei(22,i,c,r),i.elementType=H,i.lanes=a,i.stateNode={isHidden:!1},i}function jc(i,r,a){return i=Ei(6,i,null,r),i.lanes=a,i}function Tc(i,r,a){return r=Ei(4,i.children!==null?i.children:[],i.key,r),r.lanes=a,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}function zS(i,r,a,c,f){this.tag=r,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=al(0),this.expirationTimes=al(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=al(0),this.identifierPrefix=c,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Bc(i,r,a,c,f,g,x,T,z){return i=new zS(i,r,a,T,z),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Ei(3,null,null,r),i.current=g,g.stateNode=i,g.memoizedState={element:c,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},Yl(g),i}function FS(i,r,a){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:c==null?null:""+c,children:i,containerInfo:r,implementation:a}}function jp(i){if(!i)return Cn;i=i._reactInternals;e:{if($n(i)!==i||i.tag!==1)throw Error(n(170));var r=i;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(ni(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(n(171))}if(i.tag===1){var a=i.type;if(ni(a))return af(i,a,r)}return r}function Tp(i,r,a,c,f,g,x,T,z){return i=Bc(a,c,!0,i,f,g,x,T,z),i.context=jp(null),a=i.current,c=Jt(),f=Dn(a),g=on(c,f),g.callback=r??null,En(a,g,f),i.current.lanes=f,ns(i,f,c),oi(i,c),i}function aa(i,r,a,c){var f=r.current,g=Jt(),x=Dn(f);return a=jp(a),r.context===null?r.context=a:r.pendingContext=a,r=on(g,x),r.payload={element:i},c=c===void 0?null:c,c!==null&&(r.callback=c),i=En(f,r,x),i!==null&&(Ii(i,f,x,g),Oo(i,f,x)),x}function la(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function Bp(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<r?a:r}}function Ac(i,r){Bp(i,r),(i=i.alternate)&&Bp(i,r)}function HS(){return null}var Ap=typeof reportError=="function"?reportError:function(i){console.error(i)};function Ic(i){this._internalRoot=i}ca.prototype.render=Ic.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(n(409));aa(i,r,null,null)},ca.prototype.unmount=Ic.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;Qn(function(){aa(null,i,null,null)}),r[en]=null}};function ca(i){this._internalRoot=i}ca.prototype.unstable_scheduleHydration=function(i){if(i){var r=_d();i={blockedOn:null,target:i,priority:r};for(var a=0;a<_n.length&&r!==0&&r<_n[a].priority;a++);_n.splice(a,0,i),a===0&&wd(i)}};function Oc(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function ua(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function Ip(){}function $S(i,r,a,c,f){if(f){if(typeof c=="function"){var g=c;c=function(){var oe=la(x);g.call(oe)}}var x=Tp(r,c,i,0,null,!1,!1,"",Ip);return i._reactRootContainer=x,i[en]=x.current,vs(i.nodeType===8?i.parentNode:i),Qn(),x}for(;f=i.lastChild;)i.removeChild(f);if(typeof c=="function"){var T=c;c=function(){var oe=la(z);T.call(oe)}}var z=Bc(i,0,!1,null,null,!1,!1,"",Ip);return i._reactRootContainer=z,i[en]=z.current,vs(i.nodeType===8?i.parentNode:i),Qn(function(){aa(r,z,a,c)}),z}function ha(i,r,a,c,f){var g=a._reactRootContainer;if(g){var x=g;if(typeof f=="function"){var T=f;f=function(){var z=la(x);T.call(z)}}aa(r,x,i,f)}else x=$S(a,r,i,f,c);return la(x)}gd=function(i){switch(i.tag){case 3:var r=i.stateNode;if(r.current.memoizedState.isDehydrated){var a=is(r.pendingLanes);a!==0&&(ll(r,a|1),oi(r,yt()),(Je&6)===0&&(Ir=yt()+500,xn()))}break;case 13:Qn(function(){var c=sn(i,1);if(c!==null){var f=Jt();Ii(c,i,1,f)}}),Ac(i,1)}},cl=function(i){if(i.tag===13){var r=sn(i,134217728);if(r!==null){var a=Jt();Ii(r,i,134217728,a)}Ac(i,134217728)}},vd=function(i){if(i.tag===13){var r=Dn(i),a=sn(i,r);if(a!==null){var c=Jt();Ii(a,i,r,c)}Ac(i,r)}},_d=function(){return it},yd=function(i,r){var a=it;try{return it=i,r()}finally{it=a}},tl=function(i,r,a){switch(r){case"input":if(he(i,a),r=a.name,a.type==="radio"&&r!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<a.length;r++){var c=a[r];if(c!==i&&c.form===i.form){var f=Ro(c);if(!f)throw Error(n(90));ie(c),he(c,f)}}}break;case"textarea":mt(i,a);break;case"select":r=a.value,r!=null&&Ce(i,!!a.multiple,r,!1)}},nd=Pc,rd=Qn;var WS={usingClientEntryPoint:!1,Events:[Ss,xr,Ro,td,id,Pc]},Ts={findFiberByHostInstance:Wn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},US={bundleType:Ts.bundleType,version:Ts.version,rendererPackageName:Ts.rendererPackageName,rendererConfig:Ts.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:B.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=ld(i),i===null?null:i.stateNode},findFiberByHostInstance:Ts.findFiberByHostInstance||HS,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 da=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!da.isDisabled&&da.supportsFiber)try{lo=da.inject(US),Fi=da}catch{}}return ai.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=WS,ai.createPortal=function(i,r){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Oc(r))throw Error(n(200));return FS(i,r,null,a)},ai.createRoot=function(i,r){if(!Oc(i))throw Error(n(299));var a=!1,c="",f=Ap;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onRecoverableError!==void 0&&(f=r.onRecoverableError)),r=Bc(i,1,!1,null,null,a,!1,c,f),i[en]=r.current,vs(i.nodeType===8?i.parentNode:i),new Ic(r)},ai.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var r=i._reactInternals;if(r===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=ld(r),i=i===null?null:i.stateNode,i},ai.flushSync=function(i){return Qn(i)},ai.hydrate=function(i,r,a){if(!ua(r))throw Error(n(200));return ha(null,i,r,!0,a)},ai.hydrateRoot=function(i,r,a){if(!Oc(i))throw Error(n(405));var c=a!=null&&a.hydratedSources||null,f=!1,g="",x=Ap;if(a!=null&&(a.unstable_strictMode===!0&&(f=!0),a.identifierPrefix!==void 0&&(g=a.identifierPrefix),a.onRecoverableError!==void 0&&(x=a.onRecoverableError)),r=Tp(r,null,i,1,a??null,f,!1,g,x),i[en]=r.current,vs(i),c)for(i=0;i<c.length;i++)a=c[i],f=a._getVersion,f=f(a._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[a,f]:r.mutableSourceEagerHydrationData.push(a,f);return new ca(r)},ai.render=function(i,r,a){if(!ua(r))throw Error(n(200));return ha(null,i,r,!1,a)},ai.unmountComponentAtNode=function(i){if(!ua(i))throw Error(n(40));return i._reactRootContainer?(Qn(function(){ha(null,null,i,!1,function(){i._reactRootContainer=null,i[en]=null})}),!0):!1},ai.unstable_batchedUpdates=Pc,ai.unstable_renderSubtreeIntoContainer=function(i,r,a,c){if(!ua(a))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return ha(i,r,a,!1,c)},ai.version="18.3.1-next-f1338f8080-20240426",ai}var Kp;function ZS(){if(Kp)return Hc.exports;Kp=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(),Hc.exports=JS(),Hc.exports}var qp;function ew(){if(qp)return fa;qp=1;var e=ZS();return fa.createRoot=e.createRoot,fa.hydrateRoot=e.hydrateRoot,fa}var tw=ew();const iw=Nh(tw);function zt(e,t,n={}){return fetch(e,{...n,headers:{...n.headers||{},Authorization:`Bearer ${t}`}})}const La=e=>`nc_seen_${e}`;async function Ue(e,t,n={}){const s=await zt(e,t,{method:n.method||"GET",headers:{"content-type":"application/json"},body:n.body?JSON.stringify(n.body):void 0}),o=await s.json().catch(()=>({}));if(!s.ok){const l=new Error(o.error||`HTTP ${s.status}`);throw l.status=s.status,l.data=o,l}return o}const ui=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",Kt=(e,t)=>`${ui(e)}/fleet/${t}`,hr=(e,t)=>Ue(Kt(t,"status"),e),Ph=(e,t,n)=>Ue(Kt(n,"up"),e,{method:"POST",body:t}),ja=(e,t,n)=>Ue(Kt(n,"down"),e,{method:"POST",body:t}),Us=(e,t,n)=>Ue(Kt(n,"restart"),e,{method:"POST",body:{cell:t}}),Dh=(e,t)=>Ue(Kt(t,"definitions"),e),nw=(e,t)=>Ue(Kt(t,"credentials/status"),e),rw=(e,t,n,s)=>Ue(Kt(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:n}}),sw=(e,t,n)=>Ue(Kt(n,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),ow=(e,t,n)=>Ue(Kt(n,"define-engine"),e,{method:"POST",body:{def:t}}),aw=(e,t,n,s,o)=>Ue(Kt(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:n,envChanges:s}}),lw=(e,t,n)=>Ue(Kt(n,"remove-engine"),e,{method:"POST",body:{id:t}}),cw=(e,t,n)=>Ue(Kt(n,"define-cell"),e,{method:"POST",body:{def:t}}),uw=(e,t,n,s)=>Ue(Kt(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:n}}),sv=(e,t,n=!1,s)=>Ue(Kt(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:n}}),hw=(e,t,n)=>Ue(Kt(n,"import-cell"),e,{method:"POST",body:t}),dw=(e,t,n)=>Ue(Kt(n,"restore-cells"),e,{method:"POST",body:{cells:t}}),fw=(e,t,n,s)=>Ue(Kt(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!n}}),Mh=(e,t,n)=>Ue(`${ui(n)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),ov=(e,t,n,s)=>Ue(`${ui(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!n}}),av=(e,t,n)=>Ue(`${ui(n)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),lv=e=>Ue("/api/settings",e),cv=e=>Ue("/api/nodes",e),pw=e=>Ue("/api/topology",e),uv=(e,t)=>Ue(`${ui(t)}/sessions`,e),Lh=(e,t)=>Ue(`${ui(t)}/config`,e),Vp=(e,t)=>Ue(`${ui(t)}/topology`,e),hv=(e,t)=>Ue("/api/settings/config",e,{method:"POST",body:t}),mw=e=>Ue("/api/settings/token/rotate",e,{method:"POST"}),gw=(e,t)=>Ue("/api/settings/nodes/pair",e,{method:"POST",body:t}),Yp=(e,t,n=[])=>Ue(`${ui(n)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),vw=(e,t,n)=>Ue(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:n}}),_w=(e,t)=>Ue(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),jh=(e,t,n)=>Ue(`/api/settings/nodes/${encodeURIComponent(t)}/${n}`,e,{method:"POST"}),yw=(e,t,n)=>Ue(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:n}}),Xp=(e,t,n,s=[])=>Ue(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:n,selected:s}}),Sw=e=>Ue("/api/settings/service/regenerate",e,{method:"POST"}),ww=e=>Ue("/api/settings/update/check",e,{method:"POST"}),bw=e=>Ue("/api/settings/update/apply",e,{method:"POST"}),Cw=(e,t=!0)=>Ue(`/api/asks${t?"?open=1":""}`,e),xw=(e,t,n)=>Ue(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:n}}),pa=(e,t=[])=>Ue(`${ui(t)}/decks`,e),Gp=(e,t,n=[])=>Ue(`${ui(n)}/decks`,e,{method:"POST",body:{name:t}}),ma=(e,t,n,s,o=[])=>Ue(`${ui(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:n,expectedRevision:s}}),kw=(e,t,n,s,o=[])=>Ue(`${ui(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:n,expectedRevision:s}}),Ew=(e,t,n,s=[])=>Ue(`${ui(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:n}}),Nw={power:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M12 3v8"}),h.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:h.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:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),h.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),h.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),h.jsx("path",{d:"M12 18v3"})]}),enter:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),h.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),h.jsx("path",{d:"M22 2 11 13"})]}),trash:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M4 7h16"}),h.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),h.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),h.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:h.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),refresh:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),h.jsx("polyline",{points:"21 3 21 8 16 8"})]}),upload:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M12 16V5"}),h.jsx("polyline",{points:"8 9 12 5 16 9"}),h.jsx("path",{d:"M5 20h14"})]}),chevronLeft:h.jsx("polyline",{points:"14 6 8 12 14 18"}),attach:h.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:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),h.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:h.jsxs(h.Fragment,{children:[h.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"}),h.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),h.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),h.jsx("path",{d:"M21 15l-5-5L5 21"})]}),zoomIn:h.jsxs(h.Fragment,{children:[h.jsx("circle",{cx:"11",cy:"11",r:"7"}),h.jsx("path",{d:"M21 21l-4.35-4.35"}),h.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:h.jsxs(h.Fragment,{children:[h.jsx("circle",{cx:"11",cy:"11",r:"7"}),h.jsx("path",{d:"M21 21l-4.35-4.35"}),h.jsx("path",{d:"M8 11h6"})]}),gear:h.jsxs(h.Fragment,{children:[h.jsx("circle",{cx:"12",cy:"12",r:"3"}),h.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:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),h.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})};function tt({name:e,size:t=20}){return h.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:Nw[e]||null})}const Th="nc_pins";function dv(){try{const e=JSON.parse(localStorage.getItem(Th));return Array.isArray(e)?e:[]}catch{return[]}}function fv(e,t){const n=e.includes(t)?e.filter(s=>s!==t):[...e,t];try{localStorage.setItem(Th,JSON.stringify(n))}catch{}return n}function pv(e,t,n){if(!e.includes(t)||!e.includes(n)||t===n)return e;const s=[...e],o=s.indexOf(t),l=s.indexOf(n);s.splice(o,1);const u=s.indexOf(n);s.splice(o<l?u+1:u,0,t);try{localStorage.setItem(Th,JSON.stringify(s))}catch{}return s}function Rw(e,t,n){const s=e.indexOf(t);return[s===-1?1e9:s,-(n||0)]}function Pw(e,t){return e[0]-t[0]||e[1]-t[1]}const Qp=/^[a-z0-9-]{1,32}$/;function un(e,t){const n=Array.isArray(e)?e:[];return n.length?`${n.map(encodeURIComponent).join("/")}:${t}`:String(t)}function Dw(e,t,n){const s={};for(const o of Array.isArray(t)?t:[]){const l=Array.isArray(o==null?void 0:o.route)?o.route:typeof(o==null?void 0:o.name)=="string"?[o.name]:[];if(!l.length)continue;const u=l.join("/"),d=o.status==="up"||o.tunnel&&o.tunnel.status==="up",p=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!d&&!p&&(s[u]=e&&e[u]||n)}return s}function Jp(e,t,n){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${n}:${s.tmuxSession||s.cell}`}))}function Zp({nodes:e,topology:t,remote:n,down:s,fleet:o}={}){var p,m,S,w;const l=[],u=new Set,d=new Set;for(const y of Array.isArray(e)?e:[]){if(!y||typeof y.name!="string"||!Qp.test(y.name)||y.direction==="inbound"&&y.shared!==!0)continue;const v=[y.name],C=y.name;u.add(C);const b=((p=y.tunnel)==null?void 0:p.status)||"unknown",k=b==="up",N={name:y.name,label:y.label||y.name,route:v,direct:!0,instanceId:y.nodeId||null,shared:y.shared===!0,tunnelStatus:b,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&&d.add(y.nodeId),!y.nodeId&&y.paired===!1){l.push({...N,status:"needs-repair",downSince:s&&s[C]||null});continue}if(((m=y.health)==null?void 0:m.auth)==="failed"||b==="degraded"&&((S=y.health)==null?void 0:S.status)==="degraded"){l.push({...N,status:"needs-repair",downSince:s&&s[C]||null});continue}if(b==="passive"||((w=y.health)==null?void 0:w.status)==="passive"){l.push({...N,status:"passive",downSince:null});continue}if(!k){l.push({...N,status:"down",downSince:s&&s[C]||null});continue}const L=n&&(n[C]||n[y.name])||null;if(!L||L.error||!Array.isArray(L.sessions)){l.push({...N,status:"unreachable"});continue}const A=L.sessions.filter(F=>F&&typeof F.name=="string"&&F.name).map(F=>({...F,node:C,route:v,key:`${C}:${F.name}`})),B=o&&(o[C]||o[y.name]),ee=Jp(B,v,C),O=new Set(ee.map(F=>F.tmuxSession).filter(Boolean));l.push({...N,status:"up",sessions:A,cells:ee,unmanaged:A.filter(F=>!O.has(F.name)),fleetAvailable:!!(B&&B.available),capabilities:B&&B.capabilities||[],engines:B&&B.engines||[],fleetProvider:B&&B.provider||null})}for(const y of Array.isArray(t)?t:[]){if(!y||!Array.isArray(y.route)||y.route.length<1||y.route.some(B=>!Qp.test(B)))continue;const v=y.route.join("/");if(u.has(v)||y.instanceId&&d.has(y.instanceId))continue;y.instanceId&&d.add(y.instanceId);const C={name:y.name,label:y.label||y.route.join(" › "),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){l.push({...C,status:"offline",downSince:s&&s[v]||y.lastSeen||null});continue}const b=n&&n[v]||null;if(!b||b.error||!Array.isArray(b.sessions)){l.push({...C,status:"unreachable",downSince:s&&s[v]||null});continue}const k=b.sessions.filter(B=>B&&typeof B.name=="string"&&B.name).map(B=>({...B,node:v,route:y.route,key:`${v}:${B.name}`})),N=o&&o[v],L=Jp(N,y.route,v),A=new Set(L.map(B=>B.tmuxSession).filter(Boolean));l.push({...C,status:"up",sessions:k,cells:L,unmanaged:k.filter(B=>!A.has(B.name)),fleetAvailable:!!(N&&N.available),capabilities:N&&N.capabilities||[],engines:N&&N.engines||[],fleetProvider:N&&N.provider||null,lastSeen:y.lastSeen||null})}return l.sort((y,v)=>y.label.localeCompare(v.label))}const Mw=["all","pinned","active","off","technical"],mv="nc_sidebar_views_v1",gv="nc_sidebar_order_v1";function vv(e){return Mw.includes(e)?e:"all"}function Lw(e,t=[],n="all"){const s=vv(n);return s==="technical"?e.technical===!0:e.technical===!0?!1:s==="pinned"?t.includes(e.key):s==="active"?!!e.live:s==="off"?!e.live:!0}function jw(e,t,n=[],s=[]){const o=n.indexOf(e.key),l=n.indexOf(t.key),u=o===-1?Number.MAX_SAFE_INTEGER:o,d=l===-1?Number.MAX_SAFE_INTEGER:l,p=s.indexOf(e.key),m=s.indexOf(t.key),S=p===-1?Number.MAX_SAFE_INTEGER:p,w=m===-1?Number.MAX_SAFE_INTEGER:m;return u-d||S-w||+!!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 _v(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(gv));if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[s,o]of Object.entries(t).slice(0,64)){if(typeof s!="string"||!s||s.length>160||!Array.isArray(o))continue;const l=[...new Set(o.filter(u=>typeof u=="string"&&u&&u.length<=256))].slice(0,128);l.length&&(n[s]=l)}return n}catch{return{}}}function Xi(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function yv(e,t=globalThis.localStorage){try{t.setItem(gv,JSON.stringify(e))}catch{}return e}function Sv(e,t,n,s,o=[]){if(typeof t!="string"||!t||n===s)return e;const l=[...new Set(o.filter(y=>typeof y=="string"&&y))];if(!l.includes(n)||!l.includes(s))return e;const u=Xi(e,t).filter(y=>l.includes(y)),d=[...u,...l.filter(y=>!u.includes(y))],p=d.indexOf(n),m=d.indexOf(s);d.splice(p,1);const S=d.indexOf(s),w=p<m?S+1:S;return d.splice(w,0,n),{...e,[t]:d}}function wv(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(mv));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function Ta(e,t){var n,s;return{open:((n=e==null?void 0:e[t])==null?void 0:n.open)!==!1,filter:vv((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function bv(e,t=globalThis.localStorage){try{t.setItem(mv,JSON.stringify(e))}catch{}return e}function em(e,t=""){const n=String(t||"").trim().toLocaleLowerCase();return n?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(n):!0}function hn(e=[],t=[],n="all",s=[]){return[...e].filter(o=>Lw(o,t,n)).sort((o,l)=>jw(o,l,t,s))}const Bh=["it","en","es"];function Tw(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return Bh.includes(t)?t:"en"}catch{return"en"}}const ka=Tw(),Cv="nc_lang",ju="nc-lang";function xv(){return typeof localStorage<"u"?localStorage:null}const ga={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",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-degraded":"degradata: unit attiva, tmux morto","power-on":"accendi","power-off":"spegni","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…",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","fleet-editor-unavailable":"Editor disponibile solo con il provider fleet builtin.","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-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","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-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-private":"Privato: solo questo dispositivo può usare il collegamento all’hub.","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-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)","node-slug-hint":"routing su slug: {slug}","device-name-label":"Nome dispositivo","device-name-hint":"come ti vedono i peer (modificabile)","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-external-hint":"Provider esterno: engine/modello si configurano nel fleet esterno.","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",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-degraded":"degraded: unit active, tmux dead","power-on":"power on","power-off":"power off","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…",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","fleet-editor-unavailable":"The editor is available only with the builtin fleet provider.","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-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","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-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-private":"Private: only this device can use its hub connection.","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-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)","node-slug-hint":"routing on slug: {slug}","device-name-label":"Device name","device-name-hint":"how peers see you (editable)","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-external-hint":"External provider: engine/model are configured in the external fleet.","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",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-degraded":"degradada: unit activa, tmux muerto","power-on":"encender","power-off":"apagar","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…",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","fleet-editor-unavailable":"El editor solo está disponible con el proveedor builtin.","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-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","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-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-private":"Privado: solo este dispositivo puede usar la conexión al hub.","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-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)","node-slug-hint":"enrutado por slug: {slug}","device-name-label":"Nombre del dispositivo","device-name-hint":"cómo te ven los pares (editable)","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-external-hint":"Proveedor externo: motor/modelo se configuran en el fleet externo.","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 Tu(){const e=xv(),t=e?e.getItem(Cv):null;return Bh.includes(t)?t:ka}function Bw(e){const t=xv();if(t)try{t.setItem(Cv,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(ju))}function _(e){const t=Tu(),n=ga[t]||ga[ka];return Object.prototype.hasOwnProperty.call(n,e)?n[e]:Object.prototype.hasOwnProperty.call(ga[ka],e)?ga[ka][e]:e}function Aw(e){return typeof window>"u"?()=>{}:(window.addEventListener(ju,e),()=>window.removeEventListener(ju,e))}const kv=Bh;function Si(){return[M.useSyncExternalStore(Aw,Tu,Tu),Bw]}function Ba({cell:e,token:t,route:n=[],onConfirm:s,onClose:o}){var U,R;Si();const l=!!(e&&e.active),u=Array.isArray(n)?n.join("/"):"",[d,p]=M.useState([]),[m,S]=M.useState(!1);M.useEffect(()=>{let H=!0;return(async()=>{if(t)try{const I=await hr(t,u?u.split("/"):[]);if(!H)return;if(S(I.provider==="builtin"&&(I.capabilities||[]).includes("edit")),I.provider==="builtin"&&(I.capabilities||[]).includes("definitions")){const q=await Dh(t,u?u.split("/"):[]);if(!H)return;const X=new Map((I.engines||[]).map(D=>[D.id,D]));p((q.engines||[]).map(D=>{var Q,se,re,ae,le,de,ve;return{id:D.id,label:D.label||D.id,client:((Q=D.managed)==null?void 0:Q.client)||"",models:[...new Set([...((se=X.get(D.id))==null?void 0:se.models)||[],...((re=D.managedInfo)==null?void 0:re.models)||[]])].filter(Boolean),defaultModel:((ae=D.managed)==null?void 0:ae.model)||((le=D.managedInfo)==null?void 0:le.defaultModel)||"",policyDefault:((de=D.managed)==null?void 0:de.permissionPolicy)||((ve=D.managed)!=null&&ve.client&&D.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{H=!1}},[t,u]);const w=(e==null?void 0:e.engine)||((U=d[0])==null?void 0:U.id)||"",y=H=>(e==null?void 0:e.models)&&e.models[H]||"",v=H=>{const I=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[H];if(I==="standard"||I==="unsafe")return I;const q=d.find(X=>X.id===H);return q?q.policyDefault:"standard"},[C,b]=M.useState(w),[k,N]=M.useState((e==null?void 0:e.model)||""),L=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((R=e==null?void 0:e.permissionPolicies)==null?void 0:R[e==null?void 0:e.engine])||"",[A,B]=M.useState(L),[ee,O]=M.useState((e==null?void 0:e.boot)??!0),[F,Z]=M.useState(!1),[W,G]=M.useState(null);M.useEffect(()=>{d.length&&(b(H=>H||w),N(H=>H||y((e==null?void 0:e.engine)||w)||""),B(H=>H==="standard"||H==="unsafe"?H:v((e==null?void 0:e.engine)||w)))},[d.length]);const K=M.useMemo(()=>d.find(H=>H.id===C)||null,[d,C]),P=!!(K&&["claude","codex","codex-vl"].includes(K.client));function E(H){b(H);const I=d.find(q=>q.id===H);N(y(H)||(I==null?void 0:I.defaultModel)||""),B(v(H))}async function j(H){H.preventDefault(),Z(!0),G(null);try{if(l)await s({action:"down",boot:ee});else{const I=A==="standard"||A==="unsafe"?A:(K==null?void 0:K.policyDefault)||"standard";await s({action:"up",...m?{engine:C,model:k||"",...P?{permissionPolicy:I}:(K==null?void 0:K.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:ee})}o()}catch(I){G(String(I&&I.message||I)),Z(!1)}}return h.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:o,children:h.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:H=>H.stopPropagation(),onSubmit:j,children:[h.jsxs("div",{className:"nc-sheet-head",children:[h.jsx("b",{children:e==null?void 0:e.cell}),h.jsx("span",{className:"nc-sheet-state",children:_(l?"state-on":"state-off")})]}),l?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:_("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[_("model"),": ",e.model]}),h.jsx("small",{children:_("power-on-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:ee,onChange:H=>O(H.target.checked)}),_("remove-boot")]})]}):h.jsxs(h.Fragment,{children:[m&&d.length>0?h.jsxs("div",{className:"nc-launch-fields",children:[h.jsxs("label",{className:"nc-field",children:[_("engine"),h.jsx("select",{value:C,onChange:H=>E(H.target.value),children:d.map(H=>h.jsx("option",{value:H.id,children:H.label},H.id))})]}),h.jsxs("label",{className:"nc-field",children:[_("model"),h.jsx("input",{value:k,list:"nc-launch-models",placeholder:_("model-default"),onChange:H=>N(H.target.value)}),h.jsx("datalist",{id:"nc-launch-models",children:((K==null?void 0:K.models)||[]).map(H=>h.jsx("option",{value:H},H))})]}),P?h.jsxs("label",{className:"nc-field",children:[_("permissions"),h.jsxs("select",{value:A,onChange:H=>B(H.target.value),children:[h.jsx("option",{value:"standard",children:_("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:_("fleet-unsafe-permissions")})]})]}):h.jsx("small",{className:"nc-note",children:_("fleet-standard-permissions")}),P&&A==="unsafe"&&h.jsx("small",{className:"nc-err",children:_("fleet-unsafe-warning")}),h.jsx("small",{className:"nc-note",children:_("launch-engine-help")})]}):h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:_("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[_("model"),": ",e.model]}),h.jsx("small",{children:_("launch-external-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:ee,onChange:H=>O(H.target.checked)}),_("boot-persist")]})]}),W&&h.jsx("div",{className:"nc-err",children:W}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:F,children:_("cancel")}),h.jsx("button",{type:"submit",className:"nc-btn primary",disabled:F,children:_(l?"power-off":"save-and-start")})]})]})})}const Iw=4e3;function Ah(e,t=!0){const[n,s]=M.useState([]),o=M.useRef({});return M.useEffect(()=>{if(!t||!e){s([]);return}let l=!0;async function u(){var b;let p=[],m=[];if(await Promise.all([cv(e).then(k=>{p=Array.isArray(k.nodes)?k.nodes:[]}).catch(()=>{}),pw(e).then(k=>{m=Array.isArray(k.nodes)?k.nodes:[]}).catch(()=>{})]),!l)return;const S={},w={},y=new Set(p.map(k=>k.name)),v=[];for(const k of p)((b=k.tunnel)==null?void 0:b.status)==="up"&&(k.nodeId||k.paired!==!1)&&(k.direction!=="inbound"||k.shared===!0)&&v.push([k.name]);for(const k of m)!k.stale&&Array.isArray(k.route)&&!(k.route.length===1&&y.has(k.route[0]))&&v.push(k.route);if(await Promise.all(v.map(async k=>{const N=k.join("/");try{S[N]=await uv(e,k)}catch{S[N]={error:"unreachable"}}try{w[N]=await hr(e,k)}catch{w[N]={available:!1}}})),!l)return;const C=Zp({nodes:p,topology:m,remote:S,fleet:w,down:o.current});o.current=Dw(o.current,C,Math.floor(Date.now()/1e3)),s(Zp({nodes:p,topology:m,remote:S,fleet:w,down:o.current}))}u();const d=setInterval(u,Iw);return()=>{l=!1,clearInterval(d)}},[e,t]),n}const tm=52,im=14;function Wr({position:e,itemKey:t,label:n,onMove:s,onStep:o,canMove:l=()=>!0}){const u=M.useRef(null),d=M.useRef(0),[p,m]=M.useState(!1),S=()=>{var k,N,L,A;const b=u.current;(N=(k=b==null?void 0:b.over)==null?void 0:k.classList)==null||N.remove("nc-roster-over"),(A=(L=b==null?void 0:b.source)==null?void 0:L.classList)==null||A.remove("nc-roster-dragging"),d.current&&cancelAnimationFrame(d.current),d.current=0},w=(b=!1)=>{const k=u.current;if(!k)return;const N=k.target;S(),u.current=null,m(!1);try{k.handle.releasePointerCapture(k.pointerId)}catch{}b&&N&&N!==t&&l(t,N)&&s(t,N)},y=(b,k)=>{var ee,O,F,Z,W,G,K,P;const N=u.current;if(!N)return;N.x=b,N.y=k;const L=(O=(ee=document.elementFromPoint(b,k))==null?void 0:ee.closest)==null?void 0:O.call(ee,"[data-roster-key][data-position]"),A=(F=L==null?void 0:L.dataset)==null?void 0:F.rosterKey,B=((Z=L==null?void 0:L.dataset)==null?void 0:Z.position)===e&&A&&A!==t&&l(t,A);N.over!==(B?L:null)&&((G=(W=N.over)==null?void 0:W.classList)==null||G.remove("nc-roster-over"),N.over=B?L:null,(P=(K=N.over)==null?void 0:K.classList)==null||P.add("nc-roster-over")),N.target=B?A:null},v=()=>{const b=u.current;if(!b){d.current=0;return}const k=b.container;if(k){const N=k.getBoundingClientRect(),L=b.y<N.top+tm?-im:b.y>N.bottom-tm?im:0;L&&(k.scrollTop+=L,y(b.x,b.y))}d.current=requestAnimationFrame(v)};M.useEffect(()=>{const b=N=>{N.key==="Escape"&&u.current&&(N.preventDefault(),w(!1))},k=()=>w(!1);return window.addEventListener("keydown",b),window.addEventListener("blur",k),()=>{window.removeEventListener("keydown",b),window.removeEventListener("blur",k),S(),u.current=null}},[t,e]);const C=b=>{var L;if(b.pointerType==="mouse"&&b.button!==0)return;b.preventDefault(),b.stopPropagation(),b.currentTarget.focus({preventScroll:!0});const k=b.currentTarget.closest("[data-roster-key][data-position]"),N=b.currentTarget.closest(".nc-side-scroll, .nc-home-scroll");u.current={pointerId:b.pointerId,handle:b.currentTarget,source:k,container:N,target:null,over:null,x:b.clientX,y:b.clientY},(L=k==null?void 0:k.classList)==null||L.add("nc-roster-dragging");try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}m(!0),d.current=requestAnimationFrame(v)};return h.jsx("button",{type:"button",className:`nc-roster-handle${p?" active":""}`,"aria-label":`${_("reorder")} ${n}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:_("reorder-help"),onClick:b=>{b.preventDefault(),b.stopPropagation()},onDragStart:b=>b.preventDefault(),onKeyDown:b=>{b.key!=="ArrowUp"&&b.key!=="ArrowDown"||(b.preventDefault(),b.stopPropagation(),o(b.key==="ArrowUp"?-1:1))},onPointerDown:C,onPointerMove:b=>{!u.current||b.pointerId!==u.current.pointerId||(b.preventDefault(),b.stopPropagation(),y(b.clientX,b.clientY))},onPointerUp:b=>{!u.current||b.pointerId!==u.current.pointerId||(b.preventDefault(),b.stopPropagation(),w(!0))},onPointerCancel:()=>w(!1),onLostPointerCapture:()=>{u.current&&w(!1)},children:"↕"})}function Aa(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 Uc(e){return e.status==="passive"?_("node-passive"):e.status==="down"?e.downSince?_("tunnel-down-since").replace("{t}",Aa(e.downSince)):_("tunnel-down"):e.status==="unreachable"?_("node-unreachable"):e.status==="offline"?e.lastSeen?_("node-offline-seen").replace("{t}",Aa(e.lastSeen)):_("node-offline"):e.status==="needs-repair"?_("node-needs-repair"):""}function Ow(e){return e?e.status==="healthy"?"on":"warn":null}function nm(e){return e&&(e.detail||e.status)||""}function zw({onPick:e,token:t,onSettings:n}){const[s,o]=Si(),l=Ah(t),[u,d]=M.useState(null),[p,m]=M.useState(null),[S,w]=M.useState(""),[y,v]=M.useState(""),[C,b]=M.useState({bind:"127.0.0.1",port:""}),[k,N]=M.useState([]),[L,A]=M.useState(null),[B,ee]=M.useState(null),[O,F]=M.useState(dv),[Z,W]=M.useState(wv),[G,K]=M.useState(_v);async function P(){try{const he=await(await zt("/api/sessions",t)).json();he.error?(m(he.error),d([])):(m(null),d(he.sessions||[]))}catch(Y){m(String(Y)),d([])}try{const Y=await hr(t);N(Y.available?Y.cells||[]:[])}catch{N([])}}M.useEffect(()=>{P(),zt("/api/config",t).then(he=>he.json()).then(he=>{v(he.version||""),b({bind:he.bind||"127.0.0.1",port:he.port||""})}).catch(()=>{});const Y=setInterval(P,4e3);return()=>clearInterval(Y)},[]);async function E(){if(!C.port)return;const Y=`http://${C.bind}:${C.port}/#token=${t}`;try{await navigator.clipboard.writeText(Y)}catch{}}async function j(Y){if(!L)return;const{cell:he}=L,we=Array.isArray(L.route)?L.route:[];Y.action==="up"?await Ph(t,{cell:he,boot:!!Y.boot,...Y.engine?{engine:Y.engine}:{},...Y.model!==void 0?{model:Y.model}:{},...Y.permissionPolicy?{permissionPolicy:Y.permissionPolicy}:{}},we):await ja(t,{cell:he,boot:!!Y.boot},we),P()}async function U(Y,he=[]){try{await Mh(t,Y,he)}catch{return}P()}async function R(Y,he,we=[]){try{await ov(t,Y,he,we)}catch{return}P()}async function H(Y){if(!(!(Y!=null&&Y.direct)||B)){ee(Y.name);try{await jh(t,Y.name,Y.tunnelStatus==="up"?"down":"up")}catch{}ee(null)}}const I=Y=>F(he=>fv(he,Y)),q=Y=>Ta(Z,Y),X=(Y,he)=>W(we=>{const $={...we,[Y]:{...Ta(we,Y),...he}};return bv($)}),D=M.useMemo(()=>(u||[]).map(Y=>{const he=Number(localStorage.getItem(La(Y.name))||0),we=!!(Y.outbox&&Y.outbox.count>0&&Y.outbox.latest>he);return{...Y,fresh:we}}),[u]),Q=M.useMemo(()=>new Map(D.map(Y=>[Y.name,Y])),[D]),se=M.useMemo(()=>new Set(k.map(Y=>Y.tmuxSession)),[k]),re=M.useMemo(()=>D.filter(Y=>!se.has(Y.name)),[D,se]),ae=M.useMemo(()=>[...k.map(Y=>{const he=Q.get(Y.tmuxSession)||{};return{type:"cell",value:Y,key:un([],Y.tmuxSession),label:Y.cell,live:!!Y.tmux,fresh:!!he.fresh,activity:he.activity||0,searchText:`${Y.engine||""} ${Y.key||""} ${he.preview||""}`}}),...re.map(Y=>({type:"session",value:Y,key:un([],Y.name),label:Y.name,live:!0,technical:Y.technical===!0,fresh:!!Y.fresh,activity:Y.activity||0,searchText:`${Y.preview||""} ${Y.cmd||""}`}))],[k,re,Q]),le=q("local"),de=M.useMemo(()=>hn(ae,O,le.filter,Xi(G,"local")).filter(Y=>em(Y,S)),[ae,O,le.filter,S,G]),ve=l.reduce((Y,he)=>Y+(he.cells||[]).length+(he.unmanaged||[]).filter(we=>!we.technical).length,0),Re=hn(ae,O,"all",Xi(G,"local")).length+ve,Fe=u?u.length:0,te=(u||[]).filter(Y=>Y.attached).length,ie=C.port?`${C.bind}:${C.port}`:C.bind;function ye(Y,he,we,$){const fe=O.includes(he),Ce=O.includes(we);if(fe===Ce){if(fe){F(Ee=>pv(Ee,he,we));return}K(Ee=>{var rt;const Ae=((rt=$.find(Be=>Be.key===he))==null?void 0:rt.technical)===!0,mt=hn($,O,Ae?"technical":"all",Xi(Ee,Y)).map(Be=>Be.key);return yv(Sv(Ee,Y,he,we,mt))})}}function Le(Y,he,we,$){var rt;const fe=((rt=$.find(Be=>Be.key===he))==null?void 0:rt.technical)===!0,Ce=O.includes(he),Ee=hn($,O,fe?"technical":"all",Xi(G,Y)).map(Be=>Be.key).filter(Be=>O.includes(Be)===Ce),Ae=Ee.indexOf(he),mt=Ee[Ae+we];Ae>=0&&mt&&ye(Y,he,mt,$)}function je(Y,he=null,we=ae){var mt,rt;const $=Array.isArray(he==null?void 0:he.route)?he.route:[],fe=$.join("/"),Ce=fe||"local",Ee=(Be,We)=>O.includes(Be)===O.includes(We);if(Y.type==="cell"){const Be=Y.value,We=$.length?((he==null?void 0:he.sessions)||[]).find(me=>me.name===Be.tmuxSession):Q.get(Be.tmuxSession),Ie=(We==null?void 0:We.preview)||Be.preview||"",bt=[`${Be.engine}${Be.key?`·${Be.key}`:""}`,Ie,Be.active?"":_("cell-off")].filter(Boolean).join(" · "),Ge=$.length===0||((he==null?void 0:he.capabilities)||[]).includes(Be.active?"down":"up");return h.jsxs("div",{className:"nc-mcard","data-roster-key":Y.key,"data-position":Ce,children:[h.jsx(Wr,{position:Ce,itemKey:Y.key,label:Be.cell,canMove:Ee,onMove:(me,qe)=>ye(Ce,me,qe,we),onStep:me=>Le(Ce,Y.key,me,we)}),h.jsxs("button",{className:"nc-mcard-main",onClick:()=>Be.tmux&&e($.length?{session:Be.tmuxSession,node:fe}:Be.tmuxSession),title:Be.degraded?_("cell-degraded"):Be.tmux?_("cell-on"):_("cell-off"),children:[h.jsx("span",{className:`dot ${Be.degraded?"warn":Be.tmux?"on":""}`}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:Be.cell}),h.jsx("small",{children:bt})]})]}),Y.activity?h.jsx("span",{className:"nc-rel",children:Aa(Y.activity)}):null,Y.fresh&&((mt=We==null?void 0:We.outbox)==null?void 0:mt.count)>0&&h.jsx("span",{className:"nc-badge",title:_("new-files-outbox"),children:We.outbox.count}),h.jsx("button",{className:`nc-act pin${O.includes(Y.key)?" on":""}`,"aria-label":`${_("pin")} ${Be.cell}`,title:_("pin"),onClick:()=>I(Y.key),children:O.includes(Y.key)?"★":"☆"}),Ge&&h.jsx("button",{className:`nc-act power${Be.tmux?" on":""}${Be.degraded?" warn":""}`,onClick:()=>A($.length?{...Be,route:$,availableEngines:(he==null?void 0:he.engines)||[]}:Be),title:Be.active?_("power-off"):_("power-on"),"aria-label":`${Be.active?_("power-off"):_("power-on")} ${Be.cell}`,children:h.jsx(tt,{name:"power",size:16})})]},Y.key)}const Ae=Y.value;return h.jsxs("div",{className:"nc-mcard","data-roster-key":Y.key,"data-position":Ce,children:[h.jsx(Wr,{position:Ce,itemKey:Y.key,label:Ae.name,canMove:Ee,onMove:(Be,We)=>ye(Ce,Be,We,we),onStep:Be=>Le(Ce,Y.key,Be,we)}),h.jsxs("button",{className:"nc-mcard-main",onClick:()=>e($.length?{session:Ae.name,node:fe}:Ae.name),children:[h.jsx("span",{className:Ae.attached?"dot on":"dot"}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:Ae.name}),h.jsx("small",{children:Ae.preview?Ae.preview:Ae.cmd?Ae.cmd:_("windows").replace("{n}",String(Ae.windows||0))})]})]}),Y.activity?h.jsx("span",{className:"nc-rel",children:Aa(Y.activity)}):null,Y.fresh&&((rt=Ae.outbox)==null?void 0:rt.count)>0&&h.jsx("span",{className:"nc-badge",title:_("new-files-outbox"),children:Ae.outbox.count}),h.jsx("button",{className:`nc-act pin${O.includes(Y.key)?" on":""}`,"aria-label":`${_("pin")} ${Ae.name}`,title:_("pin"),onClick:()=>I(Y.key),children:O.includes(Y.key)?"★":"☆"}),h.jsx("button",{className:`nc-act technical${Ae.technical?" on":""}`,title:Ae.technical?_("mark-normal"):_("mark-technical"),"aria-label":`${Ae.technical?_("mark-normal"):_("mark-technical")} ${Ae.name}`,onClick:()=>R(Ae.name,!Ae.technical,$),children:"T"}),h.jsx("button",{className:"nc-menu",title:_("terminate"),"aria-label":`${_("terminate")} ${Ae.name}`,onClick:()=>{window.confirm(_("terminate-confirm").replace("{name}",Ae.name))&&U(Ae.name,$)},children:"⋯"})]},Y.key)}return h.jsxs("div",{className:"nc-home",children:[h.jsxs("header",{className:"nc-home-head",children:[h.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",h.jsx("span",{className:"nc-cursor"})]}),h.jsxs("div",{className:"nc-home-sub",children:[_("fleet-tmux")," · ",Fe," ",_("sessions"),te>0&&` · ${te} attached`]}),h.jsxs("span",{className:"nc-head-actions",children:[h.jsx("button",{className:"nc-refresh",onClick:()=>n("nodes",!1),title:_("settings"),children:h.jsx(tt,{name:"gear",size:18})}),h.jsx("button",{className:"nc-refresh",onClick:P,title:_("refresh"),children:h.jsx(tt,{name:"refresh",size:18})})]})]}),h.jsxs("main",{className:"nc-home-scroll",children:[Re>8&&h.jsx("input",{className:"nc-filter",type:"search",placeholder:_("filter-placeholder"),"aria-label":_("filter-placeholder"),value:S,onChange:Y=>w(Y.target.value)}),p&&h.jsx("div",{className:"nc-err",children:p}),h.jsxs("section",{className:"nc-group","data-position":"local",children:[h.jsx(rm,{label:_("position-local"),count:de.length,state:le,dotClass:"on",onToggle:()=>X("local",{open:!le.open}),onFilter:Y=>X("local",{filter:Y})}),le.open&&de.map(Y=>je(Y,null,ae)),le.open&&u===null&&h.jsx("div",{className:"nc-empty",children:_("loading-fleet")}),le.open&&u!==null&&de.length===0&&!p&&h.jsx("div",{className:"nc-empty",children:S?_("no-match").replace("{q}",S):_("no-sessions-short")})]}),l.map(Y=>{const we=Ow(Y.health)||(Y.status==="up"?"on":Y.status==="passive"?"":"warn"),$=Y.health?nm(Y.health):Y.status==="up"?"":Uc(Y),fe=Y.route||[Y.name],Ce=fe.join("/"),Ee=q(Ce),Ae=new Map((Y.sessions||[]).map(Ie=>[Ie.name,Ie])),mt=Ie=>{const bt=Number(localStorage.getItem(La(un(fe,Ie.name)))||0);return!!(Ie.outbox&&Ie.outbox.count>0&&Ie.outbox.latest>bt)},rt=[...(Y.cells||[]).map(Ie=>{const bt=Ae.get(Ie.tmuxSession)||{};return{type:"cell",value:Ie,key:un(fe,Ie.tmuxSession||Ie.cell),label:Ie.cell,live:!!Ie.tmux,fresh:mt({...bt,name:Ie.tmuxSession||Ie.cell}),activity:bt.activity||Ie.activity||0,searchText:`${Ie.engine||""} ${Ie.key||""} ${bt.preview||Ie.preview||""}`}}),...(Y.unmanaged||[]).map(Ie=>({type:"session",value:Ie,key:un(fe,Ie.name),label:Ie.name,live:!0,technical:Ie.technical===!0,fresh:mt(Ie),activity:Ie.activity||0,searchText:`${Ie.preview||""} ${Ie.cmd||""}`}))],Be=hn(rt,O,Ee.filter,Xi(G,Ce)).filter(Ie=>em(Ie,S)),We=Y.direct&&Y.health&&Y.health.managed!==!1?h.jsx("button",{type:"button",className:`nc-act power${Y.tunnelStatus==="up"?" on":""}`,disabled:B===Y.name,title:Y.tunnelStatus==="up"?_("power-off"):_("power-on"),"aria-label":`${Y.tunnelStatus==="up"?_("power-off"):_("power-on")} ${Y.label||Y.name}`,onClick:()=>H(Y),children:h.jsx(tt,{name:"power",size:15})}):null;return h.jsxs("section",{className:"nc-group","data-position":Ce,children:[h.jsx(rm,{label:Y.label||Y.name,count:Be.length,state:Ee,dotClass:we,dotTitle:$,detail:Y.status==="up"?"":Y.health&&nm(Y.health)||Uc(Y),onToggle:()=>X(Ce,{open:!Ee.open}),onFilter:Ie=>X(Ce,{filter:Ie}),action:We}),Y.status==="up"&&Ee.open&&Be.map(Ie=>je(Ie,Y,rt)),Y.status==="up"&&Ee.open&&Be.length===0&&h.jsx("div",{className:"nc-empty",children:S?_("no-match").replace("{q}",S):_("no-sessions-short")})]},`nodo-${Ce}`)}),h.jsxs("footer",{className:"nc-home-foot",onClick:E,title:_("copy-url"),children:[h.jsxs("span",{className:"nc-home-meta",children:[y&&h.jsxs("span",{className:"nc-home-version",children:["v",y]}),h.jsxs("span",{className:"nc-home-endpoint",children:[ie," · ",_("ssh-only")]})]}),h.jsx("span",{className:"nc-lang",onClick:Y=>Y.stopPropagation(),children:kv.map((Y,he)=>h.jsxs("span",{children:[he>0&&" · ",h.jsx("button",{className:`nc-lang-btn${s===Y?" on":""}`,onClick:()=>o(Y),title:Y,children:Y.toUpperCase()})]},Y))})]})]}),h.jsx("button",{className:"nc-fab",onClick:()=>n("fleet",!0),title:_("fleet-new-cell"),"aria-label":_("fleet-new-cell"),children:"+"}),L&&h.jsx(Ba,{cell:L,token:t,route:Array.isArray(L.route)?L.route:[],onConfirm:j,onClose:()=>A(null)})]})}function rm({label:e,count:t,state:n,dotClass:s="",dotTitle:o="",detail:l="",onToggle:u,onFilter:d,action:p=null}){return h.jsxs("div",{className:"nc-mobile-position-head",children:[h.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:u,"aria-expanded":n.open,"aria-label":`${e} · ${_("node-sessions").replace("{n}",String(t))}`,children:[h.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:n.open?"⌄":"›"}),h.jsx("span",{className:`dot ${s}`,title:o}),h.jsxs("span",{className:"nc-mobile-position-copy",children:[h.jsx("b",{children:e}),h.jsx("small",{children:l||_("node-sessions").replace("{n}",String(t))})]})]}),h.jsxs("select",{className:"nc-mobile-position-filter",value:n.filter,"aria-label":`${e} · ${_("filter-placeholder")}`,title:_(`view-${n.filter}`),onChange:m=>d(m.target.value),children:[h.jsx("option",{value:"all",children:_("view-all")}),h.jsx("option",{value:"pinned",children:_("view-pinned")}),h.jsx("option",{value:"active",children:_("view-active")}),h.jsx("option",{value:"off",children:_("view-off")}),h.jsx("option",{value:"technical",children:_("view-technical")})]}),p]})}/**
|
|
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 Ev=Object.defineProperty,Fw=Object.getOwnPropertyDescriptor,Hw=(e,t)=>{for(var n in t)Ev(e,n,{get:t[n],enumerable:!0})},_t=(e,t,n,s)=>{for(var o=s>1?void 0:s?Fw(t,n):t,l=e.length-1,u;l>=0;l--)(u=e[l])&&(o=(s?u(t,n,o):u(o))||o);return s&&o&&Ev(t,n,o),o},xe=(e,t)=>(n,s)=>t(n,s,e),sm="Terminal input",Bu={get:()=>sm,set:e=>sm=e},om="Too much output to announce, navigate to rows manually to read",Au={get:()=>om,set:e=>om=e};function $w(e){return e.replace(/\r?\n/g,"\r")}function Ww(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Uw(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Kw(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");Nv(o,t,n,s)}}function Nv(e,t,n,s){e=$w(e),e=Ww(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function Rv(e,t,n){let s=n.getBoundingClientRect(),o=e.clientX-s.left-10,l=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${l}px`,t.style.zIndex="1000",t.focus()}function am(e,t,n,s,o){Rv(e,t,n),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function On(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Ya(e,t=0,n=e.length){let s="";for(let o=t;o<n;++o){let l=e[o];l>65535?(l-=65536,s+=String.fromCharCode((l>>10)+55296)+String.fromCharCode(l%1024+56320)):s+=String.fromCharCode(l)}return s}var qw=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,o=0;if(this._interim){let l=e.charCodeAt(o++);56320<=l&&l<=57343?t[s++]=(this._interim-55296)*1024+l-56320+65536:(t[s++]=this._interim,t[s++]=l),this._interim=0}for(let l=o;l<n;++l){let u=e.charCodeAt(l);if(55296<=u&&u<=56319){if(++l>=n)return this._interim=u,s;let d=e.charCodeAt(l);56320<=d&&d<=57343?t[s++]=(u-55296)*1024+d-56320+65536:(t[s++]=u,t[s++]=d);continue}u!==65279&&(t[s++]=u)}return s}},Vw=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,o,l,u,d,p=0,m=0;if(this.interim[0]){let y=!1,v=this.interim[0];v&=(v&224)===192?31:(v&240)===224?15:7;let C=0,b;for(;(b=this.interim[++C]&63)&&C<4;)v<<=6,v|=b;let k=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,N=k-C;for(;m<N;){if(m>=n)return 0;if(b=e[m++],(b&192)!==128){m--,y=!0;break}else this.interim[C++]=b,v<<=6,v|=b&63}y||(k===2?v<128?m--:t[s++]=v:k===3?v<2048||v>=55296&&v<=57343||v===65279||(t[s++]=v):v<65536||v>1114111||(t[s++]=v)),this.interim.fill(0)}let S=n-4,w=m;for(;w<n;){for(;w<S&&!((o=e[w])&128)&&!((l=e[w+1])&128)&&!((u=e[w+2])&128)&&!((d=e[w+3])&128);)t[s++]=o,t[s++]=l,t[s++]=u,t[s++]=d,w+=4;if(o=e[w++],o<128)t[s++]=o;else if((o&224)===192){if(w>=n)return this.interim[0]=o,s;if(l=e[w++],(l&192)!==128){w--;continue}if(p=(o&31)<<6|l&63,p<128){w--;continue}t[s++]=p}else if((o&240)===224){if(w>=n)return this.interim[0]=o,s;if(l=e[w++],(l&192)!==128){w--;continue}if(w>=n)return this.interim[0]=o,this.interim[1]=l,s;if(u=e[w++],(u&192)!==128){w--;continue}if(p=(o&15)<<12|(l&63)<<6|u&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[s++]=p}else if((o&248)===240){if(w>=n)return this.interim[0]=o,s;if(l=e[w++],(l&192)!==128){w--;continue}if(w>=n)return this.interim[0]=o,this.interim[1]=l,s;if(u=e[w++],(u&192)!==128){w--;continue}if(w>=n)return this.interim[0]=o,this.interim[1]=l,this.interim[2]=u,s;if(d=e[w++],(d&192)!==128){w--;continue}if(p=(o&7)<<18|(l&63)<<12|(u&63)<<6|d&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},Pv="",zn=" ",eo=class Dv{constructor(){this.fg=0,this.bg=0,this.extended=new Ia}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 Dv;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}},Ia=class Mv{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Mv(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Di=class Lv extends eo{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ia,this.combinedData=""}static fromCharData(t){let n=new Lv;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?On(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(s-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},lm="di$target",Iu="di$dependencies",Kc=new Map;function Yw(e){return e[Iu]||[]}function Ft(e){if(Kc.has(e))return Kc.get(e);let t=function(n,s,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Xw(t,n,o)};return t._id=e,Kc.set(e,t),t}function Xw(e,t,n){t[lm]===t?t[Iu].push({id:e,index:n}):(t[Iu]=[{id:e,index:n}],t[lm]=t)}var ei=Ft("BufferService"),jv=Ft("CoreMouseService"),dr=Ft("CoreService"),Gw=Ft("CharsetService"),Ih=Ft("InstantiationService"),Tv=Ft("LogService"),ti=Ft("OptionsService"),Bv=Ft("OscLinkService"),Qw=Ft("UnicodeService"),to=Ft("DecorationService"),Ou=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var S;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,l=new Di,u=n.getTrimmedLength(),d=-1,p=-1,m=!1;for(let w=0;w<u;w++)if(!(p===-1&&!n.hasContent(w))){if(n.loadCell(w,l),l.hasExtendedAttrs()&&l.extended.urlId)if(p===-1){p=w,d=l.extended.urlId;continue}else m=l.extended.urlId!==d;else p!==-1&&(m=!0);if(m||p!==-1&&w===u-1){let y=(S=this._oscLinkService.getLinkData(d))==null?void 0:S.uri;if(y){let v={start:{x:p+1,y:e},end:{x:w+(!m&&w===u-1?1:0),y:e}},C=!1;if(!(o!=null&&o.allowNonHttpProtocols))try{let b=new URL(y);["http:","https:"].includes(b.protocol)||(C=!0)}catch{C=!0}C||s.push({text:y,range:v,activate:(b,k)=>o?o.activate(b,k,v):Jw(b,k),hover:(b,k)=>{var N;return(N=o==null?void 0:o.hover)==null?void 0:N.call(o,b,k,v)},leave:(b,k)=>{var N;return(N=o==null?void 0:o.leave)==null?void 0:N.call(o,b,k,v)}})}m=!1,l.hasExtendedAttrs()&&l.extended.urlId?(p=w,d=l.extended.urlId):(p=-1,d=-1)}}t(s)}};Ou=_t([xe(0,ei),xe(1,ti),xe(2,Bv)],Ou);function Jw(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
52
|
-
|
|
53
|
-
WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Xa=Ft("CharSizeService"),fn=Ft("CoreBrowserService"),Oh=Ft("MouseService"),pn=Ft("RenderService"),Zw=Ft("SelectionService"),Av=Ft("CharacterJoinerService"),Gr=Ft("ThemeService"),Iv=Ft("LinkProviderService"),e0=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?cm.isErrorNoTelemetry(e)?new cm(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)}},t0=new e0;function Ea(e){i0(e)||t0.onUnexpectedError(e)}var zu="Canceled";function i0(e){return e instanceof n0?!0:e instanceof Error&&e.name===zu&&e.message===zu}var n0=class extends Error{constructor(){super(zu),this.name=this.message}};function r0(e){return new Error(`Illegal argument: ${e}`)}var cm=class Fu extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Fu)return t;let n=new Fu;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Hu=class Ov extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Ov.prototype)}};function gi(e,t=0){return e[e.length-(1+t)]}var s0;(e=>{function t(l){return l<0}e.isLessThan=t;function n(l){return l<=0}e.isLessThanOrEqual=n;function s(l){return l>0}e.isGreaterThan=s;function o(l){return l===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(s0||(s0={}));function o0(e,t){let n=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(n,arguments))),o}}var zv;(e=>{function t(B){return B&&typeof B=="object"&&typeof B[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*o(B){yield B}e.single=o;function l(B){return t(B)?B:o(B)}e.wrap=l;function u(B){return B||n}e.from=u;function*d(B){for(let ee=B.length-1;ee>=0;ee--)yield B[ee]}e.reverse=d;function p(B){return!B||B[Symbol.iterator]().next().done===!0}e.isEmpty=p;function m(B){return B[Symbol.iterator]().next().value}e.first=m;function S(B,ee){let O=0;for(let F of B)if(ee(F,O++))return!0;return!1}e.some=S;function w(B,ee){for(let O of B)if(ee(O))return O}e.find=w;function*y(B,ee){for(let O of B)ee(O)&&(yield O)}e.filter=y;function*v(B,ee){let O=0;for(let F of B)yield ee(F,O++)}e.map=v;function*C(B,ee){let O=0;for(let F of B)yield*ee(F,O++)}e.flatMap=C;function*b(...B){for(let ee of B)yield*ee}e.concat=b;function k(B,ee,O){let F=O;for(let Z of B)F=ee(F,Z);return F}e.reduce=k;function*N(B,ee,O=B.length){for(ee<0&&(ee+=B.length),O<0?O+=B.length:O>B.length&&(O=B.length);ee<O;ee++)yield B[ee]}e.slice=N;function L(B,ee=Number.POSITIVE_INFINITY){let O=[];if(ee===0)return[O,B];let F=B[Symbol.iterator]();for(let Z=0;Z<ee;Z++){let W=F.next();if(W.done)return[O,e.empty()];O.push(W.value)}return[O,{[Symbol.iterator](){return F}}]}e.consume=L;async function A(B){let ee=[];for await(let O of B)ee.push(O);return Promise.resolve(ee)}e.asyncToArray=A})(zv||(zv={}));function cr(e){if(zv.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function a0(...e){return ut(()=>cr(e))}function ut(e){return{dispose:o0(()=>{e()})}}var Fv=class Hv{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{cr(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Hv.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)}};Fv.DISABLE_DISPOSED_WARNING=!1;var Fn=Fv,Xe=class{constructor(){this._store=new Fn,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)}};Xe.None=Object.freeze({dispose(){}});var Yr=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}},dn=typeof window=="object"?window:globalThis,$u=class Wu{constructor(t){this.element=t,this.next=Wu.Undefined,this.prev=Wu.Undefined}};$u.Undefined=new $u(void 0);var ft=$u,um=class{constructor(){this._first=ft.Undefined,this._last=ft.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ft.Undefined}clear(){let e=this._first;for(;e!==ft.Undefined;){let t=e.next;e.prev=ft.Undefined,e.next=ft.Undefined,e=t}this._first=ft.Undefined,this._last=ft.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new ft(e);if(this._first===ft.Undefined)this._first=n,this._last=n;else if(t){let o=this._last;this._last=n,n.prev=o,o.next=n}else{let o=this._first;this._first=n,n.next=o,o.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==ft.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ft.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ft.Undefined&&e.next!==ft.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ft.Undefined&&e.next===ft.Undefined?(this._first=ft.Undefined,this._last=ft.Undefined):e.next===ft.Undefined?(this._last=this._last.prev,this._last.next=ft.Undefined):e.prev===ft.Undefined&&(this._first=this._first.next,this._first.prev=ft.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ft.Undefined;)yield e.element,e=e.next}},l0=globalThis.performance&&typeof globalThis.performance.now=="function",c0=class $v{static create(t){return new $v(t)}constructor(t){this._now=l0&&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}},Ut;(e=>{e.None=()=>Xe.None;function t(P,E){return w(P,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function n(P){return(E,j=null,U)=>{let R=!1,H;return H=P(I=>{if(!R)return H?H.dispose():R=!0,E.call(j,I)},null,U),R&&H.dispose(),H}}e.once=n;function s(P,E,j){return m((U,R=null,H)=>P(I=>U.call(R,E(I)),null,H),j)}e.map=s;function o(P,E,j){return m((U,R=null,H)=>P(I=>{E(I),U.call(R,I)},null,H),j)}e.forEach=o;function l(P,E,j){return m((U,R=null,H)=>P(I=>E(I)&&U.call(R,I),null,H),j)}e.filter=l;function u(P){return P}e.signal=u;function d(...P){return(E,j=null,U)=>{let R=a0(...P.map(H=>H(I=>E.call(j,I))));return S(R,U)}}e.any=d;function p(P,E,j,U){let R=j;return s(P,H=>(R=E(R,H),R),U)}e.reduce=p;function m(P,E){let j,U={onWillAddFirstListener(){j=P(R.fire,R)},onDidRemoveLastListener(){j==null||j.dispose()}},R=new be(U);return E==null||E.add(R),R.event}function S(P,E){return E instanceof Array?E.push(P):E&&E.add(P),P}function w(P,E,j=100,U=!1,R=!1,H,I){let q,X,D,Q=0,se,re={leakWarningThreshold:H,onWillAddFirstListener(){q=P(le=>{Q++,X=E(X,le),U&&!D&&(ae.fire(X),X=void 0),se=()=>{let de=X;X=void 0,D=void 0,(!U||Q>1)&&ae.fire(de),Q=0},typeof j=="number"?(clearTimeout(D),D=setTimeout(se,j)):D===void 0&&(D=0,queueMicrotask(se))})},onWillRemoveListener(){R&&Q>0&&(se==null||se())},onDidRemoveLastListener(){se=void 0,q.dispose()}},ae=new be(re);return I==null||I.add(ae),ae.event}e.debounce=w;function y(P,E=0,j){return e.debounce(P,(U,R)=>U?(U.push(R),U):[R],E,void 0,!0,void 0,j)}e.accumulate=y;function v(P,E=(U,R)=>U===R,j){let U=!0,R;return l(P,H=>{let I=U||!E(H,R);return U=!1,R=H,I},j)}e.latch=v;function C(P,E,j){return[e.filter(P,E,j),e.filter(P,U=>!E(U),j)]}e.split=C;function b(P,E=!1,j=[],U){let R=j.slice(),H=P(X=>{R?R.push(X):q.fire(X)});U&&U.add(H);let I=()=>{R==null||R.forEach(X=>q.fire(X)),R=null},q=new be({onWillAddFirstListener(){H||(H=P(X=>q.fire(X)),U&&U.add(H))},onDidAddFirstListener(){R&&(E?setTimeout(I):I())},onDidRemoveLastListener(){H&&H.dispose(),H=null}});return U&&U.add(q),q.event}e.buffer=b;function k(P,E){return(j,U,R)=>{let H=E(new L);return P(function(I){let q=H.evaluate(I);q!==N&&j.call(U,q)},void 0,R)}}e.chain=k;let N=Symbol("HaltChainable");class L{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(j=>(E(j),j)),this}filter(E){return this.steps.push(j=>E(j)?j:N),this}reduce(E,j){let U=j;return this.steps.push(R=>(U=E(U,R),U)),this}latch(E=(j,U)=>j===U){let j=!0,U;return this.steps.push(R=>{let H=j||!E(R,U);return j=!1,U=R,H?R:N}),this}evaluate(E){for(let j of this.steps)if(E=j(E),E===N)break;return E}}function A(P,E,j=U=>U){let U=(...q)=>I.fire(j(...q)),R=()=>P.on(E,U),H=()=>P.removeListener(E,U),I=new be({onWillAddFirstListener:R,onDidRemoveLastListener:H});return I.event}e.fromNodeEventEmitter=A;function B(P,E,j=U=>U){let U=(...q)=>I.fire(j(...q)),R=()=>P.addEventListener(E,U),H=()=>P.removeEventListener(E,U),I=new be({onWillAddFirstListener:R,onDidRemoveLastListener:H});return I.event}e.fromDOMEventEmitter=B;function ee(P){return new Promise(E=>n(P)(E))}e.toPromise=ee;function O(P){let E=new be;return P.then(j=>{E.fire(j)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=O;function F(P,E){return P(j=>E.fire(j))}e.forward=F;function Z(P,E,j){return E(j),P(U=>E(U))}e.runAndSubscribe=Z;class W{constructor(E,j){this._observable=E,this._counter=0,this._hasChanged=!1;let U={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new be(U),j&&j.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,j){this._hasChanged=!0}endUpdate(E){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function G(P,E){return new W(P,E).emitter.event}e.fromObservable=G;function K(P){return(E,j,U)=>{let R=0,H=!1,I={beginUpdate(){R++},endUpdate(){R--,R===0&&(P.reportChanges(),H&&(H=!1,E.call(j)))},handlePossibleChange(){},handleChange(){H=!0}};P.addObserver(I),P.reportChanges();let q={dispose(){P.removeObserver(I)}};return U instanceof Fn?U.add(q):Array.isArray(U)&&U.push(q),q}}e.fromObservableLight=K})(Ut||(Ut={}));var Uu=class Ku{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Ku._idPool++}`,Ku.all.add(this)}start(t){this._stopWatch=new c0,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}}};Uu.all=new Set,Uu._idPool=0;var u0=Uu,h0=-1,Wv=class Uv{constructor(t,n,s=(Uv._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n<s)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[l,u]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${u}):`;console.warn(d),console.warn(l);let p=new p0(d,l);this._errorHandler(p)}return()=>{let l=this._stacks.get(t.value)||0;this._stacks.set(t.value,l-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,o]of this._stacks)(!t||n<o)&&(t=[s,o],n=o);return t}};Wv._idPool=1;var d0=Wv,f0=class Kv{constructor(t){this.value=t}static create(){let t=new Error;return new Kv(t.stack??"")}print(){console.warn(this.value.split(`
|
|
58
|
-
`).slice(2).join(`
|
|
59
|
-
`))}},p0=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},m0=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},g0=0,qc=class{constructor(e){this.value=e,this.id=g0++}},v0=2,_0,be=class{constructor(e){var t,n,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new d0((e==null?void 0:e.onListenerError)??Ea,((n=this._options)==null?void 0:n.leakWarningThreshold)??h0):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new u0(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var e,t,n,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||n.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,n)=>{var u,d,p,m,S;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let w=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(w);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],v=new m0(`${w}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((u=this._options)==null?void 0:u.onListenerError)||Ea)(v),Xe.None}if(this._disposed)return Xe.None;t&&(e=e.bind(t));let s=new qc(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=f0.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof qc?(this._deliveryQueue??(this._deliveryQueue=new y0),this._listeners=[this._listeners,s]):this._listeners.push(s):((p=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||p.call(d,this),this._listeners=s,(S=(m=this._options)==null?void 0:m.onDidAddFirstListener)==null||S.call(m,this)),this._size++;let l=ut(()=>{o==null||o(),this._removeListener(s)});return n instanceof Fn?n.add(l):Array.isArray(n)&&n.push(l),l}),this._event}_removeListener(e){var o,l,u,d;if((l=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||l.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(d=(u=this._options)==null?void 0:u.onDidRemoveLastListener)==null||d.call(u,this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let s=this._deliveryQueue.current===this;if(this._size*v0<=t.length){let p=0;for(let m=0;m<t.length;m++)t[m]?t[p++]=t[m]:s&&(this._deliveryQueue.end--,p<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=p}}_deliver(e,t){var s;if(!e)return;let n=((s=this._options)==null?void 0:s.onListenerError)||Ea;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,n,s,o;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof qc)this._deliver(this._listeners,e);else{let l=this._deliveryQueue;l.enqueue(this,e,this._listeners.length),this._deliverQueue(l)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},y0=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},qu=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new be,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new be,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};qu.INSTANCE=new qu;var zh=qu;function S0(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}zh.INSTANCE.onDidChangeZoomLevel;function w0(e){return zh.INSTANCE.getZoomFactor(e)}zh.INSTANCE.onDidChangeFullscreen;var Qr=typeof navigator=="object"?navigator.userAgent:"",Vu=Qr.indexOf("Firefox")>=0,b0=Qr.indexOf("AppleWebKit")>=0,Fh=Qr.indexOf("Chrome")>=0,C0=!Fh&&Qr.indexOf("Safari")>=0;Qr.indexOf("Electron/")>=0;Qr.indexOf("Android")>=0;var Vc=!1;if(typeof dn.matchMedia=="function"){let e=dn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=dn.matchMedia("(display-mode: fullscreen)");Vc=e.matches,S0(dn,e,({matches:n})=>{Vc&&t.matches||(Vc=n)})}var Ur="en",Yu=!1,Xu=!1,Na=!1,qv=!1,va,Ra=Ur,hm=Ur,x0,Oi,ar=globalThis,Wt,iv;typeof ar.vscode<"u"&&typeof ar.vscode.process<"u"?Wt=ar.vscode.process:typeof process<"u"&&typeof((iv=process==null?void 0:process.versions)==null?void 0:iv.node)=="string"&&(Wt=process);var nv,k0=typeof((nv=Wt==null?void 0:Wt.versions)==null?void 0:nv.electron)=="string",E0=k0&&(Wt==null?void 0:Wt.type)==="renderer",rv;if(typeof Wt=="object"){Yu=Wt.platform==="win32",Xu=Wt.platform==="darwin",Na=Wt.platform==="linux",Na&&Wt.env.SNAP&&Wt.env.SNAP_REVISION,Wt.env.CI||Wt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,va=Ur,Ra=Ur;let e=Wt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);va=t.userLocale,hm=t.osLocale,Ra=t.resolvedLanguage||Ur,x0=(rv=t.languagePack)==null?void 0:rv.translationsConfigFile}catch{}qv=!0}else typeof navigator=="object"&&!E0?(Oi=navigator.userAgent,Yu=Oi.indexOf("Windows")>=0,Xu=Oi.indexOf("Macintosh")>=0,(Oi.indexOf("Macintosh")>=0||Oi.indexOf("iPad")>=0||Oi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Na=Oi.indexOf("Linux")>=0,(Oi==null?void 0:Oi.indexOf("Mobi"))>=0,Ra=globalThis._VSCODE_NLS_LANGUAGE||Ur,va=navigator.language.toLowerCase(),hm=va):console.error("Unable to resolve platform.");var Vv=Yu,Qi=Xu,N0=Na,dm=qv,Zi=Oi,Tn=Ra,R0;(e=>{function t(){return Tn}e.value=t;function n(){return Tn.length===2?Tn==="en":Tn.length>=3?Tn[0]==="e"&&Tn[1]==="n"&&Tn[2]==="-":!1}e.isDefaultVariant=n;function s(){return Tn==="en"}e.isDefault=s})(R0||(R0={}));var P0=typeof ar.postMessage=="function"&&!ar.importScripts;(()=>{if(P0){let e=[];ar.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let l=e[s];if(l.id===n.data.vscodeScheduleAsyncWork){e.splice(s,1),l.callback();return}}});let t=0;return n=>{let s=++t;e.push({id:s,callback:n}),ar.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var D0=!!(Zi&&Zi.indexOf("Chrome")>=0);Zi&&Zi.indexOf("Firefox")>=0;!D0&&Zi&&Zi.indexOf("Safari")>=0;Zi&&Zi.indexOf("Edg/")>=0;Zi&&Zi.indexOf("Android")>=0;var zr=typeof navigator=="object"?navigator:{};dm||document.queryCommandSupported&&document.queryCommandSupported("copy")||zr&&zr.clipboard&&zr.clipboard.writeText,dm||zr&&zr.clipboard&&zr.clipboard.readText;var Hh=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}},Yc=new Hh,fm=new Hh,pm=new Hh,M0=new Array(230),Yv;(e=>{function t(d){return Yc.keyCodeToStr(d)}e.toString=t;function n(d){return Yc.strToKeyCode(d)}e.fromString=n;function s(d){return fm.keyCodeToStr(d)}e.toUserSettingsUS=s;function o(d){return pm.keyCodeToStr(d)}e.toUserSettingsGeneral=o;function l(d){return fm.strToKeyCode(d)||pm.strToKeyCode(d)}e.fromUserSettings=l;function u(d){if(d>=98&&d<=113)return null;switch(d){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Yc.keyCodeToStr(d)}e.toElectronAccelerator=u})(Yv||(Yv={}));var L0=class Xv{constructor(t,n,s,o,l){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=o,this.keyCode=l}equals(t){return t instanceof Xv&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${n}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new j0([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},j0=class{constructor(e){if(e.length===0)throw r0("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function T0(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return Yv.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(Vu)switch(t){case 59:return 85;case 60:if(N0)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Qi)return 57;break}else if(b0&&(Qi&&t===93||!Qi&&t===92))return 57;return M0[t]||0}var B0=Qi?256:2048,A0=512,I0=1024,O0=Qi?2048:256,mm=class{constructor(e){var n;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(n=t.getModifierState)==null?void 0:n.call(t,"AltGraph"),this.keyCode=T0(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|=B0),this.altKey&&(t|=A0),this.shiftKey&&(t|=I0),this.metaKey&&(t|=O0),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new L0(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},gm=new WeakMap;function z0(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!=="null"&&n.origin!=="null"&&t.origin!==n.origin)return null}catch{return null}return e.parent}var F0=class{static getSameOriginWindowChain(e){let t=gm.get(e);if(!t){t=[],gm.set(e,t);let n=e,s;do s=z0(n),s?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=s;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,s=0,o=this.getSameOriginWindowChain(e);for(let l of o){let u=l.window.deref();if(n+=(u==null?void 0:u.scrollY)??0,s+=(u==null?void 0:u.scrollX)??0,u===t||!l.iframeElement)break;let d=l.iframeElement.getBoundingClientRect();n+=d.top,s+=d.left}return{top:n,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 n=F0.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},vm=class{constructor(e,t=0,n=0){var o;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let s=!1;if(Fh){let l=navigator.userAgent.match(/Chrome\/(\d+)/);s=(l?parseInt(l[1]):123)<=122}if(e){let l=e,u=e,d=((o=e.view)==null?void 0:o.devicePixelRatio)||1;if(typeof l.wheelDeltaY<"u")s?this.deltaY=l.wheelDeltaY/(120*d):this.deltaY=l.wheelDeltaY/120;else if(typeof u.VERTICAL_AXIS<"u"&&u.axis===u.VERTICAL_AXIS)this.deltaY=-u.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Vu&&!Qi?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof l.wheelDeltaX<"u")C0&&Vv?this.deltaX=-(l.wheelDeltaX/120):s?this.deltaX=l.wheelDeltaX/(120*d):this.deltaX=l.wheelDeltaX/120;else if(typeof u.HORIZONTAL_AXIS<"u"&&u.axis===u.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Vu&&!Qi?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},Gv=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),H0;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof $0?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ut.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Gv})})(H0||(H0={}));var $0=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?Gv:(this._emitter||(this._emitter=new be),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},$h=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 Hu("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Hu("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},W0=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new Hu("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=ut(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},U0;(e=>{async function t(s){let o,l=await Promise.all(s.map(u=>u.then(d=>d,d=>{o||(o=d)})));if(typeof o<"u")throw o;return l}e.settled=t;function n(s){return new Promise(async(o,l)=>{try{await s(o,l)}catch(u){l(u)}})}e.withAsyncBody=n})(U0||(U0={}));var _m=class Ri{static fromArray(t){return new Ri(n=>{n.emitMany(t)})}static fromPromise(t){return new Ri(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Ri(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new Ri(async n=>{await Promise.all(t.map(async s=>{for await(let o of s)n.emitOne(o)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new be,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 Ut.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new Ri(async s=>{for await(let o of t)s.emitOne(n(o))})}map(t){return Ri.map(this,t)}static filter(t,n){return new Ri(async s=>{for await(let o of t)n(o)&&s.emitOne(o)})}filter(t){return Ri.filter(this,t)}static coalesce(t){return Ri.filter(t,n=>!!n)}coalesce(){return Ri.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return Ri.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())}};_m.EMPTY=_m.fromArray([]);var{getWindow:Gi,getWindowId:K0,onDidRegisterWindow:q0}=(function(){let e=new Map,t={window:dn,disposables:new Fn};e.set(dn.vscodeWindowId,t);let n=new be,s=new be,o=new be;function l(u,d){return(typeof u=="number"?e.get(u):void 0)??(d?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(u){if(e.has(u.vscodeWindowId))return Xe.None;let d=new Fn,p={window:u,disposables:d.add(new Fn)};return e.set(u.vscodeWindowId,p),d.add(ut(()=>{e.delete(u.vscodeWindowId),s.fire(u)})),d.add($e(u,Bt.BEFORE_UNLOAD,()=>{o.fire(u)})),n.fire(p),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:l,getWindow(u){var m;let d=u;if((m=d==null?void 0:d.ownerDocument)!=null&&m.defaultView)return d.ownerDocument.defaultView.window;let p=u;return p!=null&&p.view?p.view.window:dn},getDocument(u){return Gi(u).document}}})(),V0=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function $e(e,t,n,s){return new V0(e,t,n,s)}var ym=function(e,t,n,s){return $e(e,t,n,s)},Wh,Y0=class extends W0{constructor(e){super(),this.defaultTarget=e&&Gi(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Sm=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){Ea(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,o=l=>{n.set(l,!1);let u=e.get(l)??[];for(t.set(l,u),e.set(l,[]),s.set(l,!0);u.length>0;)u.sort(Sm.sort),u.shift().execute();s.set(l,!1)};Wh=(l,u,d=0)=>{let p=K0(l),m=new Sm(u,d),S=e.get(p);return S||(S=[],e.set(p,S)),S.push(m),n.get(p)||(n.set(p,!0),l.requestAnimationFrame(()=>o(p))),m}})();function X0(e){let t=e.getBoundingClientRect(),n=Gi(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Bt={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"},G0=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let n=li(t);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let n=li(t);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(t){let n=li(t);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(t){let n=li(t);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(t){let n=li(t);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(t){let n=li(t);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(t){let n=li(t);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(t){let n=li(t);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let n=li(t);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let n=li(t);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let n=li(t);this._paddingRight!==n&&(this._paddingRight=n,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let n=li(t);this._fontSize!==n&&(this._fontSize=n,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let n=li(t);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let n=li(t);this._letterSpacing!==n&&(this._letterSpacing=n,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,n){this.domNode.classList.toggle(t,n),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,n){this.domNode.setAttribute(t,n)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function li(e){return typeof e=="number"?`${e}px`:e}function Gs(e){return new G0(e)}var Qv=class{constructor(){this._hooks=new Fn,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let l=e;try{e.setPointerCapture(t),this._hooks.add(ut(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{l=Gi(e)}this._hooks.add($e(l,Bt.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add($e(l,Bt.POINTER_UP,u=>this.stopMonitoring(!0)))}};function Q0(e,t,n){let s=null,o=null;if(typeof n.value=="function"?(s="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",o=n.get),!o)throw new Error("not supported");let l=`$memoize$${t}`;n[s]=function(...u){return this.hasOwnProperty(l)||Object.defineProperty(this,l,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,u)}),this[l]}}var Yi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Yi||(Yi={}));var Ks=class Gt extends Xe{constructor(){super(),this.dispatched=!1,this.targets=new um,this.ignoreTargets=new um,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ut.runAndSubscribe(q0,({window:t,disposables:n})=>{n.add($e(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add($e(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add($e(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:dn,disposables:this._store}))}static addTarget(t){if(!Gt.isTouchDevice())return Xe.None;Gt.INSTANCE||(Gt.INSTANCE=new Gt);let n=Gt.INSTANCE.targets.push(t);return ut(n)}static ignoreTarget(t){if(!Gt.isTouchDevice())return Xe.None;Gt.INSTANCE||(Gt.INSTANCE=new Gt);let n=Gt.INSTANCE.ignoreTargets.push(t);return ut(n)}static isTouchDevice(){return"ontouchstart"in dn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,o=t.targetTouches.length;s<o;s++){let l=t.targetTouches.item(s);this.activeTouches[l.identifier]={id:l.identifier,initialTarget:l.target,initialTimeStamp:n,initialPageX:l.pageX,initialPageY:l.pageY,rollingTimestamps:[n],rollingPageX:[l.pageX],rollingPageY:[l.pageY]};let u=this.newGestureEvent(Yi.Start,l.target);u.pageX=l.pageX,u.pageY=l.pageY,this.dispatchEvent(u)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let l=0,u=n.changedTouches.length;l<u;l++){let d=n.changedTouches.item(l);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("move of an UNKNOWN touch",d);continue}let p=this.activeTouches[d.identifier],m=Date.now()-p.initialTimeStamp;if(m<Gt.HOLD_DELAY&&Math.abs(p.initialPageX-gi(p.rollingPageX))<30&&Math.abs(p.initialPageY-gi(p.rollingPageY))<30){let S=this.newGestureEvent(Yi.Tap,p.initialTarget);S.pageX=gi(p.rollingPageX),S.pageY=gi(p.rollingPageY),this.dispatchEvent(S)}else if(m>=Gt.HOLD_DELAY&&Math.abs(p.initialPageX-gi(p.rollingPageX))<30&&Math.abs(p.initialPageY-gi(p.rollingPageY))<30){let S=this.newGestureEvent(Yi.Contextmenu,p.initialTarget);S.pageX=gi(p.rollingPageX),S.pageY=gi(p.rollingPageY),this.dispatchEvent(S)}else if(o===1){let S=gi(p.rollingPageX),w=gi(p.rollingPageY),y=gi(p.rollingTimestamps)-p.rollingTimestamps[0],v=S-p.rollingPageX[0],C=w-p.rollingPageY[0],b=[...this.targets].filter(k=>p.initialTarget instanceof Node&&k.contains(p.initialTarget));this.inertia(t,b,s,Math.abs(v)/y,v>0?1:-1,S,Math.abs(C)/y,C>0?1:-1,w)}this.dispatchEvent(this.newGestureEvent(Yi.End,p.initialTarget)),delete this.activeTouches[d.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===Yi.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>Gt.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===Yi.Change||t.type===Yi.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let o=0,l=t.initialTarget;for(;l&&l!==s;)o++,l=l.parentElement;n.push([o,s])}n.sort((s,o)=>s[0]-o[0]);for(let[s,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,o,l,u,d,p,m){this.handle=Wh(t,()=>{let S=Date.now(),w=S-s,y=0,v=0,C=!0;o+=Gt.SCROLL_FRICTION*w,d+=Gt.SCROLL_FRICTION*w,o>0&&(C=!1,y=l*o*w),d>0&&(C=!1,v=p*d*w);let b=this.newGestureEvent(Yi.Change);b.translationX=y,b.translationY=v,n.forEach(k=>k.dispatchEvent(b)),C||this.inertia(t,n,S,o,l,u+y,d,p,m+v)})}onTouchMove(t){let n=Date.now();for(let s=0,o=t.changedTouches.length;s<o;s++){let l=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("end of an UNKNOWN touch",l);continue}let u=this.activeTouches[l.identifier],d=this.newGestureEvent(Yi.Change,u.initialTarget);d.translationX=l.pageX-gi(u.rollingPageX),d.translationY=l.pageY-gi(u.rollingPageY),d.pageX=l.pageX,d.pageY=l.pageY,this.dispatchEvent(d),u.rollingPageX.length>3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(l.pageX),u.rollingPageY.push(l.pageY),u.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ks.SCROLL_FRICTION=-.005,Ks.HOLD_DELAY=700,Ks.CLEAR_TAP_COUNT_TIME=400,_t([Q0],Ks,"isTouchDevice",1);var J0=Ks,Uh=class extends Xe{onclick(e,t){this._register($e(e,Bt.CLICK,n=>t(new _a(Gi(e),n))))}onmousedown(e,t){this._register($e(e,Bt.MOUSE_DOWN,n=>t(new _a(Gi(e),n))))}onmouseover(e,t){this._register($e(e,Bt.MOUSE_OVER,n=>t(new _a(Gi(e),n))))}onmouseleave(e,t){this._register($e(e,Bt.MOUSE_LEAVE,n=>t(new _a(Gi(e),n))))}onkeydown(e,t){this._register($e(e,Bt.KEY_DOWN,n=>t(new mm(n))))}onkeyup(e,t){this._register($e(e,Bt.KEY_UP,n=>t(new mm(n))))}oninput(e,t){this._register($e(e,Bt.INPUT,t))}onblur(e,t){this._register($e(e,Bt.BLUR,t))}onfocus(e,t){this._register($e(e,Bt.FOCUS,t))}onchange(e,t){this._register($e(e,Bt.CHANGE,t))}ignoreGesture(e){return J0.ignoreTarget(e)}},wm=11,Z0=class extends Uh{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=wm+"px",this.domNode.style.height=wm+"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 Qv),this._register(ym(this.bgDomNode,Bt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(ym(this.domNode,Bt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Y0),this._pointerdownScheduleRepeatTimer=this._register(new $h)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Gi(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},e1=class Gu{constructor(t,n,s,o,l,u,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,o=o|0,l=l|0,u=u|0,d=d|0),this.rawScrollLeft=o,this.rawScrollTop=d,n<0&&(n=0),o+n>s&&(o=s-n),o<0&&(o=0),l<0&&(l=0),d+l>u&&(d=u-l),d<0&&(d=0),this.width=n,this.scrollWidth=s,this.scrollLeft=o,this.height=l,this.scrollHeight=u,this.scrollTop=d}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new Gu(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Gu(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,l=this.scrollLeft!==t.scrollLeft,u=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:o,scrollLeftChanged:l,heightChanged:u,scrollHeightChanged:d,scrollTopChanged:p}}},t1=class extends Xe{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new be),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new e1(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new Cm(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=Cm.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},bm=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Xc(e,t){let n=t-e;return function(s){return e+n*r1(s)}}function i1(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var Cm=class Qu{constructor(t,n,s,o){this.from=t,this.to=n,this.duration=o,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,n,s){if(Math.abs(t-n)>2.5*s){let o,l;return t<n?(o=t+.75*s,l=n-.75*s):(o=t-.75*s,l=n+.75*s),i1(Xc(t,o),Xc(l,n),.33)}return Xc(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let s=this.scrollLeft(n),o=this.scrollTop(n);return new bm(s,o,!1)}return new bm(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return Qu.start(t,n,s)}static start(t,n,s){s=s+10;let o=Date.now()-10;return new Qu(t,n,o,s)}};function n1(e){return Math.pow(e,3)}function r1(e){return 1-n1(1-e)}var s1=class extends Xe{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new $h)}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":"")))}},o1=140,Jv=class extends Uh{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 s1(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Qv),this._shouldRender=!0,this.domNode=Gs(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($e(this.domNode.domNode,Bt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Z0(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=Gs(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register($e(this.slider.domNode,Bt.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let o=X0(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let l=this._sliderOrthogonalPointerPosition(o),u=Math.abs(l-n);if(Vv&&u>o1){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let d=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(d))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Zv=class Ju{constructor(t,n,s,o,l,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=l,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Ju(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,o,l){let u=Math.max(0,s-t),d=Math.max(0,u-2*n),p=o>0&&o>s;if(!p)return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let m=Math.round(Math.max(20,Math.floor(s*d/o))),S=(d-m)/(o-s),w=l*S;return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(m),computedSliderRatio:S,computedSliderPosition:Math.round(w)}}_refreshComputedValues(){let t=Ju._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},a1=class extends Jv{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Zv(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 Jv{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Zv(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}},c1=500,xm=50,u1=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Zu=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,s=1,o=this._rear;do{let l=o===this._front?t:Math.pow(2,-s);if(t-=l,n+=this._memory[o].score*l,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(Fh){let n=Gi(t.browserEvent),s=w0(n);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,s){let o=null,l=new u1(t,n,s);this._front===-1&&this._rear===-1?(this._memory[0]=l,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]=l),l.score=this._computeScore(l,o)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let o=Math.abs(t.deltaX),l=Math.abs(t.deltaY),u=Math.abs(n.deltaX),d=Math.abs(n.deltaY),p=Math.max(Math.min(o,u),1),m=Math.max(Math.min(l,d),1),S=Math.max(o,u),w=Math.max(l,d);S%p===0&&w%m===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Zu.INSTANCE=new Zu;var h1=Zu,d1=class extends Uh{constructor(e,t,n){super(),this._onScroll=this._register(new be),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new be),this.onWillScroll=this._onWillScroll.event,this._options=p1(t),this._scrollable=n,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let s={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new l1(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new a1(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=Gs(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Gs(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Gs(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 $h),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=cr(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Qi&&(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 vm(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=cr(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new vm(n))};this._mouseWheelToDispose.push($e(this._listenOnDomNode,Bt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=h1.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let l=e.deltaY*this._options.mouseWheelScrollSensitivity,u=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&u+l===0?u=l=0:Math.abs(l)>=Math.abs(u)?u=0:l=0),this._options.flipAxes&&([l,u]=[u,l]);let d=!Qi&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!u&&(u=l,l=0),e.browserEvent&&e.browserEvent.altKey&&(u=u*this._options.fastScrollSensitivity,l=l*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),m={};if(l){let S=xm*l,w=p.scrollTop-(S<0?Math.floor(S):Math.ceil(S));this._verticalScrollbar.writeScrollPosition(m,w)}if(u){let S=xm*u,w=p.scrollLeft-(S<0?Math.floor(S):Math.ceil(S));this._horizontalScrollbar.writeScrollPosition(m,w)}m=this._scrollable.validateScrollPosition(m),(p.scrollLeft!==m.scrollLeft||p.scrollTop!==m.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(m):this._scrollable.setScrollPositionNow(m),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,s=n?" left":"",o=t?" top":"",l=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${l}${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(),c1)}},f1=class extends d1{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function p1(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,Qi&&(t.className+=" mac"),t}var eh=class extends Xe{constructor(e,t,n,s,o,l,u,d){super(),this._bufferService=n,this._optionsService=u,this._renderService=d,this._onRequestScrollLines=this._register(new be),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new t1({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:m=>Wh(s.window,m)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new f1(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(m=>{this._scrollableElement.updateOptions({handleMouseWheel:!(m&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ut.runAndSubscribe(l.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=l.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ut(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ut(()=>this._styleElement.remove())),this._register(Ut.runAndSubscribe(l.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${l.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${l.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${l.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
60
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(m=>this._handleScroll(m)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};eh=_t([xe(2,ei),xe(3,fn),xe(4,jv),xe(5,Gr),xe(6,ti),xe(7,pn)],eh);var th=class extends Xe{constructor(e,t,n,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(l=>this._removeDecoration(l))),this._register(ut(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};th=_t([xe(1,ei),xe(2,fn),xe(3,to),xe(4,pn)],th);var m1=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Ki={full:0,left:0,center:0,right:0},Bn={full:0,left:0,center:0,right:0},As={full:0,left:0,center:0,right:0},Oa=class extends Xe{constructor(e,t,n,s,o,l,u,d){var m;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=o,this._optionsService=l,this._themeService=u,this._coreBrowserService=d,this._colorZoneStore=new m1,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(m=this._viewportElement.parentElement)==null||m.insertBefore(this._canvas,this._viewportElement),this._register(ut(()=>{var S;return(S=this._canvas)==null?void 0:S.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Bn.full=this._canvas.width,Bn.left=e,Bn.center=t,Bn.right=e,this._refreshDrawHeightConstants(),As.full=1,As.left=1,As.center=1+Bn.left,As.right=1+Bn.left+Bn.center}_refreshDrawHeightConstants(){Ki.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);Ki.left=t,Ki.center=t,Ki.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.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(As[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ki[e.position||"full"]/2),Bn[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ki[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}))}};Oa=_t([xe(2,ei),xe(3,to),xe(4,pn),xe(5,ti),xe(6,Gr),xe(7,fn)],Oa);var ue;(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=""))(ue||(ue={}));var Pa;(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=""))(Pa||(Pa={}));var e_;(e=>e.ST=`${ue.ESC}\\`)(e_||(e_={}));var ih=class{constructor(e,t,n,s,o,l){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=o,this._renderService=l,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${ue.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let l=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(l.width,1)+"px",this._textarea.style.height=Math.max(l.height,1)+"px",this._textarea.style.lineHeight=l.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};ih=_t([xe(2,ei),xe(3,ti),xe(4,dr),xe(5,pn)],ih);var At=0,It=0,Ot=0,vt=0,km={css:"#00000000",rgba:0},kt;(e=>{function t(o,l,u,d){return d!==void 0?`#${tr(o)}${tr(l)}${tr(u)}${tr(d)}`:`#${tr(o)}${tr(l)}${tr(u)}`}e.toCss=t;function n(o,l,u,d=255){return(o<<24|l<<16|u<<8|d)>>>0}e.toRgba=n;function s(o,l,u,d){return{css:e.toCss(o,l,u,d),rgba:e.toRgba(o,l,u,d)}}e.toColor=s})(kt||(kt={}));var lt;(e=>{function t(p,m){if(vt=(m.rgba&255)/255,vt===1)return{css:m.css,rgba:m.rgba};let S=m.rgba>>24&255,w=m.rgba>>16&255,y=m.rgba>>8&255,v=p.rgba>>24&255,C=p.rgba>>16&255,b=p.rgba>>8&255;At=v+Math.round((S-v)*vt),It=C+Math.round((w-C)*vt),Ot=b+Math.round((y-b)*vt);let k=kt.toCss(At,It,Ot),N=kt.toRgba(At,It,Ot);return{css:k,rgba:N}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,m,S){let w=Da.ensureContrastRatio(p.rgba,m.rgba,S);if(w)return kt.toColor(w>>24&255,w>>16&255,w>>8&255)}e.ensureContrastRatio=s;function o(p){let m=(p.rgba|255)>>>0;return[At,It,Ot]=Da.toChannels(m),{css:kt.toCss(At,It,Ot),rgba:m}}e.opaque=o;function l(p,m){return vt=Math.round(m*255),[At,It,Ot]=Da.toChannels(p.rgba),{css:kt.toCss(At,It,Ot,vt),rgba:kt.toRgba(At,It,Ot,vt)}}e.opacity=l;function u(p,m){return vt=p.rgba&255,l(p,vt*m/255)}e.multiplyOpacity=u;function d(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=d})(lt||(lt={}));var pt;(e=>{let t,n;try{let o=document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d",{willReadFrequently:!0});l&&(t=l,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return At=parseInt(o.slice(1,2).repeat(2),16),It=parseInt(o.slice(2,3).repeat(2),16),Ot=parseInt(o.slice(3,4).repeat(2),16),kt.toColor(At,It,Ot);case 5:return At=parseInt(o.slice(1,2).repeat(2),16),It=parseInt(o.slice(2,3).repeat(2),16),Ot=parseInt(o.slice(3,4).repeat(2),16),vt=parseInt(o.slice(4,5).repeat(2),16),kt.toColor(At,It,Ot,vt);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 l=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(l)return At=parseInt(l[1]),It=parseInt(l[2]),Ot=parseInt(l[3]),vt=Math.round((l[5]===void 0?1:parseFloat(l[5]))*255),kt.toColor(At,It,Ot,vt);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[At,It,Ot,vt]=t.getImageData(0,0,1,1).data,vt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:kt.toRgba(At,It,Ot,vt),css:o}}e.toColor=s})(pt||(pt={}));var Zt;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,o,l){let u=s/255,d=o/255,p=l/255,m=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),S=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),w=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return m*.2126+S*.7152+w*.0722}e.relativeLuminance2=n})(Zt||(Zt={}));var Da;(e=>{function t(u,d){if(vt=(d&255)/255,vt===1)return d;let p=d>>24&255,m=d>>16&255,S=d>>8&255,w=u>>24&255,y=u>>16&255,v=u>>8&255;return At=w+Math.round((p-w)*vt),It=y+Math.round((m-y)*vt),Ot=v+Math.round((S-v)*vt),kt.toRgba(At,It,Ot)}e.blend=t;function n(u,d,p){let m=Zt.relativeLuminance(u>>8),S=Zt.relativeLuminance(d>>8);if(cn(m,S)<p){if(S<m){let v=s(u,d,p),C=cn(m,Zt.relativeLuminance(v>>8));if(C<p){let b=o(u,d,p),k=cn(m,Zt.relativeLuminance(b>>8));return C>k?v:b}return v}let w=o(u,d,p),y=cn(m,Zt.relativeLuminance(w>>8));if(y<p){let v=s(u,d,p),C=cn(m,Zt.relativeLuminance(v>>8));return y>C?w:v}return w}}e.ensureContrastRatio=n;function s(u,d,p){let m=u>>24&255,S=u>>16&255,w=u>>8&255,y=d>>24&255,v=d>>16&255,C=d>>8&255,b=cn(Zt.relativeLuminance2(y,v,C),Zt.relativeLuminance2(m,S,w));for(;b<p&&(y>0||v>0||C>0);)y-=Math.max(0,Math.ceil(y*.1)),v-=Math.max(0,Math.ceil(v*.1)),C-=Math.max(0,Math.ceil(C*.1)),b=cn(Zt.relativeLuminance2(y,v,C),Zt.relativeLuminance2(m,S,w));return(y<<24|v<<16|C<<8|255)>>>0}e.reduceLuminance=s;function o(u,d,p){let m=u>>24&255,S=u>>16&255,w=u>>8&255,y=d>>24&255,v=d>>16&255,C=d>>8&255,b=cn(Zt.relativeLuminance2(y,v,C),Zt.relativeLuminance2(m,S,w));for(;b<p&&(y<255||v<255||C<255);)y=Math.min(255,y+Math.ceil((255-y)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),C=Math.min(255,C+Math.ceil((255-C)*.1)),b=cn(Zt.relativeLuminance2(y,v,C),Zt.relativeLuminance2(m,S,w));return(y<<24|v<<16|C<<8|255)>>>0}e.increaseLuminance=o;function l(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=l})(Da||(Da={}));function tr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function cn(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var g1=class extends eo{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},za=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Di}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],s=t.translateToString(!0),o=0,l=0,u=0,d=t.getFg(0),p=t.getBg(0);for(let m=0;m<t.getTrimmedLength();m++)if(t.loadCell(m,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==d||this._workCell.bg!==p){if(m-o>1){let S=this._getJoinedRanges(s,u,l,t,o);for(let w=0;w<S.length;w++)n.push(S[w])}o=m,u=l,d=this._workCell.fg,p=this._workCell.bg}l+=this._workCell.getChars().length||zn.length}if(this._bufferService.cols-o>1){let m=this._getJoinedRanges(s,u,l,t,o);for(let S=0;S<m.length;S++)n.push(m[S])}return n}_getJoinedRanges(e,t,n,s,o){let l=e.substring(t,n),u=[];try{u=this._characterJoiners[0].handler(l)}catch(d){console.error(d)}for(let d=1;d<this._characterJoiners.length;d++)try{let p=this._characterJoiners[d].handler(l);for(let m=0;m<p.length;m++)za._mergeRanges(u,p[m])}catch(p){console.error(p)}return this._stringRangesToCellRanges(u,s,o),u}_stringRangesToCellRanges(e,t,n){let s=0,o=!1,l=0,u=e[s];if(u){for(let d=n;d<this._bufferService.cols;d++){let p=t.getWidth(d),m=t.getString(d).length||zn.length;if(p!==0){if(!o&&u[0]<=l&&(u[0]=d,o=!0),u[1]<=l){if(u[1]=d,u=e[++s],!u)break;u[0]<=l?(u[0]=d,o=!0):o=!1}l+=m}}u&&(u[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let s=0;s<e.length;s++){let o=e[s];if(n){if(t[1]<=o[0])return e[s-1][1]=t[1],e;if(t[1]<=o[1])return e[s-1][1]=Math.max(t[1],o[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=o[0])return e.splice(s,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};za=_t([xe(0,ei)],za);function v1(e){return 57508<=e&&e<=57558}function _1(e){return 9472<=e&&e<=9631}function y1(e){return v1(e)||_1(e)}function S1(){return{css:{canvas:ya(),cell:ya()},device:{canvas:ya(),cell:ya(),char:{width:0,height:0,left:0,top:0}}}}function ya(){return{width:0,height:0}}var nh=class{constructor(e,t,n,s,o,l,u){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=s,this._coreService=o,this._decorationService=l,this._themeService=u,this._workCell=new Di,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,s,o,l,u,d,p,m,S){let w=[],y=this._characterJoinerService.getJoinedCharacters(t),v=this._themeService.colors,C=e.getNoBgTrimmedLength();n&&C<l+1&&(C=l+1);let b,k=0,N="",L=0,A=0,B=0,ee=0,O=!1,F=0,Z=!1,W=0,G=0,K=[],P=m!==-1&&S!==-1;for(let E=0;E<C;E++){e.loadCell(E,this._workCell);let j=this._workCell.getWidth();if(j===0)continue;let U=!1,R=E>=G,H=E,I=this._workCell;if(y.length>0&&E===y[0][0]&&R){let ye=y.shift(),Le=this._isCellInSelection(ye[0],t);for(L=ye[0]+1;L<ye[1];L++)R&&(R=Le===this._isCellInSelection(L,t));R&&(R=!n||l<ye[0]||l>=ye[1]),R?(U=!0,I=new g1(this._workCell,e.translateToString(!0,ye[0],ye[1]),ye[1]-ye[0]),H=ye[1]-1,j=I.getWidth()):G=ye[1]}let q=this._isCellInSelection(E,t),X=n&&E===l,D=P&&E>=m&&E<=S,Q=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ye=>{Q=!0});let se=I.getChars()||zn;if(se===" "&&(I.isUnderline()||I.isOverline())&&(se=" "),W=j*d-p.get(se,I.isBold(),I.isItalic()),!b)b=this._document.createElement("span");else if(k&&(q&&Z||!q&&!Z&&I.bg===A)&&(q&&Z&&v.selectionForeground||I.fg===B)&&I.extended.ext===ee&&D===O&&W===F&&!X&&!U&&!Q&&R){I.isInvisible()?N+=zn:N+=se,k++;continue}else k&&(b.textContent=N),b=this._document.createElement("span"),k=0,N="";if(A=I.bg,B=I.fg,ee=I.extended.ext,O=D,F=W,Z=q,U&&l>=E&&l<=H&&(l=E),!this._coreService.isCursorHidden&&X&&this._coreService.isCursorInitialized){if(K.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&K.push("xterm-cursor-blink"),K.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":K.push("xterm-cursor-outline");break;case"block":K.push("xterm-cursor-block");break;case"bar":K.push("xterm-cursor-bar");break;case"underline":K.push("xterm-cursor-underline");break}}if(I.isBold()&&K.push("xterm-bold"),I.isItalic()&&K.push("xterm-italic"),I.isDim()&&K.push("xterm-dim"),I.isInvisible()?N=zn:N=I.getChars()||zn,I.isUnderline()&&(K.push(`xterm-underline-${I.extended.underlineStyle}`),N===" "&&(N=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())b.style.textDecorationColor=`rgb(${eo.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let ye=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&ye<8&&(ye+=8),b.style.textDecorationColor=v.ansi[ye].css}I.isOverline()&&(K.push("xterm-overline"),N===" "&&(N=" ")),I.isStrikethrough()&&K.push("xterm-strikethrough"),D&&(b.style.textDecoration="underline");let re=I.getFgColor(),ae=I.getFgColorMode(),le=I.getBgColor(),de=I.getBgColorMode(),ve=!!I.isInverse();if(ve){let ye=re;re=le,le=ye;let Le=ae;ae=de,de=Le}let Re,Fe,te=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ye=>{ye.options.layer!=="top"&&te||(ye.backgroundColorRGB&&(de=50331648,le=ye.backgroundColorRGB.rgba>>8&16777215,Re=ye.backgroundColorRGB),ye.foregroundColorRGB&&(ae=50331648,re=ye.foregroundColorRGB.rgba>>8&16777215,Fe=ye.foregroundColorRGB),te=ye.options.layer==="top")}),!te&&q&&(Re=this._coreBrowserService.isFocused?v.selectionBackgroundOpaque:v.selectionInactiveBackgroundOpaque,le=Re.rgba>>8&16777215,de=50331648,te=!0,v.selectionForeground&&(ae=50331648,re=v.selectionForeground.rgba>>8&16777215,Fe=v.selectionForeground)),te&&K.push("xterm-decoration-top");let ie;switch(de){case 16777216:case 33554432:ie=v.ansi[le],K.push(`xterm-bg-${le}`);break;case 50331648:ie=kt.toColor(le>>16,le>>8&255,le&255),this._addStyle(b,`background-color:#${Em((le>>>0).toString(16),"0",6)}`);break;case 0:default:ve?(ie=v.foreground,K.push("xterm-bg-257")):ie=v.background}switch(Re||I.isDim()&&(Re=lt.multiplyOpacity(ie,.5)),ae){case 16777216:case 33554432:I.isBold()&&re<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(re+=8),this._applyMinimumContrast(b,ie,v.ansi[re],I,Re,void 0)||K.push(`xterm-fg-${re}`);break;case 50331648:let ye=kt.toColor(re>>16&255,re>>8&255,re&255);this._applyMinimumContrast(b,ie,ye,I,Re,Fe)||this._addStyle(b,`color:#${Em(re.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(b,ie,v.foreground,I,Re,Fe)||ve&&K.push("xterm-fg-257")}K.length&&(b.className=K.join(" "),K.length=0),!X&&!U&&!Q&&R?k++:b.textContent=N,W!==this.defaultSpacing&&(b.style.letterSpacing=`${W}px`),w.push(b),E=H}return b&&k&&(b.textContent=N),w}_applyMinimumContrast(e,t,n,s,o,l){if(this._optionsService.rawOptions.minimumContrastRatio===1||y1(s.getCode()))return!1;let u=this._getContrastCache(s),d;if(!o&&!l&&(d=u.getColor(t.rgba,n.rgba)),d===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);d=lt.ensureContrastRatio(o||t,l||n,p),u.setColor((o||t).rgba,(l||n).rgba,d??null)}return d?(this._addStyle(e,`color:${d.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e<s[0]&&t<=s[1]:e<n[0]&&t>=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t<s[1]||n[1]===s[1]&&t===n[1]&&e>=n[0]&&e<s[0]||n[1]<s[1]&&t===s[1]&&e<s[0]||n[1]<s[1]&&t===n[1]&&e>=n[0]}};nh=_t([xe(1,Av),xe(2,ti),xe(3,fn),xe(4,dr),xe(5,to),xe(6,Gr)],nh);function Em(e,t,n){for(;e.length<n;)e=t+e;return e}var w1=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.style.fontWeight="bold",l.style.fontStyle="italic",this._measureElements=[n,s,o,l],this._container.appendChild(n),this._container.appendChild(s),this._container.appendChild(o),this._container.appendChild(l),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,s){e===this._font&&t===this._fontSize&&n===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,n){let s=0;if(!t&&!n&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let u=this._measure(e,0);return u>0&&(this._flat[s]=u),u}let o=e;t&&(o+="B"),n&&(o+="I");let l=this._holey.get(o);if(l===void 0){let u=0;t&&(u|=1),n&&(u|=2),l=this._measure(e,u),l>0&&this._holey.set(o,l)}return l}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},b1=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,l=t[1]-o,u=n[1]-o,d=Math.max(l,0),p=Math.min(u,e.rows-1);if(d>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=l,this.viewportEndRow=u,this.viewportCappedStartRow=d,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function C1(){return new b1}var Gc="xterm-dom-renderer-owner-",Ni="xterm-rows",Sa="xterm-fg-",Nm="xterm-bg-",Is="xterm-focus",wa="xterm-selection",x1=1,rh=class extends Xe{constructor(e,t,n,s,o,l,u,d,p,m,S,w,y,v){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=o,this._helperContainer=l,this._linkifier2=u,this._charSizeService=p,this._optionsService=m,this._bufferService=S,this._coreService=w,this._coreBrowserService=y,this._themeService=v,this._terminalClass=x1++,this._rowElements=[],this._selectionRenderModel=C1(),this.onRequestRedraw=this._register(new be).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ni),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(wa),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=S1(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(C=>this._injectCss(C))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(nh,document),this._element.classList.add(Gc+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(C=>this._handleLinkHover(C))),this._register(this._linkifier2.onHideLinkUnderline(C=>this._handleLinkLeave(C))),this._register(ut(()=>{this._element.classList.remove(Gc+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new w1(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Ni} 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} .${Ni} { 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} .${Ni} .xterm-dim { color: ${lt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Ni}.${Is} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Ni}.${Is} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ni}.${Is} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${wa} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${wa} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${wa} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[l,u]of e.ansi.entries())t+=`${this._terminalSelector} .${Sa}${l} { color: ${u.css}; }${this._terminalSelector} .${Sa}${l}.xterm-dim { color: ${lt.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${Nm}${l} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${Sa}257 { color: ${lt.opaque(e.background).css}; }${this._terminalSelector} .${Sa}257.xterm-dim { color: ${lt.multiplyOpacity(lt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Nm}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Is),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Is),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,l=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(n){let p=e[0]>t[0];d.appendChild(this._createSelectionElement(l,p?t[0]:e[0],p?e[0]:t[0],u-l+1))}else{let p=s===l?e[0]:0,m=l===o?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(l,p,m));let S=u-l-1;if(d.appendChild(this._createSelectionElement(l+1,0,this._bufferService.cols,S)),l!==u){let w=o===u?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(u,0,w))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,n,s=1){let o=this._document.createElement("div"),l=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return l+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-l),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${l}px`,o.style.width=`${u}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,s=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),l=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let m=p+n.ydisp,S=this._rowElements[p],w=n.lines.get(m);if(!S||!w)break;S.replaceChildren(...this._rowFactory.createRow(w,m,m===s,u,d,o,l,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Gc}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,o,l){n<0&&(e=0),s<0&&(t=0);let u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),s=Math.max(Math.min(s,u),0),o=Math.min(o,this._bufferService.cols);let d=this._bufferService.buffer,p=d.ybase+d.y,m=Math.min(d.x,o-1),S=this._optionsService.rawOptions.cursorBlink,w=this._optionsService.rawOptions.cursorStyle,y=this._optionsService.rawOptions.cursorInactiveStyle;for(let v=n;v<=s;++v){let C=v+d.ydisp,b=this._rowElements[v],k=d.lines.get(C);if(!b||!k)break;b.replaceChildren(...this._rowFactory.createRow(k,C,C===p,w,y,m,S,this.dimensions.css.cell.width,this._widthCache,l?v===n?e:0:-1,l?(v===s?t:o)-1:-1))}}};rh=_t([xe(7,Ih),xe(8,Xa),xe(9,ti),xe(10,ei),xe(11,dr),xe(12,fn),xe(13,Gr)],rh);var sh=class extends Xe{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new be),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new E1(this._optionsService))}catch{this._measureStrategy=this._register(new k1(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())}};sh=_t([xe(2,ti)],sh);var t_=class extends Xe{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)}},k1=class extends t_{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},E1=class extends t_{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}},N1=class extends Xe{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new R1(this._window)),this._onDprChange=this._register(new be),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new be),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Ut.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register($e(this._textarea,"focus",()=>this._isFocused=!0)),this._register($e(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}},R1=class extends Xe{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Yr),this._onDprChange=this._register(new be),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ut(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=$e(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)}},P1=class extends Xe{constructor(){super(),this.linkProviders=[],this._register(ut(()=>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 Kh(e,t,n){let s=n.getBoundingClientRect(),o=e.getComputedStyle(n),l=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-l,t.clientY-s.top-u]}function D1(e,t,n,s,o,l,u,d,p){if(!l)return;let m=Kh(e,t,n);if(m)return m[0]=Math.ceil((m[0]+(p?u/2:0))/u),m[1]=Math.ceil(m[1]/d),m[0]=Math.min(Math.max(m[0],1),s+(p?1:0)),m[1]=Math.min(Math.max(m[1],1),o),m}var oh=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,o){return D1(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=Kh(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};oh=_t([xe(0,pn),xe(1,Xa)],oh);var M1=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},i_={};Hw(i_,{getSafariVersion:()=>j1,isChromeOS:()=>o_,isFirefox:()=>n_,isIpad:()=>T1,isIphone:()=>B1,isLegacyEdge:()=>L1,isLinux:()=>qh,isMac:()=>Fa,isNode:()=>Ga,isSafari:()=>r_,isWindows:()=>s_});var Ga=typeof process<"u"&&"title"in process,io=Ga?"node":navigator.userAgent,no=Ga?"node":navigator.platform,n_=io.includes("Firefox"),L1=io.includes("Edge"),r_=/^((?!chrome|android).)*safari/i.test(io);function j1(){if(!r_)return 0;let e=io.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Fa=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(no),T1=no==="iPad",B1=no==="iPhone",s_=["Windows","Win16","Win32","WinCE"].includes(no),qh=no.indexOf("Linux")>=0,o_=/\bCrOS\b/.test(io),a_=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,n=0,s=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),o=e.timeRemaining(),n*1.5>o){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=o}this.clear()}},A1=class extends a_{_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())}}},I1=class extends a_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Ha=!Ga&&"requestIdleCallback"in window?I1:A1,O1=class{constructor(){this._queue=new Ha}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},ah=class extends Xe{constructor(e,t,n,s,o,l,u,d,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=o,this._coreBrowserService=d,this._renderer=this._register(new Yr),this._pausedResizeTask=new O1,this._observerDisposable=this._register(new Yr),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 be),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new be),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new be),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new be),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new M1((m,S)=>this._renderRows(m,S),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new z1(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ut(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>{var m;return(m=this._renderer.value)==null?void 0:m.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(l.onDecorationRegistered(()=>this._fullRefresh())),this._register(l.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(m=>this._registerIntersectionObserver(m,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=ut(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};ah=_t([xe(2,ti),xe(3,Xa),xe(4,dr),xe(5,to),xe(6,ei),xe(7,fn),xe(8,Gr)],ah);var z1=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function F1(e,t,n,s){let o=n.buffer.x,l=n.buffer.y;if(!n.buffer.hasScrollback)return W1(o,l,e,t,n,s)+Qa(l,t,n,s)+U1(o,l,e,t,n,s);let u;if(l===t)return u=o>e?"D":"C",Js(Math.abs(o-e),Qs(u,s));u=l>t?"D":"C";let d=Math.abs(l-t),p=$1(l>t?e:o,n)+(d-1)*n.cols+1+H1(l>t?o:e);return Js(p,Qs(u,s))}function H1(e,t){return e-1}function $1(e,t){return t.cols-e}function W1(e,t,n,s,o,l){return Qa(t,s,o,l).length===0?"":Js(c_(e,t,e,t-ur(t,o),!1,o).length,Qs("D",l))}function Qa(e,t,n,s){let o=e-ur(e,n),l=t-ur(t,n),u=Math.abs(o-l)-K1(e,t,n);return Js(u,Qs(l_(e,t),s))}function U1(e,t,n,s,o,l){let u;Qa(t,s,o,l).length>0?u=s-ur(s,o):u=t;let d=s,p=q1(e,t,n,s,o,l);return Js(c_(e,u,n,d,p==="C",o).length,Qs(p,l))}function K1(e,t,n){var u;let s=0,o=e-ur(e,n),l=t-ur(t,n);for(let d=0;d<Math.abs(o-l);d++){let p=l_(e,t)==="A"?-1:1;(u=n.buffer.lines.get(o+p*d))!=null&&u.isWrapped&&s++}return s}function ur(e,t){let n=0,s=t.buffer.lines.get(e),o=s==null?void 0:s.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,s=t.buffer.lines.get(--e),o=s==null?void 0:s.isWrapped;return n}function q1(e,t,n,s,o,l){let u;return Qa(n,s,o,l).length>0?u=s-ur(s,o):u=t,e<n&&u<=s||e>=n&&u<s?"C":"D"}function l_(e,t){return e>t?"A":"B"}function c_(e,t,n,s,o,l){let u=e,d=t,p="";for(;(u!==n||d!==s)&&d>=0&&d<l.buffer.lines.length;)u+=o?1:-1,o&&u>l.cols-1?(p+=l.buffer.translateBufferLineToString(d,!1,e,u),u=0,e=0,d++):!o&&u<0&&(p+=l.buffer.translateBufferLineToString(d,!1,0,e+1),u=l.cols-1,e=u,d--);return p+l.buffer.translateBufferLineToString(d,!1,e,u)}function Qs(e,t){let n=t?"O":"[";return ue.ESC+n+e}function Js(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var V1=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 Rm(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 Qc=50,Y1=15,X1=50,G1=500,Q1=" ",J1=new RegExp(Q1,"g"),lh=class extends Xe{constructor(e,t,n,s,o,l,u,d,p){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=o,this._mouseService=l,this._optionsService=u,this._renderService=d,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Di,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new be),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new be),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new be),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new be),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=m=>this._handleMouseMove(m),this._mouseUpListener=m=>this._handleMouseUp(m),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(m=>this._handleTrim(m)),this._register(this._bufferService.buffers.onBufferActivate(m=>this._handleBufferActivate(m))),this.enable(),this._model=new V1(this._bufferService),this._activeSelectionMode=0,this._register(ut(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(m=>{m.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],l=e[0]<t[0]?t[0]:e[0];for(let u=e[1];u<=t[1];u++){let d=n.translateBufferLineToString(u,!0,o,l);s.push(d)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let l=e[1]+1;l<=t[1]-1;l++){let u=n.lines.get(l),d=n.translateBufferLineToString(l,!0);u!=null&&u.isWrapped?s[s.length-1]+=d:s.push(d)}if(e[1]!==t[1]){let l=n.lines.get(t[1]),u=n.translateBufferLineToString(t[1],!0,0,t[0]);l&&l.isWrapped?s[s.length-1]+=u:s.push(u)}}return s.map(o=>o.replace(J1," ")).join(s_?`\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())),qh&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var o,l;let n=(l=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:l.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Rm(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Kh(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-Qc),Qc),t/=Qc,t/Math.abs(t)+Math.round(t*(Y1-1)))}shouldForceSelection(e){return Fa?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(),X1)}_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&&!(Fa&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let s=n.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<G1&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let s=F1(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==s&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,l=o.lines.get(e[1]);if(!l)return;let u=o.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(l,e[0]),p=d,m=e[0]-d,S=0,w=0,y=0,v=0;if(u.charAt(d)===" "){for(;d>0&&u.charAt(d-1)===" ";)d--;for(;p<u.length&&u.charAt(p+1)===" ";)p++}else{let k=e[0],N=e[0];l.getWidth(k)===0&&(S++,k--),l.getWidth(N)===2&&(w++,N++);let L=l.getString(N).length;for(L>1&&(v+=L-1,p+=L-1);k>0&&d>0&&!this._isCharWordSeparator(l.loadCell(k-1,this._workCell));){l.loadCell(k-1,this._workCell);let A=this._workCell.getChars().length;this._workCell.getWidth()===0?(S++,k--):A>1&&(y+=A-1,d-=A-1),d--,k--}for(;N<l.length&&p+1<u.length&&!this._isCharWordSeparator(l.loadCell(N+1,this._workCell));){l.loadCell(N+1,this._workCell);let A=this._workCell.getChars().length;this._workCell.getWidth()===2?(w++,N++):A>1&&(v+=A-1,p+=A-1),p++,N++}}p++;let C=d+m-S+y,b=Math.min(this._bufferService.cols,p-d+S+w-y-v);if(!(!t&&u.slice(d,p).trim()==="")){if(n&&C===0&&l.getCodePoint(0)!==32){let k=o.lines.get(e[1]-1);if(k&&l.isWrapped&&k.getCodePoint(this._bufferService.cols-1)!==32){let N=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(N){let L=this._bufferService.cols-N.start;C-=L,b+=L}}}if(s&&C+b===this._bufferService.cols&&l.getCodePoint(this._bufferService.cols-1)!==32){let k=o.lines.get(e[1]+1);if(k!=null&&k.isWrapped&&k.getCodePoint(0)!==32){let N=this._getWordAt([0,e[1]+1],!1,!1,!0);N&&(b+=N.length)}}return{start:C,length:b}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Rm(n,this._bufferService.cols)}};lh=_t([xe(3,ei),xe(4,dr),xe(5,Oh),xe(6,ti),xe(7,pn),xe(8,fn)],lh);var Pm=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Dm=class{constructor(){this._color=new Pm,this._css=new Pm}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Rt=Object.freeze((()=>{let e=[pt.toColor("#2e3436"),pt.toColor("#cc0000"),pt.toColor("#4e9a06"),pt.toColor("#c4a000"),pt.toColor("#3465a4"),pt.toColor("#75507b"),pt.toColor("#06989a"),pt.toColor("#d3d7cf"),pt.toColor("#555753"),pt.toColor("#ef2929"),pt.toColor("#8ae234"),pt.toColor("#fce94f"),pt.toColor("#729fcf"),pt.toColor("#ad7fa8"),pt.toColor("#34e2e2"),pt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],o=t[n/6%6|0],l=t[n%6];e.push({css:kt.toCss(s,o,l),rgba:kt.toRgba(s,o,l)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:kt.toCss(s,s,s),rgba:kt.toRgba(s,s,s)})}return e})()),nr=pt.toColor("#ffffff"),qs=pt.toColor("#000000"),Mm=pt.toColor("#ffffff"),Lm=qs,Os={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Z1=nr,ch=class extends Xe{constructor(e){super(),this._optionsService=e,this._contrastCache=new Dm,this._halfContrastCache=new Dm,this._onChangeColors=this._register(new be),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:nr,background:qs,cursor:Mm,cursorAccent:Lm,selectionForeground:void 0,selectionBackgroundTransparent:Os,selectionBackgroundOpaque:lt.blend(qs,Os),selectionInactiveBackgroundTransparent:Os,selectionInactiveBackgroundOpaque:lt.blend(qs,Os),scrollbarSliderBackground:lt.opacity(nr,.2),scrollbarSliderHoverBackground:lt.opacity(nr,.4),scrollbarSliderActiveBackground:lt.opacity(nr,.5),overviewRulerBorder:nr,ansi:Rt.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=nt(e.foreground,nr),t.background=nt(e.background,qs),t.cursor=lt.blend(t.background,nt(e.cursor,Mm)),t.cursorAccent=lt.blend(t.background,nt(e.cursorAccent,Lm)),t.selectionBackgroundTransparent=nt(e.selectionBackground,Os),t.selectionBackgroundOpaque=lt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=nt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=lt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?nt(e.selectionForeground,km):void 0,t.selectionForeground===km&&(t.selectionForeground=void 0),lt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=lt.opacity(t.selectionBackgroundTransparent,.3)),lt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=lt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=nt(e.scrollbarSliderBackground,lt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=nt(e.scrollbarSliderHoverBackground,lt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=nt(e.scrollbarSliderActiveBackground,lt.opacity(t.foreground,.5)),t.overviewRulerBorder=nt(e.overviewRulerBorder,Z1),t.ansi=Rt.slice(),t.ansi[0]=nt(e.black,Rt[0]),t.ansi[1]=nt(e.red,Rt[1]),t.ansi[2]=nt(e.green,Rt[2]),t.ansi[3]=nt(e.yellow,Rt[3]),t.ansi[4]=nt(e.blue,Rt[4]),t.ansi[5]=nt(e.magenta,Rt[5]),t.ansi[6]=nt(e.cyan,Rt[6]),t.ansi[7]=nt(e.white,Rt[7]),t.ansi[8]=nt(e.brightBlack,Rt[8]),t.ansi[9]=nt(e.brightRed,Rt[9]),t.ansi[10]=nt(e.brightGreen,Rt[10]),t.ansi[11]=nt(e.brightYellow,Rt[11]),t.ansi[12]=nt(e.brightBlue,Rt[12]),t.ansi[13]=nt(e.brightMagenta,Rt[13]),t.ansi[14]=nt(e.brightCyan,Rt[14]),t.ansi[15]=nt(e.brightWhite,Rt[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<n;s++)t.ansi[s+16]=nt(e.extendedAnsi[s],Rt[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()}}};ch=_t([xe(0,ti)],ch);function nt(e,t){if(e!==void 0)try{return pt.toColor(e)}catch{}return t}var eb=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},tb=class{constructor(){this._services=new eb,this._services.set(Ih,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=Yw(e).sort((l,u)=>l.index-u.index),s=[];for(let l of n){let u=this._services.get(l.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${l.id._id}.`);s.push(u)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},ib={trace:0,debug:1,info:2,warn:3,error:4,off:5},nb="xterm.js: ",uh=class extends Xe{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=ib[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":nb)+t,...n)}trace(e,...t){var n;this._logLevel<=0&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var n;this._logLevel<=1&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var n;this._logLevel<=2&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var n;this._logLevel<=3&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var n;this._logLevel<=4&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.error.bind(this._optionsService.options.logger))??console.error,e,t)}};uh=_t([xe(0,ti)],uh);var jm=class extends Xe{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new be),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new be),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new be),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<n.length;s++)this._array[this._getCyclicIndex(e+s)]=n[s];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let o=t-1;o>=0;o--)this.set(e+o+n,this.get(e+o));let s=e+t+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+n,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Ye=3,xt=Object.freeze(new eo),ba=0,Jc=2,Vs=class u_{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Ye);let o=n||Di.fromCharData([0,Pv,1,0]);for(let l=0;l<t;++l)this.setCell(l,o);this.length=t}get(t){let n=this._data[t*Ye+0],s=n&2097151;return[this._data[t*Ye+1],n&2097152?this._combined[t]:s?On(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*Ye+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Ye+0]=t|2097152|n[2]<<22):this._data[t*Ye+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Ye+0]>>22}hasWidth(t){return this._data[t*Ye+0]&12582912}getFg(t){return this._data[t*Ye+1]}getBg(t){return this._data[t*Ye+2]}hasContent(t){return this._data[t*Ye+0]&4194303}getCodePoint(t){let n=this._data[t*Ye+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Ye+0]&2097152}getString(t){let n=this._data[t*Ye+0];return n&2097152?this._combined[t]:n&2097151?On(n&2097151):""}isProtected(t){return this._data[t*Ye+2]&536870912}loadCell(t,n){return ba=t*Ye,n.content=this._data[ba+0],n.fg=this._data[ba+1],n.bg=this._data[ba+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*Ye+0]=n.content,this._data[t*Ye+1]=n.fg,this._data[t*Ye+2]=n.bg}setCellFromCodepoint(t,n,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*Ye+0]=n|s<<22,this._data[t*Ye+1]=o.fg,this._data[t*Ye+2]=o.bg}addCodepointToCell(t,n,s){let o=this._data[t*Ye+0];o&2097152?this._combined[t]+=On(n):o&2097151?(this._combined[t]=On(o&2097151)+On(n),o&=-2097152,o|=2097152):o=n|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*Ye+0]=o}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length-t){let o=new Di;for(let l=this.length-t-n-1;l>=0;--l)this.setCell(t+n+l,this.loadCell(t+l,o));for(let l=0;l<n;++l)this.setCell(t+l,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,n,s){if(t%=this.length,n<this.length-t){let o=new Di;for(let l=0;l<this.length-t-n;++l)this.setCell(t+l,this.loadCell(t+n+l,o));for(let l=this.length-n;l<this.length;++l)this.setCell(l,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,n,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.setCell(t++,s)}resize(t,n){if(t===this.length)return this._data.length*4*Jc<this._data.buffer.byteLength;let s=t*Ye;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let u=0;u<o.length;u++){let d=parseInt(o[u],10);d>=t&&delete this._combined[d]}let l=Object.keys(this._extendedAttrs);for(let u=0;u<l.length;u++){let d=parseInt(l[u],10);d>=t&&delete this._extendedAttrs[d]}}return this.length=t,s*4*Jc<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Jc<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new u_(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ye+0]&4194303)return t+(this._data[t*Ye+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ye+0]&4194303||this._data[t*Ye+2]&50331648)return t+(this._data[t*Ye+0]>>22);return 0}copyCellsFrom(t,n,s,o,l){let u=t._data;if(l)for(let p=o-1;p>=0;p--){for(let m=0;m<Ye;m++)this._data[(s+p)*Ye+m]=u[(n+p)*Ye+m];u[(n+p)*Ye+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[n+p])}else for(let p=0;p<o;p++){for(let m=0;m<Ye;m++)this._data[(s+p)*Ye+m]=u[(n+p)*Ye+m];u[(n+p)*Ye+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[n+p])}let d=Object.keys(t._combined);for(let p=0;p<d.length;p++){let m=parseInt(d[p],10);m>=n&&(this._combined[m-n+s]=t._combined[m])}}translateToString(t,n,s,o){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let l="";for(;n<s;){let u=this._data[n*Ye+0],d=u&2097151,p=u&2097152?this._combined[n]:d?On(d):zn;if(l+=p,o)for(let m=0;m<p.length;++m)o.push(n);n+=u>>22||1}return o&&o.push(n),l}};function rb(e,t,n,s,o,l){let u=[];for(let d=0;d<e.length-1;d++){let p=d,m=e.get(++p);if(!m.isWrapped)continue;let S=[e.get(d)];for(;p<e.length&&m.isWrapped;)S.push(m),m=e.get(++p);if(!l&&s>=d&&s<p){d+=S.length-1;continue}let w=0,y=Zs(S,w,t),v=1,C=0;for(;v<S.length;){let k=Zs(S,v,t),N=k-C,L=n-y,A=Math.min(N,L);S[w].copyCellsFrom(S[v],C,y,A,!1),y+=A,y===n&&(w++,y=0),C+=A,C===k&&(v++,C=0),y===0&&w!==0&&S[w-1].getWidth(n-1)===2&&(S[w].copyCellsFrom(S[w-1],n-1,y++,1,!1),S[w-1].setCell(n-1,o))}S[w].replaceCells(y,n,o);let b=0;for(let k=S.length-1;k>0&&(k>w||S[k].getTrimmedLength()===0);k--)b++;b>0&&(u.push(d+S.length-b),u.push(b)),d+=S.length-1}return u}function sb(e,t){let n=[],s=0,o=t[s],l=0;for(let u=0;u<e.length;u++)if(o===u){let d=t[++s];e.onDeleteEmitter.fire({index:u-l,amount:d}),u+=d-1,l+=d,o=t[++s]}else n.push(u);return{layout:n,countRemoved:l}}function ob(e,t){let n=[];for(let s=0;s<t.length;s++)n.push(e.get(t[s]));for(let s=0;s<n.length;s++)e.set(s,n[s]);e.length=t.length}function ab(e,t,n){let s=[],o=e.map((p,m)=>Zs(e,m,t)).reduce((p,m)=>p+m),l=0,u=0,d=0;for(;d<o;){if(o-d<n){s.push(o-d);break}l+=n;let p=Zs(e,u,t);l>p&&(l-=p,u++);let m=e[u].getWidth(l-1)===2;m&&l--;let S=m?n-1:n;s.push(S),d+=S}return s}function Zs(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?n-1:n}var h_=class d_{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=d_._nextId++,this._onDispose=this.register(new be),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),cr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};h_._nextId=1;var lb=h_,Dt={},rr=Dt.B;Dt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Dt.A={"#":"£"};Dt.B=void 0;Dt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Dt.C=Dt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Dt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Dt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Dt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Dt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Dt.E=Dt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Dt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Dt.H=Dt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Dt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Tm=4294967295,Bm=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=xt.clone(),this.savedCharset=rr,this.markers=[],this._nullCell=Di.fromCharData([0,Pv,1,0]),this._whitespaceCell=Di.fromCharData([0,zn,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Ha,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new jm(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 Ia),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 Ia),this._whitespaceCell}getBlankLine(e,t){return new Vs(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>Tm?Tm:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=xt);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 jm(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(xt),s=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let u=0;u<this.lines.length;u++)s+=+this.lines.get(u).resize(e,n);let l=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 Vs(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+l+1?(this.ybase--,l++,this.ydisp>0&&this.ydisp--):this.lines.push(new Vs(e,n)));else for(let u=this._rows;u>t;u--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let u=this.lines.length-o;u>0&&(this.lines.trimStart(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),l&&(this.y+=l),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 l=0;l<this.lines.length;l++)s+=+this.lines.get(l).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=rb(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(xt),n);if(s.length>0){let o=sb(this.lines,s);ob(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(xt),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Vs(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(xt),o=[],l=0;for(let u=this.lines.length-1;u>=0;u--){let d=this.lines.get(u);if(!d||!d.isWrapped&&d.getTrimmedLength()<=e)continue;let p=[d];for(;d.isWrapped&&u>0;)d=this.lines.get(--u),p.unshift(d);if(!n){let A=this.ybase+this.y;if(A>=u&&A<u+p.length)continue}let m=p[p.length-1].getTrimmedLength(),S=ab(p,this._cols,e),w=S.length-p.length,y;this.ybase===0&&this.y!==this.lines.length-1?y=Math.max(0,this.y-this.lines.maxLength+w):y=Math.max(0,this.lines.length-this.lines.maxLength+w);let v=[];for(let A=0;A<w;A++){let B=this.getBlankLine(xt,!0);v.push(B)}v.length>0&&(o.push({start:u+p.length+l,newLines:v}),l+=v.length),p.push(...v);let C=S.length-1,b=S[C];b===0&&(C--,b=S[C]);let k=p.length-w-1,N=m;for(;k>=0;){let A=Math.min(N,b);if(p[C]===void 0)break;if(p[C].copyCellsFrom(p[k],N-A,b-A,A,!0),b-=A,b===0&&(C--,b=S[C]),N-=A,N===0){k--;let B=Math.max(k,0);N=Zs(p,B,this._cols)}}for(let A=0;A<p.length;A++)S[A]<e&&p[A].setCell(S[A],s);let L=w-y;for(;L-- >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+l)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+w,this.ybase+t-1)}if(o.length>0){let u=[],d=[];for(let b=0;b<this.lines.length;b++)d.push(this.lines.get(b));let p=this.lines.length,m=p-1,S=0,w=o[S];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+l);let y=0;for(let b=Math.min(this.lines.maxLength-1,p+l-1);b>=0;b--)if(w&&w.start>m+y){for(let k=w.newLines.length-1;k>=0;k--)this.lines.set(b--,w.newLines[k]);b++,u.push({index:m+1,amount:w.newLines.length}),y+=w.newLines.length,w=o[++S]}else this.lines.set(b,d[m--]);let v=0;for(let b=u.length-1;b>=0;b--)u[b].index+=v,this.lines.onInsertEmitter.fire(u[b]),v+=u[b].amount;let C=Math.max(0,p+l-this.lines.maxLength);C>0&&this.lines.onTrimEmitter.fire(C)}}translateBufferLineToString(e,t,n=0,s){let o=this.lines.get(e);return o?o.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new lb(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},cb=class extends Xe{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new be),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 Bm(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Bm(!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)}},f_=2,p_=1,hh=class extends Xe{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new be),this.onResize=this._onResize.event,this._onScroll=this._register(new be),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,f_),this.rows=Math.max(e.rawOptions.rows||0,p_),this.buffers=this._register(new cb(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=n.ybase+n.scrollTop,l=n.ybase+n.scrollBottom;if(n.scrollTop===0){let u=n.lines.isFull;l===n.lines.length-1?u?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(l+1,0,s.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=l-o+1;n.lines.shiftElements(o+1,u-1,-1),n.lines.set(l,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};hh=_t([xe(0,ti)],hh);var Fr={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:Fa,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},ub=["normal","bold","100","200","300","400","500","600","700","800","900"],hb=class extends Xe{constructor(e){super(),this._onOptionChange=this._register(new be),this.onOptionChange=this._onOptionChange.event;let t={...Fr};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ut(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Fr))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Fr))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Fr[e]),!db(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Fr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=ub.includes(t)?t:Fr[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 db(e){return e==="block"||e==="underline"||e==="bar"}function Ys(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&Ys(e[s],t-1);return n}var Am=Object.freeze({insertMode:!1}),Im=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),dh=class extends Xe{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new be),this.onData=this._onData.event,this._onUserInput=this._register(new be),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new be),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new be),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Ys(Am),this.decPrivateModes=Ys(Im)}reset(){this.modes=Ys(Am),this.decPrivateModes=Ys(Im)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};dh=_t([xe(0,ei),xe(1,Tv),xe(2,ti)],dh);var Om={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 Zc(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var eu=String.fromCharCode,zm={DEFAULT:e=>{let t=[Zc(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${eu(t[0])}${eu(t[1])}${eu(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Zc(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Zc(e,!0)};${e.x};${e.y}${t}`}},fh=class extends Xe{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new be),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Om))this.addProtocol(s,Om[s]);for(let s of Object.keys(zm))this.addEncoding(s,zm[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=s+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};fh=_t([xe(0,ei),xe(1,dr),xe(2,ti)],fh);var tu=[[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]],fb=[[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]],Pt;function pb(e,t){let n=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=n;)if(o=n+s>>1,e>t[o][1])n=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var mb=class{constructor(){if(this.version="6",!Pt){Pt=new Uint8Array(65536),Pt.fill(1),Pt[0]=0,Pt.fill(0,1,32),Pt.fill(0,127,160),Pt.fill(2,4352,4448),Pt[9001]=2,Pt[9002]=2,Pt.fill(2,11904,42192),Pt[12351]=1,Pt.fill(2,44032,55204),Pt.fill(2,63744,64256),Pt.fill(2,65040,65050),Pt.fill(2,65072,65136),Pt.fill(2,65280,65377),Pt.fill(2,65504,65511);for(let e=0;e<tu.length;++e)Pt.fill(0,tu[e][0],tu[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Pt[e]:pb(e,fb)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let o=or.extractWidth(t);o===0?s=!1:o>n&&(n=o)}return or.createPropertyValue(0,n,s)}},or=class Ma{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new be,this.onChange=this._onChange.event;let t=new mb;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,s=!1){return(t&16777215)<<3|(n&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,s=0,o=t.length;for(let l=0;l<o;++l){let u=t.charCodeAt(l);if(55296<=u&&u<=56319){if(++l>=o)return n+this.wcwidth(u);let m=t.charCodeAt(l);56320<=m&&m<=57343?u=(u-55296)*1024+m-56320+65536:n+=this.wcwidth(m)}let d=this.charProperties(u,s),p=Ma.extractWidth(d);Ma.extractShouldJoin(d)&&(p-=Ma.extractWidth(s)),n+=p,s=d}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},gb=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 Fm(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var zs=2147483647,vb=256,m_=class ph{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>vb)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new ph;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let l=0;l<o.length;++l)n.addSubParam(o[l]);else n.addParam(o)}return n}clone(){let t=new ph(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>zs?zs: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>zs?zs:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&(t[n]=this._subParams.slice(s,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[n-1];s[n-1]=~o?Math.min(o*10+t,zs):t}},Fs=[],_b=class{constructor(){this._state=0,this._active=Fs,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Fs}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=Fs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Fs,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",Ya(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Fs,this._id=-1,this._state=0}}},vi=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Ya(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Hs=[],yb=class{constructor(){this._handlers=Object.create(null),this._active=Hs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Hs}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Hs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Hs,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",Ya(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Hs,this._ident=0}},Xs=new m_;Xs.addParam(0);var Hm=class{constructor(e){this._handler=e,this._data="",this._params=Xs,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Xs,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Ya(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=Xs,this._data="",this._hitLimit=!1,n));return this._params=Xs,this._data="",this._hitLimit=!1,t}},Sb=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|s}},Pi=160,wb=(function(){let e=new Sb(4095),t=Array.apply(null,Array(256)).map((d,p)=>p),n=(d,p)=>t.slice(d,p),s=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let l=n(0,14),u;e.setDefault(1,0),e.addMany(s,0,2,0);for(u in l)e.addMany([24,26,153,154],u,3,0),e.addMany(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Pi,0,2,0),e.add(Pi,8,5,8),e.add(Pi,6,0,6),e.add(Pi,11,0,11),e.add(Pi,13,13,13),e})(),bb=class extends Xe{constructor(e=wb){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 m_,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ut(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new _b),this._dcsParser=this._register(new yb),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let l=e.intermediates.charCodeAt(o);if(32>l||l>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=l}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,n){let s=0,o=0,l=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,l=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let d=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&p>-1){for(;p>=0&&(u=d[p](this._params),u!==!0);p--)if(u instanceof Promise)return this._parseStack.handlerPos=p,u}this._parseStack.handlers=[];break;case 4:if(n===!1&&p>-1){for(;p>=0&&(u=d[p](),u!==!0);p--)if(u instanceof Promise)return this._parseStack.handlerPos=p,u}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(s!==24&&s!==26,n),u)return u;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],u=this._oscParser.end(s!==24&&s!==26,n),u)return u;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,l=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let d=l;d<t;++d){switch(s=e[d],o=this._transitions.table[this.currentState<<8|(s<160?s:Pi)],o>>4){case 2:for(let y=d+1;;++y){if(y>=t||(s=e[y])<32||s>126&&s<Pi){this._printHandler(e,d,y),d=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<Pi){this._printHandler(e,d,y),d=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<Pi){this._printHandler(e,d,y),d=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<Pi){this._printHandler(e,d,y),d=y-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:d,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let p=this._csiHandlers[this._collect<<8|s],m=p?p.length-1:-1;for(;m>=0&&(u=p[m](this._params),u!==!0);m--)if(u instanceof Promise)return this._preserveStack(3,p,m,o,d),u;m<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++d<t&&(s=e[d])>47&&s<60);d--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let S=this._escHandlers[this._collect<<8|s],w=S?S.length-1:-1;for(;w>=0&&(u=S[w](),u!==!0);w--)if(u instanceof Promise)return this._preserveStack(4,S,w,o,d),u;w<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let y=d+1;;++y)if(y>=t||(s=e[y])===24||s===26||s===27||s>127&&s<Pi){this._dcsParser.put(e,d,y),d=y-1;break}break;case 14:if(u=this._dcsParser.unhook(s!==24&&s!==26),u)return this._preserveStack(6,[],0,o,d),u;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let y=d+1;;y++)if(y>=t||(s=e[y])<32||s>127&&s<Pi){this._oscParser.put(e,d,y),d=y-1;break}break;case 6:if(u=this._oscParser.end(s!==24&&s!==26),u)return this._preserveStack(5,[],0,o,d),u;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},Cb=/^([\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})$/,xb=/^[\da-f]+$/;function $m(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=Cb.exec(t);if(n){let s=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/s*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/s*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),xb.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let l=parseInt(t.slice(n*o,n*o+n),16);s[o]=n===1?l<<4:n===2?l:n===3?l>>4:l>>8}return s}}function iu(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function kb(e,t=16){let[n,s,o]=e;return`rgb:${iu(n,t)}/${iu(s,t)}/${iu(o,t)}`}var Eb={"(":0,")":1,"*":2,"+":3,"-":1,".":2},An=131072,Wm=10;function Um(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 Km=5e3,qm=0,Nb=class extends Xe{constructor(e,t,n,s,o,l,u,d,p=new bb){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=o,this._oscLinkService=l,this._coreMouseService=u,this._unicodeService=d,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new qw,this._utf8Decoder=new Vw,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=xt.clone(),this._eraseAttrDataInternal=xt.clone(),this._onRequestBell=this._register(new be),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new be),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new be),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new be),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new be),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new be),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new be),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new be),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new be),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new be),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new be),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new be),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new be),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 mh(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(m=>this._activeBuffer=m.activeBuffer)),this._parser.setCsiHandlerFallback((m,S)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(m),params:S.toArray()})}),this._parser.setEscHandlerFallback(m=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(m)})}),this._parser.setExecuteHandlerFallback(m=>{this._logService.debug("Unknown EXECUTE code: ",{code:m})}),this._parser.setOscHandlerFallback((m,S,w)=>{this._logService.debug("Unknown OSC code: ",{identifier:m,action:S,data:w})}),this._parser.setDcsHandlerFallback((m,S,w)=>{S==="HOOK"&&(w=w.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(m),action:S,payload:w})}),this._parser.setPrintHandler((m,S,w)=>this.print(m,S,w)),this._parser.registerCsiHandler({final:"@"},m=>this.insertChars(m)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},m=>this.scrollLeft(m)),this._parser.registerCsiHandler({final:"A"},m=>this.cursorUp(m)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},m=>this.scrollRight(m)),this._parser.registerCsiHandler({final:"B"},m=>this.cursorDown(m)),this._parser.registerCsiHandler({final:"C"},m=>this.cursorForward(m)),this._parser.registerCsiHandler({final:"D"},m=>this.cursorBackward(m)),this._parser.registerCsiHandler({final:"E"},m=>this.cursorNextLine(m)),this._parser.registerCsiHandler({final:"F"},m=>this.cursorPrecedingLine(m)),this._parser.registerCsiHandler({final:"G"},m=>this.cursorCharAbsolute(m)),this._parser.registerCsiHandler({final:"H"},m=>this.cursorPosition(m)),this._parser.registerCsiHandler({final:"I"},m=>this.cursorForwardTab(m)),this._parser.registerCsiHandler({final:"J"},m=>this.eraseInDisplay(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},m=>this.eraseInDisplay(m,!0)),this._parser.registerCsiHandler({final:"K"},m=>this.eraseInLine(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},m=>this.eraseInLine(m,!0)),this._parser.registerCsiHandler({final:"L"},m=>this.insertLines(m)),this._parser.registerCsiHandler({final:"M"},m=>this.deleteLines(m)),this._parser.registerCsiHandler({final:"P"},m=>this.deleteChars(m)),this._parser.registerCsiHandler({final:"S"},m=>this.scrollUp(m)),this._parser.registerCsiHandler({final:"T"},m=>this.scrollDown(m)),this._parser.registerCsiHandler({final:"X"},m=>this.eraseChars(m)),this._parser.registerCsiHandler({final:"Z"},m=>this.cursorBackwardTab(m)),this._parser.registerCsiHandler({final:"`"},m=>this.charPosAbsolute(m)),this._parser.registerCsiHandler({final:"a"},m=>this.hPositionRelative(m)),this._parser.registerCsiHandler({final:"b"},m=>this.repeatPrecedingCharacter(m)),this._parser.registerCsiHandler({final:"c"},m=>this.sendDeviceAttributesPrimary(m)),this._parser.registerCsiHandler({prefix:">",final:"c"},m=>this.sendDeviceAttributesSecondary(m)),this._parser.registerCsiHandler({final:"d"},m=>this.linePosAbsolute(m)),this._parser.registerCsiHandler({final:"e"},m=>this.vPositionRelative(m)),this._parser.registerCsiHandler({final:"f"},m=>this.hVPosition(m)),this._parser.registerCsiHandler({final:"g"},m=>this.tabClear(m)),this._parser.registerCsiHandler({final:"h"},m=>this.setMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"h"},m=>this.setModePrivate(m)),this._parser.registerCsiHandler({final:"l"},m=>this.resetMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"l"},m=>this.resetModePrivate(m)),this._parser.registerCsiHandler({final:"m"},m=>this.charAttributes(m)),this._parser.registerCsiHandler({final:"n"},m=>this.deviceStatus(m)),this._parser.registerCsiHandler({prefix:"?",final:"n"},m=>this.deviceStatusPrivate(m)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},m=>this.softReset(m)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},m=>this.setCursorStyle(m)),this._parser.registerCsiHandler({final:"r"},m=>this.setScrollRegion(m)),this._parser.registerCsiHandler({final:"s"},m=>this.saveCursor(m)),this._parser.registerCsiHandler({final:"t"},m=>this.windowOptions(m)),this._parser.registerCsiHandler({final:"u"},m=>this.restoreCursor(m)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},m=>this.insertColumns(m)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},m=>this.deleteColumns(m)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},m=>this.selectProtected(m)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},m=>this.requestMode(m,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},m=>this.requestMode(m,!1)),this._parser.setExecuteHandler(ue.BEL,()=>this.bell()),this._parser.setExecuteHandler(ue.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(ue.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(ue.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(ue.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(ue.BS,()=>this.backspace()),this._parser.setExecuteHandler(ue.HT,()=>this.tab()),this._parser.setExecuteHandler(ue.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(ue.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Pa.IND,()=>this.index()),this._parser.setExecuteHandler(Pa.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Pa.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new vi(m=>(this.setTitle(m),this.setIconName(m),!0))),this._parser.registerOscHandler(1,new vi(m=>this.setIconName(m))),this._parser.registerOscHandler(2,new vi(m=>this.setTitle(m))),this._parser.registerOscHandler(4,new vi(m=>this.setOrReportIndexedColor(m))),this._parser.registerOscHandler(8,new vi(m=>this.setHyperlink(m))),this._parser.registerOscHandler(10,new vi(m=>this.setOrReportFgColor(m))),this._parser.registerOscHandler(11,new vi(m=>this.setOrReportBgColor(m))),this._parser.registerOscHandler(12,new vi(m=>this.setOrReportCursorColor(m))),this._parser.registerOscHandler(104,new vi(m=>this.restoreIndexedColor(m))),this._parser.registerOscHandler(110,new vi(m=>this.restoreFgColor(m))),this._parser.registerOscHandler(111,new vi(m=>this.restoreBgColor(m))),this._parser.registerOscHandler(112,new vi(m=>this.restoreCursorColor(m))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let m in Dt)this._parser.registerEscHandler({intermediates:"(",final:m},()=>this.selectCharset("("+m)),this._parser.registerEscHandler({intermediates:")",final:m},()=>this.selectCharset(")"+m)),this._parser.registerEscHandler({intermediates:"*",final:m},()=>this.selectCharset("*"+m)),this._parser.registerEscHandler({intermediates:"+",final:m},()=>this.selectCharset("+"+m)),this._parser.registerEscHandler({intermediates:"-",final:m},()=>this.selectCharset("-"+m)),this._parser.registerEscHandler({intermediates:".",final:m},()=>this.selectCharset("."+m)),this._parser.registerEscHandler({intermediates:"/",final:m},()=>this.selectCharset("/"+m));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(m=>(this._logService.error("Parsing error: ",m),m)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Hm((m,S)=>this.requestStatusString(m,S)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),Km))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Km} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,o=this._activeBuffer.y,l=0,u=this._parseStack.paused;if(u){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>An&&(l=this._parseStack.position+An)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,m=>String.fromCharCode(m)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(m=>m.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<An&&(this._parseBuffer=new Uint32Array(Math.min(e.length,An))),u||this._dirtyRowTracker.clearRange(),e.length>An)for(let m=l;m<e.length;m+=An){let S=m+An<e.length?m+An:e.length,w=typeof e=="string"?this._stringDecoder.decode(e.substring(m,S),this._parseBuffer):this._utf8Decoder.decode(e.subarray(m,S),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,w))return this._preserveStack(s,o,w,m),this._logSlowResolvingAsync(n),n}else if(!u){let m=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,m))return this._preserveStack(s,o,m,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let d=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),p=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);p<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(p,this._bufferService.rows-1),end:Math.min(d,this._bufferService.rows-1)})}print(e,t,n){let s,o,l=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,d=this._bufferService.cols,p=this._coreService.decPrivateModes.wraparound,m=this._coreService.modes.insertMode,S=this._curAttrData,w=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&w.getWidth(this._activeBuffer.x-1)===2&&w.setCellFromCodepoint(this._activeBuffer.x-1,0,1,S);let y=this._parser.precedingJoinState;for(let v=t;v<n;++v){if(s=e[v],s<127&&l){let N=l[String.fromCharCode(s)];N&&(s=N.charCodeAt(0))}let C=this._unicodeService.charProperties(s,y);o=or.extractWidth(C);let b=or.extractShouldJoin(C),k=b?or.extractWidth(y):0;if(y=C,u&&this._onA11yChar.fire(On(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-k>d){if(p){let N=w,L=this._activeBuffer.x-k;for(this._activeBuffer.x=k,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),w=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),k>0&&w instanceof Vs&&w.copyCellsFrom(N,L,0,k,!1);L<d;)N.setCellFromCodepoint(L++,0,1,S)}else if(this._activeBuffer.x=d-1,o===2)continue}if(b&&this._activeBuffer.x){let N=w.getWidth(this._activeBuffer.x-1)?1:2;w.addCodepointToCell(this._activeBuffer.x-N,s,o);for(let L=o-k;--L>=0;)w.setCellFromCodepoint(this._activeBuffer.x++,0,0,S);continue}if(m&&(w.insertCells(this._activeBuffer.x,o-k,this._activeBuffer.getNullCell(S)),w.getWidth(d-1)===2&&w.setCellFromCodepoint(d-1,0,1,S)),w.setCellFromCodepoint(this._activeBuffer.x++,s,o,S),o>0)for(;--o;)w.setCellFromCodepoint(this._activeBuffer.x++,0,0,S)}this._parser.precedingJoinState=y,this._activeBuffer.x<d&&n-t>0&&w.getWidth(this._activeBuffer.x)===0&&!w.hasContent(this._activeBuffer.x)&&w.setCellFromCodepoint(this._activeBuffer.x,0,1,S),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>Um(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Hm(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new vi(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,o=!1){let l=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);l.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(l.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&s.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let o=this._activeBuffer.lines.length-this._bufferService.rows;o>0&&(this._activeBuffer.lines.trimStart(o),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-o,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-o,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(xt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,s=or.extractWidth(t),o=this._activeBuffer.x-s,l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(l.length*n),d=0;for(let m=0;m<l.length;){let S=l.codePointAt(m)||0;u[d++]=S,m+=S>65535?2:1}let p=d;for(let m=1;m<n;++m)u.copyWithin(p,0,d),p+=d;return this.print(u,0,p),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(ue.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(ue.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(ue.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(ue.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(ue.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,rr),this._charsetService.setgCharset(1,rr),this._charsetService.setgCharset(2,rr),this._charsetService.setgCharset(3,rr);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){(b=>(b[b.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",b[b.SET=1]="SET",b[b.RESET=2]="RESET",b[b.PERMANENTLY_SET=3]="PERMANENTLY_SET",b[b.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:l}=this._coreMouseService,u=this._coreService,{buffers:d,cols:p}=this._bufferService,{active:m,alt:S}=d,w=this._optionsService.rawOptions,y=(b,k)=>(u.triggerDataEvent(`${ue.ESC}[${t?"":"?"}${b};${k}$y`),!0),v=b=>b?1:2,C=e.params[0];return t?C===2?y(C,4):C===4?y(C,v(u.modes.insertMode)):C===12?y(C,3):C===20?y(C,v(w.convertEol)):y(C,0):C===1?y(C,v(s.applicationCursorKeys)):C===3?y(C,w.windowOptions.setWinLines?p===80?2:p===132?1:0:0):C===6?y(C,v(s.origin)):C===7?y(C,v(s.wraparound)):C===8?y(C,3):C===9?y(C,v(o==="X10")):C===12?y(C,v(w.cursorBlink)):C===25?y(C,v(!u.isCursorHidden)):C===45?y(C,v(s.reverseWraparound)):C===66?y(C,v(s.applicationKeypad)):C===67?y(C,4):C===1e3?y(C,v(o==="VT200")):C===1002?y(C,v(o==="DRAG")):C===1003?y(C,v(o==="ANY")):C===1004?y(C,v(s.sendFocus)):C===1005?y(C,4):C===1006?y(C,v(l==="SGR")):C===1015?y(C,4):C===1016?y(C,v(l==="SGR_PIXELS")):C===1048?y(C,1):C===47||C===1047||C===1049?y(C,v(m===S)):C===2004?y(C,v(s.bracketedPasteMode)):C===2026?y(C,v(s.synchronizedOutput)):y(C,0)}_updateAttrColor(e,t,n,s,o){return t===2?(e|=50331648,e&=-16777216,e|=eo.fromColorRGB([n,s,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],o=0,l=0;do{if(s[l+o]=e.params[t+l],e.hasSubParams(t+l)){let u=e.getSubParams(t+l),d=0;do s[1]===5&&(o=1),s[l+d+1+o]=u[d];while(++d<u.length&&d+l+1+o<s.length);break}if(s[1]===5&&l+o>=2||s[1]===2&&l+o>=5)break;s[1]&&(o=1)}while(++l+t<e.length&&l+o<s.length);for(let u=2;u<s.length;++u)s[u]===-1&&(s[u]=0);switch(s[0]){case 38:n.fg=this._updateAttrColor(n.fg,s[1],s[3],s[4],s[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,s[1],s[3],s[4],s[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,s[1],s[3],s[4],s[5])}return l}_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=xt.fg,e.bg=xt.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=xt.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=xt.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=xt.fg&16777215,s.bg&=-67108864,s.bg|=xt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${ue.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ue.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ue.ESC}[?${t};${n}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=xt.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Um(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(`${ue.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Wm&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Wm&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),o=n.shift();if(/^\d+$/.exec(s)){let l=parseInt(s);if(Vm(l))if(o==="?")t.push({type:0,index:l});else{let u=$m(o);u&&t.push({type:1,index:l,color:u})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,o=n.findIndex(l=>l.startsWith("id="));return o!==-1&&(s=n[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let s=0;s<n.length&&!(t>=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=$m(n[s]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let s=0;s<n.length;++s)if(/^\d+$/.exec(n[s])){let o=parseInt(n[s]);Vm(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,rr),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Eb[e[0]],Dt[e[1]]||rr),!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=xt.clone(),this._eraseAttrDataInternal=xt.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 Di;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(n);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=u=>(this._coreService.triggerDataEvent(`${ue.ESC}${u}${ue.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},mh=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&&(qm=e,e=t,t=qm),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};mh=_t([xe(0,ei)],mh);function Vm(e){return 0<=e&&e<256}var Rb=5e7,Ym=12,Pb=50,Db=class extends Xe{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 be),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>Rb)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let u=d=>performance.now()-n>=Ym?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(n,d);o.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(u);return}let l=this._callbacks[this._bufferOffset];if(l&&l(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=Ym)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Pb&&(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()}},gh=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let d=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(p,d)),this._dataByLinkId.set(p.id,p),p.id}let n=e,s=this._getEntryIdKey(n),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let l=t.addMarker(t.ybase+t.y),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(u,l)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};gh=_t([xe(0,ei)],gh);var Xm=!1,Mb=class extends Xe{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Yr),this._onBinary=this._register(new be),this.onBinary=this._onBinary.event,this._onData=this._register(new be),this.onData=this._onData.event,this._onLineFeed=this._register(new be),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new be),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new be),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new be),this._instantiationService=new tb,this.optionsService=this._register(new hb(e)),this._instantiationService.setService(ti,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(hh)),this._instantiationService.setService(ei,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(uh)),this._instantiationService.setService(Tv,this._logService),this.coreService=this._register(this._instantiationService.createInstance(dh)),this._instantiationService.setService(dr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(fh)),this._instantiationService.setService(jv,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(or)),this._instantiationService.setService(Qw,this.unicodeService),this._charsetService=this._instantiationService.createInstance(gb),this._instantiationService.setService(Gw,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(gh),this._instantiationService.setService(Bv,this._oscLinkService),this._inputHandler=this._register(new Nb(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ut.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ut.forward(this._bufferService.onResize,this._onResize)),this._register(Ut.forward(this.coreService.onData,this._onData)),this._register(Ut.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 Db((t,n)=>this._inputHandler.parse(t,n))),this._register(Ut.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new be),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&&!Xm&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Xm=!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,f_),t=Math.max(t,p_),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(Fm.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Fm(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ut(()=>{for(let t of e)t.dispose()})}}},Lb={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 jb(e,t,n,s){var u;let o={type:0,cancel:!1,key:void 0},l=(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=ue.ESC+"OA":o.key=ue.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=ue.ESC+"OD":o.key=ue.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=ue.ESC+"OC":o.key=ue.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=ue.ESC+"OB":o.key=ue.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":ue.DEL,e.altKey&&(o.key=ue.ESC+o.key);break;case 9:if(e.shiftKey){o.key=ue.ESC+"[Z";break}o.key=ue.HT,o.cancel=!0;break;case 13:o.key=e.altKey?ue.ESC+ue.CR:ue.CR,o.cancel=!0;break;case 27:o.key=ue.ESC,e.altKey&&(o.key=ue.ESC+ue.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;l?o.key=ue.ESC+"[1;"+(l+1)+"D":t?o.key=ue.ESC+"OD":o.key=ue.ESC+"[D";break;case 39:if(e.metaKey)break;l?o.key=ue.ESC+"[1;"+(l+1)+"C":t?o.key=ue.ESC+"OC":o.key=ue.ESC+"[C";break;case 38:if(e.metaKey)break;l?o.key=ue.ESC+"[1;"+(l+1)+"A":t?o.key=ue.ESC+"OA":o.key=ue.ESC+"[A";break;case 40:if(e.metaKey)break;l?o.key=ue.ESC+"[1;"+(l+1)+"B":t?o.key=ue.ESC+"OB":o.key=ue.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=ue.ESC+"[2~");break;case 46:l?o.key=ue.ESC+"[3;"+(l+1)+"~":o.key=ue.ESC+"[3~";break;case 36:l?o.key=ue.ESC+"[1;"+(l+1)+"H":t?o.key=ue.ESC+"OH":o.key=ue.ESC+"[H";break;case 35:l?o.key=ue.ESC+"[1;"+(l+1)+"F":t?o.key=ue.ESC+"OF":o.key=ue.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=ue.ESC+"[5;"+(l+1)+"~":o.key=ue.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=ue.ESC+"[6;"+(l+1)+"~":o.key=ue.ESC+"[6~";break;case 112:l?o.key=ue.ESC+"[1;"+(l+1)+"P":o.key=ue.ESC+"OP";break;case 113:l?o.key=ue.ESC+"[1;"+(l+1)+"Q":o.key=ue.ESC+"OQ";break;case 114:l?o.key=ue.ESC+"[1;"+(l+1)+"R":o.key=ue.ESC+"OR";break;case 115:l?o.key=ue.ESC+"[1;"+(l+1)+"S":o.key=ue.ESC+"OS";break;case 116:l?o.key=ue.ESC+"[15;"+(l+1)+"~":o.key=ue.ESC+"[15~";break;case 117:l?o.key=ue.ESC+"[17;"+(l+1)+"~":o.key=ue.ESC+"[17~";break;case 118:l?o.key=ue.ESC+"[18;"+(l+1)+"~":o.key=ue.ESC+"[18~";break;case 119:l?o.key=ue.ESC+"[19;"+(l+1)+"~":o.key=ue.ESC+"[19~";break;case 120:l?o.key=ue.ESC+"[20;"+(l+1)+"~":o.key=ue.ESC+"[20~";break;case 121:l?o.key=ue.ESC+"[21;"+(l+1)+"~":o.key=ue.ESC+"[21~";break;case 122:l?o.key=ue.ESC+"[23;"+(l+1)+"~":o.key=ue.ESC+"[23~";break;case 123:l?o.key=ue.ESC+"[24;"+(l+1)+"~":o.key=ue.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=ue.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=ue.DEL:e.keyCode===219?o.key=ue.ESC:e.keyCode===220?o.key=ue.FS:e.keyCode===221&&(o.key=ue.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let d=(u=Lb[e.keyCode])==null?void 0:u[e.shiftKey?1:0];if(d)o.key=ue.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,m=String.fromCharCode(p);e.shiftKey&&(m=m.toUpperCase()),o.key=ue.ESC+m}else if(e.keyCode===32)o.key=ue.ESC+(e.ctrlKey?ue.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),o.key=ue.ESC+p,o.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=ue.US),e.key==="@"&&(o.key=ue.NUL));break}return o}var wt=0,Tb=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Ha,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Ha,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,l)=>this._getKey(o)-this._getKey(l)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[o]=e[t],t++):s[o]=this._array[n++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(wt=this._search(t),wt===-1)||this._getKey(this._array[wt])!==t)return!1;do if(this._array[wt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(wt),!0;while(++wt<this._array.length&&this._getKey(this._array[wt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,l)=>o-l),t=0,n=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[s++]=this._array[o];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(wt=this._search(e),!(wt<0||wt>=this._array.length)&&this._getKey(this._array[wt])===e))do yield this._array[wt];while(++wt<this._array.length&&this._getKey(this._array[wt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(wt=this._search(e),!(wt<0||wt>=this._array.length)&&this._getKey(this._array[wt])===e))do t(this._array[wt]);while(++wt<this._array.length&&this._getKey(this._array[wt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let s=t+n>>1,o=this._getKey(this._array[s]);if(o>e)n=s-1;else if(o<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},nu=0,Gm=0,Bb=class extends Xe{constructor(){super(),this._decorations=new Tb(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new be),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new be),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ut(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Ab(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let s=0,o=0;for(let l of this._decorations.getKeyIterator(t))s=l.options.x??0,o=s+(l.options.width??1),e>=s&&e<o&&(!n||(l.options.layer??"bottom")===n)&&(yield l)}forEachDecorationAtCell(e,t,n,s){this._decorations.forEachByKey(t,o=>{nu=o.options.x??0,Gm=nu+(o.options.width??1),e>=nu&&e<Gm&&(!n||(o.options.layer??"bottom")===n)&&s(o)})}},Ab=class extends Fn{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new be),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new be),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=pt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=pt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Ib=1e3,Ob=class{constructor(e,t=Ib){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=s-this._lastRefreshMs,l=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},l)}}_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)}},Qm=20,$a=class extends Xe{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let l=0;l<this._terminal.rows;l++)this._rowElements[l]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[l]);if(this._topBoundaryFocusListener=l=>this._handleBoundaryFocus(l,0),this._bottomBoundaryFocusListener=l=>this._handleBoundaryFocus(l,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=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 Ob(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(l=>this._handleResize(l.rows))),this._register(this._terminal.onRender(l=>this._refreshRows(l.start,l.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(l=>this._handleChar(l))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
64
|
-
`))),this._register(this._terminal.onA11yTab(l=>this._handleTab(l))),this._register(this._terminal.onKey(l=>this._handleKey(l.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register($e(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ut(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Qm+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
65
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Qm+1&&(this._liveRegion.textContent+=Au.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let o=e;o<=t;o++){let l=n.lines.get(n.ydisp+o),u=[],d=(l==null?void 0:l.translateToString(!0,void 0,void 0,u))||"",p=(n.ydisp+o+1).toString(),m=this._rowElements[o];m&&(d.length===0?(m.textContent=" ",this._rowColumns.set(m,[0,1])):(m.textContent=d,this._rowColumns.set(m,u)),m.setAttribute("aria-posinset",p),m.setAttribute("aria-setsize",s),this._alignRowWidth(m))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),l=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===l||e.relatedTarget!==s)return;let u,d;if(t===0?(u=n,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(u=this._rowElements.shift(),d=n,this._rowContainer.removeChild(u)),u.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let p=this._createAccessibilityTreeNode();this._rowElements.unshift(p),this._rowContainer.insertAdjacentElement("afterbegin",p)}else{let p=this._createAccessibilityTreeNode();this._rowElements.push(p),this._rowContainer.appendChild(p)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var d;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:((d=s.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(n.node))return;let o=({node:p,offset:m})=>{let S=p instanceof Text?p.parentNode:p,w=parseInt(S==null?void 0:S.getAttribute("aria-posinset"),10)-1;if(isNaN(w))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(S);if(!y)return console.warn("columns is null. Race condition?"),null;let v=m<y.length?y[m]:y.slice(-1)[0]+1;return v>=this._terminal.cols&&(++w,v=0),{row:w,column:v}},l=o(t),u=o(n);if(!(!l||!u)){if(l.row>u.row||l.row===u.row&&l.column>=u.column)throw new Error("invalid range");this._terminal.select(l.column,l.row,(u.row-l.row)*this._terminal.cols-l.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,l;e.style.transform="";let t=e.getBoundingClientRect().width,n=(l=(o=this._rowColumns.get(e))==null?void 0:o.slice(-1))==null?void 0:l[0];if(!n)return;let s=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};$a=_t([xe(1,Ih),xe(2,fn),xe(3,pn)],$a);var vh=class extends Xe{constructor(e,t,n,s,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new be),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new be),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ut(()=>{var l;cr(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(l=this._activeProviderReplies)==null||l.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register($e(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register($e(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register($e(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register($e(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s<n.length;s++){let o=n[s];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var s,o;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(l=>{l==null||l.forEach(u=>{u.link.dispose&&u.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[l,u]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(l)&&(n=this._checkLinkProviderResult(l,e,n)):u.provideLinks(e.y,d=>{var m,S;if(this._isMouseOut)return;let p=d==null?void 0:d.map(w=>({link:w}));(m=this._activeProviderReplies)==null||m.set(l,p),n=this._checkLinkProviderResult(l,e,n),((S=this._activeProviderReplies)==null?void 0:S.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let l=0;l<o.length;l++){let u=o[l],d=u.link.range.start.y<e?0:u.link.range.start.x,p=u.link.range.end.y>e?this._bufferService.cols:u.link.range.end.x;for(let m=d;m<=p;m++){if(n.has(m)){o.splice(l--,1);break}n.add(m)}}}}_checkLinkProviderResult(e,t,n){var l;if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),o=!1;for(let u=0;u<e;u++)(!this._activeProviderReplies.has(u)||this._activeProviderReplies.get(u))&&(o=!0);if(!o&&s){let u=s.find(d=>this._linkAtPosition(d.link,t));u&&(n=!0,this._handleNewLink(u))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let u=0;u<this._activeProviderReplies.size;u++){let d=(l=this._activeProviderReplies.get(u))==null?void 0:l.find(p=>this._linkAtPosition(p.link,t));if(d){n=!0,this._handleNewLink(d);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&zb(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,cr(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.pointerCursor},set:n=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.underline},set:n=>{var s,o,l;(s=this._currentLink)!=null&&s.state&&((l=(o=this._currentLink)==null?void 0:o.state)==null?void 0:l.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let l=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);l&&this._askForLink(l,!1)}})))}_linkHover(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return n<=o&&o<=s}_positionFromMouseEvent(e,t,n){let s=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,s,o){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:o}}};vh=_t([xe(1,Oh),xe(2,pn),xe(3,ei),xe(4,Iv)],vh);function zb(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 Fb=class extends Mb{constructor(e={}){super(e),this._linkifier=this._register(new Yr),this.browser=i_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Yr),this._onCursorMove=this._register(new be),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new be),this.onKey=this._onKey.event,this._onRender=this._register(new be),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new be),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new be),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new be),this.onBell=this._onBell.event,this._onFocus=this._register(new be),this._onBlur=this._register(new be),this._onA11yCharEmitter=this._register(new be),this._onA11yTabEmitter=this._register(new be),this._onWillOpen=this._register(new be),this._setup(),this._decorationService=this._instantiationService.createInstance(Bb),this._instantiationService.setService(to,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(P1),this._instantiationService.setService(Iv,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Ou)),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(Ut.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ut.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ut.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ut.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ut(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let o=lt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${ue.ESC}]${s};${kb(o)}${e_.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(l=>l.ansi[t.index]=kt.toColor(...t.color));else{let l=n;this._themeService.modifyColors(u=>u[l]=kt.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($a,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ue.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(ue.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),l=this._renderService.dimensions.css.cell.width*o,u=this.buffer.y*this._renderService.dimensions.css.cell.height,d=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=d+"px",this.textarea.style.top=u+"px",this.textarea.style.width=l+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register($e(this.element,"copy",t=>{this.hasSelection()&&Uw(t,this._selectionService)}));let e=t=>Kw(t,this.textarea,this.coreService,this.optionsService);this._register($e(this.textarea,"paste",e)),this._register($e(this.element,"paste",e)),n_?this._register($e(this.element,"mousedown",t=>{t.button===2&&am(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register($e(this.element,"contextmenu",t=>{am(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),qh&&this._register($e(this.element,"auxclick",t=>{t.button===1&&Rv(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register($e(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register($e(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register($e(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register($e(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register($e(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register($e(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register($e(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($e(this.screenElement,"mousemove",l=>this.updateCursorStyle(l))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Bu.get()),o_||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(N1,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(fn,this._coreBrowserService),this._register($e(this.textarea,"focus",l=>this._handleTextAreaFocus(l))),this._register($e(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(sh,this._document,this._helperContainer),this._instantiationService.setService(Xa,this._charSizeService),this._themeService=this._instantiationService.createInstance(ch),this._instantiationService.setService(Gr,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(za),this._instantiationService.setService(Av,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(ah,this.rows,this.screenElement)),this._instantiationService.setService(pn,this._renderService),this._register(this._renderService.onRenderedViewportChange(l=>this._onRender.fire(l))),this.onResize(l=>this._renderService.resize(l.cols,l.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(ih,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(oh),this._instantiationService.setService(Oh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(vh,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(eh,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(l=>{super.scrollLines(l,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(lh,this.element,this.screenElement,s)),this._instantiationService.setService(Zw,this._selectionService),this._register(this._selectionService.onRequestScrollLines(l=>this.scrollLines(l.amount,l.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(l=>this._renderService.handleSelectionChanged(l.start,l.end,l.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(l=>{this.textarea.value=l,this.textarea.focus(),this.textarea.select()})),this._register(Ut.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var l;this._selectionService.refresh(),(l=this._viewport)==null||l.queueSync()})),this._register(this._instantiationService.createInstance(th,this.screenElement)),this._register($e(this.element,"mousedown",l=>this._selectionService.handleMouseDown(l))),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($a,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",l=>this._handleScreenReaderModeOptionChange(l))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Oa,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",l=>{!this._overviewRulerRenderer&&l&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Oa,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(rh,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(l){var m,S,w,y,v;let u=e._mouseService.getMouseReportCoords(l,e.screenElement);if(!u)return!1;let d,p;switch(l.overrideType||l.type){case"mousemove":p=32,l.buttons===void 0?(d=3,l.button!==void 0&&(d=l.button<3?l.button:3)):d=l.buttons&1?0:l.buttons&4?1:l.buttons&2?2:3;break;case"mouseup":p=0,d=l.button<3?l.button:3;break;case"mousedown":p=1,d=l.button<3?l.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(l)===!1)return!1;let C=l.deltaY;if(C===0||e.coreMouseService.consumeWheelEvent(l,(y=(w=(S=(m=e._renderService)==null?void 0:m.dimensions)==null?void 0:S.device)==null?void 0:w.cell)==null?void 0:y.height,(v=e._coreBrowserService)==null?void 0:v.dpr)===0)return!1;p=C<0?0:1,d=4;break;default:return!1}return p===void 0||d===void 0||d>4?!1:e.coreMouseService.triggerMouseEvent({col:u.col,row:u.row,x:u.x,y:u.y,button:d,action:p,ctrl:l.ctrlKey,alt:l.altKey,shift:l.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:l=>(n(l),l.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(l)),wheel:l=>(n(l),this.cancel(l,!0)),mousedrag:l=>{l.buttons&&n(l)},mousemove:l=>{l.buttons||n(l)}};this._register(this.coreMouseService.onProtocolChange(l=>{l?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(l)),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()),l&8?s.mousemove||(t.addEventListener("mousemove",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),l&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),l&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),l&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register($e(t,"mousedown",l=>{if(l.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(l)))return n(l),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(l)})),this._register($e(t,"wheel",l=>{var u,d,p,m,S;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(l)===!1)return!1;if(!this.buffer.hasScrollback){if(l.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(l,(m=(p=(d=(u=e._renderService)==null?void 0:u.dimensions)==null?void 0:d.device)==null?void 0:p.cell)==null?void 0:m.height,(S=e._coreBrowserService)==null?void 0:S.dpr)===0)return this.cancel(l,!0);let w=ue.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(l.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(w,!0),this.cancel(l,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Nv(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=jb(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===ue.ETX||n.key===ue.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Hb(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var n;(n=this._charSizeService)==null||n.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(xt));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(ue.ESC+"[I"):this.coreService.triggerDataEvent(ue.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${ue.ESC}[4;${n};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${ue.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function Hb(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var $b=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},Wb=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 Di)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Jm=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 Wb(t)}getNullCell(){return new Di}},Ub=class extends Xe{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new be),this.onBufferChange=this._onBufferChange.event,this._normal=new Jm(this._core.buffers.normal,"normal"),this._alternate=new Jm(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)}},Kb=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},qb=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}},Vb=["cols","rows"],qi=0,Yb=class extends Xe{constructor(e){super(),this._core=this._register(new Fb(e)),this._addonManager=this._register(new $b),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,o)=>{this._checkReadonlyOptions(s),this._core.options[s]=o};for(let s in this._core.options){let o={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,o)}}_checkReadonlyOptions(e){if(Vb.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 Kb(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new qb(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 Ub(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
66
|
-
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Bu.get()},set promptLabel(e){Bu.set(e)},get tooMuchOutput(){return Au.get()},set tooMuchOutput(e){Au.set(e)}}}_verifyIntegers(...e){for(qi of e)if(qi===1/0||isNaN(qi)||qi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(qi of e)if(qi&&(qi===1/0||isNaN(qi)||qi%1!==0||qi<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 Xb=2,Gb=1,Qb=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 w;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:((w=this._terminal.options.overviewRuler)==null?void 0:w.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),u={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},d=u.top+u.bottom,p=u.right+u.left,m=s-d,S=o-p-t;return{cols:Math.max(Xb,Math.floor(S/e.css.cell.width)),rows:Math.max(Gb,Math.floor(m/e.css.cell.height))}}};function Jb(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function Zb({session:e,node:t,token:n,cols:s,rows:o,readonly:l=!1,takeSize:u,focused:d,onData:p,onExit:m,onFiles:S,retryBaseMs:w=250}){const y=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!y)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const C=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${Jb(t,n)}`;let b=null,k=!1,N=!1,L=null,A=0,B=d;const ee=()=>{if(k||N||L)return;const F=Math.min(5e3,Math.max(0,w)*2**Math.min(A++,5));L=setTimeout(()=>{L=null,O()},F)},O=()=>{if(k||N)return;const F=new WebSocket(C);b=F,F.binaryType="arraybuffer",F.onopen=()=>{if(b!==F||k)return;A=0;const Z={type:"attach",session:e,token:n,cols:s,rows:o,readonly:l};u!==void 0&&(Z.takeSize=u),F.send(JSON.stringify(Z)),B!==void 0&&F.send(JSON.stringify({type:"focus",on:!!B}))},F.onmessage=Z=>{if(!(b!==F||k))if(typeof Z.data=="string"){let W;try{W=JSON.parse(Z.data)}catch{return}W.type==="exit"&&(N=!0,m&&m(W.code)),W.type==="files"&&S&&S(W)}else p&&p(new Uint8Array(Z.data))},F.onerror=()=>{if(b===F)try{F.close()}catch{}},F.onclose=Z=>{b!==F||k||N||[1e3,1002,4401,4404].includes(Z==null?void 0:Z.code)||ee()}};return O(),{sendInput:F=>{if(!b||b.readyState!==1)return!1;try{return b.send(typeof F=="string"?new TextEncoder().encode(F):F),!0}catch{try{b.close()}catch{}return!1}},isReady:()=>!!b&&b.readyState===1,resize:(F,Z)=>{s=F,o=Z,(b==null?void 0:b.readyState)===1&&b.send(JSON.stringify({type:"resize",cols:F,rows:Z}))},action:F=>{(b==null?void 0:b.readyState)===1&&b.send(JSON.stringify({type:"action",name:F}))},focus:F=>{B=F,(b==null?void 0:b.readyState)===1&&b.send(JSON.stringify({type:"focus",on:!!F}))},close:()=>{if(k=!0,L&&clearTimeout(L),L=null,b)try{b.close()}catch{}},get raw(){return b}}}async function Zm(e){const t=String(e||"");if(!t)return!1;try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(t),!0}catch{}try{const n=document.createElement("textarea");n.value=t,n.readOnly=!0,n.style.position="fixed",n.style.opacity="0",n.style.pointerEvents="none",document.body.appendChild(n),n.select();const s=document.execCommand&&document.execCommand("copy");if(n.remove(),s)return!0}catch{}return!1}const eC="\r";function tC(e){const t=String(e||"");let n=t.length;for(;n>0;){const s=t.charCodeAt(n-1);if(s===10||s===13)n-=1;else break}return t.slice(0,n)}function iC({isReady:e,paste:t,send:n}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:n(eC)!==!1}catch{return!1}}}function nC(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function rC(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}const sC=450,eg=8;function oC(e,t,n,s){return Math.abs(Number(n)-Number(e))>eg||Math.abs(Number(s)-Number(t))>eg}const aC=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function ru(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 tg(e){if(!e)return[];const t=Array.from(e.files||[]).filter(Boolean);return t.length?t:Array.from(e.items||[]).filter(n=>n&&n.kind==="file"&&typeof n.getAsFile=="function").map(n=>n.getAsFile()).filter(Boolean)}function lC(e,t=0,n=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=aC.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${n}-${t+1}.${o}`}async function g_({files:e,token:t,session:n,node:s="",paste:o=!0,fetchImpl:l=zt,onProgress:u=()=>{},now:d=Date.now()}={}){const p=Array.from(e||[]).filter(Boolean),m=[],S=[];if(!n||!p.length)return{paths:m,errors:S};const w=ui(s?String(s).split("/"):[]);for(let y=0;y<p.length;y+=1){const v=p[y],C=lC(v,y,d);u({index:y,total:p.length,name:C,state:"uploading"});try{const b=new FormData;b.append("session",n),b.append("paste",o?"true":"false"),b.append("file",v,C);const k=await l(`${w}/files/upload`,t,{method:"POST",body:b}),N=await k.json().catch(()=>({}));if(!k.ok||N.error)throw new Error(N.error||`HTTP ${k.status}`);m.push(N.path),u({index:y,total:p.length,name:C,state:"done",path:N.path})}catch(b){const k=String((b==null?void 0:b.message)||b);S.push({name:C,message:k}),u({index:y,total:p.length,name:C,state:"error",error:k})}}return{paths:m,errors:S}}function v_({session:e,node:t,token:n,readonly:s,takeSize:o,focused:l,sendRef:u,composerRef:d,actionRef:p,ctrlRef:m,setCtrlArmed:S,onFiles:w,fontSize:y=13,selectionMode:v=!1,onSelectionModeChange:C}){const b=M.useRef(null),k=M.useRef(null),N=M.useRef(y);N.current=y;const L=M.useRef(l);L.current=l;const A=M.useRef(v);A.current=v;const[B,ee]=M.useState(""),[O,F]=M.useState(""),[Z,W]=M.useState(null),G=async()=>{var j,U,R,H;const P=((U=(j=k.current)==null?void 0:j.term)==null?void 0:U.getSelection())||B;if(!P){F(_("copy-empty")),setTimeout(()=>F(""),1500);return}const E=await Zm(P);F(_(E?"copied":"copy-manual")),E&&((H=(R=k.current)==null?void 0:R.term)==null||H.clearSelection(),C==null||C(!1)),setTimeout(()=>F(""),1800)},K=M.useRef(G);return K.current=G,M.useEffect(()=>{const P=k.current;P&&P.sock&&P.sock.focus&&P.sock.focus(!!l)},[l]),M.useEffect(()=>{const P=k.current;P&&(P.term.options.fontSize=y,P.fit.fit(),P.sock.resize(P.term.cols,P.term.rows))},[y]),M.useEffect(()=>{const P=new Yb({cursorBlink:!0,fontSize:N.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),E=new Qb;P.loadAddon(E),P.open(b.current),E.fit();const j=new TextDecoder;let U;try{U=Zb({session:e,node:t,token:n,readonly:s,takeSize:o,focused:L.current,onFiles:w,cols:P.cols,rows:P.rows,onData:me=>P.write(j.decode(me)),onExit:()=>P.write(`\r
|
|
78
|
-
\x1B[33m[sessione finita]\x1B[0m\r
|
|
79
|
-
`)})}catch(me){return P.write(`\r
|
|
80
|
-
\x1B[31m${me.message}\x1B[0m\r
|
|
81
|
-
`),()=>P.dispose()}k.current={term:P,fit:E,sock:U};let R=null;const H=P.onData(me=>{if(s){R&&(R.ok=!1);return}if(!R&&m&&m.current&&me.length===1){const et=me.charCodeAt(0);let ce=et;et>=97&&et<=122?ce=et-96:et>=64&&et<=95?ce=et-64:et===32&&(ce=0),me=String.fromCharCode(ce),m.current=!1,S&&S(!1)}const qe=U.sendInput(me);R&&(R.seen=!0,R.ok=R.ok&&qe)});u&&(u.current=me=>U.sendInput(me)),p&&(p.current=me=>U.action(me)),d&&(d.current=iC({isReady:()=>!s&&U.isReady(),paste:me=>{const qe={seen:!1,ok:!0};R=qe;try{P.paste(me)}catch{qe.ok=!1}finally{R=null}return qe.seen&&qe.ok},send:me=>U.sendInput(me)}));const I=P.onSelectionChange(()=>ee(P.getSelection()));P.attachCustomKeyEventHandler(me=>(me.ctrlKey||me.metaKey)&&me.key.toLowerCase()==="c"&&P.getSelection()?(me.type==="keydown"&&Zm(P.getSelection()),!1):!0);const q=b.current;let X=!1;const D=async me=>{if(!me.length||X)return;if(s){W({error:_("settings-readonly")});return}X=!0,W({current:0,total:me.length,name:""});const qe=await g_({files:me,token:n,session:e,node:t,paste:!0,onProgress:({index:et,total:ce,name:De,state:Ke,error:Mt})=>W({current:et+1,total:ce,name:De,...Ke==="error"?{error:Mt}:{}})});X=!1,qe.errors.length?W({error:qe.errors.map(et=>`${et.name}: ${et.message}`).join(" · ")}):(W({done:!0,total:qe.paths.length}),setTimeout(()=>W(null),1600))},Q=me=>{const qe=me.clipboardData;if(!ru(qe))return;const et=tg(qe);et.length&&(me.preventDefault(),me.stopPropagation(),D(et))},se=me=>{ru(me.dataTransfer)&&(me.preventDefault(),me.stopPropagation())},re=me=>{ru(me.dataTransfer)&&(me.preventDefault(),me.stopPropagation(),D(tg(me.dataTransfer)))};q.addEventListener("paste",Q,!0),q.addEventListener("dragenter",se,!0),q.addEventListener("dragover",se,!0),q.addEventListener("drop",re,!0);const ae=24;let le=null,de=null,ve=0,Re=null,Fe=null,te=null,ie=!1;const ye=()=>{te&&clearTimeout(te),te=null},Le=(me,qe)=>{const ce=(q.querySelector(".xterm-screen")||q).getBoundingClientRect(),De=Math.max(0,Math.min(P.cols-1,Math.floor((me-ce.left)/Math.max(1,ce.width)*P.cols))),Ke=Math.max(0,Math.min(P.rows-1,Math.floor((qe-ce.top)/Math.max(1,ce.height)*P.rows)));return{col:De,row:P.buffer.active.viewportY+Ke}},je=me=>Le(me.clientX,me.clientY),Y=me=>{if(ye(),ie=!1,me.touches.length!==1){le=null;return}if(A.current){me.preventDefault(),me.stopPropagation(),Fe=je(me.touches[0]),P.clearSelection();return}le=me.touches[0].clientY,de=me.touches[0].clientX,ve=0,Re=null;const qe={x:de,y:le};te=setTimeout(()=>{te=null,ie=!0,A.current=!0,C==null||C(!0),Fe=Le(qe.x,qe.y),P.clearSelection(),P.select(Fe.col,Fe.row,1),le=null,de=null,Re=null,ve=0},sC)},he=me=>{if((A.current||ie)&&Fe&&me.touches.length===1){me.preventDefault(),me.stopPropagation();const et=je(me.touches[0]),ce=Fe.row*P.cols+Fe.col,De=et.row*P.cols+et.col,Ke=ce<=De?Fe:et;P.select(Ke.col,Ke.row,Math.abs(De-ce)+1);return}if(le===null||me.touches.length!==1)return;me.preventDefault(),me.stopPropagation();const qe=me.touches[0];if(te&&oC(de,le,qe.clientX,qe.clientY)&&ye(),Re===null&&(Math.abs(qe.clientY-le)>8||Math.abs(qe.clientX-de)>8)&&(Re=Math.abs(qe.clientY-le)>Math.abs(qe.clientX-de)),!!Re){for(ve+=qe.clientY-le,le=qe.clientY;ve>=ae;)U.action("scroll-up"),ve-=ae;for(;ve<=-ae;)U.action("scroll-down"),ve+=ae}},we=()=>{ye(),le=null,de=null,Fe=null,ie=!1};let $=0;const fe=me=>{for(me.preventDefault(),me.stopPropagation(),$+=me.deltaY;$<=-ae;)U.action("scroll-up"),$+=ae;for(;$>=ae;)U.action("scroll-down"),$-=ae};q.addEventListener("touchstart",Y,{passive:!1}),q.addEventListener("touchmove",he,{passive:!1,capture:!0}),q.addEventListener("touchend",we,{passive:!0}),q.addEventListener("touchcancel",we,{passive:!0});const Ce=me=>{(A.current||ie)&&(me.preventDefault(),me.stopPropagation())};q.addEventListener("contextmenu",Ce,!0),q.addEventListener("wheel",fe,{passive:!1,capture:!0});let Ee=null;const Ae=me=>{nC(me)&&(me.preventDefault(),me.stopPropagation(),Ee=Le(me.clientX,me.clientY),P.clearSelection())},mt=me=>{if(!Ee)return;me.preventDefault(),me.stopPropagation();const qe=Le(me.clientX,me.clientY),et=Ee.row*P.cols+Ee.col,ce=qe.row*P.cols+qe.col,De=et<=ce?Ee:qe;P.select(De.col,De.row,Math.abs(ce-et)+1)},rt=me=>{Ee&&(me.stopPropagation(),Ee=null)};q.addEventListener("mousedown",Ae,!0),q.addEventListener("mousemove",mt,!0),q.addEventListener("mouseup",rt,!0);const Be=me=>{!rC(me)||!(k.current&&k.current.term&&k.current.term.getSelection())||(me.preventDefault(),me.stopPropagation(),K.current&&K.current())};q.addEventListener("keydown",Be,!0);const We=()=>{E.fit(),U.resize(P.cols,P.rows)};window.addEventListener("resize",We);const Ie=window.visualViewport;Ie&&(Ie.addEventListener("resize",We),Ie.addEventListener("scroll",We));let bt=null,Ge=0;return typeof ResizeObserver<"u"&&(bt=new ResizeObserver(()=>{Ge&&cancelAnimationFrame(Ge),Ge=requestAnimationFrame(We)}),bt.observe(q)),()=>{k.current=null,u&&(u.current=()=>!1),d&&(d.current=()=>!1),p&&(p.current=()=>!1),H.dispose(),I.dispose(),q.removeEventListener("touchstart",Y),q.removeEventListener("touchmove",he,{capture:!0}),q.removeEventListener("touchend",we),q.removeEventListener("touchcancel",we),q.removeEventListener("contextmenu",Ce,!0),ye(),q.removeEventListener("wheel",fe,{capture:!0}),q.removeEventListener("mousedown",Ae,!0),q.removeEventListener("mousemove",mt,!0),q.removeEventListener("mouseup",rt,!0),q.removeEventListener("keydown",Be,!0),q.removeEventListener("paste",Q,!0),q.removeEventListener("dragenter",se,!0),q.removeEventListener("dragover",se,!0),q.removeEventListener("drop",re,!0),window.removeEventListener("resize",We),Ie&&(Ie.removeEventListener("resize",We),Ie.removeEventListener("scroll",We)),bt&&bt.disconnect(),Ge&&cancelAnimationFrame(Ge),U.close(),P.dispose()}},[e,t,n,s,o,u,d,p,m,S,w]),h.jsxs("div",{className:`nc-terminal${v?" selecting":""}`,children:[h.jsx("div",{className:"nc-terminal-host",ref:b}),Z&&h.jsx("div",{className:`nc-upload-state${Z.error?" error":""}`,role:"status",children:Z.error?Z.error:Z.done?_("attach-uploaded").replace("{n}",String(Z.total||0)):_("attach-upload-progress").replace("{n}",String(Z.current||0)).replace("{total}",String(Z.total||0))}),(B||v)&&h.jsxs("div",{className:"nc-selection-tools",children:[B?h.jsx("button",{type:"button",onClick:G,children:O||_("copy")}):h.jsx("span",{children:_("select-drag")}),h.jsx("button",{type:"button",onClick:()=>{var P,E;(E=(P=k.current)==null?void 0:P.term)==null||E.clearSelection(),ee(""),C==null||C(!1)},children:_("cancel")}),O===_("copy-manual")&&h.jsx("textarea",{readOnly:!0,value:B,onFocus:P=>P.target.select()})]})]})}const ig="",ci="\x1B",cC=[{label:"↑",seq:ci+"[A"},{label:"↓",seq:ci+"[B"},{label:"PGUP",seq:ci+"[5~"},{label:"PGDN",seq:ci+"[6~"}];function uC({send:e,action:t,ctrlArmed:n=!1,onCtrl:s,onKeyboard:o,selectionMode:l=!1,onSelectionMode:u}){const[d,p]=M.useState(!1),[m,S]=M.useState(!1),[w,y]=M.useState(!1),v=k=>{w?(e(ci+k),y(!1)):e(k)},C=(k,N,L)=>h.jsx("button",{onMouseDown:A=>{A.preventDefault(),v(N),L&&L()},children:k},k),b=(k,N)=>h.jsx("button",{onMouseDown:L=>{L.preventDefault(),t(N),S(!1)},children:k},k);return d?h.jsxs("div",{className:"nc-keybar copy",children:[h.jsx("span",{className:"tag",children:"copy-mode"}),cC.map(k=>C(k.label,k.seq)),C("ESCI (q)","q",()=>p(!1))]}):h.jsxs("div",{className:"nc-keybar termux",children:[m&&h.jsxs("div",{className:"nc-keymenu",children:[b("←WIN","prev-window"),b("WIN→","next-window"),b("⬅PANE","pane-left"),b("PANE➡","pane-right"),C("SCROLL",ig+"[",()=>{p(!0),S(!1)}),h.jsx("button",{className:l?"armed":"",onMouseDown:k=>{k.preventDefault(),u==null||u(!l),S(!1)},children:"SELECT"}),C("⌃C","",()=>S(!1)),C("DETACH",ig+"d",()=>S(!1))]}),h.jsxs("div",{className:"row",children:[C("ESC",ci),h.jsx("button",{className:m?"armed":"",onMouseDown:k=>{k.preventDefault(),S(N=>!N)},children:"☰"},"menu"),C("/","/"),C("—","-"),C("HOME",ci+"[H"),C("↑",ci+"[A"),C("END",ci+"[F"),C("PGUP",ci+"[5~")]}),h.jsxs("div",{className:"row",children:[C("⇥"," "),h.jsx("button",{onMouseDown:k=>{k.preventDefault(),o&&o()},children:"⌨"},"kbd"),h.jsx("button",{className:n?"armed":"",onMouseDown:k=>{k.preventDefault(),s&&s()},children:"CTRL"},"ctrl"),h.jsx("button",{className:w?"armed":"",onMouseDown:k=>{k.preventDefault(),y(N=>!N)},children:"ALT"},"alt"),C("←",ci+"[D"),C("↓",ci+"[B"),C("→",ci+"[C"),C("PGDN",ci+"[6~")]})]})}const hC=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function __({session:e,node:t,token:n,filesEvent:s,onClose:o}){Si();const l=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",u=t?`${t}:${e}`:e,[d,p]=M.useState("outbox"),[m,S]=M.useState({inbox:[],outbox:[]}),[w,y]=M.useState(""),v=M.useRef(null);async function C(){try{const A=await(await zt(`${l}/files?session=${encodeURIComponent(e)}`,n)).json();if(A.error){y(A.error);return}S(A);const B=A.outbox[0]?A.outbox[0].mtime:0;localStorage.setItem(La(u),String(B))}catch(L){y(String(L))}}M.useEffect(()=>{C()},[e,t]),M.useEffect(()=>{s&&s.session===e&&C()},[s]);async function b(L){for(const A of L){y(`carico ${A.name}…`);const B=new FormData;B.append("session",e),B.append("file",A);try{const O=await(await zt(`${l}/files/upload`,n,{method:"POST",body:B})).json();y(O.error?`errore: ${O.error}`:"")}catch(ee){y(String(ee))}}C()}async function k(L){const A=await zt(`${l}/files/download?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(L)}`,n);if(!A.ok){y("errore download");return}const B=await A.blob(),ee=URL.createObjectURL(B),O=document.createElement("a");O.href=ee,O.download=L,O.click(),URL.revokeObjectURL(ee)}async function N(L){await zt(`${l}/files?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(L)}`,n,{method:"DELETE"}),C()}return h.jsxs("div",{className:"nc-files",children:[h.jsxs("header",{children:[h.jsx("b",{children:t?`${t}:${e}`:e}),h.jsx("button",{onClick:o,title:_("close"),children:h.jsx(tt,{name:"x",size:20})})]}),h.jsxs("nav",{children:[h.jsx("button",{className:d==="outbox"?"on":"",onClick:()=>p("outbox"),children:"outbox"}),h.jsx("button",{className:d==="inbox"?"on":"",onClick:()=>p("inbox"),children:"inbox"}),h.jsxs("button",{className:"up",onClick:()=>v.current&&v.current.click(),children:[h.jsx(tt,{name:"upload",size:18})," ",_("upload")]}),h.jsx("input",{type:"file",multiple:!0,ref:v,style:{display:"none"},onChange:L=>{b(Array.from(L.target.files||[])),L.target.value=""}})]}),w&&h.jsx("div",{className:"nc-busy",children:w}),h.jsxs("ul",{children:[m[d].map(L=>h.jsxs("li",{children:[h.jsx("span",{className:"name",onClick:()=>k(L.name),children:L.name}),h.jsx("small",{children:hC(L.size)}),h.jsx("button",{onClick:()=>N(L.name),title:"elimina",children:h.jsx(tt,{name:"trash",size:18})})]},L.name)),m[d].length===0&&h.jsx("li",{className:"empty",children:_("empty-files")})]})]})}function y_({submitText:e,token:t,session:n,node:s}){Si();const o=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",[l,u]=M.useState(""),[d,p]=M.useState(!1),[m,S]=M.useState(""),[w,y]=M.useState(!1),v=M.useRef(null),C=M.useRef(null),b=M.useRef(null),[k,N]=M.useState(!1),[L,A]=M.useState({left:0,bottom:0}),[B,ee]=M.useState(!1),[O,F]=M.useState(!1),Z=M.useRef(null),W=M.useRef(null),G=M.useRef(null),K=M.useRef(null),P=M.useRef(null),E=M.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);M.useEffect(()=>{let se=!1;if(s){y(!1);return}return zt(`${o}/voice/status`,t).then(re=>re.json()).then(re=>{se||y(!!re.serverSttConfigured)}).catch(()=>{se||y(!1)}),()=>{se=!0}},[t,o]);const U=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||w);async function R(){const se=l,re=tC(se);if(!re||O)return;F(!0),S("");let ae=!1;try{ae=!!await e(re)}catch{ae=!1}ae?u(le=>le===se?"":le):S(_("composer-send-failed")),F(!1),requestAnimationFrame(()=>{var le;return(le=b.current)==null?void 0:le.focus({preventScroll:!0})})}function H(){const se=Z.current&&Z.current.getBoundingClientRect();se&&A({left:Math.max(6,Math.min(se.left,window.innerWidth-186)),bottom:window.innerHeight-se.top+6}),N(!0)}function I(se){N(!1),se&&Z.current&&Z.current.focus()}M.useEffect(()=>{if(!k)return;const se=ae=>{ae.key==="Escape"&&I(!0)},re=ae=>{const le=W.current&&W.current.contains(ae.target),de=Z.current&&Z.current.contains(ae.target);!le&&!de&&I(!1)};return document.addEventListener("keydown",se),document.addEventListener("pointerdown",re),()=>{document.removeEventListener("keydown",se),document.removeEventListener("pointerdown",re)}},[k]);function q(se){I(!1),se.current&&se.current.click()}async function X(se){if(!se.length||!n)return;ee(!0),S("");const{paths:re,errors:ae}=await g_({files:se,token:t,session:n,node:s,paste:!1});ae.length&&S(ae.map(le=>`${le.name}: ${le.message}`).join(" · ")),re.length&&u(le=>le+(le&&!le.endsWith(" ")?" ":"")+re.join(" ")),ee(!1)}function D(){v.current&&v.current.stop(),C.current&&C.current.stop(),p(!1)}async function Q(){S("");const se=window.SpeechRecognition||window.webkitSpeechRecognition;if(se){const re=new se;re.lang="it-IT",re.continuous=!1,re.interimResults=!0;const ae=l?`${l} `:"";re.onresult=le=>{const de=Array.from(le.results).map(ve=>ve[0].transcript).join("");u(ae+de)},re.onend=()=>p(!1),re.onerror=le=>{S(`voice: ${le.error||"errore"}`),p(!1)},v.current=re,re.start(),p(!0);return}try{const re=await navigator.mediaDevices.getUserMedia({audio:!0}),ae=new MediaRecorder(re),le=[];ae.ondataavailable=de=>le.push(de.data),ae.onstop=async()=>{re.getTracks().forEach(de=>de.stop()),p(!1),S("trascrivo…");try{const de=new Blob(le,{type:ae.mimeType||"audio/webm"}),Re=await(await zt(`${o}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:de})).json();Re.error?S(Re.error):(S(""),u(Fe=>Fe+(Fe?" ":"")+(Re.text||"")))}catch(de){S(String(de))}},C.current={stop:()=>ae.state!=="inactive"&&ae.stop()},ae.start(),p(!0)}catch{S("microfono non disponibile"),p(!1)}}return h.jsxs("div",{className:"nc-composer",children:[m&&h.jsx("div",{className:"nc-composer-err",children:m}),h.jsxs("div",{className:"nc-composer-row",children:[n&&h.jsx("button",{ref:Z,className:B?"attach busy":"attach",disabled:B,onClick:()=>k?I(!1):H(),title:_(B?"attach-uploading":"attach"),"aria-label":_("attach"),"aria-haspopup":"menu","aria-expanded":k,"aria-controls":E.current,children:h.jsx(tt,{name:"attach",size:22})}),k&&h.jsxs("div",{ref:W,id:E.current,role:"menu",className:"nc-attach-menu",style:{left:L.left,bottom:L.bottom},children:[h.jsxs("button",{role:"menuitem",onClick:()=>q(G),children:[h.jsx(tt,{name:"file",size:18})," ",_("attach-file")]}),h.jsxs("button",{role:"menuitem",onClick:()=>q(K),children:[h.jsx(tt,{name:"camera",size:18})," ",_("attach-camera")]}),h.jsxs("button",{role:"menuitem",onClick:()=>q(P),children:[h.jsx(tt,{name:"image",size:18})," ",_("attach-gallery")]})]}),h.jsx("input",{ref:G,type:"file",multiple:!0,hidden:!0,onChange:se=>{X(Array.from(se.target.files||[])),se.target.value=""}}),h.jsx("input",{ref:K,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:se=>{X(Array.from(se.target.files||[])),se.target.value=""}}),h.jsx("input",{ref:P,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:se=>{X(Array.from(se.target.files||[])),se.target.value=""}}),h.jsx("textarea",{ref:b,rows:2,value:l,placeholder:_("composer-placeholder"),onChange:se=>u(se.target.value)}),U&&h.jsx("button",{className:d?"mic on":"mic",onClick:d?D:Q,title:_("voice"),children:h.jsx(tt,{name:"mic",size:22})}),h.jsx("button",{type:"button",className:"go",disabled:O,onPointerDown:se=>se.preventDefault(),onClick:R,title:_("send"),children:h.jsx(tt,{name:"enter",size:22})})]})]})}function Wa(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 ng(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}function Ca(e,t){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const n=Number(localStorage.getItem(La(t))||0);return e.outbox.latest>n}const dC=180,fC=480;function su(e){return e.status==="passive"?_("node-passive"):e.status==="down"?e.downSince?_("tunnel-down-since").replace("{t}",Wa(e.downSince)):_("tunnel-down"):e.status==="unreachable"?_("node-unreachable"):e.status==="offline"?e.lastSeen?_("node-offline-seen").replace("{t}",Wa(e.lastSeen)):_("node-offline"):e.status==="needs-repair"?_("node-needs-repair"):""}function pC(e){return!e||e.status==="passive"?null:e.status==="healthy"?"on":"warn"}function rg(e){return e&&(e.detail||e.status)||""}function mC({sessions:e=[],cells:t=[],activeSessions:n=[],nodeGroups:s=[],onPick:o,onAddTile:l,onPower:u,onNodePower:d,onKill:p,onVisibility:m,onNew:S,onSettings:w,width:y=240,collapsed:v=!1,onResize:C,onToggleCollapse:b}){const[k,N]=Si(),[L,A]=M.useState(dv),[B,ee]=M.useState(wv),[O,F]=M.useState(_v),Z=te=>A(ie=>fv(ie,te)),W=new Set((t||[]).map(te=>te.tmuxSession)),G=new Map((e||[]).map(te=>[te.name,te])),K=(te,ie)=>Rw(L,te,ie),P=Pw,E=[...t||[]].sort((te,ie)=>P(K(te.tmuxSession,(G.get(te.tmuxSession)||{}).activity),K(ie.tmuxSession,(G.get(ie.tmuxSession)||{}).activity))),j=(e||[]).filter(te=>!W.has(te.name)).sort((te,ie)=>P(K(te.name,te.activity),K(ie.name,ie.activity))||te.name.localeCompare(ie.name)),U=new Set(n||[]),R=te=>Ta(B,te),H=(te,ie)=>ee(ye=>{const Le={...ye,[te]:{...Ta(ye,te),...ie}};return bv(Le)}),I=[...E.map(te=>{const ie=G.get(te.tmuxSession)||{},ye=un([],te.tmuxSession);return{type:"cell",value:te,key:ye,label:te.cell,live:!!te.tmux,fresh:Ca(ie,ye),activity:ie.activity||0}}),...j.map(te=>{const ie=un([],te.name);return{type:"session",value:te,key:ie,label:te.name,live:!0,technical:te.technical===!0,fresh:Ca(te,ie),activity:te.activity||0}})],q=hn(I,L,R("local").filter,Xi(O,"local")),X=(s||[]).map(te=>{const ie=(te.route||[te.name]).join("/"),ye=R(ie),Le=new Map((te.sessions||[]).map(he=>[he.name,he])),je=[...(te.cells||[]).map(he=>{const we=Le.get(he.tmuxSession)||{},$=un(te.route,he.tmuxSession||he.cell);return{type:"cell",value:he,key:$,label:he.cell,live:!!he.tmux,fresh:Ca(we,$),activity:we.activity||he.activity||0}}),...(te.unmanaged||[]).map(he=>{const we=un(te.route,he.name);return{type:"session",value:he,key:we,label:he.name,live:!0,technical:he.technical===!0,fresh:Ca(he,we),activity:he.activity||0}})],Y=hn(je,L,ye.filter,Xi(O,ie));return{g:te,nodeRoute:ie,groupView:ye,rawItems:je,items:Y}});function D(te,ie,ye,Le){const je=L.includes(ie),Y=L.includes(ye);if(je===Y){if(je){A(he=>pv(he,ie,ye));return}F(he=>{var fe;const we=((fe=Le.find(Ce=>Ce.key===ie))==null?void 0:fe.technical)===!0,$=hn(Le,L,we?"technical":"all",Xi(he,te)).map(Ce=>Ce.key);return yv(Sv(he,te,ie,ye,$))})}}function Q(te,ie,ye,Le){var fe;const je=((fe=Le.find(Ce=>Ce.key===ie))==null?void 0:fe.technical)===!0,Y=L.includes(ie),he=hn(Le,L,je?"technical":"all",Xi(O,te)).map(Ce=>Ce.key).filter(Ce=>L.includes(Ce)===Y),we=he.indexOf(ie),$=he[we+ye];we>=0&&$&&D(te,ie,$,Le)}const se=(te,ie)=>L.includes(te)===L.includes(ie),[re,ae]=M.useState(null),le=(te,ie)=>{const ye=te.currentTarget.getBoundingClientRect();ae({text:ie,y:ye.top+ye.height/2})},de=()=>ae(null),ve=M.useRef(null);M.useEffect(()=>()=>{ve.current&&ve.current()},[]);function Re(te){te.preventDefault(),te.stopPropagation();const ie=te.clientX,ye=y,Le=Y=>{const he=Math.max(dC,Math.min(fC,ye+(Y.clientX-ie)));C&&C(he)},je=()=>{window.removeEventListener("pointermove",Le),window.removeEventListener("pointerup",je),window.removeEventListener("pointercancel",je),window.removeEventListener("blur",je),ve.current=null};window.addEventListener("pointermove",Le),window.addEventListener("pointerup",je),window.addEventListener("pointercancel",je),window.addEventListener("blur",je),ve.current=je}const Fe=v?{width:48,flex:"0 0 48px"}:{width:y,flex:`0 0 ${y}px`};return v?h.jsxs("aside",{className:"nc-sidebar mini",style:Fe,children:[h.jsx("div",{className:"nc-side-head mini",children:h.jsx("button",{className:"nc-collapse-btn",onClick:b,title:_("expand"),children:"⟩"})}),h.jsx("button",{className:"nc-side-gear mini",onClick:()=>w&&w("nodes",!1),title:_("settings"),onMouseEnter:te=>le(te,_("settings")),onMouseLeave:de,children:h.jsx(tt,{name:"gear",size:16})}),h.jsx("div",{className:"nc-side-scroll mini",children:h.jsxs("div",{className:"nc-side-group mini",children:[R("local").open&&q.map(te=>te.type==="cell"?(()=>{const ie=te.value,ye=ie.degraded?"warn":ie.tmux?"on":"",Le=!!ie.tmux;return h.jsx("button",{type:"button",className:`nc-mini-dot${U.has(ie.tmuxSession)?" active":""}`,onMouseEnter:je=>le(je,ie.cell),onMouseLeave:de,draggable:Le,onDragStart:Le?je=>je.dataTransfer.setData("text/nc-session",ie.tmuxSession):void 0,onClick:Le?()=>l&&l(ie.tmuxSession):()=>u&&u(ie),onDoubleClick:Le?()=>o&&o(ie.tmuxSession):void 0,children:h.jsx("span",{className:`nc-dot ${ye}`})},te.key)})():(()=>{const ie=te.value;return h.jsx("button",{type:"button",className:`nc-mini-init${U.has(ie.name)?" active":""}`,onMouseEnter:ye=>le(ye,ie.name),onMouseLeave:de,draggable:!0,onDragStart:ye=>ye.dataTransfer.setData("text/nc-session",ie.name),onClick:()=>l&&l(ie.name),onDoubleClick:()=>o&&o(ie.name),children:ng(ie.name)},te.key)})()),X.flatMap(({g:te,nodeRoute:ie,groupView:ye,items:Le})=>te.status==="up"?ye.open?Le.map(je=>je.type==="cell"?(()=>{const Y=je.value,he=!!Y.tmux;return h.jsx("button",{type:"button",className:`nc-mini-dot${U.has(je.key)?" active":""}`,onMouseEnter:we=>le(we,`${te.label||ie}: ${Y.cell}`),onMouseLeave:de,draggable:he,onDragStart:he?we=>we.dataTransfer.setData("text/nc-session",je.key):void 0,onClick:he?()=>l&&l(je.key):()=>u&&u({...Y,route:te.route,availableEngines:te.engines||[]}),onDoubleClick:he?()=>o&&o({session:Y.tmuxSession,node:ie}):void 0,children:h.jsx("span",{className:`nc-dot ${Y.degraded?"warn":he?"on":""}`})},je.key)})():(()=>{const Y=je.value;return h.jsx("button",{type:"button",className:`nc-mini-init${U.has(je.key)?" active":""}`,onMouseEnter:he=>le(he,`${te.label||ie}: ${Y.name}`),onMouseLeave:de,draggable:!0,onDragStart:he=>he.dataTransfer.setData("text/nc-session",je.key),onClick:()=>l&&l(je.key),onDoubleClick:()=>o&&o({session:Y.name,node:ie}),children:ng(Y.name)},je.key)})()):[]:[h.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:je=>le(je,`${te.label||(te.route||[te.name]).join(" › ")}: ${su(te)}`),onMouseLeave:de,children:h.jsx("span",{className:`nc-dot${te.status==="passive"?"":" warn"}`})},`nodo-${(te.route||[te.name]).join("/")}`)])]})}),re&&h.jsx("div",{className:"nc-mini-tip",style:{top:re.y},children:re.text})]}):h.jsxs("aside",{className:"nc-sidebar",style:Fe,children:[h.jsxs("div",{className:"nc-side-head",children:[h.jsx("button",{className:"nc-collapse-btn",onClick:b,title:_("collapse"),children:"⟨"}),h.jsx("span",{className:"nc-side-title",children:_("fleet")}),h.jsxs("button",{className:"nc-new-btn",onClick:S,title:_("fleet-new-cell"),children:["+ ",_("new")]})]}),h.jsxs("button",{className:"nc-side-gear",onClick:()=>w&&w("nodes",!1),title:_("settings"),children:[h.jsx(tt,{name:"gear",size:15})," ",_("settings")]}),h.jsxs("div",{className:"nc-side-scroll",children:[h.jsx(gC,{label:_("position-local"),count:q.length,state:R("local"),onToggle:()=>H("local",{open:!R("local").open}),onFilter:te=>H("local",{filter:te})}),R("local").open&&h.jsxs("div",{className:"nc-side-group",children:[q.map(te=>te.type==="cell"?(()=>{const ie=te.value,ye=ie.degraded?"warn":ie.tmux?"on":"",Le=ie.degraded?_("cell-degraded"):ie.tmux?_("cell-on"):_("cell-off"),je=!!ie.tmux;return h.jsxs("div",{"data-roster-key":te.key,"data-position":"local",className:`nc-cell${je?" live":""}${U.has(ie.tmuxSession)?" active":""}`,title:`${ie.cell} · ${ie.engine}${ie.key?`·${ie.key}`:""} · ${Le}`,"aria-label":`${ie.cell}, ${ie.engine}${ie.key?` ${ie.key}`:""}, ${Le}`,draggable:je,onDragStart:je?Y=>Y.dataTransfer.setData("text/nc-session",ie.tmuxSession):void 0,onClick:je?()=>l&&l(ie.tmuxSession):void 0,onDoubleClick:je?()=>o&&o(ie.tmuxSession):void 0,children:[h.jsx(Wr,{position:"local",itemKey:te.key,label:ie.cell,canMove:se,onMove:(Y,he)=>D("local",Y,he,I),onStep:Y=>Q("local",te.key,Y,I)}),h.jsx("span",{className:`nc-dot ${ye}`}),h.jsxs("span",{className:"nc-cell-main",children:[h.jsx("b",{title:ie.cell,children:ie.cell}),h.jsxs("small",{title:`${ie.engine}${ie.key?`·${ie.key}`:""}`,children:[ie.engine,ie.key?`·${ie.key}`:""]})]}),h.jsx("button",{className:`nc-pin${L.includes(te.key)?" on":""}`,title:_("pin"),onClick:Y=>{Y.stopPropagation(),Z(te.key)},children:L.includes(te.key)?"★":"☆"}),h.jsx("button",{className:`nc-power${ie.tmux?" on":""}${ie.degraded?" warn":""}`,onClick:Y=>{Y.stopPropagation(),u&&u(ie)},title:ie.active?_("power-off"):_("power-on"),children:h.jsx(tt,{name:"power",size:14})})]},te.key)})():(()=>{var ye;const ie=te.value;return h.jsxs("div",{"data-roster-key":te.key,"data-position":"local",className:`nc-side-card${U.has(ie.name)?" active":""}`,draggable:!0,onDragStart:Le=>Le.dataTransfer.setData("text/nc-session",ie.name),onClick:()=>l&&l(ie.name),onDoubleClick:()=>o&&o(ie.name),children:[h.jsx(Wr,{position:"local",itemKey:te.key,label:ie.name,canMove:se,onMove:(Le,je)=>D("local",Le,je,I),onStep:Le=>Q("local",te.key,Le,I)}),h.jsx("span",{className:ie.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:ie.name}),h.jsxs("small",{children:[ie.preview||ie.cmd||_("windows").replace("{n}",String(ie.windows||0)),((ye=ie.outbox)==null?void 0:ye.count)>0?` · 📦${ie.outbox.count}`:""]})]}),ie.activity?h.jsx("span",{className:"nc-rel",children:Wa(ie.activity)}):null,h.jsx("button",{className:`nc-pin${L.includes(te.key)?" on":""}`,title:_("pin"),onClick:Le=>{Le.stopPropagation(),Z(te.key)},children:L.includes(te.key)?"★":"☆"}),h.jsx("button",{className:`nc-technical${ie.technical?" on":""}`,title:ie.technical?_("mark-normal"):_("mark-technical"),"aria-label":`${ie.technical?_("mark-normal"):_("mark-technical")} ${ie.name}`,onClick:Le=>{Le.stopPropagation(),m&&m(ie.name,!ie.technical,[])},children:"T"}),h.jsx("button",{className:"nc-menu",title:_("terminate"),onClick:Le=>{Le.stopPropagation(),window.confirm(_("terminate-confirm").replace("{name}",ie.name))&&p&&p(ie.name)},children:"⋯"})]},te.key)})()),q.length===0&&h.jsx("div",{className:"nc-empty",children:_("no-sessions-short")})]}),X.map(({g:te,nodeRoute:ie,groupView:ye,rawItems:Le,items:je})=>{const he=pC(te.health)||(te.status==="up"?"on":te.status==="passive"?"":"warn");return h.jsxs("div",{children:[h.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>H(ie,{open:!ye.open}),onKeyDown:we=>{(we.key==="Enter"||we.key===" ")&&(we.preventDefault(),H(ie,{open:!ye.open}))},children:[h.jsx("span",{className:"nc-node-chevron",children:ye.open?"⌄":"›"}),h.jsx("span",{className:`nc-dot ${he}`,title:te.health?rg(te.health):""}),h.jsx("b",{children:te.label||te.name}),h.jsxs("small",{children:[" · ",te.status==="up"?_("node-sessions").replace("{n}",String(je.length)):te.health&&rg(te.health)||su(te)]}),h.jsxs("select",{className:"nc-node-filter",value:ye.filter,title:_(`view-${ye.filter}`),onClick:we=>we.stopPropagation(),onChange:we=>H(ie,{filter:we.target.value}),children:[h.jsx("option",{value:"all",children:_("view-all")}),h.jsx("option",{value:"pinned",children:_("view-pinned")}),h.jsx("option",{value:"active",children:_("view-active")}),h.jsx("option",{value:"off",children:_("view-off")}),h.jsx("option",{value:"technical",children:_("view-technical")})]}),te.direct&&te.health&&te.health.managed!==!1&&h.jsx("button",{type:"button",className:`nc-power${te.tunnelStatus==="up"?" on":""}`,title:te.tunnelStatus==="up"?_("power-off"):_("power-on"),onClick:we=>{we.stopPropagation(),d&&d(te)},children:h.jsx(tt,{name:"power",size:14})})]}),te.status==="up"&&ye.open&&h.jsxs("div",{className:"nc-side-group",children:[je.map(we=>we.type==="cell"?(()=>{const $=we.value,fe=!!$.tmux,Ce=$.degraded?"warn":$.tmux?"on":"";return h.jsxs("div",{"data-roster-key":we.key,"data-position":ie,className:`nc-side-card nc-cell${fe?" live":""}${U.has($.key)?" active":""}`,title:$.active?_("cell-on"):_("cell-off"),draggable:fe,onDragStart:fe?Ee=>Ee.dataTransfer.setData("text/nc-session",$.key):void 0,onClick:fe?()=>l&&l($.key):void 0,onDoubleClick:fe?()=>o&&o({session:$.tmuxSession,node:ie}):void 0,children:[h.jsx(Wr,{position:ie,itemKey:we.key,label:$.cell,canMove:se,onMove:(Ee,Ae)=>D(ie,Ee,Ae,Le),onStep:Ee=>Q(ie,we.key,Ee,Le)}),h.jsx("span",{className:`nc-dot ${Ce}`}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:$.cell}),h.jsxs("small",{children:[$.engine,$.key?`·${$.key}`:"",$.active?"":` · ${_("cell-off")}`]})]}),h.jsx("button",{className:`nc-pin${L.includes(we.key)?" on":""}`,title:_("pin"),onClick:Ee=>{Ee.stopPropagation(),Z(we.key)},children:L.includes(we.key)?"★":"☆"}),(te.capabilities||[]).includes($.active?"down":"up")&&h.jsx("button",{className:`nc-power${$.active?" on":""}${$.degraded?" warn":""}`,onClick:Ee=>{Ee.stopPropagation(),u&&u({...$,route:te.route,availableEngines:te.engines||[]})},title:$.active?_("power-off"):_("power-on"),children:h.jsx(tt,{name:"power",size:14})})]},we.key)})():(()=>{const $=we.value;return h.jsxs("div",{"data-roster-key":we.key,"data-position":ie,className:`nc-side-card${U.has($.key)?" active":""}`,draggable:!0,onDragStart:fe=>fe.dataTransfer.setData("text/nc-session",$.key),onClick:()=>l&&l($.key),onDoubleClick:()=>o&&o({session:$.name,node:$.node}),children:[h.jsx(Wr,{position:ie,itemKey:we.key,label:$.name,canMove:se,onMove:(fe,Ce)=>D(ie,fe,Ce,Le),onStep:fe=>Q(ie,we.key,fe,Le)}),h.jsx("span",{className:$.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:$.name}),h.jsx("small",{children:$.preview?$.preview:$.cmd?$.cmd:_("windows").replace("{n}",String($.windows||0))})]}),$.activity?h.jsx("span",{className:"nc-rel",children:Wa($.activity)}):null,h.jsx("button",{className:`nc-pin${L.includes(we.key)?" on":""}`,title:_("pin"),onClick:fe=>{fe.stopPropagation(),Z(we.key)},children:L.includes(we.key)?"★":"☆"}),h.jsx("button",{className:`nc-technical${$.technical?" on":""}`,title:$.technical?_("mark-normal"):_("mark-technical"),"aria-label":`${$.technical?_("mark-normal"):_("mark-technical")} ${$.name}`,onClick:fe=>{fe.stopPropagation(),m&&m($.name,!$.technical,te.route||[])},children:"T"}),h.jsx("button",{className:"nc-menu",title:_("terminate"),onClick:fe=>{fe.stopPropagation(),window.confirm(_("terminate-confirm").replace("{name}",$.name))&&p&&p($.name,te.route)},children:"⋯"})]},we.key)})()),je.length===0&&h.jsx("div",{className:"nc-empty",children:_("no-sessions-short")})]})]},`nodo-${(te.route||[te.name]).join("/")}`)})]}),h.jsx("div",{className:"nc-side-lang",children:kv.map((te,ie)=>h.jsxs("span",{children:[ie>0&&" · ",h.jsx("button",{className:`nc-lang-btn${k===te?" on":""}`,onClick:()=>N(te),title:te,children:te.toUpperCase()})]},te))}),h.jsx("div",{className:"nc-side-resize",onPointerDown:Re,title:""})]})}function gC({label:e,count:t,state:n,onToggle:s,onFilter:o}){return h.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:s,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),s())},children:[h.jsx("span",{className:"nc-node-chevron",children:n.open?"⌄":"›"}),h.jsx("span",{className:"nc-dot on"}),h.jsx("b",{children:e}),h.jsxs("small",{children:[" · ",_("node-sessions").replace("{n}",String(t))]}),h.jsxs("select",{className:"nc-node-filter",value:n.filter,title:_(`view-${n.filter}`),onClick:l=>l.stopPropagation(),onChange:l=>o(l.target.value),children:[h.jsx("option",{value:"all",children:_("view-all")}),h.jsx("option",{value:"pinned",children:_("view-pinned")}),h.jsx("option",{value:"active",children:_("view-active")}),h.jsx("option",{value:"off",children:_("view-off")}),h.jsx("option",{value:"technical",children:_("view-technical")})]})]})}const Vh=9,Ua=.2,vC=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,S_=/^[a-f0-9]{16,64}$/,_h=e=>vC.test(e)&&new Set(e.split("/")).size===e.split("/").length;function Hn(e){if(typeof e=="string"&&e){const t=e.indexOf(":");if(t<0)return{session:e};const n=e.slice(0,t),s=e.slice(t+1);return!_h(n)||!s?null:{session:s,node:n}}if(e&&typeof e=="object"&&typeof e.session=="string"&&e.session){const t=e.ownerId===void 0?void 0:typeof e.ownerId=="string"&&S_.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"&&_h(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function _i(e){const t=Hn(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const w_=9,b_=24,ro=11,_C=e=>{const t=Number(e);return t>=w_&&t<=b_?t:ro};function Kr(){return{columns:[]}}function Ji(e){return e.columns.flatMap(t=>t.tiles.map(n=>_i(n)))}function yC(e){const t=[],n=Math.max(0,...e.columns.map(s=>s.tiles.length));for(let s=0;s<n;s+=1)for(const o of e.columns)o.tiles[s]&&t.push(_i(o.tiles[s]));return t}const Jr=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))});function Yh(e,t,n,s){const o=Hn(t);if(!o||Ji(e).includes(_i(o))||Ji(e).length>=Vh)return e;const l=Jr(e),u={session:o.session,height:1,fontSize:ro,...s||{}};if(o.node&&(u.node=o.node),o.ownerId&&(u.ownerId=o.ownerId),n==="end")return l.columns.push({width:1,tiles:[u]}),l;if(n&&typeof n.col=="number"&&typeof n.row=="number"&&l.columns[n.col])return l.columns[n.col].tiles.splice(n.row,0,u),l;if(n&&typeof n.col=="number"){const d=Math.max(0,Math.min(l.columns.length,n.col));return l.columns.splice(d,0,{width:1,tiles:[u]}),l}return l.columns.push({width:1,tiles:[u]}),l}function C_(e,t){const n=_i(t);if(!n||Ji(e).includes(n)||Ji(e).length>=Vh)return e;const s=Ji(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let S=0;for(let w=1;w<e.columns.length;w+=1)e.columns[w].tiles.length<e.columns[S].tiles.length&&(S=w);return Yh(e,t,{col:S,row:e.columns[S].tiles.length})}const l=[...yC(e),n],u=new Map(e.columns.flatMap(S=>S.tiles.map(w=>[_i(w),w]))),d=Hn(t),p=e.columns.length?e.columns.reduce((S,w)=>S+(Number(w.width)||1),0)/e.columns.length:1,m=Array.from({length:o},(S,w)=>{var y;return{width:((y=e.columns[w])==null?void 0:y.width)||p,tiles:[]}});return l.forEach((S,w)=>{const y=Hn(S);if(!y)return;const v=u.get(S)||(S===n?d:{})||{},C={session:y.session,height:v.height||1,fontSize:v.fontSize||ro};y.node&&(C.node=y.node),v.ownerId&&(C.ownerId=v.ownerId),v.unavailable===!0&&(C.unavailable=!0),m[w%o].tiles.push(C)}),{columns:m.filter(S=>S.tiles.length)}}function Ka(e,t){const n=_i(t),s=Jr(e);for(const o of s.columns)o.tiles=o.tiles.filter(l=>_i(l)!==n);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function SC(e,t,n){const s=_i(t);if(!Ji(e).includes(s))return e;const o=e.columns.flatMap(l=>l.tiles).find(l=>_i(l)===s);return Yh(Ka(e,s),s,n,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function wC(e,t){if(!(t instanceof Map)||t.size===0)return e;let n=!1;const s=Jr(e);for(const o of s.columns)for(const l of o.tiles){const u=t.get(_i(l));if(!u)continue;const d=Hn(u);d&&(l.session=d.session,d.node?l.node=d.node:delete l.node,d.ownerId&&(l.ownerId=d.ownerId),n=!0)}return n?lr(s):e}function bC(e,t,n){const s=Jr(e);return s.columns[t]&&(s.columns[t].width=Math.max(Ua,Number(n)||1)),s}function CC(e,t,n,s){const o=Jr(e),l=o.columns[t]&&o.columns[t].tiles[n];return l&&(l.height=Math.max(Ua,Number(s)||1)),o}function xC(e,t,n,s){if(!(e.columns[t]&&e.columns[t].tiles[n]))return e;const l=Jr(e),u=l.columns[t].tiles[n],d=Number(u.fontSize)||ro;return u.fontSize=Math.max(w_,Math.min(b_,d+(Number(s)||0))),l}function kC(e,t,n,s){const o=e.columns[t];if(!o||!o.tiles[n])return null;switch(s){case"left":return{col:t};case"right":return{col:t+1};case"top":return{col:t,row:n};case"bottom":return{col:t,row:n+1};default:return null}}function sg(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function lr(e){if(!e||!Array.isArray(e.columns))return Kr();const t=e.columns.map(s=>({width:Math.max(Ua,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"&&_h(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&S_.test(o.ownerId)).map(o=>{const l={session:o.session,height:Math.max(Ua,Number(o.height)||1),fontSize:_C(o.fontSize)};return o.node!=null&&(l.node=o.node),o.ownerId!=null&&(l.ownerId=o.ownerId),o.unavailable===!0&&(l.unavailable=!0),l})})).filter(s=>s.tiles.length>0),n=new Set;for(const s of t)s.tiles=s.tiles.filter(o=>!n.has(_i(o))&&n.add(_i(o))&&n.size<=Vh);return{columns:t.filter(s=>s.tiles.length>0)}}function EC(e,t,n){return!e&&t?n+1:n}function NC({session:e,node:t,token:n,readonly:s=!1,focused:o,onFocus:l,onClose:u,onOpenSingle:d,alive:p=!0,available:m=!0,fontSize:S=ro,onZoom:w,decks:y=[],currentDeck:v,onSendToDeck:C}){const b=M.useRef(()=>{}),k=M.useRef(()=>!1),N=M.useRef(()=>{}),L=M.useRef(!1),[A,B]=M.useState(!1),[ee,O]=M.useState(!1),[F,Z]=M.useState(!1),[W,G]=M.useState(null),[K,P]=M.useState(0),E=M.useRef(p),j=t?`${t}:${e}`:e,U=y.filter(R=>R.id!==v&&R.available!==!1);return M.useEffect(()=>{const R=E.current;!R&&p&&P(H=>EC(R,p,H)),E.current=p},[p]),h.jsxs("div",{className:`nc-tile${o?" focused":""}`,onMouseDown:()=>l&&l(j),children:[h.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:R=>{R.dataTransfer.setData("text/nc-session",j),R.dataTransfer.effectAllowed="move"},children:[h.jsxs("button",{className:"nc-tile-name",onClick:()=>l&&l(j),children:[h.jsx("span",{className:p?"nc-dot on":"nc-dot"}),h.jsx("b",{children:e}),t&&h.jsxs("small",{className:"nc-tile-node",children:["@",t]})]}),h.jsxs("span",{className:"nc-tile-actions",children:[w&&h.jsx("button",{onClick:()=>w(-1),title:_("zoom-out"),children:h.jsx(tt,{name:"zoomOut",size:14})}),w&&h.jsx("button",{onClick:()=>w(1),title:_("zoom-in"),children:h.jsx(tt,{name:"zoomIn",size:14})}),C&&U.length>0&&h.jsxs("select",{className:"nc-tile-deck",title:_("send-to-deck"),value:"",onMouseDown:R=>R.stopPropagation(),onChange:R=>{const H=R.target.value;H&&C(j,H),R.target.value=""},children:[h.jsx("option",{value:"",children:_("send-to-deck")}),U.map(R=>h.jsxs("option",{value:R.id,children:[R.ownerLabel," · ",R.name]},R.id))]}),h.jsx("button",{onClick:()=>O(R=>!R),title:"composer",children:"⌨"}),h.jsx("button",{onClick:()=>Z(R=>!R),title:"file",children:"📁"}),d&&h.jsx("button",{onClick:()=>d({session:e,node:t}),title:"vista singola",children:"↗"}),u&&h.jsx("button",{className:"nc-tile-close",onClick:()=>u(j),title:"chiudi",children:"✕"})]})]}),h.jsxs("div",{className:"nc-tile-body",children:[m?h.jsx(v_,{session:e,node:t,token:n,readonly:s,takeSize:!1,focused:o,sendRef:b,composerRef:k,actionRef:N,ctrlRef:L,setCtrlArmed:B,onFiles:G,fontSize:S},`${j}:${K}`):h.jsx("div",{className:"nc-tile-unavailable",children:_("deck-owner-unavailable")}),m&&F&&h.jsx("div",{className:"nc-tile-files",onMouseDown:R=>R.stopPropagation(),children:h.jsx(__,{session:e,node:t,token:n,filesEvent:W,onClose:()=>Z(!1)})})]}),m&&ee&&h.jsx("div",{className:"nc-tile-composer",onMouseDown:R=>R.stopPropagation(),children:h.jsx(y_,{submitText:R=>k.current(R),token:n,session:e,node:t})})]})}const og=.2,ag=.28,x_=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),ou=e=>x_(e,"text/nc-session"),lg=e=>{var t;return x_(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function RC(e,t,n){const s=(e-n.left)/(n.width||1),o=(t-n.top)/(n.height||1);return s<ag?"left":s>1-ag?"right":o<.5?"top":"bottom"}function PC({layout:e,onLayoutChange:t,token:n,readonly:s=!1,sessionsAlive:o,focusSession:l,onFocus:u,onOpenSingle:d,decks:p=[],currentDeck:m,onSendToDeck:S}){Si();const[w,y]=M.useState(null),v=M.useRef(null),C=M.useRef([]),b=M.useRef(null);function k(W,G){const K=()=>{window.removeEventListener("pointermove",W),window.removeEventListener("pointerup",K),window.removeEventListener("pointercancel",K),window.removeEventListener("blur",K),b.current=null};window.addEventListener("pointermove",W),window.addEventListener("pointerup",K),window.addEventListener("pointercancel",K),window.addEventListener("blur",K),b.current=K}M.useEffect(()=>()=>{b.current&&b.current()},[]),M.useEffect(()=>{const W=()=>y(null);return window.addEventListener("dragend",W),window.addEventListener("drop",W),()=>{window.removeEventListener("dragend",W),window.removeEventListener("drop",W)}},[]);const N=e.columns.length,L=W=>w&&w.col===W&&w.row===void 0,A=!!w&&w.col===N,B=(W,G)=>w&&w.col===W&&w.row===G&&w.quadrant?` drop-${w.quadrant}`:"";function ee(W){if(W.preventDefault(),lg(W.dataTransfer)){y(null);return}const G=W.dataTransfer.getData("text/nc-session"),K=w;if(y(null),!G||!K)return;let P;if(K.quadrant){if(P=kC(e,K.col,K.row,K.quadrant),!P)return}else P={col:K.col};t(Ji(e).includes(G)?SC(e,G,P):Yh(e,G,P))}function O(W,G){W.preventDefault(),W.stopPropagation();const K=W.clientX,P=e.columns[G].width,E=v.current&&v.current.clientWidth||1,j=e.columns[G+1];k(R=>{let H=Math.max(og,P+(R.clientX-K)/E);if(j){const I=sg(H/(H+j.width));H=I/(1-I)*j.width}t(bC(e,G,H))})}function F(W,G,K){W.preventDefault(),W.stopPropagation();const P=W.clientY,E=e.columns[G].tiles[K].height,j=C.current[G],U=j&&j.clientHeight||1,R=e.columns[G].tiles[K+1];k(I=>{let q=Math.max(og,E+(I.clientY-P)/U);if(R){const X=sg(q/(q+R.height));q=X/(1-X)*R.height}t(CC(e,G,K,q))})}function Z(W){t(Ka(e,W))}return h.jsxs("div",{className:"nc-grid",ref:v,onDragOver:W=>{if(lg(W.dataTransfer)){W.preventDefault(),y(null);return}ou(W.dataTransfer)&&(W.preventDefault(),w&&w.col===N||y({col:N}))},onDrop:ee,onDragLeave:W=>{const G=W.relatedTarget;(!G||!(v.current&&v.current.contains(G)))&&y(null)},children:[e.columns.flatMap((W,G)=>{const K=[];return K.push(h.jsx("div",{className:`nc-col${L(G)?" drop-newcol":""}`,ref:P=>{C.current[G]=P},style:{flexGrow:W.width,flexBasis:0},onDragOver:P=>{ou(P.dataTransfer)&&(P.preventDefault(),P.stopPropagation(),w&&w.col===G&&w.row===void 0||y({col:G}))},children:W.tiles.flatMap((P,E)=>{const j=[],U=_i(P);return j.push(h.jsx("div",{className:`nc-tile-slot${B(G,E)}`,style:{flexGrow:P.height,flexBasis:0},onDragOver:R=>{if(!ou(R.dataTransfer))return;R.preventDefault(),R.stopPropagation();const H=RC(R.clientX,R.clientY,R.currentTarget.getBoundingClientRect());w&&w.col===G&&w.row===E&&w.quadrant===H||y({col:G,row:E,quadrant:H})},children:h.jsx(NC,{session:P.session,node:P.node,token:n,readonly:s,focused:l===U,onFocus:u,onClose:Z,onOpenSingle:d,available:P.unavailable!==!0,alive:P.unavailable!==!0&&(!o||o.has(U)),fontSize:P.fontSize,onZoom:R=>t(xC(e,G,E,R)),decks:p,currentDeck:m,onSendToDeck:S})},U)),E<W.tiles.length-1&&j.push(h.jsx("div",{className:"nc-divider-h",onPointerDown:R=>F(R,G,E)},`h${E}`)),j})},`c${G}`)),G<N-1&&K.push(h.jsx("div",{className:"nc-divider-v",onPointerDown:P=>O(P,G)},`v${G}`)),K}),A&&h.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),N===0&&h.jsx("div",{className:"nc-grid-empty",children:_("grid-empty")})]})}const qa="local",zi=/^[a-f0-9]{16,64}$/;function qr(e,t){return`${e&&zi.test(e)?e:qa}:${t}`}function k_(e){const t=String(e||""),n=t.indexOf(":");if(n<1)return null;const s=t.slice(0,n),o=t.slice(n+1);return s!==qa&&!zi.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===qa?null:s,name:o}}function Ja(e){return Array.isArray(e)&&e.length?e.join("/"):""}function Xh(e){return{columns:lr(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))}}function DC(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&zi.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(Ja(n.route),n.instanceId);return t}function MC(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&zi.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(n.instanceId,[...n.route]);return t}function yh(e,t,n=[]){const s=Xh(e),o=DC(n);for(const l of s.columns)for(const u of l.tiles)u.ownerId||(!u.node&&zi.test(String(t||""))?u.ownerId=t:u.node&&o.has(u.node)&&(u.ownerId=o.get(u.node)));return s}function Sh(e,t,n=[]){const s=Xh(e),o=new Map;for(const l of n)l&&zi.test(String(l.instanceId||""))&&Array.isArray(l.route)&&o.set(l.instanceId,[...l.route]);for(const l of s.columns)for(const u of l.tiles)u.ownerId&&(u.ownerId===t?(delete u.node,delete u.unavailable):o.has(u.ownerId)?(u.node=Ja(o.get(u.ownerId)),delete u.unavailable):u.unavailable=!0);return s}function cg(e,t,n=[]){const s=Xh(e),o=MC(n);for(const l of s.columns)for(const u of l.tiles)delete u.unavailable,u.ownerId&&(u.ownerId===t?delete u.node:o.has(u.ownerId)&&(u.node=Ja(o.get(u.ownerId))));return s}function E_(e,t,n=[]){const s=Hn(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...zi.test(String(t||""))?{ownerId:t}:{}};const o=n.find(l=>Ja(l&&l.route)===s.node);return{...s,...o&&zi.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const LC=/^[a-z0-9-]{1,32}$/,yi="main",N_="nc_decks",jC=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 Xr(e){return typeof e=="string"&&LC.test(e)}function TC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let n;try{n=decodeURIComponent(t[1])}catch{n=t[1]}return Xr(n)?n:yi}return yi}function BC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:qr(null,yi),ownerId:null,name:yi}}if(zi.test(s)&&Xr(o))return{id:qr(s,o),ownerId:s,name:o}}const n=TC(e);return{id:qr(null,n),ownerId:null,name:n}}function au(e,t){const n=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:k_(e)||{ownerId:null,name:e},s=Xr(n.name)?n.name:yi,o=n.ownerId?`/deck/${encodeURIComponent(n.ownerId)}/${encodeURIComponent(s)}`:s===yi?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function R_(e){return e===yi?"nc_grid_v1":`nc_grid_v1__${e}`}function P_(e){const t=[yi];if(Array.isArray(e)){for(const n of e)if(Xr(n)&&n!==yi&&!t.includes(n)&&t.push(n),t.length>=jC)break}return t}function Za(){return typeof localStorage<"u"?localStorage:null}function AC(){const e=Za();if(!e)return[yi];try{return P_(JSON.parse(e.getItem(N_)||"null"))}catch{return[yi]}}function IC(e){const t=Za();if(t)try{t.setItem(N_,JSON.stringify(P_(e)))}catch{}}function wh(e){const t=Za();if(!t)return null;try{return JSON.parse(t.getItem(R_(e))||"null")}catch{return null}}function OC(e,t){const n=Za();if(n)try{n.setItem(R_(e),JSON.stringify(t))}catch{}}function zC({decks:e=[],currentDeck:t="local:main",onCreate:n,onRename:s,onDelete:o,onOpenWindow:l,onNavigate:u,saveState:d="idle",error:p="",sidebarVisible:m,onToggleSidebar:S}){Si();const[w,y]=M.useState(null),[v,C]=M.useState(""),[b,k]=M.useState(!1),[N,L]=M.useState(""),[A,B]=M.useState(""),ee=ug(v),O=Xr(ee),F=[];for(const K of e){const P=K.local?"local":K.ownerId;let E=F.find(j=>j.key===P);E||(E={key:P,label:K.ownerLabel||(K.local?"Local":P),local:!!K.local,decks:[]},F.push(E)),E.decks.push(K)}const Z=async()=>{if(O){k(!0),L("");try{n&&await n(ee,w),C(""),y(null)}catch(K){L(String(K.message||K))}k(!1)}},W=K=>{B(""),l&&l(K.id)||B(K.id)},G=async K=>{if(!(K.id===t||!u||b||K.available===!1)){k(!0),L("");try{await u(K.id)}catch(P){L(String((P==null?void 0:P.message)||P))}k(!1)}};return h.jsxs("div",{className:"nc-deckbar",children:[S&&h.jsx("button",{className:"nc-deck-sidebar-toggle",title:_("toggle-sidebar"),onClick:S,children:m?"◀":"☰"}),h.jsx("span",{className:"nc-deckbar-label",children:_("decks")}),h.jsx("div",{className:"nc-deck-chips",children:F.map(K=>h.jsxs("span",{className:"nc-deck-owner-group",children:[h.jsx("span",{className:"nc-deck-owner",children:K.local?"Local":K.label}),K.decks.map(P=>h.jsxs("span",{className:`nc-deck-chip${P.id===t?" current":""}${P.available===!1?" offline":""}`,children:[h.jsxs("button",{className:"nc-deck-open",title:P.available===!1?`${P.ownerLabel} offline`:P.id===t?_("deck-current"):`${P.ownerLabel} · ${P.name}`,disabled:b||P.available===!1,onClick:()=>G(P),children:[P.name,P.id===t?" •":""]}),h.jsx("button",{className:"nc-deck-mini",disabled:P.available===!1,title:_("detach-deck"),onClick:()=>W(P),children:"↗"}),P.name!==yi&&h.jsxs(h.Fragment,{children:[h.jsx("button",{className:"nc-deck-mini",disabled:P.available===!1,title:_("rename-deck"),onClick:()=>{const E=(typeof window<"u"?window.prompt(_("rename-deck"),P.name):"")||"",j=ug(E);Xr(j)&&j!==P.name&&s&&s(P.id,j).catch(U=>L(String(U.message||U)))},children:"✎"}),h.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:P.available===!1,title:_("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(_("delete-deck-confirm").replace("{name}",`${P.ownerLabel} · ${P.name}`)))&&o&&o(P.id).catch(E=>L(String(E.message||E)))},children:"✕"})]})]},P.id)),w===K.key?h.jsxs("span",{className:"nc-deck-add",children:[h.jsx("input",{autoFocus:!0,className:O||!v?"":"invalid",placeholder:_("deck-name"),value:v,onChange:P=>C(P.target.value),onKeyDown:P=>{P.key==="Enter"&&Z(),P.key==="Escape"&&(C(""),y(null))}}),v&&O&&ee!==v&&h.jsxs("span",{className:"nc-deck-slug",children:["→ ",ee]}),h.jsx("button",{className:"nc-deck-ok",disabled:!O||b,onClick:Z,children:_("create")}),h.jsx("button",{className:"nc-deck-cancel",onClick:()=>{C(""),y(null)},children:_("cancel")})]}):h.jsxs("button",{className:"nc-deck-newbtn",disabled:b||K.decks.every(P=>P.available===!1),title:`${_("new-deck")} · ${K.label}`,onClick:()=>{C(""),y(K.key)},children:["+ ",_("new")]})]},K.key))}),h.jsx("span",{className:`nc-deck-state ${d}`,title:_("deck-autosave"),children:_(d==="saving"?"saving":d==="saved"?"saved":"deck-autosave")}),(N||p)&&h.jsx("span",{className:"nc-deck-error",children:N||p}),A&&h.jsx("button",{className:"nc-deck-fallback",onClick:()=>l&&l(A),children:_("popup-blocked")})]})}var Hr={},lu,hg;function FC(){return hg||(hg=1,lu=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),lu}var cu={},In={},dg;function fr(){if(dg)return In;dg=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 In.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},In.getSymbolTotalCodewords=function(s){return t[s]},In.getBCHDigit=function(n){let s=0;for(;n!==0;)s++,n>>>=1;return s},In.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},In.isKanjiModeEnabled=function(){return typeof e<"u"},In.toSJIS=function(s){return e(s)},In}var uu={},fg;function Gh(){return fg||(fg=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,o){if(e.isValid(s))return s;try{return t(s)}catch{return o}}})(uu)),uu}var hu,pg;function HC(){if(pg)return hu;pg=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const n=Math.floor(t/8);return(this.buffer[n]>>>7-t%8&1)===1},put:function(t,n){for(let s=0;s<n;s++)this.putBit((t>>>n-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},hu=e,hu}var du,mg;function $C(){if(mg)return du;mg=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,n,s,o){const l=t*this.size+n;this.data[l]=s,o&&(this.reservedBit[l]=!0)},e.prototype.get=function(t,n){return this.data[t*this.size+n]},e.prototype.xor=function(t,n,s){this.data[t*this.size+n]^=s},e.prototype.isReserved=function(t,n){return this.reservedBit[t*this.size+n]},du=e,du}var fu={},gg;function WC(){return gg||(gg=1,(function(e){const t=fr().getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const o=Math.floor(s/7)+2,l=t(s),u=l===145?26:Math.ceil((l-13)/(2*o-2))*2,d=[l-7];for(let p=1;p<o-1;p++)d[p]=d[p-1]-u;return d.push(6),d.reverse()},e.getPositions=function(s){const o=[],l=e.getRowColCoords(s),u=l.length;for(let d=0;d<u;d++)for(let p=0;p<u;p++)d===0&&p===0||d===0&&p===u-1||d===u-1&&p===0||o.push([l[d],l[p]]);return o}})(fu)),fu}var pu={},vg;function UC(){if(vg)return pu;vg=1;const e=fr().getSymbolSize,t=7;return pu.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},pu}var mu={},_g;function KC(){return _g||(_g=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 l=o.size;let u=0,d=0,p=0,m=null,S=null;for(let w=0;w<l;w++){d=p=0,m=S=null;for(let y=0;y<l;y++){let v=o.get(w,y);v===m?d++:(d>=5&&(u+=t.N1+(d-5)),m=v,d=1),v=o.get(y,w),v===S?p++:(p>=5&&(u+=t.N1+(p-5)),S=v,p=1)}d>=5&&(u+=t.N1+(d-5)),p>=5&&(u+=t.N1+(p-5))}return u},e.getPenaltyN2=function(o){const l=o.size;let u=0;for(let d=0;d<l-1;d++)for(let p=0;p<l-1;p++){const m=o.get(d,p)+o.get(d,p+1)+o.get(d+1,p)+o.get(d+1,p+1);(m===4||m===0)&&u++}return u*t.N2},e.getPenaltyN3=function(o){const l=o.size;let u=0,d=0,p=0;for(let m=0;m<l;m++){d=p=0;for(let S=0;S<l;S++)d=d<<1&2047|o.get(m,S),S>=10&&(d===1488||d===93)&&u++,p=p<<1&2047|o.get(S,m),S>=10&&(p===1488||p===93)&&u++}return u*t.N3},e.getPenaltyN4=function(o){let l=0;const u=o.data.length;for(let p=0;p<u;p++)l+=o.data[p];return Math.abs(Math.ceil(l*100/u/5)-10)*t.N4};function n(s,o,l){switch(s){case e.Patterns.PATTERN000:return(o+l)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return l%3===0;case e.Patterns.PATTERN011:return(o+l)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(l/3))%2===0;case e.Patterns.PATTERN101:return o*l%2+o*l%3===0;case e.Patterns.PATTERN110:return(o*l%2+o*l%3)%2===0;case e.Patterns.PATTERN111:return(o*l%3+(o+l)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}e.applyMask=function(o,l){const u=l.size;for(let d=0;d<u;d++)for(let p=0;p<u;p++)l.isReserved(p,d)||l.xor(p,d,n(o,p,d))},e.getBestMask=function(o,l){const u=Object.keys(e.Patterns).length;let d=0,p=1/0;for(let m=0;m<u;m++){l(m),e.applyMask(m,o);const S=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(m,o),S<p&&(p=S,d=m)}return d}})(mu)),mu}var xa={},yg;function D_(){if(yg)return xa;yg=1;const e=Gh(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return xa.getBlocksCount=function(o,l){switch(l){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}},xa.getTotalCodewordsCount=function(o,l){switch(l){case e.L:return n[(o-1)*4+0];case e.M:return n[(o-1)*4+1];case e.Q:return n[(o-1)*4+2];case e.H:return n[(o-1)*4+3];default:return}},xa}var gu={},$s={},Sg;function qC(){if(Sg)return $s;Sg=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]})(),$s.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},$s.exp=function(s){return e[s]},$s.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},$s}var wg;function VC(){return wg||(wg=1,(function(e){const t=qC();e.mul=function(s,o){const l=new Uint8Array(s.length+o.length-1);for(let u=0;u<s.length;u++)for(let d=0;d<o.length;d++)l[u+d]^=t.mul(s[u],o[d]);return l},e.mod=function(s,o){let l=new Uint8Array(s);for(;l.length-o.length>=0;){const u=l[0];for(let p=0;p<o.length;p++)l[p]^=t.mul(o[p],u);let d=0;for(;d<l.length&&l[d]===0;)d++;l=l.slice(d)}return l},e.generateECPolynomial=function(s){let o=new Uint8Array([1]);for(let l=0;l<s;l++)o=e.mul(o,new Uint8Array([1,t.exp(l)]));return o}})(gu)),gu}var vu,bg;function YC(){if(bg)return vu;bg=1;const e=VC();function t(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(s){this.degree=s,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(s.length+this.degree);o.set(s);const l=e.mod(o,this.genPoly),u=this.degree-l.length;if(u>0){const d=new Uint8Array(this.degree);return d.set(l,u),d}return l},vu=t,vu}var _u={},yu={},Su={},Cg;function M_(){return Cg||(Cg=1,Su.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Su}var Vi={},xg;function L_(){if(xg)return Vi;xg=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
|
|
82
|
-
]))+`;Vi.KANJI=new RegExp(n,"g"),Vi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Vi.BYTE=new RegExp(s,"g"),Vi.NUMERIC=new RegExp(e,"g"),Vi.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+n+"$"),l=new RegExp("^"+e+"$"),u=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Vi.testKanji=function(p){return o.test(p)},Vi.testNumeric=function(p){return l.test(p)},Vi.testAlphanumeric=function(p){return u.test(p)},Vi}var kg;function pr(){return kg||(kg=1,(function(e){const t=M_(),n=L_();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(l,u){if(!l.ccBits)throw new Error("Invalid mode: "+l);if(!t.isValid(u))throw new Error("Invalid version: "+u);return u>=1&&u<10?l.ccBits[0]:u<27?l.ccBits[1]:l.ccBits[2]},e.getBestModeForData=function(l){return n.testNumeric(l)?e.NUMERIC:n.testAlphanumeric(l)?e.ALPHANUMERIC:n.testKanji(l)?e.KANJI:e.BYTE},e.toString=function(l){if(l&&l.id)return l.id;throw new Error("Invalid mode")},e.isValid=function(l){return l&&l.bit&&l.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(l,u){if(e.isValid(l))return l;try{return s(l)}catch{return u}}})(yu)),yu}var Eg;function XC(){return Eg||(Eg=1,(function(e){const t=fr(),n=D_(),s=Gh(),o=pr(),l=M_(),u=7973,d=t.getBCHDigit(u);function p(y,v,C){for(let b=1;b<=40;b++)if(v<=e.getCapacity(b,C,y))return b}function m(y,v){return o.getCharCountIndicator(y,v)+4}function S(y,v){let C=0;return y.forEach(function(b){const k=m(b.mode,v);C+=k+b.getBitsLength()}),C}function w(y,v){for(let C=1;C<=40;C++)if(S(y,C)<=e.getCapacity(C,v,o.MIXED))return C}e.from=function(v,C){return l.isValid(v)?parseInt(v,10):C},e.getCapacity=function(v,C,b){if(!l.isValid(v))throw new Error("Invalid QR Code version");typeof b>"u"&&(b=o.BYTE);const k=t.getSymbolTotalCodewords(v),N=n.getTotalCodewordsCount(v,C),L=(k-N)*8;if(b===o.MIXED)return L;const A=L-m(b,v);switch(b){case o.NUMERIC:return Math.floor(A/10*3);case o.ALPHANUMERIC:return Math.floor(A/11*2);case o.KANJI:return Math.floor(A/13);case o.BYTE:default:return Math.floor(A/8)}},e.getBestVersionForData=function(v,C){let b;const k=s.from(C,s.M);if(Array.isArray(v)){if(v.length>1)return w(v,k);if(v.length===0)return 1;b=v[0]}else b=v;return p(b.mode,b.getLength(),k)},e.getEncodedBits=function(v){if(!l.isValid(v)||v<7)throw new Error("Invalid QR Code version");let C=v<<12;for(;t.getBCHDigit(C)-d>=0;)C^=u<<t.getBCHDigit(C)-d;return v<<12|C}})(_u)),_u}var wu={},Ng;function GC(){if(Ng)return wu;Ng=1;const e=fr(),t=1335,n=21522,s=e.getBCHDigit(t);return wu.getEncodedBits=function(l,u){const d=l.bit<<3|u;let p=d<<10;for(;e.getBCHDigit(p)-s>=0;)p^=t<<e.getBCHDigit(p)-s;return(d<<10|p)^n},wu}var bu={},Cu,Rg;function QC(){if(Rg)return Cu;Rg=1;const e=pr();function t(n){this.mode=e.NUMERIC,this.data=n.toString()}return t.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){let o,l,u;for(o=0;o+3<=this.data.length;o+=3)l=this.data.substr(o,3),u=parseInt(l,10),s.put(u,10);const d=this.data.length-o;d>0&&(l=this.data.substr(o),u=parseInt(l,10),s.put(u,d*3+1))},Cu=t,Cu}var xu,Pg;function JC(){if(Pg)return xu;Pg=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 n(s){this.mode=e.ALPHANUMERIC,this.data=s}return n.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(o){let l;for(l=0;l+2<=this.data.length;l+=2){let u=t.indexOf(this.data[l])*45;u+=t.indexOf(this.data[l+1]),o.put(u,11)}this.data.length%2&&o.put(t.indexOf(this.data[l]),6)},xu=n,xu}var ku,Dg;function ZC(){if(Dg)return ku;Dg=1;const e=pr();function t(n){this.mode=e.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return t.getBitsLength=function(s){return s*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(n){for(let s=0,o=this.data.length;s<o;s++)n.put(this.data[s],8)},ku=t,ku}var Eu,Mg;function ex(){if(Mg)return Eu;Mg=1;const e=pr(),t=fr();function n(s){this.mode=e.KANJI,this.data=s}return n.getBitsLength=function(o){return o*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(s){let o;for(o=0;o<this.data.length;o++){let l=t.toSJIS(this.data[o]);if(l>=33088&&l<=40956)l-=33088;else if(l>=57408&&l<=60351)l-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
|
|
83
|
-
Make sure your charset is UTF-8`);l=(l>>>8&255)*192+(l&255),s.put(l,13)}},Eu=n,Eu}var Nu={exports:{}},Lg;function tx(){return Lg||(Lg=1,(function(e){var t={single_source_shortest_paths:function(n,s,o){var l={},u={};u[s]=0;var d=t.PriorityQueue.make();d.push(s,0);for(var p,m,S,w,y,v,C,b,k;!d.empty();){p=d.pop(),m=p.value,w=p.cost,y=n[m]||{};for(S in y)y.hasOwnProperty(S)&&(v=y[S],C=w+v,b=u[S],k=typeof u[S]>"u",(k||b>C)&&(u[S]=C,d.push(S,C),l[S]=m))}if(typeof o<"u"&&typeof u[o]>"u"){var N=["Could not find a path from ",s," to ",o,"."].join("");throw new Error(N)}return l},extract_shortest_path_from_predecessor_list:function(n,s){for(var o=[],l=s;l;)o.push(l),n[l],l=n[l];return o.reverse(),o},find_path:function(n,s,o){var l=t.single_source_shortest_paths(n,s,o);return t.extract_shortest_path_from_predecessor_list(l,o)},PriorityQueue:{make:function(n){var s=t.PriorityQueue,o={},l;n=n||{};for(l in s)s.hasOwnProperty(l)&&(o[l]=s[l]);return o.queue=[],o.sorter=n.sorter||s.default_sorter,o},default_sorter:function(n,s){return n.cost-s.cost},push:function(n,s){var o={value:n,cost:s};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(Nu)),Nu.exports}var jg;function ix(){return jg||(jg=1,(function(e){const t=pr(),n=QC(),s=JC(),o=ZC(),l=ex(),u=L_(),d=fr(),p=tx();function m(N){return unescape(encodeURIComponent(N)).length}function S(N,L,A){const B=[];let ee;for(;(ee=N.exec(A))!==null;)B.push({data:ee[0],index:ee.index,mode:L,length:ee[0].length});return B}function w(N){const L=S(u.NUMERIC,t.NUMERIC,N),A=S(u.ALPHANUMERIC,t.ALPHANUMERIC,N);let B,ee;return d.isKanjiModeEnabled()?(B=S(u.BYTE,t.BYTE,N),ee=S(u.KANJI,t.KANJI,N)):(B=S(u.BYTE_KANJI,t.BYTE,N),ee=[]),L.concat(A,B,ee).sort(function(F,Z){return F.index-Z.index}).map(function(F){return{data:F.data,mode:F.mode,length:F.length}})}function y(N,L){switch(L){case t.NUMERIC:return n.getBitsLength(N);case t.ALPHANUMERIC:return s.getBitsLength(N);case t.KANJI:return l.getBitsLength(N);case t.BYTE:return o.getBitsLength(N)}}function v(N){return N.reduce(function(L,A){const B=L.length-1>=0?L[L.length-1]:null;return B&&B.mode===A.mode?(L[L.length-1].data+=A.data,L):(L.push(A),L)},[])}function C(N){const L=[];for(let A=0;A<N.length;A++){const B=N[A];switch(B.mode){case t.NUMERIC:L.push([B,{data:B.data,mode:t.ALPHANUMERIC,length:B.length},{data:B.data,mode:t.BYTE,length:B.length}]);break;case t.ALPHANUMERIC:L.push([B,{data:B.data,mode:t.BYTE,length:B.length}]);break;case t.KANJI:L.push([B,{data:B.data,mode:t.BYTE,length:m(B.data)}]);break;case t.BYTE:L.push([{data:B.data,mode:t.BYTE,length:m(B.data)}])}}return L}function b(N,L){const A={},B={start:{}};let ee=["start"];for(let O=0;O<N.length;O++){const F=N[O],Z=[];for(let W=0;W<F.length;W++){const G=F[W],K=""+O+W;Z.push(K),A[K]={node:G,lastCount:0},B[K]={};for(let P=0;P<ee.length;P++){const E=ee[P];A[E]&&A[E].node.mode===G.mode?(B[E][K]=y(A[E].lastCount+G.length,G.mode)-y(A[E].lastCount,G.mode),A[E].lastCount+=G.length):(A[E]&&(A[E].lastCount=G.length),B[E][K]=y(G.length,G.mode)+4+t.getCharCountIndicator(G.mode,L))}}ee=Z}for(let O=0;O<ee.length;O++)B[ee[O]].end=0;return{map:B,table:A}}function k(N,L){let A;const B=t.getBestModeForData(N);if(A=t.from(L,B),A!==t.BYTE&&A.bit<B.bit)throw new Error('"'+N+'" cannot be encoded with mode '+t.toString(A)+`.
|
|
84
|
-
Suggested mode is: `+t.toString(B));switch(A===t.KANJI&&!d.isKanjiModeEnabled()&&(A=t.BYTE),A){case t.NUMERIC:return new n(N);case t.ALPHANUMERIC:return new s(N);case t.KANJI:return new l(N);case t.BYTE:return new o(N)}}e.fromArray=function(L){return L.reduce(function(A,B){return typeof B=="string"?A.push(k(B,null)):B.data&&A.push(k(B.data,B.mode)),A},[])},e.fromString=function(L,A){const B=w(L,d.isKanjiModeEnabled()),ee=C(B),O=b(ee,A),F=p.find_path(O.map,"start","end"),Z=[];for(let W=1;W<F.length-1;W++)Z.push(O.table[F[W]].node);return e.fromArray(v(Z))},e.rawSplit=function(L){return e.fromArray(w(L,d.isKanjiModeEnabled()))}})(bu)),bu}var Tg;function nx(){if(Tg)return cu;Tg=1;const e=fr(),t=Gh(),n=HC(),s=$C(),o=WC(),l=UC(),u=KC(),d=D_(),p=YC(),m=XC(),S=GC(),w=pr(),y=ix();function v(O,F){const Z=O.size,W=l.getPositions(F);for(let G=0;G<W.length;G++){const K=W[G][0],P=W[G][1];for(let E=-1;E<=7;E++)if(!(K+E<=-1||Z<=K+E))for(let j=-1;j<=7;j++)P+j<=-1||Z<=P+j||(E>=0&&E<=6&&(j===0||j===6)||j>=0&&j<=6&&(E===0||E===6)||E>=2&&E<=4&&j>=2&&j<=4?O.set(K+E,P+j,!0,!0):O.set(K+E,P+j,!1,!0))}}function C(O){const F=O.size;for(let Z=8;Z<F-8;Z++){const W=Z%2===0;O.set(Z,6,W,!0),O.set(6,Z,W,!0)}}function b(O,F){const Z=o.getPositions(F);for(let W=0;W<Z.length;W++){const G=Z[W][0],K=Z[W][1];for(let P=-2;P<=2;P++)for(let E=-2;E<=2;E++)P===-2||P===2||E===-2||E===2||P===0&&E===0?O.set(G+P,K+E,!0,!0):O.set(G+P,K+E,!1,!0)}}function k(O,F){const Z=O.size,W=m.getEncodedBits(F);let G,K,P;for(let E=0;E<18;E++)G=Math.floor(E/3),K=E%3+Z-8-3,P=(W>>E&1)===1,O.set(G,K,P,!0),O.set(K,G,P,!0)}function N(O,F,Z){const W=O.size,G=S.getEncodedBits(F,Z);let K,P;for(K=0;K<15;K++)P=(G>>K&1)===1,K<6?O.set(K,8,P,!0):K<8?O.set(K+1,8,P,!0):O.set(W-15+K,8,P,!0),K<8?O.set(8,W-K-1,P,!0):K<9?O.set(8,15-K-1+1,P,!0):O.set(8,15-K-1,P,!0);O.set(W-8,8,1,!0)}function L(O,F){const Z=O.size;let W=-1,G=Z-1,K=7,P=0;for(let E=Z-1;E>0;E-=2)for(E===6&&E--;;){for(let j=0;j<2;j++)if(!O.isReserved(G,E-j)){let U=!1;P<F.length&&(U=(F[P]>>>K&1)===1),O.set(G,E-j,U),K--,K===-1&&(P++,K=7)}if(G+=W,G<0||Z<=G){G-=W,W=-W;break}}}function A(O,F,Z){const W=new n;Z.forEach(function(j){W.put(j.mode.bit,4),W.put(j.getLength(),w.getCharCountIndicator(j.mode,O)),j.write(W)});const G=e.getSymbolTotalCodewords(O),K=d.getTotalCodewordsCount(O,F),P=(G-K)*8;for(W.getLengthInBits()+4<=P&&W.put(0,4);W.getLengthInBits()%8!==0;)W.putBit(0);const E=(P-W.getLengthInBits())/8;for(let j=0;j<E;j++)W.put(j%2?17:236,8);return B(W,O,F)}function B(O,F,Z){const W=e.getSymbolTotalCodewords(F),G=d.getTotalCodewordsCount(F,Z),K=W-G,P=d.getBlocksCount(F,Z),E=W%P,j=P-E,U=Math.floor(W/P),R=Math.floor(K/P),H=R+1,I=U-R,q=new p(I);let X=0;const D=new Array(P),Q=new Array(P);let se=0;const re=new Uint8Array(O.buffer);for(let Re=0;Re<P;Re++){const Fe=Re<j?R:H;D[Re]=re.slice(X,X+Fe),Q[Re]=q.encode(D[Re]),X+=Fe,se=Math.max(se,Fe)}const ae=new Uint8Array(W);let le=0,de,ve;for(de=0;de<se;de++)for(ve=0;ve<P;ve++)de<D[ve].length&&(ae[le++]=D[ve][de]);for(de=0;de<I;de++)for(ve=0;ve<P;ve++)ae[le++]=Q[ve][de];return ae}function ee(O,F,Z,W){let G;if(Array.isArray(O))G=y.fromArray(O);else if(typeof O=="string"){let U=F;if(!U){const R=y.rawSplit(O);U=m.getBestVersionForData(R,Z)}G=y.fromString(O,U||40)}else throw new Error("Invalid data");const K=m.getBestVersionForData(G,Z);if(!K)throw new Error("The amount of data is too big to be stored in a QR Code");if(!F)F=K;else if(F<K)throw new Error(`
|
|
85
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
86
|
-
Minimum version required to store current data is: `+K+`.
|
|
87
|
-
`);const P=A(F,Z,G),E=e.getSymbolSize(F),j=new s(E);return v(j,F),C(j),b(j,F),N(j,Z,0),F>=7&&k(j,F),L(j,P),isNaN(W)&&(W=u.getBestMask(j,N.bind(null,j,Z))),u.applyMask(W,j),N(j,Z,W),{modules:j,version:F,errorCorrectionLevel:Z,maskPattern:W,segments:G}}return cu.create=function(F,Z){if(typeof F>"u"||F==="")throw new Error("No input text");let W=t.M,G,K;return typeof Z<"u"&&(W=t.from(Z.errorCorrectionLevel,t.M),G=m.from(Z.version),K=u.from(Z.maskPattern),Z.toSJISFunc&&e.setToSJISFunction(Z.toSJISFunc)),ee(F,G,W,K)},cu}var Ru={},Pu={},Bg;function j_(){return Bg||(Bg=1,(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let s=n.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+n);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(l){return[l,l]}))),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,l=s.width&&s.width>=21?s.width:void 0,u=s.scale||4;return{width:l,scale:l?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 l=e.getScale(s,o);return Math.floor((s+o.margin*2)*l)},e.qrToImageData=function(s,o,l){const u=o.modules.size,d=o.modules.data,p=e.getScale(u,l),m=Math.floor((u+l.margin*2)*p),S=l.margin*p,w=[l.color.light,l.color.dark];for(let y=0;y<m;y++)for(let v=0;v<m;v++){let C=(y*m+v)*4,b=l.color.light;if(y>=S&&v>=S&&y<m-S&&v<m-S){const k=Math.floor((y-S)/p),N=Math.floor((v-S)/p);b=w[d[k*u+N]?1:0]}s[C++]=b.r,s[C++]=b.g,s[C++]=b.b,s[C]=b.a}}})(Pu)),Pu}var Ag;function rx(){return Ag||(Ag=1,(function(e){const t=j_();function n(o,l,u){o.clearRect(0,0,l.width,l.height),l.style||(l.style={}),l.height=u,l.width=u,l.style.height=u+"px",l.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(l,u,d){let p=d,m=u;typeof p>"u"&&(!u||!u.getContext)&&(p=u,u=void 0),u||(m=s()),p=t.getOptions(p);const S=t.getImageWidth(l.modules.size,p),w=m.getContext("2d"),y=w.createImageData(S,S);return t.qrToImageData(y.data,l,p),n(w,m,S),w.putImageData(y,0,0),m},e.renderToDataURL=function(l,u,d){let p=d;typeof p>"u"&&(!u||!u.getContext)&&(p=u,u=void 0),p||(p={});const m=e.render(l,u,p),S=p.type||"image/png",w=p.rendererOpts||{};return m.toDataURL(S,w.quality)}})(Ru)),Ru}var Du={},Ig;function sx(){if(Ig)return Du;Ig=1;const e=j_();function t(o,l){const u=o.a/255,d=l+'="'+o.hex+'"';return u<1?d+" "+l+'-opacity="'+u.toFixed(2).slice(1)+'"':d}function n(o,l,u){let d=o+l;return typeof u<"u"&&(d+=" "+u),d}function s(o,l,u){let d="",p=0,m=!1,S=0;for(let w=0;w<o.length;w++){const y=Math.floor(w%l),v=Math.floor(w/l);!y&&!m&&(m=!0),o[w]?(S++,w>0&&y>0&&o[w-1]||(d+=m?n("M",y+u,.5+v+u):n("m",p,0),p=0,m=!1),y+1<l&&o[w+1]||(d+=n("h",S),S=0)):p++}return d}return Du.render=function(l,u,d){const p=e.getOptions(u),m=l.modules.size,S=l.modules.data,w=m+p.margin*2,y=p.color.light.a?"<path "+t(p.color.light,"fill")+' d="M0 0h'+w+"v"+w+'H0z"/>':"",v="<path "+t(p.color.dark,"stroke")+' d="'+s(S,m,p.margin)+'"/>',C='viewBox="0 0 '+w+" "+w+'"',k='<svg xmlns="http://www.w3.org/2000/svg" '+(p.width?'width="'+p.width+'" height="'+p.width+'" ':"")+C+' shape-rendering="crispEdges">'+y+v+`</svg>
|
|
88
|
-
`;return typeof d=="function"&&d(null,k),k},Du}var Og;function ox(){if(Og)return Hr;Og=1;const e=FC(),t=nx(),n=rx(),s=sx();function o(l,u,d,p,m){const S=[].slice.call(arguments,1),w=S.length,y=typeof S[w-1]=="function";if(!y&&!e())throw new Error("Callback required as last argument");if(y){if(w<2)throw new Error("Too few arguments provided");w===2?(m=d,d=u,u=p=void 0):w===3&&(u.getContext&&typeof m>"u"?(m=p,p=void 0):(m=p,p=d,d=u,u=void 0))}else{if(w<1)throw new Error("Too few arguments provided");return w===1?(d=u,u=p=void 0):w===2&&!u.getContext&&(p=d,d=u,u=void 0),new Promise(function(v,C){try{const b=t.create(d,p);v(l(b,u,p))}catch(b){C(b)}})}try{const v=t.create(d,p);m(null,l(v,u,p))}catch(v){m(v)}}return Hr.create=t.create,Hr.toCanvas=o.bind(null,n.render),Hr.toDataURL=o.bind(null,n.renderToDataURL),Hr.toString=o.bind(null,function(l,u,d){return s.render(l,d)}),Hr}var ax=ox();const lx=Nh(ax),T_=/^[a-z0-9-]{1,32}$/,cx=/^[A-Za-z0-9._-]{1,32}$/,ux=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,hx=320;function dx(e){return typeof e=="string"&&T_.test(e)}const fx=64;function bh(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=fx&&!/[\x00-\x1f\x7f]/.test(t)}function Vr(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function B_(e){if(typeof e!="string"||!e||e.length>hx||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:cx.test(e.slice(0,t))&&ux.test(e.slice(t+1))}function zg(e){if(e===""||e===null||e===void 0)return null;const t=String(e).trim();if(!/^[0-9]{1,5}$/.test(t))return;const n=Number(t);return Number.isInteger(n)&&n>=1&&n<=65535?n:void 0}function Fg({name:e,ssh:t,sshPort:n,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,l=typeof t=="string"?t.trim():t;if(!dx(o))return{ok:!1,error:"err-node-name"};if(!B_(l))return{ok:!1,error:"err-ssh"};const u=zg(n);if(u===void 0)return{ok:!1,error:"err-ssh-port"};const d=zg(s);if(d===void 0)return{ok:!1,error:"err-node-port"};const p={name:o,ssh:l};return u!==null&&(p.sshPort=u),d!==null&&(p.remotePort=d),{ok:!0,value:p}}function px(e,t){if(!e||!t||t<e)return null;const n=Math.floor((t-e)/1e3);return n<60?"ora":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}g`}function Hg(e,t){const n=!!(e&&e.status==="up"),s=!!(e&&e.status==="passive");return{up:n,...s?{passive:!0}:{},label:n?"tunnel-up":s?"node-passive":"tunnel-down",since:n?px(e.since,t):null}}const mx=new Set(["v","instanceId","port","label","invite"]),gx=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function vx(e){const t=String(e).replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),s=typeof atob=="function"?atob(n):Buffer.from(n,"base64").toString("binary"),o=Uint8Array.from(s,l=>l.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function _x(e){let t="";try{const u=new URL(String(e));t=new URLSearchParams(u.hash.replace(/^#/,"")).get("pair")||""}catch{return{ok:!1}}if(!t)return{ok:!1};let n;try{n=JSON.parse(vx(t))}catch{return{ok:!1}}if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1};const s=n.v===1?mx:n.v===2?gx:null;if(!s)return{ok:!1};for(const u of Object.keys(n))if(!s.has(u))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(n.instanceId)))return{ok:!1};const o=Number(n.port);if(!Number.isInteger(o)||o<1||o>65535)return{ok:!1};if(typeof n.label!="string")return{ok:!1};if(typeof n.invite!="string"||!n.invite)return{ok:!1};const l={ok:!0,version:n.v,label:n.label,invite:n.invite,instanceId:n.instanceId,port:o};if(n.v===2){if(n.name!==void 0){if(typeof n.name!="string"||!T_.test(n.name))return{ok:!1};l.name=n.name}if(n.ssh!==void 0){if(!B_(n.ssh))return{ok:!1};l.ssh=String(n.ssh).trim()}if(n.sshPort!==void 0){const u=Number(n.sshPort);if(!Number.isInteger(u)||u<1||u>65535)return{ok:!1};l.sshPort=u}}return l}function yx(e,t,n=new Set){if(!t||!t.ok)return e;const s={...e},o=(l,u)=>{u==null||u===""||n.has(l)||(s[l]=u)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?Vr(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}function $g(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function Sx(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const n=_x(t);if(!n||!n.ok)return{kind:"invalid"};const s=[];return n.ssh||s.push("ssh"),n.name||s.push("name"),s.length?{kind:"partial",decoded:n,missing:s}:{kind:"complete",decoded:n}}function wx(e,t,n=new Set,s=!1){if(!t||!t.ok)return e;const o=yx(e,t,n);return t.version===2&&t.name&&!n.has("name")&&!s&&(o.name=t.name),!n.has("label")&&!o.label&&t.label&&(o.label=t.label),o}function Wg(e,t,n=new Set,s=!1){const o=String(t||"").trim(),l=Sx(o);let u={...e,pairingUrl:o};return(l.kind==="complete"||l.kind==="partial")&&(u={...wx(u,l.decoded,n,s),pairingUrl:o}),{classification:l,form:u}}function bx(e,{deviceDefault:t=""}={}){const n={name:e.name,ssh:e.ssh,pairingUrl:e.pairingUrl,...e.label?{label:e.label}:{},...e.sshPort?{sshPort:Number(e.sshPort)}:{}},s=e.localLabel||t;return s&&(n.localLabel=s),n}function Cx(){const e=new Set;let t=!1;return{canAuto(n){return!t&&!e.has(String(n||""))},start(n){return t?!1:(t=!0,e.add(String(n||"")),!0)},finish(){t=!1},reset(n){e.delete(String(n||""))},isBusy(){return t}}}const xx=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function kx(e){const t=e&&e.data||{},n=typeof t.stage=="string"&&t.stage?t.stage:"",s=typeof t.detail=="string"&&t.detail?t.detail:"";return{stage:n,code:typeof t.code=="string"?t.code:"",detail:s,hint:typeof t.hint=="string"?t.hint:"",retryable:typeof t.retryable=="boolean"?t.retryable:!n,message:s||String(e&&e.message||e)}}const Ex="modulepreload",Nx=function(e){return"/"+e},Ug={},Rx=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let u=function(m){return Promise.all(m.map(S=>Promise.resolve(S).then(w=>({status:"fulfilled",value:w}),w=>({status:"rejected",reason:w}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),p=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));o=u(n.map(m=>{if(m=Nx(m),m in Ug)return;Ug[m]=!0;const S=m.endsWith(".css"),w=S?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${w}`))return;const y=document.createElement("link");if(y.rel=S?"stylesheet":Ex,S||(y.as="script"),y.crossOrigin="",y.href=m,p&&y.setAttribute("nonce",p),document.head.appendChild(y),S)return new Promise((v,C)=>{y.addEventListener("load",v),y.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${m}`)))})}))}function l(u){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=u,window.dispatchEvent(d),!d.defaultPrevented)throw u}return o.then(u=>{for(const d of u||[])d.status==="rejected"&&l(d.reason);return t().catch(l)})};class Ve{constructor(t,n,s,o,l){this._legacyCanvasSize=Ve.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),s&&typeof s=="object"?this._onDecode=n:(console.warn(s||o||l?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=n),n=typeof s=="object"?s:{},this._onDecodeError=n.onDecodeError||(typeof s=="function"?s:this._onDecodeError),this._calculateScanRegion=n.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||l||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=n.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let u=!1;if(t.hidden&&(t.hidden=!1,u=!0),document.body.contains(t)||(document.body.appendChild(t),u=!0),s=t.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(o=!!n.overlay,this.$overlay=n.overlay||document.createElement("div"),l=this.$overlay.style,l.position="absolute",l.display="none",l.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!o&&n.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}s.insertBefore(this.$overlay,this.$video.nextSibling)}n.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let d=window.getComputedStyle(t);d.display==="none"&&(t.style.setProperty("display","block","important"),u=!0),d.visibility!=="visible"&&(t.style.setProperty("visibility","visible","important"),u=!0),u&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),t.style.opacity="0",t.style.width="0",t.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),t.addEventListener("play",this._onPlay),t.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=Ve.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 Ve.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let n=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),s;try{t&&(await n()).every(o=>!o.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await n()).map((o,l)=>({id:o.deviceId,label:o.label||(l===0?"Default Camera":`Camera ${l+1}`)}))}finally{s&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),Ve._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"),Ve._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(),Ve._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:n}=await this._getCameraStream();!this._active||this._paused?Ve._stopVideoStream(t):(this._setVideoMirror(n),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(t){if(!this._paused)throw this._active=!1,t}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let n=()=>{this.$video.srcObject instanceof MediaStream&&(Ve._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(n(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(n(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,n,s,o,l=!1,u=!1){let d,p=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(d=n.scanRegion,s=n.qrEngine,o=n.canvas,l=n.disallowCanvasResizing||!1,u=n.alsoTryWithoutScanRegion||!1,p=!0):console.warn(n||s||o||l||u?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),n=!!s;try{let m,S;[s,m]=await Promise.all([s||Ve.createQrEngine(),Ve._loadImage(t)]),[o,S]=Ve._drawToCanvas(m,d,o,l);let w;if(s instanceof Worker){let y=s;n||Ve._postWorkerMessageSync(y,"inversionMode","both"),w=await new Promise((v,C)=>{let b,k,N,L=-1;k=B=>{B.data.id===L&&(y.removeEventListener("message",k),y.removeEventListener("error",N),clearTimeout(b),B.data.data!==null?v({data:B.data.data,cornerPoints:Ve._convertPoints(B.data.cornerPoints,d)}):C(Ve.NO_QR_CODE_FOUND))},N=B=>{y.removeEventListener("message",k),y.removeEventListener("error",N),clearTimeout(b),C("Scanner error: "+(B?B.message||B:"Unknown Error"))},y.addEventListener("message",k),y.addEventListener("error",N),b=setTimeout(()=>N("timeout"),1e4);let A=S.getImageData(0,0,o.width,o.height);L=Ve._postWorkerMessageSync(y,"decode",A,[A.data.buffer])})}else w=await Promise.race([new Promise((y,v)=>window.setTimeout(()=>v("Scanner error: timeout"),1e4)),(async()=>{try{var[y]=await s.detect(o);if(!y)throw Ve.NO_QR_CODE_FOUND;return{data:y.rawValue,cornerPoints:Ve._convertPoints(y.cornerPoints,d)}}catch(v){if(y=v.message||v,/not implemented|service unavailable/.test(y))return Ve._disableBarcodeDetector=!0,Ve.scanImage(t,{scanRegion:d,canvas:o,disallowCanvasResizing:l,alsoTryWithoutScanRegion:u});throw`Scanner error: ${y}`}})()]);return p?w:w.data}catch(m){if(!d||!u)throw m;let S=await Ve.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:l});return p?S:S.data}finally{n||Ve._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,n,s,o=!0){Ve._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:n,blue:s,useIntegerApproximation:o})}setInversionMode(t){Ve._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=()=>Rx(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!Ve._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let n=navigator.userAgentData;return n&&n.brands.some(({brand:s})=>/Chromium/i.test(s))&&/mac ?OS/i.test(n.platform)&&await n.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:s,platformVersion:o})=>/arm/i.test(s||"arm")&&13<=parseInt(o||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let n=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-n)/2),y:Math.round((t.videoHeight-n)/2),width:n,height:n,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,n=t.videoWidth,s=t.videoHeight,o=t.offsetWidth,l=t.offsetHeight,u=t.offsetLeft,d=t.offsetTop,p=window.getComputedStyle(t),m=p.objectFit,S=n/s,w=o/l;switch(m){case"none":var y=n,v=s;break;case"fill":y=o,v=l;break;default:(m==="cover"?S>w:S<w)?(v=l,y=v*S):(y=o,v=y/S),m==="scale-down"&&(y=Math.min(y,n),v=Math.min(v,s))}var[C,b]=p.objectPosition.split(" ").map((N,L)=>{const A=parseFloat(N);return N.endsWith("%")?(L?l-v:o-y)*A/100:A});p=this._scanRegion.width||n,w=this._scanRegion.height||s,m=this._scanRegion.x||0;var k=this._scanRegion.y||0;S=this.$overlay.style,S.width=`${p/n*y}px`,S.height=`${w/s*v}px`,S.top=`${d+b+k/s*v}px`,s=/scaleX\(-1\)/.test(t.style.transform),S.left=`${u+(s?o-C-y:C)+(s?n-m-p:m)/n*y}px`,S.transform=t.style.transform}})}static _convertPoints(t,n){if(!n)return t;let s=n.x||0,o=n.y||0,l=n.width&&n.downScaledWidth?n.width/n.downScaledWidth:1;n=n.height&&n.downScaledHeight?n.height/n.downScaledHeight:1;for(let u of t)u.x=u.x*l+s,u.y=u.y*n+o;return t}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,n=1e3/this._maxScansPerSecond;t<n&&await new Promise(o=>setTimeout(o,n-t)),this._lastScanTimestamp=Date.now();try{var s=await Ve.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!Ve._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=Ve.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:l})=>`${o},${l}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(t){t!==Ve.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",n=[{width:{min:1024}},{width:{min:768}},{}],s=n.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...s,...n])try{let l=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),u=this._getFacingMode(l)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:l,facingMode:u}}catch{}throw"Camera not found."}async _restartVideoStream(){let t=this._paused;await this.pause(!0)&&!t&&this._active&&await this.start()}static _stopVideoStream(t){for(let n of t.getTracks())n.stop(),t.removeTrack(n)}_setVideoMirror(t){this.$video.style.transform="scaleX("+(t==="user"?-1:1)+")"}_getFacingMode(t){return(t=t.getVideoTracks()[0])?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(t,n,s,o=!1){s=s||document.createElement("canvas");let l=n&&n.x?n.x:0,u=n&&n.y?n.y:0,d=n&&n.width?n.width:t.videoWidth||t.width,p=n&&n.height?n.height:t.videoHeight||t.height;return o||(o=n&&n.downScaledWidth?n.downScaledWidth:d,n=n&&n.downScaledHeight?n.downScaledHeight:p,s.width!==o&&(s.width=o),s.height!==n&&(s.height=n)),n=s.getContext("2d",{alpha:!1}),n.imageSmoothingEnabled=!1,n.drawImage(t,l,u,d,p,0,0,s.width,s.height),[s,n]}static async _loadImage(t){if(t instanceof Image)return await Ve._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(t instanceof File||t instanceof Blob||t instanceof URL||typeof t=="string"){let n=new Image;n.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await Ve._awaitImageLoad(n),n}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(n.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((n,s)=>{let o=l=>{t.removeEventListener("load",o),t.removeEventListener("error",o),l instanceof ErrorEvent?s("Image load error"):n()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,n,s,o){return Ve._postWorkerMessageSync(await t,n,s,o)}static _postWorkerMessageSync(t,n,s,o){if(!(t instanceof Worker))return-1;let l=Ve._workerMessageId++;return t.postMessage({id:l,type:n,data:s},o),l}}Ve.DEFAULT_CANVAS_SIZE=400;Ve.NO_QR_CODE_FOUND="No QR code found";Ve._disableBarcodeDetector=!1;Ve._workerMessageId=0;function Px({onResult:e,onClose:t}){const n=M.useRef(null),s=M.useRef(null),o=M.useRef(!1),[l,u]=M.useState("");M.useEffect(()=>{let p=!1;const m=n.current,S=w=>{p||o.current||(o.current=!0,e(w))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){u(_("qr-unsupported"));return}let w=!1;try{w=await Ve.hasCamera()}catch{w=!1}if(!w){u(_("qr-no-camera"));return}if(p||!m)return;const y=new Ve(m,v=>{const C=$g(v);C&&S(C)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:v=>{const C=v.videoWidth||640,b=v.videoHeight||480,k=Math.max(1,Math.round(Math.min(C,b)*.92));return{x:Math.round((C-k)/2),y:Math.round((b-k)/2),width:k,height:k,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=y;try{await y.start()}catch(v){if(p)return;const C=v&&v.name||"";u(_(C==="NotAllowedError"||C==="SecurityError"?"qr-permission":C==="NotFoundError"||C==="OverconstrainedError"||C==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{p=!0;const w=s.current;if(w){try{w.stop()}catch{}try{w.destroy()}catch{}s.current=null}const y=m,v=y&&y.srcObject;if(v&&typeof v.getTracks=="function"){for(const C of v.getTracks())try{C.stop()}catch{}try{y.srcObject=null}catch{}}}},[]);const d=async p=>{const m=p.target.files&&p.target.files[0];if(p.target.value="",!!m)try{const S=await Ve.scanImage(m,{returnDetailedScanResult:!0}),w=$g(S);if(!w)throw new Error("empty");o.current||(o.current=!0,e(w))}catch{u(_("pairing-qr-invalid"))}};return h.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:t,children:h.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:p=>p.stopPropagation(),children:[h.jsx("div",{className:"nc-sheet-head",children:h.jsx("b",{children:_("scan-qr")})}),h.jsx("video",{ref:n,className:"nc-qr-video",playsInline:!0,muted:!0}),l&&h.jsx("div",{className:"nc-err",role:"alert",children:l}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[_("qr-upload"),h.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:d})]}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:t,children:_("cancel")})]})]})})}const Kg=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:""});function A_({token:e,initial:t="",autoStart:n=!1,deviceDefault:s="",readonly:o=!1,onSuccess:l,onBusyChange:u}){const[d,p]=M.useState(Kg),[m,S]=M.useState(!1),[w,y]=M.useState(!1),[v,C]=M.useState("idle"),[b,k]=M.useState(null),[N,L]=M.useState(""),[A,B]=M.useState(!1),ee=M.useRef(Cx()),O=M.useRef(new Set),F=v==="busy";M.useEffect(()=>(u&&u(F),()=>{u&&u(!1)}),[F,u]);const Z=async j=>{const U=String(j.pairingUrl||"").trim();if(ee.current.start(U)){C("busy"),k(null),L("");try{await gw(e,bx(j,{deviceDefault:s})),C("ok"),S(!1),p(Kg()),O.current=new Set,B(!1),ee.current.finish(),l&&await l()}catch(R){const H=kx(R);k(H),C("idle"),ee.current.finish(),(H.stage==="validation"||H.stage==="conflict")&&S(!0)}}},W=(j,U=!0)=>{const{classification:R,form:H}=Wg(d,j,O.current,A),I=H.pairingUrl;if(k(null),L(""),v==="ok"&&C("idle"),p(H),R.kind==="invalid"){k({stage:"validation",code:"bad-link",message:_("pair-invalid-link"),hint:_("pair-invalid-hint"),retryable:!0});return}if(R.kind==="partial"){S(!0),L(R.missing.includes("ssh")?_("pair-missing-ssh"):_("pair-missing-name"));return}R.kind==="complete"&&U&&!o&&ee.current.canAuto(I)&&Z(H)};M.useEffect(()=>{t&&W(t,n)},[]);const G=()=>{const j=String(d.pairingUrl||"").trim(),{classification:U,form:R}=Wg(d,j,O.current,A);if(p(R),L(""),k(null),U.kind==="empty"){k({stage:"validation",message:_("pairing-required"),retryable:!0});return}if(U.kind==="invalid"){k({stage:"validation",code:"bad-link",message:_("pair-invalid-link"),hint:_("pair-invalid-hint"),retryable:!0});return}if(!R.ssh||!R.name){S(!0),L(R.ssh?_("pair-missing-name"):_("pair-missing-ssh"));return}if(R.label&&!bh(R.label)){k({stage:"validation",message:_("err-label"),retryable:!0});return}if(R.localLabel&&!bh(R.localLabel)){k({stage:"validation",message:_("err-label"),retryable:!0});return}ee.current.reset(j),Z(R)},K=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const j=await navigator.clipboard.readText();j&&j.trim()?W(j):L(_("pair-clipboard-empty"))}catch{L(_("pair-clipboard-denied"))}},P=(j,U)=>{O.current.add(j),p(R=>({...R,[j]:U}))},E=b&&b.stage&&(xx.includes(b.stage)||b.stage==="internal")?_(`pair-stage-${b.stage}`):_("pair-stage-generic");return h.jsxs("div",{className:"nc-set-form nc-pair-card",children:[h.jsx("div",{className:"nc-sheet-label",children:_("pair-card-title")}),h.jsx("div",{className:"nc-set-info",children:_("pair-card-help")}),h.jsx("input",{className:"nc-pair-input",placeholder:_("pair-paste-ph"),value:d.pairingUrl,disabled:o||F,onChange:j=>{p({...d,pairingUrl:j.target.value}),k(null),L("")},onPaste:j=>{const U=j.clipboardData&&j.clipboardData.getData("text")||"";U.trim()&&(j.preventDefault(),W(U))},onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),G())}}),h.jsxs("div",{className:"nc-pair-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||F,onClick:K,children:_("pair-paste-btn")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||F,onClick:()=>y(!0),children:_("scan-qr")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||F,title:o?_("settings-readonly"):"",onClick:G,children:_("test-and-connect")})]}),h.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[F&&h.jsx("div",{className:"nc-pair-progress",children:_("pair-progress")}),v==="ok"&&h.jsx("div",{className:"nc-set-test ok",children:_("node-connected")}),N&&h.jsx("div",{className:"nc-set-hint nc-pair-notice",children:N}),b&&h.jsxs("div",{className:"nc-err",role:"alert",children:[h.jsx("b",{children:E})," — ",b.message,b.hint&&h.jsx("div",{className:"nc-pair-hint",children:b.hint}),b.retryable&&h.jsx("div",{children:h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||F,onClick:G,children:_("pair-retry")})})]})]}),h.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:F,onClick:()=>S(j=>!j),children:[m?"▾":"▸"," ",_("pair-advanced")]}),m&&h.jsxs("div",{className:"nc-pair-advanced",children:[h.jsxs("label",{className:"nc-field",children:[_("node-display-label"),h.jsx("input",{placeholder:"Home Relay",value:d.label,disabled:o||F,onChange:j=>{O.current.add("label"),p(U=>({...U,label:j.target.value,name:A?U.name:Vr(j.target.value)}))}})]}),h.jsxs("label",{className:"nc-field",children:[_("node-name-label"),h.jsx("input",{placeholder:_("node-name-ph"),value:d.name,disabled:o||F,onChange:j=>{B(!0),O.current.add("name"),p(U=>({...U,name:j.target.value?Vr(j.target.value):""}))}})]}),h.jsx("small",{className:"nc-set-hint",children:_("node-slug-hint").replace("{slug}",d.name||"home-relay")}),h.jsxs("label",{className:"nc-field",children:[_("node-ssh-label"),h.jsx("input",{placeholder:"my-relay",value:d.ssh,disabled:o||F,onChange:j=>{O.current.add("ssh"),P("ssh",j.target.value)}})]}),h.jsxs("label",{className:"nc-field",children:[_("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:_("node-ssh-port-help"),value:d.sshPort,disabled:o||F,onChange:j=>P("sshPort",j.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),h.jsxs("label",{className:"nc-field",children:[_("device-name-label"),h.jsx("input",{placeholder:s||"NexusCrew",value:d.localLabel,disabled:o||F,onChange:j=>P("localLabel",j.target.value)}),h.jsx("small",{className:"nc-set-hint",children:_("device-name-hint")})]})]}),w&&h.jsx(Px,{onResult:j=>{y(!1),W(j)},onClose:()=>y(!1)})]})}function Qh(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function Dx(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(n),o=new Uint8Array(s.length);for(let l=0;l<s.length;l+=1)o[l]=s.charCodeAt(l);return o}async function Mx(){if(!Qh())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function Lx(e){if(!Qh())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const n=await zt("/api/push/vapid",e),{publicKey:s}=await n.json();if(!s)throw new Error("vapid non disponibile");const l=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Dx(s)}),u=await zt("/api/push/subscribe",e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:l.toJSON()})});if(!u.ok){try{await l.unsubscribe()}catch{}const d=await u.json().catch(()=>({}));throw new Error(d.error||`HTTP ${u.status}`)}return!0}async function jx(e){if(!Qh())return!1;const n=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!n)return!1;const s=n.endpoint;try{await n.unsubscribe()}catch{}try{await zt("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const I_="nexuscrew.fleet",O_=2,Tx="nexuscrew.cells",Bx=/^[A-Za-z0-9._-]{1,32}$/,Jh=/^[a-z0-9._-]{1,32}$/,z_=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,Ax=new Set(["standard","unsafe"]),Ix=4096,qg=256,Ox=8192,zx=32,Fx=24,Hx=new Set(["format","version","exportedAt","cells","engines"]),$x=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]),Wx=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag"]),Ux=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]);function sr(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function F_(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 Vg(e,t){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))return null;const n=Object.entries(e);if(n.length>128)return null;const s={};for(const[o,l]of n){if(!Jh.test(o)||!t(l))return null;s[o]=l}return s}function H_(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(l=>!$x.has(l))||!Bx.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>Ix||!Jh.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>qg)||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>Ox)return null;const n=Vg(e.models,l=>typeof l=="string"&&!!l&&l.length<=qg),s=Vg(e.permissionPolicies,l=>Ax.has(l));if(n===null||s===null)return null;const o={id:e.id,cwd:e.cwd,engine:e.engine,boot:e.boot===!0,systemPrompt:t};return e.model&&(o.model=e.model),Object.keys(n).length&&(o.models=n),Object.keys(s).length&&(o.permissionPolicies=s),o}function Kx(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(n=>!Ux.has(n)))return null;const t={};for(const[n,s]of Object.entries(e)){if(typeof s!="string"||!sr(s,n==="baseUrl"?512:128)||F_(s))return null;t[n]=s}return!t.client||!t.provider||t.envKey&&!z_.test(t.envKey)?null:t}function $_(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!Wx.has(s))||!Jh.test(String(e.id||""))||!sr(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=Kx(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!sr(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!sr(s,1024)||F_(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!sr(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")||!sr(e.model.flag,32)||/\s/.test(e.model.flag)||!sr(e.model.value||"",128))return null;t.model={flag:e.model.flag,value:e.model.value||""}}const n=e.envKeys===void 0?[]:e.envKeys;return!Array.isArray(n)||n.length>32||n.some(s=>!z_.test(s))?null:(Object.assign(t,{command:e.command,args:[...e.args],envKeys:[...new Set(n)].sort(),promptMode:e.promptMode}),e.promptMode==="flag"&&(t.promptFlag=e.promptFlag),t)}function W_(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.managed?{id:e.id,label:e.label,rc:e.rc,managed:e.managed}:{id:e.id,label:e.label,rc:e.rc,command:e.command,args:e.args,envKeys:e.envKeys,model:e.model,promptMode:e.promptMode,promptFlag:e.promptFlag},n=$_(t);return n||null}function qx(e,t,n=[],s=[],o=new Date){n instanceof Date&&(o=n,n=[],s=[]);const l=t instanceof Set?t:new Set(t||[]),u=s instanceof Set?s:new Set(s||[]),d=[];for(const m of Array.isArray(e)?e:[]){if(!l.has(m.id))continue;const S=H_({id:m.id,cwd:m.cwd,engine:m.engine,boot:m.boot===!0,...m.model?{model:m.model}:{},...m.models?{models:m.models}:{},...m.permissionPolicies?{permissionPolicies:m.permissionPolicies}:{},systemPrompt:m.prompt||""});S&&d.push(S)}const p=[];for(const m of Array.isArray(n)?n:[]){if(!u.has(m.id))continue;const S=W_(m);S&&p.push(S)}return{format:I_,version:O_,exportedAt:o.toISOString(),cells:d,engines:p}}function Vx(e){let t;try{t=JSON.parse(String(e||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const n=(t==null?void 0:t.format)===Tx&&(t==null?void 0:t.version)===1;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(d=>!Hx.has(d))||!n&&(t.format!==I_||t.version!==O_)||!Array.isArray(t.cells)||t.cells.length>zx||!n&&(!Array.isArray(t.engines)||t.engines.length>Fx))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const s=[],o=new Set;for(const d of t.cells){const p=H_(d);if(!p)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(o.has(p.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};o.add(p.id),s.push(p)}const l=[],u=new Set;for(const d of n?[]:t.engines){const p=$_(d);if(!p)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(u.has(p.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};u.add(p.id),l.push(p)}return{ok:!0,cells:s,engines:l,legacy:n,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function Yx(e,t,n){const s=new Set(n||[]);if(!s.has(t))return null;const o=p=>Object.fromEntries(Object.entries(p||{}).filter(([m])=>s.has(m))),l={id:e.id,cwd:e.cwd,engine:t,boot:e.boot===!0,prompt:e.systemPrompt||""};t===e.engine&&e.model?l.model=e.model:e.models&&e.models[t]&&(l.model=e.models[t]);const u=o(e.models),d=o(e.permissionPolicies);return Object.keys(u).length&&(l.models=u),Object.keys(d).length&&(l.permissionPolicies=d),l}const Xx=()=>({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:[]}),Yg=(e="")=>({id:"",cwd:"",engine:e,boot:!1,model:"",prompt:""}),U_=e=>e==="claude"?"unsafe":"standard",Va=(e,t)=>e.find(n=>n.client===t.client&&n.provider===t.provider&&(n.credentialProfile||"")===(t.credentialProfile||"")),Gx=(e,t)=>{var n;return((n=Va(e,t))==null?void 0:n.label)||`${t.client} · ${t.provider}`};function Qx(e){var t,n,s,o,l,u,d,p,m,S,w,y,v,C;return{kind:e.managed?"managed":"custom",id:e.id,label:e.label||"",command:e.command||"",argsText:(e.args||[]).join(`
|
|
89
|
-
`),rc:!!e.rc,client:((t=e.managed)==null?void 0:t.client)||"claude",provider:((n=e.managed)==null?void 0:n.provider)||"native",credentialProfile:((s=e.managed)==null?void 0:s.credentialProfile)||"",managedModel:((o=e.managed)==null?void 0:o.model)||"",permissionPolicy:((l=e.managed)==null?void 0:l.permissionPolicy)||U_((u=e.managed)==null?void 0:u.client),displayName:((d=e.managed)==null?void 0:d.displayName)||"",protocol:((p=e.managed)==null?void 0:p.protocol)||"",baseUrl:((m=e.managed)==null?void 0:m.baseUrl)||"",envKey:((S=e.managed)==null?void 0:S.envKey)||"",providerId:((w=e.managed)==null?void 0:w.providerId)||"nexuscrew-custom",modelOptions:e.availableModels||((y=e.managedInfo)==null?void 0:y.models)||[],promptMode:e.promptMode||"send-keys",promptFlag:e.promptFlag||"",modelFlag:((v=e.model)==null?void 0:v.flag)||"",modelValue:((C=e.model)==null?void 0:C.value)||"",envRows:(e.envKeys||[]).map(b=>({key:b,value:"",configured:!0,remove:!1}))}}function Jx(e,t,n=[]){if(e.kind==="managed"){const o={client:e.client,provider:e.provider,model:e.managedModel||"",permissionPolicy:e.permissionPolicy||U_(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile);const l=Va(n,e);return l!=null&&l.credentialEnv&&(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||Gx(n,e),rc:!!e.rc,managed:o}}const s={...t?{id:e.id}:{},label:e.label||e.id,rc:!!e.rc,command:e.command,args:e.argsText.split(`
|
|
90
|
-
`).filter(o=>o!==""),promptMode:e.promptMode};return e.modelFlag&&(s.model={flag:e.modelFlag,value:e.modelValue||""}),e.promptMode==="flag"&&(s.promptFlag=e.promptFlag),t&&(s.env=Object.fromEntries(e.envRows.filter(o=>!o.remove&&o.key).map(o=>[o.key,o.value]))),s}function $r({children:e,onClose:t,label:n,error:s=""}){const o=M.useRef(null),l=M.useRef(null),u=M.useRef(t);return u.current=t,M.useEffect(()=>{const d=document.activeElement,p=o.current,m=()=>Array.from((p==null?void 0:p.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))||[]).filter(y=>y.offsetParent!==null),S=requestAnimationFrame(()=>{var y;return(y=m()[0]||p)==null?void 0:y.focus({preventScroll:!0})}),w=y=>{var k;if(y.key==="Escape"){y.preventDefault(),(k=u.current)==null||k.call(u);return}if(y.key!=="Tab")return;const v=m();if(!v.length){y.preventDefault(),p==null||p.focus();return}const C=v[0],b=v[v.length-1];y.shiftKey&&document.activeElement===C?(y.preventDefault(),b.focus()):!y.shiftKey&&document.activeElement===b&&(y.preventDefault(),C.focus())};return document.addEventListener("keydown",w),()=>{cancelAnimationFrame(S),document.removeEventListener("keydown",w),d&&d.isConnected&&typeof d.focus=="function"&&d.focus({preventScroll:!0})}},[]),M.useEffect(()=>{s&&requestAnimationFrame(()=>{var d;return(d=l.current)==null?void 0:d.scrollIntoView({block:"nearest"})})},[s]),h.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:d=>{d.target===d.currentTarget&&t()},children:h.jsxs("div",{ref:o,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":n||_("settings"),tabIndex:-1,children:[e,s&&h.jsx("div",{ref:l,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:s})]})})}function Zx({token:e,readonly:t,targets:n=[],startNewCell:s=!1,initialLocation:o=""}){const[l,u]=M.useState({engines:[],cells:[],managedCatalog:[]}),[d,p]=M.useState({available:!1,capabilities:[]}),[m,S]=M.useState(null),[w,y]=M.useState(null),[v,C]=M.useState(!1),[b,k]=M.useState(""),[N,L]=M.useState(""),[A,B]=M.useState(o),[ee,O]=M.useState(!1),[F,Z]=M.useState(null),[W,G]=M.useState(null),[K,P]=M.useState(!1),[E,j]=M.useState([]),[U,R]=M.useState(null),[H,I]=M.useState("manage"),q=M.useRef(!1),X=A?A.split("/"):[],D=M.useCallback(async()=>{try{const $=await hr(e,X);p($);try{const fe=await Lh(e,X);O(!!fe.readonlyDefault)}catch{O(!1)}if($.provider==="builtin"&&($.capabilities||[]).includes("definitions")){const fe=await Dh(e,X),Ce=new Map(($.engines||[]).map(Ee=>[Ee.id,Ee]));if(fe.engines=(fe.engines||[]).map(Ee=>{var Ae;return{...Ee,availableModels:((Ae=Ce.get(Ee.id))==null?void 0:Ae.models)||[]}}),u(fe),($.capabilities||[]).includes("credentials"))try{j((await nw(e,X)).credentials||[])}catch{j([])}else j([])}}catch($){k(String($.message||$))}},[e,A]);M.useEffect(()=>{D();const $=setInterval(D,5e3);return()=>clearInterval($)},[D]);const Q=new Set((d.cells||[]).filter($=>$.active).map($=>$.cell)),se=d.provider==="builtin"&&(d.capabilities||[]).includes("edit"),re=(d.capabilities||[]).includes("restore");M.useEffect(()=>{!s||q.current||!se||!l.engines.length||(q.current=!0,y({mode:"new",form:Yg(l.engines[0].id)}))},[s,se,l.engines]);const ae=async $=>{C(!0),k(""),L("");try{await $(),await D()}catch(fe){k(String(fe.message||fe))}C(!1)},le=()=>ae(async()=>{const $=m.mode==="new",fe=Jx(m.form,$,l.managedCatalog||[]);!$&&m.form.kind==="custom"&&!m.form.modelFlag&&(fe.model=null),!$&&m.form.kind==="custom"&&m.form.promptMode!=="flag"&&(fe.promptFlag=null);let Ce;if($)Ce=await ow(e,fe,X);else{const Ae=m.original,mt=new Set(m.form.envRows.filter(We=>!We.remove).map(We=>We.key)),rt=(Ae.envKeys||[]).filter(We=>!mt.has(We)),Be=Object.fromEntries(m.form.envRows.filter(We=>!We.remove&&We.key&&(!We.configured||We.value!=="")).map(We=>[We.key,We.value]));Ce=await aw(e,Ae.id,fe,m.form.kind==="custom"?{set:Be,remove:rt}:void 0,X)}S(null),L(_("fleet-saved"));const Ee=(Ce==null?void 0:Ce.activeCells)||[];if(Ee.length&&window.confirm(_("fleet-restart-confirm").replace("{cells}",Ee.join(", "))))for(const Ae of Ee)await Us(e,Ae,X)}),de=()=>ae(async()=>{const $=w.mode==="new",fe=w.form,Ce={...$?{id:fe.id}:{},cwd:fe.cwd,engine:fe.engine,boot:!!fe.boot};$?(fe.model&&(Ce.model=fe.model),fe.prompt&&(Ce.prompt=fe.prompt)):(Ce.model=fe.model||null,Ce.prompt=fe.prompt||null);const Ee=$?await cw(e,Ce,X):await uw(e,w.original.id,Ce,X),Ae=$?fe.id:w.original.id;y(null),L(_("fleet-saved")),!$&&(Ee!=null&&Ee.active)&&window.confirm(_("fleet-restart-confirm").replace("{cells}",Ae))&&await Us(e,Ae,X)}),ve=t||ee,Re=$=>E.find(fe=>{var Ce;return(Ce=fe.engines)==null?void 0:Ce.includes($.id)})||null,Fe=()=>ae(async()=>{var Ce;const $=await rw(e,U.envKey,U.value,X);j($.credentials||[]),R(null),L(_("fleet-credential-saved"));const fe=((Ce=($.credentials||[]).find(Ee=>Ee.envKey===U.envKey))==null?void 0:Ce.activeCells)||[];if(fe.length&&window.confirm(_("fleet-restart-confirm").replace("{cells}",fe.join(", "))))for(const Ee of fe)await Us(e,Ee,X)}),te=$=>ae(async()=>{if(!window.confirm(_("fleet-credential-remove-confirm").replace("{key}",$.envKey)))return;const fe=await sw(e,$.envKey,X);j(fe.credentials||[]),L(_("fleet-credential-removed"))}),ie=$=>Z({...$,route:Array.isArray($==null?void 0:$.route)?$.route:X}),ye=async $=>{if(!F)return;const fe=F.cell||F.id,Ce=Array.isArray(F.route)?F.route:X;$.action==="up"?await Ph(e,{cell:fe,boot:!!$.boot,...$.engine?{engine:$.engine}:{},...$.model!==void 0?{model:$.model}:{},...$.permissionPolicy?{permissionPolicy:$.permissionPolicy}:{}},Ce):await ja(e,{cell:fe,boot:!!$.boot},Ce)},Le=($,fe)=>{k(""),G({mode:"new",route:Array.isArray(fe)?fe:X,form:{tmuxSession:$.name,id:"",engine:"",cwd:"",boot:!1},err:""})},je=()=>ae(async()=>{const $=W.form;if(!$.engine){G({...W,err:_("import-engine-required")});return}await hw(e,{tmuxSession:$.tmuxSession,id:$.id||void 0,engine:$.engine,cwd:$.cwd||void 0,boot:!!$.boot},$.route||X),G(null),L(_("fleet-saved"))}),Y=({engineRows:$=[],cellRows:fe=[]})=>ae(async()=>{const Ce=$.filter(Ge=>Ge.selected),Ee=Ce.map(Ge=>W_(Ge.engine));if(Ee.some(Ge=>!Ge))throw new Error(_("fleet-backup-invalid-engine"));const Ae=Ce.filter(Ge=>Ge.exists).map(Ge=>Ge.engine.id);if(Ae.length&&!window.confirm(_("fleet-backup-confirm-engine-overwrite").replace("{engines}",Ae.join(", "))))return;const mt=[...new Set([...l.engines.map(Ge=>Ge.id),...Ee.map(Ge=>Ge.id)])],rt=[];for(const Ge of fe.filter(me=>me.selected)){const me=Yx(Ge.cell,Ge.engine,mt);if(!me)throw new Error(`${Ge.cell.id}: ${_("fleet-backup-engine-missing")}`);rt.push(me)}const Be=fe.filter(Ge=>Ge.selected&&Ge.exists).map(Ge=>Ge.cell.id);if(Be.length&&!window.confirm(_("fleet-backup-confirm-overwrite").replace("{cells}",Be.join(", "))))return;const We=Ee.length?await fw(e,Ee,Ae.length>0,X):{needsRestart:[]},Ie=rt.length?await dw(e,rt,X):{needsRestart:[]},bt=[...new Set([...We.needsRestart||[],...Ie.needsRestart||[]])];P(!1),L(`${_("fleet-backup-restored").replace("{n}",String(rt.length))}${Ee.length?` · ${Ee.length} ${_("fleet-engines").toLowerCase()}`:""}${bt.length?` · ${_("fleet-backup-needs-restart").replace("{cells}",bt.join(", "))}`:""}`)}),he=h.jsxs("label",{className:"nc-field",children:[_("location"),h.jsxs("select",{value:A,onChange:$=>{B($.target.value),S(null),y(null),k(""),L(""),O(!1),p({available:!1,capabilities:[]}),u({engines:[],cells:[],managedCatalog:[]}),j([]),R(null)},children:[h.jsx("option",{value:"",children:_("local")}),n.map($=>h.jsxs("option",{value:$.route.join("/"),disabled:$.status&&$.status!=="up",children:[$.label,$.status&&$.status!=="up"?` · ${_("node-offline")}`:""]},$.route.join("/")))]})]}),we=h.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":_("tab-fleet"),children:[h.jsx("button",{type:"button",role:"tab","aria-selected":H==="manage",className:`nc-set-tabbtn${H==="manage"?" on":""}`,onClick:()=>I("manage"),children:_("fleet-manage-location")}),h.jsx("button",{type:"button",role:"tab","aria-selected":H==="overview",className:`nc-set-tabbtn${H==="overview"?" on":""}`,onClick:()=>I("overview"),children:_("fleet-network-overview")})]});return se?h.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[we,H==="overview"?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:_("fleet-overview-help")}),h.jsx(Xg,{token:e,targets:n,readonly:t,onPower:ie,onImport:Le})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:_("fleet-manage-help")}),he,h.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:ve||v,onClick:()=>{k(""),P(!0)},children:_("fleet-backup")}),h.jsx("small",{children:_("fleet-backup-help")})]}),h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:_("fleet-cells")}),h.jsx("span",{className:"nc-fleet-head-actions",children:h.jsxs("button",{className:"nc-btn primary",disabled:ve||v||!l.engines.length,onClick:()=>{var $;k(""),y({mode:"new",form:Yg(($=l.engines[0])==null?void 0:$.id)})},children:["+ ",_("add")]})})]}),l.cells.map($=>{const fe=Q.has($.id),Ce=d.capabilities||[];return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:$.id}),h.jsxs("small",{children:[$.engine," · ",$.cwd,fe?` · ${_("service-active")}`:` · ${_("cell-off")}`]})]}),h.jsxs("span",{children:[fe&&Ce.includes("down")&&h.jsx("button",{className:"nc-btn ghost",disabled:ve||v,onClick:()=>ae(()=>ja(e,{cell:$.id},X)),children:_("stop")}),!fe&&Ce.includes("up")&&h.jsx("button",{className:"nc-btn primary",disabled:ve||v,onClick:()=>ie({cell:$.id,id:$.id,engine:$.engine,model:$.model,models:$.models,permissionPolicies:$.permissionPolicies,active:!1,boot:$.boot}),children:_("start")}),fe&&Ce.includes("restart")&&h.jsx("button",{className:"nc-btn ghost",disabled:ve||v,onClick:()=>ae(()=>Us(e,$.id,X)),children:_("restart")}),h.jsx("button",{className:"nc-btn ghost",disabled:ve||v,onClick:()=>{k(""),y({mode:"edit",original:$,form:{...$}})},children:_("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:ve||v,onClick:()=>ae(async()=>{window.confirm(_("fleet-remove-cell").replace("{id}",$.id))&&await sv(e,$.id,!0,X)}),children:"×"})]})]},$.id)}),h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:_("fleet-engines")}),h.jsxs("button",{className:"nc-btn primary",disabled:ve||v,onClick:()=>{k(""),S({mode:"new",form:Xx()})},children:["+ ",_("add")]})]}),l.engines.map($=>{var Ce,Ee;const fe=Re($);return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:$.label}),h.jsx("small",{children:$.managed?`${$.id} · ${$.managed.client} / ${$.managed.provider} · ${(Ce=$.managedInfo)!=null&&Ce.configured?_("fleet-ready"):((Ee=$.managedInfo)==null?void 0:Ee.reason)||_("fleet-not-ready")}`:`${$.id} · ${$.command}`}),fe&&h.jsxs("small",{children:[fe.envKey," · ",_(`fleet-credential-source-${fe.source||"missing"}`)]})]}),h.jsxs("span",{children:[fe&&h.jsx("button",{className:"nc-btn ghost",disabled:ve||v,onClick:()=>{k(""),R({envKey:fe.envKey,value:""})},children:fe.configured?_("fleet-credential-change"):_("fleet-credential-set")}),(fe==null?void 0:fe.source)==="local"&&h.jsx("button",{className:"nc-btn danger",disabled:ve||v,onClick:()=>te(fe),children:_("fleet-credential-forget")}),h.jsx("button",{className:"nc-btn ghost",disabled:ve||v,onClick:()=>{k(""),S({mode:"edit",original:$,form:Qx($)})},children:_("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:ve||v,onClick:()=>ae(async()=>{window.confirm(_("fleet-remove-engine").replace("{id}",$.id))&&await lw(e,$.id,X)}),children:"×"})]})]},$.id)})]}),m&&h.jsx($r,{onClose:()=>S(null),label:_("fleet-new-engine"),error:b,children:h.jsx(tk,{state:m,setState:S,busy:v,onSave:le,catalog:l.managedCatalog||[]})}),w&&h.jsx($r,{onClose:()=>y(null),label:_("fleet-new-cell"),error:b,children:h.jsx(ik,{token:e,route:X,targets:n,location:A,setLocation:B,state:w,setState:y,engines:l.engines,busy:v,onSave:de})}),N&&h.jsx("div",{className:"nc-set-note",children:N}),b&&h.jsx("div",{className:"nc-err",children:b}),K&&h.jsx($r,{onClose:()=>P(!1),label:_("fleet-backup"),error:b,children:h.jsx(ek,{cells:l.cells,engines:l.engines,busy:v,canRestore:re,onRestore:Y,onClose:()=>P(!1)})}),U&&h.jsx($r,{onClose:()=>R(null),label:_("fleet-credential-title"),error:b,children:h.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[h.jsx("b",{children:_("fleet-credential-title")}),h.jsx("small",{children:_("fleet-credential-help")}),h.jsxs("label",{className:"nc-field",children:[U.envKey,h.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:U.value,onChange:$=>R({...U,value:$.target.value})})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>R(null),children:_("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:v||!U.value,onClick:Fe,children:_("save")})]})]})}),W&&h.jsx($r,{onClose:()=>G(null),label:_("import-as-cell"),error:b,children:h.jsx(Gg,{token:e,route:W.route||X,state:W,setState:G,busy:v,onSave:je})}),F&&h.jsx(Ba,{cell:F,token:e,route:Array.isArray(F.route)?F.route:X,onConfirm:async $=>{try{await ye($)}finally{await D()}},onClose:()=>Z(null)})]}):h.jsxs("div",{className:"nc-set-tab",children:[we,H==="overview"?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:_("fleet-overview-help")}),h.jsx(Xg,{token:e,targets:n,readonly:t,onPower:ie,onImport:Le})]}):h.jsxs(h.Fragment,{children:[he,h.jsx("div",{className:"nc-set-info",children:_("fleet-editor-unavailable")})]}),b&&h.jsx("div",{className:"nc-err",children:b}),W&&h.jsx($r,{onClose:()=>G(null),label:_("import-as-cell"),error:b,children:h.jsx(Gg,{token:e,route:W.route||X,state:W,setState:G,busy:v,onSave:je})}),F&&h.jsx(Ba,{cell:F,token:e,route:Array.isArray(F.route)?F.route:X,onConfirm:async $=>{try{await ye($)}finally{await D()}},onClose:()=>Z(null)})]})}function Xg({token:e,targets:t=[],readonly:n=!1,onPower:s,onImport:o}){const[l,u]=M.useState([]),[d,p]=M.useState(0);M.useEffect(()=>{let k=!0;async function N(){const A=[{route:[],label:_("local")}].concat((t||[]).map(ee=>({route:Array.isArray(ee.route)?ee.route:[],label:ee.label||(ee.route||[]).join(" › ")}))),B=await Promise.all(A.map(async ee=>{const O={...ee,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const F=await hr(e,ee.route);O.available=!!F.available,O.capabilities=F.capabilities||[],O.provider=F.provider||null,O.cells=(F.cells||[]).map(Z=>({...Z,route:ee.route}));try{O.readonly=!!(await Lh(e,ee.route)).readonlyDefault}catch{}try{const Z=await uv(e,ee.route),W=new Set(O.cells.map(G=>G.tmuxSession).filter(Boolean));O.unmanaged=(Z.sessions||[]).filter(G=>G&&!W.has(G.name))}catch{}}catch(F){O.err=String(F&&F.message||F)}return O}));k&&u(B)}N();const L=setInterval(N,6e3);return()=>{k=!1,clearInterval(L)}},[e,t,d]);const m=(k,N)=>Array.isArray(k.capabilities)&&k.capabilities.includes(N)&&!n&&!k.readonly,S=()=>p(k=>k+1),w=(k,N)=>{s&&s({...k,route:N})},y=(k,N)=>{s&&s({...k,route:N})},v=async(k,N)=>{try{await Us(e,k.cell,N)}catch{}S()},C=async(k,N)=>{if(window.confirm(_("fleet-remove-cell").replace("{id}",k.cell))){try{await sv(e,k.cell,!0,N)}catch{}S()}},b=async(k,N)=>{if(window.confirm(_("terminate-confirm").replace("{name}",k.name))){try{await Mh(e,k.name,N)}catch{}S()}};return h.jsxs("div",{className:"nc-fleet-inventory",children:[h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:_("fleet-inventory")}),h.jsx("small",{children:_("fleet-inventory-help")})]}),l.map(k=>{const N=k.route.length?k.route.join("/"):"local";return h.jsxs("div",{className:"nc-fleet-pos",children:[h.jsxs("div",{className:"nc-fleet-pos-title",children:[h.jsx("span",{className:`dot ${k.available?"on":"warn"}`}),h.jsx("b",{children:k.label}),h.jsx("small",{children:k.available?`${k.cells.length} ${_("fleet-cells")} · ${k.unmanaged.length} ${_("fleet-tmux")}`:k.err||_("fleet-not-available")})]}),k.cells.map(L=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[h.jsxs("span",{children:[h.jsx("b",{children:L.cell}),h.jsx("small",{children:`${L.engine||""}${L.key?`·${L.key}`:""}${L.active?"":` · ${_("cell-off")}`}`})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[L.active&&m(k,"down")&&h.jsx("button",{className:"nc-btn ghost",title:_("power-off"),onClick:()=>y(L,k.route),children:_("stop")}),!L.active&&m(k,"up")&&h.jsx("button",{className:"nc-btn ghost",title:_("power-on"),onClick:()=>w(L,k.route),children:_("start")}),m(k,"restart")&&L.active&&h.jsx("button",{className:"nc-btn ghost",title:_("restart"),onClick:()=>v(L,k.route),children:_("restart")}),m(k,"remove")&&h.jsx("button",{className:"nc-btn danger",title:_("delete"),onClick:()=>C(L,k.route),children:"×"})]})]},`${N}:${L.cell}`)),k.unmanaged.map(L=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[h.jsxs("span",{children:[h.jsx("b",{children:L.name}),h.jsx("small",{children:_("fleet-tmux")})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[m(k,"import")&&o&&h.jsx("button",{className:"nc-btn ghost",title:_("import-as-cell"),onClick:()=>o(L,k.route),children:_("import-as-cell")}),h.jsx("button",{className:"nc-btn danger",title:_("terminate"),onClick:()=>b(L,k.route),children:"×"})]})]},`${N}:u:${L.name}`)),k.available&&k.cells.length===0&&k.unmanaged.length===0&&h.jsx("div",{className:"nc-empty",children:_("fleet-inventory-empty")})]},N)})]})}function ek({cells:e=[],engines:t=[],busy:n,canRestore:s=!1,onRestore:o,onClose:l}){const[u,d]=M.useState("export"),[p,m]=M.useState(()=>new Set(e.map(E=>E.id))),[S,w]=M.useState(()=>new Set(t.map(E=>E.id))),[y,v]=M.useState([]),[C,b]=M.useState([]),[k,N]=M.useState(""),L=new Set(t.map(E=>E.id)),A=new Set(e.map(E=>E.id)),B=(E,j)=>E(U=>{const R=new Set(U);return R.has(j)?R.delete(j):R.add(j),R}),ee=()=>{const E=qx(e,p,t,S),j=t.filter(I=>S.has(I.id)).length;if(E.engines.length!==j){N(_("fleet-backup-invalid-engine"));return}if(!E.cells.length&&!E.engines.length){N(_("fleet-backup-select-one"));return}const U=new Blob([`${JSON.stringify(E,null,2)}
|
|
91
|
-
`],{type:"application/json"}),R=URL.createObjectURL(U),H=document.createElement("a");H.href=R,H.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(H),H.click(),H.remove(),setTimeout(()=>URL.revokeObjectURL(R),0),N("")},O=async E=>{if(N(""),v([]),b([]),!!E){if(E.size>1024*1024){N(_("fleet-backup-too-large"));return}try{const j=Vx(await E.text());if(!j.ok){N(_(`fleet-backup-${j.error}`));return}const U=new Set(j.engines.map(R=>R.id));b(j.engines.map(R=>({engine:R,exists:L.has(R.id),selected:!L.has(R.id)}))),v(j.cells.map(R=>{const H=L.has(R.engine)||U.has(R.engine),I=A.has(R.id);return{cell:R,engine:H?R.engine:"",selected:H&&!I,exists:I}}))}catch(j){N(String(j.message||j))}}},F=(E,j)=>v(U=>U.map((R,H)=>H===E?{...R,...j}:R)),Z=(E,j)=>b(U=>U.map((R,H)=>H===E?{...R,...j}:R)),W=new Set([...L,...C.filter(E=>E.selected).map(E=>E.engine.id)]),G=y.filter(E=>E.selected&&E.engine&&W.has(E.engine)),K=C.filter(E=>E.selected),P=[...new Map([...t.map(E=>[E.id,E.label||E.id]),...C.filter(E=>E.selected).map(E=>[E.engine.id,E.engine.label||E.engine.id])]).entries()];return h.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[h.jsx("b",{children:_("fleet-backup")}),h.jsx("small",{children:_("fleet-backup-help")}),h.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[h.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="export"?" on":""}`,onClick:()=>{d("export"),N("")},children:_("fleet-backup-export")}),h.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="import"?" on":""}`,disabled:!s,title:s?"":_("fleet-backup-restore-unavailable"),onClick:()=>{d("import"),N("")},children:_("fleet-backup-import")})]}),u==="export"?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{m(new Set(e.map(E=>E.id))),w(new Set(t.map(E=>E.id)))},children:_("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{m(new Set),w(new Set)},children:_("select-none")})]}),h.jsxs("div",{className:"nc-backup-list",children:[h.jsx("b",{children:_("fleet-engines")}),t.map(E=>{var j;return h.jsxs("label",{className:"nc-check nc-backup-row",children:[h.jsx("input",{type:"checkbox",checked:S.has(E.id),onChange:()=>B(w,E.id)}),h.jsxs("span",{children:[h.jsx("b",{children:E.label||E.id}),h.jsxs("small",{children:[E.id,(j=E.envKeys)!=null&&j.length?` · ${E.envKeys.length} ${_("fleet-backup-env-names")}`:""]})]})]},E.id)}),h.jsx("b",{children:_("fleet-cells")}),e.map(E=>h.jsxs("label",{className:"nc-check nc-backup-row",children:[h.jsx("input",{type:"checkbox",checked:p.has(E.id),onChange:()=>B(m,E.id)}),h.jsxs("span",{children:[h.jsx("b",{children:E.id}),h.jsxs("small",{children:[E.engine," · ",_("fleet-system-prompt")," ",(E.prompt||"").length," ",_("characters")]})]})]},E.id)),!e.length&&!t.length&&h.jsx("div",{className:"nc-empty",children:_("fleet-backup-empty")})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:_("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:!p.size&&!S.size,onClick:ee,children:_("fleet-backup-download")})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"file",accept:"application/json,.json",disabled:n,onChange:E=>O(E.target.files&&E.target.files[0])}),h.jsx("small",{children:_("fleet-backup-import-help")}),!!(y.length||C.length)&&h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{b(E=>E.map(j=>({...j,selected:!0}))),v(E=>E.map(j=>({...j,selected:!!j.engine})))},children:_("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{b(E=>E.map(j=>({...j,selected:!1}))),v(E=>E.map(j=>({...j,selected:!1})))},children:_("select-none")})]}),h.jsxs("div",{className:"nc-backup-list",children:[!!C.length&&h.jsx("b",{children:_("fleet-engines")}),C.map((E,j)=>{var U;return h.jsx("div",{className:"nc-backup-import-row",children:h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:E.selected,onChange:R=>Z(j,{selected:R.target.checked})}),h.jsxs("span",{children:[h.jsx("b",{children:E.engine.label||E.engine.id}),h.jsxs("small",{children:[E.engine.id," · ",E.exists?_("fleet-backup-overwrite"):_("fleet-backup-new"),(U=E.engine.envKeys)!=null&&U.length?` · ${_("fleet-backup-env-values-required")}`:""]})]})]})},E.engine.id)}),!!y.length&&h.jsx("b",{children:_("fleet-cells")}),y.map((E,j)=>h.jsxs("div",{className:"nc-backup-import-row",children:[h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:E.selected,disabled:!E.engine||!W.has(E.engine),onChange:U=>F(j,{selected:U.target.checked})}),h.jsxs("span",{children:[h.jsx("b",{children:E.cell.id}),h.jsxs("small",{children:[E.exists?_("fleet-backup-overwrite"):_("fleet-backup-new")," · ",_("fleet-system-prompt")," ",E.cell.systemPrompt.length," ",_("characters")]})]})]}),h.jsxs("select",{value:E.engine,onChange:U=>F(j,{engine:U.target.value,selected:!!U.target.value}),children:[h.jsx("option",{value:"",children:_("fleet-backup-engine-missing")}),P.map(([U,R])=>h.jsx("option",{value:U,children:R},U))]})]},E.cell.id))]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:_("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||!G.length&&!K.length,onClick:()=>o({engineRows:C,cellRows:y}),children:_("fleet-backup-restore")})]})]}),k&&h.jsx("div",{className:"nc-err",children:k})]})}function tk({state:e,setState:t,busy:n,onSave:s,catalog:o}){var y;const l=e.form,u=v=>t({...e,form:{...l,...v}}),d=l.envRows||[],p=[...new Map(o.map(v=>[v.client,v.clientLabel||v.client])).entries()],m=o.filter(v=>v.client===l.client),S=Va(o,l),w=v=>{v&&u({client:v.client,provider:v.provider,credentialProfile:v.credentialProfile||"",managedModel:v.model||"",protocol:v.protocol||"",permissionPolicy:v.permissionPolicyDefault||"standard",rc:!!v.rc,displayName:v.custom?_("fleet-custom-provider-default"):"",baseUrl:v.custom?"":v.endpoint||"",envKey:v.defaultEnvKey||"",providerId:"nexuscrew-custom",...e.mode==="new"?{id:v.id,label:""}:{}})};return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsx("b",{children:e.mode==="new"?_("fleet-new-engine"):`${_("edit")} ${l.id}`}),h.jsx("input",{value:l.id,disabled:e.mode!=="new",placeholder:"id",onChange:v=>u({id:v.target.value})}),h.jsx("input",{value:l.label,placeholder:_("label"),onChange:v=>u({label:v.target.value})}),h.jsxs("select",{value:l.kind,disabled:e.mode!=="new",onChange:v=>u({kind:v.target.value}),children:[h.jsx("option",{value:"managed",children:_("fleet-managed")}),h.jsx("option",{value:"custom",children:_("fleet-custom")})]}),l.kind==="managed"?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("select",{value:l.client,disabled:e.mode!=="new",onChange:v=>w(o.find(C=>C.client===v.target.value&&C.default)||o.find(C=>C.client===v.target.value)),children:p.map(([v,C])=>h.jsx("option",{value:v,children:C},v))}),h.jsx("select",{value:((y=Va(o,l))==null?void 0:y.id)||"",disabled:e.mode!=="new",onChange:v=>w(o.find(C=>C.id===v.target.value)),children:m.map(v=>h.jsx("option",{value:v.id,children:v.label},v.id))})]}),h.jsx("input",{value:l.managedModel,list:"nc-managed-models",placeholder:_(S!=null&&S.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:v=>u({managedModel:v.target.value})}),h.jsx("datalist",{id:"nc-managed-models",children:[...(S==null?void 0:S.models)||[],...l.modelOptions||[]].filter((v,C,b)=>v&&b.indexOf(v)===C).map(v=>h.jsx("option",{value:v},v))}),S!=null&&S.supportsUnsafe?h.jsxs("select",{value:l.permissionPolicy,onChange:v=>u({permissionPolicy:v.target.value}),children:[h.jsx("option",{value:"standard",children:_("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:_("fleet-unsafe-permissions")})]}):h.jsx("small",{children:_("fleet-standard-permissions")}),(S==null?void 0:S.supportsUnsafe)&&l.permissionPolicy==="unsafe"&&h.jsx("small",{className:"nc-err",children:_("fleet-unsafe-warning")}),(S==null?void 0:S.credentialEnv)&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.envKey,placeholder:_("fleet-api-key-env"),onChange:v=>u({envKey:v.target.value})}),h.jsx("small",{children:_("fleet-custom-secret-help")})]}),l.provider==="custom"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.displayName,placeholder:_("fleet-provider-display"),onChange:v=>u({displayName:v.target.value})}),h.jsx("input",{value:l.baseUrl,placeholder:"https://api.example.com/v1",onChange:v=>u({baseUrl:v.target.value})}),((S==null?void 0:S.protocols)||[]).length>1&&h.jsx("select",{value:l.protocol,onChange:v=>u({protocol:v.target.value}),children:S.protocols.map(v=>h.jsx("option",{value:v,children:v},v))}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:l.envKey,placeholder:_("fleet-api-key-env"),onChange:v=>u({envKey:v.target.value})}),h.jsx("input",{value:l.providerId,placeholder:_("fleet-provider-id"),onChange:v=>u({providerId:v.target.value})})]}),h.jsxs("small",{children:[l.protocol," · ",_("fleet-custom-secret-help")]})]}),h.jsx("small",{children:_("fleet-managed-help")})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.command,placeholder:_("command-path"),onChange:v=>u({command:v.target.value})}),h.jsx("textarea",{value:l.argsText,placeholder:_("args-lines"),onChange:v=>u({argsText:v.target.value})}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:l.rc,onChange:v=>u({rc:v.target.checked})})," remote control"]}),h.jsxs("select",{value:l.promptMode,onChange:v=>u({promptMode:v.target.value}),children:[h.jsx("option",{value:"send-keys",children:"send-keys"}),h.jsx("option",{value:"flag",children:"flag"})]}),l.promptMode==="flag"&&h.jsx("input",{value:l.promptFlag,placeholder:"prompt flag",onChange:v=>u({promptFlag:v.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:l.modelFlag,placeholder:"model flag",onChange:v=>u({modelFlag:v.target.value})}),h.jsx("input",{value:l.modelValue,placeholder:"model default",onChange:v=>u({modelValue:v.target.value})})]}),h.jsx("small",{children:_("env-write-only")}),d.map((v,C)=>h.jsxs("div",{className:"nc-fleet-env",children:[h.jsx("input",{value:v.key,disabled:v.configured,placeholder:"ENV_KEY",onChange:b=>{const k=d.slice();k[C]={...v,key:b.target.value},u({envRows:k})}}),h.jsx("input",{type:"password",value:v.value,placeholder:v.configured?"•••••• (unchanged)":"value",onChange:b=>{const k=d.slice();k[C]={...v,value:b.target.value},u({envRows:k})}}),h.jsx("button",{className:"nc-btn danger",onClick:()=>u({envRows:d.filter((b,k)=>k!==C)}),children:"×"})]},`${v.key}-${C}`)),h.jsx("button",{className:"nc-btn ghost",onClick:()=>u({envRows:[...d,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>t(null),children:_("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:n||!l.id||l.kind==="custom"&&!l.command||l.kind==="managed"&&(S==null?void 0:S.requiresModel)&&!l.managedModel||l.kind==="managed"&&(S==null?void 0:S.credentialEnv)&&!l.envKey||l.kind==="managed"&&l.provider==="custom"&&(!l.displayName||!l.baseUrl||!l.envKey||!l.providerId),onClick:s,children:_("save")})]})]})}function ik({token:e,route:t,targets:n=[],location:s,setLocation:o,state:l,setState:u,engines:d,busy:p,onSave:m}){const[S,w]=M.useState(null),[y,v]=M.useState(""),C=l.form,b=A=>u({...l,form:{...C,...A}}),k=d.find(A=>A.id===C.engine),N=A=>{var ee,O,F;const B=d.find(Z=>Z.id===A);b({engine:A,model:((ee=C.models)==null?void 0:ee[A])||((O=B==null?void 0:B.managed)==null?void 0:O.model)||((F=B==null?void 0:B.model)==null?void 0:F.value)||""})},L=async A=>{try{const B=await av(e,A,t);w(B),b({cwd:B.path}),v("")}catch(B){v(String(B.message||B))}};return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsx("b",{children:l.mode==="new"?_("fleet-new-cell"):`${_("edit")} ${C.id}`}),l.mode==="new"&&h.jsxs("label",{className:"nc-field",children:[_("location"),h.jsx("span",{className:"nc-req",children:" *"}),h.jsxs("select",{value:s,onChange:A=>{o(A.target.value),b({engine:""})},children:[h.jsx("option",{value:"",children:_("local")}),n.map(A=>h.jsxs("option",{value:A.route.join("/"),disabled:A.status&&A.status!=="up",children:[A.label,A.status&&A.status!=="up"?` · ${_("node-offline")}`:""]},A.route.join("/")))]})]}),h.jsx("input",{value:C.id,disabled:l.mode!=="new",placeholder:"id",onChange:A=>b({id:A.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:C.cwd,placeholder:_("cwd"),onChange:A=>b({cwd:A.target.value})}),h.jsx("button",{className:"nc-btn ghost",onClick:()=>S?w(null):L(C.cwd),children:_("browse")})]}),S&&h.jsxs("div",{className:"nc-fs",children:[h.jsx("div",{className:"nc-fs-path",children:S.path}),h.jsxs("div",{className:"nc-fs-list",children:[S.parent&&h.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>L(S.parent),children:["↑ ",_("fs-parent")]}),(S.dirs||[]).map(A=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>L(`${S.path.replace(/\/$/,"")}/${A}`),children:["📁 ",A]},A))]})]}),y&&h.jsx("div",{className:"nc-err",children:y}),h.jsx("select",{value:C.engine,onChange:A=>N(A.target.value),children:d.map(A=>h.jsx("option",{value:A.id,children:A.label},A.id))}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:!!C.boot,onChange:A=>b({boot:A.target.checked})})," boot"]}),h.jsx("input",{value:C.model||"",list:"nc-cell-models",placeholder:_("fleet-model-override"),onChange:A=>b({model:A.target.value})}),h.jsx("datalist",{id:"nc-cell-models",children:((k==null?void 0:k.availableModels)||[]).map(A=>h.jsx("option",{value:A},A))}),h.jsx("textarea",{value:C.prompt||"",placeholder:"prompt",onChange:A=>b({prompt:A.target.value})}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>u(null),children:_("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:p||!C.id||!C.cwd||!C.engine,onClick:m,children:_("save")})]})]})}function Gg({token:e,route:t=[],state:n,setState:s,busy:o,onSave:l}){const[u,d]=M.useState(null),[p,m]=M.useState([]),[S,w]=M.useState(""),y=Array.isArray(t)?t.join("/"):"";M.useEffect(()=>{let N=!0;return Dh(e,y?y.split("/"):[]).then(L=>{N&&(m(L.engines||[]),w(""))}).catch(L=>{N&&(m([]),w(String(L.message||L)))}),()=>{N=!1}},[e,y]);const v=n.form,C=N=>s({...n,form:{...v,...N}}),b=async N=>{try{const L=await av(e,N,t);d(L),C({cwd:L.path})}catch{}},k=!v.id&&v.tmuxSession?v.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):v.id;return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsxs("b",{children:[_("import-as-cell")," · ",v.tmuxSession]}),h.jsx("small",{children:_("import-help")}),h.jsx("input",{value:v.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),h.jsx("input",{value:v.id,placeholder:_("name"),onChange:N=>C({id:N.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:v.cwd,placeholder:_("cwd"),onChange:N=>C({cwd:N.target.value})}),h.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>u?d(null):b(v.cwd),children:_("browse")})]}),u&&h.jsxs("div",{className:"nc-fs",children:[h.jsx("div",{className:"nc-fs-path",children:u.path}),h.jsxs("div",{className:"nc-fs-list",children:[u.parent&&h.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>b(u.parent),children:["↑ ",_("fs-parent")]}),(u.dirs||[]).map(N=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>b(`${u.path.replace(/\/$/,"")}/${N}`),children:["📁 ",N]},N))]})]}),h.jsxs("select",{value:v.engine,onChange:N=>C({engine:N.target.value}),children:[h.jsx("option",{value:"",children:_("import-engine-required")}),p.map(N=>h.jsx("option",{value:N.id,children:N.label},N.id))]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:!!v.boot,onChange:N=>C({boot:N.target.checked})})," boot"]}),(n.err||S)&&h.jsx("div",{className:"nc-err",children:n.err||S}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:_("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:o||!v.tmuxSession||!v.engine||!p.length,onClick:l,children:_(k?"import-as-cell":"save")})]})]})}function nk({text:e}){const[t,n]=M.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return h.jsxs("div",{className:"nc-set-copyline",children:[h.jsx("code",{children:e}),h.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:s,children:[h.jsx(tt,{name:"copy",size:14})," ",_(t?"copied":"copy")]})]})}function rk({value:e}){const[t,n]=M.useState("");return M.useEffect(()=>{let s=!0;return lx.toDataURL(e,{margin:1,width:220}).then(o=>{s&&n(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?h.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function sk({token:e,nodes:t,settings:n,readonly:s,refresh:o}){const[l,u]=M.useState(null),[d,p]=M.useState(null),[m,S]=M.useState({}),[w,y]=M.useState(null),[v,C]=M.useState({ssh:"",sshPort:"",name:""}),[b,k]=M.useState(""),[N,L]=M.useState(""),[A,B]=M.useState(""),[ee,O]=M.useState(!1),F=Date.now(),Z=n&&n.deviceName||"",W=(t||[]).filter(R=>R&&R.direction==="outbound"&&R.name&&R.ssh),G=W.find(R=>R.name===b)||W[0]||null,K=W.find(R=>R.name===N)||W[0]||null,P=K?Hg(K.tunnel,F):null,E=async(R,H)=>{u(null),p(`${R}:${H}`);try{const I=await jh(e,R,H);H==="test"&&S(q=>({...q,[R]:I})),await o()}catch(I){u(`${R}: ${String(I.message||I)}`)}p(null)},j=async R=>{if(window.confirm(_("node-remove-confirm").replace("{name}",R))){u(null),p(`${R}:remove`);try{await _w(e,R),await o()}catch(H){u(`${R}: ${String(H.message||H)}`)}p(null)}},U=async()=>{if(u(null),G){const I=Fg({name:G.name,ssh:G.ssh,sshPort:G.sshPort||""});if(!I.ok){u(_(I.error));return}p("invite");try{y(await Yp(e,{ssh:I.value.ssh,...I.value.sshPort?{sshPort:I.value.sshPort}:{}},[G.name]))}catch(q){u(String(q.message||q))}p(null);return}const R=Vr(v.name||A||Z||"NexusCrew"),H=Fg({name:R,ssh:v.ssh,sshPort:v.sshPort});if(!H.ok){u(_(H.error));return}p("invite");try{y(await Yp(e,{...A||Z?{label:A||Z}:{},name:R,ssh:H.value.ssh,...H.value.sshPort?{sshPort:H.value.sshPort}:{}}))}catch(I){u(String(I.message||I))}p(null)};return h.jsxs("div",{className:"nc-set-tab",children:[h.jsx(A_,{token:e,deviceDefault:Z,readonly:s,onSuccess:o}),K&&h.jsxs("div",{className:"nc-set-form nc-local-share",children:[h.jsx("div",{className:"nc-sheet-label",children:_("share-local-heading")}),W.length>1&&h.jsxs("label",{className:"nc-field",children:[_("share-local-hub"),h.jsx("select",{value:K.name,disabled:s||!!d,onChange:R=>L(R.target.value),children:W.map(R=>h.jsx("option",{value:R.name,children:R.label||R.name},R.name))})]}),h.jsxs("label",{className:"nc-check nc-node-share",children:[h.jsx("input",{type:"checkbox",checked:K.shared===!0,disabled:s||!!d||!(P!=null&&P.up)&&!K.shared,onChange:async R=>{u(null),p(`${K.name}:share`);try{await yw(e,K.name,R.target.checked),await o()}catch(H){u(`${K.name}: ${String(H.message||H)}`)}p(null)}}),h.jsxs("span",{children:[h.jsx("b",{children:_("share-local-through").replace("{device}",Z||_("local")).replace("{hub}",K.label||K.name)}),h.jsx("small",{children:_(K.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),h.jsx("div",{className:`nc-set-test${K.shared&&(P!=null&&P.up)?" ok":""}`,children:K.shared?_("share-local-active"):_("share-local-private")})]}),(t||[]).length===0&&h.jsx("div",{className:"nc-empty",children:_("no-nodes")}),(t||[]).map(R=>{var q,X,D,Q,se;const H=Hg(R.tunnel,F),I=m[R.name];return h.jsxs("div",{className:"nc-set-node",children:[h.jsxs("div",{className:"nc-set-node-head",children:[h.jsx("span",{className:`nc-dot ${H.up?"on":""}`}),h.jsx("b",{children:R.label||R.name}),h.jsxs("small",{children:[R.name,R.direction==="outbound"?` · SSH ${R.ssh||""}`:` · ${_("node-connected-client")}`,(q=R.tunnel)!=null&&q.transport?` · ${R.tunnel.transport} ${_("transport-used")}`:""]}),h.jsxs("span",{className:`nc-set-tunnel${H.up?" up":""}`,children:[_(H.label),H.since?` · ${H.since}`:""]})]}),R.direction==="inbound"&&h.jsx("div",{className:"nc-set-info",children:_(R.shared?"peer-shared":"peer-private")}),R.direction==="inbound"&&R.shared&&h.jsxs(h.Fragment,{children:[h.jsxs("select",{value:R.visibility||"network",disabled:s||!!d,onChange:async re=>{p(`${R.name}:visibility`);try{await Xp(e,R.name,re.target.value),await o()}catch(ae){u(String(ae.message||ae))}p(null)},children:[h.jsx("option",{value:"network",children:_("visibility-network")}),h.jsx("option",{value:"relay-only",children:_("visibility-relay")}),h.jsx("option",{value:"selected",children:_("visibility-selected")})]}),R.visibility==="selected"&&h.jsx("div",{className:"nc-set-row",children:(t||[]).filter(re=>re.name!==R.name&&re.nodeId).map(re=>{const ae=(R.selected||[]).includes(re.nodeId);return h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:ae,disabled:s||!!d,onChange:async le=>{const de=le.target.checked?[...R.selected||[],re.nodeId]:(R.selected||[]).filter(ve=>ve!==re.nodeId);p(`${R.name}:visibility`);try{await Xp(e,R.name,"selected",de),await o()}catch(ve){u(String(ve.message||ve))}p(null)}})," ",re.label||re.name]},re.nodeId)})})]}),h.jsxs("div",{className:"nc-set-node-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!d,onClick:async()=>{const re=window.prompt(_("node-display-label"),R.label||R.name);if(re!=null){if(!bh(re)){u(_("err-label"));return}p(`${R.name}:label`);try{await vw(e,R.name,re),await o()}catch(ae){u(String(ae.message||ae))}p(null)}},children:_("edit")}),((X=R.health)==null?void 0:X.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(R.name,"test"),children:_("node-test")}),((D=R.health)==null?void 0:D.managed)!==!1&&(H.up?h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(R.name,"down"),children:_("tunnel-stop")}):h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(R.name,"up"),children:_("tunnel-start")})),((Q=R.health)==null?void 0:Q.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(R.name,"restart"),children:_("tunnel-restart")}),h.jsx("button",{type:"button",className:"nc-btn danger",disabled:s||!!d,title:_(s?"settings-readonly":"terminate"),onClick:()=>j(R.name),children:h.jsx(tt,{name:"trash",size:14})})]}),((se=R.health)==null?void 0:se.detail)&&h.jsx("div",{className:`nc-set-test${R.health.status==="healthy"?" ok":R.health.status==="passive"?"":" ko"}`,children:R.health.detail}),I&&h.jsxs("div",{className:`nc-set-test${I.ok?" ok":" ko"}`,children:[I.result,I.detail?` — ${I.detail}`:""]})]},R.name)}),h.jsxs("div",{className:"nc-set-form",children:[h.jsx("div",{className:"nc-sheet-label",children:_("invite-node")}),h.jsx("small",{className:"nc-set-hint",children:_(G?"invite-network-hint":"invite-v2-hint")}),G?h.jsxs(h.Fragment,{children:[W.length>1&&h.jsxs("label",{className:"nc-field",children:[_("invite-network-label"),h.jsx("select",{value:G.name,disabled:s||!!d,onChange:R=>{k(R.target.value),y(null)},children:W.map(R=>h.jsx("option",{value:R.name,children:R.label||R.name},R.name))})]}),h.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[_("invite-network-via"),": ",h.jsx("b",{children:G.label||G.name})," · ",G.ssh,G.sshPort?`:${G.sshPort}`:""]}),h.jsx("small",{className:"nc-set-hint",children:_("invite-network-route")})]}):h.jsxs("label",{className:"nc-field",children:[_("invite-endpoint-label"),h.jsx("input",{placeholder:"user@host",value:v.ssh,disabled:s,onChange:R=>C({...v,ssh:R.target.value})}),h.jsx("small",{className:"nc-set-hint",children:_("invite-endpoint-needed")})]}),!G&&ee&&h.jsxs("div",{className:"nc-invite-advanced",children:[h.jsxs("label",{className:"nc-field",children:[_("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:"22",value:v.sshPort,disabled:s,onChange:R=>C({...v,sshPort:R.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),h.jsxs("label",{className:"nc-field",children:[_("device-name-label"),h.jsx("input",{placeholder:Z||"NexusCrew",value:A,disabled:s,onChange:R=>B(R.target.value)}),h.jsx("small",{className:"nc-set-hint",children:_("device-name-hint")})]}),h.jsxs("label",{className:"nc-field",children:[_("node-name-label"),h.jsx("input",{placeholder:Vr(A||Z||_("node-name-ph")),value:v.name,disabled:s,onChange:R=>C({...v,name:R.target.value?Vr(R.target.value):""})})]})]}),h.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[h.jsx("button",{type:"button",className:"nc-btn primary",disabled:s||!!d||!G&&!v.ssh.trim(),onClick:U,children:_("create-pairing-link")}),!G&&h.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>O(R=>!R),children:[ee?"▾":"▸"," ",_("pair-advanced")]})]}),w&&h.jsxs(h.Fragment,{children:[h.jsx(rk,{value:w.pairingUrl}),h.jsx(nk,{text:w.pairingUrl}),h.jsx("div",{className:"nc-set-info",children:_("invite-next-steps")})]})]}),l&&h.jsx("div",{className:"nc-err",children:l})]})}function ok({token:e,readonly:t}){const[n,s]=M.useState("idle"),[o,l]=M.useState(!1),[u,d]=M.useState(null);M.useEffect(()=>{let m=!1;return Mx().then(S=>{m||s(S)}),()=>{m=!0}},[]);const p=async()=>{d(null),l(!0);try{n==="subscribed"?(await jx(e),s("idle")):(await Lx(e),s("subscribed"))}catch(m){const S=String(m.message||m);S==="push-denied"?(s("denied"),d(_("push-denied"))):S==="push-unsupported"?(s("unsupported"),d(_("push-unsupported"))):d(S)}l(!1)};return n==="unsupported"?h.jsx("div",{className:"nc-set-info",children:_("push-unsupported")}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||o||n==="denied",title:t?_("settings-readonly"):"",onClick:p,children:_(n==="subscribed"?"push-disable":"push-enable")}),h.jsx("span",{className:"nc-set-info",children:_(n==="subscribed"?"push-on":n==="denied"?"push-denied":"push-off")})]}),u&&h.jsx("div",{className:"nc-err",children:u})]})}function ak({token:e,settings:t,readonly:n,refresh:s}){const[o,l]=M.useState(null),[u,d]=M.useState(null),[p,m]=M.useState(!1),[S,w]=M.useState(!1),[y,v]=M.useState(null),[C,b]=M.useState(!0);M.useEffect(()=>{v(t&&t.update||null),b(!t||t.autoUpdate!==!1)},[t]);const k=async()=>{l(null),d(null),w(!0);try{const O=await mw(e);d(O.note||"ok"),m(!1)}catch(O){l(String(O.message||O))}w(!1)},N=async()=>{l(null),d(null),w(!0);try{const O=await Sw(e);d(`${O.note||"ok"}${O.target?` (${O.target})`:""}`)}catch(O){l(String(O.message||O))}w(!1)},L=async O=>{l(null),d(null),w(!0);try{await hv(e,{autoUpdate:O}),b(O),s&&await s()}catch(F){l(String(F.message||F))}w(!1)},A=async()=>{l(null),d(null),w(!0);try{v(await ww(e))}catch(O){l(String(O.message||O))}w(!1)},B=async()=>{l(null),d(null),w(!0);try{const O=await bw(e);v(O),d(_("npm-update-restarting"))}catch(O){l(String(O.message||O))}w(!1)},ee=t&&t.service;return h.jsxs("div",{className:"nc-set-tab",children:[t&&h.jsxs("div",{className:"nc-set-info",children:["v",t.version," · ",t.platform," · :",t.port,h.jsx("br",{}),ee&&ee.installed?_("service-installed"):_("service-missing"),ee&&ee.installed?` · ${ee.active?_("service-active"):_("service-inactive")}`:"",ee?` · boot ${ee.boot?"on":"off"}`:""]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||S,title:n?_("settings-readonly"):"",onClick:()=>{l(null),d(null),m(!0)},children:_("token-rotate")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||S,title:n?_("settings-readonly"):"",onClick:N,children:_("service-regenerate")})]}),h.jsxs("div",{className:"nc-set-form nc-update-settings",children:[h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:C,disabled:n||S||y&&!y.supported,onChange:O=>L(O.target.checked)}),h.jsxs("span",{children:[h.jsx("b",{children:_("npm-auto-update")}),h.jsx("small",{children:_("npm-auto-update-help")})]})]}),y&&h.jsxs("div",{className:"nc-set-info",children:[_("npm-update-current")," v",y.current,y.latest?` · ${_("npm-update-latest")} v${y.latest}`:""," · ",_(`npm-update-${y.supported?y.phase:"unsupported"}`)]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||S||!y||!y.supported,onClick:A,children:_("npm-update-check")}),y&&y.available&&h.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||S||y.phase==="installing",onClick:B,children:_("npm-update-install")})]}),y&&y.lastError&&h.jsx("div",{className:"nc-err",children:y.lastError})]}),h.jsx(ok,{token:e,readonly:n}),p&&h.jsxs("div",{className:"nc-set-confirm",children:[h.jsx("div",{children:_("token-rotate-explain")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:S,onClick:()=>m(!1),children:_("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:S,onClick:k,children:_("confirm")})]})]}),u&&h.jsx("div",{className:"nc-set-note",children:u}),o&&h.jsx("div",{className:"nc-err",children:o})]})}function lk({token:e,onClose:t,initialTab:n="nodes",initialLocation:s="",startNewCell:o=!1}){Si();const[l,u]=M.useState(n),[d,p]=M.useState(null),[m,S]=M.useState([]),[w,y]=M.useState(!1),[v,C]=M.useState(null),b=Ah(e),k=M.useCallback(async()=>{try{const N=await lv(e);p(N),C(null)}catch(N){C(String(N.message||N))}try{const N=await cv(e);S(N.nodes||[])}catch(N){C(String(N.message||N))}},[e]);return M.useEffect(()=>{k();const N=setInterval(k,5e3);return()=>clearInterval(N)},[k]),M.useEffect(()=>{let N=!1;return zt("/api/config",e).then(L=>L.json()).then(L=>{N||y(!!L.readonlyDefault)}).catch(()=>{}),()=>{N=!0}},[e]),h.jsx("div",{className:"nc-set-overlay",onClick:t,children:h.jsxs("div",{className:"nc-set-panel",onClick:N=>N.stopPropagation(),children:[h.jsxs("div",{className:"nc-set-head",children:[h.jsx(tt,{name:"gear",size:18}),h.jsx("b",{children:_("settings")}),h.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:_("close"),children:h.jsx(tt,{name:"x",size:18})})]}),w&&h.jsx("div",{className:"nc-set-readonly",children:_("settings-readonly")}),v&&h.jsx("div",{className:"nc-err",children:v}),h.jsx("div",{className:"nc-set-tabs",children:["nodes","fleet","system"].map(N=>h.jsx("button",{type:"button",className:`nc-set-tabbtn${l===N?" on":""}`,onClick:()=>u(N),children:_(`tab-${N}`)},N))}),h.jsxs("div",{className:"nc-set-body",children:[l==="nodes"&&h.jsx(sk,{token:e,nodes:m,settings:d,readonly:w,refresh:k}),l==="fleet"&&h.jsx(Zx,{token:e,readonly:w,startNewCell:o,initialLocation:s,targets:b.map(N=>({route:N.route,label:N.label||N.name,status:N.status}))}),l==="system"&&h.jsx(ak,{token:e,settings:d,readonly:w,refresh:k})]})]})})}function ck({token:e,initialPair:t,onPairDone:n,onDone:s}){Si();const[o,l]=M.useState(t?"pair":"welcome"),[u,d]=M.useState(!1),[p,m]=M.useState(null),S=async()=>{d(!0),m(null);try{await hv(e,{wizardDone:!0}),n&&n(),s()}catch(w){m(String(w.message||w)),d(!1)}};return h.jsx("div",{className:"nc-wiz-overlay",children:h.jsxs("div",{className:"nc-wiz",children:[h.jsxs("div",{className:"nc-wiz-head",children:[h.jsx("b",{children:_("wizard-title")}),h.jsx("small",{children:_("hydra-simple")})]}),o==="welcome"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:_("local-ready")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:u,onClick:S,children:_("local-only")}),h.jsx("button",{className:"nc-btn primary",disabled:u,onClick:()=>l("pair"),children:_("add-node")})]})]}),o==="pair"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx(A_,{token:e,initial:t||"",autoStart:!!t,onBusyChange:d,onSuccess:async()=>{n&&n(),l("done")}}),h.jsx("div",{className:"nc-sheet-actions",children:h.jsx("button",{className:"nc-btn ghost",disabled:u,onClick:()=>{n&&n(),l("welcome")},children:_("back")})})]}),o==="done"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:_("node-connected")}),h.jsx("div",{className:"nc-sheet-actions",children:h.jsx("button",{className:"nc-btn primary",disabled:u,onClick:S,children:_("finish")})})]}),p&&h.jsx("div",{className:"nc-err",children:p})]})})}function uk(e,t){if(typeof EventSource>"u"||!e)return()=>{};const n=new EventSource(`/api/events?token=${encodeURIComponent(e)}`);return n.onmessage=s=>{try{const o=JSON.parse(s.data);o&&typeof o=="object"&&typeof o.type=="string"&&t(o)}catch{}},()=>{try{n.close()}catch{}}}const hk=6e3,dk=12e3;function fk({n:e,onClose:t}){return h.jsxs("div",{className:`nc-ntf-toast${e.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[h.jsxs("div",{className:"nc-ntf-toast-txt",children:[h.jsx("b",{children:e.title}),e.body&&h.jsx("small",{children:e.body}),e.session&&h.jsx("span",{className:"nc-ntf-from",children:e.session})]}),h.jsx("button",{type:"button",className:"nc-ntf-x",onClick:t,title:_("close"),children:h.jsx(tt,{name:"x",size:14})})]})}function pk({ask:e,token:t,onAnswered:n}){const[s,o]=M.useState(""),[l,u]=M.useState(!1),[d,p]=M.useState(null),m=async S=>{const w=String(S||"").trim();if(!(!w||l)){p(null),u(!0);try{await xw(t,e.id,w),n(e.id)}catch(y){p(String(y.message||y))}u(!1)}};return h.jsxs("div",{className:"nc-ask-card",children:[h.jsxs("div",{className:"nc-ask-head",children:[h.jsx("span",{className:"nc-ntf-from",children:e.session}),h.jsxs("code",{className:"nc-ask-id",children:["#",e.id]})]}),h.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&h.jsx("div",{className:"nc-ask-opts",children:e.options.map(S=>h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:l,onClick:()=>m(S),children:S},S))}),h.jsxs("div",{className:"nc-ask-reply",children:[h.jsx("textarea",{rows:2,placeholder:_("ask-reply-ph"),value:s,disabled:l,onChange:S=>o(S.target.value)}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:l||!s.trim(),onClick:()=>m(s),children:_("send")})]}),d&&h.jsx("div",{className:"nc-err",children:d})]})}function mk({token:e}){Si();const[t,n]=M.useState([]),[s,o]=M.useState([]),[l,u]=M.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),d=M.useRef(0),p=M.useCallback(w=>{n(y=>y.filter(v=>v.key!==w))},[]),m=M.useCallback(w=>{const y=`t${d.current+=1}`;n(v=>[...v.slice(-3),{...w,key:y}]),setTimeout(()=>p(y),w.urgency==="high"?dk:hk)},[p]);M.useEffect(()=>{if(!e)return;let w=!1;Cw(e).then(v=>{w||o(v.asks||[])}).catch(()=>{});const y=uk(e,v=>{v.type==="notify"?m(v):v.type==="ask"&&v.ask&&v.ask.id?o(C=>C.some(b=>b.id===v.ask.id)?C:[...C,v.ask]):v.type==="ask-answered"&&v.id&&o(C=>C.filter(b=>b.id!==v.id))});return()=>{w=!0,y()}},[e,m]);const S=w=>o(y=>y.filter(v=>v.id!==w));return h.jsxs(h.Fragment,{children:[t.length>0&&h.jsx("div",{className:"nc-ntf-toasts",children:t.map(w=>h.jsx(fk,{n:w,onClose:()=>p(w.key)},w.key))}),s.length>0&&!l&&h.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>u(!0),title:_("asks-title"),children:["? ",h.jsx("span",{className:"nc-ask-count",children:s.length})]}),s.length>0&&l&&h.jsxs("div",{className:"nc-ask-panel",children:[h.jsxs("div",{className:"nc-ask-panel-head",children:[h.jsx("b",{children:_("asks-title")}),h.jsx("span",{className:"nc-ask-count",children:s.length}),h.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>u(!1),title:_("close"),children:h.jsx(tt,{name:"x",size:16})})]}),h.jsx("div",{className:"nc-ask-panel-body",children:s.map(w=>h.jsx(pk,{ask:w,token:e,onAnswered:S},w.id))})]})]})}const Mu=e=>Ji(lr(e)).length===0,Lu=e=>Array.isArray(e)?e.join("/"):"";function gk(e){const t=new Set,n=[];for(const s of Array.isArray(e)?e:[])!s||!zi.test(String(s.instanceId||""))||!Array.isArray(s.route)||!s.route.length||t.has(s.instanceId)||(t.add(s.instanceId),n.push({instanceId:s.instanceId,route:[...s.route],label:String(s.label||s.name||s.route.join(" › ")),status:s.status||"offline"}));return n.sort((s,o)=>s.label.localeCompare(o.label))}function Ws(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function ir(e,t,n,s=!1,o=!0){const l=t.instanceId;return{...e,id:qr(s?null:l,e.name),ownerId:l,ownerRoute:s?[]:[...t.route],ownerLabel:s?"Local":t.label,local:s,available:o,ownerTopology:Array.isArray(n)?n:[],layout:yh(e.layout,l,n)}}function vk(e,t,n,s,o=[]){const[l,u]=M.useState([]),[d,p]=M.useState(!1),[m,S]=M.useState("idle"),[w,y]=M.useState(""),[v,C]=M.useState(""),b=M.useRef([]),k=M.useRef([]),N=M.useRef(""),L=M.useRef(t),A=M.useRef(n),B=M.useRef(!1),ee=M.useRef(!0),O=M.useRef(""),F=M.useMemo(()=>gk(o),[o]),Z=F.map(q=>`${q.instanceId}:${Lu(q.route)}:${q.status}:${q.label}`).join("|");k.current=F,A.current=n,L.current=t,b.current=l;const W=M.useCallback(q=>Sh(q.layout,N.current,k.current),[]),G=M.useCallback((q,X=!0,D=L.current)=>{const Q=b.current.some(re=>re.id===D);b.current=q,u(q);const se=q.find(re=>re.id===D);if(X&&se){ee.current=!0;const re=W(se);s(re),se.local&&OC(se.name,re)}else Q&&!se&&(ee.current=!0,s(Kr()),y("deck non più condiviso dal nodo owner"));IC(q.filter(re=>re.local).map(re=>re.name))},[s,W]),K=M.useCallback(async q=>{let X=await pa(e);const D=X.decks.find(Q=>Q.name==="main");if(X.decks.length===1&&D&&D.revision===0&&Mu(D.layout)){const Q=AC(),se=lr(wh("main")||Kr());if(!Mu(se)){const re=yh(se,q,[]);X.decks[0]=await ma(e,"main",re,0,[])}for(const re of Q.filter(ae=>ae!=="main"))try{let ae=await Gp(e,re,[]);const le=lr(wh(re)||Kr());Mu(le)||(ae=await ma(e,re,yh(le,q,[]),ae.revision,[]))}catch{}X=await pa(e)}return X},[e]),P=M.useCallback(async({migrate:q=!1}={})=>{const X=await Lh(e,[]),D=zi.test(String(X.instanceId||""))?X.instanceId:"";if(!D)throw new Error("instanceId locale non disponibile");N.current=D,C(D);const[Q,se]=await Promise.all([q?K(D):pa(e),Vp(e,[]).catch(()=>({nodes:[]}))]),re={instanceId:D,route:[],label:"Local"},ae=Q.decks.map(de=>ir(de,re,se.nodes,!0,!0)),le=b.current;return await Promise.all(k.current.map(async de=>{if(de.status!=="up"){ae.push(...le.filter(ve=>!ve.local&&ve.ownerId===de.instanceId).map(ve=>({...ve,ownerRoute:[...de.route],ownerLabel:de.label,available:!1})));return}try{const[ve,Re]=await Promise.all([pa(e,de.route),Vp(e,de.route).catch(()=>({nodes:[]}))]);ae.push(...ve.decks.map(Fe=>ir(Fe,de,Re.nodes,!1,!0)))}catch{ae.push(...le.filter(Re=>!Re.local&&Re.ownerId===de.instanceId).map(Re=>({...Re,ownerRoute:[...de.route],ownerLabel:de.label,available:!1})))}})),ae.sort((de,ve)=>de.local===ve.local?de.ownerLabel.localeCompare(ve.ownerLabel)||(de.name==="main"?-1:ve.name==="main"?1:de.name.localeCompare(ve.name)):de.local?-1:1),ae},[e,K,Z]);M.useEffect(()=>{if(!e)return;let q=!1;const X=O.current!==e;return O.current=e,P({migrate:X}).then(D=>{if(q)return;const Q=b.current.find(ae=>ae.id===L.current),se=D.find(ae=>ae.id===L.current),re=se&&(!Q||se.revision>Q.revision||Q.available!==se.available||Lu(Q.ownerRoute)!==Lu(se.ownerRoute));G(D,X||!!re&&!B.current),p(!0),se&&y("")}).catch(D=>{q||(p(!0),y(String(D.message||D)))}),()=>{q=!0}},[G,P,Z,e]);const E=M.useCallback(async(q=L.current)=>{if(!d||!B.current)return!0;const X=b.current.find(D=>D.id===q);if(!X)return y(`deck inesistente: ${q}`),!1;if(X.available===!1)return y(`nodo owner offline: ${X.ownerLabel}`),!1;S("saving");try{const D=cg(lr(A.current),X.ownerId,X.ownerTopology),Q=await ma(e,X.name,D,X.revision,X.ownerRoute),se=ir(Q,Ws(X),X.ownerTopology,X.local,!0);return G(b.current.map(re=>re.id===q?se:re),!1),B.current=!1,S("saved"),y(""),setTimeout(()=>S("idle"),1500),!0}catch(D){if(S("error"),y(String(D.message||D)),D.status===409&&D.data&&D.data.current){const Q=b.current.find(re=>re.id===q),se=ir(D.data.current,Ws(Q),Q.ownerTopology,Q.local,!0);G(b.current.map(re=>re.id===q?se:re),!1)}return!1}},[d,e,G]);return M.useEffect(()=>{if(!d)return;if(ee.current){ee.current=!1;return}B.current=!0,S("saving");const q=setTimeout(E,650);return()=>clearTimeout(q)},[n,d,E]),M.useEffect(()=>{if(!d)return;const q=setInterval(async()=>{try{const X=await P(),D=b.current.find(re=>re.id===L.current),Q=X.find(re=>re.id===L.current),se=Q&&(!D||Q.revision>D.revision||D.available!==Q.available);G(X,se&&!B.current)}catch{}},5e3);return()=>clearInterval(q)},[d,P,G]),{decks:l,records:l,localNodeId:v,ready:d,saveState:m,error:w,setError:y,saveNow:E,select:async q=>{if(B.current&&!await E(L.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const X=b.current.find(D=>D.id===q);if(!X)throw new Error(`deck inesistente: ${q}`);return B.current=!1,ee.current=!0,W(X)},add:async(q,X=null)=>{const D=X===qa?b.current.find(re=>re.local):X?b.current.find(re=>re.ownerId===X):null;if(!D||D.available===!1)throw new Error("nodo owner non disponibile");const Q=await Gp(e,q,D.ownerRoute),se=ir(Q,Ws(D),D.ownerTopology,D.local,!0);return G([...b.current,se],!1),se},rename:async(q,X)=>{const D=b.current.find(ae=>ae.id===q);if(!D)throw new Error("deck inesistente");if(q===L.current&&B.current&&!await E(q))throw new Error(`salvataggio di "${D.name}" fallito: rinomina annullata`);const Q=b.current.find(ae=>ae.id===q);if(!Q)throw new Error("deck inesistente");const se=await kw(e,Q.name,X,Q.revision,Q.ownerRoute),re=ir(se,Ws(Q),Q.ownerTopology,Q.local,!0);return G(b.current.map(ae=>ae.id===q?re:ae),!1),re},remove:async q=>{const X=b.current.find(D=>D.id===q);if(!X)throw new Error("deck inesistente");q===L.current&&(B.current=!1),await Ew(e,X.name,X.revision,X.ownerRoute),G(b.current.filter(D=>D.id!==q),!1)},addTileTo:async(q,X)=>{const D=b.current.find(de=>de.id===q);if(!D)throw new Error("deck inesistente");if(D.available===!1)throw new Error(`nodo owner offline: ${D.ownerLabel}`);const Q=E_(X,N.current,k.current);if(!Q)throw new Error("riferimento sessione non valido");const se=W(D),re=cg(C_(se,Q),D.ownerId,D.ownerTopology),ae=await ma(e,D.name,re,D.revision,D.ownerRoute),le=ir(ae,Ws(D),D.ownerTopology,D.local,!0);return G(b.current.map(de=>de.id===q?le:de),!1),le},localMainId:qr(null,"main"),parseDeckId:k_}}const _k="/sw.js",Ch="nc-sw-update";let xh=null,kh=!1,Eh=null,K_=Object.freeze({needed:!1,kind:null,version:""}),q_=!1;function V_(){typeof window<"u"&&window.dispatchEvent(new Event(Ch))}function Y_(){const e=Eh||(kh?{kind:"reload",version:""}:null);K_=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function Qg(){return K_}function yk(e){return typeof window>"u"?()=>{}:(window.addEventListener(Ch,e),()=>window.removeEventListener(Ch,e))}function Zh(e){kh!==e&&(kh=e,Y_(),V_())}function Sk(e,t,n){let s=null;e&&t&&e!==t?s={kind:"install",version:e}:t&&n&&t!==n&&(s={kind:"reload",version:t});const o=JSON.stringify(s)===JSON.stringify(Eh);Eh=s,Y_(),o||V_()}function wk(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&Zh(!0)})}function bk(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{q_&&location.reload()}),navigator.serviceWorker.register(_k).then(e=>{xh=e,e.waiting&&Zh(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&wk(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function Ck(){q_=!0,Zh(!1);const e=xh&&xh.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function xk({hash:e="",origin:t="",pathname:n="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),l=`${n||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:l};const u=new URLSearchParams(o),d=u.get("token")||"",p=u.get("pair")||"",m=p?`${t||""}${n||""}#pair=${p}`:"";return{token:d,pair:m,nextUrl:l}}const X_=9,G_=24,Q_="nc_side_w",Jg="nc_side_min",kk=240,Zg="(min-width:1024px) and (pointer:fine)";function Ek(){const e=Number(localStorage.getItem(Q_));return e>=180&&e<=480?e:kk}function Nk(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=X_&&e<=G_?e:13}function Rk(){const e={token:"",pair:""};try{const{token:t,pair:n,nextUrl:s}=xk({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(t){e.token=t;try{localStorage.setItem("nc_token",t)}catch{}}if(n){e.pair=n;try{sessionStorage.setItem("nc_pair",n)}catch{}}if(location.hash)try{history.replaceState(null,"",s)}catch{}}catch{}if(e.token||(e.token=sessionStorage.getItem("nc_token")||localStorage.getItem("nc_token")||""),!e.pair){const t=sessionStorage.getItem("nc_pair");t&&(e.pair=t)}return e}function Pk(e){try{return lr(wh(e))}catch{return Kr()}}function ev(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 Dk(){const[e,t]=M.useState(()=>window.matchMedia(Zg).matches);return M.useEffect(()=>{const n=window.matchMedia(Zg),s=o=>t(o.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),e}function tv({session:e,node:t,token:n,readonly:s=!1,onBack:o}){Si();const[l,u]=M.useState(!1),[d,p]=M.useState(()=>window.matchMedia("(pointer: coarse)").matches),[m,S]=M.useState(null),[w,y]=M.useState(Nk),[v,C]=M.useState(""),b=W=>y(G=>{const K=Math.max(X_,Math.min(G_,G+W));return localStorage.setItem("nc_fontsize",String(K)),K}),k=M.useRef(()=>{}),N=M.useRef(()=>!1),L=M.useRef(()=>{}),A=M.useRef(!1),[B,ee]=M.useState(!1),[O,F]=M.useState(!1),Z=()=>{A.current=!A.current,ee(A.current)};return M.useEffect(()=>{let W=!0;const G=t?t.split("/"):[],K=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function P(){let j=null,U=null;try{const I=await(await zt(`${K}/sessions`,n)).json();Array.isArray(I.sessions)&&(j=I.sessions.find(q=>q.name===e))}catch{}try{const H=await hr(n,G);H.available&&Array.isArray(H.cells)&&(U=H.cells.find(I=>I.tmuxSession===e))}catch{}if(!W)return;let R="";U?R=`${U.engine}${U.key?`·${U.key}`:""}`:j&&(R=j.attached?`attached · ${ev(j.activity)}`:j.activity?ev(j.activity):""),C(R)}P();const E=setInterval(P,4e3);return()=>{W=!1,clearInterval(E)}},[e,t,n]),h.jsxs("div",{className:"nc-app",children:[h.jsxs("header",{className:"nc-bar nc-bar-single",children:[h.jsxs("button",{onClick:o,title:_("sessions"),children:[h.jsx(tt,{name:"chevronLeft",size:18}),h.jsx("span",{className:"nc-bar-label",children:_("sessions")})]}),h.jsxs("span",{className:"nc-bar-center",children:[h.jsx("b",{children:t?`${t}:${e}`:e}),v&&h.jsx("small",{className:"nc-bar-sub",children:v})]}),h.jsxs("span",{className:"nc-bar-right",children:[h.jsx("button",{onClick:()=>b(-1),title:_("zoom-out"),children:h.jsx(tt,{name:"zoomOut",size:18})}),h.jsx("button",{onClick:()=>b(1),title:_("zoom-in"),children:h.jsx(tt,{name:"zoomIn",size:18})}),h.jsx("button",{onClick:()=>p(W=>!W),title:_("composer"),children:h.jsx(tt,{name:"keyboard",size:20})}),h.jsx("button",{onClick:()=>u(W=>!W),title:_("files"),children:h.jsx(tt,{name:"folder",size:20})})]})]}),h.jsx("div",{className:"nc-termwrap",children:h.jsx(v_,{session:e,node:t,token:n,readonly:s,takeSize:!0,sendRef:k,composerRef:N,actionRef:L,ctrlRef:A,setCtrlArmed:ee,onFiles:S,fontSize:w,selectionMode:O,onSelectionModeChange:F})}),h.jsx(uC,{onKeyboard:()=>p(W=>!W),send:W=>k.current(W),action:W=>L.current(W),ctrlArmed:B,onCtrl:Z,selectionMode:O,onSelectionMode:F}),d&&h.jsx(y_,{submitText:W=>N.current(W),token:n,session:e,node:t}),l&&h.jsx(__,{session:e,node:t,token:n,filesEvent:m,onClose:()=>u(!1)})]})}function Mk(){Si();const[e]=M.useState(Rk),[t,n]=M.useState(e.token),[s,o]=M.useState(e.pair||""),l=M.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[u,d]=M.useState(!1),p=Dk(),[m]=M.useState(()=>BC(typeof location<"u"?location.pathname:"/")),[S,w]=M.useState(m.id),y=S===qr(null,yi),[v,C]=M.useState(null),b=ce=>C(Hn(ce)),[k,N]=M.useState([]),[L,A]=M.useState([]),[B,ee]=M.useState(()=>m.ownerId?Kr():Pk(m.name)),[O,F]=M.useState(null),[Z,W]=M.useState(null),G=ce=>W(Hn(ce)),K=Ah(t,p),P=M.useMemo(()=>(K||[]).filter(ce=>ce.instanceId).map(ce=>({instanceId:ce.instanceId,route:ce.route,label:ce.label,status:ce.status})),[K]),E=vk(t,S,B,ee,P),j=E.decks;M.useEffect(()=>{const ce=new Map;for(const De of K||[]){const Ke=(De.route||[De.name]).join("/"),Mt=new Set((De.sessions||[]).map(hi=>hi.name));for(const hi of De.cells||[])!hi.cell||!hi.tmuxSession||hi.cell===hi.tmuxSession||Mt.has(hi.cell)||ce.set(`${Ke}:${hi.cell}`,`${Ke}:${hi.tmuxSession}`)}ee(De=>wC(De,ce))},[K]),M.useEffect(()=>{E.localNodeId&&ee(ce=>{const De=Sh(ce,E.localNodeId,P);return JSON.stringify(De)===JSON.stringify(ce)?ce:De})},[P,E.localNodeId]);const[U,R]=M.useState(null),[H,I]=M.useState(!1),[q,X]=M.useState(Ek),[D,Q]=M.useState(!y),[se,re]=M.useState(()=>y?localStorage.getItem(Jg)==="1":!0),[ae,le]=M.useState(!1),[de,ve]=M.useState("nodes"),[Re,Fe]=M.useState(!1),[te,ie]=M.useState(""),ye=(ce="nodes",De=!1,Ke="")=>{ve(ce),Fe(De),ie(Ke),le(!0)},[Le,je]=M.useState(!1),[Y,he]=M.useState(!1);M.useEffect(()=>{try{localStorage.setItem(Q_,String(q))}catch{}},[q]),M.useEffect(()=>{try{localStorage.setItem(Jg,se?"1":"")}catch{}},[se]),M.useEffect(()=>{if(!t)return;let ce=!1;return Promise.all([lv(t),zt("/api/config",t).then(De=>De.json())]).then(([De,Ke])=>{ce||(he(!!Ke.readonlyDefault),(De.firstRun===!0&&!Ke.readonlyDefault||s)&&je(!0))}).catch(()=>{}),()=>{ce=!0}},[t,s]);const we=M.useCallback(async()=>{try{const De=await(await zt("/api/sessions",t)).json();De.error||N(De.sessions||[])}catch{}try{const ce=await hr(t);A(ce.available?ce.cells||[]:[])}catch{A([])}},[t]);M.useEffect(()=>{if(!p)return;we();const ce=setInterval(we,4e3);return()=>clearInterval(ce)},[p,we]),M.useEffect(()=>{let ce=!1;return zt("/api/config",t).then(De=>De.json()).then(De=>{ce||Sk(De.version,De.uiVersion,"0.8.14")}).catch(()=>{}),()=>{ce=!0}},[t]);const $=new Set([...k.map(ce=>ce.name),...K.flatMap(ce=>ce.sessions.map(De=>De.key))]),fe=Ji(B),Ce=ce=>ee(De=>{const Ke=E_(ce,E.localNodeId,P)||ce,Mt=C_(De,Ke);return Mt===De&&Ji(De).length>=9&&E.setError(_("grid-full")),Mt}),Ee=async(ce,De=[])=>{try{await Mh(t,ce,De)}catch{return}const Ke=De.length?`${De.join("/")}:${ce}`:ce;ee(Mt=>Ka(Mt,Ke)),we()},Ae=async(ce,De,Ke=[])=>{try{await ov(t,ce,De,Ke)}catch{return}we()},mt=async ce=>{if(!U)return;const{cell:De}=U,Ke=Array.isArray(U.route)?U.route:[];ce.action==="up"?await Ph(t,{cell:De,boot:!!ce.boot,...ce.engine?{engine:ce.engine}:{},...ce.model!==void 0?{model:ce.model}:{},...ce.permissionPolicy?{permissionPolicy:ce.permissionPolicy}:{}},Ke):await ja(t,{cell:De,boot:!!ce.boot},Ke),we()},rt=async ce=>{if(!(!(ce!=null&&ce.direct)||H)){I(!0);try{await jh(t,ce.name,ce.tunnelStatus==="up"?"down":"up")}finally{I(!1)}}},Be=ce=>{const De=j.find(Ke=>Ke.id===ce);if(!De)return!1;try{const Ke=window.open(au(De,t),"_blank");return Ke&&(Ke.opener=null),!!Ke}catch{return!1}},We=async ce=>{if(!ce||ce===S)return;const De=await E.select(ce),Ke=E.records.find(Mt=>Mt.id===ce);w(ce),ee(De),F(null),W(null);try{history.replaceState(null,"",au(Ke||ce,null))}catch{}},Ie=async(ce,De)=>{const Ke=await E.add(ce,De);await We(Ke.id)},bt=async(ce,De)=>{const Ke=await E.rename(ce,De);if(ce===S){w(Ke.id),ee(Sh(Ke.layout,E.localNodeId,P)),F(null),W(null);try{history.replaceState(null,"",au(Ke,null))}catch{}}},Ge=async ce=>{await E.remove(ce),ce===S&&await We(E.localMainId)},me=async(ce,De)=>{!De||De===S||(await E.addTileTo(De,ce),ee(Ke=>Ka(Ke,ce)))};if(!t)return h.jsxs("div",{className:"nc-auth",children:[h.jsx("p",{children:_("auth-prompt")}),h.jsx("input",{onChange:ce=>n(ce.target.value.trim()),placeholder:"token"}),h.jsxs("label",{children:[h.jsx("input",{type:"checkbox",checked:u,onChange:ce=>d(ce.target.checked)})," ",_("remember-device")]}),h.jsx("button",{onClick:()=>{(u?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const qe=h.jsxs(h.Fragment,{children:[ae&&h.jsx(lk,{token:t,initialTab:de,initialLocation:te,startNewCell:Re,onClose:()=>{le(!1),Fe(!1),ie("")}}),Le&&h.jsx(ck,{token:t,initialPair:s,onPairDone:l,onDone:()=>je(!1)}),h.jsx(mk,{token:t})]});if(!p)return v?h.jsxs(h.Fragment,{children:[h.jsx(tv,{session:v.session,node:v.node,token:t,readonly:Y,onBack:()=>C(null)}),qe]}):h.jsxs(h.Fragment,{children:[h.jsx(zw,{onPick:b,token:t,onSettings:ye}),qe]});const et=y||!D;return h.jsxs("div",{className:"nc-workspace",children:[et&&h.jsx(mC,{sessions:k,cells:L,activeSessions:fe,nodeGroups:K,onPick:G,onAddTile:Ce,onPower:R,onNodePower:rt,onKill:Ee,onVisibility:Ae,onNew:()=>ye("fleet",!0),onSettings:ye,width:q,collapsed:se,onResize:X,onToggleCollapse:()=>re(ce=>!ce)}),h.jsxs("div",{className:"nc-workspace-main",children:[h.jsx(zC,{decks:j,currentDeck:S,onCreate:Ie,onRename:bt,onDelete:Ge,onOpenWindow:Be,onNavigate:We,saveState:E.saveState,error:E.error,sidebarVisible:et,onToggleSidebar:y?null:()=>Q(ce=>!ce)}),h.jsx(PC,{layout:B,onLayoutChange:ee,token:t,readonly:Y,sessionsAlive:$,focusSession:O,onFocus:F,onOpenSingle:G,decks:j,currentDeck:S,onSendToDeck:me})]}),Z&&h.jsx("div",{className:"nc-single-overlay",children:h.jsx(tv,{session:Z.session,node:Z.node,token:t,readonly:Y,onBack:()=>W(null)})}),U&&h.jsx(Ba,{cell:U,token:t,route:Array.isArray(U.route)?U.route:[],onConfirm:mt,onClose:()=>R(null)}),qe]})}function Lk(){Si();const e=M.useSyncExternalStore(yk,Qg,Qg);if(!e.needed)return null;const t=e.kind==="install"?_("install-version-mismatch").replace("{v}",e.version):_("update-available").replace("{v}",e.version).replace(" "," ").trim();return h.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[h.jsx("span",{className:"nc-update-msg",children:t}),e.kind==="reload"&&h.jsx("button",{className:"nc-update-btn",onClick:Ck,children:_("reload")})]})}bk();iw.createRoot(document.getElementById("root")).render(h.jsxs(XS.StrictMode,{children:[h.jsx(Mk,{}),h.jsx(Lk,{})]}));
|