@mmmbuto/nexuscrew 0.8.13 → 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 +37 -18
- package/frontend/dist/assets/index-BD-7qEsn.js +91 -0
- package/frontend/dist/assets/index-C-JOkuIc.css +32 -0
- package/frontend/dist/index.html +2 -2
- package/frontend/dist/version.json +1 -1
- package/lib/config.js +10 -0
- package/lib/fleet/builtin.js +97 -16
- package/lib/fleet/cell-exec.js +81 -0
- package/lib/fleet/credentials.js +135 -0
- package/lib/fleet/env-key.js +12 -0
- package/lib/fleet/launch-broker.js +136 -0
- package/lib/fleet/managed.js +74 -11
- package/lib/fleet/routes.js +10 -0
- package/lib/nodes/peering.js +24 -7
- package/lib/nodes/tunnel-supervisor.js +10 -0
- package/lib/nodes/tunnel.js +9 -0
- package/lib/proxy/federation.js +5 -4
- package/lib/server.js +16 -1
- package/lib/tmux/list.js +21 -3
- package/package.json +1 -1
- package/frontend/dist/assets/index-4rNd0SwZ.css +0 -32
- package/frontend/dist/assets/index-DuIR61l-.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 Ph(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Fc={exports:{}},Ts={},Hc={exports:{}},Ue={};/**
|
|
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 zp;function US(){if(zp)return Ue;zp=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"),y=Symbol.for("react.lazy"),w=Symbol.iterator;function _(P){return P===null||typeof P!="object"?null:(P=w&&P[w]||P["@@iterator"],typeof P=="function"?P:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,k={};function x(P,Q,se){this.props=P,this.context=Q,this.refs=k,this.updater=se||v}x.prototype.isReactComponent={},x.prototype.setState=function(P,Q){if(typeof P!="object"&&typeof P!="function"&&P!=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,P,Q,"setState")},x.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function R(){}R.prototype=x.prototype;function j(P,Q,se){this.props=P,this.context=Q,this.refs=k,this.updater=se||v}var A=j.prototype=new R;A.constructor=j,b(A,x.prototype),A.isPureReactComponent=!0;var B=Array.isArray,ie=Object.prototype.hasOwnProperty,z={current:null},$={key:!0,ref:!0,__self:!0,__source:!0};function re(P,Q,se){var J,le={},de=null,pe=null;if(Q!=null)for(J in Q.ref!==void 0&&(pe=Q.ref),Q.key!==void 0&&(de=""+Q.key),Q)ie.call(Q,J)&&!$.hasOwnProperty(J)&&(le[J]=Q[J]);var ye=arguments.length-2;if(ye===1)le.children=se;else if(1<ye){for(var K=Array(ye),ee=0;ee<ye;ee++)K[ee]=arguments[ee+2];le.children=K}if(P&&P.defaultProps)for(J in ye=P.defaultProps,ye)le[J]===void 0&&(le[J]=ye[J]);return{$$typeof:e,type:P,key:de,ref:pe,props:le,_owner:z.current}}function U(P,Q){return{$$typeof:e,type:P.type,key:Q,ref:P.ref,props:P.props,_owner:P._owner}}function X(P){return typeof P=="object"&&P!==null&&P.$$typeof===e}function q(P){var Q={"=":"=0",":":"=2"};return"$"+P.replace(/[=:]/g,function(se){return Q[se]})}var D=/\/+/g;function E(P,Q){return typeof P=="object"&&P!==null&&P.key!=null?q(""+P.key):Q.toString(36)}function L(P,Q,se,J,le){var de=typeof P;(de==="undefined"||de==="boolean")&&(P=null);var pe=!1;if(P===null)pe=!0;else switch(de){case"string":case"number":pe=!0;break;case"object":switch(P.$$typeof){case e:case t:pe=!0}}if(pe)return pe=P,le=le(pe),P=J===""?"."+E(pe,0):J,B(le)?(se="",P!=null&&(se=P.replace(D,"$&/")+"/"),L(le,Q,se,"",function(ee){return ee})):le!=null&&(X(le)&&(le=U(le,se+(!le.key||pe&&pe.key===le.key?"":(""+le.key).replace(D,"$&/")+"/")+P)),Q.push(le)),1;if(pe=0,J=J===""?".":J+":",B(P))for(var ye=0;ye<P.length;ye++){de=P[ye];var K=J+E(de,ye);pe+=L(de,Q,se,K,le)}else if(K=_(P),typeof K=="function")for(P=K.call(P),ye=0;!(de=P.next()).done;)de=de.value,K=J+E(de,ye++),pe+=L(de,Q,se,K,le);else if(de==="object")throw Q=String(P),Error("Objects are not valid as a React child (found: "+(Q==="[object Object]"?"object with keys {"+Object.keys(P).join(", ")+"}":Q)+"). If you meant to render a collection of children, use an array instead.");return pe}function Y(P,Q,se){if(P==null)return P;var J=[],le=0;return L(P,J,"","",function(de){return Q.call(se,de,le++)}),J}function N(P){if(P._status===-1){var Q=P._result;Q=Q(),Q.then(function(se){(P._status===0||P._status===-1)&&(P._status=1,P._result=se)},function(se){(P._status===0||P._status===-1)&&(P._status=2,P._result=se)}),P._status===-1&&(P._status=0,P._result=Q)}if(P._status===1)return P._result.default;throw P._result}var H={current:null},I={transition:null},W={ReactCurrentDispatcher:H,ReactCurrentBatchConfig:I,ReactCurrentOwner:z};function Z(){throw Error("act(...) is not supported in production builds of React.")}return Ue.Children={map:Y,forEach:function(P,Q,se){Y(P,function(){Q.apply(this,arguments)},se)},count:function(P){var Q=0;return Y(P,function(){Q++}),Q},toArray:function(P){return Y(P,function(Q){return Q})||[]},only:function(P){if(!X(P))throw Error("React.Children.only expected to receive a single React element child.");return P}},Ue.Component=x,Ue.Fragment=n,Ue.Profiler=o,Ue.PureComponent=j,Ue.StrictMode=s,Ue.Suspense=p,Ue.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=W,Ue.act=Z,Ue.cloneElement=function(P,Q,se){if(P==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+P+".");var J=b({},P.props),le=P.key,de=P.ref,pe=P._owner;if(Q!=null){if(Q.ref!==void 0&&(de=Q.ref,pe=z.current),Q.key!==void 0&&(le=""+Q.key),P.type&&P.type.defaultProps)var ye=P.type.defaultProps;for(K in Q)ie.call(Q,K)&&!$.hasOwnProperty(K)&&(J[K]=Q[K]===void 0&&ye!==void 0?ye[K]:Q[K])}var K=arguments.length-2;if(K===1)J.children=se;else if(1<K){ye=Array(K);for(var ee=0;ee<K;ee++)ye[ee]=arguments[ee+2];J.children=ye}return{$$typeof:e,type:P.type,key:le,ref:de,props:J,_owner:pe}},Ue.createContext=function(P){return P={$$typeof:u,_currentValue:P,_currentValue2:P,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},P.Provider={$$typeof:l,_context:P},P.Consumer=P},Ue.createElement=re,Ue.createFactory=function(P){var Q=re.bind(null,P);return Q.type=P,Q},Ue.createRef=function(){return{current:null}},Ue.forwardRef=function(P){return{$$typeof:d,render:P}},Ue.isValidElement=X,Ue.lazy=function(P){return{$$typeof:y,_payload:{_status:-1,_result:P},_init:N}},Ue.memo=function(P,Q){return{$$typeof:m,type:P,compare:Q===void 0?null:Q}},Ue.startTransition=function(P){var Q=I.transition;I.transition={};try{P()}finally{I.transition=Q}},Ue.unstable_act=Z,Ue.useCallback=function(P,Q){return H.current.useCallback(P,Q)},Ue.useContext=function(P){return H.current.useContext(P)},Ue.useDebugValue=function(){},Ue.useDeferredValue=function(P){return H.current.useDeferredValue(P)},Ue.useEffect=function(P,Q){return H.current.useEffect(P,Q)},Ue.useId=function(){return H.current.useId()},Ue.useImperativeHandle=function(P,Q,se){return H.current.useImperativeHandle(P,Q,se)},Ue.useInsertionEffect=function(P,Q){return H.current.useInsertionEffect(P,Q)},Ue.useLayoutEffect=function(P,Q){return H.current.useLayoutEffect(P,Q)},Ue.useMemo=function(P,Q){return H.current.useMemo(P,Q)},Ue.useReducer=function(P,Q,se){return H.current.useReducer(P,Q,se)},Ue.useRef=function(P){return H.current.useRef(P)},Ue.useState=function(P){return H.current.useState(P)},Ue.useSyncExternalStore=function(P,Q,se){return H.current.useSyncExternalStore(P,Q,se)},Ue.useTransition=function(){return H.current.useTransition()},Ue.version="18.3.1",Ue}var Fp;function Dh(){return Fp||(Fp=1,Hc.exports=US()),Hc.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 Hp;function KS(){if(Hp)return Ts;Hp=1;var e=Dh(),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 y,w={},_=null,v=null;m!==void 0&&(_=""+m),p.key!==void 0&&(_=""+p.key),p.ref!==void 0&&(v=p.ref);for(y in p)s.call(p,y)&&!l.hasOwnProperty(y)&&(w[y]=p[y]);if(d&&d.defaultProps)for(y in p=d.defaultProps,p)w[y]===void 0&&(w[y]=p[y]);return{$$typeof:t,type:d,key:_,ref:v,props:w,_owner:o.current}}return Ts.Fragment=n,Ts.jsx=u,Ts.jsxs=u,Ts}var $p;function qS(){return $p||($p=1,Fc.exports=KS()),Fc.exports}var h=qS(),M=Dh();const VS=Ph(M);var da={},$c={exports:{}},si={},Wc={exports:{}},Uc={};/**
|
|
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 Wp;function YS(){return Wp||(Wp=1,(function(e){function t(I,W){var Z=I.length;I.push(W);e:for(;0<Z;){var P=Z-1>>>1,Q=I[P];if(0<o(Q,W))I[P]=W,I[Z]=Q,Z=P;else break e}}function n(I){return I.length===0?null:I[0]}function s(I){if(I.length===0)return null;var W=I[0],Z=I.pop();if(Z!==W){I[0]=Z;e:for(var P=0,Q=I.length,se=Q>>>1;P<se;){var J=2*(P+1)-1,le=I[J],de=J+1,pe=I[de];if(0>o(le,Z))de<Q&&0>o(pe,le)?(I[P]=pe,I[de]=Z,P=de):(I[P]=le,I[J]=Z,P=J);else if(de<Q&&0>o(pe,Z))I[P]=pe,I[de]=Z,P=de;else break e}}return W}function o(I,W){var Z=I.sortIndex-W.sortIndex;return Z!==0?Z:I.id-W.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=[],y=1,w=null,_=3,v=!1,b=!1,k=!1,x=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,j=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 W=n(m);W!==null;){if(W.callback===null)s(m);else if(W.startTime<=I)s(m),W.sortIndex=W.expirationTime,t(p,W);else break;W=n(m)}}function B(I){if(k=!1,A(I),!b)if(n(p)!==null)b=!0,N(ie);else{var W=n(m);W!==null&&H(B,W.startTime-I)}}function ie(I,W){b=!1,k&&(k=!1,R(re),re=-1),v=!0;var Z=_;try{for(A(W),w=n(p);w!==null&&(!(w.expirationTime>W)||I&&!q());){var P=w.callback;if(typeof P=="function"){w.callback=null,_=w.priorityLevel;var Q=P(w.expirationTime<=W);W=e.unstable_now(),typeof Q=="function"?w.callback=Q:w===n(p)&&s(p),A(W)}else s(p);w=n(p)}if(w!==null)var se=!0;else{var J=n(m);J!==null&&H(B,J.startTime-W),se=!1}return se}finally{w=null,_=Z,v=!1}}var z=!1,$=null,re=-1,U=5,X=-1;function q(){return!(e.unstable_now()-X<U)}function D(){if($!==null){var I=e.unstable_now();X=I;var W=!0;try{W=$(!0,I)}finally{W?E():(z=!1,$=null)}}else z=!1}var E;if(typeof j=="function")E=function(){j(D)};else if(typeof MessageChannel<"u"){var L=new MessageChannel,Y=L.port2;L.port1.onmessage=D,E=function(){Y.postMessage(null)}}else E=function(){x(D,0)};function N(I){$=I,z||(z=!0,E())}function H(I,W){re=x(function(){I(e.unstable_now())},W)}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(){b||v||(b=!0,N(ie))},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"):U=0<I?Math.floor(1e3/I):5},e.unstable_getCurrentPriorityLevel=function(){return _},e.unstable_getFirstCallbackNode=function(){return n(p)},e.unstable_next=function(I){switch(_){case 1:case 2:case 3:var W=3;break;default:W=_}var Z=_;_=W;try{return I()}finally{_=Z}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(I,W){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var Z=_;_=I;try{return W()}finally{_=Z}},e.unstable_scheduleCallback=function(I,W,Z){var P=e.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?P+Z:P):Z=P,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=Z+Q,I={id:y++,callback:W,priorityLevel:I,startTime:Z,expirationTime:Q,sortIndex:-1},Z>P?(I.sortIndex=Z,t(m,I),n(p)===null&&I===n(m)&&(k?(R(re),re=-1):k=!0,H(B,Z-P))):(I.sortIndex=Q,t(p,I),b||v||(b=!0,N(ie))),I},e.unstable_shouldYield=q,e.unstable_wrapCallback=function(I){var W=_;return function(){var Z=_;_=W;try{return I.apply(this,arguments)}finally{_=Z}}}})(Uc)),Uc}var Up;function XS(){return Up||(Up=1,Wc.exports=YS()),Wc.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 Kp;function GS(){if(Kp)return si;Kp=1;var e=Dh(),t=XS();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]*$/,y={},w={};function _(i){return p.call(w,i)?!0:p.call(y,i)?!1:m.test(i)?w[i]=!0:(y[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 b(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 k(i,r,a,c,f,g,C){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=C}var x={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){x[i]=new k(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var r=i[0];x[r]=new k(r,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){x[i]=new k(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){x[i]=new k(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){x[i]=new k(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){x[i]=new k(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){x[i]=new k(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){x[i]=new k(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){x[i]=new k(i,5,!1,i.toLowerCase(),null,!1,!1)});var R=/[\-:]([a-z])/g;function j(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(R,j);x[r]=new k(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(R,j);x[r]=new k(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(R,j);x[r]=new k(r,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){x[i]=new k(i,1,!1,i.toLowerCase(),null,!1,!1)}),x.xlinkHref=new k("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){x[i]=new k(i,1,!1,i.toLowerCase(),null,!0,!0)});function A(i,r,a,c){var f=x.hasOwnProperty(r)?x[r]:null;(f!==null?f.type!==0:c||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(b(r,a,f,c)&&(a=null),c||f===null?_(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,ie=Symbol.for("react.element"),z=Symbol.for("react.portal"),$=Symbol.for("react.fragment"),re=Symbol.for("react.strict_mode"),U=Symbol.for("react.profiler"),X=Symbol.for("react.provider"),q=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),N=Symbol.for("react.lazy"),H=Symbol.for("react.offscreen"),I=Symbol.iterator;function W(i){return i===null||typeof i!="object"?null:(i=I&&i[I]||i["@@iterator"],typeof i=="function"?i:null)}var Z=Object.assign,P;function Q(i){if(P===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);P=r&&r[1]||""}return`
|
|
34
|
-
`+P+i}var se=!1;function J(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
|
-
`),C=f.length-1,T=g.length-1;1<=C&&0<=T&&f[C]!==g[T];)T--;for(;1<=C&&0<=T;C--,T--)if(f[C]!==g[T]){if(C!==1||T!==1)do if(C--,T--,0>T||f[C]!==g[T]){var F=`
|
|
37
|
-
`+f[C].replace(" at new "," at ");return i.displayName&&F.includes("<anonymous>")&&(F=F.replace("<anonymous>",i.displayName)),F}while(1<=C&&0<=T);break}}}finally{se=!1,Error.prepareStackTrace=a}return(i=i?i.displayName||i.name:"")?Q(i):""}function le(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=J(i.type,!1),i;case 11:return i=J(i.type.render,!1),i;case 1:return i=J(i.type,!0),i;default:return""}}function de(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case $:return"Fragment";case z:return"Portal";case U:return"Profiler";case re:return"StrictMode";case E:return"Suspense";case L:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case q:return(i.displayName||"Context")+".Consumer";case X:return(i._context.displayName||"Context")+".Provider";case D:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case Y:return r=i.displayName||null,r!==null?r:de(i.type)||"Memo";case N:r=i._payload,i=i._init;try{return de(i(r))}catch{}}return null}function pe(i){var r=i.type;switch(i.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=r.render,i=i.displayName||i.name||"",r.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return de(r);case 8:return r===re?"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 ye(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function K(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function ee(i){var r=K(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(C){c=""+C,g.call(this,C)}}),Object.defineProperty(i,r,{enumerable:a.enumerable}),{getValue:function(){return c},setValue:function(C){c=""+C},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function Re(i){i._valueTracker||(i._valueTracker=ee(i))}function G(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var a=r.getValue(),c="";return i&&(c=K(i)?i.checked?"true":"false":i.value),i=c,i!==a?(r.setValue(i),!0):!1}function ae(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 we(i,r){var a=r.checked;return Z({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??i._wrapperState.initialChecked})}function O(i,r){var a=r.defaultValue==null?"":r.defaultValue,c=r.checked!=null?r.checked:r.defaultChecked;a=ye(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 ue(i,r){r=r.checked,r!=null&&A(i,"checked",r,!1)}function be(i,r){ue(i,r);var a=ye(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")?Ke(i,r.type,a):r.hasOwnProperty("defaultValue")&&Ke(i,r.type,ye(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(i.defaultChecked=!!r.defaultChecked)}function Le(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 Ke(i,r,a){(r!=="number"||ae(i.ownerDocument)!==i)&&(a==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+a&&(i.defaultValue=""+a))}var De=Array.isArray;function Qe(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=""+ye(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 qe(i,r){if(r.dangerouslySetInnerHTML!=null)throw Error(n(91));return Z({},r,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function Ye(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(De(a)){if(1<a.length)throw Error(n(93));a=a[0]}r=a}r==null&&(r=""),a=r}i._wrapperState={initialValue:ye(a)}}function Ct(i,r){var a=ye(r.value),c=ye(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 ze(i){var r=i.textContent;r===i._wrapperState.initialValue&&r!==""&&r!==null&&(i.value=r)}function at(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 Be(i,r){return i==null||i==="http://www.w3.org/1999/xhtml"?at(r):i==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var gt,Pi=(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(gt=gt||document.createElement("div"),gt.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=gt.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;r.firstChild;)i.appendChild(r.firstChild)}});function xt(i,r){if(r){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=r;return}}i.textContent=r}var ve={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},Ve=["Webkit","ms","Moz","O"];Object.keys(ve).forEach(function(i){Ve.forEach(function(r){r=r+i.charAt(0).toUpperCase()+i.substring(1),ve[r]=ve[i]})});function ce(i,r,a){return r==null||typeof r=="boolean"||r===""?"":a||typeof r!="number"||r===0||ve.hasOwnProperty(i)&&ve[i]?(""+r).trim():r+"px"}function xe(i,r){i=i.style;for(var a in r)if(r.hasOwnProperty(a)){var c=a.indexOf("--")===0,f=ce(a,r[a],c);a==="float"&&(a="cssFloat"),c?i.setProperty(a,f):i[a]=f}}var Oe=Z({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function dt(i,r){if(r){if(Oe[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 Yt(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 el=null;function tl(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var il=null,pr=null,mr=null;function td(i){if(i=_s(i)){if(typeof il!="function")throw Error(n(280));var r=i.stateNode;r&&(r=No(r),il(i.stateNode,i.type,r))}}function id(i){pr?mr?mr.push(i):mr=[i]:pr=i}function nd(){if(pr){var i=pr,r=mr;if(mr=pr=null,td(i),r)for(i=0;i<r.length;i++)td(r[i])}}function rd(i,r){return i(r)}function sd(){}var nl=!1;function od(i,r,a){if(nl)return i(r,a);nl=!0;try{return rd(i,r,a)}finally{nl=!1,(pr!==null||mr!==null)&&(sd(),nd())}}function Qr(i,r){var a=i.stateNode;if(a===null)return null;var c=No(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 rl=!1;if(d)try{var Jr={};Object.defineProperty(Jr,"passive",{get:function(){rl=!0}}),window.addEventListener("test",Jr,Jr),window.removeEventListener("test",Jr,Jr)}catch{rl=!1}function G_(i,r,a,c,f,g,C,T,F){var oe=Array.prototype.slice.call(arguments,3);try{r.apply(a,oe)}catch(me){this.onError(me)}}var Zr=!1,ro=null,so=!1,sl=null,Q_={onError:function(i){Zr=!0,ro=i}};function J_(i,r,a,c,f,g,C,T,F){Zr=!1,ro=null,G_.apply(Q_,arguments)}function Z_(i,r,a,c,f,g,C,T,F){if(J_.apply(this,arguments),Zr){if(Zr){var oe=ro;Zr=!1,ro=null}else throw Error(n(198));so||(so=!0,sl=oe)}}function Hn(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 ad(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 ld(i){if(Hn(i)!==i)throw Error(n(188))}function ey(i){var r=i.alternate;if(!r){if(r=Hn(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 ld(f),i;if(g===c)return ld(f),r;g=g.sibling}throw Error(n(188))}if(a.return!==c.return)a=f,c=g;else{for(var C=!1,T=f.child;T;){if(T===a){C=!0,a=f,c=g;break}if(T===c){C=!0,c=f,a=g;break}T=T.sibling}if(!C){for(T=g.child;T;){if(T===a){C=!0,a=g,c=f;break}if(T===c){C=!0,c=g,a=f;break}T=T.sibling}if(!C)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 cd(i){return i=ey(i),i!==null?ud(i):null}function ud(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var r=ud(i);if(r!==null)return r;i=i.sibling}return null}var hd=t.unstable_scheduleCallback,dd=t.unstable_cancelCallback,ty=t.unstable_shouldYield,iy=t.unstable_requestPaint,vt=t.unstable_now,ny=t.unstable_getCurrentPriorityLevel,ol=t.unstable_ImmediatePriority,fd=t.unstable_UserBlockingPriority,oo=t.unstable_NormalPriority,ry=t.unstable_LowPriority,pd=t.unstable_IdlePriority,ao=null,zi=null;function sy(i){if(zi&&typeof zi.onCommitFiberRoot=="function")try{zi.onCommitFiberRoot(ao,i,void 0,(i.current.flags&128)===128)}catch{}}var Di=Math.clz32?Math.clz32:ly,oy=Math.log,ay=Math.LN2;function ly(i){return i>>>=0,i===0?32:31-(oy(i)/ay|0)|0}var lo=64,co=4194304;function es(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 uo(i,r){var a=i.pendingLanes;if(a===0)return 0;var c=0,f=i.suspendedLanes,g=i.pingedLanes,C=a&268435455;if(C!==0){var T=C&~f;T!==0?c=es(T):(g&=C,g!==0&&(c=es(g)))}else C=a&~f,C!==0?c=es(C):g!==0&&(c=es(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-Di(r),f=1<<a,c|=i[a],r&=~f;return c}function cy(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 uy(i,r){for(var a=i.suspendedLanes,c=i.pingedLanes,f=i.expirationTimes,g=i.pendingLanes;0<g;){var C=31-Di(g),T=1<<C,F=f[C];F===-1?((T&a)===0||(T&c)!==0)&&(f[C]=cy(T,r)):F<=r&&(i.expiredLanes|=T),g&=~T}}function al(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function md(){var i=lo;return lo<<=1,(lo&4194240)===0&&(lo=64),i}function ll(i){for(var r=[],a=0;31>a;a++)r.push(i);return r}function ts(i,r,a){i.pendingLanes|=r,r!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,r=31-Di(r),i[r]=a}function hy(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-Di(a),g=1<<f;r[f]=0,c[f]=-1,i[f]=-1,a&=~g}}function cl(i,r){var a=i.entangledLanes|=r;for(i=i.entanglements;a;){var c=31-Di(a),f=1<<c;f&r|i[c]&r&&(i[c]|=r),a&=~f}}var Ze=0;function gd(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var vd,ul,_d,yd,Sd,hl=!1,ho=[],fn=null,pn=null,mn=null,is=new Map,ns=new Map,gn=[],dy="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 wd(i,r){switch(i){case"focusin":case"focusout":fn=null;break;case"dragenter":case"dragleave":pn=null;break;case"mouseover":case"mouseout":mn=null;break;case"pointerover":case"pointerout":is.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":ns.delete(r.pointerId)}}function rs(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=_s(r),r!==null&&ul(r)),i):(i.eventSystemFlags|=c,r=i.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),i)}function fy(i,r,a,c,f){switch(r){case"focusin":return fn=rs(fn,i,r,a,c,f),!0;case"dragenter":return pn=rs(pn,i,r,a,c,f),!0;case"mouseover":return mn=rs(mn,i,r,a,c,f),!0;case"pointerover":var g=f.pointerId;return is.set(g,rs(is.get(g)||null,i,r,a,c,f)),!0;case"gotpointercapture":return g=f.pointerId,ns.set(g,rs(ns.get(g)||null,i,r,a,c,f)),!0}return!1}function bd(i){var r=$n(i.target);if(r!==null){var a=Hn(r);if(a!==null){if(r=a.tag,r===13){if(r=ad(a),r!==null){i.blockedOn=r,Sd(i.priority,function(){_d(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 fo(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var a=fl(i.domEventName,i.eventSystemFlags,r[0],i.nativeEvent);if(a===null){a=i.nativeEvent;var c=new a.constructor(a.type,a);el=c,a.target.dispatchEvent(c),el=null}else return r=_s(a),r!==null&&ul(r),i.blockedOn=a,!1;r.shift()}return!0}function Cd(i,r,a){fo(i)&&a.delete(r)}function py(){hl=!1,fn!==null&&fo(fn)&&(fn=null),pn!==null&&fo(pn)&&(pn=null),mn!==null&&fo(mn)&&(mn=null),is.forEach(Cd),ns.forEach(Cd)}function ss(i,r){i.blockedOn===r&&(i.blockedOn=null,hl||(hl=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,py)))}function os(i){function r(f){return ss(f,i)}if(0<ho.length){ss(ho[0],i);for(var a=1;a<ho.length;a++){var c=ho[a];c.blockedOn===i&&(c.blockedOn=null)}}for(fn!==null&&ss(fn,i),pn!==null&&ss(pn,i),mn!==null&&ss(mn,i),is.forEach(r),ns.forEach(r),a=0;a<gn.length;a++)c=gn[a],c.blockedOn===i&&(c.blockedOn=null);for(;0<gn.length&&(a=gn[0],a.blockedOn===null);)bd(a),a.blockedOn===null&&gn.shift()}var gr=B.ReactCurrentBatchConfig,po=!0;function my(i,r,a,c){var f=Ze,g=gr.transition;gr.transition=null;try{Ze=1,dl(i,r,a,c)}finally{Ze=f,gr.transition=g}}function gy(i,r,a,c){var f=Ze,g=gr.transition;gr.transition=null;try{Ze=4,dl(i,r,a,c)}finally{Ze=f,gr.transition=g}}function dl(i,r,a,c){if(po){var f=fl(i,r,a,c);if(f===null)Dl(i,r,c,mo,a),wd(i,c);else if(fy(f,i,r,a,c))c.stopPropagation();else if(wd(i,c),r&4&&-1<dy.indexOf(i)){for(;f!==null;){var g=_s(f);if(g!==null&&vd(g),g=fl(i,r,a,c),g===null&&Dl(i,r,c,mo,a),g===f)break;f=g}f!==null&&c.stopPropagation()}else Dl(i,r,c,null,a)}}var mo=null;function fl(i,r,a,c){if(mo=null,i=tl(c),i=$n(i),i!==null)if(r=Hn(i),r===null)i=null;else if(a=r.tag,a===13){if(i=ad(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 mo=i,null}function xd(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(ny()){case ol:return 1;case fd:return 4;case oo:case ry:return 16;case pd:return 536870912;default:return 16}default:return 16}}var vn=null,pl=null,go=null;function kd(){if(go)return go;var i,r=pl,a=r.length,c,f="value"in vn?vn.value:vn.textContent,g=f.length;for(i=0;i<a&&r[i]===f[i];i++);var C=a-i;for(c=1;c<=C&&r[a-c]===f[g-c];c++);return go=f.slice(i,1<c?1-c:void 0)}function vo(i){var r=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&r===13&&(i=13)):i=r,i===10&&(i=13),32<=i||i===13?i:0}function _o(){return!0}function Ed(){return!1}function ci(i){function r(a,c,f,g,C){this._reactName=a,this._targetInst=f,this.type=c,this.nativeEvent=g,this.target=C,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)?_o:Ed,this.isPropagationStopped=Ed,this}return Z(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=_o)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=_o)},persist:function(){},isPersistent:_o}),r}var vr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ml=ci(vr),as=Z({},vr,{view:0,detail:0}),vy=ci(as),gl,vl,ls,yo=Z({},as,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:yl,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!==ls&&(ls&&i.type==="mousemove"?(gl=i.screenX-ls.screenX,vl=i.screenY-ls.screenY):vl=gl=0,ls=i),gl)},movementY:function(i){return"movementY"in i?i.movementY:vl}}),Nd=ci(yo),_y=Z({},yo,{dataTransfer:0}),yy=ci(_y),Sy=Z({},as,{relatedTarget:0}),_l=ci(Sy),wy=Z({},vr,{animationName:0,elapsedTime:0,pseudoElement:0}),by=ci(wy),Cy=Z({},vr,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),xy=ci(Cy),ky=Z({},vr,{data:0}),Rd=ci(ky),Ey={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ny={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"},Ry={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Py(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=Ry[i])?!!r[i]:!1}function yl(){return Py}var Dy=Z({},as,{key:function(i){if(i.key){var r=Ey[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=vo(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Ny[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:yl,charCode:function(i){return i.type==="keypress"?vo(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?vo(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),My=ci(Dy),Ly=Z({},yo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Pd=ci(Ly),Ty=Z({},as,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:yl}),jy=ci(Ty),By=Z({},vr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ay=ci(By),Iy=Z({},yo,{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}),Oy=ci(Iy),zy=[9,13,27,32],Sl=d&&"CompositionEvent"in window,cs=null;d&&"documentMode"in document&&(cs=document.documentMode);var Fy=d&&"TextEvent"in window&&!cs,Dd=d&&(!Sl||cs&&8<cs&&11>=cs),Md=" ",Ld=!1;function Td(i,r){switch(i){case"keyup":return zy.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 _r=!1;function Hy(i,r){switch(i){case"compositionend":return jd(r);case"keypress":return r.which!==32?null:(Ld=!0,Md);case"textInput":return i=r.data,i===Md&&Ld?null:i;default:return null}}function $y(i,r){if(_r)return i==="compositionend"||!Sl&&Td(i,r)?(i=kd(),go=pl=vn=null,_r=!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 Dd&&r.locale!=="ko"?null:r.data;default:return null}}var Wy={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 Bd(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!Wy[i.type]:r==="textarea"}function Ad(i,r,a,c){id(c),r=xo(r,"onChange"),0<r.length&&(a=new ml("onChange","change",null,a,c),i.push({event:a,listeners:r}))}var us=null,hs=null;function Uy(i){ef(i,0)}function So(i){var r=Cr(i);if(G(r))return i}function Ky(i,r){if(i==="change")return r}var Id=!1;if(d){var wl;if(d){var bl="oninput"in document;if(!bl){var Od=document.createElement("div");Od.setAttribute("oninput","return;"),bl=typeof Od.oninput=="function"}wl=bl}else wl=!1;Id=wl&&(!document.documentMode||9<document.documentMode)}function zd(){us&&(us.detachEvent("onpropertychange",Fd),hs=us=null)}function Fd(i){if(i.propertyName==="value"&&So(hs)){var r=[];Ad(r,hs,i,tl(i)),od(Uy,r)}}function qy(i,r,a){i==="focusin"?(zd(),us=r,hs=a,us.attachEvent("onpropertychange",Fd)):i==="focusout"&&zd()}function Vy(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return So(hs)}function Yy(i,r){if(i==="click")return So(r)}function Xy(i,r){if(i==="input"||i==="change")return So(r)}function Gy(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var Mi=typeof Object.is=="function"?Object.is:Gy;function ds(i,r){if(Mi(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)||!Mi(i[f],r[f]))return!1}return!0}function Hd(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function $d(i,r){var a=Hd(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=Hd(a)}}function Wd(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Wd(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Ud(){for(var i=window,r=ae();r instanceof i.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)i=r.contentWindow;else break;r=ae(i.document)}return r}function Cl(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 Qy(i){var r=Ud(),a=i.focusedElem,c=i.selectionRange;if(r!==a&&a&&a.ownerDocument&&Wd(a.ownerDocument.documentElement,a)){if(c!==null&&Cl(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=$d(a,g);var C=$d(a,c);f&&C&&(i.rangeCount!==1||i.anchorNode!==f.node||i.anchorOffset!==f.offset||i.focusNode!==C.node||i.focusOffset!==C.offset)&&(r=r.createRange(),r.setStart(f.node,f.offset),i.removeAllRanges(),g>c?(i.addRange(r),i.extend(C.node,C.offset)):(r.setEnd(C.node,C.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 Jy=d&&"documentMode"in document&&11>=document.documentMode,yr=null,xl=null,fs=null,kl=!1;function Kd(i,r,a){var c=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;kl||yr==null||yr!==ae(c)||(c=yr,"selectionStart"in c&&Cl(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}),fs&&ds(fs,c)||(fs=c,c=xo(xl,"onSelect"),0<c.length&&(r=new ml("onSelect","select",null,r,a),i.push({event:r,listeners:c}),r.target=yr)))}function wo(i,r){var a={};return a[i.toLowerCase()]=r.toLowerCase(),a["Webkit"+i]="webkit"+r,a["Moz"+i]="moz"+r,a}var Sr={animationend:wo("Animation","AnimationEnd"),animationiteration:wo("Animation","AnimationIteration"),animationstart:wo("Animation","AnimationStart"),transitionend:wo("Transition","TransitionEnd")},El={},qd={};d&&(qd=document.createElement("div").style,"AnimationEvent"in window||(delete Sr.animationend.animation,delete Sr.animationiteration.animation,delete Sr.animationstart.animation),"TransitionEvent"in window||delete Sr.transitionend.transition);function bo(i){if(El[i])return El[i];if(!Sr[i])return i;var r=Sr[i],a;for(a in r)if(r.hasOwnProperty(a)&&a in qd)return El[i]=r[a];return i}var Vd=bo("animationend"),Yd=bo("animationiteration"),Xd=bo("animationstart"),Gd=bo("transitionend"),Qd=new Map,Jd="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 _n(i,r){Qd.set(i,r),l(r,[i])}for(var Nl=0;Nl<Jd.length;Nl++){var Rl=Jd[Nl],Zy=Rl.toLowerCase(),eS=Rl[0].toUpperCase()+Rl.slice(1);_n(Zy,"on"+eS)}_n(Vd,"onAnimationEnd"),_n(Yd,"onAnimationIteration"),_n(Xd,"onAnimationStart"),_n("dblclick","onDoubleClick"),_n("focusin","onFocus"),_n("focusout","onBlur"),_n(Gd,"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 ps="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(" "),tS=new Set("cancel close invalid load scroll toggle".split(" ").concat(ps));function Zd(i,r,a){var c=i.type||"unknown-event";i.currentTarget=a,Z_(c,r,void 0,i),i.currentTarget=null}function ef(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 C=c.length-1;0<=C;C--){var T=c[C],F=T.instance,oe=T.currentTarget;if(T=T.listener,F!==g&&f.isPropagationStopped())break e;Zd(f,T,oe),g=F}else for(C=0;C<c.length;C++){if(T=c[C],F=T.instance,oe=T.currentTarget,T=T.listener,F!==g&&f.isPropagationStopped())break e;Zd(f,T,oe),g=F}}}if(so)throw i=sl,so=!1,sl=null,i}function it(i,r){var a=r[Al];a===void 0&&(a=r[Al]=new Set);var c=i+"__bubble";a.has(c)||(tf(r,i,2,!1),a.add(c))}function Pl(i,r,a){var c=0;r&&(c|=4),tf(a,i,c,r)}var Co="_reactListening"+Math.random().toString(36).slice(2);function ms(i){if(!i[Co]){i[Co]=!0,s.forEach(function(a){a!=="selectionchange"&&(tS.has(a)||Pl(a,!1,i),Pl(a,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[Co]||(r[Co]=!0,Pl("selectionchange",!1,r))}}function tf(i,r,a,c){switch(xd(r)){case 1:var f=my;break;case 4:f=gy;break;default:f=dl}a=f.bind(null,r,a,i),f=void 0,!rl||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 Dl(i,r,a,c,f){var g=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var C=c.tag;if(C===3||C===4){var T=c.stateNode.containerInfo;if(T===f||T.nodeType===8&&T.parentNode===f)break;if(C===4)for(C=c.return;C!==null;){var F=C.tag;if((F===3||F===4)&&(F=C.stateNode.containerInfo,F===f||F.nodeType===8&&F.parentNode===f))return;C=C.return}for(;T!==null;){if(C=$n(T),C===null)return;if(F=C.tag,F===5||F===6){c=g=C;continue e}T=T.parentNode}}c=c.return}od(function(){var oe=g,me=tl(a),ge=[];e:{var fe=Qd.get(i);if(fe!==void 0){var ke=ml,Ne=i;switch(i){case"keypress":if(vo(a)===0)break e;case"keydown":case"keyup":ke=My;break;case"focusin":Ne="focus",ke=_l;break;case"focusout":Ne="blur",ke=_l;break;case"beforeblur":case"afterblur":ke=_l;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=Nd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ke=yy;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ke=jy;break;case Vd:case Yd:case Xd:ke=by;break;case Gd:ke=Ay;break;case"scroll":ke=vy;break;case"wheel":ke=Oy;break;case"copy":case"cut":case"paste":ke=xy;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ke=Pd}var Pe=(r&4)!==0,_t=!Pe&&i==="scroll",te=Pe?fe!==null?fe+"Capture":null:fe;Pe=[];for(var V=oe,ne;V!==null;){ne=V;var _e=ne.stateNode;if(ne.tag===5&&_e!==null&&(ne=_e,te!==null&&(_e=Qr(V,te),_e!=null&&Pe.push(gs(V,_e,ne)))),_t)break;V=V.return}0<Pe.length&&(fe=new ke(fe,Ne,null,a,me),ge.push({event:fe,listeners:Pe}))}}if((r&7)===0){e:{if(fe=i==="mouseover"||i==="pointerover",ke=i==="mouseout"||i==="pointerout",fe&&a!==el&&(Ne=a.relatedTarget||a.fromElement)&&($n(Ne)||Ne[Ji]))break e;if((ke||fe)&&(fe=me.window===me?me:(fe=me.ownerDocument)?fe.defaultView||fe.parentWindow:window,ke?(Ne=a.relatedTarget||a.toElement,ke=oe,Ne=Ne?$n(Ne):null,Ne!==null&&(_t=Hn(Ne),Ne!==_t||Ne.tag!==5&&Ne.tag!==6)&&(Ne=null)):(ke=null,Ne=oe),ke!==Ne)){if(Pe=Nd,_e="onMouseLeave",te="onMouseEnter",V="mouse",(i==="pointerout"||i==="pointerover")&&(Pe=Pd,_e="onPointerLeave",te="onPointerEnter",V="pointer"),_t=ke==null?fe:Cr(ke),ne=Ne==null?fe:Cr(Ne),fe=new Pe(_e,V+"leave",ke,a,me),fe.target=_t,fe.relatedTarget=ne,_e=null,$n(me)===oe&&(Pe=new Pe(te,V+"enter",Ne,a,me),Pe.target=ne,Pe.relatedTarget=_t,_e=Pe),_t=_e,ke&&Ne)t:{for(Pe=ke,te=Ne,V=0,ne=Pe;ne;ne=wr(ne))V++;for(ne=0,_e=te;_e;_e=wr(_e))ne++;for(;0<V-ne;)Pe=wr(Pe),V--;for(;0<ne-V;)te=wr(te),ne--;for(;V--;){if(Pe===te||te!==null&&Pe===te.alternate)break t;Pe=wr(Pe),te=wr(te)}Pe=null}else Pe=null;ke!==null&&nf(ge,fe,ke,Pe,!1),Ne!==null&&_t!==null&&nf(ge,_t,Ne,Pe,!0)}}e:{if(fe=oe?Cr(oe):window,ke=fe.nodeName&&fe.nodeName.toLowerCase(),ke==="select"||ke==="input"&&fe.type==="file")var Me=Ky;else if(Bd(fe))if(Id)Me=Xy;else{Me=Vy;var Te=qy}else(ke=fe.nodeName)&&ke.toLowerCase()==="input"&&(fe.type==="checkbox"||fe.type==="radio")&&(Me=Yy);if(Me&&(Me=Me(i,oe))){Ad(ge,Me,a,me);break e}Te&&Te(i,fe,oe),i==="focusout"&&(Te=fe._wrapperState)&&Te.controlled&&fe.type==="number"&&Ke(fe,"number",fe.value)}switch(Te=oe?Cr(oe):window,i){case"focusin":(Bd(Te)||Te.contentEditable==="true")&&(yr=Te,xl=oe,fs=null);break;case"focusout":fs=xl=yr=null;break;case"mousedown":kl=!0;break;case"contextmenu":case"mouseup":case"dragend":kl=!1,Kd(ge,a,me);break;case"selectionchange":if(Jy)break;case"keydown":case"keyup":Kd(ge,a,me)}var je;if(Sl)e:{switch(i){case"compositionstart":var Ae="onCompositionStart";break e;case"compositionend":Ae="onCompositionEnd";break e;case"compositionupdate":Ae="onCompositionUpdate";break e}Ae=void 0}else _r?Td(i,a)&&(Ae="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(Ae="onCompositionStart");Ae&&(Dd&&a.locale!=="ko"&&(_r||Ae!=="onCompositionStart"?Ae==="onCompositionEnd"&&_r&&(je=kd()):(vn=me,pl="value"in vn?vn.value:vn.textContent,_r=!0)),Te=xo(oe,Ae),0<Te.length&&(Ae=new Rd(Ae,i,null,a,me),ge.push({event:Ae,listeners:Te}),je?Ae.data=je:(je=jd(a),je!==null&&(Ae.data=je)))),(je=Fy?Hy(i,a):$y(i,a))&&(oe=xo(oe,"onBeforeInput"),0<oe.length&&(me=new Rd("onBeforeInput","beforeinput",null,a,me),ge.push({event:me,listeners:oe}),me.data=je))}ef(ge,r)})}function gs(i,r,a){return{instance:i,listener:r,currentTarget:a}}function xo(i,r){for(var a=r+"Capture",c=[];i!==null;){var f=i,g=f.stateNode;f.tag===5&&g!==null&&(f=g,g=Qr(i,a),g!=null&&c.unshift(gs(i,g,f)),g=Qr(i,r),g!=null&&c.push(gs(i,g,f))),i=i.return}return c}function wr(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function nf(i,r,a,c,f){for(var g=r._reactName,C=[];a!==null&&a!==c;){var T=a,F=T.alternate,oe=T.stateNode;if(F!==null&&F===c)break;T.tag===5&&oe!==null&&(T=oe,f?(F=Qr(a,g),F!=null&&C.unshift(gs(a,F,T))):f||(F=Qr(a,g),F!=null&&C.push(gs(a,F,T)))),a=a.return}C.length!==0&&i.push({event:r,listeners:C})}var iS=/\r\n?/g,nS=/\u0000|\uFFFD/g;function rf(i){return(typeof i=="string"?i:""+i).replace(iS,`
|
|
38
|
-
`).replace(nS,"")}function ko(i,r,a){if(r=rf(r),rf(i)!==r&&a)throw Error(n(425))}function Eo(){}var Ml=null,Ll=null;function Tl(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,rS=typeof clearTimeout=="function"?clearTimeout:void 0,sf=typeof Promise=="function"?Promise:void 0,sS=typeof queueMicrotask=="function"?queueMicrotask:typeof sf<"u"?function(i){return sf.resolve(null).then(i).catch(oS)}:jl;function oS(i){setTimeout(function(){throw i})}function Bl(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),os(r);return}c--}else a!=="$"&&a!=="$?"&&a!=="$!"||c++;a=f}while(a);os(r)}function yn(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 of(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 br=Math.random().toString(36).slice(2),Fi="__reactFiber$"+br,vs="__reactProps$"+br,Ji="__reactContainer$"+br,Al="__reactEvents$"+br,aS="__reactListeners$"+br,lS="__reactHandles$"+br;function $n(i){var r=i[Fi];if(r)return r;for(var a=i.parentNode;a;){if(r=a[Ji]||a[Fi]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(i=of(i);i!==null;){if(a=i[Fi])return a;i=of(i)}return r}i=a,a=i.parentNode}return null}function _s(i){return i=i[Fi]||i[Ji],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function Cr(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function No(i){return i[vs]||null}var Il=[],xr=-1;function Sn(i){return{current:i}}function nt(i){0>xr||(i.current=Il[xr],Il[xr]=null,xr--)}function tt(i,r){xr++,Il[xr]=i.current,i.current=r}var wn={},Wt=Sn(wn),ei=Sn(!1),Wn=wn;function kr(i,r){var a=i.type.contextTypes;if(!a)return wn;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 ti(i){return i=i.childContextTypes,i!=null}function Ro(){nt(ei),nt(Wt)}function af(i,r,a){if(Wt.current!==wn)throw Error(n(168));tt(Wt,r),tt(ei,a)}function lf(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,pe(i)||"Unknown",f));return Z({},a,c)}function Po(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||wn,Wn=Wt.current,tt(Wt,i),tt(ei,ei.current),!0}function cf(i,r,a){var c=i.stateNode;if(!c)throw Error(n(169));a?(i=lf(i,r,Wn),c.__reactInternalMemoizedMergedChildContext=i,nt(ei),nt(Wt),tt(Wt,i)):nt(ei),tt(ei,a)}var Zi=null,Do=!1,Ol=!1;function uf(i){Zi===null?Zi=[i]:Zi.push(i)}function cS(i){Do=!0,uf(i)}function bn(){if(!Ol&&Zi!==null){Ol=!0;var i=0,r=Ze;try{var a=Zi;for(Ze=1;i<a.length;i++){var c=a[i];do c=c(!0);while(c!==null)}Zi=null,Do=!1}catch(f){throw Zi!==null&&(Zi=Zi.slice(i+1)),hd(ol,bn),f}finally{Ze=r,Ol=!1}}return null}var Er=[],Nr=0,Mo=null,Lo=0,yi=[],Si=0,Un=null,en=1,tn="";function Kn(i,r){Er[Nr++]=Lo,Er[Nr++]=Mo,Mo=i,Lo=r}function hf(i,r,a){yi[Si++]=en,yi[Si++]=tn,yi[Si++]=Un,Un=i;var c=en;i=tn;var f=32-Di(c)-1;c&=~(1<<f),a+=1;var g=32-Di(r)+f;if(30<g){var C=f-f%5;g=(c&(1<<C)-1).toString(32),c>>=C,f-=C,en=1<<32-Di(r)+f|a<<f|c,tn=g+i}else en=1<<g|a<<f|c,tn=i}function zl(i){i.return!==null&&(Kn(i,1),hf(i,1,0))}function Fl(i){for(;i===Mo;)Mo=Er[--Nr],Er[Nr]=null,Lo=Er[--Nr],Er[Nr]=null;for(;i===Un;)Un=yi[--Si],yi[Si]=null,tn=yi[--Si],yi[Si]=null,en=yi[--Si],yi[Si]=null}var ui=null,hi=null,st=!1,Li=null;function df(i,r){var a=xi(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 ff(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,ui=i,hi=yn(r.firstChild),!0):!1;case 6:return r=i.pendingProps===""||r.nodeType!==3?null:r,r!==null?(i.stateNode=r,ui=i,hi=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(a=Un!==null?{id:en,overflow:tn}:null,i.memoizedState={dehydrated:r,treeContext:a,retryLane:1073741824},a=xi(18,null,null,0),a.stateNode=r,a.return=i,i.child=a,ui=i,hi=null,!0):!1;default:return!1}}function Hl(i){return(i.mode&1)!==0&&(i.flags&128)===0}function $l(i){if(st){var r=hi;if(r){var a=r;if(!ff(i,r)){if(Hl(i))throw Error(n(418));r=yn(a.nextSibling);var c=ui;r&&ff(i,r)?df(c,a):(i.flags=i.flags&-4097|2,st=!1,ui=i)}}else{if(Hl(i))throw Error(n(418));i.flags=i.flags&-4097|2,st=!1,ui=i}}}function pf(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;ui=i}function To(i){if(i!==ui)return!1;if(!st)return pf(i),st=!0,!1;var r;if((r=i.tag!==3)&&!(r=i.tag!==5)&&(r=i.type,r=r!=="head"&&r!=="body"&&!Tl(i.type,i.memoizedProps)),r&&(r=hi)){if(Hl(i))throw mf(),Error(n(418));for(;r;)df(i,r),r=yn(r.nextSibling)}if(pf(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){hi=yn(i.nextSibling);break e}r--}else a!=="$"&&a!=="$!"&&a!=="$?"||r++}i=i.nextSibling}hi=null}}else hi=ui?yn(i.stateNode.nextSibling):null;return!0}function mf(){for(var i=hi;i;)i=yn(i.nextSibling)}function Rr(){hi=ui=null,st=!1}function Wl(i){Li===null?Li=[i]:Li.push(i)}var uS=B.ReactCurrentBatchConfig;function ys(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(C){var T=f.refs;C===null?delete T[g]:T[g]=C},r._stringRef=g,r)}if(typeof i!="string")throw Error(n(284));if(!a._owner)throw Error(n(290,i))}return i}function jo(i,r){throw i=Object.prototype.toString.call(r),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i))}function gf(i){var r=i._init;return r(i._payload)}function vf(i){function r(te,V){if(i){var ne=te.deletions;ne===null?(te.deletions=[V],te.flags|=16):ne.push(V)}}function a(te,V){if(!i)return null;for(;V!==null;)r(te,V),V=V.sibling;return null}function c(te,V){for(te=new Map;V!==null;)V.key!==null?te.set(V.key,V):te.set(V.index,V),V=V.sibling;return te}function f(te,V){return te=Dn(te,V),te.index=0,te.sibling=null,te}function g(te,V,ne){return te.index=ne,i?(ne=te.alternate,ne!==null?(ne=ne.index,ne<V?(te.flags|=2,V):ne):(te.flags|=2,V)):(te.flags|=1048576,V)}function C(te){return i&&te.alternate===null&&(te.flags|=2),te}function T(te,V,ne,_e){return V===null||V.tag!==6?(V=jc(ne,te.mode,_e),V.return=te,V):(V=f(V,ne),V.return=te,V)}function F(te,V,ne,_e){var Me=ne.type;return Me===$?me(te,V,ne.props.children,_e,ne.key):V!==null&&(V.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===N&&gf(Me)===V.type)?(_e=f(V,ne.props),_e.ref=ys(te,V,ne),_e.return=te,_e):(_e=ra(ne.type,ne.key,ne.props,null,te.mode,_e),_e.ref=ys(te,V,ne),_e.return=te,_e)}function oe(te,V,ne,_e){return V===null||V.tag!==4||V.stateNode.containerInfo!==ne.containerInfo||V.stateNode.implementation!==ne.implementation?(V=Bc(ne,te.mode,_e),V.return=te,V):(V=f(V,ne.children||[]),V.return=te,V)}function me(te,V,ne,_e,Me){return V===null||V.tag!==7?(V=Zn(ne,te.mode,_e,Me),V.return=te,V):(V=f(V,ne),V.return=te,V)}function ge(te,V,ne){if(typeof V=="string"&&V!==""||typeof V=="number")return V=jc(""+V,te.mode,ne),V.return=te,V;if(typeof V=="object"&&V!==null){switch(V.$$typeof){case ie:return ne=ra(V.type,V.key,V.props,null,te.mode,ne),ne.ref=ys(te,null,V),ne.return=te,ne;case z:return V=Bc(V,te.mode,ne),V.return=te,V;case N:var _e=V._init;return ge(te,_e(V._payload),ne)}if(De(V)||W(V))return V=Zn(V,te.mode,ne,null),V.return=te,V;jo(te,V)}return null}function fe(te,V,ne,_e){var Me=V!==null?V.key:null;if(typeof ne=="string"&&ne!==""||typeof ne=="number")return Me!==null?null:T(te,V,""+ne,_e);if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case ie:return ne.key===Me?F(te,V,ne,_e):null;case z:return ne.key===Me?oe(te,V,ne,_e):null;case N:return Me=ne._init,fe(te,V,Me(ne._payload),_e)}if(De(ne)||W(ne))return Me!==null?null:me(te,V,ne,_e,null);jo(te,ne)}return null}function ke(te,V,ne,_e,Me){if(typeof _e=="string"&&_e!==""||typeof _e=="number")return te=te.get(ne)||null,T(V,te,""+_e,Me);if(typeof _e=="object"&&_e!==null){switch(_e.$$typeof){case ie:return te=te.get(_e.key===null?ne:_e.key)||null,F(V,te,_e,Me);case z:return te=te.get(_e.key===null?ne:_e.key)||null,oe(V,te,_e,Me);case N:var Te=_e._init;return ke(te,V,ne,Te(_e._payload),Me)}if(De(_e)||W(_e))return te=te.get(ne)||null,me(V,te,_e,Me,null);jo(V,_e)}return null}function Ne(te,V,ne,_e){for(var Me=null,Te=null,je=V,Ae=V=0,Lt=null;je!==null&&Ae<ne.length;Ae++){je.index>Ae?(Lt=je,je=null):Lt=je.sibling;var Ge=fe(te,je,ne[Ae],_e);if(Ge===null){je===null&&(je=Lt);break}i&&je&&Ge.alternate===null&&r(te,je),V=g(Ge,V,Ae),Te===null?Me=Ge:Te.sibling=Ge,Te=Ge,je=Lt}if(Ae===ne.length)return a(te,je),st&&Kn(te,Ae),Me;if(je===null){for(;Ae<ne.length;Ae++)je=ge(te,ne[Ae],_e),je!==null&&(V=g(je,V,Ae),Te===null?Me=je:Te.sibling=je,Te=je);return st&&Kn(te,Ae),Me}for(je=c(te,je);Ae<ne.length;Ae++)Lt=ke(je,te,Ae,ne[Ae],_e),Lt!==null&&(i&&Lt.alternate!==null&&je.delete(Lt.key===null?Ae:Lt.key),V=g(Lt,V,Ae),Te===null?Me=Lt:Te.sibling=Lt,Te=Lt);return i&&je.forEach(function(Mn){return r(te,Mn)}),st&&Kn(te,Ae),Me}function Pe(te,V,ne,_e){var Me=W(ne);if(typeof Me!="function")throw Error(n(150));if(ne=Me.call(ne),ne==null)throw Error(n(151));for(var Te=Me=null,je=V,Ae=V=0,Lt=null,Ge=ne.next();je!==null&&!Ge.done;Ae++,Ge=ne.next()){je.index>Ae?(Lt=je,je=null):Lt=je.sibling;var Mn=fe(te,je,Ge.value,_e);if(Mn===null){je===null&&(je=Lt);break}i&&je&&Mn.alternate===null&&r(te,je),V=g(Mn,V,Ae),Te===null?Me=Mn:Te.sibling=Mn,Te=Mn,je=Lt}if(Ge.done)return a(te,je),st&&Kn(te,Ae),Me;if(je===null){for(;!Ge.done;Ae++,Ge=ne.next())Ge=ge(te,Ge.value,_e),Ge!==null&&(V=g(Ge,V,Ae),Te===null?Me=Ge:Te.sibling=Ge,Te=Ge);return st&&Kn(te,Ae),Me}for(je=c(te,je);!Ge.done;Ae++,Ge=ne.next())Ge=ke(je,te,Ae,Ge.value,_e),Ge!==null&&(i&&Ge.alternate!==null&&je.delete(Ge.key===null?Ae:Ge.key),V=g(Ge,V,Ae),Te===null?Me=Ge:Te.sibling=Ge,Te=Ge);return i&&je.forEach(function(WS){return r(te,WS)}),st&&Kn(te,Ae),Me}function _t(te,V,ne,_e){if(typeof ne=="object"&&ne!==null&&ne.type===$&&ne.key===null&&(ne=ne.props.children),typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case ie:e:{for(var Me=ne.key,Te=V;Te!==null;){if(Te.key===Me){if(Me=ne.type,Me===$){if(Te.tag===7){a(te,Te.sibling),V=f(Te,ne.props.children),V.return=te,te=V;break e}}else if(Te.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===N&&gf(Me)===Te.type){a(te,Te.sibling),V=f(Te,ne.props),V.ref=ys(te,Te,ne),V.return=te,te=V;break e}a(te,Te);break}else r(te,Te);Te=Te.sibling}ne.type===$?(V=Zn(ne.props.children,te.mode,_e,ne.key),V.return=te,te=V):(_e=ra(ne.type,ne.key,ne.props,null,te.mode,_e),_e.ref=ys(te,V,ne),_e.return=te,te=_e)}return C(te);case z:e:{for(Te=ne.key;V!==null;){if(V.key===Te)if(V.tag===4&&V.stateNode.containerInfo===ne.containerInfo&&V.stateNode.implementation===ne.implementation){a(te,V.sibling),V=f(V,ne.children||[]),V.return=te,te=V;break e}else{a(te,V);break}else r(te,V);V=V.sibling}V=Bc(ne,te.mode,_e),V.return=te,te=V}return C(te);case N:return Te=ne._init,_t(te,V,Te(ne._payload),_e)}if(De(ne))return Ne(te,V,ne,_e);if(W(ne))return Pe(te,V,ne,_e);jo(te,ne)}return typeof ne=="string"&&ne!==""||typeof ne=="number"?(ne=""+ne,V!==null&&V.tag===6?(a(te,V.sibling),V=f(V,ne),V.return=te,te=V):(a(te,V),V=jc(ne,te.mode,_e),V.return=te,te=V),C(te)):a(te,V)}return _t}var Pr=vf(!0),_f=vf(!1),Bo=Sn(null),Ao=null,Dr=null,Ul=null;function Kl(){Ul=Dr=Ao=null}function ql(i){var r=Bo.current;nt(Bo),i._currentValue=r}function Vl(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 Mr(i,r){Ao=i,Ul=Dr=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&r)!==0&&(ii=!0),i.firstContext=null)}function wi(i){var r=i._currentValue;if(Ul!==i)if(i={context:i,memoizedValue:r,next:null},Dr===null){if(Ao===null)throw Error(n(308));Dr=i,Ao.dependencies={lanes:0,firstContext:i}}else Dr=Dr.next=i;return r}var qn=null;function Yl(i){qn===null?qn=[i]:qn.push(i)}function yf(i,r,a,c){var f=r.interleaved;return f===null?(a.next=a,Yl(r)):(a.next=f.next,f.next=a),r.interleaved=a,nn(i,c)}function nn(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 Cn=!1;function Xl(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Sf(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 rn(i,r){return{eventTime:i,lane:r,tag:0,payload:null,callback:null,next:null}}function xn(i,r,a){var c=i.updateQueue;if(c===null)return null;if(c=c.shared,(Xe&2)!==0){var f=c.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),c.pending=r,nn(i,a)}return f=c.interleaved,f===null?(r.next=r,Yl(c)):(r.next=f.next,f.next=r),c.interleaved=r,nn(i,a)}function Io(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,cl(i,a)}}function wf(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 C={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};g===null?f=g=C:g=g.next=C,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 Oo(i,r,a,c){var f=i.updateQueue;Cn=!1;var g=f.firstBaseUpdate,C=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var F=T,oe=F.next;F.next=null,C===null?g=oe:C.next=oe,C=F;var me=i.alternate;me!==null&&(me=me.updateQueue,T=me.lastBaseUpdate,T!==C&&(T===null?me.firstBaseUpdate=oe:T.next=oe,me.lastBaseUpdate=F))}if(g!==null){var ge=f.baseState;C=0,me=oe=F=null,T=g;do{var fe=T.lane,ke=T.eventTime;if((c&fe)===fe){me!==null&&(me=me.next={eventTime:ke,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var Ne=i,Pe=T;switch(fe=r,ke=a,Pe.tag){case 1:if(Ne=Pe.payload,typeof Ne=="function"){ge=Ne.call(ke,ge,fe);break e}ge=Ne;break e;case 3:Ne.flags=Ne.flags&-65537|128;case 0:if(Ne=Pe.payload,fe=typeof Ne=="function"?Ne.call(ke,ge,fe):Ne,fe==null)break e;ge=Z({},ge,fe);break e;case 2:Cn=!0}}T.callback!==null&&T.lane!==0&&(i.flags|=64,fe=f.effects,fe===null?f.effects=[T]:fe.push(T))}else ke={eventTime:ke,lane:fe,tag:T.tag,payload:T.payload,callback:T.callback,next:null},me===null?(oe=me=ke,F=ge):me=me.next=ke,C|=fe;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;fe=T,T=fe.next,fe.next=null,f.lastBaseUpdate=fe,f.shared.pending=null}}while(!0);if(me===null&&(F=ge),f.baseState=F,f.firstBaseUpdate=oe,f.lastBaseUpdate=me,r=f.shared.interleaved,r!==null){f=r;do C|=f.lane,f=f.next;while(f!==r)}else g===null&&(f.shared.lanes=0);Xn|=C,i.lanes=C,i.memoizedState=ge}}function bf(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 Ss={},Hi=Sn(Ss),ws=Sn(Ss),bs=Sn(Ss);function Vn(i){if(i===Ss)throw Error(n(174));return i}function Gl(i,r){switch(tt(bs,r),tt(ws,i),tt(Hi,Ss),i=r.nodeType,i){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Be(null,"");break;default:i=i===8?r.parentNode:r,r=i.namespaceURI||null,i=i.tagName,r=Be(r,i)}nt(Hi),tt(Hi,r)}function Lr(){nt(Hi),nt(ws),nt(bs)}function Cf(i){Vn(bs.current);var r=Vn(Hi.current),a=Be(r,i.type);r!==a&&(tt(ws,i),tt(Hi,a))}function Ql(i){ws.current===i&&(nt(Hi),nt(ws))}var lt=Sn(0);function zo(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 Jl=[];function Zl(){for(var i=0;i<Jl.length;i++)Jl[i]._workInProgressVersionPrimary=null;Jl.length=0}var Fo=B.ReactCurrentDispatcher,ec=B.ReactCurrentBatchConfig,Yn=0,ct=null,kt=null,Dt=null,Ho=!1,Cs=!1,xs=0,hS=0;function Ut(){throw Error(n(321))}function tc(i,r){if(r===null)return!1;for(var a=0;a<r.length&&a<i.length;a++)if(!Mi(i[a],r[a]))return!1;return!0}function ic(i,r,a,c,f,g){if(Yn=g,ct=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Fo.current=i===null||i.memoizedState===null?mS:gS,i=a(c,f),Cs){g=0;do{if(Cs=!1,xs=0,25<=g)throw Error(n(301));g+=1,Dt=kt=null,r.updateQueue=null,Fo.current=vS,i=a(c,f)}while(Cs)}if(Fo.current=Uo,r=kt!==null&&kt.next!==null,Yn=0,Dt=kt=ct=null,Ho=!1,r)throw Error(n(300));return i}function nc(){var i=xs!==0;return xs=0,i}function $i(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Dt===null?ct.memoizedState=Dt=i:Dt=Dt.next=i,Dt}function bi(){if(kt===null){var i=ct.alternate;i=i!==null?i.memoizedState:null}else i=kt.next;var r=Dt===null?ct.memoizedState:Dt.next;if(r!==null)Dt=r,kt=i;else{if(i===null)throw Error(n(310));kt=i,i={memoizedState:kt.memoizedState,baseState:kt.baseState,baseQueue:kt.baseQueue,queue:kt.queue,next:null},Dt===null?ct.memoizedState=Dt=i:Dt=Dt.next=i}return Dt}function ks(i,r){return typeof r=="function"?r(i):r}function rc(i){var r=bi(),a=r.queue;if(a===null)throw Error(n(311));a.lastRenderedReducer=i;var c=kt,f=c.baseQueue,g=a.pending;if(g!==null){if(f!==null){var C=f.next;f.next=g.next,g.next=C}c.baseQueue=f=g,a.pending=null}if(f!==null){g=f.next,c=c.baseState;var T=C=null,F=null,oe=g;do{var me=oe.lane;if((Yn&me)===me)F!==null&&(F=F.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 ge={lane:me,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null};F===null?(T=F=ge,C=c):F=F.next=ge,ct.lanes|=me,Xn|=me}oe=oe.next}while(oe!==null&&oe!==g);F===null?C=c:F.next=T,Mi(c,r.memoizedState)||(ii=!0),r.memoizedState=c,r.baseState=C,r.baseQueue=F,a.lastRenderedState=c}if(i=a.interleaved,i!==null){f=i;do g=f.lane,ct.lanes|=g,Xn|=g,f=f.next;while(f!==i)}else f===null&&(a.lanes=0);return[r.memoizedState,a.dispatch]}function sc(i){var r=bi(),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 C=f=f.next;do g=i(g,C.action),C=C.next;while(C!==f);Mi(g,r.memoizedState)||(ii=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),a.lastRenderedState=g}return[g,c]}function xf(){}function kf(i,r){var a=ct,c=bi(),f=r(),g=!Mi(c.memoizedState,f);if(g&&(c.memoizedState=f,ii=!0),c=c.queue,oc(Rf.bind(null,a,c,i),[i]),c.getSnapshot!==r||g||Dt!==null&&Dt.memoizedState.tag&1){if(a.flags|=2048,Es(9,Nf.bind(null,a,c,f,r),void 0,null),Mt===null)throw Error(n(349));(Yn&30)!==0||Ef(a,r,f)}return f}function Ef(i,r,a){i.flags|=16384,i={getSnapshot:r,value:a},r=ct.updateQueue,r===null?(r={lastEffect:null,stores:null},ct.updateQueue=r,r.stores=[i]):(a=r.stores,a===null?r.stores=[i]:a.push(i))}function Nf(i,r,a,c){r.value=a,r.getSnapshot=c,Pf(r)&&Df(i)}function Rf(i,r,a){return a(function(){Pf(r)&&Df(i)})}function Pf(i){var r=i.getSnapshot;i=i.value;try{var a=r();return!Mi(i,a)}catch{return!0}}function Df(i){var r=nn(i,1);r!==null&&Ai(r,i,1,-1)}function Mf(i){var r=$i();return typeof i=="function"&&(i=i()),r.memoizedState=r.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ks,lastRenderedState:i},r.queue=i,i=i.dispatch=pS.bind(null,ct,i),[r.memoizedState,i]}function Es(i,r,a,c){return i={tag:i,create:r,destroy:a,deps:c,next:null},r=ct.updateQueue,r===null?(r={lastEffect:null,stores:null},ct.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 Lf(){return bi().memoizedState}function $o(i,r,a,c){var f=$i();ct.flags|=i,f.memoizedState=Es(1|r,a,void 0,c===void 0?null:c)}function Wo(i,r,a,c){var f=bi();c=c===void 0?null:c;var g=void 0;if(kt!==null){var C=kt.memoizedState;if(g=C.destroy,c!==null&&tc(c,C.deps)){f.memoizedState=Es(r,a,g,c);return}}ct.flags|=i,f.memoizedState=Es(1|r,a,g,c)}function Tf(i,r){return $o(8390656,8,i,r)}function oc(i,r){return Wo(2048,8,i,r)}function jf(i,r){return Wo(4,2,i,r)}function Bf(i,r){return Wo(4,4,i,r)}function Af(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 If(i,r,a){return a=a!=null?a.concat([i]):null,Wo(4,4,Af.bind(null,r,i),a)}function ac(){}function Of(i,r){var a=bi();r=r===void 0?null:r;var c=a.memoizedState;return c!==null&&r!==null&&tc(r,c[1])?c[0]:(a.memoizedState=[i,r],i)}function zf(i,r){var a=bi();r=r===void 0?null:r;var c=a.memoizedState;return c!==null&&r!==null&&tc(r,c[1])?c[0]:(i=i(),a.memoizedState=[i,r],i)}function Ff(i,r,a){return(Yn&21)===0?(i.baseState&&(i.baseState=!1,ii=!0),i.memoizedState=a):(Mi(a,r)||(a=md(),ct.lanes|=a,Xn|=a,i.baseState=!0),r)}function dS(i,r){var a=Ze;Ze=a!==0&&4>a?a:4,i(!0);var c=ec.transition;ec.transition={};try{i(!1),r()}finally{Ze=a,ec.transition=c}}function Hf(){return bi().memoizedState}function fS(i,r,a){var c=Rn(i);if(a={lane:c,action:a,hasEagerState:!1,eagerState:null,next:null},$f(i))Wf(r,a);else if(a=yf(i,r,a,c),a!==null){var f=Gt();Ai(a,i,c,f),Uf(a,r,c)}}function pS(i,r,a){var c=Rn(i),f={lane:c,action:a,hasEagerState:!1,eagerState:null,next:null};if($f(i))Wf(r,f);else{var g=i.alternate;if(i.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var C=r.lastRenderedState,T=g(C,a);if(f.hasEagerState=!0,f.eagerState=T,Mi(T,C)){var F=r.interleaved;F===null?(f.next=f,Yl(r)):(f.next=F.next,F.next=f),r.interleaved=f;return}}catch{}finally{}a=yf(i,r,f,c),a!==null&&(f=Gt(),Ai(a,i,c,f),Uf(a,r,c))}}function $f(i){var r=i.alternate;return i===ct||r!==null&&r===ct}function Wf(i,r){Cs=Ho=!0;var a=i.pending;a===null?r.next=r:(r.next=a.next,a.next=r),i.pending=r}function Uf(i,r,a){if((a&4194240)!==0){var c=r.lanes;c&=i.pendingLanes,a|=c,r.lanes=a,cl(i,a)}}var Uo={readContext:wi,useCallback:Ut,useContext:Ut,useEffect:Ut,useImperativeHandle:Ut,useInsertionEffect:Ut,useLayoutEffect:Ut,useMemo:Ut,useReducer:Ut,useRef:Ut,useState:Ut,useDebugValue:Ut,useDeferredValue:Ut,useTransition:Ut,useMutableSource:Ut,useSyncExternalStore:Ut,useId:Ut,unstable_isNewReconciler:!1},mS={readContext:wi,useCallback:function(i,r){return $i().memoizedState=[i,r===void 0?null:r],i},useContext:wi,useEffect:Tf,useImperativeHandle:function(i,r,a){return a=a!=null?a.concat([i]):null,$o(4194308,4,Af.bind(null,r,i),a)},useLayoutEffect:function(i,r){return $o(4194308,4,i,r)},useInsertionEffect:function(i,r){return $o(4,2,i,r)},useMemo:function(i,r){var a=$i();return r=r===void 0?null:r,i=i(),a.memoizedState=[i,r],i},useReducer:function(i,r,a){var c=$i();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=fS.bind(null,ct,i),[c.memoizedState,i]},useRef:function(i){var r=$i();return i={current:i},r.memoizedState=i},useState:Mf,useDebugValue:ac,useDeferredValue:function(i){return $i().memoizedState=i},useTransition:function(){var i=Mf(!1),r=i[0];return i=dS.bind(null,i[1]),$i().memoizedState=i,[r,i]},useMutableSource:function(){},useSyncExternalStore:function(i,r,a){var c=ct,f=$i();if(st){if(a===void 0)throw Error(n(407));a=a()}else{if(a=r(),Mt===null)throw Error(n(349));(Yn&30)!==0||Ef(c,r,a)}f.memoizedState=a;var g={value:a,getSnapshot:r};return f.queue=g,Tf(Rf.bind(null,c,g,i),[i]),c.flags|=2048,Es(9,Nf.bind(null,c,g,a,r),void 0,null),a},useId:function(){var i=$i(),r=Mt.identifierPrefix;if(st){var a=tn,c=en;a=(c&~(1<<32-Di(c)-1)).toString(32)+a,r=":"+r+"R"+a,a=xs++,0<a&&(r+="H"+a.toString(32)),r+=":"}else a=hS++,r=":"+r+"r"+a.toString(32)+":";return i.memoizedState=r},unstable_isNewReconciler:!1},gS={readContext:wi,useCallback:Of,useContext:wi,useEffect:oc,useImperativeHandle:If,useInsertionEffect:jf,useLayoutEffect:Bf,useMemo:zf,useReducer:rc,useRef:Lf,useState:function(){return rc(ks)},useDebugValue:ac,useDeferredValue:function(i){var r=bi();return Ff(r,kt.memoizedState,i)},useTransition:function(){var i=rc(ks)[0],r=bi().memoizedState;return[i,r]},useMutableSource:xf,useSyncExternalStore:kf,useId:Hf,unstable_isNewReconciler:!1},vS={readContext:wi,useCallback:Of,useContext:wi,useEffect:oc,useImperativeHandle:If,useInsertionEffect:jf,useLayoutEffect:Bf,useMemo:zf,useReducer:sc,useRef:Lf,useState:function(){return sc(ks)},useDebugValue:ac,useDeferredValue:function(i){var r=bi();return kt===null?r.memoizedState=i:Ff(r,kt.memoizedState,i)},useTransition:function(){var i=sc(ks)[0],r=bi().memoizedState;return[i,r]},useMutableSource:xf,useSyncExternalStore:kf,useId:Hf,unstable_isNewReconciler:!1};function Ti(i,r){if(i&&i.defaultProps){r=Z({},r),i=i.defaultProps;for(var a in i)r[a]===void 0&&(r[a]=i[a]);return r}return r}function lc(i,r,a,c){r=i.memoizedState,a=a(c,r),a=a==null?r:Z({},r,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Ko={isMounted:function(i){return(i=i._reactInternals)?Hn(i)===i:!1},enqueueSetState:function(i,r,a){i=i._reactInternals;var c=Gt(),f=Rn(i),g=rn(c,f);g.payload=r,a!=null&&(g.callback=a),r=xn(i,g,f),r!==null&&(Ai(r,i,f,c),Io(r,i,f))},enqueueReplaceState:function(i,r,a){i=i._reactInternals;var c=Gt(),f=Rn(i),g=rn(c,f);g.tag=1,g.payload=r,a!=null&&(g.callback=a),r=xn(i,g,f),r!==null&&(Ai(r,i,f,c),Io(r,i,f))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var a=Gt(),c=Rn(i),f=rn(a,c);f.tag=2,r!=null&&(f.callback=r),r=xn(i,f,c),r!==null&&(Ai(r,i,c,a),Io(r,i,c))}};function Kf(i,r,a,c,f,g,C){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(c,g,C):r.prototype&&r.prototype.isPureReactComponent?!ds(a,c)||!ds(f,g):!0}function qf(i,r,a){var c=!1,f=wn,g=r.contextType;return typeof g=="object"&&g!==null?g=wi(g):(f=ti(r)?Wn:Wt.current,c=r.contextTypes,g=(c=c!=null)?kr(i,f):wn),r=new r(a,g),i.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=Ko,i.stateNode=r,r._reactInternals=i,c&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=f,i.__reactInternalMemoizedMaskedChildContext=g),r}function Vf(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&&Ko.enqueueReplaceState(r,r.state,null)}function cc(i,r,a,c){var f=i.stateNode;f.props=a,f.state=i.memoizedState,f.refs={},Xl(i);var g=r.contextType;typeof g=="object"&&g!==null?f.context=wi(g):(g=ti(r)?Wn:Wt.current,f.context=kr(i,g)),f.state=i.memoizedState,g=r.getDerivedStateFromProps,typeof g=="function"&&(lc(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&&Ko.enqueueReplaceState(f,f.state,null),Oo(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+=le(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 uc(i,r,a){return{value:i,source:null,stack:a??null,digest:r??null}}function hc(i,r){try{console.error(r.value)}catch(a){setTimeout(function(){throw a})}}var _S=typeof WeakMap=="function"?WeakMap:Map;function Yf(i,r,a){a=rn(-1,a),a.tag=3,a.payload={element:null};var c=r.value;return a.callback=function(){Jo||(Jo=!0,Ec=c),hc(i,r)},a}function Xf(i,r,a){a=rn(-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(){hc(i,r)}}var g=i.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(a.callback=function(){hc(i,r),typeof c!="function"&&(En===null?En=new Set([this]):En.add(this));var C=r.stack;this.componentDidCatch(r.value,{componentStack:C!==null?C:""})}),a}function Gf(i,r,a){var c=i.pingCache;if(c===null){c=i.pingCache=new _S;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=LS.bind(null,i,r,a),r.then(i,i))}function Qf(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 Jf(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=rn(-1,1),r.tag=2,xn(a,r,1))),a.lanes|=1),i):(i.flags|=65536,i.lanes=f,i)}var yS=B.ReactCurrentOwner,ii=!1;function Xt(i,r,a,c){r.child=i===null?_f(r,null,a,c):Pr(r,i.child,a,c)}function Zf(i,r,a,c,f){a=a.render;var g=r.ref;return Mr(r,f),c=ic(i,r,a,c,g,f),a=nc(),i!==null&&!ii?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~f,sn(i,r,f)):(st&&a&&zl(r),r.flags|=1,Xt(i,r,c,f),r.child)}function ep(i,r,a,c,f){if(i===null){var g=a.type;return typeof g=="function"&&!Tc(g)&&g.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(r.tag=15,r.type=g,tp(i,r,g,c,f)):(i=ra(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 C=g.memoizedProps;if(a=a.compare,a=a!==null?a:ds,a(C,c)&&i.ref===r.ref)return sn(i,r,f)}return r.flags|=1,i=Dn(g,c),i.ref=r.ref,i.return=r,r.child=i}function tp(i,r,a,c,f){if(i!==null){var g=i.memoizedProps;if(ds(g,c)&&i.ref===r.ref)if(ii=!1,r.pendingProps=c=g,(i.lanes&f)!==0)(i.flags&131072)!==0&&(ii=!0);else return r.lanes=i.lanes,sn(i,r,f)}return dc(i,r,a,c,f)}function ip(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},tt(Br,di),di|=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,tt(Br,di),di|=i,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=g!==null?g.baseLanes:a,tt(Br,di),di|=c}else g!==null?(c=g.baseLanes|a,r.memoizedState=null):c=a,tt(Br,di),di|=c;return Xt(i,r,f,a),r.child}function np(i,r){var a=r.ref;(i===null&&a!==null||i!==null&&i.ref!==a)&&(r.flags|=512,r.flags|=2097152)}function dc(i,r,a,c,f){var g=ti(a)?Wn:Wt.current;return g=kr(r,g),Mr(r,f),a=ic(i,r,a,c,g,f),c=nc(),i!==null&&!ii?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~f,sn(i,r,f)):(st&&c&&zl(r),r.flags|=1,Xt(i,r,a,f),r.child)}function rp(i,r,a,c,f){if(ti(a)){var g=!0;Po(r)}else g=!1;if(Mr(r,f),r.stateNode===null)Vo(i,r),qf(r,a,c),cc(r,a,c,f),c=!0;else if(i===null){var C=r.stateNode,T=r.memoizedProps;C.props=T;var F=C.context,oe=a.contextType;typeof oe=="object"&&oe!==null?oe=wi(oe):(oe=ti(a)?Wn:Wt.current,oe=kr(r,oe));var me=a.getDerivedStateFromProps,ge=typeof me=="function"||typeof C.getSnapshotBeforeUpdate=="function";ge||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(T!==c||F!==oe)&&Vf(r,C,c,oe),Cn=!1;var fe=r.memoizedState;C.state=fe,Oo(r,c,C,f),F=r.memoizedState,T!==c||fe!==F||ei.current||Cn?(typeof me=="function"&&(lc(r,a,me,c),F=r.memoizedState),(T=Cn||Kf(r,a,T,c,fe,F,oe))?(ge||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount()),typeof C.componentDidMount=="function"&&(r.flags|=4194308)):(typeof C.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=F),C.props=c,C.state=F,C.context=oe,c=T):(typeof C.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{C=r.stateNode,Sf(i,r),T=r.memoizedProps,oe=r.type===r.elementType?T:Ti(r.type,T),C.props=oe,ge=r.pendingProps,fe=C.context,F=a.contextType,typeof F=="object"&&F!==null?F=wi(F):(F=ti(a)?Wn:Wt.current,F=kr(r,F));var ke=a.getDerivedStateFromProps;(me=typeof ke=="function"||typeof C.getSnapshotBeforeUpdate=="function")||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(T!==ge||fe!==F)&&Vf(r,C,c,F),Cn=!1,fe=r.memoizedState,C.state=fe,Oo(r,c,C,f);var Ne=r.memoizedState;T!==ge||fe!==Ne||ei.current||Cn?(typeof ke=="function"&&(lc(r,a,ke,c),Ne=r.memoizedState),(oe=Cn||Kf(r,a,oe,c,fe,Ne,F)||!1)?(me||typeof C.UNSAFE_componentWillUpdate!="function"&&typeof C.componentWillUpdate!="function"||(typeof C.componentWillUpdate=="function"&&C.componentWillUpdate(c,Ne,F),typeof C.UNSAFE_componentWillUpdate=="function"&&C.UNSAFE_componentWillUpdate(c,Ne,F)),typeof C.componentDidUpdate=="function"&&(r.flags|=4),typeof C.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof C.componentDidUpdate!="function"||T===i.memoizedProps&&fe===i.memoizedState||(r.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||T===i.memoizedProps&&fe===i.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=Ne),C.props=c,C.state=Ne,C.context=F,c=oe):(typeof C.componentDidUpdate!="function"||T===i.memoizedProps&&fe===i.memoizedState||(r.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||T===i.memoizedProps&&fe===i.memoizedState||(r.flags|=1024),c=!1)}return fc(i,r,a,c,g,f)}function fc(i,r,a,c,f,g){np(i,r);var C=(r.flags&128)!==0;if(!c&&!C)return f&&cf(r,a,!1),sn(i,r,g);c=r.stateNode,yS.current=r;var T=C&&typeof a.getDerivedStateFromError!="function"?null:c.render();return r.flags|=1,i!==null&&C?(r.child=Pr(r,i.child,null,g),r.child=Pr(r,null,T,g)):Xt(i,r,T,g),r.memoizedState=c.state,f&&cf(r,a,!0),r.child}function sp(i){var r=i.stateNode;r.pendingContext?af(i,r.pendingContext,r.pendingContext!==r.context):r.context&&af(i,r.context,!1),Gl(i,r.containerInfo)}function op(i,r,a,c,f){return Rr(),Wl(f),r.flags|=256,Xt(i,r,a,c),r.child}var pc={dehydrated:null,treeContext:null,retryLane:0};function mc(i){return{baseLanes:i,cachePool:null,transitions:null}}function ap(i,r,a){var c=r.pendingProps,f=lt.current,g=!1,C=(r.flags&128)!==0,T;if((T=C)||(T=i!==null&&i.memoizedState===null?!1:(f&2)!==0),T?(g=!0,r.flags&=-129):(i===null||i.memoizedState!==null)&&(f|=1),tt(lt,f&1),i===null)return $l(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):(C=c.children,i=c.fallback,g?(c=r.mode,g=r.child,C={mode:"hidden",children:C},(c&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=C):g=sa(C,c,0,null),i=Zn(i,c,a,null),g.return=r,i.return=r,g.sibling=i,r.child=g,r.child.memoizedState=mc(a),r.memoizedState=pc,i):gc(r,C));if(f=i.memoizedState,f!==null&&(T=f.dehydrated,T!==null))return SS(i,r,C,c,T,f,a);if(g){g=c.fallback,C=r.mode,f=i.child,T=f.sibling;var F={mode:"hidden",children:c.children};return(C&1)===0&&r.child!==f?(c=r.child,c.childLanes=0,c.pendingProps=F,r.deletions=null):(c=Dn(f,F),c.subtreeFlags=f.subtreeFlags&14680064),T!==null?g=Dn(T,g):(g=Zn(g,C,a,null),g.flags|=2),g.return=r,c.return=r,c.sibling=g,r.child=c,c=g,g=r.child,C=i.child.memoizedState,C=C===null?mc(a):{baseLanes:C.baseLanes|a,cachePool:null,transitions:C.transitions},g.memoizedState=C,g.childLanes=i.childLanes&~a,r.memoizedState=pc,c}return g=i.child,i=g.sibling,c=Dn(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 gc(i,r){return r=sa({mode:"visible",children:r},i.mode,0,null),r.return=i,i.child=r}function qo(i,r,a,c){return c!==null&&Wl(c),Pr(r,i.child,null,a),i=gc(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function SS(i,r,a,c,f,g,C){if(a)return r.flags&256?(r.flags&=-257,c=uc(Error(n(422))),qo(i,r,C,c)):r.memoizedState!==null?(r.child=i.child,r.flags|=128,null):(g=c.fallback,f=r.mode,c=sa({mode:"visible",children:c.children},f,0,null),g=Zn(g,f,C,null),g.flags|=2,c.return=r,g.return=r,c.sibling=g,r.child=c,(r.mode&1)!==0&&Pr(r,i.child,null,C),r.child.memoizedState=mc(C),r.memoizedState=pc,g);if((r.mode&1)===0)return qo(i,r,C,null);if(f.data==="$!"){if(c=f.nextSibling&&f.nextSibling.dataset,c)var T=c.dgst;return c=T,g=Error(n(419)),c=uc(g,c,void 0),qo(i,r,C,c)}if(T=(C&i.childLanes)!==0,ii||T){if(c=Mt,c!==null){switch(C&-C){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|C))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,nn(i,f),Ai(c,i,f,-1))}return Lc(),c=uc(Error(n(421))),qo(i,r,C,c)}return f.data==="$?"?(r.flags|=128,r.child=i.child,r=TS.bind(null,i),f._reactRetry=r,null):(i=g.treeContext,hi=yn(f.nextSibling),ui=r,st=!0,Li=null,i!==null&&(yi[Si++]=en,yi[Si++]=tn,yi[Si++]=Un,en=i.id,tn=i.overflow,Un=r),r=gc(r,c.children),r.flags|=4096,r)}function lp(i,r,a){i.lanes|=r;var c=i.alternate;c!==null&&(c.lanes|=r),Vl(i.return,r,a)}function vc(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 cp(i,r,a){var c=r.pendingProps,f=c.revealOrder,g=c.tail;if(Xt(i,r,c.children,a),c=lt.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&&lp(i,a,r);else if(i.tag===19)lp(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(tt(lt,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&&zo(i)===null&&(f=a),a=a.sibling;a=f,a===null?(f=r.child,r.child=null):(f=a.sibling,a.sibling=null),vc(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&&zo(i)===null){r.child=f;break}i=f.sibling,f.sibling=a,a=f,f=i}vc(r,!0,a,null,g);break;case"together":vc(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function Vo(i,r){(r.mode&1)===0&&i!==null&&(i.alternate=null,r.alternate=null,r.flags|=2)}function sn(i,r,a){if(i!==null&&(r.dependencies=i.dependencies),Xn|=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=Dn(i,i.pendingProps),r.child=a,a.return=r;i.sibling!==null;)i=i.sibling,a=a.sibling=Dn(i,i.pendingProps),a.return=r;a.sibling=null}return r.child}function wS(i,r,a){switch(r.tag){case 3:sp(r),Rr();break;case 5:Cf(r);break;case 1:ti(r.type)&&Po(r);break;case 4:Gl(r,r.stateNode.containerInfo);break;case 10:var c=r.type._context,f=r.memoizedProps.value;tt(Bo,c._currentValue),c._currentValue=f;break;case 13:if(c=r.memoizedState,c!==null)return c.dehydrated!==null?(tt(lt,lt.current&1),r.flags|=128,null):(a&r.child.childLanes)!==0?ap(i,r,a):(tt(lt,lt.current&1),i=sn(i,r,a),i!==null?i.sibling:null);tt(lt,lt.current&1);break;case 19:if(c=(a&r.childLanes)!==0,(i.flags&128)!==0){if(c)return cp(i,r,a);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),tt(lt,lt.current),c)break;return null;case 22:case 23:return r.lanes=0,ip(i,r,a)}return sn(i,r,a)}var up,_c,hp,dp;up=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}},_c=function(){},hp=function(i,r,a,c){var f=i.memoizedProps;if(f!==c){i=r.stateNode,Vn(Hi.current);var g=null;switch(a){case"input":f=we(i,f),c=we(i,c),g=[];break;case"select":f=Z({},f,{value:void 0}),c=Z({},c,{value:void 0}),g=[];break;case"textarea":f=qe(i,f),c=qe(i,c),g=[];break;default:typeof f.onClick!="function"&&typeof c.onClick=="function"&&(i.onclick=Eo)}dt(a,c);var C;a=null;for(oe in f)if(!c.hasOwnProperty(oe)&&f.hasOwnProperty(oe)&&f[oe]!=null)if(oe==="style"){var T=f[oe];for(C in T)T.hasOwnProperty(C)&&(a||(a={}),a[C]="")}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 F=c[oe];if(T=f!=null?f[oe]:void 0,c.hasOwnProperty(oe)&&F!==T&&(F!=null||T!=null))if(oe==="style")if(T){for(C in T)!T.hasOwnProperty(C)||F&&F.hasOwnProperty(C)||(a||(a={}),a[C]="");for(C in F)F.hasOwnProperty(C)&&T[C]!==F[C]&&(a||(a={}),a[C]=F[C])}else a||(g||(g=[]),g.push(oe,a)),a=F;else oe==="dangerouslySetInnerHTML"?(F=F?F.__html:void 0,T=T?T.__html:void 0,F!=null&&T!==F&&(g=g||[]).push(oe,F)):oe==="children"?typeof F!="string"&&typeof F!="number"||(g=g||[]).push(oe,""+F):oe!=="suppressContentEditableWarning"&&oe!=="suppressHydrationWarning"&&(o.hasOwnProperty(oe)?(F!=null&&oe==="onScroll"&&it("scroll",i),g||T===F||(g=[])):(g=g||[]).push(oe,F))}a&&(g=g||[]).push("style",a);var oe=g;(r.updateQueue=oe)&&(r.flags|=4)}},dp=function(i,r,a,c){a!==c&&(r.flags|=4)};function Ns(i,r){if(!st)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 Kt(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 bS(i,r,a){var c=r.pendingProps;switch(Fl(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Kt(r),null;case 1:return ti(r.type)&&Ro(),Kt(r),null;case 3:return c=r.stateNode,Lr(),nt(ei),nt(Wt),Zl(),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,Li!==null&&(Pc(Li),Li=null))),_c(i,r),Kt(r),null;case 5:Ql(r);var f=Vn(bs.current);if(a=r.type,i!==null&&r.stateNode!=null)hp(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 Kt(r),null}if(i=Vn(Hi.current),To(r)){c=r.stateNode,a=r.type;var g=r.memoizedProps;switch(c[Fi]=r,c[vs]=g,i=(r.mode&1)!==0,a){case"dialog":it("cancel",c),it("close",c);break;case"iframe":case"object":case"embed":it("load",c);break;case"video":case"audio":for(f=0;f<ps.length;f++)it(ps[f],c);break;case"source":it("error",c);break;case"img":case"image":case"link":it("error",c),it("load",c);break;case"details":it("toggle",c);break;case"input":O(c,g),it("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!g.multiple},it("invalid",c);break;case"textarea":Ye(c,g),it("invalid",c)}dt(a,g),f=null;for(var C in g)if(g.hasOwnProperty(C)){var T=g[C];C==="children"?typeof T=="string"?c.textContent!==T&&(g.suppressHydrationWarning!==!0&&ko(c.textContent,T,i),f=["children",T]):typeof T=="number"&&c.textContent!==""+T&&(g.suppressHydrationWarning!==!0&&ko(c.textContent,T,i),f=["children",""+T]):o.hasOwnProperty(C)&&T!=null&&C==="onScroll"&&it("scroll",c)}switch(a){case"input":Re(c),Le(c,g,!0);break;case"textarea":Re(c),ze(c);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(c.onclick=Eo)}c=f,r.updateQueue=c,c!==null&&(r.flags|=4)}else{C=f.nodeType===9?f:f.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=at(a)),i==="http://www.w3.org/1999/xhtml"?a==="script"?(i=C.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof c.is=="string"?i=C.createElement(a,{is:c.is}):(i=C.createElement(a),a==="select"&&(C=i,c.multiple?C.multiple=!0:c.size&&(C.size=c.size))):i=C.createElementNS(i,a),i[Fi]=r,i[vs]=c,up(i,r,!1,!1),r.stateNode=i;e:{switch(C=Yt(a,c),a){case"dialog":it("cancel",i),it("close",i),f=c;break;case"iframe":case"object":case"embed":it("load",i),f=c;break;case"video":case"audio":for(f=0;f<ps.length;f++)it(ps[f],i);f=c;break;case"source":it("error",i),f=c;break;case"img":case"image":case"link":it("error",i),it("load",i),f=c;break;case"details":it("toggle",i),f=c;break;case"input":O(i,c),f=we(i,c),it("invalid",i);break;case"option":f=c;break;case"select":i._wrapperState={wasMultiple:!!c.multiple},f=Z({},c,{value:void 0}),it("invalid",i);break;case"textarea":Ye(i,c),f=qe(i,c),it("invalid",i);break;default:f=c}dt(a,f),T=f;for(g in T)if(T.hasOwnProperty(g)){var F=T[g];g==="style"?xe(i,F):g==="dangerouslySetInnerHTML"?(F=F?F.__html:void 0,F!=null&&Pi(i,F)):g==="children"?typeof F=="string"?(a!=="textarea"||F!=="")&&xt(i,F):typeof F=="number"&&xt(i,""+F):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(o.hasOwnProperty(g)?F!=null&&g==="onScroll"&&it("scroll",i):F!=null&&A(i,g,F,C))}switch(a){case"input":Re(i),Le(i,c,!1);break;case"textarea":Re(i),ze(i);break;case"option":c.value!=null&&i.setAttribute("value",""+ye(c.value));break;case"select":i.multiple=!!c.multiple,g=c.value,g!=null?Qe(i,!!c.multiple,g,!1):c.defaultValue!=null&&Qe(i,!!c.multiple,c.defaultValue,!0);break;default:typeof f.onClick=="function"&&(i.onclick=Eo)}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 Kt(r),null;case 6:if(i&&r.stateNode!=null)dp(i,r,i.memoizedProps,c);else{if(typeof c!="string"&&r.stateNode===null)throw Error(n(166));if(a=Vn(bs.current),Vn(Hi.current),To(r)){if(c=r.stateNode,a=r.memoizedProps,c[Fi]=r,(g=c.nodeValue!==a)&&(i=ui,i!==null))switch(i.tag){case 3:ko(c.nodeValue,a,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&ko(c.nodeValue,a,(i.mode&1)!==0)}g&&(r.flags|=4)}else c=(a.nodeType===9?a:a.ownerDocument).createTextNode(c),c[Fi]=r,r.stateNode=c}return Kt(r),null;case 13:if(nt(lt),c=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(st&&hi!==null&&(r.mode&1)!==0&&(r.flags&128)===0)mf(),Rr(),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[Fi]=r}else Rr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Kt(r),g=!1}else Li!==null&&(Pc(Li),Li=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||(lt.current&1)!==0?Et===0&&(Et=3):Lc())),r.updateQueue!==null&&(r.flags|=4),Kt(r),null);case 4:return Lr(),_c(i,r),i===null&&ms(r.stateNode.containerInfo),Kt(r),null;case 10:return ql(r.type._context),Kt(r),null;case 17:return ti(r.type)&&Ro(),Kt(r),null;case 19:if(nt(lt),g=r.memoizedState,g===null)return Kt(r),null;if(c=(r.flags&128)!==0,C=g.rendering,C===null)if(c)Ns(g,!1);else{if(Et!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(C=zo(i),C!==null){for(r.flags|=128,Ns(g,!1),c=C.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,C=g.alternate,C===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=C.childLanes,g.lanes=C.lanes,g.child=C.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=C.memoizedProps,g.memoizedState=C.memoizedState,g.updateQueue=C.updateQueue,g.type=C.type,i=C.dependencies,g.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),a=a.sibling;return tt(lt,lt.current&1|2),r.child}i=i.sibling}g.tail!==null&&vt()>Ar&&(r.flags|=128,c=!0,Ns(g,!1),r.lanes=4194304)}else{if(!c)if(i=zo(C),i!==null){if(r.flags|=128,c=!0,a=i.updateQueue,a!==null&&(r.updateQueue=a,r.flags|=4),Ns(g,!0),g.tail===null&&g.tailMode==="hidden"&&!C.alternate&&!st)return Kt(r),null}else 2*vt()-g.renderingStartTime>Ar&&a!==1073741824&&(r.flags|=128,c=!0,Ns(g,!1),r.lanes=4194304);g.isBackwards?(C.sibling=r.child,r.child=C):(a=g.last,a!==null?a.sibling=C:r.child=C,g.last=C)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=vt(),r.sibling=null,a=lt.current,tt(lt,c?a&1|2:a&1),r):(Kt(r),null);case 22:case 23:return Mc(),c=r.memoizedState!==null,i!==null&&i.memoizedState!==null!==c&&(r.flags|=8192),c&&(r.mode&1)!==0?(di&1073741824)!==0&&(Kt(r),r.subtreeFlags&6&&(r.flags|=8192)):Kt(r),null;case 24:return null;case 25:return null}throw Error(n(156,r.tag))}function CS(i,r){switch(Fl(r),r.tag){case 1:return ti(r.type)&&Ro(),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return Lr(),nt(ei),nt(Wt),Zl(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 5:return Ql(r),null;case 13:if(nt(lt),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(n(340));Rr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return nt(lt),null;case 4:return Lr(),null;case 10:return ql(r.type._context),null;case 22:case 23:return Mc(),null;case 24:return null;default:return null}}var Yo=!1,qt=!1,xS=typeof WeakSet=="function"?WeakSet:Set,Ee=null;function jr(i,r){var a=i.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(c){ft(i,r,c)}else a.current=null}function yc(i,r,a){try{a()}catch(c){ft(i,r,c)}}var fp=!1;function kS(i,r){if(Ml=po,i=Ud(),Cl(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 C=0,T=-1,F=-1,oe=0,me=0,ge=i,fe=null;t:for(;;){for(var ke;ge!==a||f!==0&&ge.nodeType!==3||(T=C+f),ge!==g||c!==0&&ge.nodeType!==3||(F=C+c),ge.nodeType===3&&(C+=ge.nodeValue.length),(ke=ge.firstChild)!==null;)fe=ge,ge=ke;for(;;){if(ge===i)break t;if(fe===a&&++oe===f&&(T=C),fe===g&&++me===c&&(F=C),(ke=ge.nextSibling)!==null)break;ge=fe,fe=ge.parentNode}ge=ke}a=T===-1||F===-1?null:{start:T,end:F}}else a=null}a=a||{start:0,end:0}}else a=null;for(Ll={focusedElem:i,selectionRange:a},po=!1,Ee=r;Ee!==null;)if(r=Ee,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Ee=i;else for(;Ee!==null;){r=Ee;try{var Ne=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Ne!==null){var Pe=Ne.memoizedProps,_t=Ne.memoizedState,te=r.stateNode,V=te.getSnapshotBeforeUpdate(r.elementType===r.type?Pe:Ti(r.type,Pe),_t);te.__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(_e){ft(r,r.return,_e)}if(i=r.sibling,i!==null){i.return=r.return,Ee=i;break}Ee=r.return}return Ne=fp,fp=!1,Ne}function Rs(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&&yc(r,a,g)}f=f.next}while(f!==c)}}function Xo(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 Sc(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 pp(i){var r=i.alternate;r!==null&&(i.alternate=null,pp(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&(delete r[Fi],delete r[vs],delete r[Al],delete r[aS],delete r[lS])),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 mp(i){return i.tag===5||i.tag===3||i.tag===4}function gp(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||mp(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 wc(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=Eo));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}function bc(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(bc(i,r,a),i=i.sibling;i!==null;)bc(i,r,a),i=i.sibling}var zt=null,ji=!1;function kn(i,r,a){for(a=a.child;a!==null;)vp(i,r,a),a=a.sibling}function vp(i,r,a){if(zi&&typeof zi.onCommitFiberUnmount=="function")try{zi.onCommitFiberUnmount(ao,a)}catch{}switch(a.tag){case 5:qt||jr(a,r);case 6:var c=zt,f=ji;zt=null,kn(i,r,a),zt=c,ji=f,zt!==null&&(ji?(i=zt,a=a.stateNode,i.nodeType===8?i.parentNode.removeChild(a):i.removeChild(a)):zt.removeChild(a.stateNode));break;case 18:zt!==null&&(ji?(i=zt,a=a.stateNode,i.nodeType===8?Bl(i.parentNode,a):i.nodeType===1&&Bl(i,a),os(i)):Bl(zt,a.stateNode));break;case 4:c=zt,f=ji,zt=a.stateNode.containerInfo,ji=!0,kn(i,r,a),zt=c,ji=f;break;case 0:case 11:case 14:case 15:if(!qt&&(c=a.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){f=c=c.next;do{var g=f,C=g.destroy;g=g.tag,C!==void 0&&((g&2)!==0||(g&4)!==0)&&yc(a,r,C),f=f.next}while(f!==c)}kn(i,r,a);break;case 1:if(!qt&&(jr(a,r),c=a.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=a.memoizedProps,c.state=a.memoizedState,c.componentWillUnmount()}catch(T){ft(a,r,T)}kn(i,r,a);break;case 21:kn(i,r,a);break;case 22:a.mode&1?(qt=(c=qt)||a.memoizedState!==null,kn(i,r,a),qt=c):kn(i,r,a);break;default:kn(i,r,a)}}function _p(i){var r=i.updateQueue;if(r!==null){i.updateQueue=null;var a=i.stateNode;a===null&&(a=i.stateNode=new xS),r.forEach(function(c){var f=jS.bind(null,i,c);a.has(c)||(a.add(c),c.then(f,f))})}}function Bi(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,C=r,T=C;e:for(;T!==null;){switch(T.tag){case 5:zt=T.stateNode,ji=!1;break e;case 3:zt=T.stateNode.containerInfo,ji=!0;break e;case 4:zt=T.stateNode.containerInfo,ji=!0;break e}T=T.return}if(zt===null)throw Error(n(160));vp(g,C,f),zt=null,ji=!1;var F=f.alternate;F!==null&&(F.return=null),f.return=null}catch(oe){ft(f,r,oe)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)yp(r,i),r=r.sibling}function yp(i,r){var a=i.alternate,c=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(Bi(r,i),Wi(i),c&4){try{Rs(3,i,i.return),Xo(3,i)}catch(Pe){ft(i,i.return,Pe)}try{Rs(5,i,i.return)}catch(Pe){ft(i,i.return,Pe)}}break;case 1:Bi(r,i),Wi(i),c&512&&a!==null&&jr(a,a.return);break;case 5:if(Bi(r,i),Wi(i),c&512&&a!==null&&jr(a,a.return),i.flags&32){var f=i.stateNode;try{xt(f,"")}catch(Pe){ft(i,i.return,Pe)}}if(c&4&&(f=i.stateNode,f!=null)){var g=i.memoizedProps,C=a!==null?a.memoizedProps:g,T=i.type,F=i.updateQueue;if(i.updateQueue=null,F!==null)try{T==="input"&&g.type==="radio"&&g.name!=null&&ue(f,g),Yt(T,C);var oe=Yt(T,g);for(C=0;C<F.length;C+=2){var me=F[C],ge=F[C+1];me==="style"?xe(f,ge):me==="dangerouslySetInnerHTML"?Pi(f,ge):me==="children"?xt(f,ge):A(f,me,ge,oe)}switch(T){case"input":be(f,g);break;case"textarea":Ct(f,g);break;case"select":var fe=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!g.multiple;var ke=g.value;ke!=null?Qe(f,!!g.multiple,ke,!1):fe!==!!g.multiple&&(g.defaultValue!=null?Qe(f,!!g.multiple,g.defaultValue,!0):Qe(f,!!g.multiple,g.multiple?[]:"",!1))}f[vs]=g}catch(Pe){ft(i,i.return,Pe)}}break;case 6:if(Bi(r,i),Wi(i),c&4){if(i.stateNode===null)throw Error(n(162));f=i.stateNode,g=i.memoizedProps;try{f.nodeValue=g}catch(Pe){ft(i,i.return,Pe)}}break;case 3:if(Bi(r,i),Wi(i),c&4&&a!==null&&a.memoizedState.isDehydrated)try{os(r.containerInfo)}catch(Pe){ft(i,i.return,Pe)}break;case 4:Bi(r,i),Wi(i);break;case 13:Bi(r,i),Wi(i),f=i.child,f.flags&8192&&(g=f.memoizedState!==null,f.stateNode.isHidden=g,!g||f.alternate!==null&&f.alternate.memoizedState!==null||(kc=vt())),c&4&&_p(i);break;case 22:if(me=a!==null&&a.memoizedState!==null,i.mode&1?(qt=(oe=qt)||me,Bi(r,i),qt=oe):Bi(r,i),Wi(i),c&8192){if(oe=i.memoizedState!==null,(i.stateNode.isHidden=oe)&&!me&&(i.mode&1)!==0)for(Ee=i,me=i.child;me!==null;){for(ge=Ee=me;Ee!==null;){switch(fe=Ee,ke=fe.child,fe.tag){case 0:case 11:case 14:case 15:Rs(4,fe,fe.return);break;case 1:jr(fe,fe.return);var Ne=fe.stateNode;if(typeof Ne.componentWillUnmount=="function"){c=fe,a=fe.return;try{r=c,Ne.props=r.memoizedProps,Ne.state=r.memoizedState,Ne.componentWillUnmount()}catch(Pe){ft(c,a,Pe)}}break;case 5:jr(fe,fe.return);break;case 22:if(fe.memoizedState!==null){bp(ge);continue}}ke!==null?(ke.return=fe,Ee=ke):bp(ge)}me=me.sibling}e:for(me=null,ge=i;;){if(ge.tag===5){if(me===null){me=ge;try{f=ge.stateNode,oe?(g=f.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(T=ge.stateNode,F=ge.memoizedProps.style,C=F!=null&&F.hasOwnProperty("display")?F.display:null,T.style.display=ce("display",C))}catch(Pe){ft(i,i.return,Pe)}}}else if(ge.tag===6){if(me===null)try{ge.stateNode.nodeValue=oe?"":ge.memoizedProps}catch(Pe){ft(i,i.return,Pe)}}else if((ge.tag!==22&&ge.tag!==23||ge.memoizedState===null||ge===i)&&ge.child!==null){ge.child.return=ge,ge=ge.child;continue}if(ge===i)break e;for(;ge.sibling===null;){if(ge.return===null||ge.return===i)break e;me===ge&&(me=null),ge=ge.return}me===ge&&(me=null),ge.sibling.return=ge.return,ge=ge.sibling}}break;case 19:Bi(r,i),Wi(i),c&4&&_p(i);break;case 21:break;default:Bi(r,i),Wi(i)}}function Wi(i){var r=i.flags;if(r&2){try{e:{for(var a=i.return;a!==null;){if(mp(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&&(xt(f,""),c.flags&=-33);var g=gp(i);bc(i,g,f);break;case 3:case 4:var C=c.stateNode.containerInfo,T=gp(i);wc(i,T,C);break;default:throw Error(n(161))}}catch(F){ft(i,i.return,F)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function ES(i,r,a){Ee=i,Sp(i)}function Sp(i,r,a){for(var c=(i.mode&1)!==0;Ee!==null;){var f=Ee,g=f.child;if(f.tag===22&&c){var C=f.memoizedState!==null||Yo;if(!C){var T=f.alternate,F=T!==null&&T.memoizedState!==null||qt;T=Yo;var oe=qt;if(Yo=C,(qt=F)&&!oe)for(Ee=f;Ee!==null;)C=Ee,F=C.child,C.tag===22&&C.memoizedState!==null?Cp(f):F!==null?(F.return=C,Ee=F):Cp(f);for(;g!==null;)Ee=g,Sp(g),g=g.sibling;Ee=f,Yo=T,qt=oe}wp(i)}else(f.subtreeFlags&8772)!==0&&g!==null?(g.return=f,Ee=g):wp(i)}}function wp(i){for(;Ee!==null;){var r=Ee;if((r.flags&8772)!==0){var a=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:qt||Xo(5,r);break;case 1:var c=r.stateNode;if(r.flags&4&&!qt)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&&bf(r,g,c);break;case 3:var C=r.updateQueue;if(C!==null){if(a=null,r.child!==null)switch(r.child.tag){case 5:a=r.child.stateNode;break;case 1:a=r.child.stateNode}bf(r,C,a)}break;case 5:var T=r.stateNode;if(a===null&&r.flags&4){a=T;var F=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":F.autoFocus&&a.focus();break;case"img":F.src&&(a.src=F.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 me=oe.memoizedState;if(me!==null){var ge=me.dehydrated;ge!==null&&os(ge)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}qt||r.flags&512&&Sc(r)}catch(fe){ft(r,r.return,fe)}}if(r===i){Ee=null;break}if(a=r.sibling,a!==null){a.return=r.return,Ee=a;break}Ee=r.return}}function bp(i){for(;Ee!==null;){var r=Ee;if(r===i){Ee=null;break}var a=r.sibling;if(a!==null){a.return=r.return,Ee=a;break}Ee=r.return}}function Cp(i){for(;Ee!==null;){var r=Ee;try{switch(r.tag){case 0:case 11:case 15:var a=r.return;try{Xo(4,r)}catch(F){ft(r,a,F)}break;case 1:var c=r.stateNode;if(typeof c.componentDidMount=="function"){var f=r.return;try{c.componentDidMount()}catch(F){ft(r,f,F)}}var g=r.return;try{Sc(r)}catch(F){ft(r,g,F)}break;case 5:var C=r.return;try{Sc(r)}catch(F){ft(r,C,F)}}}catch(F){ft(r,r.return,F)}if(r===i){Ee=null;break}var T=r.sibling;if(T!==null){T.return=r.return,Ee=T;break}Ee=r.return}}var NS=Math.ceil,Go=B.ReactCurrentDispatcher,Cc=B.ReactCurrentOwner,Ci=B.ReactCurrentBatchConfig,Xe=0,Mt=null,St=null,Ft=0,di=0,Br=Sn(0),Et=0,Ps=null,Xn=0,Qo=0,xc=0,Ds=null,ni=null,kc=0,Ar=1/0,on=null,Jo=!1,Ec=null,En=null,Zo=!1,Nn=null,ea=0,Ms=0,Nc=null,ta=-1,ia=0;function Gt(){return(Xe&6)!==0?vt():ta!==-1?ta:ta=vt()}function Rn(i){return(i.mode&1)===0?1:(Xe&2)!==0&&Ft!==0?Ft&-Ft:uS.transition!==null?(ia===0&&(ia=md()),ia):(i=Ze,i!==0||(i=window.event,i=i===void 0?16:xd(i.type)),i)}function Ai(i,r,a,c){if(50<Ms)throw Ms=0,Nc=null,Error(n(185));ts(i,a,c),((Xe&2)===0||i!==Mt)&&(i===Mt&&((Xe&2)===0&&(Qo|=a),Et===4&&Pn(i,Ft)),ri(i,c),a===1&&Xe===0&&(r.mode&1)===0&&(Ar=vt()+500,Do&&bn()))}function ri(i,r){var a=i.callbackNode;uy(i,r);var c=uo(i,i===Mt?Ft:0);if(c===0)a!==null&&dd(a),i.callbackNode=null,i.callbackPriority=0;else if(r=c&-c,i.callbackPriority!==r){if(a!=null&&dd(a),r===1)i.tag===0?cS(kp.bind(null,i)):uf(kp.bind(null,i)),sS(function(){(Xe&6)===0&&bn()}),a=null;else{switch(gd(c)){case 1:a=ol;break;case 4:a=fd;break;case 16:a=oo;break;case 536870912:a=pd;break;default:a=oo}a=Tp(a,xp.bind(null,i))}i.callbackPriority=r,i.callbackNode=a}}function xp(i,r){if(ta=-1,ia=0,(Xe&6)!==0)throw Error(n(327));var a=i.callbackNode;if(Ir()&&i.callbackNode!==a)return null;var c=uo(i,i===Mt?Ft:0);if(c===0)return null;if((c&30)!==0||(c&i.expiredLanes)!==0||r)r=na(i,c);else{r=c;var f=Xe;Xe|=2;var g=Np();(Mt!==i||Ft!==r)&&(on=null,Ar=vt()+500,Qn(i,r));do try{DS();break}catch(T){Ep(i,T)}while(!0);Kl(),Go.current=g,Xe=f,St!==null?r=0:(Mt=null,Ft=0,r=Et)}if(r!==0){if(r===2&&(f=al(i),f!==0&&(c=f,r=Rc(i,f))),r===1)throw a=Ps,Qn(i,0),Pn(i,c),ri(i,vt()),a;if(r===6)Pn(i,c);else{if(f=i.current.alternate,(c&30)===0&&!RS(f)&&(r=na(i,c),r===2&&(g=al(i),g!==0&&(c=g,r=Rc(i,g))),r===1))throw a=Ps,Qn(i,0),Pn(i,c),ri(i,vt()),a;switch(i.finishedWork=f,i.finishedLanes=c,r){case 0:case 1:throw Error(n(345));case 2:Jn(i,ni,on);break;case 3:if(Pn(i,c),(c&130023424)===c&&(r=kc+500-vt(),10<r)){if(uo(i,0)!==0)break;if(f=i.suspendedLanes,(f&c)!==c){Gt(),i.pingedLanes|=i.suspendedLanes&f;break}i.timeoutHandle=jl(Jn.bind(null,i,ni,on),r);break}Jn(i,ni,on);break;case 4:if(Pn(i,c),(c&4194240)===c)break;for(r=i.eventTimes,f=-1;0<c;){var C=31-Di(c);g=1<<C,C=r[C],C>f&&(f=C),c&=~g}if(c=f,c=vt()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*NS(c/1960))-c,10<c){i.timeoutHandle=jl(Jn.bind(null,i,ni,on),c);break}Jn(i,ni,on);break;case 5:Jn(i,ni,on);break;default:throw Error(n(329))}}}return ri(i,vt()),i.callbackNode===a?xp.bind(null,i):null}function Rc(i,r){var a=Ds;return i.current.memoizedState.isDehydrated&&(Qn(i,r).flags|=256),i=na(i,r),i!==2&&(r=ni,ni=a,r!==null&&Pc(r)),i}function Pc(i){ni===null?ni=i:ni.push.apply(ni,i)}function RS(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(!Mi(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 Pn(i,r){for(r&=~xc,r&=~Qo,i.suspendedLanes|=r,i.pingedLanes&=~r,i=i.expirationTimes;0<r;){var a=31-Di(r),c=1<<a;i[a]=-1,r&=~c}}function kp(i){if((Xe&6)!==0)throw Error(n(327));Ir();var r=uo(i,0);if((r&1)===0)return ri(i,vt()),null;var a=na(i,r);if(i.tag!==0&&a===2){var c=al(i);c!==0&&(r=c,a=Rc(i,c))}if(a===1)throw a=Ps,Qn(i,0),Pn(i,r),ri(i,vt()),a;if(a===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=r,Jn(i,ni,on),ri(i,vt()),null}function Dc(i,r){var a=Xe;Xe|=1;try{return i(r)}finally{Xe=a,Xe===0&&(Ar=vt()+500,Do&&bn())}}function Gn(i){Nn!==null&&Nn.tag===0&&(Xe&6)===0&&Ir();var r=Xe;Xe|=1;var a=Ci.transition,c=Ze;try{if(Ci.transition=null,Ze=1,i)return i()}finally{Ze=c,Ci.transition=a,Xe=r,(Xe&6)===0&&bn()}}function Mc(){di=Br.current,nt(Br)}function Qn(i,r){i.finishedWork=null,i.finishedLanes=0;var a=i.timeoutHandle;if(a!==-1&&(i.timeoutHandle=-1,rS(a)),St!==null)for(a=St.return;a!==null;){var c=a;switch(Fl(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Ro();break;case 3:Lr(),nt(ei),nt(Wt),Zl();break;case 5:Ql(c);break;case 4:Lr();break;case 13:nt(lt);break;case 19:nt(lt);break;case 10:ql(c.type._context);break;case 22:case 23:Mc()}a=a.return}if(Mt=i,St=i=Dn(i.current,null),Ft=di=r,Et=0,Ps=null,xc=Qo=Xn=0,ni=Ds=null,qn!==null){for(r=0;r<qn.length;r++)if(a=qn[r],c=a.interleaved,c!==null){a.interleaved=null;var f=c.next,g=a.pending;if(g!==null){var C=g.next;g.next=f,c.next=C}a.pending=c}qn=null}return i}function Ep(i,r){do{var a=St;try{if(Kl(),Fo.current=Uo,Ho){for(var c=ct.memoizedState;c!==null;){var f=c.queue;f!==null&&(f.pending=null),c=c.next}Ho=!1}if(Yn=0,Dt=kt=ct=null,Cs=!1,xs=0,Cc.current=null,a===null||a.return===null){Et=1,Ps=r,St=null;break}e:{var g=i,C=a.return,T=a,F=r;if(r=Ft,T.flags|=32768,F!==null&&typeof F=="object"&&typeof F.then=="function"){var oe=F,me=T,ge=me.tag;if((me.mode&1)===0&&(ge===0||ge===11||ge===15)){var fe=me.alternate;fe?(me.updateQueue=fe.updateQueue,me.memoizedState=fe.memoizedState,me.lanes=fe.lanes):(me.updateQueue=null,me.memoizedState=null)}var ke=Qf(C);if(ke!==null){ke.flags&=-257,Jf(ke,C,T,g,r),ke.mode&1&&Gf(g,oe,r),r=ke,F=oe;var Ne=r.updateQueue;if(Ne===null){var Pe=new Set;Pe.add(F),r.updateQueue=Pe}else Ne.add(F);break e}else{if((r&1)===0){Gf(g,oe,r),Lc();break e}F=Error(n(426))}}else if(st&&T.mode&1){var _t=Qf(C);if(_t!==null){(_t.flags&65536)===0&&(_t.flags|=256),Jf(_t,C,T,g,r),Wl(Tr(F,T));break e}}g=F=Tr(F,T),Et!==4&&(Et=2),Ds===null?Ds=[g]:Ds.push(g),g=C;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var te=Yf(g,F,r);wf(g,te);break e;case 1:T=F;var V=g.type,ne=g.stateNode;if((g.flags&128)===0&&(typeof V.getDerivedStateFromError=="function"||ne!==null&&typeof ne.componentDidCatch=="function"&&(En===null||!En.has(ne)))){g.flags|=65536,r&=-r,g.lanes|=r;var _e=Xf(g,T,r);wf(g,_e);break e}}g=g.return}while(g!==null)}Pp(a)}catch(Me){r=Me,St===a&&a!==null&&(St=a=a.return);continue}break}while(!0)}function Np(){var i=Go.current;return Go.current=Uo,i===null?Uo:i}function Lc(){(Et===0||Et===3||Et===2)&&(Et=4),Mt===null||(Xn&268435455)===0&&(Qo&268435455)===0||Pn(Mt,Ft)}function na(i,r){var a=Xe;Xe|=2;var c=Np();(Mt!==i||Ft!==r)&&(on=null,Qn(i,r));do try{PS();break}catch(f){Ep(i,f)}while(!0);if(Kl(),Xe=a,Go.current=c,St!==null)throw Error(n(261));return Mt=null,Ft=0,Et}function PS(){for(;St!==null;)Rp(St)}function DS(){for(;St!==null&&!ty();)Rp(St)}function Rp(i){var r=Lp(i.alternate,i,di);i.memoizedProps=i.pendingProps,r===null?Pp(i):St=r,Cc.current=null}function Pp(i){var r=i;do{var a=r.alternate;if(i=r.return,(r.flags&32768)===0){if(a=bS(a,r,di),a!==null){St=a;return}}else{if(a=CS(a,r),a!==null){a.flags&=32767,St=a;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{Et=6,St=null;return}}if(r=r.sibling,r!==null){St=r;return}St=r=i}while(r!==null);Et===0&&(Et=5)}function Jn(i,r,a){var c=Ze,f=Ci.transition;try{Ci.transition=null,Ze=1,MS(i,r,a,c)}finally{Ci.transition=f,Ze=c}return null}function MS(i,r,a,c){do Ir();while(Nn!==null);if((Xe&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(hy(i,g),i===Mt&&(St=Mt=null,Ft=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||Zo||(Zo=!0,Tp(oo,function(){return Ir(),null})),g=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||g){g=Ci.transition,Ci.transition=null;var C=Ze;Ze=1;var T=Xe;Xe|=4,Cc.current=null,kS(i,a),yp(a,i),Qy(Ll),po=!!Ml,Ll=Ml=null,i.current=a,ES(a),iy(),Xe=T,Ze=C,Ci.transition=g}else i.current=a;if(Zo&&(Zo=!1,Nn=i,ea=f),g=i.pendingLanes,g===0&&(En=null),sy(a.stateNode),ri(i,vt()),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(Jo)throw Jo=!1,i=Ec,Ec=null,i;return(ea&1)!==0&&i.tag!==0&&Ir(),g=i.pendingLanes,(g&1)!==0?i===Nc?Ms++:(Ms=0,Nc=i):Ms=0,bn(),null}function Ir(){if(Nn!==null){var i=gd(ea),r=Ci.transition,a=Ze;try{if(Ci.transition=null,Ze=16>i?16:i,Nn===null)var c=!1;else{if(i=Nn,Nn=null,ea=0,(Xe&6)!==0)throw Error(n(331));var f=Xe;for(Xe|=4,Ee=i.current;Ee!==null;){var g=Ee,C=g.child;if((Ee.flags&16)!==0){var T=g.deletions;if(T!==null){for(var F=0;F<T.length;F++){var oe=T[F];for(Ee=oe;Ee!==null;){var me=Ee;switch(me.tag){case 0:case 11:case 15:Rs(8,me,g)}var ge=me.child;if(ge!==null)ge.return=me,Ee=ge;else for(;Ee!==null;){me=Ee;var fe=me.sibling,ke=me.return;if(pp(me),me===oe){Ee=null;break}if(fe!==null){fe.return=ke,Ee=fe;break}Ee=ke}}}var Ne=g.alternate;if(Ne!==null){var Pe=Ne.child;if(Pe!==null){Ne.child=null;do{var _t=Pe.sibling;Pe.sibling=null,Pe=_t}while(Pe!==null)}}Ee=g}}if((g.subtreeFlags&2064)!==0&&C!==null)C.return=g,Ee=C;else e:for(;Ee!==null;){if(g=Ee,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:Rs(9,g,g.return)}var te=g.sibling;if(te!==null){te.return=g.return,Ee=te;break e}Ee=g.return}}var V=i.current;for(Ee=V;Ee!==null;){C=Ee;var ne=C.child;if((C.subtreeFlags&2064)!==0&&ne!==null)ne.return=C,Ee=ne;else e:for(C=V;Ee!==null;){if(T=Ee,(T.flags&2048)!==0)try{switch(T.tag){case 0:case 11:case 15:Xo(9,T)}}catch(Me){ft(T,T.return,Me)}if(T===C){Ee=null;break e}var _e=T.sibling;if(_e!==null){_e.return=T.return,Ee=_e;break e}Ee=T.return}}if(Xe=f,bn(),zi&&typeof zi.onPostCommitFiberRoot=="function")try{zi.onPostCommitFiberRoot(ao,i)}catch{}c=!0}return c}finally{Ze=a,Ci.transition=r}}return!1}function Dp(i,r,a){r=Tr(a,r),r=Yf(i,r,1),i=xn(i,r,1),r=Gt(),i!==null&&(ts(i,1,r),ri(i,r))}function ft(i,r,a){if(i.tag===3)Dp(i,i,a);else for(;r!==null;){if(r.tag===3){Dp(r,i,a);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(En===null||!En.has(c))){i=Tr(a,i),i=Xf(r,i,1),r=xn(r,i,1),i=Gt(),r!==null&&(ts(r,1,i),ri(r,i));break}}r=r.return}}function LS(i,r,a){var c=i.pingCache;c!==null&&c.delete(r),r=Gt(),i.pingedLanes|=i.suspendedLanes&a,Mt===i&&(Ft&a)===a&&(Et===4||Et===3&&(Ft&130023424)===Ft&&500>vt()-kc?Qn(i,0):xc|=a),ri(i,r)}function Mp(i,r){r===0&&((i.mode&1)===0?r=1:(r=co,co<<=1,(co&130023424)===0&&(co=4194304)));var a=Gt();i=nn(i,r),i!==null&&(ts(i,r,a),ri(i,a))}function TS(i){var r=i.memoizedState,a=0;r!==null&&(a=r.retryLane),Mp(i,a)}function jS(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),Mp(i,a)}var Lp;Lp=function(i,r,a){if(i!==null)if(i.memoizedProps!==r.pendingProps||ei.current)ii=!0;else{if((i.lanes&a)===0&&(r.flags&128)===0)return ii=!1,wS(i,r,a);ii=(i.flags&131072)!==0}else ii=!1,st&&(r.flags&1048576)!==0&&hf(r,Lo,r.index);switch(r.lanes=0,r.tag){case 2:var c=r.type;Vo(i,r),i=r.pendingProps;var f=kr(r,Wt.current);Mr(r,a),f=ic(null,r,c,i,f,a);var g=nc();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,ti(c)?(g=!0,Po(r)):g=!1,r.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Xl(r),f.updater=Ko,r.stateNode=f,f._reactInternals=r,cc(r,c,i,a),r=fc(null,r,c,!0,g,a)):(r.tag=0,st&&g&&zl(r),Xt(null,r,f,a),r=r.child),r;case 16:c=r.elementType;e:{switch(Vo(i,r),i=r.pendingProps,f=c._init,c=f(c._payload),r.type=c,f=r.tag=AS(c),i=Ti(c,i),f){case 0:r=dc(null,r,c,i,a);break e;case 1:r=rp(null,r,c,i,a);break e;case 11:r=Zf(null,r,c,i,a);break e;case 14:r=ep(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),dc(i,r,c,f,a);case 1:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Ti(c,f),rp(i,r,c,f,a);case 3:e:{if(sp(r),i===null)throw Error(n(387));c=r.pendingProps,g=r.memoizedState,f=g.element,Sf(i,r),Oo(r,c,null,a);var C=r.memoizedState;if(c=C.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:C.cache,pendingSuspenseBoundaries:C.pendingSuspenseBoundaries,transitions:C.transitions},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){f=Tr(Error(n(423)),r),r=op(i,r,c,a,f);break e}else if(c!==f){f=Tr(Error(n(424)),r),r=op(i,r,c,a,f);break e}else for(hi=yn(r.stateNode.containerInfo.firstChild),ui=r,st=!0,Li=null,a=_f(r,null,c,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Rr(),c===f){r=sn(i,r,a);break e}Xt(i,r,c,a)}r=r.child}return r;case 5:return Cf(r),i===null&&$l(r),c=r.type,f=r.pendingProps,g=i!==null?i.memoizedProps:null,C=f.children,Tl(c,f)?C=null:g!==null&&Tl(c,g)&&(r.flags|=32),np(i,r),Xt(i,r,C,a),r.child;case 6:return i===null&&$l(r),null;case 13:return ap(i,r,a);case 4:return Gl(r,r.stateNode.containerInfo),c=r.pendingProps,i===null?r.child=Pr(r,null,c,a):Xt(i,r,c,a),r.child;case 11:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Ti(c,f),Zf(i,r,c,f,a);case 7:return Xt(i,r,r.pendingProps,a),r.child;case 8:return Xt(i,r,r.pendingProps.children,a),r.child;case 12:return Xt(i,r,r.pendingProps.children,a),r.child;case 10:e:{if(c=r.type._context,f=r.pendingProps,g=r.memoizedProps,C=f.value,tt(Bo,c._currentValue),c._currentValue=C,g!==null)if(Mi(g.value,C)){if(g.children===f.children&&!ei.current){r=sn(i,r,a);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var T=g.dependencies;if(T!==null){C=g.child;for(var F=T.firstContext;F!==null;){if(F.context===c){if(g.tag===1){F=rn(-1,a&-a),F.tag=2;var oe=g.updateQueue;if(oe!==null){oe=oe.shared;var me=oe.pending;me===null?F.next=F:(F.next=me.next,me.next=F),oe.pending=F}}g.lanes|=a,F=g.alternate,F!==null&&(F.lanes|=a),Vl(g.return,a,r),T.lanes|=a;break}F=F.next}}else if(g.tag===10)C=g.type===r.type?null:g.child;else if(g.tag===18){if(C=g.return,C===null)throw Error(n(341));C.lanes|=a,T=C.alternate,T!==null&&(T.lanes|=a),Vl(C,a,r),C=g.sibling}else C=g.child;if(C!==null)C.return=g;else for(C=g;C!==null;){if(C===r){C=null;break}if(g=C.sibling,g!==null){g.return=C.return,C=g;break}C=C.return}g=C}Xt(i,r,f.children,a),r=r.child}return r;case 9:return f=r.type,c=r.pendingProps.children,Mr(r,a),f=wi(f),c=c(f),r.flags|=1,Xt(i,r,c,a),r.child;case 14:return c=r.type,f=Ti(c,r.pendingProps),f=Ti(c.type,f),ep(i,r,c,f,a);case 15:return tp(i,r,r.type,r.pendingProps,a);case 17:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Ti(c,f),Vo(i,r),r.tag=1,ti(c)?(i=!0,Po(r)):i=!1,Mr(r,a),qf(r,c,f),cc(r,c,f,a),fc(null,r,c,!0,i,a);case 19:return cp(i,r,a);case 22:return ip(i,r,a)}throw Error(n(156,r.tag))};function Tp(i,r){return hd(i,r)}function BS(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 xi(i,r,a,c){return new BS(i,r,a,c)}function Tc(i){return i=i.prototype,!(!i||!i.isReactComponent)}function AS(i){if(typeof i=="function")return Tc(i)?1:0;if(i!=null){if(i=i.$$typeof,i===D)return 11;if(i===Y)return 14}return 2}function Dn(i,r){var a=i.alternate;return a===null?(a=xi(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 ra(i,r,a,c,f,g){var C=2;if(c=i,typeof i=="function")Tc(i)&&(C=1);else if(typeof i=="string")C=5;else e:switch(i){case $:return Zn(a.children,f,g,r);case re:C=8,f|=8;break;case U:return i=xi(12,a,r,f|2),i.elementType=U,i.lanes=g,i;case E:return i=xi(13,a,r,f),i.elementType=E,i.lanes=g,i;case L:return i=xi(19,a,r,f),i.elementType=L,i.lanes=g,i;case H:return sa(a,f,g,r);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case X:C=10;break e;case q:C=9;break e;case D:C=11;break e;case Y:C=14;break e;case N:C=16,c=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return r=xi(C,a,r,f),r.elementType=i,r.type=c,r.lanes=g,r}function Zn(i,r,a,c){return i=xi(7,i,c,r),i.lanes=a,i}function sa(i,r,a,c){return i=xi(22,i,c,r),i.elementType=H,i.lanes=a,i.stateNode={isHidden:!1},i}function jc(i,r,a){return i=xi(6,i,null,r),i.lanes=a,i}function Bc(i,r,a){return r=xi(4,i.children!==null?i.children:[],i.key,r),r.lanes=a,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}function IS(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=ll(0),this.expirationTimes=ll(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ll(0),this.identifierPrefix=c,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Ac(i,r,a,c,f,g,C,T,F){return i=new IS(i,r,a,T,F),r===1?(r=1,g===!0&&(r|=8)):r=0,g=xi(3,null,null,r),i.current=g,g.stateNode=i,g.memoizedState={element:c,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},Xl(g),i}function OS(i,r,a){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:z,key:c==null?null:""+c,children:i,containerInfo:r,implementation:a}}function jp(i){if(!i)return wn;i=i._reactInternals;e:{if(Hn(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(ti(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(ti(a))return lf(i,a,r)}return r}function Bp(i,r,a,c,f,g,C,T,F){return i=Ac(a,c,!0,i,f,g,C,T,F),i.context=jp(null),a=i.current,c=Gt(),f=Rn(a),g=rn(c,f),g.callback=r??null,xn(a,g,f),i.current.lanes=f,ts(i,f,c),ri(i,c),i}function oa(i,r,a,c){var f=r.current,g=Gt(),C=Rn(f);return a=jp(a),r.context===null?r.context=a:r.pendingContext=a,r=rn(g,C),r.payload={element:i},c=c===void 0?null:c,c!==null&&(r.callback=c),i=xn(f,r,C),i!==null&&(Ai(i,f,C,g),Io(i,f,C)),C}function aa(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 Ap(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<r?a:r}}function Ic(i,r){Ap(i,r),(i=i.alternate)&&Ap(i,r)}function zS(){return null}var Ip=typeof reportError=="function"?reportError:function(i){console.error(i)};function Oc(i){this._internalRoot=i}la.prototype.render=Oc.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(n(409));oa(i,r,null,null)},la.prototype.unmount=Oc.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;Gn(function(){oa(null,i,null,null)}),r[Ji]=null}};function la(i){this._internalRoot=i}la.prototype.unstable_scheduleHydration=function(i){if(i){var r=yd();i={blockedOn:null,target:i,priority:r};for(var a=0;a<gn.length&&r!==0&&r<gn[a].priority;a++);gn.splice(a,0,i),a===0&&bd(i)}};function zc(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function ca(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function Op(){}function FS(i,r,a,c,f){if(f){if(typeof c=="function"){var g=c;c=function(){var oe=aa(C);g.call(oe)}}var C=Bp(r,c,i,0,null,!1,!1,"",Op);return i._reactRootContainer=C,i[Ji]=C.current,ms(i.nodeType===8?i.parentNode:i),Gn(),C}for(;f=i.lastChild;)i.removeChild(f);if(typeof c=="function"){var T=c;c=function(){var oe=aa(F);T.call(oe)}}var F=Ac(i,0,!1,null,null,!1,!1,"",Op);return i._reactRootContainer=F,i[Ji]=F.current,ms(i.nodeType===8?i.parentNode:i),Gn(function(){oa(r,F,a,c)}),F}function ua(i,r,a,c,f){var g=a._reactRootContainer;if(g){var C=g;if(typeof f=="function"){var T=f;f=function(){var F=aa(C);T.call(F)}}oa(r,C,i,f)}else C=FS(a,r,i,f,c);return aa(C)}vd=function(i){switch(i.tag){case 3:var r=i.stateNode;if(r.current.memoizedState.isDehydrated){var a=es(r.pendingLanes);a!==0&&(cl(r,a|1),ri(r,vt()),(Xe&6)===0&&(Ar=vt()+500,bn()))}break;case 13:Gn(function(){var c=nn(i,1);if(c!==null){var f=Gt();Ai(c,i,1,f)}}),Ic(i,1)}},ul=function(i){if(i.tag===13){var r=nn(i,134217728);if(r!==null){var a=Gt();Ai(r,i,134217728,a)}Ic(i,134217728)}},_d=function(i){if(i.tag===13){var r=Rn(i),a=nn(i,r);if(a!==null){var c=Gt();Ai(a,i,r,c)}Ic(i,r)}},yd=function(){return Ze},Sd=function(i,r){var a=Ze;try{return Ze=i,r()}finally{Ze=a}},il=function(i,r,a){switch(r){case"input":if(be(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=No(c);if(!f)throw Error(n(90));G(c),be(c,f)}}}break;case"textarea":Ct(i,a);break;case"select":r=a.value,r!=null&&Qe(i,!!a.multiple,r,!1)}},rd=Dc,sd=Gn;var HS={usingClientEntryPoint:!1,Events:[_s,Cr,No,id,nd,Dc]},Ls={findFiberByHostInstance:$n,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},$S={bundleType:Ls.bundleType,version:Ls.version,rendererPackageName:Ls.rendererPackageName,rendererConfig:Ls.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=cd(i),i===null?null:i.stateNode},findFiberByHostInstance:Ls.findFiberByHostInstance||zS,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 ha=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ha.isDisabled&&ha.supportsFiber)try{ao=ha.inject($S),zi=ha}catch{}}return si.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=HS,si.createPortal=function(i,r){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!zc(r))throw Error(n(200));return OS(i,r,null,a)},si.createRoot=function(i,r){if(!zc(i))throw Error(n(299));var a=!1,c="",f=Ip;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onRecoverableError!==void 0&&(f=r.onRecoverableError)),r=Ac(i,1,!1,null,null,a,!1,c,f),i[Ji]=r.current,ms(i.nodeType===8?i.parentNode:i),new Oc(r)},si.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=cd(r),i=i===null?null:i.stateNode,i},si.flushSync=function(i){return Gn(i)},si.hydrate=function(i,r,a){if(!ca(r))throw Error(n(200));return ua(null,i,r,!0,a)},si.hydrateRoot=function(i,r,a){if(!zc(i))throw Error(n(405));var c=a!=null&&a.hydratedSources||null,f=!1,g="",C=Ip;if(a!=null&&(a.unstable_strictMode===!0&&(f=!0),a.identifierPrefix!==void 0&&(g=a.identifierPrefix),a.onRecoverableError!==void 0&&(C=a.onRecoverableError)),r=Bp(r,null,i,1,a??null,f,!1,g,C),i[Ji]=r.current,ms(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 la(r)},si.render=function(i,r,a){if(!ca(r))throw Error(n(200));return ua(null,i,r,!1,a)},si.unmountComponentAtNode=function(i){if(!ca(i))throw Error(n(40));return i._reactRootContainer?(Gn(function(){ua(null,null,i,!1,function(){i._reactRootContainer=null,i[Ji]=null})}),!0):!1},si.unstable_batchedUpdates=Dc,si.unstable_renderSubtreeIntoContainer=function(i,r,a,c){if(!ca(a))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return ua(i,r,a,!1,c)},si.version="18.3.1-next-f1338f8080-20240426",si}var qp;function QS(){if(qp)return $c.exports;qp=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(),$c.exports=GS(),$c.exports}var Vp;function JS(){if(Vp)return da;Vp=1;var e=QS();return da.createRoot=e.createRoot,da.hydrateRoot=e.hydrateRoot,da}var ZS=JS();const ew=Ph(ZS);function It(e,t,n={}){return fetch(e,{...n,headers:{...n.headers||{},Authorization:`Bearer ${t}`}})}const La=e=>`nc_seen_${e}`;async function Fe(e,t,n={}){const s=await It(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 vi=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",li=(e,t)=>`${vi(e)}/fleet/${t}`,ur=(e,t)=>Fe(li(t,"status"),e),Mh=(e,t,n)=>Fe(li(n,"up"),e,{method:"POST",body:t}),Ta=(e,t,n)=>Fe(li(n,"down"),e,{method:"POST",body:t}),xa=(e,t,n)=>Fe(li(n,"restart"),e,{method:"POST",body:{cell:t}}),Lh=(e,t)=>Fe(li(t,"definitions"),e),tw=(e,t,n)=>Fe(li(n,"define-engine"),e,{method:"POST",body:{def:t}}),iw=(e,t,n,s,o)=>Fe(li(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:n,envChanges:s}}),nw=(e,t,n)=>Fe(li(n,"remove-engine"),e,{method:"POST",body:{id:t}}),rw=(e,t,n)=>Fe(li(n,"define-cell"),e,{method:"POST",body:{def:t}}),sw=(e,t,n,s)=>Fe(li(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:n}}),rv=(e,t,n=!1,s)=>Fe(li(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:n}}),ow=(e,t,n)=>Fe(li(n,"import-cell"),e,{method:"POST",body:t}),aw=(e,t,n)=>Fe(li(n,"restore-cells"),e,{method:"POST",body:{cells:t}}),lw=(e,t,n,s)=>Fe(li(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!n}}),Th=(e,t,n)=>Fe(`${vi(n)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),sv=(e,t,n)=>Fe(`${vi(n)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),ov=e=>Fe("/api/settings",e),av=e=>Fe("/api/nodes",e),cw=e=>Fe("/api/topology",e),lv=(e,t)=>Fe(`${vi(t)}/sessions`,e),jh=(e,t)=>Fe(`${vi(t)}/config`,e),Yp=(e,t)=>Fe(`${vi(t)}/topology`,e),cv=(e,t)=>Fe("/api/settings/config",e,{method:"POST",body:t}),uw=e=>Fe("/api/settings/token/rotate",e,{method:"POST"}),hw=(e,t)=>Fe("/api/settings/nodes/pair",e,{method:"POST",body:t}),Xp=(e,t,n=[])=>Fe(`${vi(n)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),dw=(e,t,n)=>Fe(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:n}}),fw=(e,t)=>Fe(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Bh=(e,t,n)=>Fe(`/api/settings/nodes/${encodeURIComponent(t)}/${n}`,e,{method:"POST"}),pw=(e,t,n)=>Fe(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:n}}),Gp=(e,t,n,s=[])=>Fe(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:n,selected:s}}),mw=e=>Fe("/api/settings/service/regenerate",e,{method:"POST"}),gw=e=>Fe("/api/settings/update/check",e,{method:"POST"}),vw=e=>Fe("/api/settings/update/apply",e,{method:"POST"}),_w=(e,t=!0)=>Fe(`/api/asks${t?"?open=1":""}`,e),yw=(e,t,n)=>Fe(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:n}}),fa=(e,t=[])=>Fe(`${vi(t)}/decks`,e),Qp=(e,t,n=[])=>Fe(`${vi(n)}/decks`,e,{method:"POST",body:{name:t}}),pa=(e,t,n,s,o=[])=>Fe(`${vi(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:n,expectedRevision:s}}),Sw=(e,t,n,s,o=[])=>Fe(`${vi(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:n,expectedRevision:s}}),ww=(e,t,n,s=[])=>Fe(`${vi(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:n}}),bw={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 Je({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:bw[e]||null})}const uv="nc_pins";function hv(){try{const e=JSON.parse(localStorage.getItem(uv));return Array.isArray(e)?e:[]}catch{return[]}}function dv(e,t){const n=e.includes(t)?e.filter(s=>s!==t):[...e,t];try{localStorage.setItem(uv,JSON.stringify(n))}catch{}return n}function Cw(e,t,n){const s=e.indexOf(t);return[s===-1?1e9:s,-(n||0)]}function xw(e,t){return e[0]-t[0]||e[1]-t[1]}const Jp=/^[a-z0-9-]{1,32}$/;function ln(e,t){const n=Array.isArray(e)?e:[];return n.length?`${n.map(encodeURIComponent).join("/")}:${t}`:String(t)}function kw(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 Zp(e,t,n){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${n}:${s.tmuxSession||s.cell}`}))}function em({nodes:e,topology:t,remote:n,down:s,fleet:o}={}){var p,m,y,w;const l=[],u=new Set,d=new Set;for(const _ of Array.isArray(e)?e:[]){if(!_||typeof _.name!="string"||!Jp.test(_.name)||_.direction==="inbound"&&_.shared!==!0)continue;const v=[_.name],b=_.name;u.add(b);const k=((p=_.tunnel)==null?void 0:p.status)||"unknown",x=k==="up",R={name:_.name,label:_.label||_.name,route:v,direct:!0,instanceId:_.nodeId||null,shared:_.shared===!0,tunnelStatus:k,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:_.health||null,direction:_.direction||"outbound",roles:_.roles||null,rolesKnown:_.rolesKnown===!0};if(_.nodeId&&d.add(_.nodeId),!_.nodeId&&_.paired===!1){l.push({...R,status:"needs-repair",downSince:s&&s[b]||null});continue}if(((m=_.health)==null?void 0:m.auth)==="failed"||k==="degraded"&&((y=_.health)==null?void 0:y.status)==="degraded"){l.push({...R,status:"needs-repair",downSince:s&&s[b]||null});continue}if(k==="passive"||((w=_.health)==null?void 0:w.status)==="passive"){l.push({...R,status:"passive",downSince:null});continue}if(!x){l.push({...R,status:"down",downSince:s&&s[b]||null});continue}const j=n&&(n[b]||n[_.name])||null;if(!j||j.error||!Array.isArray(j.sessions)){l.push({...R,status:"unreachable"});continue}const A=j.sessions.filter($=>$&&typeof $.name=="string"&&$.name).map($=>({...$,node:b,route:v,key:`${b}:${$.name}`})),B=o&&(o[b]||o[_.name]),ie=Zp(B,v,b),z=new Set(ie.map($=>$.tmuxSession).filter(Boolean));l.push({...R,status:"up",sessions:A,cells:ie,unmanaged:A.filter($=>!z.has($.name)),fleetAvailable:!!(B&&B.available),capabilities:B&&B.capabilities||[],engines:B&&B.engines||[],fleetProvider:B&&B.provider||null})}for(const _ of Array.isArray(t)?t:[]){if(!_||!Array.isArray(_.route)||_.route.length<1||_.route.some(B=>!Jp.test(B)))continue;const v=_.route.join("/");if(u.has(v)||_.instanceId&&d.has(_.instanceId))continue;_.instanceId&&d.add(_.instanceId);const b={name:_.name,label:_.label||_.route.join(" › "),route:[..._.route],direct:!1,instanceId:_.instanceId||null,shared:!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:_.health||null,lastSeen:_.lastSeen||null};if(_.stale){l.push({...b,status:"offline",downSince:s&&s[v]||_.lastSeen||null});continue}const k=n&&n[v]||null;if(!k||k.error||!Array.isArray(k.sessions)){l.push({...b,status:"unreachable",downSince:s&&s[v]||null});continue}const x=k.sessions.filter(B=>B&&typeof B.name=="string"&&B.name).map(B=>({...B,node:v,route:_.route,key:`${v}:${B.name}`})),R=o&&o[v],j=Zp(R,_.route,v),A=new Set(j.map(B=>B.tmuxSession).filter(Boolean));l.push({...b,status:"up",sessions:x,cells:j,unmanaged:x.filter(B=>!A.has(B.name)),fleetAvailable:!!(R&&R.available),capabilities:R&&R.capabilities||[],engines:R&&R.engines||[],fleetProvider:R&&R.provider||null,lastSeen:_.lastSeen||null})}return l.sort((_,v)=>_.label.localeCompare(v.label))}const Ew=["all","pinned","active","off"],fv="nc_sidebar_views_v1",pv="nc_sidebar_order_v1";function mv(e){return Ew.includes(e)?e:"all"}function Nw(e,t=[],n="all"){const s=mv(n);return s==="pinned"?t.includes(e.key):s==="active"?!!e.live:s==="off"?!e.live:!0}function Rw(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),y=p===-1?Number.MAX_SAFE_INTEGER:p,w=m===-1?Number.MAX_SAFE_INTEGER:m;return u-d||y-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 gv(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(pv));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 cn(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function vv(e,t=globalThis.localStorage){try{t.setItem(pv,JSON.stringify(e))}catch{}return e}function _v(e,t,n,s,o=[]){if(typeof t!="string"||!t||n===s)return e;const l=[...new Set(o.filter(_=>typeof _=="string"&&_))];if(!l.includes(n)||!l.includes(s))return e;const u=cn(e,t).filter(_=>l.includes(_)),d=[...u,...l.filter(_=>!u.includes(_))],p=d.indexOf(n),m=d.indexOf(s);d.splice(p,1);const y=d.indexOf(s),w=p<m?y+1:y;return d.splice(w,0,n),{...e,[t]:d}}function yv(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(fv));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function ja(e,t){var n,s;return{open:((n=e==null?void 0:e[t])==null?void 0:n.open)!==!1,filter:mv((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function Sv(e,t=globalThis.localStorage){try{t.setItem(fv,JSON.stringify(e))}catch{}return e}function tm(e,t=""){const n=String(t||"").trim().toLocaleLowerCase();return n?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(n):!0}function In(e=[],t=[],n="all",s=[]){return[...e].filter(o=>Nw(o,t,n)).sort((o,l)=>Rw(o,l,t,s))}const Ah=["it","en","es"];function Pw(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return Ah.includes(t)?t:"en"}catch{return"en"}}const ka=Pw(),wv="nc_lang",ju="nc-lang";function bv(){return typeof localStorage<"u"?localStorage:null}const ma={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; su mobile tieni premuto; 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","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-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; long-press on mobile; 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","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-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; mantén pulsado en móvil; 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","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-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 Bu(){const e=bv(),t=e?e.getItem(wv):null;return Ah.includes(t)?t:ka}function Dw(e){const t=bv();if(t)try{t.setItem(wv,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(ju))}function S(e){const t=Bu(),n=ma[t]||ma[ka];return Object.prototype.hasOwnProperty.call(n,e)?n[e]:Object.prototype.hasOwnProperty.call(ma[ka],e)?ma[ka][e]:e}function Mw(e){return typeof window>"u"?()=>{}:(window.addEventListener(ju,e),()=>window.removeEventListener(ju,e))}const Cv=Ah;function _i(){return[M.useSyncExternalStore(Mw,Bu,Bu),Dw]}function Ba({cell:e,token:t,route:n=[],onConfirm:s,onClose:o}){var Y,N;_i();const l=!!(e&&e.active),u=Array.isArray(n)?n.join("/"):"",[d,p]=M.useState([]),[m,y]=M.useState(!1);M.useEffect(()=>{let H=!0;return(async()=>{if(t)try{const I=await ur(t,u?u.split("/"):[]);if(!H)return;if(y(I.provider==="builtin"&&(I.capabilities||[]).includes("edit")),I.provider==="builtin"&&(I.capabilities||[]).includes("definitions")){const W=await Lh(t,u?u.split("/"):[]);if(!H)return;const Z=new Map((I.engines||[]).map(P=>[P.id,P]));p((W.engines||[]).map(P=>{var Q,se,J,le,de,pe,ye;return{id:P.id,label:P.label||P.id,client:((Q=P.managed)==null?void 0:Q.client)||"",models:[...new Set([...((se=Z.get(P.id))==null?void 0:se.models)||[],...((J=P.managedInfo)==null?void 0:J.models)||[]])].filter(Boolean),defaultModel:((le=P.managed)==null?void 0:le.model)||((de=P.managedInfo)==null?void 0:de.defaultModel)||"",policyDefault:((pe=P.managed)==null?void 0:pe.permissionPolicy)||((ye=P.managed)!=null&&ye.client&&P.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{H=!1}},[t,u]);const w=(e==null?void 0:e.engine)||((Y=d[0])==null?void 0:Y.id)||"",_=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 W=d.find(Z=>Z.id===H);return W?W.policyDefault:"standard"},[b,k]=M.useState(w),[x,R]=M.useState((e==null?void 0:e.model)||""),j=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((N=e==null?void 0:e.permissionPolicies)==null?void 0:N[e==null?void 0:e.engine])||"",[A,B]=M.useState(j),[ie,z]=M.useState((e==null?void 0:e.boot)??!0),[$,re]=M.useState(!1),[U,X]=M.useState(null);M.useEffect(()=>{d.length&&(k(H=>H||w),R(H=>H||_((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 q=M.useMemo(()=>d.find(H=>H.id===b)||null,[d,b]),D=!!(q&&["claude","codex","codex-vl"].includes(q.client));function E(H){k(H);const I=d.find(W=>W.id===H);R(_(H)||(I==null?void 0:I.defaultModel)||""),B(v(H))}async function L(H){H.preventDefault(),re(!0),X(null);try{if(l)await s({action:"down",boot:ie});else{const I=A==="standard"||A==="unsafe"?A:(q==null?void 0:q.policyDefault)||"standard";await s({action:"up",...m?{engine:b,model:x||"",...D?{permissionPolicy:I}:(q==null?void 0:q.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:ie})}o()}catch(I){X(String(I&&I.message||I)),re(!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:L,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:S(l?"state-on":"state-off")})]}),l?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:S("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[S("model"),": ",e.model]}),h.jsx("small",{children:S("power-on-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:ie,onChange:H=>z(H.target.checked)}),S("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:[S("engine"),h.jsx("select",{value:b,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:[S("model"),h.jsx("input",{value:x,list:"nc-launch-models",placeholder:S("model-default"),onChange:H=>R(H.target.value)}),h.jsx("datalist",{id:"nc-launch-models",children:((q==null?void 0:q.models)||[]).map(H=>h.jsx("option",{value:H},H))})]}),D?h.jsxs("label",{className:"nc-field",children:[S("permissions"),h.jsxs("select",{value:A,onChange:H=>B(H.target.value),children:[h.jsx("option",{value:"standard",children:S("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:S("fleet-unsafe-permissions")})]})]}):h.jsx("small",{className:"nc-note",children:S("fleet-standard-permissions")}),D&&A==="unsafe"&&h.jsx("small",{className:"nc-err",children:S("fleet-unsafe-warning")}),h.jsx("small",{className:"nc-note",children:S("launch-engine-help")})]}):h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:S("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[S("model"),": ",e.model]}),h.jsx("small",{children:S("launch-external-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:ie,onChange:H=>z(H.target.checked)}),S("boot-persist")]})]}),U&&h.jsx("div",{className:"nc-err",children:U}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:$,children:S("cancel")}),h.jsx("button",{type:"submit",className:"nc-btn primary",disabled:$,children:S(l?"power-off":"save-and-start")})]})]})})}const Lw=4e3;function Ih(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 k;let p=[],m=[];if(await Promise.all([av(e).then(x=>{p=Array.isArray(x.nodes)?x.nodes:[]}).catch(()=>{}),cw(e).then(x=>{m=Array.isArray(x.nodes)?x.nodes:[]}).catch(()=>{})]),!l)return;const y={},w={},_=new Set(p.map(x=>x.name)),v=[];for(const x of p)((k=x.tunnel)==null?void 0:k.status)==="up"&&(x.nodeId||x.paired!==!1)&&(x.direction!=="inbound"||x.shared===!0)&&v.push([x.name]);for(const x of m)!x.stale&&Array.isArray(x.route)&&!(x.route.length===1&&_.has(x.route[0]))&&v.push(x.route);if(await Promise.all(v.map(async x=>{const R=x.join("/");try{y[R]=await lv(e,x)}catch{y[R]={error:"unreachable"}}try{w[R]=await ur(e,x)}catch{w[R]={available:!1}}})),!l)return;const b=em({nodes:p,topology:m,remote:y,fleet:w,down:o.current});o.current=kw(o.current,b,Math.floor(Date.now()/1e3)),s(em({nodes:p,topology:m,remote:y,fleet:w,down:o.current}))}u();const d=setInterval(u,Lw);return()=>{l=!1,clearInterval(d)}},[e,t]),n}const Au="application/x-nexuscrew-roster";function Ws(e,t,n){return{onDragOver:s=>{var o;Array.from(((o=s.dataTransfer)==null?void 0:o.types)||[]).includes(Au)&&(s.preventDefault(),s.dataTransfer.dropEffect="move")},onDrop:s=>{var l;const o=(l=s.dataTransfer)==null?void 0:l.getData(Au);if(o){s.preventDefault(),s.stopPropagation();try{const u=JSON.parse(o);u.position===e&&u.key&&u.key!==t&&n(u.key,t)}catch{}}}}}function Hr({position:e,itemKey:t,label:n,onMove:s,onStep:o}){const l=M.useRef(null),u=M.useRef(null),d=M.useRef(!1),p=M.useRef(null),m=M.useRef(!1),[y,w]=M.useState(!1);M.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]);const _=()=>{l.current&&clearTimeout(l.current),l.current=null,u.current=null,d.current=!1,p.current=null,w(!1)},v=x=>{x.pointerType==="mouse"||x.button!==0||(u.current={x:x.clientX,y:x.clientY,id:x.pointerId,target:x.currentTarget},l.current=setTimeout(()=>{var R;l.current=null,d.current=!0,m.current=!0,w(!0);try{(R=u.current)==null||R.target.setPointerCapture(u.current.id)}catch{}},350))},b=x=>{var A,B,ie,z;if(!u.current)return;if(!d.current){Math.hypot(x.clientX-u.current.x,x.clientY-u.current.y)>8&&_();return}x.preventDefault();const R=(B=(A=document.elementFromPoint(x.clientX,x.clientY))==null?void 0:A.closest)==null?void 0:B.call(A,"[data-roster-key][data-position]"),j=(ie=R==null?void 0:R.dataset)==null?void 0:ie.rosterKey;((z=R==null?void 0:R.dataset)==null?void 0:z.position)===e&&j&&j!==t&&j!==p.current&&(p.current=j,s(t,j))},k=()=>_();return h.jsx("button",{type:"button",className:`nc-roster-handle${y?" active":""}`,"aria-label":`${S("reorder")} ${n}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:S("reorder-help"),draggable:!0,onDragStart:x=>{x.stopPropagation(),x.dataTransfer.effectAllowed="move",x.dataTransfer.setData(Au,JSON.stringify({position:e,key:t}))},onClick:x=>{x.stopPropagation(),m.current&&(x.preventDefault(),m.current=!1)},onKeyDown:x=>{x.key!=="ArrowUp"&&x.key!=="ArrowDown"||(x.preventDefault(),x.stopPropagation(),o(x.key==="ArrowUp"?-1:1))},onPointerDown:v,onPointerMove:b,onPointerUp:k,onPointerCancel:k,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 Kc(e){return e.status==="passive"?S("node-passive"):e.status==="down"?e.downSince?S("tunnel-down-since").replace("{t}",Aa(e.downSince)):S("tunnel-down"):e.status==="unreachable"?S("node-unreachable"):e.status==="offline"?e.lastSeen?S("node-offline-seen").replace("{t}",Aa(e.lastSeen)):S("node-offline"):e.status==="needs-repair"?S("node-needs-repair"):""}function Tw(e){return e?e.status==="healthy"?"on":"warn":null}function im(e){return e&&(e.detail||e.status)||""}function jw({onPick:e,token:t,onSettings:n}){const[s,o]=_i(),l=Ih(t),[u,d]=M.useState(null),[p,m]=M.useState(null),[y,w]=M.useState(""),[_,v]=M.useState(""),[b,k]=M.useState({bind:"127.0.0.1",port:""}),[x,R]=M.useState([]),[j,A]=M.useState(null),[B,ie]=M.useState(null),[z,$]=M.useState(hv),[re,U]=M.useState(yv),[X,q]=M.useState(gv);async function D(){try{const ue=await(await It("/api/sessions",t)).json();ue.error?(m(ue.error),d([])):(m(null),d(ue.sessions||[]))}catch(O){m(String(O)),d([])}try{const O=await ur(t);R(O.available?O.cells||[]:[])}catch{R([])}}M.useEffect(()=>{D(),It("/api/config",t).then(ue=>ue.json()).then(ue=>{v(ue.version||""),k({bind:ue.bind||"127.0.0.1",port:ue.port||""})}).catch(()=>{});const O=setInterval(D,4e3);return()=>clearInterval(O)},[]);async function E(){if(!b.port)return;const O=`http://${b.bind}:${b.port}/#token=${t}`;try{await navigator.clipboard.writeText(O)}catch{}}async function L(O){if(!j)return;const{cell:ue}=j,be=Array.isArray(j.route)?j.route:[];O.action==="up"?await Mh(t,{cell:ue,boot:!!O.boot,...O.engine?{engine:O.engine}:{},...O.model!==void 0?{model:O.model}:{},...O.permissionPolicy?{permissionPolicy:O.permissionPolicy}:{}},be):await Ta(t,{cell:ue,boot:!!O.boot},be),D()}async function Y(O,ue=[]){try{await Th(t,O,ue)}catch{return}D()}async function N(O){if(!(!(O!=null&&O.direct)||B)){ie(O.name);try{await Bh(t,O.name,O.tunnelStatus==="up"?"down":"up")}catch{}ie(null)}}const H=O=>$(ue=>dv(ue,O)),I=O=>ja(re,O),W=(O,ue)=>U(be=>{const Le={...be,[O]:{...ja(be,O),...ue}};return Sv(Le)}),Z=M.useMemo(()=>(u||[]).map(O=>{const ue=Number(localStorage.getItem(La(O.name))||0),be=!!(O.outbox&&O.outbox.count>0&&O.outbox.latest>ue);return{...O,fresh:be}}),[u]),P=M.useMemo(()=>new Map(Z.map(O=>[O.name,O])),[Z]),Q=M.useMemo(()=>new Set(x.map(O=>O.tmuxSession)),[x]),se=M.useMemo(()=>Z.filter(O=>!Q.has(O.name)),[Z,Q]),J=M.useMemo(()=>[...x.map(O=>{const ue=P.get(O.tmuxSession)||{};return{type:"cell",value:O,key:ln([],O.tmuxSession),label:O.cell,live:!!O.tmux,fresh:!!ue.fresh,activity:ue.activity||0,searchText:`${O.engine||""} ${O.key||""} ${ue.preview||""}`}}),...se.map(O=>({type:"session",value:O,key:ln([],O.name),label:O.name,live:!0,fresh:!!O.fresh,activity:O.activity||0,searchText:`${O.preview||""} ${O.cmd||""}`}))],[x,se,P]),le=I("local"),de=M.useMemo(()=>In(J,z,le.filter,cn(X,"local")).filter(O=>tm(O,y)),[J,z,le.filter,y,X]),pe=l.reduce((O,ue)=>O+(ue.cells||[]).length+(ue.unmanaged||[]).length,0),ye=J.length+pe,K=u?u.length:0,ee=(u||[]).filter(O=>O.attached).length,Re=b.port?`${b.bind}:${b.port}`:b.bind;function G(O,ue,be,Le){q(Ke=>{const De=In(Le,z,"all",cn(Ke,O)).map(Qe=>Qe.key);return vv(_v(Ke,O,ue,be,De))})}function ae(O,ue,be,Le){const Ke=In(Le,z,"all",cn(X,O)).map(qe=>qe.key),De=Ke.indexOf(ue),Qe=Ke[De+be];De>=0&&Qe&&G(O,ue,Qe,Le)}function we(O,ue=null,be=J){var Ye,Ct;const Le=Array.isArray(ue==null?void 0:ue.route)?ue.route:[],Ke=Le.join("/"),De=Ke||"local",Qe=Ws(De,O.key,(ze,at)=>G(De,ze,at,be));if(O.type==="cell"){const ze=O.value,at=Le.length?((ue==null?void 0:ue.sessions)||[]).find(xt=>xt.name===ze.tmuxSession):P.get(ze.tmuxSession),Be=(at==null?void 0:at.preview)||ze.preview||"",gt=[`${ze.engine}${ze.key?`·${ze.key}`:""}`,Be,ze.active?"":S("cell-off")].filter(Boolean).join(" · "),Pi=Le.length===0||((ue==null?void 0:ue.capabilities)||[]).includes(ze.active?"down":"up");return h.jsxs("div",{className:"nc-mcard","data-roster-key":O.key,"data-position":De,...Qe,children:[h.jsx(Hr,{position:De,itemKey:O.key,label:ze.cell,onMove:(xt,ve)=>G(De,xt,ve,be),onStep:xt=>ae(De,O.key,xt,be)}),h.jsxs("button",{className:"nc-mcard-main",onClick:()=>ze.tmux&&e(Le.length?{session:ze.tmuxSession,node:Ke}:ze.tmuxSession),title:ze.degraded?S("cell-degraded"):ze.tmux?S("cell-on"):S("cell-off"),children:[h.jsx("span",{className:`dot ${ze.degraded?"warn":ze.tmux?"on":""}`}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:ze.cell}),h.jsx("small",{children:gt})]})]}),O.activity?h.jsx("span",{className:"nc-rel",children:Aa(O.activity)}):null,O.fresh&&((Ye=at==null?void 0:at.outbox)==null?void 0:Ye.count)>0&&h.jsx("span",{className:"nc-badge",title:S("new-files-outbox"),children:at.outbox.count}),h.jsx("button",{className:`nc-act pin${z.includes(O.key)?" on":""}`,"aria-label":`${S("pin")} ${ze.cell}`,title:S("pin"),onClick:()=>H(O.key),children:z.includes(O.key)?"★":"☆"}),Pi&&h.jsx("button",{className:`nc-act power${ze.tmux?" on":""}${ze.degraded?" warn":""}`,onClick:()=>A(Le.length?{...ze,route:Le,availableEngines:(ue==null?void 0:ue.engines)||[]}:ze),title:ze.active?S("power-off"):S("power-on"),"aria-label":`${ze.active?S("power-off"):S("power-on")} ${ze.cell}`,children:h.jsx(Je,{name:"power",size:16})})]},O.key)}const qe=O.value;return h.jsxs("div",{className:"nc-mcard","data-roster-key":O.key,"data-position":De,...Qe,children:[h.jsx(Hr,{position:De,itemKey:O.key,label:qe.name,onMove:(ze,at)=>G(De,ze,at,be),onStep:ze=>ae(De,O.key,ze,be)}),h.jsxs("button",{className:"nc-mcard-main",onClick:()=>e(Le.length?{session:qe.name,node:Ke}:qe.name),children:[h.jsx("span",{className:qe.attached?"dot on":"dot"}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:qe.name}),h.jsx("small",{children:qe.preview?qe.preview:qe.cmd?qe.cmd:S("windows").replace("{n}",String(qe.windows||0))})]})]}),O.activity?h.jsx("span",{className:"nc-rel",children:Aa(O.activity)}):null,O.fresh&&((Ct=qe.outbox)==null?void 0:Ct.count)>0&&h.jsx("span",{className:"nc-badge",title:S("new-files-outbox"),children:qe.outbox.count}),h.jsx("button",{className:`nc-act pin${z.includes(O.key)?" on":""}`,"aria-label":`${S("pin")} ${qe.name}`,title:S("pin"),onClick:()=>H(O.key),children:z.includes(O.key)?"★":"☆"}),h.jsx("button",{className:"nc-menu",title:S("terminate"),"aria-label":`${S("terminate")} ${qe.name}`,onClick:()=>{window.confirm(S("terminate-confirm").replace("{name}",qe.name))&&Y(qe.name,Le)},children:"⋯"})]},O.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:[S("fleet-tmux")," · ",K," ",S("sessions"),ee>0&&` · ${ee} attached`]}),h.jsxs("span",{className:"nc-head-actions",children:[h.jsx("button",{className:"nc-refresh",onClick:()=>n("nodes",!1),title:S("settings"),children:h.jsx(Je,{name:"gear",size:18})}),h.jsx("button",{className:"nc-refresh",onClick:D,title:S("refresh"),children:h.jsx(Je,{name:"refresh",size:18})})]})]}),h.jsxs("main",{className:"nc-home-scroll",children:[ye>8&&h.jsx("input",{className:"nc-filter",type:"search",placeholder:S("filter-placeholder"),"aria-label":S("filter-placeholder"),value:y,onChange:O=>w(O.target.value)}),p&&h.jsx("div",{className:"nc-err",children:p}),h.jsxs("section",{className:"nc-group","data-position":"local",children:[h.jsx(nm,{label:S("position-local"),count:J.length,state:le,dotClass:"on",onToggle:()=>W("local",{open:!le.open}),onFilter:O=>W("local",{filter:O})}),le.open&&de.map(O=>we(O,null,J)),le.open&&u===null&&h.jsx("div",{className:"nc-empty",children:S("loading-fleet")}),le.open&&u!==null&&de.length===0&&!p&&h.jsx("div",{className:"nc-empty",children:y?S("no-match").replace("{q}",y):S("no-sessions-short")})]}),l.map(O=>{const be=Tw(O.health)||(O.status==="up"?"on":O.status==="passive"?"":"warn"),Le=O.health?im(O.health):O.status==="up"?"":Kc(O),Ke=O.route||[O.name],De=Ke.join("/"),Qe=I(De),qe=new Map((O.sessions||[]).map(Be=>[Be.name,Be])),Ye=Be=>{const gt=Number(localStorage.getItem(La(ln(Ke,Be.name)))||0);return!!(Be.outbox&&Be.outbox.count>0&&Be.outbox.latest>gt)},Ct=[...(O.cells||[]).map(Be=>{const gt=qe.get(Be.tmuxSession)||{};return{type:"cell",value:Be,key:ln(Ke,Be.tmuxSession||Be.cell),label:Be.cell,live:!!Be.tmux,fresh:Ye({...gt,name:Be.tmuxSession||Be.cell}),activity:gt.activity||Be.activity||0,searchText:`${Be.engine||""} ${Be.key||""} ${gt.preview||Be.preview||""}`}}),...(O.unmanaged||[]).map(Be=>({type:"session",value:Be,key:ln(Ke,Be.name),label:Be.name,live:!0,fresh:Ye(Be),activity:Be.activity||0,searchText:`${Be.preview||""} ${Be.cmd||""}`}))],ze=In(Ct,z,Qe.filter,cn(X,De)).filter(Be=>tm(Be,y)),at=O.direct&&O.health&&O.health.managed!==!1?h.jsx("button",{type:"button",className:`nc-act power${O.tunnelStatus==="up"?" on":""}`,disabled:B===O.name,title:O.tunnelStatus==="up"?S("power-off"):S("power-on"),"aria-label":`${O.tunnelStatus==="up"?S("power-off"):S("power-on")} ${O.label||O.name}`,onClick:()=>N(O),children:h.jsx(Je,{name:"power",size:15})}):null;return h.jsxs("section",{className:"nc-group","data-position":De,children:[h.jsx(nm,{label:O.label||O.name,count:Ct.length,state:Qe,dotClass:be,dotTitle:Le,detail:O.status==="up"?"":O.health&&im(O.health)||Kc(O),onToggle:()=>W(De,{open:!Qe.open}),onFilter:Be=>W(De,{filter:Be}),action:at}),O.status==="up"&&Qe.open&&ze.map(Be=>we(Be,O,Ct)),O.status==="up"&&Qe.open&&ze.length===0&&h.jsx("div",{className:"nc-empty",children:y?S("no-match").replace("{q}",y):S("no-sessions-short")})]},`nodo-${De}`)}),h.jsxs("footer",{className:"nc-home-foot",onClick:E,title:S("copy-url"),children:[h.jsxs("span",{className:"nc-home-meta",children:[_&&h.jsxs("span",{className:"nc-home-version",children:["v",_]}),h.jsxs("span",{className:"nc-home-endpoint",children:[Re," · ",S("ssh-only")]})]}),h.jsx("span",{className:"nc-lang",onClick:O=>O.stopPropagation(),children:Cv.map((O,ue)=>h.jsxs("span",{children:[ue>0&&" · ",h.jsx("button",{className:`nc-lang-btn${s===O?" on":""}`,onClick:()=>o(O),title:O,children:O.toUpperCase()})]},O))})]})]}),h.jsx("button",{className:"nc-fab",onClick:()=>n("fleet",!0),title:S("fleet-new-cell"),"aria-label":S("fleet-new-cell"),children:"+"}),j&&h.jsx(Ba,{cell:j,token:t,route:Array.isArray(j.route)?j.route:[],onConfirm:L,onClose:()=>A(null)})]})}function nm({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} · ${S("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||S("node-sessions").replace("{n}",String(t))})]})]}),h.jsxs("select",{className:"nc-mobile-position-filter",value:n.filter,"aria-label":`${e} · ${S("filter-placeholder")}`,title:S(`view-${n.filter}`),onChange:m=>d(m.target.value),children:[h.jsx("option",{value:"all",children:S("view-all")}),h.jsx("option",{value:"pinned",children:S("view-pinned")}),h.jsx("option",{value:"active",children:S("view-active")}),h.jsx("option",{value:"off",children:S("view-off")})]}),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 xv=Object.defineProperty,Bw=Object.getOwnPropertyDescriptor,Aw=(e,t)=>{for(var n in t)xv(e,n,{get:t[n],enumerable:!0})},mt=(e,t,n,s)=>{for(var o=s>1?void 0:s?Bw(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&&xv(t,n,o),o},Ce=(e,t)=>(n,s)=>t(n,s,e),rm="Terminal input",Iu={get:()=>rm,set:e=>rm=e},sm="Too much output to announce, navigate to rows manually to read",Ou={get:()=>sm,set:e=>sm=e};function Iw(e){return e.replace(/\r?\n/g,"\r")}function Ow(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function zw(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Fw(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");kv(o,t,n,s)}}function kv(e,t,n,s){e=Iw(e),e=Ow(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function Ev(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 om(e,t,n,s,o){Ev(e,t,n),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function An(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 Hw=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}},$w=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 _=!1,v=this.interim[0];v&=(v&224)===192?31:(v&240)===224?15:7;let b=0,k;for(;(k=this.interim[++b]&63)&&b<4;)v<<=6,v|=k;let x=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,R=x-b;for(;m<R;){if(m>=n)return 0;if(k=e[m++],(k&192)!==128){m--,_=!0;break}else this.interim[b++]=k,v<<=6,v|=k&63}_||(x===2?v<128?m--:t[s++]=v:x===3?v<2048||v>=55296&&v<=57343||v===65279||(t[s++]=v):v<65536||v>1114111||(t[s++]=v)),this.interim.fill(0)}let y=n-4,w=m;for(;w<n;){for(;w<y&&!((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}},Nv="",On=" ",Zs=class Rv{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 Rv;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 Pv{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 Pv(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ri=class Dv extends Zs{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ia,this.combinedData=""}static fromCharData(t){let n=new Dv;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?An(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()]}},am="di$target",zu="di$dependencies",qc=new Map;function Ww(e){return e[zu]||[]}function Ot(e){if(qc.has(e))return qc.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");Uw(t,n,o)};return t._id=e,qc.set(e,t),t}function Uw(e,t,n){t[am]===t?t[zu].push({id:e,index:n}):(t[zu]=[{id:e,index:n}],t[am]=t)}var Jt=Ot("BufferService"),Mv=Ot("CoreMouseService"),hr=Ot("CoreService"),Kw=Ot("CharsetService"),Oh=Ot("InstantiationService"),Lv=Ot("LogService"),Zt=Ot("OptionsService"),Tv=Ot("OscLinkService"),qw=Ot("UnicodeService"),eo=Ot("DecorationService"),Fu=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var y;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,l=new Ri,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=this._oscLinkService.getLinkData(d))==null?void 0:y.uri;if(_){let v={start:{x:p+1,y:e},end:{x:w+(!m&&w===u-1?1:0),y:e}},b=!1;if(!(o!=null&&o.allowNonHttpProtocols))try{let k=new URL(_);["http:","https:"].includes(k.protocol)||(b=!0)}catch{b=!0}b||s.push({text:_,range:v,activate:(k,x)=>o?o.activate(k,x,v):Vw(k,x),hover:(k,x)=>{var R;return(R=o==null?void 0:o.hover)==null?void 0:R.call(o,k,x,v)},leave:(k,x)=>{var R;return(R=o==null?void 0:o.leave)==null?void 0:R.call(o,k,x,v)}})}m=!1,l.hasExtendedAttrs()&&l.extended.urlId?(p=w,d=l.extended.urlId):(p=-1,d=-1)}}t(s)}};Fu=mt([Ce(0,Jt),Ce(1,Zt),Ce(2,Tv)],Fu);function Vw(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=Ot("CharSizeService"),hn=Ot("CoreBrowserService"),zh=Ot("MouseService"),dn=Ot("RenderService"),Yw=Ot("SelectionService"),jv=Ot("CharacterJoinerService"),Yr=Ot("ThemeService"),Bv=Ot("LinkProviderService"),Xw=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?lm.isErrorNoTelemetry(e)?new lm(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)}},Gw=new Xw;function Ea(e){Qw(e)||Gw.onUnexpectedError(e)}var Hu="Canceled";function Qw(e){return e instanceof Jw?!0:e instanceof Error&&e.name===Hu&&e.message===Hu}var Jw=class extends Error{constructor(){super(Hu),this.name=this.message}};function Zw(e){return new Error(`Illegal argument: ${e}`)}var lm=class $u extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof $u)return t;let n=new $u;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Wu=class Av extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Av.prototype)}};function fi(e,t=0){return e[e.length-(1+t)]}var e0;(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})(e0||(e0={}));function t0(e,t){let n=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(n,arguments))),o}}var Iv;(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 ie=B.length-1;ie>=0;ie--)yield B[ie]}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 y(B,ie){let z=0;for(let $ of B)if(ie($,z++))return!0;return!1}e.some=y;function w(B,ie){for(let z of B)if(ie(z))return z}e.find=w;function*_(B,ie){for(let z of B)ie(z)&&(yield z)}e.filter=_;function*v(B,ie){let z=0;for(let $ of B)yield ie($,z++)}e.map=v;function*b(B,ie){let z=0;for(let $ of B)yield*ie($,z++)}e.flatMap=b;function*k(...B){for(let ie of B)yield*ie}e.concat=k;function x(B,ie,z){let $=z;for(let re of B)$=ie($,re);return $}e.reduce=x;function*R(B,ie,z=B.length){for(ie<0&&(ie+=B.length),z<0?z+=B.length:z>B.length&&(z=B.length);ie<z;ie++)yield B[ie]}e.slice=R;function j(B,ie=Number.POSITIVE_INFINITY){let z=[];if(ie===0)return[z,B];let $=B[Symbol.iterator]();for(let re=0;re<ie;re++){let U=$.next();if(U.done)return[z,e.empty()];z.push(U.value)}return[z,{[Symbol.iterator](){return $}}]}e.consume=j;async function A(B){let ie=[];for await(let z of B)ie.push(z);return Promise.resolve(ie)}e.asyncToArray=A})(Iv||(Iv={}));function lr(e){if(Iv.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 i0(...e){return ot(()=>lr(e))}function ot(e){return{dispose:t0(()=>{e()})}}var Ov=class zv{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{lr(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?zv.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)}};Ov.DISABLE_DISPOSED_WARNING=!1;var zn=Ov,We=class{constructor(){this._store=new zn,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};We.None=Object.freeze({dispose(){}});var qr=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}},un=typeof window=="object"?window:globalThis,Uu=class Ku{constructor(t){this.element=t,this.next=Ku.Undefined,this.prev=Ku.Undefined}};Uu.Undefined=new Uu(void 0);var ut=Uu,cm=class{constructor(){this._first=ut.Undefined,this._last=ut.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ut.Undefined}clear(){let e=this._first;for(;e!==ut.Undefined;){let t=e.next;e.prev=ut.Undefined,e.next=ut.Undefined,e=t}this._first=ut.Undefined,this._last=ut.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new ut(e);if(this._first===ut.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!==ut.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ut.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ut.Undefined&&e.next!==ut.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ut.Undefined&&e.next===ut.Undefined?(this._first=ut.Undefined,this._last=ut.Undefined):e.next===ut.Undefined?(this._last=this._last.prev,this._last.next=ut.Undefined):e.prev===ut.Undefined&&(this._first=this._first.next,this._first.prev=ut.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ut.Undefined;)yield e.element,e=e.next}},n0=globalThis.performance&&typeof globalThis.performance.now=="function",r0=class Fv{static create(t){return new Fv(t)}constructor(t){this._now=n0&&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}},$t;(e=>{e.None=()=>We.None;function t(D,E){return w(D,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function n(D){return(E,L=null,Y)=>{let N=!1,H;return H=D(I=>{if(!N)return H?H.dispose():N=!0,E.call(L,I)},null,Y),N&&H.dispose(),H}}e.once=n;function s(D,E,L){return m((Y,N=null,H)=>D(I=>Y.call(N,E(I)),null,H),L)}e.map=s;function o(D,E,L){return m((Y,N=null,H)=>D(I=>{E(I),Y.call(N,I)},null,H),L)}e.forEach=o;function l(D,E,L){return m((Y,N=null,H)=>D(I=>E(I)&&Y.call(N,I),null,H),L)}e.filter=l;function u(D){return D}e.signal=u;function d(...D){return(E,L=null,Y)=>{let N=i0(...D.map(H=>H(I=>E.call(L,I))));return y(N,Y)}}e.any=d;function p(D,E,L,Y){let N=L;return s(D,H=>(N=E(N,H),N),Y)}e.reduce=p;function m(D,E){let L,Y={onWillAddFirstListener(){L=D(N.fire,N)},onDidRemoveLastListener(){L==null||L.dispose()}},N=new Se(Y);return E==null||E.add(N),N.event}function y(D,E){return E instanceof Array?E.push(D):E&&E.add(D),D}function w(D,E,L=100,Y=!1,N=!1,H,I){let W,Z,P,Q=0,se,J={leakWarningThreshold:H,onWillAddFirstListener(){W=D(de=>{Q++,Z=E(Z,de),Y&&!P&&(le.fire(Z),Z=void 0),se=()=>{let pe=Z;Z=void 0,P=void 0,(!Y||Q>1)&&le.fire(pe),Q=0},typeof L=="number"?(clearTimeout(P),P=setTimeout(se,L)):P===void 0&&(P=0,queueMicrotask(se))})},onWillRemoveListener(){N&&Q>0&&(se==null||se())},onDidRemoveLastListener(){se=void 0,W.dispose()}},le=new Se(J);return I==null||I.add(le),le.event}e.debounce=w;function _(D,E=0,L){return e.debounce(D,(Y,N)=>Y?(Y.push(N),Y):[N],E,void 0,!0,void 0,L)}e.accumulate=_;function v(D,E=(Y,N)=>Y===N,L){let Y=!0,N;return l(D,H=>{let I=Y||!E(H,N);return Y=!1,N=H,I},L)}e.latch=v;function b(D,E,L){return[e.filter(D,E,L),e.filter(D,Y=>!E(Y),L)]}e.split=b;function k(D,E=!1,L=[],Y){let N=L.slice(),H=D(Z=>{N?N.push(Z):W.fire(Z)});Y&&Y.add(H);let I=()=>{N==null||N.forEach(Z=>W.fire(Z)),N=null},W=new Se({onWillAddFirstListener(){H||(H=D(Z=>W.fire(Z)),Y&&Y.add(H))},onDidAddFirstListener(){N&&(E?setTimeout(I):I())},onDidRemoveLastListener(){H&&H.dispose(),H=null}});return Y&&Y.add(W),W.event}e.buffer=k;function x(D,E){return(L,Y,N)=>{let H=E(new j);return D(function(I){let W=H.evaluate(I);W!==R&&L.call(Y,W)},void 0,N)}}e.chain=x;let R=Symbol("HaltChainable");class j{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(L=>(E(L),L)),this}filter(E){return this.steps.push(L=>E(L)?L:R),this}reduce(E,L){let Y=L;return this.steps.push(N=>(Y=E(Y,N),Y)),this}latch(E=(L,Y)=>L===Y){let L=!0,Y;return this.steps.push(N=>{let H=L||!E(N,Y);return L=!1,Y=N,H?N:R}),this}evaluate(E){for(let L of this.steps)if(E=L(E),E===R)break;return E}}function A(D,E,L=Y=>Y){let Y=(...W)=>I.fire(L(...W)),N=()=>D.on(E,Y),H=()=>D.removeListener(E,Y),I=new Se({onWillAddFirstListener:N,onDidRemoveLastListener:H});return I.event}e.fromNodeEventEmitter=A;function B(D,E,L=Y=>Y){let Y=(...W)=>I.fire(L(...W)),N=()=>D.addEventListener(E,Y),H=()=>D.removeEventListener(E,Y),I=new Se({onWillAddFirstListener:N,onDidRemoveLastListener:H});return I.event}e.fromDOMEventEmitter=B;function ie(D){return new Promise(E=>n(D)(E))}e.toPromise=ie;function z(D){let E=new Se;return D.then(L=>{E.fire(L)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=z;function $(D,E){return D(L=>E.fire(L))}e.forward=$;function re(D,E,L){return E(L),D(Y=>E(Y))}e.runAndSubscribe=re;class U{constructor(E,L){this._observable=E,this._counter=0,this._hasChanged=!1;let Y={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new Se(Y),L&&L.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,L){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 X(D,E){return new U(D,E).emitter.event}e.fromObservable=X;function q(D){return(E,L,Y)=>{let N=0,H=!1,I={beginUpdate(){N++},endUpdate(){N--,N===0&&(D.reportChanges(),H&&(H=!1,E.call(L)))},handlePossibleChange(){},handleChange(){H=!0}};D.addObserver(I),D.reportChanges();let W={dispose(){D.removeObserver(I)}};return Y instanceof zn?Y.add(W):Array.isArray(Y)&&Y.push(W),W}}e.fromObservableLight=q})($t||($t={}));var qu=class Vu{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Vu._idPool++}`,Vu.all.add(this)}start(t){this._stopWatch=new r0,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}}};qu.all=new Set,qu._idPool=0;var s0=qu,o0=-1,Hv=class $v{constructor(t,n,s=($v._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 c0(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}};Hv._idPool=1;var a0=Hv,l0=class Wv{constructor(t){this.value=t}static create(){let t=new Error;return new Wv(t.stack??"")}print(){console.warn(this.value.split(`
|
|
58
|
-
`).slice(2).join(`
|
|
59
|
-
`))}},c0=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},u0=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},h0=0,Vc=class{constructor(e){this.value=e,this.id=h0++}},d0=2,f0,Se=class{constructor(e){var t,n,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new a0((e==null?void 0:e.onListenerError)??Ea,((n=this._options)==null?void 0:n.leakWarningThreshold)??o0):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new s0(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,y;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 _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],v=new u0(`${w}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((u=this._options)==null?void 0:u.onListenerError)||Ea)(v),We.None}if(this._disposed)return We.None;t&&(e=e.bind(t));let s=new Vc(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=l0.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Vc?(this._deliveryQueue??(this._deliveryQueue=new p0),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,(y=(m=this._options)==null?void 0:m.onDidAddFirstListener)==null||y.call(m,this)),this._size++;let l=ot(()=>{o==null||o(),this._removeListener(s)});return n instanceof zn?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*d0<=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 Vc)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}},p0=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}},Yu=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Se,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Se,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}};Yu.INSTANCE=new Yu;var Fh=Yu;function m0(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Fh.INSTANCE.onDidChangeZoomLevel;function g0(e){return Fh.INSTANCE.getZoomFactor(e)}Fh.INSTANCE.onDidChangeFullscreen;var Xr=typeof navigator=="object"?navigator.userAgent:"",Xu=Xr.indexOf("Firefox")>=0,v0=Xr.indexOf("AppleWebKit")>=0,Hh=Xr.indexOf("Chrome")>=0,_0=!Hh&&Xr.indexOf("Safari")>=0;Xr.indexOf("Electron/")>=0;Xr.indexOf("Android")>=0;var Yc=!1;if(typeof un.matchMedia=="function"){let e=un.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=un.matchMedia("(display-mode: fullscreen)");Yc=e.matches,m0(un,e,({matches:n})=>{Yc&&t.matches||(Yc=n)})}var $r="en",Gu=!1,Qu=!1,Na=!1,Uv=!1,ga,Ra=$r,um=$r,y0,Ii,or=globalThis,Ht,tv;typeof or.vscode<"u"&&typeof or.vscode.process<"u"?Ht=or.vscode.process:typeof process<"u"&&typeof((tv=process==null?void 0:process.versions)==null?void 0:tv.node)=="string"&&(Ht=process);var iv,S0=typeof((iv=Ht==null?void 0:Ht.versions)==null?void 0:iv.electron)=="string",w0=S0&&(Ht==null?void 0:Ht.type)==="renderer",nv;if(typeof Ht=="object"){Gu=Ht.platform==="win32",Qu=Ht.platform==="darwin",Na=Ht.platform==="linux",Na&&Ht.env.SNAP&&Ht.env.SNAP_REVISION,Ht.env.CI||Ht.env.BUILD_ARTIFACTSTAGINGDIRECTORY,ga=$r,Ra=$r;let e=Ht.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);ga=t.userLocale,um=t.osLocale,Ra=t.resolvedLanguage||$r,y0=(nv=t.languagePack)==null?void 0:nv.translationsConfigFile}catch{}Uv=!0}else typeof navigator=="object"&&!w0?(Ii=navigator.userAgent,Gu=Ii.indexOf("Windows")>=0,Qu=Ii.indexOf("Macintosh")>=0,(Ii.indexOf("Macintosh")>=0||Ii.indexOf("iPad")>=0||Ii.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Na=Ii.indexOf("Linux")>=0,(Ii==null?void 0:Ii.indexOf("Mobi"))>=0,Ra=globalThis._VSCODE_NLS_LANGUAGE||$r,ga=navigator.language.toLowerCase(),um=ga):console.error("Unable to resolve platform.");var Kv=Gu,Xi=Qu,b0=Na,hm=Uv,Qi=Ii,Ln=Ra,C0;(e=>{function t(){return Ln}e.value=t;function n(){return Ln.length===2?Ln==="en":Ln.length>=3?Ln[0]==="e"&&Ln[1]==="n"&&Ln[2]==="-":!1}e.isDefaultVariant=n;function s(){return Ln==="en"}e.isDefault=s})(C0||(C0={}));var x0=typeof or.postMessage=="function"&&!or.importScripts;(()=>{if(x0){let e=[];or.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}),or.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var k0=!!(Qi&&Qi.indexOf("Chrome")>=0);Qi&&Qi.indexOf("Firefox")>=0;!k0&&Qi&&Qi.indexOf("Safari")>=0;Qi&&Qi.indexOf("Edg/")>=0;Qi&&Qi.indexOf("Android")>=0;var Or=typeof navigator=="object"?navigator:{};hm||document.queryCommandSupported&&document.queryCommandSupported("copy")||Or&&Or.clipboard&&Or.clipboard.writeText,hm||Or&&Or.clipboard&&Or.clipboard.readText;var $h=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}},Xc=new $h,dm=new $h,fm=new $h,E0=new Array(230),qv;(e=>{function t(d){return Xc.keyCodeToStr(d)}e.toString=t;function n(d){return Xc.strToKeyCode(d)}e.fromString=n;function s(d){return dm.keyCodeToStr(d)}e.toUserSettingsUS=s;function o(d){return fm.keyCodeToStr(d)}e.toUserSettingsGeneral=o;function l(d){return dm.strToKeyCode(d)||fm.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 Xc.keyCodeToStr(d)}e.toElectronAccelerator=u})(qv||(qv={}));var N0=class Vv{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 Vv&&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 R0([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},R0=class{constructor(e){if(e.length===0)throw Zw("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 P0(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return qv.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(Xu)switch(t){case 59:return 85;case 60:if(b0)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Xi)return 57;break}else if(v0&&(Xi&&t===93||!Xi&&t===92))return 57;return E0[t]||0}var D0=Xi?256:2048,M0=512,L0=1024,T0=Xi?2048:256,pm=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=P0(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|=D0),this.altKey&&(t|=M0),this.shiftKey&&(t|=L0),this.metaKey&&(t|=T0),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new N0(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},mm=new WeakMap;function j0(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 B0=class{static getSameOriginWindowChain(e){let t=mm.get(e);if(!t){t=[],mm.set(e,t);let n=e,s;do s=j0(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}}},va=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=B0.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},gm=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(Hh){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?Xu&&!Xi?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof l.wheelDeltaX<"u")_0&&Kv?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?Xu&&!Xi?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()}},Yv=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),A0;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof I0?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:$t.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Yv})})(A0||(A0={}));var I0=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?Yv:(this._emitter||(this._emitter=new Se),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Wh=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 Wu("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Wu("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},O0=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 Wu("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=ot(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},z0;(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})(z0||(z0={}));var vm=class Ei{static fromArray(t){return new Ei(n=>{n.emitMany(t)})}static fromPromise(t){return new Ei(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Ei(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new Ei(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 Se,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 $t.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 Ei(async s=>{for await(let o of t)s.emitOne(n(o))})}map(t){return Ei.map(this,t)}static filter(t,n){return new Ei(async s=>{for await(let o of t)n(o)&&s.emitOne(o)})}filter(t){return Ei.filter(this,t)}static coalesce(t){return Ei.filter(t,n=>!!n)}coalesce(){return Ei.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return Ei.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())}};vm.EMPTY=vm.fromArray([]);var{getWindow:Yi,getWindowId:F0,onDidRegisterWindow:H0}=(function(){let e=new Map,t={window:un,disposables:new zn};e.set(un.vscodeWindowId,t);let n=new Se,s=new Se,o=new Se;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 We.None;let d=new zn,p={window:u,disposables:d.add(new zn)};return e.set(u.vscodeWindowId,p),d.add(ot(()=>{e.delete(u.vscodeWindowId),s.fire(u)})),d.add(Ie(u,Tt.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:un},getDocument(u){return Yi(u).document}}})(),$0=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 Ie(e,t,n,s){return new $0(e,t,n,s)}var _m=function(e,t,n,s){return Ie(e,t,n,s)},Uh,W0=class extends O0{constructor(e){super(),this.defaultTarget=e&&Yi(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},ym=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(ym.sort),u.shift().execute();s.set(l,!1)};Uh=(l,u,d=0)=>{let p=F0(l),m=new ym(u,d),y=e.get(p);return y||(y=[],e.set(p,y)),y.push(m),n.get(p)||(n.set(p,!0),l.requestAnimationFrame(()=>o(p))),m}})();function U0(e){let t=e.getBoundingClientRect(),n=Yi(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Tt={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"},K0=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=oi(t);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let n=oi(t);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(t){let n=oi(t);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(t){let n=oi(t);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(t){let n=oi(t);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(t){let n=oi(t);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(t){let n=oi(t);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(t){let n=oi(t);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let n=oi(t);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let n=oi(t);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let n=oi(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=oi(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=oi(t);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let n=oi(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 oi(e){return typeof e=="number"?`${e}px`:e}function Xs(e){return new K0(e)}var Xv=class{constructor(){this._hooks=new zn,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let 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(ot(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{l=Yi(e)}this._hooks.add(Ie(l,Tt.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(Ie(l,Tt.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 Vi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Vi||(Vi={}));var Us=class Vt extends We{constructor(){super(),this.dispatched=!1,this.targets=new cm,this.ignoreTargets=new cm,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register($t.runAndSubscribe(H0,({window:t,disposables:n})=>{n.add(Ie(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Ie(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(Ie(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:un,disposables:this._store}))}static addTarget(t){if(!Vt.isTouchDevice())return We.None;Vt.INSTANCE||(Vt.INSTANCE=new Vt);let n=Vt.INSTANCE.targets.push(t);return ot(n)}static ignoreTarget(t){if(!Vt.isTouchDevice())return We.None;Vt.INSTANCE||(Vt.INSTANCE=new Vt);let n=Vt.INSTANCE.ignoreTargets.push(t);return ot(n)}static isTouchDevice(){return"ontouchstart"in un||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(Vi.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<Vt.HOLD_DELAY&&Math.abs(p.initialPageX-fi(p.rollingPageX))<30&&Math.abs(p.initialPageY-fi(p.rollingPageY))<30){let y=this.newGestureEvent(Vi.Tap,p.initialTarget);y.pageX=fi(p.rollingPageX),y.pageY=fi(p.rollingPageY),this.dispatchEvent(y)}else if(m>=Vt.HOLD_DELAY&&Math.abs(p.initialPageX-fi(p.rollingPageX))<30&&Math.abs(p.initialPageY-fi(p.rollingPageY))<30){let y=this.newGestureEvent(Vi.Contextmenu,p.initialTarget);y.pageX=fi(p.rollingPageX),y.pageY=fi(p.rollingPageY),this.dispatchEvent(y)}else if(o===1){let y=fi(p.rollingPageX),w=fi(p.rollingPageY),_=fi(p.rollingTimestamps)-p.rollingTimestamps[0],v=y-p.rollingPageX[0],b=w-p.rollingPageY[0],k=[...this.targets].filter(x=>p.initialTarget instanceof Node&&x.contains(p.initialTarget));this.inertia(t,k,s,Math.abs(v)/_,v>0?1:-1,y,Math.abs(b)/_,b>0?1:-1,w)}this.dispatchEvent(this.newGestureEvent(Vi.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===Vi.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>Vt.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===Vi.Change||t.type===Vi.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=Uh(t,()=>{let y=Date.now(),w=y-s,_=0,v=0,b=!0;o+=Vt.SCROLL_FRICTION*w,d+=Vt.SCROLL_FRICTION*w,o>0&&(b=!1,_=l*o*w),d>0&&(b=!1,v=p*d*w);let k=this.newGestureEvent(Vi.Change);k.translationX=_,k.translationY=v,n.forEach(x=>x.dispatchEvent(k)),b||this.inertia(t,n,y,o,l,u+_,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(Vi.Change,u.initialTarget);d.translationX=l.pageX-fi(u.rollingPageX),d.translationY=l.pageY-fi(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)}};Us.SCROLL_FRICTION=-.005,Us.HOLD_DELAY=700,Us.CLEAR_TAP_COUNT_TIME=400,mt([q0],Us,"isTouchDevice",1);var V0=Us,Kh=class extends We{onclick(e,t){this._register(Ie(e,Tt.CLICK,n=>t(new va(Yi(e),n))))}onmousedown(e,t){this._register(Ie(e,Tt.MOUSE_DOWN,n=>t(new va(Yi(e),n))))}onmouseover(e,t){this._register(Ie(e,Tt.MOUSE_OVER,n=>t(new va(Yi(e),n))))}onmouseleave(e,t){this._register(Ie(e,Tt.MOUSE_LEAVE,n=>t(new va(Yi(e),n))))}onkeydown(e,t){this._register(Ie(e,Tt.KEY_DOWN,n=>t(new pm(n))))}onkeyup(e,t){this._register(Ie(e,Tt.KEY_UP,n=>t(new pm(n))))}oninput(e,t){this._register(Ie(e,Tt.INPUT,t))}onblur(e,t){this._register(Ie(e,Tt.BLUR,t))}onfocus(e,t){this._register(Ie(e,Tt.FOCUS,t))}onchange(e,t){this._register(Ie(e,Tt.CHANGE,t))}ignoreGesture(e){return V0.ignoreTarget(e)}},Sm=11,Y0=class extends Kh{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=Sm+"px",this.domNode.style.height=Sm+"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 Xv),this._register(_m(this.bgDomNode,Tt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(_m(this.domNode,Tt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new W0),this._pointerdownScheduleRepeatTimer=this._register(new Wh)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Yi(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()}},X0=class Ju{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 Ju(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 Ju(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}}},G0=class extends We{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Se),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new X0(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 bm(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=bm.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)))}},wm=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Gc(e,t){let n=t-e;return function(s){return e+n*Z0(s)}}function Q0(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var bm=class Zu{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),Q0(Gc(t,o),Gc(l,n),.33)}return Gc(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 wm(s,o,!1)}return new wm(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return Zu.start(t,n,s)}static start(t,n,s){s=s+10;let o=Date.now()-10;return new Zu(t,n,o,s)}};function J0(e){return Math.pow(e,3)}function Z0(e){return 1-J0(1-e)}var e1=class extends We{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 Wh)}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":"")))}},t1=140,Gv=class extends Kh{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 e1(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Xv),this._shouldRender=!0,this.domNode=Xs(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(Ie(this.domNode.domNode,Tt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Y0(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=Xs(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(Ie(this.slider.domNode,Tt.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=U0(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(Kv&&u>t1){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()}},Qv=class eh{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 eh(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))),y=(d-m)/(o-s),w=l*y;return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(m),computedSliderRatio:y,computedSliderPosition:Math.round(w)}}_refreshComputedValues(){let t=eh._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)}},i1=class extends Gv{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Qv(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}},n1=class extends Gv{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Qv(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}},r1=500,Cm=50,s1=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},th=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(Hh){let n=Yi(t.browserEvent),s=g0(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 s1(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),y=Math.max(o,u),w=Math.max(l,d);y%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}};th.INSTANCE=new th;var o1=th,a1=class extends Kh{constructor(e,t,n){super(),this._onScroll=this._register(new Se),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Se),this.onWillScroll=this._onWillScroll.event,this._options=c1(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 n1(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new i1(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=Xs(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Xs(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Xs(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 Wh),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=lr(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,Xi&&(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 gm(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=lr(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new gm(n))};this._mouseWheelToDispose.push(Ie(this._listenOnDomNode,Tt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=o1.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=!Xi&&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 y=Cm*l,w=p.scrollTop-(y<0?Math.floor(y):Math.ceil(y));this._verticalScrollbar.writeScrollPosition(m,w)}if(u){let y=Cm*u,w=p.scrollLeft-(y<0?Math.floor(y):Math.ceil(y));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(),r1)}},l1=class extends a1{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 c1(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,Xi&&(t.className+=" mac"),t}var ih=class extends We{constructor(e,t,n,s,o,l,u,d){super(),this._bufferService=n,this._optionsService=u,this._renderService=d,this._onRequestScrollLines=this._register(new Se),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new G0({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:m=>Uh(s.window,m)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new l1(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($t.runAndSubscribe(l.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=l.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ot(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ot(()=>this._styleElement.remove())),this._register($t.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}};ih=mt([Ce(2,Jt),Ce(3,hn),Ce(4,Mv),Ce(5,Yr),Ce(6,Zt),Ce(7,dn)],ih);var nh=class extends We{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(ot(()=>{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()}};nh=mt([Ce(1,Jt),Ce(2,hn),Ce(3,eo),Ce(4,dn)],nh);var u1=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Ui={full:0,left:0,center:0,right:0},Tn={full:0,left:0,center:0,right:0},js={full:0,left:0,center:0,right:0},Oa=class extends We{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 u1,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(ot(()=>{var y;return(y=this._canvas)==null?void 0:y.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);Tn.full=this._canvas.width,Tn.left=e,Tn.center=t,Tn.right=e,this._refreshDrawHeightConstants(),js.full=1,js.left=1,js.center=1+Tn.left,js.right=1+Tn.left+Tn.center}_refreshDrawHeightConstants(){Ui.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Ui.left=t,Ui.center=t,Ui.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ui.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ui.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ui.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ui.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(js[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ui[e.position||"full"]/2),Tn[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ui[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Oa=mt([Ce(2,Jt),Ce(3,eo),Ce(4,dn),Ce(5,Zt),Ce(6,Yr),Ce(7,hn)],Oa);var he;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
61
|
-
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(he||(he={}));var 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 Jv;(e=>e.ST=`${he.ESC}\\`)(Jv||(Jv={}));var rh=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(`${he.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),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)}}};rh=mt([Ce(2,Jt),Ce(3,Zt),Ce(4,hr),Ce(5,dn)],rh);var jt=0,Bt=0,At=0,pt=0,xm={css:"#00000000",rgba:0},bt;(e=>{function t(o,l,u,d){return d!==void 0?`#${er(o)}${er(l)}${er(u)}${er(d)}`:`#${er(o)}${er(l)}${er(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})(bt||(bt={}));var rt;(e=>{function t(p,m){if(pt=(m.rgba&255)/255,pt===1)return{css:m.css,rgba:m.rgba};let y=m.rgba>>24&255,w=m.rgba>>16&255,_=m.rgba>>8&255,v=p.rgba>>24&255,b=p.rgba>>16&255,k=p.rgba>>8&255;jt=v+Math.round((y-v)*pt),Bt=b+Math.round((w-b)*pt),At=k+Math.round((_-k)*pt);let x=bt.toCss(jt,Bt,At),R=bt.toRgba(jt,Bt,At);return{css:x,rgba:R}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,m,y){let w=Da.ensureContrastRatio(p.rgba,m.rgba,y);if(w)return bt.toColor(w>>24&255,w>>16&255,w>>8&255)}e.ensureContrastRatio=s;function o(p){let m=(p.rgba|255)>>>0;return[jt,Bt,At]=Da.toChannels(m),{css:bt.toCss(jt,Bt,At),rgba:m}}e.opaque=o;function l(p,m){return pt=Math.round(m*255),[jt,Bt,At]=Da.toChannels(p.rgba),{css:bt.toCss(jt,Bt,At,pt),rgba:bt.toRgba(jt,Bt,At,pt)}}e.opacity=l;function u(p,m){return pt=p.rgba&255,l(p,pt*m/255)}e.multiplyOpacity=u;function d(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=d})(rt||(rt={}));var ht;(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 jt=parseInt(o.slice(1,2).repeat(2),16),Bt=parseInt(o.slice(2,3).repeat(2),16),At=parseInt(o.slice(3,4).repeat(2),16),bt.toColor(jt,Bt,At);case 5:return jt=parseInt(o.slice(1,2).repeat(2),16),Bt=parseInt(o.slice(2,3).repeat(2),16),At=parseInt(o.slice(3,4).repeat(2),16),pt=parseInt(o.slice(4,5).repeat(2),16),bt.toColor(jt,Bt,At,pt);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 jt=parseInt(l[1]),Bt=parseInt(l[2]),At=parseInt(l[3]),pt=Math.round((l[5]===void 0?1:parseFloat(l[5]))*255),bt.toColor(jt,Bt,At,pt);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[jt,Bt,At,pt]=t.getImageData(0,0,1,1).data,pt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:bt.toRgba(jt,Bt,At,pt),css:o}}e.toColor=s})(ht||(ht={}));var Qt;(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),y=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+y*.7152+w*.0722}e.relativeLuminance2=n})(Qt||(Qt={}));var Da;(e=>{function t(u,d){if(pt=(d&255)/255,pt===1)return d;let p=d>>24&255,m=d>>16&255,y=d>>8&255,w=u>>24&255,_=u>>16&255,v=u>>8&255;return jt=w+Math.round((p-w)*pt),Bt=_+Math.round((m-_)*pt),At=v+Math.round((y-v)*pt),bt.toRgba(jt,Bt,At)}e.blend=t;function n(u,d,p){let m=Qt.relativeLuminance(u>>8),y=Qt.relativeLuminance(d>>8);if(an(m,y)<p){if(y<m){let v=s(u,d,p),b=an(m,Qt.relativeLuminance(v>>8));if(b<p){let k=o(u,d,p),x=an(m,Qt.relativeLuminance(k>>8));return b>x?v:k}return v}let w=o(u,d,p),_=an(m,Qt.relativeLuminance(w>>8));if(_<p){let v=s(u,d,p),b=an(m,Qt.relativeLuminance(v>>8));return _>b?w:v}return w}}e.ensureContrastRatio=n;function s(u,d,p){let m=u>>24&255,y=u>>16&255,w=u>>8&255,_=d>>24&255,v=d>>16&255,b=d>>8&255,k=an(Qt.relativeLuminance2(_,v,b),Qt.relativeLuminance2(m,y,w));for(;k<p&&(_>0||v>0||b>0);)_-=Math.max(0,Math.ceil(_*.1)),v-=Math.max(0,Math.ceil(v*.1)),b-=Math.max(0,Math.ceil(b*.1)),k=an(Qt.relativeLuminance2(_,v,b),Qt.relativeLuminance2(m,y,w));return(_<<24|v<<16|b<<8|255)>>>0}e.reduceLuminance=s;function o(u,d,p){let m=u>>24&255,y=u>>16&255,w=u>>8&255,_=d>>24&255,v=d>>16&255,b=d>>8&255,k=an(Qt.relativeLuminance2(_,v,b),Qt.relativeLuminance2(m,y,w));for(;k<p&&(_<255||v<255||b<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),k=an(Qt.relativeLuminance2(_,v,b),Qt.relativeLuminance2(m,y,w));return(_<<24|v<<16|b<<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 er(e){let t=e.toString(16);return t.length<2?"0"+t:t}function an(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var h1=class extends Zs{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 Ri}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],s=t.translateToString(!0),o=0,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 y=this._getJoinedRanges(s,u,l,t,o);for(let w=0;w<y.length;w++)n.push(y[w])}o=m,u=l,d=this._workCell.fg,p=this._workCell.bg}l+=this._workCell.getChars().length||On.length}if(this._bufferService.cols-o>1){let m=this._getJoinedRanges(s,u,l,t,o);for(let y=0;y<m.length;y++)n.push(m[y])}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||On.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=mt([Ce(0,Jt)],za);function d1(e){return 57508<=e&&e<=57558}function f1(e){return 9472<=e&&e<=9631}function p1(e){return d1(e)||f1(e)}function m1(){return{css:{canvas:_a(),cell:_a()},device:{canvas:_a(),cell:_a(),char:{width:0,height:0,left:0,top:0}}}}function _a(){return{width:0,height:0}}var sh=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 Ri,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,s,o,l,u,d,p,m,y){let w=[],_=this._characterJoinerService.getJoinedCharacters(t),v=this._themeService.colors,b=e.getNoBgTrimmedLength();n&&b<l+1&&(b=l+1);let k,x=0,R="",j=0,A=0,B=0,ie=0,z=!1,$=0,re=!1,U=0,X=0,q=[],D=m!==-1&&y!==-1;for(let E=0;E<b;E++){e.loadCell(E,this._workCell);let L=this._workCell.getWidth();if(L===0)continue;let Y=!1,N=E>=X,H=E,I=this._workCell;if(_.length>0&&E===_[0][0]&&N){let ae=_.shift(),we=this._isCellInSelection(ae[0],t);for(j=ae[0]+1;j<ae[1];j++)N&&(N=we===this._isCellInSelection(j,t));N&&(N=!n||l<ae[0]||l>=ae[1]),N?(Y=!0,I=new h1(this._workCell,e.translateToString(!0,ae[0],ae[1]),ae[1]-ae[0]),H=ae[1]-1,L=I.getWidth()):X=ae[1]}let W=this._isCellInSelection(E,t),Z=n&&E===l,P=D&&E>=m&&E<=y,Q=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ae=>{Q=!0});let se=I.getChars()||On;if(se===" "&&(I.isUnderline()||I.isOverline())&&(se=" "),U=L*d-p.get(se,I.isBold(),I.isItalic()),!k)k=this._document.createElement("span");else if(x&&(W&&re||!W&&!re&&I.bg===A)&&(W&&re&&v.selectionForeground||I.fg===B)&&I.extended.ext===ie&&P===z&&U===$&&!Z&&!Y&&!Q&&N){I.isInvisible()?R+=On:R+=se,x++;continue}else x&&(k.textContent=R),k=this._document.createElement("span"),x=0,R="";if(A=I.bg,B=I.fg,ie=I.extended.ext,z=P,$=U,re=W,Y&&l>=E&&l<=H&&(l=E),!this._coreService.isCursorHidden&&Z&&this._coreService.isCursorInitialized){if(q.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&q.push("xterm-cursor-blink"),q.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":q.push("xterm-cursor-outline");break;case"block":q.push("xterm-cursor-block");break;case"bar":q.push("xterm-cursor-bar");break;case"underline":q.push("xterm-cursor-underline");break}}if(I.isBold()&&q.push("xterm-bold"),I.isItalic()&&q.push("xterm-italic"),I.isDim()&&q.push("xterm-dim"),I.isInvisible()?R=On:R=I.getChars()||On,I.isUnderline()&&(q.push(`xterm-underline-${I.extended.underlineStyle}`),R===" "&&(R=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())k.style.textDecorationColor=`rgb(${Zs.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let ae=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&ae<8&&(ae+=8),k.style.textDecorationColor=v.ansi[ae].css}I.isOverline()&&(q.push("xterm-overline"),R===" "&&(R=" ")),I.isStrikethrough()&&q.push("xterm-strikethrough"),P&&(k.style.textDecoration="underline");let J=I.getFgColor(),le=I.getFgColorMode(),de=I.getBgColor(),pe=I.getBgColorMode(),ye=!!I.isInverse();if(ye){let ae=J;J=de,de=ae;let we=le;le=pe,pe=we}let K,ee,Re=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ae=>{ae.options.layer!=="top"&&Re||(ae.backgroundColorRGB&&(pe=50331648,de=ae.backgroundColorRGB.rgba>>8&16777215,K=ae.backgroundColorRGB),ae.foregroundColorRGB&&(le=50331648,J=ae.foregroundColorRGB.rgba>>8&16777215,ee=ae.foregroundColorRGB),Re=ae.options.layer==="top")}),!Re&&W&&(K=this._coreBrowserService.isFocused?v.selectionBackgroundOpaque:v.selectionInactiveBackgroundOpaque,de=K.rgba>>8&16777215,pe=50331648,Re=!0,v.selectionForeground&&(le=50331648,J=v.selectionForeground.rgba>>8&16777215,ee=v.selectionForeground)),Re&&q.push("xterm-decoration-top");let G;switch(pe){case 16777216:case 33554432:G=v.ansi[de],q.push(`xterm-bg-${de}`);break;case 50331648:G=bt.toColor(de>>16,de>>8&255,de&255),this._addStyle(k,`background-color:#${km((de>>>0).toString(16),"0",6)}`);break;case 0:default:ye?(G=v.foreground,q.push("xterm-bg-257")):G=v.background}switch(K||I.isDim()&&(K=rt.multiplyOpacity(G,.5)),le){case 16777216:case 33554432:I.isBold()&&J<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(J+=8),this._applyMinimumContrast(k,G,v.ansi[J],I,K,void 0)||q.push(`xterm-fg-${J}`);break;case 50331648:let ae=bt.toColor(J>>16&255,J>>8&255,J&255);this._applyMinimumContrast(k,G,ae,I,K,ee)||this._addStyle(k,`color:#${km(J.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(k,G,v.foreground,I,K,ee)||ye&&q.push("xterm-fg-257")}q.length&&(k.className=q.join(" "),q.length=0),!Z&&!Y&&!Q&&N?x++:k.textContent=R,U!==this.defaultSpacing&&(k.style.letterSpacing=`${U}px`),w.push(k),E=H}return k&&x&&(k.textContent=R),w}_applyMinimumContrast(e,t,n,s,o,l){if(this._optionsService.rawOptions.minimumContrastRatio===1||p1(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=rt.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]}};sh=mt([Ce(1,jv),Ce(2,Zt),Ce(3,hn),Ce(4,hr),Ce(5,eo),Ce(6,Yr)],sh);function km(e,t,n){for(;e.length<n;)e=t+e;return e}var g1=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}},v1=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 _1(){return new v1}var Qc="xterm-dom-renderer-owner-",ki="xterm-rows",ya="xterm-fg-",Em="xterm-bg-",Bs="xterm-focus",Sa="xterm-selection",y1=1,oh=class extends We{constructor(e,t,n,s,o,l,u,d,p,m,y,w,_,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=y,this._coreService=w,this._coreBrowserService=_,this._themeService=v,this._terminalClass=y1++,this._rowElements=[],this._selectionRenderModel=_1(),this.onRequestRedraw=this._register(new Se).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(ki),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(Sa),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=m1(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(b=>this._injectCss(b))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(sh,document),this._element.classList.add(Qc+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(b=>this._handleLinkHover(b))),this._register(this._linkifier2.onHideLinkUnderline(b=>this._handleLinkLeave(b))),this._register(ot(()=>{this._element.classList.remove(Qc+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new g1(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} .${ki} 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} .${ki} { 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} .${ki} .xterm-dim { color: ${rt.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} .${ki}.${Bs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${ki}.${Bs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${ki}.${Bs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${ki} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${ki} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${ki} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${ki} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${ki} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Sa} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Sa} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Sa} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[l,u]of e.ansi.entries())t+=`${this._terminalSelector} .${ya}${l} { color: ${u.css}; }${this._terminalSelector} .${ya}${l}.xterm-dim { color: ${rt.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${Em}${l} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${ya}257 { color: ${rt.opaque(e.background).css}; }${this._terminalSelector} .${ya}257.xterm-dim { color: ${rt.multiplyOpacity(rt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Em}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(Bs),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Bs),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 y=u-l-1;if(d.appendChild(this._createSelectionElement(l+1,0,this._bufferService.cols,y)),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,y=this._rowElements[p],w=n.lines.get(m);if(!y||!w)break;y.replaceChildren(...this._rowFactory.createRow(w,m,m===s,u,d,o,l,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Qc}${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),y=this._optionsService.rawOptions.cursorBlink,w=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let v=n;v<=s;++v){let b=v+d.ydisp,k=this._rowElements[v],x=d.lines.get(b);if(!k||!x)break;k.replaceChildren(...this._rowFactory.createRow(x,b,b===p,w,_,m,y,this.dimensions.css.cell.width,this._widthCache,l?v===n?e:0:-1,l?(v===s?t:o)-1:-1))}}};oh=mt([Ce(7,Oh),Ce(8,Xa),Ce(9,Zt),Ce(10,Jt),Ce(11,hr),Ce(12,hn),Ce(13,Yr)],oh);var ah=class extends We{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Se),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new w1(this._optionsService))}catch{this._measureStrategy=this._register(new S1(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())}};ah=mt([Ce(2,Zt)],ah);var Zv=class extends We{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)}},S1=class extends Zv{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}},w1=class extends Zv{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}},b1=class extends We{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 C1(this._window)),this._onDprChange=this._register(new Se),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Se),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register($t.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ie(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ie(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}},C1=class extends We{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new qr),this._onDprChange=this._register(new Se),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ot(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ie(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)}},x1=class extends We{constructor(){super(),this.linkProviders=[],this._register(ot(()=>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 qh(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 k1(e,t,n,s,o,l,u,d,p){if(!l)return;let m=qh(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 lh=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,o){return k1(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=qh(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])}}};lh=mt([Ce(0,dn),Ce(1,Xa)],lh);var E1=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=[]}},e_={};Aw(e_,{getSafariVersion:()=>R1,isChromeOS:()=>r_,isFirefox:()=>t_,isIpad:()=>P1,isIphone:()=>D1,isLegacyEdge:()=>N1,isLinux:()=>Vh,isMac:()=>Fa,isNode:()=>Ga,isSafari:()=>i_,isWindows:()=>n_});var Ga=typeof process<"u"&&"title"in process,to=Ga?"node":navigator.userAgent,io=Ga?"node":navigator.platform,t_=to.includes("Firefox"),N1=to.includes("Edge"),i_=/^((?!chrome|android).)*safari/i.test(to);function R1(){if(!i_)return 0;let e=to.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Fa=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(io),P1=io==="iPad",D1=io==="iPhone",n_=["Windows","Win16","Win32","WinCE"].includes(io),Vh=io.indexOf("Linux")>=0,r_=/\bCrOS\b/.test(to),s_=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()}},M1=class extends s_{_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())}}},L1=class extends s_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Ha=!Ga&&"requestIdleCallback"in window?L1:M1,T1=class{constructor(){this._queue=new Ha}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},ch=class extends We{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 qr),this._pausedResizeTask=new T1,this._observerDisposable=this._register(new qr),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 Se),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Se),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Se),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Se),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new E1((m,y)=>this._renderRows(m,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new j1(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ot(()=>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=ot(()=>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()}};ch=mt([Ce(2,Zt),Ce(3,Xa),Ce(4,hr),Ce(5,eo),Ce(6,Jt),Ce(7,hn),Ce(8,Yr)],ch);var j1=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 B1(e,t,n,s){let o=n.buffer.x,l=n.buffer.y;if(!n.buffer.hasScrollback)return O1(o,l,e,t,n,s)+Qa(l,t,n,s)+z1(o,l,e,t,n,s);let u;if(l===t)return u=o>e?"D":"C",Qs(Math.abs(o-e),Gs(u,s));u=l>t?"D":"C";let d=Math.abs(l-t),p=I1(l>t?e:o,n)+(d-1)*n.cols+1+A1(l>t?o:e);return Qs(p,Gs(u,s))}function A1(e,t){return e-1}function I1(e,t){return t.cols-e}function O1(e,t,n,s,o,l){return Qa(t,s,o,l).length===0?"":Qs(a_(e,t,e,t-cr(t,o),!1,o).length,Gs("D",l))}function Qa(e,t,n,s){let o=e-cr(e,n),l=t-cr(t,n),u=Math.abs(o-l)-F1(e,t,n);return Qs(u,Gs(o_(e,t),s))}function z1(e,t,n,s,o,l){let u;Qa(t,s,o,l).length>0?u=s-cr(s,o):u=t;let d=s,p=H1(e,t,n,s,o,l);return Qs(a_(e,u,n,d,p==="C",o).length,Gs(p,l))}function F1(e,t,n){var u;let s=0,o=e-cr(e,n),l=t-cr(t,n);for(let d=0;d<Math.abs(o-l);d++){let p=o_(e,t)==="A"?-1:1;(u=n.buffer.lines.get(o+p*d))!=null&&u.isWrapped&&s++}return s}function cr(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 H1(e,t,n,s,o,l){let u;return Qa(n,s,o,l).length>0?u=s-cr(s,o):u=t,e<n&&u<=s||e>=n&&u<s?"C":"D"}function o_(e,t){return e>t?"A":"B"}function a_(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 Gs(e,t){let n=t?"O":"[";return he.ESC+n+e}function Qs(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var $1=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 Nm(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 Jc=50,W1=15,U1=50,K1=500,q1=" ",V1=new RegExp(q1,"g"),uh=class extends We{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 Ri,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Se),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Se),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Se),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Se),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 $1(this._bufferService),this._activeSelectionMode=0,this._register(ot(()=>{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(V1," ")).join(n_?`\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())),Vh&&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=Nm(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=qh(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,-Jc),Jc),t/=Jc,t/Math.abs(t)+Math.round(t*(W1-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(),U1)}_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<K1&&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=B1(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,y=0,w=0,_=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 x=e[0],R=e[0];l.getWidth(x)===0&&(y++,x--),l.getWidth(R)===2&&(w++,R++);let j=l.getString(R).length;for(j>1&&(v+=j-1,p+=j-1);x>0&&d>0&&!this._isCharWordSeparator(l.loadCell(x-1,this._workCell));){l.loadCell(x-1,this._workCell);let A=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,x--):A>1&&(_+=A-1,d-=A-1),d--,x--}for(;R<l.length&&p+1<u.length&&!this._isCharWordSeparator(l.loadCell(R+1,this._workCell));){l.loadCell(R+1,this._workCell);let A=this._workCell.getChars().length;this._workCell.getWidth()===2?(w++,R++):A>1&&(v+=A-1,p+=A-1),p++,R++}}p++;let b=d+m-y+_,k=Math.min(this._bufferService.cols,p-d+y+w-_-v);if(!(!t&&u.slice(d,p).trim()==="")){if(n&&b===0&&l.getCodePoint(0)!==32){let x=o.lines.get(e[1]-1);if(x&&l.isWrapped&&x.getCodePoint(this._bufferService.cols-1)!==32){let R=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(R){let j=this._bufferService.cols-R.start;b-=j,k+=j}}}if(s&&b+k===this._bufferService.cols&&l.getCodePoint(this._bufferService.cols-1)!==32){let x=o.lines.get(e[1]+1);if(x!=null&&x.isWrapped&&x.getCodePoint(0)!==32){let R=this._getWordAt([0,e[1]+1],!1,!1,!0);R&&(k+=R.length)}}return{start:b,length:k}}}_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=Nm(n,this._bufferService.cols)}};uh=mt([Ce(3,Jt),Ce(4,hr),Ce(5,zh),Ce(6,Zt),Ce(7,dn),Ce(8,hn)],uh);var Rm=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={}}},Pm=class{constructor(){this._color=new Rm,this._css=new Rm}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()}},Nt=Object.freeze((()=>{let e=[ht.toColor("#2e3436"),ht.toColor("#cc0000"),ht.toColor("#4e9a06"),ht.toColor("#c4a000"),ht.toColor("#3465a4"),ht.toColor("#75507b"),ht.toColor("#06989a"),ht.toColor("#d3d7cf"),ht.toColor("#555753"),ht.toColor("#ef2929"),ht.toColor("#8ae234"),ht.toColor("#fce94f"),ht.toColor("#729fcf"),ht.toColor("#ad7fa8"),ht.toColor("#34e2e2"),ht.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:bt.toCss(s,o,l),rgba:bt.toRgba(s,o,l)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:bt.toCss(s,s,s),rgba:bt.toRgba(s,s,s)})}return e})()),ir=ht.toColor("#ffffff"),Ks=ht.toColor("#000000"),Dm=ht.toColor("#ffffff"),Mm=Ks,As={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Y1=ir,hh=class extends We{constructor(e){super(),this._optionsService=e,this._contrastCache=new Pm,this._halfContrastCache=new Pm,this._onChangeColors=this._register(new Se),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ir,background:Ks,cursor:Dm,cursorAccent:Mm,selectionForeground:void 0,selectionBackgroundTransparent:As,selectionBackgroundOpaque:rt.blend(Ks,As),selectionInactiveBackgroundTransparent:As,selectionInactiveBackgroundOpaque:rt.blend(Ks,As),scrollbarSliderBackground:rt.opacity(ir,.2),scrollbarSliderHoverBackground:rt.opacity(ir,.4),scrollbarSliderActiveBackground:rt.opacity(ir,.5),overviewRulerBorder:ir,ansi:Nt.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=et(e.foreground,ir),t.background=et(e.background,Ks),t.cursor=rt.blend(t.background,et(e.cursor,Dm)),t.cursorAccent=rt.blend(t.background,et(e.cursorAccent,Mm)),t.selectionBackgroundTransparent=et(e.selectionBackground,As),t.selectionBackgroundOpaque=rt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=et(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=rt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?et(e.selectionForeground,xm):void 0,t.selectionForeground===xm&&(t.selectionForeground=void 0),rt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=rt.opacity(t.selectionBackgroundTransparent,.3)),rt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=rt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=et(e.scrollbarSliderBackground,rt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=et(e.scrollbarSliderHoverBackground,rt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=et(e.scrollbarSliderActiveBackground,rt.opacity(t.foreground,.5)),t.overviewRulerBorder=et(e.overviewRulerBorder,Y1),t.ansi=Nt.slice(),t.ansi[0]=et(e.black,Nt[0]),t.ansi[1]=et(e.red,Nt[1]),t.ansi[2]=et(e.green,Nt[2]),t.ansi[3]=et(e.yellow,Nt[3]),t.ansi[4]=et(e.blue,Nt[4]),t.ansi[5]=et(e.magenta,Nt[5]),t.ansi[6]=et(e.cyan,Nt[6]),t.ansi[7]=et(e.white,Nt[7]),t.ansi[8]=et(e.brightBlack,Nt[8]),t.ansi[9]=et(e.brightRed,Nt[9]),t.ansi[10]=et(e.brightGreen,Nt[10]),t.ansi[11]=et(e.brightYellow,Nt[11]),t.ansi[12]=et(e.brightBlue,Nt[12]),t.ansi[13]=et(e.brightMagenta,Nt[13]),t.ansi[14]=et(e.brightCyan,Nt[14]),t.ansi[15]=et(e.brightWhite,Nt[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]=et(e.extendedAnsi[s],Nt[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()}}};hh=mt([Ce(0,Zt)],hh);function et(e,t){if(e!==void 0)try{return ht.toColor(e)}catch{}return t}var X1=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)}},G1=class{constructor(){this._services=new X1,this._services.set(Oh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=Ww(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)}},Q1={trace:0,debug:1,info:2,warn:3,error:4,off:5},J1="xterm.js: ",dh=class extends We{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=Q1[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?"":J1)+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)}};dh=mt([Ce(0,Zt)],dh);var Lm=class extends We{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Se),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Se),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Se),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}},$e=3,wt=Object.freeze(new Zs),wa=0,Zc=2,qs=class l_{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*$e);let o=n||Ri.fromCharData([0,Nv,1,0]);for(let l=0;l<t;++l)this.setCell(l,o);this.length=t}get(t){let n=this._data[t*$e+0],s=n&2097151;return[this._data[t*$e+1],n&2097152?this._combined[t]:s?An(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*$e+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*$e+0]=t|2097152|n[2]<<22):this._data[t*$e+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*$e+0]>>22}hasWidth(t){return this._data[t*$e+0]&12582912}getFg(t){return this._data[t*$e+1]}getBg(t){return this._data[t*$e+2]}hasContent(t){return this._data[t*$e+0]&4194303}getCodePoint(t){let n=this._data[t*$e+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*$e+0]&2097152}getString(t){let n=this._data[t*$e+0];return n&2097152?this._combined[t]:n&2097151?An(n&2097151):""}isProtected(t){return this._data[t*$e+2]&536870912}loadCell(t,n){return wa=t*$e,n.content=this._data[wa+0],n.fg=this._data[wa+1],n.bg=this._data[wa+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*$e+0]=n.content,this._data[t*$e+1]=n.fg,this._data[t*$e+2]=n.bg}setCellFromCodepoint(t,n,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*$e+0]=n|s<<22,this._data[t*$e+1]=o.fg,this._data[t*$e+2]=o.bg}addCodepointToCell(t,n,s){let o=this._data[t*$e+0];o&2097152?this._combined[t]+=An(n):o&2097151?(this._combined[t]=An(o&2097151)+An(n),o&=-2097152,o|=2097152):o=n|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*$e+0]=o}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length-t){let o=new Ri;for(let 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 Ri;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*Zc<this._data.buffer.byteLength;let s=t*$e;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*Zc<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Zc<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 l_(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*$e+0]&4194303)return t+(this._data[t*$e+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*$e+0]&4194303||this._data[t*$e+2]&50331648)return t+(this._data[t*$e+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<$e;m++)this._data[(s+p)*$e+m]=u[(n+p)*$e+m];u[(n+p)*$e+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[n+p])}else for(let p=0;p<o;p++){for(let m=0;m<$e;m++)this._data[(s+p)*$e+m]=u[(n+p)*$e+m];u[(n+p)*$e+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*$e+0],d=u&2097151,p=u&2097152?this._combined[n]:d?An(d):On;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 Z1(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 y=[e.get(d)];for(;p<e.length&&m.isWrapped;)y.push(m),m=e.get(++p);if(!l&&s>=d&&s<p){d+=y.length-1;continue}let w=0,_=Js(y,w,t),v=1,b=0;for(;v<y.length;){let x=Js(y,v,t),R=x-b,j=n-_,A=Math.min(R,j);y[w].copyCellsFrom(y[v],b,_,A,!1),_+=A,_===n&&(w++,_=0),b+=A,b===x&&(v++,b=0),_===0&&w!==0&&y[w-1].getWidth(n-1)===2&&(y[w].copyCellsFrom(y[w-1],n-1,_++,1,!1),y[w-1].setCell(n-1,o))}y[w].replaceCells(_,n,o);let k=0;for(let x=y.length-1;x>0&&(x>w||y[x].getTrimmedLength()===0);x--)k++;k>0&&(u.push(d+y.length-k),u.push(k)),d+=y.length-1}return u}function eb(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 tb(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 ib(e,t,n){let s=[],o=e.map((p,m)=>Js(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=Js(e,u,t);l>p&&(l-=p,u++);let m=e[u].getWidth(l-1)===2;m&&l--;let y=m?n-1:n;s.push(y),d+=y}return s}function Js(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 c_=class u_{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=u_._nextId++,this._onDispose=this.register(new Se),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),lr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};c_._nextId=1;var nb=c_,Pt={},nr=Pt.B;Pt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Pt.A={"#":"£"};Pt.B=void 0;Pt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Pt.C=Pt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Pt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Pt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Pt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Pt.E=Pt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Pt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Pt.H=Pt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Tm=4294967295,jm=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=wt.clone(),this.savedCharset=nr,this.markers=[],this._nullCell=Ri.fromCharData([0,Nv,1,0]),this._whitespaceCell=Ri.fromCharData([0,On,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 Lm(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 qs(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=wt);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 Lm(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(wt),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 qs(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 qs(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=Z1(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(wt),n);if(s.length>0){let o=eb(this.lines,s);tb(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(wt),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new qs(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(wt),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(),y=ib(p,this._cols,e),w=y.length-p.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+w):_=Math.max(0,this.lines.length-this.lines.maxLength+w);let v=[];for(let A=0;A<w;A++){let B=this.getBlankLine(wt,!0);v.push(B)}v.length>0&&(o.push({start:u+p.length+l,newLines:v}),l+=v.length),p.push(...v);let b=y.length-1,k=y[b];k===0&&(b--,k=y[b]);let x=p.length-w-1,R=m;for(;x>=0;){let A=Math.min(R,k);if(p[b]===void 0)break;if(p[b].copyCellsFrom(p[x],R-A,k-A,A,!0),k-=A,k===0&&(b--,k=y[b]),R-=A,R===0){x--;let B=Math.max(x,0);R=Js(p,B,this._cols)}}for(let A=0;A<p.length;A++)y[A]<e&&p[A].setCell(y[A],s);let j=w-_;for(;j-- >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 k=0;k<this.lines.length;k++)d.push(this.lines.get(k));let p=this.lines.length,m=p-1,y=0,w=o[y];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+l);let _=0;for(let k=Math.min(this.lines.maxLength-1,p+l-1);k>=0;k--)if(w&&w.start>m+_){for(let x=w.newLines.length-1;x>=0;x--)this.lines.set(k--,w.newLines[x]);k++,u.push({index:m+1,amount:w.newLines.length}),_+=w.newLines.length,w=o[++y]}else this.lines.set(k,d[m--]);let v=0;for(let k=u.length-1;k>=0;k--)u[k].index+=v,this.lines.onInsertEmitter.fire(u[k]),v+=u[k].amount;let b=Math.max(0,p+l-this.lines.maxLength);b>0&&this.lines.onTrimEmitter.fire(b)}}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 nb(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)}},rb=class extends We{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Se),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 jm(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new jm(!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)}},h_=2,d_=1,fh=class extends We{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Se),this.onResize=this._onResize.event,this._onScroll=this._register(new Se),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,h_),this.rows=Math.max(e.rawOptions.rows||0,d_),this.buffers=this._register(new rb(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))}};fh=mt([Ce(0,Zt)],fh);var zr={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:{}},sb=["normal","bold","100","200","300","400","500","600","700","800","900"],ob=class extends We{constructor(e){super(),this._onOptionChange=this._register(new Se),this.onOptionChange=this._onOptionChange.event;let t={...zr};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(ot(()=>{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 zr))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in zr))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=zr[e]),!ab(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=zr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=sb.includes(t)?t:zr[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 ab(e){return e==="block"||e==="underline"||e==="bar"}function Vs(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]&&Vs(e[s],t-1);return n}var Bm=Object.freeze({insertMode:!1}),Am=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),ph=class extends We{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 Se),this.onData=this._onData.event,this._onUserInput=this._register(new Se),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Se),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Se),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Vs(Bm),this.decPrivateModes=Vs(Am)}reset(){this.modes=Vs(Bm),this.decPrivateModes=Vs(Am)}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))}};ph=mt([Ce(0,Jt),Ce(1,Lv),Ce(2,Zt)],ph);var Im={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 eu(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 tu=String.fromCharCode,Om={DEFAULT:e=>{let t=[eu(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${tu(t[0])}${tu(t[1])}${tu(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${eu(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${eu(e,!0)};${e.x};${e.y}${t}`}},mh=class extends We{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 Se),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Im))this.addProtocol(s,Im[s]);for(let s of Object.keys(Om))this.addEncoding(s,Om[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)}};mh=mt([Ce(0,Jt),Ce(1,hr),Ce(2,Zt)],mh);var iu=[[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]],lb=[[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]],Rt;function cb(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 ub=class{constructor(){if(this.version="6",!Rt){Rt=new Uint8Array(65536),Rt.fill(1),Rt[0]=0,Rt.fill(0,1,32),Rt.fill(0,127,160),Rt.fill(2,4352,4448),Rt[9001]=2,Rt[9002]=2,Rt.fill(2,11904,42192),Rt[12351]=1,Rt.fill(2,44032,55204),Rt.fill(2,63744,64256),Rt.fill(2,65040,65050),Rt.fill(2,65072,65136),Rt.fill(2,65280,65377),Rt.fill(2,65504,65511);for(let e=0;e<iu.length;++e)Rt.fill(0,iu[e][0],iu[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Rt[e]:cb(e,lb)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let o=sr.extractWidth(t);o===0?s=!1:o>n&&(n=o)}return sr.createPropertyValue(0,n,s)}},sr=class Ma{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Se,this.onChange=this._onChange.event;let t=new ub;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)}},hb=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 zm(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 Is=2147483647,db=256,f_=class gh{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>db)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 gh;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 gh(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>Is?Is: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>Is?Is: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,Is):t}},Os=[],fb=class{constructor(){this._state=0,this._active=Os,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=Os}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=Os,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Os,!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=Os,this._id=-1,this._state=0}}},pi=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=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}},zs=[],pb=class{constructor(){this._handlers=Object.create(null),this._active=zs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=zs}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=zs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||zs,!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=zs,this._ident=0}},Ys=new f_;Ys.addParam(0);var Fm=class{constructor(e){this._handler=e,this._data="",this._params=Ys,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Ys,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=Ys,this._data="",this._hitLimit=!1,n));return this._params=Ys,this._data="",this._hitLimit=!1,t}},mb=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}},Ni=160,gb=(function(){let e=new mb(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(Ni,0,2,0),e.add(Ni,8,5,8),e.add(Ni,6,0,6),e.add(Ni,11,0,11),e.add(Ni,13,13,13),e})(),vb=class extends We{constructor(e=gb){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 f_,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(ot(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new fb),this._dcsParser=this._register(new pb),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:Ni)],o>>4){case 2:for(let _=d+1;;++_){if(_>=t||(s=e[_])<32||s>126&&s<Ni){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Ni){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Ni){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Ni){this._printHandler(e,d,_),d=_-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 y=this._escHandlers[this._collect<<8|s],w=y?y.length-1:-1;for(;w>=0&&(u=y[w](),u!==!0);w--)if(u instanceof Promise)return this._preserveStack(4,y,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 _=d+1;;++_)if(_>=t||(s=e[_])===24||s===26||s===27||s>127&&s<Ni){this._dcsParser.put(e,d,_),d=_-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 _=d+1;;_++)if(_>=t||(s=e[_])<32||s>127&&s<Ni){this._oscParser.put(e,d,_),d=_-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}}},_b=/^([\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})$/,yb=/^[\da-f]+$/;function Hm(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=_b.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),yb.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 nu(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 Sb(e,t=16){let[n,s,o]=e;return`rgb:${nu(n,t)}/${nu(s,t)}/${nu(o,t)}`}var wb={"(":0,")":1,"*":2,"+":3,"-":1,".":2},jn=131072,$m=10;function Wm(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 Um=5e3,Km=0,bb=class extends We{constructor(e,t,n,s,o,l,u,d,p=new vb){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 Hw,this._utf8Decoder=new $w,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=wt.clone(),this._eraseAttrDataInternal=wt.clone(),this._onRequestBell=this._register(new Se),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Se),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Se),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Se),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Se),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Se),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Se),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Se),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Se),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Se),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Se),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Se),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Se),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 vh(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(m=>this._activeBuffer=m.activeBuffer)),this._parser.setCsiHandlerFallback((m,y)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(m),params:y.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,y,w)=>{this._logService.debug("Unknown OSC code: ",{identifier:m,action:y,data:w})}),this._parser.setDcsHandlerFallback((m,y,w)=>{y==="HOOK"&&(w=w.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(m),action:y,payload:w})}),this._parser.setPrintHandler((m,y,w)=>this.print(m,y,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(he.BEL,()=>this.bell()),this._parser.setExecuteHandler(he.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(he.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(he.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(he.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(he.BS,()=>this.backspace()),this._parser.setExecuteHandler(he.HT,()=>this.tab()),this._parser.setExecuteHandler(he.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(he.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Pa.IND,()=>this.index()),this._parser.setExecuteHandler(Pa.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Pa.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new pi(m=>(this.setTitle(m),this.setIconName(m),!0))),this._parser.registerOscHandler(1,new pi(m=>this.setIconName(m))),this._parser.registerOscHandler(2,new pi(m=>this.setTitle(m))),this._parser.registerOscHandler(4,new pi(m=>this.setOrReportIndexedColor(m))),this._parser.registerOscHandler(8,new pi(m=>this.setHyperlink(m))),this._parser.registerOscHandler(10,new pi(m=>this.setOrReportFgColor(m))),this._parser.registerOscHandler(11,new pi(m=>this.setOrReportBgColor(m))),this._parser.registerOscHandler(12,new pi(m=>this.setOrReportCursorColor(m))),this._parser.registerOscHandler(104,new pi(m=>this.restoreIndexedColor(m))),this._parser.registerOscHandler(110,new pi(m=>this.restoreFgColor(m))),this._parser.registerOscHandler(111,new pi(m=>this.restoreBgColor(m))),this._parser.registerOscHandler(112,new pi(m=>this.restoreCursorColor(m))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let m in Pt)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 Fm((m,y)=>this.requestStatusString(m,y)))}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"),Um))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Um} 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>jn&&(l=this._parseStack.position+jn)}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<jn&&(this._parseBuffer=new Uint32Array(Math.min(e.length,jn))),u||this._dirtyRowTracker.clearRange(),e.length>jn)for(let m=l;m<e.length;m+=jn){let y=m+jn<e.length?m+jn:e.length,w=typeof e=="string"?this._stringDecoder.decode(e.substring(m,y),this._parseBuffer):this._utf8Decoder.decode(e.subarray(m,y),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,y=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,y);let _=this._parser.precedingJoinState;for(let v=t;v<n;++v){if(s=e[v],s<127&&l){let R=l[String.fromCharCode(s)];R&&(s=R.charCodeAt(0))}let b=this._unicodeService.charProperties(s,_);o=sr.extractWidth(b);let k=sr.extractShouldJoin(b),x=k?sr.extractWidth(_):0;if(_=b,u&&this._onA11yChar.fire(An(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-x>d){if(p){let R=w,j=this._activeBuffer.x-x;for(this._activeBuffer.x=x,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),x>0&&w instanceof qs&&w.copyCellsFrom(R,j,0,x,!1);j<d;)R.setCellFromCodepoint(j++,0,1,y)}else if(this._activeBuffer.x=d-1,o===2)continue}if(k&&this._activeBuffer.x){let R=w.getWidth(this._activeBuffer.x-1)?1:2;w.addCodepointToCell(this._activeBuffer.x-R,s,o);for(let j=o-x;--j>=0;)w.setCellFromCodepoint(this._activeBuffer.x++,0,0,y);continue}if(m&&(w.insertCells(this._activeBuffer.x,o-x,this._activeBuffer.getNullCell(y)),w.getWidth(d-1)===2&&w.setCellFromCodepoint(d-1,0,1,y)),w.setCellFromCodepoint(this._activeBuffer.x++,s,o,y),o>0)for(;--o;)w.setCellFromCodepoint(this._activeBuffer.x++,0,0,y)}this._parser.precedingJoinState=_,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,y),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>Wm(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Fm(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new pi(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,o=!1){let 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(wt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,s=sr.extractWidth(t),o=this._activeBuffer.x-s,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 y=l.codePointAt(m)||0;u[d++]=y,m+=y>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(he.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(he.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(he.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(he.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(he.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,nr),this._charsetService.setgCharset(1,nr),this._charsetService.setgCharset(2,nr),this._charsetService.setgCharset(3,nr);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(k=>(k[k.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",k[k.SET=1]="SET",k[k.RESET=2]="RESET",k[k.PERMANENTLY_SET=3]="PERMANENTLY_SET",k[k.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:l}=this._coreMouseService,u=this._coreService,{buffers:d,cols:p}=this._bufferService,{active:m,alt:y}=d,w=this._optionsService.rawOptions,_=(k,x)=>(u.triggerDataEvent(`${he.ESC}[${t?"":"?"}${k};${x}$y`),!0),v=k=>k?1:2,b=e.params[0];return t?b===2?_(b,4):b===4?_(b,v(u.modes.insertMode)):b===12?_(b,3):b===20?_(b,v(w.convertEol)):_(b,0):b===1?_(b,v(s.applicationCursorKeys)):b===3?_(b,w.windowOptions.setWinLines?p===80?2:p===132?1:0:0):b===6?_(b,v(s.origin)):b===7?_(b,v(s.wraparound)):b===8?_(b,3):b===9?_(b,v(o==="X10")):b===12?_(b,v(w.cursorBlink)):b===25?_(b,v(!u.isCursorHidden)):b===45?_(b,v(s.reverseWraparound)):b===66?_(b,v(s.applicationKeypad)):b===67?_(b,4):b===1e3?_(b,v(o==="VT200")):b===1002?_(b,v(o==="DRAG")):b===1003?_(b,v(o==="ANY")):b===1004?_(b,v(s.sendFocus)):b===1005?_(b,4):b===1006?_(b,v(l==="SGR")):b===1015?_(b,4):b===1016?_(b,v(l==="SGR_PIXELS")):b===1048?_(b,1):b===47||b===1047||b===1049?_(b,v(m===y)):b===2004?_(b,v(s.bracketedPasteMode)):b===2026?_(b,v(s.synchronizedOutput)):_(b,0)}_updateAttrColor(e,t,n,s,o){return t===2?(e|=50331648,e&=-16777216,e|=Zs.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=wt.fg,e.bg=wt.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|=wt.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=wt.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|=wt.fg&16777215,s.bg&=-67108864,s.bg|=wt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${he.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${he.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(`${he.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=wt.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(!Wm(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${he.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>$m&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>$m&&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(qm(l))if(o==="?")t.push({type:0,index:l});else{let u=Hm(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=Hm(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]);qm(o)&&t.push({type:2,index:o})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,nr),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(wb[e[0]],Pt[e[1]]||nr),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=wt.clone(),this._eraseAttrDataInternal=wt.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Ri;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(n);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=u=>(this._coreService.triggerDataEvent(`${he.ESC}${u}${he.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)}},vh=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&&(Km=e,e=t,t=Km),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};vh=mt([Ce(0,Jt)],vh);function qm(e){return 0<=e&&e<256}var Cb=5e7,Vm=12,xb=50,kb=class extends We{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 Se),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>Cb)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>=Vm?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>=Vm)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>xb&&(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()}},_h=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)))}};_h=mt([Ce(0,Jt)],_h);var Ym=!1,Eb=class extends We{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new qr),this._onBinary=this._register(new Se),this.onBinary=this._onBinary.event,this._onData=this._register(new Se),this.onData=this._onData.event,this._onLineFeed=this._register(new Se),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Se),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Se),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Se),this._instantiationService=new G1,this.optionsService=this._register(new ob(e)),this._instantiationService.setService(Zt,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(fh)),this._instantiationService.setService(Jt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(dh)),this._instantiationService.setService(Lv,this._logService),this.coreService=this._register(this._instantiationService.createInstance(ph)),this._instantiationService.setService(hr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(mh)),this._instantiationService.setService(Mv,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(sr)),this._instantiationService.setService(qw,this.unicodeService),this._charsetService=this._instantiationService.createInstance(hb),this._instantiationService.setService(Kw,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(_h),this._instantiationService.setService(Tv,this._oscLinkService),this._inputHandler=this._register(new bb(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register($t.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register($t.forward(this._bufferService.onResize,this._onResize)),this._register($t.forward(this.coreService.onData,this._onData)),this._register($t.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 kb((t,n)=>this._inputHandler.parse(t,n))),this._register($t.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Se),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&&!Ym&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Ym=!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,h_),t=Math.max(t,d_),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(zm.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(zm(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ot(()=>{for(let t of e)t.dispose()})}}},Nb={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 Rb(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=he.ESC+"OA":o.key=he.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=he.ESC+"OD":o.key=he.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=he.ESC+"OC":o.key=he.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=he.ESC+"OB":o.key=he.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":he.DEL,e.altKey&&(o.key=he.ESC+o.key);break;case 9:if(e.shiftKey){o.key=he.ESC+"[Z";break}o.key=he.HT,o.cancel=!0;break;case 13:o.key=e.altKey?he.ESC+he.CR:he.CR,o.cancel=!0;break;case 27:o.key=he.ESC,e.altKey&&(o.key=he.ESC+he.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;l?o.key=he.ESC+"[1;"+(l+1)+"D":t?o.key=he.ESC+"OD":o.key=he.ESC+"[D";break;case 39:if(e.metaKey)break;l?o.key=he.ESC+"[1;"+(l+1)+"C":t?o.key=he.ESC+"OC":o.key=he.ESC+"[C";break;case 38:if(e.metaKey)break;l?o.key=he.ESC+"[1;"+(l+1)+"A":t?o.key=he.ESC+"OA":o.key=he.ESC+"[A";break;case 40:if(e.metaKey)break;l?o.key=he.ESC+"[1;"+(l+1)+"B":t?o.key=he.ESC+"OB":o.key=he.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=he.ESC+"[2~");break;case 46:l?o.key=he.ESC+"[3;"+(l+1)+"~":o.key=he.ESC+"[3~";break;case 36:l?o.key=he.ESC+"[1;"+(l+1)+"H":t?o.key=he.ESC+"OH":o.key=he.ESC+"[H";break;case 35:l?o.key=he.ESC+"[1;"+(l+1)+"F":t?o.key=he.ESC+"OF":o.key=he.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=he.ESC+"[5;"+(l+1)+"~":o.key=he.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=he.ESC+"[6;"+(l+1)+"~":o.key=he.ESC+"[6~";break;case 112:l?o.key=he.ESC+"[1;"+(l+1)+"P":o.key=he.ESC+"OP";break;case 113:l?o.key=he.ESC+"[1;"+(l+1)+"Q":o.key=he.ESC+"OQ";break;case 114:l?o.key=he.ESC+"[1;"+(l+1)+"R":o.key=he.ESC+"OR";break;case 115:l?o.key=he.ESC+"[1;"+(l+1)+"S":o.key=he.ESC+"OS";break;case 116:l?o.key=he.ESC+"[15;"+(l+1)+"~":o.key=he.ESC+"[15~";break;case 117:l?o.key=he.ESC+"[17;"+(l+1)+"~":o.key=he.ESC+"[17~";break;case 118:l?o.key=he.ESC+"[18;"+(l+1)+"~":o.key=he.ESC+"[18~";break;case 119:l?o.key=he.ESC+"[19;"+(l+1)+"~":o.key=he.ESC+"[19~";break;case 120:l?o.key=he.ESC+"[20;"+(l+1)+"~":o.key=he.ESC+"[20~";break;case 121:l?o.key=he.ESC+"[21;"+(l+1)+"~":o.key=he.ESC+"[21~";break;case 122:l?o.key=he.ESC+"[23;"+(l+1)+"~":o.key=he.ESC+"[23~";break;case 123:l?o.key=he.ESC+"[24;"+(l+1)+"~":o.key=he.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=he.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=he.DEL:e.keyCode===219?o.key=he.ESC:e.keyCode===220?o.key=he.FS:e.keyCode===221&&(o.key=he.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let d=(u=Nb[e.keyCode])==null?void 0:u[e.shiftKey?1:0];if(d)o.key=he.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=he.ESC+m}else if(e.keyCode===32)o.key=he.ESC+(e.ctrlKey?he.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),o.key=he.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=he.US),e.key==="@"&&(o.key=he.NUL));break}return o}var yt=0,Pb=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||(yt=this._search(t),yt===-1)||this._getKey(this._array[yt])!==t)return!1;do if(this._array[yt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(yt),!0;while(++yt<this._array.length&&this._getKey(this._array[yt])===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&&(yt=this._search(e),!(yt<0||yt>=this._array.length)&&this._getKey(this._array[yt])===e))do yield this._array[yt];while(++yt<this._array.length&&this._getKey(this._array[yt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(yt=this._search(e),!(yt<0||yt>=this._array.length)&&this._getKey(this._array[yt])===e))do t(this._array[yt]);while(++yt<this._array.length&&this._getKey(this._array[yt])===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}},ru=0,Xm=0,Db=class extends We{constructor(){super(),this._decorations=new Pb(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new Se),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Se),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ot(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Mb(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=>{ru=o.options.x??0,Xm=ru+(o.options.width??1),e>=ru&&e<Xm&&(!n||(o.options.layer??"bottom")===n)&&s(o)})}},Mb=class extends zn{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Se),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Se),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=ht.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ht.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Lb=1e3,Tb=class{constructor(e,t=Lb){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)}},Gm=20,$a=class extends We{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 Tb(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(Ie(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ot(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Gm+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
65
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Gm+1&&(this._liveRegion.textContent+=Ou.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 y=p instanceof Text?p.parentNode:p,w=parseInt(y==null?void 0:y.getAttribute("aria-posinset"),10)-1;if(isNaN(w))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(y);if(!_)return console.warn("columns is null. Race condition?"),null;let v=m<_.length?_[m]:_.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=mt([Ce(1,Oh),Ce(2,hn),Ce(3,dn)],$a);var yh=class extends We{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 Se),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Se),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ot(()=>{var l;lr(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(Ie(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ie(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ie(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ie(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,y;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),((y=this._activeProviderReplies)==null?void 0:y.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&&jb(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,lr(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}}};yh=mt([Ce(1,zh),Ce(2,dn),Ce(3,Jt),Ce(4,Bv)],yh);function jb(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 Bb=class extends Eb{constructor(e={}){super(e),this._linkifier=this._register(new qr),this.browser=e_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new qr),this._onCursorMove=this._register(new Se),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Se),this.onKey=this._onKey.event,this._onRender=this._register(new Se),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Se),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Se),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Se),this.onBell=this._onBell.event,this._onFocus=this._register(new Se),this._onBlur=this._register(new Se),this._onA11yCharEmitter=this._register(new Se),this._onA11yTabEmitter=this._register(new Se),this._onWillOpen=this._register(new Se),this._setup(),this._decorationService=this._instantiationService.createInstance(Db),this._instantiationService.setService(eo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(x1),this._instantiationService.setService(Bv,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Fu)),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($t.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register($t.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register($t.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register($t.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ot(()=>{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=rt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${he.ESC}]${s};${Sb(o)}${Jv.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(l=>l.ansi[t.index]=bt.toColor(...t.color));else{let l=n;this._themeService.modifyColors(u=>u[l]=bt.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(he.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(he.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let 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(Ie(this.element,"copy",t=>{this.hasSelection()&&zw(t,this._selectionService)}));let e=t=>Fw(t,this.textarea,this.coreService,this.optionsService);this._register(Ie(this.textarea,"paste",e)),this._register(Ie(this.element,"paste",e)),t_?this._register(Ie(this.element,"mousedown",t=>{t.button===2&&om(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ie(this.element,"contextmenu",t=>{om(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Vh&&this._register(Ie(this.element,"auxclick",t=>{t.button===1&&Ev(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ie(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ie(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ie(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ie(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ie(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ie(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ie(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(Ie(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",Iu.get()),r_||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(b1,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(hn,this._coreBrowserService),this._register(Ie(this.textarea,"focus",l=>this._handleTextAreaFocus(l))),this._register(Ie(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(ah,this._document,this._helperContainer),this._instantiationService.setService(Xa,this._charSizeService),this._themeService=this._instantiationService.createInstance(hh),this._instantiationService.setService(Yr,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(za),this._instantiationService.setService(jv,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(ch,this.rows,this.screenElement)),this._instantiationService.setService(dn,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(rh,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(lh),this._instantiationService.setService(zh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(yh,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(ih,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(uh,this.element,this.screenElement,s)),this._instantiationService.setService(Yw,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($t.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var l;this._selectionService.refresh(),(l=this._viewport)==null||l.queueSync()})),this._register(this._instantiationService.createInstance(nh,this.screenElement)),this._register(Ie(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(oh,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,y,w,_,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 b=l.deltaY;if(b===0||e.coreMouseService.consumeWheelEvent(l,(_=(w=(y=(m=e._renderService)==null?void 0:m.dimensions)==null?void 0:y.device)==null?void 0:w.cell)==null?void 0:_.height,(v=e._coreBrowserService)==null?void 0:v.dpr)===0)return!1;p=b<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(Ie(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(Ie(t,"wheel",l=>{var u,d,p,m,y;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,(y=e._coreBrowserService)==null?void 0:y.dpr)===0)return this.cancel(l,!0);let w=he.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){kv(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=Rb(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===he.ETX||n.key===he.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)&&(Ab(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(wt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(he.ESC+"[I"):this.coreService.triggerDataEvent(he.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${he.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(`${he.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function Ab(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Ib=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)}},Ob=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Ri)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Qm=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 Ob(t)}getNullCell(){return new Ri}},zb=class extends We{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Se),this.onBufferChange=this._onBufferChange.event,this._normal=new Qm(this._core.buffers.normal,"normal"),this._alternate=new Qm(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)}},Fb=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)}},Hb=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}},$b=["cols","rows"],Ki=0,Wb=class extends We{constructor(e){super(),this._core=this._register(new Bb(e)),this._addonManager=this._register(new Ib),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($b.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 Fb(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Hb(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 zb(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 Iu.get()},set promptLabel(e){Iu.set(e)},get tooMuchOutput(){return Ou.get()},set tooMuchOutput(e){Ou.set(e)}}}_verifyIntegers(...e){for(Ki of e)if(Ki===1/0||isNaN(Ki)||Ki%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Ki of e)if(Ki&&(Ki===1/0||isNaN(Ki)||Ki%1!==0||Ki<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 Ub=2,Kb=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,y=o-p-t;return{cols:Math.max(Ub,Math.floor(y/e.css.cell.width)),rows:Math.max(Kb,Math.floor(m/e.css.cell.height))}}};function Vb(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function Yb({session:e,node:t,token:n,cols:s,rows:o,readonly:l=!1,takeSize:u,focused:d,onData:p,onExit:m,onFiles:y,retryBaseMs:w=250}){const _=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!_)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const b=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${Vb(t,n)}`;let k=null,x=!1,R=!1,j=null,A=0,B=d;const ie=()=>{if(x||R||j)return;const $=Math.min(5e3,Math.max(0,w)*2**Math.min(A++,5));j=setTimeout(()=>{j=null,z()},$)},z=()=>{if(x||R)return;const $=new WebSocket(b);k=$,$.binaryType="arraybuffer",$.onopen=()=>{if(k!==$||x)return;A=0;const re={type:"attach",session:e,token:n,cols:s,rows:o,readonly:l};u!==void 0&&(re.takeSize=u),$.send(JSON.stringify(re)),B!==void 0&&$.send(JSON.stringify({type:"focus",on:!!B}))},$.onmessage=re=>{if(!(k!==$||x))if(typeof re.data=="string"){let U;try{U=JSON.parse(re.data)}catch{return}U.type==="exit"&&(R=!0,m&&m(U.code)),U.type==="files"&&y&&y(U)}else p&&p(new Uint8Array(re.data))},$.onerror=()=>{if(k===$)try{$.close()}catch{}},$.onclose=re=>{k!==$||x||R||[1e3,1002,4401,4404].includes(re==null?void 0:re.code)||ie()}};return z(),{sendInput:$=>{if(!k||k.readyState!==1)return!1;try{return k.send(typeof $=="string"?new TextEncoder().encode($):$),!0}catch{try{k.close()}catch{}return!1}},isReady:()=>!!k&&k.readyState===1,resize:($,re)=>{s=$,o=re,(k==null?void 0:k.readyState)===1&&k.send(JSON.stringify({type:"resize",cols:$,rows:re}))},action:$=>{(k==null?void 0:k.readyState)===1&&k.send(JSON.stringify({type:"action",name:$}))},focus:$=>{B=$,(k==null?void 0:k.readyState)===1&&k.send(JSON.stringify({type:"focus",on:!!$}))},close:()=>{if(x=!0,j&&clearTimeout(j),j=null,k)try{k.close()}catch{}},get raw(){return k}}}async function Jm(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 Xb="\r";function Gb(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 Qb({isReady:e,paste:t,send:n}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:n(Xb)!==!1}catch{return!1}}}function Jb(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function Zb(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}const eC=450,Zm=8;function tC(e,t,n,s){return Math.abs(Number(n)-Number(e))>Zm||Math.abs(Number(s)-Number(t))>Zm}const iC=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function su(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 eg(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 nC(e,t=0,n=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=iC.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${n}-${t+1}.${o}`}async function p_({files:e,token:t,session:n,node:s="",paste:o=!0,fetchImpl:l=It,onProgress:u=()=>{},now:d=Date.now()}={}){const p=Array.from(e||[]).filter(Boolean),m=[],y=[];if(!n||!p.length)return{paths:m,errors:y};const w=vi(s?String(s).split("/"):[]);for(let _=0;_<p.length;_+=1){const v=p[_],b=nC(v,_,d);u({index:_,total:p.length,name:b,state:"uploading"});try{const k=new FormData;k.append("session",n),k.append("paste",o?"true":"false"),k.append("file",v,b);const x=await l(`${w}/files/upload`,t,{method:"POST",body:k}),R=await x.json().catch(()=>({}));if(!x.ok||R.error)throw new Error(R.error||`HTTP ${x.status}`);m.push(R.path),u({index:_,total:p.length,name:b,state:"done",path:R.path})}catch(k){const x=String((k==null?void 0:k.message)||k);y.push({name:b,message:x}),u({index:_,total:p.length,name:b,state:"error",error:x})}}return{paths:m,errors:y}}function m_({session:e,node:t,token:n,readonly:s,takeSize:o,focused:l,sendRef:u,composerRef:d,actionRef:p,ctrlRef:m,setCtrlArmed:y,onFiles:w,fontSize:_=13,selectionMode:v=!1,onSelectionModeChange:b}){const k=M.useRef(null),x=M.useRef(null),R=M.useRef(_);R.current=_;const j=M.useRef(l);j.current=l;const A=M.useRef(v);A.current=v;const[B,ie]=M.useState(""),[z,$]=M.useState(""),[re,U]=M.useState(null),X=async()=>{var L,Y,N,H;const D=((Y=(L=x.current)==null?void 0:L.term)==null?void 0:Y.getSelection())||B;if(!D){$(S("copy-empty")),setTimeout(()=>$(""),1500);return}const E=await Jm(D);$(S(E?"copied":"copy-manual")),E&&((H=(N=x.current)==null?void 0:N.term)==null||H.clearSelection(),b==null||b(!1)),setTimeout(()=>$(""),1800)},q=M.useRef(X);return q.current=X,M.useEffect(()=>{const D=x.current;D&&D.sock&&D.sock.focus&&D.sock.focus(!!l)},[l]),M.useEffect(()=>{const D=x.current;D&&(D.term.options.fontSize=_,D.fit.fit(),D.sock.resize(D.term.cols,D.term.rows))},[_]),M.useEffect(()=>{const D=new Wb({cursorBlink:!0,fontSize:R.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),E=new qb;D.loadAddon(E),D.open(k.current),E.fit();const L=new TextDecoder;let Y;try{Y=Yb({session:e,node:t,token:n,readonly:s,takeSize:o,focused:j.current,onFiles:w,cols:D.cols,rows:D.rows,onData:ve=>D.write(L.decode(ve)),onExit:()=>D.write(`\r
|
|
78
|
-
\x1B[33m[sessione finita]\x1B[0m\r
|
|
79
|
-
`)})}catch(ve){return D.write(`\r
|
|
80
|
-
\x1B[31m${ve.message}\x1B[0m\r
|
|
81
|
-
`),()=>D.dispose()}x.current={term:D,fit:E,sock:Y};let N=null;const H=D.onData(ve=>{if(s){N&&(N.ok=!1);return}if(!N&&m&&m.current&&ve.length===1){const ce=ve.charCodeAt(0);let xe=ce;ce>=97&&ce<=122?xe=ce-96:ce>=64&&ce<=95?xe=ce-64:ce===32&&(xe=0),ve=String.fromCharCode(xe),m.current=!1,y&&y(!1)}const Ve=Y.sendInput(ve);N&&(N.seen=!0,N.ok=N.ok&&Ve)});u&&(u.current=ve=>Y.sendInput(ve)),p&&(p.current=ve=>Y.action(ve)),d&&(d.current=Qb({isReady:()=>!s&&Y.isReady(),paste:ve=>{const Ve={seen:!1,ok:!0};N=Ve;try{D.paste(ve)}catch{Ve.ok=!1}finally{N=null}return Ve.seen&&Ve.ok},send:ve=>Y.sendInput(ve)}));const I=D.onSelectionChange(()=>ie(D.getSelection()));D.attachCustomKeyEventHandler(ve=>(ve.ctrlKey||ve.metaKey)&&ve.key.toLowerCase()==="c"&&D.getSelection()?(ve.type==="keydown"&&Jm(D.getSelection()),!1):!0);const W=k.current;let Z=!1;const P=async ve=>{if(!ve.length||Z)return;if(s){U({error:S("settings-readonly")});return}Z=!0,U({current:0,total:ve.length,name:""});const Ve=await p_({files:ve,token:n,session:e,node:t,paste:!0,onProgress:({index:ce,total:xe,name:Oe,state:dt,error:Yt})=>U({current:ce+1,total:xe,name:Oe,...dt==="error"?{error:Yt}:{}})});Z=!1,Ve.errors.length?U({error:Ve.errors.map(ce=>`${ce.name}: ${ce.message}`).join(" · ")}):(U({done:!0,total:Ve.paths.length}),setTimeout(()=>U(null),1600))},Q=ve=>{const Ve=ve.clipboardData;if(!su(Ve))return;const ce=eg(Ve);ce.length&&(ve.preventDefault(),ve.stopPropagation(),P(ce))},se=ve=>{su(ve.dataTransfer)&&(ve.preventDefault(),ve.stopPropagation())},J=ve=>{su(ve.dataTransfer)&&(ve.preventDefault(),ve.stopPropagation(),P(eg(ve.dataTransfer)))};W.addEventListener("paste",Q,!0),W.addEventListener("dragenter",se,!0),W.addEventListener("dragover",se,!0),W.addEventListener("drop",J,!0);const le=24;let de=null,pe=null,ye=0,K=null,ee=null,Re=null,G=!1;const ae=()=>{Re&&clearTimeout(Re),Re=null},we=(ve,Ve)=>{const xe=(W.querySelector(".xterm-screen")||W).getBoundingClientRect(),Oe=Math.max(0,Math.min(D.cols-1,Math.floor((ve-xe.left)/Math.max(1,xe.width)*D.cols))),dt=Math.max(0,Math.min(D.rows-1,Math.floor((Ve-xe.top)/Math.max(1,xe.height)*D.rows)));return{col:Oe,row:D.buffer.active.viewportY+dt}},O=ve=>we(ve.clientX,ve.clientY),ue=ve=>{if(ae(),G=!1,ve.touches.length!==1){de=null;return}if(A.current){ve.preventDefault(),ve.stopPropagation(),ee=O(ve.touches[0]),D.clearSelection();return}de=ve.touches[0].clientY,pe=ve.touches[0].clientX,ye=0,K=null;const Ve={x:pe,y:de};Re=setTimeout(()=>{Re=null,G=!0,A.current=!0,b==null||b(!0),ee=we(Ve.x,Ve.y),D.clearSelection(),D.select(ee.col,ee.row,1),de=null,pe=null,K=null,ye=0},eC)},be=ve=>{if((A.current||G)&&ee&&ve.touches.length===1){ve.preventDefault(),ve.stopPropagation();const ce=O(ve.touches[0]),xe=ee.row*D.cols+ee.col,Oe=ce.row*D.cols+ce.col,dt=xe<=Oe?ee:ce;D.select(dt.col,dt.row,Math.abs(Oe-xe)+1);return}if(de===null||ve.touches.length!==1)return;ve.preventDefault(),ve.stopPropagation();const Ve=ve.touches[0];if(Re&&tC(pe,de,Ve.clientX,Ve.clientY)&&ae(),K===null&&(Math.abs(Ve.clientY-de)>8||Math.abs(Ve.clientX-pe)>8)&&(K=Math.abs(Ve.clientY-de)>Math.abs(Ve.clientX-pe)),!!K){for(ye+=Ve.clientY-de,de=Ve.clientY;ye>=le;)Y.action("scroll-up"),ye-=le;for(;ye<=-le;)Y.action("scroll-down"),ye+=le}},Le=()=>{ae(),de=null,pe=null,ee=null,G=!1};let Ke=0;const De=ve=>{for(ve.preventDefault(),ve.stopPropagation(),Ke+=ve.deltaY;Ke<=-le;)Y.action("scroll-up"),Ke+=le;for(;Ke>=le;)Y.action("scroll-down"),Ke-=le};W.addEventListener("touchstart",ue,{passive:!1}),W.addEventListener("touchmove",be,{passive:!1,capture:!0}),W.addEventListener("touchend",Le,{passive:!0}),W.addEventListener("touchcancel",Le,{passive:!0});const Qe=ve=>{(A.current||G)&&(ve.preventDefault(),ve.stopPropagation())};W.addEventListener("contextmenu",Qe,!0),W.addEventListener("wheel",De,{passive:!1,capture:!0});let qe=null;const Ye=ve=>{Jb(ve)&&(ve.preventDefault(),ve.stopPropagation(),qe=we(ve.clientX,ve.clientY),D.clearSelection())},Ct=ve=>{if(!qe)return;ve.preventDefault(),ve.stopPropagation();const Ve=we(ve.clientX,ve.clientY),ce=qe.row*D.cols+qe.col,xe=Ve.row*D.cols+Ve.col,Oe=ce<=xe?qe:Ve;D.select(Oe.col,Oe.row,Math.abs(xe-ce)+1)},ze=ve=>{qe&&(ve.stopPropagation(),qe=null)};W.addEventListener("mousedown",Ye,!0),W.addEventListener("mousemove",Ct,!0),W.addEventListener("mouseup",ze,!0);const at=ve=>{!Zb(ve)||!(x.current&&x.current.term&&x.current.term.getSelection())||(ve.preventDefault(),ve.stopPropagation(),q.current&&q.current())};W.addEventListener("keydown",at,!0);const Be=()=>{E.fit(),Y.resize(D.cols,D.rows)};window.addEventListener("resize",Be);const gt=window.visualViewport;gt&&(gt.addEventListener("resize",Be),gt.addEventListener("scroll",Be));let Pi=null,xt=0;return typeof ResizeObserver<"u"&&(Pi=new ResizeObserver(()=>{xt&&cancelAnimationFrame(xt),xt=requestAnimationFrame(Be)}),Pi.observe(W)),()=>{x.current=null,u&&(u.current=()=>!1),d&&(d.current=()=>!1),p&&(p.current=()=>!1),H.dispose(),I.dispose(),W.removeEventListener("touchstart",ue),W.removeEventListener("touchmove",be,{capture:!0}),W.removeEventListener("touchend",Le),W.removeEventListener("touchcancel",Le),W.removeEventListener("contextmenu",Qe,!0),ae(),W.removeEventListener("wheel",De,{capture:!0}),W.removeEventListener("mousedown",Ye,!0),W.removeEventListener("mousemove",Ct,!0),W.removeEventListener("mouseup",ze,!0),W.removeEventListener("keydown",at,!0),W.removeEventListener("paste",Q,!0),W.removeEventListener("dragenter",se,!0),W.removeEventListener("dragover",se,!0),W.removeEventListener("drop",J,!0),window.removeEventListener("resize",Be),gt&&(gt.removeEventListener("resize",Be),gt.removeEventListener("scroll",Be)),Pi&&Pi.disconnect(),xt&&cancelAnimationFrame(xt),Y.close(),D.dispose()}},[e,t,n,s,o,u,d,p,m,y,w]),h.jsxs("div",{className:`nc-terminal${v?" selecting":""}`,children:[h.jsx("div",{className:"nc-terminal-host",ref:k}),re&&h.jsx("div",{className:`nc-upload-state${re.error?" error":""}`,role:"status",children:re.error?re.error:re.done?S("attach-uploaded").replace("{n}",String(re.total||0)):S("attach-upload-progress").replace("{n}",String(re.current||0)).replace("{total}",String(re.total||0))}),(B||v)&&h.jsxs("div",{className:"nc-selection-tools",children:[B?h.jsx("button",{type:"button",onClick:X,children:z||S("copy")}):h.jsx("span",{children:S("select-drag")}),h.jsx("button",{type:"button",onClick:()=>{var D,E;(E=(D=x.current)==null?void 0:D.term)==null||E.clearSelection(),ie(""),b==null||b(!1)},children:S("cancel")}),z===S("copy-manual")&&h.jsx("textarea",{readOnly:!0,value:B,onFocus:D=>D.target.select()})]})]})}const tg="",ai="\x1B",rC=[{label:"↑",seq:ai+"[A"},{label:"↓",seq:ai+"[B"},{label:"PGUP",seq:ai+"[5~"},{label:"PGDN",seq:ai+"[6~"}];function sC({send:e,action:t,ctrlArmed:n=!1,onCtrl:s,onKeyboard:o,selectionMode:l=!1,onSelectionMode:u}){const[d,p]=M.useState(!1),[m,y]=M.useState(!1),[w,_]=M.useState(!1),v=x=>{w?(e(ai+x),_(!1)):e(x)},b=(x,R,j)=>h.jsx("button",{onMouseDown:A=>{A.preventDefault(),v(R),j&&j()},children:x},x),k=(x,R)=>h.jsx("button",{onMouseDown:j=>{j.preventDefault(),t(R),y(!1)},children:x},x);return d?h.jsxs("div",{className:"nc-keybar copy",children:[h.jsx("span",{className:"tag",children:"copy-mode"}),rC.map(x=>b(x.label,x.seq)),b("ESCI (q)","q",()=>p(!1))]}):h.jsxs("div",{className:"nc-keybar termux",children:[m&&h.jsxs("div",{className:"nc-keymenu",children:[k("←WIN","prev-window"),k("WIN→","next-window"),k("⬅PANE","pane-left"),k("PANE➡","pane-right"),b("SCROLL",tg+"[",()=>{p(!0),y(!1)}),h.jsx("button",{className:l?"armed":"",onMouseDown:x=>{x.preventDefault(),u==null||u(!l),y(!1)},children:"SELECT"}),b("⌃C","",()=>y(!1)),b("DETACH",tg+"d",()=>y(!1))]}),h.jsxs("div",{className:"row",children:[b("ESC",ai),h.jsx("button",{className:m?"armed":"",onMouseDown:x=>{x.preventDefault(),y(R=>!R)},children:"☰"},"menu"),b("/","/"),b("—","-"),b("HOME",ai+"[H"),b("↑",ai+"[A"),b("END",ai+"[F"),b("PGUP",ai+"[5~")]}),h.jsxs("div",{className:"row",children:[b("⇥"," "),h.jsx("button",{onMouseDown:x=>{x.preventDefault(),o&&o()},children:"⌨"},"kbd"),h.jsx("button",{className:n?"armed":"",onMouseDown:x=>{x.preventDefault(),s&&s()},children:"CTRL"},"ctrl"),h.jsx("button",{className:w?"armed":"",onMouseDown:x=>{x.preventDefault(),_(R=>!R)},children:"ALT"},"alt"),b("←",ai+"[D"),b("↓",ai+"[B"),b("→",ai+"[C"),b("PGDN",ai+"[6~")]})]})}const oC=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function g_({session:e,node:t,token:n,filesEvent:s,onClose:o}){_i();const l=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",u=t?`${t}:${e}`:e,[d,p]=M.useState("outbox"),[m,y]=M.useState({inbox:[],outbox:[]}),[w,_]=M.useState(""),v=M.useRef(null);async function b(){try{const A=await(await It(`${l}/files?session=${encodeURIComponent(e)}`,n)).json();if(A.error){_(A.error);return}y(A);const B=A.outbox[0]?A.outbox[0].mtime:0;localStorage.setItem(La(u),String(B))}catch(j){_(String(j))}}M.useEffect(()=>{b()},[e,t]),M.useEffect(()=>{s&&s.session===e&&b()},[s]);async function k(j){for(const A of j){_(`carico ${A.name}…`);const B=new FormData;B.append("session",e),B.append("file",A);try{const z=await(await It(`${l}/files/upload`,n,{method:"POST",body:B})).json();_(z.error?`errore: ${z.error}`:"")}catch(ie){_(String(ie))}}b()}async function x(j){const A=await It(`${l}/files/download?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(j)}`,n);if(!A.ok){_("errore download");return}const B=await A.blob(),ie=URL.createObjectURL(B),z=document.createElement("a");z.href=ie,z.download=j,z.click(),URL.revokeObjectURL(ie)}async function R(j){await It(`${l}/files?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(j)}`,n,{method:"DELETE"}),b()}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:S("close"),children:h.jsx(Je,{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(Je,{name:"upload",size:18})," ",S("upload")]}),h.jsx("input",{type:"file",multiple:!0,ref:v,style:{display:"none"},onChange:j=>{k(Array.from(j.target.files||[])),j.target.value=""}})]}),w&&h.jsx("div",{className:"nc-busy",children:w}),h.jsxs("ul",{children:[m[d].map(j=>h.jsxs("li",{children:[h.jsx("span",{className:"name",onClick:()=>x(j.name),children:j.name}),h.jsx("small",{children:oC(j.size)}),h.jsx("button",{onClick:()=>R(j.name),title:"elimina",children:h.jsx(Je,{name:"trash",size:18})})]},j.name)),m[d].length===0&&h.jsx("li",{className:"empty",children:S("empty-files")})]})]})}function v_({submitText:e,token:t,session:n,node:s}){_i();const o=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",[l,u]=M.useState(""),[d,p]=M.useState(!1),[m,y]=M.useState(""),[w,_]=M.useState(!1),v=M.useRef(null),b=M.useRef(null),k=M.useRef(null),[x,R]=M.useState(!1),[j,A]=M.useState({left:0,bottom:0}),[B,ie]=M.useState(!1),[z,$]=M.useState(!1),re=M.useRef(null),U=M.useRef(null),X=M.useRef(null),q=M.useRef(null),D=M.useRef(null),E=M.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);M.useEffect(()=>{let se=!1;if(s){_(!1);return}return It(`${o}/voice/status`,t).then(J=>J.json()).then(J=>{se||_(!!J.serverSttConfigured)}).catch(()=>{se||_(!1)}),()=>{se=!0}},[t,o]);const Y=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||w);async function N(){const se=l,J=Gb(se);if(!J||z)return;$(!0),y("");let le=!1;try{le=!!await e(J)}catch{le=!1}le?u(de=>de===se?"":de):y(S("composer-send-failed")),$(!1),requestAnimationFrame(()=>{var de;return(de=k.current)==null?void 0:de.focus({preventScroll:!0})})}function H(){const se=re.current&&re.current.getBoundingClientRect();se&&A({left:Math.max(6,Math.min(se.left,window.innerWidth-186)),bottom:window.innerHeight-se.top+6}),R(!0)}function I(se){R(!1),se&&re.current&&re.current.focus()}M.useEffect(()=>{if(!x)return;const se=le=>{le.key==="Escape"&&I(!0)},J=le=>{const de=U.current&&U.current.contains(le.target),pe=re.current&&re.current.contains(le.target);!de&&!pe&&I(!1)};return document.addEventListener("keydown",se),document.addEventListener("pointerdown",J),()=>{document.removeEventListener("keydown",se),document.removeEventListener("pointerdown",J)}},[x]);function W(se){I(!1),se.current&&se.current.click()}async function Z(se){if(!se.length||!n)return;ie(!0),y("");const{paths:J,errors:le}=await p_({files:se,token:t,session:n,node:s,paste:!1});le.length&&y(le.map(de=>`${de.name}: ${de.message}`).join(" · ")),J.length&&u(de=>de+(de&&!de.endsWith(" ")?" ":"")+J.join(" ")),ie(!1)}function P(){v.current&&v.current.stop(),b.current&&b.current.stop(),p(!1)}async function Q(){y("");const se=window.SpeechRecognition||window.webkitSpeechRecognition;if(se){const J=new se;J.lang="it-IT",J.continuous=!1,J.interimResults=!0;const le=l?`${l} `:"";J.onresult=de=>{const pe=Array.from(de.results).map(ye=>ye[0].transcript).join("");u(le+pe)},J.onend=()=>p(!1),J.onerror=de=>{y(`voice: ${de.error||"errore"}`),p(!1)},v.current=J,J.start(),p(!0);return}try{const J=await navigator.mediaDevices.getUserMedia({audio:!0}),le=new MediaRecorder(J),de=[];le.ondataavailable=pe=>de.push(pe.data),le.onstop=async()=>{J.getTracks().forEach(pe=>pe.stop()),p(!1),y("trascrivo…");try{const pe=new Blob(de,{type:le.mimeType||"audio/webm"}),K=await(await It(`${o}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:pe})).json();K.error?y(K.error):(y(""),u(ee=>ee+(ee?" ":"")+(K.text||"")))}catch(pe){y(String(pe))}},b.current={stop:()=>le.state!=="inactive"&&le.stop()},le.start(),p(!0)}catch{y("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:re,className:B?"attach busy":"attach",disabled:B,onClick:()=>x?I(!1):H(),title:S(B?"attach-uploading":"attach"),"aria-label":S("attach"),"aria-haspopup":"menu","aria-expanded":x,"aria-controls":E.current,children:h.jsx(Je,{name:"attach",size:22})}),x&&h.jsxs("div",{ref:U,id:E.current,role:"menu",className:"nc-attach-menu",style:{left:j.left,bottom:j.bottom},children:[h.jsxs("button",{role:"menuitem",onClick:()=>W(X),children:[h.jsx(Je,{name:"file",size:18})," ",S("attach-file")]}),h.jsxs("button",{role:"menuitem",onClick:()=>W(q),children:[h.jsx(Je,{name:"camera",size:18})," ",S("attach-camera")]}),h.jsxs("button",{role:"menuitem",onClick:()=>W(D),children:[h.jsx(Je,{name:"image",size:18})," ",S("attach-gallery")]})]}),h.jsx("input",{ref:X,type:"file",multiple:!0,hidden:!0,onChange:se=>{Z(Array.from(se.target.files||[])),se.target.value=""}}),h.jsx("input",{ref:q,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:se=>{Z(Array.from(se.target.files||[])),se.target.value=""}}),h.jsx("input",{ref:D,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:se=>{Z(Array.from(se.target.files||[])),se.target.value=""}}),h.jsx("textarea",{ref:k,rows:2,value:l,placeholder:S("composer-placeholder"),onChange:se=>u(se.target.value)}),Y&&h.jsx("button",{className:d?"mic on":"mic",onClick:d?P:Q,title:S("voice"),children:h.jsx(Je,{name:"mic",size:22})}),h.jsx("button",{type:"button",className:"go",disabled:z,onPointerDown:se=>se.preventDefault(),onClick:N,title:S("send"),children:h.jsx(Je,{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 ig(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}function ba(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 aC=180,lC=480;function ou(e){return e.status==="passive"?S("node-passive"):e.status==="down"?e.downSince?S("tunnel-down-since").replace("{t}",Wa(e.downSince)):S("tunnel-down"):e.status==="unreachable"?S("node-unreachable"):e.status==="offline"?e.lastSeen?S("node-offline-seen").replace("{t}",Wa(e.lastSeen)):S("node-offline"):e.status==="needs-repair"?S("node-needs-repair"):""}function cC(e){return!e||e.status==="passive"?null:e.status==="healthy"?"on":"warn"}function ng(e){return e&&(e.detail||e.status)||""}function uC({sessions:e=[],cells:t=[],activeSessions:n=[],nodeGroups:s=[],onPick:o,onAddTile:l,onPower:u,onNodePower:d,onKill:p,onNew:m,onSettings:y,width:w=240,collapsed:_=!1,onResize:v,onToggleCollapse:b}){const[k,x]=_i(),[R,j]=M.useState(hv),[A,B]=M.useState(yv),[ie,z]=M.useState(gv),$=K=>j(ee=>dv(ee,K)),re=new Set((t||[]).map(K=>K.tmuxSession)),U=new Map((e||[]).map(K=>[K.name,K])),X=(K,ee)=>Cw(R,K,ee),q=xw,D=[...t||[]].sort((K,ee)=>q(X(K.tmuxSession,(U.get(K.tmuxSession)||{}).activity),X(ee.tmuxSession,(U.get(ee.tmuxSession)||{}).activity))),E=(e||[]).filter(K=>!re.has(K.name)).sort((K,ee)=>q(X(K.name,K.activity),X(ee.name,ee.activity))||K.name.localeCompare(ee.name)),L=new Set(n||[]),Y=K=>ja(A,K),N=(K,ee)=>B(Re=>{const G={...Re,[K]:{...ja(Re,K),...ee}};return Sv(G)}),H=[...D.map(K=>{const ee=U.get(K.tmuxSession)||{},Re=ln([],K.tmuxSession);return{type:"cell",value:K,key:Re,label:K.cell,live:!!K.tmux,fresh:ba(ee,Re),activity:ee.activity||0}}),...E.map(K=>{const ee=ln([],K.name);return{type:"session",value:K,key:ee,label:K.name,live:!0,fresh:ba(K,ee),activity:K.activity||0}})],I=In(H,R,Y("local").filter,cn(ie,"local")),W=(s||[]).map(K=>{const ee=(K.route||[K.name]).join("/"),Re=Y(ee),G=new Map((K.sessions||[]).map(O=>[O.name,O])),ae=[...(K.cells||[]).map(O=>{const ue=G.get(O.tmuxSession)||{},be=ln(K.route,O.tmuxSession||O.cell);return{type:"cell",value:O,key:be,label:O.cell,live:!!O.tmux,fresh:ba(ue,be),activity:ue.activity||O.activity||0}}),...(K.unmanaged||[]).map(O=>{const ue=ln(K.route,O.name);return{type:"session",value:O,key:ue,label:O.name,live:!0,fresh:ba(O,ue),activity:O.activity||0}})],we=In(ae,R,Re.filter,cn(ie,ee));return{g:K,nodeRoute:ee,groupView:Re,rawItems:ae,items:we}});function Z(K,ee,Re,G){z(ae=>{const we=In(G,R,"all",cn(ae,K)).map(O=>O.key);return vv(_v(ae,K,ee,Re,we))})}function P(K,ee,Re,G){const ae=In(G,R,"all",cn(ie,K)).map(ue=>ue.key),we=ae.indexOf(ee),O=ae[we+Re];we>=0&&O&&Z(K,ee,O,G)}const[Q,se]=M.useState(null),J=(K,ee)=>{const Re=K.currentTarget.getBoundingClientRect();se({text:ee,y:Re.top+Re.height/2})},le=()=>se(null),de=M.useRef(null);M.useEffect(()=>()=>{de.current&&de.current()},[]);function pe(K){K.preventDefault(),K.stopPropagation();const ee=K.clientX,Re=w,G=we=>{const O=Math.max(aC,Math.min(lC,Re+(we.clientX-ee)));v&&v(O)},ae=()=>{window.removeEventListener("pointermove",G),window.removeEventListener("pointerup",ae),window.removeEventListener("pointercancel",ae),window.removeEventListener("blur",ae),de.current=null};window.addEventListener("pointermove",G),window.addEventListener("pointerup",ae),window.addEventListener("pointercancel",ae),window.addEventListener("blur",ae),de.current=ae}const ye=_?{width:48,flex:"0 0 48px"}:{width:w,flex:`0 0 ${w}px`};return _?h.jsxs("aside",{className:"nc-sidebar mini",style:ye,children:[h.jsx("div",{className:"nc-side-head mini",children:h.jsx("button",{className:"nc-collapse-btn",onClick:b,title:S("expand"),children:"⟩"})}),h.jsx("button",{className:"nc-side-gear mini",onClick:()=>y&&y("nodes",!1),title:S("settings"),onMouseEnter:K=>J(K,S("settings")),onMouseLeave:le,children:h.jsx(Je,{name:"gear",size:16})}),h.jsx("div",{className:"nc-side-scroll mini",children:h.jsxs("div",{className:"nc-side-group mini",children:[Y("local").open&&I.map(K=>K.type==="cell"?(()=>{const ee=K.value,Re=ee.degraded?"warn":ee.tmux?"on":"",G=!!ee.tmux;return h.jsx("button",{type:"button",className:`nc-mini-dot${L.has(ee.tmuxSession)?" active":""}`,onMouseEnter:ae=>J(ae,ee.cell),onMouseLeave:le,draggable:G,onDragStart:G?ae=>ae.dataTransfer.setData("text/nc-session",ee.tmuxSession):void 0,onClick:G?()=>l&&l(ee.tmuxSession):()=>u&&u(ee),onDoubleClick:G?()=>o&&o(ee.tmuxSession):void 0,children:h.jsx("span",{className:`nc-dot ${Re}`})},K.key)})():(()=>{const ee=K.value;return h.jsx("button",{type:"button",className:`nc-mini-init${L.has(ee.name)?" active":""}`,onMouseEnter:Re=>J(Re,ee.name),onMouseLeave:le,draggable:!0,onDragStart:Re=>Re.dataTransfer.setData("text/nc-session",ee.name),onClick:()=>l&&l(ee.name),onDoubleClick:()=>o&&o(ee.name),children:ig(ee.name)},K.key)})()),W.flatMap(({g:K,nodeRoute:ee,groupView:Re,items:G})=>K.status==="up"?Re.open?G.map(ae=>ae.type==="cell"?(()=>{const we=ae.value,O=!!we.tmux;return h.jsx("button",{type:"button",className:`nc-mini-dot${L.has(ae.key)?" active":""}`,onMouseEnter:ue=>J(ue,`${K.label||ee}: ${we.cell}`),onMouseLeave:le,draggable:O,onDragStart:O?ue=>ue.dataTransfer.setData("text/nc-session",ae.key):void 0,onClick:O?()=>l&&l(ae.key):()=>u&&u({...we,route:K.route,availableEngines:K.engines||[]}),onDoubleClick:O?()=>o&&o({session:we.tmuxSession,node:ee}):void 0,children:h.jsx("span",{className:`nc-dot ${we.degraded?"warn":O?"on":""}`})},ae.key)})():(()=>{const we=ae.value;return h.jsx("button",{type:"button",className:`nc-mini-init${L.has(ae.key)?" active":""}`,onMouseEnter:O=>J(O,`${K.label||ee}: ${we.name}`),onMouseLeave:le,draggable:!0,onDragStart:O=>O.dataTransfer.setData("text/nc-session",ae.key),onClick:()=>l&&l(ae.key),onDoubleClick:()=>o&&o({session:we.name,node:ee}),children:ig(we.name)},ae.key)})()):[]:[h.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:ae=>J(ae,`${K.label||(K.route||[K.name]).join(" › ")}: ${ou(K)}`),onMouseLeave:le,children:h.jsx("span",{className:`nc-dot${K.status==="passive"?"":" warn"}`})},`nodo-${(K.route||[K.name]).join("/")}`)])]})}),Q&&h.jsx("div",{className:"nc-mini-tip",style:{top:Q.y},children:Q.text})]}):h.jsxs("aside",{className:"nc-sidebar",style:ye,children:[h.jsxs("div",{className:"nc-side-head",children:[h.jsx("button",{className:"nc-collapse-btn",onClick:b,title:S("collapse"),children:"⟨"}),h.jsx("span",{className:"nc-side-title",children:S("fleet")}),h.jsxs("button",{className:"nc-new-btn",onClick:m,title:S("fleet-new-cell"),children:["+ ",S("new")]})]}),h.jsxs("button",{className:"nc-side-gear",onClick:()=>y&&y("nodes",!1),title:S("settings"),children:[h.jsx(Je,{name:"gear",size:15})," ",S("settings")]}),h.jsxs("div",{className:"nc-side-scroll",children:[h.jsx(hC,{label:S("position-local"),count:(t||[]).length+E.length,state:Y("local"),onToggle:()=>N("local",{open:!Y("local").open}),onFilter:K=>N("local",{filter:K})}),Y("local").open&&h.jsxs("div",{className:"nc-side-group",children:[I.map(K=>K.type==="cell"?(()=>{const ee=K.value,Re=ee.degraded?"warn":ee.tmux?"on":"",G=ee.degraded?S("cell-degraded"):ee.tmux?S("cell-on"):S("cell-off"),ae=!!ee.tmux;return h.jsxs("div",{"data-roster-key":K.key,"data-position":"local",className:`nc-cell${ae?" live":""}${L.has(ee.tmuxSession)?" active":""}`,title:`${ee.cell} · ${ee.engine}${ee.key?`·${ee.key}`:""} · ${G}`,"aria-label":`${ee.cell}, ${ee.engine}${ee.key?` ${ee.key}`:""}, ${G}`,draggable:ae,onDragStart:ae?we=>we.dataTransfer.setData("text/nc-session",ee.tmuxSession):void 0,onClick:ae?()=>l&&l(ee.tmuxSession):void 0,onDoubleClick:ae?()=>o&&o(ee.tmuxSession):void 0,...Ws("local",K.key,(we,O)=>Z("local",we,O,H)),children:[h.jsx(Hr,{position:"local",itemKey:K.key,label:ee.cell,onMove:(we,O)=>Z("local",we,O,H),onStep:we=>P("local",K.key,we,H)}),h.jsx("span",{className:`nc-dot ${Re}`}),h.jsxs("span",{className:"nc-cell-main",children:[h.jsx("b",{title:ee.cell,children:ee.cell}),h.jsxs("small",{title:`${ee.engine}${ee.key?`·${ee.key}`:""}`,children:[ee.engine,ee.key?`·${ee.key}`:""]})]}),h.jsx("button",{className:`nc-pin${R.includes(K.key)?" on":""}`,title:S("pin"),onClick:we=>{we.stopPropagation(),$(K.key)},children:R.includes(K.key)?"★":"☆"}),h.jsx("button",{className:`nc-power${ee.tmux?" on":""}${ee.degraded?" warn":""}`,onClick:we=>{we.stopPropagation(),u&&u(ee)},title:ee.active?S("power-off"):S("power-on"),children:h.jsx(Je,{name:"power",size:14})})]},K.key)})():(()=>{var Re;const ee=K.value;return h.jsxs("div",{"data-roster-key":K.key,"data-position":"local",className:`nc-side-card${L.has(ee.name)?" active":""}`,draggable:!0,onDragStart:G=>G.dataTransfer.setData("text/nc-session",ee.name),onClick:()=>l&&l(ee.name),onDoubleClick:()=>o&&o(ee.name),...Ws("local",K.key,(G,ae)=>Z("local",G,ae,H)),children:[h.jsx(Hr,{position:"local",itemKey:K.key,label:ee.name,onMove:(G,ae)=>Z("local",G,ae,H),onStep:G=>P("local",K.key,G,H)}),h.jsx("span",{className:ee.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:ee.name}),h.jsxs("small",{children:[ee.preview||ee.cmd||S("windows").replace("{n}",String(ee.windows||0)),((Re=ee.outbox)==null?void 0:Re.count)>0?` · 📦${ee.outbox.count}`:""]})]}),ee.activity?h.jsx("span",{className:"nc-rel",children:Wa(ee.activity)}):null,h.jsx("button",{className:`nc-pin${R.includes(K.key)?" on":""}`,title:S("pin"),onClick:G=>{G.stopPropagation(),$(K.key)},children:R.includes(K.key)?"★":"☆"}),h.jsx("button",{className:"nc-menu",title:S("terminate"),onClick:G=>{G.stopPropagation(),window.confirm(S("terminate-confirm").replace("{name}",ee.name))&&p&&p(ee.name)},children:"⋯"})]},K.key)})()),I.length===0&&h.jsx("div",{className:"nc-empty",children:S("no-sessions-short")})]}),W.map(({g:K,nodeRoute:ee,groupView:Re,rawItems:G,items:ae})=>{const O=cC(K.health)||(K.status==="up"?"on":K.status==="passive"?"":"warn");return h.jsxs("div",{children:[h.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>N(ee,{open:!Re.open}),onKeyDown:ue=>{(ue.key==="Enter"||ue.key===" ")&&(ue.preventDefault(),N(ee,{open:!Re.open}))},children:[h.jsx("span",{className:"nc-node-chevron",children:Re.open?"⌄":"›"}),h.jsx("span",{className:`nc-dot ${O}`,title:K.health?ng(K.health):""}),h.jsx("b",{children:K.label||K.name}),h.jsxs("small",{children:[" · ",K.status==="up"?S("node-sessions").replace("{n}",String((K.cells||[]).length+(K.unmanaged||[]).length)):K.health&&ng(K.health)||ou(K)]}),h.jsxs("select",{className:"nc-node-filter",value:Re.filter,title:S(`view-${Re.filter}`),onClick:ue=>ue.stopPropagation(),onChange:ue=>N(ee,{filter:ue.target.value}),children:[h.jsx("option",{value:"all",children:S("view-all")}),h.jsx("option",{value:"pinned",children:S("view-pinned")}),h.jsx("option",{value:"active",children:S("view-active")}),h.jsx("option",{value:"off",children:S("view-off")})]}),K.direct&&K.health&&K.health.managed!==!1&&h.jsx("button",{type:"button",className:`nc-power${K.tunnelStatus==="up"?" on":""}`,title:K.tunnelStatus==="up"?S("power-off"):S("power-on"),onClick:ue=>{ue.stopPropagation(),d&&d(K)},children:h.jsx(Je,{name:"power",size:14})})]}),K.status==="up"&&Re.open&&h.jsxs("div",{className:"nc-side-group",children:[ae.map(ue=>ue.type==="cell"?(()=>{const be=ue.value,Le=!!be.tmux,Ke=be.degraded?"warn":be.tmux?"on":"";return h.jsxs("div",{"data-roster-key":ue.key,"data-position":ee,className:`nc-side-card nc-cell${Le?" live":""}${L.has(be.key)?" active":""}`,title:be.active?S("cell-on"):S("cell-off"),draggable:Le,onDragStart:Le?De=>De.dataTransfer.setData("text/nc-session",be.key):void 0,onClick:Le?()=>l&&l(be.key):void 0,onDoubleClick:Le?()=>o&&o({session:be.tmuxSession,node:ee}):void 0,...Ws(ee,ue.key,(De,Qe)=>Z(ee,De,Qe,G)),children:[h.jsx(Hr,{position:ee,itemKey:ue.key,label:be.cell,onMove:(De,Qe)=>Z(ee,De,Qe,G),onStep:De=>P(ee,ue.key,De,G)}),h.jsx("span",{className:`nc-dot ${Ke}`}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:be.cell}),h.jsxs("small",{children:[be.engine,be.key?`·${be.key}`:"",be.active?"":` · ${S("cell-off")}`]})]}),h.jsx("button",{className:`nc-pin${R.includes(ue.key)?" on":""}`,title:S("pin"),onClick:De=>{De.stopPropagation(),$(ue.key)},children:R.includes(ue.key)?"★":"☆"}),(K.capabilities||[]).includes(be.active?"down":"up")&&h.jsx("button",{className:`nc-power${be.active?" on":""}${be.degraded?" warn":""}`,onClick:De=>{De.stopPropagation(),u&&u({...be,route:K.route,availableEngines:K.engines||[]})},title:be.active?S("power-off"):S("power-on"),children:h.jsx(Je,{name:"power",size:14})})]},ue.key)})():(()=>{const be=ue.value;return h.jsxs("div",{"data-roster-key":ue.key,"data-position":ee,className:`nc-side-card${L.has(be.key)?" active":""}`,draggable:!0,onDragStart:Le=>Le.dataTransfer.setData("text/nc-session",be.key),onClick:()=>l&&l(be.key),onDoubleClick:()=>o&&o({session:be.name,node:be.node}),...Ws(ee,ue.key,(Le,Ke)=>Z(ee,Le,Ke,G)),children:[h.jsx(Hr,{position:ee,itemKey:ue.key,label:be.name,onMove:(Le,Ke)=>Z(ee,Le,Ke,G),onStep:Le=>P(ee,ue.key,Le,G)}),h.jsx("span",{className:be.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:be.name}),h.jsx("small",{children:be.preview?be.preview:be.cmd?be.cmd:S("windows").replace("{n}",String(be.windows||0))})]}),be.activity?h.jsx("span",{className:"nc-rel",children:Wa(be.activity)}):null,h.jsx("button",{className:`nc-pin${R.includes(ue.key)?" on":""}`,title:S("pin"),onClick:Le=>{Le.stopPropagation(),$(ue.key)},children:R.includes(ue.key)?"★":"☆"}),h.jsx("button",{className:"nc-menu",title:S("terminate"),onClick:Le=>{Le.stopPropagation(),window.confirm(S("terminate-confirm").replace("{name}",be.name))&&p&&p(be.name,K.route)},children:"⋯"})]},ue.key)})()),ae.length===0&&h.jsx("div",{className:"nc-empty",children:S("no-sessions-short")})]})]},`nodo-${(K.route||[K.name]).join("/")}`)})]}),h.jsx("div",{className:"nc-side-lang",children:Cv.map((K,ee)=>h.jsxs("span",{children:[ee>0&&" · ",h.jsx("button",{className:`nc-lang-btn${k===K?" on":""}`,onClick:()=>x(K),title:K,children:K.toUpperCase()})]},K))}),h.jsx("div",{className:"nc-side-resize",onPointerDown:pe,title:""})]})}function hC({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:[" · ",S("node-sessions").replace("{n}",String(t))]}),h.jsxs("select",{className:"nc-node-filter",value:n.filter,title:S(`view-${n.filter}`),onClick:l=>l.stopPropagation(),onChange:l=>o(l.target.value),children:[h.jsx("option",{value:"all",children:S("view-all")}),h.jsx("option",{value:"pinned",children:S("view-pinned")}),h.jsx("option",{value:"active",children:S("view-active")}),h.jsx("option",{value:"off",children:S("view-off")})]})]})}const Yh=9,Ua=.2,dC=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,__=/^[a-f0-9]{16,64}$/,Sh=e=>dC.test(e)&&new Set(e.split("/")).size===e.split("/").length;function Fn(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!Sh(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"&&__.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"&&Sh(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function mi(e){const t=Fn(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const y_=9,S_=24,no=11,fC=e=>{const t=Number(e);return t>=y_&&t<=S_?t:no};function Wr(){return{columns:[]}}function Gi(e){return e.columns.flatMap(t=>t.tiles.map(n=>mi(n)))}function pC(e){const t=[],n=Math.max(0,...e.columns.map(s=>s.tiles.length));for(let s=0;s<n;s+=1)for(const o of e.columns)o.tiles[s]&&t.push(mi(o.tiles[s]));return t}const Gr=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))});function Xh(e,t,n,s){const o=Fn(t);if(!o||Gi(e).includes(mi(o))||Gi(e).length>=Yh)return e;const l=Gr(e),u={session:o.session,height:1,fontSize:no,...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 w_(e,t){const n=mi(t);if(!n||Gi(e).includes(n)||Gi(e).length>=Yh)return e;const s=Gi(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let y=0;for(let w=1;w<e.columns.length;w+=1)e.columns[w].tiles.length<e.columns[y].tiles.length&&(y=w);return Xh(e,t,{col:y,row:e.columns[y].tiles.length})}const l=[...pC(e),n],u=new Map(e.columns.flatMap(y=>y.tiles.map(w=>[mi(w),w]))),d=Fn(t),p=e.columns.length?e.columns.reduce((y,w)=>y+(Number(w.width)||1),0)/e.columns.length:1,m=Array.from({length:o},(y,w)=>{var _;return{width:((_=e.columns[w])==null?void 0:_.width)||p,tiles:[]}});return l.forEach((y,w)=>{const _=Fn(y);if(!_)return;const v=u.get(y)||(y===n?d:{})||{},b={session:_.session,height:v.height||1,fontSize:v.fontSize||no};_.node&&(b.node=_.node),v.ownerId&&(b.ownerId=v.ownerId),v.unavailable===!0&&(b.unavailable=!0),m[w%o].tiles.push(b)}),{columns:m.filter(y=>y.tiles.length)}}function Ka(e,t){const n=mi(t),s=Gr(e);for(const o of s.columns)o.tiles=o.tiles.filter(l=>mi(l)!==n);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function mC(e,t,n){const s=mi(t);if(!Gi(e).includes(s))return e;const o=e.columns.flatMap(l=>l.tiles).find(l=>mi(l)===s);return Xh(Ka(e,s),s,n,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function gC(e,t){if(!(t instanceof Map)||t.size===0)return e;let n=!1;const s=Gr(e);for(const o of s.columns)for(const l of o.tiles){const u=t.get(mi(l));if(!u)continue;const d=Fn(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?ar(s):e}function vC(e,t,n){const s=Gr(e);return s.columns[t]&&(s.columns[t].width=Math.max(Ua,Number(n)||1)),s}function _C(e,t,n,s){const o=Gr(e),l=o.columns[t]&&o.columns[t].tiles[n];return l&&(l.height=Math.max(Ua,Number(s)||1)),o}function yC(e,t,n,s){if(!(e.columns[t]&&e.columns[t].tiles[n]))return e;const l=Gr(e),u=l.columns[t].tiles[n],d=Number(u.fontSize)||no;return u.fontSize=Math.max(y_,Math.min(S_,d+(Number(s)||0))),l}function SC(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 rg(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function ar(e){if(!e||!Array.isArray(e.columns))return Wr();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"&&Sh(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&__.test(o.ownerId)).map(o=>{const l={session:o.session,height:Math.max(Ua,Number(o.height)||1),fontSize:fC(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(mi(o))&&n.add(mi(o))&&n.size<=Yh);return{columns:t.filter(s=>s.tiles.length>0)}}function wC(e,t,n){return!e&&t?n+1:n}function bC({session:e,node:t,token:n,readonly:s=!1,focused:o,onFocus:l,onClose:u,onOpenSingle:d,alive:p=!0,available:m=!0,fontSize:y=no,onZoom:w,decks:_=[],currentDeck:v,onSendToDeck:b}){const k=M.useRef(()=>{}),x=M.useRef(()=>!1),R=M.useRef(()=>{}),j=M.useRef(!1),[A,B]=M.useState(!1),[ie,z]=M.useState(!1),[$,re]=M.useState(!1),[U,X]=M.useState(null),[q,D]=M.useState(0),E=M.useRef(p),L=t?`${t}:${e}`:e,Y=_.filter(N=>N.id!==v&&N.available!==!1);return M.useEffect(()=>{const N=E.current;!N&&p&&D(H=>wC(N,p,H)),E.current=p},[p]),h.jsxs("div",{className:`nc-tile${o?" focused":""}`,onMouseDown:()=>l&&l(L),children:[h.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:N=>{N.dataTransfer.setData("text/nc-session",L),N.dataTransfer.effectAllowed="move"},children:[h.jsxs("button",{className:"nc-tile-name",onClick:()=>l&&l(L),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:S("zoom-out"),children:h.jsx(Je,{name:"zoomOut",size:14})}),w&&h.jsx("button",{onClick:()=>w(1),title:S("zoom-in"),children:h.jsx(Je,{name:"zoomIn",size:14})}),b&&Y.length>0&&h.jsxs("select",{className:"nc-tile-deck",title:S("send-to-deck"),value:"",onMouseDown:N=>N.stopPropagation(),onChange:N=>{const H=N.target.value;H&&b(L,H),N.target.value=""},children:[h.jsx("option",{value:"",children:S("send-to-deck")}),Y.map(N=>h.jsxs("option",{value:N.id,children:[N.ownerLabel," · ",N.name]},N.id))]}),h.jsx("button",{onClick:()=>z(N=>!N),title:"composer",children:"⌨"}),h.jsx("button",{onClick:()=>re(N=>!N),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(L),title:"chiudi",children:"✕"})]})]}),h.jsxs("div",{className:"nc-tile-body",children:[m?h.jsx(m_,{session:e,node:t,token:n,readonly:s,takeSize:!1,focused:o,sendRef:k,composerRef:x,actionRef:R,ctrlRef:j,setCtrlArmed:B,onFiles:X,fontSize:y},`${L}:${q}`):h.jsx("div",{className:"nc-tile-unavailable",children:S("deck-owner-unavailable")}),m&&$&&h.jsx("div",{className:"nc-tile-files",onMouseDown:N=>N.stopPropagation(),children:h.jsx(g_,{session:e,node:t,token:n,filesEvent:U,onClose:()=>re(!1)})})]}),m&&ie&&h.jsx("div",{className:"nc-tile-composer",onMouseDown:N=>N.stopPropagation(),children:h.jsx(v_,{submitText:N=>x.current(N),token:n,session:e,node:t})})]})}const sg=.2,og=.28,b_=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),au=e=>b_(e,"text/nc-session"),ag=e=>{var t;return b_(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function CC(e,t,n){const s=(e-n.left)/(n.width||1),o=(t-n.top)/(n.height||1);return s<og?"left":s>1-og?"right":o<.5?"top":"bottom"}function xC({layout:e,onLayoutChange:t,token:n,readonly:s=!1,sessionsAlive:o,focusSession:l,onFocus:u,onOpenSingle:d,decks:p=[],currentDeck:m,onSendToDeck:y}){_i();const[w,_]=M.useState(null),v=M.useRef(null),b=M.useRef([]),k=M.useRef(null);function x(U,X){const q=()=>{window.removeEventListener("pointermove",U),window.removeEventListener("pointerup",q),window.removeEventListener("pointercancel",q),window.removeEventListener("blur",q),k.current=null};window.addEventListener("pointermove",U),window.addEventListener("pointerup",q),window.addEventListener("pointercancel",q),window.addEventListener("blur",q),k.current=q}M.useEffect(()=>()=>{k.current&&k.current()},[]),M.useEffect(()=>{const U=()=>_(null);return window.addEventListener("dragend",U),window.addEventListener("drop",U),()=>{window.removeEventListener("dragend",U),window.removeEventListener("drop",U)}},[]);const R=e.columns.length,j=U=>w&&w.col===U&&w.row===void 0,A=!!w&&w.col===R,B=(U,X)=>w&&w.col===U&&w.row===X&&w.quadrant?` drop-${w.quadrant}`:"";function ie(U){if(U.preventDefault(),ag(U.dataTransfer)){_(null);return}const X=U.dataTransfer.getData("text/nc-session"),q=w;if(_(null),!X||!q)return;let D;if(q.quadrant){if(D=SC(e,q.col,q.row,q.quadrant),!D)return}else D={col:q.col};t(Gi(e).includes(X)?mC(e,X,D):Xh(e,X,D))}function z(U,X){U.preventDefault(),U.stopPropagation();const q=U.clientX,D=e.columns[X].width,E=v.current&&v.current.clientWidth||1,L=e.columns[X+1];x(N=>{let H=Math.max(sg,D+(N.clientX-q)/E);if(L){const I=rg(H/(H+L.width));H=I/(1-I)*L.width}t(vC(e,X,H))})}function $(U,X,q){U.preventDefault(),U.stopPropagation();const D=U.clientY,E=e.columns[X].tiles[q].height,L=b.current[X],Y=L&&L.clientHeight||1,N=e.columns[X].tiles[q+1];x(I=>{let W=Math.max(sg,E+(I.clientY-D)/Y);if(N){const Z=rg(W/(W+N.height));W=Z/(1-Z)*N.height}t(_C(e,X,q,W))})}function re(U){t(Ka(e,U))}return h.jsxs("div",{className:"nc-grid",ref:v,onDragOver:U=>{if(ag(U.dataTransfer)){U.preventDefault(),_(null);return}au(U.dataTransfer)&&(U.preventDefault(),w&&w.col===R||_({col:R}))},onDrop:ie,onDragLeave:U=>{const X=U.relatedTarget;(!X||!(v.current&&v.current.contains(X)))&&_(null)},children:[e.columns.flatMap((U,X)=>{const q=[];return q.push(h.jsx("div",{className:`nc-col${j(X)?" drop-newcol":""}`,ref:D=>{b.current[X]=D},style:{flexGrow:U.width,flexBasis:0},onDragOver:D=>{au(D.dataTransfer)&&(D.preventDefault(),D.stopPropagation(),w&&w.col===X&&w.row===void 0||_({col:X}))},children:U.tiles.flatMap((D,E)=>{const L=[],Y=mi(D);return L.push(h.jsx("div",{className:`nc-tile-slot${B(X,E)}`,style:{flexGrow:D.height,flexBasis:0},onDragOver:N=>{if(!au(N.dataTransfer))return;N.preventDefault(),N.stopPropagation();const H=CC(N.clientX,N.clientY,N.currentTarget.getBoundingClientRect());w&&w.col===X&&w.row===E&&w.quadrant===H||_({col:X,row:E,quadrant:H})},children:h.jsx(bC,{session:D.session,node:D.node,token:n,readonly:s,focused:l===Y,onFocus:u,onClose:re,onOpenSingle:d,available:D.unavailable!==!0,alive:D.unavailable!==!0&&(!o||o.has(Y)),fontSize:D.fontSize,onZoom:N=>t(yC(e,X,E,N)),decks:p,currentDeck:m,onSendToDeck:y})},Y)),E<U.tiles.length-1&&L.push(h.jsx("div",{className:"nc-divider-h",onPointerDown:N=>$(N,X,E)},`h${E}`)),L})},`c${X}`)),X<R-1&&q.push(h.jsx("div",{className:"nc-divider-v",onPointerDown:D=>z(D,X)},`v${X}`)),q}),A&&h.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),R===0&&h.jsx("div",{className:"nc-grid-empty",children:S("grid-empty")})]})}const qa="local",Oi=/^[a-f0-9]{16,64}$/;function Ur(e,t){return`${e&&Oi.test(e)?e:qa}:${t}`}function C_(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&&!Oi.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 Gh(e){return{columns:ar(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))}}function kC(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&Oi.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(Ja(n.route),n.instanceId);return t}function EC(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&Oi.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(n.instanceId,[...n.route]);return t}function wh(e,t,n=[]){const s=Gh(e),o=kC(n);for(const l of s.columns)for(const u of l.tiles)u.ownerId||(!u.node&&Oi.test(String(t||""))?u.ownerId=t:u.node&&o.has(u.node)&&(u.ownerId=o.get(u.node)));return s}function bh(e,t,n=[]){const s=Gh(e),o=new Map;for(const l of n)l&&Oi.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 lg(e,t,n=[]){const s=Gh(e),o=EC(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 x_(e,t,n=[]){const s=Fn(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...Oi.test(String(t||""))?{ownerId:t}:{}};const o=n.find(l=>Ja(l&&l.route)===s.node);return{...s,...o&&Oi.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const NC=/^[a-z0-9-]{1,32}$/,gi="main",k_="nc_decks",RC=24;function cg(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function Vr(e){return typeof e=="string"&&NC.test(e)}function PC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let n;try{n=decodeURIComponent(t[1])}catch{n=t[1]}return Vr(n)?n:gi}return gi}function DC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:Ur(null,gi),ownerId:null,name:gi}}if(Oi.test(s)&&Vr(o))return{id:Ur(s,o),ownerId:s,name:o}}const n=PC(e);return{id:Ur(null,n),ownerId:null,name:n}}function lu(e,t){const n=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:C_(e)||{ownerId:null,name:e},s=Vr(n.name)?n.name:gi,o=n.ownerId?`/deck/${encodeURIComponent(n.ownerId)}/${encodeURIComponent(s)}`:s===gi?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function E_(e){return e===gi?"nc_grid_v1":`nc_grid_v1__${e}`}function N_(e){const t=[gi];if(Array.isArray(e)){for(const n of e)if(Vr(n)&&n!==gi&&!t.includes(n)&&t.push(n),t.length>=RC)break}return t}function Za(){return typeof localStorage<"u"?localStorage:null}function MC(){const e=Za();if(!e)return[gi];try{return N_(JSON.parse(e.getItem(k_)||"null"))}catch{return[gi]}}function LC(e){const t=Za();if(t)try{t.setItem(k_,JSON.stringify(N_(e)))}catch{}}function Ch(e){const t=Za();if(!t)return null;try{return JSON.parse(t.getItem(E_(e))||"null")}catch{return null}}function TC(e,t){const n=Za();if(n)try{n.setItem(E_(e),JSON.stringify(t))}catch{}}function jC({decks:e=[],currentDeck:t="local:main",onCreate:n,onRename:s,onDelete:o,onOpenWindow:l,onNavigate:u,saveState:d="idle",error:p="",sidebarVisible:m,onToggleSidebar:y}){_i();const[w,_]=M.useState(null),[v,b]=M.useState(""),[k,x]=M.useState(!1),[R,j]=M.useState(""),[A,B]=M.useState(""),ie=cg(v),z=Vr(ie),$=[];for(const q of e){const D=q.local?"local":q.ownerId;let E=$.find(L=>L.key===D);E||(E={key:D,label:q.ownerLabel||(q.local?"Local":D),local:!!q.local,decks:[]},$.push(E)),E.decks.push(q)}const re=async()=>{if(z){x(!0),j("");try{n&&await n(ie,w),b(""),_(null)}catch(q){j(String(q.message||q))}x(!1)}},U=q=>{B(""),l&&l(q.id)||B(q.id)},X=async q=>{if(!(q.id===t||!u||k||q.available===!1)){x(!0),j("");try{await u(q.id)}catch(D){j(String((D==null?void 0:D.message)||D))}x(!1)}};return h.jsxs("div",{className:"nc-deckbar",children:[y&&h.jsx("button",{className:"nc-deck-sidebar-toggle",title:S("toggle-sidebar"),onClick:y,children:m?"◀":"☰"}),h.jsx("span",{className:"nc-deckbar-label",children:S("decks")}),h.jsx("div",{className:"nc-deck-chips",children:$.map(q=>h.jsxs("span",{className:"nc-deck-owner-group",children:[h.jsx("span",{className:"nc-deck-owner",children:q.local?"Local":q.label}),q.decks.map(D=>h.jsxs("span",{className:`nc-deck-chip${D.id===t?" current":""}${D.available===!1?" offline":""}`,children:[h.jsxs("button",{className:"nc-deck-open",title:D.available===!1?`${D.ownerLabel} offline`:D.id===t?S("deck-current"):`${D.ownerLabel} · ${D.name}`,disabled:k||D.available===!1,onClick:()=>X(D),children:[D.name,D.id===t?" •":""]}),h.jsx("button",{className:"nc-deck-mini",disabled:D.available===!1,title:S("detach-deck"),onClick:()=>U(D),children:"↗"}),D.name!==gi&&h.jsxs(h.Fragment,{children:[h.jsx("button",{className:"nc-deck-mini",disabled:D.available===!1,title:S("rename-deck"),onClick:()=>{const E=(typeof window<"u"?window.prompt(S("rename-deck"),D.name):"")||"",L=cg(E);Vr(L)&&L!==D.name&&s&&s(D.id,L).catch(Y=>j(String(Y.message||Y)))},children:"✎"}),h.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:D.available===!1,title:S("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(S("delete-deck-confirm").replace("{name}",`${D.ownerLabel} · ${D.name}`)))&&o&&o(D.id).catch(E=>j(String(E.message||E)))},children:"✕"})]})]},D.id)),w===q.key?h.jsxs("span",{className:"nc-deck-add",children:[h.jsx("input",{autoFocus:!0,className:z||!v?"":"invalid",placeholder:S("deck-name"),value:v,onChange:D=>b(D.target.value),onKeyDown:D=>{D.key==="Enter"&&re(),D.key==="Escape"&&(b(""),_(null))}}),v&&z&&ie!==v&&h.jsxs("span",{className:"nc-deck-slug",children:["→ ",ie]}),h.jsx("button",{className:"nc-deck-ok",disabled:!z||k,onClick:re,children:S("create")}),h.jsx("button",{className:"nc-deck-cancel",onClick:()=>{b(""),_(null)},children:S("cancel")})]}):h.jsxs("button",{className:"nc-deck-newbtn",disabled:k||q.decks.every(D=>D.available===!1),title:`${S("new-deck")} · ${q.label}`,onClick:()=>{b(""),_(q.key)},children:["+ ",S("new")]})]},q.key))}),h.jsx("span",{className:`nc-deck-state ${d}`,title:S("deck-autosave"),children:S(d==="saving"?"saving":d==="saved"?"saved":"deck-autosave")}),(R||p)&&h.jsx("span",{className:"nc-deck-error",children:R||p}),A&&h.jsx("button",{className:"nc-deck-fallback",onClick:()=>l&&l(A),children:S("popup-blocked")})]})}var Fr={},cu,ug;function BC(){return ug||(ug=1,cu=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),cu}var uu={},Bn={},hg;function dr(){if(hg)return Bn;hg=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 Bn.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},Bn.getSymbolTotalCodewords=function(s){return t[s]},Bn.getBCHDigit=function(n){let s=0;for(;n!==0;)s++,n>>>=1;return s},Bn.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},Bn.isKanjiModeEnabled=function(){return typeof e<"u"},Bn.toSJIS=function(s){return e(s)},Bn}var hu={},dg;function Qh(){return dg||(dg=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}}})(hu)),hu}var du,fg;function AC(){if(fg)return du;fg=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++}},du=e,du}var fu,pg;function IC(){if(pg)return fu;pg=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]},fu=e,fu}var pu={},mg;function OC(){return mg||(mg=1,(function(e){const t=dr().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}})(pu)),pu}var mu={},gg;function zC(){if(gg)return mu;gg=1;const e=dr().getSymbolSize,t=7;return mu.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},mu}var gu={},vg;function FC(){return vg||(vg=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,y=null;for(let w=0;w<l;w++){d=p=0,m=y=null;for(let _=0;_<l;_++){let v=o.get(w,_);v===m?d++:(d>=5&&(u+=t.N1+(d-5)),m=v,d=1),v=o.get(_,w),v===y?p++:(p>=5&&(u+=t.N1+(p-5)),y=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 y=0;y<l;y++)d=d<<1&2047|o.get(m,y),y>=10&&(d===1488||d===93)&&u++,p=p<<1&2047|o.get(y,m),y>=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 y=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(m,o),y<p&&(p=y,d=m)}return d}})(gu)),gu}var Ca={},_g;function R_(){if(_g)return Ca;_g=1;const e=Qh(),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 Ca.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}},Ca.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}},Ca}var vu={},Fs={},yg;function HC(){if(yg)return Fs;yg=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]})(),Fs.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},Fs.exp=function(s){return e[s]},Fs.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},Fs}var Sg;function $C(){return Sg||(Sg=1,(function(e){const t=HC();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}})(vu)),vu}var _u,wg;function WC(){if(wg)return _u;wg=1;const e=$C();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},_u=t,_u}var yu={},Su={},wu={},bg;function P_(){return bg||(bg=1,wu.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),wu}var qi={},Cg;function D_(){if(Cg)return qi;Cg=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
|
-
]))+`;qi.KANJI=new RegExp(n,"g"),qi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),qi.BYTE=new RegExp(s,"g"),qi.NUMERIC=new RegExp(e,"g"),qi.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+n+"$"),l=new RegExp("^"+e+"$"),u=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return qi.testKanji=function(p){return o.test(p)},qi.testNumeric=function(p){return l.test(p)},qi.testAlphanumeric=function(p){return u.test(p)},qi}var xg;function fr(){return xg||(xg=1,(function(e){const t=P_(),n=D_();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}}})(Su)),Su}var kg;function UC(){return kg||(kg=1,(function(e){const t=dr(),n=R_(),s=Qh(),o=fr(),l=P_(),u=7973,d=t.getBCHDigit(u);function p(_,v,b){for(let k=1;k<=40;k++)if(v<=e.getCapacity(k,b,_))return k}function m(_,v){return o.getCharCountIndicator(_,v)+4}function y(_,v){let b=0;return _.forEach(function(k){const x=m(k.mode,v);b+=x+k.getBitsLength()}),b}function w(_,v){for(let b=1;b<=40;b++)if(y(_,b)<=e.getCapacity(b,v,o.MIXED))return b}e.from=function(v,b){return l.isValid(v)?parseInt(v,10):b},e.getCapacity=function(v,b,k){if(!l.isValid(v))throw new Error("Invalid QR Code version");typeof k>"u"&&(k=o.BYTE);const x=t.getSymbolTotalCodewords(v),R=n.getTotalCodewordsCount(v,b),j=(x-R)*8;if(k===o.MIXED)return j;const A=j-m(k,v);switch(k){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,b){let k;const x=s.from(b,s.M);if(Array.isArray(v)){if(v.length>1)return w(v,x);if(v.length===0)return 1;k=v[0]}else k=v;return p(k.mode,k.getLength(),x)},e.getEncodedBits=function(v){if(!l.isValid(v)||v<7)throw new Error("Invalid QR Code version");let b=v<<12;for(;t.getBCHDigit(b)-d>=0;)b^=u<<t.getBCHDigit(b)-d;return v<<12|b}})(yu)),yu}var bu={},Eg;function KC(){if(Eg)return bu;Eg=1;const e=dr(),t=1335,n=21522,s=e.getBCHDigit(t);return bu.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},bu}var Cu={},xu,Ng;function qC(){if(Ng)return xu;Ng=1;const e=fr();function t(n){this.mode=e.NUMERIC,this.data=n.toString()}return t.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){let o,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))},xu=t,xu}var ku,Rg;function VC(){if(Rg)return ku;Rg=1;const e=fr(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function n(s){this.mode=e.ALPHANUMERIC,this.data=s}return n.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(o){let 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)},ku=n,ku}var Eu,Pg;function YC(){if(Pg)return Eu;Pg=1;const e=fr();function t(n){this.mode=e.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return t.getBitsLength=function(s){return s*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(n){for(let s=0,o=this.data.length;s<o;s++)n.put(this.data[s],8)},Eu=t,Eu}var Nu,Dg;function XC(){if(Dg)return Nu;Dg=1;const e=fr(),t=dr();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)}},Nu=n,Nu}var Ru={exports:{}},Mg;function GC(){return Mg||(Mg=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,y,w,_,v,b,k,x;!d.empty();){p=d.pop(),m=p.value,w=p.cost,_=n[m]||{};for(y in _)_.hasOwnProperty(y)&&(v=_[y],b=w+v,k=u[y],x=typeof u[y]>"u",(x||k>b)&&(u[y]=b,d.push(y,b),l[y]=m))}if(typeof o<"u"&&typeof u[o]>"u"){var R=["Could not find a path from ",s," to ",o,"."].join("");throw new Error(R)}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})(Ru)),Ru.exports}var Lg;function QC(){return Lg||(Lg=1,(function(e){const t=fr(),n=qC(),s=VC(),o=YC(),l=XC(),u=D_(),d=dr(),p=GC();function m(R){return unescape(encodeURIComponent(R)).length}function y(R,j,A){const B=[];let ie;for(;(ie=R.exec(A))!==null;)B.push({data:ie[0],index:ie.index,mode:j,length:ie[0].length});return B}function w(R){const j=y(u.NUMERIC,t.NUMERIC,R),A=y(u.ALPHANUMERIC,t.ALPHANUMERIC,R);let B,ie;return d.isKanjiModeEnabled()?(B=y(u.BYTE,t.BYTE,R),ie=y(u.KANJI,t.KANJI,R)):(B=y(u.BYTE_KANJI,t.BYTE,R),ie=[]),j.concat(A,B,ie).sort(function($,re){return $.index-re.index}).map(function($){return{data:$.data,mode:$.mode,length:$.length}})}function _(R,j){switch(j){case t.NUMERIC:return n.getBitsLength(R);case t.ALPHANUMERIC:return s.getBitsLength(R);case t.KANJI:return l.getBitsLength(R);case t.BYTE:return o.getBitsLength(R)}}function v(R){return R.reduce(function(j,A){const B=j.length-1>=0?j[j.length-1]:null;return B&&B.mode===A.mode?(j[j.length-1].data+=A.data,j):(j.push(A),j)},[])}function b(R){const j=[];for(let A=0;A<R.length;A++){const B=R[A];switch(B.mode){case t.NUMERIC:j.push([B,{data:B.data,mode:t.ALPHANUMERIC,length:B.length},{data:B.data,mode:t.BYTE,length:B.length}]);break;case t.ALPHANUMERIC:j.push([B,{data:B.data,mode:t.BYTE,length:B.length}]);break;case t.KANJI:j.push([B,{data:B.data,mode:t.BYTE,length:m(B.data)}]);break;case t.BYTE:j.push([{data:B.data,mode:t.BYTE,length:m(B.data)}])}}return j}function k(R,j){const A={},B={start:{}};let ie=["start"];for(let z=0;z<R.length;z++){const $=R[z],re=[];for(let U=0;U<$.length;U++){const X=$[U],q=""+z+U;re.push(q),A[q]={node:X,lastCount:0},B[q]={};for(let D=0;D<ie.length;D++){const E=ie[D];A[E]&&A[E].node.mode===X.mode?(B[E][q]=_(A[E].lastCount+X.length,X.mode)-_(A[E].lastCount,X.mode),A[E].lastCount+=X.length):(A[E]&&(A[E].lastCount=X.length),B[E][q]=_(X.length,X.mode)+4+t.getCharCountIndicator(X.mode,j))}}ie=re}for(let z=0;z<ie.length;z++)B[ie[z]].end=0;return{map:B,table:A}}function x(R,j){let A;const B=t.getBestModeForData(R);if(A=t.from(j,B),A!==t.BYTE&&A.bit<B.bit)throw new Error('"'+R+'" 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(R);case t.ALPHANUMERIC:return new s(R);case t.KANJI:return new l(R);case t.BYTE:return new o(R)}}e.fromArray=function(j){return j.reduce(function(A,B){return typeof B=="string"?A.push(x(B,null)):B.data&&A.push(x(B.data,B.mode)),A},[])},e.fromString=function(j,A){const B=w(j,d.isKanjiModeEnabled()),ie=b(B),z=k(ie,A),$=p.find_path(z.map,"start","end"),re=[];for(let U=1;U<$.length-1;U++)re.push(z.table[$[U]].node);return e.fromArray(v(re))},e.rawSplit=function(j){return e.fromArray(w(j,d.isKanjiModeEnabled()))}})(Cu)),Cu}var Tg;function JC(){if(Tg)return uu;Tg=1;const e=dr(),t=Qh(),n=AC(),s=IC(),o=OC(),l=zC(),u=FC(),d=R_(),p=WC(),m=UC(),y=KC(),w=fr(),_=QC();function v(z,$){const re=z.size,U=l.getPositions($);for(let X=0;X<U.length;X++){const q=U[X][0],D=U[X][1];for(let E=-1;E<=7;E++)if(!(q+E<=-1||re<=q+E))for(let L=-1;L<=7;L++)D+L<=-1||re<=D+L||(E>=0&&E<=6&&(L===0||L===6)||L>=0&&L<=6&&(E===0||E===6)||E>=2&&E<=4&&L>=2&&L<=4?z.set(q+E,D+L,!0,!0):z.set(q+E,D+L,!1,!0))}}function b(z){const $=z.size;for(let re=8;re<$-8;re++){const U=re%2===0;z.set(re,6,U,!0),z.set(6,re,U,!0)}}function k(z,$){const re=o.getPositions($);for(let U=0;U<re.length;U++){const X=re[U][0],q=re[U][1];for(let D=-2;D<=2;D++)for(let E=-2;E<=2;E++)D===-2||D===2||E===-2||E===2||D===0&&E===0?z.set(X+D,q+E,!0,!0):z.set(X+D,q+E,!1,!0)}}function x(z,$){const re=z.size,U=m.getEncodedBits($);let X,q,D;for(let E=0;E<18;E++)X=Math.floor(E/3),q=E%3+re-8-3,D=(U>>E&1)===1,z.set(X,q,D,!0),z.set(q,X,D,!0)}function R(z,$,re){const U=z.size,X=y.getEncodedBits($,re);let q,D;for(q=0;q<15;q++)D=(X>>q&1)===1,q<6?z.set(q,8,D,!0):q<8?z.set(q+1,8,D,!0):z.set(U-15+q,8,D,!0),q<8?z.set(8,U-q-1,D,!0):q<9?z.set(8,15-q-1+1,D,!0):z.set(8,15-q-1,D,!0);z.set(U-8,8,1,!0)}function j(z,$){const re=z.size;let U=-1,X=re-1,q=7,D=0;for(let E=re-1;E>0;E-=2)for(E===6&&E--;;){for(let L=0;L<2;L++)if(!z.isReserved(X,E-L)){let Y=!1;D<$.length&&(Y=($[D]>>>q&1)===1),z.set(X,E-L,Y),q--,q===-1&&(D++,q=7)}if(X+=U,X<0||re<=X){X-=U,U=-U;break}}}function A(z,$,re){const U=new n;re.forEach(function(L){U.put(L.mode.bit,4),U.put(L.getLength(),w.getCharCountIndicator(L.mode,z)),L.write(U)});const X=e.getSymbolTotalCodewords(z),q=d.getTotalCodewordsCount(z,$),D=(X-q)*8;for(U.getLengthInBits()+4<=D&&U.put(0,4);U.getLengthInBits()%8!==0;)U.putBit(0);const E=(D-U.getLengthInBits())/8;for(let L=0;L<E;L++)U.put(L%2?17:236,8);return B(U,z,$)}function B(z,$,re){const U=e.getSymbolTotalCodewords($),X=d.getTotalCodewordsCount($,re),q=U-X,D=d.getBlocksCount($,re),E=U%D,L=D-E,Y=Math.floor(U/D),N=Math.floor(q/D),H=N+1,I=Y-N,W=new p(I);let Z=0;const P=new Array(D),Q=new Array(D);let se=0;const J=new Uint8Array(z.buffer);for(let K=0;K<D;K++){const ee=K<L?N:H;P[K]=J.slice(Z,Z+ee),Q[K]=W.encode(P[K]),Z+=ee,se=Math.max(se,ee)}const le=new Uint8Array(U);let de=0,pe,ye;for(pe=0;pe<se;pe++)for(ye=0;ye<D;ye++)pe<P[ye].length&&(le[de++]=P[ye][pe]);for(pe=0;pe<I;pe++)for(ye=0;ye<D;ye++)le[de++]=Q[ye][pe];return le}function ie(z,$,re,U){let X;if(Array.isArray(z))X=_.fromArray(z);else if(typeof z=="string"){let Y=$;if(!Y){const N=_.rawSplit(z);Y=m.getBestVersionForData(N,re)}X=_.fromString(z,Y||40)}else throw new Error("Invalid data");const q=m.getBestVersionForData(X,re);if(!q)throw new Error("The amount of data is too big to be stored in a QR Code");if(!$)$=q;else if($<q)throw new Error(`
|
|
85
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
86
|
-
Minimum version required to store current data is: `+q+`.
|
|
87
|
-
`);const D=A($,re,X),E=e.getSymbolSize($),L=new s(E);return v(L,$),b(L),k(L,$),R(L,re,0),$>=7&&x(L,$),j(L,D),isNaN(U)&&(U=u.getBestMask(L,R.bind(null,L,re))),u.applyMask(U,L),R(L,re,U),{modules:L,version:$,errorCorrectionLevel:re,maskPattern:U,segments:X}}return uu.create=function($,re){if(typeof $>"u"||$==="")throw new Error("No input text");let U=t.M,X,q;return typeof re<"u"&&(U=t.from(re.errorCorrectionLevel,t.M),X=m.from(re.version),q=u.from(re.maskPattern),re.toSJISFunc&&e.setToSJISFunction(re.toSJISFunc)),ie($,X,U,q)},uu}var Pu={},Du={},jg;function M_(){return jg||(jg=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),y=l.margin*p,w=[l.color.light,l.color.dark];for(let _=0;_<m;_++)for(let v=0;v<m;v++){let b=(_*m+v)*4,k=l.color.light;if(_>=y&&v>=y&&_<m-y&&v<m-y){const x=Math.floor((_-y)/p),R=Math.floor((v-y)/p);k=w[d[x*u+R]?1:0]}s[b++]=k.r,s[b++]=k.g,s[b++]=k.b,s[b]=k.a}}})(Du)),Du}var Bg;function ZC(){return Bg||(Bg=1,(function(e){const t=M_();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 y=t.getImageWidth(l.modules.size,p),w=m.getContext("2d"),_=w.createImageData(y,y);return t.qrToImageData(_.data,l,p),n(w,m,y),w.putImageData(_,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),y=p.type||"image/png",w=p.rendererOpts||{};return m.toDataURL(y,w.quality)}})(Pu)),Pu}var Mu={},Ag;function ex(){if(Ag)return Mu;Ag=1;const e=M_();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,y=0;for(let w=0;w<o.length;w++){const _=Math.floor(w%l),v=Math.floor(w/l);!_&&!m&&(m=!0),o[w]?(y++,w>0&&_>0&&o[w-1]||(d+=m?n("M",_+u,.5+v+u):n("m",p,0),p=0,m=!1),_+1<l&&o[w+1]||(d+=n("h",y),y=0)):p++}return d}return Mu.render=function(l,u,d){const p=e.getOptions(u),m=l.modules.size,y=l.modules.data,w=m+p.margin*2,_=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(y,m,p.margin)+'"/>',b='viewBox="0 0 '+w+" "+w+'"',x='<svg xmlns="http://www.w3.org/2000/svg" '+(p.width?'width="'+p.width+'" height="'+p.width+'" ':"")+b+' shape-rendering="crispEdges">'+_+v+`</svg>
|
|
88
|
-
`;return typeof d=="function"&&d(null,x),x},Mu}var Ig;function tx(){if(Ig)return Fr;Ig=1;const e=BC(),t=JC(),n=ZC(),s=ex();function o(l,u,d,p,m){const y=[].slice.call(arguments,1),w=y.length,_=typeof y[w-1]=="function";if(!_&&!e())throw new Error("Callback required as last argument");if(_){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,b){try{const k=t.create(d,p);v(l(k,u,p))}catch(k){b(k)}})}try{const v=t.create(d,p);m(null,l(v,u,p))}catch(v){m(v)}}return Fr.create=t.create,Fr.toCanvas=o.bind(null,n.render),Fr.toDataURL=o.bind(null,n.renderToDataURL),Fr.toString=o.bind(null,function(l,u,d){return s.render(l,d)}),Fr}var ix=tx();const nx=Ph(ix),L_=/^[a-z0-9-]{1,32}$/,rx=/^[A-Za-z0-9._-]{1,32}$/,sx=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,ox=320;function ax(e){return typeof e=="string"&&L_.test(e)}const lx=64;function xh(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=lx&&!/[\x00-\x1f\x7f]/.test(t)}function Kr(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function T_(e){if(typeof e!="string"||!e||e.length>ox||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:rx.test(e.slice(0,t))&&sx.test(e.slice(t+1))}function Og(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 zg({name:e,ssh:t,sshPort:n,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,l=typeof t=="string"?t.trim():t;if(!ax(o))return{ok:!1,error:"err-node-name"};if(!T_(l))return{ok:!1,error:"err-ssh"};const u=Og(n);if(u===void 0)return{ok:!1,error:"err-ssh-port"};const d=Og(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 cx(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 Fg(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?cx(e.since,t):null}}const ux=new Set(["v","instanceId","port","label","invite"]),hx=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function dx(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 fx(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(dx(t))}catch{return{ok:!1}}if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1};const s=n.v===1?ux:n.v===2?hx: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"||!L_.test(n.name))return{ok:!1};l.name=n.name}if(n.ssh!==void 0){if(!T_(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 px(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?Kr(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}function Hg(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function mx(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const n=fx(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 gx(e,t,n=new Set,s=!1){if(!t||!t.ok)return e;const o=px(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 $g(e,t,n=new Set,s=!1){const o=String(t||"").trim(),l=mx(o);let u={...e,pairingUrl:o};return(l.kind==="complete"||l.kind==="partial")&&(u={...gx(u,l.decoded,n,s),pairingUrl:o}),{classification:l,form:u}}function vx(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 _x(){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 yx=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function Sx(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 wx="modulepreload",bx=function(e){return"/"+e},Wg={},Cx=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let u=function(m){return Promise.all(m.map(y=>Promise.resolve(y).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=bx(m),m in Wg)return;Wg[m]=!0;const y=m.endsWith(".css"),w=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${w}`))return;const _=document.createElement("link");if(_.rel=y?"stylesheet":wx,y||(_.as="script"),_.crossOrigin="",_.href=m,p&&_.setAttribute("nonce",p),document.head.appendChild(_),y)return new Promise((v,b)=>{_.addEventListener("load",v),_.addEventListener("error",()=>b(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 He{constructor(t,n,s,o,l){this._legacyCanvasSize=He.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=He.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 He.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"),He._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"),He._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(),He._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?He._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&&(He._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,y;[s,m]=await Promise.all([s||He.createQrEngine(),He._loadImage(t)]),[o,y]=He._drawToCanvas(m,d,o,l);let w;if(s instanceof Worker){let _=s;n||He._postWorkerMessageSync(_,"inversionMode","both"),w=await new Promise((v,b)=>{let k,x,R,j=-1;x=B=>{B.data.id===j&&(_.removeEventListener("message",x),_.removeEventListener("error",R),clearTimeout(k),B.data.data!==null?v({data:B.data.data,cornerPoints:He._convertPoints(B.data.cornerPoints,d)}):b(He.NO_QR_CODE_FOUND))},R=B=>{_.removeEventListener("message",x),_.removeEventListener("error",R),clearTimeout(k),b("Scanner error: "+(B?B.message||B:"Unknown Error"))},_.addEventListener("message",x),_.addEventListener("error",R),k=setTimeout(()=>R("timeout"),1e4);let A=y.getImageData(0,0,o.width,o.height);j=He._postWorkerMessageSync(_,"decode",A,[A.data.buffer])})}else w=await Promise.race([new Promise((_,v)=>window.setTimeout(()=>v("Scanner error: timeout"),1e4)),(async()=>{try{var[_]=await s.detect(o);if(!_)throw He.NO_QR_CODE_FOUND;return{data:_.rawValue,cornerPoints:He._convertPoints(_.cornerPoints,d)}}catch(v){if(_=v.message||v,/not implemented|service unavailable/.test(_))return He._disableBarcodeDetector=!0,He.scanImage(t,{scanRegion:d,canvas:o,disallowCanvasResizing:l,alsoTryWithoutScanRegion:u});throw`Scanner error: ${_}`}})()]);return p?w:w.data}catch(m){if(!d||!u)throw m;let y=await He.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:l});return p?y:y.data}finally{n||He._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,n,s,o=!0){He._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:n,blue:s,useIntegerApproximation:o})}setInversionMode(t){He._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=()=>Cx(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!He._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,y=n/s,w=o/l;switch(m){case"none":var _=n,v=s;break;case"fill":_=o,v=l;break;default:(m==="cover"?y>w:y<w)?(v=l,_=v*y):(_=o,v=_/y),m==="scale-down"&&(_=Math.min(_,n),v=Math.min(v,s))}var[b,k]=p.objectPosition.split(" ").map((R,j)=>{const A=parseFloat(R);return R.endsWith("%")?(j?l-v:o-_)*A/100:A});p=this._scanRegion.width||n,w=this._scanRegion.height||s,m=this._scanRegion.x||0;var x=this._scanRegion.y||0;y=this.$overlay.style,y.width=`${p/n*_}px`,y.height=`${w/s*v}px`,y.top=`${d+k+x/s*v}px`,s=/scaleX\(-1\)/.test(t.style.transform),y.left=`${u+(s?o-b-_:b)+(s?n-m-p:m)/n*_}px`,y.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 He.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!He._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=He.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!==He.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 He._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 He._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 He._postWorkerMessageSync(await t,n,s,o)}static _postWorkerMessageSync(t,n,s,o){if(!(t instanceof Worker))return-1;let l=He._workerMessageId++;return t.postMessage({id:l,type:n,data:s},o),l}}He.DEFAULT_CANVAS_SIZE=400;He.NO_QR_CODE_FOUND="No QR code found";He._disableBarcodeDetector=!1;He._workerMessageId=0;function xx({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,y=w=>{p||o.current||(o.current=!0,e(w))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){u(S("qr-unsupported"));return}let w=!1;try{w=await He.hasCamera()}catch{w=!1}if(!w){u(S("qr-no-camera"));return}if(p||!m)return;const _=new He(m,v=>{const b=Hg(v);b&&y(b)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:v=>{const b=v.videoWidth||640,k=v.videoHeight||480,x=Math.max(1,Math.round(Math.min(b,k)*.92));return{x:Math.round((b-x)/2),y:Math.round((k-x)/2),width:x,height:x,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=_;try{await _.start()}catch(v){if(p)return;const b=v&&v.name||"";u(S(b==="NotAllowedError"||b==="SecurityError"?"qr-permission":b==="NotFoundError"||b==="OverconstrainedError"||b==="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 _=m,v=_&&_.srcObject;if(v&&typeof v.getTracks=="function"){for(const b of v.getTracks())try{b.stop()}catch{}try{_.srcObject=null}catch{}}}},[]);const d=async p=>{const m=p.target.files&&p.target.files[0];if(p.target.value="",!!m)try{const y=await He.scanImage(m,{returnDetailedScanResult:!0}),w=Hg(y);if(!w)throw new Error("empty");o.current||(o.current=!0,e(w))}catch{u(S("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:S("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:[S("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:S("cancel")})]})]})})}const Ug=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:""});function j_({token:e,initial:t="",autoStart:n=!1,deviceDefault:s="",readonly:o=!1,onSuccess:l,onBusyChange:u}){const[d,p]=M.useState(Ug),[m,y]=M.useState(!1),[w,_]=M.useState(!1),[v,b]=M.useState("idle"),[k,x]=M.useState(null),[R,j]=M.useState(""),[A,B]=M.useState(!1),ie=M.useRef(_x()),z=M.useRef(new Set),$=v==="busy";M.useEffect(()=>(u&&u($),()=>{u&&u(!1)}),[$,u]);const re=async L=>{const Y=String(L.pairingUrl||"").trim();if(ie.current.start(Y)){b("busy"),x(null),j("");try{await hw(e,vx(L,{deviceDefault:s})),b("ok"),y(!1),p(Ug()),z.current=new Set,B(!1),ie.current.finish(),l&&await l()}catch(N){const H=Sx(N);x(H),b("idle"),ie.current.finish(),(H.stage==="validation"||H.stage==="conflict")&&y(!0)}}},U=(L,Y=!0)=>{const{classification:N,form:H}=$g(d,L,z.current,A),I=H.pairingUrl;if(x(null),j(""),v==="ok"&&b("idle"),p(H),N.kind==="invalid"){x({stage:"validation",code:"bad-link",message:S("pair-invalid-link"),hint:S("pair-invalid-hint"),retryable:!0});return}if(N.kind==="partial"){y(!0),j(N.missing.includes("ssh")?S("pair-missing-ssh"):S("pair-missing-name"));return}N.kind==="complete"&&Y&&!o&&ie.current.canAuto(I)&&re(H)};M.useEffect(()=>{t&&U(t,n)},[]);const X=()=>{const L=String(d.pairingUrl||"").trim(),{classification:Y,form:N}=$g(d,L,z.current,A);if(p(N),j(""),x(null),Y.kind==="empty"){x({stage:"validation",message:S("pairing-required"),retryable:!0});return}if(Y.kind==="invalid"){x({stage:"validation",code:"bad-link",message:S("pair-invalid-link"),hint:S("pair-invalid-hint"),retryable:!0});return}if(!N.ssh||!N.name){y(!0),j(N.ssh?S("pair-missing-name"):S("pair-missing-ssh"));return}if(N.label&&!xh(N.label)){x({stage:"validation",message:S("err-label"),retryable:!0});return}if(N.localLabel&&!xh(N.localLabel)){x({stage:"validation",message:S("err-label"),retryable:!0});return}ie.current.reset(L),re(N)},q=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const L=await navigator.clipboard.readText();L&&L.trim()?U(L):j(S("pair-clipboard-empty"))}catch{j(S("pair-clipboard-denied"))}},D=(L,Y)=>{z.current.add(L),p(N=>({...N,[L]:Y}))},E=k&&k.stage&&(yx.includes(k.stage)||k.stage==="internal")?S(`pair-stage-${k.stage}`):S("pair-stage-generic");return h.jsxs("div",{className:"nc-set-form nc-pair-card",children:[h.jsx("div",{className:"nc-sheet-label",children:S("pair-card-title")}),h.jsx("div",{className:"nc-set-info",children:S("pair-card-help")}),h.jsx("input",{className:"nc-pair-input",placeholder:S("pair-paste-ph"),value:d.pairingUrl,disabled:o||$,onChange:L=>{p({...d,pairingUrl:L.target.value}),x(null),j("")},onPaste:L=>{const Y=L.clipboardData&&L.clipboardData.getData("text")||"";Y.trim()&&(L.preventDefault(),U(Y))},onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),X())}}),h.jsxs("div",{className:"nc-pair-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||$,onClick:q,children:S("pair-paste-btn")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||$,onClick:()=>_(!0),children:S("scan-qr")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||$,title:o?S("settings-readonly"):"",onClick:X,children:S("test-and-connect")})]}),h.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[$&&h.jsx("div",{className:"nc-pair-progress",children:S("pair-progress")}),v==="ok"&&h.jsx("div",{className:"nc-set-test ok",children:S("node-connected")}),R&&h.jsx("div",{className:"nc-set-hint nc-pair-notice",children:R}),k&&h.jsxs("div",{className:"nc-err",role:"alert",children:[h.jsx("b",{children:E})," — ",k.message,k.hint&&h.jsx("div",{className:"nc-pair-hint",children:k.hint}),k.retryable&&h.jsx("div",{children:h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||$,onClick:X,children:S("pair-retry")})})]})]}),h.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:$,onClick:()=>y(L=>!L),children:[m?"▾":"▸"," ",S("pair-advanced")]}),m&&h.jsxs("div",{className:"nc-pair-advanced",children:[h.jsxs("label",{className:"nc-field",children:[S("node-display-label"),h.jsx("input",{placeholder:"Home Relay",value:d.label,disabled:o||$,onChange:L=>{z.current.add("label"),p(Y=>({...Y,label:L.target.value,name:A?Y.name:Kr(L.target.value)}))}})]}),h.jsxs("label",{className:"nc-field",children:[S("node-name-label"),h.jsx("input",{placeholder:S("node-name-ph"),value:d.name,disabled:o||$,onChange:L=>{B(!0),z.current.add("name"),p(Y=>({...Y,name:L.target.value?Kr(L.target.value):""}))}})]}),h.jsx("small",{className:"nc-set-hint",children:S("node-slug-hint").replace("{slug}",d.name||"home-relay")}),h.jsxs("label",{className:"nc-field",children:[S("node-ssh-label"),h.jsx("input",{placeholder:"my-relay",value:d.ssh,disabled:o||$,onChange:L=>{z.current.add("ssh"),D("ssh",L.target.value)}})]}),h.jsxs("label",{className:"nc-field",children:[S("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:S("node-ssh-port-help"),value:d.sshPort,disabled:o||$,onChange:L=>D("sshPort",L.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),h.jsxs("label",{className:"nc-field",children:[S("device-name-label"),h.jsx("input",{placeholder:s||"NexusCrew",value:d.localLabel,disabled:o||$,onChange:L=>D("localLabel",L.target.value)}),h.jsx("small",{className:"nc-set-hint",children:S("device-name-hint")})]})]}),w&&h.jsx(xx,{onResult:L=>{_(!1),U(L)},onClose:()=>_(!1)})]})}function Jh(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function kx(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 Ex(){if(!Jh())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function Nx(e){if(!Jh())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const n=await It("/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:kx(s)}),u=await It("/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 Rx(e){if(!Jh())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 It("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const B_="nexuscrew.fleet",A_=2,Px="nexuscrew.cells",Dx=/^[A-Za-z0-9._-]{1,32}$/,Zh=/^[a-z0-9._-]{1,32}$/,I_=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,Mx=new Set(["standard","unsafe"]),Lx=4096,Kg=256,Tx=8192,jx=32,Bx=24,Ax=new Set(["format","version","exportedAt","cells","engines"]),Ix=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]),Ox=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag"]),zx=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]);function rr(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function O_(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 qg(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(!Zh.test(o)||!t(l))return null;s[o]=l}return s}function z_(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(l=>!Ix.has(l))||!Dx.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>Lx||!Zh.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>Kg)||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>Tx)return null;const n=qg(e.models,l=>typeof l=="string"&&!!l&&l.length<=Kg),s=qg(e.permissionPolicies,l=>Mx.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 Fx(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(n=>!zx.has(n)))return null;const t={};for(const[n,s]of Object.entries(e)){if(typeof s!="string"||!rr(s,n==="baseUrl"?512:128)||O_(s))return null;t[n]=s}return!t.client||!t.provider||t.envKey&&!I_.test(t.envKey)?null:t}function F_(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!Ox.has(s))||!Zh.test(String(e.id||""))||!rr(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=Fx(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!rr(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!rr(s,1024)||O_(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!rr(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")||!rr(e.model.flag,32)||/\s/.test(e.model.flag)||!rr(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=>!I_.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 H_(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=F_(t);return n||null}function Hx(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 y=z_({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||""});y&&d.push(y)}const p=[];for(const m of Array.isArray(n)?n:[]){if(!u.has(m.id))continue;const y=H_(m);y&&p.push(y)}return{format:B_,version:A_,exportedAt:o.toISOString(),cells:d,engines:p}}function $x(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)===Px&&(t==null?void 0:t.version)===1;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(d=>!Ax.has(d))||!n&&(t.format!==B_||t.version!==A_)||!Array.isArray(t.cells)||t.cells.length>jx||!n&&(!Array.isArray(t.engines)||t.engines.length>Bx))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const s=[],o=new Set;for(const d of t.cells){const p=z_(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=F_(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 Wx(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 Ux=()=>({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:[]}),Vg=(e="")=>({id:"",cwd:"",engine:e,boot:!1,model:"",prompt:""}),$_=e=>e==="claude"?"unsafe":"standard",Va=(e,t)=>e.find(n=>n.client===t.client&&n.provider===t.provider&&(n.credentialProfile||"")===(t.credentialProfile||"")),Kx=(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,y,w,_,v,b;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=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:((y=e.managed)==null?void 0:y.envKey)||"",providerId:((w=e.managed)==null?void 0:w.providerId)||"nexuscrew-custom",modelOptions:e.availableModels||((_=e.managedInfo)==null?void 0:_.models)||[],promptMode:e.promptMode||"send-keys",promptFlag:e.promptFlag||"",modelFlag:((v=e.model)==null?void 0:v.flag)||"",modelValue:((b=e.model)==null?void 0:b.value)||"",envRows:(e.envKeys||[]).map(k=>({key:k,value:"",configured:!0,remove:!1}))}}function Vx(e,t,n=[]){if(e.kind==="managed"){const o={client:e.client,provider:e.provider,model:e.managedModel||"",permissionPolicy:e.permissionPolicy||$_(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||Kx(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 Hs({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(_=>_.offsetParent!==null),y=requestAnimationFrame(()=>{var _;return(_=m()[0]||p)==null?void 0:_.focus({preventScroll:!0})}),w=_=>{var x;if(_.key==="Escape"){_.preventDefault(),(x=u.current)==null||x.call(u);return}if(_.key!=="Tab")return;const v=m();if(!v.length){_.preventDefault(),p==null||p.focus();return}const b=v[0],k=v[v.length-1];_.shiftKey&&document.activeElement===b?(_.preventDefault(),k.focus()):!_.shiftKey&&document.activeElement===k&&(_.preventDefault(),b.focus())};return document.addEventListener("keydown",w),()=>{cancelAnimationFrame(y),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||S("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 Yx({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,y]=M.useState(null),[w,_]=M.useState(null),[v,b]=M.useState(!1),[k,x]=M.useState(""),[R,j]=M.useState(""),[A,B]=M.useState(o),[ie,z]=M.useState(!1),[$,re]=M.useState(null),[U,X]=M.useState(null),[q,D]=M.useState(!1),[E,L]=M.useState("manage"),Y=M.useRef(!1),N=A?A.split("/"):[],H=M.useCallback(async()=>{try{const G=await ur(e,N);p(G);try{const ae=await jh(e,N);z(!!ae.readonlyDefault)}catch{z(!1)}if(G.provider==="builtin"&&(G.capabilities||[]).includes("definitions")){const ae=await Lh(e,N),we=new Map((G.engines||[]).map(O=>[O.id,O]));ae.engines=(ae.engines||[]).map(O=>{var ue;return{...O,availableModels:((ue=we.get(O.id))==null?void 0:ue.models)||[]}}),u(ae)}}catch(G){x(String(G.message||G))}},[e,A]);M.useEffect(()=>{H();const G=setInterval(H,5e3);return()=>clearInterval(G)},[H]);const I=new Set((d.cells||[]).filter(G=>G.active).map(G=>G.cell)),W=d.provider==="builtin"&&(d.capabilities||[]).includes("edit"),Z=(d.capabilities||[]).includes("restore");M.useEffect(()=>{!s||Y.current||!W||!l.engines.length||(Y.current=!0,_({mode:"new",form:Vg(l.engines[0].id)}))},[s,W,l.engines]);const P=async G=>{b(!0),x(""),j("");try{await G(),await H()}catch(ae){x(String(ae.message||ae))}b(!1)},Q=()=>P(async()=>{const G=m.mode==="new",ae=Vx(m.form,G,l.managedCatalog||[]);!G&&m.form.kind==="custom"&&!m.form.modelFlag&&(ae.model=null),!G&&m.form.kind==="custom"&&m.form.promptMode!=="flag"&&(ae.promptFlag=null);let we;if(G)we=await tw(e,ae,N);else{const ue=m.original,be=new Set(m.form.envRows.filter(De=>!De.remove).map(De=>De.key)),Le=(ue.envKeys||[]).filter(De=>!be.has(De)),Ke=Object.fromEntries(m.form.envRows.filter(De=>!De.remove&&De.key&&(!De.configured||De.value!=="")).map(De=>[De.key,De.value]));we=await iw(e,ue.id,ae,m.form.kind==="custom"?{set:Ke,remove:Le}:void 0,N)}y(null),j(S("fleet-saved"));const O=(we==null?void 0:we.activeCells)||[];if(O.length&&window.confirm(S("fleet-restart-confirm").replace("{cells}",O.join(", "))))for(const ue of O)await xa(e,ue,N)}),se=()=>P(async()=>{const G=w.mode==="new",ae=w.form,we={...G?{id:ae.id}:{},cwd:ae.cwd,engine:ae.engine,boot:!!ae.boot};G?(ae.model&&(we.model=ae.model),ae.prompt&&(we.prompt=ae.prompt)):(we.model=ae.model||null,we.prompt=ae.prompt||null);const O=G?await rw(e,we,N):await sw(e,w.original.id,we,N),ue=G?ae.id:w.original.id;_(null),j(S("fleet-saved")),!G&&(O!=null&&O.active)&&window.confirm(S("fleet-restart-confirm").replace("{cells}",ue))&&await xa(e,ue,N)}),J=t||ie,le=G=>re({...G,route:Array.isArray(G==null?void 0:G.route)?G.route:N}),de=async G=>{if(!$)return;const ae=$.cell||$.id,we=Array.isArray($.route)?$.route:N;G.action==="up"?await Mh(e,{cell:ae,boot:!!G.boot,...G.engine?{engine:G.engine}:{},...G.model!==void 0?{model:G.model}:{},...G.permissionPolicy?{permissionPolicy:G.permissionPolicy}:{}},we):await Ta(e,{cell:ae,boot:!!G.boot},we)},pe=(G,ae)=>{x(""),X({mode:"new",route:Array.isArray(ae)?ae:N,form:{tmuxSession:G.name,id:"",engine:"",cwd:"",boot:!1},err:""})},ye=()=>P(async()=>{const G=U.form;if(!G.engine){X({...U,err:S("import-engine-required")});return}await ow(e,{tmuxSession:G.tmuxSession,id:G.id||void 0,engine:G.engine,cwd:G.cwd||void 0,boot:!!G.boot},G.route||N),X(null),j(S("fleet-saved"))}),K=({engineRows:G=[],cellRows:ae=[]})=>P(async()=>{const we=G.filter(Ye=>Ye.selected),O=we.map(Ye=>H_(Ye.engine));if(O.some(Ye=>!Ye))throw new Error(S("fleet-backup-invalid-engine"));const ue=we.filter(Ye=>Ye.exists).map(Ye=>Ye.engine.id);if(ue.length&&!window.confirm(S("fleet-backup-confirm-engine-overwrite").replace("{engines}",ue.join(", "))))return;const be=[...new Set([...l.engines.map(Ye=>Ye.id),...O.map(Ye=>Ye.id)])],Le=[];for(const Ye of ae.filter(Ct=>Ct.selected)){const Ct=Wx(Ye.cell,Ye.engine,be);if(!Ct)throw new Error(`${Ye.cell.id}: ${S("fleet-backup-engine-missing")}`);Le.push(Ct)}const Ke=ae.filter(Ye=>Ye.selected&&Ye.exists).map(Ye=>Ye.cell.id);if(Ke.length&&!window.confirm(S("fleet-backup-confirm-overwrite").replace("{cells}",Ke.join(", "))))return;const De=O.length?await lw(e,O,ue.length>0,N):{needsRestart:[]},Qe=Le.length?await aw(e,Le,N):{needsRestart:[]},qe=[...new Set([...De.needsRestart||[],...Qe.needsRestart||[]])];D(!1),j(`${S("fleet-backup-restored").replace("{n}",String(Le.length))}${O.length?` · ${O.length} ${S("fleet-engines").toLowerCase()}`:""}${qe.length?` · ${S("fleet-backup-needs-restart").replace("{cells}",qe.join(", "))}`:""}`)}),ee=h.jsxs("label",{className:"nc-field",children:[S("location"),h.jsxs("select",{value:A,onChange:G=>{B(G.target.value),y(null),_(null),x(""),j(""),z(!1),p({available:!1,capabilities:[]}),u({engines:[],cells:[],managedCatalog:[]})},children:[h.jsx("option",{value:"",children:S("local")}),n.map(G=>h.jsxs("option",{value:G.route.join("/"),disabled:G.status&&G.status!=="up",children:[G.label,G.status&&G.status!=="up"?` · ${S("node-offline")}`:""]},G.route.join("/")))]})]}),Re=h.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":S("tab-fleet"),children:[h.jsx("button",{type:"button",role:"tab","aria-selected":E==="manage",className:`nc-set-tabbtn${E==="manage"?" on":""}`,onClick:()=>L("manage"),children:S("fleet-manage-location")}),h.jsx("button",{type:"button",role:"tab","aria-selected":E==="overview",className:`nc-set-tabbtn${E==="overview"?" on":""}`,onClick:()=>L("overview"),children:S("fleet-network-overview")})]});return W?h.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[Re,E==="overview"?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:S("fleet-overview-help")}),h.jsx(Yg,{token:e,targets:n,readonly:t,onPower:le,onImport:pe})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:S("fleet-manage-help")}),ee,h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:S("fleet-cells")}),h.jsxs("span",{className:"nc-fleet-head-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:J||v,onClick:()=>{x(""),D(!0)},children:S("fleet-backup")}),h.jsxs("button",{className:"nc-btn primary",disabled:J||v||!l.engines.length,onClick:()=>{var G;x(""),_({mode:"new",form:Vg((G=l.engines[0])==null?void 0:G.id)})},children:["+ ",S("add")]})]})]}),l.cells.map(G=>{const ae=I.has(G.id),we=d.capabilities||[];return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:G.id}),h.jsxs("small",{children:[G.engine," · ",G.cwd,ae?` · ${S("service-active")}`:` · ${S("cell-off")}`]})]}),h.jsxs("span",{children:[ae&&we.includes("down")&&h.jsx("button",{className:"nc-btn ghost",disabled:J||v,onClick:()=>P(()=>Ta(e,{cell:G.id},N)),children:S("stop")}),!ae&&we.includes("up")&&h.jsx("button",{className:"nc-btn primary",disabled:J||v,onClick:()=>le({cell:G.id,id:G.id,engine:G.engine,model:G.model,models:G.models,permissionPolicies:G.permissionPolicies,active:!1,boot:G.boot}),children:S("start")}),ae&&we.includes("restart")&&h.jsx("button",{className:"nc-btn ghost",disabled:J||v,onClick:()=>P(()=>xa(e,G.id,N)),children:S("restart")}),h.jsx("button",{className:"nc-btn ghost",disabled:J||v,onClick:()=>{x(""),_({mode:"edit",original:G,form:{...G}})},children:S("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:J||v,onClick:()=>P(async()=>{window.confirm(S("fleet-remove-cell").replace("{id}",G.id))&&await rv(e,G.id,!0,N)}),children:"×"})]})]},G.id)}),h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:S("fleet-engines")}),h.jsxs("button",{className:"nc-btn primary",disabled:J||v,onClick:()=>{x(""),y({mode:"new",form:Ux()})},children:["+ ",S("add")]})]}),l.engines.map(G=>{var ae,we;return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:G.label}),h.jsx("small",{children:G.managed?`${G.id} · ${G.managed.client} / ${G.managed.provider} · ${(ae=G.managedInfo)!=null&&ae.configured?S("fleet-ready"):((we=G.managedInfo)==null?void 0:we.reason)||S("fleet-not-ready")}`:`${G.id} · ${G.command}`})]}),h.jsxs("span",{children:[h.jsx("button",{className:"nc-btn ghost",disabled:J||v,onClick:()=>{x(""),y({mode:"edit",original:G,form:qx(G)})},children:S("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:J||v,onClick:()=>P(async()=>{window.confirm(S("fleet-remove-engine").replace("{id}",G.id))&&await nw(e,G.id,N)}),children:"×"})]})]},G.id)})]}),m&&h.jsx(Hs,{onClose:()=>y(null),label:S("fleet-new-engine"),error:k,children:h.jsx(Gx,{state:m,setState:y,busy:v,onSave:Q,catalog:l.managedCatalog||[]})}),w&&h.jsx(Hs,{onClose:()=>_(null),label:S("fleet-new-cell"),error:k,children:h.jsx(Qx,{token:e,route:N,targets:n,location:A,setLocation:B,state:w,setState:_,engines:l.engines,busy:v,onSave:se})}),R&&h.jsx("div",{className:"nc-set-note",children:R}),k&&h.jsx("div",{className:"nc-err",children:k}),q&&h.jsx(Hs,{onClose:()=>D(!1),label:S("fleet-backup"),error:k,children:h.jsx(Xx,{cells:l.cells,engines:l.engines,busy:v,canRestore:Z,onRestore:K,onClose:()=>D(!1)})}),U&&h.jsx(Hs,{onClose:()=>X(null),label:S("import-as-cell"),error:k,children:h.jsx(Xg,{token:e,route:U.route||N,state:U,setState:X,busy:v,onSave:ye})}),$&&h.jsx(Ba,{cell:$,token:e,route:Array.isArray($.route)?$.route:N,onConfirm:async G=>{try{await de(G)}finally{await H()}},onClose:()=>re(null)})]}):h.jsxs("div",{className:"nc-set-tab",children:[Re,E==="overview"?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:S("fleet-overview-help")}),h.jsx(Yg,{token:e,targets:n,readonly:t,onPower:le,onImport:pe})]}):h.jsxs(h.Fragment,{children:[ee,h.jsx("div",{className:"nc-set-info",children:S("fleet-editor-unavailable")})]}),k&&h.jsx("div",{className:"nc-err",children:k}),U&&h.jsx(Hs,{onClose:()=>X(null),label:S("import-as-cell"),error:k,children:h.jsx(Xg,{token:e,route:U.route||N,state:U,setState:X,busy:v,onSave:ye})}),$&&h.jsx(Ba,{cell:$,token:e,route:Array.isArray($.route)?$.route:N,onConfirm:async G=>{try{await de(G)}finally{await H()}},onClose:()=>re(null)})]})}function Yg({token:e,targets:t=[],readonly:n=!1,onPower:s,onImport:o}){const[l,u]=M.useState([]),[d,p]=M.useState(0);M.useEffect(()=>{let x=!0;async function R(){const A=[{route:[],label:S("local")}].concat((t||[]).map(ie=>({route:Array.isArray(ie.route)?ie.route:[],label:ie.label||(ie.route||[]).join(" › ")}))),B=await Promise.all(A.map(async ie=>{const z={...ie,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const $=await ur(e,ie.route);z.available=!!$.available,z.capabilities=$.capabilities||[],z.provider=$.provider||null,z.cells=($.cells||[]).map(re=>({...re,route:ie.route}));try{z.readonly=!!(await jh(e,ie.route)).readonlyDefault}catch{}try{const re=await lv(e,ie.route),U=new Set(z.cells.map(X=>X.tmuxSession).filter(Boolean));z.unmanaged=(re.sessions||[]).filter(X=>X&&!U.has(X.name))}catch{}}catch($){z.err=String($&&$.message||$)}return z}));x&&u(B)}R();const j=setInterval(R,6e3);return()=>{x=!1,clearInterval(j)}},[e,t,d]);const m=(x,R)=>Array.isArray(x.capabilities)&&x.capabilities.includes(R)&&!n&&!x.readonly,y=()=>p(x=>x+1),w=(x,R)=>{s&&s({...x,route:R})},_=(x,R)=>{s&&s({...x,route:R})},v=async(x,R)=>{try{await xa(e,x.cell,R)}catch{}y()},b=async(x,R)=>{if(window.confirm(S("fleet-remove-cell").replace("{id}",x.cell))){try{await rv(e,x.cell,!0,R)}catch{}y()}},k=async(x,R)=>{if(window.confirm(S("terminate-confirm").replace("{name}",x.name))){try{await Th(e,x.name,R)}catch{}y()}};return h.jsxs("div",{className:"nc-fleet-inventory",children:[h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:S("fleet-inventory")}),h.jsx("small",{children:S("fleet-inventory-help")})]}),l.map(x=>{const R=x.route.length?x.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 ${x.available?"on":"warn"}`}),h.jsx("b",{children:x.label}),h.jsx("small",{children:x.available?`${x.cells.length} ${S("fleet-cells")} · ${x.unmanaged.length} ${S("fleet-tmux")}`:x.err||S("fleet-not-available")})]}),x.cells.map(j=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[h.jsxs("span",{children:[h.jsx("b",{children:j.cell}),h.jsx("small",{children:`${j.engine||""}${j.key?`·${j.key}`:""}${j.active?"":` · ${S("cell-off")}`}`})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[j.active&&m(x,"down")&&h.jsx("button",{className:"nc-btn ghost",title:S("power-off"),onClick:()=>_(j,x.route),children:S("stop")}),!j.active&&m(x,"up")&&h.jsx("button",{className:"nc-btn ghost",title:S("power-on"),onClick:()=>w(j,x.route),children:S("start")}),m(x,"restart")&&j.active&&h.jsx("button",{className:"nc-btn ghost",title:S("restart"),onClick:()=>v(j,x.route),children:S("restart")}),m(x,"remove")&&h.jsx("button",{className:"nc-btn danger",title:S("delete"),onClick:()=>b(j,x.route),children:"×"})]})]},`${R}:${j.cell}`)),x.unmanaged.map(j=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[h.jsxs("span",{children:[h.jsx("b",{children:j.name}),h.jsx("small",{children:S("fleet-tmux")})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[m(x,"import")&&o&&h.jsx("button",{className:"nc-btn ghost",title:S("import-as-cell"),onClick:()=>o(j,x.route),children:S("import-as-cell")}),h.jsx("button",{className:"nc-btn danger",title:S("terminate"),onClick:()=>k(j,x.route),children:"×"})]})]},`${R}:u:${j.name}`)),x.available&&x.cells.length===0&&x.unmanaged.length===0&&h.jsx("div",{className:"nc-empty",children:S("fleet-inventory-empty")})]},R)})]})}function Xx({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))),[y,w]=M.useState(()=>new Set(t.map(E=>E.id))),[_,v]=M.useState([]),[b,k]=M.useState([]),[x,R]=M.useState(""),j=new Set(t.map(E=>E.id)),A=new Set(e.map(E=>E.id)),B=(E,L)=>E(Y=>{const N=new Set(Y);return N.has(L)?N.delete(L):N.add(L),N}),ie=()=>{const E=Hx(e,p,t,y),L=t.filter(I=>y.has(I.id)).length;if(E.engines.length!==L){R(S("fleet-backup-invalid-engine"));return}if(!E.cells.length&&!E.engines.length){R(S("fleet-backup-select-one"));return}const Y=new Blob([`${JSON.stringify(E,null,2)}
|
|
91
|
-
`],{type:"application/json"}),N=URL.createObjectURL(Y),H=document.createElement("a");H.href=N,H.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(H),H.click(),H.remove(),setTimeout(()=>URL.revokeObjectURL(N),0),R("")},z=async E=>{if(R(""),v([]),k([]),!!E){if(E.size>1024*1024){R(S("fleet-backup-too-large"));return}try{const L=$x(await E.text());if(!L.ok){R(S(`fleet-backup-${L.error}`));return}const Y=new Set(L.engines.map(N=>N.id));k(L.engines.map(N=>({engine:N,exists:j.has(N.id),selected:!j.has(N.id)}))),v(L.cells.map(N=>{const H=j.has(N.engine)||Y.has(N.engine),I=A.has(N.id);return{cell:N,engine:H?N.engine:"",selected:H&&!I,exists:I}}))}catch(L){R(String(L.message||L))}}},$=(E,L)=>v(Y=>Y.map((N,H)=>H===E?{...N,...L}:N)),re=(E,L)=>k(Y=>Y.map((N,H)=>H===E?{...N,...L}:N)),U=new Set([...j,...b.filter(E=>E.selected).map(E=>E.engine.id)]),X=_.filter(E=>E.selected&&E.engine&&U.has(E.engine)),q=b.filter(E=>E.selected),D=[...new Map([...t.map(E=>[E.id,E.label||E.id]),...b.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:S("fleet-backup")}),h.jsx("small",{children:S("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"),R("")},children:S("fleet-backup-export")}),h.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="import"?" on":""}`,disabled:!s,title:s?"":S("fleet-backup-restore-unavailable"),onClick:()=>{d("import"),R("")},children:S("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:S("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{m(new Set),w(new Set)},children:S("select-none")})]}),h.jsxs("div",{className:"nc-backup-list",children:[h.jsx("b",{children:S("fleet-engines")}),t.map(E=>{var L;return h.jsxs("label",{className:"nc-check nc-backup-row",children:[h.jsx("input",{type:"checkbox",checked:y.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,(L=E.envKeys)!=null&&L.length?` · ${E.envKeys.length} ${S("fleet-backup-env-names")}`:""]})]})]},E.id)}),h.jsx("b",{children:S("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," · ",S("fleet-system-prompt")," ",(E.prompt||"").length," ",S("characters")]})]})]},E.id)),!e.length&&!t.length&&h.jsx("div",{className:"nc-empty",children:S("fleet-backup-empty")})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:S("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:!p.size&&!y.size,onClick:ie,children:S("fleet-backup-download")})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"file",accept:"application/json,.json",disabled:n,onChange:E=>z(E.target.files&&E.target.files[0])}),h.jsx("small",{children:S("fleet-backup-import-help")}),!!(_.length||b.length)&&h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{k(E=>E.map(L=>({...L,selected:!0}))),v(E=>E.map(L=>({...L,selected:!!L.engine})))},children:S("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{k(E=>E.map(L=>({...L,selected:!1}))),v(E=>E.map(L=>({...L,selected:!1})))},children:S("select-none")})]}),h.jsxs("div",{className:"nc-backup-list",children:[!!b.length&&h.jsx("b",{children:S("fleet-engines")}),b.map((E,L)=>{var Y;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:N=>re(L,{selected:N.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?S("fleet-backup-overwrite"):S("fleet-backup-new"),(Y=E.engine.envKeys)!=null&&Y.length?` · ${S("fleet-backup-env-values-required")}`:""]})]})]})},E.engine.id)}),!!_.length&&h.jsx("b",{children:S("fleet-cells")}),_.map((E,L)=>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||!U.has(E.engine),onChange:Y=>$(L,{selected:Y.target.checked})}),h.jsxs("span",{children:[h.jsx("b",{children:E.cell.id}),h.jsxs("small",{children:[E.exists?S("fleet-backup-overwrite"):S("fleet-backup-new")," · ",S("fleet-system-prompt")," ",E.cell.systemPrompt.length," ",S("characters")]})]})]}),h.jsxs("select",{value:E.engine,onChange:Y=>$(L,{engine:Y.target.value,selected:!!Y.target.value}),children:[h.jsx("option",{value:"",children:S("fleet-backup-engine-missing")}),D.map(([Y,N])=>h.jsx("option",{value:Y,children:N},Y))]})]},E.cell.id))]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:S("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||!X.length&&!q.length,onClick:()=>o({engineRows:b,cellRows:_}),children:S("fleet-backup-restore")})]})]}),x&&h.jsx("div",{className:"nc-err",children:x})]})}function Gx({state:e,setState:t,busy:n,onSave:s,catalog:o}){var _;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),y=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?S("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"?S("fleet-new-engine"):`${S("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:S("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:S("fleet-managed")}),h.jsx("option",{value:"custom",children:S("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(b=>b.client===v.target.value&&b.default)||o.find(b=>b.client===v.target.value)),children:p.map(([v,b])=>h.jsx("option",{value:v,children:b},v))}),h.jsx("select",{value:((_=Va(o,l))==null?void 0:_.id)||"",disabled:e.mode!=="new",onChange:v=>w(o.find(b=>b.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(y!=null&&y.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:v=>u({managedModel:v.target.value})}),h.jsx("datalist",{id:"nc-managed-models",children:[...(y==null?void 0:y.models)||[],...l.modelOptions||[]].filter((v,b,k)=>v&&k.indexOf(v)===b).map(v=>h.jsx("option",{value:v},v))}),y!=null&&y.supportsUnsafe?h.jsxs("select",{value:l.permissionPolicy,onChange:v=>u({permissionPolicy:v.target.value}),children:[h.jsx("option",{value:"standard",children:S("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:S("fleet-unsafe-permissions")})]}):h.jsx("small",{children:S("fleet-standard-permissions")}),(y==null?void 0:y.supportsUnsafe)&&l.permissionPolicy==="unsafe"&&h.jsx("small",{className:"nc-err",children:S("fleet-unsafe-warning")}),(y==null?void 0:y.credentialEnv)&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.envKey,placeholder:S("fleet-api-key-env"),onChange:v=>u({envKey:v.target.value})}),h.jsx("small",{children:S("fleet-custom-secret-help")})]}),l.provider==="custom"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.displayName,placeholder:S("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})}),((y==null?void 0:y.protocols)||[]).length>1&&h.jsx("select",{value:l.protocol,onChange:v=>u({protocol:v.target.value}),children:y.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:S("fleet-api-key-env"),onChange:v=>u({envKey:v.target.value})}),h.jsx("input",{value:l.providerId,placeholder:S("fleet-provider-id"),onChange:v=>u({providerId:v.target.value})})]}),h.jsxs("small",{children:[l.protocol," · ",S("fleet-custom-secret-help")]})]}),h.jsx("small",{children:S("fleet-managed-help")})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.command,placeholder:S("command-path"),onChange:v=>u({command:v.target.value})}),h.jsx("textarea",{value:l.argsText,placeholder:S("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:S("env-write-only")}),d.map((v,b)=>h.jsxs("div",{className:"nc-fleet-env",children:[h.jsx("input",{value:v.key,disabled:v.configured,placeholder:"ENV_KEY",onChange:k=>{const x=d.slice();x[b]={...v,key:k.target.value},u({envRows:x})}}),h.jsx("input",{type:"password",value:v.value,placeholder:v.configured?"•••••• (unchanged)":"value",onChange:k=>{const x=d.slice();x[b]={...v,value:k.target.value},u({envRows:x})}}),h.jsx("button",{className:"nc-btn danger",onClick:()=>u({envRows:d.filter((k,x)=>x!==b)}),children:"×"})]},`${v.key}-${b}`)),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:S("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:n||!l.id||l.kind==="custom"&&!l.command||l.kind==="managed"&&(y==null?void 0:y.requiresModel)&&!l.managedModel||l.kind==="managed"&&(y==null?void 0:y.credentialEnv)&&!l.envKey||l.kind==="managed"&&l.provider==="custom"&&(!l.displayName||!l.baseUrl||!l.envKey||!l.providerId),onClick:s,children:S("save")})]})]})}function Qx({token:e,route:t,targets:n=[],location:s,setLocation:o,state:l,setState:u,engines:d,busy:p,onSave:m}){const[y,w]=M.useState(null),[_,v]=M.useState(""),b=l.form,k=A=>u({...l,form:{...b,...A}}),x=d.find(A=>A.id===b.engine),R=A=>{var ie,z,$;const B=d.find(re=>re.id===A);k({engine:A,model:((ie=b.models)==null?void 0:ie[A])||((z=B==null?void 0:B.managed)==null?void 0:z.model)||(($=B==null?void 0:B.model)==null?void 0:$.value)||""})},j=async A=>{try{const B=await sv(e,A,t);w(B),k({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"?S("fleet-new-cell"):`${S("edit")} ${b.id}`}),l.mode==="new"&&h.jsxs("label",{className:"nc-field",children:[S("location"),h.jsx("span",{className:"nc-req",children:" *"}),h.jsxs("select",{value:s,onChange:A=>{o(A.target.value),k({engine:""})},children:[h.jsx("option",{value:"",children:S("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"?` · ${S("node-offline")}`:""]},A.route.join("/")))]})]}),h.jsx("input",{value:b.id,disabled:l.mode!=="new",placeholder:"id",onChange:A=>k({id:A.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:b.cwd,placeholder:S("cwd"),onChange:A=>k({cwd:A.target.value})}),h.jsx("button",{className:"nc-btn ghost",onClick:()=>y?w(null):j(b.cwd),children:S("browse")})]}),y&&h.jsxs("div",{className:"nc-fs",children:[h.jsx("div",{className:"nc-fs-path",children:y.path}),h.jsxs("div",{className:"nc-fs-list",children:[y.parent&&h.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>j(y.parent),children:["↑ ",S("fs-parent")]}),(y.dirs||[]).map(A=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>j(`${y.path.replace(/\/$/,"")}/${A}`),children:["📁 ",A]},A))]})]}),_&&h.jsx("div",{className:"nc-err",children:_}),h.jsx("select",{value:b.engine,onChange:A=>R(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:!!b.boot,onChange:A=>k({boot:A.target.checked})})," boot"]}),h.jsx("input",{value:b.model||"",list:"nc-cell-models",placeholder:S("fleet-model-override"),onChange:A=>k({model:A.target.value})}),h.jsx("datalist",{id:"nc-cell-models",children:((x==null?void 0:x.availableModels)||[]).map(A=>h.jsx("option",{value:A},A))}),h.jsx("textarea",{value:b.prompt||"",placeholder:"prompt",onChange:A=>k({prompt:A.target.value})}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>u(null),children:S("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:p||!b.id||!b.cwd||!b.engine,onClick:m,children:S("save")})]})]})}function Xg({token:e,route:t=[],state:n,setState:s,busy:o,onSave:l}){const[u,d]=M.useState(null),[p,m]=M.useState([]),[y,w]=M.useState(""),_=Array.isArray(t)?t.join("/"):"";M.useEffect(()=>{let R=!0;return Lh(e,_?_.split("/"):[]).then(j=>{R&&(m(j.engines||[]),w(""))}).catch(j=>{R&&(m([]),w(String(j.message||j)))}),()=>{R=!1}},[e,_]);const v=n.form,b=R=>s({...n,form:{...v,...R}}),k=async R=>{try{const j=await sv(e,R,t);d(j),b({cwd:j.path})}catch{}},x=!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:[S("import-as-cell")," · ",v.tmuxSession]}),h.jsx("small",{children:S("import-help")}),h.jsx("input",{value:v.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),h.jsx("input",{value:v.id,placeholder:S("name"),onChange:R=>b({id:R.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:v.cwd,placeholder:S("cwd"),onChange:R=>b({cwd:R.target.value})}),h.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>u?d(null):k(v.cwd),children:S("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:()=>k(u.parent),children:["↑ ",S("fs-parent")]}),(u.dirs||[]).map(R=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>k(`${u.path.replace(/\/$/,"")}/${R}`),children:["📁 ",R]},R))]})]}),h.jsxs("select",{value:v.engine,onChange:R=>b({engine:R.target.value}),children:[h.jsx("option",{value:"",children:S("import-engine-required")}),p.map(R=>h.jsx("option",{value:R.id,children:R.label},R.id))]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:!!v.boot,onChange:R=>b({boot:R.target.checked})})," boot"]}),(n.err||y)&&h.jsx("div",{className:"nc-err",children:n.err||y}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:S("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:o||!v.tmuxSession||!v.engine||!p.length,onClick:l,children:S(x?"import-as-cell":"save")})]})]})}function Jx({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(Je,{name:"copy",size:14})," ",S(t?"copied":"copy")]})]})}function Zx({value:e}){const[t,n]=M.useState("");return M.useEffect(()=>{let s=!0;return nx.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 ek({token:e,nodes:t,settings:n,readonly:s,refresh:o}){const[l,u]=M.useState(null),[d,p]=M.useState(null),[m,y]=M.useState({}),[w,_]=M.useState(null),[v,b]=M.useState({ssh:"",sshPort:"",name:""}),[k,x]=M.useState(""),[R,j]=M.useState(""),[A,B]=M.useState(""),[ie,z]=M.useState(!1),$=Date.now(),re=n&&n.deviceName||"",U=(t||[]).filter(N=>N&&N.direction==="outbound"&&N.name&&N.ssh),X=U.find(N=>N.name===k)||U[0]||null,q=U.find(N=>N.name===R)||U[0]||null,D=q?Fg(q.tunnel,$):null,E=async(N,H)=>{u(null),p(`${N}:${H}`);try{const I=await Bh(e,N,H);H==="test"&&y(W=>({...W,[N]:I})),await o()}catch(I){u(`${N}: ${String(I.message||I)}`)}p(null)},L=async N=>{if(window.confirm(S("node-remove-confirm").replace("{name}",N))){u(null),p(`${N}:remove`);try{await fw(e,N),await o()}catch(H){u(`${N}: ${String(H.message||H)}`)}p(null)}},Y=async()=>{if(u(null),X){const I=zg({name:X.name,ssh:X.ssh,sshPort:X.sshPort||""});if(!I.ok){u(S(I.error));return}p("invite");try{_(await Xp(e,{ssh:I.value.ssh,...I.value.sshPort?{sshPort:I.value.sshPort}:{}},[X.name]))}catch(W){u(String(W.message||W))}p(null);return}const N=Kr(v.name||A||re||"NexusCrew"),H=zg({name:N,ssh:v.ssh,sshPort:v.sshPort});if(!H.ok){u(S(H.error));return}p("invite");try{_(await Xp(e,{...A||re?{label:A||re}:{},name:N,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(j_,{token:e,deviceDefault:re,readonly:s,onSuccess:o}),q&&h.jsxs("div",{className:"nc-set-form nc-local-share",children:[h.jsx("div",{className:"nc-sheet-label",children:S("share-local-heading")}),U.length>1&&h.jsxs("label",{className:"nc-field",children:[S("share-local-hub"),h.jsx("select",{value:q.name,disabled:s||!!d,onChange:N=>j(N.target.value),children:U.map(N=>h.jsx("option",{value:N.name,children:N.label||N.name},N.name))})]}),h.jsxs("label",{className:"nc-check nc-node-share",children:[h.jsx("input",{type:"checkbox",checked:q.shared===!0,disabled:s||!!d||!(D!=null&&D.up)&&!q.shared,onChange:async N=>{u(null),p(`${q.name}:share`);try{await pw(e,q.name,N.target.checked),await o()}catch(H){u(`${q.name}: ${String(H.message||H)}`)}p(null)}}),h.jsxs("span",{children:[h.jsx("b",{children:S("share-local-through").replace("{device}",re||S("local")).replace("{hub}",q.label||q.name)}),h.jsx("small",{children:S(q.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),h.jsx("div",{className:`nc-set-test${q.shared&&(D!=null&&D.up)?" ok":""}`,children:q.shared?S("share-local-active"):S("share-local-private")})]}),(t||[]).length===0&&h.jsx("div",{className:"nc-empty",children:S("no-nodes")}),(t||[]).map(N=>{var W,Z,P,Q,se;const H=Fg(N.tunnel,$),I=m[N.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:N.label||N.name}),h.jsxs("small",{children:[N.name,N.direction==="outbound"?` · SSH ${N.ssh||""}`:` · ${S("node-connected-client")}`,(W=N.tunnel)!=null&&W.transport?` · ${N.tunnel.transport} ${S("transport-used")}`:""]}),h.jsxs("span",{className:`nc-set-tunnel${H.up?" up":""}`,children:[S(H.label),H.since?` · ${H.since}`:""]})]}),N.direction==="inbound"&&h.jsx("div",{className:"nc-set-info",children:S(N.shared?"peer-shared":"peer-private")}),N.direction==="inbound"&&N.shared&&h.jsxs(h.Fragment,{children:[h.jsxs("select",{value:N.visibility||"network",disabled:s||!!d,onChange:async J=>{p(`${N.name}:visibility`);try{await Gp(e,N.name,J.target.value),await o()}catch(le){u(String(le.message||le))}p(null)},children:[h.jsx("option",{value:"network",children:S("visibility-network")}),h.jsx("option",{value:"relay-only",children:S("visibility-relay")}),h.jsx("option",{value:"selected",children:S("visibility-selected")})]}),N.visibility==="selected"&&h.jsx("div",{className:"nc-set-row",children:(t||[]).filter(J=>J.name!==N.name&&J.nodeId).map(J=>{const le=(N.selected||[]).includes(J.nodeId);return h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:le,disabled:s||!!d,onChange:async de=>{const pe=de.target.checked?[...N.selected||[],J.nodeId]:(N.selected||[]).filter(ye=>ye!==J.nodeId);p(`${N.name}:visibility`);try{await Gp(e,N.name,"selected",pe),await o()}catch(ye){u(String(ye.message||ye))}p(null)}})," ",J.label||J.name]},J.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 J=window.prompt(S("node-display-label"),N.label||N.name);if(J!=null){if(!xh(J)){u(S("err-label"));return}p(`${N.name}:label`);try{await dw(e,N.name,J),await o()}catch(le){u(String(le.message||le))}p(null)}},children:S("edit")}),((Z=N.health)==null?void 0:Z.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(N.name,"test"),children:S("node-test")}),((P=N.health)==null?void 0:P.managed)!==!1&&(H.up?h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(N.name,"down"),children:S("tunnel-stop")}):h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(N.name,"up"),children:S("tunnel-start")})),((Q=N.health)==null?void 0:Q.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(N.name,"restart"),children:S("tunnel-restart")}),h.jsx("button",{type:"button",className:"nc-btn danger",disabled:s||!!d,title:S(s?"settings-readonly":"terminate"),onClick:()=>L(N.name),children:h.jsx(Je,{name:"trash",size:14})})]}),((se=N.health)==null?void 0:se.detail)&&h.jsx("div",{className:`nc-set-test${N.health.status==="healthy"?" ok":N.health.status==="passive"?"":" ko"}`,children:N.health.detail}),I&&h.jsxs("div",{className:`nc-set-test${I.ok?" ok":" ko"}`,children:[I.result,I.detail?` — ${I.detail}`:""]})]},N.name)}),h.jsxs("div",{className:"nc-set-form",children:[h.jsx("div",{className:"nc-sheet-label",children:S("invite-node")}),h.jsx("small",{className:"nc-set-hint",children:S(X?"invite-network-hint":"invite-v2-hint")}),X?h.jsxs(h.Fragment,{children:[U.length>1&&h.jsxs("label",{className:"nc-field",children:[S("invite-network-label"),h.jsx("select",{value:X.name,disabled:s||!!d,onChange:N=>{x(N.target.value),_(null)},children:U.map(N=>h.jsx("option",{value:N.name,children:N.label||N.name},N.name))})]}),h.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[S("invite-network-via"),": ",h.jsx("b",{children:X.label||X.name})," · ",X.ssh,X.sshPort?`:${X.sshPort}`:""]}),h.jsx("small",{className:"nc-set-hint",children:S("invite-network-route")})]}):h.jsxs("label",{className:"nc-field",children:[S("invite-endpoint-label"),h.jsx("input",{placeholder:"user@host",value:v.ssh,disabled:s,onChange:N=>b({...v,ssh:N.target.value})}),h.jsx("small",{className:"nc-set-hint",children:S("invite-endpoint-needed")})]}),!X&&ie&&h.jsxs("div",{className:"nc-invite-advanced",children:[h.jsxs("label",{className:"nc-field",children:[S("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:"22",value:v.sshPort,disabled:s,onChange:N=>b({...v,sshPort:N.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),h.jsxs("label",{className:"nc-field",children:[S("device-name-label"),h.jsx("input",{placeholder:re||"NexusCrew",value:A,disabled:s,onChange:N=>B(N.target.value)}),h.jsx("small",{className:"nc-set-hint",children:S("device-name-hint")})]}),h.jsxs("label",{className:"nc-field",children:[S("node-name-label"),h.jsx("input",{placeholder:Kr(A||re||S("node-name-ph")),value:v.name,disabled:s,onChange:N=>b({...v,name:N.target.value?Kr(N.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||!X&&!v.ssh.trim(),onClick:Y,children:S("create-pairing-link")}),!X&&h.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>z(N=>!N),children:[ie?"▾":"▸"," ",S("pair-advanced")]})]}),w&&h.jsxs(h.Fragment,{children:[h.jsx(Zx,{value:w.pairingUrl}),h.jsx(Jx,{text:w.pairingUrl}),h.jsx("div",{className:"nc-set-info",children:S("invite-next-steps")})]})]}),l&&h.jsx("div",{className:"nc-err",children:l})]})}function tk({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 Ex().then(y=>{m||s(y)}),()=>{m=!0}},[]);const p=async()=>{d(null),l(!0);try{n==="subscribed"?(await Rx(e),s("idle")):(await Nx(e),s("subscribed"))}catch(m){const y=String(m.message||m);y==="push-denied"?(s("denied"),d(S("push-denied"))):y==="push-unsupported"?(s("unsupported"),d(S("push-unsupported"))):d(y)}l(!1)};return n==="unsupported"?h.jsx("div",{className:"nc-set-info",children:S("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?S("settings-readonly"):"",onClick:p,children:S(n==="subscribed"?"push-disable":"push-enable")}),h.jsx("span",{className:"nc-set-info",children:S(n==="subscribed"?"push-on":n==="denied"?"push-denied":"push-off")})]}),u&&h.jsx("div",{className:"nc-err",children:u})]})}function ik({token:e,settings:t,readonly:n,refresh:s}){const[o,l]=M.useState(null),[u,d]=M.useState(null),[p,m]=M.useState(!1),[y,w]=M.useState(!1),[_,v]=M.useState(null),[b,k]=M.useState(!0);M.useEffect(()=>{v(t&&t.update||null),k(!t||t.autoUpdate!==!1)},[t]);const x=async()=>{l(null),d(null),w(!0);try{const z=await uw(e);d(z.note||"ok"),m(!1)}catch(z){l(String(z.message||z))}w(!1)},R=async()=>{l(null),d(null),w(!0);try{const z=await mw(e);d(`${z.note||"ok"}${z.target?` (${z.target})`:""}`)}catch(z){l(String(z.message||z))}w(!1)},j=async z=>{l(null),d(null),w(!0);try{await cv(e,{autoUpdate:z}),k(z),s&&await s()}catch($){l(String($.message||$))}w(!1)},A=async()=>{l(null),d(null),w(!0);try{v(await gw(e))}catch(z){l(String(z.message||z))}w(!1)},B=async()=>{l(null),d(null),w(!0);try{const z=await vw(e);v(z),d(S("npm-update-restarting"))}catch(z){l(String(z.message||z))}w(!1)},ie=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",{}),ie&&ie.installed?S("service-installed"):S("service-missing"),ie&&ie.installed?` · ${ie.active?S("service-active"):S("service-inactive")}`:"",ie?` · boot ${ie.boot?"on":"off"}`:""]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||y,title:n?S("settings-readonly"):"",onClick:()=>{l(null),d(null),m(!0)},children:S("token-rotate")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||y,title:n?S("settings-readonly"):"",onClick:R,children:S("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:b,disabled:n||y||_&&!_.supported,onChange:z=>j(z.target.checked)}),h.jsxs("span",{children:[h.jsx("b",{children:S("npm-auto-update")}),h.jsx("small",{children:S("npm-auto-update-help")})]})]}),_&&h.jsxs("div",{className:"nc-set-info",children:[S("npm-update-current")," v",_.current,_.latest?` · ${S("npm-update-latest")} v${_.latest}`:""," · ",S(`npm-update-${_.supported?_.phase:"unsupported"}`)]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||y||!_||!_.supported,onClick:A,children:S("npm-update-check")}),_&&_.available&&h.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||y||_.phase==="installing",onClick:B,children:S("npm-update-install")})]}),_&&_.lastError&&h.jsx("div",{className:"nc-err",children:_.lastError})]}),h.jsx(tk,{token:e,readonly:n}),p&&h.jsxs("div",{className:"nc-set-confirm",children:[h.jsx("div",{children:S("token-rotate-explain")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:y,onClick:()=>m(!1),children:S("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:y,onClick:x,children:S("confirm")})]})]}),u&&h.jsx("div",{className:"nc-set-note",children:u}),o&&h.jsx("div",{className:"nc-err",children:o})]})}function nk({token:e,onClose:t,initialTab:n="nodes",initialLocation:s="",startNewCell:o=!1}){_i();const[l,u]=M.useState(n),[d,p]=M.useState(null),[m,y]=M.useState([]),[w,_]=M.useState(!1),[v,b]=M.useState(null),k=Ih(e),x=M.useCallback(async()=>{try{const R=await ov(e);p(R),b(null)}catch(R){b(String(R.message||R))}try{const R=await av(e);y(R.nodes||[])}catch(R){b(String(R.message||R))}},[e]);return M.useEffect(()=>{x();const R=setInterval(x,5e3);return()=>clearInterval(R)},[x]),M.useEffect(()=>{let R=!1;return It("/api/config",e).then(j=>j.json()).then(j=>{R||_(!!j.readonlyDefault)}).catch(()=>{}),()=>{R=!0}},[e]),h.jsx("div",{className:"nc-set-overlay",onClick:t,children:h.jsxs("div",{className:"nc-set-panel",onClick:R=>R.stopPropagation(),children:[h.jsxs("div",{className:"nc-set-head",children:[h.jsx(Je,{name:"gear",size:18}),h.jsx("b",{children:S("settings")}),h.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:S("close"),children:h.jsx(Je,{name:"x",size:18})})]}),w&&h.jsx("div",{className:"nc-set-readonly",children:S("settings-readonly")}),v&&h.jsx("div",{className:"nc-err",children:v}),h.jsx("div",{className:"nc-set-tabs",children:["nodes","fleet","system"].map(R=>h.jsx("button",{type:"button",className:`nc-set-tabbtn${l===R?" on":""}`,onClick:()=>u(R),children:S(`tab-${R}`)},R))}),h.jsxs("div",{className:"nc-set-body",children:[l==="nodes"&&h.jsx(ek,{token:e,nodes:m,settings:d,readonly:w,refresh:x}),l==="fleet"&&h.jsx(Yx,{token:e,readonly:w,startNewCell:o,initialLocation:s,targets:k.map(R=>({route:R.route,label:R.label||R.name,status:R.status}))}),l==="system"&&h.jsx(ik,{token:e,settings:d,readonly:w,refresh:x})]})]})})}function rk({token:e,initialPair:t,onPairDone:n,onDone:s}){_i();const[o,l]=M.useState(t?"pair":"welcome"),[u,d]=M.useState(!1),[p,m]=M.useState(null),y=async()=>{d(!0),m(null);try{await cv(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:S("wizard-title")}),h.jsx("small",{children:S("hydra-simple")})]}),o==="welcome"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:S("local-ready")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:u,onClick:y,children:S("local-only")}),h.jsx("button",{className:"nc-btn primary",disabled:u,onClick:()=>l("pair"),children:S("add-node")})]})]}),o==="pair"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx(j_,{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:S("back")})})]}),o==="done"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:S("node-connected")}),h.jsx("div",{className:"nc-sheet-actions",children:h.jsx("button",{className:"nc-btn primary",disabled:u,onClick:y,children:S("finish")})})]}),p&&h.jsx("div",{className:"nc-err",children:p})]})})}function sk(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 ok=6e3,ak=12e3;function lk({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:S("close"),children:h.jsx(Je,{name:"x",size:14})})]})}function ck({ask:e,token:t,onAnswered:n}){const[s,o]=M.useState(""),[l,u]=M.useState(!1),[d,p]=M.useState(null),m=async y=>{const w=String(y||"").trim();if(!(!w||l)){p(null),u(!0);try{await yw(t,e.id,w),n(e.id)}catch(_){p(String(_.message||_))}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(y=>h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:l,onClick:()=>m(y),children:y},y))}),h.jsxs("div",{className:"nc-ask-reply",children:[h.jsx("textarea",{rows:2,placeholder:S("ask-reply-ph"),value:s,disabled:l,onChange:y=>o(y.target.value)}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:l||!s.trim(),onClick:()=>m(s),children:S("send")})]}),d&&h.jsx("div",{className:"nc-err",children:d})]})}function uk({token:e}){_i();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(_=>_.filter(v=>v.key!==w))},[]),m=M.useCallback(w=>{const _=`t${d.current+=1}`;n(v=>[...v.slice(-3),{...w,key:_}]),setTimeout(()=>p(_),w.urgency==="high"?ak:ok)},[p]);M.useEffect(()=>{if(!e)return;let w=!1;_w(e).then(v=>{w||o(v.asks||[])}).catch(()=>{});const _=sk(e,v=>{v.type==="notify"?m(v):v.type==="ask"&&v.ask&&v.ask.id?o(b=>b.some(k=>k.id===v.ask.id)?b:[...b,v.ask]):v.type==="ask-answered"&&v.id&&o(b=>b.filter(k=>k.id!==v.id))});return()=>{w=!0,_()}},[e,m]);const y=w=>o(_=>_.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(lk,{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:S("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:S("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:S("close"),children:h.jsx(Je,{name:"x",size:16})})]}),h.jsx("div",{className:"nc-ask-panel-body",children:s.map(w=>h.jsx(ck,{ask:w,token:e,onAnswered:y},w.id))})]})]})}const Lu=e=>Gi(ar(e)).length===0,Tu=e=>Array.isArray(e)?e.join("/"):"";function hk(e){const t=new Set,n=[];for(const s of Array.isArray(e)?e:[])!s||!Oi.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 $s(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function tr(e,t,n,s=!1,o=!0){const l=t.instanceId;return{...e,id:Ur(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:wh(e.layout,l,n)}}function dk(e,t,n,s,o=[]){const[l,u]=M.useState([]),[d,p]=M.useState(!1),[m,y]=M.useState("idle"),[w,_]=M.useState(""),[v,b]=M.useState(""),k=M.useRef([]),x=M.useRef([]),R=M.useRef(""),j=M.useRef(t),A=M.useRef(n),B=M.useRef(!1),ie=M.useRef(!0),z=M.useRef(""),$=M.useMemo(()=>hk(o),[o]),re=$.map(W=>`${W.instanceId}:${Tu(W.route)}:${W.status}:${W.label}`).join("|");x.current=$,A.current=n,j.current=t,k.current=l;const U=M.useCallback(W=>bh(W.layout,R.current,x.current),[]),X=M.useCallback((W,Z=!0,P=j.current)=>{const Q=k.current.some(J=>J.id===P);k.current=W,u(W);const se=W.find(J=>J.id===P);if(Z&&se){ie.current=!0;const J=U(se);s(J),se.local&&TC(se.name,J)}else Q&&!se&&(ie.current=!0,s(Wr()),_("deck non più condiviso dal nodo owner"));LC(W.filter(J=>J.local).map(J=>J.name))},[s,U]),q=M.useCallback(async W=>{let Z=await fa(e);const P=Z.decks.find(Q=>Q.name==="main");if(Z.decks.length===1&&P&&P.revision===0&&Lu(P.layout)){const Q=MC(),se=ar(Ch("main")||Wr());if(!Lu(se)){const J=wh(se,W,[]);Z.decks[0]=await pa(e,"main",J,0,[])}for(const J of Q.filter(le=>le!=="main"))try{let le=await Qp(e,J,[]);const de=ar(Ch(J)||Wr());Lu(de)||(le=await pa(e,J,wh(de,W,[]),le.revision,[]))}catch{}Z=await fa(e)}return Z},[e]),D=M.useCallback(async({migrate:W=!1}={})=>{const Z=await jh(e,[]),P=Oi.test(String(Z.instanceId||""))?Z.instanceId:"";if(!P)throw new Error("instanceId locale non disponibile");R.current=P,b(P);const[Q,se]=await Promise.all([W?q(P):fa(e),Yp(e,[]).catch(()=>({nodes:[]}))]),J={instanceId:P,route:[],label:"Local"},le=Q.decks.map(pe=>tr(pe,J,se.nodes,!0,!0)),de=k.current;return await Promise.all(x.current.map(async pe=>{if(pe.status!=="up"){le.push(...de.filter(ye=>!ye.local&&ye.ownerId===pe.instanceId).map(ye=>({...ye,ownerRoute:[...pe.route],ownerLabel:pe.label,available:!1})));return}try{const[ye,K]=await Promise.all([fa(e,pe.route),Yp(e,pe.route).catch(()=>({nodes:[]}))]);le.push(...ye.decks.map(ee=>tr(ee,pe,K.nodes,!1,!0)))}catch{le.push(...de.filter(K=>!K.local&&K.ownerId===pe.instanceId).map(K=>({...K,ownerRoute:[...pe.route],ownerLabel:pe.label,available:!1})))}})),le.sort((pe,ye)=>pe.local===ye.local?pe.ownerLabel.localeCompare(ye.ownerLabel)||(pe.name==="main"?-1:ye.name==="main"?1:pe.name.localeCompare(ye.name)):pe.local?-1:1),le},[e,q,re]);M.useEffect(()=>{if(!e)return;let W=!1;const Z=z.current!==e;return z.current=e,D({migrate:Z}).then(P=>{if(W)return;const Q=k.current.find(le=>le.id===j.current),se=P.find(le=>le.id===j.current),J=se&&(!Q||se.revision>Q.revision||Q.available!==se.available||Tu(Q.ownerRoute)!==Tu(se.ownerRoute));X(P,Z||!!J&&!B.current),p(!0),se&&_("")}).catch(P=>{W||(p(!0),_(String(P.message||P)))}),()=>{W=!0}},[X,D,re,e]);const E=M.useCallback(async(W=j.current)=>{if(!d||!B.current)return!0;const Z=k.current.find(P=>P.id===W);if(!Z)return _(`deck inesistente: ${W}`),!1;if(Z.available===!1)return _(`nodo owner offline: ${Z.ownerLabel}`),!1;y("saving");try{const P=lg(ar(A.current),Z.ownerId,Z.ownerTopology),Q=await pa(e,Z.name,P,Z.revision,Z.ownerRoute),se=tr(Q,$s(Z),Z.ownerTopology,Z.local,!0);return X(k.current.map(J=>J.id===W?se:J),!1),B.current=!1,y("saved"),_(""),setTimeout(()=>y("idle"),1500),!0}catch(P){if(y("error"),_(String(P.message||P)),P.status===409&&P.data&&P.data.current){const Q=k.current.find(J=>J.id===W),se=tr(P.data.current,$s(Q),Q.ownerTopology,Q.local,!0);X(k.current.map(J=>J.id===W?se:J),!1)}return!1}},[d,e,X]);return M.useEffect(()=>{if(!d)return;if(ie.current){ie.current=!1;return}B.current=!0,y("saving");const W=setTimeout(E,650);return()=>clearTimeout(W)},[n,d,E]),M.useEffect(()=>{if(!d)return;const W=setInterval(async()=>{try{const Z=await D(),P=k.current.find(J=>J.id===j.current),Q=Z.find(J=>J.id===j.current),se=Q&&(!P||Q.revision>P.revision||P.available!==Q.available);X(Z,se&&!B.current)}catch{}},5e3);return()=>clearInterval(W)},[d,D,X]),{decks:l,records:l,localNodeId:v,ready:d,saveState:m,error:w,setError:_,saveNow:E,select:async W=>{if(B.current&&!await E(j.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const Z=k.current.find(P=>P.id===W);if(!Z)throw new Error(`deck inesistente: ${W}`);return B.current=!1,ie.current=!0,U(Z)},add:async(W,Z=null)=>{const P=Z===qa?k.current.find(J=>J.local):Z?k.current.find(J=>J.ownerId===Z):null;if(!P||P.available===!1)throw new Error("nodo owner non disponibile");const Q=await Qp(e,W,P.ownerRoute),se=tr(Q,$s(P),P.ownerTopology,P.local,!0);return X([...k.current,se],!1),se},rename:async(W,Z)=>{const P=k.current.find(le=>le.id===W);if(!P)throw new Error("deck inesistente");if(W===j.current&&B.current&&!await E(W))throw new Error(`salvataggio di "${P.name}" fallito: rinomina annullata`);const Q=k.current.find(le=>le.id===W);if(!Q)throw new Error("deck inesistente");const se=await Sw(e,Q.name,Z,Q.revision,Q.ownerRoute),J=tr(se,$s(Q),Q.ownerTopology,Q.local,!0);return X(k.current.map(le=>le.id===W?J:le),!1),J},remove:async W=>{const Z=k.current.find(P=>P.id===W);if(!Z)throw new Error("deck inesistente");W===j.current&&(B.current=!1),await ww(e,Z.name,Z.revision,Z.ownerRoute),X(k.current.filter(P=>P.id!==W),!1)},addTileTo:async(W,Z)=>{const P=k.current.find(pe=>pe.id===W);if(!P)throw new Error("deck inesistente");if(P.available===!1)throw new Error(`nodo owner offline: ${P.ownerLabel}`);const Q=x_(Z,R.current,x.current);if(!Q)throw new Error("riferimento sessione non valido");const se=U(P),J=lg(w_(se,Q),P.ownerId,P.ownerTopology),le=await pa(e,P.name,J,P.revision,P.ownerRoute),de=tr(le,$s(P),P.ownerTopology,P.local,!0);return X(k.current.map(pe=>pe.id===W?de:pe),!1),de},localMainId:Ur(null,"main"),parseDeckId:C_}}const fk="/sw.js",kh="nc-sw-update";let Eh=null,Nh=!1,Rh=null,W_=Object.freeze({needed:!1,kind:null,version:""}),U_=!1;function K_(){typeof window<"u"&&window.dispatchEvent(new Event(kh))}function q_(){const e=Rh||(Nh?{kind:"reload",version:""}:null);W_=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function Gg(){return W_}function pk(e){return typeof window>"u"?()=>{}:(window.addEventListener(kh,e),()=>window.removeEventListener(kh,e))}function ed(e){Nh!==e&&(Nh=e,q_(),K_())}function mk(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(Rh);Rh=s,q_(),o||K_()}function gk(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&ed(!0)})}function vk(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{U_&&location.reload()}),navigator.serviceWorker.register(fk).then(e=>{Eh=e,e.waiting&&ed(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&gk(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function _k(){U_=!0,ed(!1);const e=Eh&&Eh.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function yk({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 V_=9,Y_=24,X_="nc_side_w",Qg="nc_side_min",Sk=240,Jg="(min-width:1024px) and (pointer:fine)";function wk(){const e=Number(localStorage.getItem(X_));return e>=180&&e<=480?e:Sk}function bk(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=V_&&e<=Y_?e:13}function Ck(){const e={token:"",pair:""};try{const{token:t,pair:n,nextUrl:s}=yk({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 xk(e){try{return ar(Ch(e))}catch{return Wr()}}function Zg(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 kk(){const[e,t]=M.useState(()=>window.matchMedia(Jg).matches);return M.useEffect(()=>{const n=window.matchMedia(Jg),s=o=>t(o.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),e}function ev({session:e,node:t,token:n,readonly:s=!1,onBack:o}){_i();const[l,u]=M.useState(!1),[d,p]=M.useState(()=>window.matchMedia("(pointer: coarse)").matches),[m,y]=M.useState(null),[w,_]=M.useState(bk),[v,b]=M.useState(""),k=U=>_(X=>{const q=Math.max(V_,Math.min(Y_,X+U));return localStorage.setItem("nc_fontsize",String(q)),q}),x=M.useRef(()=>{}),R=M.useRef(()=>!1),j=M.useRef(()=>{}),A=M.useRef(!1),[B,ie]=M.useState(!1),[z,$]=M.useState(!1),re=()=>{A.current=!A.current,ie(A.current)};return M.useEffect(()=>{let U=!0;const X=t?t.split("/"):[],q=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function D(){let L=null,Y=null;try{const I=await(await It(`${q}/sessions`,n)).json();Array.isArray(I.sessions)&&(L=I.sessions.find(W=>W.name===e))}catch{}try{const H=await ur(n,X);H.available&&Array.isArray(H.cells)&&(Y=H.cells.find(I=>I.tmuxSession===e))}catch{}if(!U)return;let N="";Y?N=`${Y.engine}${Y.key?`·${Y.key}`:""}`:L&&(N=L.attached?`attached · ${Zg(L.activity)}`:L.activity?Zg(L.activity):""),b(N)}D();const E=setInterval(D,4e3);return()=>{U=!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:S("sessions"),children:[h.jsx(Je,{name:"chevronLeft",size:18}),h.jsx("span",{className:"nc-bar-label",children:S("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:()=>k(-1),title:S("zoom-out"),children:h.jsx(Je,{name:"zoomOut",size:18})}),h.jsx("button",{onClick:()=>k(1),title:S("zoom-in"),children:h.jsx(Je,{name:"zoomIn",size:18})}),h.jsx("button",{onClick:()=>p(U=>!U),title:S("composer"),children:h.jsx(Je,{name:"keyboard",size:20})}),h.jsx("button",{onClick:()=>u(U=>!U),title:S("files"),children:h.jsx(Je,{name:"folder",size:20})})]})]}),h.jsx("div",{className:"nc-termwrap",children:h.jsx(m_,{session:e,node:t,token:n,readonly:s,takeSize:!0,sendRef:x,composerRef:R,actionRef:j,ctrlRef:A,setCtrlArmed:ie,onFiles:y,fontSize:w,selectionMode:z,onSelectionModeChange:$})}),h.jsx(sC,{onKeyboard:()=>p(U=>!U),send:U=>x.current(U),action:U=>j.current(U),ctrlArmed:B,onCtrl:re,selectionMode:z,onSelectionMode:$}),d&&h.jsx(v_,{submitText:U=>R.current(U),token:n,session:e,node:t}),l&&h.jsx(g_,{session:e,node:t,token:n,filesEvent:m,onClose:()=>u(!1)})]})}function Ek(){_i();const[e]=M.useState(Ck),[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=kk(),[m]=M.useState(()=>DC(typeof location<"u"?location.pathname:"/")),[y,w]=M.useState(m.id),_=y===Ur(null,gi),[v,b]=M.useState(null),k=ce=>b(Fn(ce)),[x,R]=M.useState([]),[j,A]=M.useState([]),[B,ie]=M.useState(()=>m.ownerId?Wr():xk(m.name)),[z,$]=M.useState(null),[re,U]=M.useState(null),X=ce=>U(Fn(ce)),q=Ih(t,p),D=M.useMemo(()=>(q||[]).filter(ce=>ce.instanceId).map(ce=>({instanceId:ce.instanceId,route:ce.route,label:ce.label,status:ce.status})),[q]),E=dk(t,y,B,ie,D),L=E.decks;M.useEffect(()=>{const ce=new Map;for(const xe of q||[]){const Oe=(xe.route||[xe.name]).join("/"),dt=new Set((xe.sessions||[]).map(Yt=>Yt.name));for(const Yt of xe.cells||[])!Yt.cell||!Yt.tmuxSession||Yt.cell===Yt.tmuxSession||dt.has(Yt.cell)||ce.set(`${Oe}:${Yt.cell}`,`${Oe}:${Yt.tmuxSession}`)}ie(xe=>gC(xe,ce))},[q]),M.useEffect(()=>{E.localNodeId&&ie(ce=>{const xe=bh(ce,E.localNodeId,D);return JSON.stringify(xe)===JSON.stringify(ce)?ce:xe})},[D,E.localNodeId]);const[Y,N]=M.useState(null),[H,I]=M.useState(!1),[W,Z]=M.useState(wk),[P,Q]=M.useState(!_),[se,J]=M.useState(()=>_?localStorage.getItem(Qg)==="1":!0),[le,de]=M.useState(!1),[pe,ye]=M.useState("nodes"),[K,ee]=M.useState(!1),[Re,G]=M.useState(""),ae=(ce="nodes",xe=!1,Oe="")=>{ye(ce),ee(xe),G(Oe),de(!0)},[we,O]=M.useState(!1),[ue,be]=M.useState(!1);M.useEffect(()=>{try{localStorage.setItem(X_,String(W))}catch{}},[W]),M.useEffect(()=>{try{localStorage.setItem(Qg,se?"1":"")}catch{}},[se]),M.useEffect(()=>{if(!t)return;let ce=!1;return Promise.all([ov(t),It("/api/config",t).then(xe=>xe.json())]).then(([xe,Oe])=>{ce||(be(!!Oe.readonlyDefault),(xe.firstRun===!0&&!Oe.readonlyDefault||s)&&O(!0))}).catch(()=>{}),()=>{ce=!0}},[t,s]);const Le=M.useCallback(async()=>{try{const xe=await(await It("/api/sessions",t)).json();xe.error||R(xe.sessions||[])}catch{}try{const ce=await ur(t);A(ce.available?ce.cells||[]:[])}catch{A([])}},[t]);M.useEffect(()=>{if(!p)return;Le();const ce=setInterval(Le,4e3);return()=>clearInterval(ce)},[p,Le]),M.useEffect(()=>{let ce=!1;return It("/api/config",t).then(xe=>xe.json()).then(xe=>{ce||mk(xe.version,xe.uiVersion,"0.8.13")}).catch(()=>{}),()=>{ce=!0}},[t]);const Ke=new Set([...x.map(ce=>ce.name),...q.flatMap(ce=>ce.sessions.map(xe=>xe.key))]),De=Gi(B),Qe=ce=>ie(xe=>{const Oe=x_(ce,E.localNodeId,D)||ce,dt=w_(xe,Oe);return dt===xe&&Gi(xe).length>=9&&E.setError(S("grid-full")),dt}),qe=async(ce,xe=[])=>{try{await Th(t,ce,xe)}catch{return}const Oe=xe.length?`${xe.join("/")}:${ce}`:ce;ie(dt=>Ka(dt,Oe)),Le()},Ye=async ce=>{if(!Y)return;const{cell:xe}=Y,Oe=Array.isArray(Y.route)?Y.route:[];ce.action==="up"?await Mh(t,{cell:xe,boot:!!ce.boot,...ce.engine?{engine:ce.engine}:{},...ce.model!==void 0?{model:ce.model}:{},...ce.permissionPolicy?{permissionPolicy:ce.permissionPolicy}:{}},Oe):await Ta(t,{cell:xe,boot:!!ce.boot},Oe),Le()},Ct=async ce=>{if(!(!(ce!=null&&ce.direct)||H)){I(!0);try{await Bh(t,ce.name,ce.tunnelStatus==="up"?"down":"up")}finally{I(!1)}}},ze=ce=>{const xe=L.find(Oe=>Oe.id===ce);if(!xe)return!1;try{const Oe=window.open(lu(xe,t),"_blank");return Oe&&(Oe.opener=null),!!Oe}catch{return!1}},at=async ce=>{if(!ce||ce===y)return;const xe=await E.select(ce),Oe=E.records.find(dt=>dt.id===ce);w(ce),ie(xe),$(null),U(null);try{history.replaceState(null,"",lu(Oe||ce,null))}catch{}},Be=async(ce,xe)=>{const Oe=await E.add(ce,xe);await at(Oe.id)},gt=async(ce,xe)=>{const Oe=await E.rename(ce,xe);if(ce===y){w(Oe.id),ie(bh(Oe.layout,E.localNodeId,D)),$(null),U(null);try{history.replaceState(null,"",lu(Oe,null))}catch{}}},Pi=async ce=>{await E.remove(ce),ce===y&&await at(E.localMainId)},xt=async(ce,xe)=>{!xe||xe===y||(await E.addTileTo(xe,ce),ie(Oe=>Ka(Oe,ce)))};if(!t)return h.jsxs("div",{className:"nc-auth",children:[h.jsx("p",{children:S("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)})," ",S("remember-device")]}),h.jsx("button",{onClick:()=>{(u?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const ve=h.jsxs(h.Fragment,{children:[le&&h.jsx(nk,{token:t,initialTab:pe,initialLocation:Re,startNewCell:K,onClose:()=>{de(!1),ee(!1),G("")}}),we&&h.jsx(rk,{token:t,initialPair:s,onPairDone:l,onDone:()=>O(!1)}),h.jsx(uk,{token:t})]});if(!p)return v?h.jsxs(h.Fragment,{children:[h.jsx(ev,{session:v.session,node:v.node,token:t,readonly:ue,onBack:()=>b(null)}),ve]}):h.jsxs(h.Fragment,{children:[h.jsx(jw,{onPick:k,token:t,onSettings:ae}),ve]});const Ve=_||!P;return h.jsxs("div",{className:"nc-workspace",children:[Ve&&h.jsx(uC,{sessions:x,cells:j,activeSessions:De,nodeGroups:q,onPick:X,onAddTile:Qe,onPower:N,onNodePower:Ct,onKill:qe,onNew:()=>ae("fleet",!0),onSettings:ae,width:W,collapsed:se,onResize:Z,onToggleCollapse:()=>J(ce=>!ce)}),h.jsxs("div",{className:"nc-workspace-main",children:[h.jsx(jC,{decks:L,currentDeck:y,onCreate:Be,onRename:gt,onDelete:Pi,onOpenWindow:ze,onNavigate:at,saveState:E.saveState,error:E.error,sidebarVisible:Ve,onToggleSidebar:_?null:()=>Q(ce=>!ce)}),h.jsx(xC,{layout:B,onLayoutChange:ie,token:t,readonly:ue,sessionsAlive:Ke,focusSession:z,onFocus:$,onOpenSingle:X,decks:L,currentDeck:y,onSendToDeck:xt})]}),re&&h.jsx("div",{className:"nc-single-overlay",children:h.jsx(ev,{session:re.session,node:re.node,token:t,readonly:ue,onBack:()=>U(null)})}),Y&&h.jsx(Ba,{cell:Y,token:t,route:Array.isArray(Y.route)?Y.route:[],onConfirm:Ye,onClose:()=>N(null)}),ve]})}function Nk(){_i();const e=M.useSyncExternalStore(pk,Gg,Gg);if(!e.needed)return null;const t=e.kind==="install"?S("install-version-mismatch").replace("{v}",e.version):S("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:_k,children:S("reload")})]})}vk();ew.createRoot(document.getElementById("root")).render(h.jsxs(VS.StrictMode,{children:[h.jsx(Ek,{}),h.jsx(Nk,{})]}));
|