@mmmbuto/nexuscrew 0.8.18 → 0.8.19
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 +2 -2
- package/frontend/dist/assets/{index-CyN8rOAl.js → index-DOHx885g.js} +28 -28
- package/frontend/dist/assets/{index-BkAGUEmR.css → index-kxpt4ezv.css} +1 -1
- package/frontend/dist/index.html +2 -2
- package/frontend/dist/version.json +1 -1
- package/lib/fleet/index.js +2 -1
- package/lib/server.js +15 -5
- package/lib/tmux/list.js +35 -3
- package/lib/tmux/preview.js +27 -9
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Qp;function
|
|
9
|
+
*/var Qp;function _w(){if(Qp)return Je;Qp=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),C=Symbol.iterator;function _(M){return M===null||typeof M!="object"?null:(M=C&&M[C]||M["@@iterator"],typeof M=="function"?M:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,b={};function x(M,W,oe){this.props=M,this.context=W,this.refs=b,this.updater=oe||v}x.prototype.isReactComponent={},x.prototype.setState=function(M,W){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,W,"setState")},x.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function N(){}N.prototype=x.prototype;function L(M,W,oe){this.props=M,this.context=W,this.refs=b,this.updater=oe||v}var j=L.prototype=new N;j.constructor=L,w(j,x.prototype),j.isPureReactComponent=!0;var T=Array.isArray,Q=Object.prototype.hasOwnProperty,H={current:null},I={key:!0,ref:!0,__self:!0,__source:!0};function G(M,W,oe){var ae,se={},le=null,ye=null;if(W!=null)for(ae in W.ref!==void 0&&(ye=W.ref),W.key!==void 0&&(le=""+W.key),W)Q.call(W,ae)&&!I.hasOwnProperty(ae)&&(se[ae]=W[ae]);var ce=arguments.length-2;if(ce===1)se.children=oe;else if(1<ce){for(var Y=Array(ce),ne=0;ne<ce;ne++)Y[ne]=arguments[ne+2];se.children=Y}if(M&&M.defaultProps)for(ae in ce=M.defaultProps,ce)se[ae]===void 0&&(se[ae]=ce[ae]);return{$$typeof:e,type:M,key:le,ref:ye,props:se,_owner:H.current}}function U(M,W){return{$$typeof:e,type:M.type,key:W,ref:M.ref,props:M.props,_owner:M._owner}}function q(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function X(M){var W={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(oe){return W[oe]})}var A=/\/+/g;function E(M,W){return typeof M=="object"&&M!==null&&M.key!=null?X(""+M.key):W.toString(36)}function R(M,W,oe,ae,se){var le=typeof M;(le==="undefined"||le==="boolean")&&(M=null);var ye=!1;if(M===null)ye=!0;else switch(le){case"string":case"number":ye=!0;break;case"object":switch(M.$$typeof){case e:case t:ye=!0}}if(ye)return ye=M,se=se(ye),M=ae===""?"."+E(ye,0):ae,T(se)?(oe="",M!=null&&(oe=M.replace(A,"$&/")+"/"),R(se,W,oe,"",function(ne){return ne})):se!=null&&(q(se)&&(se=U(se,oe+(!se.key||ye&&ye.key===se.key?"":(""+se.key).replace(A,"$&/")+"/")+M)),W.push(se)),1;if(ye=0,ae=ae===""?".":ae+":",T(M))for(var ce=0;ce<M.length;ce++){le=M[ce];var Y=ae+E(le,ce);ye+=R(le,W,oe,Y,se)}else if(Y=_(M),typeof Y=="function")for(M=Y.call(M),ce=0;!(le=M.next()).done;)le=le.value,Y=ae+E(le,ce++),ye+=R(le,W,oe,Y,se);else if(le==="object")throw W=String(M),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.");return ye}function F(M,W,oe){if(M==null)return M;var ae=[],se=0;return R(M,ae,"","",function(le){return W.call(oe,le,se++)}),ae}function D(M){if(M._status===-1){var W=M._result;W=W(),W.then(function(oe){(M._status===0||M._status===-1)&&(M._status=1,M._result=oe)},function(oe){(M._status===0||M._status===-1)&&(M._status=2,M._result=oe)}),M._status===-1&&(M._status=0,M._result=W)}if(M._status===1)return M._result.default;throw M._result}var O={current:null},z={transition:null},ie={ReactCurrentDispatcher:O,ReactCurrentBatchConfig:z,ReactCurrentOwner:H};function K(){throw Error("act(...) is not supported in production builds of React.")}return Je.Children={map:F,forEach:function(M,W,oe){F(M,function(){W.apply(this,arguments)},oe)},count:function(M){var W=0;return F(M,function(){W++}),W},toArray:function(M){return F(M,function(W){return W})||[]},only:function(M){if(!q(M))throw Error("React.Children.only expected to receive a single React element child.");return M}},Je.Component=x,Je.Fragment=i,Je.Profiler=o,Je.PureComponent=L,Je.StrictMode=s,Je.Suspense=m,Je.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ie,Je.act=K,Je.cloneElement=function(M,W,oe){if(M==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+M+".");var ae=w({},M.props),se=M.key,le=M.ref,ye=M._owner;if(W!=null){if(W.ref!==void 0&&(le=W.ref,ye=H.current),W.key!==void 0&&(se=""+W.key),M.type&&M.type.defaultProps)var ce=M.type.defaultProps;for(Y in W)Q.call(W,Y)&&!I.hasOwnProperty(Y)&&(ae[Y]=W[Y]===void 0&&ce!==void 0?ce[Y]:W[Y])}var Y=arguments.length-2;if(Y===1)ae.children=oe;else if(1<Y){ce=Array(Y);for(var ne=0;ne<Y;ne++)ce[ne]=arguments[ne+2];ae.children=ce}return{$$typeof:e,type:M.type,key:se,ref:le,props:ae,_owner:ye}},Je.createContext=function(M){return M={$$typeof:c,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},M.Provider={$$typeof:l,_context:M},M.Consumer=M},Je.createElement=G,Je.createFactory=function(M){var W=G.bind(null,M);return W.type=M,W},Je.createRef=function(){return{current:null}},Je.forwardRef=function(M){return{$$typeof:d,render:M}},Je.isValidElement=q,Je.lazy=function(M){return{$$typeof:S,_payload:{_status:-1,_result:M},_init:D}},Je.memo=function(M,W){return{$$typeof:p,type:M,compare:W===void 0?null:W}},Je.startTransition=function(M){var W=z.transition;z.transition={};try{M()}finally{z.transition=W}},Je.unstable_act=K,Je.useCallback=function(M,W){return O.current.useCallback(M,W)},Je.useContext=function(M){return O.current.useContext(M)},Je.useDebugValue=function(){},Je.useDeferredValue=function(M){return O.current.useDeferredValue(M)},Je.useEffect=function(M,W){return O.current.useEffect(M,W)},Je.useId=function(){return O.current.useId()},Je.useImperativeHandle=function(M,W,oe){return O.current.useImperativeHandle(M,W,oe)},Je.useInsertionEffect=function(M,W){return O.current.useInsertionEffect(M,W)},Je.useLayoutEffect=function(M,W){return O.current.useLayoutEffect(M,W)},Je.useMemo=function(M,W){return O.current.useMemo(M,W)},Je.useReducer=function(M,W,oe){return O.current.useReducer(M,W,oe)},Je.useRef=function(M){return O.current.useRef(M)},Je.useState=function(M){return O.current.useState(M)},Je.useSyncExternalStore=function(M,W,oe){return O.current.useSyncExternalStore(M,W,oe)},Je.useTransition=function(){return O.current.useTransition()},Je.version="18.3.1",Je}var Jp;function zh(){return Jp||(Jp=1,Gc.exports=_w()),Gc.exports}/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.production.min.js
|
|
12
12
|
*
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Zp;function
|
|
17
|
+
*/var Zp;function yw(){if(Zp)return Fs;Zp=1;var e=zh(),t=Symbol.for("react.element"),i=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(d,m,p){var S,C={},_=null,v=null;p!==void 0&&(_=""+p),m.key!==void 0&&(_=""+m.key),m.ref!==void 0&&(v=m.ref);for(S in m)s.call(m,S)&&!l.hasOwnProperty(S)&&(C[S]=m[S]);if(d&&d.defaultProps)for(S in m=d.defaultProps,m)C[S]===void 0&&(C[S]=m[S]);return{$$typeof:t,type:d,key:_,ref:v,props:C,_owner:o.current}}return Fs.Fragment=i,Fs.jsx=c,Fs.jsxs=c,Fs}var em;function Sw(){return em||(em=1,Xc.exports=yw()),Xc.exports}var h=Sw(),P=zh();const ww=Oh(P);var wa={},Qc={exports:{}},ai={},Jc={exports:{}},Zc={};/**
|
|
18
18
|
* @license React
|
|
19
19
|
* scheduler.production.min.js
|
|
20
20
|
*
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*
|
|
23
23
|
* This source code is licensed under the MIT license found in the
|
|
24
24
|
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/var tm;function
|
|
25
|
+
*/var tm;function bw(){return tm||(tm=1,(function(e){function t(z,ie){var K=z.length;z.push(ie);e:for(;0<K;){var M=K-1>>>1,W=z[M];if(0<o(W,ie))z[M]=ie,z[K]=W,K=M;else break e}}function i(z){return z.length===0?null:z[0]}function s(z){if(z.length===0)return null;var ie=z[0],K=z.pop();if(K!==ie){z[0]=K;e:for(var M=0,W=z.length,oe=W>>>1;M<oe;){var ae=2*(M+1)-1,se=z[ae],le=ae+1,ye=z[le];if(0>o(se,K))le<W&&0>o(ye,se)?(z[M]=ye,z[le]=K,M=le):(z[M]=se,z[ae]=K,M=ae);else if(le<W&&0>o(ye,K))z[M]=ye,z[le]=K,M=le;else break e}}return ie}function o(z,ie){var K=z.sortIndex-ie.sortIndex;return K!==0?K:z.id-ie.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var m=[],p=[],S=1,C=null,_=3,v=!1,w=!1,b=!1,x=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function j(z){for(var ie=i(p);ie!==null;){if(ie.callback===null)s(p);else if(ie.startTime<=z)s(p),ie.sortIndex=ie.expirationTime,t(m,ie);else break;ie=i(p)}}function T(z){if(b=!1,j(z),!w)if(i(m)!==null)w=!0,D(Q);else{var ie=i(p);ie!==null&&O(T,ie.startTime-z)}}function Q(z,ie){w=!1,b&&(b=!1,N(G),G=-1),v=!0;var K=_;try{for(j(ie),C=i(m);C!==null&&(!(C.expirationTime>ie)||z&&!X());){var M=C.callback;if(typeof M=="function"){C.callback=null,_=C.priorityLevel;var W=M(C.expirationTime<=ie);ie=e.unstable_now(),typeof W=="function"?C.callback=W:C===i(m)&&s(m),j(ie)}else s(m);C=i(m)}if(C!==null)var oe=!0;else{var ae=i(p);ae!==null&&O(T,ae.startTime-ie),oe=!1}return oe}finally{C=null,_=K,v=!1}}var H=!1,I=null,G=-1,U=5,q=-1;function X(){return!(e.unstable_now()-q<U)}function A(){if(I!==null){var z=e.unstable_now();q=z;var ie=!0;try{ie=I(!0,z)}finally{ie?E():(H=!1,I=null)}}else H=!1}var E;if(typeof L=="function")E=function(){L(A)};else if(typeof MessageChannel<"u"){var R=new MessageChannel,F=R.port2;R.port1.onmessage=A,E=function(){F.postMessage(null)}}else E=function(){x(A,0)};function D(z){I=z,H||(H=!0,E())}function O(z,ie){G=x(function(){z(e.unstable_now())},ie)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_continueExecution=function(){w||v||(w=!0,D(Q))},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return _},e.unstable_getFirstCallbackNode=function(){return i(m)},e.unstable_next=function(z){switch(_){case 1:case 2:case 3:var ie=3;break;default:ie=_}var K=_;_=ie;try{return z()}finally{_=K}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(z,ie){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var K=_;_=z;try{return ie()}finally{_=K}},e.unstable_scheduleCallback=function(z,ie,K){var M=e.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?M+K:M):K=M,z){case 1:var W=-1;break;case 2:W=250;break;case 5:W=1073741823;break;case 4:W=1e4;break;default:W=5e3}return W=K+W,z={id:S++,callback:ie,priorityLevel:z,startTime:K,expirationTime:W,sortIndex:-1},K>M?(z.sortIndex=K,t(p,z),i(m)===null&&z===i(p)&&(b?(N(G),G=-1):b=!0,O(T,K-M))):(z.sortIndex=W,t(m,z),w||v||(w=!0,D(Q))),z},e.unstable_shouldYield=X,e.unstable_wrapCallback=function(z){var ie=_;return function(){var K=_;_=ie;try{return z.apply(this,arguments)}finally{_=K}}}})(Zc)),Zc}var im;function Cw(){return im||(im=1,Jc.exports=bw()),Jc.exports}/**
|
|
26
26
|
* @license React
|
|
27
27
|
* react-dom.production.min.js
|
|
28
28
|
*
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
*
|
|
31
31
|
* This source code is licensed under the MIT license found in the
|
|
32
32
|
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/var nm;function
|
|
33
|
+
*/var nm;function xw(){if(nm)return ai;nm=1;var e=zh(),t=Cw();function i(n){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+n,a=1;a<arguments.length;a++)r+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+n+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,o={};function l(n,r){c(n,r),c(n+"Capture",r)}function c(n,r){for(o[n]=r,n=0;n<r.length;n++)s.add(r[n])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,p=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,S={},C={};function _(n){return m.call(C,n)?!0:m.call(S,n)?!1:p.test(n)?C[n]=!0:(S[n]=!0,!1)}function v(n,r,a,u){if(a!==null&&a.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return u?!1:a!==null?!a.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function w(n,r,a,u){if(r===null||typeof r>"u"||v(n,r,a,u))return!0;if(u)return!1;if(a!==null)switch(a.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function b(n,r,a,u,f,g,k){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=u,this.attributeNamespace=f,this.mustUseProperty=a,this.propertyName=n,this.type=r,this.sanitizeURL=g,this.removeEmptyString=k}var x={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){x[n]=new b(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var r=n[0];x[r]=new b(r,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){x[n]=new b(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){x[n]=new b(n,2,!1,n,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){x[n]=new b(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){x[n]=new b(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){x[n]=new b(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){x[n]=new b(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){x[n]=new b(n,5,!1,n.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function L(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var r=n.replace(N,L);x[r]=new b(r,1,!1,n,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var r=n.replace(N,L);x[r]=new b(r,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(n){var r=n.replace(N,L);x[r]=new b(r,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){x[n]=new b(n,1,!1,n.toLowerCase(),null,!1,!1)}),x.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){x[n]=new b(n,1,!1,n.toLowerCase(),null,!0,!0)});function j(n,r,a,u){var f=x.hasOwnProperty(r)?x[r]:null;(f!==null?f.type!==0:u||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(w(r,a,f,u)&&(a=null),u||f===null?_(r)&&(a===null?n.removeAttribute(r):n.setAttribute(r,""+a)):f.mustUseProperty?n[f.propertyName]=a===null?f.type===3?!1:"":a:(r=f.attributeName,u=f.attributeNamespace,a===null?n.removeAttribute(r):(f=f.type,a=f===3||f===4&&a===!0?"":""+a,u?n.setAttributeNS(u,r,a):n.setAttribute(r,a))))}var T=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Q=Symbol.for("react.element"),H=Symbol.for("react.portal"),I=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),U=Symbol.for("react.profiler"),q=Symbol.for("react.provider"),X=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),O=Symbol.for("react.offscreen"),z=Symbol.iterator;function ie(n){return n===null||typeof n!="object"?null:(n=z&&n[z]||n["@@iterator"],typeof n=="function"?n:null)}var K=Object.assign,M;function W(n){if(M===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);M=r&&r[1]||""}return`
|
|
34
34
|
`+M+n}var oe=!1;function ae(n,r){if(!n||oe)return"";oe=!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(re){var u=re}Reflect.construct(n,[],r)}else{try{r.call()}catch(re){u=re}n.call(r.prototype)}else{try{throw Error()}catch(re){u=re}n()}}catch(re){if(re&&u&&typeof re.stack=="string"){for(var f=re.stack.split(`
|
|
35
35
|
`),g=u.stack.split(`
|
|
36
36
|
`),k=f.length-1,B=g.length-1;1<=k&&0<=B&&f[k]!==g[B];)B--;for(;1<=k&&0<=B;k--,B--)if(f[k]!==g[B]){if(k!==1||B!==1)do if(k--,B--,0>B||f[k]!==g[B]){var $=`
|
|
37
|
-
`+f[k].replace(" at new "," at ");return n.displayName&&$.includes("<anonymous>")&&($=$.replace("<anonymous>",n.displayName)),$}while(1<=k&&0<=B);break}}}finally{oe=!1,Error.prepareStackTrace=a}return(n=n?n.displayName||n.name:"")?W(n):""}function se(n){switch(n.tag){case 5:return W(n.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return n=ae(n.type,!1),n;case 11:return n=ae(n.type.render,!1),n;case 1:return n=ae(n.type,!0),n;default:return""}}function le(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case I:return"Fragment";case H:return"Portal";case U:return"Profiler";case G:return"StrictMode";case E:return"Suspense";case R:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Y:return(n.displayName||"Context")+".Consumer";case q:return(n._context.displayName||"Context")+".Provider";case A:var r=n.render;return n=n.displayName,n||(n=r.displayName||r.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case F:return r=n.displayName||null,r!==null?r:le(n.type)||"Memo";case D:r=n._payload,n=n._init;try{return le(n(r))}catch{}}return null}function _e(n){var r=n.type;switch(n.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=r.render,n=n.displayName||n.name||"",r.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return le(r);case 8:return r===G?"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 ce(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function X(n){var r=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Z(n){var r=X(n)?"checked":"value",a=Object.getOwnPropertyDescriptor(n.constructor.prototype,r),u=""+n[r];if(!n.hasOwnProperty(r)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var f=a.get,g=a.set;return Object.defineProperty(n,r,{configurable:!0,get:function(){return f.call(this)},set:function(k){u=""+k,g.call(this,k)}}),Object.defineProperty(n,r,{enumerable:a.enumerable}),{getValue:function(){return u},setValue:function(k){u=""+k},stopTracking:function(){n._valueTracker=null,delete n[r]}}}}function je(n){n._valueTracker||(n._valueTracker=Z(n))}function Me(n){if(!n)return!1;var r=n._valueTracker;if(!r)return!0;var a=r.getValue(),u="";return n&&(u=X(n)?n.checked?"true":"false":n.value),n=u,n!==a?(r.setValue(n),!0):!1}function ye(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function ee(n,r){var a=r.checked;return K({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??n._wrapperState.initialChecked})}function Ce(n,r){var a=r.defaultValue==null?"":r.defaultValue,u=r.checked!=null?r.checked:r.defaultChecked;a=ce(r.value!=null?r.value:a),n._wrapperState={initialChecked:u,initialValue:a,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Te(n,r){r=r.checked,r!=null&&j(n,"checked",r,!1)}function xe(n,r){Te(n,r);var a=ce(r.value),u=r.type;if(a!=null)u==="number"?(a===0&&n.value===""||n.value!=a)&&(n.value=""+a):n.value!==""+a&&(n.value=""+a);else if(u==="submit"||u==="reset"){n.removeAttribute("value");return}r.hasOwnProperty("value")?te(n,r.type,a):r.hasOwnProperty("defaultValue")&&te(n,r.type,ce(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(n.defaultChecked=!!r.defaultChecked)}function qe(n,r,a){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var u=r.type;if(!(u!=="submit"&&u!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+n._wrapperState.initialValue,a||r===n.value||(n.value=r),n.defaultValue=r}a=n.name,a!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,a!==""&&(n.name=a)}function te(n,r,a){(r!=="number"||ye(n.ownerDocument)!==n)&&(a==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+a&&(n.defaultValue=""+a))}var ve=Array.isArray;function Be(n,r,a,u){if(n=n.options,r){r={};for(var f=0;f<a.length;f++)r["$"+a[f]]=!0;for(a=0;a<n.length;a++)f=r.hasOwnProperty("$"+n[a].value),n[a].selected!==f&&(n[a].selected=f),f&&u&&(n[a].defaultSelected=!0)}else{for(a=""+ce(a),r=null,f=0;f<n.length;f++){if(n[f].value===a){n[f].selected=!0,u&&(n[f].defaultSelected=!0);return}r!==null||n[f].disabled||(r=n[f])}r!==null&&(r.selected=!0)}}function Ie(n,r){if(r.dangerouslySetInnerHTML!=null)throw Error(i(91));return K({},r,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function Fe(n,r){var a=r.value;if(a==null){if(a=r.children,r=r.defaultValue,a!=null){if(r!=null)throw Error(i(92));if(ve(a)){if(1<a.length)throw Error(i(93));a=a[0]}r=a}r==null&&(r=""),a=r}n._wrapperState={initialValue:ce(a)}}function gt(n,r){var a=ce(r.value),u=ce(r.defaultValue);a!=null&&(a=""+a,a!==n.value&&(n.value=a),r.defaultValue==null&&n.defaultValue!==a&&(n.defaultValue=a)),u!=null&&(n.defaultValue=""+u)}function ge(n){var r=n.textContent;r===n._wrapperState.initialValue&&r!==""&&r!==null&&(n.value=r)}function be(n){switch(n){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ke(n,r){return n==null||n==="http://www.w3.org/1999/xhtml"?be(r):n==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var Xe,rt=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,a,u,f){MSApp.execUnsafeLocalFunction(function(){return n(r,a,u,f)})}:n})(function(n,r){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=r;else{for(Xe=Xe||document.createElement("div"),Xe.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=Xe.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;r.firstChild;)n.appendChild(r.firstChild)}});function Ve(n,r){if(r){var a=n.firstChild;if(a&&a===n.lastChild&&a.nodeType===3){a.nodeValue=r;return}}n.textContent=r}var de={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},Ke=["Webkit","ms","Moz","O"];Object.keys(de).forEach(function(n){Ke.forEach(function(r){r=r+n.charAt(0).toUpperCase()+n.substring(1),de[r]=de[n]})});function it(n,r,a){return r==null||typeof r=="boolean"||r===""?"":a||typeof r!="number"||r===0||de.hasOwnProperty(n)&&de[n]?(""+r).trim():r+"px"}function ue(n,r){n=n.style;for(var a in r)if(r.hasOwnProperty(a)){var u=a.indexOf("--")===0,f=it(a,r[a],u);a==="float"&&(a="cssFloat"),u?n.setProperty(a,f):n[a]=f}}var De=K({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 Ue(n,r){if(r){if(De[n]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(i(137,n));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(i(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(i(61))}if(r.style!=null&&typeof r.style!="object")throw Error(i(62))}}function Mt(n,r){if(n.indexOf("-")===-1)return typeof r.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var hi=null;function ul(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var hl=null,gr=null,vr=null;function fd(n){if(n=ks(n)){if(typeof hl!="function")throw Error(i(280));var r=n.stateNode;r&&(r=Bo(r),hl(n.stateNode,n.type,r))}}function pd(n){gr?vr?vr.push(n):vr=[n]:gr=n}function md(){if(gr){var n=gr,r=vr;if(vr=gr=null,fd(n),r)for(n=0;n<r.length;n++)fd(r[n])}}function gd(n,r){return n(r)}function vd(){}var dl=!1;function _d(n,r,a){if(dl)return n(r,a);dl=!0;try{return gd(n,r,a)}finally{dl=!1,(gr!==null||vr!==null)&&(vd(),md())}}function rs(n,r){var a=n.stateNode;if(a===null)return null;var u=Bo(a);if(u===null)return null;a=u[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":(u=!u.disabled)||(n=n.type,u=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!u;break e;default:n=!1}if(n)return null;if(a&&typeof a!="function")throw Error(i(231,r,typeof a));return a}var fl=!1;if(d)try{var ss={};Object.defineProperty(ss,"passive",{get:function(){fl=!0}}),window.addEventListener("test",ss,ss),window.removeEventListener("test",ss,ss)}catch{fl=!1}function by(n,r,a,u,f,g,k,B,$){var re=Array.prototype.slice.call(arguments,3);try{r.apply(a,re)}catch(pe){this.onError(pe)}}var os=!1,po=null,mo=!1,pl=null,Cy={onError:function(n){os=!0,po=n}};function xy(n,r,a,u,f,g,k,B,$){os=!1,po=null,by.apply(Cy,arguments)}function ky(n,r,a,u,f,g,k,B,$){if(xy.apply(this,arguments),os){if(os){var re=po;os=!1,po=null}else throw Error(i(198));mo||(mo=!0,pl=re)}}function $n(n){var r=n,a=n;if(n.alternate)for(;r.return;)r=r.return;else{n=r;do r=n,(r.flags&4098)!==0&&(a=r.return),n=r.return;while(n)}return r.tag===3?a:null}function yd(n){if(n.tag===13){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function Sd(n){if($n(n)!==n)throw Error(i(188))}function Ey(n){var r=n.alternate;if(!r){if(r=$n(n),r===null)throw Error(i(188));return r!==n?null:n}for(var a=n,u=r;;){var f=a.return;if(f===null)break;var g=f.alternate;if(g===null){if(u=f.return,u!==null){a=u;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===a)return Sd(f),n;if(g===u)return Sd(f),r;g=g.sibling}throw Error(i(188))}if(a.return!==u.return)a=f,u=g;else{for(var k=!1,B=f.child;B;){if(B===a){k=!0,a=f,u=g;break}if(B===u){k=!0,u=f,a=g;break}B=B.sibling}if(!k){for(B=g.child;B;){if(B===a){k=!0,a=g,u=f;break}if(B===u){k=!0,u=g,a=f;break}B=B.sibling}if(!k)throw Error(i(189))}}if(a.alternate!==u)throw Error(i(190))}if(a.tag!==3)throw Error(i(188));return a.stateNode.current===a?n:r}function wd(n){return n=Ey(n),n!==null?bd(n):null}function bd(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var r=bd(n);if(r!==null)return r;n=n.sibling}return null}var Cd=t.unstable_scheduleCallback,xd=t.unstable_cancelCallback,Ny=t.unstable_shouldYield,Ry=t.unstable_requestPaint,St=t.unstable_now,Py=t.unstable_getCurrentPriorityLevel,ml=t.unstable_ImmediatePriority,kd=t.unstable_UserBlockingPriority,go=t.unstable_NormalPriority,Dy=t.unstable_LowPriority,Ed=t.unstable_IdlePriority,vo=null,Fi=null;function My(n){if(Fi&&typeof Fi.onCommitFiberRoot=="function")try{Fi.onCommitFiberRoot(vo,n,void 0,(n.current.flags&128)===128)}catch{}}var Li=Math.clz32?Math.clz32:Ty,Ly=Math.log,jy=Math.LN2;function Ty(n){return n>>>=0,n===0?32:31-(Ly(n)/jy|0)|0}var _o=64,yo=4194304;function as(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function So(n,r){var a=n.pendingLanes;if(a===0)return 0;var u=0,f=n.suspendedLanes,g=n.pingedLanes,k=a&268435455;if(k!==0){var B=k&~f;B!==0?u=as(B):(g&=k,g!==0&&(u=as(g)))}else k=a&~f,k!==0?u=as(k):g!==0&&(u=as(g));if(u===0)return 0;if(r!==0&&r!==u&&(r&f)===0&&(f=u&-u,g=r&-r,f>=g||f===16&&(g&4194240)!==0))return r;if((u&4)!==0&&(u|=a&16),r=n.entangledLanes,r!==0)for(n=n.entanglements,r&=u;0<r;)a=31-Li(r),f=1<<a,u|=n[a],r&=~f;return u}function Ay(n,r){switch(n){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function By(n,r){for(var a=n.suspendedLanes,u=n.pingedLanes,f=n.expirationTimes,g=n.pendingLanes;0<g;){var k=31-Li(g),B=1<<k,$=f[k];$===-1?((B&a)===0||(B&u)!==0)&&(f[k]=Ay(B,r)):$<=r&&(n.expiredLanes|=B),g&=~B}}function gl(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function Nd(){var n=_o;return _o<<=1,(_o&4194240)===0&&(_o=64),n}function vl(n){for(var r=[],a=0;31>a;a++)r.push(n);return r}function ls(n,r,a){n.pendingLanes|=r,r!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,r=31-Li(r),n[r]=a}function Iy(n,r){var a=n.pendingLanes&~r;n.pendingLanes=r,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=r,n.mutableReadLanes&=r,n.entangledLanes&=r,r=n.entanglements;var u=n.eventTimes;for(n=n.expirationTimes;0<a;){var f=31-Li(a),g=1<<f;r[f]=0,u[f]=-1,n[f]=-1,a&=~g}}function _l(n,r){var a=n.entangledLanes|=r;for(n=n.entanglements;a;){var u=31-Li(a),f=1<<u;f&r|n[u]&r&&(n[u]|=r),a&=~f}}var nt=0;function Rd(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var Pd,yl,Dd,Md,Ld,Sl=!1,wo=[],pn=null,mn=null,gn=null,cs=new Map,us=new Map,vn=[],Oy="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 jd(n,r){switch(n){case"focusin":case"focusout":pn=null;break;case"dragenter":case"dragleave":mn=null;break;case"mouseover":case"mouseout":gn=null;break;case"pointerover":case"pointerout":cs.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":us.delete(r.pointerId)}}function hs(n,r,a,u,f,g){return n===null||n.nativeEvent!==g?(n={blockedOn:r,domEventName:a,eventSystemFlags:u,nativeEvent:g,targetContainers:[f]},r!==null&&(r=ks(r),r!==null&&yl(r)),n):(n.eventSystemFlags|=u,r=n.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),n)}function zy(n,r,a,u,f){switch(r){case"focusin":return pn=hs(pn,n,r,a,u,f),!0;case"dragenter":return mn=hs(mn,n,r,a,u,f),!0;case"mouseover":return gn=hs(gn,n,r,a,u,f),!0;case"pointerover":var g=f.pointerId;return cs.set(g,hs(cs.get(g)||null,n,r,a,u,f)),!0;case"gotpointercapture":return g=f.pointerId,us.set(g,hs(us.get(g)||null,n,r,a,u,f)),!0}return!1}function Td(n){var r=Wn(n.target);if(r!==null){var a=$n(r);if(a!==null){if(r=a.tag,r===13){if(r=yd(a),r!==null){n.blockedOn=r,Ld(n.priority,function(){Dd(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){n.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}n.blockedOn=null}function bo(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var a=bl(n.domEventName,n.eventSystemFlags,r[0],n.nativeEvent);if(a===null){a=n.nativeEvent;var u=new a.constructor(a.type,a);hi=u,a.target.dispatchEvent(u),hi=null}else return r=ks(a),r!==null&&yl(r),n.blockedOn=a,!1;r.shift()}return!0}function Ad(n,r,a){bo(n)&&a.delete(r)}function Fy(){Sl=!1,pn!==null&&bo(pn)&&(pn=null),mn!==null&&bo(mn)&&(mn=null),gn!==null&&bo(gn)&&(gn=null),cs.forEach(Ad),us.forEach(Ad)}function ds(n,r){n.blockedOn===r&&(n.blockedOn=null,Sl||(Sl=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Fy)))}function fs(n){function r(f){return ds(f,n)}if(0<wo.length){ds(wo[0],n);for(var a=1;a<wo.length;a++){var u=wo[a];u.blockedOn===n&&(u.blockedOn=null)}}for(pn!==null&&ds(pn,n),mn!==null&&ds(mn,n),gn!==null&&ds(gn,n),cs.forEach(r),us.forEach(r),a=0;a<vn.length;a++)u=vn[a],u.blockedOn===n&&(u.blockedOn=null);for(;0<vn.length&&(a=vn[0],a.blockedOn===null);)Td(a),a.blockedOn===null&&vn.shift()}var _r=T.ReactCurrentBatchConfig,Co=!0;function Hy(n,r,a,u){var f=nt,g=_r.transition;_r.transition=null;try{nt=1,wl(n,r,a,u)}finally{nt=f,_r.transition=g}}function $y(n,r,a,u){var f=nt,g=_r.transition;_r.transition=null;try{nt=4,wl(n,r,a,u)}finally{nt=f,_r.transition=g}}function wl(n,r,a,u){if(Co){var f=bl(n,r,a,u);if(f===null)zl(n,r,u,xo,a),jd(n,u);else if(zy(f,n,r,a,u))u.stopPropagation();else if(jd(n,u),r&4&&-1<Oy.indexOf(n)){for(;f!==null;){var g=ks(f);if(g!==null&&Pd(g),g=bl(n,r,a,u),g===null&&zl(n,r,u,xo,a),g===f)break;f=g}f!==null&&u.stopPropagation()}else zl(n,r,u,null,a)}}var xo=null;function bl(n,r,a,u){if(xo=null,n=ul(u),n=Wn(n),n!==null)if(r=$n(n),r===null)n=null;else if(a=r.tag,a===13){if(n=yd(r),n!==null)return n;n=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;n=null}else r!==n&&(n=null);return xo=n,null}function Bd(n){switch(n){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Py()){case ml:return 1;case kd:return 4;case go:case Dy:return 16;case Ed:return 536870912;default:return 16}default:return 16}}var _n=null,Cl=null,ko=null;function Id(){if(ko)return ko;var n,r=Cl,a=r.length,u,f="value"in _n?_n.value:_n.textContent,g=f.length;for(n=0;n<a&&r[n]===f[n];n++);var k=a-n;for(u=1;u<=k&&r[a-u]===f[g-u];u++);return ko=f.slice(n,1<u?1-u:void 0)}function Eo(n){var r=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&r===13&&(n=13)):n=r,n===10&&(n=13),32<=n||n===13?n:0}function No(){return!0}function Od(){return!1}function di(n){function r(a,u,f,g,k){this._reactName=a,this._targetInst=f,this.type=u,this.nativeEvent=g,this.target=k,this.currentTarget=null;for(var B in n)n.hasOwnProperty(B)&&(a=n[B],this[B]=a?a(g):g[B]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?No:Od,this.isPropagationStopped=Od,this}return K(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=No)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=No)},persist:function(){},isPersistent:No}),r}var yr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},xl=di(yr),ps=K({},yr,{view:0,detail:0}),Wy=di(ps),kl,El,ms,Ro=K({},ps,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Rl,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==ms&&(ms&&n.type==="mousemove"?(kl=n.screenX-ms.screenX,El=n.screenY-ms.screenY):El=kl=0,ms=n),kl)},movementY:function(n){return"movementY"in n?n.movementY:El}}),zd=di(Ro),Uy=K({},Ro,{dataTransfer:0}),Ky=di(Uy),qy=K({},ps,{relatedTarget:0}),Nl=di(qy),Vy=K({},yr,{animationName:0,elapsedTime:0,pseudoElement:0}),Yy=di(Vy),Xy=K({},yr,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),Gy=di(Xy),Qy=K({},yr,{data:0}),Fd=di(Qy),Jy={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Zy={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"},eS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function tS(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=eS[n])?!!r[n]:!1}function Rl(){return tS}var iS=K({},ps,{key:function(n){if(n.key){var r=Jy[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=Eo(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?Zy[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Rl,charCode:function(n){return n.type==="keypress"?Eo(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Eo(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),nS=di(iS),rS=K({},Ro,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Hd=di(rS),sS=K({},ps,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Rl}),oS=di(sS),aS=K({},yr,{propertyName:0,elapsedTime:0,pseudoElement:0}),lS=di(aS),cS=K({},Ro,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),uS=di(cS),hS=[9,13,27,32],Pl=d&&"CompositionEvent"in window,gs=null;d&&"documentMode"in document&&(gs=document.documentMode);var dS=d&&"TextEvent"in window&&!gs,$d=d&&(!Pl||gs&&8<gs&&11>=gs),Wd=" ",Ud=!1;function Kd(n,r){switch(n){case"keyup":return hS.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function qd(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Sr=!1;function fS(n,r){switch(n){case"compositionend":return qd(r);case"keypress":return r.which!==32?null:(Ud=!0,Wd);case"textInput":return n=r.data,n===Wd&&Ud?null:n;default:return null}}function pS(n,r){if(Sr)return n==="compositionend"||!Pl&&Kd(n,r)?(n=Id(),ko=Cl=_n=null,Sr=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return $d&&r.locale!=="ko"?null:r.data;default:return null}}var mS={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Vd(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!mS[n.type]:r==="textarea"}function Yd(n,r,a,u){pd(u),r=jo(r,"onChange"),0<r.length&&(a=new xl("onChange","change",null,a,u),n.push({event:a,listeners:r}))}var vs=null,_s=null;function gS(n){ff(n,0)}function Po(n){var r=kr(n);if(Me(r))return n}function vS(n,r){if(n==="change")return r}var Xd=!1;if(d){var Dl;if(d){var Ml="oninput"in document;if(!Ml){var Gd=document.createElement("div");Gd.setAttribute("oninput","return;"),Ml=typeof Gd.oninput=="function"}Dl=Ml}else Dl=!1;Xd=Dl&&(!document.documentMode||9<document.documentMode)}function Qd(){vs&&(vs.detachEvent("onpropertychange",Jd),_s=vs=null)}function Jd(n){if(n.propertyName==="value"&&Po(_s)){var r=[];Yd(r,_s,n,ul(n)),_d(gS,r)}}function _S(n,r,a){n==="focusin"?(Qd(),vs=r,_s=a,vs.attachEvent("onpropertychange",Jd)):n==="focusout"&&Qd()}function yS(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Po(_s)}function SS(n,r){if(n==="click")return Po(r)}function wS(n,r){if(n==="input"||n==="change")return Po(r)}function bS(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var ji=typeof Object.is=="function"?Object.is:bS;function ys(n,r){if(ji(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;var a=Object.keys(n),u=Object.keys(r);if(a.length!==u.length)return!1;for(u=0;u<a.length;u++){var f=a[u];if(!m.call(r,f)||!ji(n[f],r[f]))return!1}return!0}function Zd(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function ef(n,r){var a=Zd(n);n=0;for(var u;a;){if(a.nodeType===3){if(u=n+a.textContent.length,n<=r&&u>=r)return{node:a,offset:r-n};n=u}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Zd(a)}}function tf(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?tf(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function nf(){for(var n=window,r=ye();r instanceof n.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)n=r.contentWindow;else break;r=ye(n.document)}return r}function Ll(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r&&(r==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||r==="textarea"||n.contentEditable==="true")}function CS(n){var r=nf(),a=n.focusedElem,u=n.selectionRange;if(r!==a&&a&&a.ownerDocument&&tf(a.ownerDocument.documentElement,a)){if(u!==null&&Ll(a)){if(r=u.start,n=u.end,n===void 0&&(n=r),"selectionStart"in a)a.selectionStart=r,a.selectionEnd=Math.min(n,a.value.length);else if(n=(r=a.ownerDocument||document)&&r.defaultView||window,n.getSelection){n=n.getSelection();var f=a.textContent.length,g=Math.min(u.start,f);u=u.end===void 0?g:Math.min(u.end,f),!n.extend&&g>u&&(f=u,u=g,g=f),f=ef(a,g);var k=ef(a,u);f&&k&&(n.rangeCount!==1||n.anchorNode!==f.node||n.anchorOffset!==f.offset||n.focusNode!==k.node||n.focusOffset!==k.offset)&&(r=r.createRange(),r.setStart(f.node,f.offset),n.removeAllRanges(),g>u?(n.addRange(r),n.extend(k.node,k.offset)):(r.setEnd(k.node,k.offset),n.addRange(r)))}}for(r=[],n=a;n=n.parentNode;)n.nodeType===1&&r.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<r.length;a++)n=r[a],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var xS=d&&"documentMode"in document&&11>=document.documentMode,wr=null,jl=null,Ss=null,Tl=!1;function rf(n,r,a){var u=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Tl||wr==null||wr!==ye(u)||(u=wr,"selectionStart"in u&&Ll(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),Ss&&ys(Ss,u)||(Ss=u,u=jo(jl,"onSelect"),0<u.length&&(r=new xl("onSelect","select",null,r,a),n.push({event:r,listeners:u}),r.target=wr)))}function Do(n,r){var a={};return a[n.toLowerCase()]=r.toLowerCase(),a["Webkit"+n]="webkit"+r,a["Moz"+n]="moz"+r,a}var br={animationend:Do("Animation","AnimationEnd"),animationiteration:Do("Animation","AnimationIteration"),animationstart:Do("Animation","AnimationStart"),transitionend:Do("Transition","TransitionEnd")},Al={},sf={};d&&(sf=document.createElement("div").style,"AnimationEvent"in window||(delete br.animationend.animation,delete br.animationiteration.animation,delete br.animationstart.animation),"TransitionEvent"in window||delete br.transitionend.transition);function Mo(n){if(Al[n])return Al[n];if(!br[n])return n;var r=br[n],a;for(a in r)if(r.hasOwnProperty(a)&&a in sf)return Al[n]=r[a];return n}var of=Mo("animationend"),af=Mo("animationiteration"),lf=Mo("animationstart"),cf=Mo("transitionend"),uf=new Map,hf="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 yn(n,r){uf.set(n,r),l(r,[n])}for(var Bl=0;Bl<hf.length;Bl++){var Il=hf[Bl],kS=Il.toLowerCase(),ES=Il[0].toUpperCase()+Il.slice(1);yn(kS,"on"+ES)}yn(of,"onAnimationEnd"),yn(af,"onAnimationIteration"),yn(lf,"onAnimationStart"),yn("dblclick","onDoubleClick"),yn("focusin","onFocus"),yn("focusout","onBlur"),yn(cf,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("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 ws="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),NS=new Set("cancel close invalid load scroll toggle".split(" ").concat(ws));function df(n,r,a){var u=n.type||"unknown-event";n.currentTarget=a,ky(u,r,void 0,n),n.currentTarget=null}function ff(n,r){r=(r&4)!==0;for(var a=0;a<n.length;a++){var u=n[a],f=u.event;u=u.listeners;e:{var g=void 0;if(r)for(var k=u.length-1;0<=k;k--){var B=u[k],$=B.instance,re=B.currentTarget;if(B=B.listener,$!==g&&f.isPropagationStopped())break e;df(f,B,re),g=$}else for(k=0;k<u.length;k++){if(B=u[k],$=B.instance,re=B.currentTarget,B=B.listener,$!==g&&f.isPropagationStopped())break e;df(f,B,re),g=$}}}if(mo)throw n=pl,mo=!1,pl=null,n}function at(n,r){var a=r[Kl];a===void 0&&(a=r[Kl]=new Set);var u=n+"__bubble";a.has(u)||(pf(r,n,2,!1),a.add(u))}function Ol(n,r,a){var u=0;r&&(u|=4),pf(a,n,u,r)}var Lo="_reactListening"+Math.random().toString(36).slice(2);function bs(n){if(!n[Lo]){n[Lo]=!0,s.forEach(function(a){a!=="selectionchange"&&(NS.has(a)||Ol(a,!1,n),Ol(a,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Lo]||(r[Lo]=!0,Ol("selectionchange",!1,r))}}function pf(n,r,a,u){switch(Bd(r)){case 1:var f=Hy;break;case 4:f=$y;break;default:f=wl}a=f.bind(null,r,a,n),f=void 0,!fl||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),u?f!==void 0?n.addEventListener(r,a,{capture:!0,passive:f}):n.addEventListener(r,a,!0):f!==void 0?n.addEventListener(r,a,{passive:f}):n.addEventListener(r,a,!1)}function zl(n,r,a,u,f){var g=u;if((r&1)===0&&(r&2)===0&&u!==null)e:for(;;){if(u===null)return;var k=u.tag;if(k===3||k===4){var B=u.stateNode.containerInfo;if(B===f||B.nodeType===8&&B.parentNode===f)break;if(k===4)for(k=u.return;k!==null;){var $=k.tag;if(($===3||$===4)&&($=k.stateNode.containerInfo,$===f||$.nodeType===8&&$.parentNode===f))return;k=k.return}for(;B!==null;){if(k=Wn(B),k===null)return;if($=k.tag,$===5||$===6){u=g=k;continue e}B=B.parentNode}}u=u.return}_d(function(){var re=g,pe=ul(a),me=[];e:{var fe=uf.get(n);if(fe!==void 0){var Ne=xl,Pe=n;switch(n){case"keypress":if(Eo(a)===0)break e;case"keydown":case"keyup":Ne=nS;break;case"focusin":Pe="focus",Ne=Nl;break;case"focusout":Pe="blur",Ne=Nl;break;case"beforeblur":case"afterblur":Ne=Nl;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":Ne=zd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ne=Ky;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ne=oS;break;case of:case af:case lf:Ne=Yy;break;case cf:Ne=lS;break;case"scroll":Ne=Wy;break;case"wheel":Ne=uS;break;case"copy":case"cut":case"paste":Ne=Gy;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ne=Hd}var Le=(r&4)!==0,wt=!Le&&n==="scroll",J=Le?fe!==null?fe+"Capture":null:fe;Le=[];for(var V=re,ie;V!==null;){ie=V;var Se=ie.stateNode;if(ie.tag===5&&Se!==null&&(ie=Se,J!==null&&(Se=rs(V,J),Se!=null&&Le.push(Cs(V,Se,ie)))),wt)break;V=V.return}0<Le.length&&(fe=new Ne(fe,Pe,null,a,pe),me.push({event:fe,listeners:Le}))}}if((r&7)===0){e:{if(fe=n==="mouseover"||n==="pointerover",Ne=n==="mouseout"||n==="pointerout",fe&&a!==hi&&(Pe=a.relatedTarget||a.fromElement)&&(Wn(Pe)||Pe[en]))break e;if((Ne||fe)&&(fe=pe.window===pe?pe:(fe=pe.ownerDocument)?fe.defaultView||fe.parentWindow:window,Ne?(Pe=a.relatedTarget||a.toElement,Ne=re,Pe=Pe?Wn(Pe):null,Pe!==null&&(wt=$n(Pe),Pe!==wt||Pe.tag!==5&&Pe.tag!==6)&&(Pe=null)):(Ne=null,Pe=re),Ne!==Pe)){if(Le=zd,Se="onMouseLeave",J="onMouseEnter",V="mouse",(n==="pointerout"||n==="pointerover")&&(Le=Hd,Se="onPointerLeave",J="onPointerEnter",V="pointer"),wt=Ne==null?fe:kr(Ne),ie=Pe==null?fe:kr(Pe),fe=new Le(Se,V+"leave",Ne,a,pe),fe.target=wt,fe.relatedTarget=ie,Se=null,Wn(pe)===re&&(Le=new Le(J,V+"enter",Pe,a,pe),Le.target=ie,Le.relatedTarget=wt,Se=Le),wt=Se,Ne&&Pe)t:{for(Le=Ne,J=Pe,V=0,ie=Le;ie;ie=Cr(ie))V++;for(ie=0,Se=J;Se;Se=Cr(Se))ie++;for(;0<V-ie;)Le=Cr(Le),V--;for(;0<ie-V;)J=Cr(J),ie--;for(;V--;){if(Le===J||J!==null&&Le===J.alternate)break t;Le=Cr(Le),J=Cr(J)}Le=null}else Le=null;Ne!==null&&mf(me,fe,Ne,Le,!1),Pe!==null&&wt!==null&&mf(me,wt,Pe,Le,!0)}}e:{if(fe=re?kr(re):window,Ne=fe.nodeName&&fe.nodeName.toLowerCase(),Ne==="select"||Ne==="input"&&fe.type==="file")var Ae=vS;else if(Vd(fe))if(Xd)Ae=wS;else{Ae=yS;var Oe=_S}else(Ne=fe.nodeName)&&Ne.toLowerCase()==="input"&&(fe.type==="checkbox"||fe.type==="radio")&&(Ae=SS);if(Ae&&(Ae=Ae(n,re))){Yd(me,Ae,a,pe);break e}Oe&&Oe(n,fe,re),n==="focusout"&&(Oe=fe._wrapperState)&&Oe.controlled&&fe.type==="number"&&te(fe,"number",fe.value)}switch(Oe=re?kr(re):window,n){case"focusin":(Vd(Oe)||Oe.contentEditable==="true")&&(wr=Oe,jl=re,Ss=null);break;case"focusout":Ss=jl=wr=null;break;case"mousedown":Tl=!0;break;case"contextmenu":case"mouseup":case"dragend":Tl=!1,rf(me,a,pe);break;case"selectionchange":if(xS)break;case"keydown":case"keyup":rf(me,a,pe)}var ze;if(Pl)e:{switch(n){case"compositionstart":var He="onCompositionStart";break e;case"compositionend":He="onCompositionEnd";break e;case"compositionupdate":He="onCompositionUpdate";break e}He=void 0}else Sr?Kd(n,a)&&(He="onCompositionEnd"):n==="keydown"&&a.keyCode===229&&(He="onCompositionStart");He&&($d&&a.locale!=="ko"&&(Sr||He!=="onCompositionStart"?He==="onCompositionEnd"&&Sr&&(ze=Id()):(_n=pe,Cl="value"in _n?_n.value:_n.textContent,Sr=!0)),Oe=jo(re,He),0<Oe.length&&(He=new Fd(He,n,null,a,pe),me.push({event:He,listeners:Oe}),ze?He.data=ze:(ze=qd(a),ze!==null&&(He.data=ze)))),(ze=dS?fS(n,a):pS(n,a))&&(re=jo(re,"onBeforeInput"),0<re.length&&(pe=new Fd("onBeforeInput","beforeinput",null,a,pe),me.push({event:pe,listeners:re}),pe.data=ze))}ff(me,r)})}function Cs(n,r,a){return{instance:n,listener:r,currentTarget:a}}function jo(n,r){for(var a=r+"Capture",u=[];n!==null;){var f=n,g=f.stateNode;f.tag===5&&g!==null&&(f=g,g=rs(n,a),g!=null&&u.unshift(Cs(n,g,f)),g=rs(n,r),g!=null&&u.push(Cs(n,g,f))),n=n.return}return u}function Cr(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function mf(n,r,a,u,f){for(var g=r._reactName,k=[];a!==null&&a!==u;){var B=a,$=B.alternate,re=B.stateNode;if($!==null&&$===u)break;B.tag===5&&re!==null&&(B=re,f?($=rs(a,g),$!=null&&k.unshift(Cs(a,$,B))):f||($=rs(a,g),$!=null&&k.push(Cs(a,$,B)))),a=a.return}k.length!==0&&n.push({event:r,listeners:k})}var RS=/\r\n?/g,PS=/\u0000|\uFFFD/g;function gf(n){return(typeof n=="string"?n:""+n).replace(RS,`
|
|
38
|
-
`).replace(PS,"")}function To(n,r,a){if(r=gf(r),gf(n)!==r&&a)throw Error(i(425))}function Ao(){}var Fl=null,Hl=null;function $l(n,r){return n==="textarea"||n==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Wl=typeof setTimeout=="function"?setTimeout:void 0,DS=typeof clearTimeout=="function"?clearTimeout:void 0,vf=typeof Promise=="function"?Promise:void 0,MS=typeof queueMicrotask=="function"?queueMicrotask:typeof vf<"u"?function(n){return vf.resolve(null).then(n).catch(LS)}:Wl;function LS(n){setTimeout(function(){throw n})}function Ul(n,r){var a=r,u=0;do{var f=a.nextSibling;if(n.removeChild(a),f&&f.nodeType===8)if(a=f.data,a==="/$"){if(u===0){n.removeChild(f),fs(r);return}u--}else a!=="$"&&a!=="$?"&&a!=="$!"||u++;a=f}while(a);fs(r)}function Sn(n){for(;n!=null;n=n.nextSibling){var r=n.nodeType;if(r===1||r===3)break;if(r===8){if(r=n.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return n}function _f(n){n=n.previousSibling;for(var r=0;n;){if(n.nodeType===8){var a=n.data;if(a==="$"||a==="$!"||a==="$?"){if(r===0)return n;r--}else a==="/$"&&r++}n=n.previousSibling}return null}var xr=Math.random().toString(36).slice(2),Hi="__reactFiber$"+xr,xs="__reactProps$"+xr,en="__reactContainer$"+xr,Kl="__reactEvents$"+xr,jS="__reactListeners$"+xr,TS="__reactHandles$"+xr;function Wn(n){var r=n[Hi];if(r)return r;for(var a=n.parentNode;a;){if(r=a[en]||a[Hi]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(n=_f(n);n!==null;){if(a=n[Hi])return a;n=_f(n)}return r}n=a,a=n.parentNode}return null}function ks(n){return n=n[Hi]||n[en],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function kr(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(i(33))}function Bo(n){return n[xs]||null}var ql=[],Er=-1;function wn(n){return{current:n}}function lt(n){0>Er||(n.current=ql[Er],ql[Er]=null,Er--)}function ot(n,r){Er++,ql[Er]=n.current,n.current=r}var bn={},qt=wn(bn),ii=wn(!1),Un=bn;function Nr(n,r){var a=n.type.contextTypes;if(!a)return bn;var u=n.stateNode;if(u&&u.__reactInternalMemoizedUnmaskedChildContext===r)return u.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in a)f[g]=r[g];return u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=r,n.__reactInternalMemoizedMaskedChildContext=f),f}function ni(n){return n=n.childContextTypes,n!=null}function Io(){lt(ii),lt(qt)}function yf(n,r,a){if(qt.current!==bn)throw Error(i(168));ot(qt,r),ot(ii,a)}function Sf(n,r,a){var u=n.stateNode;if(r=r.childContextTypes,typeof u.getChildContext!="function")return a;u=u.getChildContext();for(var f in u)if(!(f in r))throw Error(i(108,_e(n)||"Unknown",f));return K({},a,u)}function Oo(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||bn,Un=qt.current,ot(qt,n),ot(ii,ii.current),!0}function wf(n,r,a){var u=n.stateNode;if(!u)throw Error(i(169));a?(n=Sf(n,r,Un),u.__reactInternalMemoizedMergedChildContext=n,lt(ii),lt(qt),ot(qt,n)):lt(ii),ot(ii,a)}var tn=null,zo=!1,Vl=!1;function bf(n){tn===null?tn=[n]:tn.push(n)}function AS(n){zo=!0,bf(n)}function Cn(){if(!Vl&&tn!==null){Vl=!0;var n=0,r=nt;try{var a=tn;for(nt=1;n<a.length;n++){var u=a[n];do u=u(!0);while(u!==null)}tn=null,zo=!1}catch(f){throw tn!==null&&(tn=tn.slice(n+1)),Cd(ml,Cn),f}finally{nt=r,Vl=!1}}return null}var Rr=[],Pr=0,Fo=null,Ho=0,wi=[],bi=0,Kn=null,nn=1,rn="";function qn(n,r){Rr[Pr++]=Ho,Rr[Pr++]=Fo,Fo=n,Ho=r}function Cf(n,r,a){wi[bi++]=nn,wi[bi++]=rn,wi[bi++]=Kn,Kn=n;var u=nn;n=rn;var f=32-Li(u)-1;u&=~(1<<f),a+=1;var g=32-Li(r)+f;if(30<g){var k=f-f%5;g=(u&(1<<k)-1).toString(32),u>>=k,f-=k,nn=1<<32-Li(r)+f|a<<f|u,rn=g+n}else nn=1<<g|a<<f|u,rn=n}function Yl(n){n.return!==null&&(qn(n,1),Cf(n,1,0))}function Xl(n){for(;n===Fo;)Fo=Rr[--Pr],Rr[Pr]=null,Ho=Rr[--Pr],Rr[Pr]=null;for(;n===Kn;)Kn=wi[--bi],wi[bi]=null,rn=wi[--bi],wi[bi]=null,nn=wi[--bi],wi[bi]=null}var fi=null,pi=null,ut=!1,Ti=null;function xf(n,r){var a=Ei(5,null,null,0);a.elementType="DELETED",a.stateNode=r,a.return=n,r=n.deletions,r===null?(n.deletions=[a],n.flags|=16):r.push(a)}function kf(n,r){switch(n.tag){case 5:var a=n.type;return r=r.nodeType!==1||a.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(n.stateNode=r,fi=n,pi=Sn(r.firstChild),!0):!1;case 6:return r=n.pendingProps===""||r.nodeType!==3?null:r,r!==null?(n.stateNode=r,fi=n,pi=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(a=Kn!==null?{id:nn,overflow:rn}:null,n.memoizedState={dehydrated:r,treeContext:a,retryLane:1073741824},a=Ei(18,null,null,0),a.stateNode=r,a.return=n,n.child=a,fi=n,pi=null,!0):!1;default:return!1}}function Gl(n){return(n.mode&1)!==0&&(n.flags&128)===0}function Ql(n){if(ut){var r=pi;if(r){var a=r;if(!kf(n,r)){if(Gl(n))throw Error(i(418));r=Sn(a.nextSibling);var u=fi;r&&kf(n,r)?xf(u,a):(n.flags=n.flags&-4097|2,ut=!1,fi=n)}}else{if(Gl(n))throw Error(i(418));n.flags=n.flags&-4097|2,ut=!1,fi=n}}}function Ef(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;fi=n}function $o(n){if(n!==fi)return!1;if(!ut)return Ef(n),ut=!0,!1;var r;if((r=n.tag!==3)&&!(r=n.tag!==5)&&(r=n.type,r=r!=="head"&&r!=="body"&&!$l(n.type,n.memoizedProps)),r&&(r=pi)){if(Gl(n))throw Nf(),Error(i(418));for(;r;)xf(n,r),r=Sn(r.nextSibling)}if(Ef(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(317));e:{for(n=n.nextSibling,r=0;n;){if(n.nodeType===8){var a=n.data;if(a==="/$"){if(r===0){pi=Sn(n.nextSibling);break e}r--}else a!=="$"&&a!=="$!"&&a!=="$?"||r++}n=n.nextSibling}pi=null}}else pi=fi?Sn(n.stateNode.nextSibling):null;return!0}function Nf(){for(var n=pi;n;)n=Sn(n.nextSibling)}function Dr(){pi=fi=null,ut=!1}function Jl(n){Ti===null?Ti=[n]:Ti.push(n)}var BS=T.ReactCurrentBatchConfig;function Es(n,r,a){if(n=a.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(a._owner){if(a=a._owner,a){if(a.tag!==1)throw Error(i(309));var u=a.stateNode}if(!u)throw Error(i(147,n));var f=u,g=""+n;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===g?r.ref:(r=function(k){var B=f.refs;k===null?delete B[g]:B[g]=k},r._stringRef=g,r)}if(typeof n!="string")throw Error(i(284));if(!a._owner)throw Error(i(290,n))}return n}function Wo(n,r){throw n=Object.prototype.toString.call(r),Error(i(31,n==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":n))}function Rf(n){var r=n._init;return r(n._payload)}function Pf(n){function r(J,V){if(n){var ie=J.deletions;ie===null?(J.deletions=[V],J.flags|=16):ie.push(V)}}function a(J,V){if(!n)return null;for(;V!==null;)r(J,V),V=V.sibling;return null}function u(J,V){for(J=new Map;V!==null;)V.key!==null?J.set(V.key,V):J.set(V.index,V),V=V.sibling;return J}function f(J,V){return J=Mn(J,V),J.index=0,J.sibling=null,J}function g(J,V,ie){return J.index=ie,n?(ie=J.alternate,ie!==null?(ie=ie.index,ie<V?(J.flags|=2,V):ie):(J.flags|=2,V)):(J.flags|=1048576,V)}function k(J){return n&&J.alternate===null&&(J.flags|=2),J}function B(J,V,ie,Se){return V===null||V.tag!==6?(V=Wc(ie,J.mode,Se),V.return=J,V):(V=f(V,ie),V.return=J,V)}function $(J,V,ie,Se){var Ae=ie.type;return Ae===I?pe(J,V,ie.props.children,Se,ie.key):V!==null&&(V.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===D&&Rf(Ae)===V.type)?(Se=f(V,ie.props),Se.ref=Es(J,V,ie),Se.return=J,Se):(Se=fa(ie.type,ie.key,ie.props,null,J.mode,Se),Se.ref=Es(J,V,ie),Se.return=J,Se)}function re(J,V,ie,Se){return V===null||V.tag!==4||V.stateNode.containerInfo!==ie.containerInfo||V.stateNode.implementation!==ie.implementation?(V=Uc(ie,J.mode,Se),V.return=J,V):(V=f(V,ie.children||[]),V.return=J,V)}function pe(J,V,ie,Se,Ae){return V===null||V.tag!==7?(V=er(ie,J.mode,Se,Ae),V.return=J,V):(V=f(V,ie),V.return=J,V)}function me(J,V,ie){if(typeof V=="string"&&V!==""||typeof V=="number")return V=Wc(""+V,J.mode,ie),V.return=J,V;if(typeof V=="object"&&V!==null){switch(V.$$typeof){case Q:return ie=fa(V.type,V.key,V.props,null,J.mode,ie),ie.ref=Es(J,null,V),ie.return=J,ie;case H:return V=Uc(V,J.mode,ie),V.return=J,V;case D:var Se=V._init;return me(J,Se(V._payload),ie)}if(ve(V)||ne(V))return V=er(V,J.mode,ie,null),V.return=J,V;Wo(J,V)}return null}function fe(J,V,ie,Se){var Ae=V!==null?V.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number")return Ae!==null?null:B(J,V,""+ie,Se);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case Q:return ie.key===Ae?$(J,V,ie,Se):null;case H:return ie.key===Ae?re(J,V,ie,Se):null;case D:return Ae=ie._init,fe(J,V,Ae(ie._payload),Se)}if(ve(ie)||ne(ie))return Ae!==null?null:pe(J,V,ie,Se,null);Wo(J,ie)}return null}function Ne(J,V,ie,Se,Ae){if(typeof Se=="string"&&Se!==""||typeof Se=="number")return J=J.get(ie)||null,B(V,J,""+Se,Ae);if(typeof Se=="object"&&Se!==null){switch(Se.$$typeof){case Q:return J=J.get(Se.key===null?ie:Se.key)||null,$(V,J,Se,Ae);case H:return J=J.get(Se.key===null?ie:Se.key)||null,re(V,J,Se,Ae);case D:var Oe=Se._init;return Ne(J,V,ie,Oe(Se._payload),Ae)}if(ve(Se)||ne(Se))return J=J.get(ie)||null,pe(V,J,Se,Ae,null);Wo(V,Se)}return null}function Pe(J,V,ie,Se){for(var Ae=null,Oe=null,ze=V,He=V=0,Tt=null;ze!==null&&He<ie.length;He++){ze.index>He?(Tt=ze,ze=null):Tt=ze.sibling;var tt=fe(J,ze,ie[He],Se);if(tt===null){ze===null&&(ze=Tt);break}n&&ze&&tt.alternate===null&&r(J,ze),V=g(tt,V,He),Oe===null?Ae=tt:Oe.sibling=tt,Oe=tt,ze=Tt}if(He===ie.length)return a(J,ze),ut&&qn(J,He),Ae;if(ze===null){for(;He<ie.length;He++)ze=me(J,ie[He],Se),ze!==null&&(V=g(ze,V,He),Oe===null?Ae=ze:Oe.sibling=ze,Oe=ze);return ut&&qn(J,He),Ae}for(ze=u(J,ze);He<ie.length;He++)Tt=Ne(ze,J,He,ie[He],Se),Tt!==null&&(n&&Tt.alternate!==null&&ze.delete(Tt.key===null?He:Tt.key),V=g(Tt,V,He),Oe===null?Ae=Tt:Oe.sibling=Tt,Oe=Tt);return n&&ze.forEach(function(Ln){return r(J,Ln)}),ut&&qn(J,He),Ae}function Le(J,V,ie,Se){var Ae=ne(ie);if(typeof Ae!="function")throw Error(i(150));if(ie=Ae.call(ie),ie==null)throw Error(i(151));for(var Oe=Ae=null,ze=V,He=V=0,Tt=null,tt=ie.next();ze!==null&&!tt.done;He++,tt=ie.next()){ze.index>He?(Tt=ze,ze=null):Tt=ze.sibling;var Ln=fe(J,ze,tt.value,Se);if(Ln===null){ze===null&&(ze=Tt);break}n&&ze&&Ln.alternate===null&&r(J,ze),V=g(Ln,V,He),Oe===null?Ae=Ln:Oe.sibling=Ln,Oe=Ln,ze=Tt}if(tt.done)return a(J,ze),ut&&qn(J,He),Ae;if(ze===null){for(;!tt.done;He++,tt=ie.next())tt=me(J,tt.value,Se),tt!==null&&(V=g(tt,V,He),Oe===null?Ae=tt:Oe.sibling=tt,Oe=tt);return ut&&qn(J,He),Ae}for(ze=u(J,ze);!tt.done;He++,tt=ie.next())tt=Ne(ze,J,He,tt.value,Se),tt!==null&&(n&&tt.alternate!==null&&ze.delete(tt.key===null?He:tt.key),V=g(tt,V,He),Oe===null?Ae=tt:Oe.sibling=tt,Oe=tt);return n&&ze.forEach(function(mw){return r(J,mw)}),ut&&qn(J,He),Ae}function wt(J,V,ie,Se){if(typeof ie=="object"&&ie!==null&&ie.type===I&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case Q:e:{for(var Ae=ie.key,Oe=V;Oe!==null;){if(Oe.key===Ae){if(Ae=ie.type,Ae===I){if(Oe.tag===7){a(J,Oe.sibling),V=f(Oe,ie.props.children),V.return=J,J=V;break e}}else if(Oe.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===D&&Rf(Ae)===Oe.type){a(J,Oe.sibling),V=f(Oe,ie.props),V.ref=Es(J,Oe,ie),V.return=J,J=V;break e}a(J,Oe);break}else r(J,Oe);Oe=Oe.sibling}ie.type===I?(V=er(ie.props.children,J.mode,Se,ie.key),V.return=J,J=V):(Se=fa(ie.type,ie.key,ie.props,null,J.mode,Se),Se.ref=Es(J,V,ie),Se.return=J,J=Se)}return k(J);case H:e:{for(Oe=ie.key;V!==null;){if(V.key===Oe)if(V.tag===4&&V.stateNode.containerInfo===ie.containerInfo&&V.stateNode.implementation===ie.implementation){a(J,V.sibling),V=f(V,ie.children||[]),V.return=J,J=V;break e}else{a(J,V);break}else r(J,V);V=V.sibling}V=Uc(ie,J.mode,Se),V.return=J,J=V}return k(J);case D:return Oe=ie._init,wt(J,V,Oe(ie._payload),Se)}if(ve(ie))return Pe(J,V,ie,Se);if(ne(ie))return Le(J,V,ie,Se);Wo(J,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"?(ie=""+ie,V!==null&&V.tag===6?(a(J,V.sibling),V=f(V,ie),V.return=J,J=V):(a(J,V),V=Wc(ie,J.mode,Se),V.return=J,J=V),k(J)):a(J,V)}return wt}var Mr=Pf(!0),Df=Pf(!1),Uo=wn(null),Ko=null,Lr=null,Zl=null;function ec(){Zl=Lr=Ko=null}function tc(n){var r=Uo.current;lt(Uo),n._currentValue=r}function ic(n,r,a){for(;n!==null;){var u=n.alternate;if((n.childLanes&r)!==r?(n.childLanes|=r,u!==null&&(u.childLanes|=r)):u!==null&&(u.childLanes&r)!==r&&(u.childLanes|=r),n===a)break;n=n.return}}function jr(n,r){Ko=n,Zl=Lr=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&r)!==0&&(ri=!0),n.firstContext=null)}function Ci(n){var r=n._currentValue;if(Zl!==n)if(n={context:n,memoizedValue:r,next:null},Lr===null){if(Ko===null)throw Error(i(308));Lr=n,Ko.dependencies={lanes:0,firstContext:n}}else Lr=Lr.next=n;return r}var Vn=null;function nc(n){Vn===null?Vn=[n]:Vn.push(n)}function Mf(n,r,a,u){var f=r.interleaved;return f===null?(a.next=a,nc(r)):(a.next=f.next,f.next=a),r.interleaved=a,sn(n,u)}function sn(n,r){n.lanes|=r;var a=n.alternate;for(a!==null&&(a.lanes|=r),a=n,n=n.return;n!==null;)n.childLanes|=r,a=n.alternate,a!==null&&(a.childLanes|=r),a=n,n=n.return;return a.tag===3?a.stateNode:null}var xn=!1;function rc(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Lf(n,r){n=n.updateQueue,r.updateQueue===n&&(r.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function on(n,r){return{eventTime:n,lane:r,tag:0,payload:null,callback:null,next:null}}function kn(n,r,a){var u=n.updateQueue;if(u===null)return null;if(u=u.shared,(Ze&2)!==0){var f=u.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),u.pending=r,sn(n,a)}return f=u.interleaved,f===null?(r.next=r,nc(u)):(r.next=f.next,f.next=r),u.interleaved=r,sn(n,a)}function qo(n,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194240)!==0)){var u=r.lanes;u&=n.pendingLanes,a|=u,r.lanes=a,_l(n,a)}}function jf(n,r){var a=n.updateQueue,u=n.alternate;if(u!==null&&(u=u.updateQueue,a===u)){var f=null,g=null;if(a=a.firstBaseUpdate,a!==null){do{var k={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};g===null?f=g=k:g=g.next=k,a=a.next}while(a!==null);g===null?f=g=r:g=g.next=r}else f=g=r;a={baseState:u.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:u.shared,effects:u.effects},n.updateQueue=a;return}n=a.lastBaseUpdate,n===null?a.firstBaseUpdate=r:n.next=r,a.lastBaseUpdate=r}function Vo(n,r,a,u){var f=n.updateQueue;xn=!1;var g=f.firstBaseUpdate,k=f.lastBaseUpdate,B=f.shared.pending;if(B!==null){f.shared.pending=null;var $=B,re=$.next;$.next=null,k===null?g=re:k.next=re,k=$;var pe=n.alternate;pe!==null&&(pe=pe.updateQueue,B=pe.lastBaseUpdate,B!==k&&(B===null?pe.firstBaseUpdate=re:B.next=re,pe.lastBaseUpdate=$))}if(g!==null){var me=f.baseState;k=0,pe=re=$=null,B=g;do{var fe=B.lane,Ne=B.eventTime;if((u&fe)===fe){pe!==null&&(pe=pe.next={eventTime:Ne,lane:0,tag:B.tag,payload:B.payload,callback:B.callback,next:null});e:{var Pe=n,Le=B;switch(fe=r,Ne=a,Le.tag){case 1:if(Pe=Le.payload,typeof Pe=="function"){me=Pe.call(Ne,me,fe);break e}me=Pe;break e;case 3:Pe.flags=Pe.flags&-65537|128;case 0:if(Pe=Le.payload,fe=typeof Pe=="function"?Pe.call(Ne,me,fe):Pe,fe==null)break e;me=K({},me,fe);break e;case 2:xn=!0}}B.callback!==null&&B.lane!==0&&(n.flags|=64,fe=f.effects,fe===null?f.effects=[B]:fe.push(B))}else Ne={eventTime:Ne,lane:fe,tag:B.tag,payload:B.payload,callback:B.callback,next:null},pe===null?(re=pe=Ne,$=me):pe=pe.next=Ne,k|=fe;if(B=B.next,B===null){if(B=f.shared.pending,B===null)break;fe=B,B=fe.next,fe.next=null,f.lastBaseUpdate=fe,f.shared.pending=null}}while(!0);if(pe===null&&($=me),f.baseState=$,f.firstBaseUpdate=re,f.lastBaseUpdate=pe,r=f.shared.interleaved,r!==null){f=r;do k|=f.lane,f=f.next;while(f!==r)}else g===null&&(f.shared.lanes=0);Gn|=k,n.lanes=k,n.memoizedState=me}}function Tf(n,r,a){if(n=r.effects,r.effects=null,n!==null)for(r=0;r<n.length;r++){var u=n[r],f=u.callback;if(f!==null){if(u.callback=null,u=a,typeof f!="function")throw Error(i(191,f));f.call(u)}}}var Ns={},$i=wn(Ns),Rs=wn(Ns),Ps=wn(Ns);function Yn(n){if(n===Ns)throw Error(i(174));return n}function sc(n,r){switch(ot(Ps,r),ot(Rs,n),ot($i,Ns),n=r.nodeType,n){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:ke(null,"");break;default:n=n===8?r.parentNode:r,r=n.namespaceURI||null,n=n.tagName,r=ke(r,n)}lt($i),ot($i,r)}function Tr(){lt($i),lt(Rs),lt(Ps)}function Af(n){Yn(Ps.current);var r=Yn($i.current),a=ke(r,n.type);r!==a&&(ot(Rs,n),ot($i,a))}function oc(n){Rs.current===n&&(lt($i),lt(Rs))}var dt=wn(0);function Yo(n){for(var r=n;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===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var ac=[];function lc(){for(var n=0;n<ac.length;n++)ac[n]._workInProgressVersionPrimary=null;ac.length=0}var Xo=T.ReactCurrentDispatcher,cc=T.ReactCurrentBatchConfig,Xn=0,ft=null,Et=null,Lt=null,Go=!1,Ds=!1,Ms=0,IS=0;function Vt(){throw Error(i(321))}function uc(n,r){if(r===null)return!1;for(var a=0;a<r.length&&a<n.length;a++)if(!ji(n[a],r[a]))return!1;return!0}function hc(n,r,a,u,f,g){if(Xn=g,ft=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Xo.current=n===null||n.memoizedState===null?HS:$S,n=a(u,f),Ds){g=0;do{if(Ds=!1,Ms=0,25<=g)throw Error(i(301));g+=1,Lt=Et=null,r.updateQueue=null,Xo.current=WS,n=a(u,f)}while(Ds)}if(Xo.current=Zo,r=Et!==null&&Et.next!==null,Xn=0,Lt=Et=ft=null,Go=!1,r)throw Error(i(300));return n}function dc(){var n=Ms!==0;return Ms=0,n}function Wi(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Lt===null?ft.memoizedState=Lt=n:Lt=Lt.next=n,Lt}function xi(){if(Et===null){var n=ft.alternate;n=n!==null?n.memoizedState:null}else n=Et.next;var r=Lt===null?ft.memoizedState:Lt.next;if(r!==null)Lt=r,Et=n;else{if(n===null)throw Error(i(310));Et=n,n={memoizedState:Et.memoizedState,baseState:Et.baseState,baseQueue:Et.baseQueue,queue:Et.queue,next:null},Lt===null?ft.memoizedState=Lt=n:Lt=Lt.next=n}return Lt}function Ls(n,r){return typeof r=="function"?r(n):r}function fc(n){var r=xi(),a=r.queue;if(a===null)throw Error(i(311));a.lastRenderedReducer=n;var u=Et,f=u.baseQueue,g=a.pending;if(g!==null){if(f!==null){var k=f.next;f.next=g.next,g.next=k}u.baseQueue=f=g,a.pending=null}if(f!==null){g=f.next,u=u.baseState;var B=k=null,$=null,re=g;do{var pe=re.lane;if((Xn&pe)===pe)$!==null&&($=$.next={lane:0,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null}),u=re.hasEagerState?re.eagerState:n(u,re.action);else{var me={lane:pe,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null};$===null?(B=$=me,k=u):$=$.next=me,ft.lanes|=pe,Gn|=pe}re=re.next}while(re!==null&&re!==g);$===null?k=u:$.next=B,ji(u,r.memoizedState)||(ri=!0),r.memoizedState=u,r.baseState=k,r.baseQueue=$,a.lastRenderedState=u}if(n=a.interleaved,n!==null){f=n;do g=f.lane,ft.lanes|=g,Gn|=g,f=f.next;while(f!==n)}else f===null&&(a.lanes=0);return[r.memoizedState,a.dispatch]}function pc(n){var r=xi(),a=r.queue;if(a===null)throw Error(i(311));a.lastRenderedReducer=n;var u=a.dispatch,f=a.pending,g=r.memoizedState;if(f!==null){a.pending=null;var k=f=f.next;do g=n(g,k.action),k=k.next;while(k!==f);ji(g,r.memoizedState)||(ri=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),a.lastRenderedState=g}return[g,u]}function Bf(){}function If(n,r){var a=ft,u=xi(),f=r(),g=!ji(u.memoizedState,f);if(g&&(u.memoizedState=f,ri=!0),u=u.queue,mc(Ff.bind(null,a,u,n),[n]),u.getSnapshot!==r||g||Lt!==null&&Lt.memoizedState.tag&1){if(a.flags|=2048,js(9,zf.bind(null,a,u,f,r),void 0,null),jt===null)throw Error(i(349));(Xn&30)!==0||Of(a,r,f)}return f}function Of(n,r,a){n.flags|=16384,n={getSnapshot:r,value:a},r=ft.updateQueue,r===null?(r={lastEffect:null,stores:null},ft.updateQueue=r,r.stores=[n]):(a=r.stores,a===null?r.stores=[n]:a.push(n))}function zf(n,r,a,u){r.value=a,r.getSnapshot=u,Hf(r)&&$f(n)}function Ff(n,r,a){return a(function(){Hf(r)&&$f(n)})}function Hf(n){var r=n.getSnapshot;n=n.value;try{var a=r();return!ji(n,a)}catch{return!0}}function $f(n){var r=sn(n,1);r!==null&&Oi(r,n,1,-1)}function Wf(n){var r=Wi();return typeof n=="function"&&(n=n()),r.memoizedState=r.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ls,lastRenderedState:n},r.queue=n,n=n.dispatch=FS.bind(null,ft,n),[r.memoizedState,n]}function js(n,r,a,u){return n={tag:n,create:r,destroy:a,deps:u,next:null},r=ft.updateQueue,r===null?(r={lastEffect:null,stores:null},ft.updateQueue=r,r.lastEffect=n.next=n):(a=r.lastEffect,a===null?r.lastEffect=n.next=n:(u=a.next,a.next=n,n.next=u,r.lastEffect=n)),n}function Uf(){return xi().memoizedState}function Qo(n,r,a,u){var f=Wi();ft.flags|=n,f.memoizedState=js(1|r,a,void 0,u===void 0?null:u)}function Jo(n,r,a,u){var f=xi();u=u===void 0?null:u;var g=void 0;if(Et!==null){var k=Et.memoizedState;if(g=k.destroy,u!==null&&uc(u,k.deps)){f.memoizedState=js(r,a,g,u);return}}ft.flags|=n,f.memoizedState=js(1|r,a,g,u)}function Kf(n,r){return Qo(8390656,8,n,r)}function mc(n,r){return Jo(2048,8,n,r)}function qf(n,r){return Jo(4,2,n,r)}function Vf(n,r){return Jo(4,4,n,r)}function Yf(n,r){if(typeof r=="function")return n=n(),r(n),function(){r(null)};if(r!=null)return n=n(),r.current=n,function(){r.current=null}}function Xf(n,r,a){return a=a!=null?a.concat([n]):null,Jo(4,4,Yf.bind(null,r,n),a)}function gc(){}function Gf(n,r){var a=xi();r=r===void 0?null:r;var u=a.memoizedState;return u!==null&&r!==null&&uc(r,u[1])?u[0]:(a.memoizedState=[n,r],n)}function Qf(n,r){var a=xi();r=r===void 0?null:r;var u=a.memoizedState;return u!==null&&r!==null&&uc(r,u[1])?u[0]:(n=n(),a.memoizedState=[n,r],n)}function Jf(n,r,a){return(Xn&21)===0?(n.baseState&&(n.baseState=!1,ri=!0),n.memoizedState=a):(ji(a,r)||(a=Nd(),ft.lanes|=a,Gn|=a,n.baseState=!0),r)}function OS(n,r){var a=nt;nt=a!==0&&4>a?a:4,n(!0);var u=cc.transition;cc.transition={};try{n(!1),r()}finally{nt=a,cc.transition=u}}function Zf(){return xi().memoizedState}function zS(n,r,a){var u=Pn(n);if(a={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null},ep(n))tp(r,a);else if(a=Mf(n,r,a,u),a!==null){var f=Jt();Oi(a,n,u,f),ip(a,r,u)}}function FS(n,r,a){var u=Pn(n),f={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null};if(ep(n))tp(r,f);else{var g=n.alternate;if(n.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var k=r.lastRenderedState,B=g(k,a);if(f.hasEagerState=!0,f.eagerState=B,ji(B,k)){var $=r.interleaved;$===null?(f.next=f,nc(r)):(f.next=$.next,$.next=f),r.interleaved=f;return}}catch{}finally{}a=Mf(n,r,f,u),a!==null&&(f=Jt(),Oi(a,n,u,f),ip(a,r,u))}}function ep(n){var r=n.alternate;return n===ft||r!==null&&r===ft}function tp(n,r){Ds=Go=!0;var a=n.pending;a===null?r.next=r:(r.next=a.next,a.next=r),n.pending=r}function ip(n,r,a){if((a&4194240)!==0){var u=r.lanes;u&=n.pendingLanes,a|=u,r.lanes=a,_l(n,a)}}var Zo={readContext:Ci,useCallback:Vt,useContext:Vt,useEffect:Vt,useImperativeHandle:Vt,useInsertionEffect:Vt,useLayoutEffect:Vt,useMemo:Vt,useReducer:Vt,useRef:Vt,useState:Vt,useDebugValue:Vt,useDeferredValue:Vt,useTransition:Vt,useMutableSource:Vt,useSyncExternalStore:Vt,useId:Vt,unstable_isNewReconciler:!1},HS={readContext:Ci,useCallback:function(n,r){return Wi().memoizedState=[n,r===void 0?null:r],n},useContext:Ci,useEffect:Kf,useImperativeHandle:function(n,r,a){return a=a!=null?a.concat([n]):null,Qo(4194308,4,Yf.bind(null,r,n),a)},useLayoutEffect:function(n,r){return Qo(4194308,4,n,r)},useInsertionEffect:function(n,r){return Qo(4,2,n,r)},useMemo:function(n,r){var a=Wi();return r=r===void 0?null:r,n=n(),a.memoizedState=[n,r],n},useReducer:function(n,r,a){var u=Wi();return r=a!==void 0?a(r):r,u.memoizedState=u.baseState=r,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:r},u.queue=n,n=n.dispatch=zS.bind(null,ft,n),[u.memoizedState,n]},useRef:function(n){var r=Wi();return n={current:n},r.memoizedState=n},useState:Wf,useDebugValue:gc,useDeferredValue:function(n){return Wi().memoizedState=n},useTransition:function(){var n=Wf(!1),r=n[0];return n=OS.bind(null,n[1]),Wi().memoizedState=n,[r,n]},useMutableSource:function(){},useSyncExternalStore:function(n,r,a){var u=ft,f=Wi();if(ut){if(a===void 0)throw Error(i(407));a=a()}else{if(a=r(),jt===null)throw Error(i(349));(Xn&30)!==0||Of(u,r,a)}f.memoizedState=a;var g={value:a,getSnapshot:r};return f.queue=g,Kf(Ff.bind(null,u,g,n),[n]),u.flags|=2048,js(9,zf.bind(null,u,g,a,r),void 0,null),a},useId:function(){var n=Wi(),r=jt.identifierPrefix;if(ut){var a=rn,u=nn;a=(u&~(1<<32-Li(u)-1)).toString(32)+a,r=":"+r+"R"+a,a=Ms++,0<a&&(r+="H"+a.toString(32)),r+=":"}else a=IS++,r=":"+r+"r"+a.toString(32)+":";return n.memoizedState=r},unstable_isNewReconciler:!1},$S={readContext:Ci,useCallback:Gf,useContext:Ci,useEffect:mc,useImperativeHandle:Xf,useInsertionEffect:qf,useLayoutEffect:Vf,useMemo:Qf,useReducer:fc,useRef:Uf,useState:function(){return fc(Ls)},useDebugValue:gc,useDeferredValue:function(n){var r=xi();return Jf(r,Et.memoizedState,n)},useTransition:function(){var n=fc(Ls)[0],r=xi().memoizedState;return[n,r]},useMutableSource:Bf,useSyncExternalStore:If,useId:Zf,unstable_isNewReconciler:!1},WS={readContext:Ci,useCallback:Gf,useContext:Ci,useEffect:mc,useImperativeHandle:Xf,useInsertionEffect:qf,useLayoutEffect:Vf,useMemo:Qf,useReducer:pc,useRef:Uf,useState:function(){return pc(Ls)},useDebugValue:gc,useDeferredValue:function(n){var r=xi();return Et===null?r.memoizedState=n:Jf(r,Et.memoizedState,n)},useTransition:function(){var n=pc(Ls)[0],r=xi().memoizedState;return[n,r]},useMutableSource:Bf,useSyncExternalStore:If,useId:Zf,unstable_isNewReconciler:!1};function Ai(n,r){if(n&&n.defaultProps){r=K({},r),n=n.defaultProps;for(var a in n)r[a]===void 0&&(r[a]=n[a]);return r}return r}function vc(n,r,a,u){r=n.memoizedState,a=a(u,r),a=a==null?r:K({},r,a),n.memoizedState=a,n.lanes===0&&(n.updateQueue.baseState=a)}var ea={isMounted:function(n){return(n=n._reactInternals)?$n(n)===n:!1},enqueueSetState:function(n,r,a){n=n._reactInternals;var u=Jt(),f=Pn(n),g=on(u,f);g.payload=r,a!=null&&(g.callback=a),r=kn(n,g,f),r!==null&&(Oi(r,n,f,u),qo(r,n,f))},enqueueReplaceState:function(n,r,a){n=n._reactInternals;var u=Jt(),f=Pn(n),g=on(u,f);g.tag=1,g.payload=r,a!=null&&(g.callback=a),r=kn(n,g,f),r!==null&&(Oi(r,n,f,u),qo(r,n,f))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var a=Jt(),u=Pn(n),f=on(a,u);f.tag=2,r!=null&&(f.callback=r),r=kn(n,f,u),r!==null&&(Oi(r,n,u,a),qo(r,n,u))}};function np(n,r,a,u,f,g,k){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(u,g,k):r.prototype&&r.prototype.isPureReactComponent?!ys(a,u)||!ys(f,g):!0}function rp(n,r,a){var u=!1,f=bn,g=r.contextType;return typeof g=="object"&&g!==null?g=Ci(g):(f=ni(r)?Un:qt.current,u=r.contextTypes,g=(u=u!=null)?Nr(n,f):bn),r=new r(a,g),n.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=ea,n.stateNode=r,r._reactInternals=n,u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=f,n.__reactInternalMemoizedMaskedChildContext=g),r}function sp(n,r,a,u){n=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,u),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,u),r.state!==n&&ea.enqueueReplaceState(r,r.state,null)}function _c(n,r,a,u){var f=n.stateNode;f.props=a,f.state=n.memoizedState,f.refs={},rc(n);var g=r.contextType;typeof g=="object"&&g!==null?f.context=Ci(g):(g=ni(r)?Un:qt.current,f.context=Nr(n,g)),f.state=n.memoizedState,g=r.getDerivedStateFromProps,typeof g=="function"&&(vc(n,r,g,a),f.state=n.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&&ea.enqueueReplaceState(f,f.state,null),Vo(n,a,f,u),f.state=n.memoizedState),typeof f.componentDidMount=="function"&&(n.flags|=4194308)}function Ar(n,r){try{var a="",u=r;do a+=se(u),u=u.return;while(u);var f=a}catch(g){f=`
|
|
37
|
+
`+f[k].replace(" at new "," at ");return n.displayName&&$.includes("<anonymous>")&&($=$.replace("<anonymous>",n.displayName)),$}while(1<=k&&0<=B);break}}}finally{oe=!1,Error.prepareStackTrace=a}return(n=n?n.displayName||n.name:"")?W(n):""}function se(n){switch(n.tag){case 5:return W(n.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return n=ae(n.type,!1),n;case 11:return n=ae(n.type.render,!1),n;case 1:return n=ae(n.type,!0),n;default:return""}}function le(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case I:return"Fragment";case H:return"Portal";case U:return"Profiler";case G:return"StrictMode";case E:return"Suspense";case R:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case X:return(n.displayName||"Context")+".Consumer";case q:return(n._context.displayName||"Context")+".Provider";case A:var r=n.render;return n=n.displayName,n||(n=r.displayName||r.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case F:return r=n.displayName||null,r!==null?r:le(n.type)||"Memo";case D:r=n._payload,n=n._init;try{return le(n(r))}catch{}}return null}function ye(n){var r=n.type;switch(n.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=r.render,n=n.displayName||n.name||"",r.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return le(r);case 8:return r===G?"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 ce(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Y(n){var r=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function ne(n){var r=Y(n)?"checked":"value",a=Object.getOwnPropertyDescriptor(n.constructor.prototype,r),u=""+n[r];if(!n.hasOwnProperty(r)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var f=a.get,g=a.set;return Object.defineProperty(n,r,{configurable:!0,get:function(){return f.call(this)},set:function(k){u=""+k,g.call(this,k)}}),Object.defineProperty(n,r,{enumerable:a.enumerable}),{getValue:function(){return u},setValue:function(k){u=""+k},stopTracking:function(){n._valueTracker=null,delete n[r]}}}}function Te(n){n._valueTracker||(n._valueTracker=ne(n))}function De(n){if(!n)return!1;var r=n._valueTracker;if(!r)return!0;var a=r.getValue(),u="";return n&&(u=Y(n)?n.checked?"true":"false":n.value),n=u,n!==a?(r.setValue(n),!0):!1}function ge(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function Z(n,r){var a=r.checked;return K({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??n._wrapperState.initialChecked})}function Ce(n,r){var a=r.defaultValue==null?"":r.defaultValue,u=r.checked!=null?r.checked:r.defaultChecked;a=ce(r.value!=null?r.value:a),n._wrapperState={initialChecked:u,initialValue:a,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Pe(n,r){r=r.checked,r!=null&&j(n,"checked",r,!1)}function Ne(n,r){Pe(n,r);var a=ce(r.value),u=r.type;if(a!=null)u==="number"?(a===0&&n.value===""||n.value!=a)&&(n.value=""+a):n.value!==""+a&&(n.value=""+a);else if(u==="submit"||u==="reset"){n.removeAttribute("value");return}r.hasOwnProperty("value")?ee(n,r.type,a):r.hasOwnProperty("defaultValue")&&ee(n,r.type,ce(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(n.defaultChecked=!!r.defaultChecked)}function qe(n,r,a){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var u=r.type;if(!(u!=="submit"&&u!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+n._wrapperState.initialValue,a||r===n.value||(n.value=r),n.defaultValue=r}a=n.name,a!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,a!==""&&(n.name=a)}function ee(n,r,a){(r!=="number"||ge(n.ownerDocument)!==n)&&(a==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+a&&(n.defaultValue=""+a))}var _e=Array.isArray;function Be(n,r,a,u){if(n=n.options,r){r={};for(var f=0;f<a.length;f++)r["$"+a[f]]=!0;for(a=0;a<n.length;a++)f=r.hasOwnProperty("$"+n[a].value),n[a].selected!==f&&(n[a].selected=f),f&&u&&(n[a].defaultSelected=!0)}else{for(a=""+ce(a),r=null,f=0;f<n.length;f++){if(n[f].value===a){n[f].selected=!0,u&&(n[f].defaultSelected=!0);return}r!==null||n[f].disabled||(r=n[f])}r!==null&&(r.selected=!0)}}function Ie(n,r){if(r.dangerouslySetInnerHTML!=null)throw Error(i(91));return K({},r,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function Fe(n,r){var a=r.value;if(a==null){if(a=r.children,r=r.defaultValue,a!=null){if(r!=null)throw Error(i(92));if(_e(a)){if(1<a.length)throw Error(i(93));a=a[0]}r=a}r==null&&(r=""),a=r}n._wrapperState={initialValue:ce(a)}}function gt(n,r){var a=ce(r.value),u=ce(r.defaultValue);a!=null&&(a=""+a,a!==n.value&&(n.value=a),r.defaultValue==null&&n.defaultValue!==a&&(n.defaultValue=a)),u!=null&&(n.defaultValue=""+u)}function ve(n){var r=n.textContent;r===n._wrapperState.initialValue&&r!==""&&r!==null&&(n.value=r)}function be(n){switch(n){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Ee(n,r){return n==null||n==="http://www.w3.org/1999/xhtml"?be(r):n==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var Ye,rt=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,a,u,f){MSApp.execUnsafeLocalFunction(function(){return n(r,a,u,f)})}:n})(function(n,r){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=r;else{for(Ye=Ye||document.createElement("div"),Ye.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=Ye.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;r.firstChild;)n.appendChild(r.firstChild)}});function We(n,r){if(r){var a=n.firstChild;if(a&&a===n.lastChild&&a.nodeType===3){a.nodeValue=r;return}}n.textContent=r}var fe={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(fe).forEach(function(n){Ve.forEach(function(r){r=r+n.charAt(0).toUpperCase()+n.substring(1),fe[r]=fe[n]})});function it(n,r,a){return r==null||typeof r=="boolean"||r===""?"":a||typeof r!="number"||r===0||fe.hasOwnProperty(n)&&fe[n]?(""+r).trim():r+"px"}function ue(n,r){n=n.style;for(var a in r)if(r.hasOwnProperty(a)){var u=a.indexOf("--")===0,f=it(a,r[a],u);a==="float"&&(a="cssFloat"),u?n.setProperty(a,f):n[a]=f}}var Le=K({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ke(n,r){if(r){if(Le[n]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(i(137,n));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(i(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(i(61))}if(r.style!=null&&typeof r.style!="object")throw Error(i(62))}}function Mt(n,r){if(n.indexOf("-")===-1)return typeof r.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var hi=null;function ul(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var hl=null,gr=null,vr=null;function fd(n){if(n=ks(n)){if(typeof hl!="function")throw Error(i(280));var r=n.stateNode;r&&(r=Bo(r),hl(n.stateNode,n.type,r))}}function pd(n){gr?vr?vr.push(n):vr=[n]:gr=n}function md(){if(gr){var n=gr,r=vr;if(vr=gr=null,fd(n),r)for(n=0;n<r.length;n++)fd(r[n])}}function gd(n,r){return n(r)}function vd(){}var dl=!1;function _d(n,r,a){if(dl)return n(r,a);dl=!0;try{return gd(n,r,a)}finally{dl=!1,(gr!==null||vr!==null)&&(vd(),md())}}function rs(n,r){var a=n.stateNode;if(a===null)return null;var u=Bo(a);if(u===null)return null;a=u[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":(u=!u.disabled)||(n=n.type,u=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!u;break e;default:n=!1}if(n)return null;if(a&&typeof a!="function")throw Error(i(231,r,typeof a));return a}var fl=!1;if(d)try{var ss={};Object.defineProperty(ss,"passive",{get:function(){fl=!0}}),window.addEventListener("test",ss,ss),window.removeEventListener("test",ss,ss)}catch{fl=!1}function xy(n,r,a,u,f,g,k,B,$){var re=Array.prototype.slice.call(arguments,3);try{r.apply(a,re)}catch(pe){this.onError(pe)}}var os=!1,po=null,mo=!1,pl=null,ky={onError:function(n){os=!0,po=n}};function Ey(n,r,a,u,f,g,k,B,$){os=!1,po=null,xy.apply(ky,arguments)}function Ny(n,r,a,u,f,g,k,B,$){if(Ey.apply(this,arguments),os){if(os){var re=po;os=!1,po=null}else throw Error(i(198));mo||(mo=!0,pl=re)}}function $n(n){var r=n,a=n;if(n.alternate)for(;r.return;)r=r.return;else{n=r;do r=n,(r.flags&4098)!==0&&(a=r.return),n=r.return;while(n)}return r.tag===3?a:null}function yd(n){if(n.tag===13){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function Sd(n){if($n(n)!==n)throw Error(i(188))}function Ry(n){var r=n.alternate;if(!r){if(r=$n(n),r===null)throw Error(i(188));return r!==n?null:n}for(var a=n,u=r;;){var f=a.return;if(f===null)break;var g=f.alternate;if(g===null){if(u=f.return,u!==null){a=u;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===a)return Sd(f),n;if(g===u)return Sd(f),r;g=g.sibling}throw Error(i(188))}if(a.return!==u.return)a=f,u=g;else{for(var k=!1,B=f.child;B;){if(B===a){k=!0,a=f,u=g;break}if(B===u){k=!0,u=f,a=g;break}B=B.sibling}if(!k){for(B=g.child;B;){if(B===a){k=!0,a=g,u=f;break}if(B===u){k=!0,u=g,a=f;break}B=B.sibling}if(!k)throw Error(i(189))}}if(a.alternate!==u)throw Error(i(190))}if(a.tag!==3)throw Error(i(188));return a.stateNode.current===a?n:r}function wd(n){return n=Ry(n),n!==null?bd(n):null}function bd(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var r=bd(n);if(r!==null)return r;n=n.sibling}return null}var Cd=t.unstable_scheduleCallback,xd=t.unstable_cancelCallback,Py=t.unstable_shouldYield,Dy=t.unstable_requestPaint,St=t.unstable_now,My=t.unstable_getCurrentPriorityLevel,ml=t.unstable_ImmediatePriority,kd=t.unstable_UserBlockingPriority,go=t.unstable_NormalPriority,Ly=t.unstable_LowPriority,Ed=t.unstable_IdlePriority,vo=null,Fi=null;function jy(n){if(Fi&&typeof Fi.onCommitFiberRoot=="function")try{Fi.onCommitFiberRoot(vo,n,void 0,(n.current.flags&128)===128)}catch{}}var Li=Math.clz32?Math.clz32:By,Ty=Math.log,Ay=Math.LN2;function By(n){return n>>>=0,n===0?32:31-(Ty(n)/Ay|0)|0}var _o=64,yo=4194304;function as(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function So(n,r){var a=n.pendingLanes;if(a===0)return 0;var u=0,f=n.suspendedLanes,g=n.pingedLanes,k=a&268435455;if(k!==0){var B=k&~f;B!==0?u=as(B):(g&=k,g!==0&&(u=as(g)))}else k=a&~f,k!==0?u=as(k):g!==0&&(u=as(g));if(u===0)return 0;if(r!==0&&r!==u&&(r&f)===0&&(f=u&-u,g=r&-r,f>=g||f===16&&(g&4194240)!==0))return r;if((u&4)!==0&&(u|=a&16),r=n.entangledLanes,r!==0)for(n=n.entanglements,r&=u;0<r;)a=31-Li(r),f=1<<a,u|=n[a],r&=~f;return u}function Iy(n,r){switch(n){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Oy(n,r){for(var a=n.suspendedLanes,u=n.pingedLanes,f=n.expirationTimes,g=n.pendingLanes;0<g;){var k=31-Li(g),B=1<<k,$=f[k];$===-1?((B&a)===0||(B&u)!==0)&&(f[k]=Iy(B,r)):$<=r&&(n.expiredLanes|=B),g&=~B}}function gl(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function Nd(){var n=_o;return _o<<=1,(_o&4194240)===0&&(_o=64),n}function vl(n){for(var r=[],a=0;31>a;a++)r.push(n);return r}function ls(n,r,a){n.pendingLanes|=r,r!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,r=31-Li(r),n[r]=a}function zy(n,r){var a=n.pendingLanes&~r;n.pendingLanes=r,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=r,n.mutableReadLanes&=r,n.entangledLanes&=r,r=n.entanglements;var u=n.eventTimes;for(n=n.expirationTimes;0<a;){var f=31-Li(a),g=1<<f;r[f]=0,u[f]=-1,n[f]=-1,a&=~g}}function _l(n,r){var a=n.entangledLanes|=r;for(n=n.entanglements;a;){var u=31-Li(a),f=1<<u;f&r|n[u]&r&&(n[u]|=r),a&=~f}}var nt=0;function Rd(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var Pd,yl,Dd,Md,Ld,Sl=!1,wo=[],pn=null,mn=null,gn=null,cs=new Map,us=new Map,vn=[],Fy="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 jd(n,r){switch(n){case"focusin":case"focusout":pn=null;break;case"dragenter":case"dragleave":mn=null;break;case"mouseover":case"mouseout":gn=null;break;case"pointerover":case"pointerout":cs.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":us.delete(r.pointerId)}}function hs(n,r,a,u,f,g){return n===null||n.nativeEvent!==g?(n={blockedOn:r,domEventName:a,eventSystemFlags:u,nativeEvent:g,targetContainers:[f]},r!==null&&(r=ks(r),r!==null&&yl(r)),n):(n.eventSystemFlags|=u,r=n.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),n)}function Hy(n,r,a,u,f){switch(r){case"focusin":return pn=hs(pn,n,r,a,u,f),!0;case"dragenter":return mn=hs(mn,n,r,a,u,f),!0;case"mouseover":return gn=hs(gn,n,r,a,u,f),!0;case"pointerover":var g=f.pointerId;return cs.set(g,hs(cs.get(g)||null,n,r,a,u,f)),!0;case"gotpointercapture":return g=f.pointerId,us.set(g,hs(us.get(g)||null,n,r,a,u,f)),!0}return!1}function Td(n){var r=Wn(n.target);if(r!==null){var a=$n(r);if(a!==null){if(r=a.tag,r===13){if(r=yd(a),r!==null){n.blockedOn=r,Ld(n.priority,function(){Dd(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){n.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}n.blockedOn=null}function bo(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var a=bl(n.domEventName,n.eventSystemFlags,r[0],n.nativeEvent);if(a===null){a=n.nativeEvent;var u=new a.constructor(a.type,a);hi=u,a.target.dispatchEvent(u),hi=null}else return r=ks(a),r!==null&&yl(r),n.blockedOn=a,!1;r.shift()}return!0}function Ad(n,r,a){bo(n)&&a.delete(r)}function $y(){Sl=!1,pn!==null&&bo(pn)&&(pn=null),mn!==null&&bo(mn)&&(mn=null),gn!==null&&bo(gn)&&(gn=null),cs.forEach(Ad),us.forEach(Ad)}function ds(n,r){n.blockedOn===r&&(n.blockedOn=null,Sl||(Sl=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,$y)))}function fs(n){function r(f){return ds(f,n)}if(0<wo.length){ds(wo[0],n);for(var a=1;a<wo.length;a++){var u=wo[a];u.blockedOn===n&&(u.blockedOn=null)}}for(pn!==null&&ds(pn,n),mn!==null&&ds(mn,n),gn!==null&&ds(gn,n),cs.forEach(r),us.forEach(r),a=0;a<vn.length;a++)u=vn[a],u.blockedOn===n&&(u.blockedOn=null);for(;0<vn.length&&(a=vn[0],a.blockedOn===null);)Td(a),a.blockedOn===null&&vn.shift()}var _r=T.ReactCurrentBatchConfig,Co=!0;function Wy(n,r,a,u){var f=nt,g=_r.transition;_r.transition=null;try{nt=1,wl(n,r,a,u)}finally{nt=f,_r.transition=g}}function Uy(n,r,a,u){var f=nt,g=_r.transition;_r.transition=null;try{nt=4,wl(n,r,a,u)}finally{nt=f,_r.transition=g}}function wl(n,r,a,u){if(Co){var f=bl(n,r,a,u);if(f===null)zl(n,r,u,xo,a),jd(n,u);else if(Hy(f,n,r,a,u))u.stopPropagation();else if(jd(n,u),r&4&&-1<Fy.indexOf(n)){for(;f!==null;){var g=ks(f);if(g!==null&&Pd(g),g=bl(n,r,a,u),g===null&&zl(n,r,u,xo,a),g===f)break;f=g}f!==null&&u.stopPropagation()}else zl(n,r,u,null,a)}}var xo=null;function bl(n,r,a,u){if(xo=null,n=ul(u),n=Wn(n),n!==null)if(r=$n(n),r===null)n=null;else if(a=r.tag,a===13){if(n=yd(r),n!==null)return n;n=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;n=null}else r!==n&&(n=null);return xo=n,null}function Bd(n){switch(n){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(My()){case ml:return 1;case kd:return 4;case go:case Ly:return 16;case Ed:return 536870912;default:return 16}default:return 16}}var _n=null,Cl=null,ko=null;function Id(){if(ko)return ko;var n,r=Cl,a=r.length,u,f="value"in _n?_n.value:_n.textContent,g=f.length;for(n=0;n<a&&r[n]===f[n];n++);var k=a-n;for(u=1;u<=k&&r[a-u]===f[g-u];u++);return ko=f.slice(n,1<u?1-u:void 0)}function Eo(n){var r=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&r===13&&(n=13)):n=r,n===10&&(n=13),32<=n||n===13?n:0}function No(){return!0}function Od(){return!1}function di(n){function r(a,u,f,g,k){this._reactName=a,this._targetInst=f,this.type=u,this.nativeEvent=g,this.target=k,this.currentTarget=null;for(var B in n)n.hasOwnProperty(B)&&(a=n[B],this[B]=a?a(g):g[B]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?No:Od,this.isPropagationStopped=Od,this}return K(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=No)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=No)},persist:function(){},isPersistent:No}),r}var yr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},xl=di(yr),ps=K({},yr,{view:0,detail:0}),Ky=di(ps),kl,El,ms,Ro=K({},ps,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Rl,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==ms&&(ms&&n.type==="mousemove"?(kl=n.screenX-ms.screenX,El=n.screenY-ms.screenY):El=kl=0,ms=n),kl)},movementY:function(n){return"movementY"in n?n.movementY:El}}),zd=di(Ro),qy=K({},Ro,{dataTransfer:0}),Vy=di(qy),Yy=K({},ps,{relatedTarget:0}),Nl=di(Yy),Xy=K({},yr,{animationName:0,elapsedTime:0,pseudoElement:0}),Gy=di(Xy),Qy=K({},yr,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),Jy=di(Qy),Zy=K({},yr,{data:0}),Fd=di(Zy),eS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},tS={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},iS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function nS(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=iS[n])?!!r[n]:!1}function Rl(){return nS}var rS=K({},ps,{key:function(n){if(n.key){var r=eS[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=Eo(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?tS[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Rl,charCode:function(n){return n.type==="keypress"?Eo(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Eo(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),sS=di(rS),oS=K({},Ro,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Hd=di(oS),aS=K({},ps,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Rl}),lS=di(aS),cS=K({},yr,{propertyName:0,elapsedTime:0,pseudoElement:0}),uS=di(cS),hS=K({},Ro,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),dS=di(hS),fS=[9,13,27,32],Pl=d&&"CompositionEvent"in window,gs=null;d&&"documentMode"in document&&(gs=document.documentMode);var pS=d&&"TextEvent"in window&&!gs,$d=d&&(!Pl||gs&&8<gs&&11>=gs),Wd=" ",Ud=!1;function Kd(n,r){switch(n){case"keyup":return fS.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function qd(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Sr=!1;function mS(n,r){switch(n){case"compositionend":return qd(r);case"keypress":return r.which!==32?null:(Ud=!0,Wd);case"textInput":return n=r.data,n===Wd&&Ud?null:n;default:return null}}function gS(n,r){if(Sr)return n==="compositionend"||!Pl&&Kd(n,r)?(n=Id(),ko=Cl=_n=null,Sr=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return $d&&r.locale!=="ko"?null:r.data;default:return null}}var vS={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Vd(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!vS[n.type]:r==="textarea"}function Yd(n,r,a,u){pd(u),r=jo(r,"onChange"),0<r.length&&(a=new xl("onChange","change",null,a,u),n.push({event:a,listeners:r}))}var vs=null,_s=null;function _S(n){ff(n,0)}function Po(n){var r=kr(n);if(De(r))return n}function yS(n,r){if(n==="change")return r}var Xd=!1;if(d){var Dl;if(d){var Ml="oninput"in document;if(!Ml){var Gd=document.createElement("div");Gd.setAttribute("oninput","return;"),Ml=typeof Gd.oninput=="function"}Dl=Ml}else Dl=!1;Xd=Dl&&(!document.documentMode||9<document.documentMode)}function Qd(){vs&&(vs.detachEvent("onpropertychange",Jd),_s=vs=null)}function Jd(n){if(n.propertyName==="value"&&Po(_s)){var r=[];Yd(r,_s,n,ul(n)),_d(_S,r)}}function SS(n,r,a){n==="focusin"?(Qd(),vs=r,_s=a,vs.attachEvent("onpropertychange",Jd)):n==="focusout"&&Qd()}function wS(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Po(_s)}function bS(n,r){if(n==="click")return Po(r)}function CS(n,r){if(n==="input"||n==="change")return Po(r)}function xS(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var ji=typeof Object.is=="function"?Object.is:xS;function ys(n,r){if(ji(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;var a=Object.keys(n),u=Object.keys(r);if(a.length!==u.length)return!1;for(u=0;u<a.length;u++){var f=a[u];if(!m.call(r,f)||!ji(n[f],r[f]))return!1}return!0}function Zd(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function ef(n,r){var a=Zd(n);n=0;for(var u;a;){if(a.nodeType===3){if(u=n+a.textContent.length,n<=r&&u>=r)return{node:a,offset:r-n};n=u}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Zd(a)}}function tf(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?tf(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function nf(){for(var n=window,r=ge();r instanceof n.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)n=r.contentWindow;else break;r=ge(n.document)}return r}function Ll(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r&&(r==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||r==="textarea"||n.contentEditable==="true")}function kS(n){var r=nf(),a=n.focusedElem,u=n.selectionRange;if(r!==a&&a&&a.ownerDocument&&tf(a.ownerDocument.documentElement,a)){if(u!==null&&Ll(a)){if(r=u.start,n=u.end,n===void 0&&(n=r),"selectionStart"in a)a.selectionStart=r,a.selectionEnd=Math.min(n,a.value.length);else if(n=(r=a.ownerDocument||document)&&r.defaultView||window,n.getSelection){n=n.getSelection();var f=a.textContent.length,g=Math.min(u.start,f);u=u.end===void 0?g:Math.min(u.end,f),!n.extend&&g>u&&(f=u,u=g,g=f),f=ef(a,g);var k=ef(a,u);f&&k&&(n.rangeCount!==1||n.anchorNode!==f.node||n.anchorOffset!==f.offset||n.focusNode!==k.node||n.focusOffset!==k.offset)&&(r=r.createRange(),r.setStart(f.node,f.offset),n.removeAllRanges(),g>u?(n.addRange(r),n.extend(k.node,k.offset)):(r.setEnd(k.node,k.offset),n.addRange(r)))}}for(r=[],n=a;n=n.parentNode;)n.nodeType===1&&r.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<r.length;a++)n=r[a],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var ES=d&&"documentMode"in document&&11>=document.documentMode,wr=null,jl=null,Ss=null,Tl=!1;function rf(n,r,a){var u=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Tl||wr==null||wr!==ge(u)||(u=wr,"selectionStart"in u&&Ll(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),Ss&&ys(Ss,u)||(Ss=u,u=jo(jl,"onSelect"),0<u.length&&(r=new xl("onSelect","select",null,r,a),n.push({event:r,listeners:u}),r.target=wr)))}function Do(n,r){var a={};return a[n.toLowerCase()]=r.toLowerCase(),a["Webkit"+n]="webkit"+r,a["Moz"+n]="moz"+r,a}var br={animationend:Do("Animation","AnimationEnd"),animationiteration:Do("Animation","AnimationIteration"),animationstart:Do("Animation","AnimationStart"),transitionend:Do("Transition","TransitionEnd")},Al={},sf={};d&&(sf=document.createElement("div").style,"AnimationEvent"in window||(delete br.animationend.animation,delete br.animationiteration.animation,delete br.animationstart.animation),"TransitionEvent"in window||delete br.transitionend.transition);function Mo(n){if(Al[n])return Al[n];if(!br[n])return n;var r=br[n],a;for(a in r)if(r.hasOwnProperty(a)&&a in sf)return Al[n]=r[a];return n}var of=Mo("animationend"),af=Mo("animationiteration"),lf=Mo("animationstart"),cf=Mo("transitionend"),uf=new Map,hf="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 yn(n,r){uf.set(n,r),l(r,[n])}for(var Bl=0;Bl<hf.length;Bl++){var Il=hf[Bl],NS=Il.toLowerCase(),RS=Il[0].toUpperCase()+Il.slice(1);yn(NS,"on"+RS)}yn(of,"onAnimationEnd"),yn(af,"onAnimationIteration"),yn(lf,"onAnimationStart"),yn("dblclick","onDoubleClick"),yn("focusin","onFocus"),yn("focusout","onBlur"),yn(cf,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("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 ws="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),PS=new Set("cancel close invalid load scroll toggle".split(" ").concat(ws));function df(n,r,a){var u=n.type||"unknown-event";n.currentTarget=a,Ny(u,r,void 0,n),n.currentTarget=null}function ff(n,r){r=(r&4)!==0;for(var a=0;a<n.length;a++){var u=n[a],f=u.event;u=u.listeners;e:{var g=void 0;if(r)for(var k=u.length-1;0<=k;k--){var B=u[k],$=B.instance,re=B.currentTarget;if(B=B.listener,$!==g&&f.isPropagationStopped())break e;df(f,B,re),g=$}else for(k=0;k<u.length;k++){if(B=u[k],$=B.instance,re=B.currentTarget,B=B.listener,$!==g&&f.isPropagationStopped())break e;df(f,B,re),g=$}}}if(mo)throw n=pl,mo=!1,pl=null,n}function at(n,r){var a=r[Kl];a===void 0&&(a=r[Kl]=new Set);var u=n+"__bubble";a.has(u)||(pf(r,n,2,!1),a.add(u))}function Ol(n,r,a){var u=0;r&&(u|=4),pf(a,n,u,r)}var Lo="_reactListening"+Math.random().toString(36).slice(2);function bs(n){if(!n[Lo]){n[Lo]=!0,s.forEach(function(a){a!=="selectionchange"&&(PS.has(a)||Ol(a,!1,n),Ol(a,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Lo]||(r[Lo]=!0,Ol("selectionchange",!1,r))}}function pf(n,r,a,u){switch(Bd(r)){case 1:var f=Wy;break;case 4:f=Uy;break;default:f=wl}a=f.bind(null,r,a,n),f=void 0,!fl||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),u?f!==void 0?n.addEventListener(r,a,{capture:!0,passive:f}):n.addEventListener(r,a,!0):f!==void 0?n.addEventListener(r,a,{passive:f}):n.addEventListener(r,a,!1)}function zl(n,r,a,u,f){var g=u;if((r&1)===0&&(r&2)===0&&u!==null)e:for(;;){if(u===null)return;var k=u.tag;if(k===3||k===4){var B=u.stateNode.containerInfo;if(B===f||B.nodeType===8&&B.parentNode===f)break;if(k===4)for(k=u.return;k!==null;){var $=k.tag;if(($===3||$===4)&&($=k.stateNode.containerInfo,$===f||$.nodeType===8&&$.parentNode===f))return;k=k.return}for(;B!==null;){if(k=Wn(B),k===null)return;if($=k.tag,$===5||$===6){u=g=k;continue e}B=B.parentNode}}u=u.return}_d(function(){var re=g,pe=ul(a),me=[];e:{var de=uf.get(n);if(de!==void 0){var ke=xl,Me=n;switch(n){case"keypress":if(Eo(a)===0)break e;case"keydown":case"keyup":ke=sS;break;case"focusin":Me="focus",ke=Nl;break;case"focusout":Me="blur",ke=Nl;break;case"beforeblur":case"afterblur":ke=Nl;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=zd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ke=Vy;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ke=lS;break;case of:case af:case lf:ke=Gy;break;case cf:ke=uS;break;case"scroll":ke=Ky;break;case"wheel":ke=dS;break;case"copy":case"cut":case"paste":ke=Jy;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ke=Hd}var je=(r&4)!==0,wt=!je&&n==="scroll",J=je?de!==null?de+"Capture":null:de;je=[];for(var V=re,te;V!==null;){te=V;var Se=te.stateNode;if(te.tag===5&&Se!==null&&(te=Se,J!==null&&(Se=rs(V,J),Se!=null&&je.push(Cs(V,Se,te)))),wt)break;V=V.return}0<je.length&&(de=new ke(de,Me,null,a,pe),me.push({event:de,listeners:je}))}}if((r&7)===0){e:{if(de=n==="mouseover"||n==="pointerover",ke=n==="mouseout"||n==="pointerout",de&&a!==hi&&(Me=a.relatedTarget||a.fromElement)&&(Wn(Me)||Me[en]))break e;if((ke||de)&&(de=pe.window===pe?pe:(de=pe.ownerDocument)?de.defaultView||de.parentWindow:window,ke?(Me=a.relatedTarget||a.toElement,ke=re,Me=Me?Wn(Me):null,Me!==null&&(wt=$n(Me),Me!==wt||Me.tag!==5&&Me.tag!==6)&&(Me=null)):(ke=null,Me=re),ke!==Me)){if(je=zd,Se="onMouseLeave",J="onMouseEnter",V="mouse",(n==="pointerout"||n==="pointerover")&&(je=Hd,Se="onPointerLeave",J="onPointerEnter",V="pointer"),wt=ke==null?de:kr(ke),te=Me==null?de:kr(Me),de=new je(Se,V+"leave",ke,a,pe),de.target=wt,de.relatedTarget=te,Se=null,Wn(pe)===re&&(je=new je(J,V+"enter",Me,a,pe),je.target=te,je.relatedTarget=wt,Se=je),wt=Se,ke&&Me)t:{for(je=ke,J=Me,V=0,te=je;te;te=Cr(te))V++;for(te=0,Se=J;Se;Se=Cr(Se))te++;for(;0<V-te;)je=Cr(je),V--;for(;0<te-V;)J=Cr(J),te--;for(;V--;){if(je===J||J!==null&&je===J.alternate)break t;je=Cr(je),J=Cr(J)}je=null}else je=null;ke!==null&&mf(me,de,ke,je,!1),Me!==null&&wt!==null&&mf(me,wt,Me,je,!0)}}e:{if(de=re?kr(re):window,ke=de.nodeName&&de.nodeName.toLowerCase(),ke==="select"||ke==="input"&&de.type==="file")var Ae=yS;else if(Vd(de))if(Xd)Ae=CS;else{Ae=wS;var Oe=SS}else(ke=de.nodeName)&&ke.toLowerCase()==="input"&&(de.type==="checkbox"||de.type==="radio")&&(Ae=bS);if(Ae&&(Ae=Ae(n,re))){Yd(me,Ae,a,pe);break e}Oe&&Oe(n,de,re),n==="focusout"&&(Oe=de._wrapperState)&&Oe.controlled&&de.type==="number"&&ee(de,"number",de.value)}switch(Oe=re?kr(re):window,n){case"focusin":(Vd(Oe)||Oe.contentEditable==="true")&&(wr=Oe,jl=re,Ss=null);break;case"focusout":Ss=jl=wr=null;break;case"mousedown":Tl=!0;break;case"contextmenu":case"mouseup":case"dragend":Tl=!1,rf(me,a,pe);break;case"selectionchange":if(ES)break;case"keydown":case"keyup":rf(me,a,pe)}var ze;if(Pl)e:{switch(n){case"compositionstart":var He="onCompositionStart";break e;case"compositionend":He="onCompositionEnd";break e;case"compositionupdate":He="onCompositionUpdate";break e}He=void 0}else Sr?Kd(n,a)&&(He="onCompositionEnd"):n==="keydown"&&a.keyCode===229&&(He="onCompositionStart");He&&($d&&a.locale!=="ko"&&(Sr||He!=="onCompositionStart"?He==="onCompositionEnd"&&Sr&&(ze=Id()):(_n=pe,Cl="value"in _n?_n.value:_n.textContent,Sr=!0)),Oe=jo(re,He),0<Oe.length&&(He=new Fd(He,n,null,a,pe),me.push({event:He,listeners:Oe}),ze?He.data=ze:(ze=qd(a),ze!==null&&(He.data=ze)))),(ze=pS?mS(n,a):gS(n,a))&&(re=jo(re,"onBeforeInput"),0<re.length&&(pe=new Fd("onBeforeInput","beforeinput",null,a,pe),me.push({event:pe,listeners:re}),pe.data=ze))}ff(me,r)})}function Cs(n,r,a){return{instance:n,listener:r,currentTarget:a}}function jo(n,r){for(var a=r+"Capture",u=[];n!==null;){var f=n,g=f.stateNode;f.tag===5&&g!==null&&(f=g,g=rs(n,a),g!=null&&u.unshift(Cs(n,g,f)),g=rs(n,r),g!=null&&u.push(Cs(n,g,f))),n=n.return}return u}function Cr(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function mf(n,r,a,u,f){for(var g=r._reactName,k=[];a!==null&&a!==u;){var B=a,$=B.alternate,re=B.stateNode;if($!==null&&$===u)break;B.tag===5&&re!==null&&(B=re,f?($=rs(a,g),$!=null&&k.unshift(Cs(a,$,B))):f||($=rs(a,g),$!=null&&k.push(Cs(a,$,B)))),a=a.return}k.length!==0&&n.push({event:r,listeners:k})}var DS=/\r\n?/g,MS=/\u0000|\uFFFD/g;function gf(n){return(typeof n=="string"?n:""+n).replace(DS,`
|
|
38
|
+
`).replace(MS,"")}function To(n,r,a){if(r=gf(r),gf(n)!==r&&a)throw Error(i(425))}function Ao(){}var Fl=null,Hl=null;function $l(n,r){return n==="textarea"||n==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Wl=typeof setTimeout=="function"?setTimeout:void 0,LS=typeof clearTimeout=="function"?clearTimeout:void 0,vf=typeof Promise=="function"?Promise:void 0,jS=typeof queueMicrotask=="function"?queueMicrotask:typeof vf<"u"?function(n){return vf.resolve(null).then(n).catch(TS)}:Wl;function TS(n){setTimeout(function(){throw n})}function Ul(n,r){var a=r,u=0;do{var f=a.nextSibling;if(n.removeChild(a),f&&f.nodeType===8)if(a=f.data,a==="/$"){if(u===0){n.removeChild(f),fs(r);return}u--}else a!=="$"&&a!=="$?"&&a!=="$!"||u++;a=f}while(a);fs(r)}function Sn(n){for(;n!=null;n=n.nextSibling){var r=n.nodeType;if(r===1||r===3)break;if(r===8){if(r=n.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return n}function _f(n){n=n.previousSibling;for(var r=0;n;){if(n.nodeType===8){var a=n.data;if(a==="$"||a==="$!"||a==="$?"){if(r===0)return n;r--}else a==="/$"&&r++}n=n.previousSibling}return null}var xr=Math.random().toString(36).slice(2),Hi="__reactFiber$"+xr,xs="__reactProps$"+xr,en="__reactContainer$"+xr,Kl="__reactEvents$"+xr,AS="__reactListeners$"+xr,BS="__reactHandles$"+xr;function Wn(n){var r=n[Hi];if(r)return r;for(var a=n.parentNode;a;){if(r=a[en]||a[Hi]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(n=_f(n);n!==null;){if(a=n[Hi])return a;n=_f(n)}return r}n=a,a=n.parentNode}return null}function ks(n){return n=n[Hi]||n[en],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function kr(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(i(33))}function Bo(n){return n[xs]||null}var ql=[],Er=-1;function wn(n){return{current:n}}function lt(n){0>Er||(n.current=ql[Er],ql[Er]=null,Er--)}function ot(n,r){Er++,ql[Er]=n.current,n.current=r}var bn={},qt=wn(bn),ii=wn(!1),Un=bn;function Nr(n,r){var a=n.type.contextTypes;if(!a)return bn;var u=n.stateNode;if(u&&u.__reactInternalMemoizedUnmaskedChildContext===r)return u.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in a)f[g]=r[g];return u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=r,n.__reactInternalMemoizedMaskedChildContext=f),f}function ni(n){return n=n.childContextTypes,n!=null}function Io(){lt(ii),lt(qt)}function yf(n,r,a){if(qt.current!==bn)throw Error(i(168));ot(qt,r),ot(ii,a)}function Sf(n,r,a){var u=n.stateNode;if(r=r.childContextTypes,typeof u.getChildContext!="function")return a;u=u.getChildContext();for(var f in u)if(!(f in r))throw Error(i(108,ye(n)||"Unknown",f));return K({},a,u)}function Oo(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||bn,Un=qt.current,ot(qt,n),ot(ii,ii.current),!0}function wf(n,r,a){var u=n.stateNode;if(!u)throw Error(i(169));a?(n=Sf(n,r,Un),u.__reactInternalMemoizedMergedChildContext=n,lt(ii),lt(qt),ot(qt,n)):lt(ii),ot(ii,a)}var tn=null,zo=!1,Vl=!1;function bf(n){tn===null?tn=[n]:tn.push(n)}function IS(n){zo=!0,bf(n)}function Cn(){if(!Vl&&tn!==null){Vl=!0;var n=0,r=nt;try{var a=tn;for(nt=1;n<a.length;n++){var u=a[n];do u=u(!0);while(u!==null)}tn=null,zo=!1}catch(f){throw tn!==null&&(tn=tn.slice(n+1)),Cd(ml,Cn),f}finally{nt=r,Vl=!1}}return null}var Rr=[],Pr=0,Fo=null,Ho=0,wi=[],bi=0,Kn=null,nn=1,rn="";function qn(n,r){Rr[Pr++]=Ho,Rr[Pr++]=Fo,Fo=n,Ho=r}function Cf(n,r,a){wi[bi++]=nn,wi[bi++]=rn,wi[bi++]=Kn,Kn=n;var u=nn;n=rn;var f=32-Li(u)-1;u&=~(1<<f),a+=1;var g=32-Li(r)+f;if(30<g){var k=f-f%5;g=(u&(1<<k)-1).toString(32),u>>=k,f-=k,nn=1<<32-Li(r)+f|a<<f|u,rn=g+n}else nn=1<<g|a<<f|u,rn=n}function Yl(n){n.return!==null&&(qn(n,1),Cf(n,1,0))}function Xl(n){for(;n===Fo;)Fo=Rr[--Pr],Rr[Pr]=null,Ho=Rr[--Pr],Rr[Pr]=null;for(;n===Kn;)Kn=wi[--bi],wi[bi]=null,rn=wi[--bi],wi[bi]=null,nn=wi[--bi],wi[bi]=null}var fi=null,pi=null,ut=!1,Ti=null;function xf(n,r){var a=Ei(5,null,null,0);a.elementType="DELETED",a.stateNode=r,a.return=n,r=n.deletions,r===null?(n.deletions=[a],n.flags|=16):r.push(a)}function kf(n,r){switch(n.tag){case 5:var a=n.type;return r=r.nodeType!==1||a.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(n.stateNode=r,fi=n,pi=Sn(r.firstChild),!0):!1;case 6:return r=n.pendingProps===""||r.nodeType!==3?null:r,r!==null?(n.stateNode=r,fi=n,pi=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(a=Kn!==null?{id:nn,overflow:rn}:null,n.memoizedState={dehydrated:r,treeContext:a,retryLane:1073741824},a=Ei(18,null,null,0),a.stateNode=r,a.return=n,n.child=a,fi=n,pi=null,!0):!1;default:return!1}}function Gl(n){return(n.mode&1)!==0&&(n.flags&128)===0}function Ql(n){if(ut){var r=pi;if(r){var a=r;if(!kf(n,r)){if(Gl(n))throw Error(i(418));r=Sn(a.nextSibling);var u=fi;r&&kf(n,r)?xf(u,a):(n.flags=n.flags&-4097|2,ut=!1,fi=n)}}else{if(Gl(n))throw Error(i(418));n.flags=n.flags&-4097|2,ut=!1,fi=n}}}function Ef(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;fi=n}function $o(n){if(n!==fi)return!1;if(!ut)return Ef(n),ut=!0,!1;var r;if((r=n.tag!==3)&&!(r=n.tag!==5)&&(r=n.type,r=r!=="head"&&r!=="body"&&!$l(n.type,n.memoizedProps)),r&&(r=pi)){if(Gl(n))throw Nf(),Error(i(418));for(;r;)xf(n,r),r=Sn(r.nextSibling)}if(Ef(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(317));e:{for(n=n.nextSibling,r=0;n;){if(n.nodeType===8){var a=n.data;if(a==="/$"){if(r===0){pi=Sn(n.nextSibling);break e}r--}else a!=="$"&&a!=="$!"&&a!=="$?"||r++}n=n.nextSibling}pi=null}}else pi=fi?Sn(n.stateNode.nextSibling):null;return!0}function Nf(){for(var n=pi;n;)n=Sn(n.nextSibling)}function Dr(){pi=fi=null,ut=!1}function Jl(n){Ti===null?Ti=[n]:Ti.push(n)}var OS=T.ReactCurrentBatchConfig;function Es(n,r,a){if(n=a.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(a._owner){if(a=a._owner,a){if(a.tag!==1)throw Error(i(309));var u=a.stateNode}if(!u)throw Error(i(147,n));var f=u,g=""+n;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===g?r.ref:(r=function(k){var B=f.refs;k===null?delete B[g]:B[g]=k},r._stringRef=g,r)}if(typeof n!="string")throw Error(i(284));if(!a._owner)throw Error(i(290,n))}return n}function Wo(n,r){throw n=Object.prototype.toString.call(r),Error(i(31,n==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":n))}function Rf(n){var r=n._init;return r(n._payload)}function Pf(n){function r(J,V){if(n){var te=J.deletions;te===null?(J.deletions=[V],J.flags|=16):te.push(V)}}function a(J,V){if(!n)return null;for(;V!==null;)r(J,V),V=V.sibling;return null}function u(J,V){for(J=new Map;V!==null;)V.key!==null?J.set(V.key,V):J.set(V.index,V),V=V.sibling;return J}function f(J,V){return J=Mn(J,V),J.index=0,J.sibling=null,J}function g(J,V,te){return J.index=te,n?(te=J.alternate,te!==null?(te=te.index,te<V?(J.flags|=2,V):te):(J.flags|=2,V)):(J.flags|=1048576,V)}function k(J){return n&&J.alternate===null&&(J.flags|=2),J}function B(J,V,te,Se){return V===null||V.tag!==6?(V=Wc(te,J.mode,Se),V.return=J,V):(V=f(V,te),V.return=J,V)}function $(J,V,te,Se){var Ae=te.type;return Ae===I?pe(J,V,te.props.children,Se,te.key):V!==null&&(V.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===D&&Rf(Ae)===V.type)?(Se=f(V,te.props),Se.ref=Es(J,V,te),Se.return=J,Se):(Se=fa(te.type,te.key,te.props,null,J.mode,Se),Se.ref=Es(J,V,te),Se.return=J,Se)}function re(J,V,te,Se){return V===null||V.tag!==4||V.stateNode.containerInfo!==te.containerInfo||V.stateNode.implementation!==te.implementation?(V=Uc(te,J.mode,Se),V.return=J,V):(V=f(V,te.children||[]),V.return=J,V)}function pe(J,V,te,Se,Ae){return V===null||V.tag!==7?(V=er(te,J.mode,Se,Ae),V.return=J,V):(V=f(V,te),V.return=J,V)}function me(J,V,te){if(typeof V=="string"&&V!==""||typeof V=="number")return V=Wc(""+V,J.mode,te),V.return=J,V;if(typeof V=="object"&&V!==null){switch(V.$$typeof){case Q:return te=fa(V.type,V.key,V.props,null,J.mode,te),te.ref=Es(J,null,V),te.return=J,te;case H:return V=Uc(V,J.mode,te),V.return=J,V;case D:var Se=V._init;return me(J,Se(V._payload),te)}if(_e(V)||ie(V))return V=er(V,J.mode,te,null),V.return=J,V;Wo(J,V)}return null}function de(J,V,te,Se){var Ae=V!==null?V.key:null;if(typeof te=="string"&&te!==""||typeof te=="number")return Ae!==null?null:B(J,V,""+te,Se);if(typeof te=="object"&&te!==null){switch(te.$$typeof){case Q:return te.key===Ae?$(J,V,te,Se):null;case H:return te.key===Ae?re(J,V,te,Se):null;case D:return Ae=te._init,de(J,V,Ae(te._payload),Se)}if(_e(te)||ie(te))return Ae!==null?null:pe(J,V,te,Se,null);Wo(J,te)}return null}function ke(J,V,te,Se,Ae){if(typeof Se=="string"&&Se!==""||typeof Se=="number")return J=J.get(te)||null,B(V,J,""+Se,Ae);if(typeof Se=="object"&&Se!==null){switch(Se.$$typeof){case Q:return J=J.get(Se.key===null?te:Se.key)||null,$(V,J,Se,Ae);case H:return J=J.get(Se.key===null?te:Se.key)||null,re(V,J,Se,Ae);case D:var Oe=Se._init;return ke(J,V,te,Oe(Se._payload),Ae)}if(_e(Se)||ie(Se))return J=J.get(te)||null,pe(V,J,Se,Ae,null);Wo(V,Se)}return null}function Me(J,V,te,Se){for(var Ae=null,Oe=null,ze=V,He=V=0,Tt=null;ze!==null&&He<te.length;He++){ze.index>He?(Tt=ze,ze=null):Tt=ze.sibling;var tt=de(J,ze,te[He],Se);if(tt===null){ze===null&&(ze=Tt);break}n&&ze&&tt.alternate===null&&r(J,ze),V=g(tt,V,He),Oe===null?Ae=tt:Oe.sibling=tt,Oe=tt,ze=Tt}if(He===te.length)return a(J,ze),ut&&qn(J,He),Ae;if(ze===null){for(;He<te.length;He++)ze=me(J,te[He],Se),ze!==null&&(V=g(ze,V,He),Oe===null?Ae=ze:Oe.sibling=ze,Oe=ze);return ut&&qn(J,He),Ae}for(ze=u(J,ze);He<te.length;He++)Tt=ke(ze,J,He,te[He],Se),Tt!==null&&(n&&Tt.alternate!==null&&ze.delete(Tt.key===null?He:Tt.key),V=g(Tt,V,He),Oe===null?Ae=Tt:Oe.sibling=Tt,Oe=Tt);return n&&ze.forEach(function(Ln){return r(J,Ln)}),ut&&qn(J,He),Ae}function je(J,V,te,Se){var Ae=ie(te);if(typeof Ae!="function")throw Error(i(150));if(te=Ae.call(te),te==null)throw Error(i(151));for(var Oe=Ae=null,ze=V,He=V=0,Tt=null,tt=te.next();ze!==null&&!tt.done;He++,tt=te.next()){ze.index>He?(Tt=ze,ze=null):Tt=ze.sibling;var Ln=de(J,ze,tt.value,Se);if(Ln===null){ze===null&&(ze=Tt);break}n&&ze&&Ln.alternate===null&&r(J,ze),V=g(Ln,V,He),Oe===null?Ae=Ln:Oe.sibling=Ln,Oe=Ln,ze=Tt}if(tt.done)return a(J,ze),ut&&qn(J,He),Ae;if(ze===null){for(;!tt.done;He++,tt=te.next())tt=me(J,tt.value,Se),tt!==null&&(V=g(tt,V,He),Oe===null?Ae=tt:Oe.sibling=tt,Oe=tt);return ut&&qn(J,He),Ae}for(ze=u(J,ze);!tt.done;He++,tt=te.next())tt=ke(ze,J,He,tt.value,Se),tt!==null&&(n&&tt.alternate!==null&&ze.delete(tt.key===null?He:tt.key),V=g(tt,V,He),Oe===null?Ae=tt:Oe.sibling=tt,Oe=tt);return n&&ze.forEach(function(vw){return r(J,vw)}),ut&&qn(J,He),Ae}function wt(J,V,te,Se){if(typeof te=="object"&&te!==null&&te.type===I&&te.key===null&&(te=te.props.children),typeof te=="object"&&te!==null){switch(te.$$typeof){case Q:e:{for(var Ae=te.key,Oe=V;Oe!==null;){if(Oe.key===Ae){if(Ae=te.type,Ae===I){if(Oe.tag===7){a(J,Oe.sibling),V=f(Oe,te.props.children),V.return=J,J=V;break e}}else if(Oe.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===D&&Rf(Ae)===Oe.type){a(J,Oe.sibling),V=f(Oe,te.props),V.ref=Es(J,Oe,te),V.return=J,J=V;break e}a(J,Oe);break}else r(J,Oe);Oe=Oe.sibling}te.type===I?(V=er(te.props.children,J.mode,Se,te.key),V.return=J,J=V):(Se=fa(te.type,te.key,te.props,null,J.mode,Se),Se.ref=Es(J,V,te),Se.return=J,J=Se)}return k(J);case H:e:{for(Oe=te.key;V!==null;){if(V.key===Oe)if(V.tag===4&&V.stateNode.containerInfo===te.containerInfo&&V.stateNode.implementation===te.implementation){a(J,V.sibling),V=f(V,te.children||[]),V.return=J,J=V;break e}else{a(J,V);break}else r(J,V);V=V.sibling}V=Uc(te,J.mode,Se),V.return=J,J=V}return k(J);case D:return Oe=te._init,wt(J,V,Oe(te._payload),Se)}if(_e(te))return Me(J,V,te,Se);if(ie(te))return je(J,V,te,Se);Wo(J,te)}return typeof te=="string"&&te!==""||typeof te=="number"?(te=""+te,V!==null&&V.tag===6?(a(J,V.sibling),V=f(V,te),V.return=J,J=V):(a(J,V),V=Wc(te,J.mode,Se),V.return=J,J=V),k(J)):a(J,V)}return wt}var Mr=Pf(!0),Df=Pf(!1),Uo=wn(null),Ko=null,Lr=null,Zl=null;function ec(){Zl=Lr=Ko=null}function tc(n){var r=Uo.current;lt(Uo),n._currentValue=r}function ic(n,r,a){for(;n!==null;){var u=n.alternate;if((n.childLanes&r)!==r?(n.childLanes|=r,u!==null&&(u.childLanes|=r)):u!==null&&(u.childLanes&r)!==r&&(u.childLanes|=r),n===a)break;n=n.return}}function jr(n,r){Ko=n,Zl=Lr=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&r)!==0&&(ri=!0),n.firstContext=null)}function Ci(n){var r=n._currentValue;if(Zl!==n)if(n={context:n,memoizedValue:r,next:null},Lr===null){if(Ko===null)throw Error(i(308));Lr=n,Ko.dependencies={lanes:0,firstContext:n}}else Lr=Lr.next=n;return r}var Vn=null;function nc(n){Vn===null?Vn=[n]:Vn.push(n)}function Mf(n,r,a,u){var f=r.interleaved;return f===null?(a.next=a,nc(r)):(a.next=f.next,f.next=a),r.interleaved=a,sn(n,u)}function sn(n,r){n.lanes|=r;var a=n.alternate;for(a!==null&&(a.lanes|=r),a=n,n=n.return;n!==null;)n.childLanes|=r,a=n.alternate,a!==null&&(a.childLanes|=r),a=n,n=n.return;return a.tag===3?a.stateNode:null}var xn=!1;function rc(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Lf(n,r){n=n.updateQueue,r.updateQueue===n&&(r.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function on(n,r){return{eventTime:n,lane:r,tag:0,payload:null,callback:null,next:null}}function kn(n,r,a){var u=n.updateQueue;if(u===null)return null;if(u=u.shared,(Ze&2)!==0){var f=u.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),u.pending=r,sn(n,a)}return f=u.interleaved,f===null?(r.next=r,nc(u)):(r.next=f.next,f.next=r),u.interleaved=r,sn(n,a)}function qo(n,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194240)!==0)){var u=r.lanes;u&=n.pendingLanes,a|=u,r.lanes=a,_l(n,a)}}function jf(n,r){var a=n.updateQueue,u=n.alternate;if(u!==null&&(u=u.updateQueue,a===u)){var f=null,g=null;if(a=a.firstBaseUpdate,a!==null){do{var k={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};g===null?f=g=k:g=g.next=k,a=a.next}while(a!==null);g===null?f=g=r:g=g.next=r}else f=g=r;a={baseState:u.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:u.shared,effects:u.effects},n.updateQueue=a;return}n=a.lastBaseUpdate,n===null?a.firstBaseUpdate=r:n.next=r,a.lastBaseUpdate=r}function Vo(n,r,a,u){var f=n.updateQueue;xn=!1;var g=f.firstBaseUpdate,k=f.lastBaseUpdate,B=f.shared.pending;if(B!==null){f.shared.pending=null;var $=B,re=$.next;$.next=null,k===null?g=re:k.next=re,k=$;var pe=n.alternate;pe!==null&&(pe=pe.updateQueue,B=pe.lastBaseUpdate,B!==k&&(B===null?pe.firstBaseUpdate=re:B.next=re,pe.lastBaseUpdate=$))}if(g!==null){var me=f.baseState;k=0,pe=re=$=null,B=g;do{var de=B.lane,ke=B.eventTime;if((u&de)===de){pe!==null&&(pe=pe.next={eventTime:ke,lane:0,tag:B.tag,payload:B.payload,callback:B.callback,next:null});e:{var Me=n,je=B;switch(de=r,ke=a,je.tag){case 1:if(Me=je.payload,typeof Me=="function"){me=Me.call(ke,me,de);break e}me=Me;break e;case 3:Me.flags=Me.flags&-65537|128;case 0:if(Me=je.payload,de=typeof Me=="function"?Me.call(ke,me,de):Me,de==null)break e;me=K({},me,de);break e;case 2:xn=!0}}B.callback!==null&&B.lane!==0&&(n.flags|=64,de=f.effects,de===null?f.effects=[B]:de.push(B))}else ke={eventTime:ke,lane:de,tag:B.tag,payload:B.payload,callback:B.callback,next:null},pe===null?(re=pe=ke,$=me):pe=pe.next=ke,k|=de;if(B=B.next,B===null){if(B=f.shared.pending,B===null)break;de=B,B=de.next,de.next=null,f.lastBaseUpdate=de,f.shared.pending=null}}while(!0);if(pe===null&&($=me),f.baseState=$,f.firstBaseUpdate=re,f.lastBaseUpdate=pe,r=f.shared.interleaved,r!==null){f=r;do k|=f.lane,f=f.next;while(f!==r)}else g===null&&(f.shared.lanes=0);Gn|=k,n.lanes=k,n.memoizedState=me}}function Tf(n,r,a){if(n=r.effects,r.effects=null,n!==null)for(r=0;r<n.length;r++){var u=n[r],f=u.callback;if(f!==null){if(u.callback=null,u=a,typeof f!="function")throw Error(i(191,f));f.call(u)}}}var Ns={},$i=wn(Ns),Rs=wn(Ns),Ps=wn(Ns);function Yn(n){if(n===Ns)throw Error(i(174));return n}function sc(n,r){switch(ot(Ps,r),ot(Rs,n),ot($i,Ns),n=r.nodeType,n){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Ee(null,"");break;default:n=n===8?r.parentNode:r,r=n.namespaceURI||null,n=n.tagName,r=Ee(r,n)}lt($i),ot($i,r)}function Tr(){lt($i),lt(Rs),lt(Ps)}function Af(n){Yn(Ps.current);var r=Yn($i.current),a=Ee(r,n.type);r!==a&&(ot(Rs,n),ot($i,a))}function oc(n){Rs.current===n&&(lt($i),lt(Rs))}var dt=wn(0);function Yo(n){for(var r=n;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===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var ac=[];function lc(){for(var n=0;n<ac.length;n++)ac[n]._workInProgressVersionPrimary=null;ac.length=0}var Xo=T.ReactCurrentDispatcher,cc=T.ReactCurrentBatchConfig,Xn=0,ft=null,Et=null,Lt=null,Go=!1,Ds=!1,Ms=0,zS=0;function Vt(){throw Error(i(321))}function uc(n,r){if(r===null)return!1;for(var a=0;a<r.length&&a<n.length;a++)if(!ji(n[a],r[a]))return!1;return!0}function hc(n,r,a,u,f,g){if(Xn=g,ft=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Xo.current=n===null||n.memoizedState===null?WS:US,n=a(u,f),Ds){g=0;do{if(Ds=!1,Ms=0,25<=g)throw Error(i(301));g+=1,Lt=Et=null,r.updateQueue=null,Xo.current=KS,n=a(u,f)}while(Ds)}if(Xo.current=Zo,r=Et!==null&&Et.next!==null,Xn=0,Lt=Et=ft=null,Go=!1,r)throw Error(i(300));return n}function dc(){var n=Ms!==0;return Ms=0,n}function Wi(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Lt===null?ft.memoizedState=Lt=n:Lt=Lt.next=n,Lt}function xi(){if(Et===null){var n=ft.alternate;n=n!==null?n.memoizedState:null}else n=Et.next;var r=Lt===null?ft.memoizedState:Lt.next;if(r!==null)Lt=r,Et=n;else{if(n===null)throw Error(i(310));Et=n,n={memoizedState:Et.memoizedState,baseState:Et.baseState,baseQueue:Et.baseQueue,queue:Et.queue,next:null},Lt===null?ft.memoizedState=Lt=n:Lt=Lt.next=n}return Lt}function Ls(n,r){return typeof r=="function"?r(n):r}function fc(n){var r=xi(),a=r.queue;if(a===null)throw Error(i(311));a.lastRenderedReducer=n;var u=Et,f=u.baseQueue,g=a.pending;if(g!==null){if(f!==null){var k=f.next;f.next=g.next,g.next=k}u.baseQueue=f=g,a.pending=null}if(f!==null){g=f.next,u=u.baseState;var B=k=null,$=null,re=g;do{var pe=re.lane;if((Xn&pe)===pe)$!==null&&($=$.next={lane:0,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null}),u=re.hasEagerState?re.eagerState:n(u,re.action);else{var me={lane:pe,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null};$===null?(B=$=me,k=u):$=$.next=me,ft.lanes|=pe,Gn|=pe}re=re.next}while(re!==null&&re!==g);$===null?k=u:$.next=B,ji(u,r.memoizedState)||(ri=!0),r.memoizedState=u,r.baseState=k,r.baseQueue=$,a.lastRenderedState=u}if(n=a.interleaved,n!==null){f=n;do g=f.lane,ft.lanes|=g,Gn|=g,f=f.next;while(f!==n)}else f===null&&(a.lanes=0);return[r.memoizedState,a.dispatch]}function pc(n){var r=xi(),a=r.queue;if(a===null)throw Error(i(311));a.lastRenderedReducer=n;var u=a.dispatch,f=a.pending,g=r.memoizedState;if(f!==null){a.pending=null;var k=f=f.next;do g=n(g,k.action),k=k.next;while(k!==f);ji(g,r.memoizedState)||(ri=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),a.lastRenderedState=g}return[g,u]}function Bf(){}function If(n,r){var a=ft,u=xi(),f=r(),g=!ji(u.memoizedState,f);if(g&&(u.memoizedState=f,ri=!0),u=u.queue,mc(Ff.bind(null,a,u,n),[n]),u.getSnapshot!==r||g||Lt!==null&&Lt.memoizedState.tag&1){if(a.flags|=2048,js(9,zf.bind(null,a,u,f,r),void 0,null),jt===null)throw Error(i(349));(Xn&30)!==0||Of(a,r,f)}return f}function Of(n,r,a){n.flags|=16384,n={getSnapshot:r,value:a},r=ft.updateQueue,r===null?(r={lastEffect:null,stores:null},ft.updateQueue=r,r.stores=[n]):(a=r.stores,a===null?r.stores=[n]:a.push(n))}function zf(n,r,a,u){r.value=a,r.getSnapshot=u,Hf(r)&&$f(n)}function Ff(n,r,a){return a(function(){Hf(r)&&$f(n)})}function Hf(n){var r=n.getSnapshot;n=n.value;try{var a=r();return!ji(n,a)}catch{return!0}}function $f(n){var r=sn(n,1);r!==null&&Oi(r,n,1,-1)}function Wf(n){var r=Wi();return typeof n=="function"&&(n=n()),r.memoizedState=r.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ls,lastRenderedState:n},r.queue=n,n=n.dispatch=$S.bind(null,ft,n),[r.memoizedState,n]}function js(n,r,a,u){return n={tag:n,create:r,destroy:a,deps:u,next:null},r=ft.updateQueue,r===null?(r={lastEffect:null,stores:null},ft.updateQueue=r,r.lastEffect=n.next=n):(a=r.lastEffect,a===null?r.lastEffect=n.next=n:(u=a.next,a.next=n,n.next=u,r.lastEffect=n)),n}function Uf(){return xi().memoizedState}function Qo(n,r,a,u){var f=Wi();ft.flags|=n,f.memoizedState=js(1|r,a,void 0,u===void 0?null:u)}function Jo(n,r,a,u){var f=xi();u=u===void 0?null:u;var g=void 0;if(Et!==null){var k=Et.memoizedState;if(g=k.destroy,u!==null&&uc(u,k.deps)){f.memoizedState=js(r,a,g,u);return}}ft.flags|=n,f.memoizedState=js(1|r,a,g,u)}function Kf(n,r){return Qo(8390656,8,n,r)}function mc(n,r){return Jo(2048,8,n,r)}function qf(n,r){return Jo(4,2,n,r)}function Vf(n,r){return Jo(4,4,n,r)}function Yf(n,r){if(typeof r=="function")return n=n(),r(n),function(){r(null)};if(r!=null)return n=n(),r.current=n,function(){r.current=null}}function Xf(n,r,a){return a=a!=null?a.concat([n]):null,Jo(4,4,Yf.bind(null,r,n),a)}function gc(){}function Gf(n,r){var a=xi();r=r===void 0?null:r;var u=a.memoizedState;return u!==null&&r!==null&&uc(r,u[1])?u[0]:(a.memoizedState=[n,r],n)}function Qf(n,r){var a=xi();r=r===void 0?null:r;var u=a.memoizedState;return u!==null&&r!==null&&uc(r,u[1])?u[0]:(n=n(),a.memoizedState=[n,r],n)}function Jf(n,r,a){return(Xn&21)===0?(n.baseState&&(n.baseState=!1,ri=!0),n.memoizedState=a):(ji(a,r)||(a=Nd(),ft.lanes|=a,Gn|=a,n.baseState=!0),r)}function FS(n,r){var a=nt;nt=a!==0&&4>a?a:4,n(!0);var u=cc.transition;cc.transition={};try{n(!1),r()}finally{nt=a,cc.transition=u}}function Zf(){return xi().memoizedState}function HS(n,r,a){var u=Pn(n);if(a={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null},ep(n))tp(r,a);else if(a=Mf(n,r,a,u),a!==null){var f=Jt();Oi(a,n,u,f),ip(a,r,u)}}function $S(n,r,a){var u=Pn(n),f={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null};if(ep(n))tp(r,f);else{var g=n.alternate;if(n.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var k=r.lastRenderedState,B=g(k,a);if(f.hasEagerState=!0,f.eagerState=B,ji(B,k)){var $=r.interleaved;$===null?(f.next=f,nc(r)):(f.next=$.next,$.next=f),r.interleaved=f;return}}catch{}finally{}a=Mf(n,r,f,u),a!==null&&(f=Jt(),Oi(a,n,u,f),ip(a,r,u))}}function ep(n){var r=n.alternate;return n===ft||r!==null&&r===ft}function tp(n,r){Ds=Go=!0;var a=n.pending;a===null?r.next=r:(r.next=a.next,a.next=r),n.pending=r}function ip(n,r,a){if((a&4194240)!==0){var u=r.lanes;u&=n.pendingLanes,a|=u,r.lanes=a,_l(n,a)}}var Zo={readContext:Ci,useCallback:Vt,useContext:Vt,useEffect:Vt,useImperativeHandle:Vt,useInsertionEffect:Vt,useLayoutEffect:Vt,useMemo:Vt,useReducer:Vt,useRef:Vt,useState:Vt,useDebugValue:Vt,useDeferredValue:Vt,useTransition:Vt,useMutableSource:Vt,useSyncExternalStore:Vt,useId:Vt,unstable_isNewReconciler:!1},WS={readContext:Ci,useCallback:function(n,r){return Wi().memoizedState=[n,r===void 0?null:r],n},useContext:Ci,useEffect:Kf,useImperativeHandle:function(n,r,a){return a=a!=null?a.concat([n]):null,Qo(4194308,4,Yf.bind(null,r,n),a)},useLayoutEffect:function(n,r){return Qo(4194308,4,n,r)},useInsertionEffect:function(n,r){return Qo(4,2,n,r)},useMemo:function(n,r){var a=Wi();return r=r===void 0?null:r,n=n(),a.memoizedState=[n,r],n},useReducer:function(n,r,a){var u=Wi();return r=a!==void 0?a(r):r,u.memoizedState=u.baseState=r,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:r},u.queue=n,n=n.dispatch=HS.bind(null,ft,n),[u.memoizedState,n]},useRef:function(n){var r=Wi();return n={current:n},r.memoizedState=n},useState:Wf,useDebugValue:gc,useDeferredValue:function(n){return Wi().memoizedState=n},useTransition:function(){var n=Wf(!1),r=n[0];return n=FS.bind(null,n[1]),Wi().memoizedState=n,[r,n]},useMutableSource:function(){},useSyncExternalStore:function(n,r,a){var u=ft,f=Wi();if(ut){if(a===void 0)throw Error(i(407));a=a()}else{if(a=r(),jt===null)throw Error(i(349));(Xn&30)!==0||Of(u,r,a)}f.memoizedState=a;var g={value:a,getSnapshot:r};return f.queue=g,Kf(Ff.bind(null,u,g,n),[n]),u.flags|=2048,js(9,zf.bind(null,u,g,a,r),void 0,null),a},useId:function(){var n=Wi(),r=jt.identifierPrefix;if(ut){var a=rn,u=nn;a=(u&~(1<<32-Li(u)-1)).toString(32)+a,r=":"+r+"R"+a,a=Ms++,0<a&&(r+="H"+a.toString(32)),r+=":"}else a=zS++,r=":"+r+"r"+a.toString(32)+":";return n.memoizedState=r},unstable_isNewReconciler:!1},US={readContext:Ci,useCallback:Gf,useContext:Ci,useEffect:mc,useImperativeHandle:Xf,useInsertionEffect:qf,useLayoutEffect:Vf,useMemo:Qf,useReducer:fc,useRef:Uf,useState:function(){return fc(Ls)},useDebugValue:gc,useDeferredValue:function(n){var r=xi();return Jf(r,Et.memoizedState,n)},useTransition:function(){var n=fc(Ls)[0],r=xi().memoizedState;return[n,r]},useMutableSource:Bf,useSyncExternalStore:If,useId:Zf,unstable_isNewReconciler:!1},KS={readContext:Ci,useCallback:Gf,useContext:Ci,useEffect:mc,useImperativeHandle:Xf,useInsertionEffect:qf,useLayoutEffect:Vf,useMemo:Qf,useReducer:pc,useRef:Uf,useState:function(){return pc(Ls)},useDebugValue:gc,useDeferredValue:function(n){var r=xi();return Et===null?r.memoizedState=n:Jf(r,Et.memoizedState,n)},useTransition:function(){var n=pc(Ls)[0],r=xi().memoizedState;return[n,r]},useMutableSource:Bf,useSyncExternalStore:If,useId:Zf,unstable_isNewReconciler:!1};function Ai(n,r){if(n&&n.defaultProps){r=K({},r),n=n.defaultProps;for(var a in n)r[a]===void 0&&(r[a]=n[a]);return r}return r}function vc(n,r,a,u){r=n.memoizedState,a=a(u,r),a=a==null?r:K({},r,a),n.memoizedState=a,n.lanes===0&&(n.updateQueue.baseState=a)}var ea={isMounted:function(n){return(n=n._reactInternals)?$n(n)===n:!1},enqueueSetState:function(n,r,a){n=n._reactInternals;var u=Jt(),f=Pn(n),g=on(u,f);g.payload=r,a!=null&&(g.callback=a),r=kn(n,g,f),r!==null&&(Oi(r,n,f,u),qo(r,n,f))},enqueueReplaceState:function(n,r,a){n=n._reactInternals;var u=Jt(),f=Pn(n),g=on(u,f);g.tag=1,g.payload=r,a!=null&&(g.callback=a),r=kn(n,g,f),r!==null&&(Oi(r,n,f,u),qo(r,n,f))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var a=Jt(),u=Pn(n),f=on(a,u);f.tag=2,r!=null&&(f.callback=r),r=kn(n,f,u),r!==null&&(Oi(r,n,u,a),qo(r,n,u))}};function np(n,r,a,u,f,g,k){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(u,g,k):r.prototype&&r.prototype.isPureReactComponent?!ys(a,u)||!ys(f,g):!0}function rp(n,r,a){var u=!1,f=bn,g=r.contextType;return typeof g=="object"&&g!==null?g=Ci(g):(f=ni(r)?Un:qt.current,u=r.contextTypes,g=(u=u!=null)?Nr(n,f):bn),r=new r(a,g),n.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=ea,n.stateNode=r,r._reactInternals=n,u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=f,n.__reactInternalMemoizedMaskedChildContext=g),r}function sp(n,r,a,u){n=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,u),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,u),r.state!==n&&ea.enqueueReplaceState(r,r.state,null)}function _c(n,r,a,u){var f=n.stateNode;f.props=a,f.state=n.memoizedState,f.refs={},rc(n);var g=r.contextType;typeof g=="object"&&g!==null?f.context=Ci(g):(g=ni(r)?Un:qt.current,f.context=Nr(n,g)),f.state=n.memoizedState,g=r.getDerivedStateFromProps,typeof g=="function"&&(vc(n,r,g,a),f.state=n.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&&ea.enqueueReplaceState(f,f.state,null),Vo(n,a,f,u),f.state=n.memoizedState),typeof f.componentDidMount=="function"&&(n.flags|=4194308)}function Ar(n,r){try{var a="",u=r;do a+=se(u),u=u.return;while(u);var f=a}catch(g){f=`
|
|
39
39
|
Error generating stack: `+g.message+`
|
|
40
|
-
`+g.stack}return{value:n,source:r,stack:f,digest:null}}function yc(n,r,a){return{value:n,source:null,stack:a??null,digest:r??null}}function Sc(n,r){try{console.error(r.value)}catch(a){setTimeout(function(){throw a})}}var US=typeof WeakMap=="function"?WeakMap:Map;function op(n,r,a){a=on(-1,a),a.tag=3,a.payload={element:null};var u=r.value;return a.callback=function(){aa||(aa=!0,Ac=u),Sc(n,r)},a}function ap(n,r,a){a=on(-1,a),a.tag=3;var u=n.type.getDerivedStateFromError;if(typeof u=="function"){var f=r.value;a.payload=function(){return u(f)},a.callback=function(){Sc(n,r)}}var g=n.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(a.callback=function(){Sc(n,r),typeof u!="function"&&(Nn===null?Nn=new Set([this]):Nn.add(this));var k=r.stack;this.componentDidCatch(r.value,{componentStack:k!==null?k:""})}),a}function lp(n,r,a){var u=n.pingCache;if(u===null){u=n.pingCache=new US;var f=new Set;u.set(r,f)}else f=u.get(r),f===void 0&&(f=new Set,u.set(r,f));f.has(a)||(f.add(a),n=rw.bind(null,n,r,a),r.then(n,n))}function cp(n){do{var r;if((r=n.tag===13)&&(r=n.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return n;n=n.return}while(n!==null);return null}function up(n,r,a,u,f){return(n.mode&1)===0?(n===r?n.flags|=65536:(n.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(r=on(-1,1),r.tag=2,kn(a,r,1))),a.lanes|=1),n):(n.flags|=65536,n.lanes=f,n)}var KS=T.ReactCurrentOwner,ri=!1;function Qt(n,r,a,u){r.child=n===null?Df(r,null,a,u):Mr(r,n.child,a,u)}function hp(n,r,a,u,f){a=a.render;var g=r.ref;return jr(r,f),u=hc(n,r,a,u,g,f),a=dc(),n!==null&&!ri?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,an(n,r,f)):(ut&&a&&Yl(r),r.flags|=1,Qt(n,r,u,f),r.child)}function dp(n,r,a,u,f){if(n===null){var g=a.type;return typeof g=="function"&&!$c(g)&&g.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(r.tag=15,r.type=g,fp(n,r,g,u,f)):(n=fa(a.type,null,u,r,r.mode,f),n.ref=r.ref,n.return=r,r.child=n)}if(g=n.child,(n.lanes&f)===0){var k=g.memoizedProps;if(a=a.compare,a=a!==null?a:ys,a(k,u)&&n.ref===r.ref)return an(n,r,f)}return r.flags|=1,n=Mn(g,u),n.ref=r.ref,n.return=r,r.child=n}function fp(n,r,a,u,f){if(n!==null){var g=n.memoizedProps;if(ys(g,u)&&n.ref===r.ref)if(ri=!1,r.pendingProps=u=g,(n.lanes&f)!==0)(n.flags&131072)!==0&&(ri=!0);else return r.lanes=n.lanes,an(n,r,f)}return wc(n,r,a,u,f)}function pp(n,r,a){var u=r.pendingProps,f=u.children,g=n!==null?n.memoizedState:null;if(u.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},ot(Ir,mi),mi|=a;else{if((a&1073741824)===0)return n=g!==null?g.baseLanes|a:a,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:n,cachePool:null,transitions:null},r.updateQueue=null,ot(Ir,mi),mi|=n,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=g!==null?g.baseLanes:a,ot(Ir,mi),mi|=u}else g!==null?(u=g.baseLanes|a,r.memoizedState=null):u=a,ot(Ir,mi),mi|=u;return Qt(n,r,f,a),r.child}function mp(n,r){var a=r.ref;(n===null&&a!==null||n!==null&&n.ref!==a)&&(r.flags|=512,r.flags|=2097152)}function wc(n,r,a,u,f){var g=ni(a)?Un:qt.current;return g=Nr(r,g),jr(r,f),a=hc(n,r,a,u,g,f),u=dc(),n!==null&&!ri?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,an(n,r,f)):(ut&&u&&Yl(r),r.flags|=1,Qt(n,r,a,f),r.child)}function gp(n,r,a,u,f){if(ni(a)){var g=!0;Oo(r)}else g=!1;if(jr(r,f),r.stateNode===null)ia(n,r),rp(r,a,u),_c(r,a,u,f),u=!0;else if(n===null){var k=r.stateNode,B=r.memoizedProps;k.props=B;var $=k.context,re=a.contextType;typeof re=="object"&&re!==null?re=Ci(re):(re=ni(a)?Un:qt.current,re=Nr(r,re));var pe=a.getDerivedStateFromProps,me=typeof pe=="function"||typeof k.getSnapshotBeforeUpdate=="function";me||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(B!==u||$!==re)&&sp(r,k,u,re),xn=!1;var fe=r.memoizedState;k.state=fe,Vo(r,u,k,f),$=r.memoizedState,B!==u||fe!==$||ii.current||xn?(typeof pe=="function"&&(vc(r,a,pe,u),$=r.memoizedState),(B=xn||np(r,a,B,u,fe,$,re))?(me||typeof k.UNSAFE_componentWillMount!="function"&&typeof k.componentWillMount!="function"||(typeof k.componentWillMount=="function"&&k.componentWillMount(),typeof k.UNSAFE_componentWillMount=="function"&&k.UNSAFE_componentWillMount()),typeof k.componentDidMount=="function"&&(r.flags|=4194308)):(typeof k.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=u,r.memoizedState=$),k.props=u,k.state=$,k.context=re,u=B):(typeof k.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{k=r.stateNode,Lf(n,r),B=r.memoizedProps,re=r.type===r.elementType?B:Ai(r.type,B),k.props=re,me=r.pendingProps,fe=k.context,$=a.contextType,typeof $=="object"&&$!==null?$=Ci($):($=ni(a)?Un:qt.current,$=Nr(r,$));var Ne=a.getDerivedStateFromProps;(pe=typeof Ne=="function"||typeof k.getSnapshotBeforeUpdate=="function")||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(B!==me||fe!==$)&&sp(r,k,u,$),xn=!1,fe=r.memoizedState,k.state=fe,Vo(r,u,k,f);var Pe=r.memoizedState;B!==me||fe!==Pe||ii.current||xn?(typeof Ne=="function"&&(vc(r,a,Ne,u),Pe=r.memoizedState),(re=xn||np(r,a,re,u,fe,Pe,$)||!1)?(pe||typeof k.UNSAFE_componentWillUpdate!="function"&&typeof k.componentWillUpdate!="function"||(typeof k.componentWillUpdate=="function"&&k.componentWillUpdate(u,Pe,$),typeof k.UNSAFE_componentWillUpdate=="function"&&k.UNSAFE_componentWillUpdate(u,Pe,$)),typeof k.componentDidUpdate=="function"&&(r.flags|=4),typeof k.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof k.componentDidUpdate!="function"||B===n.memoizedProps&&fe===n.memoizedState||(r.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||B===n.memoizedProps&&fe===n.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=Pe),k.props=u,k.state=Pe,k.context=$,u=re):(typeof k.componentDidUpdate!="function"||B===n.memoizedProps&&fe===n.memoizedState||(r.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||B===n.memoizedProps&&fe===n.memoizedState||(r.flags|=1024),u=!1)}return bc(n,r,a,u,g,f)}function bc(n,r,a,u,f,g){mp(n,r);var k=(r.flags&128)!==0;if(!u&&!k)return f&&wf(r,a,!1),an(n,r,g);u=r.stateNode,KS.current=r;var B=k&&typeof a.getDerivedStateFromError!="function"?null:u.render();return r.flags|=1,n!==null&&k?(r.child=Mr(r,n.child,null,g),r.child=Mr(r,null,B,g)):Qt(n,r,B,g),r.memoizedState=u.state,f&&wf(r,a,!0),r.child}function vp(n){var r=n.stateNode;r.pendingContext?yf(n,r.pendingContext,r.pendingContext!==r.context):r.context&&yf(n,r.context,!1),sc(n,r.containerInfo)}function _p(n,r,a,u,f){return Dr(),Jl(f),r.flags|=256,Qt(n,r,a,u),r.child}var Cc={dehydrated:null,treeContext:null,retryLane:0};function xc(n){return{baseLanes:n,cachePool:null,transitions:null}}function yp(n,r,a){var u=r.pendingProps,f=dt.current,g=!1,k=(r.flags&128)!==0,B;if((B=k)||(B=n!==null&&n.memoizedState===null?!1:(f&2)!==0),B?(g=!0,r.flags&=-129):(n===null||n.memoizedState!==null)&&(f|=1),ot(dt,f&1),n===null)return Ql(r),n=r.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((r.mode&1)===0?r.lanes=1:n.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(k=u.children,n=u.fallback,g?(u=r.mode,g=r.child,k={mode:"hidden",children:k},(u&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=k):g=pa(k,u,0,null),n=er(n,u,a,null),g.return=r,n.return=r,g.sibling=n,r.child=g,r.child.memoizedState=xc(a),r.memoizedState=Cc,n):kc(r,k));if(f=n.memoizedState,f!==null&&(B=f.dehydrated,B!==null))return qS(n,r,k,u,B,f,a);if(g){g=u.fallback,k=r.mode,f=n.child,B=f.sibling;var $={mode:"hidden",children:u.children};return(k&1)===0&&r.child!==f?(u=r.child,u.childLanes=0,u.pendingProps=$,r.deletions=null):(u=Mn(f,$),u.subtreeFlags=f.subtreeFlags&14680064),B!==null?g=Mn(B,g):(g=er(g,k,a,null),g.flags|=2),g.return=r,u.return=r,u.sibling=g,r.child=u,u=g,g=r.child,k=n.child.memoizedState,k=k===null?xc(a):{baseLanes:k.baseLanes|a,cachePool:null,transitions:k.transitions},g.memoizedState=k,g.childLanes=n.childLanes&~a,r.memoizedState=Cc,u}return g=n.child,n=g.sibling,u=Mn(g,{mode:"visible",children:u.children}),(r.mode&1)===0&&(u.lanes=a),u.return=r,u.sibling=null,n!==null&&(a=r.deletions,a===null?(r.deletions=[n],r.flags|=16):a.push(n)),r.child=u,r.memoizedState=null,u}function kc(n,r){return r=pa({mode:"visible",children:r},n.mode,0,null),r.return=n,n.child=r}function ta(n,r,a,u){return u!==null&&Jl(u),Mr(r,n.child,null,a),n=kc(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function qS(n,r,a,u,f,g,k){if(a)return r.flags&256?(r.flags&=-257,u=yc(Error(i(422))),ta(n,r,k,u)):r.memoizedState!==null?(r.child=n.child,r.flags|=128,null):(g=u.fallback,f=r.mode,u=pa({mode:"visible",children:u.children},f,0,null),g=er(g,f,k,null),g.flags|=2,u.return=r,g.return=r,u.sibling=g,r.child=u,(r.mode&1)!==0&&Mr(r,n.child,null,k),r.child.memoizedState=xc(k),r.memoizedState=Cc,g);if((r.mode&1)===0)return ta(n,r,k,null);if(f.data==="$!"){if(u=f.nextSibling&&f.nextSibling.dataset,u)var B=u.dgst;return u=B,g=Error(i(419)),u=yc(g,u,void 0),ta(n,r,k,u)}if(B=(k&n.childLanes)!==0,ri||B){if(u=jt,u!==null){switch(k&-k){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&(u.suspendedLanes|k))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,sn(n,f),Oi(u,n,f,-1))}return Hc(),u=yc(Error(i(421))),ta(n,r,k,u)}return f.data==="$?"?(r.flags|=128,r.child=n.child,r=sw.bind(null,n),f._reactRetry=r,null):(n=g.treeContext,pi=Sn(f.nextSibling),fi=r,ut=!0,Ti=null,n!==null&&(wi[bi++]=nn,wi[bi++]=rn,wi[bi++]=Kn,nn=n.id,rn=n.overflow,Kn=r),r=kc(r,u.children),r.flags|=4096,r)}function Sp(n,r,a){n.lanes|=r;var u=n.alternate;u!==null&&(u.lanes|=r),ic(n.return,r,a)}function Ec(n,r,a,u,f){var g=n.memoizedState;g===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:a,tailMode:f}:(g.isBackwards=r,g.rendering=null,g.renderingStartTime=0,g.last=u,g.tail=a,g.tailMode=f)}function wp(n,r,a){var u=r.pendingProps,f=u.revealOrder,g=u.tail;if(Qt(n,r,u.children,a),u=dt.current,(u&2)!==0)u=u&1|2,r.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&Sp(n,a,r);else if(n.tag===19)Sp(n,a,r);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break e;for(;n.sibling===null;){if(n.return===null||n.return===r)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}u&=1}if(ot(dt,u),(r.mode&1)===0)r.memoizedState=null;else switch(f){case"forwards":for(a=r.child,f=null;a!==null;)n=a.alternate,n!==null&&Yo(n)===null&&(f=a),a=a.sibling;a=f,a===null?(f=r.child,r.child=null):(f=a.sibling,a.sibling=null),Ec(r,!1,f,a,g);break;case"backwards":for(a=null,f=r.child,r.child=null;f!==null;){if(n=f.alternate,n!==null&&Yo(n)===null){r.child=f;break}n=f.sibling,f.sibling=a,a=f,f=n}Ec(r,!0,a,null,g);break;case"together":Ec(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function ia(n,r){(r.mode&1)===0&&n!==null&&(n.alternate=null,r.alternate=null,r.flags|=2)}function an(n,r,a){if(n!==null&&(r.dependencies=n.dependencies),Gn|=r.lanes,(a&r.childLanes)===0)return null;if(n!==null&&r.child!==n.child)throw Error(i(153));if(r.child!==null){for(n=r.child,a=Mn(n,n.pendingProps),r.child=a,a.return=r;n.sibling!==null;)n=n.sibling,a=a.sibling=Mn(n,n.pendingProps),a.return=r;a.sibling=null}return r.child}function VS(n,r,a){switch(r.tag){case 3:vp(r),Dr();break;case 5:Af(r);break;case 1:ni(r.type)&&Oo(r);break;case 4:sc(r,r.stateNode.containerInfo);break;case 10:var u=r.type._context,f=r.memoizedProps.value;ot(Uo,u._currentValue),u._currentValue=f;break;case 13:if(u=r.memoizedState,u!==null)return u.dehydrated!==null?(ot(dt,dt.current&1),r.flags|=128,null):(a&r.child.childLanes)!==0?yp(n,r,a):(ot(dt,dt.current&1),n=an(n,r,a),n!==null?n.sibling:null);ot(dt,dt.current&1);break;case 19:if(u=(a&r.childLanes)!==0,(n.flags&128)!==0){if(u)return wp(n,r,a);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),ot(dt,dt.current),u)break;return null;case 22:case 23:return r.lanes=0,pp(n,r,a)}return an(n,r,a)}var bp,Nc,Cp,xp;bp=function(n,r){for(var a=r.child;a!==null;){if(a.tag===5||a.tag===6)n.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}},Nc=function(){},Cp=function(n,r,a,u){var f=n.memoizedProps;if(f!==u){n=r.stateNode,Yn($i.current);var g=null;switch(a){case"input":f=ee(n,f),u=ee(n,u),g=[];break;case"select":f=K({},f,{value:void 0}),u=K({},u,{value:void 0}),g=[];break;case"textarea":f=Ie(n,f),u=Ie(n,u),g=[];break;default:typeof f.onClick!="function"&&typeof u.onClick=="function"&&(n.onclick=Ao)}Ue(a,u);var k;a=null;for(re in f)if(!u.hasOwnProperty(re)&&f.hasOwnProperty(re)&&f[re]!=null)if(re==="style"){var B=f[re];for(k in B)B.hasOwnProperty(k)&&(a||(a={}),a[k]="")}else re!=="dangerouslySetInnerHTML"&&re!=="children"&&re!=="suppressContentEditableWarning"&&re!=="suppressHydrationWarning"&&re!=="autoFocus"&&(o.hasOwnProperty(re)?g||(g=[]):(g=g||[]).push(re,null));for(re in u){var $=u[re];if(B=f!=null?f[re]:void 0,u.hasOwnProperty(re)&&$!==B&&($!=null||B!=null))if(re==="style")if(B){for(k in B)!B.hasOwnProperty(k)||$&&$.hasOwnProperty(k)||(a||(a={}),a[k]="");for(k in $)$.hasOwnProperty(k)&&B[k]!==$[k]&&(a||(a={}),a[k]=$[k])}else a||(g||(g=[]),g.push(re,a)),a=$;else re==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,B=B?B.__html:void 0,$!=null&&B!==$&&(g=g||[]).push(re,$)):re==="children"?typeof $!="string"&&typeof $!="number"||(g=g||[]).push(re,""+$):re!=="suppressContentEditableWarning"&&re!=="suppressHydrationWarning"&&(o.hasOwnProperty(re)?($!=null&&re==="onScroll"&&at("scroll",n),g||B===$||(g=[])):(g=g||[]).push(re,$))}a&&(g=g||[]).push("style",a);var re=g;(r.updateQueue=re)&&(r.flags|=4)}},xp=function(n,r,a,u){a!==u&&(r.flags|=4)};function Ts(n,r){if(!ut)switch(n.tailMode){case"hidden":r=n.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?n.tail=null:a.sibling=null;break;case"collapsed":a=n.tail;for(var u=null;a!==null;)a.alternate!==null&&(u=a),a=a.sibling;u===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:u.sibling=null}}function Yt(n){var r=n.alternate!==null&&n.alternate.child===n.child,a=0,u=0;if(r)for(var f=n.child;f!==null;)a|=f.lanes|f.childLanes,u|=f.subtreeFlags&14680064,u|=f.flags&14680064,f.return=n,f=f.sibling;else for(f=n.child;f!==null;)a|=f.lanes|f.childLanes,u|=f.subtreeFlags,u|=f.flags,f.return=n,f=f.sibling;return n.subtreeFlags|=u,n.childLanes=a,r}function YS(n,r,a){var u=r.pendingProps;switch(Xl(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Yt(r),null;case 1:return ni(r.type)&&Io(),Yt(r),null;case 3:return u=r.stateNode,Tr(),lt(ii),lt(qt),lc(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(n===null||n.child===null)&&($o(r)?r.flags|=4:n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Ti!==null&&(Oc(Ti),Ti=null))),Nc(n,r),Yt(r),null;case 5:oc(r);var f=Yn(Ps.current);if(a=r.type,n!==null&&r.stateNode!=null)Cp(n,r,a,u,f),n.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!u){if(r.stateNode===null)throw Error(i(166));return Yt(r),null}if(n=Yn($i.current),$o(r)){u=r.stateNode,a=r.type;var g=r.memoizedProps;switch(u[Hi]=r,u[xs]=g,n=(r.mode&1)!==0,a){case"dialog":at("cancel",u),at("close",u);break;case"iframe":case"object":case"embed":at("load",u);break;case"video":case"audio":for(f=0;f<ws.length;f++)at(ws[f],u);break;case"source":at("error",u);break;case"img":case"image":case"link":at("error",u),at("load",u);break;case"details":at("toggle",u);break;case"input":Ce(u,g),at("invalid",u);break;case"select":u._wrapperState={wasMultiple:!!g.multiple},at("invalid",u);break;case"textarea":Fe(u,g),at("invalid",u)}Ue(a,g),f=null;for(var k in g)if(g.hasOwnProperty(k)){var B=g[k];k==="children"?typeof B=="string"?u.textContent!==B&&(g.suppressHydrationWarning!==!0&&To(u.textContent,B,n),f=["children",B]):typeof B=="number"&&u.textContent!==""+B&&(g.suppressHydrationWarning!==!0&&To(u.textContent,B,n),f=["children",""+B]):o.hasOwnProperty(k)&&B!=null&&k==="onScroll"&&at("scroll",u)}switch(a){case"input":je(u),qe(u,g,!0);break;case"textarea":je(u),ge(u);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(u.onclick=Ao)}u=f,r.updateQueue=u,u!==null&&(r.flags|=4)}else{k=f.nodeType===9?f:f.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=be(a)),n==="http://www.w3.org/1999/xhtml"?a==="script"?(n=k.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof u.is=="string"?n=k.createElement(a,{is:u.is}):(n=k.createElement(a),a==="select"&&(k=n,u.multiple?k.multiple=!0:u.size&&(k.size=u.size))):n=k.createElementNS(n,a),n[Hi]=r,n[xs]=u,bp(n,r,!1,!1),r.stateNode=n;e:{switch(k=Mt(a,u),a){case"dialog":at("cancel",n),at("close",n),f=u;break;case"iframe":case"object":case"embed":at("load",n),f=u;break;case"video":case"audio":for(f=0;f<ws.length;f++)at(ws[f],n);f=u;break;case"source":at("error",n),f=u;break;case"img":case"image":case"link":at("error",n),at("load",n),f=u;break;case"details":at("toggle",n),f=u;break;case"input":Ce(n,u),f=ee(n,u),at("invalid",n);break;case"option":f=u;break;case"select":n._wrapperState={wasMultiple:!!u.multiple},f=K({},u,{value:void 0}),at("invalid",n);break;case"textarea":Fe(n,u),f=Ie(n,u),at("invalid",n);break;default:f=u}Ue(a,f),B=f;for(g in B)if(B.hasOwnProperty(g)){var $=B[g];g==="style"?ue(n,$):g==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,$!=null&&rt(n,$)):g==="children"?typeof $=="string"?(a!=="textarea"||$!=="")&&Ve(n,$):typeof $=="number"&&Ve(n,""+$):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(o.hasOwnProperty(g)?$!=null&&g==="onScroll"&&at("scroll",n):$!=null&&j(n,g,$,k))}switch(a){case"input":je(n),qe(n,u,!1);break;case"textarea":je(n),ge(n);break;case"option":u.value!=null&&n.setAttribute("value",""+ce(u.value));break;case"select":n.multiple=!!u.multiple,g=u.value,g!=null?Be(n,!!u.multiple,g,!1):u.defaultValue!=null&&Be(n,!!u.multiple,u.defaultValue,!0);break;default:typeof f.onClick=="function"&&(n.onclick=Ao)}switch(a){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}}u&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return Yt(r),null;case 6:if(n&&r.stateNode!=null)xp(n,r,n.memoizedProps,u);else{if(typeof u!="string"&&r.stateNode===null)throw Error(i(166));if(a=Yn(Ps.current),Yn($i.current),$o(r)){if(u=r.stateNode,a=r.memoizedProps,u[Hi]=r,(g=u.nodeValue!==a)&&(n=fi,n!==null))switch(n.tag){case 3:To(u.nodeValue,a,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&To(u.nodeValue,a,(n.mode&1)!==0)}g&&(r.flags|=4)}else u=(a.nodeType===9?a:a.ownerDocument).createTextNode(u),u[Hi]=r,r.stateNode=u}return Yt(r),null;case 13:if(lt(dt),u=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(ut&&pi!==null&&(r.mode&1)!==0&&(r.flags&128)===0)Nf(),Dr(),r.flags|=98560,g=!1;else if(g=$o(r),u!==null&&u.dehydrated!==null){if(n===null){if(!g)throw Error(i(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(i(317));g[Hi]=r}else Dr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Yt(r),g=!1}else Ti!==null&&(Oc(Ti),Ti=null),g=!0;if(!g)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=a,r):(u=u!==null,u!==(n!==null&&n.memoizedState!==null)&&u&&(r.child.flags|=8192,(r.mode&1)!==0&&(n===null||(dt.current&1)!==0?Nt===0&&(Nt=3):Hc())),r.updateQueue!==null&&(r.flags|=4),Yt(r),null);case 4:return Tr(),Nc(n,r),n===null&&bs(r.stateNode.containerInfo),Yt(r),null;case 10:return tc(r.type._context),Yt(r),null;case 17:return ni(r.type)&&Io(),Yt(r),null;case 19:if(lt(dt),g=r.memoizedState,g===null)return Yt(r),null;if(u=(r.flags&128)!==0,k=g.rendering,k===null)if(u)Ts(g,!1);else{if(Nt!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(k=Yo(n),k!==null){for(r.flags|=128,Ts(g,!1),u=k.updateQueue,u!==null&&(r.updateQueue=u,r.flags|=4),r.subtreeFlags=0,u=a,a=r.child;a!==null;)g=a,n=u,g.flags&=14680066,k=g.alternate,k===null?(g.childLanes=0,g.lanes=n,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=k.childLanes,g.lanes=k.lanes,g.child=k.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=k.memoizedProps,g.memoizedState=k.memoizedState,g.updateQueue=k.updateQueue,g.type=k.type,n=k.dependencies,g.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),a=a.sibling;return ot(dt,dt.current&1|2),r.child}n=n.sibling}g.tail!==null&&St()>Or&&(r.flags|=128,u=!0,Ts(g,!1),r.lanes=4194304)}else{if(!u)if(n=Yo(k),n!==null){if(r.flags|=128,u=!0,a=n.updateQueue,a!==null&&(r.updateQueue=a,r.flags|=4),Ts(g,!0),g.tail===null&&g.tailMode==="hidden"&&!k.alternate&&!ut)return Yt(r),null}else 2*St()-g.renderingStartTime>Or&&a!==1073741824&&(r.flags|=128,u=!0,Ts(g,!1),r.lanes=4194304);g.isBackwards?(k.sibling=r.child,r.child=k):(a=g.last,a!==null?a.sibling=k:r.child=k,g.last=k)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=St(),r.sibling=null,a=dt.current,ot(dt,u?a&1|2:a&1),r):(Yt(r),null);case 22:case 23:return Fc(),u=r.memoizedState!==null,n!==null&&n.memoizedState!==null!==u&&(r.flags|=8192),u&&(r.mode&1)!==0?(mi&1073741824)!==0&&(Yt(r),r.subtreeFlags&6&&(r.flags|=8192)):Yt(r),null;case 24:return null;case 25:return null}throw Error(i(156,r.tag))}function XS(n,r){switch(Xl(r),r.tag){case 1:return ni(r.type)&&Io(),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return Tr(),lt(ii),lt(qt),lc(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 5:return oc(r),null;case 13:if(lt(dt),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(i(340));Dr()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return lt(dt),null;case 4:return Tr(),null;case 10:return tc(r.type._context),null;case 22:case 23:return Fc(),null;case 24:return null;default:return null}}var na=!1,Xt=!1,GS=typeof WeakSet=="function"?WeakSet:Set,Re=null;function Br(n,r){var a=n.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(u){vt(n,r,u)}else a.current=null}function Rc(n,r,a){try{a()}catch(u){vt(n,r,u)}}var kp=!1;function QS(n,r){if(Fl=Co,n=nf(),Ll(n)){if("selectionStart"in n)var a={start:n.selectionStart,end:n.selectionEnd};else e:{a=(a=n.ownerDocument)&&a.defaultView||window;var u=a.getSelection&&a.getSelection();if(u&&u.rangeCount!==0){a=u.anchorNode;var f=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{a.nodeType,g.nodeType}catch{a=null;break e}var k=0,B=-1,$=-1,re=0,pe=0,me=n,fe=null;t:for(;;){for(var Ne;me!==a||f!==0&&me.nodeType!==3||(B=k+f),me!==g||u!==0&&me.nodeType!==3||($=k+u),me.nodeType===3&&(k+=me.nodeValue.length),(Ne=me.firstChild)!==null;)fe=me,me=Ne;for(;;){if(me===n)break t;if(fe===a&&++re===f&&(B=k),fe===g&&++pe===u&&($=k),(Ne=me.nextSibling)!==null)break;me=fe,fe=me.parentNode}me=Ne}a=B===-1||$===-1?null:{start:B,end:$}}else a=null}a=a||{start:0,end:0}}else a=null;for(Hl={focusedElem:n,selectionRange:a},Co=!1,Re=r;Re!==null;)if(r=Re,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,Re=n;else for(;Re!==null;){r=Re;try{var Pe=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Pe!==null){var Le=Pe.memoizedProps,wt=Pe.memoizedState,J=r.stateNode,V=J.getSnapshotBeforeUpdate(r.elementType===r.type?Le:Ai(r.type,Le),wt);J.__reactInternalSnapshotBeforeUpdate=V}break;case 3:var ie=r.stateNode.containerInfo;ie.nodeType===1?ie.textContent="":ie.nodeType===9&&ie.documentElement&&ie.removeChild(ie.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(Se){vt(r,r.return,Se)}if(n=r.sibling,n!==null){n.return=r.return,Re=n;break}Re=r.return}return Pe=kp,kp=!1,Pe}function As(n,r,a){var u=r.updateQueue;if(u=u!==null?u.lastEffect:null,u!==null){var f=u=u.next;do{if((f.tag&n)===n){var g=f.destroy;f.destroy=void 0,g!==void 0&&Rc(r,a,g)}f=f.next}while(f!==u)}}function ra(n,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var a=r=r.next;do{if((a.tag&n)===n){var u=a.create;a.destroy=u()}a=a.next}while(a!==r)}}function Pc(n){var r=n.ref;if(r!==null){var a=n.stateNode;switch(n.tag){case 5:n=a;break;default:n=a}typeof r=="function"?r(n):r.current=n}}function Ep(n){var r=n.alternate;r!==null&&(n.alternate=null,Ep(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&(delete r[Hi],delete r[xs],delete r[Kl],delete r[jS],delete r[TS])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function Np(n){return n.tag===5||n.tag===3||n.tag===4}function Rp(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Np(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function Dc(n,r,a){var u=n.tag;if(u===5||u===6)n=n.stateNode,r?a.nodeType===8?a.parentNode.insertBefore(n,r):a.insertBefore(n,r):(a.nodeType===8?(r=a.parentNode,r.insertBefore(n,a)):(r=a,r.appendChild(n)),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=Ao));else if(u!==4&&(n=n.child,n!==null))for(Dc(n,r,a),n=n.sibling;n!==null;)Dc(n,r,a),n=n.sibling}function Mc(n,r,a){var u=n.tag;if(u===5||u===6)n=n.stateNode,r?a.insertBefore(n,r):a.appendChild(n);else if(u!==4&&(n=n.child,n!==null))for(Mc(n,r,a),n=n.sibling;n!==null;)Mc(n,r,a),n=n.sibling}var Ht=null,Bi=!1;function En(n,r,a){for(a=a.child;a!==null;)Pp(n,r,a),a=a.sibling}function Pp(n,r,a){if(Fi&&typeof Fi.onCommitFiberUnmount=="function")try{Fi.onCommitFiberUnmount(vo,a)}catch{}switch(a.tag){case 5:Xt||Br(a,r);case 6:var u=Ht,f=Bi;Ht=null,En(n,r,a),Ht=u,Bi=f,Ht!==null&&(Bi?(n=Ht,a=a.stateNode,n.nodeType===8?n.parentNode.removeChild(a):n.removeChild(a)):Ht.removeChild(a.stateNode));break;case 18:Ht!==null&&(Bi?(n=Ht,a=a.stateNode,n.nodeType===8?Ul(n.parentNode,a):n.nodeType===1&&Ul(n,a),fs(n)):Ul(Ht,a.stateNode));break;case 4:u=Ht,f=Bi,Ht=a.stateNode.containerInfo,Bi=!0,En(n,r,a),Ht=u,Bi=f;break;case 0:case 11:case 14:case 15:if(!Xt&&(u=a.updateQueue,u!==null&&(u=u.lastEffect,u!==null))){f=u=u.next;do{var g=f,k=g.destroy;g=g.tag,k!==void 0&&((g&2)!==0||(g&4)!==0)&&Rc(a,r,k),f=f.next}while(f!==u)}En(n,r,a);break;case 1:if(!Xt&&(Br(a,r),u=a.stateNode,typeof u.componentWillUnmount=="function"))try{u.props=a.memoizedProps,u.state=a.memoizedState,u.componentWillUnmount()}catch(B){vt(a,r,B)}En(n,r,a);break;case 21:En(n,r,a);break;case 22:a.mode&1?(Xt=(u=Xt)||a.memoizedState!==null,En(n,r,a),Xt=u):En(n,r,a);break;default:En(n,r,a)}}function Dp(n){var r=n.updateQueue;if(r!==null){n.updateQueue=null;var a=n.stateNode;a===null&&(a=n.stateNode=new GS),r.forEach(function(u){var f=ow.bind(null,n,u);a.has(u)||(a.add(u),u.then(f,f))})}}function Ii(n,r){var a=r.deletions;if(a!==null)for(var u=0;u<a.length;u++){var f=a[u];try{var g=n,k=r,B=k;e:for(;B!==null;){switch(B.tag){case 5:Ht=B.stateNode,Bi=!1;break e;case 3:Ht=B.stateNode.containerInfo,Bi=!0;break e;case 4:Ht=B.stateNode.containerInfo,Bi=!0;break e}B=B.return}if(Ht===null)throw Error(i(160));Pp(g,k,f),Ht=null,Bi=!1;var $=f.alternate;$!==null&&($.return=null),f.return=null}catch(re){vt(f,r,re)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)Mp(r,n),r=r.sibling}function Mp(n,r){var a=n.alternate,u=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Ii(r,n),Ui(n),u&4){try{As(3,n,n.return),ra(3,n)}catch(Le){vt(n,n.return,Le)}try{As(5,n,n.return)}catch(Le){vt(n,n.return,Le)}}break;case 1:Ii(r,n),Ui(n),u&512&&a!==null&&Br(a,a.return);break;case 5:if(Ii(r,n),Ui(n),u&512&&a!==null&&Br(a,a.return),n.flags&32){var f=n.stateNode;try{Ve(f,"")}catch(Le){vt(n,n.return,Le)}}if(u&4&&(f=n.stateNode,f!=null)){var g=n.memoizedProps,k=a!==null?a.memoizedProps:g,B=n.type,$=n.updateQueue;if(n.updateQueue=null,$!==null)try{B==="input"&&g.type==="radio"&&g.name!=null&&Te(f,g),Mt(B,k);var re=Mt(B,g);for(k=0;k<$.length;k+=2){var pe=$[k],me=$[k+1];pe==="style"?ue(f,me):pe==="dangerouslySetInnerHTML"?rt(f,me):pe==="children"?Ve(f,me):j(f,pe,me,re)}switch(B){case"input":xe(f,g);break;case"textarea":gt(f,g);break;case"select":var fe=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!g.multiple;var Ne=g.value;Ne!=null?Be(f,!!g.multiple,Ne,!1):fe!==!!g.multiple&&(g.defaultValue!=null?Be(f,!!g.multiple,g.defaultValue,!0):Be(f,!!g.multiple,g.multiple?[]:"",!1))}f[xs]=g}catch(Le){vt(n,n.return,Le)}}break;case 6:if(Ii(r,n),Ui(n),u&4){if(n.stateNode===null)throw Error(i(162));f=n.stateNode,g=n.memoizedProps;try{f.nodeValue=g}catch(Le){vt(n,n.return,Le)}}break;case 3:if(Ii(r,n),Ui(n),u&4&&a!==null&&a.memoizedState.isDehydrated)try{fs(r.containerInfo)}catch(Le){vt(n,n.return,Le)}break;case 4:Ii(r,n),Ui(n);break;case 13:Ii(r,n),Ui(n),f=n.child,f.flags&8192&&(g=f.memoizedState!==null,f.stateNode.isHidden=g,!g||f.alternate!==null&&f.alternate.memoizedState!==null||(Tc=St())),u&4&&Dp(n);break;case 22:if(pe=a!==null&&a.memoizedState!==null,n.mode&1?(Xt=(re=Xt)||pe,Ii(r,n),Xt=re):Ii(r,n),Ui(n),u&8192){if(re=n.memoizedState!==null,(n.stateNode.isHidden=re)&&!pe&&(n.mode&1)!==0)for(Re=n,pe=n.child;pe!==null;){for(me=Re=pe;Re!==null;){switch(fe=Re,Ne=fe.child,fe.tag){case 0:case 11:case 14:case 15:As(4,fe,fe.return);break;case 1:Br(fe,fe.return);var Pe=fe.stateNode;if(typeof Pe.componentWillUnmount=="function"){u=fe,a=fe.return;try{r=u,Pe.props=r.memoizedProps,Pe.state=r.memoizedState,Pe.componentWillUnmount()}catch(Le){vt(u,a,Le)}}break;case 5:Br(fe,fe.return);break;case 22:if(fe.memoizedState!==null){Tp(me);continue}}Ne!==null?(Ne.return=fe,Re=Ne):Tp(me)}pe=pe.sibling}e:for(pe=null,me=n;;){if(me.tag===5){if(pe===null){pe=me;try{f=me.stateNode,re?(g=f.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(B=me.stateNode,$=me.memoizedProps.style,k=$!=null&&$.hasOwnProperty("display")?$.display:null,B.style.display=it("display",k))}catch(Le){vt(n,n.return,Le)}}}else if(me.tag===6){if(pe===null)try{me.stateNode.nodeValue=re?"":me.memoizedProps}catch(Le){vt(n,n.return,Le)}}else if((me.tag!==22&&me.tag!==23||me.memoizedState===null||me===n)&&me.child!==null){me.child.return=me,me=me.child;continue}if(me===n)break e;for(;me.sibling===null;){if(me.return===null||me.return===n)break e;pe===me&&(pe=null),me=me.return}pe===me&&(pe=null),me.sibling.return=me.return,me=me.sibling}}break;case 19:Ii(r,n),Ui(n),u&4&&Dp(n);break;case 21:break;default:Ii(r,n),Ui(n)}}function Ui(n){var r=n.flags;if(r&2){try{e:{for(var a=n.return;a!==null;){if(Np(a)){var u=a;break e}a=a.return}throw Error(i(160))}switch(u.tag){case 5:var f=u.stateNode;u.flags&32&&(Ve(f,""),u.flags&=-33);var g=Rp(n);Mc(n,g,f);break;case 3:case 4:var k=u.stateNode.containerInfo,B=Rp(n);Dc(n,B,k);break;default:throw Error(i(161))}}catch($){vt(n,n.return,$)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function JS(n,r,a){Re=n,Lp(n)}function Lp(n,r,a){for(var u=(n.mode&1)!==0;Re!==null;){var f=Re,g=f.child;if(f.tag===22&&u){var k=f.memoizedState!==null||na;if(!k){var B=f.alternate,$=B!==null&&B.memoizedState!==null||Xt;B=na;var re=Xt;if(na=k,(Xt=$)&&!re)for(Re=f;Re!==null;)k=Re,$=k.child,k.tag===22&&k.memoizedState!==null?Ap(f):$!==null?($.return=k,Re=$):Ap(f);for(;g!==null;)Re=g,Lp(g),g=g.sibling;Re=f,na=B,Xt=re}jp(n)}else(f.subtreeFlags&8772)!==0&&g!==null?(g.return=f,Re=g):jp(n)}}function jp(n){for(;Re!==null;){var r=Re;if((r.flags&8772)!==0){var a=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Xt||ra(5,r);break;case 1:var u=r.stateNode;if(r.flags&4&&!Xt)if(a===null)u.componentDidMount();else{var f=r.elementType===r.type?a.memoizedProps:Ai(r.type,a.memoizedProps);u.componentDidUpdate(f,a.memoizedState,u.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&Tf(r,g,u);break;case 3:var k=r.updateQueue;if(k!==null){if(a=null,r.child!==null)switch(r.child.tag){case 5:a=r.child.stateNode;break;case 1:a=r.child.stateNode}Tf(r,k,a)}break;case 5:var B=r.stateNode;if(a===null&&r.flags&4){a=B;var $=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":$.autoFocus&&a.focus();break;case"img":$.src&&(a.src=$.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var re=r.alternate;if(re!==null){var pe=re.memoizedState;if(pe!==null){var me=pe.dehydrated;me!==null&&fs(me)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(i(163))}Xt||r.flags&512&&Pc(r)}catch(fe){vt(r,r.return,fe)}}if(r===n){Re=null;break}if(a=r.sibling,a!==null){a.return=r.return,Re=a;break}Re=r.return}}function Tp(n){for(;Re!==null;){var r=Re;if(r===n){Re=null;break}var a=r.sibling;if(a!==null){a.return=r.return,Re=a;break}Re=r.return}}function Ap(n){for(;Re!==null;){var r=Re;try{switch(r.tag){case 0:case 11:case 15:var a=r.return;try{ra(4,r)}catch($){vt(r,a,$)}break;case 1:var u=r.stateNode;if(typeof u.componentDidMount=="function"){var f=r.return;try{u.componentDidMount()}catch($){vt(r,f,$)}}var g=r.return;try{Pc(r)}catch($){vt(r,g,$)}break;case 5:var k=r.return;try{Pc(r)}catch($){vt(r,k,$)}}}catch($){vt(r,r.return,$)}if(r===n){Re=null;break}var B=r.sibling;if(B!==null){B.return=r.return,Re=B;break}Re=r.return}}var ZS=Math.ceil,sa=T.ReactCurrentDispatcher,Lc=T.ReactCurrentOwner,ki=T.ReactCurrentBatchConfig,Ze=0,jt=null,Ct=null,$t=0,mi=0,Ir=wn(0),Nt=0,Bs=null,Gn=0,oa=0,jc=0,Is=null,si=null,Tc=0,Or=1/0,ln=null,aa=!1,Ac=null,Nn=null,la=!1,Rn=null,ca=0,Os=0,Bc=null,ua=-1,ha=0;function Jt(){return(Ze&6)!==0?St():ua!==-1?ua:ua=St()}function Pn(n){return(n.mode&1)===0?1:(Ze&2)!==0&&$t!==0?$t&-$t:BS.transition!==null?(ha===0&&(ha=Nd()),ha):(n=nt,n!==0||(n=window.event,n=n===void 0?16:Bd(n.type)),n)}function Oi(n,r,a,u){if(50<Os)throw Os=0,Bc=null,Error(i(185));ls(n,a,u),((Ze&2)===0||n!==jt)&&(n===jt&&((Ze&2)===0&&(oa|=a),Nt===4&&Dn(n,$t)),oi(n,u),a===1&&Ze===0&&(r.mode&1)===0&&(Or=St()+500,zo&&Cn()))}function oi(n,r){var a=n.callbackNode;By(n,r);var u=So(n,n===jt?$t:0);if(u===0)a!==null&&xd(a),n.callbackNode=null,n.callbackPriority=0;else if(r=u&-u,n.callbackPriority!==r){if(a!=null&&xd(a),r===1)n.tag===0?AS(Ip.bind(null,n)):bf(Ip.bind(null,n)),MS(function(){(Ze&6)===0&&Cn()}),a=null;else{switch(Rd(u)){case 1:a=ml;break;case 4:a=kd;break;case 16:a=go;break;case 536870912:a=Ed;break;default:a=go}a=Kp(a,Bp.bind(null,n))}n.callbackPriority=r,n.callbackNode=a}}function Bp(n,r){if(ua=-1,ha=0,(Ze&6)!==0)throw Error(i(327));var a=n.callbackNode;if(zr()&&n.callbackNode!==a)return null;var u=So(n,n===jt?$t:0);if(u===0)return null;if((u&30)!==0||(u&n.expiredLanes)!==0||r)r=da(n,u);else{r=u;var f=Ze;Ze|=2;var g=zp();(jt!==n||$t!==r)&&(ln=null,Or=St()+500,Jn(n,r));do try{iw();break}catch(B){Op(n,B)}while(!0);ec(),sa.current=g,Ze=f,Ct!==null?r=0:(jt=null,$t=0,r=Nt)}if(r!==0){if(r===2&&(f=gl(n),f!==0&&(u=f,r=Ic(n,f))),r===1)throw a=Bs,Jn(n,0),Dn(n,u),oi(n,St()),a;if(r===6)Dn(n,u);else{if(f=n.current.alternate,(u&30)===0&&!ew(f)&&(r=da(n,u),r===2&&(g=gl(n),g!==0&&(u=g,r=Ic(n,g))),r===1))throw a=Bs,Jn(n,0),Dn(n,u),oi(n,St()),a;switch(n.finishedWork=f,n.finishedLanes=u,r){case 0:case 1:throw Error(i(345));case 2:Zn(n,si,ln);break;case 3:if(Dn(n,u),(u&130023424)===u&&(r=Tc+500-St(),10<r)){if(So(n,0)!==0)break;if(f=n.suspendedLanes,(f&u)!==u){Jt(),n.pingedLanes|=n.suspendedLanes&f;break}n.timeoutHandle=Wl(Zn.bind(null,n,si,ln),r);break}Zn(n,si,ln);break;case 4:if(Dn(n,u),(u&4194240)===u)break;for(r=n.eventTimes,f=-1;0<u;){var k=31-Li(u);g=1<<k,k=r[k],k>f&&(f=k),u&=~g}if(u=f,u=St()-u,u=(120>u?120:480>u?480:1080>u?1080:1920>u?1920:3e3>u?3e3:4320>u?4320:1960*ZS(u/1960))-u,10<u){n.timeoutHandle=Wl(Zn.bind(null,n,si,ln),u);break}Zn(n,si,ln);break;case 5:Zn(n,si,ln);break;default:throw Error(i(329))}}}return oi(n,St()),n.callbackNode===a?Bp.bind(null,n):null}function Ic(n,r){var a=Is;return n.current.memoizedState.isDehydrated&&(Jn(n,r).flags|=256),n=da(n,r),n!==2&&(r=si,si=a,r!==null&&Oc(r)),n}function Oc(n){si===null?si=n:si.push.apply(si,n)}function ew(n){for(var r=n;;){if(r.flags&16384){var a=r.updateQueue;if(a!==null&&(a=a.stores,a!==null))for(var u=0;u<a.length;u++){var f=a[u],g=f.getSnapshot;f=f.value;try{if(!ji(g(),f))return!1}catch{return!1}}}if(a=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;else{if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Dn(n,r){for(r&=~jc,r&=~oa,n.suspendedLanes|=r,n.pingedLanes&=~r,n=n.expirationTimes;0<r;){var a=31-Li(r),u=1<<a;n[a]=-1,r&=~u}}function Ip(n){if((Ze&6)!==0)throw Error(i(327));zr();var r=So(n,0);if((r&1)===0)return oi(n,St()),null;var a=da(n,r);if(n.tag!==0&&a===2){var u=gl(n);u!==0&&(r=u,a=Ic(n,u))}if(a===1)throw a=Bs,Jn(n,0),Dn(n,r),oi(n,St()),a;if(a===6)throw Error(i(345));return n.finishedWork=n.current.alternate,n.finishedLanes=r,Zn(n,si,ln),oi(n,St()),null}function zc(n,r){var a=Ze;Ze|=1;try{return n(r)}finally{Ze=a,Ze===0&&(Or=St()+500,zo&&Cn())}}function Qn(n){Rn!==null&&Rn.tag===0&&(Ze&6)===0&&zr();var r=Ze;Ze|=1;var a=ki.transition,u=nt;try{if(ki.transition=null,nt=1,n)return n()}finally{nt=u,ki.transition=a,Ze=r,(Ze&6)===0&&Cn()}}function Fc(){mi=Ir.current,lt(Ir)}function Jn(n,r){n.finishedWork=null,n.finishedLanes=0;var a=n.timeoutHandle;if(a!==-1&&(n.timeoutHandle=-1,DS(a)),Ct!==null)for(a=Ct.return;a!==null;){var u=a;switch(Xl(u),u.tag){case 1:u=u.type.childContextTypes,u!=null&&Io();break;case 3:Tr(),lt(ii),lt(qt),lc();break;case 5:oc(u);break;case 4:Tr();break;case 13:lt(dt);break;case 19:lt(dt);break;case 10:tc(u.type._context);break;case 22:case 23:Fc()}a=a.return}if(jt=n,Ct=n=Mn(n.current,null),$t=mi=r,Nt=0,Bs=null,jc=oa=Gn=0,si=Is=null,Vn!==null){for(r=0;r<Vn.length;r++)if(a=Vn[r],u=a.interleaved,u!==null){a.interleaved=null;var f=u.next,g=a.pending;if(g!==null){var k=g.next;g.next=f,u.next=k}a.pending=u}Vn=null}return n}function Op(n,r){do{var a=Ct;try{if(ec(),Xo.current=Zo,Go){for(var u=ft.memoizedState;u!==null;){var f=u.queue;f!==null&&(f.pending=null),u=u.next}Go=!1}if(Xn=0,Lt=Et=ft=null,Ds=!1,Ms=0,Lc.current=null,a===null||a.return===null){Nt=1,Bs=r,Ct=null;break}e:{var g=n,k=a.return,B=a,$=r;if(r=$t,B.flags|=32768,$!==null&&typeof $=="object"&&typeof $.then=="function"){var re=$,pe=B,me=pe.tag;if((pe.mode&1)===0&&(me===0||me===11||me===15)){var fe=pe.alternate;fe?(pe.updateQueue=fe.updateQueue,pe.memoizedState=fe.memoizedState,pe.lanes=fe.lanes):(pe.updateQueue=null,pe.memoizedState=null)}var Ne=cp(k);if(Ne!==null){Ne.flags&=-257,up(Ne,k,B,g,r),Ne.mode&1&&lp(g,re,r),r=Ne,$=re;var Pe=r.updateQueue;if(Pe===null){var Le=new Set;Le.add($),r.updateQueue=Le}else Pe.add($);break e}else{if((r&1)===0){lp(g,re,r),Hc();break e}$=Error(i(426))}}else if(ut&&B.mode&1){var wt=cp(k);if(wt!==null){(wt.flags&65536)===0&&(wt.flags|=256),up(wt,k,B,g,r),Jl(Ar($,B));break e}}g=$=Ar($,B),Nt!==4&&(Nt=2),Is===null?Is=[g]:Is.push(g),g=k;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var J=op(g,$,r);jf(g,J);break e;case 1:B=$;var V=g.type,ie=g.stateNode;if((g.flags&128)===0&&(typeof V.getDerivedStateFromError=="function"||ie!==null&&typeof ie.componentDidCatch=="function"&&(Nn===null||!Nn.has(ie)))){g.flags|=65536,r&=-r,g.lanes|=r;var Se=ap(g,B,r);jf(g,Se);break e}}g=g.return}while(g!==null)}Hp(a)}catch(Ae){r=Ae,Ct===a&&a!==null&&(Ct=a=a.return);continue}break}while(!0)}function zp(){var n=sa.current;return sa.current=Zo,n===null?Zo:n}function Hc(){(Nt===0||Nt===3||Nt===2)&&(Nt=4),jt===null||(Gn&268435455)===0&&(oa&268435455)===0||Dn(jt,$t)}function da(n,r){var a=Ze;Ze|=2;var u=zp();(jt!==n||$t!==r)&&(ln=null,Jn(n,r));do try{tw();break}catch(f){Op(n,f)}while(!0);if(ec(),Ze=a,sa.current=u,Ct!==null)throw Error(i(261));return jt=null,$t=0,Nt}function tw(){for(;Ct!==null;)Fp(Ct)}function iw(){for(;Ct!==null&&!Ny();)Fp(Ct)}function Fp(n){var r=Up(n.alternate,n,mi);n.memoizedProps=n.pendingProps,r===null?Hp(n):Ct=r,Lc.current=null}function Hp(n){var r=n;do{var a=r.alternate;if(n=r.return,(r.flags&32768)===0){if(a=YS(a,r,mi),a!==null){Ct=a;return}}else{if(a=XS(a,r),a!==null){a.flags&=32767,Ct=a;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{Nt=6,Ct=null;return}}if(r=r.sibling,r!==null){Ct=r;return}Ct=r=n}while(r!==null);Nt===0&&(Nt=5)}function Zn(n,r,a){var u=nt,f=ki.transition;try{ki.transition=null,nt=1,nw(n,r,a,u)}finally{ki.transition=f,nt=u}return null}function nw(n,r,a,u){do zr();while(Rn!==null);if((Ze&6)!==0)throw Error(i(327));a=n.finishedWork;var f=n.finishedLanes;if(a===null)return null;if(n.finishedWork=null,n.finishedLanes=0,a===n.current)throw Error(i(177));n.callbackNode=null,n.callbackPriority=0;var g=a.lanes|a.childLanes;if(Iy(n,g),n===jt&&(Ct=jt=null,$t=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||la||(la=!0,Kp(go,function(){return zr(),null})),g=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||g){g=ki.transition,ki.transition=null;var k=nt;nt=1;var B=Ze;Ze|=4,Lc.current=null,QS(n,a),Mp(a,n),CS(Hl),Co=!!Fl,Hl=Fl=null,n.current=a,JS(a),Ry(),Ze=B,nt=k,ki.transition=g}else n.current=a;if(la&&(la=!1,Rn=n,ca=f),g=n.pendingLanes,g===0&&(Nn=null),My(a.stateNode),oi(n,St()),r!==null)for(u=n.onRecoverableError,a=0;a<r.length;a++)f=r[a],u(f.value,{componentStack:f.stack,digest:f.digest});if(aa)throw aa=!1,n=Ac,Ac=null,n;return(ca&1)!==0&&n.tag!==0&&zr(),g=n.pendingLanes,(g&1)!==0?n===Bc?Os++:(Os=0,Bc=n):Os=0,Cn(),null}function zr(){if(Rn!==null){var n=Rd(ca),r=ki.transition,a=nt;try{if(ki.transition=null,nt=16>n?16:n,Rn===null)var u=!1;else{if(n=Rn,Rn=null,ca=0,(Ze&6)!==0)throw Error(i(331));var f=Ze;for(Ze|=4,Re=n.current;Re!==null;){var g=Re,k=g.child;if((Re.flags&16)!==0){var B=g.deletions;if(B!==null){for(var $=0;$<B.length;$++){var re=B[$];for(Re=re;Re!==null;){var pe=Re;switch(pe.tag){case 0:case 11:case 15:As(8,pe,g)}var me=pe.child;if(me!==null)me.return=pe,Re=me;else for(;Re!==null;){pe=Re;var fe=pe.sibling,Ne=pe.return;if(Ep(pe),pe===re){Re=null;break}if(fe!==null){fe.return=Ne,Re=fe;break}Re=Ne}}}var Pe=g.alternate;if(Pe!==null){var Le=Pe.child;if(Le!==null){Pe.child=null;do{var wt=Le.sibling;Le.sibling=null,Le=wt}while(Le!==null)}}Re=g}}if((g.subtreeFlags&2064)!==0&&k!==null)k.return=g,Re=k;else e:for(;Re!==null;){if(g=Re,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:As(9,g,g.return)}var J=g.sibling;if(J!==null){J.return=g.return,Re=J;break e}Re=g.return}}var V=n.current;for(Re=V;Re!==null;){k=Re;var ie=k.child;if((k.subtreeFlags&2064)!==0&&ie!==null)ie.return=k,Re=ie;else e:for(k=V;Re!==null;){if(B=Re,(B.flags&2048)!==0)try{switch(B.tag){case 0:case 11:case 15:ra(9,B)}}catch(Ae){vt(B,B.return,Ae)}if(B===k){Re=null;break e}var Se=B.sibling;if(Se!==null){Se.return=B.return,Re=Se;break e}Re=B.return}}if(Ze=f,Cn(),Fi&&typeof Fi.onPostCommitFiberRoot=="function")try{Fi.onPostCommitFiberRoot(vo,n)}catch{}u=!0}return u}finally{nt=a,ki.transition=r}}return!1}function $p(n,r,a){r=Ar(a,r),r=op(n,r,1),n=kn(n,r,1),r=Jt(),n!==null&&(ls(n,1,r),oi(n,r))}function vt(n,r,a){if(n.tag===3)$p(n,n,a);else for(;r!==null;){if(r.tag===3){$p(r,n,a);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Nn===null||!Nn.has(u))){n=Ar(a,n),n=ap(r,n,1),r=kn(r,n,1),n=Jt(),r!==null&&(ls(r,1,n),oi(r,n));break}}r=r.return}}function rw(n,r,a){var u=n.pingCache;u!==null&&u.delete(r),r=Jt(),n.pingedLanes|=n.suspendedLanes&a,jt===n&&($t&a)===a&&(Nt===4||Nt===3&&($t&130023424)===$t&&500>St()-Tc?Jn(n,0):jc|=a),oi(n,r)}function Wp(n,r){r===0&&((n.mode&1)===0?r=1:(r=yo,yo<<=1,(yo&130023424)===0&&(yo=4194304)));var a=Jt();n=sn(n,r),n!==null&&(ls(n,r,a),oi(n,a))}function sw(n){var r=n.memoizedState,a=0;r!==null&&(a=r.retryLane),Wp(n,a)}function ow(n,r){var a=0;switch(n.tag){case 13:var u=n.stateNode,f=n.memoizedState;f!==null&&(a=f.retryLane);break;case 19:u=n.stateNode;break;default:throw Error(i(314))}u!==null&&u.delete(r),Wp(n,a)}var Up;Up=function(n,r,a){if(n!==null)if(n.memoizedProps!==r.pendingProps||ii.current)ri=!0;else{if((n.lanes&a)===0&&(r.flags&128)===0)return ri=!1,VS(n,r,a);ri=(n.flags&131072)!==0}else ri=!1,ut&&(r.flags&1048576)!==0&&Cf(r,Ho,r.index);switch(r.lanes=0,r.tag){case 2:var u=r.type;ia(n,r),n=r.pendingProps;var f=Nr(r,qt.current);jr(r,a),f=hc(null,r,u,n,f,a);var g=dc();return r.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,ni(u)?(g=!0,Oo(r)):g=!1,r.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,rc(r),f.updater=ea,r.stateNode=f,f._reactInternals=r,_c(r,u,n,a),r=bc(null,r,u,!0,g,a)):(r.tag=0,ut&&g&&Yl(r),Qt(null,r,f,a),r=r.child),r;case 16:u=r.elementType;e:{switch(ia(n,r),n=r.pendingProps,f=u._init,u=f(u._payload),r.type=u,f=r.tag=lw(u),n=Ai(u,n),f){case 0:r=wc(null,r,u,n,a);break e;case 1:r=gp(null,r,u,n,a);break e;case 11:r=hp(null,r,u,n,a);break e;case 14:r=dp(null,r,u,Ai(u.type,n),a);break e}throw Error(i(306,u,""))}return r;case 0:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),wc(n,r,u,f,a);case 1:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),gp(n,r,u,f,a);case 3:e:{if(vp(r),n===null)throw Error(i(387));u=r.pendingProps,g=r.memoizedState,f=g.element,Lf(n,r),Vo(r,u,null,a);var k=r.memoizedState;if(u=k.element,g.isDehydrated)if(g={element:u,isDehydrated:!1,cache:k.cache,pendingSuspenseBoundaries:k.pendingSuspenseBoundaries,transitions:k.transitions},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){f=Ar(Error(i(423)),r),r=_p(n,r,u,a,f);break e}else if(u!==f){f=Ar(Error(i(424)),r),r=_p(n,r,u,a,f);break e}else for(pi=Sn(r.stateNode.containerInfo.firstChild),fi=r,ut=!0,Ti=null,a=Df(r,null,u,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Dr(),u===f){r=an(n,r,a);break e}Qt(n,r,u,a)}r=r.child}return r;case 5:return Af(r),n===null&&Ql(r),u=r.type,f=r.pendingProps,g=n!==null?n.memoizedProps:null,k=f.children,$l(u,f)?k=null:g!==null&&$l(u,g)&&(r.flags|=32),mp(n,r),Qt(n,r,k,a),r.child;case 6:return n===null&&Ql(r),null;case 13:return yp(n,r,a);case 4:return sc(r,r.stateNode.containerInfo),u=r.pendingProps,n===null?r.child=Mr(r,null,u,a):Qt(n,r,u,a),r.child;case 11:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),hp(n,r,u,f,a);case 7:return Qt(n,r,r.pendingProps,a),r.child;case 8:return Qt(n,r,r.pendingProps.children,a),r.child;case 12:return Qt(n,r,r.pendingProps.children,a),r.child;case 10:e:{if(u=r.type._context,f=r.pendingProps,g=r.memoizedProps,k=f.value,ot(Uo,u._currentValue),u._currentValue=k,g!==null)if(ji(g.value,k)){if(g.children===f.children&&!ii.current){r=an(n,r,a);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var B=g.dependencies;if(B!==null){k=g.child;for(var $=B.firstContext;$!==null;){if($.context===u){if(g.tag===1){$=on(-1,a&-a),$.tag=2;var re=g.updateQueue;if(re!==null){re=re.shared;var pe=re.pending;pe===null?$.next=$:($.next=pe.next,pe.next=$),re.pending=$}}g.lanes|=a,$=g.alternate,$!==null&&($.lanes|=a),ic(g.return,a,r),B.lanes|=a;break}$=$.next}}else if(g.tag===10)k=g.type===r.type?null:g.child;else if(g.tag===18){if(k=g.return,k===null)throw Error(i(341));k.lanes|=a,B=k.alternate,B!==null&&(B.lanes|=a),ic(k,a,r),k=g.sibling}else k=g.child;if(k!==null)k.return=g;else for(k=g;k!==null;){if(k===r){k=null;break}if(g=k.sibling,g!==null){g.return=k.return,k=g;break}k=k.return}g=k}Qt(n,r,f.children,a),r=r.child}return r;case 9:return f=r.type,u=r.pendingProps.children,jr(r,a),f=Ci(f),u=u(f),r.flags|=1,Qt(n,r,u,a),r.child;case 14:return u=r.type,f=Ai(u,r.pendingProps),f=Ai(u.type,f),dp(n,r,u,f,a);case 15:return fp(n,r,r.type,r.pendingProps,a);case 17:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),ia(n,r),r.tag=1,ni(u)?(n=!0,Oo(r)):n=!1,jr(r,a),rp(r,u,f),_c(r,u,f,a),bc(null,r,u,!0,n,a);case 19:return wp(n,r,a);case 22:return pp(n,r,a)}throw Error(i(156,r.tag))};function Kp(n,r){return Cd(n,r)}function aw(n,r,a,u){this.tag=n,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=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ei(n,r,a,u){return new aw(n,r,a,u)}function $c(n){return n=n.prototype,!(!n||!n.isReactComponent)}function lw(n){if(typeof n=="function")return $c(n)?1:0;if(n!=null){if(n=n.$$typeof,n===A)return 11;if(n===F)return 14}return 2}function Mn(n,r){var a=n.alternate;return a===null?(a=Ei(n.tag,r,n.key,n.mode),a.elementType=n.elementType,a.type=n.type,a.stateNode=n.stateNode,a.alternate=n,n.alternate=a):(a.pendingProps=r,a.type=n.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=n.flags&14680064,a.childLanes=n.childLanes,a.lanes=n.lanes,a.child=n.child,a.memoizedProps=n.memoizedProps,a.memoizedState=n.memoizedState,a.updateQueue=n.updateQueue,r=n.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=n.sibling,a.index=n.index,a.ref=n.ref,a}function fa(n,r,a,u,f,g){var k=2;if(u=n,typeof n=="function")$c(n)&&(k=1);else if(typeof n=="string")k=5;else e:switch(n){case I:return er(a.children,f,g,r);case G:k=8,f|=8;break;case U:return n=Ei(12,a,r,f|2),n.elementType=U,n.lanes=g,n;case E:return n=Ei(13,a,r,f),n.elementType=E,n.lanes=g,n;case R:return n=Ei(19,a,r,f),n.elementType=R,n.lanes=g,n;case O:return pa(a,f,g,r);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case q:k=10;break e;case Y:k=9;break e;case A:k=11;break e;case F:k=14;break e;case D:k=16,u=null;break e}throw Error(i(130,n==null?n:typeof n,""))}return r=Ei(k,a,r,f),r.elementType=n,r.type=u,r.lanes=g,r}function er(n,r,a,u){return n=Ei(7,n,u,r),n.lanes=a,n}function pa(n,r,a,u){return n=Ei(22,n,u,r),n.elementType=O,n.lanes=a,n.stateNode={isHidden:!1},n}function Wc(n,r,a){return n=Ei(6,n,null,r),n.lanes=a,n}function Uc(n,r,a){return r=Ei(4,n.children!==null?n.children:[],n.key,r),r.lanes=a,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}function cw(n,r,a,u,f){this.tag=r,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=vl(0),this.expirationTimes=vl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=vl(0),this.identifierPrefix=u,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Kc(n,r,a,u,f,g,k,B,$){return n=new cw(n,r,a,B,$),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Ei(3,null,null,r),n.current=g,g.stateNode=n,g.memoizedState={element:u,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},rc(g),n}function uw(n,r,a){var u=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:H,key:u==null?null:""+u,children:n,containerInfo:r,implementation:a}}function qp(n){if(!n)return bn;n=n._reactInternals;e:{if($n(n)!==n||n.tag!==1)throw Error(i(170));var r=n;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(ni(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(i(171))}if(n.tag===1){var a=n.type;if(ni(a))return Sf(n,a,r)}return r}function Vp(n,r,a,u,f,g,k,B,$){return n=Kc(a,u,!0,n,f,g,k,B,$),n.context=qp(null),a=n.current,u=Jt(),f=Pn(a),g=on(u,f),g.callback=r??null,kn(a,g,f),n.current.lanes=f,ls(n,f,u),oi(n,u),n}function ma(n,r,a,u){var f=r.current,g=Jt(),k=Pn(f);return a=qp(a),r.context===null?r.context=a:r.pendingContext=a,r=on(g,k),r.payload={element:n},u=u===void 0?null:u,u!==null&&(r.callback=u),n=kn(f,r,k),n!==null&&(Oi(n,f,k,g),qo(n,f,k)),k}function ga(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function Yp(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var a=n.retryLane;n.retryLane=a!==0&&a<r?a:r}}function qc(n,r){Yp(n,r),(n=n.alternate)&&Yp(n,r)}function hw(){return null}var Xp=typeof reportError=="function"?reportError:function(n){console.error(n)};function Vc(n){this._internalRoot=n}va.prototype.render=Vc.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(i(409));ma(n,r,null,null)},va.prototype.unmount=Vc.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;Qn(function(){ma(null,n,null,null)}),r[en]=null}};function va(n){this._internalRoot=n}va.prototype.unstable_scheduleHydration=function(n){if(n){var r=Md();n={blockedOn:null,target:n,priority:r};for(var a=0;a<vn.length&&r!==0&&r<vn[a].priority;a++);vn.splice(a,0,n),a===0&&Td(n)}};function Yc(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function _a(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function Gp(){}function dw(n,r,a,u,f){if(f){if(typeof u=="function"){var g=u;u=function(){var re=ga(k);g.call(re)}}var k=Vp(r,u,n,0,null,!1,!1,"",Gp);return n._reactRootContainer=k,n[en]=k.current,bs(n.nodeType===8?n.parentNode:n),Qn(),k}for(;f=n.lastChild;)n.removeChild(f);if(typeof u=="function"){var B=u;u=function(){var re=ga($);B.call(re)}}var $=Kc(n,0,!1,null,null,!1,!1,"",Gp);return n._reactRootContainer=$,n[en]=$.current,bs(n.nodeType===8?n.parentNode:n),Qn(function(){ma(r,$,a,u)}),$}function ya(n,r,a,u,f){var g=a._reactRootContainer;if(g){var k=g;if(typeof f=="function"){var B=f;f=function(){var $=ga(k);B.call($)}}ma(r,k,n,f)}else k=dw(a,r,n,f,u);return ga(k)}Pd=function(n){switch(n.tag){case 3:var r=n.stateNode;if(r.current.memoizedState.isDehydrated){var a=as(r.pendingLanes);a!==0&&(_l(r,a|1),oi(r,St()),(Ze&6)===0&&(Or=St()+500,Cn()))}break;case 13:Qn(function(){var u=sn(n,1);if(u!==null){var f=Jt();Oi(u,n,1,f)}}),qc(n,1)}},yl=function(n){if(n.tag===13){var r=sn(n,134217728);if(r!==null){var a=Jt();Oi(r,n,134217728,a)}qc(n,134217728)}},Dd=function(n){if(n.tag===13){var r=Pn(n),a=sn(n,r);if(a!==null){var u=Jt();Oi(a,n,r,u)}qc(n,r)}},Md=function(){return nt},Ld=function(n,r){var a=nt;try{return nt=n,r()}finally{nt=a}},hl=function(n,r,a){switch(r){case"input":if(xe(n,a),r=a.name,a.type==="radio"&&r!=null){for(a=n;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<a.length;r++){var u=a[r];if(u!==n&&u.form===n.form){var f=Bo(u);if(!f)throw Error(i(90));Me(u),xe(u,f)}}}break;case"textarea":gt(n,a);break;case"select":r=a.value,r!=null&&Be(n,!!a.multiple,r,!1)}},gd=zc,vd=Qn;var fw={usingClientEntryPoint:!1,Events:[ks,kr,Bo,pd,md,zc]},zs={findFiberByHostInstance:Wn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},pw={bundleType:zs.bundleType,version:zs.version,rendererPackageName:zs.rendererPackageName,rendererConfig:zs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=wd(n),n===null?null:n.stateNode},findFiberByHostInstance:zs.findFiberByHostInstance||hw,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 Sa=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Sa.isDisabled&&Sa.supportsFiber)try{vo=Sa.inject(pw),Fi=Sa}catch{}}return ai.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=fw,ai.createPortal=function(n,r){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Yc(r))throw Error(i(200));return uw(n,r,null,a)},ai.createRoot=function(n,r){if(!Yc(n))throw Error(i(299));var a=!1,u="",f=Xp;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onRecoverableError!==void 0&&(f=r.onRecoverableError)),r=Kc(n,1,!1,null,null,a,!1,u,f),n[en]=r.current,bs(n.nodeType===8?n.parentNode:n),new Vc(r)},ai.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var r=n._reactInternals;if(r===void 0)throw typeof n.render=="function"?Error(i(188)):(n=Object.keys(n).join(","),Error(i(268,n)));return n=wd(r),n=n===null?null:n.stateNode,n},ai.flushSync=function(n){return Qn(n)},ai.hydrate=function(n,r,a){if(!_a(r))throw Error(i(200));return ya(null,n,r,!0,a)},ai.hydrateRoot=function(n,r,a){if(!Yc(n))throw Error(i(405));var u=a!=null&&a.hydratedSources||null,f=!1,g="",k=Xp;if(a!=null&&(a.unstable_strictMode===!0&&(f=!0),a.identifierPrefix!==void 0&&(g=a.identifierPrefix),a.onRecoverableError!==void 0&&(k=a.onRecoverableError)),r=Vp(r,null,n,1,a??null,f,!1,g,k),n[en]=r.current,bs(n),u)for(n=0;n<u.length;n++)a=u[n],f=a._getVersion,f=f(a._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[a,f]:r.mutableSourceEagerHydrationData.push(a,f);return new va(r)},ai.render=function(n,r,a){if(!_a(r))throw Error(i(200));return ya(null,n,r,!1,a)},ai.unmountComponentAtNode=function(n){if(!_a(n))throw Error(i(40));return n._reactRootContainer?(Qn(function(){ya(null,null,n,!1,function(){n._reactRootContainer=null,n[en]=null})}),!0):!1},ai.unstable_batchedUpdates=zc,ai.unstable_renderSubtreeIntoContainer=function(n,r,a,u){if(!_a(a))throw Error(i(200));if(n==null||n._reactInternals===void 0)throw Error(i(38));return ya(n,r,a,!1,u)},ai.version="18.3.1-next-f1338f8080-20240426",ai}var rm;function Cw(){if(rm)return Qc.exports;rm=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(),Qc.exports=bw(),Qc.exports}var sm;function xw(){if(sm)return wa;sm=1;var e=Cw();return wa.createRoot=e.createRoot,wa.hydrateRoot=e.hydrateRoot,wa}var kw=xw();const Ew=Oh(kw);function zt(e,t,i={}){return fetch(e,{...i,headers:{...i.headers||{},Authorization:`Bearer ${t}`}})}const xv=e=>`nc_seen_${e}`;async function We(e,t,i={}){const s=await zt(e,t,{method:i.method||"GET",headers:{"content-type":"application/json"},body:i.body?JSON.stringify(i.body):void 0}),o=await s.json().catch(()=>({}));if(!s.ok){const l=new Error(o.error||`HTTP ${s.status}`);throw l.status=s.status,l.data=o,l}return o}const ui=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",Kt=(e,t)=>`${ui(e)}/fleet/${t}`,dr=(e,t)=>We(Kt(t,"status"),e),Fh=(e,t,i)=>We(Kt(i,"up"),e,{method:"POST",body:t}),Fa=(e,t,i)=>We(Kt(i,"down"),e,{method:"POST",body:t}),Gs=(e,t,i)=>We(Kt(i,"restart"),e,{method:"POST",body:{cell:t}}),Hh=(e,t)=>We(Kt(t,"definitions"),e),Nw=(e,t)=>We(Kt(t,"credentials/status"),e),Rw=(e,t,i,s)=>We(Kt(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:i}}),Pw=(e,t,i)=>We(Kt(i,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),Dw=(e,t,i)=>We(Kt(i,"define-engine"),e,{method:"POST",body:{def:t}}),Mw=(e,t,i,s,o)=>We(Kt(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:i,envChanges:s}}),Lw=(e,t,i)=>We(Kt(i,"remove-engine"),e,{method:"POST",body:{id:t}}),jw=(e,t,i)=>We(Kt(i,"define-cell"),e,{method:"POST",body:{def:t}}),Tw=(e,t,i,s)=>We(Kt(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:i}}),kv=(e,t,i=!1,s)=>We(Kt(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:i}}),Aw=(e,t,i)=>We(Kt(i,"import-cell"),e,{method:"POST",body:t}),Bw=(e,t,i)=>We(Kt(i,"restore-cells"),e,{method:"POST",body:{cells:t}}),Iw=(e,t,i,s)=>We(Kt(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!i}}),$h=(e,t,i)=>We(`${ui(i)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Ev=(e,t,i,s)=>We(`${ui(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!i}}),Nv=(e,t,i)=>We(`${ui(i)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),Rv=e=>We("/api/settings",e),Pv=e=>We("/api/nodes",e),Ow=e=>We("/api/topology",e),Dv=(e,t)=>We(`${ui(t)}/sessions`,e),Wh=(e,t)=>We(`${ui(t)}/config`,e),om=(e,t)=>We(`${ui(t)}/topology`,e),Mv=(e,t)=>We("/api/settings/config",e,{method:"POST",body:t}),zw=e=>We("/api/settings/token/rotate",e,{method:"POST"}),Fw=(e,t)=>We("/api/settings/nodes/pair",e,{method:"POST",body:t}),am=(e,t,i=[])=>We(`${ui(i)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),Hw=(e,t,i)=>We(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:i}}),$w=(e,t)=>We(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Uh=(e,t,i)=>We(`/api/settings/nodes/${encodeURIComponent(t)}/${i}`,e,{method:"POST"}),Ww=(e,t,i)=>We(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:i}}),lm=(e,t,i,s=[])=>We(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:i,selected:s}}),Uw=e=>We("/api/settings/service/regenerate",e,{method:"POST"}),Kw=e=>We("/api/settings/update/check",e,{method:"POST"}),qw=e=>We("/api/settings/update/apply",e,{method:"POST"}),Vw=(e,t=!0)=>We(`/api/asks${t?"?open=1":""}`,e),Yw=(e,t,i)=>We(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:i}}),ba=(e,t=[])=>We(`${ui(t)}/decks`,e),cm=(e,t,i=[])=>We(`${ui(i)}/decks`,e,{method:"POST",body:{name:t}}),Ca=(e,t,i,s,o=[])=>We(`${ui(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:i,expectedRevision:s}}),Xw=(e,t,i,s,o=[])=>We(`${ui(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:i,expectedRevision:s}}),Gw=(e,t,i,s=[])=>We(`${ui(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:i}}),Qw={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"}),chevronUp:h.jsx("polyline",{points:"6 14 12 8 18 14"}),chevronDown:h.jsx("polyline",{points:"6 10 12 16 18 10"}),history:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),h.jsx("polyline",{points:"3 3 3 8 8 8"}),h.jsx("path",{d:"M12 7v5l3 2"})]}),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 et({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:Qw[e]||null})}const Jw=["all","pinned","active","off","technical"],Lv="nc_sidebar_views_v1",jv="nc_sidebar_order_v1";function Tv(e){return Jw.includes(e)?e:"all"}function Zw(e,t=[],i="all"){const s=Tv(i);return s==="technical"?e.technical===!0:e.technical===!0?!1:s==="pinned"?t.includes(e.key):s==="active"?!!e.live:s==="off"?!e.live:!0}function e0(e,t,i=[],s=[]){const o=i.indexOf(e.key),l=i.indexOf(t.key),c=o===-1?Number.MAX_SAFE_INTEGER:o,d=l===-1?Number.MAX_SAFE_INTEGER:l,m=s.indexOf(e.key),p=s.indexOf(t.key),S=m===-1?Number.MAX_SAFE_INTEGER:m,C=p===-1?Number.MAX_SAFE_INTEGER:p;return c-d||S-C||+!!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 t0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(jv));if(!t||typeof t!="object"||Array.isArray(t))return{};const i={};for(const[s,o]of Object.entries(t).slice(0,64)){if(typeof s!="string"||!s||s.length>160||!Array.isArray(o))continue;const l=[...new Set(o.filter(c=>typeof c=="string"&&c&&c.length<=256))].slice(0,128);l.length&&(i[s]=l)}return i}catch{return{}}}function zn(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function i0(e,t=globalThis.localStorage){try{t.setItem(jv,JSON.stringify(e))}catch{}return e}function n0(e,t,i,s,o=[]){if(typeof t!="string"||!t||i===s)return e;const l=[...new Set(o.filter(_=>typeof _=="string"&&_))];if(!l.includes(i)||!l.includes(s))return e;const c=zn(e,t).filter(_=>l.includes(_)),d=[...c,...l.filter(_=>!c.includes(_))],m=d.indexOf(i),p=d.indexOf(s);d.splice(m,1);const S=d.indexOf(s),C=m<p?S+1:S;return d.splice(C,0,i),{...e,[t]:d}}function r0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Lv));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function um(e,t){var i,s;return{open:((i=e==null?void 0:e[t])==null?void 0:i.open)!==!1,filter:Tv((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function s0(e,t=globalThis.localStorage){try{t.setItem(Lv,JSON.stringify(e))}catch{}return e}function hm(e,t=""){const i=String(t||"").trim().toLocaleLowerCase();return i?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(i):!0}function ar(e=[],t=[],i="all",s=[]){return[...e].filter(o=>Zw(o,t,i)).sort((o,l)=>e0(o,l,t,s))}const Kh=["it","en","es"];function o0(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return Kh.includes(t)?t:"en"}catch{return"en"}}const ja=o0(),Av="nc_lang",$u="nc-lang";function Bv(){return typeof localStorage<"u"?localStorage:null}const xa={it:{"update-available":"nuova versione {v} disponibile","install-version-mismatch":"installazione incompleta: frontend e server non coincidono (v{v})",reload:"ricarica","grid-empty":"trascina qui una sessione dalla sidebar, o doppio-clic per la vista singola","grid-full":"il deck può mostrare al massimo 9 sessioni",pin:"fissa in cima",reorder:"riordina","reorder-help":"trascina la maniglia; frecce su/giu da tastiera","reorder-deck-help":"trascina il deck; frecce sinistra/destra da tastiera",sessions:"sessioni","new-session":"nuova sessione",new:"nuova",fleet:"Flotta","fleet-tmux":"flotta tmux","other-sessions":"Altre sessioni","view-all":"tutte","view-pinned":"fissate","view-active":"attive","view-off":"spente","view-technical":"tecniche","mark-technical":"nascondi come sessione tecnica","mark-normal":"mostra come sessione normale","position-local":"Locale",files:"file",refresh:"aggiorna","filter-placeholder":"filtra sessioni…","loading-fleet":"carico la flotta…","no-sessions":"nessuna sessione tmux viva — la flotta parte al boot (systemd)","no-match":'nessuna sessione contiene "{q}"',"copy-url":"clicca per copiare l'URL","ssh-only":"solo tunnel SSH/VPN","new-files-outbox":"nuovi file in outbox",terminate:"termina","terminate-confirm":'Terminare la sessione "{name}"?',"cell-on":"tmux vivo","cell-off":"spenta","cell-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…","composer-history-tools":"cronologia e dimensione input","composer-history":"cronologia della cella","composer-history-empty":"nessun input inviato","composer-history-clear":"cancella cronologia di questa cella","composer-expand":"espandi input","composer-collapse":"riduci input","composer-clear-data":"cancella bozze e cronologia","composer-clear-data-help":"Rimuove da questo browser tutte le bozze e la cronologia input delle celle.","composer-clear-confirm":"Cancellare tutte le bozze e la cronologia input salvate in questo browser?","composer-clear-done":"Bozze e cronologia cancellate.","composer-clear-failed":"Impossibile cancellare i dati del composer in questo browser.",attach:"allega","attach-file":"File","attach-camera":"Fotocamera","attach-gallery":"Galleria","attach-uploading":"carico…","attach-upload-progress":"allegato {n}/{total}…","attach-uploaded":"{n} allegati caricati",voice:"voice",send:"invia","composer-send-failed":"connessione non pronta — testo conservato, riprova",close:"chiudi","lang-label":"lingua",decks:"deck","new-deck":"nuovo deck","deck-name":"nome deck","open-deck-window":"apri in una nuova finestra","detach-deck":"stacca in una nuova finestra","deck-current":"questo deck (finestra corrente)","deck-owner-unavailable":"nodo owner non condiviso o non raggiungibile","rename-deck":"rinomina deck","delete-deck":"elimina deck","delete-deck-confirm":'Eliminare il deck "{name}"?',"send-to-deck":"manda al deck…","deck-autosave":"salvataggio automatico",saving:"salvataggio…",saved:"salvato","popup-blocked":"popup bloccato: apri qui","select-drag":"trascina per selezionare","copy-manual":"seleziona e copia manualmente","toggle-sidebar":"mostra/nascondi la barra laterale",settings:"impostazioni","tab-roles":"ruoli","tab-nodes":"nodi",local:"Locale",location:"Dove","pairing-link":"link di pairing","pairing-required":"nome, alias SSH e link di pairing sono obbligatori","pairing-connect-help":"Per collegare un nodo servono: nome, Host SSH già funzionante e link/QR creato sull’altra installazione NexusCrew.","pairing-localhost-hint":"127.0.0.1 nel link è corretto: non aprirlo qui. NexusCrew usa invito e porta attraverso l’Host SSH.","scan-qr":"scansiona QR","pairing-qr-invalid":"QR di pairing non valido","invite-node":"invita un nodo","create-pairing-link":"crea link / QR","visibility-network":"tutta la rete","visibility-relay":"solo relay","visibility-selected":"nodi selezionati","hydra-simple":"locale + nodi, una sola rete","local-ready":"Questo dispositivo è pronto. Puoi usarlo da solo o collegarlo a un nodo.","local-only":"solo locale","add-node":"aggiungi nodo",connect:"collega","node-connected":"Nodo collegato. La rete verrà sincronizzata automaticamente.","tab-system":"sistema","tab-fleet":"flotta","fleet-editor-unavailable":"Editor disponibile solo con il provider fleet builtin.","fleet-managed":"gestito da NexusCrew","fleet-custom":"comando personalizzato","fleet-managed-help":"Client, provider e avvio sono gestiti internamente; i segreti non vengono mostrati.","fleet-credential-title":"API key su questo dispositivo","fleet-credential-help":"La key resta solo sul nodo selezionato, non viene mostrata, esportata o condivisa con la rete.","fleet-credential-set":"imposta key","fleet-credential-change":"cambia key","fleet-credential-forget":"dimentica","fleet-credential-saved":"Key salvata localmente.","fleet-credential-removed":"Key locale rimossa.","fleet-credential-remove-confirm":"Rimuovere la key locale {key}?","fleet-credential-source-environment":"ambiente","fleet-credential-source-local":"store locale","fleet-credential-source-compatibility":"config compatibile","fleet-credential-source-missing":"mancante","fleet-model-default":"modello predefinito (opzionale)","fleet-model-required":"modello (obbligatorio)","fleet-standard-permissions":"permessi standard","fleet-unsafe-permissions":"non sicuro · ignora approvazioni/sandbox","fleet-unsafe-warning":"Modalità non sicura esplicita: il worker può agire senza le normali approvazioni o protezioni sandbox.","fleet-provider-display":"nome visualizzato del provider","fleet-custom-provider-default":"Provider personalizzato","fleet-api-key-env":"NOME_VARIABILE_API_KEY","fleet-provider-id":"id-provider","fleet-custom-secret-help":"NexusCrew salva solo il nome della variabile d’ambiente, mai il suo valore.","fleet-model-override":"modello alternativo","fleet-ready":"pronto","fleet-not-ready":"non configurato","fleet-engines":"Engine","fleet-cells":"Celle / sessioni cloud","fleet-backup":"backup / ripristino","fleet-backup-help":"Esporta o ripristina selettivamente engine, celle e system prompt. Token, API key e segreti provider non entrano mai nel file.","fleet-backup-export":"esporta","fleet-backup-import":"importa","fleet-backup-download":"scarica backup","fleet-backup-restore":"ripristina selezionate","fleet-backup-import-help":"Scegli un backup JSON, controlla le celle e seleziona l’engine di destinazione prima del ripristino.","fleet-backup-overwrite":"sovrascrive la cella esistente","fleet-backup-new":"nuova cella","fleet-backup-engine-missing":"scegli un engine disponibile","fleet-backup-restore-unavailable":"Il nodo selezionato supporta solo l’esportazione; aggiornalo per ripristinare backup.","fleet-backup-restored":"{n} celle ripristinate","fleet-backup-confirm-overwrite":"Sovrascrivere queste celle? {cells}","fleet-backup-needs-restart":"riavvio necessario: {cells}","fleet-backup-empty":"nessuna cella da esportare","fleet-backup-select-one":"seleziona almeno una cella","fleet-backup-too-large":"backup troppo grande (massimo 1 MB)","fleet-backup-invalid-json":"il file non contiene JSON valido","fleet-backup-invalid-format":"formato o versione del backup non supportati","fleet-backup-invalid-cell":"il backup contiene una cella non valida","fleet-backup-duplicate-cell":"il backup contiene ID cella duplicati","fleet-backup-invalid-engine":"il backup contiene un engine non valido","fleet-backup-duplicate-engine":"il backup contiene ID engine duplicati","fleet-backup-confirm-engine-overwrite":"Sovrascrivere questi engine? I valori ambiente già configurati sul target restano invariati. {engines}","fleet-backup-env-names":"nomi ambiente","fleet-backup-env-values-required":"i valori ambiente vanno configurati sul dispositivo","fleet-system-prompt":"system prompt",characters:"caratteri","select-all":"seleziona tutte","select-none":"nessuna",edit:"modifica",save:"salva",label:"etichetta","command-path":"path assoluto del comando","args-lines":"argomenti, uno per riga","env-write-only":"I valori env sono write-only: vuoto mantiene il valore esistente.","fleet-new-engine":"Nuovo engine","fleet-new-cell":"Nuova cella","fleet-saved":"Definizione salvata.","fleet-restart-confirm":"Modifica salvata. Riavviare ora: {cells}?","fleet-remove-engine":'Eliminare l’engine "{id}"?',"fleet-remove-cell":'Eliminare la cella "{id}"? Se è attiva verrà prima fermata.',"settings-readonly":"READONLY attivo: le modifiche sono bloccate dal server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"questa macchina guarda altri nodi via tunnel SSH","role-node":"nodo (raggiungibile)","published-port":"porta pubblicata (opzionale)","no-nodes":"nessun nodo remoto configurato","node-add":"collega installazione NexusCrew","node-connect-help":"La porta SSH serve a raggiungere il server SSH. La porta NexusCrew è invece la porta locale mostrata da `nexuscrew status` sul nodo remoto.","node-name-label":"Nome del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH su questo dispositivo","node-ssh-local-help":"Puoi sostituire l’indirizzo del link con lo stesso alias che funziona usando ssh su questo dispositivo. Alias, agent e chiavi restano locali e non viaggiano nel link.","node-ssh-port-label":"Porta SSH","node-ssh-port-help":"Di solito 22; usa la porta pubblica del server SSH.","node-app-port-label":"Porta NexusCrew sul nodo","node-app-port-help":"È la porta mostrata da `nexuscrew status` sul nodo remoto.","node-name-ph":"nome (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"porta remota (opz.)","node-remove-confirm":'Rimuovere il nodo "{name}"?',"node-test":"test","tunnel-start":"avvia tunnel","tunnel-stop":"ferma tunnel","tunnel-restart":"riavvia tunnel","share-node":"Condividi questo nodo","share-local-heading":"Condivisione di questo dispositivo","share-local-hub":"Hub di condivisione","share-local-through":"Condividi {device} tramite {hub}","share-local-active":"Condiviso e raggiungibile dalla rete collegata all’hub.","share-local-private":"Privato: solo questo dispositivo può usare il collegamento all’hub.","share-node-off-desc":"Privato: resta collegato al nodo hub, ma gli altri client non possono raggiungerlo.","share-node-on-desc":"Condiviso: il nodo hub può mostrarlo e smistare celle e deck autorizzati.","peer-shared":"Nodo client condiviso nella rete Hydra","peer-private":"Nodo client privato: collegato, non pubblicato nella rete Hydra","node-connected-client":"client collegato","transport-used":"in uso","tunnel-up":"tunnel su","tunnel-down":"tunnel giù","authorized-keys-hint":"incolla questa riga in ~/.ssh/authorized_keys sull'host remoto:",copy:"copia",copied:"copiato","token-rotate":"ruota token","token-rotate-explain":"Il nuovo token NON verrà mostrato: recuperalo con `nexuscrew show token`. La sessione corrente verrà invalidata.","service-regenerate":"rigenera service","npm-auto-update":"aggiornamenti automatici da npm","npm-auto-update-help":"Controlla periodicamente latest e installa solo versioni più recenti. Mai downgrade.","npm-update-current":"installata","npm-update-latest":"npm latest","npm-update-check":"controlla ora","npm-update-install":"aggiorna ora","npm-update-restarting":"Aggiornamento avviato; NexusCrew si riaprirà dopo il riavvio del servizio.","npm-update-idle":"aggiornato","npm-update-checking":"controllo in corso","npm-update-available":"aggiornamento disponibile","npm-update-installing":"installazione in corso","npm-update-installed":"installato, riavvio in corso","npm-update-error":"controllo fallito","npm-update-unsupported":"disponibile solo con installazione npm globale","service-installed":"service installato","service-missing":"service non installato","service-active":"attivo","service-inactive":"non attivo",confirm:"conferma",add:"aggiungi",enable:"attiva","wizard-title":"benvenuto in NexusCrew","wizard-skip":"configura dopo dai settings","wizard-step-roles":"ruoli di questa installazione","wizard-step-node":"primo nodo remoto (opzionale)","wizard-done":"tutto pronto","wizard-done-desc":"setup completato — puoi cambiare tutto dai settings",next:"continua",back:"indietro",skip:"salta",finish:"fine","err-node-name":"nome non valido (a-z, 0-9, -, max 32)","err-ssh":"ssh non valido (atteso user@host o alias)","err-port":"porta non valida (1–65535)","err-ssh-port":"porta SSH non valida (1–65535)","err-node-port":"porta NexusCrew non valida (1–65535)","node-sessions":"{n} sessioni","tunnel-down-since":"tunnel giù da {t}","node-unreachable":"nodo non raggiungibile","node-passive":"client offline · stato normale","node-offline":"nodo offline","node-offline-seen":"offline · visto {t} fa","node-needs-repair":"legacy · ripeti il pairing","asks-title":"domande dalle celle","ask-reply-ph":"scrivi la risposta…","push-enable":"attiva notifiche push","push-disable":"disattiva notifiche push","push-on":"push attive su questo device","push-off":"push non attive","push-denied":"permesso notifiche negato dal browser","push-unsupported":"push non supportate in questo browser","node-display-label":"Nome (etichetta)","node-slug-hint":"routing su slug: {slug}","device-name-label":"Nome dispositivo","device-name-hint":"come ti vedono i peer (modificabile)","err-label":"etichetta non valida (max 64 char, niente a capo)","fleet-inventory":"Celle e sessioni","fleet-inventory-help":"tutte le posizioni (Locale + route Hydra)","fleet-manage-location":"Gestisci posizione","fleet-network-overview":"Panoramica rete","fleet-manage-help":"crea e configura celle nella posizione selezionata","fleet-overview-help":"stato operativo di tutte le posizioni, senza duplicare l’editor","fleet-inventory-empty":"nessuna cella o sessione","fleet-not-available":"fleet non disponibile su questa posizione",start:"avvia",stop:"ferma",restart:"riavvia",delete:"elimina","copy-manual":"copia non riuscita — seleziona e Cmd+C, o copia a mano","copy-empty":"niente selezione: trascina con Shift per selezionare","save-and-start":"salva e avvia",permissions:"Permessi","power-on-hint":"Spegni la cella; puoi anche toglierla dal boot.","launch-engine-help":"Provider, credenziali e nuovi engine si creano in Impostazioni → Flotta. Modello e permessi sono per questa cella.","launch-external-hint":"Provider esterno: engine/modello si configurano nel fleet esterno.","import-as-cell":"Importa come cella","import-help":"Riconcilia una sessione tmux esistente in una cella gestita. Scegli un engine già dichiarato: nessun engine viene inventato.","import-engine-required":"scegli un engine (obbligatorio)","test-and-connect":"testa e collega","pairing-v2-hint":"Incolla o scansiona UN solo link: precompila nome, Host SSH ed etichetta quando il link li include (v2).","invite-v2-hint":"Crea un invito monouso completo. Se sei già collegato a un hub, viene usato automaticamente; altrimenti serve solo il suo indirizzo SSH raggiungibile.","invite-network-hint":"Crea un invito per la rete a cui sei già collegato. Il nuovo dispositivo entrerà attraverso l’hub, non si collegherà direttamente a questo dispositivo.","invite-network-label":"Rete di destinazione","invite-network-via":"Hub","invite-network-route":"Un solo collegamento verso l’hub; nodi, celle e deck vengono smistati internamente.","invite-endpoint-label":"Indirizzo SSH di questo hub visto dagli altri dispositivi","invite-endpoint-auto":"Endpoint già configurato","invite-endpoint-needed":"Inserisci user@host o un alias SSH condiviso. Non è 127.0.0.1 e non è l’URL HTTP NexusCrew.","invite-ssh-hint":"Il target SSH con cui L’ALTRO dispositivo raggiunge QUESTA installazione (user@host o alias). Obbligatorio: viene incluso nel link.","invite-next-steps":"copia questo link, apri NexusCrew sull’altro dispositivo e incollalo in Impostazioni → Nodi (o scansiona il QR): al resto pensa NexusCrew","pair-card-title":"collega con un solo link","pair-card-help":"Incolla il link di pairing generato sull’altro dispositivo (o scansiona il suo QR): NexusCrew decodifica, prova la connessione SSH e collega da solo.","pair-paste-ph":"incolla qui il link di pairing","pair-paste-btn":"incolla","pair-advanced":"avanzate / modifica","pair-progress":"collegamento in corso: SSH → invito → conferma → verifica…","pair-retry":"riprova","pair-invalid-link":"questo non è un link di pairing valido","pair-invalid-hint":"serve il link completo (http://…#pair=…) generato dall’altro NexusCrew: non aprirlo, incollalo qui","pair-missing-ssh":"il link non include il target SSH (formato v1): indica in “avanzate” come questo dispositivo raggiunge l’altro via SSH — non viene mai inventato","pair-missing-name":"manca il nome del nodo: completalo in “avanzate”","pair-clipboard-denied":"lettura degli appunti non consentita: incolla manualmente nel campo","pair-clipboard-empty":"appunti vuoti: copia prima il link di pairing","pair-stage-validation":"dati non validi","pair-stage-conflict":"nome già in uso","pair-stage-ssh-start":"avvio del tunnel SSH fallito","pair-stage-ssh-ready":"peer non raggiungibile via SSH","pair-stage-join":"scambio dell’invito fallito","pair-stage-tunnel-final":"tunnel negoziato fallito","pair-stage-confirm":"conferma del pairing fallita","pair-stage-health":"verifica finale della federazione fallita","pair-stage-internal":"errore interno","pair-stage-generic":"connessione fallita","qr-no-camera":"nessuna camera disponibile su questo dispositivo: usa una foto del QR","qr-permission":"permesso camera negato: consentilo nel browser o usa una foto del QR","qr-unsupported":"scanner live non supportato qui: carica una foto del QR","qr-upload":"usa una foto"},en:{"update-available":"new version {v} available","install-version-mismatch":"incomplete installation: frontend and server do not match (v{v})",reload:"reload","grid-empty":"drag a session here from the sidebar, or double-click for single view","grid-full":"a deck can show at most 9 sessions",pin:"pin to top",reorder:"reorder","reorder-help":"drag the handle; keyboard up/down arrows","reorder-deck-help":"drag the deck; keyboard left/right arrows",sessions:"sessions","new-session":"new session",new:"new",fleet:"Fleet","fleet-tmux":"tmux fleet","other-sessions":"Other sessions","view-all":"all","view-pinned":"pinned","view-active":"active","view-off":"off","view-technical":"technical","mark-technical":"hide as technical session","mark-normal":"show as normal session","position-local":"Local",files:"files",refresh:"refresh","filter-placeholder":"filter sessions…","loading-fleet":"loading fleet…","no-sessions":"no live tmux sessions — the fleet starts at boot (systemd)","no-match":'no session matches "{q}"',"copy-url":"click to copy URL","ssh-only":"SSH/VPN tunnel only","new-files-outbox":"new files in outbox",terminate:"terminate","terminate-confirm":'Terminate session "{name}"?',"cell-on":"tmux alive","cell-off":"off","cell-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…","composer-history-tools":"input history and size","composer-history":"cell history","composer-history-empty":"no submitted input","composer-history-clear":"clear this cell history","composer-expand":"expand input","composer-collapse":"collapse input","composer-clear-data":"clear drafts and history","composer-clear-data-help":"Removes every saved cell draft and input-history entry from this browser.","composer-clear-confirm":"Clear every saved draft and input-history entry from this browser?","composer-clear-done":"Drafts and history cleared.","composer-clear-failed":"Could not clear composer data in this browser.",attach:"attach","attach-file":"File","attach-camera":"Camera","attach-gallery":"Gallery","attach-uploading":"uploading…","attach-upload-progress":"attachment {n}/{total}…","attach-uploaded":"{n} attachments uploaded",voice:"voice",send:"send","composer-send-failed":"connection not ready — text kept, try again",close:"close","lang-label":"language",decks:"decks","new-deck":"new deck","deck-name":"deck name","open-deck-window":"open in a new window","detach-deck":"detach into a new window","deck-current":"this deck (current window)","deck-owner-unavailable":"owner node is not shared or reachable","rename-deck":"rename deck","delete-deck":"delete deck","delete-deck-confirm":'Delete deck "{name}"?',"send-to-deck":"send to deck…","deck-autosave":"autosave",saving:"saving…",saved:"saved","popup-blocked":"popup blocked: open here","select-drag":"drag to select","copy-manual":"select and copy manually","toggle-sidebar":"show/hide the sidebar",settings:"settings","tab-roles":"roles","tab-nodes":"nodes",local:"Local",location:"Location","pairing-link":"pairing link","pairing-required":"name, SSH alias and pairing link are required","pairing-connect-help":"Connecting a node requires a name, a working SSH Host, and a link/QR created by the other NexusCrew installation.","pairing-localhost-hint":"127.0.0.1 in the link is correct: do not open it here. NexusCrew carries the invite and port through the SSH Host.","scan-qr":"scan QR","pairing-qr-invalid":"invalid pairing QR","invite-node":"invite a node","create-pairing-link":"create link / QR","visibility-network":"whole network","visibility-relay":"relay only","visibility-selected":"selected nodes","hydra-simple":"local + nodes, one network","local-ready":"This device is ready. Use it alone or connect it to a node.","local-only":"local only","add-node":"add node",connect:"connect","node-connected":"Node connected. The network will synchronize automatically.","tab-system":"system","tab-fleet":"fleet","fleet-editor-unavailable":"The editor is available only with the builtin fleet provider.","fleet-managed":"managed by NexusCrew","fleet-custom":"custom command","fleet-managed-help":"Client, provider and launch are managed internally; secrets are never displayed.","fleet-credential-title":"API key on this device","fleet-credential-help":"The key stays only on the selected node and is never displayed, exported or shared with the network.","fleet-credential-set":"set key","fleet-credential-change":"change key","fleet-credential-forget":"forget","fleet-credential-saved":"Key saved locally.","fleet-credential-removed":"Local key removed.","fleet-credential-remove-confirm":"Remove the local {key} key?","fleet-credential-source-environment":"environment","fleet-credential-source-local":"local store","fleet-credential-source-compatibility":"compatible config","fleet-credential-source-missing":"missing","fleet-model-default":"default model (optional)","fleet-model-required":"model (required)","fleet-standard-permissions":"standard permissions","fleet-unsafe-permissions":"unsafe · bypass approvals/sandbox","fleet-unsafe-warning":"Explicit unsafe mode: the worker can act without normal approval or sandbox gates.","fleet-provider-display":"provider display name","fleet-custom-provider-default":"Custom provider","fleet-api-key-env":"API_KEY_ENV_NAME","fleet-provider-id":"provider-id","fleet-custom-secret-help":"NexusCrew stores only the environment-variable name, never its value.","fleet-model-override":"model override","fleet-ready":"ready","fleet-not-ready":"not configured","fleet-engines":"Engines","fleet-cells":"Cells / cloud sessions","fleet-backup":"backup / restore","fleet-backup-help":"Selectively export or restore engines, cells, and system prompts. Tokens, API keys, and provider secrets never enter the file.","fleet-backup-export":"export","fleet-backup-import":"import","fleet-backup-download":"download backup","fleet-backup-restore":"restore selected","fleet-backup-import-help":"Choose a JSON backup, review the cells and select a destination engine before restoring.","fleet-backup-overwrite":"overwrites existing cell","fleet-backup-new":"new cell","fleet-backup-engine-missing":"choose an available engine","fleet-backup-restore-unavailable":"The selected node supports export only; update it to restore backups.","fleet-backup-restored":"{n} cells restored","fleet-backup-confirm-overwrite":"Overwrite these cells? {cells}","fleet-backup-needs-restart":"restart required: {cells}","fleet-backup-empty":"no cells to export","fleet-backup-select-one":"select at least one cell","fleet-backup-too-large":"backup is too large (1 MB maximum)","fleet-backup-invalid-json":"the file does not contain valid JSON","fleet-backup-invalid-format":"unsupported backup format or version","fleet-backup-invalid-cell":"the backup contains an invalid cell","fleet-backup-duplicate-cell":"the backup contains duplicate cell IDs","fleet-backup-invalid-engine":"the backup contains an invalid engine","fleet-backup-duplicate-engine":"the backup contains duplicate engine IDs","fleet-backup-confirm-engine-overwrite":"Overwrite these engines? Environment values already configured on the target stay unchanged. {engines}","fleet-backup-env-names":"environment names","fleet-backup-env-values-required":"environment values must be configured on this device","fleet-system-prompt":"system prompt",characters:"characters","select-all":"select all","select-none":"select none",edit:"edit",save:"save",label:"label","command-path":"absolute command path","args-lines":"arguments, one per line","env-write-only":"Environment values are write-only: blank keeps the existing value.","fleet-new-engine":"New engine","fleet-new-cell":"New cell","fleet-saved":"Definition saved.","fleet-restart-confirm":"Change saved. Restart now: {cells}?","fleet-remove-engine":'Delete engine "{id}"?',"fleet-remove-cell":'Delete cell "{id}"? If active it will be stopped first.',"settings-readonly":"READONLY active: changes are blocked by the server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"this machine watches other nodes via SSH tunnels","role-node":"node (reachable)","published-port":"published port (optional)","no-nodes":"no remote nodes configured","node-add":"connect a NexusCrew installation","node-connect-help":"The SSH port reaches the SSH server. The NexusCrew port is the local port reported by `nexuscrew status` on the remote node.","node-name-label":"Node name","node-ssh-label":"SSH host","pair-ssh-local-label":"SSH host or alias on this device","node-ssh-local-help":"You may replace the link address with the same alias that works with ssh on this device. Aliases, agents and private keys stay local and are never carried in the link.","node-ssh-port-label":"SSH port","node-ssh-port-help":"Usually 22; use the SSH server public port.","node-app-port-label":"NexusCrew port on node","node-app-port-help":"The port reported by `nexuscrew status` on the remote node.","node-name-ph":"name (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"remote port (opt.)","node-remove-confirm":'Remove node "{name}"?',"node-test":"test","tunnel-start":"start tunnel","tunnel-stop":"stop tunnel","tunnel-restart":"restart tunnel","share-node":"Share this node","share-local-heading":"Share this device","share-local-hub":"Sharing hub","share-local-through":"Share {device} through {hub}","share-local-active":"Shared and reachable by the network connected to the hub.","share-local-private":"Private: only this device can use its hub connection.","share-node-off-desc":"Private: it stays connected to the hub, but other clients cannot reach it.","share-node-on-desc":"Shared: the hub may advertise it and route authorized cells and decks.","peer-shared":"Client node shared on the Hydra network","peer-private":"Private client node: connected, not published on Hydra","node-connected-client":"connected client","transport-used":"in use","tunnel-up":"tunnel up","tunnel-down":"tunnel down","authorized-keys-hint":"paste this line into ~/.ssh/authorized_keys on the remote host:",copy:"copy",copied:"copied","token-rotate":"rotate token","token-rotate-explain":"The new token will NOT be shown: retrieve it with `nexuscrew show token`. The current session will be invalidated.","service-regenerate":"regenerate service","npm-auto-update":"automatic updates from npm","npm-auto-update-help":"Periodically checks latest and installs only newer versions. Never downgrades.","npm-update-current":"installed","npm-update-latest":"npm latest","npm-update-check":"check now","npm-update-install":"update now","npm-update-restarting":"Update started; NexusCrew will return after the service restarts.","npm-update-idle":"up to date","npm-update-checking":"checking","npm-update-available":"update available","npm-update-installing":"installing","npm-update-installed":"installed, restarting","npm-update-error":"check failed","npm-update-unsupported":"available only for global npm installations","service-installed":"service installed","service-missing":"service not installed","service-active":"active","service-inactive":"not active",confirm:"confirm",add:"add",enable:"enable","wizard-title":"welcome to NexusCrew","wizard-skip":"configure later from settings","wizard-step-roles":"roles of this install","wizard-step-node":"first remote node (optional)","wizard-done":"all set","wizard-done-desc":"setup complete — you can change everything from settings",next:"continue",back:"back",skip:"skip",finish:"finish","err-node-name":"invalid name (a-z, 0-9, -, max 32)","err-ssh":"invalid ssh (expected user@host or alias)","err-port":"invalid port (1–65535)","err-ssh-port":"invalid SSH port (1–65535)","err-node-port":"invalid NexusCrew port (1–65535)","node-sessions":"{n} sessions","tunnel-down-since":"tunnel down for {t}","node-unreachable":"node unreachable","node-passive":"client offline · expected","node-offline":"node offline","node-offline-seen":"offline · seen {t} ago","node-needs-repair":"legacy · pair again","asks-title":"questions from the cells","ask-reply-ph":"type your answer…","push-enable":"enable push notifications","push-disable":"disable push notifications","push-on":"push active on this device","push-off":"push not active","push-denied":"notification permission denied by the browser","push-unsupported":"push not supported in this browser","node-display-label":"Name (label)","node-slug-hint":"routing on slug: {slug}","device-name-label":"Device name","device-name-hint":"how peers see you (editable)","err-label":"invalid label (max 64 chars, no line breaks)","fleet-inventory":"Cells and sessions","fleet-inventory-help":"all positions (Local + Hydra routes)","fleet-manage-location":"Manage location","fleet-network-overview":"Network overview","fleet-manage-help":"create and configure cells at the selected location","fleet-overview-help":"operational state of every location, separate from the editor","fleet-inventory-empty":"no cells or sessions","fleet-not-available":"fleet not available on this position",start:"start",stop:"stop",restart:"restart",delete:"delete","copy-manual":"copy failed — select and press Cmd+C, or copy manually","copy-empty":"nothing selected: drag with Shift to select","save-and-start":"save and start",permissions:"Permissions","power-on-hint":"Stop the cell; you can also remove it from boot.","launch-engine-help":"Providers, credentials and new engines are created in Settings → Fleet. Model and permissions are per cell.","launch-external-hint":"External provider: engine/model are configured in the external fleet.","import-as-cell":"Import as cell","import-help":"Reconcile an existing tmux session into a managed cell. Pick an already-declared engine: no engine is invented.","import-engine-required":"pick an engine (required)","test-and-connect":"test and connect","pairing-v2-hint":"Paste or scan ONE link: it prefills name, SSH host and label when the link carries them (v2).","invite-v2-hint":"Create one complete one-time invitation. If this device already joined a hub, that hub is used automatically; otherwise only its reachable SSH address is required.","invite-network-hint":"Create an invitation for the network you already joined. The new device enters through the hub instead of connecting directly to this device.","invite-network-label":"Destination network","invite-network-via":"Hub","invite-network-route":"One connection to the hub; nodes, cells and decks are routed internally.","invite-endpoint-label":"This hub’s SSH address as seen by other devices","invite-endpoint-auto":"Configured endpoint","invite-endpoint-needed":"Enter user@host or a shared SSH alias. This is not 127.0.0.1 and not the NexusCrew HTTP URL.","invite-ssh-hint":"The SSH target the OTHER device uses to reach THIS installation (user@host or alias). Required: it is included in the link.","invite-next-steps":"copy this link, open NexusCrew on the other device and paste it in Settings → Nodes (or scan the QR): NexusCrew does the rest","pair-card-title":"connect with one link","pair-card-help":"Paste the pairing link generated on the other device (or scan its QR): NexusCrew decodes it, tests the SSH connection and connects on its own.","pair-paste-ph":"paste the pairing link here","pair-paste-btn":"paste","pair-advanced":"advanced / edit","pair-progress":"connecting: SSH → invite → confirm → verify…","pair-retry":"retry","pair-invalid-link":"this is not a valid pairing link","pair-invalid-hint":"you need the full link (http://…#pair=…) generated by the other NexusCrew: don’t open it, paste it here","pair-missing-ssh":"the link carries no SSH target (v1 format): set in “advanced” how this device reaches the other one over SSH — it is never invented","pair-missing-name":"the node name is missing: fill it in “advanced”","pair-clipboard-denied":"clipboard read not allowed: paste manually into the field","pair-clipboard-empty":"clipboard is empty: copy the pairing link first","pair-stage-validation":"invalid data","pair-stage-conflict":"name already in use","pair-stage-ssh-start":"SSH tunnel start failed","pair-stage-ssh-ready":"peer unreachable over SSH","pair-stage-join":"invite exchange failed","pair-stage-tunnel-final":"negotiated tunnel failed","pair-stage-confirm":"pairing confirmation failed","pair-stage-health":"final federation check failed","pair-stage-internal":"internal error","pair-stage-generic":"connection failed","qr-no-camera":"no camera available on this device: use a photo of the QR","qr-permission":"camera permission denied: allow it in the browser or use a photo of the QR","qr-unsupported":"live scanner not supported here: upload a photo of the QR","qr-upload":"use a photo"},es:{"update-available":"nueva versión {v} disponible","install-version-mismatch":"instalación incompleta: frontend y servidor no coinciden (v{v})",reload:"recargar","grid-empty":"arrastra aquí una sesión desde la barra lateral, o doble clic para vista única","grid-full":"un deck puede mostrar como máximo 9 sesiones",pin:"fijar arriba",reorder:"reordenar","reorder-help":"arrastra el control; flechas arriba/abajo","reorder-deck-help":"arrastra el deck; flechas izquierda/derecha",sessions:"sesiones","new-session":"nueva sesión",new:"nueva",fleet:"Flota","fleet-tmux":"flota tmux","other-sessions":"Otras sesiones","view-all":"todas","view-pinned":"fijadas","view-active":"activas","view-off":"apagadas","view-technical":"técnicas","mark-technical":"ocultar como sesión técnica","mark-normal":"mostrar como sesión normal","position-local":"Local",files:"archivos",refresh:"actualizar","filter-placeholder":"filtrar sesiones…","loading-fleet":"cargando flota…","no-sessions":"sin sesiones tmux vivas — la flota arranca en el boot (systemd)","no-match":"ninguna sesión coincide con «{q}»","copy-url":"clic para copiar la URL","ssh-only":"solo túnel SSH/VPN","new-files-outbox":"archivos nuevos en outbox",terminate:"terminar","terminate-confirm":"¿Terminar la sesión «{name}»?","cell-on":"tmux activo","cell-off":"apagada","cell-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…","composer-history-tools":"historial y tamaño de entrada","composer-history":"historial de la celda","composer-history-empty":"ninguna entrada enviada","composer-history-clear":"borrar historial de esta celda","composer-expand":"ampliar entrada","composer-collapse":"reducir entrada","composer-clear-data":"borrar borradores e historial","composer-clear-data-help":"Elimina de este navegador todos los borradores y el historial de entrada de las celdas.","composer-clear-confirm":"¿Borrar todos los borradores y el historial de entrada guardados en este navegador?","composer-clear-done":"Borradores e historial eliminados.","composer-clear-failed":"No se pudieron borrar los datos del composer en este navegador.",attach:"adjuntar","attach-file":"Archivo","attach-camera":"Cámara","attach-gallery":"Galería","attach-uploading":"subiendo…","attach-upload-progress":"adjunto {n}/{total}…","attach-uploaded":"{n} adjuntos subidos",voice:"voz",send:"enviar","composer-send-failed":"conexión no disponible — texto conservado, inténtalo de nuevo",close:"cerrar","lang-label":"idioma",decks:"decks","new-deck":"nuevo deck","deck-name":"nombre del deck","open-deck-window":"abrir en una ventana nueva","detach-deck":"separar en una ventana nueva","deck-current":"este deck (ventana actual)","deck-owner-unavailable":"el nodo propietario no está compartido o accesible","rename-deck":"renombrar deck","delete-deck":"eliminar deck","delete-deck-confirm":"¿Eliminar el deck «{name}»?","send-to-deck":"enviar al deck…","deck-autosave":"guardado automático",saving:"guardando…",saved:"guardado","popup-blocked":"ventana bloqueada: abrir aquí","select-drag":"arrastra para seleccionar","copy-manual":"selecciona y copia manualmente","toggle-sidebar":"mostrar/ocultar la barra lateral",settings:"ajustes","tab-roles":"roles","tab-nodes":"nodos",local:"Local",location:"Ubicación","pairing-link":"enlace de emparejamiento","pairing-required":"nombre, alias SSH y enlace son obligatorios","pairing-connect-help":"Para conectar un nodo necesitas un nombre, un Host SSH funcional y el enlace/QR creado por la otra instalación NexusCrew.","pairing-localhost-hint":"127.0.0.1 en el enlace es correcto: no lo abras aquí. NexusCrew usa la invitación y el puerto mediante el Host SSH.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","invite-node":"invitar un nodo","create-pairing-link":"crear enlace / QR","visibility-network":"toda la red","visibility-relay":"solo relay","visibility-selected":"nodos seleccionados","hydra-simple":"local + nodos, una red","local-ready":"Este dispositivo está listo. Úsalo solo o conéctalo a un nodo.","local-only":"solo local","add-node":"añadir nodo",connect:"conectar","node-connected":"Nodo conectado. La red se sincronizará automáticamente.","tab-system":"sistema","tab-fleet":"flota","fleet-editor-unavailable":"El editor solo está disponible con el proveedor builtin.","fleet-managed":"gestionado por NexusCrew","fleet-custom":"comando personalizado","fleet-managed-help":"Cliente, proveedor e inicio se gestionan internamente; los secretos nunca se muestran.","fleet-credential-title":"Clave API en este dispositivo","fleet-credential-help":"La clave permanece solo en el nodo seleccionado y nunca se muestra, exporta ni comparte con la red.","fleet-credential-set":"poner clave","fleet-credential-change":"cambiar clave","fleet-credential-forget":"olvidar","fleet-credential-saved":"Clave guardada localmente.","fleet-credential-removed":"Clave local eliminada.","fleet-credential-remove-confirm":"¿Eliminar la clave local {key}?","fleet-credential-source-environment":"entorno","fleet-credential-source-local":"almacén local","fleet-credential-source-compatibility":"config compatible","fleet-credential-source-missing":"ausente","fleet-model-default":"modelo predeterminado (opcional)","fleet-model-required":"modelo (obligatorio)","fleet-standard-permissions":"permisos estándar","fleet-unsafe-permissions":"inseguro · omitir aprobaciones/sandbox","fleet-unsafe-warning":"Modo inseguro explícito: el worker puede actuar sin las aprobaciones normales ni las protecciones del sandbox.","fleet-provider-display":"nombre visible del proveedor","fleet-custom-provider-default":"Proveedor personalizado","fleet-api-key-env":"NOMBRE_VARIABLE_API_KEY","fleet-provider-id":"id-proveedor","fleet-custom-secret-help":"NexusCrew guarda solo el nombre de la variable de entorno, nunca su valor.","fleet-model-override":"modelo alternativo","fleet-ready":"listo","fleet-not-ready":"no configurado","fleet-engines":"Motores","fleet-cells":"Celdas / sesiones cloud","fleet-backup":"copia / restauración","fleet-backup-help":"Exporta o restaura selectivamente motores, celdas y system prompts. Tokens, claves API y secretos del proveedor nunca entran en el archivo.","fleet-backup-export":"exportar","fleet-backup-import":"importar","fleet-backup-download":"descargar copia","fleet-backup-restore":"restaurar seleccionadas","fleet-backup-import-help":"Elige una copia JSON, revisa las celdas y selecciona un motor de destino antes de restaurar.","fleet-backup-overwrite":"sobrescribe la celda existente","fleet-backup-new":"celda nueva","fleet-backup-engine-missing":"elige un motor disponible","fleet-backup-restore-unavailable":"El nodo seleccionado solo admite exportación; actualízalo para restaurar copias.","fleet-backup-restored":"{n} celdas restauradas","fleet-backup-confirm-overwrite":"¿Sobrescribir estas celdas? {cells}","fleet-backup-needs-restart":"reinicio necesario: {cells}","fleet-backup-empty":"no hay celdas para exportar","fleet-backup-select-one":"selecciona al menos una celda","fleet-backup-too-large":"copia demasiado grande (máximo 1 MB)","fleet-backup-invalid-json":"el archivo no contiene JSON válido","fleet-backup-invalid-format":"formato o versión de copia no compatible","fleet-backup-invalid-cell":"la copia contiene una celda no válida","fleet-backup-duplicate-cell":"la copia contiene IDs de celda duplicados","fleet-backup-invalid-engine":"la copia contiene un motor no válido","fleet-backup-duplicate-engine":"la copia contiene IDs de motor duplicados","fleet-backup-confirm-engine-overwrite":"¿Sobrescribir estos motores? Los valores de entorno ya configurados en el destino no cambian. {engines}","fleet-backup-env-names":"nombres de entorno","fleet-backup-env-values-required":"los valores de entorno deben configurarse en este dispositivo","fleet-system-prompt":"system prompt",characters:"caracteres","select-all":"seleccionar todas","select-none":"ninguna",edit:"editar",save:"guardar",label:"etiqueta","command-path":"ruta absoluta del comando","args-lines":"argumentos, uno por línea","env-write-only":"Los valores env son de solo escritura: vacío conserva el valor existente.","fleet-new-engine":"Nuevo motor","fleet-new-cell":"Nueva celda","fleet-saved":"Definición guardada.","fleet-restart-confirm":"Cambio guardado. ¿Reiniciar ahora: {cells}?","fleet-remove-engine":'¿Eliminar el motor "{id}"?',"fleet-remove-cell":'¿Eliminar la celda "{id}"? Si está activa se detendrá primero.',"settings-readonly":"READONLY activo: los cambios están bloqueados por el servidor (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"esta máquina observa otros nodos vía túneles SSH","role-node":"nodo (alcanzable)","published-port":"puerto publicado (opcional)","no-nodes":"sin nodos remotos configurados","node-add":"conectar una instalación NexusCrew","node-connect-help":"El puerto SSH conecta con el servidor SSH. El puerto NexusCrew es el puerto local indicado por `nexuscrew status` en el nodo remoto.","node-name-label":"Nombre del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH en este dispositivo","node-ssh-local-help":"Puedes sustituir la dirección del enlace por el mismo alias que funciona con ssh en este dispositivo. Los alias, agentes y claves permanecen locales y nunca viajan en el enlace.","node-ssh-port-label":"Puerto SSH","node-ssh-port-help":"Normalmente 22; usa el puerto público del servidor SSH.","node-app-port-label":"Puerto NexusCrew del nodo","node-app-port-help":"El puerto indicado por `nexuscrew status` en el nodo remoto.","node-name-ph":"nombre (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"puerto remoto (opc.)","node-remove-confirm":"¿Eliminar el nodo «{name}»?","node-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 Wu(){const e=Bv(),t=e?e.getItem(Av):null;return Kh.includes(t)?t:ja}function a0(e){const t=Bv();if(t)try{t.setItem(Av,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event($u))}function y(e){const t=Wu(),i=xa[t]||xa[ja];return Object.prototype.hasOwnProperty.call(i,e)?i[e]:Object.prototype.hasOwnProperty.call(xa[ja],e)?xa[ja][e]:e}function l0(e){return typeof window>"u"?()=>{}:(window.addEventListener($u,e),()=>window.removeEventListener($u,e))}const Iv=Kh;function Si(){return[P.useSyncExternalStore(l0,Wu,Wu),a0]}function Ha({cell:e,token:t,route:i=[],onConfirm:s,onClose:o}){var F,D;Si();const l=!!(e&&e.active),c=Array.isArray(i)?i.join("/"):"",[d,m]=P.useState([]),[p,S]=P.useState(!1);P.useEffect(()=>{let O=!0;return(async()=>{if(t)try{const z=await dr(t,c?c.split("/"):[]);if(!O)return;if(S(z.provider==="builtin"&&(z.capabilities||[]).includes("edit")),z.provider==="builtin"&&(z.capabilities||[]).includes("definitions")){const ne=await Hh(t,c?c.split("/"):[]);if(!O)return;const K=new Map((z.engines||[]).map(M=>[M.id,M]));m((ne.engines||[]).map(M=>{var W,oe,ae,se,le,_e,ce;return{id:M.id,label:M.label||M.id,client:((W=M.managed)==null?void 0:W.client)||"",models:[...new Set([...((oe=K.get(M.id))==null?void 0:oe.models)||[],...((ae=M.managedInfo)==null?void 0:ae.models)||[]])].filter(Boolean),defaultModel:((se=M.managed)==null?void 0:se.model)||((le=M.managedInfo)==null?void 0:le.defaultModel)||"",policyDefault:((_e=M.managed)==null?void 0:_e.permissionPolicy)||((ce=M.managed)!=null&&ce.client&&M.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{O=!1}},[t,c]);const C=(e==null?void 0:e.engine)||((F=d[0])==null?void 0:F.id)||"",_=O=>(e==null?void 0:e.models)&&e.models[O]||"",v=O=>{const z=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[O];if(z==="standard"||z==="unsafe")return z;const ne=d.find(K=>K.id===O);return ne?ne.policyDefault:"standard"},[w,b]=P.useState(C),[x,N]=P.useState((e==null?void 0:e.model)||""),L=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((D=e==null?void 0:e.permissionPolicies)==null?void 0:D[e==null?void 0:e.engine])||"",[j,T]=P.useState(L),[Q,H]=P.useState((e==null?void 0:e.boot)??!0),[I,G]=P.useState(!1),[U,q]=P.useState(null);P.useEffect(()=>{d.length&&(b(O=>O||C),N(O=>O||_((e==null?void 0:e.engine)||C)||""),T(O=>O==="standard"||O==="unsafe"?O:v((e==null?void 0:e.engine)||C)))},[d.length]);const Y=P.useMemo(()=>d.find(O=>O.id===w)||null,[d,w]),A=!!(Y&&["claude","codex","codex-vl"].includes(Y.client));function E(O){b(O);const z=d.find(ne=>ne.id===O);N(_(O)||(z==null?void 0:z.defaultModel)||""),T(v(O))}async function R(O){O.preventDefault(),G(!0),q(null);try{if(l)await s({action:"down",boot:Q});else{const z=j==="standard"||j==="unsafe"?j:(Y==null?void 0:Y.policyDefault)||"standard";await s({action:"up",...p?{engine:w,model:x||"",...A?{permissionPolicy:z}:(Y==null?void 0:Y.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:Q})}o()}catch(z){q(String(z&&z.message||z)),G(!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:O=>O.stopPropagation(),onSubmit:R,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:y(l?"state-on":"state-off")})]}),l?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:y("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[y("model"),": ",e.model]}),h.jsx("small",{children:y("power-on-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:Q,onChange:O=>H(O.target.checked)}),y("remove-boot")]})]}):h.jsxs(h.Fragment,{children:[p&&d.length>0?h.jsxs("div",{className:"nc-launch-fields",children:[h.jsxs("label",{className:"nc-field",children:[y("engine"),h.jsx("select",{value:w,onChange:O=>E(O.target.value),children:d.map(O=>h.jsx("option",{value:O.id,children:O.label},O.id))})]}),h.jsxs("label",{className:"nc-field",children:[y("model"),h.jsx("input",{value:x,list:"nc-launch-models",placeholder:y("model-default"),onChange:O=>N(O.target.value)}),h.jsx("datalist",{id:"nc-launch-models",children:((Y==null?void 0:Y.models)||[]).map(O=>h.jsx("option",{value:O},O))})]}),A?h.jsxs("label",{className:"nc-field",children:[y("permissions"),h.jsxs("select",{value:j,onChange:O=>T(O.target.value),children:[h.jsx("option",{value:"standard",children:y("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:y("fleet-unsafe-permissions")})]})]}):h.jsx("small",{className:"nc-note",children:y("fleet-standard-permissions")}),A&&j==="unsafe"&&h.jsx("small",{className:"nc-err",children:y("fleet-unsafe-warning")}),h.jsx("small",{className:"nc-note",children:y("launch-engine-help")})]}):h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:y("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[y("model"),": ",e.model]}),h.jsx("small",{children:y("launch-external-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:Q,onChange:O=>H(O.target.checked)}),y("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:I,children:y("cancel")}),h.jsx("button",{type:"submit",className:"nc-btn primary",disabled:I,children:y(l?"power-off":"save-and-start")})]})]})})}const dm=/^[a-z0-9-]{1,32}$/;function $a(e,t){const i=Array.isArray(e)?e:[];return i.length?`${i.map(encodeURIComponent).join("/")}:${t}`:String(t)}function c0(e,t,i){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 c=l.join("/"),d=o.status==="up"||o.tunnel&&o.tunnel.status==="up",m=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!d&&!m&&(s[c]=e&&e[c]||i)}return s}function fm(e,t,i){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${i}:${s.tmuxSession||s.cell}`}))}function pm({nodes:e,topology:t,remote:i,down:s,fleet:o}={}){var m,p,S,C;const l=[],c=new Set,d=new Set;for(const _ of Array.isArray(e)?e:[]){if(!_||typeof _.name!="string"||!dm.test(_.name)||_.direction==="inbound"&&_.shared!==!0)continue;const v=[_.name],w=_.name;c.add(w);const b=((m=_.tunnel)==null?void 0:m.status)||"unknown",x=b==="up",N={name:_.name,label:_.label||_.name,route:v,direct:!0,instanceId:_.nodeId||null,shared:_.shared===!0,tunnelStatus:b,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({...N,status:"needs-repair",downSince:s&&s[w]||null});continue}if(((p=_.health)==null?void 0:p.auth)==="failed"||b==="degraded"&&((S=_.health)==null?void 0:S.status)==="degraded"){l.push({...N,status:"needs-repair",downSince:s&&s[w]||null});continue}if(b==="passive"||((C=_.health)==null?void 0:C.status)==="passive"){l.push({...N,status:"passive",downSince:null});continue}if(!x){l.push({...N,status:"down",downSince:s&&s[w]||null});continue}const L=i&&(i[w]||i[_.name])||null;if(!L||L.error||!Array.isArray(L.sessions)){l.push({...N,status:"unreachable"});continue}const j=L.sessions.filter(I=>I&&typeof I.name=="string"&&I.name).map(I=>({...I,node:w,route:v,key:`${w}:${I.name}`})),T=o&&(o[w]||o[_.name]),Q=fm(T,v,w),H=new Set(Q.map(I=>I.tmuxSession).filter(Boolean));l.push({...N,status:"up",sessions:j,cells:Q,unmanaged:j.filter(I=>!H.has(I.name)),fleetAvailable:!!(T&&T.available),capabilities:T&&T.capabilities||[],engines:T&&T.engines||[],fleetProvider:T&&T.provider||null})}for(const _ of Array.isArray(t)?t:[]){if(!_||!Array.isArray(_.route)||_.route.length<1||_.route.some(T=>!dm.test(T)))continue;const v=_.route.join("/");if(c.has(v)||_.instanceId&&d.has(_.instanceId))continue;_.instanceId&&d.add(_.instanceId);const w={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({...w,status:"offline",downSince:s&&s[v]||_.lastSeen||null});continue}const b=i&&i[v]||null;if(!b||b.error||!Array.isArray(b.sessions)){l.push({...w,status:"unreachable",downSince:s&&s[v]||null});continue}const x=b.sessions.filter(T=>T&&typeof T.name=="string"&&T.name).map(T=>({...T,node:v,route:_.route,key:`${v}:${T.name}`})),N=o&&o[v],L=fm(N,_.route,v),j=new Set(L.map(T=>T.tmuxSession).filter(Boolean));l.push({...w,status:"up",sessions:x,cells:L,unmanaged:x.filter(T=>!j.has(T.name)),fleetAvailable:!!(N&&N.available),capabilities:N&&N.capabilities||[],engines:N&&N.engines||[],fleetProvider:N&&N.provider||null,lastSeen:_.lastSeen||null})}return l.sort((_,v)=>_.label.localeCompare(v.label))}const u0=4e3;function qh(e,t=!0){const[i,s]=P.useState([]),o=P.useRef({});return P.useEffect(()=>{if(!t||!e){s([]);return}let l=!0;async function c(){var b;let m=[],p=[];if(await Promise.all([Pv(e).then(x=>{m=Array.isArray(x.nodes)?x.nodes:[]}).catch(()=>{}),Ow(e).then(x=>{p=Array.isArray(x.nodes)?x.nodes:[]}).catch(()=>{})]),!l)return;const S={},C={},_=new Set(m.map(x=>x.name)),v=[];for(const x of m)((b=x.tunnel)==null?void 0:b.status)==="up"&&(x.nodeId||x.paired!==!1)&&(x.direction!=="inbound"||x.shared===!0)&&v.push([x.name]);for(const x of p)!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 N=x.join("/");try{S[N]=await Dv(e,x)}catch{S[N]={error:"unreachable"}}try{C[N]=await dr(e,x)}catch{C[N]={available:!1}}})),!l)return;const w=pm({nodes:m,topology:p,remote:S,fleet:C,down:o.current});o.current=c0(o.current,w,Math.floor(Date.now()/1e3)),s(pm({nodes:m,topology:p,remote:S,fleet:C,down:o.current}))}c();const d=setInterval(c,u0);return()=>{l=!1,clearInterval(d)}},[e,t]),i}const mm=52,gm=14;function Ur({position:e,itemKey:t,label:i,onMove:s,onStep:o,canMove:l=()=>!0}){const c=P.useRef(null),d=P.useRef(0),[m,p]=P.useState(!1),S=()=>{var x,N,L,j;const b=c.current;(N=(x=b==null?void 0:b.over)==null?void 0:x.classList)==null||N.remove("nc-roster-over"),(j=(L=b==null?void 0:b.source)==null?void 0:L.classList)==null||j.remove("nc-roster-dragging"),d.current&&cancelAnimationFrame(d.current),d.current=0},C=(b=!1)=>{const x=c.current;if(!x)return;const N=x.target;S(),c.current=null,p(!1);try{x.handle.releasePointerCapture(x.pointerId)}catch{}b&&N&&N!==t&&l(t,N)&&s(t,N)},_=(b,x)=>{var Q,H,I,G,U,q,Y,A;const N=c.current;if(!N)return;N.x=b,N.y=x;const L=(H=(Q=document.elementFromPoint(b,x))==null?void 0:Q.closest)==null?void 0:H.call(Q,"[data-roster-key][data-position]"),j=(I=L==null?void 0:L.dataset)==null?void 0:I.rosterKey,T=((G=L==null?void 0:L.dataset)==null?void 0:G.position)===e&&j&&j!==t&&l(t,j);N.over!==(T?L:null)&&((q=(U=N.over)==null?void 0:U.classList)==null||q.remove("nc-roster-over"),N.over=T?L:null,(A=(Y=N.over)==null?void 0:Y.classList)==null||A.add("nc-roster-over")),N.target=T?j:null},v=()=>{const b=c.current;if(!b){d.current=0;return}const x=b.container;if(x){const N=x.getBoundingClientRect(),L=b.y<N.top+mm?-gm:b.y>N.bottom-mm?gm:0;L&&(x.scrollTop+=L,_(b.x,b.y))}d.current=requestAnimationFrame(v)};P.useEffect(()=>{const b=N=>{N.key==="Escape"&&c.current&&(N.preventDefault(),C(!1))},x=()=>C(!1);return window.addEventListener("keydown",b),window.addEventListener("blur",x),()=>{window.removeEventListener("keydown",b),window.removeEventListener("blur",x),S(),c.current=null}},[t,e]);const w=b=>{var L;if(b.pointerType==="mouse"&&b.button!==0)return;b.preventDefault(),b.stopPropagation(),b.currentTarget.focus({preventScroll:!0});const x=b.currentTarget.closest("[data-roster-key][data-position]"),N=b.currentTarget.closest(".nc-side-scroll, .nc-home-scroll");c.current={pointerId:b.pointerId,handle:b.currentTarget,source:x,container:N,target:null,over:null,x:b.clientX,y:b.clientY},(L=x==null?void 0:x.classList)==null||L.add("nc-roster-dragging");try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}p(!0),d.current=requestAnimationFrame(v)};return h.jsx("button",{type:"button",className:`nc-roster-handle${m?" active":""}`,"aria-label":`${y("reorder")} ${i}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:y("reorder-help"),onClick:b=>{b.preventDefault(),b.stopPropagation()},onDragStart:b=>b.preventDefault(),onKeyDown:b=>{b.key!=="ArrowUp"&&b.key!=="ArrowDown"||(b.preventDefault(),b.stopPropagation(),o(b.key==="ArrowUp"?-1:1))},onPointerDown:w,onPointerMove:b=>{!c.current||b.pointerId!==c.current.pointerId||(b.preventDefault(),b.stopPropagation(),_(b.clientX,b.clientY))},onPointerUp:b=>{!c.current||b.pointerId!==c.current.pointerId||(b.preventDefault(),b.stopPropagation(),C(!0))},onPointerCancel:()=>C(!1),onLostPointerCapture:()=>{c.current&&C(!1)},children:"↕"})}const Vh="nc_pins";function h0(){try{const e=JSON.parse(localStorage.getItem(Vh));return Array.isArray(e)?e:[]}catch{return[]}}function d0(e,t){const i=e.includes(t)?e.filter(s=>s!==t):[...e,t];try{localStorage.setItem(Vh,JSON.stringify(i))}catch{}return i}function f0(e,t,i){if(!e.includes(t)||!e.includes(i)||t===i)return e;const s=[...e],o=s.indexOf(t),l=s.indexOf(i);s.splice(o,1);const c=s.indexOf(i);s.splice(o<l?c+1:c,0,t);try{localStorage.setItem(Vh,JSON.stringify(s))}catch{}return s}function p0(e,t,i){const s=e.indexOf(t);return[s===-1?1e9:s,-(i||0)]}function m0(e,t){return e[0]-t[0]||e[1]-t[1]}function Ov(){const[e,t]=P.useState(h0),[i,s]=P.useState(r0),[o,l]=P.useState(t0),c=_=>t(v=>d0(v,_)),d=_=>um(i,_),m=(_,v)=>s(w=>{const b={...w,[_]:{...um(w,_),...v}};return s0(b)}),p=(_,v)=>e.includes(_)===e.includes(v);function S(_,v,w,b){const x=e.includes(v),N=e.includes(w);if(x===N){if(x){t(L=>f0(L,v,w));return}l(L=>{var Q;const j=((Q=b.find(H=>H.key===v))==null?void 0:Q.technical)===!0,T=ar(b,e,j?"technical":"all",zn(L,_)).map(H=>H.key);return i0(n0(L,_,v,w,T))})}}function C(_,v,w,b){var Q;const x=((Q=b.find(H=>H.key===v))==null?void 0:Q.technical)===!0,N=e.includes(v),L=ar(b,e,x?"technical":"all",zn(o,_)).map(H=>H.key).filter(H=>e.includes(H)===N),j=L.indexOf(v),T=L[j+w];j>=0&&T&&S(_,v,T,b)}return{pins:e,views:i,orders:o,togglePin:c,viewFor:d,updateView:m,canMoveRoster:p,moveRoster:S,stepRoster:C}}function Gr(e,t=Math.floor(Date.now()/1e3)){if(!e)return"";const i=t-e;return i<0||i<60?"ora":i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}g`}function qr(e){return e.status==="passive"?y("node-passive"):e.status==="down"?e.downSince?y("tunnel-down-since").replace("{t}",Gr(e.downSince)):y("tunnel-down"):e.status==="unreachable"?y("node-unreachable"):e.status==="offline"?e.lastSeen?y("node-offline-seen").replace("{t}",Gr(e.lastSeen)):y("node-offline"):e.status==="needs-repair"?y("node-needs-repair"):""}function zv(e,{passive:t=null}={}){return e?e.status==="passive"?t:e.status==="healthy"?"on":"warn":null}function Wa(e){return e&&(e.detail||e.status)||""}function Ua(e,t,i=globalThis.localStorage){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const s=Number(i.getItem(xv(t))||0);return e.outbox.latest>s}function Fv(e,t,i,s=globalThis.localStorage){return[...(Array.isArray(e)?e:[]).map(o=>{const l=i.get(o.tmuxSession)||{},c=$a([],o.tmuxSession);return{type:"cell",value:o,key:c,label:o.cell,live:!!o.tmux,fresh:Ua(l,c,s),activity:l.activity||0,searchText:`${o.engine||""} ${o.key||""} ${l.preview||""}`}}),...(Array.isArray(t)?t:[]).map(o=>{const l=$a([],o.name);return{type:"session",value:o,key:l,label:o.name,live:!0,technical:o.technical===!0,fresh:Ua(o,l,s),activity:o.activity||0,searchText:`${o.preview||""} ${o.cmd||""}`}})]}function Hv(e,t=globalThis.localStorage){const i=e||{},s=Array.isArray(i.route)?i.route:[],o=new Map((i.sessions||[]).map(c=>[c.name,c])),l=[...(i.cells||[]).map(c=>{const d=o.get(c.tmuxSession)||{},m=$a(s,c.tmuxSession||c.cell);return{type:"cell",value:c,key:m,label:c.cell,live:!!c.tmux,fresh:Ua(d,m,t),activity:d.activity||c.activity||0,searchText:`${c.engine||""} ${c.key||""} ${d.preview||c.preview||""}`}}),...(i.unmanaged||[]).map(c=>{const d=$a(s,c.name);return{type:"session",value:c,key:d,label:c.name,live:!0,technical:c.technical===!0,fresh:Ua(c,d,t),activity:c.activity||0,searchText:`${c.preview||""} ${c.cmd||""}`}})];return{route:s,rawItems:l}}const Yh=9,Ka=.2,g0=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,Qr=/^[a-f0-9]{16,64}$/,Uu=e=>g0.test(e)&&new Set(e.split("/")).size===e.split("/").length;function Hn(e){if(typeof e=="string"&&e){const t=e.indexOf(":");if(t<0)return{session:e};const i=e.slice(0,t),s=e.slice(t+1);return!Uu(i)||!s?null:{session:s,node:i}}if(e&&typeof e=="object"&&typeof e.session=="string"&&e.session){const t=e.ownerId===void 0?void 0:typeof e.ownerId=="string"&&Qr.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"&&Uu(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function _i(e){const t=Hn(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const $v=9,Wv=24,oo=11,v0=e=>{const t=Number(e);return t>=$v&&t<=Wv?t:oo};function Vr(){return{columns:[]}}function Gi(e){return e.columns.flatMap(t=>t.tiles.map(i=>_i(i)))}function _0(e){const t=[],i=Math.max(0,...e.columns.map(s=>s.tiles.length));for(let s=0;s<i;s+=1)for(const o of e.columns)o.tiles[s]&&t.push(_i(o.tiles[s]));return t}const es=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))});function Xh(e,t,i,s){const o=Hn(t);if(!o||Gi(e).includes(_i(o))||Gi(e).length>=Yh)return e;const l=es(e),c={session:o.session,height:1,fontSize:oo,...s||{}};if(o.node&&(c.node=o.node),o.ownerId&&(c.ownerId=o.ownerId),i==="end")return l.columns.push({width:1,tiles:[c]}),l;if(i&&typeof i.col=="number"&&typeof i.row=="number"&&l.columns[i.col])return l.columns[i.col].tiles.splice(i.row,0,c),l;if(i&&typeof i.col=="number"){const d=Math.max(0,Math.min(l.columns.length,i.col));return l.columns.splice(d,0,{width:1,tiles:[c]}),l}return l.columns.push({width:1,tiles:[c]}),l}function Uv(e,t){const i=_i(t);if(!i||Gi(e).includes(i)||Gi(e).length>=Yh)return e;const s=Gi(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let S=0;for(let C=1;C<e.columns.length;C+=1)e.columns[C].tiles.length<e.columns[S].tiles.length&&(S=C);return Xh(e,t,{col:S,row:e.columns[S].tiles.length})}const l=[..._0(e),i],c=new Map(e.columns.flatMap(S=>S.tiles.map(C=>[_i(C),C]))),d=Hn(t),m=e.columns.length?e.columns.reduce((S,C)=>S+(Number(C.width)||1),0)/e.columns.length:1,p=Array.from({length:o},(S,C)=>{var _;return{width:((_=e.columns[C])==null?void 0:_.width)||m,tiles:[]}});return l.forEach((S,C)=>{const _=Hn(S);if(!_)return;const v=c.get(S)||(S===i?d:{})||{},w={session:_.session,height:v.height||1,fontSize:v.fontSize||oo};_.node&&(w.node=_.node),v.ownerId&&(w.ownerId=v.ownerId),v.unavailable===!0&&(w.unavailable=!0),p[C%o].tiles.push(w)}),{columns:p.filter(S=>S.tiles.length)}}function qa(e,t){const i=_i(t),s=es(e);for(const o of s.columns)o.tiles=o.tiles.filter(l=>_i(l)!==i);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function y0(e,t,i){const s=_i(t);if(!Gi(e).includes(s))return e;const o=e.columns.flatMap(l=>l.tiles).find(l=>_i(l)===s);return Xh(qa(e,s),s,i,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function S0(e,t){if(!(t instanceof Map)||t.size===0)return e;let i=!1;const s=es(e);for(const o of s.columns)for(const l of o.tiles){const c=t.get(_i(l));if(!c)continue;const d=Hn(c);d&&(l.session=d.session,d.node?l.node=d.node:delete l.node,d.ownerId&&(l.ownerId=d.ownerId),i=!0)}return i?lr(s):e}function w0(e,t,i){const s=es(e);return s.columns[t]&&(s.columns[t].width=Math.max(Ka,Number(i)||1)),s}function b0(e,t,i,s){const o=es(e),l=o.columns[t]&&o.columns[t].tiles[i];return l&&(l.height=Math.max(Ka,Number(s)||1)),o}function C0(e,t,i,s){if(!(e.columns[t]&&e.columns[t].tiles[i]))return e;const l=es(e),c=l.columns[t].tiles[i],d=Number(c.fontSize)||oo;return c.fontSize=Math.max($v,Math.min(Wv,d+(Number(s)||0))),l}function x0(e,t,i,s){const o=e.columns[t];if(!o||!o.tiles[i])return null;switch(s){case"left":return{col:t};case"right":return{col:t+1};case"top":return{col:t,row:i};case"bottom":return{col:t,row:i+1};default:return null}}function vm(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function lr(e){if(!e||!Array.isArray(e.columns))return Vr();const t=e.columns.map(s=>({width:Math.max(Ka,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"&&Uu(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&Qr.test(o.ownerId)).map(o=>{const l={session:o.session,height:Math.max(Ka,Number(o.height)||1),fontSize:v0(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),i=new Set;for(const s of t)s.tiles=s.tiles.filter(o=>!i.has(_i(o))&&i.add(_i(o))&&i.size<=Yh);return{columns:t.filter(s=>s.tiles.length>0)}}function k0({onPick:e,token:t,onSettings:i}){const[s,o]=Si(),l=qh(t),[c,d]=P.useState(null),[m,p]=P.useState(null),[S,C]=P.useState(""),[_,v]=P.useState(""),[w,b]=P.useState({bind:"127.0.0.1",port:""}),[x,N]=P.useState(""),[L,j]=P.useState([]),[T,Q]=P.useState(null),[H,I]=P.useState(null),{pins:G,orders:U,togglePin:q,viewFor:Y,updateView:A,canMoveRoster:E,moveRoster:R,stepRoster:F}=Ov();async function D(){try{const Ce=await(await zt("/api/sessions",t)).json();Ce.error?(p(Ce.error),d([])):(p(null),d(Ce.sessions||[]))}catch(ee){p(String(ee)),d([])}try{const ee=await dr(t);j(ee.available?ee.cells||[]:[])}catch{j([])}}P.useEffect(()=>{D(),zt("/api/config",t).then(Ce=>Ce.json()).then(Ce=>{v(Ce.version||""),b({bind:Ce.bind||"127.0.0.1",port:Ce.port||""}),N(Qr.test(String(Ce.instanceId||""))?Ce.instanceId:"")}).catch(()=>{});const ee=setInterval(D,4e3);return()=>clearInterval(ee)},[]);async function O(){if(!w.port)return;const ee=`http://${w.bind}:${w.port}/#token=${t}`;try{await navigator.clipboard.writeText(ee)}catch{}}async function z(ee){if(!T)return;const{cell:Ce}=T,Te=Array.isArray(T.route)?T.route:[];ee.action==="up"?await Fh(t,{cell:Ce,boot:!!ee.boot,...ee.engine?{engine:ee.engine}:{},...ee.model!==void 0?{model:ee.model}:{},...ee.permissionPolicy?{permissionPolicy:ee.permissionPolicy}:{}},Te):await Fa(t,{cell:Ce,boot:!!ee.boot},Te),D()}async function ne(ee,Ce=[]){try{await $h(t,ee,Ce)}catch{return}D()}async function K(ee,Ce,Te=[]){try{await Ev(t,ee,Ce,Te)}catch{return}D()}async function M(ee){if(!(!(ee!=null&&ee.direct)||H)){I(ee.name);try{await Uh(t,ee.name,ee.tunnelStatus==="up"?"down":"up")}catch{}I(null)}}const W=P.useMemo(()=>new Map((c||[]).map(ee=>[ee.name,ee])),[c]),oe=P.useMemo(()=>new Set(L.map(ee=>ee.tmuxSession)),[L]),ae=P.useMemo(()=>(c||[]).filter(ee=>!oe.has(ee.name)),[c,oe]),se=P.useMemo(()=>Fv(L,ae,W),[L,ae,W]),le=Y("local"),_e=P.useMemo(()=>ar(se,G,le.filter,zn(U,"local")).filter(ee=>hm(ee,S)),[se,G,le.filter,S,U]),ce=l.reduce((ee,Ce)=>ee+(Ce.cells||[]).length+(Ce.unmanaged||[]).filter(Te=>!Te.technical).length,0),X=ar(se,G,"all",zn(U,"local")).length+ce,Z=c?c.length:0,je=(c||[]).filter(ee=>ee.attached).length,Me=w.port?`${w.bind}:${w.port}`:w.bind;function ye(ee,Ce=null,Te=se){var gt,ge;const xe=Array.isArray(Ce==null?void 0:Ce.route)?Ce.route:[],qe=xe.join("/"),te=qe||"local",ve=xe.length?Ce==null?void 0:Ce.instanceId:x,Be=be=>e({session:be,...qe?{node:qe}:{},...Qr.test(String(ve||""))?{ownerId:ve}:{}}),Ie=E;if(ee.type==="cell"){const be=ee.value,ke=xe.length?((Ce==null?void 0:Ce.sessions)||[]).find(de=>de.name===be.tmuxSession):W.get(be.tmuxSession),Xe=(ke==null?void 0:ke.preview)||be.preview||"",rt=[`${be.engine}${be.key?`·${be.key}`:""}`,Xe,be.active?"":y("cell-off")].filter(Boolean).join(" · "),Ve=xe.length===0||((Ce==null?void 0:Ce.capabilities)||[]).includes(be.active?"down":"up");return h.jsxs("div",{className:"nc-mcard","data-roster-key":ee.key,"data-position":te,children:[h.jsx(Ur,{position:te,itemKey:ee.key,label:be.cell,canMove:Ie,onMove:(de,Ke)=>R(te,de,Ke,Te),onStep:de=>F(te,ee.key,de,Te)}),h.jsxs("button",{className:"nc-mcard-main",onClick:()=>be.tmux&&Be(be.tmuxSession),title:be.degraded?y("cell-degraded"):be.tmux?y("cell-on"):y("cell-off"),children:[h.jsx("span",{className:`dot ${be.degraded?"warn":be.tmux?"on":""}`}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:be.cell}),h.jsx("small",{children:rt})]})]}),ee.activity?h.jsx("span",{className:"nc-rel",children:Gr(ee.activity)}):null,ee.fresh&&((gt=ke==null?void 0:ke.outbox)==null?void 0:gt.count)>0&&h.jsx("span",{className:"nc-badge",title:y("new-files-outbox"),children:ke.outbox.count}),h.jsx("button",{className:`nc-act pin${G.includes(ee.key)?" on":""}`,"aria-label":`${y("pin")} ${be.cell}`,title:y("pin"),onClick:()=>q(ee.key),children:G.includes(ee.key)?"★":"☆"}),Ve&&h.jsx("button",{className:`nc-act power${be.tmux?" on":""}${be.degraded?" warn":""}`,onClick:()=>Q(xe.length?{...be,route:xe,availableEngines:(Ce==null?void 0:Ce.engines)||[]}:be),title:be.active?y("power-off"):y("power-on"),"aria-label":`${be.active?y("power-off"):y("power-on")} ${be.cell}`,children:h.jsx(et,{name:"power",size:16})})]},ee.key)}const Fe=ee.value;return h.jsxs("div",{className:"nc-mcard","data-roster-key":ee.key,"data-position":te,children:[h.jsx(Ur,{position:te,itemKey:ee.key,label:Fe.name,canMove:Ie,onMove:(be,ke)=>R(te,be,ke,Te),onStep:be=>F(te,ee.key,be,Te)}),h.jsxs("button",{className:"nc-mcard-main",onClick:()=>Be(Fe.name),children:[h.jsx("span",{className:Fe.attached?"dot on":"dot"}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:Fe.name}),h.jsx("small",{children:Fe.preview?Fe.preview:Fe.cmd?Fe.cmd:y("windows").replace("{n}",String(Fe.windows||0))})]})]}),ee.activity?h.jsx("span",{className:"nc-rel",children:Gr(ee.activity)}):null,ee.fresh&&((ge=Fe.outbox)==null?void 0:ge.count)>0&&h.jsx("span",{className:"nc-badge",title:y("new-files-outbox"),children:Fe.outbox.count}),h.jsx("button",{className:`nc-act pin${G.includes(ee.key)?" on":""}`,"aria-label":`${y("pin")} ${Fe.name}`,title:y("pin"),onClick:()=>q(ee.key),children:G.includes(ee.key)?"★":"☆"}),h.jsx("button",{className:`nc-act technical${Fe.technical?" on":""}`,title:Fe.technical?y("mark-normal"):y("mark-technical"),"aria-label":`${Fe.technical?y("mark-normal"):y("mark-technical")} ${Fe.name}`,onClick:()=>K(Fe.name,!Fe.technical,xe),children:"T"}),h.jsx("button",{className:"nc-menu",title:y("terminate"),"aria-label":`${y("terminate")} ${Fe.name}`,onClick:()=>{window.confirm(y("terminate-confirm").replace("{name}",Fe.name))&&ne(Fe.name,xe)},children:"⋯"})]},ee.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:[y("fleet-tmux")," · ",Z," ",y("sessions"),je>0&&` · ${je} attached`]}),h.jsxs("span",{className:"nc-head-actions",children:[h.jsx("button",{className:"nc-refresh",onClick:()=>i("nodes",!1),title:y("settings"),children:h.jsx(et,{name:"gear",size:18})}),h.jsx("button",{className:"nc-refresh",onClick:D,title:y("refresh"),children:h.jsx(et,{name:"refresh",size:18})})]})]}),h.jsxs("main",{className:"nc-home-scroll",children:[X>8&&h.jsx("input",{className:"nc-filter",type:"search",placeholder:y("filter-placeholder"),"aria-label":y("filter-placeholder"),value:S,onChange:ee=>C(ee.target.value)}),m&&h.jsx("div",{className:"nc-err",children:m}),h.jsxs("section",{className:"nc-group","data-position":"local",children:[h.jsx(_m,{label:y("position-local"),count:_e.length,state:le,dotClass:"on",onToggle:()=>A("local",{open:!le.open}),onFilter:ee=>A("local",{filter:ee})}),le.open&&_e.map(ee=>ye(ee,null,se)),le.open&&c===null&&h.jsx("div",{className:"nc-empty",children:y("loading-fleet")}),le.open&&c!==null&&_e.length===0&&!m&&h.jsx("div",{className:"nc-empty",children:S?y("no-match").replace("{q}",S):y("no-sessions-short")})]}),l.map(ee=>{const Te=zv(ee.health,{passive:"warn"})||(ee.status==="up"?"on":ee.status==="passive"?"":"warn"),xe=ee.health?Wa(ee.health):ee.status==="up"?"":qr(ee),te=(ee.route||[ee.name]).join("/"),ve=Y(te),{rawItems:Be}=Hv(ee),Ie=ar(Be,G,ve.filter,zn(U,te)).filter(gt=>hm(gt,S)),Fe=ee.direct&&ee.health&&ee.health.managed!==!1?h.jsx("button",{type:"button",className:`nc-act power${ee.tunnelStatus==="up"?" on":""}`,disabled:H===ee.name,title:ee.tunnelStatus==="up"?y("power-off"):y("power-on"),"aria-label":`${ee.tunnelStatus==="up"?y("power-off"):y("power-on")} ${ee.label||ee.name}`,onClick:()=>M(ee),children:h.jsx(et,{name:"power",size:15})}):null;return h.jsxs("section",{className:"nc-group","data-position":te,children:[h.jsx(_m,{label:ee.label||ee.name,count:Ie.length,state:ve,dotClass:Te,dotTitle:xe,detail:ee.status==="up"?"":ee.health&&Wa(ee.health)||qr(ee),onToggle:()=>A(te,{open:!ve.open}),onFilter:gt=>A(te,{filter:gt}),action:Fe}),ee.status==="up"&&ve.open&&Ie.map(gt=>ye(gt,ee,Be)),ee.status==="up"&&ve.open&&Ie.length===0&&h.jsx("div",{className:"nc-empty",children:S?y("no-match").replace("{q}",S):y("no-sessions-short")})]},`nodo-${te}`)}),h.jsxs("footer",{className:"nc-home-foot",onClick:O,title:y("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:[Me," · ",y("ssh-only")]})]}),h.jsx("span",{className:"nc-lang",onClick:ee=>ee.stopPropagation(),children:Iv.map((ee,Ce)=>h.jsxs("span",{children:[Ce>0&&" · ",h.jsx("button",{className:`nc-lang-btn${s===ee?" on":""}`,onClick:()=>o(ee),title:ee,children:ee.toUpperCase()})]},ee))})]})]}),h.jsx("button",{className:"nc-fab",onClick:()=>i("fleet",!0),title:y("fleet-new-cell"),"aria-label":y("fleet-new-cell"),children:"+"}),T&&h.jsx(Ha,{cell:T,token:t,route:Array.isArray(T.route)?T.route:[],onConfirm:z,onClose:()=>Q(null)})]})}function _m({label:e,count:t,state:i,dotClass:s="",dotTitle:o="",detail:l="",onToggle:c,onFilter:d,action:m=null}){return h.jsxs("div",{className:"nc-mobile-position-head",children:[h.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:c,"aria-expanded":i.open,"aria-label":`${e} · ${y("node-sessions").replace("{n}",String(t))}`,children:[h.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:i.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||y("node-sessions").replace("{n}",String(t))})]})]}),h.jsxs("select",{className:"nc-mobile-position-filter",value:i.filter,"aria-label":`${e} · ${y("filter-placeholder")}`,title:y(`view-${i.filter}`),onChange:p=>d(p.target.value),children:[h.jsx("option",{value:"all",children:y("view-all")}),h.jsx("option",{value:"pinned",children:y("view-pinned")}),h.jsx("option",{value:"active",children:y("view-active")}),h.jsx("option",{value:"off",children:y("view-off")}),h.jsx("option",{value:"technical",children:y("view-technical")})]}),m]})}/**
|
|
40
|
+
`+g.stack}return{value:n,source:r,stack:f,digest:null}}function yc(n,r,a){return{value:n,source:null,stack:a??null,digest:r??null}}function Sc(n,r){try{console.error(r.value)}catch(a){setTimeout(function(){throw a})}}var qS=typeof WeakMap=="function"?WeakMap:Map;function op(n,r,a){a=on(-1,a),a.tag=3,a.payload={element:null};var u=r.value;return a.callback=function(){aa||(aa=!0,Ac=u),Sc(n,r)},a}function ap(n,r,a){a=on(-1,a),a.tag=3;var u=n.type.getDerivedStateFromError;if(typeof u=="function"){var f=r.value;a.payload=function(){return u(f)},a.callback=function(){Sc(n,r)}}var g=n.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(a.callback=function(){Sc(n,r),typeof u!="function"&&(Nn===null?Nn=new Set([this]):Nn.add(this));var k=r.stack;this.componentDidCatch(r.value,{componentStack:k!==null?k:""})}),a}function lp(n,r,a){var u=n.pingCache;if(u===null){u=n.pingCache=new qS;var f=new Set;u.set(r,f)}else f=u.get(r),f===void 0&&(f=new Set,u.set(r,f));f.has(a)||(f.add(a),n=ow.bind(null,n,r,a),r.then(n,n))}function cp(n){do{var r;if((r=n.tag===13)&&(r=n.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return n;n=n.return}while(n!==null);return null}function up(n,r,a,u,f){return(n.mode&1)===0?(n===r?n.flags|=65536:(n.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(r=on(-1,1),r.tag=2,kn(a,r,1))),a.lanes|=1),n):(n.flags|=65536,n.lanes=f,n)}var VS=T.ReactCurrentOwner,ri=!1;function Qt(n,r,a,u){r.child=n===null?Df(r,null,a,u):Mr(r,n.child,a,u)}function hp(n,r,a,u,f){a=a.render;var g=r.ref;return jr(r,f),u=hc(n,r,a,u,g,f),a=dc(),n!==null&&!ri?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,an(n,r,f)):(ut&&a&&Yl(r),r.flags|=1,Qt(n,r,u,f),r.child)}function dp(n,r,a,u,f){if(n===null){var g=a.type;return typeof g=="function"&&!$c(g)&&g.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(r.tag=15,r.type=g,fp(n,r,g,u,f)):(n=fa(a.type,null,u,r,r.mode,f),n.ref=r.ref,n.return=r,r.child=n)}if(g=n.child,(n.lanes&f)===0){var k=g.memoizedProps;if(a=a.compare,a=a!==null?a:ys,a(k,u)&&n.ref===r.ref)return an(n,r,f)}return r.flags|=1,n=Mn(g,u),n.ref=r.ref,n.return=r,r.child=n}function fp(n,r,a,u,f){if(n!==null){var g=n.memoizedProps;if(ys(g,u)&&n.ref===r.ref)if(ri=!1,r.pendingProps=u=g,(n.lanes&f)!==0)(n.flags&131072)!==0&&(ri=!0);else return r.lanes=n.lanes,an(n,r,f)}return wc(n,r,a,u,f)}function pp(n,r,a){var u=r.pendingProps,f=u.children,g=n!==null?n.memoizedState:null;if(u.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},ot(Ir,mi),mi|=a;else{if((a&1073741824)===0)return n=g!==null?g.baseLanes|a:a,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:n,cachePool:null,transitions:null},r.updateQueue=null,ot(Ir,mi),mi|=n,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=g!==null?g.baseLanes:a,ot(Ir,mi),mi|=u}else g!==null?(u=g.baseLanes|a,r.memoizedState=null):u=a,ot(Ir,mi),mi|=u;return Qt(n,r,f,a),r.child}function mp(n,r){var a=r.ref;(n===null&&a!==null||n!==null&&n.ref!==a)&&(r.flags|=512,r.flags|=2097152)}function wc(n,r,a,u,f){var g=ni(a)?Un:qt.current;return g=Nr(r,g),jr(r,f),a=hc(n,r,a,u,g,f),u=dc(),n!==null&&!ri?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,an(n,r,f)):(ut&&u&&Yl(r),r.flags|=1,Qt(n,r,a,f),r.child)}function gp(n,r,a,u,f){if(ni(a)){var g=!0;Oo(r)}else g=!1;if(jr(r,f),r.stateNode===null)ia(n,r),rp(r,a,u),_c(r,a,u,f),u=!0;else if(n===null){var k=r.stateNode,B=r.memoizedProps;k.props=B;var $=k.context,re=a.contextType;typeof re=="object"&&re!==null?re=Ci(re):(re=ni(a)?Un:qt.current,re=Nr(r,re));var pe=a.getDerivedStateFromProps,me=typeof pe=="function"||typeof k.getSnapshotBeforeUpdate=="function";me||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(B!==u||$!==re)&&sp(r,k,u,re),xn=!1;var de=r.memoizedState;k.state=de,Vo(r,u,k,f),$=r.memoizedState,B!==u||de!==$||ii.current||xn?(typeof pe=="function"&&(vc(r,a,pe,u),$=r.memoizedState),(B=xn||np(r,a,B,u,de,$,re))?(me||typeof k.UNSAFE_componentWillMount!="function"&&typeof k.componentWillMount!="function"||(typeof k.componentWillMount=="function"&&k.componentWillMount(),typeof k.UNSAFE_componentWillMount=="function"&&k.UNSAFE_componentWillMount()),typeof k.componentDidMount=="function"&&(r.flags|=4194308)):(typeof k.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=u,r.memoizedState=$),k.props=u,k.state=$,k.context=re,u=B):(typeof k.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{k=r.stateNode,Lf(n,r),B=r.memoizedProps,re=r.type===r.elementType?B:Ai(r.type,B),k.props=re,me=r.pendingProps,de=k.context,$=a.contextType,typeof $=="object"&&$!==null?$=Ci($):($=ni(a)?Un:qt.current,$=Nr(r,$));var ke=a.getDerivedStateFromProps;(pe=typeof ke=="function"||typeof k.getSnapshotBeforeUpdate=="function")||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(B!==me||de!==$)&&sp(r,k,u,$),xn=!1,de=r.memoizedState,k.state=de,Vo(r,u,k,f);var Me=r.memoizedState;B!==me||de!==Me||ii.current||xn?(typeof ke=="function"&&(vc(r,a,ke,u),Me=r.memoizedState),(re=xn||np(r,a,re,u,de,Me,$)||!1)?(pe||typeof k.UNSAFE_componentWillUpdate!="function"&&typeof k.componentWillUpdate!="function"||(typeof k.componentWillUpdate=="function"&&k.componentWillUpdate(u,Me,$),typeof k.UNSAFE_componentWillUpdate=="function"&&k.UNSAFE_componentWillUpdate(u,Me,$)),typeof k.componentDidUpdate=="function"&&(r.flags|=4),typeof k.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof k.componentDidUpdate!="function"||B===n.memoizedProps&&de===n.memoizedState||(r.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||B===n.memoizedProps&&de===n.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=Me),k.props=u,k.state=Me,k.context=$,u=re):(typeof k.componentDidUpdate!="function"||B===n.memoizedProps&&de===n.memoizedState||(r.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||B===n.memoizedProps&&de===n.memoizedState||(r.flags|=1024),u=!1)}return bc(n,r,a,u,g,f)}function bc(n,r,a,u,f,g){mp(n,r);var k=(r.flags&128)!==0;if(!u&&!k)return f&&wf(r,a,!1),an(n,r,g);u=r.stateNode,VS.current=r;var B=k&&typeof a.getDerivedStateFromError!="function"?null:u.render();return r.flags|=1,n!==null&&k?(r.child=Mr(r,n.child,null,g),r.child=Mr(r,null,B,g)):Qt(n,r,B,g),r.memoizedState=u.state,f&&wf(r,a,!0),r.child}function vp(n){var r=n.stateNode;r.pendingContext?yf(n,r.pendingContext,r.pendingContext!==r.context):r.context&&yf(n,r.context,!1),sc(n,r.containerInfo)}function _p(n,r,a,u,f){return Dr(),Jl(f),r.flags|=256,Qt(n,r,a,u),r.child}var Cc={dehydrated:null,treeContext:null,retryLane:0};function xc(n){return{baseLanes:n,cachePool:null,transitions:null}}function yp(n,r,a){var u=r.pendingProps,f=dt.current,g=!1,k=(r.flags&128)!==0,B;if((B=k)||(B=n!==null&&n.memoizedState===null?!1:(f&2)!==0),B?(g=!0,r.flags&=-129):(n===null||n.memoizedState!==null)&&(f|=1),ot(dt,f&1),n===null)return Ql(r),n=r.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((r.mode&1)===0?r.lanes=1:n.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(k=u.children,n=u.fallback,g?(u=r.mode,g=r.child,k={mode:"hidden",children:k},(u&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=k):g=pa(k,u,0,null),n=er(n,u,a,null),g.return=r,n.return=r,g.sibling=n,r.child=g,r.child.memoizedState=xc(a),r.memoizedState=Cc,n):kc(r,k));if(f=n.memoizedState,f!==null&&(B=f.dehydrated,B!==null))return YS(n,r,k,u,B,f,a);if(g){g=u.fallback,k=r.mode,f=n.child,B=f.sibling;var $={mode:"hidden",children:u.children};return(k&1)===0&&r.child!==f?(u=r.child,u.childLanes=0,u.pendingProps=$,r.deletions=null):(u=Mn(f,$),u.subtreeFlags=f.subtreeFlags&14680064),B!==null?g=Mn(B,g):(g=er(g,k,a,null),g.flags|=2),g.return=r,u.return=r,u.sibling=g,r.child=u,u=g,g=r.child,k=n.child.memoizedState,k=k===null?xc(a):{baseLanes:k.baseLanes|a,cachePool:null,transitions:k.transitions},g.memoizedState=k,g.childLanes=n.childLanes&~a,r.memoizedState=Cc,u}return g=n.child,n=g.sibling,u=Mn(g,{mode:"visible",children:u.children}),(r.mode&1)===0&&(u.lanes=a),u.return=r,u.sibling=null,n!==null&&(a=r.deletions,a===null?(r.deletions=[n],r.flags|=16):a.push(n)),r.child=u,r.memoizedState=null,u}function kc(n,r){return r=pa({mode:"visible",children:r},n.mode,0,null),r.return=n,n.child=r}function ta(n,r,a,u){return u!==null&&Jl(u),Mr(r,n.child,null,a),n=kc(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function YS(n,r,a,u,f,g,k){if(a)return r.flags&256?(r.flags&=-257,u=yc(Error(i(422))),ta(n,r,k,u)):r.memoizedState!==null?(r.child=n.child,r.flags|=128,null):(g=u.fallback,f=r.mode,u=pa({mode:"visible",children:u.children},f,0,null),g=er(g,f,k,null),g.flags|=2,u.return=r,g.return=r,u.sibling=g,r.child=u,(r.mode&1)!==0&&Mr(r,n.child,null,k),r.child.memoizedState=xc(k),r.memoizedState=Cc,g);if((r.mode&1)===0)return ta(n,r,k,null);if(f.data==="$!"){if(u=f.nextSibling&&f.nextSibling.dataset,u)var B=u.dgst;return u=B,g=Error(i(419)),u=yc(g,u,void 0),ta(n,r,k,u)}if(B=(k&n.childLanes)!==0,ri||B){if(u=jt,u!==null){switch(k&-k){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&(u.suspendedLanes|k))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,sn(n,f),Oi(u,n,f,-1))}return Hc(),u=yc(Error(i(421))),ta(n,r,k,u)}return f.data==="$?"?(r.flags|=128,r.child=n.child,r=aw.bind(null,n),f._reactRetry=r,null):(n=g.treeContext,pi=Sn(f.nextSibling),fi=r,ut=!0,Ti=null,n!==null&&(wi[bi++]=nn,wi[bi++]=rn,wi[bi++]=Kn,nn=n.id,rn=n.overflow,Kn=r),r=kc(r,u.children),r.flags|=4096,r)}function Sp(n,r,a){n.lanes|=r;var u=n.alternate;u!==null&&(u.lanes|=r),ic(n.return,r,a)}function Ec(n,r,a,u,f){var g=n.memoizedState;g===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:a,tailMode:f}:(g.isBackwards=r,g.rendering=null,g.renderingStartTime=0,g.last=u,g.tail=a,g.tailMode=f)}function wp(n,r,a){var u=r.pendingProps,f=u.revealOrder,g=u.tail;if(Qt(n,r,u.children,a),u=dt.current,(u&2)!==0)u=u&1|2,r.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&Sp(n,a,r);else if(n.tag===19)Sp(n,a,r);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break e;for(;n.sibling===null;){if(n.return===null||n.return===r)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}u&=1}if(ot(dt,u),(r.mode&1)===0)r.memoizedState=null;else switch(f){case"forwards":for(a=r.child,f=null;a!==null;)n=a.alternate,n!==null&&Yo(n)===null&&(f=a),a=a.sibling;a=f,a===null?(f=r.child,r.child=null):(f=a.sibling,a.sibling=null),Ec(r,!1,f,a,g);break;case"backwards":for(a=null,f=r.child,r.child=null;f!==null;){if(n=f.alternate,n!==null&&Yo(n)===null){r.child=f;break}n=f.sibling,f.sibling=a,a=f,f=n}Ec(r,!0,a,null,g);break;case"together":Ec(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function ia(n,r){(r.mode&1)===0&&n!==null&&(n.alternate=null,r.alternate=null,r.flags|=2)}function an(n,r,a){if(n!==null&&(r.dependencies=n.dependencies),Gn|=r.lanes,(a&r.childLanes)===0)return null;if(n!==null&&r.child!==n.child)throw Error(i(153));if(r.child!==null){for(n=r.child,a=Mn(n,n.pendingProps),r.child=a,a.return=r;n.sibling!==null;)n=n.sibling,a=a.sibling=Mn(n,n.pendingProps),a.return=r;a.sibling=null}return r.child}function XS(n,r,a){switch(r.tag){case 3:vp(r),Dr();break;case 5:Af(r);break;case 1:ni(r.type)&&Oo(r);break;case 4:sc(r,r.stateNode.containerInfo);break;case 10:var u=r.type._context,f=r.memoizedProps.value;ot(Uo,u._currentValue),u._currentValue=f;break;case 13:if(u=r.memoizedState,u!==null)return u.dehydrated!==null?(ot(dt,dt.current&1),r.flags|=128,null):(a&r.child.childLanes)!==0?yp(n,r,a):(ot(dt,dt.current&1),n=an(n,r,a),n!==null?n.sibling:null);ot(dt,dt.current&1);break;case 19:if(u=(a&r.childLanes)!==0,(n.flags&128)!==0){if(u)return wp(n,r,a);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),ot(dt,dt.current),u)break;return null;case 22:case 23:return r.lanes=0,pp(n,r,a)}return an(n,r,a)}var bp,Nc,Cp,xp;bp=function(n,r){for(var a=r.child;a!==null;){if(a.tag===5||a.tag===6)n.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}},Nc=function(){},Cp=function(n,r,a,u){var f=n.memoizedProps;if(f!==u){n=r.stateNode,Yn($i.current);var g=null;switch(a){case"input":f=Z(n,f),u=Z(n,u),g=[];break;case"select":f=K({},f,{value:void 0}),u=K({},u,{value:void 0}),g=[];break;case"textarea":f=Ie(n,f),u=Ie(n,u),g=[];break;default:typeof f.onClick!="function"&&typeof u.onClick=="function"&&(n.onclick=Ao)}Ke(a,u);var k;a=null;for(re in f)if(!u.hasOwnProperty(re)&&f.hasOwnProperty(re)&&f[re]!=null)if(re==="style"){var B=f[re];for(k in B)B.hasOwnProperty(k)&&(a||(a={}),a[k]="")}else re!=="dangerouslySetInnerHTML"&&re!=="children"&&re!=="suppressContentEditableWarning"&&re!=="suppressHydrationWarning"&&re!=="autoFocus"&&(o.hasOwnProperty(re)?g||(g=[]):(g=g||[]).push(re,null));for(re in u){var $=u[re];if(B=f!=null?f[re]:void 0,u.hasOwnProperty(re)&&$!==B&&($!=null||B!=null))if(re==="style")if(B){for(k in B)!B.hasOwnProperty(k)||$&&$.hasOwnProperty(k)||(a||(a={}),a[k]="");for(k in $)$.hasOwnProperty(k)&&B[k]!==$[k]&&(a||(a={}),a[k]=$[k])}else a||(g||(g=[]),g.push(re,a)),a=$;else re==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,B=B?B.__html:void 0,$!=null&&B!==$&&(g=g||[]).push(re,$)):re==="children"?typeof $!="string"&&typeof $!="number"||(g=g||[]).push(re,""+$):re!=="suppressContentEditableWarning"&&re!=="suppressHydrationWarning"&&(o.hasOwnProperty(re)?($!=null&&re==="onScroll"&&at("scroll",n),g||B===$||(g=[])):(g=g||[]).push(re,$))}a&&(g=g||[]).push("style",a);var re=g;(r.updateQueue=re)&&(r.flags|=4)}},xp=function(n,r,a,u){a!==u&&(r.flags|=4)};function Ts(n,r){if(!ut)switch(n.tailMode){case"hidden":r=n.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?n.tail=null:a.sibling=null;break;case"collapsed":a=n.tail;for(var u=null;a!==null;)a.alternate!==null&&(u=a),a=a.sibling;u===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:u.sibling=null}}function Yt(n){var r=n.alternate!==null&&n.alternate.child===n.child,a=0,u=0;if(r)for(var f=n.child;f!==null;)a|=f.lanes|f.childLanes,u|=f.subtreeFlags&14680064,u|=f.flags&14680064,f.return=n,f=f.sibling;else for(f=n.child;f!==null;)a|=f.lanes|f.childLanes,u|=f.subtreeFlags,u|=f.flags,f.return=n,f=f.sibling;return n.subtreeFlags|=u,n.childLanes=a,r}function GS(n,r,a){var u=r.pendingProps;switch(Xl(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Yt(r),null;case 1:return ni(r.type)&&Io(),Yt(r),null;case 3:return u=r.stateNode,Tr(),lt(ii),lt(qt),lc(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(n===null||n.child===null)&&($o(r)?r.flags|=4:n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Ti!==null&&(Oc(Ti),Ti=null))),Nc(n,r),Yt(r),null;case 5:oc(r);var f=Yn(Ps.current);if(a=r.type,n!==null&&r.stateNode!=null)Cp(n,r,a,u,f),n.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!u){if(r.stateNode===null)throw Error(i(166));return Yt(r),null}if(n=Yn($i.current),$o(r)){u=r.stateNode,a=r.type;var g=r.memoizedProps;switch(u[Hi]=r,u[xs]=g,n=(r.mode&1)!==0,a){case"dialog":at("cancel",u),at("close",u);break;case"iframe":case"object":case"embed":at("load",u);break;case"video":case"audio":for(f=0;f<ws.length;f++)at(ws[f],u);break;case"source":at("error",u);break;case"img":case"image":case"link":at("error",u),at("load",u);break;case"details":at("toggle",u);break;case"input":Ce(u,g),at("invalid",u);break;case"select":u._wrapperState={wasMultiple:!!g.multiple},at("invalid",u);break;case"textarea":Fe(u,g),at("invalid",u)}Ke(a,g),f=null;for(var k in g)if(g.hasOwnProperty(k)){var B=g[k];k==="children"?typeof B=="string"?u.textContent!==B&&(g.suppressHydrationWarning!==!0&&To(u.textContent,B,n),f=["children",B]):typeof B=="number"&&u.textContent!==""+B&&(g.suppressHydrationWarning!==!0&&To(u.textContent,B,n),f=["children",""+B]):o.hasOwnProperty(k)&&B!=null&&k==="onScroll"&&at("scroll",u)}switch(a){case"input":Te(u),qe(u,g,!0);break;case"textarea":Te(u),ve(u);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(u.onclick=Ao)}u=f,r.updateQueue=u,u!==null&&(r.flags|=4)}else{k=f.nodeType===9?f:f.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=be(a)),n==="http://www.w3.org/1999/xhtml"?a==="script"?(n=k.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof u.is=="string"?n=k.createElement(a,{is:u.is}):(n=k.createElement(a),a==="select"&&(k=n,u.multiple?k.multiple=!0:u.size&&(k.size=u.size))):n=k.createElementNS(n,a),n[Hi]=r,n[xs]=u,bp(n,r,!1,!1),r.stateNode=n;e:{switch(k=Mt(a,u),a){case"dialog":at("cancel",n),at("close",n),f=u;break;case"iframe":case"object":case"embed":at("load",n),f=u;break;case"video":case"audio":for(f=0;f<ws.length;f++)at(ws[f],n);f=u;break;case"source":at("error",n),f=u;break;case"img":case"image":case"link":at("error",n),at("load",n),f=u;break;case"details":at("toggle",n),f=u;break;case"input":Ce(n,u),f=Z(n,u),at("invalid",n);break;case"option":f=u;break;case"select":n._wrapperState={wasMultiple:!!u.multiple},f=K({},u,{value:void 0}),at("invalid",n);break;case"textarea":Fe(n,u),f=Ie(n,u),at("invalid",n);break;default:f=u}Ke(a,f),B=f;for(g in B)if(B.hasOwnProperty(g)){var $=B[g];g==="style"?ue(n,$):g==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,$!=null&&rt(n,$)):g==="children"?typeof $=="string"?(a!=="textarea"||$!=="")&&We(n,$):typeof $=="number"&&We(n,""+$):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(o.hasOwnProperty(g)?$!=null&&g==="onScroll"&&at("scroll",n):$!=null&&j(n,g,$,k))}switch(a){case"input":Te(n),qe(n,u,!1);break;case"textarea":Te(n),ve(n);break;case"option":u.value!=null&&n.setAttribute("value",""+ce(u.value));break;case"select":n.multiple=!!u.multiple,g=u.value,g!=null?Be(n,!!u.multiple,g,!1):u.defaultValue!=null&&Be(n,!!u.multiple,u.defaultValue,!0);break;default:typeof f.onClick=="function"&&(n.onclick=Ao)}switch(a){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}}u&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return Yt(r),null;case 6:if(n&&r.stateNode!=null)xp(n,r,n.memoizedProps,u);else{if(typeof u!="string"&&r.stateNode===null)throw Error(i(166));if(a=Yn(Ps.current),Yn($i.current),$o(r)){if(u=r.stateNode,a=r.memoizedProps,u[Hi]=r,(g=u.nodeValue!==a)&&(n=fi,n!==null))switch(n.tag){case 3:To(u.nodeValue,a,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&To(u.nodeValue,a,(n.mode&1)!==0)}g&&(r.flags|=4)}else u=(a.nodeType===9?a:a.ownerDocument).createTextNode(u),u[Hi]=r,r.stateNode=u}return Yt(r),null;case 13:if(lt(dt),u=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(ut&&pi!==null&&(r.mode&1)!==0&&(r.flags&128)===0)Nf(),Dr(),r.flags|=98560,g=!1;else if(g=$o(r),u!==null&&u.dehydrated!==null){if(n===null){if(!g)throw Error(i(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(i(317));g[Hi]=r}else Dr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Yt(r),g=!1}else Ti!==null&&(Oc(Ti),Ti=null),g=!0;if(!g)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=a,r):(u=u!==null,u!==(n!==null&&n.memoizedState!==null)&&u&&(r.child.flags|=8192,(r.mode&1)!==0&&(n===null||(dt.current&1)!==0?Nt===0&&(Nt=3):Hc())),r.updateQueue!==null&&(r.flags|=4),Yt(r),null);case 4:return Tr(),Nc(n,r),n===null&&bs(r.stateNode.containerInfo),Yt(r),null;case 10:return tc(r.type._context),Yt(r),null;case 17:return ni(r.type)&&Io(),Yt(r),null;case 19:if(lt(dt),g=r.memoizedState,g===null)return Yt(r),null;if(u=(r.flags&128)!==0,k=g.rendering,k===null)if(u)Ts(g,!1);else{if(Nt!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(k=Yo(n),k!==null){for(r.flags|=128,Ts(g,!1),u=k.updateQueue,u!==null&&(r.updateQueue=u,r.flags|=4),r.subtreeFlags=0,u=a,a=r.child;a!==null;)g=a,n=u,g.flags&=14680066,k=g.alternate,k===null?(g.childLanes=0,g.lanes=n,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=k.childLanes,g.lanes=k.lanes,g.child=k.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=k.memoizedProps,g.memoizedState=k.memoizedState,g.updateQueue=k.updateQueue,g.type=k.type,n=k.dependencies,g.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),a=a.sibling;return ot(dt,dt.current&1|2),r.child}n=n.sibling}g.tail!==null&&St()>Or&&(r.flags|=128,u=!0,Ts(g,!1),r.lanes=4194304)}else{if(!u)if(n=Yo(k),n!==null){if(r.flags|=128,u=!0,a=n.updateQueue,a!==null&&(r.updateQueue=a,r.flags|=4),Ts(g,!0),g.tail===null&&g.tailMode==="hidden"&&!k.alternate&&!ut)return Yt(r),null}else 2*St()-g.renderingStartTime>Or&&a!==1073741824&&(r.flags|=128,u=!0,Ts(g,!1),r.lanes=4194304);g.isBackwards?(k.sibling=r.child,r.child=k):(a=g.last,a!==null?a.sibling=k:r.child=k,g.last=k)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=St(),r.sibling=null,a=dt.current,ot(dt,u?a&1|2:a&1),r):(Yt(r),null);case 22:case 23:return Fc(),u=r.memoizedState!==null,n!==null&&n.memoizedState!==null!==u&&(r.flags|=8192),u&&(r.mode&1)!==0?(mi&1073741824)!==0&&(Yt(r),r.subtreeFlags&6&&(r.flags|=8192)):Yt(r),null;case 24:return null;case 25:return null}throw Error(i(156,r.tag))}function QS(n,r){switch(Xl(r),r.tag){case 1:return ni(r.type)&&Io(),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return Tr(),lt(ii),lt(qt),lc(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 5:return oc(r),null;case 13:if(lt(dt),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(i(340));Dr()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return lt(dt),null;case 4:return Tr(),null;case 10:return tc(r.type._context),null;case 22:case 23:return Fc(),null;case 24:return null;default:return null}}var na=!1,Xt=!1,JS=typeof WeakSet=="function"?WeakSet:Set,Re=null;function Br(n,r){var a=n.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(u){vt(n,r,u)}else a.current=null}function Rc(n,r,a){try{a()}catch(u){vt(n,r,u)}}var kp=!1;function ZS(n,r){if(Fl=Co,n=nf(),Ll(n)){if("selectionStart"in n)var a={start:n.selectionStart,end:n.selectionEnd};else e:{a=(a=n.ownerDocument)&&a.defaultView||window;var u=a.getSelection&&a.getSelection();if(u&&u.rangeCount!==0){a=u.anchorNode;var f=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{a.nodeType,g.nodeType}catch{a=null;break e}var k=0,B=-1,$=-1,re=0,pe=0,me=n,de=null;t:for(;;){for(var ke;me!==a||f!==0&&me.nodeType!==3||(B=k+f),me!==g||u!==0&&me.nodeType!==3||($=k+u),me.nodeType===3&&(k+=me.nodeValue.length),(ke=me.firstChild)!==null;)de=me,me=ke;for(;;){if(me===n)break t;if(de===a&&++re===f&&(B=k),de===g&&++pe===u&&($=k),(ke=me.nextSibling)!==null)break;me=de,de=me.parentNode}me=ke}a=B===-1||$===-1?null:{start:B,end:$}}else a=null}a=a||{start:0,end:0}}else a=null;for(Hl={focusedElem:n,selectionRange:a},Co=!1,Re=r;Re!==null;)if(r=Re,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,Re=n;else for(;Re!==null;){r=Re;try{var Me=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Me!==null){var je=Me.memoizedProps,wt=Me.memoizedState,J=r.stateNode,V=J.getSnapshotBeforeUpdate(r.elementType===r.type?je:Ai(r.type,je),wt);J.__reactInternalSnapshotBeforeUpdate=V}break;case 3:var te=r.stateNode.containerInfo;te.nodeType===1?te.textContent="":te.nodeType===9&&te.documentElement&&te.removeChild(te.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(Se){vt(r,r.return,Se)}if(n=r.sibling,n!==null){n.return=r.return,Re=n;break}Re=r.return}return Me=kp,kp=!1,Me}function As(n,r,a){var u=r.updateQueue;if(u=u!==null?u.lastEffect:null,u!==null){var f=u=u.next;do{if((f.tag&n)===n){var g=f.destroy;f.destroy=void 0,g!==void 0&&Rc(r,a,g)}f=f.next}while(f!==u)}}function ra(n,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var a=r=r.next;do{if((a.tag&n)===n){var u=a.create;a.destroy=u()}a=a.next}while(a!==r)}}function Pc(n){var r=n.ref;if(r!==null){var a=n.stateNode;switch(n.tag){case 5:n=a;break;default:n=a}typeof r=="function"?r(n):r.current=n}}function Ep(n){var r=n.alternate;r!==null&&(n.alternate=null,Ep(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&(delete r[Hi],delete r[xs],delete r[Kl],delete r[AS],delete r[BS])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function Np(n){return n.tag===5||n.tag===3||n.tag===4}function Rp(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Np(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function Dc(n,r,a){var u=n.tag;if(u===5||u===6)n=n.stateNode,r?a.nodeType===8?a.parentNode.insertBefore(n,r):a.insertBefore(n,r):(a.nodeType===8?(r=a.parentNode,r.insertBefore(n,a)):(r=a,r.appendChild(n)),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=Ao));else if(u!==4&&(n=n.child,n!==null))for(Dc(n,r,a),n=n.sibling;n!==null;)Dc(n,r,a),n=n.sibling}function Mc(n,r,a){var u=n.tag;if(u===5||u===6)n=n.stateNode,r?a.insertBefore(n,r):a.appendChild(n);else if(u!==4&&(n=n.child,n!==null))for(Mc(n,r,a),n=n.sibling;n!==null;)Mc(n,r,a),n=n.sibling}var Ht=null,Bi=!1;function En(n,r,a){for(a=a.child;a!==null;)Pp(n,r,a),a=a.sibling}function Pp(n,r,a){if(Fi&&typeof Fi.onCommitFiberUnmount=="function")try{Fi.onCommitFiberUnmount(vo,a)}catch{}switch(a.tag){case 5:Xt||Br(a,r);case 6:var u=Ht,f=Bi;Ht=null,En(n,r,a),Ht=u,Bi=f,Ht!==null&&(Bi?(n=Ht,a=a.stateNode,n.nodeType===8?n.parentNode.removeChild(a):n.removeChild(a)):Ht.removeChild(a.stateNode));break;case 18:Ht!==null&&(Bi?(n=Ht,a=a.stateNode,n.nodeType===8?Ul(n.parentNode,a):n.nodeType===1&&Ul(n,a),fs(n)):Ul(Ht,a.stateNode));break;case 4:u=Ht,f=Bi,Ht=a.stateNode.containerInfo,Bi=!0,En(n,r,a),Ht=u,Bi=f;break;case 0:case 11:case 14:case 15:if(!Xt&&(u=a.updateQueue,u!==null&&(u=u.lastEffect,u!==null))){f=u=u.next;do{var g=f,k=g.destroy;g=g.tag,k!==void 0&&((g&2)!==0||(g&4)!==0)&&Rc(a,r,k),f=f.next}while(f!==u)}En(n,r,a);break;case 1:if(!Xt&&(Br(a,r),u=a.stateNode,typeof u.componentWillUnmount=="function"))try{u.props=a.memoizedProps,u.state=a.memoizedState,u.componentWillUnmount()}catch(B){vt(a,r,B)}En(n,r,a);break;case 21:En(n,r,a);break;case 22:a.mode&1?(Xt=(u=Xt)||a.memoizedState!==null,En(n,r,a),Xt=u):En(n,r,a);break;default:En(n,r,a)}}function Dp(n){var r=n.updateQueue;if(r!==null){n.updateQueue=null;var a=n.stateNode;a===null&&(a=n.stateNode=new JS),r.forEach(function(u){var f=lw.bind(null,n,u);a.has(u)||(a.add(u),u.then(f,f))})}}function Ii(n,r){var a=r.deletions;if(a!==null)for(var u=0;u<a.length;u++){var f=a[u];try{var g=n,k=r,B=k;e:for(;B!==null;){switch(B.tag){case 5:Ht=B.stateNode,Bi=!1;break e;case 3:Ht=B.stateNode.containerInfo,Bi=!0;break e;case 4:Ht=B.stateNode.containerInfo,Bi=!0;break e}B=B.return}if(Ht===null)throw Error(i(160));Pp(g,k,f),Ht=null,Bi=!1;var $=f.alternate;$!==null&&($.return=null),f.return=null}catch(re){vt(f,r,re)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)Mp(r,n),r=r.sibling}function Mp(n,r){var a=n.alternate,u=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Ii(r,n),Ui(n),u&4){try{As(3,n,n.return),ra(3,n)}catch(je){vt(n,n.return,je)}try{As(5,n,n.return)}catch(je){vt(n,n.return,je)}}break;case 1:Ii(r,n),Ui(n),u&512&&a!==null&&Br(a,a.return);break;case 5:if(Ii(r,n),Ui(n),u&512&&a!==null&&Br(a,a.return),n.flags&32){var f=n.stateNode;try{We(f,"")}catch(je){vt(n,n.return,je)}}if(u&4&&(f=n.stateNode,f!=null)){var g=n.memoizedProps,k=a!==null?a.memoizedProps:g,B=n.type,$=n.updateQueue;if(n.updateQueue=null,$!==null)try{B==="input"&&g.type==="radio"&&g.name!=null&&Pe(f,g),Mt(B,k);var re=Mt(B,g);for(k=0;k<$.length;k+=2){var pe=$[k],me=$[k+1];pe==="style"?ue(f,me):pe==="dangerouslySetInnerHTML"?rt(f,me):pe==="children"?We(f,me):j(f,pe,me,re)}switch(B){case"input":Ne(f,g);break;case"textarea":gt(f,g);break;case"select":var de=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!g.multiple;var ke=g.value;ke!=null?Be(f,!!g.multiple,ke,!1):de!==!!g.multiple&&(g.defaultValue!=null?Be(f,!!g.multiple,g.defaultValue,!0):Be(f,!!g.multiple,g.multiple?[]:"",!1))}f[xs]=g}catch(je){vt(n,n.return,je)}}break;case 6:if(Ii(r,n),Ui(n),u&4){if(n.stateNode===null)throw Error(i(162));f=n.stateNode,g=n.memoizedProps;try{f.nodeValue=g}catch(je){vt(n,n.return,je)}}break;case 3:if(Ii(r,n),Ui(n),u&4&&a!==null&&a.memoizedState.isDehydrated)try{fs(r.containerInfo)}catch(je){vt(n,n.return,je)}break;case 4:Ii(r,n),Ui(n);break;case 13:Ii(r,n),Ui(n),f=n.child,f.flags&8192&&(g=f.memoizedState!==null,f.stateNode.isHidden=g,!g||f.alternate!==null&&f.alternate.memoizedState!==null||(Tc=St())),u&4&&Dp(n);break;case 22:if(pe=a!==null&&a.memoizedState!==null,n.mode&1?(Xt=(re=Xt)||pe,Ii(r,n),Xt=re):Ii(r,n),Ui(n),u&8192){if(re=n.memoizedState!==null,(n.stateNode.isHidden=re)&&!pe&&(n.mode&1)!==0)for(Re=n,pe=n.child;pe!==null;){for(me=Re=pe;Re!==null;){switch(de=Re,ke=de.child,de.tag){case 0:case 11:case 14:case 15:As(4,de,de.return);break;case 1:Br(de,de.return);var Me=de.stateNode;if(typeof Me.componentWillUnmount=="function"){u=de,a=de.return;try{r=u,Me.props=r.memoizedProps,Me.state=r.memoizedState,Me.componentWillUnmount()}catch(je){vt(u,a,je)}}break;case 5:Br(de,de.return);break;case 22:if(de.memoizedState!==null){Tp(me);continue}}ke!==null?(ke.return=de,Re=ke):Tp(me)}pe=pe.sibling}e:for(pe=null,me=n;;){if(me.tag===5){if(pe===null){pe=me;try{f=me.stateNode,re?(g=f.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(B=me.stateNode,$=me.memoizedProps.style,k=$!=null&&$.hasOwnProperty("display")?$.display:null,B.style.display=it("display",k))}catch(je){vt(n,n.return,je)}}}else if(me.tag===6){if(pe===null)try{me.stateNode.nodeValue=re?"":me.memoizedProps}catch(je){vt(n,n.return,je)}}else if((me.tag!==22&&me.tag!==23||me.memoizedState===null||me===n)&&me.child!==null){me.child.return=me,me=me.child;continue}if(me===n)break e;for(;me.sibling===null;){if(me.return===null||me.return===n)break e;pe===me&&(pe=null),me=me.return}pe===me&&(pe=null),me.sibling.return=me.return,me=me.sibling}}break;case 19:Ii(r,n),Ui(n),u&4&&Dp(n);break;case 21:break;default:Ii(r,n),Ui(n)}}function Ui(n){var r=n.flags;if(r&2){try{e:{for(var a=n.return;a!==null;){if(Np(a)){var u=a;break e}a=a.return}throw Error(i(160))}switch(u.tag){case 5:var f=u.stateNode;u.flags&32&&(We(f,""),u.flags&=-33);var g=Rp(n);Mc(n,g,f);break;case 3:case 4:var k=u.stateNode.containerInfo,B=Rp(n);Dc(n,B,k);break;default:throw Error(i(161))}}catch($){vt(n,n.return,$)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function ew(n,r,a){Re=n,Lp(n)}function Lp(n,r,a){for(var u=(n.mode&1)!==0;Re!==null;){var f=Re,g=f.child;if(f.tag===22&&u){var k=f.memoizedState!==null||na;if(!k){var B=f.alternate,$=B!==null&&B.memoizedState!==null||Xt;B=na;var re=Xt;if(na=k,(Xt=$)&&!re)for(Re=f;Re!==null;)k=Re,$=k.child,k.tag===22&&k.memoizedState!==null?Ap(f):$!==null?($.return=k,Re=$):Ap(f);for(;g!==null;)Re=g,Lp(g),g=g.sibling;Re=f,na=B,Xt=re}jp(n)}else(f.subtreeFlags&8772)!==0&&g!==null?(g.return=f,Re=g):jp(n)}}function jp(n){for(;Re!==null;){var r=Re;if((r.flags&8772)!==0){var a=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Xt||ra(5,r);break;case 1:var u=r.stateNode;if(r.flags&4&&!Xt)if(a===null)u.componentDidMount();else{var f=r.elementType===r.type?a.memoizedProps:Ai(r.type,a.memoizedProps);u.componentDidUpdate(f,a.memoizedState,u.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&Tf(r,g,u);break;case 3:var k=r.updateQueue;if(k!==null){if(a=null,r.child!==null)switch(r.child.tag){case 5:a=r.child.stateNode;break;case 1:a=r.child.stateNode}Tf(r,k,a)}break;case 5:var B=r.stateNode;if(a===null&&r.flags&4){a=B;var $=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":$.autoFocus&&a.focus();break;case"img":$.src&&(a.src=$.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var re=r.alternate;if(re!==null){var pe=re.memoizedState;if(pe!==null){var me=pe.dehydrated;me!==null&&fs(me)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(i(163))}Xt||r.flags&512&&Pc(r)}catch(de){vt(r,r.return,de)}}if(r===n){Re=null;break}if(a=r.sibling,a!==null){a.return=r.return,Re=a;break}Re=r.return}}function Tp(n){for(;Re!==null;){var r=Re;if(r===n){Re=null;break}var a=r.sibling;if(a!==null){a.return=r.return,Re=a;break}Re=r.return}}function Ap(n){for(;Re!==null;){var r=Re;try{switch(r.tag){case 0:case 11:case 15:var a=r.return;try{ra(4,r)}catch($){vt(r,a,$)}break;case 1:var u=r.stateNode;if(typeof u.componentDidMount=="function"){var f=r.return;try{u.componentDidMount()}catch($){vt(r,f,$)}}var g=r.return;try{Pc(r)}catch($){vt(r,g,$)}break;case 5:var k=r.return;try{Pc(r)}catch($){vt(r,k,$)}}}catch($){vt(r,r.return,$)}if(r===n){Re=null;break}var B=r.sibling;if(B!==null){B.return=r.return,Re=B;break}Re=r.return}}var tw=Math.ceil,sa=T.ReactCurrentDispatcher,Lc=T.ReactCurrentOwner,ki=T.ReactCurrentBatchConfig,Ze=0,jt=null,Ct=null,$t=0,mi=0,Ir=wn(0),Nt=0,Bs=null,Gn=0,oa=0,jc=0,Is=null,si=null,Tc=0,Or=1/0,ln=null,aa=!1,Ac=null,Nn=null,la=!1,Rn=null,ca=0,Os=0,Bc=null,ua=-1,ha=0;function Jt(){return(Ze&6)!==0?St():ua!==-1?ua:ua=St()}function Pn(n){return(n.mode&1)===0?1:(Ze&2)!==0&&$t!==0?$t&-$t:OS.transition!==null?(ha===0&&(ha=Nd()),ha):(n=nt,n!==0||(n=window.event,n=n===void 0?16:Bd(n.type)),n)}function Oi(n,r,a,u){if(50<Os)throw Os=0,Bc=null,Error(i(185));ls(n,a,u),((Ze&2)===0||n!==jt)&&(n===jt&&((Ze&2)===0&&(oa|=a),Nt===4&&Dn(n,$t)),oi(n,u),a===1&&Ze===0&&(r.mode&1)===0&&(Or=St()+500,zo&&Cn()))}function oi(n,r){var a=n.callbackNode;Oy(n,r);var u=So(n,n===jt?$t:0);if(u===0)a!==null&&xd(a),n.callbackNode=null,n.callbackPriority=0;else if(r=u&-u,n.callbackPriority!==r){if(a!=null&&xd(a),r===1)n.tag===0?IS(Ip.bind(null,n)):bf(Ip.bind(null,n)),jS(function(){(Ze&6)===0&&Cn()}),a=null;else{switch(Rd(u)){case 1:a=ml;break;case 4:a=kd;break;case 16:a=go;break;case 536870912:a=Ed;break;default:a=go}a=Kp(a,Bp.bind(null,n))}n.callbackPriority=r,n.callbackNode=a}}function Bp(n,r){if(ua=-1,ha=0,(Ze&6)!==0)throw Error(i(327));var a=n.callbackNode;if(zr()&&n.callbackNode!==a)return null;var u=So(n,n===jt?$t:0);if(u===0)return null;if((u&30)!==0||(u&n.expiredLanes)!==0||r)r=da(n,u);else{r=u;var f=Ze;Ze|=2;var g=zp();(jt!==n||$t!==r)&&(ln=null,Or=St()+500,Jn(n,r));do try{rw();break}catch(B){Op(n,B)}while(!0);ec(),sa.current=g,Ze=f,Ct!==null?r=0:(jt=null,$t=0,r=Nt)}if(r!==0){if(r===2&&(f=gl(n),f!==0&&(u=f,r=Ic(n,f))),r===1)throw a=Bs,Jn(n,0),Dn(n,u),oi(n,St()),a;if(r===6)Dn(n,u);else{if(f=n.current.alternate,(u&30)===0&&!iw(f)&&(r=da(n,u),r===2&&(g=gl(n),g!==0&&(u=g,r=Ic(n,g))),r===1))throw a=Bs,Jn(n,0),Dn(n,u),oi(n,St()),a;switch(n.finishedWork=f,n.finishedLanes=u,r){case 0:case 1:throw Error(i(345));case 2:Zn(n,si,ln);break;case 3:if(Dn(n,u),(u&130023424)===u&&(r=Tc+500-St(),10<r)){if(So(n,0)!==0)break;if(f=n.suspendedLanes,(f&u)!==u){Jt(),n.pingedLanes|=n.suspendedLanes&f;break}n.timeoutHandle=Wl(Zn.bind(null,n,si,ln),r);break}Zn(n,si,ln);break;case 4:if(Dn(n,u),(u&4194240)===u)break;for(r=n.eventTimes,f=-1;0<u;){var k=31-Li(u);g=1<<k,k=r[k],k>f&&(f=k),u&=~g}if(u=f,u=St()-u,u=(120>u?120:480>u?480:1080>u?1080:1920>u?1920:3e3>u?3e3:4320>u?4320:1960*tw(u/1960))-u,10<u){n.timeoutHandle=Wl(Zn.bind(null,n,si,ln),u);break}Zn(n,si,ln);break;case 5:Zn(n,si,ln);break;default:throw Error(i(329))}}}return oi(n,St()),n.callbackNode===a?Bp.bind(null,n):null}function Ic(n,r){var a=Is;return n.current.memoizedState.isDehydrated&&(Jn(n,r).flags|=256),n=da(n,r),n!==2&&(r=si,si=a,r!==null&&Oc(r)),n}function Oc(n){si===null?si=n:si.push.apply(si,n)}function iw(n){for(var r=n;;){if(r.flags&16384){var a=r.updateQueue;if(a!==null&&(a=a.stores,a!==null))for(var u=0;u<a.length;u++){var f=a[u],g=f.getSnapshot;f=f.value;try{if(!ji(g(),f))return!1}catch{return!1}}}if(a=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;else{if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Dn(n,r){for(r&=~jc,r&=~oa,n.suspendedLanes|=r,n.pingedLanes&=~r,n=n.expirationTimes;0<r;){var a=31-Li(r),u=1<<a;n[a]=-1,r&=~u}}function Ip(n){if((Ze&6)!==0)throw Error(i(327));zr();var r=So(n,0);if((r&1)===0)return oi(n,St()),null;var a=da(n,r);if(n.tag!==0&&a===2){var u=gl(n);u!==0&&(r=u,a=Ic(n,u))}if(a===1)throw a=Bs,Jn(n,0),Dn(n,r),oi(n,St()),a;if(a===6)throw Error(i(345));return n.finishedWork=n.current.alternate,n.finishedLanes=r,Zn(n,si,ln),oi(n,St()),null}function zc(n,r){var a=Ze;Ze|=1;try{return n(r)}finally{Ze=a,Ze===0&&(Or=St()+500,zo&&Cn())}}function Qn(n){Rn!==null&&Rn.tag===0&&(Ze&6)===0&&zr();var r=Ze;Ze|=1;var a=ki.transition,u=nt;try{if(ki.transition=null,nt=1,n)return n()}finally{nt=u,ki.transition=a,Ze=r,(Ze&6)===0&&Cn()}}function Fc(){mi=Ir.current,lt(Ir)}function Jn(n,r){n.finishedWork=null,n.finishedLanes=0;var a=n.timeoutHandle;if(a!==-1&&(n.timeoutHandle=-1,LS(a)),Ct!==null)for(a=Ct.return;a!==null;){var u=a;switch(Xl(u),u.tag){case 1:u=u.type.childContextTypes,u!=null&&Io();break;case 3:Tr(),lt(ii),lt(qt),lc();break;case 5:oc(u);break;case 4:Tr();break;case 13:lt(dt);break;case 19:lt(dt);break;case 10:tc(u.type._context);break;case 22:case 23:Fc()}a=a.return}if(jt=n,Ct=n=Mn(n.current,null),$t=mi=r,Nt=0,Bs=null,jc=oa=Gn=0,si=Is=null,Vn!==null){for(r=0;r<Vn.length;r++)if(a=Vn[r],u=a.interleaved,u!==null){a.interleaved=null;var f=u.next,g=a.pending;if(g!==null){var k=g.next;g.next=f,u.next=k}a.pending=u}Vn=null}return n}function Op(n,r){do{var a=Ct;try{if(ec(),Xo.current=Zo,Go){for(var u=ft.memoizedState;u!==null;){var f=u.queue;f!==null&&(f.pending=null),u=u.next}Go=!1}if(Xn=0,Lt=Et=ft=null,Ds=!1,Ms=0,Lc.current=null,a===null||a.return===null){Nt=1,Bs=r,Ct=null;break}e:{var g=n,k=a.return,B=a,$=r;if(r=$t,B.flags|=32768,$!==null&&typeof $=="object"&&typeof $.then=="function"){var re=$,pe=B,me=pe.tag;if((pe.mode&1)===0&&(me===0||me===11||me===15)){var de=pe.alternate;de?(pe.updateQueue=de.updateQueue,pe.memoizedState=de.memoizedState,pe.lanes=de.lanes):(pe.updateQueue=null,pe.memoizedState=null)}var ke=cp(k);if(ke!==null){ke.flags&=-257,up(ke,k,B,g,r),ke.mode&1&&lp(g,re,r),r=ke,$=re;var Me=r.updateQueue;if(Me===null){var je=new Set;je.add($),r.updateQueue=je}else Me.add($);break e}else{if((r&1)===0){lp(g,re,r),Hc();break e}$=Error(i(426))}}else if(ut&&B.mode&1){var wt=cp(k);if(wt!==null){(wt.flags&65536)===0&&(wt.flags|=256),up(wt,k,B,g,r),Jl(Ar($,B));break e}}g=$=Ar($,B),Nt!==4&&(Nt=2),Is===null?Is=[g]:Is.push(g),g=k;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var J=op(g,$,r);jf(g,J);break e;case 1:B=$;var V=g.type,te=g.stateNode;if((g.flags&128)===0&&(typeof V.getDerivedStateFromError=="function"||te!==null&&typeof te.componentDidCatch=="function"&&(Nn===null||!Nn.has(te)))){g.flags|=65536,r&=-r,g.lanes|=r;var Se=ap(g,B,r);jf(g,Se);break e}}g=g.return}while(g!==null)}Hp(a)}catch(Ae){r=Ae,Ct===a&&a!==null&&(Ct=a=a.return);continue}break}while(!0)}function zp(){var n=sa.current;return sa.current=Zo,n===null?Zo:n}function Hc(){(Nt===0||Nt===3||Nt===2)&&(Nt=4),jt===null||(Gn&268435455)===0&&(oa&268435455)===0||Dn(jt,$t)}function da(n,r){var a=Ze;Ze|=2;var u=zp();(jt!==n||$t!==r)&&(ln=null,Jn(n,r));do try{nw();break}catch(f){Op(n,f)}while(!0);if(ec(),Ze=a,sa.current=u,Ct!==null)throw Error(i(261));return jt=null,$t=0,Nt}function nw(){for(;Ct!==null;)Fp(Ct)}function rw(){for(;Ct!==null&&!Py();)Fp(Ct)}function Fp(n){var r=Up(n.alternate,n,mi);n.memoizedProps=n.pendingProps,r===null?Hp(n):Ct=r,Lc.current=null}function Hp(n){var r=n;do{var a=r.alternate;if(n=r.return,(r.flags&32768)===0){if(a=GS(a,r,mi),a!==null){Ct=a;return}}else{if(a=QS(a,r),a!==null){a.flags&=32767,Ct=a;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{Nt=6,Ct=null;return}}if(r=r.sibling,r!==null){Ct=r;return}Ct=r=n}while(r!==null);Nt===0&&(Nt=5)}function Zn(n,r,a){var u=nt,f=ki.transition;try{ki.transition=null,nt=1,sw(n,r,a,u)}finally{ki.transition=f,nt=u}return null}function sw(n,r,a,u){do zr();while(Rn!==null);if((Ze&6)!==0)throw Error(i(327));a=n.finishedWork;var f=n.finishedLanes;if(a===null)return null;if(n.finishedWork=null,n.finishedLanes=0,a===n.current)throw Error(i(177));n.callbackNode=null,n.callbackPriority=0;var g=a.lanes|a.childLanes;if(zy(n,g),n===jt&&(Ct=jt=null,$t=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||la||(la=!0,Kp(go,function(){return zr(),null})),g=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||g){g=ki.transition,ki.transition=null;var k=nt;nt=1;var B=Ze;Ze|=4,Lc.current=null,ZS(n,a),Mp(a,n),kS(Hl),Co=!!Fl,Hl=Fl=null,n.current=a,ew(a),Dy(),Ze=B,nt=k,ki.transition=g}else n.current=a;if(la&&(la=!1,Rn=n,ca=f),g=n.pendingLanes,g===0&&(Nn=null),jy(a.stateNode),oi(n,St()),r!==null)for(u=n.onRecoverableError,a=0;a<r.length;a++)f=r[a],u(f.value,{componentStack:f.stack,digest:f.digest});if(aa)throw aa=!1,n=Ac,Ac=null,n;return(ca&1)!==0&&n.tag!==0&&zr(),g=n.pendingLanes,(g&1)!==0?n===Bc?Os++:(Os=0,Bc=n):Os=0,Cn(),null}function zr(){if(Rn!==null){var n=Rd(ca),r=ki.transition,a=nt;try{if(ki.transition=null,nt=16>n?16:n,Rn===null)var u=!1;else{if(n=Rn,Rn=null,ca=0,(Ze&6)!==0)throw Error(i(331));var f=Ze;for(Ze|=4,Re=n.current;Re!==null;){var g=Re,k=g.child;if((Re.flags&16)!==0){var B=g.deletions;if(B!==null){for(var $=0;$<B.length;$++){var re=B[$];for(Re=re;Re!==null;){var pe=Re;switch(pe.tag){case 0:case 11:case 15:As(8,pe,g)}var me=pe.child;if(me!==null)me.return=pe,Re=me;else for(;Re!==null;){pe=Re;var de=pe.sibling,ke=pe.return;if(Ep(pe),pe===re){Re=null;break}if(de!==null){de.return=ke,Re=de;break}Re=ke}}}var Me=g.alternate;if(Me!==null){var je=Me.child;if(je!==null){Me.child=null;do{var wt=je.sibling;je.sibling=null,je=wt}while(je!==null)}}Re=g}}if((g.subtreeFlags&2064)!==0&&k!==null)k.return=g,Re=k;else e:for(;Re!==null;){if(g=Re,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:As(9,g,g.return)}var J=g.sibling;if(J!==null){J.return=g.return,Re=J;break e}Re=g.return}}var V=n.current;for(Re=V;Re!==null;){k=Re;var te=k.child;if((k.subtreeFlags&2064)!==0&&te!==null)te.return=k,Re=te;else e:for(k=V;Re!==null;){if(B=Re,(B.flags&2048)!==0)try{switch(B.tag){case 0:case 11:case 15:ra(9,B)}}catch(Ae){vt(B,B.return,Ae)}if(B===k){Re=null;break e}var Se=B.sibling;if(Se!==null){Se.return=B.return,Re=Se;break e}Re=B.return}}if(Ze=f,Cn(),Fi&&typeof Fi.onPostCommitFiberRoot=="function")try{Fi.onPostCommitFiberRoot(vo,n)}catch{}u=!0}return u}finally{nt=a,ki.transition=r}}return!1}function $p(n,r,a){r=Ar(a,r),r=op(n,r,1),n=kn(n,r,1),r=Jt(),n!==null&&(ls(n,1,r),oi(n,r))}function vt(n,r,a){if(n.tag===3)$p(n,n,a);else for(;r!==null;){if(r.tag===3){$p(r,n,a);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Nn===null||!Nn.has(u))){n=Ar(a,n),n=ap(r,n,1),r=kn(r,n,1),n=Jt(),r!==null&&(ls(r,1,n),oi(r,n));break}}r=r.return}}function ow(n,r,a){var u=n.pingCache;u!==null&&u.delete(r),r=Jt(),n.pingedLanes|=n.suspendedLanes&a,jt===n&&($t&a)===a&&(Nt===4||Nt===3&&($t&130023424)===$t&&500>St()-Tc?Jn(n,0):jc|=a),oi(n,r)}function Wp(n,r){r===0&&((n.mode&1)===0?r=1:(r=yo,yo<<=1,(yo&130023424)===0&&(yo=4194304)));var a=Jt();n=sn(n,r),n!==null&&(ls(n,r,a),oi(n,a))}function aw(n){var r=n.memoizedState,a=0;r!==null&&(a=r.retryLane),Wp(n,a)}function lw(n,r){var a=0;switch(n.tag){case 13:var u=n.stateNode,f=n.memoizedState;f!==null&&(a=f.retryLane);break;case 19:u=n.stateNode;break;default:throw Error(i(314))}u!==null&&u.delete(r),Wp(n,a)}var Up;Up=function(n,r,a){if(n!==null)if(n.memoizedProps!==r.pendingProps||ii.current)ri=!0;else{if((n.lanes&a)===0&&(r.flags&128)===0)return ri=!1,XS(n,r,a);ri=(n.flags&131072)!==0}else ri=!1,ut&&(r.flags&1048576)!==0&&Cf(r,Ho,r.index);switch(r.lanes=0,r.tag){case 2:var u=r.type;ia(n,r),n=r.pendingProps;var f=Nr(r,qt.current);jr(r,a),f=hc(null,r,u,n,f,a);var g=dc();return r.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,ni(u)?(g=!0,Oo(r)):g=!1,r.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,rc(r),f.updater=ea,r.stateNode=f,f._reactInternals=r,_c(r,u,n,a),r=bc(null,r,u,!0,g,a)):(r.tag=0,ut&&g&&Yl(r),Qt(null,r,f,a),r=r.child),r;case 16:u=r.elementType;e:{switch(ia(n,r),n=r.pendingProps,f=u._init,u=f(u._payload),r.type=u,f=r.tag=uw(u),n=Ai(u,n),f){case 0:r=wc(null,r,u,n,a);break e;case 1:r=gp(null,r,u,n,a);break e;case 11:r=hp(null,r,u,n,a);break e;case 14:r=dp(null,r,u,Ai(u.type,n),a);break e}throw Error(i(306,u,""))}return r;case 0:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),wc(n,r,u,f,a);case 1:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),gp(n,r,u,f,a);case 3:e:{if(vp(r),n===null)throw Error(i(387));u=r.pendingProps,g=r.memoizedState,f=g.element,Lf(n,r),Vo(r,u,null,a);var k=r.memoizedState;if(u=k.element,g.isDehydrated)if(g={element:u,isDehydrated:!1,cache:k.cache,pendingSuspenseBoundaries:k.pendingSuspenseBoundaries,transitions:k.transitions},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){f=Ar(Error(i(423)),r),r=_p(n,r,u,a,f);break e}else if(u!==f){f=Ar(Error(i(424)),r),r=_p(n,r,u,a,f);break e}else for(pi=Sn(r.stateNode.containerInfo.firstChild),fi=r,ut=!0,Ti=null,a=Df(r,null,u,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Dr(),u===f){r=an(n,r,a);break e}Qt(n,r,u,a)}r=r.child}return r;case 5:return Af(r),n===null&&Ql(r),u=r.type,f=r.pendingProps,g=n!==null?n.memoizedProps:null,k=f.children,$l(u,f)?k=null:g!==null&&$l(u,g)&&(r.flags|=32),mp(n,r),Qt(n,r,k,a),r.child;case 6:return n===null&&Ql(r),null;case 13:return yp(n,r,a);case 4:return sc(r,r.stateNode.containerInfo),u=r.pendingProps,n===null?r.child=Mr(r,null,u,a):Qt(n,r,u,a),r.child;case 11:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),hp(n,r,u,f,a);case 7:return Qt(n,r,r.pendingProps,a),r.child;case 8:return Qt(n,r,r.pendingProps.children,a),r.child;case 12:return Qt(n,r,r.pendingProps.children,a),r.child;case 10:e:{if(u=r.type._context,f=r.pendingProps,g=r.memoizedProps,k=f.value,ot(Uo,u._currentValue),u._currentValue=k,g!==null)if(ji(g.value,k)){if(g.children===f.children&&!ii.current){r=an(n,r,a);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var B=g.dependencies;if(B!==null){k=g.child;for(var $=B.firstContext;$!==null;){if($.context===u){if(g.tag===1){$=on(-1,a&-a),$.tag=2;var re=g.updateQueue;if(re!==null){re=re.shared;var pe=re.pending;pe===null?$.next=$:($.next=pe.next,pe.next=$),re.pending=$}}g.lanes|=a,$=g.alternate,$!==null&&($.lanes|=a),ic(g.return,a,r),B.lanes|=a;break}$=$.next}}else if(g.tag===10)k=g.type===r.type?null:g.child;else if(g.tag===18){if(k=g.return,k===null)throw Error(i(341));k.lanes|=a,B=k.alternate,B!==null&&(B.lanes|=a),ic(k,a,r),k=g.sibling}else k=g.child;if(k!==null)k.return=g;else for(k=g;k!==null;){if(k===r){k=null;break}if(g=k.sibling,g!==null){g.return=k.return,k=g;break}k=k.return}g=k}Qt(n,r,f.children,a),r=r.child}return r;case 9:return f=r.type,u=r.pendingProps.children,jr(r,a),f=Ci(f),u=u(f),r.flags|=1,Qt(n,r,u,a),r.child;case 14:return u=r.type,f=Ai(u,r.pendingProps),f=Ai(u.type,f),dp(n,r,u,f,a);case 15:return fp(n,r,r.type,r.pendingProps,a);case 17:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),ia(n,r),r.tag=1,ni(u)?(n=!0,Oo(r)):n=!1,jr(r,a),rp(r,u,f),_c(r,u,f,a),bc(null,r,u,!0,n,a);case 19:return wp(n,r,a);case 22:return pp(n,r,a)}throw Error(i(156,r.tag))};function Kp(n,r){return Cd(n,r)}function cw(n,r,a,u){this.tag=n,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=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ei(n,r,a,u){return new cw(n,r,a,u)}function $c(n){return n=n.prototype,!(!n||!n.isReactComponent)}function uw(n){if(typeof n=="function")return $c(n)?1:0;if(n!=null){if(n=n.$$typeof,n===A)return 11;if(n===F)return 14}return 2}function Mn(n,r){var a=n.alternate;return a===null?(a=Ei(n.tag,r,n.key,n.mode),a.elementType=n.elementType,a.type=n.type,a.stateNode=n.stateNode,a.alternate=n,n.alternate=a):(a.pendingProps=r,a.type=n.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=n.flags&14680064,a.childLanes=n.childLanes,a.lanes=n.lanes,a.child=n.child,a.memoizedProps=n.memoizedProps,a.memoizedState=n.memoizedState,a.updateQueue=n.updateQueue,r=n.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=n.sibling,a.index=n.index,a.ref=n.ref,a}function fa(n,r,a,u,f,g){var k=2;if(u=n,typeof n=="function")$c(n)&&(k=1);else if(typeof n=="string")k=5;else e:switch(n){case I:return er(a.children,f,g,r);case G:k=8,f|=8;break;case U:return n=Ei(12,a,r,f|2),n.elementType=U,n.lanes=g,n;case E:return n=Ei(13,a,r,f),n.elementType=E,n.lanes=g,n;case R:return n=Ei(19,a,r,f),n.elementType=R,n.lanes=g,n;case O:return pa(a,f,g,r);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case q:k=10;break e;case X:k=9;break e;case A:k=11;break e;case F:k=14;break e;case D:k=16,u=null;break e}throw Error(i(130,n==null?n:typeof n,""))}return r=Ei(k,a,r,f),r.elementType=n,r.type=u,r.lanes=g,r}function er(n,r,a,u){return n=Ei(7,n,u,r),n.lanes=a,n}function pa(n,r,a,u){return n=Ei(22,n,u,r),n.elementType=O,n.lanes=a,n.stateNode={isHidden:!1},n}function Wc(n,r,a){return n=Ei(6,n,null,r),n.lanes=a,n}function Uc(n,r,a){return r=Ei(4,n.children!==null?n.children:[],n.key,r),r.lanes=a,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}function hw(n,r,a,u,f){this.tag=r,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=vl(0),this.expirationTimes=vl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=vl(0),this.identifierPrefix=u,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Kc(n,r,a,u,f,g,k,B,$){return n=new hw(n,r,a,B,$),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Ei(3,null,null,r),n.current=g,g.stateNode=n,g.memoizedState={element:u,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},rc(g),n}function dw(n,r,a){var u=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:H,key:u==null?null:""+u,children:n,containerInfo:r,implementation:a}}function qp(n){if(!n)return bn;n=n._reactInternals;e:{if($n(n)!==n||n.tag!==1)throw Error(i(170));var r=n;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(ni(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(i(171))}if(n.tag===1){var a=n.type;if(ni(a))return Sf(n,a,r)}return r}function Vp(n,r,a,u,f,g,k,B,$){return n=Kc(a,u,!0,n,f,g,k,B,$),n.context=qp(null),a=n.current,u=Jt(),f=Pn(a),g=on(u,f),g.callback=r??null,kn(a,g,f),n.current.lanes=f,ls(n,f,u),oi(n,u),n}function ma(n,r,a,u){var f=r.current,g=Jt(),k=Pn(f);return a=qp(a),r.context===null?r.context=a:r.pendingContext=a,r=on(g,k),r.payload={element:n},u=u===void 0?null:u,u!==null&&(r.callback=u),n=kn(f,r,k),n!==null&&(Oi(n,f,k,g),qo(n,f,k)),k}function ga(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function Yp(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var a=n.retryLane;n.retryLane=a!==0&&a<r?a:r}}function qc(n,r){Yp(n,r),(n=n.alternate)&&Yp(n,r)}function fw(){return null}var Xp=typeof reportError=="function"?reportError:function(n){console.error(n)};function Vc(n){this._internalRoot=n}va.prototype.render=Vc.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(i(409));ma(n,r,null,null)},va.prototype.unmount=Vc.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;Qn(function(){ma(null,n,null,null)}),r[en]=null}};function va(n){this._internalRoot=n}va.prototype.unstable_scheduleHydration=function(n){if(n){var r=Md();n={blockedOn:null,target:n,priority:r};for(var a=0;a<vn.length&&r!==0&&r<vn[a].priority;a++);vn.splice(a,0,n),a===0&&Td(n)}};function Yc(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function _a(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function Gp(){}function pw(n,r,a,u,f){if(f){if(typeof u=="function"){var g=u;u=function(){var re=ga(k);g.call(re)}}var k=Vp(r,u,n,0,null,!1,!1,"",Gp);return n._reactRootContainer=k,n[en]=k.current,bs(n.nodeType===8?n.parentNode:n),Qn(),k}for(;f=n.lastChild;)n.removeChild(f);if(typeof u=="function"){var B=u;u=function(){var re=ga($);B.call(re)}}var $=Kc(n,0,!1,null,null,!1,!1,"",Gp);return n._reactRootContainer=$,n[en]=$.current,bs(n.nodeType===8?n.parentNode:n),Qn(function(){ma(r,$,a,u)}),$}function ya(n,r,a,u,f){var g=a._reactRootContainer;if(g){var k=g;if(typeof f=="function"){var B=f;f=function(){var $=ga(k);B.call($)}}ma(r,k,n,f)}else k=pw(a,r,n,f,u);return ga(k)}Pd=function(n){switch(n.tag){case 3:var r=n.stateNode;if(r.current.memoizedState.isDehydrated){var a=as(r.pendingLanes);a!==0&&(_l(r,a|1),oi(r,St()),(Ze&6)===0&&(Or=St()+500,Cn()))}break;case 13:Qn(function(){var u=sn(n,1);if(u!==null){var f=Jt();Oi(u,n,1,f)}}),qc(n,1)}},yl=function(n){if(n.tag===13){var r=sn(n,134217728);if(r!==null){var a=Jt();Oi(r,n,134217728,a)}qc(n,134217728)}},Dd=function(n){if(n.tag===13){var r=Pn(n),a=sn(n,r);if(a!==null){var u=Jt();Oi(a,n,r,u)}qc(n,r)}},Md=function(){return nt},Ld=function(n,r){var a=nt;try{return nt=n,r()}finally{nt=a}},hl=function(n,r,a){switch(r){case"input":if(Ne(n,a),r=a.name,a.type==="radio"&&r!=null){for(a=n;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<a.length;r++){var u=a[r];if(u!==n&&u.form===n.form){var f=Bo(u);if(!f)throw Error(i(90));De(u),Ne(u,f)}}}break;case"textarea":gt(n,a);break;case"select":r=a.value,r!=null&&Be(n,!!a.multiple,r,!1)}},gd=zc,vd=Qn;var mw={usingClientEntryPoint:!1,Events:[ks,kr,Bo,pd,md,zc]},zs={findFiberByHostInstance:Wn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},gw={bundleType:zs.bundleType,version:zs.version,rendererPackageName:zs.rendererPackageName,rendererConfig:zs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=wd(n),n===null?null:n.stateNode},findFiberByHostInstance:zs.findFiberByHostInstance||fw,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 Sa=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Sa.isDisabled&&Sa.supportsFiber)try{vo=Sa.inject(gw),Fi=Sa}catch{}}return ai.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=mw,ai.createPortal=function(n,r){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Yc(r))throw Error(i(200));return dw(n,r,null,a)},ai.createRoot=function(n,r){if(!Yc(n))throw Error(i(299));var a=!1,u="",f=Xp;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onRecoverableError!==void 0&&(f=r.onRecoverableError)),r=Kc(n,1,!1,null,null,a,!1,u,f),n[en]=r.current,bs(n.nodeType===8?n.parentNode:n),new Vc(r)},ai.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var r=n._reactInternals;if(r===void 0)throw typeof n.render=="function"?Error(i(188)):(n=Object.keys(n).join(","),Error(i(268,n)));return n=wd(r),n=n===null?null:n.stateNode,n},ai.flushSync=function(n){return Qn(n)},ai.hydrate=function(n,r,a){if(!_a(r))throw Error(i(200));return ya(null,n,r,!0,a)},ai.hydrateRoot=function(n,r,a){if(!Yc(n))throw Error(i(405));var u=a!=null&&a.hydratedSources||null,f=!1,g="",k=Xp;if(a!=null&&(a.unstable_strictMode===!0&&(f=!0),a.identifierPrefix!==void 0&&(g=a.identifierPrefix),a.onRecoverableError!==void 0&&(k=a.onRecoverableError)),r=Vp(r,null,n,1,a??null,f,!1,g,k),n[en]=r.current,bs(n),u)for(n=0;n<u.length;n++)a=u[n],f=a._getVersion,f=f(a._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[a,f]:r.mutableSourceEagerHydrationData.push(a,f);return new va(r)},ai.render=function(n,r,a){if(!_a(r))throw Error(i(200));return ya(null,n,r,!1,a)},ai.unmountComponentAtNode=function(n){if(!_a(n))throw Error(i(40));return n._reactRootContainer?(Qn(function(){ya(null,null,n,!1,function(){n._reactRootContainer=null,n[en]=null})}),!0):!1},ai.unstable_batchedUpdates=zc,ai.unstable_renderSubtreeIntoContainer=function(n,r,a,u){if(!_a(a))throw Error(i(200));if(n==null||n._reactInternals===void 0)throw Error(i(38));return ya(n,r,a,!1,u)},ai.version="18.3.1-next-f1338f8080-20240426",ai}var rm;function kw(){if(rm)return Qc.exports;rm=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(),Qc.exports=xw(),Qc.exports}var sm;function Ew(){if(sm)return wa;sm=1;var e=kw();return wa.createRoot=e.createRoot,wa.hydrateRoot=e.hydrateRoot,wa}var Nw=Ew();const Rw=Oh(Nw);function zt(e,t,i={}){return fetch(e,{...i,headers:{...i.headers||{},Authorization:`Bearer ${t}`}})}const xv=e=>`nc_seen_${e}`;async function Ue(e,t,i={}){const s=await zt(e,t,{method:i.method||"GET",headers:{"content-type":"application/json"},body:i.body?JSON.stringify(i.body):void 0}),o=await s.json().catch(()=>({}));if(!s.ok){const l=new Error(o.error||`HTTP ${s.status}`);throw l.status=s.status,l.data=o,l}return o}const ui=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",Kt=(e,t)=>`${ui(e)}/fleet/${t}`,dr=(e,t)=>Ue(Kt(t,"status"),e),Fh=(e,t,i)=>Ue(Kt(i,"up"),e,{method:"POST",body:t}),Fa=(e,t,i)=>Ue(Kt(i,"down"),e,{method:"POST",body:t}),Gs=(e,t,i)=>Ue(Kt(i,"restart"),e,{method:"POST",body:{cell:t}}),Hh=(e,t)=>Ue(Kt(t,"definitions"),e),Pw=(e,t)=>Ue(Kt(t,"credentials/status"),e),Dw=(e,t,i,s)=>Ue(Kt(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:i}}),Mw=(e,t,i)=>Ue(Kt(i,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),Lw=(e,t,i)=>Ue(Kt(i,"define-engine"),e,{method:"POST",body:{def:t}}),jw=(e,t,i,s,o)=>Ue(Kt(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:i,envChanges:s}}),Tw=(e,t,i)=>Ue(Kt(i,"remove-engine"),e,{method:"POST",body:{id:t}}),Aw=(e,t,i)=>Ue(Kt(i,"define-cell"),e,{method:"POST",body:{def:t}}),Bw=(e,t,i,s)=>Ue(Kt(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:i}}),kv=(e,t,i=!1,s)=>Ue(Kt(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:i}}),Iw=(e,t,i)=>Ue(Kt(i,"import-cell"),e,{method:"POST",body:t}),Ow=(e,t,i)=>Ue(Kt(i,"restore-cells"),e,{method:"POST",body:{cells:t}}),zw=(e,t,i,s)=>Ue(Kt(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!i}}),$h=(e,t,i)=>Ue(`${ui(i)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Ev=(e,t,i,s)=>Ue(`${ui(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!i}}),Nv=(e,t,i)=>Ue(`${ui(i)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),Rv=e=>Ue("/api/settings",e),Pv=e=>Ue("/api/nodes",e),Fw=e=>Ue("/api/topology",e),Dv=(e,t)=>Ue(`${ui(t)}/sessions`,e),Wh=(e,t)=>Ue(`${ui(t)}/config`,e),om=(e,t)=>Ue(`${ui(t)}/topology`,e),Mv=(e,t)=>Ue("/api/settings/config",e,{method:"POST",body:t}),Hw=e=>Ue("/api/settings/token/rotate",e,{method:"POST"}),$w=(e,t)=>Ue("/api/settings/nodes/pair",e,{method:"POST",body:t}),am=(e,t,i=[])=>Ue(`${ui(i)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),Ww=(e,t,i)=>Ue(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:i}}),Uw=(e,t)=>Ue(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Uh=(e,t,i)=>Ue(`/api/settings/nodes/${encodeURIComponent(t)}/${i}`,e,{method:"POST"}),Kw=(e,t,i)=>Ue(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:i}}),lm=(e,t,i,s=[])=>Ue(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:i,selected:s}}),qw=e=>Ue("/api/settings/service/regenerate",e,{method:"POST"}),Vw=e=>Ue("/api/settings/update/check",e,{method:"POST"}),Yw=e=>Ue("/api/settings/update/apply",e,{method:"POST"}),Xw=(e,t=!0)=>Ue(`/api/asks${t?"?open=1":""}`,e),Gw=(e,t,i)=>Ue(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:i}}),ba=(e,t=[])=>Ue(`${ui(t)}/decks`,e),cm=(e,t,i=[])=>Ue(`${ui(i)}/decks`,e,{method:"POST",body:{name:t}}),Ca=(e,t,i,s,o=[])=>Ue(`${ui(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:i,expectedRevision:s}}),Qw=(e,t,i,s,o=[])=>Ue(`${ui(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:i,expectedRevision:s}}),Jw=(e,t,i,s=[])=>Ue(`${ui(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:i}}),Zw={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"}),chevronUp:h.jsx("polyline",{points:"6 14 12 8 18 14"}),chevronDown:h.jsx("polyline",{points:"6 10 12 16 18 10"}),history:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),h.jsx("polyline",{points:"3 3 3 8 8 8"}),h.jsx("path",{d:"M12 7v5l3 2"})]}),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 et({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:Zw[e]||null})}const e0=["all","pinned","active","off","technical"],Lv="nc_sidebar_views_v1",jv="nc_sidebar_order_v1";function Tv(e){return e0.includes(e)?e:"all"}function t0(e,t=[],i="all"){const s=Tv(i);return s==="technical"?e.technical===!0:e.technical===!0?!1:s==="pinned"?t.includes(e.key):s==="active"?!!e.live:s==="off"?!e.live:!0}function i0(e,t,i=[],s=[]){const o=i.indexOf(e.key),l=i.indexOf(t.key),c=o===-1?Number.MAX_SAFE_INTEGER:o,d=l===-1?Number.MAX_SAFE_INTEGER:l,m=s.indexOf(e.key),p=s.indexOf(t.key),S=m===-1?Number.MAX_SAFE_INTEGER:m,C=p===-1?Number.MAX_SAFE_INTEGER:p;return c-d||S-C||+!!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 n0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(jv));if(!t||typeof t!="object"||Array.isArray(t))return{};const i={};for(const[s,o]of Object.entries(t).slice(0,64)){if(typeof s!="string"||!s||s.length>160||!Array.isArray(o))continue;const l=[...new Set(o.filter(c=>typeof c=="string"&&c&&c.length<=256))].slice(0,128);l.length&&(i[s]=l)}return i}catch{return{}}}function zn(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function r0(e,t=globalThis.localStorage){try{t.setItem(jv,JSON.stringify(e))}catch{}return e}function s0(e,t,i,s,o=[]){if(typeof t!="string"||!t||i===s)return e;const l=[...new Set(o.filter(_=>typeof _=="string"&&_))];if(!l.includes(i)||!l.includes(s))return e;const c=zn(e,t).filter(_=>l.includes(_)),d=[...c,...l.filter(_=>!c.includes(_))],m=d.indexOf(i),p=d.indexOf(s);d.splice(m,1);const S=d.indexOf(s),C=m<p?S+1:S;return d.splice(C,0,i),{...e,[t]:d}}function o0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Lv));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function um(e,t){var i,s;return{open:((i=e==null?void 0:e[t])==null?void 0:i.open)!==!1,filter:Tv((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function a0(e,t=globalThis.localStorage){try{t.setItem(Lv,JSON.stringify(e))}catch{}return e}function hm(e,t=""){const i=String(t||"").trim().toLocaleLowerCase();return i?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(i):!0}function ar(e=[],t=[],i="all",s=[]){return[...e].filter(o=>t0(o,t,i)).sort((o,l)=>i0(o,l,t,s))}const Kh=["it","en","es"];function l0(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return Kh.includes(t)?t:"en"}catch{return"en"}}const ja=l0(),Av="nc_lang",$u="nc-lang";function Bv(){return typeof localStorage<"u"?localStorage:null}const xa={it:{"update-available":"nuova versione {v} disponibile","install-version-mismatch":"installazione incompleta: frontend e server non coincidono (v{v})",reload:"ricarica","grid-empty":"trascina qui una sessione dalla sidebar, o doppio-clic per la vista singola","grid-full":"il deck può mostrare al massimo 9 sessioni",pin:"fissa in cima",reorder:"riordina","reorder-help":"trascina la maniglia; frecce su/giu da tastiera","reorder-deck-help":"trascina il deck; frecce sinistra/destra da tastiera",sessions:"sessioni","new-session":"nuova sessione",new:"nuova",fleet:"Flotta","fleet-tmux":"flotta tmux","other-sessions":"Altre sessioni","view-all":"tutte","view-pinned":"fissate","view-active":"attive","view-off":"spente","view-technical":"tecniche","mark-technical":"nascondi come sessione tecnica","mark-normal":"mostra come sessione normale","position-local":"Locale",files:"file",refresh:"aggiorna","filter-placeholder":"filtra sessioni…","loading-fleet":"carico la flotta…","no-sessions":"nessuna sessione tmux viva — la flotta parte al boot (systemd)","no-match":'nessuna sessione contiene "{q}"',"copy-url":"clicca per copiare l'URL","ssh-only":"solo tunnel SSH/VPN","new-files-outbox":"nuovi file in outbox",terminate:"termina","terminate-confirm":'Terminare la sessione "{name}"?',"cell-on":"tmux vivo","cell-off":"spenta","cell-working":"al lavoro","cell-idle":"in attesa","cell-degraded":"degradata: unit attiva, tmux morto","power-on":"accendi","power-off":"spegni","state-on":"accesa","state-off":"spenta",engine:"Engine",model:"Modello","model-default":"Modello predefinito del provider","model-remembered":"Ultimo modello usato con questo engine","boot-persist":"avvia al boot","remove-boot":"togli anche dal boot","power-config-in-settings":"Engine, provider, profilo, modello e permessi si modificano in Impostazioni → Flotta.","no-remote-control":"⚠ engine non-native: niente RC da app claude.ai (da qui la piloti comunque)",cancel:"annulla",name:"nome","name-invalid":"nome non valido: a-zA-Z0-9._- max 64, senza '-' iniziale",cwd:"cartella",browse:"sfoglia","fs-home":"home","fs-parent":".. su",preset:"preset","preset-2x2":"griglia 2×2","preset-columns":"colonne","preset-equalize":"equalizza",collapse:"comprimi",expand:"espandi",create:"crea","auth-prompt":"Incolla il token (stampato dal server):","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande",composer:"composer",windows:"{n} finestre","empty-files":"vuota",upload:"carica","no-sessions-short":"nessuna sessione","composer-placeholder":"scrivi o detta…","composer-history-tools":"cronologia e dimensione input","composer-history":"cronologia della cella","composer-history-empty":"nessun input inviato","composer-history-clear":"cancella cronologia di questa cella","composer-expand":"espandi input","composer-collapse":"riduci input","composer-clear-data":"cancella bozze e cronologia","composer-clear-data-help":"Rimuove da questo browser tutte le bozze e la cronologia input delle celle.","composer-clear-confirm":"Cancellare tutte le bozze e la cronologia input salvate in questo browser?","composer-clear-done":"Bozze e cronologia cancellate.","composer-clear-failed":"Impossibile cancellare i dati del composer in questo browser.",attach:"allega","attach-file":"File","attach-camera":"Fotocamera","attach-gallery":"Galleria","attach-uploading":"carico…","attach-upload-progress":"allegato {n}/{total}…","attach-uploaded":"{n} allegati caricati",voice:"voice",send:"invia","composer-send-failed":"connessione non pronta — testo conservato, riprova",close:"chiudi","lang-label":"lingua",decks:"deck","new-deck":"nuovo deck","deck-name":"nome deck","open-deck-window":"apri in una nuova finestra","detach-deck":"stacca in una nuova finestra","deck-current":"questo deck (finestra corrente)","deck-owner-unavailable":"nodo owner non condiviso o non raggiungibile","rename-deck":"rinomina deck","delete-deck":"elimina deck","delete-deck-confirm":'Eliminare il deck "{name}"?',"send-to-deck":"manda al deck…","deck-autosave":"salvataggio automatico",saving:"salvataggio…",saved:"salvato","popup-blocked":"popup bloccato: apri qui","select-drag":"trascina per selezionare","copy-manual":"seleziona e copia manualmente","toggle-sidebar":"mostra/nascondi la barra laterale",settings:"impostazioni","tab-roles":"ruoli","tab-nodes":"nodi",local:"Locale",location:"Dove","pairing-link":"link di pairing","pairing-required":"nome, alias SSH e link di pairing sono obbligatori","pairing-connect-help":"Per collegare un nodo servono: nome, Host SSH già funzionante e link/QR creato sull’altra installazione NexusCrew.","pairing-localhost-hint":"127.0.0.1 nel link è corretto: non aprirlo qui. NexusCrew usa invito e porta attraverso l’Host SSH.","scan-qr":"scansiona QR","pairing-qr-invalid":"QR di pairing non valido","invite-node":"invita un nodo","create-pairing-link":"crea link / QR","visibility-network":"tutta la rete","visibility-relay":"solo relay","visibility-selected":"nodi selezionati","hydra-simple":"locale + nodi, una sola rete","local-ready":"Questo dispositivo è pronto. Puoi usarlo da solo o collegarlo a un nodo.","local-only":"solo locale","add-node":"aggiungi nodo",connect:"collega","node-connected":"Nodo collegato. La rete verrà sincronizzata automaticamente.","tab-system":"sistema","tab-fleet":"flotta","fleet-editor-unavailable":"Editor disponibile solo con il provider fleet builtin.","fleet-managed":"gestito da NexusCrew","fleet-custom":"comando personalizzato","fleet-managed-help":"Client, provider e avvio sono gestiti internamente; i segreti non vengono mostrati.","fleet-credential-title":"API key su questo dispositivo","fleet-credential-help":"La key resta solo sul nodo selezionato, non viene mostrata, esportata o condivisa con la rete.","fleet-credential-set":"imposta key","fleet-credential-change":"cambia key","fleet-credential-forget":"dimentica","fleet-credential-saved":"Key salvata localmente.","fleet-credential-removed":"Key locale rimossa.","fleet-credential-remove-confirm":"Rimuovere la key locale {key}?","fleet-credential-source-environment":"ambiente","fleet-credential-source-local":"store locale","fleet-credential-source-compatibility":"config compatibile","fleet-credential-source-missing":"mancante","fleet-model-default":"modello predefinito (opzionale)","fleet-model-required":"modello (obbligatorio)","fleet-standard-permissions":"permessi standard","fleet-unsafe-permissions":"non sicuro · ignora approvazioni/sandbox","fleet-unsafe-warning":"Modalità non sicura esplicita: il worker può agire senza le normali approvazioni o protezioni sandbox.","fleet-provider-display":"nome visualizzato del provider","fleet-custom-provider-default":"Provider personalizzato","fleet-api-key-env":"NOME_VARIABILE_API_KEY","fleet-provider-id":"id-provider","fleet-custom-secret-help":"NexusCrew salva solo il nome della variabile d’ambiente, mai il suo valore.","fleet-model-override":"modello alternativo","fleet-ready":"pronto","fleet-not-ready":"non configurato","fleet-engines":"Engine","fleet-cells":"Celle / sessioni cloud","fleet-backup":"backup / ripristino","fleet-backup-help":"Esporta o ripristina selettivamente engine, celle e system prompt. Token, API key e segreti provider non entrano mai nel file.","fleet-backup-export":"esporta","fleet-backup-import":"importa","fleet-backup-download":"scarica backup","fleet-backup-restore":"ripristina selezionate","fleet-backup-import-help":"Scegli un backup JSON, controlla le celle e seleziona l’engine di destinazione prima del ripristino.","fleet-backup-overwrite":"sovrascrive la cella esistente","fleet-backup-new":"nuova cella","fleet-backup-engine-missing":"scegli un engine disponibile","fleet-backup-restore-unavailable":"Il nodo selezionato supporta solo l’esportazione; aggiornalo per ripristinare backup.","fleet-backup-restored":"{n} celle ripristinate","fleet-backup-confirm-overwrite":"Sovrascrivere queste celle? {cells}","fleet-backup-needs-restart":"riavvio necessario: {cells}","fleet-backup-empty":"nessuna cella da esportare","fleet-backup-select-one":"seleziona almeno una cella","fleet-backup-too-large":"backup troppo grande (massimo 1 MB)","fleet-backup-invalid-json":"il file non contiene JSON valido","fleet-backup-invalid-format":"formato o versione del backup non supportati","fleet-backup-invalid-cell":"il backup contiene una cella non valida","fleet-backup-duplicate-cell":"il backup contiene ID cella duplicati","fleet-backup-invalid-engine":"il backup contiene un engine non valido","fleet-backup-duplicate-engine":"il backup contiene ID engine duplicati","fleet-backup-confirm-engine-overwrite":"Sovrascrivere questi engine? I valori ambiente già configurati sul target restano invariati. {engines}","fleet-backup-env-names":"nomi ambiente","fleet-backup-env-values-required":"i valori ambiente vanno configurati sul dispositivo","fleet-system-prompt":"system prompt",characters:"caratteri","select-all":"seleziona tutte","select-none":"nessuna",edit:"modifica",save:"salva",label:"etichetta","command-path":"path assoluto del comando","args-lines":"argomenti, uno per riga","env-write-only":"I valori env sono write-only: vuoto mantiene il valore esistente.","fleet-new-engine":"Nuovo engine","fleet-new-cell":"Nuova cella","fleet-saved":"Definizione salvata.","fleet-restart-confirm":"Modifica salvata. Riavviare ora: {cells}?","fleet-remove-engine":'Eliminare l’engine "{id}"?',"fleet-remove-cell":'Eliminare la cella "{id}"? Se è attiva verrà prima fermata.',"settings-readonly":"READONLY attivo: le modifiche sono bloccate dal server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"questa macchina guarda altri nodi via tunnel SSH","role-node":"nodo (raggiungibile)","published-port":"porta pubblicata (opzionale)","no-nodes":"nessun nodo remoto configurato","node-add":"collega installazione NexusCrew","node-connect-help":"La porta SSH serve a raggiungere il server SSH. La porta NexusCrew è invece la porta locale mostrata da `nexuscrew status` sul nodo remoto.","node-name-label":"Nome del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH su questo dispositivo","node-ssh-local-help":"Puoi sostituire l’indirizzo del link con lo stesso alias che funziona usando ssh su questo dispositivo. Alias, agent e chiavi restano locali e non viaggiano nel link.","node-ssh-port-label":"Porta SSH","node-ssh-port-help":"Di solito 22; usa la porta pubblica del server SSH.","node-app-port-label":"Porta NexusCrew sul nodo","node-app-port-help":"È la porta mostrata da `nexuscrew status` sul nodo remoto.","node-name-ph":"nome (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"porta remota (opz.)","node-remove-confirm":'Rimuovere il nodo "{name}"?',"node-test":"test","tunnel-start":"avvia tunnel","tunnel-stop":"ferma tunnel","tunnel-restart":"riavvia tunnel","share-node":"Condividi questo nodo","share-local-heading":"Condivisione di questo dispositivo","share-local-hub":"Hub di condivisione","share-local-through":"Condividi {device} tramite {hub}","share-local-active":"Condiviso e raggiungibile dalla rete collegata all’hub.","share-local-private":"Privato: solo questo dispositivo può usare il collegamento all’hub.","share-node-off-desc":"Privato: resta collegato al nodo hub, ma gli altri client non possono raggiungerlo.","share-node-on-desc":"Condiviso: il nodo hub può mostrarlo e smistare celle e deck autorizzati.","peer-shared":"Nodo client condiviso nella rete Hydra","peer-private":"Nodo client privato: collegato, non pubblicato nella rete Hydra","node-connected-client":"client collegato","transport-used":"in uso","tunnel-up":"tunnel su","tunnel-down":"tunnel giù","authorized-keys-hint":"incolla questa riga in ~/.ssh/authorized_keys sull'host remoto:",copy:"copia",copied:"copiato","token-rotate":"ruota token","token-rotate-explain":"Il nuovo token NON verrà mostrato: recuperalo con `nexuscrew show token`. La sessione corrente verrà invalidata.","service-regenerate":"rigenera service","npm-auto-update":"aggiornamenti automatici da npm","npm-auto-update-help":"Controlla periodicamente latest e installa solo versioni più recenti. Mai downgrade.","npm-update-current":"installata","npm-update-latest":"npm latest","npm-update-check":"controlla ora","npm-update-install":"aggiorna ora","npm-update-restarting":"Aggiornamento avviato; NexusCrew si riaprirà dopo il riavvio del servizio.","npm-update-idle":"aggiornato","npm-update-checking":"controllo in corso","npm-update-available":"aggiornamento disponibile","npm-update-installing":"installazione in corso","npm-update-installed":"installato, riavvio in corso","npm-update-error":"controllo fallito","npm-update-unsupported":"disponibile solo con installazione npm globale","service-installed":"service installato","service-missing":"service non installato","service-active":"attivo","service-inactive":"non attivo",confirm:"conferma",add:"aggiungi",enable:"attiva","wizard-title":"benvenuto in NexusCrew","wizard-skip":"configura dopo dai settings","wizard-step-roles":"ruoli di questa installazione","wizard-step-node":"primo nodo remoto (opzionale)","wizard-done":"tutto pronto","wizard-done-desc":"setup completato — puoi cambiare tutto dai settings",next:"continua",back:"indietro",skip:"salta",finish:"fine","err-node-name":"nome non valido (a-z, 0-9, -, max 32)","err-ssh":"ssh non valido (atteso user@host o alias)","err-port":"porta non valida (1–65535)","err-ssh-port":"porta SSH non valida (1–65535)","err-node-port":"porta NexusCrew non valida (1–65535)","node-sessions":"{n} sessioni","tunnel-down-since":"tunnel giù da {t}","node-unreachable":"nodo non raggiungibile","node-passive":"client offline · stato normale","node-offline":"nodo offline","node-offline-seen":"offline · visto {t} fa","node-needs-repair":"legacy · ripeti il pairing","asks-title":"domande dalle celle","ask-reply-ph":"scrivi la risposta…","push-enable":"attiva notifiche push","push-disable":"disattiva notifiche push","push-on":"push attive su questo device","push-off":"push non attive","push-denied":"permesso notifiche negato dal browser","push-unsupported":"push non supportate in questo browser","node-display-label":"Nome (etichetta)","node-slug-hint":"routing su slug: {slug}","device-name-label":"Nome dispositivo","device-name-hint":"come ti vedono i peer (modificabile)","err-label":"etichetta non valida (max 64 char, niente a capo)","fleet-inventory":"Celle e sessioni","fleet-inventory-help":"tutte le posizioni (Locale + route Hydra)","fleet-manage-location":"Gestisci posizione","fleet-network-overview":"Panoramica rete","fleet-manage-help":"crea e configura celle nella posizione selezionata","fleet-overview-help":"stato operativo di tutte le posizioni, senza duplicare l’editor","fleet-inventory-empty":"nessuna cella o sessione","fleet-not-available":"fleet non disponibile su questa posizione",start:"avvia",stop:"ferma",restart:"riavvia",delete:"elimina","copy-manual":"copia non riuscita — seleziona e Cmd+C, o copia a mano","copy-empty":"niente selezione: trascina con Shift per selezionare","save-and-start":"salva e avvia",permissions:"Permessi","power-on-hint":"Spegni la cella; puoi anche toglierla dal boot.","launch-engine-help":"Provider, credenziali e nuovi engine si creano in Impostazioni → Flotta. Modello e permessi sono per questa cella.","launch-external-hint":"Provider esterno: engine/modello si configurano nel fleet esterno.","import-as-cell":"Importa come cella","import-help":"Riconcilia una sessione tmux esistente in una cella gestita. Scegli un engine già dichiarato: nessun engine viene inventato.","import-engine-required":"scegli un engine (obbligatorio)","test-and-connect":"testa e collega","pairing-v2-hint":"Incolla o scansiona UN solo link: precompila nome, Host SSH ed etichetta quando il link li include (v2).","invite-v2-hint":"Crea un invito monouso completo. Se sei già collegato a un hub, viene usato automaticamente; altrimenti serve solo il suo indirizzo SSH raggiungibile.","invite-network-hint":"Crea un invito per la rete a cui sei già collegato. Il nuovo dispositivo entrerà attraverso l’hub, non si collegherà direttamente a questo dispositivo.","invite-network-label":"Rete di destinazione","invite-network-via":"Hub","invite-network-route":"Un solo collegamento verso l’hub; nodi, celle e deck vengono smistati internamente.","invite-endpoint-label":"Indirizzo SSH di questo hub visto dagli altri dispositivi","invite-endpoint-auto":"Endpoint già configurato","invite-endpoint-needed":"Inserisci user@host o un alias SSH condiviso. Non è 127.0.0.1 e non è l’URL HTTP NexusCrew.","invite-ssh-hint":"Il target SSH con cui L’ALTRO dispositivo raggiunge QUESTA installazione (user@host o alias). Obbligatorio: viene incluso nel link.","invite-next-steps":"copia questo link, apri NexusCrew sull’altro dispositivo e incollalo in Impostazioni → Nodi (o scansiona il QR): al resto pensa NexusCrew","pair-card-title":"collega con un solo link","pair-card-help":"Incolla il link di pairing generato sull’altro dispositivo (o scansiona il suo QR): NexusCrew decodifica, prova la connessione SSH e collega da solo.","pair-paste-ph":"incolla qui il link di pairing","pair-paste-btn":"incolla","pair-advanced":"avanzate / modifica","pair-progress":"collegamento in corso: SSH → invito → conferma → verifica…","pair-retry":"riprova","pair-invalid-link":"questo non è un link di pairing valido","pair-invalid-hint":"serve il link completo (http://…#pair=…) generato dall’altro NexusCrew: non aprirlo, incollalo qui","pair-missing-ssh":"il link non include il target SSH (formato v1): indica in “avanzate” come questo dispositivo raggiunge l’altro via SSH — non viene mai inventato","pair-missing-name":"manca il nome del nodo: completalo in “avanzate”","pair-clipboard-denied":"lettura degli appunti non consentita: incolla manualmente nel campo","pair-clipboard-empty":"appunti vuoti: copia prima il link di pairing","pair-stage-validation":"dati non validi","pair-stage-conflict":"nome già in uso","pair-stage-ssh-start":"avvio del tunnel SSH fallito","pair-stage-ssh-ready":"peer non raggiungibile via SSH","pair-stage-join":"scambio dell’invito fallito","pair-stage-tunnel-final":"tunnel negoziato fallito","pair-stage-confirm":"conferma del pairing fallita","pair-stage-health":"verifica finale della federazione fallita","pair-stage-internal":"errore interno","pair-stage-generic":"connessione fallita","qr-no-camera":"nessuna camera disponibile su questo dispositivo: usa una foto del QR","qr-permission":"permesso camera negato: consentilo nel browser o usa una foto del QR","qr-unsupported":"scanner live non supportato qui: carica una foto del QR","qr-upload":"usa una foto"},en:{"update-available":"new version {v} available","install-version-mismatch":"incomplete installation: frontend and server do not match (v{v})",reload:"reload","grid-empty":"drag a session here from the sidebar, or double-click for single view","grid-full":"a deck can show at most 9 sessions",pin:"pin to top",reorder:"reorder","reorder-help":"drag the handle; keyboard up/down arrows","reorder-deck-help":"drag the deck; keyboard left/right arrows",sessions:"sessions","new-session":"new session",new:"new",fleet:"Fleet","fleet-tmux":"tmux fleet","other-sessions":"Other sessions","view-all":"all","view-pinned":"pinned","view-active":"active","view-off":"off","view-technical":"technical","mark-technical":"hide as technical session","mark-normal":"show as normal session","position-local":"Local",files:"files",refresh:"refresh","filter-placeholder":"filter sessions…","loading-fleet":"loading fleet…","no-sessions":"no live tmux sessions — the fleet starts at boot (systemd)","no-match":'no session matches "{q}"',"copy-url":"click to copy URL","ssh-only":"SSH/VPN tunnel only","new-files-outbox":"new files in outbox",terminate:"terminate","terminate-confirm":'Terminate session "{name}"?',"cell-on":"tmux alive","cell-off":"off","cell-working":"working","cell-idle":"idle","cell-degraded":"degraded: unit active, tmux dead","power-on":"power on","power-off":"power off","state-on":"running","state-off":"stopped",engine:"Engine",model:"Model","model-default":"Provider default model","model-remembered":"Last model used with this engine","boot-persist":"start at boot","remove-boot":"also remove from boot","power-config-in-settings":"Edit engine, provider, profile, model and permissions in Settings → Fleet.","no-remote-control":"⚠ non-native engine: no claude.ai app RC (you can still drive it from here)",cancel:"cancel",name:"name","name-invalid":"invalid name: a-zA-Z0-9._- max 64, no leading '-'",cwd:"folder",browse:"browse","fs-home":"home","fs-parent":".. up",preset:"preset","preset-2x2":"2×2 grid","preset-columns":"columns","preset-equalize":"equalize",collapse:"collapse",expand:"expand",create:"create","auth-prompt":"Paste the token (printed by the server):","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text",composer:"composer",windows:"{n} windows","empty-files":"empty",upload:"upload","no-sessions-short":"no sessions","composer-placeholder":"type or dictate…","composer-history-tools":"input history and size","composer-history":"cell history","composer-history-empty":"no submitted input","composer-history-clear":"clear this cell history","composer-expand":"expand input","composer-collapse":"collapse input","composer-clear-data":"clear drafts and history","composer-clear-data-help":"Removes every saved cell draft and input-history entry from this browser.","composer-clear-confirm":"Clear every saved draft and input-history entry from this browser?","composer-clear-done":"Drafts and history cleared.","composer-clear-failed":"Could not clear composer data in this browser.",attach:"attach","attach-file":"File","attach-camera":"Camera","attach-gallery":"Gallery","attach-uploading":"uploading…","attach-upload-progress":"attachment {n}/{total}…","attach-uploaded":"{n} attachments uploaded",voice:"voice",send:"send","composer-send-failed":"connection not ready — text kept, try again",close:"close","lang-label":"language",decks:"decks","new-deck":"new deck","deck-name":"deck name","open-deck-window":"open in a new window","detach-deck":"detach into a new window","deck-current":"this deck (current window)","deck-owner-unavailable":"owner node is not shared or reachable","rename-deck":"rename deck","delete-deck":"delete deck","delete-deck-confirm":'Delete deck "{name}"?',"send-to-deck":"send to deck…","deck-autosave":"autosave",saving:"saving…",saved:"saved","popup-blocked":"popup blocked: open here","select-drag":"drag to select","copy-manual":"select and copy manually","toggle-sidebar":"show/hide the sidebar",settings:"settings","tab-roles":"roles","tab-nodes":"nodes",local:"Local",location:"Location","pairing-link":"pairing link","pairing-required":"name, SSH alias and pairing link are required","pairing-connect-help":"Connecting a node requires a name, a working SSH Host, and a link/QR created by the other NexusCrew installation.","pairing-localhost-hint":"127.0.0.1 in the link is correct: do not open it here. NexusCrew carries the invite and port through the SSH Host.","scan-qr":"scan QR","pairing-qr-invalid":"invalid pairing QR","invite-node":"invite a node","create-pairing-link":"create link / QR","visibility-network":"whole network","visibility-relay":"relay only","visibility-selected":"selected nodes","hydra-simple":"local + nodes, one network","local-ready":"This device is ready. Use it alone or connect it to a node.","local-only":"local only","add-node":"add node",connect:"connect","node-connected":"Node connected. The network will synchronize automatically.","tab-system":"system","tab-fleet":"fleet","fleet-editor-unavailable":"The editor is available only with the builtin fleet provider.","fleet-managed":"managed by NexusCrew","fleet-custom":"custom command","fleet-managed-help":"Client, provider and launch are managed internally; secrets are never displayed.","fleet-credential-title":"API key on this device","fleet-credential-help":"The key stays only on the selected node and is never displayed, exported or shared with the network.","fleet-credential-set":"set key","fleet-credential-change":"change key","fleet-credential-forget":"forget","fleet-credential-saved":"Key saved locally.","fleet-credential-removed":"Local key removed.","fleet-credential-remove-confirm":"Remove the local {key} key?","fleet-credential-source-environment":"environment","fleet-credential-source-local":"local store","fleet-credential-source-compatibility":"compatible config","fleet-credential-source-missing":"missing","fleet-model-default":"default model (optional)","fleet-model-required":"model (required)","fleet-standard-permissions":"standard permissions","fleet-unsafe-permissions":"unsafe · bypass approvals/sandbox","fleet-unsafe-warning":"Explicit unsafe mode: the worker can act without normal approval or sandbox gates.","fleet-provider-display":"provider display name","fleet-custom-provider-default":"Custom provider","fleet-api-key-env":"API_KEY_ENV_NAME","fleet-provider-id":"provider-id","fleet-custom-secret-help":"NexusCrew stores only the environment-variable name, never its value.","fleet-model-override":"model override","fleet-ready":"ready","fleet-not-ready":"not configured","fleet-engines":"Engines","fleet-cells":"Cells / cloud sessions","fleet-backup":"backup / restore","fleet-backup-help":"Selectively export or restore engines, cells, and system prompts. Tokens, API keys, and provider secrets never enter the file.","fleet-backup-export":"export","fleet-backup-import":"import","fleet-backup-download":"download backup","fleet-backup-restore":"restore selected","fleet-backup-import-help":"Choose a JSON backup, review the cells and select a destination engine before restoring.","fleet-backup-overwrite":"overwrites existing cell","fleet-backup-new":"new cell","fleet-backup-engine-missing":"choose an available engine","fleet-backup-restore-unavailable":"The selected node supports export only; update it to restore backups.","fleet-backup-restored":"{n} cells restored","fleet-backup-confirm-overwrite":"Overwrite these cells? {cells}","fleet-backup-needs-restart":"restart required: {cells}","fleet-backup-empty":"no cells to export","fleet-backup-select-one":"select at least one cell","fleet-backup-too-large":"backup is too large (1 MB maximum)","fleet-backup-invalid-json":"the file does not contain valid JSON","fleet-backup-invalid-format":"unsupported backup format or version","fleet-backup-invalid-cell":"the backup contains an invalid cell","fleet-backup-duplicate-cell":"the backup contains duplicate cell IDs","fleet-backup-invalid-engine":"the backup contains an invalid engine","fleet-backup-duplicate-engine":"the backup contains duplicate engine IDs","fleet-backup-confirm-engine-overwrite":"Overwrite these engines? Environment values already configured on the target stay unchanged. {engines}","fleet-backup-env-names":"environment names","fleet-backup-env-values-required":"environment values must be configured on this device","fleet-system-prompt":"system prompt",characters:"characters","select-all":"select all","select-none":"select none",edit:"edit",save:"save",label:"label","command-path":"absolute command path","args-lines":"arguments, one per line","env-write-only":"Environment values are write-only: blank keeps the existing value.","fleet-new-engine":"New engine","fleet-new-cell":"New cell","fleet-saved":"Definition saved.","fleet-restart-confirm":"Change saved. Restart now: {cells}?","fleet-remove-engine":'Delete engine "{id}"?',"fleet-remove-cell":'Delete cell "{id}"? If active it will be stopped first.',"settings-readonly":"READONLY active: changes are blocked by the server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"this machine watches other nodes via SSH tunnels","role-node":"node (reachable)","published-port":"published port (optional)","no-nodes":"no remote nodes configured","node-add":"connect a NexusCrew installation","node-connect-help":"The SSH port reaches the SSH server. The NexusCrew port is the local port reported by `nexuscrew status` on the remote node.","node-name-label":"Node name","node-ssh-label":"SSH host","pair-ssh-local-label":"SSH host or alias on this device","node-ssh-local-help":"You may replace the link address with the same alias that works with ssh on this device. Aliases, agents and private keys stay local and are never carried in the link.","node-ssh-port-label":"SSH port","node-ssh-port-help":"Usually 22; use the SSH server public port.","node-app-port-label":"NexusCrew port on node","node-app-port-help":"The port reported by `nexuscrew status` on the remote node.","node-name-ph":"name (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"remote port (opt.)","node-remove-confirm":'Remove node "{name}"?',"node-test":"test","tunnel-start":"start tunnel","tunnel-stop":"stop tunnel","tunnel-restart":"restart tunnel","share-node":"Share this node","share-local-heading":"Share this device","share-local-hub":"Sharing hub","share-local-through":"Share {device} through {hub}","share-local-active":"Shared and reachable by the network connected to the hub.","share-local-private":"Private: only this device can use its hub connection.","share-node-off-desc":"Private: it stays connected to the hub, but other clients cannot reach it.","share-node-on-desc":"Shared: the hub may advertise it and route authorized cells and decks.","peer-shared":"Client node shared on the Hydra network","peer-private":"Private client node: connected, not published on Hydra","node-connected-client":"connected client","transport-used":"in use","tunnel-up":"tunnel up","tunnel-down":"tunnel down","authorized-keys-hint":"paste this line into ~/.ssh/authorized_keys on the remote host:",copy:"copy",copied:"copied","token-rotate":"rotate token","token-rotate-explain":"The new token will NOT be shown: retrieve it with `nexuscrew show token`. The current session will be invalidated.","service-regenerate":"regenerate service","npm-auto-update":"automatic updates from npm","npm-auto-update-help":"Periodically checks latest and installs only newer versions. Never downgrades.","npm-update-current":"installed","npm-update-latest":"npm latest","npm-update-check":"check now","npm-update-install":"update now","npm-update-restarting":"Update started; NexusCrew will return after the service restarts.","npm-update-idle":"up to date","npm-update-checking":"checking","npm-update-available":"update available","npm-update-installing":"installing","npm-update-installed":"installed, restarting","npm-update-error":"check failed","npm-update-unsupported":"available only for global npm installations","service-installed":"service installed","service-missing":"service not installed","service-active":"active","service-inactive":"not active",confirm:"confirm",add:"add",enable:"enable","wizard-title":"welcome to NexusCrew","wizard-skip":"configure later from settings","wizard-step-roles":"roles of this install","wizard-step-node":"first remote node (optional)","wizard-done":"all set","wizard-done-desc":"setup complete — you can change everything from settings",next:"continue",back:"back",skip:"skip",finish:"finish","err-node-name":"invalid name (a-z, 0-9, -, max 32)","err-ssh":"invalid ssh (expected user@host or alias)","err-port":"invalid port (1–65535)","err-ssh-port":"invalid SSH port (1–65535)","err-node-port":"invalid NexusCrew port (1–65535)","node-sessions":"{n} sessions","tunnel-down-since":"tunnel down for {t}","node-unreachable":"node unreachable","node-passive":"client offline · expected","node-offline":"node offline","node-offline-seen":"offline · seen {t} ago","node-needs-repair":"legacy · pair again","asks-title":"questions from the cells","ask-reply-ph":"type your answer…","push-enable":"enable push notifications","push-disable":"disable push notifications","push-on":"push active on this device","push-off":"push not active","push-denied":"notification permission denied by the browser","push-unsupported":"push not supported in this browser","node-display-label":"Name (label)","node-slug-hint":"routing on slug: {slug}","device-name-label":"Device name","device-name-hint":"how peers see you (editable)","err-label":"invalid label (max 64 chars, no line breaks)","fleet-inventory":"Cells and sessions","fleet-inventory-help":"all positions (Local + Hydra routes)","fleet-manage-location":"Manage location","fleet-network-overview":"Network overview","fleet-manage-help":"create and configure cells at the selected location","fleet-overview-help":"operational state of every location, separate from the editor","fleet-inventory-empty":"no cells or sessions","fleet-not-available":"fleet not available on this position",start:"start",stop:"stop",restart:"restart",delete:"delete","copy-manual":"copy failed — select and press Cmd+C, or copy manually","copy-empty":"nothing selected: drag with Shift to select","save-and-start":"save and start",permissions:"Permissions","power-on-hint":"Stop the cell; you can also remove it from boot.","launch-engine-help":"Providers, credentials and new engines are created in Settings → Fleet. Model and permissions are per cell.","launch-external-hint":"External provider: engine/model are configured in the external fleet.","import-as-cell":"Import as cell","import-help":"Reconcile an existing tmux session into a managed cell. Pick an already-declared engine: no engine is invented.","import-engine-required":"pick an engine (required)","test-and-connect":"test and connect","pairing-v2-hint":"Paste or scan ONE link: it prefills name, SSH host and label when the link carries them (v2).","invite-v2-hint":"Create one complete one-time invitation. If this device already joined a hub, that hub is used automatically; otherwise only its reachable SSH address is required.","invite-network-hint":"Create an invitation for the network you already joined. The new device enters through the hub instead of connecting directly to this device.","invite-network-label":"Destination network","invite-network-via":"Hub","invite-network-route":"One connection to the hub; nodes, cells and decks are routed internally.","invite-endpoint-label":"This hub’s SSH address as seen by other devices","invite-endpoint-auto":"Configured endpoint","invite-endpoint-needed":"Enter user@host or a shared SSH alias. This is not 127.0.0.1 and not the NexusCrew HTTP URL.","invite-ssh-hint":"The SSH target the OTHER device uses to reach THIS installation (user@host or alias). Required: it is included in the link.","invite-next-steps":"copy this link, open NexusCrew on the other device and paste it in Settings → Nodes (or scan the QR): NexusCrew does the rest","pair-card-title":"connect with one link","pair-card-help":"Paste the pairing link generated on the other device (or scan its QR): NexusCrew decodes it, tests the SSH connection and connects on its own.","pair-paste-ph":"paste the pairing link here","pair-paste-btn":"paste","pair-advanced":"advanced / edit","pair-progress":"connecting: SSH → invite → confirm → verify…","pair-retry":"retry","pair-invalid-link":"this is not a valid pairing link","pair-invalid-hint":"you need the full link (http://…#pair=…) generated by the other NexusCrew: don’t open it, paste it here","pair-missing-ssh":"the link carries no SSH target (v1 format): set in “advanced” how this device reaches the other one over SSH — it is never invented","pair-missing-name":"the node name is missing: fill it in “advanced”","pair-clipboard-denied":"clipboard read not allowed: paste manually into the field","pair-clipboard-empty":"clipboard is empty: copy the pairing link first","pair-stage-validation":"invalid data","pair-stage-conflict":"name already in use","pair-stage-ssh-start":"SSH tunnel start failed","pair-stage-ssh-ready":"peer unreachable over SSH","pair-stage-join":"invite exchange failed","pair-stage-tunnel-final":"negotiated tunnel failed","pair-stage-confirm":"pairing confirmation failed","pair-stage-health":"final federation check failed","pair-stage-internal":"internal error","pair-stage-generic":"connection failed","qr-no-camera":"no camera available on this device: use a photo of the QR","qr-permission":"camera permission denied: allow it in the browser or use a photo of the QR","qr-unsupported":"live scanner not supported here: upload a photo of the QR","qr-upload":"use a photo"},es:{"update-available":"nueva versión {v} disponible","install-version-mismatch":"instalación incompleta: frontend y servidor no coinciden (v{v})",reload:"recargar","grid-empty":"arrastra aquí una sesión desde la barra lateral, o doble clic para vista única","grid-full":"un deck puede mostrar como máximo 9 sesiones",pin:"fijar arriba",reorder:"reordenar","reorder-help":"arrastra el control; flechas arriba/abajo","reorder-deck-help":"arrastra el deck; flechas izquierda/derecha",sessions:"sesiones","new-session":"nueva sesión",new:"nueva",fleet:"Flota","fleet-tmux":"flota tmux","other-sessions":"Otras sesiones","view-all":"todas","view-pinned":"fijadas","view-active":"activas","view-off":"apagadas","view-technical":"técnicas","mark-technical":"ocultar como sesión técnica","mark-normal":"mostrar como sesión normal","position-local":"Local",files:"archivos",refresh:"actualizar","filter-placeholder":"filtrar sesiones…","loading-fleet":"cargando flota…","no-sessions":"sin sesiones tmux vivas — la flota arranca en el boot (systemd)","no-match":"ninguna sesión coincide con «{q}»","copy-url":"clic para copiar la URL","ssh-only":"solo túnel SSH/VPN","new-files-outbox":"archivos nuevos en outbox",terminate:"terminar","terminate-confirm":"¿Terminar la sesión «{name}»?","cell-on":"tmux activo","cell-off":"apagada","cell-working":"trabajando","cell-idle":"en espera","cell-degraded":"degradada: unit activa, tmux muerto","power-on":"encender","power-off":"apagar","state-on":"encendida","state-off":"apagada",engine:"Motor",model:"Modelo","model-default":"Modelo predeterminado del proveedor","model-remembered":"Último modelo usado con este motor","boot-persist":"iniciar en el boot","remove-boot":"quitar también del boot","power-config-in-settings":"Modifica motor, proveedor, perfil, modelo y permisos en Ajustes → Flota.","no-remote-control":"⚠ motor no nativo: sin RC de la app claude.ai (aquí puedes pilotarla igual)",cancel:"cancelar",name:"nombre","name-invalid":"nombre inválido: a-zA-Z0-9._- máx 64, sin '-' inicial",cwd:"carpeta",browse:"explorar","fs-home":"home","fs-parent":".. arriba",preset:"preset","preset-2x2":"cuadrícula 2×2","preset-columns":"columnas","preset-equalize":"igualar",collapse:"contraer",expand:"expandir",create:"crear","auth-prompt":"Pega el token (impreso por el servidor):","remember-device":"recordar en este dispositivo","zoom-out":"texto más pequeño","zoom-in":"texto más grande",composer:"composer",windows:"{n} ventanas","empty-files":"vacía",upload:"subir","no-sessions-short":"sin sesiones","composer-placeholder":"escribe o dicta…","composer-history-tools":"historial y tamaño de entrada","composer-history":"historial de la celda","composer-history-empty":"ninguna entrada enviada","composer-history-clear":"borrar historial de esta celda","composer-expand":"ampliar entrada","composer-collapse":"reducir entrada","composer-clear-data":"borrar borradores e historial","composer-clear-data-help":"Elimina de este navegador todos los borradores y el historial de entrada de las celdas.","composer-clear-confirm":"¿Borrar todos los borradores y el historial de entrada guardados en este navegador?","composer-clear-done":"Borradores e historial eliminados.","composer-clear-failed":"No se pudieron borrar los datos del composer en este navegador.",attach:"adjuntar","attach-file":"Archivo","attach-camera":"Cámara","attach-gallery":"Galería","attach-uploading":"subiendo…","attach-upload-progress":"adjunto {n}/{total}…","attach-uploaded":"{n} adjuntos subidos",voice:"voz",send:"enviar","composer-send-failed":"conexión no disponible — texto conservado, inténtalo de nuevo",close:"cerrar","lang-label":"idioma",decks:"decks","new-deck":"nuevo deck","deck-name":"nombre del deck","open-deck-window":"abrir en una ventana nueva","detach-deck":"separar en una ventana nueva","deck-current":"este deck (ventana actual)","deck-owner-unavailable":"el nodo propietario no está compartido o accesible","rename-deck":"renombrar deck","delete-deck":"eliminar deck","delete-deck-confirm":"¿Eliminar el deck «{name}»?","send-to-deck":"enviar al deck…","deck-autosave":"guardado automático",saving:"guardando…",saved:"guardado","popup-blocked":"ventana bloqueada: abrir aquí","select-drag":"arrastra para seleccionar","copy-manual":"selecciona y copia manualmente","toggle-sidebar":"mostrar/ocultar la barra lateral",settings:"ajustes","tab-roles":"roles","tab-nodes":"nodos",local:"Local",location:"Ubicación","pairing-link":"enlace de emparejamiento","pairing-required":"nombre, alias SSH y enlace son obligatorios","pairing-connect-help":"Para conectar un nodo necesitas un nombre, un Host SSH funcional y el enlace/QR creado por la otra instalación NexusCrew.","pairing-localhost-hint":"127.0.0.1 en el enlace es correcto: no lo abras aquí. NexusCrew usa la invitación y el puerto mediante el Host SSH.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","invite-node":"invitar un nodo","create-pairing-link":"crear enlace / QR","visibility-network":"toda la red","visibility-relay":"solo relay","visibility-selected":"nodos seleccionados","hydra-simple":"local + nodos, una red","local-ready":"Este dispositivo está listo. Úsalo solo o conéctalo a un nodo.","local-only":"solo local","add-node":"añadir nodo",connect:"conectar","node-connected":"Nodo conectado. La red se sincronizará automáticamente.","tab-system":"sistema","tab-fleet":"flota","fleet-editor-unavailable":"El editor solo está disponible con el proveedor builtin.","fleet-managed":"gestionado por NexusCrew","fleet-custom":"comando personalizado","fleet-managed-help":"Cliente, proveedor e inicio se gestionan internamente; los secretos nunca se muestran.","fleet-credential-title":"Clave API en este dispositivo","fleet-credential-help":"La clave permanece solo en el nodo seleccionado y nunca se muestra, exporta ni comparte con la red.","fleet-credential-set":"poner clave","fleet-credential-change":"cambiar clave","fleet-credential-forget":"olvidar","fleet-credential-saved":"Clave guardada localmente.","fleet-credential-removed":"Clave local eliminada.","fleet-credential-remove-confirm":"¿Eliminar la clave local {key}?","fleet-credential-source-environment":"entorno","fleet-credential-source-local":"almacén local","fleet-credential-source-compatibility":"config compatible","fleet-credential-source-missing":"ausente","fleet-model-default":"modelo predeterminado (opcional)","fleet-model-required":"modelo (obligatorio)","fleet-standard-permissions":"permisos estándar","fleet-unsafe-permissions":"inseguro · omitir aprobaciones/sandbox","fleet-unsafe-warning":"Modo inseguro explícito: el worker puede actuar sin las aprobaciones normales ni las protecciones del sandbox.","fleet-provider-display":"nombre visible del proveedor","fleet-custom-provider-default":"Proveedor personalizado","fleet-api-key-env":"NOMBRE_VARIABLE_API_KEY","fleet-provider-id":"id-proveedor","fleet-custom-secret-help":"NexusCrew guarda solo el nombre de la variable de entorno, nunca su valor.","fleet-model-override":"modelo alternativo","fleet-ready":"listo","fleet-not-ready":"no configurado","fleet-engines":"Motores","fleet-cells":"Celdas / sesiones cloud","fleet-backup":"copia / restauración","fleet-backup-help":"Exporta o restaura selectivamente motores, celdas y system prompts. Tokens, claves API y secretos del proveedor nunca entran en el archivo.","fleet-backup-export":"exportar","fleet-backup-import":"importar","fleet-backup-download":"descargar copia","fleet-backup-restore":"restaurar seleccionadas","fleet-backup-import-help":"Elige una copia JSON, revisa las celdas y selecciona un motor de destino antes de restaurar.","fleet-backup-overwrite":"sobrescribe la celda existente","fleet-backup-new":"celda nueva","fleet-backup-engine-missing":"elige un motor disponible","fleet-backup-restore-unavailable":"El nodo seleccionado solo admite exportación; actualízalo para restaurar copias.","fleet-backup-restored":"{n} celdas restauradas","fleet-backup-confirm-overwrite":"¿Sobrescribir estas celdas? {cells}","fleet-backup-needs-restart":"reinicio necesario: {cells}","fleet-backup-empty":"no hay celdas para exportar","fleet-backup-select-one":"selecciona al menos una celda","fleet-backup-too-large":"copia demasiado grande (máximo 1 MB)","fleet-backup-invalid-json":"el archivo no contiene JSON válido","fleet-backup-invalid-format":"formato o versión de copia no compatible","fleet-backup-invalid-cell":"la copia contiene una celda no válida","fleet-backup-duplicate-cell":"la copia contiene IDs de celda duplicados","fleet-backup-invalid-engine":"la copia contiene un motor no válido","fleet-backup-duplicate-engine":"la copia contiene IDs de motor duplicados","fleet-backup-confirm-engine-overwrite":"¿Sobrescribir estos motores? Los valores de entorno ya configurados en el destino no cambian. {engines}","fleet-backup-env-names":"nombres de entorno","fleet-backup-env-values-required":"los valores de entorno deben configurarse en este dispositivo","fleet-system-prompt":"system prompt",characters:"caracteres","select-all":"seleccionar todas","select-none":"ninguna",edit:"editar",save:"guardar",label:"etiqueta","command-path":"ruta absoluta del comando","args-lines":"argumentos, uno por línea","env-write-only":"Los valores env son de solo escritura: vacío conserva el valor existente.","fleet-new-engine":"Nuevo motor","fleet-new-cell":"Nueva celda","fleet-saved":"Definición guardada.","fleet-restart-confirm":"Cambio guardado. ¿Reiniciar ahora: {cells}?","fleet-remove-engine":'¿Eliminar el motor "{id}"?',"fleet-remove-cell":'¿Eliminar la celda "{id}"? Si está activa se detendrá primero.',"settings-readonly":"READONLY activo: los cambios están bloqueados por el servidor (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"esta máquina observa otros nodos vía túneles SSH","role-node":"nodo (alcanzable)","published-port":"puerto publicado (opcional)","no-nodes":"sin nodos remotos configurados","node-add":"conectar una instalación NexusCrew","node-connect-help":"El puerto SSH conecta con el servidor SSH. El puerto NexusCrew es el puerto local indicado por `nexuscrew status` en el nodo remoto.","node-name-label":"Nombre del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH en este dispositivo","node-ssh-local-help":"Puedes sustituir la dirección del enlace por el mismo alias que funciona con ssh en este dispositivo. Los alias, agentes y claves permanecen locales y nunca viajan en el enlace.","node-ssh-port-label":"Puerto SSH","node-ssh-port-help":"Normalmente 22; usa el puerto público del servidor SSH.","node-app-port-label":"Puerto NexusCrew del nodo","node-app-port-help":"El puerto indicado por `nexuscrew status` en el nodo remoto.","node-name-ph":"nombre (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"puerto remoto (opc.)","node-remove-confirm":"¿Eliminar el nodo «{name}»?","node-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 Wu(){const e=Bv(),t=e?e.getItem(Av):null;return Kh.includes(t)?t:ja}function c0(e){const t=Bv();if(t)try{t.setItem(Av,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event($u))}function y(e){const t=Wu(),i=xa[t]||xa[ja];return Object.prototype.hasOwnProperty.call(i,e)?i[e]:Object.prototype.hasOwnProperty.call(xa[ja],e)?xa[ja][e]:e}function u0(e){return typeof window>"u"?()=>{}:(window.addEventListener($u,e),()=>window.removeEventListener($u,e))}const Iv=Kh;function Si(){return[P.useSyncExternalStore(u0,Wu,Wu),c0]}function Ha({cell:e,token:t,route:i=[],onConfirm:s,onClose:o}){var F,D;Si();const l=!!(e&&e.active),c=Array.isArray(i)?i.join("/"):"",[d,m]=P.useState([]),[p,S]=P.useState(!1);P.useEffect(()=>{let O=!0;return(async()=>{if(t)try{const z=await dr(t,c?c.split("/"):[]);if(!O)return;if(S(z.provider==="builtin"&&(z.capabilities||[]).includes("edit")),z.provider==="builtin"&&(z.capabilities||[]).includes("definitions")){const ie=await Hh(t,c?c.split("/"):[]);if(!O)return;const K=new Map((z.engines||[]).map(M=>[M.id,M]));m((ie.engines||[]).map(M=>{var W,oe,ae,se,le,ye,ce;return{id:M.id,label:M.label||M.id,client:((W=M.managed)==null?void 0:W.client)||"",models:[...new Set([...((oe=K.get(M.id))==null?void 0:oe.models)||[],...((ae=M.managedInfo)==null?void 0:ae.models)||[]])].filter(Boolean),defaultModel:((se=M.managed)==null?void 0:se.model)||((le=M.managedInfo)==null?void 0:le.defaultModel)||"",policyDefault:((ye=M.managed)==null?void 0:ye.permissionPolicy)||((ce=M.managed)!=null&&ce.client&&M.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{O=!1}},[t,c]);const C=(e==null?void 0:e.engine)||((F=d[0])==null?void 0:F.id)||"",_=O=>(e==null?void 0:e.models)&&e.models[O]||"",v=O=>{const z=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[O];if(z==="standard"||z==="unsafe")return z;const ie=d.find(K=>K.id===O);return ie?ie.policyDefault:"standard"},[w,b]=P.useState(C),[x,N]=P.useState((e==null?void 0:e.model)||""),L=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((D=e==null?void 0:e.permissionPolicies)==null?void 0:D[e==null?void 0:e.engine])||"",[j,T]=P.useState(L),[Q,H]=P.useState((e==null?void 0:e.boot)??!0),[I,G]=P.useState(!1),[U,q]=P.useState(null);P.useEffect(()=>{d.length&&(b(O=>O||C),N(O=>O||_((e==null?void 0:e.engine)||C)||""),T(O=>O==="standard"||O==="unsafe"?O:v((e==null?void 0:e.engine)||C)))},[d.length]);const X=P.useMemo(()=>d.find(O=>O.id===w)||null,[d,w]),A=!!(X&&["claude","codex","codex-vl"].includes(X.client));function E(O){b(O);const z=d.find(ie=>ie.id===O);N(_(O)||(z==null?void 0:z.defaultModel)||""),T(v(O))}async function R(O){O.preventDefault(),G(!0),q(null);try{if(l)await s({action:"down",boot:Q});else{const z=j==="standard"||j==="unsafe"?j:(X==null?void 0:X.policyDefault)||"standard";await s({action:"up",...p?{engine:w,model:x||"",...A?{permissionPolicy:z}:(X==null?void 0:X.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:Q})}o()}catch(z){q(String(z&&z.message||z)),G(!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:O=>O.stopPropagation(),onSubmit:R,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:y(l?"state-on":"state-off")})]}),l?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:y("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[y("model"),": ",e.model]}),h.jsx("small",{children:y("power-on-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:Q,onChange:O=>H(O.target.checked)}),y("remove-boot")]})]}):h.jsxs(h.Fragment,{children:[p&&d.length>0?h.jsxs("div",{className:"nc-launch-fields",children:[h.jsxs("label",{className:"nc-field",children:[y("engine"),h.jsx("select",{value:w,onChange:O=>E(O.target.value),children:d.map(O=>h.jsx("option",{value:O.id,children:O.label},O.id))})]}),h.jsxs("label",{className:"nc-field",children:[y("model"),h.jsx("input",{value:x,list:"nc-launch-models",placeholder:y("model-default"),onChange:O=>N(O.target.value)}),h.jsx("datalist",{id:"nc-launch-models",children:((X==null?void 0:X.models)||[]).map(O=>h.jsx("option",{value:O},O))})]}),A?h.jsxs("label",{className:"nc-field",children:[y("permissions"),h.jsxs("select",{value:j,onChange:O=>T(O.target.value),children:[h.jsx("option",{value:"standard",children:y("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:y("fleet-unsafe-permissions")})]})]}):h.jsx("small",{className:"nc-note",children:y("fleet-standard-permissions")}),A&&j==="unsafe"&&h.jsx("small",{className:"nc-err",children:y("fleet-unsafe-warning")}),h.jsx("small",{className:"nc-note",children:y("launch-engine-help")})]}):h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:y("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[y("model"),": ",e.model]}),h.jsx("small",{children:y("launch-external-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:Q,onChange:O=>H(O.target.checked)}),y("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:I,children:y("cancel")}),h.jsx("button",{type:"submit",className:"nc-btn primary",disabled:I,children:y(l?"power-off":"save-and-start")})]})]})})}const dm=/^[a-z0-9-]{1,32}$/;function $a(e,t){const i=Array.isArray(e)?e:[];return i.length?`${i.map(encodeURIComponent).join("/")}:${t}`:String(t)}function h0(e,t,i){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 c=l.join("/"),d=o.status==="up"||o.tunnel&&o.tunnel.status==="up",m=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!d&&!m&&(s[c]=e&&e[c]||i)}return s}function fm(e,t,i){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${i}:${s.tmuxSession||s.cell}`}))}function pm({nodes:e,topology:t,remote:i,down:s,fleet:o}={}){var m,p,S,C;const l=[],c=new Set,d=new Set;for(const _ of Array.isArray(e)?e:[]){if(!_||typeof _.name!="string"||!dm.test(_.name)||_.direction==="inbound"&&_.shared!==!0)continue;const v=[_.name],w=_.name;c.add(w);const b=((m=_.tunnel)==null?void 0:m.status)||"unknown",x=b==="up",N={name:_.name,label:_.label||_.name,route:v,direct:!0,instanceId:_.nodeId||null,shared:_.shared===!0,tunnelStatus:b,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({...N,status:"needs-repair",downSince:s&&s[w]||null});continue}if(((p=_.health)==null?void 0:p.auth)==="failed"||b==="degraded"&&((S=_.health)==null?void 0:S.status)==="degraded"){l.push({...N,status:"needs-repair",downSince:s&&s[w]||null});continue}if(b==="passive"||((C=_.health)==null?void 0:C.status)==="passive"){l.push({...N,status:"passive",downSince:null});continue}if(!x){l.push({...N,status:"down",downSince:s&&s[w]||null});continue}const L=i&&(i[w]||i[_.name])||null;if(!L||L.error||!Array.isArray(L.sessions)){l.push({...N,status:"unreachable"});continue}const j=L.sessions.filter(I=>I&&typeof I.name=="string"&&I.name).map(I=>({...I,node:w,route:v,key:`${w}:${I.name}`})),T=o&&(o[w]||o[_.name]),Q=fm(T,v,w),H=new Set(Q.map(I=>I.tmuxSession).filter(Boolean));l.push({...N,status:"up",sessions:j,cells:Q,unmanaged:j.filter(I=>!H.has(I.name)),fleetAvailable:!!(T&&T.available),capabilities:T&&T.capabilities||[],engines:T&&T.engines||[],fleetProvider:T&&T.provider||null})}for(const _ of Array.isArray(t)?t:[]){if(!_||!Array.isArray(_.route)||_.route.length<1||_.route.some(T=>!dm.test(T)))continue;const v=_.route.join("/");if(c.has(v)||_.instanceId&&d.has(_.instanceId))continue;_.instanceId&&d.add(_.instanceId);const w={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({...w,status:"offline",downSince:s&&s[v]||_.lastSeen||null});continue}const b=i&&i[v]||null;if(!b||b.error||!Array.isArray(b.sessions)){l.push({...w,status:"unreachable",downSince:s&&s[v]||null});continue}const x=b.sessions.filter(T=>T&&typeof T.name=="string"&&T.name).map(T=>({...T,node:v,route:_.route,key:`${v}:${T.name}`})),N=o&&o[v],L=fm(N,_.route,v),j=new Set(L.map(T=>T.tmuxSession).filter(Boolean));l.push({...w,status:"up",sessions:x,cells:L,unmanaged:x.filter(T=>!j.has(T.name)),fleetAvailable:!!(N&&N.available),capabilities:N&&N.capabilities||[],engines:N&&N.engines||[],fleetProvider:N&&N.provider||null,lastSeen:_.lastSeen||null})}return l.sort((_,v)=>_.label.localeCompare(v.label))}const d0=4e3;function qh(e,t=!0){const[i,s]=P.useState([]),o=P.useRef({});return P.useEffect(()=>{if(!t||!e){s([]);return}let l=!0;async function c(){var b;let m=[],p=[];if(await Promise.all([Pv(e).then(x=>{m=Array.isArray(x.nodes)?x.nodes:[]}).catch(()=>{}),Fw(e).then(x=>{p=Array.isArray(x.nodes)?x.nodes:[]}).catch(()=>{})]),!l)return;const S={},C={},_=new Set(m.map(x=>x.name)),v=[];for(const x of m)((b=x.tunnel)==null?void 0:b.status)==="up"&&(x.nodeId||x.paired!==!1)&&(x.direction!=="inbound"||x.shared===!0)&&v.push([x.name]);for(const x of p)!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 N=x.join("/");try{S[N]=await Dv(e,x)}catch{S[N]={error:"unreachable"}}try{C[N]=await dr(e,x)}catch{C[N]={available:!1}}})),!l)return;const w=pm({nodes:m,topology:p,remote:S,fleet:C,down:o.current});o.current=h0(o.current,w,Math.floor(Date.now()/1e3)),s(pm({nodes:m,topology:p,remote:S,fleet:C,down:o.current}))}c();const d=setInterval(c,d0);return()=>{l=!1,clearInterval(d)}},[e,t]),i}const mm=52,gm=14;function Ur({position:e,itemKey:t,label:i,onMove:s,onStep:o,canMove:l=()=>!0}){const c=P.useRef(null),d=P.useRef(0),[m,p]=P.useState(!1),S=()=>{var x,N,L,j;const b=c.current;(N=(x=b==null?void 0:b.over)==null?void 0:x.classList)==null||N.remove("nc-roster-over"),(j=(L=b==null?void 0:b.source)==null?void 0:L.classList)==null||j.remove("nc-roster-dragging"),d.current&&cancelAnimationFrame(d.current),d.current=0},C=(b=!1)=>{const x=c.current;if(!x)return;const N=x.target;S(),c.current=null,p(!1);try{x.handle.releasePointerCapture(x.pointerId)}catch{}b&&N&&N!==t&&l(t,N)&&s(t,N)},_=(b,x)=>{var Q,H,I,G,U,q,X,A;const N=c.current;if(!N)return;N.x=b,N.y=x;const L=(H=(Q=document.elementFromPoint(b,x))==null?void 0:Q.closest)==null?void 0:H.call(Q,"[data-roster-key][data-position]"),j=(I=L==null?void 0:L.dataset)==null?void 0:I.rosterKey,T=((G=L==null?void 0:L.dataset)==null?void 0:G.position)===e&&j&&j!==t&&l(t,j);N.over!==(T?L:null)&&((q=(U=N.over)==null?void 0:U.classList)==null||q.remove("nc-roster-over"),N.over=T?L:null,(A=(X=N.over)==null?void 0:X.classList)==null||A.add("nc-roster-over")),N.target=T?j:null},v=()=>{const b=c.current;if(!b){d.current=0;return}const x=b.container;if(x){const N=x.getBoundingClientRect(),L=b.y<N.top+mm?-gm:b.y>N.bottom-mm?gm:0;L&&(x.scrollTop+=L,_(b.x,b.y))}d.current=requestAnimationFrame(v)};P.useEffect(()=>{const b=N=>{N.key==="Escape"&&c.current&&(N.preventDefault(),C(!1))},x=()=>C(!1);return window.addEventListener("keydown",b),window.addEventListener("blur",x),()=>{window.removeEventListener("keydown",b),window.removeEventListener("blur",x),S(),c.current=null}},[t,e]);const w=b=>{var L;if(b.pointerType==="mouse"&&b.button!==0)return;b.preventDefault(),b.stopPropagation(),b.currentTarget.focus({preventScroll:!0});const x=b.currentTarget.closest("[data-roster-key][data-position]"),N=b.currentTarget.closest(".nc-side-scroll, .nc-home-scroll");c.current={pointerId:b.pointerId,handle:b.currentTarget,source:x,container:N,target:null,over:null,x:b.clientX,y:b.clientY},(L=x==null?void 0:x.classList)==null||L.add("nc-roster-dragging");try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}p(!0),d.current=requestAnimationFrame(v)};return h.jsx("button",{type:"button",className:`nc-roster-handle${m?" active":""}`,"aria-label":`${y("reorder")} ${i}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:y("reorder-help"),onClick:b=>{b.preventDefault(),b.stopPropagation()},onDragStart:b=>b.preventDefault(),onKeyDown:b=>{b.key!=="ArrowUp"&&b.key!=="ArrowDown"||(b.preventDefault(),b.stopPropagation(),o(b.key==="ArrowUp"?-1:1))},onPointerDown:w,onPointerMove:b=>{!c.current||b.pointerId!==c.current.pointerId||(b.preventDefault(),b.stopPropagation(),_(b.clientX,b.clientY))},onPointerUp:b=>{!c.current||b.pointerId!==c.current.pointerId||(b.preventDefault(),b.stopPropagation(),C(!0))},onPointerCancel:()=>C(!1),onLostPointerCapture:()=>{c.current&&C(!1)},children:"↕"})}const Vh="nc_pins";function f0(){try{const e=JSON.parse(localStorage.getItem(Vh));return Array.isArray(e)?e:[]}catch{return[]}}function p0(e,t){const i=e.includes(t)?e.filter(s=>s!==t):[...e,t];try{localStorage.setItem(Vh,JSON.stringify(i))}catch{}return i}function m0(e,t,i){if(!e.includes(t)||!e.includes(i)||t===i)return e;const s=[...e],o=s.indexOf(t),l=s.indexOf(i);s.splice(o,1);const c=s.indexOf(i);s.splice(o<l?c+1:c,0,t);try{localStorage.setItem(Vh,JSON.stringify(s))}catch{}return s}function g0(e,t,i){const s=e.indexOf(t);return[s===-1?1e9:s,-(i||0)]}function v0(e,t){return e[0]-t[0]||e[1]-t[1]}function Ov(){const[e,t]=P.useState(f0),[i,s]=P.useState(o0),[o,l]=P.useState(n0),c=_=>t(v=>p0(v,_)),d=_=>um(i,_),m=(_,v)=>s(w=>{const b={...w,[_]:{...um(w,_),...v}};return a0(b)}),p=(_,v)=>e.includes(_)===e.includes(v);function S(_,v,w,b){const x=e.includes(v),N=e.includes(w);if(x===N){if(x){t(L=>m0(L,v,w));return}l(L=>{var Q;const j=((Q=b.find(H=>H.key===v))==null?void 0:Q.technical)===!0,T=ar(b,e,j?"technical":"all",zn(L,_)).map(H=>H.key);return r0(s0(L,_,v,w,T))})}}function C(_,v,w,b){var Q;const x=((Q=b.find(H=>H.key===v))==null?void 0:Q.technical)===!0,N=e.includes(v),L=ar(b,e,x?"technical":"all",zn(o,_)).map(H=>H.key).filter(H=>e.includes(H)===N),j=L.indexOf(v),T=L[j+w];j>=0&&T&&S(_,v,T,b)}return{pins:e,views:i,orders:o,togglePin:c,viewFor:d,updateView:m,canMoveRoster:p,moveRoster:S,stepRoster:C}}function Gr(e,t=Math.floor(Date.now()/1e3)){if(!e)return"";const i=t-e;return i<0||i<60?"ora":i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}g`}function qr(e){return e.status==="passive"?y("node-passive"):e.status==="down"?e.downSince?y("tunnel-down-since").replace("{t}",Gr(e.downSince)):y("tunnel-down"):e.status==="unreachable"?y("node-unreachable"):e.status==="offline"?e.lastSeen?y("node-offline-seen").replace("{t}",Gr(e.lastSeen)):y("node-offline"):e.status==="needs-repair"?y("node-needs-repair"):""}function zv(e,{passive:t=null}={}){return e?e.status==="passive"?t:e.status==="healthy"?"on":"warn":null}function Wa(e){return e&&(e.detail||e.status)||""}function Ua(e,t,i=globalThis.localStorage){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const s=Number(i.getItem(xv(t))||0);return e.outbox.latest>s}function Fv(e,t={}){const i=e||{};if(!i.tmux){const s=`${i.engine||""}${i.key?`·${i.key}`:""}`,o=[s,i.model&&i.model!==s?i.model:""].filter(Boolean).join(" · ");return{working:!1,subtitle:String(o||y("cell-off")).trim()}}if(t.working===!0){const s=y("cell-working"),o=String(t.status||"").trim();return{working:!0,subtitle:!o||/^working(?:\.{3}|…)?$/i.test(o)?s:`${s} · ${o}`}}return t.working===!1?{working:!1,subtitle:y("cell-idle")}:{working:!1,subtitle:String(t.preview||i.preview||y("cell-on")).trim()}}function Hv(e,t){return[...new Set([e.engine,e.model,e.key,t.preview,e.preview,t.status].filter(Boolean).map(String))].join(" ")}function $v(e,t,i,s=globalThis.localStorage){return[...(Array.isArray(e)?e:[]).map(o=>{const l=i.get(o.tmuxSession)||{},c=$a([],o.tmuxSession),d=Fv(o,l);return{type:"cell",value:o,key:c,label:o.cell,live:!!o.tmux,fresh:Ua(l,c,s),activity:l.activity||0,working:d.working,subtitle:d.subtitle,searchText:Hv(o,l)}}),...(Array.isArray(t)?t:[]).map(o=>{const l=$a([],o.name);return{type:"session",value:o,key:l,label:o.name,live:!0,technical:o.technical===!0,fresh:Ua(o,l,s),activity:o.activity||0,searchText:`${o.preview||""} ${o.cmd||""}`}})]}function Wv(e,t=globalThis.localStorage){const i=e||{},s=Array.isArray(i.route)?i.route:[],o=new Map((i.sessions||[]).map(c=>[c.name,c])),l=[...(i.cells||[]).map(c=>{const d=o.get(c.tmuxSession)||{},m=$a(s,c.tmuxSession||c.cell),p=Fv(c,d);return{type:"cell",value:c,key:m,label:c.cell,live:!!c.tmux,fresh:Ua(d,m,t),activity:d.activity||c.activity||0,working:p.working,subtitle:p.subtitle,searchText:Hv(c,d)}}),...(i.unmanaged||[]).map(c=>{const d=$a(s,c.name);return{type:"session",value:c,key:d,label:c.name,live:!0,technical:c.technical===!0,fresh:Ua(c,d,t),activity:c.activity||0,searchText:`${c.preview||""} ${c.cmd||""}`}})];return{route:s,rawItems:l}}const Yh=9,Ka=.2,_0=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,Qr=/^[a-f0-9]{16,64}$/,Uu=e=>_0.test(e)&&new Set(e.split("/")).size===e.split("/").length;function Hn(e){if(typeof e=="string"&&e){const t=e.indexOf(":");if(t<0)return{session:e};const i=e.slice(0,t),s=e.slice(t+1);return!Uu(i)||!s?null:{session:s,node:i}}if(e&&typeof e=="object"&&typeof e.session=="string"&&e.session){const t=e.ownerId===void 0?void 0:typeof e.ownerId=="string"&&Qr.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"&&Uu(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function _i(e){const t=Hn(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const Uv=9,Kv=24,oo=11,y0=e=>{const t=Number(e);return t>=Uv&&t<=Kv?t:oo};function Vr(){return{columns:[]}}function Gi(e){return e.columns.flatMap(t=>t.tiles.map(i=>_i(i)))}function S0(e){const t=[],i=Math.max(0,...e.columns.map(s=>s.tiles.length));for(let s=0;s<i;s+=1)for(const o of e.columns)o.tiles[s]&&t.push(_i(o.tiles[s]));return t}const es=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))});function Xh(e,t,i,s){const o=Hn(t);if(!o||Gi(e).includes(_i(o))||Gi(e).length>=Yh)return e;const l=es(e),c={session:o.session,height:1,fontSize:oo,...s||{}};if(o.node&&(c.node=o.node),o.ownerId&&(c.ownerId=o.ownerId),i==="end")return l.columns.push({width:1,tiles:[c]}),l;if(i&&typeof i.col=="number"&&typeof i.row=="number"&&l.columns[i.col])return l.columns[i.col].tiles.splice(i.row,0,c),l;if(i&&typeof i.col=="number"){const d=Math.max(0,Math.min(l.columns.length,i.col));return l.columns.splice(d,0,{width:1,tiles:[c]}),l}return l.columns.push({width:1,tiles:[c]}),l}function qv(e,t){const i=_i(t);if(!i||Gi(e).includes(i)||Gi(e).length>=Yh)return e;const s=Gi(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let S=0;for(let C=1;C<e.columns.length;C+=1)e.columns[C].tiles.length<e.columns[S].tiles.length&&(S=C);return Xh(e,t,{col:S,row:e.columns[S].tiles.length})}const l=[...S0(e),i],c=new Map(e.columns.flatMap(S=>S.tiles.map(C=>[_i(C),C]))),d=Hn(t),m=e.columns.length?e.columns.reduce((S,C)=>S+(Number(C.width)||1),0)/e.columns.length:1,p=Array.from({length:o},(S,C)=>{var _;return{width:((_=e.columns[C])==null?void 0:_.width)||m,tiles:[]}});return l.forEach((S,C)=>{const _=Hn(S);if(!_)return;const v=c.get(S)||(S===i?d:{})||{},w={session:_.session,height:v.height||1,fontSize:v.fontSize||oo};_.node&&(w.node=_.node),v.ownerId&&(w.ownerId=v.ownerId),v.unavailable===!0&&(w.unavailable=!0),p[C%o].tiles.push(w)}),{columns:p.filter(S=>S.tiles.length)}}function qa(e,t){const i=_i(t),s=es(e);for(const o of s.columns)o.tiles=o.tiles.filter(l=>_i(l)!==i);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function w0(e,t,i){const s=_i(t);if(!Gi(e).includes(s))return e;const o=e.columns.flatMap(l=>l.tiles).find(l=>_i(l)===s);return Xh(qa(e,s),s,i,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function b0(e,t){if(!(t instanceof Map)||t.size===0)return e;let i=!1;const s=es(e);for(const o of s.columns)for(const l of o.tiles){const c=t.get(_i(l));if(!c)continue;const d=Hn(c);d&&(l.session=d.session,d.node?l.node=d.node:delete l.node,d.ownerId&&(l.ownerId=d.ownerId),i=!0)}return i?lr(s):e}function C0(e,t,i){const s=es(e);return s.columns[t]&&(s.columns[t].width=Math.max(Ka,Number(i)||1)),s}function x0(e,t,i,s){const o=es(e),l=o.columns[t]&&o.columns[t].tiles[i];return l&&(l.height=Math.max(Ka,Number(s)||1)),o}function k0(e,t,i,s){if(!(e.columns[t]&&e.columns[t].tiles[i]))return e;const l=es(e),c=l.columns[t].tiles[i],d=Number(c.fontSize)||oo;return c.fontSize=Math.max(Uv,Math.min(Kv,d+(Number(s)||0))),l}function E0(e,t,i,s){const o=e.columns[t];if(!o||!o.tiles[i])return null;switch(s){case"left":return{col:t};case"right":return{col:t+1};case"top":return{col:t,row:i};case"bottom":return{col:t,row:i+1};default:return null}}function vm(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function lr(e){if(!e||!Array.isArray(e.columns))return Vr();const t=e.columns.map(s=>({width:Math.max(Ka,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"&&Uu(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&Qr.test(o.ownerId)).map(o=>{const l={session:o.session,height:Math.max(Ka,Number(o.height)||1),fontSize:y0(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),i=new Set;for(const s of t)s.tiles=s.tiles.filter(o=>!i.has(_i(o))&&i.add(_i(o))&&i.size<=Yh);return{columns:t.filter(s=>s.tiles.length>0)}}function N0({onPick:e,token:t,onSettings:i}){const[s,o]=Si(),l=qh(t),[c,d]=P.useState(null),[m,p]=P.useState(null),[S,C]=P.useState(""),[_,v]=P.useState(""),[w,b]=P.useState({bind:"127.0.0.1",port:""}),[x,N]=P.useState(""),[L,j]=P.useState([]),[T,Q]=P.useState(null),[H,I]=P.useState(null),{pins:G,orders:U,togglePin:q,viewFor:X,updateView:A,canMoveRoster:E,moveRoster:R,stepRoster:F}=Ov();async function D(){try{const Ce=await(await zt("/api/sessions",t)).json();Ce.error?(p(Ce.error),d([])):(p(null),d(Ce.sessions||[]))}catch(Z){p(String(Z)),d([])}try{const Z=await dr(t);j(Z.available?Z.cells||[]:[])}catch{j([])}}P.useEffect(()=>{D(),zt("/api/config",t).then(Ce=>Ce.json()).then(Ce=>{v(Ce.version||""),b({bind:Ce.bind||"127.0.0.1",port:Ce.port||""}),N(Qr.test(String(Ce.instanceId||""))?Ce.instanceId:"")}).catch(()=>{});const Z=setInterval(D,4e3);return()=>clearInterval(Z)},[]);async function O(){if(!w.port)return;const Z=`http://${w.bind}:${w.port}/#token=${t}`;try{await navigator.clipboard.writeText(Z)}catch{}}async function z(Z){if(!T)return;const{cell:Ce}=T,Pe=Array.isArray(T.route)?T.route:[];Z.action==="up"?await Fh(t,{cell:Ce,boot:!!Z.boot,...Z.engine?{engine:Z.engine}:{},...Z.model!==void 0?{model:Z.model}:{},...Z.permissionPolicy?{permissionPolicy:Z.permissionPolicy}:{}},Pe):await Fa(t,{cell:Ce,boot:!!Z.boot},Pe),D()}async function ie(Z,Ce=[]){try{await $h(t,Z,Ce)}catch{return}D()}async function K(Z,Ce,Pe=[]){try{await Ev(t,Z,Ce,Pe)}catch{return}D()}async function M(Z){if(!(!(Z!=null&&Z.direct)||H)){I(Z.name);try{await Uh(t,Z.name,Z.tunnelStatus==="up"?"down":"up")}catch{}I(null)}}const W=P.useMemo(()=>new Map((c||[]).map(Z=>[Z.name,Z])),[c]),oe=P.useMemo(()=>new Set(L.map(Z=>Z.tmuxSession)),[L]),ae=P.useMemo(()=>(c||[]).filter(Z=>!oe.has(Z.name)),[c,oe]),se=P.useMemo(()=>$v(L,ae,W),[L,ae,W]),le=X("local"),ye=P.useMemo(()=>ar(se,G,le.filter,zn(U,"local")).filter(Z=>hm(Z,S)),[se,G,le.filter,S,U]),ce=l.reduce((Z,Ce)=>Z+(Ce.cells||[]).length+(Ce.unmanaged||[]).filter(Pe=>!Pe.technical).length,0),Y=ar(se,G,"all",zn(U,"local")).length+ce,ne=c?c.length:0,Te=(c||[]).filter(Z=>Z.attached).length,De=w.port?`${w.bind}:${w.port}`:w.bind;function ge(Z,Ce=null,Pe=se){var gt,ve;const Ne=Array.isArray(Ce==null?void 0:Ce.route)?Ce.route:[],qe=Ne.join("/"),ee=qe||"local",_e=Ne.length?Ce==null?void 0:Ce.instanceId:x,Be=be=>e({session:be,...qe?{node:qe}:{},...Qr.test(String(_e||""))?{ownerId:_e}:{}}),Ie=E;if(Z.type==="cell"){const be=Z.value,Ee=Ne.length?((Ce==null?void 0:Ce.sessions)||[]).find(We=>We.name===be.tmuxSession):W.get(be.tmuxSession),Ye=be.degraded?y("cell-degraded"):Z.working?Z.subtitle:be.tmux?y("cell-idle"):y("cell-off"),rt=Ne.length===0||((Ce==null?void 0:Ce.capabilities)||[]).includes(be.active?"down":"up");return h.jsxs("div",{className:"nc-mcard","data-roster-key":Z.key,"data-position":ee,children:[h.jsx(Ur,{position:ee,itemKey:Z.key,label:be.cell,canMove:Ie,onMove:(We,fe)=>R(ee,We,fe,Pe),onStep:We=>F(ee,Z.key,We,Pe)}),h.jsxs("button",{className:"nc-mcard-main",onClick:()=>be.tmux&&Be(be.tmuxSession),title:Ye,"aria-label":`${be.cell}, ${Ye}`,children:[h.jsx("span",{className:`dot ${be.degraded?"warn":be.tmux?`on${Z.working?" working":""}`:""}`}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:be.cell}),h.jsx("small",{title:Z.subtitle,children:Z.subtitle})]})]}),Z.activity?h.jsx("span",{className:"nc-rel",children:Gr(Z.activity)}):null,Z.fresh&&((gt=Ee==null?void 0:Ee.outbox)==null?void 0:gt.count)>0&&h.jsx("span",{className:"nc-badge",title:y("new-files-outbox"),children:Ee.outbox.count}),h.jsx("button",{className:`nc-act pin${G.includes(Z.key)?" on":""}`,"aria-label":`${y("pin")} ${be.cell}`,title:y("pin"),onClick:()=>q(Z.key),children:G.includes(Z.key)?"★":"☆"}),rt&&h.jsx("button",{className:`nc-act power${be.tmux?" on":""}${be.degraded?" warn":""}`,onClick:()=>Q(Ne.length?{...be,route:Ne,availableEngines:(Ce==null?void 0:Ce.engines)||[]}:be),title:be.active?y("power-off"):y("power-on"),"aria-label":`${be.active?y("power-off"):y("power-on")} ${be.cell}`,children:h.jsx(et,{name:"power",size:16})})]},Z.key)}const Fe=Z.value;return h.jsxs("div",{className:"nc-mcard","data-roster-key":Z.key,"data-position":ee,children:[h.jsx(Ur,{position:ee,itemKey:Z.key,label:Fe.name,canMove:Ie,onMove:(be,Ee)=>R(ee,be,Ee,Pe),onStep:be=>F(ee,Z.key,be,Pe)}),h.jsxs("button",{className:"nc-mcard-main",onClick:()=>Be(Fe.name),children:[h.jsx("span",{className:Fe.attached?"dot on":"dot"}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:Fe.name}),h.jsx("small",{children:Fe.preview?Fe.preview:Fe.cmd?Fe.cmd:y("windows").replace("{n}",String(Fe.windows||0))})]})]}),Z.activity?h.jsx("span",{className:"nc-rel",children:Gr(Z.activity)}):null,Z.fresh&&((ve=Fe.outbox)==null?void 0:ve.count)>0&&h.jsx("span",{className:"nc-badge",title:y("new-files-outbox"),children:Fe.outbox.count}),h.jsx("button",{className:`nc-act pin${G.includes(Z.key)?" on":""}`,"aria-label":`${y("pin")} ${Fe.name}`,title:y("pin"),onClick:()=>q(Z.key),children:G.includes(Z.key)?"★":"☆"}),h.jsx("button",{className:`nc-act technical${Fe.technical?" on":""}`,title:Fe.technical?y("mark-normal"):y("mark-technical"),"aria-label":`${Fe.technical?y("mark-normal"):y("mark-technical")} ${Fe.name}`,onClick:()=>K(Fe.name,!Fe.technical,Ne),children:"T"}),h.jsx("button",{className:"nc-menu",title:y("terminate"),"aria-label":`${y("terminate")} ${Fe.name}`,onClick:()=>{window.confirm(y("terminate-confirm").replace("{name}",Fe.name))&&ie(Fe.name,Ne)},children:"⋯"})]},Z.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:[y("fleet-tmux")," · ",ne," ",y("sessions"),Te>0&&` · ${Te} attached`]}),h.jsxs("span",{className:"nc-head-actions",children:[h.jsx("button",{className:"nc-refresh",onClick:()=>i("nodes",!1),title:y("settings"),children:h.jsx(et,{name:"gear",size:18})}),h.jsx("button",{className:"nc-refresh",onClick:D,title:y("refresh"),children:h.jsx(et,{name:"refresh",size:18})})]})]}),h.jsxs("main",{className:"nc-home-scroll",children:[Y>8&&h.jsx("input",{className:"nc-filter",type:"search",placeholder:y("filter-placeholder"),"aria-label":y("filter-placeholder"),value:S,onChange:Z=>C(Z.target.value)}),m&&h.jsx("div",{className:"nc-err",children:m}),h.jsxs("section",{className:"nc-group","data-position":"local",children:[h.jsx(_m,{label:y("position-local"),count:ye.length,state:le,dotClass:"on",onToggle:()=>A("local",{open:!le.open}),onFilter:Z=>A("local",{filter:Z})}),le.open&&ye.map(Z=>ge(Z,null,se)),le.open&&c===null&&h.jsx("div",{className:"nc-empty",children:y("loading-fleet")}),le.open&&c!==null&&ye.length===0&&!m&&h.jsx("div",{className:"nc-empty",children:S?y("no-match").replace("{q}",S):y("no-sessions-short")})]}),l.map(Z=>{const Pe=zv(Z.health,{passive:"warn"})||(Z.status==="up"?"on":Z.status==="passive"?"":"warn"),Ne=Z.health?Wa(Z.health):Z.status==="up"?"":qr(Z),ee=(Z.route||[Z.name]).join("/"),_e=X(ee),{rawItems:Be}=Wv(Z),Ie=ar(Be,G,_e.filter,zn(U,ee)).filter(gt=>hm(gt,S)),Fe=Z.direct&&Z.health&&Z.health.managed!==!1?h.jsx("button",{type:"button",className:`nc-act power${Z.tunnelStatus==="up"?" on":""}`,disabled:H===Z.name,title:Z.tunnelStatus==="up"?y("power-off"):y("power-on"),"aria-label":`${Z.tunnelStatus==="up"?y("power-off"):y("power-on")} ${Z.label||Z.name}`,onClick:()=>M(Z),children:h.jsx(et,{name:"power",size:15})}):null;return h.jsxs("section",{className:"nc-group","data-position":ee,children:[h.jsx(_m,{label:Z.label||Z.name,count:Ie.length,state:_e,dotClass:Pe,dotTitle:Ne,detail:Z.status==="up"?"":Z.health&&Wa(Z.health)||qr(Z),onToggle:()=>A(ee,{open:!_e.open}),onFilter:gt=>A(ee,{filter:gt}),action:Fe}),Z.status==="up"&&_e.open&&Ie.map(gt=>ge(gt,Z,Be)),Z.status==="up"&&_e.open&&Ie.length===0&&h.jsx("div",{className:"nc-empty",children:S?y("no-match").replace("{q}",S):y("no-sessions-short")})]},`nodo-${ee}`)}),h.jsxs("footer",{className:"nc-home-foot",onClick:O,title:y("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:[De," · ",y("ssh-only")]})]}),h.jsx("span",{className:"nc-lang",onClick:Z=>Z.stopPropagation(),children:Iv.map((Z,Ce)=>h.jsxs("span",{children:[Ce>0&&" · ",h.jsx("button",{className:`nc-lang-btn${s===Z?" on":""}`,onClick:()=>o(Z),title:Z,children:Z.toUpperCase()})]},Z))})]})]}),h.jsx("button",{className:"nc-fab",onClick:()=>i("fleet",!0),title:y("fleet-new-cell"),"aria-label":y("fleet-new-cell"),children:"+"}),T&&h.jsx(Ha,{cell:T,token:t,route:Array.isArray(T.route)?T.route:[],onConfirm:z,onClose:()=>Q(null)})]})}function _m({label:e,count:t,state:i,dotClass:s="",dotTitle:o="",detail:l="",onToggle:c,onFilter:d,action:m=null}){return h.jsxs("div",{className:"nc-mobile-position-head",children:[h.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:c,"aria-expanded":i.open,"aria-label":`${e} · ${y("node-sessions").replace("{n}",String(t))}`,children:[h.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:i.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||y("node-sessions").replace("{n}",String(t))})]})]}),h.jsxs("select",{className:"nc-mobile-position-filter",value:i.filter,"aria-label":`${e} · ${y("filter-placeholder")}`,title:y(`view-${i.filter}`),onChange:p=>d(p.target.value),children:[h.jsx("option",{value:"all",children:y("view-all")}),h.jsx("option",{value:"pinned",children:y("view-pinned")}),h.jsx("option",{value:"active",children:y("view-active")}),h.jsx("option",{value:"off",children:y("view-off")}),h.jsx("option",{value:"technical",children:y("view-technical")})]}),m]})}/**
|
|
41
41
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
42
42
|
* @license MIT
|
|
43
43
|
*
|
|
@@ -48,21 +48,21 @@ Error generating stack: `+g.message+`
|
|
|
48
48
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
49
49
|
* http://bellard.org/jslinux/
|
|
50
50
|
* Copyright (c) 2011 Fabrice Bellard
|
|
51
|
-
*/var
|
|
51
|
+
*/var Vv=Object.defineProperty,R0=Object.getOwnPropertyDescriptor,P0=(e,t)=>{for(var i in t)Vv(e,i,{get:t[i],enumerable:!0})},yt=(e,t,i,s)=>{for(var o=s>1?void 0:s?R0(t,i):t,l=e.length-1,c;l>=0;l--)(c=e[l])&&(o=(s?c(t,i,o):c(o))||o);return s&&o&&Vv(t,i,o),o},xe=(e,t)=>(i,s)=>t(i,s,e),ym="Terminal input",Ku={get:()=>ym,set:e=>ym=e},Sm="Too much output to announce, navigate to rows manually to read",qu={get:()=>Sm,set:e=>Sm=e};function D0(e){return e.replace(/\r?\n/g,"\r")}function M0(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function L0(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function j0(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");Yv(o,t,i,s)}}function Yv(e,t,i,s){e=D0(e),e=M0(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function Xv(e,t,i){let s=i.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 wm(e,t,i,s,o){Xv(e,t,i),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function In(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function il(e,t=0,i=e.length){let s="";for(let o=t;o<i;++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 T0=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,o=0;if(this._interim){let 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<i;++l){let c=e.charCodeAt(l);if(55296<=c&&c<=56319){if(++l>=i)return this._interim=c,s;let d=e.charCodeAt(l);56320<=d&&d<=57343?t[s++]=(c-55296)*1024+d-56320+65536:(t[s++]=c,t[s++]=d);continue}c!==65279&&(t[s++]=c)}return s}},A0=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,o,l,c,d,m=0,p=0;if(this.interim[0]){let _=!1,v=this.interim[0];v&=(v&224)===192?31:(v&240)===224?15:7;let w=0,b;for(;(b=this.interim[++w]&63)&&w<4;)v<<=6,v|=b;let x=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,N=x-w;for(;p<N;){if(p>=i)return 0;if(b=e[p++],(b&192)!==128){p--,_=!0;break}else this.interim[w++]=b,v<<=6,v|=b&63}_||(x===2?v<128?p--: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 S=i-4,C=p;for(;C<i;){for(;C<S&&!((o=e[C])&128)&&!((l=e[C+1])&128)&&!((c=e[C+2])&128)&&!((d=e[C+3])&128);)t[s++]=o,t[s++]=l,t[s++]=c,t[s++]=d,C+=4;if(o=e[C++],o<128)t[s++]=o;else if((o&224)===192){if(C>=i)return this.interim[0]=o,s;if(l=e[C++],(l&192)!==128){C--;continue}if(m=(o&31)<<6|l&63,m<128){C--;continue}t[s++]=m}else if((o&240)===224){if(C>=i)return this.interim[0]=o,s;if(l=e[C++],(l&192)!==128){C--;continue}if(C>=i)return this.interim[0]=o,this.interim[1]=l,s;if(c=e[C++],(c&192)!==128){C--;continue}if(m=(o&15)<<12|(l&63)<<6|c&63,m<2048||m>=55296&&m<=57343||m===65279)continue;t[s++]=m}else if((o&248)===240){if(C>=i)return this.interim[0]=o,s;if(l=e[C++],(l&192)!==128){C--;continue}if(C>=i)return this.interim[0]=o,this.interim[1]=l,s;if(c=e[C++],(c&192)!==128){C--;continue}if(C>=i)return this.interim[0]=o,this.interim[1]=l,this.interim[2]=c,s;if(d=e[C++],(d&192)!==128){C--;continue}if(m=(o&7)<<18|(l&63)<<12|(c&63)<<6|d&63,m<65536||m>1114111)continue;t[s++]=m}}return s}},Gv="",On=" ",ao=class Qv{constructor(){this.fg=0,this.bg=0,this.extended=new Va}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 Qv;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}},Va=class Jv{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Jv(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Di=class Zv extends ao{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Va,this.combinedData=""}static fromCharData(t){let i=new Zv;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?In(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(s-55296)*1024+o-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},bm="di$target",Vu="di$dependencies",eu=new Map;function B0(e){return e[Vu]||[]}function Ft(e){if(eu.has(e))return eu.get(e);let t=function(i,s,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");I0(t,i,o)};return t._id=e,eu.set(e,t),t}function I0(e,t,i){t[bm]===t?t[Vu].push({id:e,index:i}):(t[Vu]=[{id:e,index:i}],t[bm]=t)}var ei=Ft("BufferService"),e_=Ft("CoreMouseService"),fr=Ft("CoreService"),O0=Ft("CharsetService"),Gh=Ft("InstantiationService"),t_=Ft("LogService"),ti=Ft("OptionsService"),i_=Ft("OscLinkService"),z0=Ft("UnicodeService"),lo=Ft("DecorationService"),Yu=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var S;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,l=new Di,c=i.getTrimmedLength(),d=-1,m=-1,p=!1;for(let C=0;C<c;C++)if(!(m===-1&&!i.hasContent(C))){if(i.loadCell(C,l),l.hasExtendedAttrs()&&l.extended.urlId)if(m===-1){m=C,d=l.extended.urlId;continue}else p=l.extended.urlId!==d;else m!==-1&&(p=!0);if(p||m!==-1&&C===c-1){let _=(S=this._oscLinkService.getLinkData(d))==null?void 0:S.uri;if(_){let v={start:{x:m+1,y:e},end:{x:C+(!p&&C===c-1?1:0),y:e}},w=!1;if(!(o!=null&&o.allowNonHttpProtocols))try{let b=new URL(_);["http:","https:"].includes(b.protocol)||(w=!0)}catch{w=!0}w||s.push({text:_,range:v,activate:(b,x)=>o?o.activate(b,x,v):F0(b,x),hover:(b,x)=>{var N;return(N=o==null?void 0:o.hover)==null?void 0:N.call(o,b,x,v)},leave:(b,x)=>{var N;return(N=o==null?void 0:o.leave)==null?void 0:N.call(o,b,x,v)}})}p=!1,l.hasExtendedAttrs()&&l.extended.urlId?(m=C,d=l.extended.urlId):(m=-1,d=-1)}}t(s)}};Yu=yt([xe(0,ei),xe(1,ti),xe(2,i_)],Yu);function F0(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
52
52
|
|
|
53
|
-
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var nl=Ft("CharSizeService"),dn=Ft("CoreBrowserService"),Qh=Ft("MouseService"),fn=Ft("RenderService"),
|
|
53
|
+
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var nl=Ft("CharSizeService"),dn=Ft("CoreBrowserService"),Qh=Ft("MouseService"),fn=Ft("RenderService"),H0=Ft("SelectionService"),n_=Ft("CharacterJoinerService"),ts=Ft("ThemeService"),r_=Ft("LinkProviderService"),$0=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Cm.isErrorNoTelemetry(e)?new Cm(e.message+`
|
|
54
54
|
|
|
55
55
|
`+e.stack):new Error(e.message+`
|
|
56
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)}},H0=new F0;function Ta(e){$0(e)||H0.onUnexpectedError(e)}var Xu="Canceled";function $0(e){return e instanceof W0?!0:e instanceof Error&&e.name===Xu&&e.message===Xu}var W0=class extends Error{constructor(){super(Xu),this.name=this.message}};function U0(e){return new Error(`Illegal argument: ${e}`)}var Cm=class Gu extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Gu)return t;let i=new Gu;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Qu=class n_ extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,n_.prototype)}};function gi(e,t=0){return e[e.length-(1+t)]}var K0;(e=>{function t(l){return l<0}e.isLessThan=t;function i(l){return l<=0}e.isLessThanOrEqual=i;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})(K0||(K0={}));function q0(e,t){let i=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(i,arguments))),o}}var r_;(e=>{function t(T){return T&&typeof T=="object"&&typeof T[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*o(T){yield T}e.single=o;function l(T){return t(T)?T:o(T)}e.wrap=l;function c(T){return T||i}e.from=c;function*d(T){for(let Q=T.length-1;Q>=0;Q--)yield T[Q]}e.reverse=d;function m(T){return!T||T[Symbol.iterator]().next().done===!0}e.isEmpty=m;function p(T){return T[Symbol.iterator]().next().value}e.first=p;function S(T,Q){let H=0;for(let I of T)if(Q(I,H++))return!0;return!1}e.some=S;function C(T,Q){for(let H of T)if(Q(H))return H}e.find=C;function*_(T,Q){for(let H of T)Q(H)&&(yield H)}e.filter=_;function*v(T,Q){let H=0;for(let I of T)yield Q(I,H++)}e.map=v;function*w(T,Q){let H=0;for(let I of T)yield*Q(I,H++)}e.flatMap=w;function*b(...T){for(let Q of T)yield*Q}e.concat=b;function x(T,Q,H){let I=H;for(let G of T)I=Q(I,G);return I}e.reduce=x;function*N(T,Q,H=T.length){for(Q<0&&(Q+=T.length),H<0?H+=T.length:H>T.length&&(H=T.length);Q<H;Q++)yield T[Q]}e.slice=N;function L(T,Q=Number.POSITIVE_INFINITY){let H=[];if(Q===0)return[H,T];let I=T[Symbol.iterator]();for(let G=0;G<Q;G++){let U=I.next();if(U.done)return[H,e.empty()];H.push(U.value)}return[H,{[Symbol.iterator](){return I}}]}e.consume=L;async function j(T){let Q=[];for await(let H of T)Q.push(H);return Promise.resolve(Q)}e.asyncToArray=j})(r_||(r_={}));function ur(e){if(r_.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function V0(...e){return ht(()=>ur(e))}function ht(e){return{dispose:q0(()=>{e()})}}var s_=class o_{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{ur(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?o_.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)}};s_.DISABLE_DISPOSED_WARNING=!1;var Fn=s_,Qe=class{constructor(){this._store=new Fn,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Qe.None=Object.freeze({dispose(){}});var Jr=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}},hn=typeof window=="object"?window:globalThis,Ju=class Zu{constructor(t){this.element=t,this.next=Zu.Undefined,this.prev=Zu.Undefined}};Ju.Undefined=new Ju(void 0);var pt=Ju,xm=class{constructor(){this._first=pt.Undefined,this._last=pt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===pt.Undefined}clear(){let e=this._first;for(;e!==pt.Undefined;){let t=e.next;e.prev=pt.Undefined,e.next=pt.Undefined,e=t}this._first=pt.Undefined,this._last=pt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new pt(e);if(this._first===pt.Undefined)this._first=i,this._last=i;else if(t){let o=this._last;this._last=i,i.prev=o,o.next=i}else{let o=this._first;this._first=i,i.next=o,o.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==pt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==pt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==pt.Undefined&&e.next!==pt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===pt.Undefined&&e.next===pt.Undefined?(this._first=pt.Undefined,this._last=pt.Undefined):e.next===pt.Undefined?(this._last=this._last.prev,this._last.next=pt.Undefined):e.prev===pt.Undefined&&(this._first=this._first.next,this._first.prev=pt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==pt.Undefined;)yield e.element,e=e.next}},Y0=globalThis.performance&&typeof globalThis.performance.now=="function",X0=class a_{static create(t){return new a_(t)}constructor(t){this._now=Y0&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Ut;(e=>{e.None=()=>Qe.None;function t(A,E){return C(A,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function i(A){return(E,R=null,F)=>{let D=!1,O;return O=A(z=>{if(!D)return O?O.dispose():D=!0,E.call(R,z)},null,F),D&&O.dispose(),O}}e.once=i;function s(A,E,R){return p((F,D=null,O)=>A(z=>F.call(D,E(z)),null,O),R)}e.map=s;function o(A,E,R){return p((F,D=null,O)=>A(z=>{E(z),F.call(D,z)},null,O),R)}e.forEach=o;function l(A,E,R){return p((F,D=null,O)=>A(z=>E(z)&&F.call(D,z),null,O),R)}e.filter=l;function c(A){return A}e.signal=c;function d(...A){return(E,R=null,F)=>{let D=V0(...A.map(O=>O(z=>E.call(R,z))));return S(D,F)}}e.any=d;function m(A,E,R,F){let D=R;return s(A,O=>(D=E(D,O),D),F)}e.reduce=m;function p(A,E){let R,F={onWillAddFirstListener(){R=A(D.fire,D)},onDidRemoveLastListener(){R==null||R.dispose()}},D=new we(F);return E==null||E.add(D),D.event}function S(A,E){return E instanceof Array?E.push(A):E&&E.add(A),A}function C(A,E,R=100,F=!1,D=!1,O,z){let ne,K,M,W=0,oe,ae={leakWarningThreshold:O,onWillAddFirstListener(){ne=A(le=>{W++,K=E(K,le),F&&!M&&(se.fire(K),K=void 0),oe=()=>{let _e=K;K=void 0,M=void 0,(!F||W>1)&&se.fire(_e),W=0},typeof R=="number"?(clearTimeout(M),M=setTimeout(oe,R)):M===void 0&&(M=0,queueMicrotask(oe))})},onWillRemoveListener(){D&&W>0&&(oe==null||oe())},onDidRemoveLastListener(){oe=void 0,ne.dispose()}},se=new we(ae);return z==null||z.add(se),se.event}e.debounce=C;function _(A,E=0,R){return e.debounce(A,(F,D)=>F?(F.push(D),F):[D],E,void 0,!0,void 0,R)}e.accumulate=_;function v(A,E=(F,D)=>F===D,R){let F=!0,D;return l(A,O=>{let z=F||!E(O,D);return F=!1,D=O,z},R)}e.latch=v;function w(A,E,R){return[e.filter(A,E,R),e.filter(A,F=>!E(F),R)]}e.split=w;function b(A,E=!1,R=[],F){let D=R.slice(),O=A(K=>{D?D.push(K):ne.fire(K)});F&&F.add(O);let z=()=>{D==null||D.forEach(K=>ne.fire(K)),D=null},ne=new we({onWillAddFirstListener(){O||(O=A(K=>ne.fire(K)),F&&F.add(O))},onDidAddFirstListener(){D&&(E?setTimeout(z):z())},onDidRemoveLastListener(){O&&O.dispose(),O=null}});return F&&F.add(ne),ne.event}e.buffer=b;function x(A,E){return(R,F,D)=>{let O=E(new L);return A(function(z){let ne=O.evaluate(z);ne!==N&&R.call(F,ne)},void 0,D)}}e.chain=x;let N=Symbol("HaltChainable");class L{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(R=>(E(R),R)),this}filter(E){return this.steps.push(R=>E(R)?R:N),this}reduce(E,R){let F=R;return this.steps.push(D=>(F=E(F,D),F)),this}latch(E=(R,F)=>R===F){let R=!0,F;return this.steps.push(D=>{let O=R||!E(D,F);return R=!1,F=D,O?D:N}),this}evaluate(E){for(let R of this.steps)if(E=R(E),E===N)break;return E}}function j(A,E,R=F=>F){let F=(...ne)=>z.fire(R(...ne)),D=()=>A.on(E,F),O=()=>A.removeListener(E,F),z=new we({onWillAddFirstListener:D,onDidRemoveLastListener:O});return z.event}e.fromNodeEventEmitter=j;function T(A,E,R=F=>F){let F=(...ne)=>z.fire(R(...ne)),D=()=>A.addEventListener(E,F),O=()=>A.removeEventListener(E,F),z=new we({onWillAddFirstListener:D,onDidRemoveLastListener:O});return z.event}e.fromDOMEventEmitter=T;function Q(A){return new Promise(E=>i(A)(E))}e.toPromise=Q;function H(A){let E=new we;return A.then(R=>{E.fire(R)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=H;function I(A,E){return A(R=>E.fire(R))}e.forward=I;function G(A,E,R){return E(R),A(F=>E(F))}e.runAndSubscribe=G;class U{constructor(E,R){this._observable=E,this._counter=0,this._hasChanged=!1;let F={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new we(F),R&&R.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,R){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 q(A,E){return new U(A,E).emitter.event}e.fromObservable=q;function Y(A){return(E,R,F)=>{let D=0,O=!1,z={beginUpdate(){D++},endUpdate(){D--,D===0&&(A.reportChanges(),O&&(O=!1,E.call(R)))},handlePossibleChange(){},handleChange(){O=!0}};A.addObserver(z),A.reportChanges();let ne={dispose(){A.removeObserver(z)}};return F instanceof Fn?F.add(ne):Array.isArray(F)&&F.push(ne),ne}}e.fromObservableLight=Y})(Ut||(Ut={}));var eh=class th{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${th._idPool++}`,th.all.add(this)}start(t){this._stopWatch=new X0,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}}};eh.all=new Set,eh._idPool=0;var G0=eh,Q0=-1,l_=class c_{constructor(t,i,s=(c_._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[l,c]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${c}):`;console.warn(d),console.warn(l);let m=new eb(d,l);this._errorHandler(m)}return()=>{let l=this._stacks.get(t.value)||0;this._stacks.set(t.value,l-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,o]of this._stacks)(!t||i<o)&&(t=[s,o],i=o);return t}};l_._idPool=1;var J0=l_,Z0=class u_{constructor(t){this.value=t}static create(){let t=new Error;return new u_(t.stack??"")}print(){console.warn(this.value.split(`
|
|
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)}},W0=new $0;function Ta(e){U0(e)||W0.onUnexpectedError(e)}var Xu="Canceled";function U0(e){return e instanceof K0?!0:e instanceof Error&&e.name===Xu&&e.message===Xu}var K0=class extends Error{constructor(){super(Xu),this.name=this.message}};function q0(e){return new Error(`Illegal argument: ${e}`)}var Cm=class Gu extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Gu)return t;let i=new Gu;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Qu=class s_ extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,s_.prototype)}};function gi(e,t=0){return e[e.length-(1+t)]}var V0;(e=>{function t(l){return l<0}e.isLessThan=t;function i(l){return l<=0}e.isLessThanOrEqual=i;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})(V0||(V0={}));function Y0(e,t){let i=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(i,arguments))),o}}var o_;(e=>{function t(T){return T&&typeof T=="object"&&typeof T[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*o(T){yield T}e.single=o;function l(T){return t(T)?T:o(T)}e.wrap=l;function c(T){return T||i}e.from=c;function*d(T){for(let Q=T.length-1;Q>=0;Q--)yield T[Q]}e.reverse=d;function m(T){return!T||T[Symbol.iterator]().next().done===!0}e.isEmpty=m;function p(T){return T[Symbol.iterator]().next().value}e.first=p;function S(T,Q){let H=0;for(let I of T)if(Q(I,H++))return!0;return!1}e.some=S;function C(T,Q){for(let H of T)if(Q(H))return H}e.find=C;function*_(T,Q){for(let H of T)Q(H)&&(yield H)}e.filter=_;function*v(T,Q){let H=0;for(let I of T)yield Q(I,H++)}e.map=v;function*w(T,Q){let H=0;for(let I of T)yield*Q(I,H++)}e.flatMap=w;function*b(...T){for(let Q of T)yield*Q}e.concat=b;function x(T,Q,H){let I=H;for(let G of T)I=Q(I,G);return I}e.reduce=x;function*N(T,Q,H=T.length){for(Q<0&&(Q+=T.length),H<0?H+=T.length:H>T.length&&(H=T.length);Q<H;Q++)yield T[Q]}e.slice=N;function L(T,Q=Number.POSITIVE_INFINITY){let H=[];if(Q===0)return[H,T];let I=T[Symbol.iterator]();for(let G=0;G<Q;G++){let U=I.next();if(U.done)return[H,e.empty()];H.push(U.value)}return[H,{[Symbol.iterator](){return I}}]}e.consume=L;async function j(T){let Q=[];for await(let H of T)Q.push(H);return Promise.resolve(Q)}e.asyncToArray=j})(o_||(o_={}));function ur(e){if(o_.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function X0(...e){return ht(()=>ur(e))}function ht(e){return{dispose:Y0(()=>{e()})}}var a_=class l_{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{ur(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?l_.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)}};a_.DISABLE_DISPOSED_WARNING=!1;var Fn=a_,Qe=class{constructor(){this._store=new Fn,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Qe.None=Object.freeze({dispose(){}});var Jr=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}},hn=typeof window=="object"?window:globalThis,Ju=class Zu{constructor(t){this.element=t,this.next=Zu.Undefined,this.prev=Zu.Undefined}};Ju.Undefined=new Ju(void 0);var pt=Ju,xm=class{constructor(){this._first=pt.Undefined,this._last=pt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===pt.Undefined}clear(){let e=this._first;for(;e!==pt.Undefined;){let t=e.next;e.prev=pt.Undefined,e.next=pt.Undefined,e=t}this._first=pt.Undefined,this._last=pt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new pt(e);if(this._first===pt.Undefined)this._first=i,this._last=i;else if(t){let o=this._last;this._last=i,i.prev=o,o.next=i}else{let o=this._first;this._first=i,i.next=o,o.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==pt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==pt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==pt.Undefined&&e.next!==pt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===pt.Undefined&&e.next===pt.Undefined?(this._first=pt.Undefined,this._last=pt.Undefined):e.next===pt.Undefined?(this._last=this._last.prev,this._last.next=pt.Undefined):e.prev===pt.Undefined&&(this._first=this._first.next,this._first.prev=pt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==pt.Undefined;)yield e.element,e=e.next}},G0=globalThis.performance&&typeof globalThis.performance.now=="function",Q0=class c_{static create(t){return new c_(t)}constructor(t){this._now=G0&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Ut;(e=>{e.None=()=>Qe.None;function t(A,E){return C(A,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function i(A){return(E,R=null,F)=>{let D=!1,O;return O=A(z=>{if(!D)return O?O.dispose():D=!0,E.call(R,z)},null,F),D&&O.dispose(),O}}e.once=i;function s(A,E,R){return p((F,D=null,O)=>A(z=>F.call(D,E(z)),null,O),R)}e.map=s;function o(A,E,R){return p((F,D=null,O)=>A(z=>{E(z),F.call(D,z)},null,O),R)}e.forEach=o;function l(A,E,R){return p((F,D=null,O)=>A(z=>E(z)&&F.call(D,z),null,O),R)}e.filter=l;function c(A){return A}e.signal=c;function d(...A){return(E,R=null,F)=>{let D=X0(...A.map(O=>O(z=>E.call(R,z))));return S(D,F)}}e.any=d;function m(A,E,R,F){let D=R;return s(A,O=>(D=E(D,O),D),F)}e.reduce=m;function p(A,E){let R,F={onWillAddFirstListener(){R=A(D.fire,D)},onDidRemoveLastListener(){R==null||R.dispose()}},D=new we(F);return E==null||E.add(D),D.event}function S(A,E){return E instanceof Array?E.push(A):E&&E.add(A),A}function C(A,E,R=100,F=!1,D=!1,O,z){let ie,K,M,W=0,oe,ae={leakWarningThreshold:O,onWillAddFirstListener(){ie=A(le=>{W++,K=E(K,le),F&&!M&&(se.fire(K),K=void 0),oe=()=>{let ye=K;K=void 0,M=void 0,(!F||W>1)&&se.fire(ye),W=0},typeof R=="number"?(clearTimeout(M),M=setTimeout(oe,R)):M===void 0&&(M=0,queueMicrotask(oe))})},onWillRemoveListener(){D&&W>0&&(oe==null||oe())},onDidRemoveLastListener(){oe=void 0,ie.dispose()}},se=new we(ae);return z==null||z.add(se),se.event}e.debounce=C;function _(A,E=0,R){return e.debounce(A,(F,D)=>F?(F.push(D),F):[D],E,void 0,!0,void 0,R)}e.accumulate=_;function v(A,E=(F,D)=>F===D,R){let F=!0,D;return l(A,O=>{let z=F||!E(O,D);return F=!1,D=O,z},R)}e.latch=v;function w(A,E,R){return[e.filter(A,E,R),e.filter(A,F=>!E(F),R)]}e.split=w;function b(A,E=!1,R=[],F){let D=R.slice(),O=A(K=>{D?D.push(K):ie.fire(K)});F&&F.add(O);let z=()=>{D==null||D.forEach(K=>ie.fire(K)),D=null},ie=new we({onWillAddFirstListener(){O||(O=A(K=>ie.fire(K)),F&&F.add(O))},onDidAddFirstListener(){D&&(E?setTimeout(z):z())},onDidRemoveLastListener(){O&&O.dispose(),O=null}});return F&&F.add(ie),ie.event}e.buffer=b;function x(A,E){return(R,F,D)=>{let O=E(new L);return A(function(z){let ie=O.evaluate(z);ie!==N&&R.call(F,ie)},void 0,D)}}e.chain=x;let N=Symbol("HaltChainable");class L{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(R=>(E(R),R)),this}filter(E){return this.steps.push(R=>E(R)?R:N),this}reduce(E,R){let F=R;return this.steps.push(D=>(F=E(F,D),F)),this}latch(E=(R,F)=>R===F){let R=!0,F;return this.steps.push(D=>{let O=R||!E(D,F);return R=!1,F=D,O?D:N}),this}evaluate(E){for(let R of this.steps)if(E=R(E),E===N)break;return E}}function j(A,E,R=F=>F){let F=(...ie)=>z.fire(R(...ie)),D=()=>A.on(E,F),O=()=>A.removeListener(E,F),z=new we({onWillAddFirstListener:D,onDidRemoveLastListener:O});return z.event}e.fromNodeEventEmitter=j;function T(A,E,R=F=>F){let F=(...ie)=>z.fire(R(...ie)),D=()=>A.addEventListener(E,F),O=()=>A.removeEventListener(E,F),z=new we({onWillAddFirstListener:D,onDidRemoveLastListener:O});return z.event}e.fromDOMEventEmitter=T;function Q(A){return new Promise(E=>i(A)(E))}e.toPromise=Q;function H(A){let E=new we;return A.then(R=>{E.fire(R)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=H;function I(A,E){return A(R=>E.fire(R))}e.forward=I;function G(A,E,R){return E(R),A(F=>E(F))}e.runAndSubscribe=G;class U{constructor(E,R){this._observable=E,this._counter=0,this._hasChanged=!1;let F={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new we(F),R&&R.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,R){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 q(A,E){return new U(A,E).emitter.event}e.fromObservable=q;function X(A){return(E,R,F)=>{let D=0,O=!1,z={beginUpdate(){D++},endUpdate(){D--,D===0&&(A.reportChanges(),O&&(O=!1,E.call(R)))},handlePossibleChange(){},handleChange(){O=!0}};A.addObserver(z),A.reportChanges();let ie={dispose(){A.removeObserver(z)}};return F instanceof Fn?F.add(ie):Array.isArray(F)&&F.push(ie),ie}}e.fromObservableLight=X})(Ut||(Ut={}));var eh=class th{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${th._idPool++}`,th.all.add(this)}start(t){this._stopWatch=new Q0,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}}};eh.all=new Set,eh._idPool=0;var J0=eh,Z0=-1,u_=class h_{constructor(t,i,s=(h_._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[l,c]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${c}):`;console.warn(d),console.warn(l);let m=new ib(d,l);this._errorHandler(m)}return()=>{let l=this._stacks.get(t.value)||0;this._stacks.set(t.value,l-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,o]of this._stacks)(!t||i<o)&&(t=[s,o],i=o);return t}};u_._idPool=1;var eb=u_,tb=class d_{constructor(t){this.value=t}static create(){let t=new Error;return new d_(t.stack??"")}print(){console.warn(this.value.split(`
|
|
58
58
|
`).slice(2).join(`
|
|
59
|
-
`))}},eb=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},tb=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},ib=0,tu=class{constructor(e){this.value=e,this.id=ib++}},nb=2,rb,we=class{constructor(e){var t,i,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new J0((e==null?void 0:e.onListenerError)??Ta,((i=this._options)==null?void 0:i.leakWarningThreshold)??Q0):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new G0(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||i.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var c,d,m,p,S;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let C=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(C);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],v=new tb(`${C}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((c=this._options)==null?void 0:c.onListenerError)||Ta)(v),Qe.None}if(this._disposed)return Qe.None;t&&(e=e.bind(t));let s=new tu(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Z0.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof tu?(this._deliveryQueue??(this._deliveryQueue=new sb),this._listeners=[this._listeners,s]):this._listeners.push(s):((m=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||m.call(d,this),this._listeners=s,(S=(p=this._options)==null?void 0:p.onDidAddFirstListener)==null||S.call(p,this)),this._size++;let l=ht(()=>{o==null||o(),this._removeListener(s)});return i instanceof Fn?i.add(l):Array.isArray(i)&&i.push(l),l}),this._event}_removeListener(e){var o,l,c,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=(c=this._options)==null?void 0:c.onDidRemoveLastListener)==null||d.call(c,this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*nb<=t.length){let m=0;for(let p=0;p<t.length;p++)t[p]?t[m++]=t[p]:s&&(this._deliveryQueue.end--,m<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=m}}_deliver(e,t){var s;if(!e)return;let i=((s=this._options)==null?void 0:s.onListenerError)||Ta;if(!i){e.value(t);return}try{e.value(t)}catch(o){i(o)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,o;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof tu)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}},sb=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},ih=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new we,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new we,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};ih.INSTANCE=new ih;var Jh=ih;function ob(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Jh.INSTANCE.onDidChangeZoomLevel;function ab(e){return Jh.INSTANCE.getZoomFactor(e)}Jh.INSTANCE.onDidChangeFullscreen;var is=typeof navigator=="object"?navigator.userAgent:"",nh=is.indexOf("Firefox")>=0,lb=is.indexOf("AppleWebKit")>=0,Zh=is.indexOf("Chrome")>=0,cb=!Zh&&is.indexOf("Safari")>=0;is.indexOf("Electron/")>=0;is.indexOf("Android")>=0;var iu=!1;if(typeof hn.matchMedia=="function"){let e=hn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=hn.matchMedia("(display-mode: fullscreen)");iu=e.matches,ob(hn,e,({matches:i})=>{iu&&t.matches||(iu=i)})}var Kr="en",rh=!1,sh=!1,Aa=!1,h_=!1,ka,Ba=Kr,km=Kr,ub,zi,cr=globalThis,Wt,wv;typeof cr.vscode<"u"&&typeof cr.vscode.process<"u"?Wt=cr.vscode.process:typeof process<"u"&&typeof((wv=process==null?void 0:process.versions)==null?void 0:wv.node)=="string"&&(Wt=process);var bv,hb=typeof((bv=Wt==null?void 0:Wt.versions)==null?void 0:bv.electron)=="string",db=hb&&(Wt==null?void 0:Wt.type)==="renderer",Cv;if(typeof Wt=="object"){rh=Wt.platform==="win32",sh=Wt.platform==="darwin",Aa=Wt.platform==="linux",Aa&&Wt.env.SNAP&&Wt.env.SNAP_REVISION,Wt.env.CI||Wt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,ka=Kr,Ba=Kr;let e=Wt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);ka=t.userLocale,km=t.osLocale,Ba=t.resolvedLanguage||Kr,ub=(Cv=t.languagePack)==null?void 0:Cv.translationsConfigFile}catch{}h_=!0}else typeof navigator=="object"&&!db?(zi=navigator.userAgent,rh=zi.indexOf("Windows")>=0,sh=zi.indexOf("Macintosh")>=0,(zi.indexOf("Macintosh")>=0||zi.indexOf("iPad")>=0||zi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Aa=zi.indexOf("Linux")>=0,(zi==null?void 0:zi.indexOf("Mobi"))>=0,Ba=globalThis._VSCODE_NLS_LANGUAGE||Kr,ka=navigator.language.toLowerCase(),km=ka):console.error("Unable to resolve platform.");var d_=rh,Qi=sh,fb=Aa,Em=h_,Zi=zi,jn=Ba,pb;(e=>{function t(){return jn}e.value=t;function i(){return jn.length===2?jn==="en":jn.length>=3?jn[0]==="e"&&jn[1]==="n"&&jn[2]==="-":!1}e.isDefaultVariant=i;function s(){return jn==="en"}e.isDefault=s})(pb||(pb={}));var mb=typeof cr.postMessage=="function"&&!cr.importScripts;(()=>{if(mb){let e=[];cr.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let l=e[s];if(l.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),l.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),cr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var gb=!!(Zi&&Zi.indexOf("Chrome")>=0);Zi&&Zi.indexOf("Firefox")>=0;!gb&&Zi&&Zi.indexOf("Safari")>=0;Zi&&Zi.indexOf("Edg/")>=0;Zi&&Zi.indexOf("Android")>=0;var Fr=typeof navigator=="object"?navigator:{};Em||document.queryCommandSupported&&document.queryCommandSupported("copy")||Fr&&Fr.clipboard&&Fr.clipboard.writeText,Em||Fr&&Fr.clipboard&&Fr.clipboard.readText;var ed=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}},nu=new ed,Nm=new ed,Rm=new ed,vb=new Array(230),f_;(e=>{function t(d){return nu.keyCodeToStr(d)}e.toString=t;function i(d){return nu.strToKeyCode(d)}e.fromString=i;function s(d){return Nm.keyCodeToStr(d)}e.toUserSettingsUS=s;function o(d){return Rm.keyCodeToStr(d)}e.toUserSettingsGeneral=o;function l(d){return Nm.strToKeyCode(d)||Rm.strToKeyCode(d)}e.fromUserSettings=l;function c(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 nu.keyCodeToStr(d)}e.toElectronAccelerator=c})(f_||(f_={}));var _b=class p_{constructor(t,i,s,o,l){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=o,this.keyCode=l}equals(t){return t instanceof p_&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${i}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new yb([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},yb=class{constructor(e){if(e.length===0)throw U0("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function Sb(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return f_.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(nh)switch(t){case 59:return 85;case 60:if(fb)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Qi)return 57;break}else if(lb&&(Qi&&t===93||!Qi&&t===92))return 57;return vb[t]||0}var wb=Qi?256:2048,bb=512,Cb=1024,xb=Qi?2048:256,Pm=class{constructor(e){var i;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=Sb(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|=wb),this.altKey&&(t|=bb),this.shiftKey&&(t|=Cb),this.metaKey&&(t|=xb),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new _b(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Dm=new WeakMap;function kb(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var Eb=class{static getSameOriginWindowChain(e){let t=Dm.get(e);if(!t){t=[],Dm.set(e,t);let i=e,s;do s=kb(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,o=this.getSameOriginWindowChain(e);for(let l of o){let c=l.window.deref();if(i+=(c==null?void 0:c.scrollY)??0,s+=(c==null?void 0:c.scrollX)??0,c===t||!l.iframeElement)break;let d=l.iframeElement.getBoundingClientRect();i+=d.top,s+=d.left}return{top:i,left:s}}},Ea=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=Eb.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Mm=class{constructor(e,t=0,i=0){var o;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(Zh){let l=navigator.userAgent.match(/Chrome\/(\d+)/);s=(l?parseInt(l[1]):123)<=122}if(e){let l=e,c=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 c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?nh&&!Qi?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof l.wheelDeltaX<"u")cb&&d_?this.deltaX=-(l.wheelDeltaX/120):s?this.deltaX=l.wheelDeltaX/(120*d):this.deltaX=l.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?nh&&!Qi?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},m_=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Nb;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Rb?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ut.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:m_})})(Nb||(Nb={}));var Rb=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?m_:(this._emitter||(this._emitter=new we),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},td=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 Qu("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Qu("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Pb=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new Qu("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=ht(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Db;(e=>{async function t(s){let o,l=await Promise.all(s.map(c=>c.then(d=>d,d=>{o||(o=d)})));if(typeof o<"u")throw o;return l}e.settled=t;function i(s){return new Promise(async(o,l)=>{try{await s(o,l)}catch(c){l(c)}})}e.withAsyncBody=i})(Db||(Db={}));var Lm=class Ri{static fromArray(t){return new Ri(i=>{i.emitMany(t)})}static fromPromise(t){return new Ri(async i=>{i.emitMany(await t)})}static fromPromises(t){return new Ri(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new Ri(async i=>{await Promise.all(t.map(async s=>{for await(let o of s)i.emitOne(o)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new we,queueMicrotask(async()=>{let s={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(s)),this.resolve()}catch(o){this.reject(o)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Ut.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new Ri(async s=>{for await(let o of t)s.emitOne(i(o))})}map(t){return Ri.map(this,t)}static filter(t,i){return new Ri(async s=>{for await(let o of t)i(o)&&s.emitOne(o)})}filter(t){return Ri.filter(this,t)}static coalesce(t){return Ri.filter(t,i=>!!i)}coalesce(){return Ri.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return Ri.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Lm.EMPTY=Lm.fromArray([]);var{getWindow:Xi,getWindowId:Mb,onDidRegisterWindow:Lb}=(function(){let e=new Map,t={window:hn,disposables:new Fn};e.set(hn.vscodeWindowId,t);let i=new we,s=new we,o=new we;function l(c,d){return(typeof c=="number"?e.get(c):void 0)??(d?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return Qe.None;let d=new Fn,m={window:c,disposables:d.add(new Fn)};return e.set(c.vscodeWindowId,m),d.add(ht(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),d.add($e(c,At.BEFORE_UNLOAD,()=>{o.fire(c)})),i.fire(m),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:l,getWindow(c){var p;let d=c;if((p=d==null?void 0:d.ownerDocument)!=null&&p.defaultView)return d.ownerDocument.defaultView.window;let m=c;return m!=null&&m.view?m.view.window:hn},getDocument(c){return Xi(c).document}}})(),jb=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function $e(e,t,i,s){return new jb(e,t,i,s)}var jm=function(e,t,i,s){return $e(e,t,i,s)},id,Tb=class extends Pb{constructor(e){super(),this.defaultTarget=e&&Xi(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Tm=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){Ta(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,o=l=>{i.set(l,!1);let c=e.get(l)??[];for(t.set(l,c),e.set(l,[]),s.set(l,!0);c.length>0;)c.sort(Tm.sort),c.shift().execute();s.set(l,!1)};id=(l,c,d=0)=>{let m=Mb(l),p=new Tm(c,d),S=e.get(m);return S||(S=[],e.set(m,S)),S.push(p),i.get(m)||(i.set(m,!0),l.requestAnimationFrame(()=>o(m))),p}})();function Ab(e){let t=e.getBoundingClientRect(),i=Xi(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var At={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"},Bb=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let i=li(t);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let i=li(t);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(t){let i=li(t);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(t){let i=li(t);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(t){let i=li(t);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(t){let i=li(t);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(t){let i=li(t);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(t){let i=li(t);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let i=li(t);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let i=li(t);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let i=li(t);this._paddingRight!==i&&(this._paddingRight=i,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let i=li(t);this._fontSize!==i&&(this._fontSize=i,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let i=li(t);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let i=li(t);this._letterSpacing!==i&&(this._letterSpacing=i,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,i){this.domNode.classList.toggle(t,i),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,i){this.domNode.setAttribute(t,i)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function li(e){return typeof e=="number"?`${e}px`:e}function io(e){return new Bb(e)}var g_=class{constructor(){this._hooks=new Fn,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let l=e;try{e.setPointerCapture(t),this._hooks.add(ht(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{l=Xi(e)}this._hooks.add($e(l,At.POINTER_MOVE,c=>{if(c.buttons!==i){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add($e(l,At.POINTER_UP,c=>this.stopMonitoring(!0)))}};function Ib(e,t,i){let s=null,o=null;if(typeof i.value=="function"?(s="value",o=i.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",o=i.get),!o)throw new Error("not supported");let l=`$memoize$${t}`;i[s]=function(...c){return this.hasOwnProperty(l)||Object.defineProperty(this,l,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,c)}),this[l]}}var Yi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Yi||(Yi={}));var Qs=class Gt extends Qe{constructor(){super(),this.dispatched=!1,this.targets=new xm,this.ignoreTargets=new xm,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ut.runAndSubscribe(Lb,({window:t,disposables:i})=>{i.add($e(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add($e(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add($e(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:hn,disposables:this._store}))}static addTarget(t){if(!Gt.isTouchDevice())return Qe.None;Gt.INSTANCE||(Gt.INSTANCE=new Gt);let i=Gt.INSTANCE.targets.push(t);return ht(i)}static ignoreTarget(t){if(!Gt.isTouchDevice())return Qe.None;Gt.INSTANCE||(Gt.INSTANCE=new Gt);let i=Gt.INSTANCE.ignoreTargets.push(t);return ht(i)}static isTouchDevice(){return"ontouchstart"in hn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,o=t.targetTouches.length;s<o;s++){let l=t.targetTouches.item(s);this.activeTouches[l.identifier]={id:l.identifier,initialTarget:l.target,initialTimeStamp:i,initialPageX:l.pageX,initialPageY:l.pageY,rollingTimestamps:[i],rollingPageX:[l.pageX],rollingPageY:[l.pageY]};let c=this.newGestureEvent(Yi.Start,l.target);c.pageX=l.pageX,c.pageY=l.pageY,this.dispatchEvent(c)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let l=0,c=i.changedTouches.length;l<c;l++){let d=i.changedTouches.item(l);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("move of an UNKNOWN touch",d);continue}let m=this.activeTouches[d.identifier],p=Date.now()-m.initialTimeStamp;if(p<Gt.HOLD_DELAY&&Math.abs(m.initialPageX-gi(m.rollingPageX))<30&&Math.abs(m.initialPageY-gi(m.rollingPageY))<30){let S=this.newGestureEvent(Yi.Tap,m.initialTarget);S.pageX=gi(m.rollingPageX),S.pageY=gi(m.rollingPageY),this.dispatchEvent(S)}else if(p>=Gt.HOLD_DELAY&&Math.abs(m.initialPageX-gi(m.rollingPageX))<30&&Math.abs(m.initialPageY-gi(m.rollingPageY))<30){let S=this.newGestureEvent(Yi.Contextmenu,m.initialTarget);S.pageX=gi(m.rollingPageX),S.pageY=gi(m.rollingPageY),this.dispatchEvent(S)}else if(o===1){let S=gi(m.rollingPageX),C=gi(m.rollingPageY),_=gi(m.rollingTimestamps)-m.rollingTimestamps[0],v=S-m.rollingPageX[0],w=C-m.rollingPageY[0],b=[...this.targets].filter(x=>m.initialTarget instanceof Node&&x.contains(m.initialTarget));this.inertia(t,b,s,Math.abs(v)/_,v>0?1:-1,S,Math.abs(w)/_,w>0?1:-1,C)}this.dispatchEvent(this.newGestureEvent(Yi.End,m.initialTarget)),delete this.activeTouches[d.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===Yi.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Gt.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===Yi.Change||t.type===Yi.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];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;i.push([o,s])}i.sort((s,o)=>s[0]-o[0]);for(let[s,o]of i)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,o,l,c,d,m,p){this.handle=id(t,()=>{let S=Date.now(),C=S-s,_=0,v=0,w=!0;o+=Gt.SCROLL_FRICTION*C,d+=Gt.SCROLL_FRICTION*C,o>0&&(w=!1,_=l*o*C),d>0&&(w=!1,v=m*d*C);let b=this.newGestureEvent(Yi.Change);b.translationX=_,b.translationY=v,i.forEach(x=>x.dispatchEvent(b)),w||this.inertia(t,i,S,o,l,c+_,d,m,p+v)})}onTouchMove(t){let i=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 c=this.activeTouches[l.identifier],d=this.newGestureEvent(Yi.Change,c.initialTarget);d.translationX=l.pageX-gi(c.rollingPageX),d.translationY=l.pageY-gi(c.rollingPageY),d.pageX=l.pageX,d.pageY=l.pageY,this.dispatchEvent(d),c.rollingPageX.length>3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(l.pageX),c.rollingPageY.push(l.pageY),c.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Qs.SCROLL_FRICTION=-.005,Qs.HOLD_DELAY=700,Qs.CLEAR_TAP_COUNT_TIME=400,yt([Ib],Qs,"isTouchDevice",1);var Ob=Qs,nd=class extends Qe{onclick(e,t){this._register($e(e,At.CLICK,i=>t(new Ea(Xi(e),i))))}onmousedown(e,t){this._register($e(e,At.MOUSE_DOWN,i=>t(new Ea(Xi(e),i))))}onmouseover(e,t){this._register($e(e,At.MOUSE_OVER,i=>t(new Ea(Xi(e),i))))}onmouseleave(e,t){this._register($e(e,At.MOUSE_LEAVE,i=>t(new Ea(Xi(e),i))))}onkeydown(e,t){this._register($e(e,At.KEY_DOWN,i=>t(new Pm(i))))}onkeyup(e,t){this._register($e(e,At.KEY_UP,i=>t(new Pm(i))))}oninput(e,t){this._register($e(e,At.INPUT,t))}onblur(e,t){this._register($e(e,At.BLUR,t))}onfocus(e,t){this._register($e(e,At.FOCUS,t))}onchange(e,t){this._register($e(e,At.CHANGE,t))}ignoreGesture(e){return Ob.ignoreTarget(e)}},Am=11,zb=class extends nd{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=Am+"px",this.domNode.style.height=Am+"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 g_),this._register(jm(this.bgDomNode,At.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(jm(this.domNode,At.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Tb),this._pointerdownScheduleRepeatTimer=this._register(new td)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Xi(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Fb=class oh{constructor(t,i,s,o,l,c,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,o=o|0,l=l|0,c=c|0,d=d|0),this.rawScrollLeft=o,this.rawScrollTop=d,i<0&&(i=0),o+i>s&&(o=s-i),o<0&&(o=0),l<0&&(l=0),d+l>c&&(d=c-l),d<0&&(d=0),this.width=i,this.scrollWidth=s,this.scrollLeft=o,this.height=l,this.scrollHeight=c,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,i){return new oh(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new oh(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,l=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,m=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:o,scrollLeftChanged:l,heightChanged:c,scrollHeightChanged:d,scrollTopChanged:m}}},Hb=class extends Qe{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Fb(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new Im(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=Im.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},Bm=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function ru(e,t){let i=t-e;return function(s){return e+i*Ub(s)}}function $b(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var Im=class ah{constructor(t,i,s,o){this.from=t,this.to=i,this.duration=o,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,s){if(Math.abs(t-i)>2.5*s){let o,l;return t<i?(o=t+.75*s,l=i-.75*s):(o=t-.75*s,l=i+.75*s),$b(ru(t,o),ru(l,i),.33)}return ru(t,i)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),o=this.scrollTop(i);return new Bm(s,o,!1)}return new Bm(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return ah.start(t,i,s)}static start(t,i,s){s=s+10;let o=Date.now()-10;return new ah(t,i,o,s)}};function Wb(e){return Math.pow(e,3)}function Ub(e){return 1-Wb(1-e)}var Kb=class extends Qe{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new td)}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":"")))}},qb=140,v_=class extends nd{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 Kb(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new g_),this._shouldRender=!0,this.domNode=io(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register($e(this.domNode.domNode,At.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new zb(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=io(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register($e(this.slider.domNode,At.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);i<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let o=Ab(this.domNode.domNode);t=e.pageX-o.left,i=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let l=this._sliderOrthogonalPointerPosition(o),c=Math.abs(l-i);if(d_&&c>qb){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()}},__=class lh{constructor(t,i,s,o,l,c){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=l,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new lh(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,o,l){let c=Math.max(0,s-t),d=Math.max(0,c-2*i),m=o>0&&o>s;if(!m)return{computedAvailableSize:Math.round(c),computedIsNeeded:m,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(s*d/o))),S=(d-p)/(o-s),C=l*S;return{computedAvailableSize:Math.round(c),computedIsNeeded:m,computedSliderSize:Math.round(p),computedSliderRatio:S,computedSliderPosition:Math.round(C)}}_refreshComputedValues(){let t=lh._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},Vb=class extends v_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new __(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}},Yb=class extends v_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new __(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}},Xb=500,Om=50,Gb=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},ch=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,i=0,s=1,o=this._rear;do{let l=o===this._front?t:Math.pow(2,-s);if(t-=l,i+=this._memory[o].score*l,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Zh){let i=Xi(t.browserEvent),s=ab(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let o=null,l=new Gb(t,i,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,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let o=Math.abs(t.deltaX),l=Math.abs(t.deltaY),c=Math.abs(i.deltaX),d=Math.abs(i.deltaY),m=Math.max(Math.min(o,c),1),p=Math.max(Math.min(l,d),1),S=Math.max(o,c),C=Math.max(l,d);S%m===0&&C%p===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};ch.INSTANCE=new ch;var Qb=ch,Jb=class extends nd{constructor(e,t,i){super(),this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new we),this.onWillScroll=this._onWillScroll.event,this._options=e1(t),this._scrollable=i,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let s={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Yb(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Vb(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=io(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=io(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=io(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 td),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ur(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Qi&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Mm(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ur(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new Mm(i))};this._mouseWheelToDispose.push($e(this._listenOnDomNode,At.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=Qb.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let l=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+l===0?c=l=0:Math.abs(l)>=Math.abs(c)?c=0:l=0),this._options.flipAxes&&([l,c]=[c,l]);let d=!Qi&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!c&&(c=l,l=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,l=l*this._options.fastScrollSensitivity);let m=this._scrollable.getFutureScrollPosition(),p={};if(l){let S=Om*l,C=m.scrollTop-(S<0?Math.floor(S):Math.ceil(S));this._verticalScrollbar.writeScrollPosition(p,C)}if(c){let S=Om*c,C=m.scrollLeft-(S<0?Math.floor(S):Math.ceil(S));this._horizontalScrollbar.writeScrollPosition(p,C)}p=this._scrollable.validateScrollPosition(p),(m.scrollLeft!==p.scrollLeft||m.scrollTop!==p.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(p):this._scrollable.setScrollPositionNow(p),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",o=t?" top":"",l=i||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(),Xb)}},Zb=class extends Jb{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function e1(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,Qi&&(t.className+=" mac"),t}var uh=class extends Qe{constructor(e,t,i,s,o,l,c,d){super(),this._bufferService=i,this._optionsService=c,this._renderService=d,this._onRequestScrollLines=this._register(new we),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let m=this._register(new Hb({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>id(s.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{m.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Zb(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},m)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(p=>{this._scrollableElement.updateOptions({handleMouseWheel:!(p&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ut.runAndSubscribe(l.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=l.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ht(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ht(()=>this._styleElement.remove())),this._register(Ut.runAndSubscribe(l.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${l.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${l.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${l.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
60
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(p=>this._handleScroll(p)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};uh=yt([Ee(2,ei),Ee(3,dn),Ee(4,Jv),Ee(5,ts),Ee(6,ti),Ee(7,fn)],uh);var hh=class extends Qe{constructor(e,t,i,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(l=>this._removeDecoration(l))),this._register(ht(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};hh=yt([Ee(1,ei),Ee(2,dn),Ee(3,lo),Ee(4,fn)],hh);var t1=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Ki={full:0,left:0,center:0,right:0},Tn={full:0,left:0,center:0,right:0},Hs={full:0,left:0,center:0,right:0},Ya=class extends Qe{constructor(e,t,i,s,o,l,c,d){var p;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=o,this._optionsService=l,this._themeService=c,this._coreBrowserService=d,this._colorZoneStore=new t1,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(),(p=this._viewportElement.parentElement)==null||p.insertBefore(this._canvas,this._viewportElement),this._register(ht(()=>{var S;return(S=this._canvas)==null?void 0:S.remove()}));let m=this._canvas.getContext("2d");if(m)this._ctx=m;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Tn.full=this._canvas.width,Tn.left=e,Tn.center=t,Tn.right=e,this._refreshDrawHeightConstants(),Hs.full=1,Hs.left=1,Hs.center=1+Tn.left,Hs.right=1+Tn.left+Tn.center}_refreshDrawHeightConstants(){Ki.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Ki.left=t,Ki.center=t,Ki.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Hs[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ki[e.position||"full"]/2),Tn[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ki[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Ya=yt([Ee(2,ei),Ee(3,lo),Ee(4,fn),Ee(5,ti),Ee(6,ts),Ee(7,dn)],Ya);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 Ia;(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=""))(Ia||(Ia={}));var y_;(e=>e.ST=`${he.ESC}\\`)(y_||(y_={}));var dh=class{constructor(e,t,i,s,o,l){this._textarea=e,this._compositionView=t,this._bufferService=i,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 i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${he.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let 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)}}};dh=yt([Ee(2,ei),Ee(3,ti),Ee(4,fr),Ee(5,fn)],dh);var Bt=0,It=0,Ot=0,_t=0,zm={css:"#00000000",rgba:0},kt;(e=>{function t(o,l,c,d){return d!==void 0?`#${tr(o)}${tr(l)}${tr(c)}${tr(d)}`:`#${tr(o)}${tr(l)}${tr(c)}`}e.toCss=t;function i(o,l,c,d=255){return(o<<24|l<<16|c<<8|d)>>>0}e.toRgba=i;function s(o,l,c,d){return{css:e.toCss(o,l,c,d),rgba:e.toRgba(o,l,c,d)}}e.toColor=s})(kt||(kt={}));var ct;(e=>{function t(m,p){if(_t=(p.rgba&255)/255,_t===1)return{css:p.css,rgba:p.rgba};let S=p.rgba>>24&255,C=p.rgba>>16&255,_=p.rgba>>8&255,v=m.rgba>>24&255,w=m.rgba>>16&255,b=m.rgba>>8&255;Bt=v+Math.round((S-v)*_t),It=w+Math.round((C-w)*_t),Ot=b+Math.round((_-b)*_t);let x=kt.toCss(Bt,It,Ot),N=kt.toRgba(Bt,It,Ot);return{css:x,rgba:N}}e.blend=t;function i(m){return(m.rgba&255)===255}e.isOpaque=i;function s(m,p,S){let C=Oa.ensureContrastRatio(m.rgba,p.rgba,S);if(C)return kt.toColor(C>>24&255,C>>16&255,C>>8&255)}e.ensureContrastRatio=s;function o(m){let p=(m.rgba|255)>>>0;return[Bt,It,Ot]=Oa.toChannels(p),{css:kt.toCss(Bt,It,Ot),rgba:p}}e.opaque=o;function l(m,p){return _t=Math.round(p*255),[Bt,It,Ot]=Oa.toChannels(m.rgba),{css:kt.toCss(Bt,It,Ot,_t),rgba:kt.toRgba(Bt,It,Ot,_t)}}e.opacity=l;function c(m,p){return _t=m.rgba&255,l(m,_t*p/255)}e.multiplyOpacity=c;function d(m){return[m.rgba>>24&255,m.rgba>>16&255,m.rgba>>8&255]}e.toColorRGB=d})(ct||(ct={}));var mt;(e=>{let t,i;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",i=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return Bt=parseInt(o.slice(1,2).repeat(2),16),It=parseInt(o.slice(2,3).repeat(2),16),Ot=parseInt(o.slice(3,4).repeat(2),16),kt.toColor(Bt,It,Ot);case 5:return Bt=parseInt(o.slice(1,2).repeat(2),16),It=parseInt(o.slice(2,3).repeat(2),16),Ot=parseInt(o.slice(3,4).repeat(2),16),_t=parseInt(o.slice(4,5).repeat(2),16),kt.toColor(Bt,It,Ot,_t);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 Bt=parseInt(l[1]),It=parseInt(l[2]),Ot=parseInt(l[3]),_t=Math.round((l[5]===void 0?1:parseFloat(l[5]))*255),kt.toColor(Bt,It,Ot,_t);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Bt,It,Ot,_t]=t.getImageData(0,0,1,1).data,_t!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:kt.toRgba(Bt,It,Ot,_t),css:o}}e.toColor=s})(mt||(mt={}));var Zt;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,o,l){let c=s/255,d=o/255,m=l/255,p=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),S=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),C=m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4);return p*.2126+S*.7152+C*.0722}e.relativeLuminance2=i})(Zt||(Zt={}));var Oa;(e=>{function t(c,d){if(_t=(d&255)/255,_t===1)return d;let m=d>>24&255,p=d>>16&255,S=d>>8&255,C=c>>24&255,_=c>>16&255,v=c>>8&255;return Bt=C+Math.round((m-C)*_t),It=_+Math.round((p-_)*_t),Ot=v+Math.round((S-v)*_t),kt.toRgba(Bt,It,Ot)}e.blend=t;function i(c,d,m){let p=Zt.relativeLuminance(c>>8),S=Zt.relativeLuminance(d>>8);if(cn(p,S)<m){if(S<p){let v=s(c,d,m),w=cn(p,Zt.relativeLuminance(v>>8));if(w<m){let b=o(c,d,m),x=cn(p,Zt.relativeLuminance(b>>8));return w>x?v:b}return v}let C=o(c,d,m),_=cn(p,Zt.relativeLuminance(C>>8));if(_<m){let v=s(c,d,m),w=cn(p,Zt.relativeLuminance(v>>8));return _>w?C:v}return C}}e.ensureContrastRatio=i;function s(c,d,m){let p=c>>24&255,S=c>>16&255,C=c>>8&255,_=d>>24&255,v=d>>16&255,w=d>>8&255,b=cn(Zt.relativeLuminance2(_,v,w),Zt.relativeLuminance2(p,S,C));for(;b<m&&(_>0||v>0||w>0);)_-=Math.max(0,Math.ceil(_*.1)),v-=Math.max(0,Math.ceil(v*.1)),w-=Math.max(0,Math.ceil(w*.1)),b=cn(Zt.relativeLuminance2(_,v,w),Zt.relativeLuminance2(p,S,C));return(_<<24|v<<16|w<<8|255)>>>0}e.reduceLuminance=s;function o(c,d,m){let p=c>>24&255,S=c>>16&255,C=c>>8&255,_=d>>24&255,v=d>>16&255,w=d>>8&255,b=cn(Zt.relativeLuminance2(_,v,w),Zt.relativeLuminance2(p,S,C));for(;b<m&&(_<255||v<255||w<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),b=cn(Zt.relativeLuminance2(_,v,w),Zt.relativeLuminance2(p,S,C));return(_<<24|v<<16|w<<8|255)>>>0}e.increaseLuminance=o;function l(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=l})(Oa||(Oa={}));function tr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function cn(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var i1=class extends ao{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Xa=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Di}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let i=[],s=t.translateToString(!0),o=0,l=0,c=0,d=t.getFg(0),m=t.getBg(0);for(let p=0;p<t.getTrimmedLength();p++)if(t.loadCell(p,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==d||this._workCell.bg!==m){if(p-o>1){let S=this._getJoinedRanges(s,c,l,t,o);for(let C=0;C<S.length;C++)i.push(S[C])}o=p,c=l,d=this._workCell.fg,m=this._workCell.bg}l+=this._workCell.getChars().length||On.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(s,c,l,t,o);for(let S=0;S<p.length;S++)i.push(p[S])}return i}_getJoinedRanges(e,t,i,s,o){let l=e.substring(t,i),c=[];try{c=this._characterJoiners[0].handler(l)}catch(d){console.error(d)}for(let d=1;d<this._characterJoiners.length;d++)try{let m=this._characterJoiners[d].handler(l);for(let p=0;p<m.length;p++)Xa._mergeRanges(c,m[p])}catch(m){console.error(m)}return this._stringRangesToCellRanges(c,s,o),c}_stringRangesToCellRanges(e,t,i){let s=0,o=!1,l=0,c=e[s];if(c){for(let d=i;d<this._bufferService.cols;d++){let m=t.getWidth(d),p=t.getString(d).length||On.length;if(m!==0){if(!o&&c[0]<=l&&(c[0]=d,o=!0),c[1]<=l){if(c[1]=d,c=e[++s],!c)break;c[0]<=l?(c[0]=d,o=!0):o=!1}l+=p}}c&&(c[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let o=e[s];if(i){if(t[1]<=o[0])return e[s-1][1]=t[1],e;if(t[1]<=o[1])return e[s-1][1]=Math.max(t[1],o[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=o[0])return e.splice(s,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};Xa=yt([Ee(0,ei)],Xa);function n1(e){return 57508<=e&&e<=57558}function r1(e){return 9472<=e&&e<=9631}function s1(e){return n1(e)||r1(e)}function o1(){return{css:{canvas:Na(),cell:Na()},device:{canvas:Na(),cell:Na(),char:{width:0,height:0,left:0,top:0}}}}function Na(){return{width:0,height:0}}var fh=class{constructor(e,t,i,s,o,l,c){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=o,this._decorationService=l,this._themeService=c,this._workCell=new Di,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,o,l,c,d,m,p,S){let C=[],_=this._characterJoinerService.getJoinedCharacters(t),v=this._themeService.colors,w=e.getNoBgTrimmedLength();i&&w<l+1&&(w=l+1);let b,x=0,N="",L=0,j=0,T=0,Q=0,H=!1,I=0,G=!1,U=0,q=0,Y=[],A=p!==-1&&S!==-1;for(let E=0;E<w;E++){e.loadCell(E,this._workCell);let R=this._workCell.getWidth();if(R===0)continue;let F=!1,D=E>=q,O=E,z=this._workCell;if(_.length>0&&E===_[0][0]&&D){let ye=_.shift(),ee=this._isCellInSelection(ye[0],t);for(L=ye[0]+1;L<ye[1];L++)D&&(D=ee===this._isCellInSelection(L,t));D&&(D=!i||l<ye[0]||l>=ye[1]),D?(F=!0,z=new i1(this._workCell,e.translateToString(!0,ye[0],ye[1]),ye[1]-ye[0]),O=ye[1]-1,R=z.getWidth()):q=ye[1]}let ne=this._isCellInSelection(E,t),K=i&&E===l,M=A&&E>=p&&E<=S,W=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ye=>{W=!0});let oe=z.getChars()||On;if(oe===" "&&(z.isUnderline()||z.isOverline())&&(oe=" "),U=R*d-m.get(oe,z.isBold(),z.isItalic()),!b)b=this._document.createElement("span");else if(x&&(ne&&G||!ne&&!G&&z.bg===j)&&(ne&&G&&v.selectionForeground||z.fg===T)&&z.extended.ext===Q&&M===H&&U===I&&!K&&!F&&!W&&D){z.isInvisible()?N+=On:N+=oe,x++;continue}else x&&(b.textContent=N),b=this._document.createElement("span"),x=0,N="";if(j=z.bg,T=z.fg,Q=z.extended.ext,H=M,I=U,G=ne,F&&l>=E&&l<=O&&(l=E),!this._coreService.isCursorHidden&&K&&this._coreService.isCursorInitialized){if(Y.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&Y.push("xterm-cursor-blink"),Y.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":Y.push("xterm-cursor-outline");break;case"block":Y.push("xterm-cursor-block");break;case"bar":Y.push("xterm-cursor-bar");break;case"underline":Y.push("xterm-cursor-underline");break}}if(z.isBold()&&Y.push("xterm-bold"),z.isItalic()&&Y.push("xterm-italic"),z.isDim()&&Y.push("xterm-dim"),z.isInvisible()?N=On:N=z.getChars()||On,z.isUnderline()&&(Y.push(`xterm-underline-${z.extended.underlineStyle}`),N===" "&&(N=" "),!z.isUnderlineColorDefault()))if(z.isUnderlineColorRGB())b.style.textDecorationColor=`rgb(${ao.toColorRGB(z.getUnderlineColor()).join(",")})`;else{let ye=z.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&z.isBold()&&ye<8&&(ye+=8),b.style.textDecorationColor=v.ansi[ye].css}z.isOverline()&&(Y.push("xterm-overline"),N===" "&&(N=" ")),z.isStrikethrough()&&Y.push("xterm-strikethrough"),M&&(b.style.textDecoration="underline");let ae=z.getFgColor(),se=z.getFgColorMode(),le=z.getBgColor(),_e=z.getBgColorMode(),ce=!!z.isInverse();if(ce){let ye=ae;ae=le,le=ye;let ee=se;se=_e,_e=ee}let X,Z,je=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ye=>{ye.options.layer!=="top"&&je||(ye.backgroundColorRGB&&(_e=50331648,le=ye.backgroundColorRGB.rgba>>8&16777215,X=ye.backgroundColorRGB),ye.foregroundColorRGB&&(se=50331648,ae=ye.foregroundColorRGB.rgba>>8&16777215,Z=ye.foregroundColorRGB),je=ye.options.layer==="top")}),!je&&ne&&(X=this._coreBrowserService.isFocused?v.selectionBackgroundOpaque:v.selectionInactiveBackgroundOpaque,le=X.rgba>>8&16777215,_e=50331648,je=!0,v.selectionForeground&&(se=50331648,ae=v.selectionForeground.rgba>>8&16777215,Z=v.selectionForeground)),je&&Y.push("xterm-decoration-top");let Me;switch(_e){case 16777216:case 33554432:Me=v.ansi[le],Y.push(`xterm-bg-${le}`);break;case 50331648:Me=kt.toColor(le>>16,le>>8&255,le&255),this._addStyle(b,`background-color:#${Fm((le>>>0).toString(16),"0",6)}`);break;case 0:default:ce?(Me=v.foreground,Y.push("xterm-bg-257")):Me=v.background}switch(X||z.isDim()&&(X=ct.multiplyOpacity(Me,.5)),se){case 16777216:case 33554432:z.isBold()&&ae<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ae+=8),this._applyMinimumContrast(b,Me,v.ansi[ae],z,X,void 0)||Y.push(`xterm-fg-${ae}`);break;case 50331648:let ye=kt.toColor(ae>>16&255,ae>>8&255,ae&255);this._applyMinimumContrast(b,Me,ye,z,X,Z)||this._addStyle(b,`color:#${Fm(ae.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(b,Me,v.foreground,z,X,Z)||ce&&Y.push("xterm-fg-257")}Y.length&&(b.className=Y.join(" "),Y.length=0),!K&&!F&&!W&&D?x++:b.textContent=N,U!==this.defaultSpacing&&(b.style.letterSpacing=`${U}px`),C.push(b),E=O}return b&&x&&(b.textContent=N),C}_applyMinimumContrast(e,t,i,s,o,l){if(this._optionsService.rawOptions.minimumContrastRatio===1||s1(s.getCode()))return!1;let c=this._getContrastCache(s),d;if(!o&&!l&&(d=c.getColor(t.rgba,i.rgba)),d===void 0){let m=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);d=ct.ensureContrastRatio(o||t,l||i,m),c.setColor((o||t).rgba,(l||i).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 i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};fh=yt([Ee(1,t_),Ee(2,ti),Ee(3,dn),Ee(4,fr),Ee(5,lo),Ee(6,ts)],fh);function Fm(e,t,i){for(;e.length<i;)e=t+e;return e}var a1=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.style.fontWeight="bold",l.style.fontStyle="italic",this._measureElements=[i,s,o,l],this._container.appendChild(i),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,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let c=this._measure(e,0);return c>0&&(this._flat[s]=c),c}let o=e;t&&(o+="B"),i&&(o+="I");let l=this._holey.get(o);if(l===void 0){let c=0;t&&(c|=1),i&&(c|=2),l=this._measure(e,c),l>0&&this._holey.set(o,l)}return l}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},l1=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let o=e.buffers.active.ydisp,l=t[1]-o,c=i[1]-o,d=Math.max(l,0),m=Math.min(c,e.rows-1);if(d>=e.rows||m<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=l,this.viewportEndRow=c,this.viewportCappedStartRow=d,this.viewportCappedEndRow=m,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function c1(){return new l1}var su="xterm-dom-renderer-owner-",Ni="xterm-rows",Ra="xterm-fg-",Hm="xterm-bg-",$s="xterm-focus",Pa="xterm-selection",u1=1,ph=class extends Qe{constructor(e,t,i,s,o,l,c,d,m,p,S,C,_,v){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=o,this._helperContainer=l,this._linkifier2=c,this._charSizeService=m,this._optionsService=p,this._bufferService=S,this._coreService=C,this._coreBrowserService=_,this._themeService=v,this._terminalClass=u1++,this._rowElements=[],this._selectionRenderModel=c1(),this.onRequestRedraw=this._register(new we).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ni),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Pa),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=o1(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(w=>this._injectCss(w))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(fh,document),this._element.classList.add(su+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(w=>this._handleLinkHover(w))),this._register(this._linkifier2.onHideLinkUnderline(w=>this._handleLinkLeave(w))),this._register(ht(()=>{this._element.classList.remove(su+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new a1(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Ni} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Ni} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Ni} .xterm-dim { color: ${ct.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Ni}.${$s} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ni}.${$s} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ni}.${$s} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Pa} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Pa} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Pa} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[l,c]of e.ansi.entries())t+=`${this._terminalSelector} .${Ra}${l} { color: ${c.css}; }${this._terminalSelector} .${Ra}${l}.xterm-dim { color: ${ct.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Hm}${l} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${Ra}257 { color: ${ct.opaque(e.background).css}; }${this._terminalSelector} .${Ra}257.xterm-dim { color: ${ct.multiplyOpacity(ct.opaque(e.background),.5).css}; }${this._terminalSelector} .${Hm}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove($s),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add($s),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,l=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(i){let m=e[0]>t[0];d.appendChild(this._createSelectionElement(l,m?t[0]:e[0],m?e[0]:t[0],c-l+1))}else{let m=s===l?e[0]:0,p=l===o?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(l,m,p));let S=c-l-1;if(d.appendChild(this._createSelectionElement(l+1,0,this._bufferService.cols,S)),l!==c){let C=o===c?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(c,0,C))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,i,s=1){let o=this._document.createElement("div"),l=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(i-t);return l+c>this.dimensions.css.canvas.width&&(c=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=`${c}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,o=Math.min(i.x,this._bufferService.cols-1),l=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=e;m<=t;m++){let p=m+i.ydisp,S=this._rowElements[m],C=i.lines.get(p);if(!S||!C)break;S.replaceChildren(...this._rowFactory.createRow(C,p,p===s,c,d,o,l,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${su}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,o,l){i<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;i=Math.max(Math.min(i,c),0),s=Math.max(Math.min(s,c),0),o=Math.min(o,this._bufferService.cols);let d=this._bufferService.buffer,m=d.ybase+d.y,p=Math.min(d.x,o-1),S=this._optionsService.rawOptions.cursorBlink,C=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let v=i;v<=s;++v){let w=v+d.ydisp,b=this._rowElements[v],x=d.lines.get(w);if(!b||!x)break;b.replaceChildren(...this._rowFactory.createRow(x,w,w===m,C,_,p,S,this.dimensions.css.cell.width,this._widthCache,l?v===i?e:0:-1,l?(v===s?t:o)-1:-1))}}};ph=yt([Ee(7,Gh),Ee(8,nl),Ee(9,ti),Ee(10,ei),Ee(11,fr),Ee(12,dn),Ee(13,ts)],ph);var mh=class extends Qe{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new we),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new d1(this._optionsService))}catch{this._measureStrategy=this._register(new h1(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())}};mh=yt([Ee(2,ti)],mh);var S_=class extends Qe{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},h1=class extends S_{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},d1=class extends S_{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}},f1=class extends Qe{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new p1(this._window)),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new we),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Ut.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register($e(this._textarea,"focus",()=>this._isFocused=!0)),this._register($e(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},p1=class extends Qe{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Jr),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ht(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=$e(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},m1=class extends Qe{constructor(){super(),this.linkProviders=[],this._register(ht(()=>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 rd(e,t,i){let s=i.getBoundingClientRect(),o=e.getComputedStyle(i),l=parseInt(o.getPropertyValue("padding-left")),c=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-l,t.clientY-s.top-c]}function g1(e,t,i,s,o,l,c,d,m){if(!l)return;let p=rd(e,t,i);if(p)return p[0]=Math.ceil((p[0]+(m?c/2:0))/c),p[1]=Math.ceil(p[1]/d),p[0]=Math.min(Math.max(p[0],1),s+(m?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var gh=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,o){return g1(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let i=rd(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};gh=yt([Ee(0,fn),Ee(1,nl)],gh);var v1=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},w_={};N0(w_,{getSafariVersion:()=>y1,isChromeOS:()=>k_,isFirefox:()=>b_,isIpad:()=>S1,isIphone:()=>w1,isLegacyEdge:()=>_1,isLinux:()=>sd,isMac:()=>Ga,isNode:()=>rl,isSafari:()=>C_,isWindows:()=>x_});var rl=typeof process<"u"&&"title"in process,co=rl?"node":navigator.userAgent,uo=rl?"node":navigator.platform,b_=co.includes("Firefox"),_1=co.includes("Edge"),C_=/^((?!chrome|android).)*safari/i.test(co);function y1(){if(!C_)return 0;let e=co.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Ga=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(uo),S1=uo==="iPad",w1=uo==="iPhone",x_=["Windows","Win16","Win32","WinCE"].includes(uo),sd=uo.indexOf("Linux")>=0,k_=/\bCrOS\b/.test(co),E_=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,s=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),o=e.timeRemaining(),i*1.5>o){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=o}this.clear()}},b1=class extends E_{_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())}}},C1=class extends E_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Qa=!rl&&"requestIdleCallback"in window?C1:b1,x1=class{constructor(){this._queue=new Qa}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},vh=class extends Qe{constructor(e,t,i,s,o,l,c,d,m){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=o,this._coreBrowserService=d,this._renderer=this._register(new Jr),this._pausedResizeTask=new x1,this._observerDisposable=this._register(new Jr),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 we),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new we),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new we),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new v1((p,S)=>this._renderRows(p,S),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new k1(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ht(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var p;return(p=this._renderer.value)==null?void 0:p.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(c.cols,c.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(c.buffer.y,c.buffer.y,!0))),this._register(m.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(p=>this._registerIntersectionObserver(p,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=ht(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};vh=yt([Ee(2,ti),Ee(3,nl),Ee(4,fr),Ee(5,lo),Ee(6,ei),Ee(7,dn),Ee(8,ts)],vh);var k1=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function E1(e,t,i,s){let o=i.buffer.x,l=i.buffer.y;if(!i.buffer.hasScrollback)return P1(o,l,e,t,i,s)+sl(l,t,i,s)+D1(o,l,e,t,i,s);let c;if(l===t)return c=o>e?"D":"C",ro(Math.abs(o-e),no(c,s));c=l>t?"D":"C";let d=Math.abs(l-t),m=R1(l>t?e:o,i)+(d-1)*i.cols+1+N1(l>t?o:e);return ro(m,no(c,s))}function N1(e,t){return e-1}function R1(e,t){return t.cols-e}function P1(e,t,i,s,o,l){return sl(t,s,o,l).length===0?"":ro(R_(e,t,e,t-hr(t,o),!1,o).length,no("D",l))}function sl(e,t,i,s){let o=e-hr(e,i),l=t-hr(t,i),c=Math.abs(o-l)-M1(e,t,i);return ro(c,no(N_(e,t),s))}function D1(e,t,i,s,o,l){let c;sl(t,s,o,l).length>0?c=s-hr(s,o):c=t;let d=s,m=L1(e,t,i,s,o,l);return ro(R_(e,c,i,d,m==="C",o).length,no(m,l))}function M1(e,t,i){var c;let s=0,o=e-hr(e,i),l=t-hr(t,i);for(let d=0;d<Math.abs(o-l);d++){let m=N_(e,t)==="A"?-1:1;(c=i.buffer.lines.get(o+m*d))!=null&&c.isWrapped&&s++}return s}function hr(e,t){let i=0,s=t.buffer.lines.get(e),o=s==null?void 0:s.isWrapped;for(;o&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),o=s==null?void 0:s.isWrapped;return i}function L1(e,t,i,s,o,l){let c;return sl(i,s,o,l).length>0?c=s-hr(s,o):c=t,e<i&&c<=s||e>=i&&c<s?"C":"D"}function N_(e,t){return e>t?"A":"B"}function R_(e,t,i,s,o,l){let c=e,d=t,m="";for(;(c!==i||d!==s)&&d>=0&&d<l.buffer.lines.length;)c+=o?1:-1,o&&c>l.cols-1?(m+=l.buffer.translateBufferLineToString(d,!1,e,c),c=0,e=0,d++):!o&&c<0&&(m+=l.buffer.translateBufferLineToString(d,!1,0,e+1),c=l.cols-1,e=c,d--);return m+l.buffer.translateBufferLineToString(d,!1,e,c)}function no(e,t){let i=t?"O":"[";return he.ESC+i+e}function ro(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var j1=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 $m(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 ou=50,T1=15,A1=50,B1=500,I1=" ",O1=new RegExp(I1,"g"),_h=class extends Qe{constructor(e,t,i,s,o,l,c,d,m){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=o,this._mouseService=l,this._optionsService=c,this._renderService=d,this._coreBrowserService=m,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Di,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new we),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new we),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new we),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=p=>this._handleMouseMove(p),this._mouseUpListener=p=>this._handleMouseUp(p),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(p=>this._handleTrim(p)),this._register(this._bufferService.buffers.onBufferActivate(p=>this._handleBufferActivate(p))),this.enable(),this._model=new j1(this._bufferService),this._activeSelectionMode=0,this._register(ht(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(p=>{p.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],l=e[0]<t[0]?t[0]:e[0];for(let c=e[1];c<=t[1];c++){let d=i.translateBufferLineToString(c,!0,o,l);s.push(d)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],o));for(let l=e[1]+1;l<=t[1]-1;l++){let c=i.lines.get(l),d=i.translateBufferLineToString(l,!0);c!=null&&c.isWrapped?s[s.length-1]+=d:s.push(d)}if(e[1]!==t[1]){let l=i.lines.get(t[1]),c=i.translateBufferLineToString(t[1],!0,0,t[0]);l&&l.isWrapped?s[s.length-1]+=c:s.push(c)}}return s.map(o=>o.replace(O1," ")).join(x_?`\r
|
|
59
|
+
`))}},ib=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},nb=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},rb=0,tu=class{constructor(e){this.value=e,this.id=rb++}},sb=2,ob,we=class{constructor(e){var t,i,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new eb((e==null?void 0:e.onListenerError)??Ta,((i=this._options)==null?void 0:i.leakWarningThreshold)??Z0):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new J0(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||i.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var c,d,m,p,S;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let C=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(C);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],v=new nb(`${C}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((c=this._options)==null?void 0:c.onListenerError)||Ta)(v),Qe.None}if(this._disposed)return Qe.None;t&&(e=e.bind(t));let s=new tu(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=tb.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof tu?(this._deliveryQueue??(this._deliveryQueue=new ab),this._listeners=[this._listeners,s]):this._listeners.push(s):((m=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||m.call(d,this),this._listeners=s,(S=(p=this._options)==null?void 0:p.onDidAddFirstListener)==null||S.call(p,this)),this._size++;let l=ht(()=>{o==null||o(),this._removeListener(s)});return i instanceof Fn?i.add(l):Array.isArray(i)&&i.push(l),l}),this._event}_removeListener(e){var o,l,c,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=(c=this._options)==null?void 0:c.onDidRemoveLastListener)==null||d.call(c,this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*sb<=t.length){let m=0;for(let p=0;p<t.length;p++)t[p]?t[m++]=t[p]:s&&(this._deliveryQueue.end--,m<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=m}}_deliver(e,t){var s;if(!e)return;let i=((s=this._options)==null?void 0:s.onListenerError)||Ta;if(!i){e.value(t);return}try{e.value(t)}catch(o){i(o)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,o;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof tu)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}},ab=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},ih=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new we,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new we,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};ih.INSTANCE=new ih;var Jh=ih;function lb(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Jh.INSTANCE.onDidChangeZoomLevel;function cb(e){return Jh.INSTANCE.getZoomFactor(e)}Jh.INSTANCE.onDidChangeFullscreen;var is=typeof navigator=="object"?navigator.userAgent:"",nh=is.indexOf("Firefox")>=0,ub=is.indexOf("AppleWebKit")>=0,Zh=is.indexOf("Chrome")>=0,hb=!Zh&&is.indexOf("Safari")>=0;is.indexOf("Electron/")>=0;is.indexOf("Android")>=0;var iu=!1;if(typeof hn.matchMedia=="function"){let e=hn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=hn.matchMedia("(display-mode: fullscreen)");iu=e.matches,lb(hn,e,({matches:i})=>{iu&&t.matches||(iu=i)})}var Kr="en",rh=!1,sh=!1,Aa=!1,f_=!1,ka,Ba=Kr,km=Kr,db,zi,cr=globalThis,Wt,wv;typeof cr.vscode<"u"&&typeof cr.vscode.process<"u"?Wt=cr.vscode.process:typeof process<"u"&&typeof((wv=process==null?void 0:process.versions)==null?void 0:wv.node)=="string"&&(Wt=process);var bv,fb=typeof((bv=Wt==null?void 0:Wt.versions)==null?void 0:bv.electron)=="string",pb=fb&&(Wt==null?void 0:Wt.type)==="renderer",Cv;if(typeof Wt=="object"){rh=Wt.platform==="win32",sh=Wt.platform==="darwin",Aa=Wt.platform==="linux",Aa&&Wt.env.SNAP&&Wt.env.SNAP_REVISION,Wt.env.CI||Wt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,ka=Kr,Ba=Kr;let e=Wt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);ka=t.userLocale,km=t.osLocale,Ba=t.resolvedLanguage||Kr,db=(Cv=t.languagePack)==null?void 0:Cv.translationsConfigFile}catch{}f_=!0}else typeof navigator=="object"&&!pb?(zi=navigator.userAgent,rh=zi.indexOf("Windows")>=0,sh=zi.indexOf("Macintosh")>=0,(zi.indexOf("Macintosh")>=0||zi.indexOf("iPad")>=0||zi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Aa=zi.indexOf("Linux")>=0,(zi==null?void 0:zi.indexOf("Mobi"))>=0,Ba=globalThis._VSCODE_NLS_LANGUAGE||Kr,ka=navigator.language.toLowerCase(),km=ka):console.error("Unable to resolve platform.");var p_=rh,Qi=sh,mb=Aa,Em=f_,Zi=zi,jn=Ba,gb;(e=>{function t(){return jn}e.value=t;function i(){return jn.length===2?jn==="en":jn.length>=3?jn[0]==="e"&&jn[1]==="n"&&jn[2]==="-":!1}e.isDefaultVariant=i;function s(){return jn==="en"}e.isDefault=s})(gb||(gb={}));var vb=typeof cr.postMessage=="function"&&!cr.importScripts;(()=>{if(vb){let e=[];cr.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let l=e[s];if(l.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),l.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),cr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var _b=!!(Zi&&Zi.indexOf("Chrome")>=0);Zi&&Zi.indexOf("Firefox")>=0;!_b&&Zi&&Zi.indexOf("Safari")>=0;Zi&&Zi.indexOf("Edg/")>=0;Zi&&Zi.indexOf("Android")>=0;var Fr=typeof navigator=="object"?navigator:{};Em||document.queryCommandSupported&&document.queryCommandSupported("copy")||Fr&&Fr.clipboard&&Fr.clipboard.writeText,Em||Fr&&Fr.clipboard&&Fr.clipboard.readText;var ed=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}},nu=new ed,Nm=new ed,Rm=new ed,yb=new Array(230),m_;(e=>{function t(d){return nu.keyCodeToStr(d)}e.toString=t;function i(d){return nu.strToKeyCode(d)}e.fromString=i;function s(d){return Nm.keyCodeToStr(d)}e.toUserSettingsUS=s;function o(d){return Rm.keyCodeToStr(d)}e.toUserSettingsGeneral=o;function l(d){return Nm.strToKeyCode(d)||Rm.strToKeyCode(d)}e.fromUserSettings=l;function c(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 nu.keyCodeToStr(d)}e.toElectronAccelerator=c})(m_||(m_={}));var Sb=class g_{constructor(t,i,s,o,l){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=o,this.keyCode=l}equals(t){return t instanceof g_&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${i}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new wb([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},wb=class{constructor(e){if(e.length===0)throw q0("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function bb(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return m_.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(nh)switch(t){case 59:return 85;case 60:if(mb)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Qi)return 57;break}else if(ub&&(Qi&&t===93||!Qi&&t===92))return 57;return yb[t]||0}var Cb=Qi?256:2048,xb=512,kb=1024,Eb=Qi?2048:256,Pm=class{constructor(e){var i;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=bb(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|=Cb),this.altKey&&(t|=xb),this.shiftKey&&(t|=kb),this.metaKey&&(t|=Eb),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Sb(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Dm=new WeakMap;function Nb(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var Rb=class{static getSameOriginWindowChain(e){let t=Dm.get(e);if(!t){t=[],Dm.set(e,t);let i=e,s;do s=Nb(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,o=this.getSameOriginWindowChain(e);for(let l of o){let c=l.window.deref();if(i+=(c==null?void 0:c.scrollY)??0,s+=(c==null?void 0:c.scrollX)??0,c===t||!l.iframeElement)break;let d=l.iframeElement.getBoundingClientRect();i+=d.top,s+=d.left}return{top:i,left:s}}},Ea=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=Rb.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Mm=class{constructor(e,t=0,i=0){var o;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(Zh){let l=navigator.userAgent.match(/Chrome\/(\d+)/);s=(l?parseInt(l[1]):123)<=122}if(e){let l=e,c=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 c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?nh&&!Qi?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof l.wheelDeltaX<"u")hb&&p_?this.deltaX=-(l.wheelDeltaX/120):s?this.deltaX=l.wheelDeltaX/(120*d):this.deltaX=l.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?nh&&!Qi?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},v_=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Pb;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Db?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ut.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:v_})})(Pb||(Pb={}));var Db=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?v_:(this._emitter||(this._emitter=new we),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},td=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 Qu("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Qu("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Mb=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new Qu("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=ht(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Lb;(e=>{async function t(s){let o,l=await Promise.all(s.map(c=>c.then(d=>d,d=>{o||(o=d)})));if(typeof o<"u")throw o;return l}e.settled=t;function i(s){return new Promise(async(o,l)=>{try{await s(o,l)}catch(c){l(c)}})}e.withAsyncBody=i})(Lb||(Lb={}));var Lm=class Ri{static fromArray(t){return new Ri(i=>{i.emitMany(t)})}static fromPromise(t){return new Ri(async i=>{i.emitMany(await t)})}static fromPromises(t){return new Ri(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new Ri(async i=>{await Promise.all(t.map(async s=>{for await(let o of s)i.emitOne(o)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new we,queueMicrotask(async()=>{let s={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(s)),this.resolve()}catch(o){this.reject(o)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Ut.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new Ri(async s=>{for await(let o of t)s.emitOne(i(o))})}map(t){return Ri.map(this,t)}static filter(t,i){return new Ri(async s=>{for await(let o of t)i(o)&&s.emitOne(o)})}filter(t){return Ri.filter(this,t)}static coalesce(t){return Ri.filter(t,i=>!!i)}coalesce(){return Ri.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return Ri.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Lm.EMPTY=Lm.fromArray([]);var{getWindow:Xi,getWindowId:jb,onDidRegisterWindow:Tb}=(function(){let e=new Map,t={window:hn,disposables:new Fn};e.set(hn.vscodeWindowId,t);let i=new we,s=new we,o=new we;function l(c,d){return(typeof c=="number"?e.get(c):void 0)??(d?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return Qe.None;let d=new Fn,m={window:c,disposables:d.add(new Fn)};return e.set(c.vscodeWindowId,m),d.add(ht(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),d.add($e(c,At.BEFORE_UNLOAD,()=>{o.fire(c)})),i.fire(m),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:l,getWindow(c){var p;let d=c;if((p=d==null?void 0:d.ownerDocument)!=null&&p.defaultView)return d.ownerDocument.defaultView.window;let m=c;return m!=null&&m.view?m.view.window:hn},getDocument(c){return Xi(c).document}}})(),Ab=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function $e(e,t,i,s){return new Ab(e,t,i,s)}var jm=function(e,t,i,s){return $e(e,t,i,s)},id,Bb=class extends Mb{constructor(e){super(),this.defaultTarget=e&&Xi(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Tm=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){Ta(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,o=l=>{i.set(l,!1);let c=e.get(l)??[];for(t.set(l,c),e.set(l,[]),s.set(l,!0);c.length>0;)c.sort(Tm.sort),c.shift().execute();s.set(l,!1)};id=(l,c,d=0)=>{let m=jb(l),p=new Tm(c,d),S=e.get(m);return S||(S=[],e.set(m,S)),S.push(p),i.get(m)||(i.set(m,!0),l.requestAnimationFrame(()=>o(m))),p}})();function Ib(e){let t=e.getBoundingClientRect(),i=Xi(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var At={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"},Ob=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let i=li(t);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let i=li(t);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(t){let i=li(t);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(t){let i=li(t);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(t){let i=li(t);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(t){let i=li(t);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(t){let i=li(t);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(t){let i=li(t);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let i=li(t);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let i=li(t);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let i=li(t);this._paddingRight!==i&&(this._paddingRight=i,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let i=li(t);this._fontSize!==i&&(this._fontSize=i,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let i=li(t);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let i=li(t);this._letterSpacing!==i&&(this._letterSpacing=i,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,i){this.domNode.classList.toggle(t,i),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,i){this.domNode.setAttribute(t,i)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function li(e){return typeof e=="number"?`${e}px`:e}function io(e){return new Ob(e)}var __=class{constructor(){this._hooks=new Fn,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let l=e;try{e.setPointerCapture(t),this._hooks.add(ht(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{l=Xi(e)}this._hooks.add($e(l,At.POINTER_MOVE,c=>{if(c.buttons!==i){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add($e(l,At.POINTER_UP,c=>this.stopMonitoring(!0)))}};function zb(e,t,i){let s=null,o=null;if(typeof i.value=="function"?(s="value",o=i.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",o=i.get),!o)throw new Error("not supported");let l=`$memoize$${t}`;i[s]=function(...c){return this.hasOwnProperty(l)||Object.defineProperty(this,l,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,c)}),this[l]}}var Yi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Yi||(Yi={}));var Qs=class Gt extends Qe{constructor(){super(),this.dispatched=!1,this.targets=new xm,this.ignoreTargets=new xm,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ut.runAndSubscribe(Tb,({window:t,disposables:i})=>{i.add($e(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add($e(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add($e(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:hn,disposables:this._store}))}static addTarget(t){if(!Gt.isTouchDevice())return Qe.None;Gt.INSTANCE||(Gt.INSTANCE=new Gt);let i=Gt.INSTANCE.targets.push(t);return ht(i)}static ignoreTarget(t){if(!Gt.isTouchDevice())return Qe.None;Gt.INSTANCE||(Gt.INSTANCE=new Gt);let i=Gt.INSTANCE.ignoreTargets.push(t);return ht(i)}static isTouchDevice(){return"ontouchstart"in hn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,o=t.targetTouches.length;s<o;s++){let l=t.targetTouches.item(s);this.activeTouches[l.identifier]={id:l.identifier,initialTarget:l.target,initialTimeStamp:i,initialPageX:l.pageX,initialPageY:l.pageY,rollingTimestamps:[i],rollingPageX:[l.pageX],rollingPageY:[l.pageY]};let c=this.newGestureEvent(Yi.Start,l.target);c.pageX=l.pageX,c.pageY=l.pageY,this.dispatchEvent(c)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let l=0,c=i.changedTouches.length;l<c;l++){let d=i.changedTouches.item(l);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("move of an UNKNOWN touch",d);continue}let m=this.activeTouches[d.identifier],p=Date.now()-m.initialTimeStamp;if(p<Gt.HOLD_DELAY&&Math.abs(m.initialPageX-gi(m.rollingPageX))<30&&Math.abs(m.initialPageY-gi(m.rollingPageY))<30){let S=this.newGestureEvent(Yi.Tap,m.initialTarget);S.pageX=gi(m.rollingPageX),S.pageY=gi(m.rollingPageY),this.dispatchEvent(S)}else if(p>=Gt.HOLD_DELAY&&Math.abs(m.initialPageX-gi(m.rollingPageX))<30&&Math.abs(m.initialPageY-gi(m.rollingPageY))<30){let S=this.newGestureEvent(Yi.Contextmenu,m.initialTarget);S.pageX=gi(m.rollingPageX),S.pageY=gi(m.rollingPageY),this.dispatchEvent(S)}else if(o===1){let S=gi(m.rollingPageX),C=gi(m.rollingPageY),_=gi(m.rollingTimestamps)-m.rollingTimestamps[0],v=S-m.rollingPageX[0],w=C-m.rollingPageY[0],b=[...this.targets].filter(x=>m.initialTarget instanceof Node&&x.contains(m.initialTarget));this.inertia(t,b,s,Math.abs(v)/_,v>0?1:-1,S,Math.abs(w)/_,w>0?1:-1,C)}this.dispatchEvent(this.newGestureEvent(Yi.End,m.initialTarget)),delete this.activeTouches[d.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===Yi.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Gt.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===Yi.Change||t.type===Yi.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];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;i.push([o,s])}i.sort((s,o)=>s[0]-o[0]);for(let[s,o]of i)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,o,l,c,d,m,p){this.handle=id(t,()=>{let S=Date.now(),C=S-s,_=0,v=0,w=!0;o+=Gt.SCROLL_FRICTION*C,d+=Gt.SCROLL_FRICTION*C,o>0&&(w=!1,_=l*o*C),d>0&&(w=!1,v=m*d*C);let b=this.newGestureEvent(Yi.Change);b.translationX=_,b.translationY=v,i.forEach(x=>x.dispatchEvent(b)),w||this.inertia(t,i,S,o,l,c+_,d,m,p+v)})}onTouchMove(t){let i=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 c=this.activeTouches[l.identifier],d=this.newGestureEvent(Yi.Change,c.initialTarget);d.translationX=l.pageX-gi(c.rollingPageX),d.translationY=l.pageY-gi(c.rollingPageY),d.pageX=l.pageX,d.pageY=l.pageY,this.dispatchEvent(d),c.rollingPageX.length>3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(l.pageX),c.rollingPageY.push(l.pageY),c.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Qs.SCROLL_FRICTION=-.005,Qs.HOLD_DELAY=700,Qs.CLEAR_TAP_COUNT_TIME=400,yt([zb],Qs,"isTouchDevice",1);var Fb=Qs,nd=class extends Qe{onclick(e,t){this._register($e(e,At.CLICK,i=>t(new Ea(Xi(e),i))))}onmousedown(e,t){this._register($e(e,At.MOUSE_DOWN,i=>t(new Ea(Xi(e),i))))}onmouseover(e,t){this._register($e(e,At.MOUSE_OVER,i=>t(new Ea(Xi(e),i))))}onmouseleave(e,t){this._register($e(e,At.MOUSE_LEAVE,i=>t(new Ea(Xi(e),i))))}onkeydown(e,t){this._register($e(e,At.KEY_DOWN,i=>t(new Pm(i))))}onkeyup(e,t){this._register($e(e,At.KEY_UP,i=>t(new Pm(i))))}oninput(e,t){this._register($e(e,At.INPUT,t))}onblur(e,t){this._register($e(e,At.BLUR,t))}onfocus(e,t){this._register($e(e,At.FOCUS,t))}onchange(e,t){this._register($e(e,At.CHANGE,t))}ignoreGesture(e){return Fb.ignoreTarget(e)}},Am=11,Hb=class extends nd{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=Am+"px",this.domNode.style.height=Am+"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 __),this._register(jm(this.bgDomNode,At.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(jm(this.domNode,At.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Bb),this._pointerdownScheduleRepeatTimer=this._register(new td)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Xi(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},$b=class oh{constructor(t,i,s,o,l,c,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,o=o|0,l=l|0,c=c|0,d=d|0),this.rawScrollLeft=o,this.rawScrollTop=d,i<0&&(i=0),o+i>s&&(o=s-i),o<0&&(o=0),l<0&&(l=0),d+l>c&&(d=c-l),d<0&&(d=0),this.width=i,this.scrollWidth=s,this.scrollLeft=o,this.height=l,this.scrollHeight=c,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,i){return new oh(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new oh(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,l=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,m=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:o,scrollLeftChanged:l,heightChanged:c,scrollHeightChanged:d,scrollTopChanged:m}}},Wb=class extends Qe{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new $b(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new Im(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=Im.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},Bm=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function ru(e,t){let i=t-e;return function(s){return e+i*qb(s)}}function Ub(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var Im=class ah{constructor(t,i,s,o){this.from=t,this.to=i,this.duration=o,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,s){if(Math.abs(t-i)>2.5*s){let o,l;return t<i?(o=t+.75*s,l=i-.75*s):(o=t-.75*s,l=i+.75*s),Ub(ru(t,o),ru(l,i),.33)}return ru(t,i)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),o=this.scrollTop(i);return new Bm(s,o,!1)}return new Bm(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return ah.start(t,i,s)}static start(t,i,s){s=s+10;let o=Date.now()-10;return new ah(t,i,o,s)}};function Kb(e){return Math.pow(e,3)}function qb(e){return 1-Kb(1-e)}var Vb=class extends Qe{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new td)}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":"")))}},Yb=140,y_=class extends nd{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 Vb(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new __),this._shouldRender=!0,this.domNode=io(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register($e(this.domNode.domNode,At.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Hb(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=io(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register($e(this.slider.domNode,At.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);i<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let o=Ib(this.domNode.domNode);t=e.pageX-o.left,i=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let l=this._sliderOrthogonalPointerPosition(o),c=Math.abs(l-i);if(p_&&c>Yb){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()}},S_=class lh{constructor(t,i,s,o,l,c){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=l,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new lh(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,o,l){let c=Math.max(0,s-t),d=Math.max(0,c-2*i),m=o>0&&o>s;if(!m)return{computedAvailableSize:Math.round(c),computedIsNeeded:m,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(s*d/o))),S=(d-p)/(o-s),C=l*S;return{computedAvailableSize:Math.round(c),computedIsNeeded:m,computedSliderSize:Math.round(p),computedSliderRatio:S,computedSliderPosition:Math.round(C)}}_refreshComputedValues(){let t=lh._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},Xb=class extends y_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new S_(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}},Gb=class extends y_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new S_(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}},Qb=500,Om=50,Jb=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},ch=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,i=0,s=1,o=this._rear;do{let l=o===this._front?t:Math.pow(2,-s);if(t-=l,i+=this._memory[o].score*l,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Zh){let i=Xi(t.browserEvent),s=cb(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let o=null,l=new Jb(t,i,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,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let o=Math.abs(t.deltaX),l=Math.abs(t.deltaY),c=Math.abs(i.deltaX),d=Math.abs(i.deltaY),m=Math.max(Math.min(o,c),1),p=Math.max(Math.min(l,d),1),S=Math.max(o,c),C=Math.max(l,d);S%m===0&&C%p===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};ch.INSTANCE=new ch;var Zb=ch,e1=class extends nd{constructor(e,t,i){super(),this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new we),this.onWillScroll=this._onWillScroll.event,this._options=i1(t),this._scrollable=i,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let s={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Gb(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Xb(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=io(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=io(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=io(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 td),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ur(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Qi&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Mm(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ur(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new Mm(i))};this._mouseWheelToDispose.push($e(this._listenOnDomNode,At.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=Zb.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let l=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+l===0?c=l=0:Math.abs(l)>=Math.abs(c)?c=0:l=0),this._options.flipAxes&&([l,c]=[c,l]);let d=!Qi&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!c&&(c=l,l=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,l=l*this._options.fastScrollSensitivity);let m=this._scrollable.getFutureScrollPosition(),p={};if(l){let S=Om*l,C=m.scrollTop-(S<0?Math.floor(S):Math.ceil(S));this._verticalScrollbar.writeScrollPosition(p,C)}if(c){let S=Om*c,C=m.scrollLeft-(S<0?Math.floor(S):Math.ceil(S));this._horizontalScrollbar.writeScrollPosition(p,C)}p=this._scrollable.validateScrollPosition(p),(m.scrollLeft!==p.scrollLeft||m.scrollTop!==p.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(p):this._scrollable.setScrollPositionNow(p),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",o=t?" top":"",l=i||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(),Qb)}},t1=class extends e1{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function i1(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,Qi&&(t.className+=" mac"),t}var uh=class extends Qe{constructor(e,t,i,s,o,l,c,d){super(),this._bufferService=i,this._optionsService=c,this._renderService=d,this._onRequestScrollLines=this._register(new we),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let m=this._register(new Wb({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>id(s.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{m.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new t1(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},m)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(p=>{this._scrollableElement.updateOptions({handleMouseWheel:!(p&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ut.runAndSubscribe(l.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=l.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ht(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ht(()=>this._styleElement.remove())),this._register(Ut.runAndSubscribe(l.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${l.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${l.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${l.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
60
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(p=>this._handleScroll(p)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};uh=yt([xe(2,ei),xe(3,dn),xe(4,e_),xe(5,ts),xe(6,ti),xe(7,fn)],uh);var hh=class extends Qe{constructor(e,t,i,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(l=>this._removeDecoration(l))),this._register(ht(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};hh=yt([xe(1,ei),xe(2,dn),xe(3,lo),xe(4,fn)],hh);var n1=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Ki={full:0,left:0,center:0,right:0},Tn={full:0,left:0,center:0,right:0},Hs={full:0,left:0,center:0,right:0},Ya=class extends Qe{constructor(e,t,i,s,o,l,c,d){var p;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=o,this._optionsService=l,this._themeService=c,this._coreBrowserService=d,this._colorZoneStore=new n1,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(),(p=this._viewportElement.parentElement)==null||p.insertBefore(this._canvas,this._viewportElement),this._register(ht(()=>{var S;return(S=this._canvas)==null?void 0:S.remove()}));let m=this._canvas.getContext("2d");if(m)this._ctx=m;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Tn.full=this._canvas.width,Tn.left=e,Tn.center=t,Tn.right=e,this._refreshDrawHeightConstants(),Hs.full=1,Hs.left=1,Hs.center=1+Tn.left,Hs.right=1+Tn.left+Tn.center}_refreshDrawHeightConstants(){Ki.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Ki.left=t,Ki.center=t,Ki.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Hs[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ki[e.position||"full"]/2),Tn[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ki[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Ya=yt([xe(2,ei),xe(3,lo),xe(4,fn),xe(5,ti),xe(6,ts),xe(7,dn)],Ya);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 Ia;(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=""))(Ia||(Ia={}));var w_;(e=>e.ST=`${he.ESC}\\`)(w_||(w_={}));var dh=class{constructor(e,t,i,s,o,l){this._textarea=e,this._compositionView=t,this._bufferService=i,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 i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${he.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let 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)}}};dh=yt([xe(2,ei),xe(3,ti),xe(4,fr),xe(5,fn)],dh);var Bt=0,It=0,Ot=0,_t=0,zm={css:"#00000000",rgba:0},kt;(e=>{function t(o,l,c,d){return d!==void 0?`#${tr(o)}${tr(l)}${tr(c)}${tr(d)}`:`#${tr(o)}${tr(l)}${tr(c)}`}e.toCss=t;function i(o,l,c,d=255){return(o<<24|l<<16|c<<8|d)>>>0}e.toRgba=i;function s(o,l,c,d){return{css:e.toCss(o,l,c,d),rgba:e.toRgba(o,l,c,d)}}e.toColor=s})(kt||(kt={}));var ct;(e=>{function t(m,p){if(_t=(p.rgba&255)/255,_t===1)return{css:p.css,rgba:p.rgba};let S=p.rgba>>24&255,C=p.rgba>>16&255,_=p.rgba>>8&255,v=m.rgba>>24&255,w=m.rgba>>16&255,b=m.rgba>>8&255;Bt=v+Math.round((S-v)*_t),It=w+Math.round((C-w)*_t),Ot=b+Math.round((_-b)*_t);let x=kt.toCss(Bt,It,Ot),N=kt.toRgba(Bt,It,Ot);return{css:x,rgba:N}}e.blend=t;function i(m){return(m.rgba&255)===255}e.isOpaque=i;function s(m,p,S){let C=Oa.ensureContrastRatio(m.rgba,p.rgba,S);if(C)return kt.toColor(C>>24&255,C>>16&255,C>>8&255)}e.ensureContrastRatio=s;function o(m){let p=(m.rgba|255)>>>0;return[Bt,It,Ot]=Oa.toChannels(p),{css:kt.toCss(Bt,It,Ot),rgba:p}}e.opaque=o;function l(m,p){return _t=Math.round(p*255),[Bt,It,Ot]=Oa.toChannels(m.rgba),{css:kt.toCss(Bt,It,Ot,_t),rgba:kt.toRgba(Bt,It,Ot,_t)}}e.opacity=l;function c(m,p){return _t=m.rgba&255,l(m,_t*p/255)}e.multiplyOpacity=c;function d(m){return[m.rgba>>24&255,m.rgba>>16&255,m.rgba>>8&255]}e.toColorRGB=d})(ct||(ct={}));var mt;(e=>{let t,i;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",i=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return Bt=parseInt(o.slice(1,2).repeat(2),16),It=parseInt(o.slice(2,3).repeat(2),16),Ot=parseInt(o.slice(3,4).repeat(2),16),kt.toColor(Bt,It,Ot);case 5:return Bt=parseInt(o.slice(1,2).repeat(2),16),It=parseInt(o.slice(2,3).repeat(2),16),Ot=parseInt(o.slice(3,4).repeat(2),16),_t=parseInt(o.slice(4,5).repeat(2),16),kt.toColor(Bt,It,Ot,_t);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 Bt=parseInt(l[1]),It=parseInt(l[2]),Ot=parseInt(l[3]),_t=Math.round((l[5]===void 0?1:parseFloat(l[5]))*255),kt.toColor(Bt,It,Ot,_t);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Bt,It,Ot,_t]=t.getImageData(0,0,1,1).data,_t!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:kt.toRgba(Bt,It,Ot,_t),css:o}}e.toColor=s})(mt||(mt={}));var Zt;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,o,l){let c=s/255,d=o/255,m=l/255,p=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),S=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),C=m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4);return p*.2126+S*.7152+C*.0722}e.relativeLuminance2=i})(Zt||(Zt={}));var Oa;(e=>{function t(c,d){if(_t=(d&255)/255,_t===1)return d;let m=d>>24&255,p=d>>16&255,S=d>>8&255,C=c>>24&255,_=c>>16&255,v=c>>8&255;return Bt=C+Math.round((m-C)*_t),It=_+Math.round((p-_)*_t),Ot=v+Math.round((S-v)*_t),kt.toRgba(Bt,It,Ot)}e.blend=t;function i(c,d,m){let p=Zt.relativeLuminance(c>>8),S=Zt.relativeLuminance(d>>8);if(cn(p,S)<m){if(S<p){let v=s(c,d,m),w=cn(p,Zt.relativeLuminance(v>>8));if(w<m){let b=o(c,d,m),x=cn(p,Zt.relativeLuminance(b>>8));return w>x?v:b}return v}let C=o(c,d,m),_=cn(p,Zt.relativeLuminance(C>>8));if(_<m){let v=s(c,d,m),w=cn(p,Zt.relativeLuminance(v>>8));return _>w?C:v}return C}}e.ensureContrastRatio=i;function s(c,d,m){let p=c>>24&255,S=c>>16&255,C=c>>8&255,_=d>>24&255,v=d>>16&255,w=d>>8&255,b=cn(Zt.relativeLuminance2(_,v,w),Zt.relativeLuminance2(p,S,C));for(;b<m&&(_>0||v>0||w>0);)_-=Math.max(0,Math.ceil(_*.1)),v-=Math.max(0,Math.ceil(v*.1)),w-=Math.max(0,Math.ceil(w*.1)),b=cn(Zt.relativeLuminance2(_,v,w),Zt.relativeLuminance2(p,S,C));return(_<<24|v<<16|w<<8|255)>>>0}e.reduceLuminance=s;function o(c,d,m){let p=c>>24&255,S=c>>16&255,C=c>>8&255,_=d>>24&255,v=d>>16&255,w=d>>8&255,b=cn(Zt.relativeLuminance2(_,v,w),Zt.relativeLuminance2(p,S,C));for(;b<m&&(_<255||v<255||w<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),b=cn(Zt.relativeLuminance2(_,v,w),Zt.relativeLuminance2(p,S,C));return(_<<24|v<<16|w<<8|255)>>>0}e.increaseLuminance=o;function l(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=l})(Oa||(Oa={}));function tr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function cn(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var r1=class extends ao{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Xa=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Di}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let i=[],s=t.translateToString(!0),o=0,l=0,c=0,d=t.getFg(0),m=t.getBg(0);for(let p=0;p<t.getTrimmedLength();p++)if(t.loadCell(p,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==d||this._workCell.bg!==m){if(p-o>1){let S=this._getJoinedRanges(s,c,l,t,o);for(let C=0;C<S.length;C++)i.push(S[C])}o=p,c=l,d=this._workCell.fg,m=this._workCell.bg}l+=this._workCell.getChars().length||On.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(s,c,l,t,o);for(let S=0;S<p.length;S++)i.push(p[S])}return i}_getJoinedRanges(e,t,i,s,o){let l=e.substring(t,i),c=[];try{c=this._characterJoiners[0].handler(l)}catch(d){console.error(d)}for(let d=1;d<this._characterJoiners.length;d++)try{let m=this._characterJoiners[d].handler(l);for(let p=0;p<m.length;p++)Xa._mergeRanges(c,m[p])}catch(m){console.error(m)}return this._stringRangesToCellRanges(c,s,o),c}_stringRangesToCellRanges(e,t,i){let s=0,o=!1,l=0,c=e[s];if(c){for(let d=i;d<this._bufferService.cols;d++){let m=t.getWidth(d),p=t.getString(d).length||On.length;if(m!==0){if(!o&&c[0]<=l&&(c[0]=d,o=!0),c[1]<=l){if(c[1]=d,c=e[++s],!c)break;c[0]<=l?(c[0]=d,o=!0):o=!1}l+=p}}c&&(c[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let o=e[s];if(i){if(t[1]<=o[0])return e[s-1][1]=t[1],e;if(t[1]<=o[1])return e[s-1][1]=Math.max(t[1],o[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=o[0])return e.splice(s,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};Xa=yt([xe(0,ei)],Xa);function s1(e){return 57508<=e&&e<=57558}function o1(e){return 9472<=e&&e<=9631}function a1(e){return s1(e)||o1(e)}function l1(){return{css:{canvas:Na(),cell:Na()},device:{canvas:Na(),cell:Na(),char:{width:0,height:0,left:0,top:0}}}}function Na(){return{width:0,height:0}}var fh=class{constructor(e,t,i,s,o,l,c){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=o,this._decorationService=l,this._themeService=c,this._workCell=new Di,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,o,l,c,d,m,p,S){let C=[],_=this._characterJoinerService.getJoinedCharacters(t),v=this._themeService.colors,w=e.getNoBgTrimmedLength();i&&w<l+1&&(w=l+1);let b,x=0,N="",L=0,j=0,T=0,Q=0,H=!1,I=0,G=!1,U=0,q=0,X=[],A=p!==-1&&S!==-1;for(let E=0;E<w;E++){e.loadCell(E,this._workCell);let R=this._workCell.getWidth();if(R===0)continue;let F=!1,D=E>=q,O=E,z=this._workCell;if(_.length>0&&E===_[0][0]&&D){let ge=_.shift(),Z=this._isCellInSelection(ge[0],t);for(L=ge[0]+1;L<ge[1];L++)D&&(D=Z===this._isCellInSelection(L,t));D&&(D=!i||l<ge[0]||l>=ge[1]),D?(F=!0,z=new r1(this._workCell,e.translateToString(!0,ge[0],ge[1]),ge[1]-ge[0]),O=ge[1]-1,R=z.getWidth()):q=ge[1]}let ie=this._isCellInSelection(E,t),K=i&&E===l,M=A&&E>=p&&E<=S,W=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ge=>{W=!0});let oe=z.getChars()||On;if(oe===" "&&(z.isUnderline()||z.isOverline())&&(oe=" "),U=R*d-m.get(oe,z.isBold(),z.isItalic()),!b)b=this._document.createElement("span");else if(x&&(ie&&G||!ie&&!G&&z.bg===j)&&(ie&&G&&v.selectionForeground||z.fg===T)&&z.extended.ext===Q&&M===H&&U===I&&!K&&!F&&!W&&D){z.isInvisible()?N+=On:N+=oe,x++;continue}else x&&(b.textContent=N),b=this._document.createElement("span"),x=0,N="";if(j=z.bg,T=z.fg,Q=z.extended.ext,H=M,I=U,G=ie,F&&l>=E&&l<=O&&(l=E),!this._coreService.isCursorHidden&&K&&this._coreService.isCursorInitialized){if(X.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&X.push("xterm-cursor-blink"),X.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":X.push("xterm-cursor-outline");break;case"block":X.push("xterm-cursor-block");break;case"bar":X.push("xterm-cursor-bar");break;case"underline":X.push("xterm-cursor-underline");break}}if(z.isBold()&&X.push("xterm-bold"),z.isItalic()&&X.push("xterm-italic"),z.isDim()&&X.push("xterm-dim"),z.isInvisible()?N=On:N=z.getChars()||On,z.isUnderline()&&(X.push(`xterm-underline-${z.extended.underlineStyle}`),N===" "&&(N=" "),!z.isUnderlineColorDefault()))if(z.isUnderlineColorRGB())b.style.textDecorationColor=`rgb(${ao.toColorRGB(z.getUnderlineColor()).join(",")})`;else{let ge=z.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&z.isBold()&&ge<8&&(ge+=8),b.style.textDecorationColor=v.ansi[ge].css}z.isOverline()&&(X.push("xterm-overline"),N===" "&&(N=" ")),z.isStrikethrough()&&X.push("xterm-strikethrough"),M&&(b.style.textDecoration="underline");let ae=z.getFgColor(),se=z.getFgColorMode(),le=z.getBgColor(),ye=z.getBgColorMode(),ce=!!z.isInverse();if(ce){let ge=ae;ae=le,le=ge;let Z=se;se=ye,ye=Z}let Y,ne,Te=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ge=>{ge.options.layer!=="top"&&Te||(ge.backgroundColorRGB&&(ye=50331648,le=ge.backgroundColorRGB.rgba>>8&16777215,Y=ge.backgroundColorRGB),ge.foregroundColorRGB&&(se=50331648,ae=ge.foregroundColorRGB.rgba>>8&16777215,ne=ge.foregroundColorRGB),Te=ge.options.layer==="top")}),!Te&&ie&&(Y=this._coreBrowserService.isFocused?v.selectionBackgroundOpaque:v.selectionInactiveBackgroundOpaque,le=Y.rgba>>8&16777215,ye=50331648,Te=!0,v.selectionForeground&&(se=50331648,ae=v.selectionForeground.rgba>>8&16777215,ne=v.selectionForeground)),Te&&X.push("xterm-decoration-top");let De;switch(ye){case 16777216:case 33554432:De=v.ansi[le],X.push(`xterm-bg-${le}`);break;case 50331648:De=kt.toColor(le>>16,le>>8&255,le&255),this._addStyle(b,`background-color:#${Fm((le>>>0).toString(16),"0",6)}`);break;case 0:default:ce?(De=v.foreground,X.push("xterm-bg-257")):De=v.background}switch(Y||z.isDim()&&(Y=ct.multiplyOpacity(De,.5)),se){case 16777216:case 33554432:z.isBold()&&ae<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ae+=8),this._applyMinimumContrast(b,De,v.ansi[ae],z,Y,void 0)||X.push(`xterm-fg-${ae}`);break;case 50331648:let ge=kt.toColor(ae>>16&255,ae>>8&255,ae&255);this._applyMinimumContrast(b,De,ge,z,Y,ne)||this._addStyle(b,`color:#${Fm(ae.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(b,De,v.foreground,z,Y,ne)||ce&&X.push("xterm-fg-257")}X.length&&(b.className=X.join(" "),X.length=0),!K&&!F&&!W&&D?x++:b.textContent=N,U!==this.defaultSpacing&&(b.style.letterSpacing=`${U}px`),C.push(b),E=O}return b&&x&&(b.textContent=N),C}_applyMinimumContrast(e,t,i,s,o,l){if(this._optionsService.rawOptions.minimumContrastRatio===1||a1(s.getCode()))return!1;let c=this._getContrastCache(s),d;if(!o&&!l&&(d=c.getColor(t.rgba,i.rgba)),d===void 0){let m=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);d=ct.ensureContrastRatio(o||t,l||i,m),c.setColor((o||t).rgba,(l||i).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 i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};fh=yt([xe(1,n_),xe(2,ti),xe(3,dn),xe(4,fr),xe(5,lo),xe(6,ts)],fh);function Fm(e,t,i){for(;e.length<i;)e=t+e;return e}var c1=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.style.fontWeight="bold",l.style.fontStyle="italic",this._measureElements=[i,s,o,l],this._container.appendChild(i),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,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let c=this._measure(e,0);return c>0&&(this._flat[s]=c),c}let o=e;t&&(o+="B"),i&&(o+="I");let l=this._holey.get(o);if(l===void 0){let c=0;t&&(c|=1),i&&(c|=2),l=this._measure(e,c),l>0&&this._holey.set(o,l)}return l}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},u1=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let o=e.buffers.active.ydisp,l=t[1]-o,c=i[1]-o,d=Math.max(l,0),m=Math.min(c,e.rows-1);if(d>=e.rows||m<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=l,this.viewportEndRow=c,this.viewportCappedStartRow=d,this.viewportCappedEndRow=m,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function h1(){return new u1}var su="xterm-dom-renderer-owner-",Ni="xterm-rows",Ra="xterm-fg-",Hm="xterm-bg-",$s="xterm-focus",Pa="xterm-selection",d1=1,ph=class extends Qe{constructor(e,t,i,s,o,l,c,d,m,p,S,C,_,v){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=o,this._helperContainer=l,this._linkifier2=c,this._charSizeService=m,this._optionsService=p,this._bufferService=S,this._coreService=C,this._coreBrowserService=_,this._themeService=v,this._terminalClass=d1++,this._rowElements=[],this._selectionRenderModel=h1(),this.onRequestRedraw=this._register(new we).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ni),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Pa),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=l1(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(w=>this._injectCss(w))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(fh,document),this._element.classList.add(su+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(w=>this._handleLinkHover(w))),this._register(this._linkifier2.onHideLinkUnderline(w=>this._handleLinkLeave(w))),this._register(ht(()=>{this._element.classList.remove(su+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new c1(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Ni} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Ni} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Ni} .xterm-dim { color: ${ct.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Ni}.${$s} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ni}.${$s} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ni}.${$s} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Pa} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Pa} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Pa} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[l,c]of e.ansi.entries())t+=`${this._terminalSelector} .${Ra}${l} { color: ${c.css}; }${this._terminalSelector} .${Ra}${l}.xterm-dim { color: ${ct.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Hm}${l} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${Ra}257 { color: ${ct.opaque(e.background).css}; }${this._terminalSelector} .${Ra}257.xterm-dim { color: ${ct.multiplyOpacity(ct.opaque(e.background),.5).css}; }${this._terminalSelector} .${Hm}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove($s),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add($s),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,l=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(i){let m=e[0]>t[0];d.appendChild(this._createSelectionElement(l,m?t[0]:e[0],m?e[0]:t[0],c-l+1))}else{let m=s===l?e[0]:0,p=l===o?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(l,m,p));let S=c-l-1;if(d.appendChild(this._createSelectionElement(l+1,0,this._bufferService.cols,S)),l!==c){let C=o===c?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(c,0,C))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,i,s=1){let o=this._document.createElement("div"),l=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(i-t);return l+c>this.dimensions.css.canvas.width&&(c=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=`${c}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,o=Math.min(i.x,this._bufferService.cols-1),l=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=e;m<=t;m++){let p=m+i.ydisp,S=this._rowElements[m],C=i.lines.get(p);if(!S||!C)break;S.replaceChildren(...this._rowFactory.createRow(C,p,p===s,c,d,o,l,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${su}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,o,l){i<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;i=Math.max(Math.min(i,c),0),s=Math.max(Math.min(s,c),0),o=Math.min(o,this._bufferService.cols);let d=this._bufferService.buffer,m=d.ybase+d.y,p=Math.min(d.x,o-1),S=this._optionsService.rawOptions.cursorBlink,C=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let v=i;v<=s;++v){let w=v+d.ydisp,b=this._rowElements[v],x=d.lines.get(w);if(!b||!x)break;b.replaceChildren(...this._rowFactory.createRow(x,w,w===m,C,_,p,S,this.dimensions.css.cell.width,this._widthCache,l?v===i?e:0:-1,l?(v===s?t:o)-1:-1))}}};ph=yt([xe(7,Gh),xe(8,nl),xe(9,ti),xe(10,ei),xe(11,fr),xe(12,dn),xe(13,ts)],ph);var mh=class extends Qe{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new we),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new p1(this._optionsService))}catch{this._measureStrategy=this._register(new f1(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())}};mh=yt([xe(2,ti)],mh);var b_=class extends Qe{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},f1=class extends b_{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},p1=class extends b_{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}},m1=class extends Qe{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new g1(this._window)),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new we),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Ut.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register($e(this._textarea,"focus",()=>this._isFocused=!0)),this._register($e(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},g1=class extends Qe{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Jr),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ht(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=$e(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},v1=class extends Qe{constructor(){super(),this.linkProviders=[],this._register(ht(()=>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 rd(e,t,i){let s=i.getBoundingClientRect(),o=e.getComputedStyle(i),l=parseInt(o.getPropertyValue("padding-left")),c=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-l,t.clientY-s.top-c]}function _1(e,t,i,s,o,l,c,d,m){if(!l)return;let p=rd(e,t,i);if(p)return p[0]=Math.ceil((p[0]+(m?c/2:0))/c),p[1]=Math.ceil(p[1]/d),p[0]=Math.min(Math.max(p[0],1),s+(m?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var gh=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,o){return _1(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let i=rd(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};gh=yt([xe(0,fn),xe(1,nl)],gh);var y1=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},C_={};P0(C_,{getSafariVersion:()=>w1,isChromeOS:()=>N_,isFirefox:()=>x_,isIpad:()=>b1,isIphone:()=>C1,isLegacyEdge:()=>S1,isLinux:()=>sd,isMac:()=>Ga,isNode:()=>rl,isSafari:()=>k_,isWindows:()=>E_});var rl=typeof process<"u"&&"title"in process,co=rl?"node":navigator.userAgent,uo=rl?"node":navigator.platform,x_=co.includes("Firefox"),S1=co.includes("Edge"),k_=/^((?!chrome|android).)*safari/i.test(co);function w1(){if(!k_)return 0;let e=co.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Ga=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(uo),b1=uo==="iPad",C1=uo==="iPhone",E_=["Windows","Win16","Win32","WinCE"].includes(uo),sd=uo.indexOf("Linux")>=0,N_=/\bCrOS\b/.test(co),R_=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,s=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),o=e.timeRemaining(),i*1.5>o){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=o}this.clear()}},x1=class extends R_{_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())}}},k1=class extends R_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Qa=!rl&&"requestIdleCallback"in window?k1:x1,E1=class{constructor(){this._queue=new Qa}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},vh=class extends Qe{constructor(e,t,i,s,o,l,c,d,m){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=o,this._coreBrowserService=d,this._renderer=this._register(new Jr),this._pausedResizeTask=new E1,this._observerDisposable=this._register(new Jr),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 we),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new we),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new we),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new y1((p,S)=>this._renderRows(p,S),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new N1(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ht(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var p;return(p=this._renderer.value)==null?void 0:p.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(c.cols,c.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(c.buffer.y,c.buffer.y,!0))),this._register(m.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(p=>this._registerIntersectionObserver(p,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=ht(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};vh=yt([xe(2,ti),xe(3,nl),xe(4,fr),xe(5,lo),xe(6,ei),xe(7,dn),xe(8,ts)],vh);var N1=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function R1(e,t,i,s){let o=i.buffer.x,l=i.buffer.y;if(!i.buffer.hasScrollback)return M1(o,l,e,t,i,s)+sl(l,t,i,s)+L1(o,l,e,t,i,s);let c;if(l===t)return c=o>e?"D":"C",ro(Math.abs(o-e),no(c,s));c=l>t?"D":"C";let d=Math.abs(l-t),m=D1(l>t?e:o,i)+(d-1)*i.cols+1+P1(l>t?o:e);return ro(m,no(c,s))}function P1(e,t){return e-1}function D1(e,t){return t.cols-e}function M1(e,t,i,s,o,l){return sl(t,s,o,l).length===0?"":ro(D_(e,t,e,t-hr(t,o),!1,o).length,no("D",l))}function sl(e,t,i,s){let o=e-hr(e,i),l=t-hr(t,i),c=Math.abs(o-l)-j1(e,t,i);return ro(c,no(P_(e,t),s))}function L1(e,t,i,s,o,l){let c;sl(t,s,o,l).length>0?c=s-hr(s,o):c=t;let d=s,m=T1(e,t,i,s,o,l);return ro(D_(e,c,i,d,m==="C",o).length,no(m,l))}function j1(e,t,i){var c;let s=0,o=e-hr(e,i),l=t-hr(t,i);for(let d=0;d<Math.abs(o-l);d++){let m=P_(e,t)==="A"?-1:1;(c=i.buffer.lines.get(o+m*d))!=null&&c.isWrapped&&s++}return s}function hr(e,t){let i=0,s=t.buffer.lines.get(e),o=s==null?void 0:s.isWrapped;for(;o&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),o=s==null?void 0:s.isWrapped;return i}function T1(e,t,i,s,o,l){let c;return sl(i,s,o,l).length>0?c=s-hr(s,o):c=t,e<i&&c<=s||e>=i&&c<s?"C":"D"}function P_(e,t){return e>t?"A":"B"}function D_(e,t,i,s,o,l){let c=e,d=t,m="";for(;(c!==i||d!==s)&&d>=0&&d<l.buffer.lines.length;)c+=o?1:-1,o&&c>l.cols-1?(m+=l.buffer.translateBufferLineToString(d,!1,e,c),c=0,e=0,d++):!o&&c<0&&(m+=l.buffer.translateBufferLineToString(d,!1,0,e+1),c=l.cols-1,e=c,d--);return m+l.buffer.translateBufferLineToString(d,!1,e,c)}function no(e,t){let i=t?"O":"[";return he.ESC+i+e}function ro(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var A1=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 $m(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 ou=50,B1=15,I1=50,O1=500,z1=" ",F1=new RegExp(z1,"g"),_h=class extends Qe{constructor(e,t,i,s,o,l,c,d,m){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=o,this._mouseService=l,this._optionsService=c,this._renderService=d,this._coreBrowserService=m,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Di,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new we),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new we),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new we),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=p=>this._handleMouseMove(p),this._mouseUpListener=p=>this._handleMouseUp(p),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(p=>this._handleTrim(p)),this._register(this._bufferService.buffers.onBufferActivate(p=>this._handleBufferActivate(p))),this.enable(),this._model=new A1(this._bufferService),this._activeSelectionMode=0,this._register(ht(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(p=>{p.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],l=e[0]<t[0]?t[0]:e[0];for(let c=e[1];c<=t[1];c++){let d=i.translateBufferLineToString(c,!0,o,l);s.push(d)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],o));for(let l=e[1]+1;l<=t[1]-1;l++){let c=i.lines.get(l),d=i.translateBufferLineToString(l,!0);c!=null&&c.isWrapped?s[s.length-1]+=d:s.push(d)}if(e[1]!==t[1]){let l=i.lines.get(t[1]),c=i.translateBufferLineToString(t[1],!0,0,t[0]);l&&l.isWrapped?s[s.length-1]+=c:s.push(c)}}return s.map(o=>o.replace(F1," ")).join(E_?`\r
|
|
62
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())),sd&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var o,l;let i=(l=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:l.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=$m(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=rd(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-ou),ou),t/=ou,t/Math.abs(t)+Math.round(t*(T1-1)))}shouldForceSelection(e){return Ga?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(),A1)}_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&&!(Ga&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<B1&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=E1(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:o>1&&t!==s&&(i+=o-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,l=o.lines.get(e[1]);if(!l)return;let c=o.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(l,e[0]),m=d,p=e[0]-d,S=0,C=0,_=0,v=0;if(c.charAt(d)===" "){for(;d>0&&c.charAt(d-1)===" ";)d--;for(;m<c.length&&c.charAt(m+1)===" ";)m++}else{let x=e[0],N=e[0];l.getWidth(x)===0&&(S++,x--),l.getWidth(N)===2&&(C++,N++);let L=l.getString(N).length;for(L>1&&(v+=L-1,m+=L-1);x>0&&d>0&&!this._isCharWordSeparator(l.loadCell(x-1,this._workCell));){l.loadCell(x-1,this._workCell);let j=this._workCell.getChars().length;this._workCell.getWidth()===0?(S++,x--):j>1&&(_+=j-1,d-=j-1),d--,x--}for(;N<l.length&&m+1<c.length&&!this._isCharWordSeparator(l.loadCell(N+1,this._workCell));){l.loadCell(N+1,this._workCell);let j=this._workCell.getChars().length;this._workCell.getWidth()===2?(C++,N++):j>1&&(v+=j-1,m+=j-1),m++,N++}}m++;let w=d+p-S+_,b=Math.min(this._bufferService.cols,m-d+S+C-_-v);if(!(!t&&c.slice(d,m).trim()==="")){if(i&&w===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 N=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(N){let L=this._bufferService.cols-N.start;w-=L,b+=L}}}if(s&&w+b===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 N=this._getWordAt([0,e[1]+1],!1,!1,!0);N&&(b+=N.length)}}return{start:w,length:b}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=$m(i,this._bufferService.cols)}};_h=yt([Ee(3,ei),Ee(4,fr),Ee(5,Qh),Ee(6,ti),Ee(7,fn),Ee(8,dn)],_h);var Wm=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Um=class{constructor(){this._color=new Wm,this._css=new Wm}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Rt=Object.freeze((()=>{let e=[mt.toColor("#2e3436"),mt.toColor("#cc0000"),mt.toColor("#4e9a06"),mt.toColor("#c4a000"),mt.toColor("#3465a4"),mt.toColor("#75507b"),mt.toColor("#06989a"),mt.toColor("#d3d7cf"),mt.toColor("#555753"),mt.toColor("#ef2929"),mt.toColor("#8ae234"),mt.toColor("#fce94f"),mt.toColor("#729fcf"),mt.toColor("#ad7fa8"),mt.toColor("#34e2e2"),mt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],o=t[i/6%6|0],l=t[i%6];e.push({css:kt.toCss(s,o,l),rgba:kt.toRgba(s,o,l)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:kt.toCss(s,s,s),rgba:kt.toRgba(s,s,s)})}return e})()),nr=mt.toColor("#ffffff"),Js=mt.toColor("#000000"),Km=mt.toColor("#ffffff"),qm=Js,Ws={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},z1=nr,yh=class extends Qe{constructor(e){super(),this._optionsService=e,this._contrastCache=new Um,this._halfContrastCache=new Um,this._onChangeColors=this._register(new we),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:nr,background:Js,cursor:Km,cursorAccent:qm,selectionForeground:void 0,selectionBackgroundTransparent:Ws,selectionBackgroundOpaque:ct.blend(Js,Ws),selectionInactiveBackgroundTransparent:Ws,selectionInactiveBackgroundOpaque:ct.blend(Js,Ws),scrollbarSliderBackground:ct.opacity(nr,.2),scrollbarSliderHoverBackground:ct.opacity(nr,.4),scrollbarSliderActiveBackground:ct.opacity(nr,.5),overviewRulerBorder:nr,ansi:Rt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=st(e.foreground,nr),t.background=st(e.background,Js),t.cursor=ct.blend(t.background,st(e.cursor,Km)),t.cursorAccent=ct.blend(t.background,st(e.cursorAccent,qm)),t.selectionBackgroundTransparent=st(e.selectionBackground,Ws),t.selectionBackgroundOpaque=ct.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=st(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ct.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?st(e.selectionForeground,zm):void 0,t.selectionForeground===zm&&(t.selectionForeground=void 0),ct.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ct.opacity(t.selectionBackgroundTransparent,.3)),ct.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ct.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=st(e.scrollbarSliderBackground,ct.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=st(e.scrollbarSliderHoverBackground,ct.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=st(e.scrollbarSliderActiveBackground,ct.opacity(t.foreground,.5)),t.overviewRulerBorder=st(e.overviewRulerBorder,z1),t.ansi=Rt.slice(),t.ansi[0]=st(e.black,Rt[0]),t.ansi[1]=st(e.red,Rt[1]),t.ansi[2]=st(e.green,Rt[2]),t.ansi[3]=st(e.yellow,Rt[3]),t.ansi[4]=st(e.blue,Rt[4]),t.ansi[5]=st(e.magenta,Rt[5]),t.ansi[6]=st(e.cyan,Rt[6]),t.ansi[7]=st(e.white,Rt[7]),t.ansi[8]=st(e.brightBlack,Rt[8]),t.ansi[9]=st(e.brightRed,Rt[9]),t.ansi[10]=st(e.brightGreen,Rt[10]),t.ansi[11]=st(e.brightYellow,Rt[11]),t.ansi[12]=st(e.brightBlue,Rt[12]),t.ansi[13]=st(e.brightMagenta,Rt[13]),t.ansi[14]=st(e.brightCyan,Rt[14]),t.ansi[15]=st(e.brightWhite,Rt[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=st(e.extendedAnsi[s],Rt[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};yh=yt([Ee(0,ti)],yh);function st(e,t){if(e!==void 0)try{return mt.toColor(e)}catch{}return t}var F1=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},H1=class{constructor(){this._services=new F1,this._services.set(Gh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=T0(e).sort((l,c)=>l.index-c.index),s=[];for(let l of i){let c=this._services.get(l.id);if(!c)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${l.id._id}.`);s.push(c)}let o=i.length>0?i[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},$1={trace:0,debug:1,info:2,warn:3,error:4,off:5},W1="xterm.js: ",Sh=class extends Qe{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=$1[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":W1)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Sh=yt([Ee(0,ti)],Sh);var Vm=class extends Qe{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new we),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new we),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new we),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let o=t-1;o>=0;o--)this.set(e+o+i,this.get(e+o));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Ge=3,xt=Object.freeze(new ao),Da=0,au=2,Zs=class P_{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Ge);let o=i||Di.fromCharData([0,Yv,1,0]);for(let l=0;l<t;++l)this.setCell(l,o);this.length=t}get(t){let i=this._data[t*Ge+0],s=i&2097151;return[this._data[t*Ge+1],i&2097152?this._combined[t]:s?In(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*Ge+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*Ge+0]=t|2097152|i[2]<<22):this._data[t*Ge+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*Ge+0]>>22}hasWidth(t){return this._data[t*Ge+0]&12582912}getFg(t){return this._data[t*Ge+1]}getBg(t){return this._data[t*Ge+2]}hasContent(t){return this._data[t*Ge+0]&4194303}getCodePoint(t){let i=this._data[t*Ge+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*Ge+0]&2097152}getString(t){let i=this._data[t*Ge+0];return i&2097152?this._combined[t]:i&2097151?In(i&2097151):""}isProtected(t){return this._data[t*Ge+2]&536870912}loadCell(t,i){return Da=t*Ge,i.content=this._data[Da+0],i.fg=this._data[Da+1],i.bg=this._data[Da+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*Ge+0]=i.content,this._data[t*Ge+1]=i.fg,this._data[t*Ge+2]=i.bg}setCellFromCodepoint(t,i,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*Ge+0]=i|s<<22,this._data[t*Ge+1]=o.fg,this._data[t*Ge+2]=o.bg}addCodepointToCell(t,i,s){let o=this._data[t*Ge+0];o&2097152?this._combined[t]+=In(i):o&2097151?(this._combined[t]=In(o&2097151)+In(i),o&=-2097152,o|=2097152):o=i|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*Ge+0]=o}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let o=new Di;for(let l=this.length-t-i-1;l>=0;--l)this.setCell(t+i+l,this.loadCell(t+l,o));for(let l=0;l<i;++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,i,s){if(t%=this.length,i<this.length-t){let o=new Di;for(let l=0;l<this.length-t-i;++l)this.setCell(t+l,this.loadCell(t+i+l,o));for(let l=this.length-i;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,i,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*au<this._data.buffer.byteLength;let s=t*Ge;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,i)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let c=0;c<o.length;c++){let d=parseInt(o[c],10);d>=t&&delete this._combined[d]}let l=Object.keys(this._extendedAttrs);for(let c=0;c<l.length;c++){let d=parseInt(l[c],10);d>=t&&delete this._extendedAttrs[d]}}return this.length=t,s*4*au<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*au<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new P_(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ge+0]&4194303)return t+(this._data[t*Ge+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ge+0]&4194303||this._data[t*Ge+2]&50331648)return t+(this._data[t*Ge+0]>>22);return 0}copyCellsFrom(t,i,s,o,l){let c=t._data;if(l)for(let m=o-1;m>=0;m--){for(let p=0;p<Ge;p++)this._data[(s+m)*Ge+p]=c[(i+m)*Ge+p];c[(i+m)*Ge+2]&268435456&&(this._extendedAttrs[s+m]=t._extendedAttrs[i+m])}else for(let m=0;m<o;m++){for(let p=0;p<Ge;p++)this._data[(s+m)*Ge+p]=c[(i+m)*Ge+p];c[(i+m)*Ge+2]&268435456&&(this._extendedAttrs[s+m]=t._extendedAttrs[i+m])}let d=Object.keys(t._combined);for(let m=0;m<d.length;m++){let p=parseInt(d[m],10);p>=i&&(this._combined[p-i+s]=t._combined[p])}}translateToString(t,i,s,o){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let l="";for(;i<s;){let c=this._data[i*Ge+0],d=c&2097151,m=c&2097152?this._combined[i]:d?In(d):On;if(l+=m,o)for(let p=0;p<m.length;++p)o.push(i);i+=c>>22||1}return o&&o.push(i),l}};function U1(e,t,i,s,o,l){let c=[];for(let d=0;d<e.length-1;d++){let m=d,p=e.get(++m);if(!p.isWrapped)continue;let S=[e.get(d)];for(;m<e.length&&p.isWrapped;)S.push(p),p=e.get(++m);if(!l&&s>=d&&s<m){d+=S.length-1;continue}let C=0,_=so(S,C,t),v=1,w=0;for(;v<S.length;){let x=so(S,v,t),N=x-w,L=i-_,j=Math.min(N,L);S[C].copyCellsFrom(S[v],w,_,j,!1),_+=j,_===i&&(C++,_=0),w+=j,w===x&&(v++,w=0),_===0&&C!==0&&S[C-1].getWidth(i-1)===2&&(S[C].copyCellsFrom(S[C-1],i-1,_++,1,!1),S[C-1].setCell(i-1,o))}S[C].replaceCells(_,i,o);let b=0;for(let x=S.length-1;x>0&&(x>C||S[x].getTrimmedLength()===0);x--)b++;b>0&&(c.push(d+S.length-b),c.push(b)),d+=S.length-1}return c}function K1(e,t){let i=[],s=0,o=t[s],l=0;for(let c=0;c<e.length;c++)if(o===c){let d=t[++s];e.onDeleteEmitter.fire({index:c-l,amount:d}),c+=d-1,l+=d,o=t[++s]}else i.push(c);return{layout:i,countRemoved:l}}function q1(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function V1(e,t,i){let s=[],o=e.map((m,p)=>so(e,p,t)).reduce((m,p)=>m+p),l=0,c=0,d=0;for(;d<o;){if(o-d<i){s.push(o-d);break}l+=i;let m=so(e,c,t);l>m&&(l-=m,c++);let p=e[c].getWidth(l-1)===2;p&&l--;let S=p?i-1:i;s.push(S),d+=S}return s}function so(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?i-1:i}var D_=class M_{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=M_._nextId++,this._onDispose=this.register(new we),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ur(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};D_._nextId=1;var Y1=D_,Dt={},rr=Dt.B;Dt[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Dt.A={"#":"£"};Dt.B=void 0;Dt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Dt.C=Dt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Dt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Dt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Dt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Dt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Dt.E=Dt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Dt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Dt.H=Dt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Dt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Ym=4294967295,Xm=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=xt.clone(),this.savedCharset=rr,this.markers=[],this._nullCell=Di.fromCharData([0,Yv,1,0]),this._whitespaceCell=Di.fromCharData([0,On,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Qa,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Vm(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 Va),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 Va),this._whitespaceCell}getBlankLine(e,t){return new Zs(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>Ym?Ym:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=xt);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Vm(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(xt),s=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let c=0;c<this.lines.length;c++)s+=+this.lines.get(c).resize(e,i);let l=0;if(this._rows<t)for(let c=this._rows;c<t;c++)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 Zs(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+l+1?(this.ybase--,l++,this.ydisp>0&&this.ydisp--):this.lines.push(new Zs(e,i)));else for(let c=this._rows;c>t;c--)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 c=this.lines.length-o;c>0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,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,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=U1(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(xt),i);if(s.length>0){let o=K1(this.lines,s);q1(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(xt),o=i;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Zs(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(xt),o=[],l=0;for(let c=this.lines.length-1;c>=0;c--){let d=this.lines.get(c);if(!d||!d.isWrapped&&d.getTrimmedLength()<=e)continue;let m=[d];for(;d.isWrapped&&c>0;)d=this.lines.get(--c),m.unshift(d);if(!i){let j=this.ybase+this.y;if(j>=c&&j<c+m.length)continue}let p=m[m.length-1].getTrimmedLength(),S=V1(m,this._cols,e),C=S.length-m.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+C):_=Math.max(0,this.lines.length-this.lines.maxLength+C);let v=[];for(let j=0;j<C;j++){let T=this.getBlankLine(xt,!0);v.push(T)}v.length>0&&(o.push({start:c+m.length+l,newLines:v}),l+=v.length),m.push(...v);let w=S.length-1,b=S[w];b===0&&(w--,b=S[w]);let x=m.length-C-1,N=p;for(;x>=0;){let j=Math.min(N,b);if(m[w]===void 0)break;if(m[w].copyCellsFrom(m[x],N-j,b-j,j,!0),b-=j,b===0&&(w--,b=S[w]),N-=j,N===0){x--;let T=Math.max(x,0);N=so(m,T,this._cols)}}for(let j=0;j<m.length;j++)S[j]<e&&m[j].setCell(S[j],s);let L=C-_;for(;L-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+l)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+C,this.ybase+t-1)}if(o.length>0){let c=[],d=[];for(let b=0;b<this.lines.length;b++)d.push(this.lines.get(b));let m=this.lines.length,p=m-1,S=0,C=o[S];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+l);let _=0;for(let b=Math.min(this.lines.maxLength-1,m+l-1);b>=0;b--)if(C&&C.start>p+_){for(let x=C.newLines.length-1;x>=0;x--)this.lines.set(b--,C.newLines[x]);b++,c.push({index:p+1,amount:C.newLines.length}),_+=C.newLines.length,C=o[++S]}else this.lines.set(b,d[p--]);let v=0;for(let b=c.length-1;b>=0;b--)c[b].index+=v,this.lines.onInsertEmitter.fire(c[b]),v+=c[b].amount;let w=Math.max(0,m+l-this.lines.maxLength);w>0&&this.lines.onTrimEmitter.fire(w)}}translateBufferLineToString(e,t,i=0,s){let o=this.lines.get(e);return o?o.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new Y1(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},X1=class extends Qe{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new we),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 Xm(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Xm(!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)}},L_=2,j_=1,wh=class extends Qe{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,L_),this.rows=Math.max(e.rawOptions.rows||0,j_),this.buffers=this._register(new X1(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=i.ybase+i.scrollTop,l=i.ybase+i.scrollBottom;if(i.scrollTop===0){let c=i.lines.isFull;l===i.lines.length-1?c?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(l+1,0,s.clone()),c?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let c=l-o+1;i.lines.shiftElements(o+1,c-1,-1),i.lines.set(l,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};wh=yt([Ee(0,ti)],wh);var Hr={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:Ga,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},G1=["normal","bold","100","200","300","400","500","600","700","800","900"],Q1=class extends Qe{constructor(e){super(),this._onOptionChange=this._register(new we),this.onOptionChange=this._onOptionChange.event;let t={...Hr};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ht(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in Hr))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Hr))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Hr[e]),!J1(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Hr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=G1.includes(t)?t:Hr[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 J1(e){return e==="block"||e==="underline"||e==="bar"}function eo(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&eo(e[s],t-1);return i}var Gm=Object.freeze({insertMode:!1}),Qm=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),bh=class extends Qe{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new we),this.onData=this._onData.event,this._onUserInput=this._register(new we),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new we),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=eo(Gm),this.decPrivateModes=eo(Qm)}reset(){this.modes=eo(Gm),this.decPrivateModes=eo(Qm)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};bh=yt([Ee(0,ei),Ee(1,Zv),Ee(2,ti)],bh);var Jm={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function lu(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var cu=String.fromCharCode,Zm={DEFAULT:e=>{let t=[lu(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${cu(t[0])}${cu(t[1])}${cu(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${lu(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${lu(e,!0)};${e.x};${e.y}${t}`}},Ch=class extends Qe{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new we),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Jm))this.addProtocol(s,Jm[s]);for(let s of Object.keys(Zm))this.addEncoding(s,Zm[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=s+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Ch=yt([Ee(0,ei),Ee(1,fr),Ee(2,ti)],Ch);var uu=[[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]],Z1=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Pt;function eC(e,t){let i=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(o=i+s>>1,e>t[o][1])i=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var tC=class{constructor(){if(this.version="6",!Pt){Pt=new Uint8Array(65536),Pt.fill(1),Pt[0]=0,Pt.fill(0,1,32),Pt.fill(0,127,160),Pt.fill(2,4352,4448),Pt[9001]=2,Pt[9002]=2,Pt.fill(2,11904,42192),Pt[12351]=1,Pt.fill(2,44032,55204),Pt.fill(2,63744,64256),Pt.fill(2,65040,65050),Pt.fill(2,65072,65136),Pt.fill(2,65280,65377),Pt.fill(2,65504,65511);for(let e=0;e<uu.length;++e)Pt.fill(0,uu[e][0],uu[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Pt[e]:eC(e,Z1)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let o=or.extractWidth(t);o===0?s=!1:o>i&&(i=o)}return or.createPropertyValue(0,i,s)}},or=class za{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new we,this.onChange=this._onChange.event;let t=new tC;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,o=t.length;for(let l=0;l<o;++l){let c=t.charCodeAt(l);if(55296<=c&&c<=56319){if(++l>=o)return i+this.wcwidth(c);let p=t.charCodeAt(l);56320<=p&&p<=57343?c=(c-55296)*1024+p-56320+65536:i+=this.wcwidth(p)}let d=this.charProperties(c,s),m=za.extractWidth(d);za.extractShouldJoin(d)&&(m-=za.extractWidth(s)),i+=m,s=d}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},iC=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 eg(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var Us=2147483647,nC=256,T_=class xh{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>nC)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new xh;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let l=0;l<o.length;++l)i.addSubParam(o[l]);else i.addParam(o)}return i}clone(){let t=new xh(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,o=this._subParamsIdx[i]&255;o-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Us?Us: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>Us?Us:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,o=this._subParamsIdx[i]&255;o-s>0&&(t[i]=this._subParams.slice(s,o))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[i-1];s[i-1]=~o?Math.min(o*10+t,Us):t}},Ks=[],rC=class{constructor(){this._state=0,this._active=Ks,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ks}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=Ks,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Ks,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",il(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Ks,this._id=-1,this._state=0}}},vi=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=il(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},qs=[],sC=class{constructor(){this._handlers=Object.create(null),this._active=qs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=qs}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=qs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||qs,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",il(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=qs,this._ident=0}},to=new T_;to.addParam(0);var tg=class{constructor(e){this._handler=e,this._data="",this._params=to,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():to,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=il(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=to,this._data="",this._hitLimit=!1,i));return this._params=to,this._data="",this._hitLimit=!1,t}},oC=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=i<<4|s}},Pi=160,aC=(function(){let e=new oC(4095),t=Array.apply(null,Array(256)).map((d,m)=>m),i=(d,m)=>t.slice(d,m),s=i(32,127),o=i(0,24);o.push(25),o.push.apply(o,i(28,32));let l=i(0,14),c;e.setDefault(1,0),e.addMany(s,0,2,0);for(c in l)e.addMany([24,26,153,154],c,3,0),e.addMany(i(128,144),c,3,0),e.addMany(i(144,152),c,3,0),e.add(156,c,0,0),e.add(27,c,11,1),e.add(157,c,4,8),e.addMany([152,158,159],c,0,7),e.add(155,c,11,3),e.add(144,c,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Pi,0,2,0),e.add(Pi,8,5,8),e.add(Pi,6,0,6),e.add(Pi,11,0,11),e.add(Pi,13,13,13),e})(),lC=class extends Qe{constructor(e=aC){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 T_,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ht(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new rC),this._dcsParser=this._register(new sC),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let l=e.intermediates.charCodeAt(o);if(32>l||l>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=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 i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,i){let s=0,o=0,l=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,l=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let d=this._parseStack.handlers,m=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&m>-1){for(;m>=0&&(c=d[m](this._params),c!==!0);m--)if(c instanceof Promise)return this._parseStack.handlerPos=m,c}this._parseStack.handlers=[];break;case 4:if(i===!1&&m>-1){for(;m>=0&&(c=d[m](),c!==!0);m--)if(c instanceof Promise)return this._parseStack.handlerPos=m,c}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(s!==24&&s!==26,i),c)return c;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],c=this._oscParser.end(s!==24&&s!==26,i),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,l=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let d=l;d<t;++d){switch(s=e[d],o=this._transitions.table[this.currentState<<8|(s<160?s:Pi)],o>>4){case 2:for(let _=d+1;;++_){if(_>=t||(s=e[_])<32||s>126&&s<Pi){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Pi){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Pi){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Pi){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 m=this._csiHandlers[this._collect<<8|s],p=m?m.length-1:-1;for(;p>=0&&(c=m[p](this._params),c!==!0);p--)if(c instanceof Promise)return this._preserveStack(3,m,p,o,d),c;p<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++d<t&&(s=e[d])>47&&s<60);d--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let S=this._escHandlers[this._collect<<8|s],C=S?S.length-1:-1;for(;C>=0&&(c=S[C](),c!==!0);C--)if(c instanceof Promise)return this._preserveStack(4,S,C,o,d),c;C<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<Pi){this._dcsParser.put(e,d,_),d=_-1;break}break;case 14:if(c=this._dcsParser.unhook(s!==24&&s!==26),c)return this._preserveStack(6,[],0,o,d),c;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<Pi){this._oscParser.put(e,d,_),d=_-1;break}break;case 6:if(c=this._oscParser.end(s!==24&&s!==26),c)return this._preserveStack(5,[],0,o,d),c;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},cC=/^([\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})$/,uC=/^[\da-f]+$/;function ig(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=cC.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),uC.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let l=parseInt(t.slice(i*o,i*o+i),16);s[o]=i===1?l<<4:i===2?l:i===3?l>>4:l>>8}return s}}function hu(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function hC(e,t=16){let[i,s,o]=e;return`rgb:${hu(i,t)}/${hu(s,t)}/${hu(o,t)}`}var dC={"(":0,")":1,"*":2,"+":3,"-":1,".":2},An=131072,ng=10;function rg(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 sg=5e3,og=0,fC=class extends Qe{constructor(e,t,i,s,o,l,c,d,m=new lC){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=o,this._oscLinkService=l,this._coreMouseService=c,this._unicodeService=d,this._parser=m,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new L0,this._utf8Decoder=new j0,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=xt.clone(),this._eraseAttrDataInternal=xt.clone(),this._onRequestBell=this._register(new we),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new we),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new we),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new we),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new we),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new we),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new we),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new we),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new we),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 kh(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,S)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:S.toArray()})}),this._parser.setEscHandlerFallback(p=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(p)})}),this._parser.setExecuteHandlerFallback(p=>{this._logService.debug("Unknown EXECUTE code: ",{code:p})}),this._parser.setOscHandlerFallback((p,S,C)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:S,data:C})}),this._parser.setDcsHandlerFallback((p,S,C)=>{S==="HOOK"&&(C=C.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:S,payload:C})}),this._parser.setPrintHandler((p,S,C)=>this.print(p,S,C)),this._parser.registerCsiHandler({final:"@"},p=>this.insertChars(p)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},p=>this.scrollLeft(p)),this._parser.registerCsiHandler({final:"A"},p=>this.cursorUp(p)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},p=>this.scrollRight(p)),this._parser.registerCsiHandler({final:"B"},p=>this.cursorDown(p)),this._parser.registerCsiHandler({final:"C"},p=>this.cursorForward(p)),this._parser.registerCsiHandler({final:"D"},p=>this.cursorBackward(p)),this._parser.registerCsiHandler({final:"E"},p=>this.cursorNextLine(p)),this._parser.registerCsiHandler({final:"F"},p=>this.cursorPrecedingLine(p)),this._parser.registerCsiHandler({final:"G"},p=>this.cursorCharAbsolute(p)),this._parser.registerCsiHandler({final:"H"},p=>this.cursorPosition(p)),this._parser.registerCsiHandler({final:"I"},p=>this.cursorForwardTab(p)),this._parser.registerCsiHandler({final:"J"},p=>this.eraseInDisplay(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},p=>this.eraseInDisplay(p,!0)),this._parser.registerCsiHandler({final:"K"},p=>this.eraseInLine(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},p=>this.eraseInLine(p,!0)),this._parser.registerCsiHandler({final:"L"},p=>this.insertLines(p)),this._parser.registerCsiHandler({final:"M"},p=>this.deleteLines(p)),this._parser.registerCsiHandler({final:"P"},p=>this.deleteChars(p)),this._parser.registerCsiHandler({final:"S"},p=>this.scrollUp(p)),this._parser.registerCsiHandler({final:"T"},p=>this.scrollDown(p)),this._parser.registerCsiHandler({final:"X"},p=>this.eraseChars(p)),this._parser.registerCsiHandler({final:"Z"},p=>this.cursorBackwardTab(p)),this._parser.registerCsiHandler({final:"`"},p=>this.charPosAbsolute(p)),this._parser.registerCsiHandler({final:"a"},p=>this.hPositionRelative(p)),this._parser.registerCsiHandler({final:"b"},p=>this.repeatPrecedingCharacter(p)),this._parser.registerCsiHandler({final:"c"},p=>this.sendDeviceAttributesPrimary(p)),this._parser.registerCsiHandler({prefix:">",final:"c"},p=>this.sendDeviceAttributesSecondary(p)),this._parser.registerCsiHandler({final:"d"},p=>this.linePosAbsolute(p)),this._parser.registerCsiHandler({final:"e"},p=>this.vPositionRelative(p)),this._parser.registerCsiHandler({final:"f"},p=>this.hVPosition(p)),this._parser.registerCsiHandler({final:"g"},p=>this.tabClear(p)),this._parser.registerCsiHandler({final:"h"},p=>this.setMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"h"},p=>this.setModePrivate(p)),this._parser.registerCsiHandler({final:"l"},p=>this.resetMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"l"},p=>this.resetModePrivate(p)),this._parser.registerCsiHandler({final:"m"},p=>this.charAttributes(p)),this._parser.registerCsiHandler({final:"n"},p=>this.deviceStatus(p)),this._parser.registerCsiHandler({prefix:"?",final:"n"},p=>this.deviceStatusPrivate(p)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},p=>this.softReset(p)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},p=>this.setCursorStyle(p)),this._parser.registerCsiHandler({final:"r"},p=>this.setScrollRegion(p)),this._parser.registerCsiHandler({final:"s"},p=>this.saveCursor(p)),this._parser.registerCsiHandler({final:"t"},p=>this.windowOptions(p)),this._parser.registerCsiHandler({final:"u"},p=>this.restoreCursor(p)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},p=>this.insertColumns(p)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},p=>this.deleteColumns(p)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},p=>this.selectProtected(p)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},p=>this.requestMode(p,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},p=>this.requestMode(p,!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(Ia.IND,()=>this.index()),this._parser.setExecuteHandler(Ia.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ia.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new vi(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new vi(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new vi(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new vi(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new vi(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new vi(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new vi(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new vi(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new vi(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new vi(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new vi(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new vi(p=>this.restoreCursorColor(p))),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 p in Dt)this._parser.registerEscHandler({intermediates:"(",final:p},()=>this.selectCharset("("+p)),this._parser.registerEscHandler({intermediates:")",final:p},()=>this.selectCharset(")"+p)),this._parser.registerEscHandler({intermediates:"*",final:p},()=>this.selectCharset("*"+p)),this._parser.registerEscHandler({intermediates:"+",final:p},()=>this.selectCharset("+"+p)),this._parser.registerEscHandler({intermediates:"-",final:p},()=>this.selectCharset("-"+p)),this._parser.registerEscHandler({intermediates:".",final:p},()=>this.selectCharset("."+p)),this._parser.registerEscHandler({intermediates:"/",final:p},()=>this.selectCharset("/"+p));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(p=>(this._logService.error("Parsing error: ",p),p)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new tg((p,S)=>this.requestStatusString(p,S)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),sg))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${sg} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,o=this._activeBuffer.y,l=0,c=this._parseStack.paused;if(c){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>An&&(l=this._parseStack.position+An)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,p=>String.fromCharCode(p)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(p=>p.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<An&&(this._parseBuffer=new Uint32Array(Math.min(e.length,An))),c||this._dirtyRowTracker.clearRange(),e.length>An)for(let p=l;p<e.length;p+=An){let S=p+An<e.length?p+An:e.length,C=typeof e=="string"?this._stringDecoder.decode(e.substring(p,S),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,S),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,C))return this._preserveStack(s,o,C,p),this._logSlowResolvingAsync(i),i}else if(!c){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,p))return this._preserveStack(s,o,p,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let d=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),m=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);m<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(m,this._bufferService.rows-1),end:Math.min(d,this._bufferService.rows-1)})}print(e,t,i){let s,o,l=this._charsetService.charset,c=this._optionsService.rawOptions.screenReaderMode,d=this._bufferService.cols,m=this._coreService.decPrivateModes.wraparound,p=this._coreService.modes.insertMode,S=this._curAttrData,C=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&C.getWidth(this._activeBuffer.x-1)===2&&C.setCellFromCodepoint(this._activeBuffer.x-1,0,1,S);let _=this._parser.precedingJoinState;for(let v=t;v<i;++v){if(s=e[v],s<127&&l){let N=l[String.fromCharCode(s)];N&&(s=N.charCodeAt(0))}let w=this._unicodeService.charProperties(s,_);o=or.extractWidth(w);let b=or.extractShouldJoin(w),x=b?or.extractWidth(_):0;if(_=w,c&&this._onA11yChar.fire(In(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-x>d){if(m){let N=C,L=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),C=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),x>0&&C instanceof Zs&&C.copyCellsFrom(N,L,0,x,!1);L<d;)N.setCellFromCodepoint(L++,0,1,S)}else if(this._activeBuffer.x=d-1,o===2)continue}if(b&&this._activeBuffer.x){let N=C.getWidth(this._activeBuffer.x-1)?1:2;C.addCodepointToCell(this._activeBuffer.x-N,s,o);for(let L=o-x;--L>=0;)C.setCellFromCodepoint(this._activeBuffer.x++,0,0,S);continue}if(p&&(C.insertCells(this._activeBuffer.x,o-x,this._activeBuffer.getNullCell(S)),C.getWidth(d-1)===2&&C.setCellFromCodepoint(d-1,0,1,S)),C.setCellFromCodepoint(this._activeBuffer.x++,s,o,S),o>0)for(;--o;)C.setCellFromCodepoint(this._activeBuffer.x++,0,0,S)}this._parser.precedingJoinState=_,this._activeBuffer.x<d&&i-t>0&&C.getWidth(this._activeBuffer.x)===0&&!C.hasContent(this._activeBuffer.x)&&C.setCellFromCodepoint(this._activeBuffer.x,0,1,S),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>rg(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new tg(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new vi(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,o=!1){let l=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);l.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(l.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let o=this._activeBuffer.lines.length-this._bufferService.rows;o>0&&(this._activeBuffer.lines.trimStart(o),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-o,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-o,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(xt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=or.extractWidth(t),o=this._activeBuffer.x-s,l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),c=new Uint32Array(l.length*i),d=0;for(let p=0;p<l.length;){let S=l.codePointAt(p)||0;c[d++]=S,p+=S>65535?2:1}let m=d;for(let p=1;p<i;++p)c.copyWithin(m,0,d),m+=d;return this.print(c,0,m),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(he.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(he.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(he.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(he.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(he.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,rr),this._charsetService.setgCharset(1,rr),this._charsetService.setgCharset(2,rr),this._charsetService.setgCharset(3,rr);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(b=>(b[b.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",b[b.SET=1]="SET",b[b.RESET=2]="RESET",b[b.PERMANENTLY_SET=3]="PERMANENTLY_SET",b[b.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:l}=this._coreMouseService,c=this._coreService,{buffers:d,cols:m}=this._bufferService,{active:p,alt:S}=d,C=this._optionsService.rawOptions,_=(b,x)=>(c.triggerDataEvent(`${he.ESC}[${t?"":"?"}${b};${x}$y`),!0),v=b=>b?1:2,w=e.params[0];return t?w===2?_(w,4):w===4?_(w,v(c.modes.insertMode)):w===12?_(w,3):w===20?_(w,v(C.convertEol)):_(w,0):w===1?_(w,v(s.applicationCursorKeys)):w===3?_(w,C.windowOptions.setWinLines?m===80?2:m===132?1:0:0):w===6?_(w,v(s.origin)):w===7?_(w,v(s.wraparound)):w===8?_(w,3):w===9?_(w,v(o==="X10")):w===12?_(w,v(C.cursorBlink)):w===25?_(w,v(!c.isCursorHidden)):w===45?_(w,v(s.reverseWraparound)):w===66?_(w,v(s.applicationKeypad)):w===67?_(w,4):w===1e3?_(w,v(o==="VT200")):w===1002?_(w,v(o==="DRAG")):w===1003?_(w,v(o==="ANY")):w===1004?_(w,v(s.sendFocus)):w===1005?_(w,4):w===1006?_(w,v(l==="SGR")):w===1015?_(w,4):w===1016?_(w,v(l==="SGR_PIXELS")):w===1048?_(w,1):w===47||w===1047||w===1049?_(w,v(p===S)):w===2004?_(w,v(s.bracketedPasteMode)):w===2026?_(w,v(s.synchronizedOutput)):_(w,0)}_updateAttrColor(e,t,i,s,o){return t===2?(e|=50331648,e&=-16777216,e|=ao.fromColorRGB([i,s,o])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],o=0,l=0;do{if(s[l+o]=e.params[t+l],e.hasSubParams(t+l)){let c=e.getSubParams(t+l),d=0;do s[1]===5&&(o=1),s[l+d+1+o]=c[d];while(++d<c.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 c=2;c<s.length;++c)s[c]===-1&&(s[c]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return l}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=xt.fg,e.bg=xt.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,s=this._curAttrData;for(let o=0;o<t;o++)i=e.params[o],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=xt.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=xt.bg&16777215):i===38||i===48||i===58?o+=this._extractColor(e,o,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=xt.fg&16777215,s.bg&=-67108864,s.bg|=xt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${he.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${he.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${he.ESC}[?${t};${i}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=xt.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!rg(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>ng&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>ng&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),o=i.shift();if(/^\d+$/.exec(s)){let l=parseInt(s);if(ag(l))if(o==="?")t.push({type:0,index:l});else{let c=ig(o);c&&t.push({type:1,index:l,color:c})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,o=i.findIndex(l=>l.startsWith("id="));return o!==-1&&(s=i[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=ig(i[s]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let o=parseInt(i[s]);ag(o)&&t.push({type:2,index:o})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,rr),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(dC[e[0]],Dt[e[1]]||rr),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=xt.clone(),this._eraseAttrDataInternal=xt.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Di;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=c=>(this._coreService.triggerDataEvent(`${he.ESC}${c}${he.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},kh=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&&(og=e,e=t,t=og),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};kh=yt([Ee(0,ei)],kh);function ag(e){return 0<=e&&e<256}var pC=5e7,lg=12,mC=50,gC=class extends Qe{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new we),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>pC)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let c=d=>performance.now()-i>=lg?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(i,d);o.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(c);return}let l=this._callbacks[this._bufferOffset];if(l&&l(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=lg)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>mC&&(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()}},Eh=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),m={data:e,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(m,d)),this._dataByLinkId.set(m.id,m),m.id}let i=e,s=this._getEntryIdKey(i),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let l=t.addMarker(t.ybase+t.y),c={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(c,l)),this._entriesWithId.set(c.key,c),this._dataByLinkId.set(c.id,c),c.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Eh=yt([Ee(0,ei)],Eh);var cg=!1,vC=class extends Qe{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Jr),this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onData=this._register(new we),this.onData=this._onData.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new we),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new we),this._instantiationService=new H1,this.optionsService=this._register(new Q1(e)),this._instantiationService.setService(ti,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(wh)),this._instantiationService.setService(ei,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Sh)),this._instantiationService.setService(Zv,this._logService),this.coreService=this._register(this._instantiationService.createInstance(bh)),this._instantiationService.setService(fr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ch)),this._instantiationService.setService(Jv,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(or)),this._instantiationService.setService(I0,this.unicodeService),this._charsetService=this._instantiationService.createInstance(iC),this._instantiationService.setService(B0,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Eh),this._instantiationService.setService(e_,this._oscLinkService),this._inputHandler=this._register(new fC(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ut.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ut.forward(this._bufferService.onResize,this._onResize)),this._register(Ut.forward(this.coreService.onData,this._onData)),this._register(Ut.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new gC((t,i)=>this._inputHandler.parse(t,i))),this._register(Ut.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new we),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&&!cg&&(this._logService.warn("writeSync is unreliable and will be removed soon."),cg=!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,L_),t=Math.max(t,j_),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(eg.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(eg(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ht(()=>{for(let t of e)t.dispose()})}}},_C={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 yC(e,t,i,s){var c;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((!i||s)&&e.altKey&&!e.metaKey){let d=(c=_C[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(d)o.key=he.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let m=e.ctrlKey?e.keyCode-64:e.keyCode+32,p=String.fromCharCode(m);e.shiftKey&&(p=p.toUpperCase()),o.key=he.ESC+p}else if(e.keyCode===32)o.key=he.ESC+(e.ctrlKey?he.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let m=e.code.slice(3,4);e.shiftKey||(m=m.toLowerCase()),o.key=he.ESC+m,o.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=he.US),e.key==="@"&&(o.key=he.NUL));break}return o}var bt=0,SC=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Qa,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Qa,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,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[o]=e[t],t++):s[o]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(bt=this._search(t),bt===-1)||this._getKey(this._array[bt])!==t)return!1;do if(this._array[bt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(bt),!0;while(++bt<this._array.length&&this._getKey(this._array[bt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,l)=>o-l),t=0,i=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:i[s++]=this._array[o];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(bt=this._search(e),!(bt<0||bt>=this._array.length)&&this._getKey(this._array[bt])===e))do yield this._array[bt];while(++bt<this._array.length&&this._getKey(this._array[bt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(bt=this._search(e),!(bt<0||bt>=this._array.length)&&this._getKey(this._array[bt])===e))do t(this._array[bt]);while(++bt<this._array.length&&this._getKey(this._array[bt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,o=this._getKey(this._array[s]);if(o>e)i=s-1;else if(o<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},du=0,ug=0,wC=class extends Qe{constructor(){super(),this._decorations=new SC(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new we),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new we),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ht(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new bC(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,o=0;for(let l of this._decorations.getKeyIterator(t))s=l.options.x??0,o=s+(l.options.width??1),e>=s&&e<o&&(!i||(l.options.layer??"bottom")===i)&&(yield l)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,o=>{du=o.options.x??0,ug=du+(o.options.width??1),e>=du&&e<ug&&(!i||(o.options.layer??"bottom")===i)&&s(o)})}},bC=class extends Fn{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new we),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new we),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=mt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=mt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},CC=1e3,xC=class{constructor(e,t=CC){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=s-this._lastRefreshMs,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)}},hg=20,Ja=class extends Qe{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let 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 xC(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(`
|
|
63
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),sd&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var o,l;let i=(l=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:l.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=$m(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=rd(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-ou),ou),t/=ou,t/Math.abs(t)+Math.round(t*(B1-1)))}shouldForceSelection(e){return Ga?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(),I1)}_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&&!(Ga&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<O1&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=R1(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:o>1&&t!==s&&(i+=o-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,l=o.lines.get(e[1]);if(!l)return;let c=o.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(l,e[0]),m=d,p=e[0]-d,S=0,C=0,_=0,v=0;if(c.charAt(d)===" "){for(;d>0&&c.charAt(d-1)===" ";)d--;for(;m<c.length&&c.charAt(m+1)===" ";)m++}else{let x=e[0],N=e[0];l.getWidth(x)===0&&(S++,x--),l.getWidth(N)===2&&(C++,N++);let L=l.getString(N).length;for(L>1&&(v+=L-1,m+=L-1);x>0&&d>0&&!this._isCharWordSeparator(l.loadCell(x-1,this._workCell));){l.loadCell(x-1,this._workCell);let j=this._workCell.getChars().length;this._workCell.getWidth()===0?(S++,x--):j>1&&(_+=j-1,d-=j-1),d--,x--}for(;N<l.length&&m+1<c.length&&!this._isCharWordSeparator(l.loadCell(N+1,this._workCell));){l.loadCell(N+1,this._workCell);let j=this._workCell.getChars().length;this._workCell.getWidth()===2?(C++,N++):j>1&&(v+=j-1,m+=j-1),m++,N++}}m++;let w=d+p-S+_,b=Math.min(this._bufferService.cols,m-d+S+C-_-v);if(!(!t&&c.slice(d,m).trim()==="")){if(i&&w===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 N=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(N){let L=this._bufferService.cols-N.start;w-=L,b+=L}}}if(s&&w+b===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 N=this._getWordAt([0,e[1]+1],!1,!1,!0);N&&(b+=N.length)}}return{start:w,length:b}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=$m(i,this._bufferService.cols)}};_h=yt([xe(3,ei),xe(4,fr),xe(5,Qh),xe(6,ti),xe(7,fn),xe(8,dn)],_h);var Wm=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Um=class{constructor(){this._color=new Wm,this._css=new Wm}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Rt=Object.freeze((()=>{let e=[mt.toColor("#2e3436"),mt.toColor("#cc0000"),mt.toColor("#4e9a06"),mt.toColor("#c4a000"),mt.toColor("#3465a4"),mt.toColor("#75507b"),mt.toColor("#06989a"),mt.toColor("#d3d7cf"),mt.toColor("#555753"),mt.toColor("#ef2929"),mt.toColor("#8ae234"),mt.toColor("#fce94f"),mt.toColor("#729fcf"),mt.toColor("#ad7fa8"),mt.toColor("#34e2e2"),mt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],o=t[i/6%6|0],l=t[i%6];e.push({css:kt.toCss(s,o,l),rgba:kt.toRgba(s,o,l)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:kt.toCss(s,s,s),rgba:kt.toRgba(s,s,s)})}return e})()),nr=mt.toColor("#ffffff"),Js=mt.toColor("#000000"),Km=mt.toColor("#ffffff"),qm=Js,Ws={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},H1=nr,yh=class extends Qe{constructor(e){super(),this._optionsService=e,this._contrastCache=new Um,this._halfContrastCache=new Um,this._onChangeColors=this._register(new we),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:nr,background:Js,cursor:Km,cursorAccent:qm,selectionForeground:void 0,selectionBackgroundTransparent:Ws,selectionBackgroundOpaque:ct.blend(Js,Ws),selectionInactiveBackgroundTransparent:Ws,selectionInactiveBackgroundOpaque:ct.blend(Js,Ws),scrollbarSliderBackground:ct.opacity(nr,.2),scrollbarSliderHoverBackground:ct.opacity(nr,.4),scrollbarSliderActiveBackground:ct.opacity(nr,.5),overviewRulerBorder:nr,ansi:Rt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=st(e.foreground,nr),t.background=st(e.background,Js),t.cursor=ct.blend(t.background,st(e.cursor,Km)),t.cursorAccent=ct.blend(t.background,st(e.cursorAccent,qm)),t.selectionBackgroundTransparent=st(e.selectionBackground,Ws),t.selectionBackgroundOpaque=ct.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=st(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ct.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?st(e.selectionForeground,zm):void 0,t.selectionForeground===zm&&(t.selectionForeground=void 0),ct.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ct.opacity(t.selectionBackgroundTransparent,.3)),ct.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ct.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=st(e.scrollbarSliderBackground,ct.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=st(e.scrollbarSliderHoverBackground,ct.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=st(e.scrollbarSliderActiveBackground,ct.opacity(t.foreground,.5)),t.overviewRulerBorder=st(e.overviewRulerBorder,H1),t.ansi=Rt.slice(),t.ansi[0]=st(e.black,Rt[0]),t.ansi[1]=st(e.red,Rt[1]),t.ansi[2]=st(e.green,Rt[2]),t.ansi[3]=st(e.yellow,Rt[3]),t.ansi[4]=st(e.blue,Rt[4]),t.ansi[5]=st(e.magenta,Rt[5]),t.ansi[6]=st(e.cyan,Rt[6]),t.ansi[7]=st(e.white,Rt[7]),t.ansi[8]=st(e.brightBlack,Rt[8]),t.ansi[9]=st(e.brightRed,Rt[9]),t.ansi[10]=st(e.brightGreen,Rt[10]),t.ansi[11]=st(e.brightYellow,Rt[11]),t.ansi[12]=st(e.brightBlue,Rt[12]),t.ansi[13]=st(e.brightMagenta,Rt[13]),t.ansi[14]=st(e.brightCyan,Rt[14]),t.ansi[15]=st(e.brightWhite,Rt[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=st(e.extendedAnsi[s],Rt[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};yh=yt([xe(0,ti)],yh);function st(e,t){if(e!==void 0)try{return mt.toColor(e)}catch{}return t}var $1=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},W1=class{constructor(){this._services=new $1,this._services.set(Gh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=B0(e).sort((l,c)=>l.index-c.index),s=[];for(let l of i){let c=this._services.get(l.id);if(!c)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${l.id._id}.`);s.push(c)}let o=i.length>0?i[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},U1={trace:0,debug:1,info:2,warn:3,error:4,off:5},K1="xterm.js: ",Sh=class extends Qe{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=U1[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":K1)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Sh=yt([xe(0,ti)],Sh);var Vm=class extends Qe{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new we),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new we),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new we),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let o=t-1;o>=0;o--)this.set(e+o+i,this.get(e+o));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Ge=3,xt=Object.freeze(new ao),Da=0,au=2,Zs=class M_{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Ge);let o=i||Di.fromCharData([0,Gv,1,0]);for(let l=0;l<t;++l)this.setCell(l,o);this.length=t}get(t){let i=this._data[t*Ge+0],s=i&2097151;return[this._data[t*Ge+1],i&2097152?this._combined[t]:s?In(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*Ge+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*Ge+0]=t|2097152|i[2]<<22):this._data[t*Ge+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*Ge+0]>>22}hasWidth(t){return this._data[t*Ge+0]&12582912}getFg(t){return this._data[t*Ge+1]}getBg(t){return this._data[t*Ge+2]}hasContent(t){return this._data[t*Ge+0]&4194303}getCodePoint(t){let i=this._data[t*Ge+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*Ge+0]&2097152}getString(t){let i=this._data[t*Ge+0];return i&2097152?this._combined[t]:i&2097151?In(i&2097151):""}isProtected(t){return this._data[t*Ge+2]&536870912}loadCell(t,i){return Da=t*Ge,i.content=this._data[Da+0],i.fg=this._data[Da+1],i.bg=this._data[Da+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*Ge+0]=i.content,this._data[t*Ge+1]=i.fg,this._data[t*Ge+2]=i.bg}setCellFromCodepoint(t,i,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*Ge+0]=i|s<<22,this._data[t*Ge+1]=o.fg,this._data[t*Ge+2]=o.bg}addCodepointToCell(t,i,s){let o=this._data[t*Ge+0];o&2097152?this._combined[t]+=In(i):o&2097151?(this._combined[t]=In(o&2097151)+In(i),o&=-2097152,o|=2097152):o=i|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*Ge+0]=o}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let o=new Di;for(let l=this.length-t-i-1;l>=0;--l)this.setCell(t+i+l,this.loadCell(t+l,o));for(let l=0;l<i;++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,i,s){if(t%=this.length,i<this.length-t){let o=new Di;for(let l=0;l<this.length-t-i;++l)this.setCell(t+l,this.loadCell(t+i+l,o));for(let l=this.length-i;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,i,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*au<this._data.buffer.byteLength;let s=t*Ge;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,i)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let c=0;c<o.length;c++){let d=parseInt(o[c],10);d>=t&&delete this._combined[d]}let l=Object.keys(this._extendedAttrs);for(let c=0;c<l.length;c++){let d=parseInt(l[c],10);d>=t&&delete this._extendedAttrs[d]}}return this.length=t,s*4*au<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*au<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new M_(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ge+0]&4194303)return t+(this._data[t*Ge+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ge+0]&4194303||this._data[t*Ge+2]&50331648)return t+(this._data[t*Ge+0]>>22);return 0}copyCellsFrom(t,i,s,o,l){let c=t._data;if(l)for(let m=o-1;m>=0;m--){for(let p=0;p<Ge;p++)this._data[(s+m)*Ge+p]=c[(i+m)*Ge+p];c[(i+m)*Ge+2]&268435456&&(this._extendedAttrs[s+m]=t._extendedAttrs[i+m])}else for(let m=0;m<o;m++){for(let p=0;p<Ge;p++)this._data[(s+m)*Ge+p]=c[(i+m)*Ge+p];c[(i+m)*Ge+2]&268435456&&(this._extendedAttrs[s+m]=t._extendedAttrs[i+m])}let d=Object.keys(t._combined);for(let m=0;m<d.length;m++){let p=parseInt(d[m],10);p>=i&&(this._combined[p-i+s]=t._combined[p])}}translateToString(t,i,s,o){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let l="";for(;i<s;){let c=this._data[i*Ge+0],d=c&2097151,m=c&2097152?this._combined[i]:d?In(d):On;if(l+=m,o)for(let p=0;p<m.length;++p)o.push(i);i+=c>>22||1}return o&&o.push(i),l}};function q1(e,t,i,s,o,l){let c=[];for(let d=0;d<e.length-1;d++){let m=d,p=e.get(++m);if(!p.isWrapped)continue;let S=[e.get(d)];for(;m<e.length&&p.isWrapped;)S.push(p),p=e.get(++m);if(!l&&s>=d&&s<m){d+=S.length-1;continue}let C=0,_=so(S,C,t),v=1,w=0;for(;v<S.length;){let x=so(S,v,t),N=x-w,L=i-_,j=Math.min(N,L);S[C].copyCellsFrom(S[v],w,_,j,!1),_+=j,_===i&&(C++,_=0),w+=j,w===x&&(v++,w=0),_===0&&C!==0&&S[C-1].getWidth(i-1)===2&&(S[C].copyCellsFrom(S[C-1],i-1,_++,1,!1),S[C-1].setCell(i-1,o))}S[C].replaceCells(_,i,o);let b=0;for(let x=S.length-1;x>0&&(x>C||S[x].getTrimmedLength()===0);x--)b++;b>0&&(c.push(d+S.length-b),c.push(b)),d+=S.length-1}return c}function V1(e,t){let i=[],s=0,o=t[s],l=0;for(let c=0;c<e.length;c++)if(o===c){let d=t[++s];e.onDeleteEmitter.fire({index:c-l,amount:d}),c+=d-1,l+=d,o=t[++s]}else i.push(c);return{layout:i,countRemoved:l}}function Y1(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function X1(e,t,i){let s=[],o=e.map((m,p)=>so(e,p,t)).reduce((m,p)=>m+p),l=0,c=0,d=0;for(;d<o;){if(o-d<i){s.push(o-d);break}l+=i;let m=so(e,c,t);l>m&&(l-=m,c++);let p=e[c].getWidth(l-1)===2;p&&l--;let S=p?i-1:i;s.push(S),d+=S}return s}function so(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?i-1:i}var L_=class j_{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=j_._nextId++,this._onDispose=this.register(new we),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ur(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};L_._nextId=1;var G1=L_,Dt={},rr=Dt.B;Dt[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Dt.A={"#":"£"};Dt.B=void 0;Dt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Dt.C=Dt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Dt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Dt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Dt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Dt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Dt.E=Dt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Dt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Dt.H=Dt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Dt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Ym=4294967295,Xm=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=xt.clone(),this.savedCharset=rr,this.markers=[],this._nullCell=Di.fromCharData([0,Gv,1,0]),this._whitespaceCell=Di.fromCharData([0,On,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Qa,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Vm(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 Va),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 Va),this._whitespaceCell}getBlankLine(e,t){return new Zs(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>Ym?Ym:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=xt);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Vm(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(xt),s=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let c=0;c<this.lines.length;c++)s+=+this.lines.get(c).resize(e,i);let l=0;if(this._rows<t)for(let c=this._rows;c<t;c++)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 Zs(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+l+1?(this.ybase--,l++,this.ydisp>0&&this.ydisp--):this.lines.push(new Zs(e,i)));else for(let c=this._rows;c>t;c--)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 c=this.lines.length-o;c>0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,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,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=q1(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(xt),i);if(s.length>0){let o=V1(this.lines,s);Y1(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(xt),o=i;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Zs(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(xt),o=[],l=0;for(let c=this.lines.length-1;c>=0;c--){let d=this.lines.get(c);if(!d||!d.isWrapped&&d.getTrimmedLength()<=e)continue;let m=[d];for(;d.isWrapped&&c>0;)d=this.lines.get(--c),m.unshift(d);if(!i){let j=this.ybase+this.y;if(j>=c&&j<c+m.length)continue}let p=m[m.length-1].getTrimmedLength(),S=X1(m,this._cols,e),C=S.length-m.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+C):_=Math.max(0,this.lines.length-this.lines.maxLength+C);let v=[];for(let j=0;j<C;j++){let T=this.getBlankLine(xt,!0);v.push(T)}v.length>0&&(o.push({start:c+m.length+l,newLines:v}),l+=v.length),m.push(...v);let w=S.length-1,b=S[w];b===0&&(w--,b=S[w]);let x=m.length-C-1,N=p;for(;x>=0;){let j=Math.min(N,b);if(m[w]===void 0)break;if(m[w].copyCellsFrom(m[x],N-j,b-j,j,!0),b-=j,b===0&&(w--,b=S[w]),N-=j,N===0){x--;let T=Math.max(x,0);N=so(m,T,this._cols)}}for(let j=0;j<m.length;j++)S[j]<e&&m[j].setCell(S[j],s);let L=C-_;for(;L-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+l)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+C,this.ybase+t-1)}if(o.length>0){let c=[],d=[];for(let b=0;b<this.lines.length;b++)d.push(this.lines.get(b));let m=this.lines.length,p=m-1,S=0,C=o[S];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+l);let _=0;for(let b=Math.min(this.lines.maxLength-1,m+l-1);b>=0;b--)if(C&&C.start>p+_){for(let x=C.newLines.length-1;x>=0;x--)this.lines.set(b--,C.newLines[x]);b++,c.push({index:p+1,amount:C.newLines.length}),_+=C.newLines.length,C=o[++S]}else this.lines.set(b,d[p--]);let v=0;for(let b=c.length-1;b>=0;b--)c[b].index+=v,this.lines.onInsertEmitter.fire(c[b]),v+=c[b].amount;let w=Math.max(0,m+l-this.lines.maxLength);w>0&&this.lines.onTrimEmitter.fire(w)}}translateBufferLineToString(e,t,i=0,s){let o=this.lines.get(e);return o?o.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new G1(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Q1=class extends Qe{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new we),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 Xm(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Xm(!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)}},T_=2,A_=1,wh=class extends Qe{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,T_),this.rows=Math.max(e.rawOptions.rows||0,A_),this.buffers=this._register(new Q1(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=i.ybase+i.scrollTop,l=i.ybase+i.scrollBottom;if(i.scrollTop===0){let c=i.lines.isFull;l===i.lines.length-1?c?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(l+1,0,s.clone()),c?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let c=l-o+1;i.lines.shiftElements(o+1,c-1,-1),i.lines.set(l,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};wh=yt([xe(0,ti)],wh);var Hr={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:Ga,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},J1=["normal","bold","100","200","300","400","500","600","700","800","900"],Z1=class extends Qe{constructor(e){super(),this._onOptionChange=this._register(new we),this.onOptionChange=this._onOptionChange.event;let t={...Hr};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ht(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in Hr))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Hr))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Hr[e]),!eC(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Hr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=J1.includes(t)?t:Hr[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 eC(e){return e==="block"||e==="underline"||e==="bar"}function eo(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&eo(e[s],t-1);return i}var Gm=Object.freeze({insertMode:!1}),Qm=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),bh=class extends Qe{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new we),this.onData=this._onData.event,this._onUserInput=this._register(new we),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new we),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=eo(Gm),this.decPrivateModes=eo(Qm)}reset(){this.modes=eo(Gm),this.decPrivateModes=eo(Qm)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};bh=yt([xe(0,ei),xe(1,t_),xe(2,ti)],bh);var Jm={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function lu(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var cu=String.fromCharCode,Zm={DEFAULT:e=>{let t=[lu(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${cu(t[0])}${cu(t[1])}${cu(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${lu(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${lu(e,!0)};${e.x};${e.y}${t}`}},Ch=class extends Qe{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new we),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Jm))this.addProtocol(s,Jm[s]);for(let s of Object.keys(Zm))this.addEncoding(s,Zm[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=s+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Ch=yt([xe(0,ei),xe(1,fr),xe(2,ti)],Ch);var uu=[[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]],tC=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Pt;function iC(e,t){let i=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(o=i+s>>1,e>t[o][1])i=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var nC=class{constructor(){if(this.version="6",!Pt){Pt=new Uint8Array(65536),Pt.fill(1),Pt[0]=0,Pt.fill(0,1,32),Pt.fill(0,127,160),Pt.fill(2,4352,4448),Pt[9001]=2,Pt[9002]=2,Pt.fill(2,11904,42192),Pt[12351]=1,Pt.fill(2,44032,55204),Pt.fill(2,63744,64256),Pt.fill(2,65040,65050),Pt.fill(2,65072,65136),Pt.fill(2,65280,65377),Pt.fill(2,65504,65511);for(let e=0;e<uu.length;++e)Pt.fill(0,uu[e][0],uu[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Pt[e]:iC(e,tC)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let o=or.extractWidth(t);o===0?s=!1:o>i&&(i=o)}return or.createPropertyValue(0,i,s)}},or=class za{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new we,this.onChange=this._onChange.event;let t=new nC;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,o=t.length;for(let l=0;l<o;++l){let c=t.charCodeAt(l);if(55296<=c&&c<=56319){if(++l>=o)return i+this.wcwidth(c);let p=t.charCodeAt(l);56320<=p&&p<=57343?c=(c-55296)*1024+p-56320+65536:i+=this.wcwidth(p)}let d=this.charProperties(c,s),m=za.extractWidth(d);za.extractShouldJoin(d)&&(m-=za.extractWidth(s)),i+=m,s=d}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},rC=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 eg(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var Us=2147483647,sC=256,B_=class xh{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>sC)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new xh;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let l=0;l<o.length;++l)i.addSubParam(o[l]);else i.addParam(o)}return i}clone(){let t=new xh(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,o=this._subParamsIdx[i]&255;o-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Us?Us: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>Us?Us:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,o=this._subParamsIdx[i]&255;o-s>0&&(t[i]=this._subParams.slice(s,o))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[i-1];s[i-1]=~o?Math.min(o*10+t,Us):t}},Ks=[],oC=class{constructor(){this._state=0,this._active=Ks,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ks}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=Ks,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Ks,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",il(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Ks,this._id=-1,this._state=0}}},vi=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=il(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},qs=[],aC=class{constructor(){this._handlers=Object.create(null),this._active=qs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=qs}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=qs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||qs,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",il(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=qs,this._ident=0}},to=new B_;to.addParam(0);var tg=class{constructor(e){this._handler=e,this._data="",this._params=to,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():to,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=il(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=to,this._data="",this._hitLimit=!1,i));return this._params=to,this._data="",this._hitLimit=!1,t}},lC=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=i<<4|s}},Pi=160,cC=(function(){let e=new lC(4095),t=Array.apply(null,Array(256)).map((d,m)=>m),i=(d,m)=>t.slice(d,m),s=i(32,127),o=i(0,24);o.push(25),o.push.apply(o,i(28,32));let l=i(0,14),c;e.setDefault(1,0),e.addMany(s,0,2,0);for(c in l)e.addMany([24,26,153,154],c,3,0),e.addMany(i(128,144),c,3,0),e.addMany(i(144,152),c,3,0),e.add(156,c,0,0),e.add(27,c,11,1),e.add(157,c,4,8),e.addMany([152,158,159],c,0,7),e.add(155,c,11,3),e.add(144,c,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Pi,0,2,0),e.add(Pi,8,5,8),e.add(Pi,6,0,6),e.add(Pi,11,0,11),e.add(Pi,13,13,13),e})(),uC=class extends Qe{constructor(e=cC){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 B_,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ht(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new oC),this._dcsParser=this._register(new aC),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let l=e.intermediates.charCodeAt(o);if(32>l||l>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=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 i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,i){let s=0,o=0,l=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,l=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let d=this._parseStack.handlers,m=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&m>-1){for(;m>=0&&(c=d[m](this._params),c!==!0);m--)if(c instanceof Promise)return this._parseStack.handlerPos=m,c}this._parseStack.handlers=[];break;case 4:if(i===!1&&m>-1){for(;m>=0&&(c=d[m](),c!==!0);m--)if(c instanceof Promise)return this._parseStack.handlerPos=m,c}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(s!==24&&s!==26,i),c)return c;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],c=this._oscParser.end(s!==24&&s!==26,i),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,l=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let d=l;d<t;++d){switch(s=e[d],o=this._transitions.table[this.currentState<<8|(s<160?s:Pi)],o>>4){case 2:for(let _=d+1;;++_){if(_>=t||(s=e[_])<32||s>126&&s<Pi){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Pi){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Pi){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Pi){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 m=this._csiHandlers[this._collect<<8|s],p=m?m.length-1:-1;for(;p>=0&&(c=m[p](this._params),c!==!0);p--)if(c instanceof Promise)return this._preserveStack(3,m,p,o,d),c;p<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++d<t&&(s=e[d])>47&&s<60);d--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let S=this._escHandlers[this._collect<<8|s],C=S?S.length-1:-1;for(;C>=0&&(c=S[C](),c!==!0);C--)if(c instanceof Promise)return this._preserveStack(4,S,C,o,d),c;C<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<Pi){this._dcsParser.put(e,d,_),d=_-1;break}break;case 14:if(c=this._dcsParser.unhook(s!==24&&s!==26),c)return this._preserveStack(6,[],0,o,d),c;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<Pi){this._oscParser.put(e,d,_),d=_-1;break}break;case 6:if(c=this._oscParser.end(s!==24&&s!==26),c)return this._preserveStack(5,[],0,o,d),c;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},hC=/^([\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})$/,dC=/^[\da-f]+$/;function ig(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=hC.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),dC.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let l=parseInt(t.slice(i*o,i*o+i),16);s[o]=i===1?l<<4:i===2?l:i===3?l>>4:l>>8}return s}}function hu(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function fC(e,t=16){let[i,s,o]=e;return`rgb:${hu(i,t)}/${hu(s,t)}/${hu(o,t)}`}var pC={"(":0,")":1,"*":2,"+":3,"-":1,".":2},An=131072,ng=10;function rg(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 sg=5e3,og=0,mC=class extends Qe{constructor(e,t,i,s,o,l,c,d,m=new uC){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=o,this._oscLinkService=l,this._coreMouseService=c,this._unicodeService=d,this._parser=m,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new T0,this._utf8Decoder=new A0,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=xt.clone(),this._eraseAttrDataInternal=xt.clone(),this._onRequestBell=this._register(new we),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new we),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new we),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new we),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new we),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new we),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new we),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new we),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new we),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 kh(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,S)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:S.toArray()})}),this._parser.setEscHandlerFallback(p=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(p)})}),this._parser.setExecuteHandlerFallback(p=>{this._logService.debug("Unknown EXECUTE code: ",{code:p})}),this._parser.setOscHandlerFallback((p,S,C)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:S,data:C})}),this._parser.setDcsHandlerFallback((p,S,C)=>{S==="HOOK"&&(C=C.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:S,payload:C})}),this._parser.setPrintHandler((p,S,C)=>this.print(p,S,C)),this._parser.registerCsiHandler({final:"@"},p=>this.insertChars(p)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},p=>this.scrollLeft(p)),this._parser.registerCsiHandler({final:"A"},p=>this.cursorUp(p)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},p=>this.scrollRight(p)),this._parser.registerCsiHandler({final:"B"},p=>this.cursorDown(p)),this._parser.registerCsiHandler({final:"C"},p=>this.cursorForward(p)),this._parser.registerCsiHandler({final:"D"},p=>this.cursorBackward(p)),this._parser.registerCsiHandler({final:"E"},p=>this.cursorNextLine(p)),this._parser.registerCsiHandler({final:"F"},p=>this.cursorPrecedingLine(p)),this._parser.registerCsiHandler({final:"G"},p=>this.cursorCharAbsolute(p)),this._parser.registerCsiHandler({final:"H"},p=>this.cursorPosition(p)),this._parser.registerCsiHandler({final:"I"},p=>this.cursorForwardTab(p)),this._parser.registerCsiHandler({final:"J"},p=>this.eraseInDisplay(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},p=>this.eraseInDisplay(p,!0)),this._parser.registerCsiHandler({final:"K"},p=>this.eraseInLine(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},p=>this.eraseInLine(p,!0)),this._parser.registerCsiHandler({final:"L"},p=>this.insertLines(p)),this._parser.registerCsiHandler({final:"M"},p=>this.deleteLines(p)),this._parser.registerCsiHandler({final:"P"},p=>this.deleteChars(p)),this._parser.registerCsiHandler({final:"S"},p=>this.scrollUp(p)),this._parser.registerCsiHandler({final:"T"},p=>this.scrollDown(p)),this._parser.registerCsiHandler({final:"X"},p=>this.eraseChars(p)),this._parser.registerCsiHandler({final:"Z"},p=>this.cursorBackwardTab(p)),this._parser.registerCsiHandler({final:"`"},p=>this.charPosAbsolute(p)),this._parser.registerCsiHandler({final:"a"},p=>this.hPositionRelative(p)),this._parser.registerCsiHandler({final:"b"},p=>this.repeatPrecedingCharacter(p)),this._parser.registerCsiHandler({final:"c"},p=>this.sendDeviceAttributesPrimary(p)),this._parser.registerCsiHandler({prefix:">",final:"c"},p=>this.sendDeviceAttributesSecondary(p)),this._parser.registerCsiHandler({final:"d"},p=>this.linePosAbsolute(p)),this._parser.registerCsiHandler({final:"e"},p=>this.vPositionRelative(p)),this._parser.registerCsiHandler({final:"f"},p=>this.hVPosition(p)),this._parser.registerCsiHandler({final:"g"},p=>this.tabClear(p)),this._parser.registerCsiHandler({final:"h"},p=>this.setMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"h"},p=>this.setModePrivate(p)),this._parser.registerCsiHandler({final:"l"},p=>this.resetMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"l"},p=>this.resetModePrivate(p)),this._parser.registerCsiHandler({final:"m"},p=>this.charAttributes(p)),this._parser.registerCsiHandler({final:"n"},p=>this.deviceStatus(p)),this._parser.registerCsiHandler({prefix:"?",final:"n"},p=>this.deviceStatusPrivate(p)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},p=>this.softReset(p)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},p=>this.setCursorStyle(p)),this._parser.registerCsiHandler({final:"r"},p=>this.setScrollRegion(p)),this._parser.registerCsiHandler({final:"s"},p=>this.saveCursor(p)),this._parser.registerCsiHandler({final:"t"},p=>this.windowOptions(p)),this._parser.registerCsiHandler({final:"u"},p=>this.restoreCursor(p)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},p=>this.insertColumns(p)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},p=>this.deleteColumns(p)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},p=>this.selectProtected(p)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},p=>this.requestMode(p,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},p=>this.requestMode(p,!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(Ia.IND,()=>this.index()),this._parser.setExecuteHandler(Ia.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ia.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new vi(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new vi(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new vi(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new vi(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new vi(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new vi(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new vi(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new vi(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new vi(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new vi(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new vi(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new vi(p=>this.restoreCursorColor(p))),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 p in Dt)this._parser.registerEscHandler({intermediates:"(",final:p},()=>this.selectCharset("("+p)),this._parser.registerEscHandler({intermediates:")",final:p},()=>this.selectCharset(")"+p)),this._parser.registerEscHandler({intermediates:"*",final:p},()=>this.selectCharset("*"+p)),this._parser.registerEscHandler({intermediates:"+",final:p},()=>this.selectCharset("+"+p)),this._parser.registerEscHandler({intermediates:"-",final:p},()=>this.selectCharset("-"+p)),this._parser.registerEscHandler({intermediates:".",final:p},()=>this.selectCharset("."+p)),this._parser.registerEscHandler({intermediates:"/",final:p},()=>this.selectCharset("/"+p));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(p=>(this._logService.error("Parsing error: ",p),p)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new tg((p,S)=>this.requestStatusString(p,S)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),sg))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${sg} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,o=this._activeBuffer.y,l=0,c=this._parseStack.paused;if(c){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>An&&(l=this._parseStack.position+An)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,p=>String.fromCharCode(p)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(p=>p.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<An&&(this._parseBuffer=new Uint32Array(Math.min(e.length,An))),c||this._dirtyRowTracker.clearRange(),e.length>An)for(let p=l;p<e.length;p+=An){let S=p+An<e.length?p+An:e.length,C=typeof e=="string"?this._stringDecoder.decode(e.substring(p,S),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,S),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,C))return this._preserveStack(s,o,C,p),this._logSlowResolvingAsync(i),i}else if(!c){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,p))return this._preserveStack(s,o,p,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let d=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),m=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);m<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(m,this._bufferService.rows-1),end:Math.min(d,this._bufferService.rows-1)})}print(e,t,i){let s,o,l=this._charsetService.charset,c=this._optionsService.rawOptions.screenReaderMode,d=this._bufferService.cols,m=this._coreService.decPrivateModes.wraparound,p=this._coreService.modes.insertMode,S=this._curAttrData,C=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&C.getWidth(this._activeBuffer.x-1)===2&&C.setCellFromCodepoint(this._activeBuffer.x-1,0,1,S);let _=this._parser.precedingJoinState;for(let v=t;v<i;++v){if(s=e[v],s<127&&l){let N=l[String.fromCharCode(s)];N&&(s=N.charCodeAt(0))}let w=this._unicodeService.charProperties(s,_);o=or.extractWidth(w);let b=or.extractShouldJoin(w),x=b?or.extractWidth(_):0;if(_=w,c&&this._onA11yChar.fire(In(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-x>d){if(m){let N=C,L=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),C=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),x>0&&C instanceof Zs&&C.copyCellsFrom(N,L,0,x,!1);L<d;)N.setCellFromCodepoint(L++,0,1,S)}else if(this._activeBuffer.x=d-1,o===2)continue}if(b&&this._activeBuffer.x){let N=C.getWidth(this._activeBuffer.x-1)?1:2;C.addCodepointToCell(this._activeBuffer.x-N,s,o);for(let L=o-x;--L>=0;)C.setCellFromCodepoint(this._activeBuffer.x++,0,0,S);continue}if(p&&(C.insertCells(this._activeBuffer.x,o-x,this._activeBuffer.getNullCell(S)),C.getWidth(d-1)===2&&C.setCellFromCodepoint(d-1,0,1,S)),C.setCellFromCodepoint(this._activeBuffer.x++,s,o,S),o>0)for(;--o;)C.setCellFromCodepoint(this._activeBuffer.x++,0,0,S)}this._parser.precedingJoinState=_,this._activeBuffer.x<d&&i-t>0&&C.getWidth(this._activeBuffer.x)===0&&!C.hasContent(this._activeBuffer.x)&&C.setCellFromCodepoint(this._activeBuffer.x,0,1,S),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>rg(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new tg(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new vi(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,o=!1){let l=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);l.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(l.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let o=this._activeBuffer.lines.length-this._bufferService.rows;o>0&&(this._activeBuffer.lines.trimStart(o),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-o,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-o,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(xt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=or.extractWidth(t),o=this._activeBuffer.x-s,l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),c=new Uint32Array(l.length*i),d=0;for(let p=0;p<l.length;){let S=l.codePointAt(p)||0;c[d++]=S,p+=S>65535?2:1}let m=d;for(let p=1;p<i;++p)c.copyWithin(m,0,d),m+=d;return this.print(c,0,m),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(he.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(he.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(he.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(he.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(he.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,rr),this._charsetService.setgCharset(1,rr),this._charsetService.setgCharset(2,rr),this._charsetService.setgCharset(3,rr);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(b=>(b[b.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",b[b.SET=1]="SET",b[b.RESET=2]="RESET",b[b.PERMANENTLY_SET=3]="PERMANENTLY_SET",b[b.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:l}=this._coreMouseService,c=this._coreService,{buffers:d,cols:m}=this._bufferService,{active:p,alt:S}=d,C=this._optionsService.rawOptions,_=(b,x)=>(c.triggerDataEvent(`${he.ESC}[${t?"":"?"}${b};${x}$y`),!0),v=b=>b?1:2,w=e.params[0];return t?w===2?_(w,4):w===4?_(w,v(c.modes.insertMode)):w===12?_(w,3):w===20?_(w,v(C.convertEol)):_(w,0):w===1?_(w,v(s.applicationCursorKeys)):w===3?_(w,C.windowOptions.setWinLines?m===80?2:m===132?1:0:0):w===6?_(w,v(s.origin)):w===7?_(w,v(s.wraparound)):w===8?_(w,3):w===9?_(w,v(o==="X10")):w===12?_(w,v(C.cursorBlink)):w===25?_(w,v(!c.isCursorHidden)):w===45?_(w,v(s.reverseWraparound)):w===66?_(w,v(s.applicationKeypad)):w===67?_(w,4):w===1e3?_(w,v(o==="VT200")):w===1002?_(w,v(o==="DRAG")):w===1003?_(w,v(o==="ANY")):w===1004?_(w,v(s.sendFocus)):w===1005?_(w,4):w===1006?_(w,v(l==="SGR")):w===1015?_(w,4):w===1016?_(w,v(l==="SGR_PIXELS")):w===1048?_(w,1):w===47||w===1047||w===1049?_(w,v(p===S)):w===2004?_(w,v(s.bracketedPasteMode)):w===2026?_(w,v(s.synchronizedOutput)):_(w,0)}_updateAttrColor(e,t,i,s,o){return t===2?(e|=50331648,e&=-16777216,e|=ao.fromColorRGB([i,s,o])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],o=0,l=0;do{if(s[l+o]=e.params[t+l],e.hasSubParams(t+l)){let c=e.getSubParams(t+l),d=0;do s[1]===5&&(o=1),s[l+d+1+o]=c[d];while(++d<c.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 c=2;c<s.length;++c)s[c]===-1&&(s[c]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return l}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=xt.fg,e.bg=xt.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,s=this._curAttrData;for(let o=0;o<t;o++)i=e.params[o],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=xt.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=xt.bg&16777215):i===38||i===48||i===58?o+=this._extractColor(e,o,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=xt.fg&16777215,s.bg&=-67108864,s.bg|=xt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${he.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${he.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${he.ESC}[?${t};${i}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=xt.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!rg(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>ng&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>ng&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),o=i.shift();if(/^\d+$/.exec(s)){let l=parseInt(s);if(ag(l))if(o==="?")t.push({type:0,index:l});else{let c=ig(o);c&&t.push({type:1,index:l,color:c})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,o=i.findIndex(l=>l.startsWith("id="));return o!==-1&&(s=i[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=ig(i[s]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let o=parseInt(i[s]);ag(o)&&t.push({type:2,index:o})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,rr),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(pC[e[0]],Dt[e[1]]||rr),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=xt.clone(),this._eraseAttrDataInternal=xt.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Di;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=c=>(this._coreService.triggerDataEvent(`${he.ESC}${c}${he.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},kh=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&&(og=e,e=t,t=og),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};kh=yt([xe(0,ei)],kh);function ag(e){return 0<=e&&e<256}var gC=5e7,lg=12,vC=50,_C=class extends Qe{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new we),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>gC)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let c=d=>performance.now()-i>=lg?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(i,d);o.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(c);return}let l=this._callbacks[this._bufferOffset];if(l&&l(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=lg)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>vC&&(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()}},Eh=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),m={data:e,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(m,d)),this._dataByLinkId.set(m.id,m),m.id}let i=e,s=this._getEntryIdKey(i),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let l=t.addMarker(t.ybase+t.y),c={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(c,l)),this._entriesWithId.set(c.key,c),this._dataByLinkId.set(c.id,c),c.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Eh=yt([xe(0,ei)],Eh);var cg=!1,yC=class extends Qe{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Jr),this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onData=this._register(new we),this.onData=this._onData.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new we),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new we),this._instantiationService=new W1,this.optionsService=this._register(new Z1(e)),this._instantiationService.setService(ti,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(wh)),this._instantiationService.setService(ei,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Sh)),this._instantiationService.setService(t_,this._logService),this.coreService=this._register(this._instantiationService.createInstance(bh)),this._instantiationService.setService(fr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ch)),this._instantiationService.setService(e_,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(or)),this._instantiationService.setService(z0,this.unicodeService),this._charsetService=this._instantiationService.createInstance(rC),this._instantiationService.setService(O0,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Eh),this._instantiationService.setService(i_,this._oscLinkService),this._inputHandler=this._register(new mC(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ut.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ut.forward(this._bufferService.onResize,this._onResize)),this._register(Ut.forward(this.coreService.onData,this._onData)),this._register(Ut.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new _C((t,i)=>this._inputHandler.parse(t,i))),this._register(Ut.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new we),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&&!cg&&(this._logService.warn("writeSync is unreliable and will be removed soon."),cg=!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,T_),t=Math.max(t,A_),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(eg.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(eg(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ht(()=>{for(let t of e)t.dispose()})}}},SC={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 wC(e,t,i,s){var c;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((!i||s)&&e.altKey&&!e.metaKey){let d=(c=SC[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(d)o.key=he.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let m=e.ctrlKey?e.keyCode-64:e.keyCode+32,p=String.fromCharCode(m);e.shiftKey&&(p=p.toUpperCase()),o.key=he.ESC+p}else if(e.keyCode===32)o.key=he.ESC+(e.ctrlKey?he.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let m=e.code.slice(3,4);e.shiftKey||(m=m.toLowerCase()),o.key=he.ESC+m,o.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=he.US),e.key==="@"&&(o.key=he.NUL));break}return o}var bt=0,bC=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Qa,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Qa,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,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[o]=e[t],t++):s[o]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(bt=this._search(t),bt===-1)||this._getKey(this._array[bt])!==t)return!1;do if(this._array[bt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(bt),!0;while(++bt<this._array.length&&this._getKey(this._array[bt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,l)=>o-l),t=0,i=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:i[s++]=this._array[o];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(bt=this._search(e),!(bt<0||bt>=this._array.length)&&this._getKey(this._array[bt])===e))do yield this._array[bt];while(++bt<this._array.length&&this._getKey(this._array[bt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(bt=this._search(e),!(bt<0||bt>=this._array.length)&&this._getKey(this._array[bt])===e))do t(this._array[bt]);while(++bt<this._array.length&&this._getKey(this._array[bt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,o=this._getKey(this._array[s]);if(o>e)i=s-1;else if(o<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},du=0,ug=0,CC=class extends Qe{constructor(){super(),this._decorations=new bC(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new we),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new we),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ht(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new xC(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,o=0;for(let l of this._decorations.getKeyIterator(t))s=l.options.x??0,o=s+(l.options.width??1),e>=s&&e<o&&(!i||(l.options.layer??"bottom")===i)&&(yield l)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,o=>{du=o.options.x??0,ug=du+(o.options.width??1),e>=du&&e<ug&&(!i||(o.options.layer??"bottom")===i)&&s(o)})}},xC=class extends Fn{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new we),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new we),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=mt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=mt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},kC=1e3,EC=class{constructor(e,t=kC){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=s-this._lastRefreshMs,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)}},hg=20,Ja=class extends Qe{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let 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 EC(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
64
|
`))),this._register(this._terminal.onA11yTab(l=>this._handleTab(l))),this._register(this._terminal.onKey(l=>this._handleKey(l.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register($e(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ht(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<hg+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
65
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===hg+1&&(this._liveRegion.textContent+=qu.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let o=e;o<=t;o++){let l=i.lines.get(i.ydisp+o),c=[],d=(l==null?void 0:l.translateToString(!0,void 0,void 0,c))||"",m=(i.ydisp+o+1).toString(),p=this._rowElements[o];p&&(d.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=d,this._rowColumns.set(p,c)),p.setAttribute("aria-posinset",m),p.setAttribute("aria-setsize",s),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=i.getAttribute("aria-posinset"),l=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===l||e.relatedTarget!==s)return;let c,d;if(t===0?(c=i,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(c=this._rowElements.shift(),d=i,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let m=this._createAccessibilityTreeNode();this._rowElements.unshift(m),this._rowContainer.insertAdjacentElement("afterbegin",m)}else{let m=this._createAccessibilityTreeNode();this._rowElements.push(m),this._rowContainer.appendChild(m)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var 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},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((d=s.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(i.node))return;let o=({node:m,offset:p})=>{let S=m instanceof Text?m.parentNode:m,C=parseInt(S==null?void 0:S.getAttribute("aria-posinset"),10)-1;if(isNaN(C))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(S);if(!_)return console.warn("columns is null. Race condition?"),null;let v=p<_.length?_[p]:_.slice(-1)[0]+1;return v>=this._terminal.cols&&(++C,v=0),{row:C,column:v}},l=o(t),c=o(i);if(!(!l||!c)){if(l.row>c.row||l.row===c.row&&l.column>=c.column)throw new Error("invalid range");this._terminal.select(l.column,l.row,(c.row-l.row)*this._terminal.cols-l.column+c.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,i=(l=(o=this._rowColumns.get(e))==null?void 0:o.slice(-1))==null?void 0:l[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Ja=yt([Ee(1,Gh),Ee(2,dn),Ee(3,fn)],Ja);var Nh=class extends Qe{constructor(e,t,i,s,o){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new we),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new we),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ht(()=>{var l;ur(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(l=this._activeProviderReplies)==null||l.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register($e(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register($e(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register($e(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register($e(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s<i.length;s++){let o=i[s];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var s,o;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(l=>{l==null||l.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[l,c]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(l)&&(i=this._checkLinkProviderResult(l,e,i)):c.provideLinks(e.y,d=>{var p,S;if(this._isMouseOut)return;let m=d==null?void 0:d.map(C=>({link:C}));(p=this._activeProviderReplies)==null||p.set(l,m),i=this._checkLinkProviderResult(l,e,i),((S=this._activeProviderReplies)==null?void 0:S.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let l=0;l<o.length;l++){let c=o[l],d=c.link.range.start.y<e?0:c.link.range.start.x,m=c.link.range.end.y>e?this._bufferService.cols:c.link.range.end.x;for(let p=d;p<=m;p++){if(i.has(p)){o.splice(l--,1);break}i.add(p)}}}}_checkLinkProviderResult(e,t,i){var l;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),o=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(o=!0);if(!o&&s){let c=s.find(d=>this._linkAtPosition(d.link,t));c&&(i=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let c=0;c<this._activeProviderReplies.size;c++){let d=(l=this._activeProviderReplies.get(c))==null?void 0:l.find(m=>this._linkAtPosition(m.link,t));if(d){i=!0,this._handleNewLink(d);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&kC(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,ur(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,o,l;(s=this._currentLink)!=null&&s.state&&((l=(o=this._currentLink)==null?void 0:o.state)==null?void 0:l.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let l=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);l&&this._askForLink(l,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return i<=o&&o<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,o){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:o}}};Nh=yt([Ee(1,Qh),Ee(2,fn),Ee(3,ei),Ee(4,i_)],Nh);function kC(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 EC=class extends vC{constructor(e={}){super(e),this._linkifier=this._register(new Jr),this.browser=w_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Jr),this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new we),this.onKey=this._onKey.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new we),this.onBell=this._onBell.event,this._onFocus=this._register(new we),this._onBlur=this._register(new we),this._onA11yCharEmitter=this._register(new we),this._onA11yTabEmitter=this._register(new we),this._onWillOpen=this._register(new we),this._setup(),this._decorationService=this._instantiationService.createInstance(wC),this._instantiationService.setService(lo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(m1),this._instantiationService.setService(i_,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Yu)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Ut.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ut.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ut.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ut.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ht(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let o=ct.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${he.ESC}]${s};${hC(o)}${y_.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(l=>l.ansi[t.index]=kt.toColor(...t.color));else{let l=i;this._themeService.modifyColors(c=>c[l]=kt.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Ja,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(he.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(he.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(i),l=this._renderService.dimensions.css.cell.width*o,c=this.buffer.y*this._renderService.dimensions.css.cell.height,d=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=d+"px",this.textarea.style.top=c+"px",this.textarea.style.width=l+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register($e(this.element,"copy",t=>{this.hasSelection()&&D0(t,this._selectionService)}));let e=t=>M0(t,this.textarea,this.coreService,this.optionsService);this._register($e(this.textarea,"paste",e)),this._register($e(this.element,"paste",e)),b_?this._register($e(this.element,"mousedown",t=>{t.button===2&&wm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register($e(this.element,"contextmenu",t=>{wm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),sd&&this._register($e(this.element,"auxclick",t=>{t.button===1&&Vv(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register($e(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register($e(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register($e(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register($e(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register($e(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register($e(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register($e(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var o;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((o=this.element)==null?void 0:o.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register($e(this.screenElement,"mousemove",l=>this.updateCursorStyle(l))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Ku.get()),k_||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(f1,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(dn,this._coreBrowserService),this._register($e(this.textarea,"focus",l=>this._handleTextAreaFocus(l))),this._register($e(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(mh,this._document,this._helperContainer),this._instantiationService.setService(nl,this._charSizeService),this._themeService=this._instantiationService.createInstance(yh),this._instantiationService.setService(ts,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Xa),this._instantiationService.setService(t_,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(vh,this.rows,this.screenElement)),this._instantiationService.setService(fn,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(dh,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(gh),this._instantiationService.setService(Qh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Nh,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(uh,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(_h,this.element,this.screenElement,s)),this._instantiationService.setService(z0,this._selectionService),this._register(this._selectionService.onRequestScrollLines(l=>this.scrollLines(l.amount,l.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(l=>this._renderService.handleSelectionChanged(l.start,l.end,l.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(l=>{this.textarea.value=l,this.textarea.focus(),this.textarea.select()})),this._register(Ut.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var l;this._selectionService.refresh(),(l=this._viewport)==null||l.queueSync()})),this._register(this._instantiationService.createInstance(hh,this.screenElement)),this._register($e(this.element,"mousedown",l=>this._selectionService.handleMouseDown(l))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Ja,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",l=>this._handleScreenReaderModeOptionChange(l))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ya,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",l=>{!this._overviewRulerRenderer&&l&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ya,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(ph,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(l){var p,S,C,_,v;let c=e._mouseService.getMouseReportCoords(l,e.screenElement);if(!c)return!1;let d,m;switch(l.overrideType||l.type){case"mousemove":m=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":m=0,d=l.button<3?l.button:3;break;case"mousedown":m=1,d=l.button<3?l.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(l)===!1)return!1;let w=l.deltaY;if(w===0||e.coreMouseService.consumeWheelEvent(l,(_=(C=(S=(p=e._renderService)==null?void 0:p.dimensions)==null?void 0:S.device)==null?void 0:C.cell)==null?void 0:_.height,(v=e._coreBrowserService)==null?void 0:v.dpr)===0)return!1;m=w<0?0:1,d=4;break;default:return!1}return m===void 0||d===void 0||d>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:d,action:m,ctrl:l.ctrlKey,alt:l.altKey,shift:l.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:l=>(i(l),l.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(l)),wheel:l=>(i(l),this.cancel(l,!0)),mousedrag:l=>{l.buttons&&i(l)},mousemove:l=>{l.buttons||i(l)}};this._register(this.coreMouseService.onProtocolChange(l=>{l?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(l)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),l&8?s.mousemove||(t.addEventListener("mousemove",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),l&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),l&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),l&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register($e(t,"mousedown",l=>{if(l.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(l)))return i(l),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(l)})),this._register($e(t,"wheel",l=>{var c,d,m,p,S;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(l)===!1)return!1;if(!this.buffer.hasScrollback){if(l.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(l,(p=(m=(d=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:d.device)==null?void 0:m.cell)==null?void 0:p.height,(S=e._coreBrowserService)==null?void 0:S.dpr)===0)return this.cancel(l,!0);let C=he.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(l.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(C,!0),this.cancel(l,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){qv(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=yC(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===he.ETX||i.key===he.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(NC(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(xt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(he.ESC+"[I"):this.coreService.triggerDataEvent(he.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${he.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${he.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function NC(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var RC=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},PC=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Di)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},dg=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 PC(t)}getNullCell(){return new Di}},DC=class extends Qe{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new we),this.onBufferChange=this._onBufferChange.event,this._normal=new dg(this._core.buffers.normal,"normal"),this._alternate=new dg(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)}},MC=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},LC=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}},jC=["cols","rows"],qi=0,TC=class extends Qe{constructor(e){super(),this._core=this._register(new EC(e)),this._addonManager=this._register(new RC),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,o)=>{this._checkReadonlyOptions(s),this._core.options[s]=o};for(let s in this._core.options){let o={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,o)}}_checkReadonlyOptions(e){if(jC.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 MC(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new LC(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 DC(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
65
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===hg+1&&(this._liveRegion.textContent+=qu.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let o=e;o<=t;o++){let l=i.lines.get(i.ydisp+o),c=[],d=(l==null?void 0:l.translateToString(!0,void 0,void 0,c))||"",m=(i.ydisp+o+1).toString(),p=this._rowElements[o];p&&(d.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=d,this._rowColumns.set(p,c)),p.setAttribute("aria-posinset",m),p.setAttribute("aria-setsize",s),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=i.getAttribute("aria-posinset"),l=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===l||e.relatedTarget!==s)return;let c,d;if(t===0?(c=i,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(c=this._rowElements.shift(),d=i,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let m=this._createAccessibilityTreeNode();this._rowElements.unshift(m),this._rowContainer.insertAdjacentElement("afterbegin",m)}else{let m=this._createAccessibilityTreeNode();this._rowElements.push(m),this._rowContainer.appendChild(m)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var 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},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((d=s.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(i.node))return;let o=({node:m,offset:p})=>{let S=m instanceof Text?m.parentNode:m,C=parseInt(S==null?void 0:S.getAttribute("aria-posinset"),10)-1;if(isNaN(C))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(S);if(!_)return console.warn("columns is null. Race condition?"),null;let v=p<_.length?_[p]:_.slice(-1)[0]+1;return v>=this._terminal.cols&&(++C,v=0),{row:C,column:v}},l=o(t),c=o(i);if(!(!l||!c)){if(l.row>c.row||l.row===c.row&&l.column>=c.column)throw new Error("invalid range");this._terminal.select(l.column,l.row,(c.row-l.row)*this._terminal.cols-l.column+c.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,i=(l=(o=this._rowColumns.get(e))==null?void 0:o.slice(-1))==null?void 0:l[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Ja=yt([xe(1,Gh),xe(2,dn),xe(3,fn)],Ja);var Nh=class extends Qe{constructor(e,t,i,s,o){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new we),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new we),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ht(()=>{var l;ur(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(l=this._activeProviderReplies)==null||l.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register($e(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register($e(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register($e(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register($e(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s<i.length;s++){let o=i[s];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var s,o;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(l=>{l==null||l.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[l,c]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(l)&&(i=this._checkLinkProviderResult(l,e,i)):c.provideLinks(e.y,d=>{var p,S;if(this._isMouseOut)return;let m=d==null?void 0:d.map(C=>({link:C}));(p=this._activeProviderReplies)==null||p.set(l,m),i=this._checkLinkProviderResult(l,e,i),((S=this._activeProviderReplies)==null?void 0:S.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let l=0;l<o.length;l++){let c=o[l],d=c.link.range.start.y<e?0:c.link.range.start.x,m=c.link.range.end.y>e?this._bufferService.cols:c.link.range.end.x;for(let p=d;p<=m;p++){if(i.has(p)){o.splice(l--,1);break}i.add(p)}}}}_checkLinkProviderResult(e,t,i){var l;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),o=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(o=!0);if(!o&&s){let c=s.find(d=>this._linkAtPosition(d.link,t));c&&(i=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let c=0;c<this._activeProviderReplies.size;c++){let d=(l=this._activeProviderReplies.get(c))==null?void 0:l.find(m=>this._linkAtPosition(m.link,t));if(d){i=!0,this._handleNewLink(d);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&NC(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,ur(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,o,l;(s=this._currentLink)!=null&&s.state&&((l=(o=this._currentLink)==null?void 0:o.state)==null?void 0:l.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let l=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);l&&this._askForLink(l,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return i<=o&&o<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,o){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:o}}};Nh=yt([xe(1,Qh),xe(2,fn),xe(3,ei),xe(4,r_)],Nh);function NC(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 RC=class extends yC{constructor(e={}){super(e),this._linkifier=this._register(new Jr),this.browser=C_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Jr),this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new we),this.onKey=this._onKey.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new we),this.onBell=this._onBell.event,this._onFocus=this._register(new we),this._onBlur=this._register(new we),this._onA11yCharEmitter=this._register(new we),this._onA11yTabEmitter=this._register(new we),this._onWillOpen=this._register(new we),this._setup(),this._decorationService=this._instantiationService.createInstance(CC),this._instantiationService.setService(lo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(v1),this._instantiationService.setService(r_,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Yu)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Ut.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ut.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ut.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ut.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ht(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let o=ct.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${he.ESC}]${s};${fC(o)}${w_.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(l=>l.ansi[t.index]=kt.toColor(...t.color));else{let l=i;this._themeService.modifyColors(c=>c[l]=kt.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Ja,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(he.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(he.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(i),l=this._renderService.dimensions.css.cell.width*o,c=this.buffer.y*this._renderService.dimensions.css.cell.height,d=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=d+"px",this.textarea.style.top=c+"px",this.textarea.style.width=l+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register($e(this.element,"copy",t=>{this.hasSelection()&&L0(t,this._selectionService)}));let e=t=>j0(t,this.textarea,this.coreService,this.optionsService);this._register($e(this.textarea,"paste",e)),this._register($e(this.element,"paste",e)),x_?this._register($e(this.element,"mousedown",t=>{t.button===2&&wm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register($e(this.element,"contextmenu",t=>{wm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),sd&&this._register($e(this.element,"auxclick",t=>{t.button===1&&Xv(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register($e(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register($e(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register($e(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register($e(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register($e(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register($e(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register($e(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var o;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((o=this.element)==null?void 0:o.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register($e(this.screenElement,"mousemove",l=>this.updateCursorStyle(l))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Ku.get()),N_||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(m1,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(dn,this._coreBrowserService),this._register($e(this.textarea,"focus",l=>this._handleTextAreaFocus(l))),this._register($e(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(mh,this._document,this._helperContainer),this._instantiationService.setService(nl,this._charSizeService),this._themeService=this._instantiationService.createInstance(yh),this._instantiationService.setService(ts,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Xa),this._instantiationService.setService(n_,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(vh,this.rows,this.screenElement)),this._instantiationService.setService(fn,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(dh,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(gh),this._instantiationService.setService(Qh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Nh,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(uh,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(_h,this.element,this.screenElement,s)),this._instantiationService.setService(H0,this._selectionService),this._register(this._selectionService.onRequestScrollLines(l=>this.scrollLines(l.amount,l.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(l=>this._renderService.handleSelectionChanged(l.start,l.end,l.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(l=>{this.textarea.value=l,this.textarea.focus(),this.textarea.select()})),this._register(Ut.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var l;this._selectionService.refresh(),(l=this._viewport)==null||l.queueSync()})),this._register(this._instantiationService.createInstance(hh,this.screenElement)),this._register($e(this.element,"mousedown",l=>this._selectionService.handleMouseDown(l))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Ja,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",l=>this._handleScreenReaderModeOptionChange(l))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ya,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",l=>{!this._overviewRulerRenderer&&l&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ya,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(ph,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(l){var p,S,C,_,v;let c=e._mouseService.getMouseReportCoords(l,e.screenElement);if(!c)return!1;let d,m;switch(l.overrideType||l.type){case"mousemove":m=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":m=0,d=l.button<3?l.button:3;break;case"mousedown":m=1,d=l.button<3?l.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(l)===!1)return!1;let w=l.deltaY;if(w===0||e.coreMouseService.consumeWheelEvent(l,(_=(C=(S=(p=e._renderService)==null?void 0:p.dimensions)==null?void 0:S.device)==null?void 0:C.cell)==null?void 0:_.height,(v=e._coreBrowserService)==null?void 0:v.dpr)===0)return!1;m=w<0?0:1,d=4;break;default:return!1}return m===void 0||d===void 0||d>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:d,action:m,ctrl:l.ctrlKey,alt:l.altKey,shift:l.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:l=>(i(l),l.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(l)),wheel:l=>(i(l),this.cancel(l,!0)),mousedrag:l=>{l.buttons&&i(l)},mousemove:l=>{l.buttons||i(l)}};this._register(this.coreMouseService.onProtocolChange(l=>{l?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(l)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),l&8?s.mousemove||(t.addEventListener("mousemove",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),l&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),l&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),l&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register($e(t,"mousedown",l=>{if(l.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(l)))return i(l),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(l)})),this._register($e(t,"wheel",l=>{var c,d,m,p,S;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(l)===!1)return!1;if(!this.buffer.hasScrollback){if(l.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(l,(p=(m=(d=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:d.device)==null?void 0:m.cell)==null?void 0:p.height,(S=e._coreBrowserService)==null?void 0:S.dpr)===0)return this.cancel(l,!0);let C=he.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(l.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(C,!0),this.cancel(l,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Yv(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=wC(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===he.ETX||i.key===he.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(PC(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(xt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(he.ESC+"[I"):this.coreService.triggerDataEvent(he.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${he.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${he.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function PC(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var DC=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},MC=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Di)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},dg=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 MC(t)}getNullCell(){return new Di}},LC=class extends Qe{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new we),this.onBufferChange=this._onBufferChange.event,this._normal=new dg(this._core.buffers.normal,"normal"),this._alternate=new dg(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)}},jC=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},TC=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}},AC=["cols","rows"],qi=0,BC=class extends Qe{constructor(e){super(),this._core=this._register(new RC(e)),this._addonManager=this._register(new DC),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,o)=>{this._checkReadonlyOptions(s),this._core.options[s]=o};for(let s in this._core.options){let o={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,o)}}_checkReadonlyOptions(e){if(AC.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 jC(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new TC(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 LC(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
66
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 Ku.get()},set promptLabel(e){Ku.set(e)},get tooMuchOutput(){return qu.get()},set tooMuchOutput(e){qu.set(e)}}}_verifyIntegers(...e){for(qi of e)if(qi===1/0||isNaN(qi)||qi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(qi of e)if(qi&&(qi===1/0||isNaN(qi)||qi%1!==0||qi<0))throw new Error("This API only accepts positive integers")}};/**
|
|
67
67
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
68
68
|
* @license MIT
|
|
@@ -74,18 +74,18 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t
|
|
|
74
74
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
75
75
|
* http://bellard.org/jslinux/
|
|
76
76
|
* Copyright (c) 2011 Fabrice Bellard
|
|
77
|
-
*/var
|
|
77
|
+
*/var IC=2,OC=1,zC=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 C;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:((C=this._terminal.options.overviewRuler)==null?void 0:C.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),o=Math.max(0,parseInt(i.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),c={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=c.top+c.bottom,m=c.right+c.left,p=s-d,S=o-m-t;return{cols:Math.max(IC,Math.floor(S/e.css.cell.width)),rows:Math.max(OC,Math.floor(p/e.css.cell.height))}}};function FC(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function HC({session:e,node:t,token:i,cols:s,rows:o,readonly:l=!1,takeSize:c,focused:d,onData:m,onExit:p,onFiles:S,retryBaseMs:C=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 w=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${FC(t,i)}`;let b=null,x=!1,N=!1,L=null,j=0,T=d;const Q=()=>{if(x||N||L)return;const I=Math.min(5e3,Math.max(0,C)*2**Math.min(j++,5));L=setTimeout(()=>{L=null,H()},I)},H=()=>{if(x||N)return;const I=new WebSocket(w);b=I,I.binaryType="arraybuffer",I.onopen=()=>{if(b!==I||x)return;j=0;const G={type:"attach",session:e,token:i,cols:s,rows:o,readonly:l};c!==void 0&&(G.takeSize=c),I.send(JSON.stringify(G)),T!==void 0&&I.send(JSON.stringify({type:"focus",on:!!T}))},I.onmessage=G=>{if(!(b!==I||x))if(typeof G.data=="string"){let U;try{U=JSON.parse(G.data)}catch{return}U.type==="exit"&&(N=!0,p&&p(U.code)),U.type==="files"&&S&&S(U)}else m&&m(new Uint8Array(G.data))},I.onerror=()=>{if(b===I)try{I.close()}catch{}},I.onclose=G=>{b!==I||x||N||[1e3,1002,4401,4404].includes(G==null?void 0:G.code)||Q()}};return H(),{sendInput:I=>{if(!b||b.readyState!==1)return!1;try{return b.send(typeof I=="string"?new TextEncoder().encode(I):I),!0}catch{try{b.close()}catch{}return!1}},isReady:()=>!!b&&b.readyState===1,resize:(I,G)=>{s=I,o=G,(b==null?void 0:b.readyState)===1&&b.send(JSON.stringify({type:"resize",cols:I,rows:G}))},action:I=>{(b==null?void 0:b.readyState)===1&&b.send(JSON.stringify({type:"action",name:I}))},focus:I=>{T=I,(b==null?void 0:b.readyState)===1&&b.send(JSON.stringify({type:"focus",on:!!I}))},close:()=>{if(x=!0,L&&clearTimeout(L),L=null,b)try{b.close()}catch{}},get raw(){return b}}}async function fg(e){const t=String(e||"");if(!t)return!1;try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(t),!0}catch{}try{const i=document.createElement("textarea");i.value=t,i.readOnly=!0,i.style.position="fixed",i.style.opacity="0",i.style.pointerEvents="none",document.body.appendChild(i),i.select();const s=document.execCommand&&document.execCommand("copy");if(i.remove(),s)return!0}catch{}return!1}const $C="\r";function WC(e){const t=String(e||"");let i=t.length;for(;i>0;){const s=t.charCodeAt(i-1);if(s===10||s===13)i-=1;else break}return t.slice(0,i)}function UC({isReady:e,paste:t,send:i}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:i($C)!==!1}catch{return!1}}}function KC(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function qC(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}const VC=450,pg=8;function YC(e,t,i,s){return Math.abs(Number(i)-Number(e))>pg||Math.abs(Number(s)-Number(t))>pg}const XC=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function fu(e){return e?e.files&&e.files.length>0||Array.from(e.items||[]).some(t=>t&&t.kind==="file")?!0:Array.from(e.types||[]).includes("Files"):!1}function mg(e){if(!e)return[];const t=Array.from(e.files||[]).filter(Boolean);return t.length?t:Array.from(e.items||[]).filter(i=>i&&i.kind==="file"&&typeof i.getAsFile=="function").map(i=>i.getAsFile()).filter(Boolean)}function GC(e,t=0,i=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=XC.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${i}-${t+1}.${o}`}async function I_({files:e,token:t,session:i,node:s="",paste:o=!0,fetchImpl:l=zt,onProgress:c=()=>{},now:d=Date.now()}={}){const m=Array.from(e||[]).filter(Boolean),p=[],S=[];if(!i||!m.length)return{paths:p,errors:S};const C=ui(s?String(s).split("/"):[]);for(let _=0;_<m.length;_+=1){const v=m[_],w=GC(v,_,d);c({index:_,total:m.length,name:w,state:"uploading"});try{const b=new FormData;b.append("session",i),b.append("paste",o?"true":"false"),b.append("file",v,w);const x=await l(`${C}/files/upload`,t,{method:"POST",body:b}),N=await x.json().catch(()=>({}));if(!x.ok||N.error)throw new Error(N.error||`HTTP ${x.status}`);p.push(N.path),c({index:_,total:m.length,name:w,state:"done",path:N.path})}catch(b){const x=String((b==null?void 0:b.message)||b);S.push({name:w,message:x}),c({index:_,total:m.length,name:w,state:"error",error:x})}}return{paths:p,errors:S}}function O_({session:e,node:t,token:i,readonly:s,takeSize:o,focused:l,sendRef:c,composerRef:d,actionRef:m,ctrlRef:p,setCtrlArmed:S,onFiles:C,fontSize:_=13,selectionMode:v=!1,onSelectionModeChange:w}){const b=P.useRef(null),x=P.useRef(null),N=P.useRef(_);N.current=_;const L=P.useRef(l);L.current=l;const j=P.useRef(v);j.current=v;const[T,Q]=P.useState(""),[H,I]=P.useState(""),[G,U]=P.useState(null),q=async()=>{var R,F,D,O;const A=((F=(R=x.current)==null?void 0:R.term)==null?void 0:F.getSelection())||T;if(!A){I(y("copy-empty")),setTimeout(()=>I(""),1500);return}const E=await fg(A);I(y(E?"copied":"copy-manual")),E&&((O=(D=x.current)==null?void 0:D.term)==null||O.clearSelection(),w==null||w(!1)),setTimeout(()=>I(""),1800)},X=P.useRef(q);return X.current=q,P.useEffect(()=>{const A=x.current;A&&A.sock&&A.sock.focus&&A.sock.focus(!!l)},[l]),P.useEffect(()=>{const A=x.current;A&&(A.term.options.fontSize=_,A.fit.fit(),A.sock.resize(A.term.cols,A.term.rows))},[_]),P.useEffect(()=>{const A=new BC({cursorBlink:!0,fontSize:N.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),E=new zC;A.loadAddon(E),A.open(b.current),E.fit();const R=new TextDecoder;let F;try{F=HC({session:e,node:t,token:i,readonly:s,takeSize:o,focused:L.current,onFiles:C,cols:A.cols,rows:A.rows,onData:fe=>A.write(R.decode(fe)),onExit:()=>A.write(`\r
|
|
78
78
|
\x1B[33m[sessione finita]\x1B[0m\r
|
|
79
|
-
`)})}catch(
|
|
80
|
-
\x1B[31m${
|
|
81
|
-
`),()=>A.dispose()}x.current={term:A,fit:E,sock:F};let D=null;const O=A.onData(de=>{if(s){D&&(D.ok=!1);return}if(!D&&p&&p.current&&de.length===1){const it=de.charCodeAt(0);let ue=it;it>=97&&it<=122?ue=it-96:it>=64&&it<=95?ue=it-64:it===32&&(ue=0),de=String.fromCharCode(ue),p.current=!1,S&&S(!1)}const Ke=F.sendInput(de);D&&(D.seen=!0,D.ok=D.ok&&Ke)});c&&(c.current=de=>F.sendInput(de)),m&&(m.current=de=>F.action(de)),d&&(d.current=$C({isReady:()=>!s&&F.isReady(),paste:de=>{const Ke={seen:!1,ok:!0};D=Ke;try{A.paste(de)}catch{Ke.ok=!1}finally{D=null}return Ke.seen&&Ke.ok},send:de=>F.sendInput(de)}));const z=A.onSelectionChange(()=>Q(A.getSelection()));A.attachCustomKeyEventHandler(de=>(de.ctrlKey||de.metaKey)&&de.key.toLowerCase()==="c"&&A.getSelection()?(de.type==="keydown"&&fg(A.getSelection()),!1):!0);const ne=b.current;let K=!1;const M=async de=>{if(!de.length||K)return;if(s){U({error:y("settings-readonly")});return}K=!0,U({current:0,total:de.length,name:""});const Ke=await A_({files:de,token:i,session:e,node:t,paste:!0,onProgress:({index:it,total:ue,name:De,state:Ue,error:Mt})=>U({current:it+1,total:ue,name:De,...Ue==="error"?{error:Mt}:{}})});K=!1,Ke.errors.length?U({error:Ke.errors.map(it=>`${it.name}: ${it.message}`).join(" · ")}):(U({done:!0,total:Ke.paths.length}),setTimeout(()=>U(null),1600))},W=de=>{const Ke=de.clipboardData;if(!fu(Ke))return;const it=mg(Ke);it.length&&(de.preventDefault(),de.stopPropagation(),M(it))},oe=de=>{fu(de.dataTransfer)&&(de.preventDefault(),de.stopPropagation())},ae=de=>{fu(de.dataTransfer)&&(de.preventDefault(),de.stopPropagation(),M(mg(de.dataTransfer)))};ne.addEventListener("paste",W,!0),ne.addEventListener("dragenter",oe,!0),ne.addEventListener("dragover",oe,!0),ne.addEventListener("drop",ae,!0);const se=24;let le=null,_e=null,ce=0,X=null,Z=null,je=null,Me=!1;const ye=()=>{je&&clearTimeout(je),je=null},ee=(de,Ke)=>{const ue=(ne.querySelector(".xterm-screen")||ne).getBoundingClientRect(),De=Math.max(0,Math.min(A.cols-1,Math.floor((de-ue.left)/Math.max(1,ue.width)*A.cols))),Ue=Math.max(0,Math.min(A.rows-1,Math.floor((Ke-ue.top)/Math.max(1,ue.height)*A.rows)));return{col:De,row:A.buffer.active.viewportY+Ue}},Ce=de=>ee(de.clientX,de.clientY),Te=de=>{if(ye(),Me=!1,de.touches.length!==1){le=null;return}if(j.current){de.preventDefault(),de.stopPropagation(),Z=Ce(de.touches[0]),A.clearSelection();return}le=de.touches[0].clientY,_e=de.touches[0].clientX,ce=0,X=null;const Ke={x:_e,y:le};je=setTimeout(()=>{je=null,Me=!0,j.current=!0,w==null||w(!0),Z=ee(Ke.x,Ke.y),A.clearSelection(),A.select(Z.col,Z.row,1),le=null,_e=null,X=null,ce=0},KC)},xe=de=>{if((j.current||Me)&&Z&&de.touches.length===1){de.preventDefault(),de.stopPropagation();const it=Ce(de.touches[0]),ue=Z.row*A.cols+Z.col,De=it.row*A.cols+it.col,Ue=ue<=De?Z:it;A.select(Ue.col,Ue.row,Math.abs(De-ue)+1);return}if(le===null||de.touches.length!==1)return;de.preventDefault(),de.stopPropagation();const Ke=de.touches[0];if(je&&qC(_e,le,Ke.clientX,Ke.clientY)&&ye(),X===null&&(Math.abs(Ke.clientY-le)>8||Math.abs(Ke.clientX-_e)>8)&&(X=Math.abs(Ke.clientY-le)>Math.abs(Ke.clientX-_e)),!!X){for(ce+=Ke.clientY-le,le=Ke.clientY;ce>=se;)F.action("scroll-up"),ce-=se;for(;ce<=-se;)F.action("scroll-down"),ce+=se}},qe=()=>{ye(),le=null,_e=null,Z=null,Me=!1};let te=0;const ve=de=>{for(de.preventDefault(),de.stopPropagation(),te+=de.deltaY;te<=-se;)F.action("scroll-up"),te+=se;for(;te>=se;)F.action("scroll-down"),te-=se};ne.addEventListener("touchstart",Te,{passive:!1}),ne.addEventListener("touchmove",xe,{passive:!1,capture:!0}),ne.addEventListener("touchend",qe,{passive:!0}),ne.addEventListener("touchcancel",qe,{passive:!0});const Be=de=>{(j.current||Me)&&(de.preventDefault(),de.stopPropagation())};ne.addEventListener("contextmenu",Be,!0),ne.addEventListener("wheel",ve,{passive:!1,capture:!0});let Ie=null;const Fe=de=>{WC(de)&&(de.preventDefault(),de.stopPropagation(),Ie=ee(de.clientX,de.clientY),A.clearSelection())},gt=de=>{if(!Ie)return;de.preventDefault(),de.stopPropagation();const Ke=ee(de.clientX,de.clientY),it=Ie.row*A.cols+Ie.col,ue=Ke.row*A.cols+Ke.col,De=it<=ue?Ie:Ke;A.select(De.col,De.row,Math.abs(ue-it)+1)},ge=de=>{Ie&&(de.stopPropagation(),Ie=null)};ne.addEventListener("mousedown",Fe,!0),ne.addEventListener("mousemove",gt,!0),ne.addEventListener("mouseup",ge,!0);const be=de=>{!UC(de)||!(x.current&&x.current.term&&x.current.term.getSelection())||(de.preventDefault(),de.stopPropagation(),Y.current&&Y.current())};ne.addEventListener("keydown",be,!0);const ke=()=>{E.fit(),F.resize(A.cols,A.rows)};window.addEventListener("resize",ke);const Xe=window.visualViewport;Xe&&(Xe.addEventListener("resize",ke),Xe.addEventListener("scroll",ke));let rt=null,Ve=0;return typeof ResizeObserver<"u"&&(rt=new ResizeObserver(()=>{Ve&&cancelAnimationFrame(Ve),Ve=requestAnimationFrame(ke)}),rt.observe(ne)),()=>{x.current=null,c&&(c.current=()=>!1),d&&(d.current=()=>!1),m&&(m.current=()=>!1),O.dispose(),z.dispose(),ne.removeEventListener("touchstart",Te),ne.removeEventListener("touchmove",xe,{capture:!0}),ne.removeEventListener("touchend",qe),ne.removeEventListener("touchcancel",qe),ne.removeEventListener("contextmenu",Be,!0),ye(),ne.removeEventListener("wheel",ve,{capture:!0}),ne.removeEventListener("mousedown",Fe,!0),ne.removeEventListener("mousemove",gt,!0),ne.removeEventListener("mouseup",ge,!0),ne.removeEventListener("keydown",be,!0),ne.removeEventListener("paste",W,!0),ne.removeEventListener("dragenter",oe,!0),ne.removeEventListener("dragover",oe,!0),ne.removeEventListener("drop",ae,!0),window.removeEventListener("resize",ke),Xe&&(Xe.removeEventListener("resize",ke),Xe.removeEventListener("scroll",ke)),rt&&rt.disconnect(),Ve&&cancelAnimationFrame(Ve),F.close(),A.dispose()}},[e,t,i,s,o,c,d,m,p,S,C]),h.jsxs("div",{className:`nc-terminal${v?" selecting":""}`,children:[h.jsx("div",{className:"nc-terminal-host",ref:b}),G&&h.jsx("div",{className:`nc-upload-state${G.error?" error":""}`,role:"status",children:G.error?G.error:G.done?y("attach-uploaded").replace("{n}",String(G.total||0)):y("attach-upload-progress").replace("{n}",String(G.current||0)).replace("{total}",String(G.total||0))}),(T||v)&&h.jsxs("div",{className:"nc-selection-tools",children:[T?h.jsx("button",{type:"button",onClick:q,children:H||y("copy")}):h.jsx("span",{children:y("select-drag")}),h.jsx("button",{type:"button",onClick:()=>{var A,E;(E=(A=x.current)==null?void 0:A.term)==null||E.clearSelection(),Q(""),w==null||w(!1)},children:y("cancel")}),H===y("copy-manual")&&h.jsx("textarea",{readOnly:!0,value:T,onFocus:A=>A.target.select()})]})]})}const gg="",ci="\x1B",XC=[{label:"↑",seq:ci+"[A"},{label:"↓",seq:ci+"[B"},{label:"PGUP",seq:ci+"[5~"},{label:"PGDN",seq:ci+"[6~"}];function GC({send:e,action:t,ctrlArmed:i=!1,onCtrl:s,onKeyboard:o,selectionMode:l=!1,onSelectionMode:c}){const[d,m]=P.useState(!1),[p,S]=P.useState(!1),[C,_]=P.useState(!1),v=x=>{C?(e(ci+x),_(!1)):e(x)},w=(x,N,L)=>h.jsx("button",{onMouseDown:j=>{j.preventDefault(),v(N),L&&L()},children:x},x),b=(x,N)=>h.jsx("button",{onMouseDown:L=>{L.preventDefault(),t(N),S(!1)},children:x},x);return d?h.jsxs("div",{className:"nc-keybar copy",children:[h.jsx("span",{className:"tag",children:"copy-mode"}),XC.map(x=>w(x.label,x.seq)),w("ESCI (q)","q",()=>m(!1))]}):h.jsxs("div",{className:"nc-keybar termux",children:[p&&h.jsxs("div",{className:"nc-keymenu",children:[b("←WIN","prev-window"),b("WIN→","next-window"),b("⬅PANE","pane-left"),b("PANE➡","pane-right"),w("SCROLL",gg+"[",()=>{m(!0),S(!1)}),h.jsx("button",{className:l?"armed":"",onMouseDown:x=>{x.preventDefault(),c==null||c(!l),S(!1)},children:"SELECT"}),w("⌃C","",()=>S(!1)),w("DETACH",gg+"d",()=>S(!1))]}),h.jsxs("div",{className:"row",children:[w("ESC",ci),h.jsx("button",{className:p?"armed":"",onMouseDown:x=>{x.preventDefault(),S(N=>!N)},children:"☰"},"menu"),w("/","/"),w("—","-"),w("HOME",ci+"[H"),w("↑",ci+"[A"),w("END",ci+"[F"),w("PGUP",ci+"[5~")]}),h.jsxs("div",{className:"row",children:[w("⇥"," "),h.jsx("button",{onMouseDown:x=>{x.preventDefault(),o&&o()},children:"⌨"},"kbd"),h.jsx("button",{className:i?"armed":"",onMouseDown:x=>{x.preventDefault(),s&&s()},children:"CTRL"},"ctrl"),h.jsx("button",{className:C?"armed":"",onMouseDown:x=>{x.preventDefault(),_(N=>!N)},children:"ALT"},"alt"),w("←",ci+"[D"),w("↓",ci+"[B"),w("→",ci+"[C"),w("PGDN",ci+"[6~")]})]})}const QC=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function I_({session:e,node:t,token:i,filesEvent:s,onClose:o}){Si();const l=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",c=t?`${t}:${e}`:e,[d,m]=P.useState("outbox"),[p,S]=P.useState({inbox:[],outbox:[]}),[C,_]=P.useState(""),v=P.useRef(null);async function w(){try{const j=await(await zt(`${l}/files?session=${encodeURIComponent(e)}`,i)).json();if(j.error){_(j.error);return}S(j);const T=j.outbox[0]?j.outbox[0].mtime:0;localStorage.setItem(xv(c),String(T))}catch(L){_(String(L))}}P.useEffect(()=>{w()},[e,t]),P.useEffect(()=>{s&&s.session===e&&w()},[s]);async function b(L){for(const j of L){_(`carico ${j.name}…`);const T=new FormData;T.append("session",e),T.append("file",j);try{const H=await(await zt(`${l}/files/upload`,i,{method:"POST",body:T})).json();_(H.error?`errore: ${H.error}`:"")}catch(Q){_(String(Q))}}w()}async function x(L){const j=await zt(`${l}/files/download?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(L)}`,i);if(!j.ok){_("errore download");return}const T=await j.blob(),Q=URL.createObjectURL(T),H=document.createElement("a");H.href=Q,H.download=L,H.click(),URL.revokeObjectURL(Q)}async function N(L){await zt(`${l}/files?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(L)}`,i,{method:"DELETE"}),w()}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:y("close"),children:h.jsx(et,{name:"x",size:20})})]}),h.jsxs("nav",{children:[h.jsx("button",{className:d==="outbox"?"on":"",onClick:()=>m("outbox"),children:"outbox"}),h.jsx("button",{className:d==="inbox"?"on":"",onClick:()=>m("inbox"),children:"inbox"}),h.jsxs("button",{className:"up",onClick:()=>v.current&&v.current.click(),children:[h.jsx(et,{name:"upload",size:18})," ",y("upload")]}),h.jsx("input",{type:"file",multiple:!0,ref:v,style:{display:"none"},onChange:L=>{b(Array.from(L.target.files||[])),L.target.value=""}})]}),C&&h.jsx("div",{className:"nc-busy",children:C}),h.jsxs("ul",{children:[p[d].map(L=>h.jsxs("li",{children:[h.jsx("span",{className:"name",onClick:()=>x(L.name),children:L.name}),h.jsx("small",{children:QC(L.size)}),h.jsx("button",{onClick:()=>N(L.name),title:"elimina",children:h.jsx(et,{name:"trash",size:18})})]},L.name)),p[d].length===0&&h.jsx("li",{className:"empty",children:y("empty-files")})]})]})}const ol="nc_composer_v1",Rh="nc-composer-reset",JC=50,O_=256*1024,z_=512*1024,ZC=768*1024,vg=2*1024*1024,F_=720*60*60*1e3,Ph=1;function H_(e){const t=Number(e);return Number.isFinite(t)&&t>0?t:0}function od(e){if(e!==void 0)return e;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Za(){return{version:Ph,cells:{}}}function $_(e){const t=[];for(const s of Array.isArray(e)?e:[]){const o=typeof s=="string"?s:s&&s.text,l=H_(typeof s=="string"?0:s&&s.at);if(!(typeof o!="string"||!o||o.length>O_)&&!(t.length&&t[t.length-1].text===o)&&(t.push({text:o,at:l}),t.length>=JC))break}let i=0;return t.filter(s=>i+s.text.length>ZC?!1:(i+=s.text.length,!0))}function el(e){if(!e||typeof e!="object")return null;const t=typeof e.draft=="string"&&e.draft.length<=z_?e.draft:"",i=$_(e.history),s=H_(e.updatedAt),o=e.expanded===!0;return!t&&!i.length&&!o?null:{draft:t,history:i,expanded:o,updatedAt:s}}function ex(e){let t;try{t=typeof e=="string"?JSON.parse(e):e}catch{return Za()}if(!t||typeof t!="object"||t.version!==Ph||!t.cells||typeof t.cells!="object")return Za();const i=Object.create(null);for(const[s,o]of Object.entries(t.cells)){if(!s||typeof s!="string"||s.length>512||s==="__proto__"||s==="constructor"||s==="prototype")continue;const l=el(o);l&&(i[s]=l)}return{version:Ph,cells:i}}function W_(e){const t=od(e);if(!t)return Za();try{return ex(t.getItem(ol))}catch{return Za()}}function _g(e){try{return JSON.stringify(e).length}catch{return 1/0}}function tx(e,t,i){for(const[s,o]of Object.entries(e.cells))s!==i&&o.updatedAt>0&&t-o.updatedAt>F_&&delete e.cells[s]}function U_(e,t){return Object.entries(e.cells).filter(([i])=>i!==t).sort((i,s)=>i[1].updatedAt-s[1].updatedAt).map(([i])=>i)}function ix(e,t){for(;_g(e)>vg;){const i=Object.entries(e.cells).filter(([,s])=>s.history.length).sort((s,o)=>s[1].updatedAt-o[1].updatedAt);if(!i.length)break;i[0][1].history.pop()}for(const i of U_(e,t)){if(_g(e)<=vg)break;delete e.cells[i]}}function K_(e,t,i){const s=od(e);if(!s)return!1;ix(t,i);const o=()=>(s.setItem(ol,JSON.stringify(t)),!0);try{return o()}catch{for(const c of U_(t,i)){delete t.cells[c];try{return o()}catch{}}return!1}}function ho(e,t,i,s){const o=W_(t);tx(o,i,e);const l=el(o.cells[e])||{draft:"",history:[],expanded:!1,updatedAt:0},c=s({...l,history:[...l.history]}),d=el(c);return d?o.cells[e]={...d,updatedAt:i}:delete o.cells[e],{ok:K_(t,o,e),cell:o.cells[e]||{draft:"",history:[],expanded:!1,updatedAt:i}}}function nx({ownerId:e,node:t,session:i}){const s=String(i||"");if(!s)return"";const o=Qr.test(String(e||""))?String(e):t?`route:${String(t)}`:"local";return`${encodeURIComponent(o)}:${encodeURIComponent(s)}`}function Vs(e,t,i=Date.now()){if(!e)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=W_(t),o=el(s.cells[e]);return!o||o.updatedAt>0&&i-o.updatedAt>F_?(s.cells[e]&&(delete s.cells[e],K_(t,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...o,history:[...o.history]}}function yg(e,t,i,s=Date.now()){const o=String(t||"");return!e||o.length>z_?!1:ho(e,i,s,l=>({...l,draft:o})).ok}function Sg(e,t,i=Date.now()){return e?ho(e,t,i,s=>({...s,draft:""})).ok:!1}function rx(e,t,i,s=Date.now()){return e?ho(e,i,s,o=>({...o,expanded:!!t})).ok:!1}function sx(e,t,i,s=Date.now()){const o=String(t||"");return!e||!o||o.length>O_?!1:ho(e,i,s,l=>{const c=l.history.filter(d=>d.text!==o);return c.unshift({text:o,at:s}),{...l,history:$_(c)}}).ok}function ox(e,t,i=Date.now()){return e?ho(e,t,i,s=>({...s,history:[]})).ok:!1}function ax(e){const t=od(e);if(!t)return!1;try{return t.removeItem(ol),!0}catch{return!1}}const lx=300;function cx(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function ux({ownerId:e,node:t,session:i,storage:s=cx()}){const o=P.useMemo(()=>nx({ownerId:e,node:t,session:i}),[e,t,i]),l=P.useMemo(()=>Vs(o,s),[]),[c,d]=P.useState(l.draft),[m,p]=P.useState(l.expanded),[S,C]=P.useState(l.history),[_,v]=P.useState(-1),w=P.useRef(o),b=P.useRef(l.draft),x=P.useRef(null),N=P.useRef(l.updatedAt||0),L=P.useRef(l.draft),j=P.useCallback(()=>{x.current&&clearTimeout(x.current),x.current=null},[]),T=P.useCallback(()=>{j(),yg(w.current,b.current,s)},[j,s]),Q=P.useCallback(()=>{j(),x.current=setTimeout(()=>{x.current=null,yg(w.current,b.current,s)},lx)},[j,s]),H=P.useCallback(R=>{const F=String(typeof R=="function"?R(b.current):R||"");b.current=F,N.current=Date.now(),L.current=F,v(-1),d(F),Q()},[Q]),I=P.useCallback((R,F)=>{j(),b.current=R,N.current=Date.now(),d(R),v(F),Q()},[j,Q]),G=P.useCallback(()=>{if(!S.length)return!1;const R=Math.min(_+1,S.length-1);return _<0&&(L.current=b.current),I(S[R].text,R),!0},[I,S,_]),U=P.useCallback(()=>{if(_<0)return!1;const R=_-1;return I(R<0?L.current:S[R].text,R),!0},[I,S,_]),q=P.useCallback(R=>{L.current=b.current;const F=S.findIndex(D=>D.text===R);I(String(R||""),F)},[I,S]),Y=P.useCallback(()=>{p(R=>{const F=!R;return rx(w.current,F,s),F})},[s]),A=P.useCallback((R,F,D)=>{if(!R)return;if(sx(R,D,s),!(w.current===R)){Vs(R,s).draft===F&&Sg(R,s);return}C(Vs(R,s).history),L.current="",v(-1),b.current===F?(j(),b.current="",N.current=Date.now(),d(""),Sg(R,s)):Q()},[j,Q,s]),E=P.useCallback(()=>{ox(w.current,s),C([]),v(-1),L.current=b.current},[s]);return P.useEffect(()=>{if(w.current===o)return;T(),w.current=o;const R=Vs(o,s);b.current=R.draft,N.current=R.updatedAt||0,L.current=R.draft,d(R.draft),p(R.expanded),C(R.history),v(-1)},[o,T,s]),P.useEffect(()=>{const R=()=>T(),F=()=>{document.visibilityState==="hidden"&&T()};return window.addEventListener("pagehide",R),document.addEventListener("visibilitychange",F),()=>{window.removeEventListener("pagehide",R),document.removeEventListener("visibilitychange",F),T()}},[T]),P.useEffect(()=>{const R=()=>{j(),b.current="",N.current=0,L.current="",d(""),p(!1),C([]),v(-1)},F=O=>{if(O.key!==ol)return;if(O.newValue==null){R();return}const z=Vs(w.current,s);z.updatedAt<N.current||(j(),b.current=z.draft,N.current=z.updatedAt,L.current=z.draft,d(z.draft),p(z.expanded),C(z.history),v(-1))},D=()=>R();return window.addEventListener("storage",F),window.addEventListener(Rh,D),()=>{window.removeEventListener("storage",F),window.removeEventListener(Rh,D)}},[j,s]),{cellKey:o,text:c,setText:H,expanded:m,toggleExpanded:Y,history:S,historyCursor:_,recallPrevious:G,recallNext:U,selectHistory:q,confirmSubmitted:A,clearHistory:E,flush:T}}function q_({submitText:e,token:t,session:i,node:s,ownerId:o}){Si();const l=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:c,text:d,setText:m,expanded:p,toggleExpanded:S,history:C,historyCursor:_,recallPrevious:v,recallNext:w,selectHistory:b,confirmSubmitted:x,clearHistory:N,flush:L}=ux({ownerId:o,node:s,session:i}),[j,T]=P.useState(!1),[Q,H]=P.useState(""),[I,G]=P.useState(!1),U=P.useRef(null),q=P.useRef(null),Y=P.useRef(null),[A,E]=P.useState(!1),[R,F]=P.useState({left:0,bottom:0}),[D,O]=P.useState(!1),[z,ne]=P.useState(!1),K=P.useRef(null),M=P.useRef(null),W=P.useRef(null),oe=P.useRef(null),ae=P.useRef(null),se=P.useRef(null),le=P.useRef(null),_e=P.useRef(!1),[ce,X]=P.useState(!1),[Z,je]=P.useState({left:0,bottom:0,width:320}),Me=P.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);P.useEffect(()=>{let ge=!1;if(s){G(!1);return}return zt(`${l}/voice/status`,t).then(be=>be.json()).then(be=>{ge||G(!!be.serverSttConfigured)}).catch(()=>{ge||G(!1)}),()=>{ge=!0}},[t,l]);const ee=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||I);async function Ce(){const ge=d,be=HC(ge);if(!be||z)return;ne(!0),H("");let ke=!1;try{ke=!!await e(be)}catch{ke=!1}ke?x(c,ge,be):H(y("composer-send-failed")),ne(!1),requestAnimationFrame(()=>{var Xe;return(Xe=Y.current)==null?void 0:Xe.focus({preventScroll:!0})})}function Te(){const ge=K.current&&K.current.getBoundingClientRect();ge&&F({left:Math.max(6,Math.min(ge.left,window.innerWidth-186)),bottom:window.innerHeight-ge.top+6}),E(!0)}function xe(ge){E(!1),ge&&K.current&&K.current.focus()}function qe(){const ge=W.current&&W.current.getBoundingClientRect();if(ge){const be=Math.max(220,Math.min(360,window.innerWidth-12));je({left:Math.max(6,Math.min(ge.right-be,window.innerWidth-be-6)),bottom:window.innerHeight-ge.top+6,width:be})}X(!0)}function te(ge){X(!1),ge&&W.current&&W.current.focus()}P.useEffect(()=>{if(!A)return;const ge=ke=>{ke.key==="Escape"&&xe(!0)},be=ke=>{const Xe=M.current&&M.current.contains(ke.target),rt=K.current&&K.current.contains(ke.target);!Xe&&!rt&&xe(!1)};return document.addEventListener("keydown",ge),document.addEventListener("pointerdown",be),()=>{document.removeEventListener("keydown",ge),document.removeEventListener("pointerdown",be)}},[A]),P.useEffect(()=>{if(!ce)return;const ge=ke=>{ke.key==="Escape"&&te(!0)},be=ke=>{const Xe=oe.current&&oe.current.contains(ke.target),rt=W.current&&W.current.contains(ke.target);!Xe&&!rt&&te(!1)};return document.addEventListener("keydown",ge),document.addEventListener("pointerdown",be),()=>{document.removeEventListener("keydown",ge),document.removeEventListener("pointerdown",be)}},[ce]);function ve(ge){if(!(ge.isComposing||_e.current||ge.altKey||ge.ctrlKey||ge.metaKey)){if(ge.key==="ArrowUp"&&ge.currentTarget.selectionStart===0&&ge.currentTarget.selectionEnd===0){v()&&ge.preventDefault();return}ge.key==="ArrowDown"&&_>=0&&ge.currentTarget.selectionStart===d.length&&ge.currentTarget.selectionEnd===d.length&&w()&&ge.preventDefault()}}function Be(ge){xe(!1),ge.current&&ge.current.click()}async function Ie(ge){if(!ge.length||!i)return;O(!0),H("");const{paths:be,errors:ke}=await A_({files:ge,token:t,session:i,node:s,paste:!1});ke.length&&H(ke.map(Xe=>`${Xe.name}: ${Xe.message}`).join(" · ")),be.length&&m(Xe=>Xe+(Xe&&!Xe.endsWith(" ")?" ":"")+be.join(" ")),O(!1)}function Fe(){U.current&&U.current.stop(),q.current&&q.current.stop(),T(!1)}async function gt(){H("");const ge=window.SpeechRecognition||window.webkitSpeechRecognition;if(ge){const be=new ge;be.lang="it-IT",be.continuous=!1,be.interimResults=!0;const ke=d?`${d} `:"";be.onresult=Xe=>{const rt=Array.from(Xe.results).map(Ve=>Ve[0].transcript).join("");m(ke+rt)},be.onend=()=>T(!1),be.onerror=Xe=>{H(`voice: ${Xe.error||"errore"}`),T(!1)},U.current=be,be.start(),T(!0);return}try{const be=await navigator.mediaDevices.getUserMedia({audio:!0}),ke=new MediaRecorder(be),Xe=[];ke.ondataavailable=rt=>Xe.push(rt.data),ke.onstop=async()=>{be.getTracks().forEach(rt=>rt.stop()),T(!1),H("trascrivo…");try{const rt=new Blob(Xe,{type:ke.mimeType||"audio/webm"}),de=await(await zt(`${l}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:rt})).json();de.error?H(de.error):(H(""),m(Ke=>Ke+(Ke?" ":"")+(de.text||"")))}catch(rt){H(String(rt))}},q.current={stop:()=>ke.state!=="inactive"&&ke.stop()},ke.start(),T(!0)}catch{H("microfono non disponibile"),T(!1)}}return h.jsxs("div",{className:"nc-composer",children:[Q&&h.jsx("div",{className:"nc-composer-err",children:Q}),h.jsxs("div",{className:"nc-composer-row",children:[i&&h.jsx("button",{ref:K,className:D?"attach busy":"attach",disabled:D,onClick:()=>A?xe(!1):Te(),title:y(D?"attach-uploading":"attach"),"aria-label":y("attach"),"aria-haspopup":"menu","aria-expanded":A,"aria-controls":Me.current,children:h.jsx(et,{name:"attach",size:22})}),A&&h.jsxs("div",{ref:M,id:Me.current,role:"menu",className:"nc-attach-menu",style:{left:R.left,bottom:R.bottom},children:[h.jsxs("button",{role:"menuitem",onClick:()=>Be(ae),children:[h.jsx(et,{name:"file",size:18})," ",y("attach-file")]}),h.jsxs("button",{role:"menuitem",onClick:()=>Be(se),children:[h.jsx(et,{name:"camera",size:18})," ",y("attach-camera")]}),h.jsxs("button",{role:"menuitem",onClick:()=>Be(le),children:[h.jsx(et,{name:"image",size:18})," ",y("attach-gallery")]})]}),h.jsx("button",{ref:W,type:"button",className:"history",onPointerDown:ge=>ge.preventDefault(),onClick:()=>ce?te(!1):qe(),title:y("composer-history-tools"),"aria-label":y("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":ce,children:h.jsx(et,{name:"history",size:21})}),ce&&h.jsxs("div",{ref:oe,role:"menu",className:"nc-composer-history-menu",style:{left:Z.left,bottom:Z.bottom,width:Z.width},children:[h.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:ge=>ge.preventDefault(),onClick:()=>{S(),te(!1),requestAnimationFrame(()=>{var ge;return(ge=Y.current)==null?void 0:ge.focus({preventScroll:!0})})},children:[h.jsx(et,{name:p?"chevronDown":"chevronUp",size:18}),y(p?"composer-collapse":"composer-expand")]}),h.jsx("div",{className:"nc-composer-history-title",children:y("composer-history")}),C.length===0&&h.jsx("div",{className:"nc-composer-history-empty",children:y("composer-history-empty")}),C.map((ge,be)=>h.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:ke=>ke.preventDefault(),onClick:()=>{b(ge.text),te(!1),requestAnimationFrame(()=>{var ke;return(ke=Y.current)==null?void 0:ke.focus({preventScroll:!0})})},children:[h.jsx("span",{children:ge.text.replace(/\s+/g," ").slice(0,180)}),ge.at>0&&h.jsx("small",{children:new Date(ge.at).toLocaleString()})]},`${ge.at}:${be}`)),C.length>0&&h.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:ge=>ge.preventDefault(),onClick:()=>{N(),te(!1)},children:y("composer-history-clear")})]}),h.jsx("input",{ref:ae,type:"file",multiple:!0,hidden:!0,onChange:ge=>{Ie(Array.from(ge.target.files||[])),ge.target.value=""}}),h.jsx("input",{ref:se,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:ge=>{Ie(Array.from(ge.target.files||[])),ge.target.value=""}}),h.jsx("input",{ref:le,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:ge=>{Ie(Array.from(ge.target.files||[])),ge.target.value=""}}),h.jsx("textarea",{ref:Y,className:p?"expanded":"",rows:p?8:2,value:d,placeholder:y("composer-placeholder"),onChange:ge=>m(ge.target.value),onKeyDown:ve,onCompositionStart:()=>{_e.current=!0},onCompositionEnd:()=>{_e.current=!1},onBlur:L}),ee&&h.jsx("button",{className:j?"mic on":"mic",onClick:j?Fe:gt,title:y("voice"),children:h.jsx(et,{name:"mic",size:22})}),h.jsx("button",{type:"button",className:"go",disabled:z,onPointerDown:ge=>ge.preventDefault(),onClick:Ce,title:y("send"),children:h.jsx(et,{name:"enter",size:22})})]})]})}function wg(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const hx=180,dx=480;function fx({sessions:e=[],cells:t=[],activeSessions:i=[],nodeGroups:s=[],onPick:o,onAddTile:l,onPower:c,onNodePower:d,onKill:m,onVisibility:p,onNew:S,onSettings:C,localNodeId:_,width:v=240,collapsed:w=!1,onResize:b,onToggleCollapse:x}){const[N,L]=Si(),{pins:j,orders:T,togglePin:Q,viewFor:H,updateView:I,canMoveRoster:G,moveRoster:U,stepRoster:q}=Ov(),Y=new Set((t||[]).map(X=>X.tmuxSession)),A=new Map((e||[]).map(X=>[X.name,X])),E=(X,Z)=>p0(j,X,Z),R=m0,F=[...t||[]].sort((X,Z)=>R(E(X.tmuxSession,(A.get(X.tmuxSession)||{}).activity),E(Z.tmuxSession,(A.get(Z.tmuxSession)||{}).activity))),D=(e||[]).filter(X=>!Y.has(X.name)).sort((X,Z)=>R(E(X.name,X.activity),E(Z.name,Z.activity))||X.name.localeCompare(Z.name)),O=new Set(i||[]),z=Fv(F,D,A),ne=ar(z,j,H("local").filter,zn(T,"local")),K=(s||[]).map(X=>{const Z=(X.route||[X.name]).join("/"),je=H(Z),{rawItems:Me}=Hv(X),ye=ar(Me,j,je.filter,zn(T,Z));return{g:X,nodeRoute:Z,groupView:je,rawItems:Me,items:ye}}),M=(X,Z,je)=>o&&o({session:X,...Z?{node:Z}:{},...Qr.test(String(je||""))?{ownerId:je}:{}}),[W,oe]=P.useState(null),ae=(X,Z)=>{const je=X.currentTarget.getBoundingClientRect();oe({text:Z,y:je.top+je.height/2})},se=()=>oe(null),le=P.useRef(null);P.useEffect(()=>()=>{le.current&&le.current()},[]);function _e(X){X.preventDefault(),X.stopPropagation();const Z=X.clientX,je=v,Me=ee=>{const Ce=Math.max(hx,Math.min(dx,je+(ee.clientX-Z)));b&&b(Ce)},ye=()=>{window.removeEventListener("pointermove",Me),window.removeEventListener("pointerup",ye),window.removeEventListener("pointercancel",ye),window.removeEventListener("blur",ye),le.current=null};window.addEventListener("pointermove",Me),window.addEventListener("pointerup",ye),window.addEventListener("pointercancel",ye),window.addEventListener("blur",ye),le.current=ye}const ce=w?{width:48,flex:"0 0 48px"}:{width:v,flex:`0 0 ${v}px`};return w?h.jsxs("aside",{className:"nc-sidebar mini",style:ce,children:[h.jsx("div",{className:"nc-side-head mini",children:h.jsx("button",{className:"nc-collapse-btn",onClick:x,title:y("expand"),children:"⟩"})}),h.jsx("button",{className:"nc-side-gear mini",onClick:()=>C&&C("nodes",!1),title:y("settings"),onMouseEnter:X=>ae(X,y("settings")),onMouseLeave:se,children:h.jsx(et,{name:"gear",size:16})}),h.jsx("div",{className:"nc-side-scroll mini",children:h.jsxs("div",{className:"nc-side-group mini",children:[H("local").open&&ne.map(X=>X.type==="cell"?(()=>{const Z=X.value,je=Z.degraded?"warn":Z.tmux?"on":"",Me=!!Z.tmux;return h.jsx("button",{type:"button",className:`nc-mini-dot${O.has(Z.tmuxSession)?" active":""}`,onMouseEnter:ye=>ae(ye,Z.cell),onMouseLeave:se,draggable:Me,onDragStart:Me?ye=>ye.dataTransfer.setData("text/nc-session",Z.tmuxSession):void 0,onClick:Me?()=>l&&l(Z.tmuxSession):()=>c&&c(Z),onDoubleClick:Me?()=>M(Z.tmuxSession,"",_):void 0,children:h.jsx("span",{className:`nc-dot ${je}`})},X.key)})():(()=>{const Z=X.value;return h.jsx("button",{type:"button",className:`nc-mini-init${O.has(Z.name)?" active":""}`,onMouseEnter:je=>ae(je,Z.name),onMouseLeave:se,draggable:!0,onDragStart:je=>je.dataTransfer.setData("text/nc-session",Z.name),onClick:()=>l&&l(Z.name),onDoubleClick:()=>M(Z.name,"",_),children:wg(Z.name)},X.key)})()),K.flatMap(({g:X,nodeRoute:Z,groupView:je,items:Me})=>X.status==="up"?je.open?Me.map(ye=>ye.type==="cell"?(()=>{const ee=ye.value,Ce=!!ee.tmux;return h.jsx("button",{type:"button",className:`nc-mini-dot${O.has(ye.key)?" active":""}`,onMouseEnter:Te=>ae(Te,`${X.label||Z}: ${ee.cell}`),onMouseLeave:se,draggable:Ce,onDragStart:Ce?Te=>Te.dataTransfer.setData("text/nc-session",ye.key):void 0,onClick:Ce?()=>l&&l(ye.key):()=>c&&c({...ee,route:X.route,availableEngines:X.engines||[]}),onDoubleClick:Ce?()=>M(ee.tmuxSession,Z,X.instanceId):void 0,children:h.jsx("span",{className:`nc-dot ${ee.degraded?"warn":Ce?"on":""}`})},ye.key)})():(()=>{const ee=ye.value;return h.jsx("button",{type:"button",className:`nc-mini-init${O.has(ye.key)?" active":""}`,onMouseEnter:Ce=>ae(Ce,`${X.label||Z}: ${ee.name}`),onMouseLeave:se,draggable:!0,onDragStart:Ce=>Ce.dataTransfer.setData("text/nc-session",ye.key),onClick:()=>l&&l(ye.key),onDoubleClick:()=>M(ee.name,Z,X.instanceId),children:wg(ee.name)},ye.key)})()):[]:[h.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:ye=>ae(ye,`${X.label||(X.route||[X.name]).join(" › ")}: ${qr(X)}`),onMouseLeave:se,children:h.jsx("span",{className:`nc-dot${X.status==="passive"?"":" warn"}`})},`nodo-${(X.route||[X.name]).join("/")}`)])]})}),W&&h.jsx("div",{className:"nc-mini-tip",style:{top:W.y},children:W.text})]}):h.jsxs("aside",{className:"nc-sidebar",style:ce,children:[h.jsxs("div",{className:"nc-side-head",children:[h.jsx("button",{className:"nc-collapse-btn",onClick:x,title:y("collapse"),children:"⟨"}),h.jsx("span",{className:"nc-side-title",children:y("fleet")}),h.jsxs("button",{className:"nc-new-btn",onClick:S,title:y("fleet-new-cell"),children:["+ ",y("new")]})]}),h.jsxs("button",{className:"nc-side-gear",onClick:()=>C&&C("nodes",!1),title:y("settings"),children:[h.jsx(et,{name:"gear",size:15})," ",y("settings")]}),h.jsxs("div",{className:"nc-side-scroll",children:[h.jsx(px,{label:y("position-local"),count:ne.length,state:H("local"),onToggle:()=>I("local",{open:!H("local").open}),onFilter:X=>I("local",{filter:X})}),H("local").open&&h.jsxs("div",{className:"nc-side-group",children:[ne.map(X=>X.type==="cell"?(()=>{const Z=X.value,je=Z.degraded?"warn":Z.tmux?"on":"",Me=Z.degraded?y("cell-degraded"):Z.tmux?y("cell-on"):y("cell-off"),ye=!!Z.tmux;return h.jsxs("div",{"data-roster-key":X.key,"data-position":"local",className:`nc-cell${ye?" live":""}${O.has(Z.tmuxSession)?" active":""}`,title:`${Z.cell} · ${Z.engine}${Z.key?`·${Z.key}`:""} · ${Me}`,"aria-label":`${Z.cell}, ${Z.engine}${Z.key?` ${Z.key}`:""}, ${Me}`,draggable:ye,onDragStart:ye?ee=>ee.dataTransfer.setData("text/nc-session",Z.tmuxSession):void 0,onClick:ye?()=>l&&l(Z.tmuxSession):void 0,onDoubleClick:ye?()=>M(Z.tmuxSession,"",_):void 0,children:[h.jsx(Ur,{position:"local",itemKey:X.key,label:Z.cell,canMove:G,onMove:(ee,Ce)=>U("local",ee,Ce,z),onStep:ee=>q("local",X.key,ee,z)}),h.jsx("span",{className:`nc-dot ${je}`}),h.jsxs("span",{className:"nc-cell-main",children:[h.jsx("b",{title:Z.cell,children:Z.cell}),h.jsxs("small",{title:`${Z.engine}${Z.key?`·${Z.key}`:""}`,children:[Z.engine,Z.key?`·${Z.key}`:""]})]}),h.jsx("button",{className:`nc-pin${j.includes(X.key)?" on":""}`,title:y("pin"),onClick:ee=>{ee.stopPropagation(),Q(X.key)},children:j.includes(X.key)?"★":"☆"}),h.jsx("button",{className:`nc-power${Z.tmux?" on":""}${Z.degraded?" warn":""}`,onClick:ee=>{ee.stopPropagation(),c&&c(Z)},title:Z.active?y("power-off"):y("power-on"),children:h.jsx(et,{name:"power",size:14})})]},X.key)})():(()=>{var je;const Z=X.value;return h.jsxs("div",{"data-roster-key":X.key,"data-position":"local",className:`nc-side-card${O.has(Z.name)?" active":""}`,draggable:!0,onDragStart:Me=>Me.dataTransfer.setData("text/nc-session",Z.name),onClick:()=>l&&l(Z.name),onDoubleClick:()=>M(Z.name,"",_),children:[h.jsx(Ur,{position:"local",itemKey:X.key,label:Z.name,canMove:G,onMove:(Me,ye)=>U("local",Me,ye,z),onStep:Me=>q("local",X.key,Me,z)}),h.jsx("span",{className:Z.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:Z.name}),h.jsxs("small",{children:[Z.preview||Z.cmd||y("windows").replace("{n}",String(Z.windows||0)),((je=Z.outbox)==null?void 0:je.count)>0?` · 📦${Z.outbox.count}`:""]})]}),Z.activity?h.jsx("span",{className:"nc-rel",children:Gr(Z.activity)}):null,h.jsx("button",{className:`nc-pin${j.includes(X.key)?" on":""}`,title:y("pin"),onClick:Me=>{Me.stopPropagation(),Q(X.key)},children:j.includes(X.key)?"★":"☆"}),h.jsx("button",{className:`nc-technical${Z.technical?" on":""}`,title:Z.technical?y("mark-normal"):y("mark-technical"),"aria-label":`${Z.technical?y("mark-normal"):y("mark-technical")} ${Z.name}`,onClick:Me=>{Me.stopPropagation(),p&&p(Z.name,!Z.technical,[])},children:"T"}),h.jsx("button",{className:"nc-menu",title:y("terminate"),onClick:Me=>{Me.stopPropagation(),window.confirm(y("terminate-confirm").replace("{name}",Z.name))&&m&&m(Z.name)},children:"⋯"})]},X.key)})()),ne.length===0&&h.jsx("div",{className:"nc-empty",children:y("no-sessions-short")})]}),K.map(({g:X,nodeRoute:Z,groupView:je,rawItems:Me,items:ye})=>{const Ce=zv(X.health)||(X.status==="up"?"on":X.status==="passive"?"":"warn");return h.jsxs("div",{children:[h.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>I(Z,{open:!je.open}),onKeyDown:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),I(Z,{open:!je.open}))},children:[h.jsx("span",{className:"nc-node-chevron",children:je.open?"⌄":"›"}),h.jsx("span",{className:`nc-dot ${Ce}`,title:X.health?Wa(X.health):""}),h.jsx("b",{children:X.label||X.name}),h.jsxs("small",{children:[" · ",X.status==="up"?y("node-sessions").replace("{n}",String(ye.length)):X.health&&Wa(X.health)||qr(X)]}),h.jsxs("select",{className:"nc-node-filter",value:je.filter,title:y(`view-${je.filter}`),onClick:Te=>Te.stopPropagation(),onChange:Te=>I(Z,{filter:Te.target.value}),children:[h.jsx("option",{value:"all",children:y("view-all")}),h.jsx("option",{value:"pinned",children:y("view-pinned")}),h.jsx("option",{value:"active",children:y("view-active")}),h.jsx("option",{value:"off",children:y("view-off")}),h.jsx("option",{value:"technical",children:y("view-technical")})]}),X.direct&&X.health&&X.health.managed!==!1&&h.jsx("button",{type:"button",className:`nc-power${X.tunnelStatus==="up"?" on":""}`,title:X.tunnelStatus==="up"?y("power-off"):y("power-on"),onClick:Te=>{Te.stopPropagation(),d&&d(X)},children:h.jsx(et,{name:"power",size:14})})]}),X.status==="up"&&je.open&&h.jsxs("div",{className:"nc-side-group",children:[ye.map(Te=>Te.type==="cell"?(()=>{const xe=Te.value,qe=!!xe.tmux,te=xe.degraded?"warn":xe.tmux?"on":"";return h.jsxs("div",{"data-roster-key":Te.key,"data-position":Z,className:`nc-side-card nc-cell${qe?" live":""}${O.has(xe.key)?" active":""}`,title:xe.active?y("cell-on"):y("cell-off"),draggable:qe,onDragStart:qe?ve=>ve.dataTransfer.setData("text/nc-session",xe.key):void 0,onClick:qe?()=>l&&l(xe.key):void 0,onDoubleClick:qe?()=>M(xe.tmuxSession,Z,X.instanceId):void 0,children:[h.jsx(Ur,{position:Z,itemKey:Te.key,label:xe.cell,canMove:G,onMove:(ve,Be)=>U(Z,ve,Be,Me),onStep:ve=>q(Z,Te.key,ve,Me)}),h.jsx("span",{className:`nc-dot ${te}`}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:xe.cell}),h.jsxs("small",{children:[xe.engine,xe.key?`·${xe.key}`:"",xe.active?"":` · ${y("cell-off")}`]})]}),h.jsx("button",{className:`nc-pin${j.includes(Te.key)?" on":""}`,title:y("pin"),onClick:ve=>{ve.stopPropagation(),Q(Te.key)},children:j.includes(Te.key)?"★":"☆"}),(X.capabilities||[]).includes(xe.active?"down":"up")&&h.jsx("button",{className:`nc-power${xe.active?" on":""}${xe.degraded?" warn":""}`,onClick:ve=>{ve.stopPropagation(),c&&c({...xe,route:X.route,availableEngines:X.engines||[]})},title:xe.active?y("power-off"):y("power-on"),children:h.jsx(et,{name:"power",size:14})})]},Te.key)})():(()=>{const xe=Te.value;return h.jsxs("div",{"data-roster-key":Te.key,"data-position":Z,className:`nc-side-card${O.has(xe.key)?" active":""}`,draggable:!0,onDragStart:qe=>qe.dataTransfer.setData("text/nc-session",xe.key),onClick:()=>l&&l(xe.key),onDoubleClick:()=>M(xe.name,xe.node||Z,X.instanceId),children:[h.jsx(Ur,{position:Z,itemKey:Te.key,label:xe.name,canMove:G,onMove:(qe,te)=>U(Z,qe,te,Me),onStep:qe=>q(Z,Te.key,qe,Me)}),h.jsx("span",{className:xe.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:xe.name}),h.jsx("small",{children:xe.preview?xe.preview:xe.cmd?xe.cmd:y("windows").replace("{n}",String(xe.windows||0))})]}),xe.activity?h.jsx("span",{className:"nc-rel",children:Gr(xe.activity)}):null,h.jsx("button",{className:`nc-pin${j.includes(Te.key)?" on":""}`,title:y("pin"),onClick:qe=>{qe.stopPropagation(),Q(Te.key)},children:j.includes(Te.key)?"★":"☆"}),h.jsx("button",{className:`nc-technical${xe.technical?" on":""}`,title:xe.technical?y("mark-normal"):y("mark-technical"),"aria-label":`${xe.technical?y("mark-normal"):y("mark-technical")} ${xe.name}`,onClick:qe=>{qe.stopPropagation(),p&&p(xe.name,!xe.technical,X.route||[])},children:"T"}),h.jsx("button",{className:"nc-menu",title:y("terminate"),onClick:qe=>{qe.stopPropagation(),window.confirm(y("terminate-confirm").replace("{name}",xe.name))&&m&&m(xe.name,X.route)},children:"⋯"})]},Te.key)})()),ye.length===0&&h.jsx("div",{className:"nc-empty",children:y("no-sessions-short")})]})]},`nodo-${(X.route||[X.name]).join("/")}`)})]}),h.jsx("div",{className:"nc-side-lang",children:Iv.map((X,Z)=>h.jsxs("span",{children:[Z>0&&" · ",h.jsx("button",{className:`nc-lang-btn${N===X?" on":""}`,onClick:()=>L(X),title:X,children:X.toUpperCase()})]},X))}),h.jsx("div",{className:"nc-side-resize",onPointerDown:_e,title:""})]})}function px({label:e,count:t,state:i,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:i.open?"⌄":"›"}),h.jsx("span",{className:"nc-dot on"}),h.jsx("b",{children:e}),h.jsxs("small",{children:[" · ",y("node-sessions").replace("{n}",String(t))]}),h.jsxs("select",{className:"nc-node-filter",value:i.filter,title:y(`view-${i.filter}`),onClick:l=>l.stopPropagation(),onChange:l=>o(l.target.value),children:[h.jsx("option",{value:"all",children:y("view-all")}),h.jsx("option",{value:"pinned",children:y("view-pinned")}),h.jsx("option",{value:"active",children:y("view-active")}),h.jsx("option",{value:"off",children:y("view-off")}),h.jsx("option",{value:"technical",children:y("view-technical")})]})]})}function mx(e,t,i){return!e&&t?i+1:i}function gx({session:e,node:t,ownerId:i,token:s,readonly:o=!1,focused:l,onFocus:c,onClose:d,onOpenSingle:m,alive:p=!0,available:S=!0,fontSize:C=oo,onZoom:_,decks:v=[],currentDeck:w,onSendToDeck:b}){const x=P.useRef(()=>{}),N=P.useRef(()=>!1),L=P.useRef(()=>{}),j=P.useRef(!1),[T,Q]=P.useState(!1),[H,I]=P.useState(!1),[G,U]=P.useState(!1),[q,Y]=P.useState(null),[A,E]=P.useState(0),R=P.useRef(p),F=t?`${t}:${e}`:e,D=v.filter(O=>O.id!==w&&O.available!==!1);return P.useEffect(()=>{const O=R.current;!O&&p&&E(z=>mx(O,p,z)),R.current=p},[p]),h.jsxs("div",{className:`nc-tile${l?" focused":""}`,onMouseDown:()=>c&&c(F),children:[h.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:O=>{O.dataTransfer.setData("text/nc-session",F),O.dataTransfer.effectAllowed="move"},children:[h.jsxs("button",{className:"nc-tile-name",onClick:()=>c&&c(F),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:[_&&h.jsx("button",{onClick:()=>_(-1),title:y("zoom-out"),children:h.jsx(et,{name:"zoomOut",size:14})}),_&&h.jsx("button",{onClick:()=>_(1),title:y("zoom-in"),children:h.jsx(et,{name:"zoomIn",size:14})}),b&&D.length>0&&h.jsxs("select",{className:"nc-tile-deck",title:y("send-to-deck"),value:"",onMouseDown:O=>O.stopPropagation(),onChange:O=>{const z=O.target.value;z&&b(F,z),O.target.value=""},children:[h.jsx("option",{value:"",children:y("send-to-deck")}),D.map(O=>h.jsxs("option",{value:O.id,children:[O.ownerLabel," · ",O.name]},O.id))]}),h.jsx("button",{onClick:()=>I(O=>!O),title:"composer",children:"⌨"}),h.jsx("button",{onClick:()=>U(O=>!O),title:"file",children:"📁"}),m&&h.jsx("button",{onClick:()=>m({session:e,node:t,ownerId:i}),title:"vista singola",children:"↗"}),d&&h.jsx("button",{className:"nc-tile-close",onClick:()=>d(F),title:"chiudi",children:"✕"})]})]}),h.jsxs("div",{className:"nc-tile-body",children:[S?h.jsx(B_,{session:e,node:t,token:s,readonly:o,takeSize:!1,focused:l,sendRef:x,composerRef:N,actionRef:L,ctrlRef:j,setCtrlArmed:Q,onFiles:Y,fontSize:C},`${F}:${A}`):h.jsx("div",{className:"nc-tile-unavailable",children:y("deck-owner-unavailable")}),S&&G&&h.jsx("div",{className:"nc-tile-files",onMouseDown:O=>O.stopPropagation(),children:h.jsx(I_,{session:e,node:t,token:s,filesEvent:q,onClose:()=>U(!1)})})]}),S&&H&&h.jsx("div",{className:"nc-tile-composer",onMouseDown:O=>O.stopPropagation(),children:h.jsx(q_,{submitText:O=>N.current(O),token:s,session:e,node:t,ownerId:i})})]})}const bg=.2,Cg=.28,V_=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),pu=e=>V_(e,"text/nc-session"),xg=e=>{var t;return V_(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function vx(e,t,i){const s=(e-i.left)/(i.width||1),o=(t-i.top)/(i.height||1);return s<Cg?"left":s>1-Cg?"right":o<.5?"top":"bottom"}function _x({layout:e,onLayoutChange:t,token:i,readonly:s=!1,sessionsAlive:o,focusSession:l,onFocus:c,onOpenSingle:d,decks:m=[],currentDeck:p,onSendToDeck:S}){Si();const[C,_]=P.useState(null),v=P.useRef(null),w=P.useRef([]),b=P.useRef(null);function x(U,q){const Y=()=>{window.removeEventListener("pointermove",U),window.removeEventListener("pointerup",Y),window.removeEventListener("pointercancel",Y),window.removeEventListener("blur",Y),b.current=null};window.addEventListener("pointermove",U),window.addEventListener("pointerup",Y),window.addEventListener("pointercancel",Y),window.addEventListener("blur",Y),b.current=Y}P.useEffect(()=>()=>{b.current&&b.current()},[]),P.useEffect(()=>{const U=()=>_(null);return window.addEventListener("dragend",U),window.addEventListener("drop",U),()=>{window.removeEventListener("dragend",U),window.removeEventListener("drop",U)}},[]);const N=e.columns.length,L=U=>C&&C.col===U&&C.row===void 0,j=!!C&&C.col===N,T=(U,q)=>C&&C.col===U&&C.row===q&&C.quadrant?` drop-${C.quadrant}`:"";function Q(U){if(U.preventDefault(),xg(U.dataTransfer)){_(null);return}const q=U.dataTransfer.getData("text/nc-session"),Y=C;if(_(null),!q||!Y)return;let A;if(Y.quadrant){if(A=x0(e,Y.col,Y.row,Y.quadrant),!A)return}else A={col:Y.col};t(Gi(e).includes(q)?y0(e,q,A):Xh(e,q,A))}function H(U,q){U.preventDefault(),U.stopPropagation();const Y=U.clientX,A=e.columns[q].width,E=v.current&&v.current.clientWidth||1,R=e.columns[q+1];x(D=>{let O=Math.max(bg,A+(D.clientX-Y)/E);if(R){const z=vm(O/(O+R.width));O=z/(1-z)*R.width}t(w0(e,q,O))})}function I(U,q,Y){U.preventDefault(),U.stopPropagation();const A=U.clientY,E=e.columns[q].tiles[Y].height,R=w.current[q],F=R&&R.clientHeight||1,D=e.columns[q].tiles[Y+1];x(z=>{let ne=Math.max(bg,E+(z.clientY-A)/F);if(D){const K=vm(ne/(ne+D.height));ne=K/(1-K)*D.height}t(b0(e,q,Y,ne))})}function G(U){t(qa(e,U))}return h.jsxs("div",{className:"nc-grid",ref:v,onDragOver:U=>{if(xg(U.dataTransfer)){U.preventDefault(),_(null);return}pu(U.dataTransfer)&&(U.preventDefault(),C&&C.col===N||_({col:N}))},onDrop:Q,onDragLeave:U=>{const q=U.relatedTarget;(!q||!(v.current&&v.current.contains(q)))&&_(null)},children:[e.columns.flatMap((U,q)=>{const Y=[];return Y.push(h.jsx("div",{className:`nc-col${L(q)?" drop-newcol":""}`,ref:A=>{w.current[q]=A},style:{flexGrow:U.width,flexBasis:0},onDragOver:A=>{pu(A.dataTransfer)&&(A.preventDefault(),A.stopPropagation(),C&&C.col===q&&C.row===void 0||_({col:q}))},children:U.tiles.flatMap((A,E)=>{const R=[],F=_i(A);return R.push(h.jsx("div",{className:`nc-tile-slot${T(q,E)}`,style:{flexGrow:A.height,flexBasis:0},onDragOver:D=>{if(!pu(D.dataTransfer))return;D.preventDefault(),D.stopPropagation();const O=vx(D.clientX,D.clientY,D.currentTarget.getBoundingClientRect());C&&C.col===q&&C.row===E&&C.quadrant===O||_({col:q,row:E,quadrant:O})},children:h.jsx(gx,{session:A.session,node:A.node,ownerId:A.ownerId,token:i,readonly:s,focused:l===F,onFocus:c,onClose:G,onOpenSingle:d,available:A.unavailable!==!0,alive:A.unavailable!==!0&&(!o||o.has(F)),fontSize:A.fontSize,onZoom:D=>t(C0(e,q,E,D)),decks:m,currentDeck:p,onSendToDeck:S})},F)),E<U.tiles.length-1&&R.push(h.jsx("div",{className:"nc-divider-h",onPointerDown:D=>I(D,q,E)},`h${E}`)),R})},`c${q}`)),q<N-1&&Y.push(h.jsx("div",{className:"nc-divider-v",onPointerDown:A=>H(A,q)},`v${q}`)),Y}),j&&h.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),N===0&&h.jsx("div",{className:"nc-grid-empty",children:y("grid-empty")})]})}const un="local",Mi=/^[a-f0-9]{16,64}$/;function Yr(e,t){return`${e&&Mi.test(e)?e:un}:${t}`}function ad(e){const t=String(e||""),i=t.indexOf(":");if(i<1)return null;const s=t.slice(0,i),o=t.slice(i+1);return s!==un&&!Mi.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===un?null:s,name:o}}function al(e){return Array.isArray(e)&&e.length?e.join("/"):""}function ld(e){return{columns:lr(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))}}function yx(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&Mi.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(al(i.route),i.instanceId);return t}function Sx(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&Mi.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(i.instanceId,[...i.route]);return t}function Dh(e,t,i=[]){const s=ld(e),o=yx(i);for(const l of s.columns)for(const c of l.tiles)c.ownerId||(!c.node&&Mi.test(String(t||""))?c.ownerId=t:c.node&&o.has(c.node)&&(c.ownerId=o.get(c.node)));return s}function Mh(e,t,i=[]){const s=ld(e),o=new Map;for(const l of i)l&&Mi.test(String(l.instanceId||""))&&Array.isArray(l.route)&&o.set(l.instanceId,[...l.route]);for(const l of s.columns)for(const c of l.tiles)c.ownerId&&(c.ownerId===t?(delete c.node,delete c.unavailable):o.has(c.ownerId)?(c.node=al(o.get(c.ownerId)),delete c.unavailable):c.unavailable=!0);return s}function kg(e,t,i=[]){const s=ld(e),o=Sx(i);for(const l of s.columns)for(const c of l.tiles)delete c.unavailable,c.ownerId&&(c.ownerId===t?delete c.node:o.has(c.ownerId)&&(c.node=al(o.get(c.ownerId))));return s}function Y_(e,t,i=[]){const s=Hn(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...Mi.test(String(t||""))?{ownerId:t}:{}};const o=i.find(l=>al(l&&l.route)===s.node);return{...s,...o&&Mi.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const wx=/^[a-z0-9-]{1,32}$/,yi="main",X_="nc_decks",G_="nc_deck_order_v1",Q_=24;function Eg(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function Zr(e){return typeof e=="string"&&wx.test(e)}function bx(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let i;try{i=decodeURIComponent(t[1])}catch{i=t[1]}return Zr(i)?i:yi}return yi}function Cx(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:Yr(null,yi),ownerId:null,name:yi}}if(Mi.test(s)&&Zr(o))return{id:Yr(s,o),ownerId:s,name:o}}const i=bx(e);return{id:Yr(null,i),ownerId:null,name:i}}function mu(e,t){const i=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:ad(e)||{ownerId:null,name:e},s=Zr(i.name)?i.name:yi,o=i.ownerId?`/deck/${encodeURIComponent(i.ownerId)}/${encodeURIComponent(s)}`:s===yi?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function J_(e){return e===yi?"nc_grid_v1":`nc_grid_v1__${e}`}function Z_(e){const t=[yi];if(Array.isArray(e)){for(const i of e)if(Zr(i)&&i!==yi&&!t.includes(i)&&t.push(i),t.length>=Q_)break}return t}function ns(){return typeof localStorage<"u"?localStorage:null}function xx(){const e=ns();if(!e)return[yi];try{return Z_(JSON.parse(e.getItem(X_)||"null"))}catch{return[yi]}}function kx(e){const t=ns();if(t)try{t.setItem(X_,JSON.stringify(Z_(e)))}catch{}}function fo(e){return e==="local"||Mi.test(String(e||""))}function ll(e,t){const i=ad(e);return!!i&&(i.ownerId||"local")===t}function Ji(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[i,s]of Object.entries(e).slice(0,64)){if(!fo(i)||!Array.isArray(s))continue;const o=[...new Set(s.filter(l=>typeof l=="string"&&l.length<=100&&ll(l,i)))].slice(0,Q_);o.length&&(t[i]=o)}return t}function Ma(e=ns()){if(!e)return{};try{return Ji(JSON.parse(e.getItem(G_)||"null"))}catch{return{}}}function gu(e,t=ns()){const i=Ji(e);if(t)try{t.setItem(G_,JSON.stringify(i))}catch{}return i}function cl(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function Ex(e,t,i,s,o=[]){if(!fo(t)||i===s)return Ji(e);const l=[...new Set(o.filter(C=>ll(C,t)))];if(!l.includes(i)||!l.includes(s))return Ji(e);const c=cl(e,t).filter(C=>l.includes(C)),d=[...c,...l.filter(C=>!c.includes(C))],m=d.indexOf(i),p=d.indexOf(s);d.splice(m,1);const S=d.indexOf(s);return d.splice(m<p?S+1:S,0,i),Ji({...e,[t]:d})}function Nx(e,t,i,s){if(!fo(t)||!ll(s,t))return Ji(e);const o=cl(e,t);return o.includes(i)?Ji({...e,[t]:o.map(l=>l===i?s:l)}):Ji(e)}function Rx(e,t,i){return fo(t)?Ji({...e,[t]:cl(e,t).filter(s=>s!==i)}):Ji(e)}function Ng(e,t={}){const i=new Map;for(const o of Array.isArray(e)?e:[]){const l=o!=null&&o.local?"local":String((o==null?void 0:o.ownerId)||"");!fo(l)||!ll(o==null?void 0:o.id,l)||(i.has(l)||i.set(l,[]),i.get(l).push(o))}const s=[];for(const[,o]of i){const l=o[0].local?"local":o[0].ownerId,c=cl(t,l),d=new Map(c.map((m,p)=>[m,p]));o.sort((m,p)=>{const S=d.has(m.id)?d.get(m.id):Number.MAX_SAFE_INTEGER,C=d.has(p.id)?d.get(p.id):Number.MAX_SAFE_INTEGER;return S-C}),s.push(...o)}return s}function Lh(e){const t=ns();if(!t)return null;try{return JSON.parse(t.getItem(J_(e))||"null")}catch{return null}}function Px(e,t){const i=ns();if(i)try{i.setItem(J_(e),JSON.stringify(t))}catch{}}const Rg=52,Pg=18;function Dx({ownerKey:e,deckId:t,label:i,onMove:s,onStep:o}){const l=P.useRef(null),c=P.useRef(0),[d,m]=P.useState(!1),p=()=>{var b,x,N,L;const w=l.current;(x=(b=w==null?void 0:w.over)==null?void 0:b.classList)==null||x.remove("nc-deck-over"),(L=(N=w==null?void 0:w.source)==null?void 0:N.classList)==null||L.remove("nc-deck-dragging"),c.current&&cancelAnimationFrame(c.current),c.current=0},S=(w=!1)=>{const b=l.current;if(!b)return;const x=b.target;p(),l.current=null,m(!1);try{b.handle.releasePointerCapture(b.pointerId)}catch{}w&&x&&x!==t&&s(t,x)},C=(w,b)=>{var T,Q,H,I,G,U,q,Y;const x=l.current;if(!x)return;x.x=w,x.y=b;const N=(Q=(T=document.elementFromPoint(w,b))==null?void 0:T.closest)==null?void 0:Q.call(T,"[data-deck-id][data-owner-key]"),L=(H=N==null?void 0:N.dataset)==null?void 0:H.deckId,j=((I=N==null?void 0:N.dataset)==null?void 0:I.ownerKey)===e&&L&&L!==t;x.over!==(j?N:null)&&((U=(G=x.over)==null?void 0:G.classList)==null||U.remove("nc-deck-over"),x.over=j?N:null,(Y=(q=x.over)==null?void 0:q.classList)==null||Y.add("nc-deck-over")),x.target=j?L:null},_=()=>{var x,N;const w=l.current;if(!w){c.current=0;return}const b=(N=(x=w.container)==null?void 0:x.getBoundingClientRect)==null?void 0:N.call(x);if(b){const L=w.x<b.left+Rg?-Pg:w.x>b.right-Rg?Pg:0;L&&(w.container.scrollLeft+=L,C(w.x,w.y))}c.current=requestAnimationFrame(_)};P.useEffect(()=>{const w=x=>{x.key==="Escape"&&l.current&&(x.preventDefault(),S(!1))},b=()=>S(!1);return window.addEventListener("keydown",w),window.addEventListener("blur",b),()=>{window.removeEventListener("keydown",w),window.removeEventListener("blur",b),p(),l.current=null}},[t,e]);const v=w=>{var N;if(w.pointerType==="mouse"&&w.button!==0)return;w.preventDefault(),w.stopPropagation(),w.currentTarget.focus({preventScroll:!0});const b=w.currentTarget.closest("[data-deck-id][data-owner-key]"),x=w.currentTarget.closest(".nc-deckbar");l.current={pointerId:w.pointerId,handle:w.currentTarget,source:b,container:x,target:null,over:null,x:w.clientX,y:w.clientY},(N=b==null?void 0:b.classList)==null||N.add("nc-deck-dragging");try{w.currentTarget.setPointerCapture(w.pointerId)}catch{}m(!0),c.current=requestAnimationFrame(_)};return h.jsx("button",{type:"button",className:`nc-deck-handle${d?" active":""}`,"aria-label":`${y("reorder")} ${i}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:y("reorder-deck-help"),onClick:w=>{w.preventDefault(),w.stopPropagation()},onDragStart:w=>w.preventDefault(),onKeyDown:w=>{w.key!=="ArrowLeft"&&w.key!=="ArrowRight"||(w.preventDefault(),w.stopPropagation(),o(w.key==="ArrowLeft"?-1:1))},onPointerDown:v,onPointerMove:w=>{!l.current||w.pointerId!==l.current.pointerId||(w.preventDefault(),w.stopPropagation(),C(w.clientX,w.clientY))},onPointerUp:w=>{!l.current||w.pointerId!==l.current.pointerId||(w.preventDefault(),w.stopPropagation(),S(!0))},onPointerCancel:()=>S(!1),onLostPointerCapture:()=>{l.current&&S(!1)},children:"↔"})}function Mx({decks:e=[],currentDeck:t="local:main",onCreate:i,onRename:s,onDelete:o,onReorder:l,onOpenWindow:c,onNavigate:d,saveState:m="idle",error:p="",sidebarVisible:S,onToggleSidebar:C}){Si();const[_,v]=P.useState(null),[w,b]=P.useState(""),[x,N]=P.useState(!1),[L,j]=P.useState(""),[T,Q]=P.useState(""),H=Eg(w),I=Zr(H),G=[];for(const E of e){const R=E.local?"local":E.ownerId;let F=G.find(D=>D.key===R);F||(F={key:R,label:E.ownerLabel||(E.local?"Local":R),local:!!E.local,decks:[]},G.push(F)),F.decks.push(E)}const U=async()=>{if(I){N(!0),j("");try{i&&await i(H,_),b(""),v(null)}catch(E){j(String(E.message||E))}N(!1)}},q=E=>{Q(""),c&&c(E.id)||Q(E.id)},Y=async E=>{if(!(E.id===t||!d||x||E.available===!1)){N(!0),j("");try{await d(E.id)}catch(R){j(String((R==null?void 0:R.message)||R))}N(!1)}},A=(E,R,F)=>{const D=E.decks.findIndex(z=>z.id===R.id),O=E.decks[D+F];D>=0&&O&&l&&!x&&l(R.id,O.id)};return h.jsxs("div",{className:"nc-deckbar",children:[C&&h.jsx("button",{className:"nc-deck-sidebar-toggle",title:y("toggle-sidebar"),onClick:C,children:S?"◀":"☰"}),h.jsx("span",{className:"nc-deckbar-label",children:y("decks")}),h.jsx("div",{className:"nc-deck-chips",children:G.map(E=>h.jsxs("span",{className:"nc-deck-owner-group",children:[h.jsx("span",{className:"nc-deck-owner",children:E.local?"Local":E.label}),E.decks.map(R=>h.jsxs("span",{"data-deck-id":R.id,"data-owner-key":E.key,className:`nc-deck-chip${R.id===t?" current":""}${R.available===!1?" offline":""}`,children:[h.jsx(Dx,{ownerKey:E.key,deckId:R.id,label:`${E.label} · ${R.name}`,onMove:(F,D)=>{l&&!x&&l(F,D)},onStep:F=>A(E,R,F)}),h.jsxs("button",{className:"nc-deck-open",title:R.available===!1?`${R.ownerLabel} offline`:R.id===t?y("deck-current"):`${R.ownerLabel} · ${R.name}`,disabled:x||R.available===!1,onClick:()=>Y(R),children:[R.name,R.id===t?" •":""]}),h.jsx("button",{className:"nc-deck-mini",disabled:R.available===!1,title:y("detach-deck"),onClick:()=>q(R),children:"↗"}),R.name!==yi&&h.jsxs(h.Fragment,{children:[h.jsx("button",{className:"nc-deck-mini",disabled:R.available===!1,title:y("rename-deck"),onClick:()=>{const F=(typeof window<"u"?window.prompt(y("rename-deck"),R.name):"")||"",D=Eg(F);Zr(D)&&D!==R.name&&s&&s(R.id,D).catch(O=>j(String(O.message||O)))},children:"✎"}),h.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:R.available===!1,title:y("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(y("delete-deck-confirm").replace("{name}",`${R.ownerLabel} · ${R.name}`)))&&o&&o(R.id).catch(F=>j(String(F.message||F)))},children:"✕"})]})]},R.id)),_===E.key?h.jsxs("span",{className:"nc-deck-add",children:[h.jsx("input",{autoFocus:!0,className:I||!w?"":"invalid",placeholder:y("deck-name"),value:w,onChange:R=>b(R.target.value),onKeyDown:R=>{R.key==="Enter"&&U(),R.key==="Escape"&&(b(""),v(null))}}),w&&I&&H!==w&&h.jsxs("span",{className:"nc-deck-slug",children:["→ ",H]}),h.jsx("button",{className:"nc-deck-ok",disabled:!I||x,onClick:U,children:y("create")}),h.jsx("button",{className:"nc-deck-cancel",onClick:()=>{b(""),v(null)},children:y("cancel")})]}):h.jsxs("button",{className:"nc-deck-newbtn",disabled:x||E.decks.every(R=>R.available===!1),title:`${y("new-deck")} · ${E.label}`,onClick:()=>{b(""),v(E.key)},children:["+ ",y("new")]})]},E.key))}),h.jsx("span",{className:`nc-deck-state ${m}`,title:y("deck-autosave"),children:y(m==="saving"?"saving":m==="saved"?"saved":"deck-autosave")}),(L||p)&&h.jsx("span",{className:"nc-deck-error",children:L||p}),T&&h.jsx("button",{className:"nc-deck-fallback",onClick:()=>c&&c(T),children:y("popup-blocked")})]})}var $r={},vu,Dg;function Lx(){return Dg||(Dg=1,vu=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),vu}var _u={},Bn={},Mg;function pr(){if(Mg)return Bn;Mg=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(i){let s=0;for(;i!==0;)s++,i>>>=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 yu={},Lg;function cd(){return Lg||(Lg=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+i)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,o){if(e.isValid(s))return s;try{return t(s)}catch{return o}}})(yu)),yu}var Su,jg;function jx(){if(jg)return Su;jg=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const i=Math.floor(t/8);return(this.buffer[i]>>>7-t%8&1)===1},put:function(t,i){for(let s=0;s<i;s++)this.putBit((t>>>i-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const i=Math.floor(this.length/8);this.buffer.length<=i&&this.buffer.push(0),t&&(this.buffer[i]|=128>>>this.length%8),this.length++}},Su=e,Su}var wu,Tg;function Tx(){if(Tg)return wu;Tg=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,i,s,o){const l=t*this.size+i;this.data[l]=s,o&&(this.reservedBit[l]=!0)},e.prototype.get=function(t,i){return this.data[t*this.size+i]},e.prototype.xor=function(t,i,s){this.data[t*this.size+i]^=s},e.prototype.isReserved=function(t,i){return this.reservedBit[t*this.size+i]},wu=e,wu}var bu={},Ag;function Ax(){return Ag||(Ag=1,(function(e){const t=pr().getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const o=Math.floor(s/7)+2,l=t(s),c=l===145?26:Math.ceil((l-13)/(2*o-2))*2,d=[l-7];for(let m=1;m<o-1;m++)d[m]=d[m-1]-c;return d.push(6),d.reverse()},e.getPositions=function(s){const o=[],l=e.getRowColCoords(s),c=l.length;for(let d=0;d<c;d++)for(let m=0;m<c;m++)d===0&&m===0||d===0&&m===c-1||d===c-1&&m===0||o.push([l[d],l[m]]);return o}})(bu)),bu}var Cu={},Bg;function Bx(){if(Bg)return Cu;Bg=1;const e=pr().getSymbolSize,t=7;return Cu.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},Cu}var xu={},Ig;function Ix(){return Ig||(Ig=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 c=0,d=0,m=0,p=null,S=null;for(let C=0;C<l;C++){d=m=0,p=S=null;for(let _=0;_<l;_++){let v=o.get(C,_);v===p?d++:(d>=5&&(c+=t.N1+(d-5)),p=v,d=1),v=o.get(_,C),v===S?m++:(m>=5&&(c+=t.N1+(m-5)),S=v,m=1)}d>=5&&(c+=t.N1+(d-5)),m>=5&&(c+=t.N1+(m-5))}return c},e.getPenaltyN2=function(o){const l=o.size;let c=0;for(let d=0;d<l-1;d++)for(let m=0;m<l-1;m++){const p=o.get(d,m)+o.get(d,m+1)+o.get(d+1,m)+o.get(d+1,m+1);(p===4||p===0)&&c++}return c*t.N2},e.getPenaltyN3=function(o){const l=o.size;let c=0,d=0,m=0;for(let p=0;p<l;p++){d=m=0;for(let S=0;S<l;S++)d=d<<1&2047|o.get(p,S),S>=10&&(d===1488||d===93)&&c++,m=m<<1&2047|o.get(S,p),S>=10&&(m===1488||m===93)&&c++}return c*t.N3},e.getPenaltyN4=function(o){let l=0;const c=o.data.length;for(let m=0;m<c;m++)l+=o.data[m];return Math.abs(Math.ceil(l*100/c/5)-10)*t.N4};function i(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 c=l.size;for(let d=0;d<c;d++)for(let m=0;m<c;m++)l.isReserved(m,d)||l.xor(m,d,i(o,m,d))},e.getBestMask=function(o,l){const c=Object.keys(e.Patterns).length;let d=0,m=1/0;for(let p=0;p<c;p++){l(p),e.applyMask(p,o);const S=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(p,o),S<m&&(m=S,d=p)}return d}})(xu)),xu}var La={},Og;function ey(){if(Og)return La;Og=1;const e=cd(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return La.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}},La.getTotalCodewordsCount=function(o,l){switch(l){case e.L:return i[(o-1)*4+0];case e.M:return i[(o-1)*4+1];case e.Q:return i[(o-1)*4+2];case e.H:return i[(o-1)*4+3];default:return}},La}var ku={},Ys={},zg;function Ox(){if(zg)return Ys;zg=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]})(),Ys.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},Ys.exp=function(s){return e[s]},Ys.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},Ys}var Fg;function zx(){return Fg||(Fg=1,(function(e){const t=Ox();e.mul=function(s,o){const l=new Uint8Array(s.length+o.length-1);for(let c=0;c<s.length;c++)for(let d=0;d<o.length;d++)l[c+d]^=t.mul(s[c],o[d]);return l},e.mod=function(s,o){let l=new Uint8Array(s);for(;l.length-o.length>=0;){const c=l[0];for(let m=0;m<o.length;m++)l[m]^=t.mul(o[m],c);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}})(ku)),ku}var Eu,Hg;function Fx(){if(Hg)return Eu;Hg=1;const e=zx();function t(i){this.genPoly=void 0,this.degree=i,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(s){this.degree=s,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(s.length+this.degree);o.set(s);const l=e.mod(o,this.genPoly),c=this.degree-l.length;if(c>0){const d=new Uint8Array(this.degree);return d.set(l,c),d}return l},Eu=t,Eu}var Nu={},Ru={},Pu={},$g;function ty(){return $g||($g=1,Pu.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Pu}var Vi={},Wg;function iy(){if(Wg)return Vi;Wg=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+`)(?:.|[\r
|
|
82
|
-
]))+`;Vi.KANJI=new RegExp(i,"g"),Vi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Vi.BYTE=new RegExp(s,"g"),Vi.NUMERIC=new RegExp(e,"g"),Vi.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+i+"$"),l=new RegExp("^"+e+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Vi.testKanji=function(m){return o.test(m)},Vi.testNumeric=function(m){return l.test(m)},Vi.testAlphanumeric=function(m){return c.test(m)},Vi}var Ug;function mr(){return Ug||(Ug=1,(function(e){const t=
|
|
83
|
-
Make sure your charset is UTF-8`);l=(l>>>8&255)*192+(l&255),s.put(l,13)}},Au=i,Au}var Bu={exports:{}},Qg;function
|
|
84
|
-
Suggested mode is: `+t.toString(T));switch(j===t.KANJI&&!d.isKanjiModeEnabled()&&(j=t.BYTE),j){case t.NUMERIC:return new i(N);case t.ALPHANUMERIC:return new s(N);case t.KANJI:return new l(N);case t.BYTE:return new o(N)}}e.fromArray=function(L){return L.reduce(function(j,T){return typeof T=="string"?j.push(x(T,null)):T.data&&j.push(x(T.data,T.mode)),j},[])},e.fromString=function(L,j){const T=C(L,d.isKanjiModeEnabled()),Q=w(T),H=b(Q,j),I=m.find_path(H.map,"start","end"),G=[];for(let U=1;U<I.length-1;U++)G.push(H.table[I[U]].node);return e.fromArray(v(G))},e.rawSplit=function(L){return e.fromArray(C(L,d.isKanjiModeEnabled()))}})(Mu)),Mu}var Zg;function
|
|
79
|
+
`)})}catch(fe){return A.write(`\r
|
|
80
|
+
\x1B[31m${fe.message}\x1B[0m\r
|
|
81
|
+
`),()=>A.dispose()}x.current={term:A,fit:E,sock:F};let D=null;const O=A.onData(fe=>{if(s){D&&(D.ok=!1);return}if(!D&&p&&p.current&&fe.length===1){const it=fe.charCodeAt(0);let ue=it;it>=97&&it<=122?ue=it-96:it>=64&&it<=95?ue=it-64:it===32&&(ue=0),fe=String.fromCharCode(ue),p.current=!1,S&&S(!1)}const Ve=F.sendInput(fe);D&&(D.seen=!0,D.ok=D.ok&&Ve)});c&&(c.current=fe=>F.sendInput(fe)),m&&(m.current=fe=>F.action(fe)),d&&(d.current=UC({isReady:()=>!s&&F.isReady(),paste:fe=>{const Ve={seen:!1,ok:!0};D=Ve;try{A.paste(fe)}catch{Ve.ok=!1}finally{D=null}return Ve.seen&&Ve.ok},send:fe=>F.sendInput(fe)}));const z=A.onSelectionChange(()=>Q(A.getSelection()));A.attachCustomKeyEventHandler(fe=>(fe.ctrlKey||fe.metaKey)&&fe.key.toLowerCase()==="c"&&A.getSelection()?(fe.type==="keydown"&&fg(A.getSelection()),!1):!0);const ie=b.current;let K=!1;const M=async fe=>{if(!fe.length||K)return;if(s){U({error:y("settings-readonly")});return}K=!0,U({current:0,total:fe.length,name:""});const Ve=await I_({files:fe,token:i,session:e,node:t,paste:!0,onProgress:({index:it,total:ue,name:Le,state:Ke,error:Mt})=>U({current:it+1,total:ue,name:Le,...Ke==="error"?{error:Mt}:{}})});K=!1,Ve.errors.length?U({error:Ve.errors.map(it=>`${it.name}: ${it.message}`).join(" · ")}):(U({done:!0,total:Ve.paths.length}),setTimeout(()=>U(null),1600))},W=fe=>{const Ve=fe.clipboardData;if(!fu(Ve))return;const it=mg(Ve);it.length&&(fe.preventDefault(),fe.stopPropagation(),M(it))},oe=fe=>{fu(fe.dataTransfer)&&(fe.preventDefault(),fe.stopPropagation())},ae=fe=>{fu(fe.dataTransfer)&&(fe.preventDefault(),fe.stopPropagation(),M(mg(fe.dataTransfer)))};ie.addEventListener("paste",W,!0),ie.addEventListener("dragenter",oe,!0),ie.addEventListener("dragover",oe,!0),ie.addEventListener("drop",ae,!0);const se=24;let le=null,ye=null,ce=0,Y=null,ne=null,Te=null,De=!1;const ge=()=>{Te&&clearTimeout(Te),Te=null},Z=(fe,Ve)=>{const ue=(ie.querySelector(".xterm-screen")||ie).getBoundingClientRect(),Le=Math.max(0,Math.min(A.cols-1,Math.floor((fe-ue.left)/Math.max(1,ue.width)*A.cols))),Ke=Math.max(0,Math.min(A.rows-1,Math.floor((Ve-ue.top)/Math.max(1,ue.height)*A.rows)));return{col:Le,row:A.buffer.active.viewportY+Ke}},Ce=fe=>Z(fe.clientX,fe.clientY),Pe=fe=>{if(ge(),De=!1,fe.touches.length!==1){le=null;return}if(j.current){fe.preventDefault(),fe.stopPropagation(),ne=Ce(fe.touches[0]),A.clearSelection();return}le=fe.touches[0].clientY,ye=fe.touches[0].clientX,ce=0,Y=null;const Ve={x:ye,y:le};Te=setTimeout(()=>{Te=null,De=!0,j.current=!0,w==null||w(!0),ne=Z(Ve.x,Ve.y),A.clearSelection(),A.select(ne.col,ne.row,1),le=null,ye=null,Y=null,ce=0},VC)},Ne=fe=>{if((j.current||De)&&ne&&fe.touches.length===1){fe.preventDefault(),fe.stopPropagation();const it=Ce(fe.touches[0]),ue=ne.row*A.cols+ne.col,Le=it.row*A.cols+it.col,Ke=ue<=Le?ne:it;A.select(Ke.col,Ke.row,Math.abs(Le-ue)+1);return}if(le===null||fe.touches.length!==1)return;fe.preventDefault(),fe.stopPropagation();const Ve=fe.touches[0];if(Te&&YC(ye,le,Ve.clientX,Ve.clientY)&&ge(),Y===null&&(Math.abs(Ve.clientY-le)>8||Math.abs(Ve.clientX-ye)>8)&&(Y=Math.abs(Ve.clientY-le)>Math.abs(Ve.clientX-ye)),!!Y){for(ce+=Ve.clientY-le,le=Ve.clientY;ce>=se;)F.action("scroll-up"),ce-=se;for(;ce<=-se;)F.action("scroll-down"),ce+=se}},qe=()=>{ge(),le=null,ye=null,ne=null,De=!1};let ee=0;const _e=fe=>{for(fe.preventDefault(),fe.stopPropagation(),ee+=fe.deltaY;ee<=-se;)F.action("scroll-up"),ee+=se;for(;ee>=se;)F.action("scroll-down"),ee-=se};ie.addEventListener("touchstart",Pe,{passive:!1}),ie.addEventListener("touchmove",Ne,{passive:!1,capture:!0}),ie.addEventListener("touchend",qe,{passive:!0}),ie.addEventListener("touchcancel",qe,{passive:!0});const Be=fe=>{(j.current||De)&&(fe.preventDefault(),fe.stopPropagation())};ie.addEventListener("contextmenu",Be,!0),ie.addEventListener("wheel",_e,{passive:!1,capture:!0});let Ie=null;const Fe=fe=>{KC(fe)&&(fe.preventDefault(),fe.stopPropagation(),Ie=Z(fe.clientX,fe.clientY),A.clearSelection())},gt=fe=>{if(!Ie)return;fe.preventDefault(),fe.stopPropagation();const Ve=Z(fe.clientX,fe.clientY),it=Ie.row*A.cols+Ie.col,ue=Ve.row*A.cols+Ve.col,Le=it<=ue?Ie:Ve;A.select(Le.col,Le.row,Math.abs(ue-it)+1)},ve=fe=>{Ie&&(fe.stopPropagation(),Ie=null)};ie.addEventListener("mousedown",Fe,!0),ie.addEventListener("mousemove",gt,!0),ie.addEventListener("mouseup",ve,!0);const be=fe=>{!qC(fe)||!(x.current&&x.current.term&&x.current.term.getSelection())||(fe.preventDefault(),fe.stopPropagation(),X.current&&X.current())};ie.addEventListener("keydown",be,!0);const Ee=()=>{E.fit(),F.resize(A.cols,A.rows)};window.addEventListener("resize",Ee);const Ye=window.visualViewport;Ye&&(Ye.addEventListener("resize",Ee),Ye.addEventListener("scroll",Ee));let rt=null,We=0;return typeof ResizeObserver<"u"&&(rt=new ResizeObserver(()=>{We&&cancelAnimationFrame(We),We=requestAnimationFrame(Ee)}),rt.observe(ie)),()=>{x.current=null,c&&(c.current=()=>!1),d&&(d.current=()=>!1),m&&(m.current=()=>!1),O.dispose(),z.dispose(),ie.removeEventListener("touchstart",Pe),ie.removeEventListener("touchmove",Ne,{capture:!0}),ie.removeEventListener("touchend",qe),ie.removeEventListener("touchcancel",qe),ie.removeEventListener("contextmenu",Be,!0),ge(),ie.removeEventListener("wheel",_e,{capture:!0}),ie.removeEventListener("mousedown",Fe,!0),ie.removeEventListener("mousemove",gt,!0),ie.removeEventListener("mouseup",ve,!0),ie.removeEventListener("keydown",be,!0),ie.removeEventListener("paste",W,!0),ie.removeEventListener("dragenter",oe,!0),ie.removeEventListener("dragover",oe,!0),ie.removeEventListener("drop",ae,!0),window.removeEventListener("resize",Ee),Ye&&(Ye.removeEventListener("resize",Ee),Ye.removeEventListener("scroll",Ee)),rt&&rt.disconnect(),We&&cancelAnimationFrame(We),F.close(),A.dispose()}},[e,t,i,s,o,c,d,m,p,S,C]),h.jsxs("div",{className:`nc-terminal${v?" selecting":""}`,children:[h.jsx("div",{className:"nc-terminal-host",ref:b}),G&&h.jsx("div",{className:`nc-upload-state${G.error?" error":""}`,role:"status",children:G.error?G.error:G.done?y("attach-uploaded").replace("{n}",String(G.total||0)):y("attach-upload-progress").replace("{n}",String(G.current||0)).replace("{total}",String(G.total||0))}),(T||v)&&h.jsxs("div",{className:"nc-selection-tools",children:[T?h.jsx("button",{type:"button",onClick:q,children:H||y("copy")}):h.jsx("span",{children:y("select-drag")}),h.jsx("button",{type:"button",onClick:()=>{var A,E;(E=(A=x.current)==null?void 0:A.term)==null||E.clearSelection(),Q(""),w==null||w(!1)},children:y("cancel")}),H===y("copy-manual")&&h.jsx("textarea",{readOnly:!0,value:T,onFocus:A=>A.target.select()})]})]})}const gg="",ci="\x1B",QC=[{label:"↑",seq:ci+"[A"},{label:"↓",seq:ci+"[B"},{label:"PGUP",seq:ci+"[5~"},{label:"PGDN",seq:ci+"[6~"}];function JC({send:e,action:t,ctrlArmed:i=!1,onCtrl:s,onKeyboard:o,selectionMode:l=!1,onSelectionMode:c}){const[d,m]=P.useState(!1),[p,S]=P.useState(!1),[C,_]=P.useState(!1),v=x=>{C?(e(ci+x),_(!1)):e(x)},w=(x,N,L)=>h.jsx("button",{onMouseDown:j=>{j.preventDefault(),v(N),L&&L()},children:x},x),b=(x,N)=>h.jsx("button",{onMouseDown:L=>{L.preventDefault(),t(N),S(!1)},children:x},x);return d?h.jsxs("div",{className:"nc-keybar copy",children:[h.jsx("span",{className:"tag",children:"copy-mode"}),QC.map(x=>w(x.label,x.seq)),w("ESCI (q)","q",()=>m(!1))]}):h.jsxs("div",{className:"nc-keybar termux",children:[p&&h.jsxs("div",{className:"nc-keymenu",children:[b("←WIN","prev-window"),b("WIN→","next-window"),b("⬅PANE","pane-left"),b("PANE➡","pane-right"),w("SCROLL",gg+"[",()=>{m(!0),S(!1)}),h.jsx("button",{className:l?"armed":"",onMouseDown:x=>{x.preventDefault(),c==null||c(!l),S(!1)},children:"SELECT"}),w("⌃C","",()=>S(!1)),w("DETACH",gg+"d",()=>S(!1))]}),h.jsxs("div",{className:"row",children:[w("ESC",ci),h.jsx("button",{className:p?"armed":"",onMouseDown:x=>{x.preventDefault(),S(N=>!N)},children:"☰"},"menu"),w("/","/"),w("—","-"),w("HOME",ci+"[H"),w("↑",ci+"[A"),w("END",ci+"[F"),w("PGUP",ci+"[5~")]}),h.jsxs("div",{className:"row",children:[w("⇥"," "),h.jsx("button",{onMouseDown:x=>{x.preventDefault(),o&&o()},children:"⌨"},"kbd"),h.jsx("button",{className:i?"armed":"",onMouseDown:x=>{x.preventDefault(),s&&s()},children:"CTRL"},"ctrl"),h.jsx("button",{className:C?"armed":"",onMouseDown:x=>{x.preventDefault(),_(N=>!N)},children:"ALT"},"alt"),w("←",ci+"[D"),w("↓",ci+"[B"),w("→",ci+"[C"),w("PGDN",ci+"[6~")]})]})}const ZC=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function z_({session:e,node:t,token:i,filesEvent:s,onClose:o}){Si();const l=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",c=t?`${t}:${e}`:e,[d,m]=P.useState("outbox"),[p,S]=P.useState({inbox:[],outbox:[]}),[C,_]=P.useState(""),v=P.useRef(null);async function w(){try{const j=await(await zt(`${l}/files?session=${encodeURIComponent(e)}`,i)).json();if(j.error){_(j.error);return}S(j);const T=j.outbox[0]?j.outbox[0].mtime:0;localStorage.setItem(xv(c),String(T))}catch(L){_(String(L))}}P.useEffect(()=>{w()},[e,t]),P.useEffect(()=>{s&&s.session===e&&w()},[s]);async function b(L){for(const j of L){_(`carico ${j.name}…`);const T=new FormData;T.append("session",e),T.append("file",j);try{const H=await(await zt(`${l}/files/upload`,i,{method:"POST",body:T})).json();_(H.error?`errore: ${H.error}`:"")}catch(Q){_(String(Q))}}w()}async function x(L){const j=await zt(`${l}/files/download?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(L)}`,i);if(!j.ok){_("errore download");return}const T=await j.blob(),Q=URL.createObjectURL(T),H=document.createElement("a");H.href=Q,H.download=L,H.click(),URL.revokeObjectURL(Q)}async function N(L){await zt(`${l}/files?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(L)}`,i,{method:"DELETE"}),w()}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:y("close"),children:h.jsx(et,{name:"x",size:20})})]}),h.jsxs("nav",{children:[h.jsx("button",{className:d==="outbox"?"on":"",onClick:()=>m("outbox"),children:"outbox"}),h.jsx("button",{className:d==="inbox"?"on":"",onClick:()=>m("inbox"),children:"inbox"}),h.jsxs("button",{className:"up",onClick:()=>v.current&&v.current.click(),children:[h.jsx(et,{name:"upload",size:18})," ",y("upload")]}),h.jsx("input",{type:"file",multiple:!0,ref:v,style:{display:"none"},onChange:L=>{b(Array.from(L.target.files||[])),L.target.value=""}})]}),C&&h.jsx("div",{className:"nc-busy",children:C}),h.jsxs("ul",{children:[p[d].map(L=>h.jsxs("li",{children:[h.jsx("span",{className:"name",onClick:()=>x(L.name),children:L.name}),h.jsx("small",{children:ZC(L.size)}),h.jsx("button",{onClick:()=>N(L.name),title:"elimina",children:h.jsx(et,{name:"trash",size:18})})]},L.name)),p[d].length===0&&h.jsx("li",{className:"empty",children:y("empty-files")})]})]})}const ol="nc_composer_v1",Rh="nc-composer-reset",ex=50,F_=256*1024,H_=512*1024,tx=768*1024,vg=2*1024*1024,$_=720*60*60*1e3,Ph=1;function W_(e){const t=Number(e);return Number.isFinite(t)&&t>0?t:0}function od(e){if(e!==void 0)return e;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Za(){return{version:Ph,cells:{}}}function U_(e){const t=[];for(const s of Array.isArray(e)?e:[]){const o=typeof s=="string"?s:s&&s.text,l=W_(typeof s=="string"?0:s&&s.at);if(!(typeof o!="string"||!o||o.length>F_)&&!(t.length&&t[t.length-1].text===o)&&(t.push({text:o,at:l}),t.length>=ex))break}let i=0;return t.filter(s=>i+s.text.length>tx?!1:(i+=s.text.length,!0))}function el(e){if(!e||typeof e!="object")return null;const t=typeof e.draft=="string"&&e.draft.length<=H_?e.draft:"",i=U_(e.history),s=W_(e.updatedAt),o=e.expanded===!0;return!t&&!i.length&&!o?null:{draft:t,history:i,expanded:o,updatedAt:s}}function ix(e){let t;try{t=typeof e=="string"?JSON.parse(e):e}catch{return Za()}if(!t||typeof t!="object"||t.version!==Ph||!t.cells||typeof t.cells!="object")return Za();const i=Object.create(null);for(const[s,o]of Object.entries(t.cells)){if(!s||typeof s!="string"||s.length>512||s==="__proto__"||s==="constructor"||s==="prototype")continue;const l=el(o);l&&(i[s]=l)}return{version:Ph,cells:i}}function K_(e){const t=od(e);if(!t)return Za();try{return ix(t.getItem(ol))}catch{return Za()}}function _g(e){try{return JSON.stringify(e).length}catch{return 1/0}}function nx(e,t,i){for(const[s,o]of Object.entries(e.cells))s!==i&&o.updatedAt>0&&t-o.updatedAt>$_&&delete e.cells[s]}function q_(e,t){return Object.entries(e.cells).filter(([i])=>i!==t).sort((i,s)=>i[1].updatedAt-s[1].updatedAt).map(([i])=>i)}function rx(e,t){for(;_g(e)>vg;){const i=Object.entries(e.cells).filter(([,s])=>s.history.length).sort((s,o)=>s[1].updatedAt-o[1].updatedAt);if(!i.length)break;i[0][1].history.pop()}for(const i of q_(e,t)){if(_g(e)<=vg)break;delete e.cells[i]}}function V_(e,t,i){const s=od(e);if(!s)return!1;rx(t,i);const o=()=>(s.setItem(ol,JSON.stringify(t)),!0);try{return o()}catch{for(const c of q_(t,i)){delete t.cells[c];try{return o()}catch{}}return!1}}function ho(e,t,i,s){const o=K_(t);nx(o,i,e);const l=el(o.cells[e])||{draft:"",history:[],expanded:!1,updatedAt:0},c=s({...l,history:[...l.history]}),d=el(c);return d?o.cells[e]={...d,updatedAt:i}:delete o.cells[e],{ok:V_(t,o,e),cell:o.cells[e]||{draft:"",history:[],expanded:!1,updatedAt:i}}}function sx({ownerId:e,node:t,session:i}){const s=String(i||"");if(!s)return"";const o=Qr.test(String(e||""))?String(e):t?`route:${String(t)}`:"local";return`${encodeURIComponent(o)}:${encodeURIComponent(s)}`}function Vs(e,t,i=Date.now()){if(!e)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=K_(t),o=el(s.cells[e]);return!o||o.updatedAt>0&&i-o.updatedAt>$_?(s.cells[e]&&(delete s.cells[e],V_(t,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...o,history:[...o.history]}}function yg(e,t,i,s=Date.now()){const o=String(t||"");return!e||o.length>H_?!1:ho(e,i,s,l=>({...l,draft:o})).ok}function Sg(e,t,i=Date.now()){return e?ho(e,t,i,s=>({...s,draft:""})).ok:!1}function ox(e,t,i,s=Date.now()){return e?ho(e,i,s,o=>({...o,expanded:!!t})).ok:!1}function ax(e,t,i,s=Date.now()){const o=String(t||"");return!e||!o||o.length>F_?!1:ho(e,i,s,l=>{const c=l.history.filter(d=>d.text!==o);return c.unshift({text:o,at:s}),{...l,history:U_(c)}}).ok}function lx(e,t,i=Date.now()){return e?ho(e,t,i,s=>({...s,history:[]})).ok:!1}function cx(e){const t=od(e);if(!t)return!1;try{return t.removeItem(ol),!0}catch{return!1}}const ux=300;function hx(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function dx({ownerId:e,node:t,session:i,storage:s=hx()}){const o=P.useMemo(()=>sx({ownerId:e,node:t,session:i}),[e,t,i]),l=P.useMemo(()=>Vs(o,s),[]),[c,d]=P.useState(l.draft),[m,p]=P.useState(l.expanded),[S,C]=P.useState(l.history),[_,v]=P.useState(-1),w=P.useRef(o),b=P.useRef(l.draft),x=P.useRef(null),N=P.useRef(l.updatedAt||0),L=P.useRef(l.draft),j=P.useCallback(()=>{x.current&&clearTimeout(x.current),x.current=null},[]),T=P.useCallback(()=>{j(),yg(w.current,b.current,s)},[j,s]),Q=P.useCallback(()=>{j(),x.current=setTimeout(()=>{x.current=null,yg(w.current,b.current,s)},ux)},[j,s]),H=P.useCallback(R=>{const F=String(typeof R=="function"?R(b.current):R||"");b.current=F,N.current=Date.now(),L.current=F,v(-1),d(F),Q()},[Q]),I=P.useCallback((R,F)=>{j(),b.current=R,N.current=Date.now(),d(R),v(F),Q()},[j,Q]),G=P.useCallback(()=>{if(!S.length)return!1;const R=Math.min(_+1,S.length-1);return _<0&&(L.current=b.current),I(S[R].text,R),!0},[I,S,_]),U=P.useCallback(()=>{if(_<0)return!1;const R=_-1;return I(R<0?L.current:S[R].text,R),!0},[I,S,_]),q=P.useCallback(R=>{L.current=b.current;const F=S.findIndex(D=>D.text===R);I(String(R||""),F)},[I,S]),X=P.useCallback(()=>{p(R=>{const F=!R;return ox(w.current,F,s),F})},[s]),A=P.useCallback((R,F,D)=>{if(!R)return;if(ax(R,D,s),!(w.current===R)){Vs(R,s).draft===F&&Sg(R,s);return}C(Vs(R,s).history),L.current="",v(-1),b.current===F?(j(),b.current="",N.current=Date.now(),d(""),Sg(R,s)):Q()},[j,Q,s]),E=P.useCallback(()=>{lx(w.current,s),C([]),v(-1),L.current=b.current},[s]);return P.useEffect(()=>{if(w.current===o)return;T(),w.current=o;const R=Vs(o,s);b.current=R.draft,N.current=R.updatedAt||0,L.current=R.draft,d(R.draft),p(R.expanded),C(R.history),v(-1)},[o,T,s]),P.useEffect(()=>{const R=()=>T(),F=()=>{document.visibilityState==="hidden"&&T()};return window.addEventListener("pagehide",R),document.addEventListener("visibilitychange",F),()=>{window.removeEventListener("pagehide",R),document.removeEventListener("visibilitychange",F),T()}},[T]),P.useEffect(()=>{const R=()=>{j(),b.current="",N.current=0,L.current="",d(""),p(!1),C([]),v(-1)},F=O=>{if(O.key!==ol)return;if(O.newValue==null){R();return}const z=Vs(w.current,s);z.updatedAt<N.current||(j(),b.current=z.draft,N.current=z.updatedAt,L.current=z.draft,d(z.draft),p(z.expanded),C(z.history),v(-1))},D=()=>R();return window.addEventListener("storage",F),window.addEventListener(Rh,D),()=>{window.removeEventListener("storage",F),window.removeEventListener(Rh,D)}},[j,s]),{cellKey:o,text:c,setText:H,expanded:m,toggleExpanded:X,history:S,historyCursor:_,recallPrevious:G,recallNext:U,selectHistory:q,confirmSubmitted:A,clearHistory:E,flush:T}}function Y_({submitText:e,token:t,session:i,node:s,ownerId:o}){Si();const l=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:c,text:d,setText:m,expanded:p,toggleExpanded:S,history:C,historyCursor:_,recallPrevious:v,recallNext:w,selectHistory:b,confirmSubmitted:x,clearHistory:N,flush:L}=dx({ownerId:o,node:s,session:i}),[j,T]=P.useState(!1),[Q,H]=P.useState(""),[I,G]=P.useState(!1),U=P.useRef(null),q=P.useRef(null),X=P.useRef(null),[A,E]=P.useState(!1),[R,F]=P.useState({left:0,bottom:0}),[D,O]=P.useState(!1),[z,ie]=P.useState(!1),K=P.useRef(null),M=P.useRef(null),W=P.useRef(null),oe=P.useRef(null),ae=P.useRef(null),se=P.useRef(null),le=P.useRef(null),ye=P.useRef(!1),[ce,Y]=P.useState(!1),[ne,Te]=P.useState({left:0,bottom:0,width:320}),De=P.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);P.useEffect(()=>{let ve=!1;if(s){G(!1);return}return zt(`${l}/voice/status`,t).then(be=>be.json()).then(be=>{ve||G(!!be.serverSttConfigured)}).catch(()=>{ve||G(!1)}),()=>{ve=!0}},[t,l]);const Z=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||I);async function Ce(){const ve=d,be=WC(ve);if(!be||z)return;ie(!0),H("");let Ee=!1;try{Ee=!!await e(be)}catch{Ee=!1}Ee?x(c,ve,be):H(y("composer-send-failed")),ie(!1),requestAnimationFrame(()=>{var Ye;return(Ye=X.current)==null?void 0:Ye.focus({preventScroll:!0})})}function Pe(){const ve=K.current&&K.current.getBoundingClientRect();ve&&F({left:Math.max(6,Math.min(ve.left,window.innerWidth-186)),bottom:window.innerHeight-ve.top+6}),E(!0)}function Ne(ve){E(!1),ve&&K.current&&K.current.focus()}function qe(){const ve=W.current&&W.current.getBoundingClientRect();if(ve){const be=Math.max(220,Math.min(360,window.innerWidth-12));Te({left:Math.max(6,Math.min(ve.right-be,window.innerWidth-be-6)),bottom:window.innerHeight-ve.top+6,width:be})}Y(!0)}function ee(ve){Y(!1),ve&&W.current&&W.current.focus()}P.useEffect(()=>{if(!A)return;const ve=Ee=>{Ee.key==="Escape"&&Ne(!0)},be=Ee=>{const Ye=M.current&&M.current.contains(Ee.target),rt=K.current&&K.current.contains(Ee.target);!Ye&&!rt&&Ne(!1)};return document.addEventListener("keydown",ve),document.addEventListener("pointerdown",be),()=>{document.removeEventListener("keydown",ve),document.removeEventListener("pointerdown",be)}},[A]),P.useEffect(()=>{if(!ce)return;const ve=Ee=>{Ee.key==="Escape"&&ee(!0)},be=Ee=>{const Ye=oe.current&&oe.current.contains(Ee.target),rt=W.current&&W.current.contains(Ee.target);!Ye&&!rt&&ee(!1)};return document.addEventListener("keydown",ve),document.addEventListener("pointerdown",be),()=>{document.removeEventListener("keydown",ve),document.removeEventListener("pointerdown",be)}},[ce]);function _e(ve){if(!(ve.isComposing||ye.current||ve.altKey||ve.ctrlKey||ve.metaKey)){if(ve.key==="ArrowUp"&&ve.currentTarget.selectionStart===0&&ve.currentTarget.selectionEnd===0){v()&&ve.preventDefault();return}ve.key==="ArrowDown"&&_>=0&&ve.currentTarget.selectionStart===d.length&&ve.currentTarget.selectionEnd===d.length&&w()&&ve.preventDefault()}}function Be(ve){Ne(!1),ve.current&&ve.current.click()}async function Ie(ve){if(!ve.length||!i)return;O(!0),H("");const{paths:be,errors:Ee}=await I_({files:ve,token:t,session:i,node:s,paste:!1});Ee.length&&H(Ee.map(Ye=>`${Ye.name}: ${Ye.message}`).join(" · ")),be.length&&m(Ye=>Ye+(Ye&&!Ye.endsWith(" ")?" ":"")+be.join(" ")),O(!1)}function Fe(){U.current&&U.current.stop(),q.current&&q.current.stop(),T(!1)}async function gt(){H("");const ve=window.SpeechRecognition||window.webkitSpeechRecognition;if(ve){const be=new ve;be.lang="it-IT",be.continuous=!1,be.interimResults=!0;const Ee=d?`${d} `:"";be.onresult=Ye=>{const rt=Array.from(Ye.results).map(We=>We[0].transcript).join("");m(Ee+rt)},be.onend=()=>T(!1),be.onerror=Ye=>{H(`voice: ${Ye.error||"errore"}`),T(!1)},U.current=be,be.start(),T(!0);return}try{const be=await navigator.mediaDevices.getUserMedia({audio:!0}),Ee=new MediaRecorder(be),Ye=[];Ee.ondataavailable=rt=>Ye.push(rt.data),Ee.onstop=async()=>{be.getTracks().forEach(rt=>rt.stop()),T(!1),H("trascrivo…");try{const rt=new Blob(Ye,{type:Ee.mimeType||"audio/webm"}),fe=await(await zt(`${l}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:rt})).json();fe.error?H(fe.error):(H(""),m(Ve=>Ve+(Ve?" ":"")+(fe.text||"")))}catch(rt){H(String(rt))}},q.current={stop:()=>Ee.state!=="inactive"&&Ee.stop()},Ee.start(),T(!0)}catch{H("microfono non disponibile"),T(!1)}}return h.jsxs("div",{className:"nc-composer",children:[Q&&h.jsx("div",{className:"nc-composer-err",children:Q}),h.jsxs("div",{className:"nc-composer-row",children:[i&&h.jsx("button",{ref:K,className:D?"attach busy":"attach",disabled:D,onClick:()=>A?Ne(!1):Pe(),title:y(D?"attach-uploading":"attach"),"aria-label":y("attach"),"aria-haspopup":"menu","aria-expanded":A,"aria-controls":De.current,children:h.jsx(et,{name:"attach",size:22})}),A&&h.jsxs("div",{ref:M,id:De.current,role:"menu",className:"nc-attach-menu",style:{left:R.left,bottom:R.bottom},children:[h.jsxs("button",{role:"menuitem",onClick:()=>Be(ae),children:[h.jsx(et,{name:"file",size:18})," ",y("attach-file")]}),h.jsxs("button",{role:"menuitem",onClick:()=>Be(se),children:[h.jsx(et,{name:"camera",size:18})," ",y("attach-camera")]}),h.jsxs("button",{role:"menuitem",onClick:()=>Be(le),children:[h.jsx(et,{name:"image",size:18})," ",y("attach-gallery")]})]}),h.jsx("button",{ref:W,type:"button",className:"history",onPointerDown:ve=>ve.preventDefault(),onClick:()=>ce?ee(!1):qe(),title:y("composer-history-tools"),"aria-label":y("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":ce,children:h.jsx(et,{name:"history",size:21})}),ce&&h.jsxs("div",{ref:oe,role:"menu",className:"nc-composer-history-menu",style:{left:ne.left,bottom:ne.bottom,width:ne.width},children:[h.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:ve=>ve.preventDefault(),onClick:()=>{S(),ee(!1),requestAnimationFrame(()=>{var ve;return(ve=X.current)==null?void 0:ve.focus({preventScroll:!0})})},children:[h.jsx(et,{name:p?"chevronDown":"chevronUp",size:18}),y(p?"composer-collapse":"composer-expand")]}),h.jsx("div",{className:"nc-composer-history-title",children:y("composer-history")}),C.length===0&&h.jsx("div",{className:"nc-composer-history-empty",children:y("composer-history-empty")}),C.map((ve,be)=>h.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:Ee=>Ee.preventDefault(),onClick:()=>{b(ve.text),ee(!1),requestAnimationFrame(()=>{var Ee;return(Ee=X.current)==null?void 0:Ee.focus({preventScroll:!0})})},children:[h.jsx("span",{children:ve.text.replace(/\s+/g," ").slice(0,180)}),ve.at>0&&h.jsx("small",{children:new Date(ve.at).toLocaleString()})]},`${ve.at}:${be}`)),C.length>0&&h.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:ve=>ve.preventDefault(),onClick:()=>{N(),ee(!1)},children:y("composer-history-clear")})]}),h.jsx("input",{ref:ae,type:"file",multiple:!0,hidden:!0,onChange:ve=>{Ie(Array.from(ve.target.files||[])),ve.target.value=""}}),h.jsx("input",{ref:se,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:ve=>{Ie(Array.from(ve.target.files||[])),ve.target.value=""}}),h.jsx("input",{ref:le,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:ve=>{Ie(Array.from(ve.target.files||[])),ve.target.value=""}}),h.jsx("textarea",{ref:X,className:p?"expanded":"",rows:p?8:2,value:d,placeholder:y("composer-placeholder"),onChange:ve=>m(ve.target.value),onKeyDown:_e,onCompositionStart:()=>{ye.current=!0},onCompositionEnd:()=>{ye.current=!1},onBlur:L}),Z&&h.jsx("button",{className:j?"mic on":"mic",onClick:j?Fe:gt,title:y("voice"),children:h.jsx(et,{name:"mic",size:22})}),h.jsx("button",{type:"button",className:"go",disabled:z,onPointerDown:ve=>ve.preventDefault(),onClick:Ce,title:y("send"),children:h.jsx(et,{name:"enter",size:22})})]})]})}function wg(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const fx=180,px=480;function mx({sessions:e=[],cells:t=[],activeSessions:i=[],nodeGroups:s=[],onPick:o,onAddTile:l,onPower:c,onNodePower:d,onKill:m,onVisibility:p,onNew:S,onSettings:C,localNodeId:_,width:v=240,collapsed:w=!1,onResize:b,onToggleCollapse:x}){const[N,L]=Si(),{pins:j,orders:T,togglePin:Q,viewFor:H,updateView:I,canMoveRoster:G,moveRoster:U,stepRoster:q}=Ov(),X=new Set((t||[]).map(Y=>Y.tmuxSession)),A=new Map((e||[]).map(Y=>[Y.name,Y])),E=(Y,ne)=>g0(j,Y,ne),R=v0,F=[...t||[]].sort((Y,ne)=>R(E(Y.tmuxSession,(A.get(Y.tmuxSession)||{}).activity),E(ne.tmuxSession,(A.get(ne.tmuxSession)||{}).activity))),D=(e||[]).filter(Y=>!X.has(Y.name)).sort((Y,ne)=>R(E(Y.name,Y.activity),E(ne.name,ne.activity))||Y.name.localeCompare(ne.name)),O=new Set(i||[]),z=$v(F,D,A),ie=ar(z,j,H("local").filter,zn(T,"local")),K=(s||[]).map(Y=>{const ne=(Y.route||[Y.name]).join("/"),Te=H(ne),{rawItems:De}=Wv(Y),ge=ar(De,j,Te.filter,zn(T,ne));return{g:Y,nodeRoute:ne,groupView:Te,rawItems:De,items:ge}}),M=(Y,ne,Te)=>o&&o({session:Y,...ne?{node:ne}:{},...Qr.test(String(Te||""))?{ownerId:Te}:{}}),[W,oe]=P.useState(null),ae=(Y,ne)=>{const Te=Y.currentTarget.getBoundingClientRect();oe({text:ne,y:Te.top+Te.height/2})},se=()=>oe(null),le=P.useRef(null);P.useEffect(()=>()=>{le.current&&le.current()},[]);function ye(Y){Y.preventDefault(),Y.stopPropagation();const ne=Y.clientX,Te=v,De=Z=>{const Ce=Math.max(fx,Math.min(px,Te+(Z.clientX-ne)));b&&b(Ce)},ge=()=>{window.removeEventListener("pointermove",De),window.removeEventListener("pointerup",ge),window.removeEventListener("pointercancel",ge),window.removeEventListener("blur",ge),le.current=null};window.addEventListener("pointermove",De),window.addEventListener("pointerup",ge),window.addEventListener("pointercancel",ge),window.addEventListener("blur",ge),le.current=ge}const ce=w?{width:48,flex:"0 0 48px"}:{width:v,flex:`0 0 ${v}px`};return w?h.jsxs("aside",{className:"nc-sidebar mini",style:ce,children:[h.jsx("div",{className:"nc-side-head mini",children:h.jsx("button",{className:"nc-collapse-btn",onClick:x,title:y("expand"),children:"⟩"})}),h.jsx("button",{className:"nc-side-gear mini",onClick:()=>C&&C("nodes",!1),title:y("settings"),onMouseEnter:Y=>ae(Y,y("settings")),onMouseLeave:se,children:h.jsx(et,{name:"gear",size:16})}),h.jsx("div",{className:"nc-side-scroll mini",children:h.jsxs("div",{className:"nc-side-group mini",children:[H("local").open&&ie.map(Y=>Y.type==="cell"?(()=>{const ne=Y.value,Te=ne.degraded?"warn":ne.tmux?"on":"",De=!!ne.tmux;return h.jsx("button",{type:"button",className:`nc-mini-dot${O.has(ne.tmuxSession)?" active":""}`,onMouseEnter:ge=>ae(ge,`${ne.cell}: ${Y.subtitle}`),onMouseLeave:se,draggable:De,onDragStart:De?ge=>ge.dataTransfer.setData("text/nc-session",ne.tmuxSession):void 0,onClick:De?()=>l&&l(ne.tmuxSession):()=>c&&c(ne),onDoubleClick:De?()=>M(ne.tmuxSession,"",_):void 0,children:h.jsx("span",{className:`nc-dot ${Te}${Y.working?" working":""}`})},Y.key)})():(()=>{const ne=Y.value;return h.jsx("button",{type:"button",className:`nc-mini-init${O.has(ne.name)?" active":""}`,onMouseEnter:Te=>ae(Te,ne.name),onMouseLeave:se,draggable:!0,onDragStart:Te=>Te.dataTransfer.setData("text/nc-session",ne.name),onClick:()=>l&&l(ne.name),onDoubleClick:()=>M(ne.name,"",_),children:wg(ne.name)},Y.key)})()),K.flatMap(({g:Y,nodeRoute:ne,groupView:Te,items:De})=>Y.status==="up"?Te.open?De.map(ge=>ge.type==="cell"?(()=>{const Z=ge.value,Ce=!!Z.tmux;return h.jsx("button",{type:"button",className:`nc-mini-dot${O.has(ge.key)?" active":""}`,onMouseEnter:Pe=>ae(Pe,`${Y.label||ne}: ${Z.cell} · ${ge.subtitle}`),onMouseLeave:se,draggable:Ce,onDragStart:Ce?Pe=>Pe.dataTransfer.setData("text/nc-session",ge.key):void 0,onClick:Ce?()=>l&&l(ge.key):()=>c&&c({...Z,route:Y.route,availableEngines:Y.engines||[]}),onDoubleClick:Ce?()=>M(Z.tmuxSession,ne,Y.instanceId):void 0,children:h.jsx("span",{className:`nc-dot ${Z.degraded?"warn":Ce?`on${ge.working?" working":""}`:""}`})},ge.key)})():(()=>{const Z=ge.value;return h.jsx("button",{type:"button",className:`nc-mini-init${O.has(ge.key)?" active":""}`,onMouseEnter:Ce=>ae(Ce,`${Y.label||ne}: ${Z.name}`),onMouseLeave:se,draggable:!0,onDragStart:Ce=>Ce.dataTransfer.setData("text/nc-session",ge.key),onClick:()=>l&&l(ge.key),onDoubleClick:()=>M(Z.name,ne,Y.instanceId),children:wg(Z.name)},ge.key)})()):[]:[h.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:ge=>ae(ge,`${Y.label||(Y.route||[Y.name]).join(" › ")}: ${qr(Y)}`),onMouseLeave:se,children:h.jsx("span",{className:`nc-dot${Y.status==="passive"?"":" warn"}`})},`nodo-${(Y.route||[Y.name]).join("/")}`)])]})}),W&&h.jsx("div",{className:"nc-mini-tip",style:{top:W.y},children:W.text})]}):h.jsxs("aside",{className:"nc-sidebar",style:ce,children:[h.jsxs("div",{className:"nc-side-head",children:[h.jsx("button",{className:"nc-collapse-btn",onClick:x,title:y("collapse"),children:"⟨"}),h.jsx("span",{className:"nc-side-title",children:y("fleet")}),h.jsxs("button",{className:"nc-new-btn",onClick:S,title:y("fleet-new-cell"),children:["+ ",y("new")]})]}),h.jsxs("button",{className:"nc-side-gear",onClick:()=>C&&C("nodes",!1),title:y("settings"),children:[h.jsx(et,{name:"gear",size:15})," ",y("settings")]}),h.jsxs("div",{className:"nc-side-scroll",children:[h.jsx(gx,{label:y("position-local"),count:ie.length,state:H("local"),onToggle:()=>I("local",{open:!H("local").open}),onFilter:Y=>I("local",{filter:Y})}),H("local").open&&h.jsxs("div",{className:"nc-side-group",children:[ie.map(Y=>Y.type==="cell"?(()=>{const ne=Y.value,Te=ne.degraded?"warn":ne.tmux?"on":"",De=ne.degraded?y("cell-degraded"):Y.working?Y.subtitle:ne.tmux?y("cell-idle"):y("cell-off"),ge=!!ne.tmux;return h.jsxs("div",{"data-roster-key":Y.key,"data-position":"local",className:`nc-cell${ge?" live":""}${O.has(ne.tmuxSession)?" active":""}`,title:`${ne.cell} · ${Y.subtitle}${De===Y.subtitle?"":` · ${De}`}`,"aria-label":`${ne.cell}, ${Y.subtitle}${De===Y.subtitle?"":`, ${De}`}`,draggable:ge,onDragStart:ge?Z=>Z.dataTransfer.setData("text/nc-session",ne.tmuxSession):void 0,onClick:ge?()=>l&&l(ne.tmuxSession):void 0,onDoubleClick:ge?()=>M(ne.tmuxSession,"",_):void 0,children:[h.jsx(Ur,{position:"local",itemKey:Y.key,label:ne.cell,canMove:G,onMove:(Z,Ce)=>U("local",Z,Ce,z),onStep:Z=>q("local",Y.key,Z,z)}),h.jsx("span",{className:`nc-dot ${Te}${Y.working?" working":""}`}),h.jsxs("span",{className:"nc-cell-main",children:[h.jsx("b",{title:ne.cell,children:ne.cell}),h.jsx("small",{title:Y.subtitle,children:Y.subtitle})]}),h.jsx("button",{className:`nc-pin${j.includes(Y.key)?" on":""}`,title:y("pin"),onClick:Z=>{Z.stopPropagation(),Q(Y.key)},children:j.includes(Y.key)?"★":"☆"}),h.jsx("button",{className:`nc-power${ne.tmux?" on":""}${ne.degraded?" warn":""}`,onClick:Z=>{Z.stopPropagation(),c&&c(ne)},title:ne.active?y("power-off"):y("power-on"),children:h.jsx(et,{name:"power",size:14})})]},Y.key)})():(()=>{var Te;const ne=Y.value;return h.jsxs("div",{"data-roster-key":Y.key,"data-position":"local",className:`nc-side-card${O.has(ne.name)?" active":""}`,draggable:!0,onDragStart:De=>De.dataTransfer.setData("text/nc-session",ne.name),onClick:()=>l&&l(ne.name),onDoubleClick:()=>M(ne.name,"",_),children:[h.jsx(Ur,{position:"local",itemKey:Y.key,label:ne.name,canMove:G,onMove:(De,ge)=>U("local",De,ge,z),onStep:De=>q("local",Y.key,De,z)}),h.jsx("span",{className:ne.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:ne.name}),h.jsxs("small",{children:[ne.preview||ne.cmd||y("windows").replace("{n}",String(ne.windows||0)),((Te=ne.outbox)==null?void 0:Te.count)>0?` · 📦${ne.outbox.count}`:""]})]}),ne.activity?h.jsx("span",{className:"nc-rel",children:Gr(ne.activity)}):null,h.jsx("button",{className:`nc-pin${j.includes(Y.key)?" on":""}`,title:y("pin"),onClick:De=>{De.stopPropagation(),Q(Y.key)},children:j.includes(Y.key)?"★":"☆"}),h.jsx("button",{className:`nc-technical${ne.technical?" on":""}`,title:ne.technical?y("mark-normal"):y("mark-technical"),"aria-label":`${ne.technical?y("mark-normal"):y("mark-technical")} ${ne.name}`,onClick:De=>{De.stopPropagation(),p&&p(ne.name,!ne.technical,[])},children:"T"}),h.jsx("button",{className:"nc-menu",title:y("terminate"),onClick:De=>{De.stopPropagation(),window.confirm(y("terminate-confirm").replace("{name}",ne.name))&&m&&m(ne.name)},children:"⋯"})]},Y.key)})()),ie.length===0&&h.jsx("div",{className:"nc-empty",children:y("no-sessions-short")})]}),K.map(({g:Y,nodeRoute:ne,groupView:Te,rawItems:De,items:ge})=>{const Ce=zv(Y.health)||(Y.status==="up"?"on":Y.status==="passive"?"":"warn");return h.jsxs("div",{children:[h.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>I(ne,{open:!Te.open}),onKeyDown:Pe=>{(Pe.key==="Enter"||Pe.key===" ")&&(Pe.preventDefault(),I(ne,{open:!Te.open}))},children:[h.jsx("span",{className:"nc-node-chevron",children:Te.open?"⌄":"›"}),h.jsx("span",{className:`nc-dot ${Ce}`,title:Y.health?Wa(Y.health):""}),h.jsx("b",{children:Y.label||Y.name}),h.jsxs("small",{children:[" · ",Y.status==="up"?y("node-sessions").replace("{n}",String(ge.length)):Y.health&&Wa(Y.health)||qr(Y)]}),h.jsxs("select",{className:"nc-node-filter",value:Te.filter,title:y(`view-${Te.filter}`),onClick:Pe=>Pe.stopPropagation(),onChange:Pe=>I(ne,{filter:Pe.target.value}),children:[h.jsx("option",{value:"all",children:y("view-all")}),h.jsx("option",{value:"pinned",children:y("view-pinned")}),h.jsx("option",{value:"active",children:y("view-active")}),h.jsx("option",{value:"off",children:y("view-off")}),h.jsx("option",{value:"technical",children:y("view-technical")})]}),Y.direct&&Y.health&&Y.health.managed!==!1&&h.jsx("button",{type:"button",className:`nc-power${Y.tunnelStatus==="up"?" on":""}`,title:Y.tunnelStatus==="up"?y("power-off"):y("power-on"),onClick:Pe=>{Pe.stopPropagation(),d&&d(Y)},children:h.jsx(et,{name:"power",size:14})})]}),Y.status==="up"&&Te.open&&h.jsxs("div",{className:"nc-side-group",children:[ge.map(Pe=>Pe.type==="cell"?(()=>{const Ne=Pe.value,qe=!!Ne.tmux,ee=Ne.degraded?"warn":Ne.tmux?"on":"";return h.jsxs("div",{"data-roster-key":Pe.key,"data-position":ne,className:`nc-side-card nc-cell${qe?" live":""}${O.has(Ne.key)?" active":""}`,title:Pe.working?Pe.subtitle:Ne.tmux?y("cell-idle"):y("cell-off"),draggable:qe,onDragStart:qe?_e=>_e.dataTransfer.setData("text/nc-session",Ne.key):void 0,onClick:qe?()=>l&&l(Ne.key):void 0,onDoubleClick:qe?()=>M(Ne.tmuxSession,ne,Y.instanceId):void 0,children:[h.jsx(Ur,{position:ne,itemKey:Pe.key,label:Ne.cell,canMove:G,onMove:(_e,Be)=>U(ne,_e,Be,De),onStep:_e=>q(ne,Pe.key,_e,De)}),h.jsx("span",{className:`nc-dot ${ee}${Pe.working?" working":""}`}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:Ne.cell}),h.jsx("small",{title:Pe.subtitle,children:Pe.subtitle})]}),h.jsx("button",{className:`nc-pin${j.includes(Pe.key)?" on":""}`,title:y("pin"),onClick:_e=>{_e.stopPropagation(),Q(Pe.key)},children:j.includes(Pe.key)?"★":"☆"}),(Y.capabilities||[]).includes(Ne.active?"down":"up")&&h.jsx("button",{className:`nc-power${Ne.active?" on":""}${Ne.degraded?" warn":""}`,onClick:_e=>{_e.stopPropagation(),c&&c({...Ne,route:Y.route,availableEngines:Y.engines||[]})},title:Ne.active?y("power-off"):y("power-on"),children:h.jsx(et,{name:"power",size:14})})]},Pe.key)})():(()=>{const Ne=Pe.value;return h.jsxs("div",{"data-roster-key":Pe.key,"data-position":ne,className:`nc-side-card${O.has(Ne.key)?" active":""}`,draggable:!0,onDragStart:qe=>qe.dataTransfer.setData("text/nc-session",Ne.key),onClick:()=>l&&l(Ne.key),onDoubleClick:()=>M(Ne.name,Ne.node||ne,Y.instanceId),children:[h.jsx(Ur,{position:ne,itemKey:Pe.key,label:Ne.name,canMove:G,onMove:(qe,ee)=>U(ne,qe,ee,De),onStep:qe=>q(ne,Pe.key,qe,De)}),h.jsx("span",{className:Ne.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:Ne.name}),h.jsx("small",{children:Ne.preview?Ne.preview:Ne.cmd?Ne.cmd:y("windows").replace("{n}",String(Ne.windows||0))})]}),Ne.activity?h.jsx("span",{className:"nc-rel",children:Gr(Ne.activity)}):null,h.jsx("button",{className:`nc-pin${j.includes(Pe.key)?" on":""}`,title:y("pin"),onClick:qe=>{qe.stopPropagation(),Q(Pe.key)},children:j.includes(Pe.key)?"★":"☆"}),h.jsx("button",{className:`nc-technical${Ne.technical?" on":""}`,title:Ne.technical?y("mark-normal"):y("mark-technical"),"aria-label":`${Ne.technical?y("mark-normal"):y("mark-technical")} ${Ne.name}`,onClick:qe=>{qe.stopPropagation(),p&&p(Ne.name,!Ne.technical,Y.route||[])},children:"T"}),h.jsx("button",{className:"nc-menu",title:y("terminate"),onClick:qe=>{qe.stopPropagation(),window.confirm(y("terminate-confirm").replace("{name}",Ne.name))&&m&&m(Ne.name,Y.route)},children:"⋯"})]},Pe.key)})()),ge.length===0&&h.jsx("div",{className:"nc-empty",children:y("no-sessions-short")})]})]},`nodo-${(Y.route||[Y.name]).join("/")}`)})]}),h.jsx("div",{className:"nc-side-lang",children:Iv.map((Y,ne)=>h.jsxs("span",{children:[ne>0&&" · ",h.jsx("button",{className:`nc-lang-btn${N===Y?" on":""}`,onClick:()=>L(Y),title:Y,children:Y.toUpperCase()})]},Y))}),h.jsx("div",{className:"nc-side-resize",onPointerDown:ye,title:""})]})}function gx({label:e,count:t,state:i,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:i.open?"⌄":"›"}),h.jsx("span",{className:"nc-dot on"}),h.jsx("b",{children:e}),h.jsxs("small",{children:[" · ",y("node-sessions").replace("{n}",String(t))]}),h.jsxs("select",{className:"nc-node-filter",value:i.filter,title:y(`view-${i.filter}`),onClick:l=>l.stopPropagation(),onChange:l=>o(l.target.value),children:[h.jsx("option",{value:"all",children:y("view-all")}),h.jsx("option",{value:"pinned",children:y("view-pinned")}),h.jsx("option",{value:"active",children:y("view-active")}),h.jsx("option",{value:"off",children:y("view-off")}),h.jsx("option",{value:"technical",children:y("view-technical")})]})]})}function vx(e,t,i){return!e&&t?i+1:i}function _x({session:e,node:t,ownerId:i,token:s,readonly:o=!1,focused:l,onFocus:c,onClose:d,onOpenSingle:m,alive:p=!0,available:S=!0,fontSize:C=oo,onZoom:_,decks:v=[],currentDeck:w,onSendToDeck:b}){const x=P.useRef(()=>{}),N=P.useRef(()=>!1),L=P.useRef(()=>{}),j=P.useRef(!1),[T,Q]=P.useState(!1),[H,I]=P.useState(!1),[G,U]=P.useState(!1),[q,X]=P.useState(null),[A,E]=P.useState(0),R=P.useRef(p),F=t?`${t}:${e}`:e,D=v.filter(O=>O.id!==w&&O.available!==!1);return P.useEffect(()=>{const O=R.current;!O&&p&&E(z=>vx(O,p,z)),R.current=p},[p]),h.jsxs("div",{className:`nc-tile${l?" focused":""}`,onMouseDown:()=>c&&c(F),children:[h.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:O=>{O.dataTransfer.setData("text/nc-session",F),O.dataTransfer.effectAllowed="move"},children:[h.jsxs("button",{className:"nc-tile-name",onClick:()=>c&&c(F),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:[_&&h.jsx("button",{onClick:()=>_(-1),title:y("zoom-out"),children:h.jsx(et,{name:"zoomOut",size:14})}),_&&h.jsx("button",{onClick:()=>_(1),title:y("zoom-in"),children:h.jsx(et,{name:"zoomIn",size:14})}),b&&D.length>0&&h.jsxs("select",{className:"nc-tile-deck",title:y("send-to-deck"),value:"",onMouseDown:O=>O.stopPropagation(),onChange:O=>{const z=O.target.value;z&&b(F,z),O.target.value=""},children:[h.jsx("option",{value:"",children:y("send-to-deck")}),D.map(O=>h.jsxs("option",{value:O.id,children:[O.ownerLabel," · ",O.name]},O.id))]}),h.jsx("button",{onClick:()=>I(O=>!O),title:"composer",children:"⌨"}),h.jsx("button",{onClick:()=>U(O=>!O),title:"file",children:"📁"}),m&&h.jsx("button",{onClick:()=>m({session:e,node:t,ownerId:i}),title:"vista singola",children:"↗"}),d&&h.jsx("button",{className:"nc-tile-close",onClick:()=>d(F),title:"chiudi",children:"✕"})]})]}),h.jsxs("div",{className:"nc-tile-body",children:[S?h.jsx(O_,{session:e,node:t,token:s,readonly:o,takeSize:!1,focused:l,sendRef:x,composerRef:N,actionRef:L,ctrlRef:j,setCtrlArmed:Q,onFiles:X,fontSize:C},`${F}:${A}`):h.jsx("div",{className:"nc-tile-unavailable",children:y("deck-owner-unavailable")}),S&&G&&h.jsx("div",{className:"nc-tile-files",onMouseDown:O=>O.stopPropagation(),children:h.jsx(z_,{session:e,node:t,token:s,filesEvent:q,onClose:()=>U(!1)})})]}),S&&H&&h.jsx("div",{className:"nc-tile-composer",onMouseDown:O=>O.stopPropagation(),children:h.jsx(Y_,{submitText:O=>N.current(O),token:s,session:e,node:t,ownerId:i})})]})}const bg=.2,Cg=.28,X_=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),pu=e=>X_(e,"text/nc-session"),xg=e=>{var t;return X_(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function yx(e,t,i){const s=(e-i.left)/(i.width||1),o=(t-i.top)/(i.height||1);return s<Cg?"left":s>1-Cg?"right":o<.5?"top":"bottom"}function Sx({layout:e,onLayoutChange:t,token:i,readonly:s=!1,sessionsAlive:o,focusSession:l,onFocus:c,onOpenSingle:d,decks:m=[],currentDeck:p,onSendToDeck:S}){Si();const[C,_]=P.useState(null),v=P.useRef(null),w=P.useRef([]),b=P.useRef(null);function x(U,q){const X=()=>{window.removeEventListener("pointermove",U),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),window.removeEventListener("blur",X),b.current=null};window.addEventListener("pointermove",U),window.addEventListener("pointerup",X),window.addEventListener("pointercancel",X),window.addEventListener("blur",X),b.current=X}P.useEffect(()=>()=>{b.current&&b.current()},[]),P.useEffect(()=>{const U=()=>_(null);return window.addEventListener("dragend",U),window.addEventListener("drop",U),()=>{window.removeEventListener("dragend",U),window.removeEventListener("drop",U)}},[]);const N=e.columns.length,L=U=>C&&C.col===U&&C.row===void 0,j=!!C&&C.col===N,T=(U,q)=>C&&C.col===U&&C.row===q&&C.quadrant?` drop-${C.quadrant}`:"";function Q(U){if(U.preventDefault(),xg(U.dataTransfer)){_(null);return}const q=U.dataTransfer.getData("text/nc-session"),X=C;if(_(null),!q||!X)return;let A;if(X.quadrant){if(A=E0(e,X.col,X.row,X.quadrant),!A)return}else A={col:X.col};t(Gi(e).includes(q)?w0(e,q,A):Xh(e,q,A))}function H(U,q){U.preventDefault(),U.stopPropagation();const X=U.clientX,A=e.columns[q].width,E=v.current&&v.current.clientWidth||1,R=e.columns[q+1];x(D=>{let O=Math.max(bg,A+(D.clientX-X)/E);if(R){const z=vm(O/(O+R.width));O=z/(1-z)*R.width}t(C0(e,q,O))})}function I(U,q,X){U.preventDefault(),U.stopPropagation();const A=U.clientY,E=e.columns[q].tiles[X].height,R=w.current[q],F=R&&R.clientHeight||1,D=e.columns[q].tiles[X+1];x(z=>{let ie=Math.max(bg,E+(z.clientY-A)/F);if(D){const K=vm(ie/(ie+D.height));ie=K/(1-K)*D.height}t(x0(e,q,X,ie))})}function G(U){t(qa(e,U))}return h.jsxs("div",{className:"nc-grid",ref:v,onDragOver:U=>{if(xg(U.dataTransfer)){U.preventDefault(),_(null);return}pu(U.dataTransfer)&&(U.preventDefault(),C&&C.col===N||_({col:N}))},onDrop:Q,onDragLeave:U=>{const q=U.relatedTarget;(!q||!(v.current&&v.current.contains(q)))&&_(null)},children:[e.columns.flatMap((U,q)=>{const X=[];return X.push(h.jsx("div",{className:`nc-col${L(q)?" drop-newcol":""}`,ref:A=>{w.current[q]=A},style:{flexGrow:U.width,flexBasis:0},onDragOver:A=>{pu(A.dataTransfer)&&(A.preventDefault(),A.stopPropagation(),C&&C.col===q&&C.row===void 0||_({col:q}))},children:U.tiles.flatMap((A,E)=>{const R=[],F=_i(A);return R.push(h.jsx("div",{className:`nc-tile-slot${T(q,E)}`,style:{flexGrow:A.height,flexBasis:0},onDragOver:D=>{if(!pu(D.dataTransfer))return;D.preventDefault(),D.stopPropagation();const O=yx(D.clientX,D.clientY,D.currentTarget.getBoundingClientRect());C&&C.col===q&&C.row===E&&C.quadrant===O||_({col:q,row:E,quadrant:O})},children:h.jsx(_x,{session:A.session,node:A.node,ownerId:A.ownerId,token:i,readonly:s,focused:l===F,onFocus:c,onClose:G,onOpenSingle:d,available:A.unavailable!==!0,alive:A.unavailable!==!0&&(!o||o.has(F)),fontSize:A.fontSize,onZoom:D=>t(k0(e,q,E,D)),decks:m,currentDeck:p,onSendToDeck:S})},F)),E<U.tiles.length-1&&R.push(h.jsx("div",{className:"nc-divider-h",onPointerDown:D=>I(D,q,E)},`h${E}`)),R})},`c${q}`)),q<N-1&&X.push(h.jsx("div",{className:"nc-divider-v",onPointerDown:A=>H(A,q)},`v${q}`)),X}),j&&h.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),N===0&&h.jsx("div",{className:"nc-grid-empty",children:y("grid-empty")})]})}const un="local",Mi=/^[a-f0-9]{16,64}$/;function Yr(e,t){return`${e&&Mi.test(e)?e:un}:${t}`}function ad(e){const t=String(e||""),i=t.indexOf(":");if(i<1)return null;const s=t.slice(0,i),o=t.slice(i+1);return s!==un&&!Mi.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===un?null:s,name:o}}function al(e){return Array.isArray(e)&&e.length?e.join("/"):""}function ld(e){return{columns:lr(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))}}function wx(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&Mi.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(al(i.route),i.instanceId);return t}function bx(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&Mi.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(i.instanceId,[...i.route]);return t}function Dh(e,t,i=[]){const s=ld(e),o=wx(i);for(const l of s.columns)for(const c of l.tiles)c.ownerId||(!c.node&&Mi.test(String(t||""))?c.ownerId=t:c.node&&o.has(c.node)&&(c.ownerId=o.get(c.node)));return s}function Mh(e,t,i=[]){const s=ld(e),o=new Map;for(const l of i)l&&Mi.test(String(l.instanceId||""))&&Array.isArray(l.route)&&o.set(l.instanceId,[...l.route]);for(const l of s.columns)for(const c of l.tiles)c.ownerId&&(c.ownerId===t?(delete c.node,delete c.unavailable):o.has(c.ownerId)?(c.node=al(o.get(c.ownerId)),delete c.unavailable):c.unavailable=!0);return s}function kg(e,t,i=[]){const s=ld(e),o=bx(i);for(const l of s.columns)for(const c of l.tiles)delete c.unavailable,c.ownerId&&(c.ownerId===t?delete c.node:o.has(c.ownerId)&&(c.node=al(o.get(c.ownerId))));return s}function G_(e,t,i=[]){const s=Hn(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...Mi.test(String(t||""))?{ownerId:t}:{}};const o=i.find(l=>al(l&&l.route)===s.node);return{...s,...o&&Mi.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const Cx=/^[a-z0-9-]{1,32}$/,yi="main",Q_="nc_decks",J_="nc_deck_order_v1",Z_=24;function Eg(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function Zr(e){return typeof e=="string"&&Cx.test(e)}function xx(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let i;try{i=decodeURIComponent(t[1])}catch{i=t[1]}return Zr(i)?i:yi}return yi}function kx(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:Yr(null,yi),ownerId:null,name:yi}}if(Mi.test(s)&&Zr(o))return{id:Yr(s,o),ownerId:s,name:o}}const i=xx(e);return{id:Yr(null,i),ownerId:null,name:i}}function mu(e,t){const i=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:ad(e)||{ownerId:null,name:e},s=Zr(i.name)?i.name:yi,o=i.ownerId?`/deck/${encodeURIComponent(i.ownerId)}/${encodeURIComponent(s)}`:s===yi?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function ey(e){return e===yi?"nc_grid_v1":`nc_grid_v1__${e}`}function ty(e){const t=[yi];if(Array.isArray(e)){for(const i of e)if(Zr(i)&&i!==yi&&!t.includes(i)&&t.push(i),t.length>=Z_)break}return t}function ns(){return typeof localStorage<"u"?localStorage:null}function Ex(){const e=ns();if(!e)return[yi];try{return ty(JSON.parse(e.getItem(Q_)||"null"))}catch{return[yi]}}function Nx(e){const t=ns();if(t)try{t.setItem(Q_,JSON.stringify(ty(e)))}catch{}}function fo(e){return e==="local"||Mi.test(String(e||""))}function ll(e,t){const i=ad(e);return!!i&&(i.ownerId||"local")===t}function Ji(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[i,s]of Object.entries(e).slice(0,64)){if(!fo(i)||!Array.isArray(s))continue;const o=[...new Set(s.filter(l=>typeof l=="string"&&l.length<=100&&ll(l,i)))].slice(0,Z_);o.length&&(t[i]=o)}return t}function Ma(e=ns()){if(!e)return{};try{return Ji(JSON.parse(e.getItem(J_)||"null"))}catch{return{}}}function gu(e,t=ns()){const i=Ji(e);if(t)try{t.setItem(J_,JSON.stringify(i))}catch{}return i}function cl(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function Rx(e,t,i,s,o=[]){if(!fo(t)||i===s)return Ji(e);const l=[...new Set(o.filter(C=>ll(C,t)))];if(!l.includes(i)||!l.includes(s))return Ji(e);const c=cl(e,t).filter(C=>l.includes(C)),d=[...c,...l.filter(C=>!c.includes(C))],m=d.indexOf(i),p=d.indexOf(s);d.splice(m,1);const S=d.indexOf(s);return d.splice(m<p?S+1:S,0,i),Ji({...e,[t]:d})}function Px(e,t,i,s){if(!fo(t)||!ll(s,t))return Ji(e);const o=cl(e,t);return o.includes(i)?Ji({...e,[t]:o.map(l=>l===i?s:l)}):Ji(e)}function Dx(e,t,i){return fo(t)?Ji({...e,[t]:cl(e,t).filter(s=>s!==i)}):Ji(e)}function Ng(e,t={}){const i=new Map;for(const o of Array.isArray(e)?e:[]){const l=o!=null&&o.local?"local":String((o==null?void 0:o.ownerId)||"");!fo(l)||!ll(o==null?void 0:o.id,l)||(i.has(l)||i.set(l,[]),i.get(l).push(o))}const s=[];for(const[,o]of i){const l=o[0].local?"local":o[0].ownerId,c=cl(t,l),d=new Map(c.map((m,p)=>[m,p]));o.sort((m,p)=>{const S=d.has(m.id)?d.get(m.id):Number.MAX_SAFE_INTEGER,C=d.has(p.id)?d.get(p.id):Number.MAX_SAFE_INTEGER;return S-C}),s.push(...o)}return s}function Lh(e){const t=ns();if(!t)return null;try{return JSON.parse(t.getItem(ey(e))||"null")}catch{return null}}function Mx(e,t){const i=ns();if(i)try{i.setItem(ey(e),JSON.stringify(t))}catch{}}const Rg=52,Pg=18;function Lx({ownerKey:e,deckId:t,label:i,onMove:s,onStep:o}){const l=P.useRef(null),c=P.useRef(0),[d,m]=P.useState(!1),p=()=>{var b,x,N,L;const w=l.current;(x=(b=w==null?void 0:w.over)==null?void 0:b.classList)==null||x.remove("nc-deck-over"),(L=(N=w==null?void 0:w.source)==null?void 0:N.classList)==null||L.remove("nc-deck-dragging"),c.current&&cancelAnimationFrame(c.current),c.current=0},S=(w=!1)=>{const b=l.current;if(!b)return;const x=b.target;p(),l.current=null,m(!1);try{b.handle.releasePointerCapture(b.pointerId)}catch{}w&&x&&x!==t&&s(t,x)},C=(w,b)=>{var T,Q,H,I,G,U,q,X;const x=l.current;if(!x)return;x.x=w,x.y=b;const N=(Q=(T=document.elementFromPoint(w,b))==null?void 0:T.closest)==null?void 0:Q.call(T,"[data-deck-id][data-owner-key]"),L=(H=N==null?void 0:N.dataset)==null?void 0:H.deckId,j=((I=N==null?void 0:N.dataset)==null?void 0:I.ownerKey)===e&&L&&L!==t;x.over!==(j?N:null)&&((U=(G=x.over)==null?void 0:G.classList)==null||U.remove("nc-deck-over"),x.over=j?N:null,(X=(q=x.over)==null?void 0:q.classList)==null||X.add("nc-deck-over")),x.target=j?L:null},_=()=>{var x,N;const w=l.current;if(!w){c.current=0;return}const b=(N=(x=w.container)==null?void 0:x.getBoundingClientRect)==null?void 0:N.call(x);if(b){const L=w.x<b.left+Rg?-Pg:w.x>b.right-Rg?Pg:0;L&&(w.container.scrollLeft+=L,C(w.x,w.y))}c.current=requestAnimationFrame(_)};P.useEffect(()=>{const w=x=>{x.key==="Escape"&&l.current&&(x.preventDefault(),S(!1))},b=()=>S(!1);return window.addEventListener("keydown",w),window.addEventListener("blur",b),()=>{window.removeEventListener("keydown",w),window.removeEventListener("blur",b),p(),l.current=null}},[t,e]);const v=w=>{var N;if(w.pointerType==="mouse"&&w.button!==0)return;w.preventDefault(),w.stopPropagation(),w.currentTarget.focus({preventScroll:!0});const b=w.currentTarget.closest("[data-deck-id][data-owner-key]"),x=w.currentTarget.closest(".nc-deckbar");l.current={pointerId:w.pointerId,handle:w.currentTarget,source:b,container:x,target:null,over:null,x:w.clientX,y:w.clientY},(N=b==null?void 0:b.classList)==null||N.add("nc-deck-dragging");try{w.currentTarget.setPointerCapture(w.pointerId)}catch{}m(!0),c.current=requestAnimationFrame(_)};return h.jsx("button",{type:"button",className:`nc-deck-handle${d?" active":""}`,"aria-label":`${y("reorder")} ${i}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:y("reorder-deck-help"),onClick:w=>{w.preventDefault(),w.stopPropagation()},onDragStart:w=>w.preventDefault(),onKeyDown:w=>{w.key!=="ArrowLeft"&&w.key!=="ArrowRight"||(w.preventDefault(),w.stopPropagation(),o(w.key==="ArrowLeft"?-1:1))},onPointerDown:v,onPointerMove:w=>{!l.current||w.pointerId!==l.current.pointerId||(w.preventDefault(),w.stopPropagation(),C(w.clientX,w.clientY))},onPointerUp:w=>{!l.current||w.pointerId!==l.current.pointerId||(w.preventDefault(),w.stopPropagation(),S(!0))},onPointerCancel:()=>S(!1),onLostPointerCapture:()=>{l.current&&S(!1)},children:"↔"})}function jx({decks:e=[],currentDeck:t="local:main",onCreate:i,onRename:s,onDelete:o,onReorder:l,onOpenWindow:c,onNavigate:d,saveState:m="idle",error:p="",sidebarVisible:S,onToggleSidebar:C}){Si();const[_,v]=P.useState(null),[w,b]=P.useState(""),[x,N]=P.useState(!1),[L,j]=P.useState(""),[T,Q]=P.useState(""),H=Eg(w),I=Zr(H),G=[];for(const E of e){const R=E.local?"local":E.ownerId;let F=G.find(D=>D.key===R);F||(F={key:R,label:E.ownerLabel||(E.local?"Local":R),local:!!E.local,decks:[]},G.push(F)),F.decks.push(E)}const U=async()=>{if(I){N(!0),j("");try{i&&await i(H,_),b(""),v(null)}catch(E){j(String(E.message||E))}N(!1)}},q=E=>{Q(""),c&&c(E.id)||Q(E.id)},X=async E=>{if(!(E.id===t||!d||x||E.available===!1)){N(!0),j("");try{await d(E.id)}catch(R){j(String((R==null?void 0:R.message)||R))}N(!1)}},A=(E,R,F)=>{const D=E.decks.findIndex(z=>z.id===R.id),O=E.decks[D+F];D>=0&&O&&l&&!x&&l(R.id,O.id)};return h.jsxs("div",{className:"nc-deckbar",children:[C&&h.jsx("button",{className:"nc-deck-sidebar-toggle",title:y("toggle-sidebar"),onClick:C,children:S?"◀":"☰"}),h.jsx("span",{className:"nc-deckbar-label",children:y("decks")}),h.jsx("div",{className:"nc-deck-chips",children:G.map(E=>h.jsxs("span",{className:"nc-deck-owner-group",children:[h.jsx("span",{className:"nc-deck-owner",children:E.local?"Local":E.label}),E.decks.map(R=>h.jsxs("span",{"data-deck-id":R.id,"data-owner-key":E.key,className:`nc-deck-chip${R.id===t?" current":""}${R.available===!1?" offline":""}`,children:[h.jsx(Lx,{ownerKey:E.key,deckId:R.id,label:`${E.label} · ${R.name}`,onMove:(F,D)=>{l&&!x&&l(F,D)},onStep:F=>A(E,R,F)}),h.jsxs("button",{className:"nc-deck-open",title:R.available===!1?`${R.ownerLabel} offline`:R.id===t?y("deck-current"):`${R.ownerLabel} · ${R.name}`,disabled:x||R.available===!1,onClick:()=>X(R),children:[R.name,R.id===t?" •":""]}),h.jsx("button",{className:"nc-deck-mini",disabled:R.available===!1,title:y("detach-deck"),onClick:()=>q(R),children:"↗"}),R.name!==yi&&h.jsxs(h.Fragment,{children:[h.jsx("button",{className:"nc-deck-mini",disabled:R.available===!1,title:y("rename-deck"),onClick:()=>{const F=(typeof window<"u"?window.prompt(y("rename-deck"),R.name):"")||"",D=Eg(F);Zr(D)&&D!==R.name&&s&&s(R.id,D).catch(O=>j(String(O.message||O)))},children:"✎"}),h.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:R.available===!1,title:y("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(y("delete-deck-confirm").replace("{name}",`${R.ownerLabel} · ${R.name}`)))&&o&&o(R.id).catch(F=>j(String(F.message||F)))},children:"✕"})]})]},R.id)),_===E.key?h.jsxs("span",{className:"nc-deck-add",children:[h.jsx("input",{autoFocus:!0,className:I||!w?"":"invalid",placeholder:y("deck-name"),value:w,onChange:R=>b(R.target.value),onKeyDown:R=>{R.key==="Enter"&&U(),R.key==="Escape"&&(b(""),v(null))}}),w&&I&&H!==w&&h.jsxs("span",{className:"nc-deck-slug",children:["→ ",H]}),h.jsx("button",{className:"nc-deck-ok",disabled:!I||x,onClick:U,children:y("create")}),h.jsx("button",{className:"nc-deck-cancel",onClick:()=>{b(""),v(null)},children:y("cancel")})]}):h.jsxs("button",{className:"nc-deck-newbtn",disabled:x||E.decks.every(R=>R.available===!1),title:`${y("new-deck")} · ${E.label}`,onClick:()=>{b(""),v(E.key)},children:["+ ",y("new")]})]},E.key))}),h.jsx("span",{className:`nc-deck-state ${m}`,title:y("deck-autosave"),children:y(m==="saving"?"saving":m==="saved"?"saved":"deck-autosave")}),(L||p)&&h.jsx("span",{className:"nc-deck-error",children:L||p}),T&&h.jsx("button",{className:"nc-deck-fallback",onClick:()=>c&&c(T),children:y("popup-blocked")})]})}var $r={},vu,Dg;function Tx(){return Dg||(Dg=1,vu=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),vu}var _u={},Bn={},Mg;function pr(){if(Mg)return Bn;Mg=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(i){let s=0;for(;i!==0;)s++,i>>>=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 yu={},Lg;function cd(){return Lg||(Lg=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+i)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,o){if(e.isValid(s))return s;try{return t(s)}catch{return o}}})(yu)),yu}var Su,jg;function Ax(){if(jg)return Su;jg=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const i=Math.floor(t/8);return(this.buffer[i]>>>7-t%8&1)===1},put:function(t,i){for(let s=0;s<i;s++)this.putBit((t>>>i-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const i=Math.floor(this.length/8);this.buffer.length<=i&&this.buffer.push(0),t&&(this.buffer[i]|=128>>>this.length%8),this.length++}},Su=e,Su}var wu,Tg;function Bx(){if(Tg)return wu;Tg=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,i,s,o){const l=t*this.size+i;this.data[l]=s,o&&(this.reservedBit[l]=!0)},e.prototype.get=function(t,i){return this.data[t*this.size+i]},e.prototype.xor=function(t,i,s){this.data[t*this.size+i]^=s},e.prototype.isReserved=function(t,i){return this.reservedBit[t*this.size+i]},wu=e,wu}var bu={},Ag;function Ix(){return Ag||(Ag=1,(function(e){const t=pr().getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const o=Math.floor(s/7)+2,l=t(s),c=l===145?26:Math.ceil((l-13)/(2*o-2))*2,d=[l-7];for(let m=1;m<o-1;m++)d[m]=d[m-1]-c;return d.push(6),d.reverse()},e.getPositions=function(s){const o=[],l=e.getRowColCoords(s),c=l.length;for(let d=0;d<c;d++)for(let m=0;m<c;m++)d===0&&m===0||d===0&&m===c-1||d===c-1&&m===0||o.push([l[d],l[m]]);return o}})(bu)),bu}var Cu={},Bg;function Ox(){if(Bg)return Cu;Bg=1;const e=pr().getSymbolSize,t=7;return Cu.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},Cu}var xu={},Ig;function zx(){return Ig||(Ig=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 c=0,d=0,m=0,p=null,S=null;for(let C=0;C<l;C++){d=m=0,p=S=null;for(let _=0;_<l;_++){let v=o.get(C,_);v===p?d++:(d>=5&&(c+=t.N1+(d-5)),p=v,d=1),v=o.get(_,C),v===S?m++:(m>=5&&(c+=t.N1+(m-5)),S=v,m=1)}d>=5&&(c+=t.N1+(d-5)),m>=5&&(c+=t.N1+(m-5))}return c},e.getPenaltyN2=function(o){const l=o.size;let c=0;for(let d=0;d<l-1;d++)for(let m=0;m<l-1;m++){const p=o.get(d,m)+o.get(d,m+1)+o.get(d+1,m)+o.get(d+1,m+1);(p===4||p===0)&&c++}return c*t.N2},e.getPenaltyN3=function(o){const l=o.size;let c=0,d=0,m=0;for(let p=0;p<l;p++){d=m=0;for(let S=0;S<l;S++)d=d<<1&2047|o.get(p,S),S>=10&&(d===1488||d===93)&&c++,m=m<<1&2047|o.get(S,p),S>=10&&(m===1488||m===93)&&c++}return c*t.N3},e.getPenaltyN4=function(o){let l=0;const c=o.data.length;for(let m=0;m<c;m++)l+=o.data[m];return Math.abs(Math.ceil(l*100/c/5)-10)*t.N4};function i(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 c=l.size;for(let d=0;d<c;d++)for(let m=0;m<c;m++)l.isReserved(m,d)||l.xor(m,d,i(o,m,d))},e.getBestMask=function(o,l){const c=Object.keys(e.Patterns).length;let d=0,m=1/0;for(let p=0;p<c;p++){l(p),e.applyMask(p,o);const S=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(p,o),S<m&&(m=S,d=p)}return d}})(xu)),xu}var La={},Og;function iy(){if(Og)return La;Og=1;const e=cd(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return La.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}},La.getTotalCodewordsCount=function(o,l){switch(l){case e.L:return i[(o-1)*4+0];case e.M:return i[(o-1)*4+1];case e.Q:return i[(o-1)*4+2];case e.H:return i[(o-1)*4+3];default:return}},La}var ku={},Ys={},zg;function Fx(){if(zg)return Ys;zg=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]})(),Ys.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},Ys.exp=function(s){return e[s]},Ys.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},Ys}var Fg;function Hx(){return Fg||(Fg=1,(function(e){const t=Fx();e.mul=function(s,o){const l=new Uint8Array(s.length+o.length-1);for(let c=0;c<s.length;c++)for(let d=0;d<o.length;d++)l[c+d]^=t.mul(s[c],o[d]);return l},e.mod=function(s,o){let l=new Uint8Array(s);for(;l.length-o.length>=0;){const c=l[0];for(let m=0;m<o.length;m++)l[m]^=t.mul(o[m],c);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}})(ku)),ku}var Eu,Hg;function $x(){if(Hg)return Eu;Hg=1;const e=Hx();function t(i){this.genPoly=void 0,this.degree=i,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(s){this.degree=s,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(s.length+this.degree);o.set(s);const l=e.mod(o,this.genPoly),c=this.degree-l.length;if(c>0){const d=new Uint8Array(this.degree);return d.set(l,c),d}return l},Eu=t,Eu}var Nu={},Ru={},Pu={},$g;function ny(){return $g||($g=1,Pu.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Pu}var Vi={},Wg;function ry(){if(Wg)return Vi;Wg=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+`)(?:.|[\r
|
|
82
|
+
]))+`;Vi.KANJI=new RegExp(i,"g"),Vi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Vi.BYTE=new RegExp(s,"g"),Vi.NUMERIC=new RegExp(e,"g"),Vi.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+i+"$"),l=new RegExp("^"+e+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Vi.testKanji=function(m){return o.test(m)},Vi.testNumeric=function(m){return l.test(m)},Vi.testAlphanumeric=function(m){return c.test(m)},Vi}var Ug;function mr(){return Ug||(Ug=1,(function(e){const t=ny(),i=ry();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,c){if(!l.ccBits)throw new Error("Invalid mode: "+l);if(!t.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?l.ccBits[0]:c<27?l.ccBits[1]:l.ccBits[2]},e.getBestModeForData=function(l){return i.testNumeric(l)?e.NUMERIC:i.testAlphanumeric(l)?e.ALPHANUMERIC:i.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,c){if(e.isValid(l))return l;try{return s(l)}catch{return c}}})(Ru)),Ru}var Kg;function Wx(){return Kg||(Kg=1,(function(e){const t=pr(),i=iy(),s=cd(),o=mr(),l=ny(),c=7973,d=t.getBCHDigit(c);function m(_,v,w){for(let b=1;b<=40;b++)if(v<=e.getCapacity(b,w,_))return b}function p(_,v){return o.getCharCountIndicator(_,v)+4}function S(_,v){let w=0;return _.forEach(function(b){const x=p(b.mode,v);w+=x+b.getBitsLength()}),w}function C(_,v){for(let w=1;w<=40;w++)if(S(_,w)<=e.getCapacity(w,v,o.MIXED))return w}e.from=function(v,w){return l.isValid(v)?parseInt(v,10):w},e.getCapacity=function(v,w,b){if(!l.isValid(v))throw new Error("Invalid QR Code version");typeof b>"u"&&(b=o.BYTE);const x=t.getSymbolTotalCodewords(v),N=i.getTotalCodewordsCount(v,w),L=(x-N)*8;if(b===o.MIXED)return L;const j=L-p(b,v);switch(b){case o.NUMERIC:return Math.floor(j/10*3);case o.ALPHANUMERIC:return Math.floor(j/11*2);case o.KANJI:return Math.floor(j/13);case o.BYTE:default:return Math.floor(j/8)}},e.getBestVersionForData=function(v,w){let b;const x=s.from(w,s.M);if(Array.isArray(v)){if(v.length>1)return C(v,x);if(v.length===0)return 1;b=v[0]}else b=v;return m(b.mode,b.getLength(),x)},e.getEncodedBits=function(v){if(!l.isValid(v)||v<7)throw new Error("Invalid QR Code version");let w=v<<12;for(;t.getBCHDigit(w)-d>=0;)w^=c<<t.getBCHDigit(w)-d;return v<<12|w}})(Nu)),Nu}var Du={},qg;function Ux(){if(qg)return Du;qg=1;const e=pr(),t=1335,i=21522,s=e.getBCHDigit(t);return Du.getEncodedBits=function(l,c){const d=l.bit<<3|c;let m=d<<10;for(;e.getBCHDigit(m)-s>=0;)m^=t<<e.getBCHDigit(m)-s;return(d<<10|m)^i},Du}var Mu={},Lu,Vg;function Kx(){if(Vg)return Lu;Vg=1;const e=mr();function t(i){this.mode=e.NUMERIC,this.data=i.toString()}return t.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){let o,l,c;for(o=0;o+3<=this.data.length;o+=3)l=this.data.substr(o,3),c=parseInt(l,10),s.put(c,10);const d=this.data.length-o;d>0&&(l=this.data.substr(o),c=parseInt(l,10),s.put(c,d*3+1))},Lu=t,Lu}var ju,Yg;function qx(){if(Yg)return ju;Yg=1;const e=mr(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(s){this.mode=e.ALPHANUMERIC,this.data=s}return i.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(o){let l;for(l=0;l+2<=this.data.length;l+=2){let c=t.indexOf(this.data[l])*45;c+=t.indexOf(this.data[l+1]),o.put(c,11)}this.data.length%2&&o.put(t.indexOf(this.data[l]),6)},ju=i,ju}var Tu,Xg;function Vx(){if(Xg)return Tu;Xg=1;const e=mr();function t(i){this.mode=e.BYTE,typeof i=="string"?this.data=new TextEncoder().encode(i):this.data=new Uint8Array(i)}return t.getBitsLength=function(s){return s*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(i){for(let s=0,o=this.data.length;s<o;s++)i.put(this.data[s],8)},Tu=t,Tu}var Au,Gg;function Yx(){if(Gg)return Au;Gg=1;const e=mr(),t=pr();function i(s){this.mode=e.KANJI,this.data=s}return i.getBitsLength=function(o){return o*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(s){let o;for(o=0;o<this.data.length;o++){let 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)}},Au=i,Au}var Bu={exports:{}},Qg;function Xx(){return Qg||(Qg=1,(function(e){var t={single_source_shortest_paths:function(i,s,o){var l={},c={};c[s]=0;var d=t.PriorityQueue.make();d.push(s,0);for(var m,p,S,C,_,v,w,b,x;!d.empty();){m=d.pop(),p=m.value,C=m.cost,_=i[p]||{};for(S in _)_.hasOwnProperty(S)&&(v=_[S],w=C+v,b=c[S],x=typeof c[S]>"u",(x||b>w)&&(c[S]=w,d.push(S,w),l[S]=p))}if(typeof o<"u"&&typeof c[o]>"u"){var N=["Could not find a path from ",s," to ",o,"."].join("");throw new Error(N)}return l},extract_shortest_path_from_predecessor_list:function(i,s){for(var o=[],l=s;l;)o.push(l),i[l],l=i[l];return o.reverse(),o},find_path:function(i,s,o){var l=t.single_source_shortest_paths(i,s,o);return t.extract_shortest_path_from_predecessor_list(l,o)},PriorityQueue:{make:function(i){var s=t.PriorityQueue,o={},l;i=i||{};for(l in s)s.hasOwnProperty(l)&&(o[l]=s[l]);return o.queue=[],o.sorter=i.sorter||s.default_sorter,o},default_sorter:function(i,s){return i.cost-s.cost},push:function(i,s){var o={value:i,cost:s};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(Bu)),Bu.exports}var Jg;function Gx(){return Jg||(Jg=1,(function(e){const t=mr(),i=Kx(),s=qx(),o=Vx(),l=Yx(),c=ry(),d=pr(),m=Xx();function p(N){return unescape(encodeURIComponent(N)).length}function S(N,L,j){const T=[];let Q;for(;(Q=N.exec(j))!==null;)T.push({data:Q[0],index:Q.index,mode:L,length:Q[0].length});return T}function C(N){const L=S(c.NUMERIC,t.NUMERIC,N),j=S(c.ALPHANUMERIC,t.ALPHANUMERIC,N);let T,Q;return d.isKanjiModeEnabled()?(T=S(c.BYTE,t.BYTE,N),Q=S(c.KANJI,t.KANJI,N)):(T=S(c.BYTE_KANJI,t.BYTE,N),Q=[]),L.concat(j,T,Q).sort(function(I,G){return I.index-G.index}).map(function(I){return{data:I.data,mode:I.mode,length:I.length}})}function _(N,L){switch(L){case t.NUMERIC:return i.getBitsLength(N);case t.ALPHANUMERIC:return s.getBitsLength(N);case t.KANJI:return l.getBitsLength(N);case t.BYTE:return o.getBitsLength(N)}}function v(N){return N.reduce(function(L,j){const T=L.length-1>=0?L[L.length-1]:null;return T&&T.mode===j.mode?(L[L.length-1].data+=j.data,L):(L.push(j),L)},[])}function w(N){const L=[];for(let j=0;j<N.length;j++){const T=N[j];switch(T.mode){case t.NUMERIC:L.push([T,{data:T.data,mode:t.ALPHANUMERIC,length:T.length},{data:T.data,mode:t.BYTE,length:T.length}]);break;case t.ALPHANUMERIC:L.push([T,{data:T.data,mode:t.BYTE,length:T.length}]);break;case t.KANJI:L.push([T,{data:T.data,mode:t.BYTE,length:p(T.data)}]);break;case t.BYTE:L.push([{data:T.data,mode:t.BYTE,length:p(T.data)}])}}return L}function b(N,L){const j={},T={start:{}};let Q=["start"];for(let H=0;H<N.length;H++){const I=N[H],G=[];for(let U=0;U<I.length;U++){const q=I[U],X=""+H+U;G.push(X),j[X]={node:q,lastCount:0},T[X]={};for(let A=0;A<Q.length;A++){const E=Q[A];j[E]&&j[E].node.mode===q.mode?(T[E][X]=_(j[E].lastCount+q.length,q.mode)-_(j[E].lastCount,q.mode),j[E].lastCount+=q.length):(j[E]&&(j[E].lastCount=q.length),T[E][X]=_(q.length,q.mode)+4+t.getCharCountIndicator(q.mode,L))}}Q=G}for(let H=0;H<Q.length;H++)T[Q[H]].end=0;return{map:T,table:j}}function x(N,L){let j;const T=t.getBestModeForData(N);if(j=t.from(L,T),j!==t.BYTE&&j.bit<T.bit)throw new Error('"'+N+'" cannot be encoded with mode '+t.toString(j)+`.
|
|
84
|
+
Suggested mode is: `+t.toString(T));switch(j===t.KANJI&&!d.isKanjiModeEnabled()&&(j=t.BYTE),j){case t.NUMERIC:return new i(N);case t.ALPHANUMERIC:return new s(N);case t.KANJI:return new l(N);case t.BYTE:return new o(N)}}e.fromArray=function(L){return L.reduce(function(j,T){return typeof T=="string"?j.push(x(T,null)):T.data&&j.push(x(T.data,T.mode)),j},[])},e.fromString=function(L,j){const T=C(L,d.isKanjiModeEnabled()),Q=w(T),H=b(Q,j),I=m.find_path(H.map,"start","end"),G=[];for(let U=1;U<I.length-1;U++)G.push(H.table[I[U]].node);return e.fromArray(v(G))},e.rawSplit=function(L){return e.fromArray(C(L,d.isKanjiModeEnabled()))}})(Mu)),Mu}var Zg;function Qx(){if(Zg)return _u;Zg=1;const e=pr(),t=cd(),i=Ax(),s=Bx(),o=Ix(),l=Ox(),c=zx(),d=iy(),m=$x(),p=Wx(),S=Ux(),C=mr(),_=Gx();function v(H,I){const G=H.size,U=l.getPositions(I);for(let q=0;q<U.length;q++){const X=U[q][0],A=U[q][1];for(let E=-1;E<=7;E++)if(!(X+E<=-1||G<=X+E))for(let R=-1;R<=7;R++)A+R<=-1||G<=A+R||(E>=0&&E<=6&&(R===0||R===6)||R>=0&&R<=6&&(E===0||E===6)||E>=2&&E<=4&&R>=2&&R<=4?H.set(X+E,A+R,!0,!0):H.set(X+E,A+R,!1,!0))}}function w(H){const I=H.size;for(let G=8;G<I-8;G++){const U=G%2===0;H.set(G,6,U,!0),H.set(6,G,U,!0)}}function b(H,I){const G=o.getPositions(I);for(let U=0;U<G.length;U++){const q=G[U][0],X=G[U][1];for(let A=-2;A<=2;A++)for(let E=-2;E<=2;E++)A===-2||A===2||E===-2||E===2||A===0&&E===0?H.set(q+A,X+E,!0,!0):H.set(q+A,X+E,!1,!0)}}function x(H,I){const G=H.size,U=p.getEncodedBits(I);let q,X,A;for(let E=0;E<18;E++)q=Math.floor(E/3),X=E%3+G-8-3,A=(U>>E&1)===1,H.set(q,X,A,!0),H.set(X,q,A,!0)}function N(H,I,G){const U=H.size,q=S.getEncodedBits(I,G);let X,A;for(X=0;X<15;X++)A=(q>>X&1)===1,X<6?H.set(X,8,A,!0):X<8?H.set(X+1,8,A,!0):H.set(U-15+X,8,A,!0),X<8?H.set(8,U-X-1,A,!0):X<9?H.set(8,15-X-1+1,A,!0):H.set(8,15-X-1,A,!0);H.set(U-8,8,1,!0)}function L(H,I){const G=H.size;let U=-1,q=G-1,X=7,A=0;for(let E=G-1;E>0;E-=2)for(E===6&&E--;;){for(let R=0;R<2;R++)if(!H.isReserved(q,E-R)){let F=!1;A<I.length&&(F=(I[A]>>>X&1)===1),H.set(q,E-R,F),X--,X===-1&&(A++,X=7)}if(q+=U,q<0||G<=q){q-=U,U=-U;break}}}function j(H,I,G){const U=new i;G.forEach(function(R){U.put(R.mode.bit,4),U.put(R.getLength(),C.getCharCountIndicator(R.mode,H)),R.write(U)});const q=e.getSymbolTotalCodewords(H),X=d.getTotalCodewordsCount(H,I),A=(q-X)*8;for(U.getLengthInBits()+4<=A&&U.put(0,4);U.getLengthInBits()%8!==0;)U.putBit(0);const E=(A-U.getLengthInBits())/8;for(let R=0;R<E;R++)U.put(R%2?17:236,8);return T(U,H,I)}function T(H,I,G){const U=e.getSymbolTotalCodewords(I),q=d.getTotalCodewordsCount(I,G),X=U-q,A=d.getBlocksCount(I,G),E=U%A,R=A-E,F=Math.floor(U/A),D=Math.floor(X/A),O=D+1,z=F-D,ie=new m(z);let K=0;const M=new Array(A),W=new Array(A);let oe=0;const ae=new Uint8Array(H.buffer);for(let Y=0;Y<A;Y++){const ne=Y<R?D:O;M[Y]=ae.slice(K,K+ne),W[Y]=ie.encode(M[Y]),K+=ne,oe=Math.max(oe,ne)}const se=new Uint8Array(U);let le=0,ye,ce;for(ye=0;ye<oe;ye++)for(ce=0;ce<A;ce++)ye<M[ce].length&&(se[le++]=M[ce][ye]);for(ye=0;ye<z;ye++)for(ce=0;ce<A;ce++)se[le++]=W[ce][ye];return se}function Q(H,I,G,U){let q;if(Array.isArray(H))q=_.fromArray(H);else if(typeof H=="string"){let F=I;if(!F){const D=_.rawSplit(H);F=p.getBestVersionForData(D,G)}q=_.fromString(H,F||40)}else throw new Error("Invalid data");const X=p.getBestVersionForData(q,G);if(!X)throw new Error("The amount of data is too big to be stored in a QR Code");if(!I)I=X;else if(I<X)throw new Error(`
|
|
85
85
|
The chosen QR Code version cannot contain this amount of data.
|
|
86
|
-
Minimum version required to store current data is: `+
|
|
87
|
-
`);const A=j(I,G,q),E=e.getSymbolSize(I),R=new s(E);return v(R,I),w(R),b(R,I),N(R,G,0),I>=7&&x(R,I),L(R,A),isNaN(U)&&(U=c.getBestMask(R,N.bind(null,R,G))),c.applyMask(U,R),N(R,G,U),{modules:R,version:I,errorCorrectionLevel:G,maskPattern:U,segments:q}}return _u.create=function(I,G){if(typeof I>"u"||I==="")throw new Error("No input text");let U=t.M,q,
|
|
88
|
-
`;return typeof d=="function"&&d(null,x),x},zu}var nv;function Jx(){if(nv)return $r;nv=1;const e=Lx(),t=Xx(),i=Gx(),s=Qx();function o(l,c,d,m,p){const S=[].slice.call(arguments,1),C=S.length,_=typeof S[C-1]=="function";if(!_&&!e())throw new Error("Callback required as last argument");if(_){if(C<2)throw new Error("Too few arguments provided");C===2?(p=d,d=c,c=m=void 0):C===3&&(c.getContext&&typeof p>"u"?(p=m,m=void 0):(p=m,m=d,d=c,c=void 0))}else{if(C<1)throw new Error("Too few arguments provided");return C===1?(d=c,c=m=void 0):C===2&&!c.getContext&&(m=d,d=c,c=void 0),new Promise(function(v,w){try{const b=t.create(d,m);v(l(b,c,m))}catch(b){w(b)}})}try{const v=t.create(d,m);p(null,l(v,c,m))}catch(v){p(v)}}return $r.create=t.create,$r.toCanvas=o.bind(null,i.render),$r.toDataURL=o.bind(null,i.renderToDataURL),$r.toString=o.bind(null,function(l,c,d){return s.render(l,d)}),$r}var Zx=Jx();const ek=Oh(Zx),ry=/^[a-z0-9-]{1,32}$/,tk=/^[A-Za-z0-9._-]{1,32}$/,ik=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,nk=320;function rk(e){return typeof e=="string"&&ry.test(e)}const sk=64;function jh(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=sk&&!/[\x00-\x1f\x7f]/.test(t)}function Xr(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function sy(e){if(typeof e!="string"||!e||e.length>nk||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:tk.test(e.slice(0,t))&&ik.test(e.slice(t+1))}function rv(e){if(e===""||e===null||e===void 0)return null;const t=String(e).trim();if(!/^[0-9]{1,5}$/.test(t))return;const i=Number(t);return Number.isInteger(i)&&i>=1&&i<=65535?i:void 0}function sv({name:e,ssh:t,sshPort:i,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,l=typeof t=="string"?t.trim():t;if(!rk(o))return{ok:!1,error:"err-node-name"};if(!sy(l))return{ok:!1,error:"err-ssh"};const c=rv(i);if(c===void 0)return{ok:!1,error:"err-ssh-port"};const d=rv(s);if(d===void 0)return{ok:!1,error:"err-node-port"};const m={name:o,ssh:l};return c!==null&&(m.sshPort=c),d!==null&&(m.remotePort=d),{ok:!0,value:m}}function ok(e,t){if(!e||!t||t<e)return null;const i=Math.floor((t-e)/1e3);return i<60?"ora":i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}g`}function ov(e,t){const i=!!(e&&e.status==="up"),s=!!(e&&e.status==="passive");return{up:i,...s?{passive:!0}:{},label:i?"tunnel-up":s?"node-passive":"tunnel-down",since:i?ok(e.since,t):null}}const ak=new Set(["v","instanceId","port","label","invite"]),lk=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function ck(e){const t=String(e).replace(/-/g,"+").replace(/_/g,"/"),i=t+"=".repeat((4-t.length%4)%4),s=typeof atob=="function"?atob(i):Buffer.from(i,"base64").toString("binary"),o=Uint8Array.from(s,l=>l.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function uk(e){let t="";try{const c=new URL(String(e));t=new URLSearchParams(c.hash.replace(/^#/,"")).get("pair")||""}catch{return{ok:!1}}if(!t)return{ok:!1};let i;try{i=JSON.parse(ck(t))}catch{return{ok:!1}}if(!i||typeof i!="object"||Array.isArray(i))return{ok:!1};const s=i.v===1?ak:i.v===2?lk:null;if(!s)return{ok:!1};for(const c of Object.keys(i))if(!s.has(c))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(i.instanceId)))return{ok:!1};const o=Number(i.port);if(!Number.isInteger(o)||o<1||o>65535)return{ok:!1};if(typeof i.label!="string")return{ok:!1};if(typeof i.invite!="string"||!i.invite)return{ok:!1};const l={ok:!0,version:i.v,label:i.label,invite:i.invite,instanceId:i.instanceId,port:o};if(i.v===2){if(i.name!==void 0){if(typeof i.name!="string"||!ry.test(i.name))return{ok:!1};l.name=i.name}if(i.ssh!==void 0){if(!sy(i.ssh))return{ok:!1};l.ssh=String(i.ssh).trim()}if(i.sshPort!==void 0){const c=Number(i.sshPort);if(!Number.isInteger(c)||c<1||c>65535)return{ok:!1};l.sshPort=c}}return l}function hk(e,t,i=new Set){if(!t||!t.ok)return e;const s={...e},o=(l,c)=>{c==null||c===""||i.has(l)||(s[l]=c)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?Xr(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}function av(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function dk(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const i=uk(t);if(!i||!i.ok)return{kind:"invalid"};const s=[];return i.ssh||s.push("ssh"),i.name||s.push("name"),s.length?{kind:"partial",decoded:i,missing:s}:{kind:"complete",decoded:i}}function fk(e,t,i=new Set,s=!1){if(!t||!t.ok)return e;const o=hk(e,t,i);return t.version===2&&t.name&&!i.has("name")&&!s&&(o.name=t.name),!i.has("label")&&!o.label&&t.label&&(o.label=t.label),o}function lv(e,t,i=new Set,s=!1){const o=String(t||"").trim(),l=dk(o);let c={...e,pairingUrl:o};return(l.kind==="complete"||l.kind==="partial")&&(c={...fk(c,l.decoded,i,s),pairingUrl:o}),{classification:l,form:c}}function pk(e,{deviceDefault:t=""}={}){const i={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&&(i.localLabel=s),i}function mk(){const e=new Set;let t=!1;return{canAuto(i){return!t&&!e.has(String(i||""))},start(i){return t?!1:(t=!0,e.add(String(i||"")),!0)},finish(){t=!1},reset(i){e.delete(String(i||""))},isBusy(){return t}}}const gk=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function vk(e){const t=e&&e.data||{},i=typeof t.stage=="string"&&t.stage?t.stage:"",s=typeof t.detail=="string"&&t.detail?t.detail:"";return{stage:i,code:typeof t.code=="string"?t.code:"",detail:s,hint:typeof t.hint=="string"?t.hint:"",retryable:typeof t.retryable=="boolean"?t.retryable:!i,message:s||String(e&&e.message||e)}}const _k="modulepreload",yk=function(e){return"/"+e},cv={},Sk=function(t,i,s){let o=Promise.resolve();if(i&&i.length>0){let c=function(p){return Promise.all(p.map(S=>Promise.resolve(S).then(C=>({status:"fulfilled",value:C}),C=>({status:"rejected",reason:C}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),m=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));o=c(i.map(p=>{if(p=yk(p),p in cv)return;cv[p]=!0;const S=p.endsWith(".css"),C=S?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${C}`))return;const _=document.createElement("link");if(_.rel=S?"stylesheet":_k,S||(_.as="script"),_.crossOrigin="",_.href=p,m&&_.setAttribute("nonce",m),document.head.appendChild(_),S)return new Promise((v,w)=>{_.addEventListener("load",v),_.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${p}`)))})}))}function l(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return o.then(c=>{for(const d of c||[])d.status==="rejected"&&l(d.reason);return t().catch(l)})};class Ye{constructor(t,i,s,o,l){this._legacyCanvasSize=Ye.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),s&&typeof s=="object"?this._onDecode=i:(console.warn(s||o||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=i),i=typeof s=="object"?s:{},this._onDecodeError=i.onDecodeError||(typeof s=="function"?s:this._onDecodeError),this._calculateScanRegion=i.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=i.preferredCamera||l||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=i.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let c=!1;if(t.hidden&&(t.hidden=!1,c=!0),document.body.contains(t)||(document.body.appendChild(t),c=!0),s=t.parentElement,i.highlightScanRegion||i.highlightCodeOutline){if(o=!!i.overlay,this.$overlay=i.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&&i.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}s.insertBefore(this.$overlay,this.$video.nextSibling)}i.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let d=window.getComputedStyle(t);d.display==="none"&&(t.style.setProperty("display","block","important"),c=!0),d.visibility!=="visible"&&(t.style.setProperty("visibility","visible","important"),c=!0),c&&(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=Ye.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 Ye.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let i=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),s;try{t&&(await i()).every(o=>!o.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await i()).map((o,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"),Ye._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"),Ye._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(),Ye._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:i}=await this._getCameraStream();!this._active||this._paused?Ye._stopVideoStream(t):(this._setVideoMirror(i),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(t){if(!this._paused)throw this._active=!1,t}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let i=()=>{this.$video.srcObject instanceof MediaStream&&(Ye._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(i(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(i(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,i,s,o,l=!1,c=!1){let d,m=!1;i&&("scanRegion"in i||"qrEngine"in i||"canvas"in i||"disallowCanvasResizing"in i||"alsoTryWithoutScanRegion"in i||"returnDetailedScanResult"in i)?(d=i.scanRegion,s=i.qrEngine,o=i.canvas,l=i.disallowCanvasResizing||!1,c=i.alsoTryWithoutScanRegion||!1,m=!0):console.warn(i||s||o||l||c?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),i=!!s;try{let p,S;[s,p]=await Promise.all([s||Ye.createQrEngine(),Ye._loadImage(t)]),[o,S]=Ye._drawToCanvas(p,d,o,l);let C;if(s instanceof Worker){let _=s;i||Ye._postWorkerMessageSync(_,"inversionMode","both"),C=await new Promise((v,w)=>{let b,x,N,L=-1;x=T=>{T.data.id===L&&(_.removeEventListener("message",x),_.removeEventListener("error",N),clearTimeout(b),T.data.data!==null?v({data:T.data.data,cornerPoints:Ye._convertPoints(T.data.cornerPoints,d)}):w(Ye.NO_QR_CODE_FOUND))},N=T=>{_.removeEventListener("message",x),_.removeEventListener("error",N),clearTimeout(b),w("Scanner error: "+(T?T.message||T:"Unknown Error"))},_.addEventListener("message",x),_.addEventListener("error",N),b=setTimeout(()=>N("timeout"),1e4);let j=S.getImageData(0,0,o.width,o.height);L=Ye._postWorkerMessageSync(_,"decode",j,[j.data.buffer])})}else C=await Promise.race([new Promise((_,v)=>window.setTimeout(()=>v("Scanner error: timeout"),1e4)),(async()=>{try{var[_]=await s.detect(o);if(!_)throw Ye.NO_QR_CODE_FOUND;return{data:_.rawValue,cornerPoints:Ye._convertPoints(_.cornerPoints,d)}}catch(v){if(_=v.message||v,/not implemented|service unavailable/.test(_))return Ye._disableBarcodeDetector=!0,Ye.scanImage(t,{scanRegion:d,canvas:o,disallowCanvasResizing:l,alsoTryWithoutScanRegion:c});throw`Scanner error: ${_}`}})()]);return m?C:C.data}catch(p){if(!d||!c)throw p;let S=await Ye.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:l});return m?S:S.data}finally{i||Ye._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,i,s,o=!0){Ye._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:i,blue:s,useIntegerApproximation:o})}setInversionMode(t){Ye._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=()=>Sk(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!Ye._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let i=navigator.userAgentData;return i&&i.brands.some(({brand:s})=>/Chromium/i.test(s))&&/mac ?OS/i.test(i.platform)&&await i.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:s,platformVersion:o})=>/arm/i.test(s||"arm")&&13<=parseInt(o||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let i=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-i)/2),y:Math.round((t.videoHeight-i)/2),width:i,height:i,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,i=t.videoWidth,s=t.videoHeight,o=t.offsetWidth,l=t.offsetHeight,c=t.offsetLeft,d=t.offsetTop,m=window.getComputedStyle(t),p=m.objectFit,S=i/s,C=o/l;switch(p){case"none":var _=i,v=s;break;case"fill":_=o,v=l;break;default:(p==="cover"?S>C:S<C)?(v=l,_=v*S):(_=o,v=_/S),p==="scale-down"&&(_=Math.min(_,i),v=Math.min(v,s))}var[w,b]=m.objectPosition.split(" ").map((N,L)=>{const j=parseFloat(N);return N.endsWith("%")?(L?l-v:o-_)*j/100:j});m=this._scanRegion.width||i,C=this._scanRegion.height||s,p=this._scanRegion.x||0;var x=this._scanRegion.y||0;S=this.$overlay.style,S.width=`${m/i*_}px`,S.height=`${C/s*v}px`,S.top=`${d+b+x/s*v}px`,s=/scaleX\(-1\)/.test(t.style.transform),S.left=`${c+(s?o-w-_:w)+(s?i-p-m:p)/i*_}px`,S.transform=t.style.transform}})}static _convertPoints(t,i){if(!i)return t;let s=i.x||0,o=i.y||0,l=i.width&&i.downScaledWidth?i.width/i.downScaledWidth:1;i=i.height&&i.downScaledHeight?i.height/i.downScaledHeight:1;for(let c of t)c.x=c.x*l+s,c.y=c.y*i+o;return t}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,i=1e3/this._maxScansPerSecond;t<i&&await new Promise(o=>setTimeout(o,i-t)),this._lastScanTimestamp=Date.now();try{var s=await Ye.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!Ye._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=Ye.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!==Ye.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",i=[{width:{min:1024}},{width:{min:768}},{}],s=i.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...s,...i])try{let l=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),c=this._getFacingMode(l)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:l,facingMode:c}}catch{}throw"Camera not found."}async _restartVideoStream(){let t=this._paused;await this.pause(!0)&&!t&&this._active&&await this.start()}static _stopVideoStream(t){for(let i of t.getTracks())i.stop(),t.removeTrack(i)}_setVideoMirror(t){this.$video.style.transform="scaleX("+(t==="user"?-1:1)+")"}_getFacingMode(t){return(t=t.getVideoTracks()[0])?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(t,i,s,o=!1){s=s||document.createElement("canvas");let l=i&&i.x?i.x:0,c=i&&i.y?i.y:0,d=i&&i.width?i.width:t.videoWidth||t.width,m=i&&i.height?i.height:t.videoHeight||t.height;return o||(o=i&&i.downScaledWidth?i.downScaledWidth:d,i=i&&i.downScaledHeight?i.downScaledHeight:m,s.width!==o&&(s.width=o),s.height!==i&&(s.height=i)),i=s.getContext("2d",{alpha:!1}),i.imageSmoothingEnabled=!1,i.drawImage(t,l,c,d,m,0,0,s.width,s.height),[s,i]}static async _loadImage(t){if(t instanceof Image)return await Ye._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(t instanceof File||t instanceof Blob||t instanceof URL||typeof t=="string"){let i=new Image;i.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await Ye._awaitImageLoad(i),i}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(i.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((i,s)=>{let o=l=>{t.removeEventListener("load",o),t.removeEventListener("error",o),l instanceof ErrorEvent?s("Image load error"):i()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,i,s,o){return Ye._postWorkerMessageSync(await t,i,s,o)}static _postWorkerMessageSync(t,i,s,o){if(!(t instanceof Worker))return-1;let l=Ye._workerMessageId++;return t.postMessage({id:l,type:i,data:s},o),l}}Ye.DEFAULT_CANVAS_SIZE=400;Ye.NO_QR_CODE_FOUND="No QR code found";Ye._disableBarcodeDetector=!1;Ye._workerMessageId=0;function wk({onResult:e,onClose:t}){const i=P.useRef(null),s=P.useRef(null),o=P.useRef(!1),[l,c]=P.useState("");P.useEffect(()=>{let m=!1;const p=i.current,S=C=>{m||o.current||(o.current=!0,e(C))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){c(y("qr-unsupported"));return}let C=!1;try{C=await Ye.hasCamera()}catch{C=!1}if(!C){c(y("qr-no-camera"));return}if(m||!p)return;const _=new Ye(p,v=>{const w=av(v);w&&S(w)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:v=>{const w=v.videoWidth||640,b=v.videoHeight||480,x=Math.max(1,Math.round(Math.min(w,b)*.92));return{x:Math.round((w-x)/2),y:Math.round((b-x)/2),width:x,height:x,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=_;try{await _.start()}catch(v){if(m)return;const w=v&&v.name||"";c(y(w==="NotAllowedError"||w==="SecurityError"?"qr-permission":w==="NotFoundError"||w==="OverconstrainedError"||w==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{m=!0;const C=s.current;if(C){try{C.stop()}catch{}try{C.destroy()}catch{}s.current=null}const _=p,v=_&&_.srcObject;if(v&&typeof v.getTracks=="function"){for(const w of v.getTracks())try{w.stop()}catch{}try{_.srcObject=null}catch{}}}},[]);const d=async m=>{const p=m.target.files&&m.target.files[0];if(m.target.value="",!!p)try{const S=await Ye.scanImage(p,{returnDetailedScanResult:!0}),C=av(S);if(!C)throw new Error("empty");o.current||(o.current=!0,e(C))}catch{c(y("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:m=>m.stopPropagation(),children:[h.jsx("div",{className:"nc-sheet-head",children:h.jsx("b",{children:y("scan-qr")})}),h.jsx("video",{ref:i,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:[y("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:y("cancel")})]})]})})}const uv=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:""});function oy({token:e,initial:t="",autoStart:i=!1,deviceDefault:s="",readonly:o=!1,onSuccess:l,onBusyChange:c}){const[d,m]=P.useState(uv),[p,S]=P.useState(!1),[C,_]=P.useState(!1),[v,w]=P.useState("idle"),[b,x]=P.useState(null),[N,L]=P.useState(""),[j,T]=P.useState(!1),Q=P.useRef(mk()),H=P.useRef(new Set),I=v==="busy";P.useEffect(()=>(c&&c(I),()=>{c&&c(!1)}),[I,c]);const G=async R=>{const F=String(R.pairingUrl||"").trim();if(Q.current.start(F)){w("busy"),x(null),L("");try{await Fw(e,pk(R,{deviceDefault:s})),w("ok"),S(!1),m(uv()),H.current=new Set,T(!1),Q.current.finish(),l&&await l()}catch(D){const O=vk(D);x(O),w("idle"),Q.current.finish(),(O.stage==="validation"||O.stage==="conflict"||O.stage==="ssh-start"||O.stage==="ssh-ready"||String(O.code||"").startsWith("ssh-"))&&S(!0)}}},U=(R,F=!0)=>{const{classification:D,form:O}=lv(d,R,H.current,j),z=O.pairingUrl;if(x(null),L(""),v==="ok"&&w("idle"),m(O),D.kind==="invalid"){x({stage:"validation",code:"bad-link",message:y("pair-invalid-link"),hint:y("pair-invalid-hint"),retryable:!0});return}if(D.kind==="partial"){S(!0),L(D.missing.includes("ssh")?y("pair-missing-ssh"):y("pair-missing-name"));return}D.kind==="complete"&&F&&!o&&Q.current.canAuto(z)&&G(O)};P.useEffect(()=>{t&&U(t,i)},[]);const q=()=>{const R=String(d.pairingUrl||"").trim(),{classification:F,form:D}=lv(d,R,H.current,j);if(m(D),L(""),x(null),F.kind==="empty"){x({stage:"validation",message:y("pairing-required"),retryable:!0});return}if(F.kind==="invalid"){x({stage:"validation",code:"bad-link",message:y("pair-invalid-link"),hint:y("pair-invalid-hint"),retryable:!0});return}if(!D.ssh||!D.name){S(!0),L(D.ssh?y("pair-missing-name"):y("pair-missing-ssh"));return}if(D.label&&!jh(D.label)){x({stage:"validation",message:y("err-label"),retryable:!0});return}if(D.localLabel&&!jh(D.localLabel)){x({stage:"validation",message:y("err-label"),retryable:!0});return}Q.current.reset(R),G(D)},Y=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const R=await navigator.clipboard.readText();R&&R.trim()?U(R):L(y("pair-clipboard-empty"))}catch{L(y("pair-clipboard-denied"))}},A=(R,F)=>{H.current.add(R),m(D=>({...D,[R]:F}))},E=b&&b.stage&&(gk.includes(b.stage)||b.stage==="internal")?y(`pair-stage-${b.stage}`):y("pair-stage-generic");return h.jsxs("div",{className:"nc-set-form nc-pair-card",children:[h.jsx("div",{className:"nc-sheet-label",children:y("pair-card-title")}),h.jsx("div",{className:"nc-set-info",children:y("pair-card-help")}),h.jsx("input",{className:"nc-pair-input",placeholder:y("pair-paste-ph"),value:d.pairingUrl,disabled:o||I,onChange:R=>{m({...d,pairingUrl:R.target.value}),x(null),L("")},onPaste:R=>{const F=R.clipboardData&&R.clipboardData.getData("text")||"";F.trim()&&(R.preventDefault(),U(F))},onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),q())}}),h.jsxs("div",{className:"nc-pair-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||I,onClick:Y,children:y("pair-paste-btn")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||I,onClick:()=>_(!0),children:y("scan-qr")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||I,title:o?y("settings-readonly"):"",onClick:q,children:y("test-and-connect")})]}),h.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[I&&h.jsx("div",{className:"nc-pair-progress",children:y("pair-progress")}),v==="ok"&&h.jsx("div",{className:"nc-set-test ok",children:y("node-connected")}),N&&h.jsx("div",{className:"nc-set-hint nc-pair-notice",children:N}),b&&h.jsxs("div",{className:"nc-err",role:"alert",children:[h.jsx("b",{children:E})," — ",b.message,b.hint&&h.jsx("div",{className:"nc-pair-hint",children:b.hint}),b.retryable&&h.jsx("div",{children:h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||I,onClick:q,children:y("pair-retry")})})]})]}),h.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:I,onClick:()=>S(R=>!R),children:[p?"▾":"▸"," ",y("pair-advanced")]}),p&&h.jsxs("div",{className:"nc-pair-advanced",children:[h.jsxs("label",{className:"nc-field",children:[y("node-display-label"),h.jsx("input",{placeholder:"Home Relay",value:d.label,disabled:o||I,onChange:R=>{H.current.add("label"),m(F=>({...F,label:R.target.value,name:j?F.name:Xr(R.target.value)}))}})]}),h.jsxs("label",{className:"nc-field",children:[y("node-name-label"),h.jsx("input",{placeholder:y("node-name-ph"),value:d.name,disabled:o||I,onChange:R=>{T(!0),H.current.add("name"),m(F=>({...F,name:R.target.value?Xr(R.target.value):""}))}})]}),h.jsx("small",{className:"nc-set-hint",children:y("node-slug-hint").replace("{slug}",d.name||"home-relay")}),h.jsxs("label",{className:"nc-field",children:[y("pair-ssh-local-label"),h.jsx("input",{placeholder:"my-relay",value:d.ssh,disabled:o||I,onChange:R=>{H.current.add("ssh"),A("ssh",R.target.value)}}),h.jsx("small",{className:"nc-set-hint",children:y("node-ssh-local-help")})]}),h.jsxs("label",{className:"nc-field",children:[y("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:y("node-ssh-port-help"),value:d.sshPort,disabled:o||I,onChange:R=>A("sshPort",R.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),h.jsxs("label",{className:"nc-field",children:[y("device-name-label"),h.jsx("input",{placeholder:s||"NexusCrew",value:d.localLabel,disabled:o||I,onChange:R=>A("localLabel",R.target.value)}),h.jsx("small",{className:"nc-set-hint",children:y("device-name-hint")})]})]}),C&&h.jsx(wk,{onResult:R=>{_(!1),U(R)},onClose:()=>_(!1)})]})}function ud(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function bk(e){const t="=".repeat((4-e.length%4)%4),i=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(i),o=new Uint8Array(s.length);for(let l=0;l<s.length;l+=1)o[l]=s.charCodeAt(l);return o}async function Ck(){if(!ud())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function xk(e){if(!ud())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const i=await zt("/api/push/vapid",e),{publicKey:s}=await i.json();if(!s)throw new Error("vapid non disponibile");const l=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:bk(s)}),c=await zt("/api/push/subscribe",e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:l.toJSON()})});if(!c.ok){try{await l.unsubscribe()}catch{}const d=await c.json().catch(()=>({}));throw new Error(d.error||`HTTP ${c.status}`)}return!0}async function kk(e){if(!ud())return!1;const i=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!i)return!1;const s=i.endpoint;try{await i.unsubscribe()}catch{}try{await zt("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const ay="nexuscrew.fleet",ly=2,Ek="nexuscrew.cells",Nk=/^[A-Za-z0-9._-]{1,32}$/,hd=/^[a-z0-9._-]{1,32}$/,cy=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,Rk=new Set(["standard","unsafe"]),Pk=4096,hv=256,Dk=8192,Mk=32,Lk=24,jk=new Set(["format","version","exportedAt","cells","engines"]),Tk=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]),Ak=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag"]),Bk=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]);function sr(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function uy(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 dv(e,t){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))return null;const i=Object.entries(e);if(i.length>128)return null;const s={};for(const[o,l]of i){if(!hd.test(o)||!t(l))return null;s[o]=l}return s}function hy(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(l=>!Tk.has(l))||!Nk.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>Pk||!hd.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>hv)||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>Dk)return null;const i=dv(e.models,l=>typeof l=="string"&&!!l&&l.length<=hv),s=dv(e.permissionPolicies,l=>Rk.has(l));if(i===null||s===null)return null;const o={id:e.id,cwd:e.cwd,engine:e.engine,boot:e.boot===!0,systemPrompt:t};return e.model&&(o.model=e.model),Object.keys(i).length&&(o.models=i),Object.keys(s).length&&(o.permissionPolicies=s),o}function Ik(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(i=>!Bk.has(i)))return null;const t={};for(const[i,s]of Object.entries(e)){if(typeof s!="string"||!sr(s,i==="baseUrl"?512:128)||uy(s))return null;t[i]=s}return!t.client||!t.provider||t.envKey&&!cy.test(t.envKey)?null:t}function dy(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!Ak.has(s))||!hd.test(String(e.id||""))||!sr(e.label||e.id,64)||e.rc!==void 0&&typeof e.rc!="boolean")return null;const t={id:e.id,label:e.label||e.id,rc:e.rc===!0};if(e.managed!==void 0){const s=Ik(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!sr(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!sr(s,1024)||uy(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!sr(e.promptFlag,32)||/\s/.test(e.promptFlag)))return null;if(e.model!==void 0){if(!e.model||typeof e.model!="object"||Array.isArray(e.model)||Object.keys(e.model).some(s=>s!=="flag"&&s!=="value")||!sr(e.model.flag,32)||/\s/.test(e.model.flag)||!sr(e.model.value||"",128))return null;t.model={flag:e.model.flag,value:e.model.value||""}}const i=e.envKeys===void 0?[]:e.envKeys;return!Array.isArray(i)||i.length>32||i.some(s=>!cy.test(s))?null:(Object.assign(t,{command:e.command,args:[...e.args],envKeys:[...new Set(i)].sort(),promptMode:e.promptMode}),e.promptMode==="flag"&&(t.promptFlag=e.promptFlag),t)}function fy(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.managed?{id:e.id,label:e.label,rc:e.rc,managed:e.managed}:{id:e.id,label:e.label,rc:e.rc,command:e.command,args:e.args,envKeys:e.envKeys,model:e.model,promptMode:e.promptMode,promptFlag:e.promptFlag},i=dy(t);return i||null}function Ok(e,t,i=[],s=[],o=new Date){i instanceof Date&&(o=i,i=[],s=[]);const l=t instanceof Set?t:new Set(t||[]),c=s instanceof Set?s:new Set(s||[]),d=[];for(const p of Array.isArray(e)?e:[]){if(!l.has(p.id))continue;const S=hy({id:p.id,cwd:p.cwd,engine:p.engine,boot:p.boot===!0,...p.model?{model:p.model}:{},...p.models?{models:p.models}:{},...p.permissionPolicies?{permissionPolicies:p.permissionPolicies}:{},systemPrompt:p.prompt||""});S&&d.push(S)}const m=[];for(const p of Array.isArray(i)?i:[]){if(!c.has(p.id))continue;const S=fy(p);S&&m.push(S)}return{format:ay,version:ly,exportedAt:o.toISOString(),cells:d,engines:m}}function zk(e){let t;try{t=JSON.parse(String(e||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const i=(t==null?void 0:t.format)===Ek&&(t==null?void 0:t.version)===1;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(d=>!jk.has(d))||!i&&(t.format!==ay||t.version!==ly)||!Array.isArray(t.cells)||t.cells.length>Mk||!i&&(!Array.isArray(t.engines)||t.engines.length>Lk))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const s=[],o=new Set;for(const d of t.cells){const m=hy(d);if(!m)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(o.has(m.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};o.add(m.id),s.push(m)}const l=[],c=new Set;for(const d of i?[]:t.engines){const m=dy(d);if(!m)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(c.has(m.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};c.add(m.id),l.push(m)}return{ok:!0,cells:s,engines:l,legacy:i,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function Fk(e,t,i){const s=new Set(i||[]);if(!s.has(t))return null;const o=m=>Object.fromEntries(Object.entries(m||{}).filter(([p])=>s.has(p))),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 c=o(e.models),d=o(e.permissionPolicies);return Object.keys(c).length&&(l.models=c),Object.keys(d).length&&(l.permissionPolicies=d),l}const Hk=()=>({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:[]}),fv=(e="")=>({id:"",cwd:"",engine:e,boot:!1,model:"",prompt:""}),py=e=>e==="claude"?"unsafe":"standard",tl=(e,t)=>e.find(i=>i.client===t.client&&i.provider===t.provider&&(i.credentialProfile||"")===(t.credentialProfile||"")),$k=(e,t)=>{var i;return((i=tl(e,t))==null?void 0:i.label)||`${t.client} · ${t.provider}`};function Wk(e){var t,i,s,o,l,c,d,m,p,S,C,_,v,w;return{kind:e.managed?"managed":"custom",id:e.id,label:e.label||"",command:e.command||"",argsText:(e.args||[]).join(`
|
|
89
|
-
`),rc:!!e.rc,client:((t=e.managed)==null?void 0:t.client)||"claude",provider:((i=e.managed)==null?void 0:i.provider)||"native",credentialProfile:((s=e.managed)==null?void 0:s.credentialProfile)||"",managedModel:((o=e.managed)==null?void 0:o.model)||"",permissionPolicy:((l=e.managed)==null?void 0:l.permissionPolicy)||
|
|
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 Wr({children:e,onClose:t,label:i,error:s=""}){const o=P.useRef(null),l=P.useRef(null),c=P.useRef(t);return c.current=t,P.useEffect(()=>{const d=document.activeElement,m=o.current,p=()=>Array.from((m==null?void 0:m.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))||[]).filter(_=>_.offsetParent!==null),S=requestAnimationFrame(()=>{var _;return(_=p()[0]||m)==null?void 0:_.focus({preventScroll:!0})}),C=_=>{var x;if(_.key==="Escape"){_.preventDefault(),(x=c.current)==null||x.call(c);return}if(_.key!=="Tab")return;const v=p();if(!v.length){_.preventDefault(),m==null||m.focus();return}const w=v[0],b=v[v.length-1];_.shiftKey&&document.activeElement===w?(_.preventDefault(),b.focus()):!_.shiftKey&&document.activeElement===b&&(_.preventDefault(),w.focus())};return document.addEventListener("keydown",C),()=>{cancelAnimationFrame(S),document.removeEventListener("keydown",C),d&&d.isConnected&&typeof d.focus=="function"&&d.focus({preventScroll:!0})}},[]),P.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":i||y("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 pv({token:e,targets:t=[],readonly:i=!1,onPower:s,onImport:o}){const[l,c]=P.useState([]),[d,m]=P.useState(0);P.useEffect(()=>{let x=!0;async function N(){const j=[{route:[],label:y("local")}].concat((t||[]).map(Q=>({route:Array.isArray(Q.route)?Q.route:[],label:Q.label||(Q.route||[]).join(" › ")}))),T=await Promise.all(j.map(async Q=>{const H={...Q,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const I=await dr(e,Q.route);H.available=!!I.available,H.capabilities=I.capabilities||[],H.provider=I.provider||null,H.cells=(I.cells||[]).map(G=>({...G,route:Q.route}));try{H.readonly=!!(await Wh(e,Q.route)).readonlyDefault}catch{}try{const G=await Dv(e,Q.route),U=new Set(H.cells.map(q=>q.tmuxSession).filter(Boolean));H.unmanaged=(G.sessions||[]).filter(q=>q&&!U.has(q.name))}catch{}}catch(I){H.err=String(I&&I.message||I)}return H}));x&&c(T)}N();const L=setInterval(N,6e3);return()=>{x=!1,clearInterval(L)}},[e,t,d]);const p=(x,N)=>Array.isArray(x.capabilities)&&x.capabilities.includes(N)&&!i&&!x.readonly,S=()=>m(x=>x+1),C=(x,N)=>{s&&s({...x,route:N})},_=(x,N)=>{s&&s({...x,route:N})},v=async(x,N)=>{try{await Gs(e,x.cell,N)}catch{}S()},w=async(x,N)=>{if(window.confirm(y("fleet-remove-cell").replace("{id}",x.cell))){try{await kv(e,x.cell,!0,N)}catch{}S()}},b=async(x,N)=>{if(window.confirm(y("terminate-confirm").replace("{name}",x.name))){try{await $h(e,x.name,N)}catch{}S()}};return h.jsxs("div",{className:"nc-fleet-inventory",children:[h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:y("fleet-inventory")}),h.jsx("small",{children:y("fleet-inventory-help")})]}),l.map(x=>{const N=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} ${y("fleet-cells")} · ${x.unmanaged.length} ${y("fleet-tmux")}`:x.err||y("fleet-not-available")})]}),x.cells.map(L=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[h.jsxs("span",{children:[h.jsx("b",{children:L.cell}),h.jsx("small",{children:`${L.engine||""}${L.key?`·${L.key}`:""}${L.active?"":` · ${y("cell-off")}`}`})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[L.active&&p(x,"down")&&h.jsx("button",{className:"nc-btn ghost",title:y("power-off"),onClick:()=>_(L,x.route),children:y("stop")}),!L.active&&p(x,"up")&&h.jsx("button",{className:"nc-btn ghost",title:y("power-on"),onClick:()=>C(L,x.route),children:y("start")}),p(x,"restart")&&L.active&&h.jsx("button",{className:"nc-btn ghost",title:y("restart"),onClick:()=>v(L,x.route),children:y("restart")}),p(x,"remove")&&h.jsx("button",{className:"nc-btn danger",title:y("delete"),onClick:()=>w(L,x.route),children:"×"})]})]},`${N}:${L.cell}`)),x.unmanaged.map(L=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[h.jsxs("span",{children:[h.jsx("b",{children:L.name}),h.jsx("small",{children:y("fleet-tmux")})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[p(x,"import")&&o&&h.jsx("button",{className:"nc-btn ghost",title:y("import-as-cell"),onClick:()=>o(L,x.route),children:y("import-as-cell")}),h.jsx("button",{className:"nc-btn danger",title:y("terminate"),onClick:()=>b(L,x.route),children:"×"})]})]},`${N}:u:${L.name}`)),x.available&&x.cells.length===0&&x.unmanaged.length===0&&h.jsx("div",{className:"nc-empty",children:y("fleet-inventory-empty")})]},N)})]})}function
|
|
91
|
-
`],{type:"application/json"}),D=URL.createObjectURL(F),O=document.createElement("a");O.href=D,O.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(O),O.click(),O.remove(),setTimeout(()=>URL.revokeObjectURL(D),0),N("")},H=async E=>{if(N(""),v([]),b([]),!!E){if(E.size>1024*1024){N(y("fleet-backup-too-large"));return}try{const R=zk(await E.text());if(!R.ok){N(y(`fleet-backup-${R.error}`));return}const F=new Set(R.engines.map(D=>D.id));b(R.engines.map(D=>({engine:D,exists:L.has(D.id),selected:!L.has(D.id)}))),v(R.cells.map(D=>{const O=L.has(D.engine)||F.has(D.engine),z=j.has(D.id);return{cell:D,engine:O?D.engine:"",selected:O&&!z,exists:z}}))}catch(R){N(String(R.message||R))}}},I=(E,R)=>v(F=>F.map((D,O)=>O===E?{...D,...R}:D)),G=(E,R)=>b(F=>F.map((D,O)=>O===E?{...D,...R}:D)),U=new Set([...L,...w.filter(E=>E.selected).map(E=>E.engine.id)]),q=_.filter(E=>E.selected&&E.engine&&U.has(E.engine)),Y=w.filter(E=>E.selected),A=[...new Map([...t.map(E=>[E.id,E.label||E.id]),...w.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:y("fleet-backup")}),h.jsx("small",{children:y("fleet-backup-help")}),h.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[h.jsx("button",{type:"button",className:`nc-set-tabbtn${c==="export"?" on":""}`,onClick:()=>{d("export"),N("")},children:y("fleet-backup-export")}),h.jsx("button",{type:"button",className:`nc-set-tabbtn${c==="import"?" on":""}`,disabled:!s,title:s?"":y("fleet-backup-restore-unavailable"),onClick:()=>{d("import"),N("")},children:y("fleet-backup-import")})]}),c==="export"?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{p(new Set(e.map(E=>E.id))),C(new Set(t.map(E=>E.id)))},children:y("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{p(new Set),C(new Set)},children:y("select-none")})]}),h.jsxs("div",{className:"nc-backup-list",children:[h.jsx("b",{children:y("fleet-engines")}),t.map(E=>{var R;return h.jsxs("label",{className:"nc-check nc-backup-row",children:[h.jsx("input",{type:"checkbox",checked:S.has(E.id),onChange:()=>T(C,E.id)}),h.jsxs("span",{children:[h.jsx("b",{children:E.label||E.id}),h.jsxs("small",{children:[E.id,(R=E.envKeys)!=null&&R.length?` · ${E.envKeys.length} ${y("fleet-backup-env-names")}`:""]})]})]},E.id)}),h.jsx("b",{children:y("fleet-cells")}),e.map(E=>h.jsxs("label",{className:"nc-check nc-backup-row",children:[h.jsx("input",{type:"checkbox",checked:m.has(E.id),onChange:()=>T(p,E.id)}),h.jsxs("span",{children:[h.jsx("b",{children:E.id}),h.jsxs("small",{children:[E.engine," · ",y("fleet-system-prompt")," ",(E.prompt||"").length," ",y("characters")]})]})]},E.id)),!e.length&&!t.length&&h.jsx("div",{className:"nc-empty",children:y("fleet-backup-empty")})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:y("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:!m.size&&!S.size,onClick:Q,children:y("fleet-backup-download")})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"file",accept:"application/json,.json",disabled:i,onChange:E=>H(E.target.files&&E.target.files[0])}),h.jsx("small",{children:y("fleet-backup-import-help")}),!!(_.length||w.length)&&h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{b(E=>E.map(R=>({...R,selected:!0}))),v(E=>E.map(R=>({...R,selected:!!R.engine})))},children:y("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{b(E=>E.map(R=>({...R,selected:!1}))),v(E=>E.map(R=>({...R,selected:!1})))},children:y("select-none")})]}),h.jsxs("div",{className:"nc-backup-list",children:[!!w.length&&h.jsx("b",{children:y("fleet-engines")}),w.map((E,R)=>{var F;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:D=>G(R,{selected:D.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?y("fleet-backup-overwrite"):y("fleet-backup-new"),(F=E.engine.envKeys)!=null&&F.length?` · ${y("fleet-backup-env-values-required")}`:""]})]})]})},E.engine.id)}),!!_.length&&h.jsx("b",{children:y("fleet-cells")}),_.map((E,R)=>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:F=>I(R,{selected:F.target.checked})}),h.jsxs("span",{children:[h.jsx("b",{children:E.cell.id}),h.jsxs("small",{children:[E.exists?y("fleet-backup-overwrite"):y("fleet-backup-new")," · ",y("fleet-system-prompt")," ",E.cell.systemPrompt.length," ",y("characters")]})]})]}),h.jsxs("select",{value:E.engine,onChange:F=>I(R,{engine:F.target.value,selected:!!F.target.value}),children:[h.jsx("option",{value:"",children:y("fleet-backup-engine-missing")}),A.map(([F,D])=>h.jsx("option",{value:F,children:D},F))]})]},E.cell.id))]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:y("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||!q.length&&!Y.length,onClick:()=>o({engineRows:w,cellRows:_}),children:y("fleet-backup-restore")})]})]}),x&&h.jsx("div",{className:"nc-err",children:x})]})}function qk({state:e,setState:t,busy:i,onSave:s,catalog:o}){var _;const l=e.form,c=v=>t({...e,form:{...l,...v}}),d=l.envRows||[],m=[...new Map(o.map(v=>[v.client,v.clientLabel||v.client])).entries()],p=o.filter(v=>v.client===l.client),S=tl(o,l),C=v=>{v&&c({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?y("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"?y("fleet-new-engine"):`${y("edit")} ${l.id}`}),h.jsx("input",{value:l.id,disabled:e.mode!=="new",placeholder:"id",onChange:v=>c({id:v.target.value})}),h.jsx("input",{value:l.label,placeholder:y("label"),onChange:v=>c({label:v.target.value})}),h.jsxs("select",{value:l.kind,disabled:e.mode!=="new",onChange:v=>c({kind:v.target.value}),children:[h.jsx("option",{value:"managed",children:y("fleet-managed")}),h.jsx("option",{value:"custom",children:y("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=>C(o.find(w=>w.client===v.target.value&&w.default)||o.find(w=>w.client===v.target.value)),children:m.map(([v,w])=>h.jsx("option",{value:v,children:w},v))}),h.jsx("select",{value:((_=tl(o,l))==null?void 0:_.id)||"",disabled:e.mode!=="new",onChange:v=>C(o.find(w=>w.id===v.target.value)),children:p.map(v=>h.jsx("option",{value:v.id,children:v.label},v.id))})]}),h.jsx("input",{value:l.managedModel,list:"nc-managed-models",placeholder:y(S!=null&&S.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:v=>c({managedModel:v.target.value})}),h.jsx("datalist",{id:"nc-managed-models",children:[...(S==null?void 0:S.models)||[],...l.modelOptions||[]].filter((v,w,b)=>v&&b.indexOf(v)===w).map(v=>h.jsx("option",{value:v},v))}),S!=null&&S.supportsUnsafe?h.jsxs("select",{value:l.permissionPolicy,onChange:v=>c({permissionPolicy:v.target.value}),children:[h.jsx("option",{value:"standard",children:y("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:y("fleet-unsafe-permissions")})]}):h.jsx("small",{children:y("fleet-standard-permissions")}),(S==null?void 0:S.supportsUnsafe)&&l.permissionPolicy==="unsafe"&&h.jsx("small",{className:"nc-err",children:y("fleet-unsafe-warning")}),(S==null?void 0:S.credentialEnv)&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.envKey,placeholder:y("fleet-api-key-env"),onChange:v=>c({envKey:v.target.value})}),h.jsx("small",{children:y("fleet-custom-secret-help")})]}),l.provider==="custom"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.displayName,placeholder:y("fleet-provider-display"),onChange:v=>c({displayName:v.target.value})}),h.jsx("input",{value:l.baseUrl,placeholder:"https://api.example.com/v1",onChange:v=>c({baseUrl:v.target.value})}),((S==null?void 0:S.protocols)||[]).length>1&&h.jsx("select",{value:l.protocol,onChange:v=>c({protocol:v.target.value}),children:S.protocols.map(v=>h.jsx("option",{value:v,children:v},v))}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:l.envKey,placeholder:y("fleet-api-key-env"),onChange:v=>c({envKey:v.target.value})}),h.jsx("input",{value:l.providerId,placeholder:y("fleet-provider-id"),onChange:v=>c({providerId:v.target.value})})]}),h.jsxs("small",{children:[l.protocol," · ",y("fleet-custom-secret-help")]})]}),h.jsx("small",{children:y("fleet-managed-help")})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.command,placeholder:y("command-path"),onChange:v=>c({command:v.target.value})}),h.jsx("textarea",{value:l.argsText,placeholder:y("args-lines"),onChange:v=>c({argsText:v.target.value})}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:l.rc,onChange:v=>c({rc:v.target.checked})})," remote control"]}),h.jsxs("select",{value:l.promptMode,onChange:v=>c({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=>c({promptFlag:v.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:l.modelFlag,placeholder:"model flag",onChange:v=>c({modelFlag:v.target.value})}),h.jsx("input",{value:l.modelValue,placeholder:"model default",onChange:v=>c({modelValue:v.target.value})})]}),h.jsx("small",{children:y("env-write-only")}),d.map((v,w)=>h.jsxs("div",{className:"nc-fleet-env",children:[h.jsx("input",{value:v.key,disabled:v.configured,placeholder:"ENV_KEY",onChange:b=>{const x=d.slice();x[w]={...v,key:b.target.value},c({envRows:x})}}),h.jsx("input",{type:"password",value:v.value,placeholder:v.configured?"•••••• (unchanged)":"value",onChange:b=>{const x=d.slice();x[w]={...v,value:b.target.value},c({envRows:x})}}),h.jsx("button",{className:"nc-btn danger",onClick:()=>c({envRows:d.filter((b,x)=>x!==w)}),children:"×"})]},`${v.key}-${w}`)),h.jsx("button",{className:"nc-btn ghost",onClick:()=>c({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:y("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:i||!l.id||l.kind==="custom"&&!l.command||l.kind==="managed"&&(S==null?void 0:S.requiresModel)&&!l.managedModel||l.kind==="managed"&&(S==null?void 0:S.credentialEnv)&&!l.envKey||l.kind==="managed"&&l.provider==="custom"&&(!l.displayName||!l.baseUrl||!l.envKey||!l.providerId),onClick:s,children:y("save")})]})]})}function Vk({token:e,route:t,targets:i=[],location:s,setLocation:o,state:l,setState:c,engines:d,busy:m,onSave:p}){const[S,C]=P.useState(null),[_,v]=P.useState(""),w=l.form,b=j=>c({...l,form:{...w,...j}}),x=d.find(j=>j.id===w.engine),N=j=>{var Q,H,I;const T=d.find(G=>G.id===j);b({engine:j,model:((Q=w.models)==null?void 0:Q[j])||((H=T==null?void 0:T.managed)==null?void 0:H.model)||((I=T==null?void 0:T.model)==null?void 0:I.value)||""})},L=async j=>{try{const T=await Nv(e,j,t);C(T),b({cwd:T.path}),v("")}catch(T){v(String(T.message||T))}};return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsx("b",{children:l.mode==="new"?y("fleet-new-cell"):`${y("edit")} ${w.id}`}),l.mode==="new"&&h.jsxs("label",{className:"nc-field",children:[y("location"),h.jsx("span",{className:"nc-req",children:" *"}),h.jsxs("select",{value:s,onChange:j=>{o(j.target.value),b({engine:""})},children:[h.jsx("option",{value:"",children:y("local")}),i.map(j=>h.jsxs("option",{value:j.route.join("/"),disabled:j.status&&j.status!=="up",children:[j.label,j.status&&j.status!=="up"?` · ${y("node-offline")}`:""]},j.route.join("/")))]})]}),h.jsx("input",{value:w.id,disabled:l.mode!=="new",placeholder:"id",onChange:j=>b({id:j.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:w.cwd,placeholder:y("cwd"),onChange:j=>b({cwd:j.target.value})}),h.jsx("button",{className:"nc-btn ghost",onClick:()=>S?C(null):L(w.cwd),children:y("browse")})]}),S&&h.jsxs("div",{className:"nc-fs",children:[h.jsx("div",{className:"nc-fs-path",children:S.path}),h.jsxs("div",{className:"nc-fs-list",children:[S.parent&&h.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>L(S.parent),children:["↑ ",y("fs-parent")]}),(S.dirs||[]).map(j=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>L(`${S.path.replace(/\/$/,"")}/${j}`),children:["📁 ",j]},j))]})]}),_&&h.jsx("div",{className:"nc-err",children:_}),h.jsx("select",{value:w.engine,onChange:j=>N(j.target.value),children:d.map(j=>h.jsx("option",{value:j.id,children:j.label},j.id))}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:!!w.boot,onChange:j=>b({boot:j.target.checked})})," boot"]}),h.jsx("input",{value:w.model||"",list:"nc-cell-models",placeholder:y("fleet-model-override"),onChange:j=>b({model:j.target.value})}),h.jsx("datalist",{id:"nc-cell-models",children:((x==null?void 0:x.availableModels)||[]).map(j=>h.jsx("option",{value:j},j))}),h.jsx("textarea",{value:w.prompt||"",placeholder:"prompt",onChange:j=>b({prompt:j.target.value})}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>c(null),children:y("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:m||!w.id||!w.cwd||!w.engine,onClick:p,children:y("save")})]})]})}function mv({token:e,route:t=[],state:i,setState:s,busy:o,onSave:l}){const[c,d]=P.useState(null),[m,p]=P.useState([]),[S,C]=P.useState(""),_=Array.isArray(t)?t.join("/"):"";P.useEffect(()=>{let N=!0;return Hh(e,_?_.split("/"):[]).then(L=>{N&&(p(L.engines||[]),C(""))}).catch(L=>{N&&(p([]),C(String(L.message||L)))}),()=>{N=!1}},[e,_]);const v=i.form,w=N=>s({...i,form:{...v,...N}}),b=async N=>{try{const L=await Nv(e,N,t);d(L),w({cwd:L.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:[y("import-as-cell")," · ",v.tmuxSession]}),h.jsx("small",{children:y("import-help")}),h.jsx("input",{value:v.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),h.jsx("input",{value:v.id,placeholder:y("name"),onChange:N=>w({id:N.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:v.cwd,placeholder:y("cwd"),onChange:N=>w({cwd:N.target.value})}),h.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>c?d(null):b(v.cwd),children:y("browse")})]}),c&&h.jsxs("div",{className:"nc-fs",children:[h.jsx("div",{className:"nc-fs-path",children:c.path}),h.jsxs("div",{className:"nc-fs-list",children:[c.parent&&h.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>b(c.parent),children:["↑ ",y("fs-parent")]}),(c.dirs||[]).map(N=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>b(`${c.path.replace(/\/$/,"")}/${N}`),children:["📁 ",N]},N))]})]}),h.jsxs("select",{value:v.engine,onChange:N=>w({engine:N.target.value}),children:[h.jsx("option",{value:"",children:y("import-engine-required")}),m.map(N=>h.jsx("option",{value:N.id,children:N.label},N.id))]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:!!v.boot,onChange:N=>w({boot:N.target.checked})})," boot"]}),(i.err||S)&&h.jsx("div",{className:"nc-err",children:i.err||S}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:y("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:o||!v.tmuxSession||!v.engine||!m.length,onClick:l,children:y(x?"import-as-cell":"save")})]})]})}function Yk({token:e,readonly:t,targets:i=[],startNewCell:s=!1,initialLocation:o=""}){const[l,c]=P.useState({engines:[],cells:[],managedCatalog:[]}),[d,m]=P.useState({available:!1,capabilities:[]}),[p,S]=P.useState(null),[C,_]=P.useState(null),[v,w]=P.useState(!1),[b,x]=P.useState(""),[N,L]=P.useState(""),[j,T]=P.useState(o),[Q,H]=P.useState(!1),[I,G]=P.useState(null),[U,q]=P.useState(null),[Y,A]=P.useState(!1),[E,R]=P.useState([]),[F,D]=P.useState(null),[O,z]=P.useState("manage"),ne=P.useRef(!1),K=j?j.split("/"):[],M=P.useCallback(async()=>{try{const te=await dr(e,K);m(te);try{const ve=await Wh(e,K);H(!!ve.readonlyDefault)}catch{H(!1)}if(te.provider==="builtin"&&(te.capabilities||[]).includes("definitions")){const ve=await Hh(e,K),Be=new Map((te.engines||[]).map(Ie=>[Ie.id,Ie]));if(ve.engines=(ve.engines||[]).map(Ie=>{var Fe;return{...Ie,availableModels:((Fe=Be.get(Ie.id))==null?void 0:Fe.models)||[]}}),c(ve),(te.capabilities||[]).includes("credentials"))try{R((await Nw(e,K)).credentials||[])}catch{R([])}else R([])}}catch(te){x(String(te.message||te))}},[e,j]);P.useEffect(()=>{M();const te=setInterval(M,5e3);return()=>clearInterval(te)},[M]);const W=new Set((d.cells||[]).filter(te=>te.active).map(te=>te.cell)),oe=d.provider==="builtin"&&(d.capabilities||[]).includes("edit"),ae=(d.capabilities||[]).includes("restore");P.useEffect(()=>{!s||ne.current||!oe||!l.engines.length||(ne.current=!0,_({mode:"new",form:fv(l.engines[0].id)}))},[s,oe,l.engines]);const se=async te=>{w(!0),x(""),L("");try{await te(),await M()}catch(ve){x(String(ve.message||ve))}w(!1)},le=()=>se(async()=>{const te=p.mode==="new",ve=Uk(p.form,te,l.managedCatalog||[]);!te&&p.form.kind==="custom"&&!p.form.modelFlag&&(ve.model=null),!te&&p.form.kind==="custom"&&p.form.promptMode!=="flag"&&(ve.promptFlag=null);let Be;if(te)Be=await Dw(e,ve,K);else{const Fe=p.original,gt=new Set(p.form.envRows.filter(ke=>!ke.remove).map(ke=>ke.key)),ge=(Fe.envKeys||[]).filter(ke=>!gt.has(ke)),be=Object.fromEntries(p.form.envRows.filter(ke=>!ke.remove&&ke.key&&(!ke.configured||ke.value!=="")).map(ke=>[ke.key,ke.value]));Be=await Mw(e,Fe.id,ve,p.form.kind==="custom"?{set:be,remove:ge}:void 0,K)}S(null),L(y("fleet-saved"));const Ie=(Be==null?void 0:Be.activeCells)||[];if(Ie.length&&window.confirm(y("fleet-restart-confirm").replace("{cells}",Ie.join(", "))))for(const Fe of Ie)await Gs(e,Fe,K)}),_e=()=>se(async()=>{const te=C.mode==="new",ve=C.form,Be={...te?{id:ve.id}:{},cwd:ve.cwd,engine:ve.engine,boot:!!ve.boot};te?(ve.model&&(Be.model=ve.model),ve.prompt&&(Be.prompt=ve.prompt)):(Be.model=ve.model||null,Be.prompt=ve.prompt||null);const Ie=te?await jw(e,Be,K):await Tw(e,C.original.id,Be,K),Fe=te?ve.id:C.original.id;_(null),L(y("fleet-saved")),!te&&(Ie!=null&&Ie.active)&&window.confirm(y("fleet-restart-confirm").replace("{cells}",Fe))&&await Gs(e,Fe,K)}),ce=t||Q,X=te=>E.find(ve=>{var Be;return(Be=ve.engines)==null?void 0:Be.includes(te.id)})||null,Z=()=>se(async()=>{var Be;const te=await Rw(e,F.envKey,F.value,K);R(te.credentials||[]),D(null),L(y("fleet-credential-saved"));const ve=((Be=(te.credentials||[]).find(Ie=>Ie.envKey===F.envKey))==null?void 0:Be.activeCells)||[];if(ve.length&&window.confirm(y("fleet-restart-confirm").replace("{cells}",ve.join(", "))))for(const Ie of ve)await Gs(e,Ie,K)}),je=te=>se(async()=>{if(!window.confirm(y("fleet-credential-remove-confirm").replace("{key}",te.envKey)))return;const ve=await Pw(e,te.envKey,K);R(ve.credentials||[]),L(y("fleet-credential-removed"))}),Me=te=>G({...te,route:Array.isArray(te==null?void 0:te.route)?te.route:K}),ye=async te=>{if(!I)return;const ve=I.cell||I.id,Be=Array.isArray(I.route)?I.route:K;te.action==="up"?await Fh(e,{cell:ve,boot:!!te.boot,...te.engine?{engine:te.engine}:{},...te.model!==void 0?{model:te.model}:{},...te.permissionPolicy?{permissionPolicy:te.permissionPolicy}:{}},Be):await Fa(e,{cell:ve,boot:!!te.boot},Be)},ee=(te,ve)=>{x(""),q({mode:"new",route:Array.isArray(ve)?ve:K,form:{tmuxSession:te.name,id:"",engine:"",cwd:"",boot:!1},err:""})},Ce=()=>se(async()=>{const te=U.form;if(!te.engine){q({...U,err:y("import-engine-required")});return}await Aw(e,{tmuxSession:te.tmuxSession,id:te.id||void 0,engine:te.engine,cwd:te.cwd||void 0,boot:!!te.boot},te.route||K),q(null),L(y("fleet-saved"))}),Te=({engineRows:te=[],cellRows:ve=[]})=>se(async()=>{const Be=te.filter(Ve=>Ve.selected),Ie=Be.map(Ve=>fy(Ve.engine));if(Ie.some(Ve=>!Ve))throw new Error(y("fleet-backup-invalid-engine"));const Fe=Be.filter(Ve=>Ve.exists).map(Ve=>Ve.engine.id);if(Fe.length&&!window.confirm(y("fleet-backup-confirm-engine-overwrite").replace("{engines}",Fe.join(", "))))return;const gt=[...new Set([...l.engines.map(Ve=>Ve.id),...Ie.map(Ve=>Ve.id)])],ge=[];for(const Ve of ve.filter(de=>de.selected)){const de=Fk(Ve.cell,Ve.engine,gt);if(!de)throw new Error(`${Ve.cell.id}: ${y("fleet-backup-engine-missing")}`);ge.push(de)}const be=ve.filter(Ve=>Ve.selected&&Ve.exists).map(Ve=>Ve.cell.id);if(be.length&&!window.confirm(y("fleet-backup-confirm-overwrite").replace("{cells}",be.join(", "))))return;const ke=Ie.length?await Iw(e,Ie,Fe.length>0,K):{needsRestart:[]},Xe=ge.length?await Bw(e,ge,K):{needsRestart:[]},rt=[...new Set([...ke.needsRestart||[],...Xe.needsRestart||[]])];A(!1),L(`${y("fleet-backup-restored").replace("{n}",String(ge.length))}${Ie.length?` · ${Ie.length} ${y("fleet-engines").toLowerCase()}`:""}${rt.length?` · ${y("fleet-backup-needs-restart").replace("{cells}",rt.join(", "))}`:""}`)}),xe=h.jsxs("label",{className:"nc-field",children:[y("location"),h.jsxs("select",{value:j,onChange:te=>{T(te.target.value),S(null),_(null),x(""),L(""),H(!1),m({available:!1,capabilities:[]}),c({engines:[],cells:[],managedCatalog:[]}),R([]),D(null)},children:[h.jsx("option",{value:"",children:y("local")}),i.map(te=>h.jsxs("option",{value:te.route.join("/"),disabled:te.status&&te.status!=="up",children:[te.label,te.status&&te.status!=="up"?` · ${y("node-offline")}`:""]},te.route.join("/")))]})]}),qe=h.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":y("tab-fleet"),children:[h.jsx("button",{type:"button",role:"tab","aria-selected":O==="manage",className:`nc-set-tabbtn${O==="manage"?" on":""}`,onClick:()=>z("manage"),children:y("fleet-manage-location")}),h.jsx("button",{type:"button",role:"tab","aria-selected":O==="overview",className:`nc-set-tabbtn${O==="overview"?" on":""}`,onClick:()=>z("overview"),children:y("fleet-network-overview")})]});return oe?h.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[qe,O==="overview"?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:y("fleet-overview-help")}),h.jsx(pv,{token:e,targets:i,readonly:t,onPower:Me,onImport:ee})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:y("fleet-manage-help")}),xe,h.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:ce||v,onClick:()=>{x(""),A(!0)},children:y("fleet-backup")}),h.jsx("small",{children:y("fleet-backup-help")})]}),h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:y("fleet-cells")}),h.jsx("span",{className:"nc-fleet-head-actions",children:h.jsxs("button",{className:"nc-btn primary",disabled:ce||v||!l.engines.length,onClick:()=>{var te;x(""),_({mode:"new",form:fv((te=l.engines[0])==null?void 0:te.id)})},children:["+ ",y("add")]})})]}),l.cells.map(te=>{const ve=W.has(te.id),Be=d.capabilities||[];return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:te.id}),h.jsxs("small",{children:[te.engine," · ",te.cwd,ve?` · ${y("service-active")}`:` · ${y("cell-off")}`]})]}),h.jsxs("span",{children:[ve&&Be.includes("down")&&h.jsx("button",{className:"nc-btn ghost",disabled:ce||v,onClick:()=>se(()=>Fa(e,{cell:te.id},K)),children:y("stop")}),!ve&&Be.includes("up")&&h.jsx("button",{className:"nc-btn primary",disabled:ce||v,onClick:()=>Me({cell:te.id,id:te.id,engine:te.engine,model:te.model,models:te.models,permissionPolicies:te.permissionPolicies,active:!1,boot:te.boot}),children:y("start")}),ve&&Be.includes("restart")&&h.jsx("button",{className:"nc-btn ghost",disabled:ce||v,onClick:()=>se(()=>Gs(e,te.id,K)),children:y("restart")}),h.jsx("button",{className:"nc-btn ghost",disabled:ce||v,onClick:()=>{x(""),_({mode:"edit",original:te,form:{...te}})},children:y("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:ce||v,onClick:()=>se(async()=>{window.confirm(y("fleet-remove-cell").replace("{id}",te.id))&&await kv(e,te.id,!0,K)}),children:"×"})]})]},te.id)}),h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:y("fleet-engines")}),h.jsxs("button",{className:"nc-btn primary",disabled:ce||v,onClick:()=>{x(""),S({mode:"new",form:Hk()})},children:["+ ",y("add")]})]}),l.engines.map(te=>{var Be,Ie;const ve=X(te);return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:te.label}),h.jsx("small",{children:te.managed?`${te.id} · ${te.managed.client} / ${te.managed.provider} · ${(Be=te.managedInfo)!=null&&Be.configured?y("fleet-ready"):((Ie=te.managedInfo)==null?void 0:Ie.reason)||y("fleet-not-ready")}`:`${te.id} · ${te.command}`}),ve&&h.jsxs("small",{children:[ve.envKey," · ",y(`fleet-credential-source-${ve.source||"missing"}`)]})]}),h.jsxs("span",{children:[ve&&h.jsx("button",{className:"nc-btn ghost",disabled:ce||v,onClick:()=>{x(""),D({envKey:ve.envKey,value:""})},children:ve.configured?y("fleet-credential-change"):y("fleet-credential-set")}),(ve==null?void 0:ve.source)==="local"&&h.jsx("button",{className:"nc-btn danger",disabled:ce||v,onClick:()=>je(ve),children:y("fleet-credential-forget")}),h.jsx("button",{className:"nc-btn ghost",disabled:ce||v,onClick:()=>{x(""),S({mode:"edit",original:te,form:Wk(te)})},children:y("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:ce||v,onClick:()=>se(async()=>{window.confirm(y("fleet-remove-engine").replace("{id}",te.id))&&await Lw(e,te.id,K)}),children:"×"})]})]},te.id)})]}),p&&h.jsx(Wr,{onClose:()=>S(null),label:y("fleet-new-engine"),error:b,children:h.jsx(qk,{state:p,setState:S,busy:v,onSave:le,catalog:l.managedCatalog||[]})}),C&&h.jsx(Wr,{onClose:()=>_(null),label:y("fleet-new-cell"),error:b,children:h.jsx(Vk,{token:e,route:K,targets:i,location:j,setLocation:T,state:C,setState:_,engines:l.engines,busy:v,onSave:_e})}),N&&h.jsx("div",{className:"nc-set-note",children:N}),b&&h.jsx("div",{className:"nc-err",children:b}),Y&&h.jsx(Wr,{onClose:()=>A(!1),label:y("fleet-backup"),error:b,children:h.jsx(Kk,{cells:l.cells,engines:l.engines,busy:v,canRestore:ae,onRestore:Te,onClose:()=>A(!1)})}),F&&h.jsx(Wr,{onClose:()=>D(null),label:y("fleet-credential-title"),error:b,children:h.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[h.jsx("b",{children:y("fleet-credential-title")}),h.jsx("small",{children:y("fleet-credential-help")}),h.jsxs("label",{className:"nc-field",children:[F.envKey,h.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:F.value,onChange:te=>D({...F,value:te.target.value})})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>D(null),children:y("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:v||!F.value,onClick:Z,children:y("save")})]})]})}),U&&h.jsx(Wr,{onClose:()=>q(null),label:y("import-as-cell"),error:b,children:h.jsx(mv,{token:e,route:U.route||K,state:U,setState:q,busy:v,onSave:Ce})}),I&&h.jsx(Ha,{cell:I,token:e,route:Array.isArray(I.route)?I.route:K,onConfirm:async te=>{try{await ye(te)}finally{await M()}},onClose:()=>G(null)})]}):h.jsxs("div",{className:"nc-set-tab",children:[qe,O==="overview"?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:y("fleet-overview-help")}),h.jsx(pv,{token:e,targets:i,readonly:t,onPower:Me,onImport:ee})]}):h.jsxs(h.Fragment,{children:[xe,h.jsx("div",{className:"nc-set-info",children:y("fleet-editor-unavailable")})]}),b&&h.jsx("div",{className:"nc-err",children:b}),U&&h.jsx(Wr,{onClose:()=>q(null),label:y("import-as-cell"),error:b,children:h.jsx(mv,{token:e,route:U.route||K,state:U,setState:q,busy:v,onSave:Ce})}),I&&h.jsx(Ha,{cell:I,token:e,route:Array.isArray(I.route)?I.route:K,onConfirm:async te=>{try{await ye(te)}finally{await M()}},onClose:()=>G(null)})]})}function Xk({text:e}){const[t,i]=P.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!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(et,{name:"copy",size:14})," ",y(t?"copied":"copy")]})]})}function Gk({value:e}){const[t,i]=P.useState("");return P.useEffect(()=>{let s=!0;return ek.toDataURL(e,{margin:1,width:220}).then(o=>{s&&i(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?h.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function Qk({token:e,nodes:t,settings:i,readonly:s,refresh:o}){const[l,c]=P.useState(null),[d,m]=P.useState(null),[p,S]=P.useState({}),[C,_]=P.useState(null),[v,w]=P.useState({ssh:"",sshPort:"",name:""}),[b,x]=P.useState(""),[N,L]=P.useState(""),[j,T]=P.useState(""),[Q,H]=P.useState(!1),I=Date.now(),G=i&&i.deviceName||"",U=(t||[]).filter(D=>D&&D.direction==="outbound"&&D.name&&D.ssh),q=U.find(D=>D.name===b)||U[0]||null,Y=U.find(D=>D.name===N)||U[0]||null,A=Y?ov(Y.tunnel,I):null,E=async(D,O)=>{c(null),m(`${D}:${O}`);try{const z=await Uh(e,D,O);O==="test"&&S(ne=>({...ne,[D]:z})),await o()}catch(z){c(`${D}: ${String(z.message||z)}`)}m(null)},R=async D=>{if(window.confirm(y("node-remove-confirm").replace("{name}",D))){c(null),m(`${D}:remove`);try{await $w(e,D),await o()}catch(O){c(`${D}: ${String(O.message||O)}`)}m(null)}},F=async()=>{if(c(null),q){const z=sv({name:q.name,ssh:q.ssh,sshPort:q.sshPort||""});if(!z.ok){c(y(z.error));return}m("invite");try{_(await am(e,{ssh:z.value.ssh,...z.value.sshPort?{sshPort:z.value.sshPort}:{}},[q.name]))}catch(ne){c(String(ne.message||ne))}m(null);return}const D=Xr(v.name||j||G||"NexusCrew"),O=sv({name:D,ssh:v.ssh,sshPort:v.sshPort});if(!O.ok){c(y(O.error));return}m("invite");try{_(await am(e,{...j||G?{label:j||G}:{},name:D,ssh:O.value.ssh,...O.value.sshPort?{sshPort:O.value.sshPort}:{}}))}catch(z){c(String(z.message||z))}m(null)};return h.jsxs("div",{className:"nc-set-tab",children:[h.jsx(oy,{token:e,deviceDefault:G,readonly:s,onSuccess:o}),Y&&h.jsxs("div",{className:"nc-set-form nc-local-share",children:[h.jsx("div",{className:"nc-sheet-label",children:y("share-local-heading")}),U.length>1&&h.jsxs("label",{className:"nc-field",children:[y("share-local-hub"),h.jsx("select",{value:Y.name,disabled:s||!!d,onChange:D=>L(D.target.value),children:U.map(D=>h.jsx("option",{value:D.name,children:D.label||D.name},D.name))})]}),h.jsxs("label",{className:"nc-check nc-node-share",children:[h.jsx("input",{type:"checkbox",checked:Y.shared===!0,disabled:s||!!d||!(A!=null&&A.up)&&!Y.shared,onChange:async D=>{c(null),m(`${Y.name}:share`);try{await Ww(e,Y.name,D.target.checked),await o()}catch(O){c(`${Y.name}: ${String(O.message||O)}`)}m(null)}}),h.jsxs("span",{children:[h.jsx("b",{children:y("share-local-through").replace("{device}",G||y("local")).replace("{hub}",Y.label||Y.name)}),h.jsx("small",{children:y(Y.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),h.jsx("div",{className:`nc-set-test${Y.shared&&(A!=null&&A.up)?" ok":""}`,children:Y.shared?y("share-local-active"):y("share-local-private")})]}),(t||[]).length===0&&h.jsx("div",{className:"nc-empty",children:y("no-nodes")}),(t||[]).map(D=>{var ne,K,M,W,oe;const O=ov(D.tunnel,I),z=p[D.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 ${O.up?"on":""}`}),h.jsx("b",{children:D.label||D.name}),h.jsxs("small",{children:[D.name,D.direction==="outbound"?` · SSH ${D.ssh||""}`:` · ${y("node-connected-client")}`,(ne=D.tunnel)!=null&&ne.transport?` · ${D.tunnel.transport} ${y("transport-used")}`:""]}),h.jsxs("span",{className:`nc-set-tunnel${O.up?" up":""}`,children:[y(O.label),O.since?` · ${O.since}`:""]})]}),D.direction==="inbound"&&h.jsx("div",{className:"nc-set-info",children:y(D.shared?"peer-shared":"peer-private")}),D.direction==="inbound"&&D.shared&&h.jsxs(h.Fragment,{children:[h.jsxs("select",{value:D.visibility||"network",disabled:s||!!d,onChange:async ae=>{m(`${D.name}:visibility`);try{await lm(e,D.name,ae.target.value),await o()}catch(se){c(String(se.message||se))}m(null)},children:[h.jsx("option",{value:"network",children:y("visibility-network")}),h.jsx("option",{value:"relay-only",children:y("visibility-relay")}),h.jsx("option",{value:"selected",children:y("visibility-selected")})]}),D.visibility==="selected"&&h.jsx("div",{className:"nc-set-row",children:(t||[]).filter(ae=>ae.name!==D.name&&ae.nodeId).map(ae=>{const se=(D.selected||[]).includes(ae.nodeId);return h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:se,disabled:s||!!d,onChange:async le=>{const _e=le.target.checked?[...D.selected||[],ae.nodeId]:(D.selected||[]).filter(ce=>ce!==ae.nodeId);m(`${D.name}:visibility`);try{await lm(e,D.name,"selected",_e),await o()}catch(ce){c(String(ce.message||ce))}m(null)}})," ",ae.label||ae.name]},ae.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 ae=window.prompt(y("node-display-label"),D.label||D.name);if(ae!=null){if(!jh(ae)){c(y("err-label"));return}m(`${D.name}:label`);try{await Hw(e,D.name,ae),await o()}catch(se){c(String(se.message||se))}m(null)}},children:y("edit")}),((K=D.health)==null?void 0:K.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(D.name,"test"),children:y("node-test")}),((M=D.health)==null?void 0:M.managed)!==!1&&(O.up?h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(D.name,"down"),children:y("tunnel-stop")}):h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(D.name,"up"),children:y("tunnel-start")})),((W=D.health)==null?void 0:W.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(D.name,"restart"),children:y("tunnel-restart")}),h.jsx("button",{type:"button",className:"nc-btn danger",disabled:s||!!d,title:y(s?"settings-readonly":"terminate"),onClick:()=>R(D.name),children:h.jsx(et,{name:"trash",size:14})})]}),((oe=D.health)==null?void 0:oe.detail)&&h.jsx("div",{className:`nc-set-test${D.health.status==="healthy"?" ok":D.health.status==="passive"?"":" ko"}`,children:D.health.detail}),z&&h.jsxs("div",{className:`nc-set-test${z.ok?" ok":" ko"}`,children:[z.result,z.detail?` — ${z.detail}`:""]})]},D.name)}),h.jsxs("div",{className:"nc-set-form",children:[h.jsx("div",{className:"nc-sheet-label",children:y("invite-node")}),h.jsx("small",{className:"nc-set-hint",children:y(q?"invite-network-hint":"invite-v2-hint")}),q?h.jsxs(h.Fragment,{children:[U.length>1&&h.jsxs("label",{className:"nc-field",children:[y("invite-network-label"),h.jsx("select",{value:q.name,disabled:s||!!d,onChange:D=>{x(D.target.value),_(null)},children:U.map(D=>h.jsx("option",{value:D.name,children:D.label||D.name},D.name))})]}),h.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[y("invite-network-via"),": ",h.jsx("b",{children:q.label||q.name})," · ",q.ssh,q.sshPort?`:${q.sshPort}`:""]}),h.jsx("small",{className:"nc-set-hint",children:y("invite-network-route")})]}):h.jsxs("label",{className:"nc-field",children:[y("invite-endpoint-label"),h.jsx("input",{placeholder:"user@host",value:v.ssh,disabled:s,onChange:D=>w({...v,ssh:D.target.value})}),h.jsx("small",{className:"nc-set-hint",children:y("invite-endpoint-needed")})]}),!q&&Q&&h.jsxs("div",{className:"nc-invite-advanced",children:[h.jsxs("label",{className:"nc-field",children:[y("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:"22",value:v.sshPort,disabled:s,onChange:D=>w({...v,sshPort:D.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),h.jsxs("label",{className:"nc-field",children:[y("device-name-label"),h.jsx("input",{placeholder:G||"NexusCrew",value:j,disabled:s,onChange:D=>T(D.target.value)}),h.jsx("small",{className:"nc-set-hint",children:y("device-name-hint")})]}),h.jsxs("label",{className:"nc-field",children:[y("node-name-label"),h.jsx("input",{placeholder:Xr(j||G||y("node-name-ph")),value:v.name,disabled:s,onChange:D=>w({...v,name:D.target.value?Xr(D.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||!q&&!v.ssh.trim(),onClick:F,children:y("create-pairing-link")}),!q&&h.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>H(D=>!D),children:[Q?"▾":"▸"," ",y("pair-advanced")]})]}),C&&h.jsxs(h.Fragment,{children:[h.jsx(Gk,{value:C.pairingUrl}),h.jsx(Xk,{text:C.pairingUrl}),h.jsx("div",{className:"nc-set-info",children:y("invite-next-steps")})]})]}),l&&h.jsx("div",{className:"nc-err",children:l})]})}function Jk({token:e,readonly:t}){const[i,s]=P.useState("idle"),[o,l]=P.useState(!1),[c,d]=P.useState(null);P.useEffect(()=>{let p=!1;return Ck().then(S=>{p||s(S)}),()=>{p=!0}},[]);const m=async()=>{d(null),l(!0);try{i==="subscribed"?(await kk(e),s("idle")):(await xk(e),s("subscribed"))}catch(p){const S=String(p.message||p);S==="push-denied"?(s("denied"),d(y("push-denied"))):S==="push-unsupported"?(s("unsupported"),d(y("push-unsupported"))):d(S)}l(!1)};return i==="unsupported"?h.jsx("div",{className:"nc-set-info",children:y("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||i==="denied",title:t?y("settings-readonly"):"",onClick:m,children:y(i==="subscribed"?"push-disable":"push-enable")}),h.jsx("span",{className:"nc-set-info",children:y(i==="subscribed"?"push-on":i==="denied"?"push-denied":"push-off")})]}),c&&h.jsx("div",{className:"nc-err",children:c})]})}function Zk({token:e,settings:t,readonly:i,refresh:s}){const[o,l]=P.useState(null),[c,d]=P.useState(null),[m,p]=P.useState(!1),[S,C]=P.useState(!1),[_,v]=P.useState(null),[w,b]=P.useState(!0);P.useEffect(()=>{v(t&&t.update||null),b(!t||t.autoUpdate!==!1)},[t]);const x=async()=>{l(null),d(null),C(!0);try{const I=await zw(e);d(I.note||"ok"),p(!1)}catch(I){l(String(I.message||I))}C(!1)},N=async()=>{l(null),d(null),C(!0);try{const I=await Uw(e);d(`${I.note||"ok"}${I.target?` (${I.target})`:""}`)}catch(I){l(String(I.message||I))}C(!1)},L=async I=>{l(null),d(null),C(!0);try{await Mv(e,{autoUpdate:I}),b(I),s&&await s()}catch(G){l(String(G.message||G))}C(!1)},j=async()=>{l(null),d(null),C(!0);try{v(await Kw(e))}catch(I){l(String(I.message||I))}C(!1)},T=async()=>{l(null),d(null),C(!0);try{const I=await qw(e);v(I),d(y("npm-update-restarting"))}catch(I){l(String(I.message||I))}C(!1)},Q=()=>{window.confirm(y("composer-clear-confirm"))&&(l(null),ax()?(window.dispatchEvent(new Event(Rh)),d(y("composer-clear-done"))):l(y("composer-clear-failed")))},H=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",{}),H&&H.installed?y("service-installed"):y("service-missing"),H&&H.installed?` · ${H.active?y("service-active"):y("service-inactive")}`:"",H?` · boot ${H.boot?"on":"off"}`:""]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||S,title:i?y("settings-readonly"):"",onClick:()=>{l(null),d(null),p(!0)},children:y("token-rotate")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||S,title:i?y("settings-readonly"):"",onClick:N,children:y("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:w,disabled:i||S||_&&!_.supported,onChange:I=>L(I.target.checked)}),h.jsxs("span",{children:[h.jsx("b",{children:y("npm-auto-update")}),h.jsx("small",{children:y("npm-auto-update-help")})]})]}),_&&h.jsxs("div",{className:"nc-set-info",children:[y("npm-update-current")," v",_.current,_.latest?` · ${y("npm-update-latest")} v${_.latest}`:""," · ",y(`npm-update-${_.supported?_.phase:"unsupported"}`)]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||S||!_||!_.supported,onClick:j,children:y("npm-update-check")}),_&&_.available&&h.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||S||_.phase==="installing",onClick:T,children:y("npm-update-install")})]}),_&&_.lastError&&h.jsx("div",{className:"nc-err",children:_.lastError})]}),h.jsx(Jk,{token:e,readonly:i}),h.jsxs("div",{className:"nc-set-form",children:[h.jsx("div",{className:"nc-sheet-label",children:y("composer-clear-data")}),h.jsx("small",{className:"nc-set-hint",children:y("composer-clear-data-help")}),h.jsx("div",{className:"nc-set-row",children:h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:Q,children:y("composer-clear-data")})})]}),m&&h.jsxs("div",{className:"nc-set-confirm",children:[h.jsx("div",{children:y("token-rotate-explain")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:S,onClick:()=>p(!1),children:y("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:S,onClick:x,children:y("confirm")})]})]}),c&&h.jsx("div",{className:"nc-set-note",children:c}),o&&h.jsx("div",{className:"nc-err",children:o})]})}function eE({token:e,onClose:t,initialTab:i="nodes",initialLocation:s="",startNewCell:o=!1}){Si();const[l,c]=P.useState(i),[d,m]=P.useState(null),[p,S]=P.useState([]),[C,_]=P.useState(!1),[v,w]=P.useState(null),b=qh(e),x=P.useCallback(async()=>{try{const N=await Rv(e);m(N),w(null)}catch(N){w(String(N.message||N))}try{const N=await Pv(e);S(N.nodes||[])}catch(N){w(String(N.message||N))}},[e]);return P.useEffect(()=>{x();const N=setInterval(x,5e3);return()=>clearInterval(N)},[x]),P.useEffect(()=>{let N=!1;return zt("/api/config",e).then(L=>L.json()).then(L=>{N||_(!!L.readonlyDefault)}).catch(()=>{}),()=>{N=!0}},[e]),h.jsx("div",{className:"nc-set-overlay",onClick:t,children:h.jsxs("div",{className:"nc-set-panel",onClick:N=>N.stopPropagation(),children:[h.jsxs("div",{className:"nc-set-head",children:[h.jsx(et,{name:"gear",size:18}),h.jsx("b",{children:y("settings")}),h.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:y("close"),children:h.jsx(et,{name:"x",size:18})})]}),C&&h.jsx("div",{className:"nc-set-readonly",children:y("settings-readonly")}),v&&h.jsx("div",{className:"nc-err",children:v}),h.jsx("div",{className:"nc-set-tabs",children:["nodes","fleet","system"].map(N=>h.jsx("button",{type:"button",className:`nc-set-tabbtn${l===N?" on":""}`,onClick:()=>c(N),children:y(`tab-${N}`)},N))}),h.jsxs("div",{className:"nc-set-body",children:[l==="nodes"&&h.jsx(Qk,{token:e,nodes:p,settings:d,readonly:C,refresh:x}),l==="fleet"&&h.jsx(Yk,{token:e,readonly:C,startNewCell:o,initialLocation:s,targets:b.map(N=>({route:N.route,label:N.label||N.name,status:N.status}))}),l==="system"&&h.jsx(Zk,{token:e,settings:d,readonly:C,refresh:x})]})]})})}function tE({token:e,initialPair:t,onPairDone:i,onDone:s}){Si();const[o,l]=P.useState(t?"pair":"welcome"),[c,d]=P.useState(!1),[m,p]=P.useState(null),S=async()=>{d(!0),p(null);try{await Mv(e,{wizardDone:!0}),i&&i(),s()}catch(C){p(String(C.message||C)),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:y("wizard-title")}),h.jsx("small",{children:y("hydra-simple")})]}),o==="welcome"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:y("local-ready")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:c,onClick:S,children:y("local-only")}),h.jsx("button",{className:"nc-btn primary",disabled:c,onClick:()=>l("pair"),children:y("add-node")})]})]}),o==="pair"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx(oy,{token:e,initial:t||"",autoStart:!!t,onBusyChange:d,onSuccess:async()=>{i&&i(),l("done")}}),h.jsx("div",{className:"nc-sheet-actions",children:h.jsx("button",{className:"nc-btn ghost",disabled:c,onClick:()=>{i&&i(),l("welcome")},children:y("back")})})]}),o==="done"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:y("node-connected")}),h.jsx("div",{className:"nc-sheet-actions",children:h.jsx("button",{className:"nc-btn primary",disabled:c,onClick:S,children:y("finish")})})]}),m&&h.jsx("div",{className:"nc-err",children:m})]})})}function iE(e,t){if(typeof EventSource>"u"||!e)return()=>{};const i=new EventSource(`/api/events?token=${encodeURIComponent(e)}`);return i.onmessage=s=>{try{const o=JSON.parse(s.data);o&&typeof o=="object"&&typeof o.type=="string"&&t(o)}catch{}},()=>{try{i.close()}catch{}}}const nE=6e3,rE=12e3;function sE({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:y("close"),children:h.jsx(et,{name:"x",size:14})})]})}function oE({ask:e,token:t,onAnswered:i}){const[s,o]=P.useState(""),[l,c]=P.useState(!1),[d,m]=P.useState(null),p=async S=>{const C=String(S||"").trim();if(!(!C||l)){m(null),c(!0);try{await Yw(t,e.id,C),i(e.id)}catch(_){m(String(_.message||_))}c(!1)}};return h.jsxs("div",{className:"nc-ask-card",children:[h.jsxs("div",{className:"nc-ask-head",children:[h.jsx("span",{className:"nc-ntf-from",children:e.session}),h.jsxs("code",{className:"nc-ask-id",children:["#",e.id]})]}),h.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&h.jsx("div",{className:"nc-ask-opts",children:e.options.map(S=>h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:l,onClick:()=>p(S),children:S},S))}),h.jsxs("div",{className:"nc-ask-reply",children:[h.jsx("textarea",{rows:2,placeholder:y("ask-reply-ph"),value:s,disabled:l,onChange:S=>o(S.target.value)}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:l||!s.trim(),onClick:()=>p(s),children:y("send")})]}),d&&h.jsx("div",{className:"nc-err",children:d})]})}function aE({token:e}){Si();const[t,i]=P.useState([]),[s,o]=P.useState([]),[l,c]=P.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),d=P.useRef(0),m=P.useCallback(C=>{i(_=>_.filter(v=>v.key!==C))},[]),p=P.useCallback(C=>{const _=`t${d.current+=1}`;i(v=>[...v.slice(-3),{...C,key:_}]),setTimeout(()=>m(_),C.urgency==="high"?rE:nE)},[m]);P.useEffect(()=>{if(!e)return;let C=!1;Vw(e).then(v=>{C||o(v.asks||[])}).catch(()=>{});const _=iE(e,v=>{v.type==="notify"?p(v):v.type==="ask"&&v.ask&&v.ask.id?o(w=>w.some(b=>b.id===v.ask.id)?w:[...w,v.ask]):v.type==="ask-answered"&&v.id&&o(w=>w.filter(b=>b.id!==v.id))});return()=>{C=!0,_()}},[e,p]);const S=C=>o(_=>_.filter(v=>v.id!==C));return h.jsxs(h.Fragment,{children:[t.length>0&&h.jsx("div",{className:"nc-ntf-toasts",children:t.map(C=>h.jsx(sE,{n:C,onClose:()=>m(C.key)},C.key))}),s.length>0&&!l&&h.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>c(!0),title:y("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:y("asks-title")}),h.jsx("span",{className:"nc-ask-count",children:s.length}),h.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>c(!1),title:y("close"),children:h.jsx(et,{name:"x",size:16})})]}),h.jsx("div",{className:"nc-ask-panel-body",children:s.map(C=>h.jsx(oE,{ask:C,token:e,onAnswered:S},C.id))})]})]})}const Fu=e=>Gi(lr(e)).length===0,Hu=e=>Array.isArray(e)?e.join("/"):"";function lE(e){const t=new Set,i=[];for(const s of Array.isArray(e)?e:[])!s||!Mi.test(String(s.instanceId||""))||!Array.isArray(s.route)||!s.route.length||t.has(s.instanceId)||(t.add(s.instanceId),i.push({instanceId:s.instanceId,route:[...s.route],label:String(s.label||s.name||s.route.join(" › ")),status:s.status||"offline"}));return i.sort((s,o)=>s.label.localeCompare(o.label))}function Xs(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function ir(e,t,i,s=!1,o=!0){const l=t.instanceId;return{...e,id:Yr(s?null:l,e.name),ownerId:l,ownerRoute:s?[]:[...t.route],ownerLabel:s?"Local":t.label,local:s,available:o,ownerTopology:Array.isArray(i)?i:[],layout:Dh(e.layout,l,i)}}function cE(e,t,i,s,o=[]){const[l,c]=P.useState([]),[d,m]=P.useState(!1),[p,S]=P.useState("idle"),[C,_]=P.useState(""),[v,w]=P.useState(""),b=P.useRef([]),x=P.useRef([]),N=P.useRef(""),L=P.useRef(t),j=P.useRef(i),T=P.useRef(!1),Q=P.useRef(!0),H=P.useRef(""),I=P.useMemo(()=>lE(o),[o]),G=I.map(K=>`${K.instanceId}:${Hu(K.route)}:${K.status}:${K.label}`).join("|");x.current=I,j.current=i,L.current=t,b.current=l;const U=P.useCallback(K=>Mh(K.layout,N.current,x.current),[]),q=P.useCallback((K,M=!0,W=L.current)=>{const oe=Ng(K,Ma()),ae=b.current.some(le=>le.id===W);b.current=oe,c(oe);const se=oe.find(le=>le.id===W);if(M&&se){Q.current=!0;const le=U(se);s(le),se.local&&Px(se.name,le)}else ae&&!se&&(Q.current=!0,s(Vr()),_("deck non più condiviso dal nodo owner"));kx(oe.filter(le=>le.local).map(le=>le.name))},[s,U]),Y=P.useCallback(async K=>{let M=await ba(e);const W=M.decks.find(oe=>oe.name==="main");if(M.decks.length===1&&W&&W.revision===0&&Fu(W.layout)){const oe=xx(),ae=lr(Lh("main")||Vr());if(!Fu(ae)){const se=Dh(ae,K,[]);M.decks[0]=await Ca(e,"main",se,0,[])}for(const se of oe.filter(le=>le!=="main"))try{let le=await cm(e,se,[]);const _e=lr(Lh(se)||Vr());Fu(_e)||(le=await Ca(e,se,Dh(_e,K,[]),le.revision,[]))}catch{}M=await ba(e)}return M},[e]),A=P.useCallback(async({migrate:K=!1}={})=>{const M=await Wh(e,[]),W=Mi.test(String(M.instanceId||""))?M.instanceId:"";if(!W)throw new Error("instanceId locale non disponibile");N.current=W,w(W);const[oe,ae]=await Promise.all([K?Y(W):ba(e),om(e,[]).catch(()=>({nodes:[]}))]),se={instanceId:W,route:[],label:"Local"},le=oe.decks.map(ce=>ir(ce,se,ae.nodes,!0,!0)),_e=b.current;return await Promise.all(x.current.map(async ce=>{if(ce.status!=="up"){le.push(..._e.filter(X=>!X.local&&X.ownerId===ce.instanceId).map(X=>({...X,ownerRoute:[...ce.route],ownerLabel:ce.label,available:!1})));return}try{const[X,Z]=await Promise.all([ba(e,ce.route),om(e,ce.route).catch(()=>({nodes:[]}))]);le.push(...X.decks.map(je=>ir(je,ce,Z.nodes,!1,!0)))}catch{le.push(..._e.filter(Z=>!Z.local&&Z.ownerId===ce.instanceId).map(Z=>({...Z,ownerRoute:[...ce.route],ownerLabel:ce.label,available:!1})))}})),le.sort((ce,X)=>ce.local===X.local?ce.ownerLabel.localeCompare(X.ownerLabel)||(ce.name==="main"?-1:X.name==="main"?1:ce.name.localeCompare(X.name)):ce.local?-1:1),le},[e,Y,G]);P.useEffect(()=>{if(!e)return;let K=!1;const M=H.current!==e;return H.current=e,A({migrate:M}).then(W=>{if(K)return;const oe=b.current.find(le=>le.id===L.current),ae=W.find(le=>le.id===L.current),se=ae&&(!oe||ae.revision>oe.revision||oe.available!==ae.available||Hu(oe.ownerRoute)!==Hu(ae.ownerRoute));q(W,M||!!se&&!T.current),m(!0),ae&&_("")}).catch(W=>{K||(m(!0),_(String(W.message||W)))}),()=>{K=!0}},[q,A,G,e]);const E=P.useCallback(async(K=L.current)=>{if(!d||!T.current)return!0;const M=b.current.find(W=>W.id===K);if(!M)return _(`deck inesistente: ${K}`),!1;if(M.available===!1)return _(`nodo owner offline: ${M.ownerLabel}`),!1;S("saving");try{const W=kg(lr(j.current),M.ownerId,M.ownerTopology),oe=await Ca(e,M.name,W,M.revision,M.ownerRoute),ae=ir(oe,Xs(M),M.ownerTopology,M.local,!0);return q(b.current.map(se=>se.id===K?ae:se),!1),T.current=!1,S("saved"),_(""),setTimeout(()=>S("idle"),1500),!0}catch(W){if(S("error"),_(String(W.message||W)),W.status===409&&W.data&&W.data.current){const oe=b.current.find(se=>se.id===K),ae=ir(W.data.current,Xs(oe),oe.ownerTopology,oe.local,!0);q(b.current.map(se=>se.id===K?ae:se),!1)}return!1}},[d,e,q]);return P.useEffect(()=>{if(!d)return;if(Q.current){Q.current=!1;return}T.current=!0,S("saving");const K=setTimeout(E,650);return()=>clearTimeout(K)},[i,d,E]),P.useEffect(()=>{if(!d)return;const K=setInterval(async()=>{try{const M=await A(),W=b.current.find(se=>se.id===L.current),oe=M.find(se=>se.id===L.current),ae=oe&&(!W||oe.revision>W.revision||W.available!==oe.available);q(M,ae&&!T.current)}catch{}},5e3);return()=>clearInterval(K)},[d,A,q]),{decks:l,records:l,localNodeId:v,ready:d,saveState:p,error:C,setError:_,saveNow:E,select:async K=>{if(T.current&&!await E(L.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const M=b.current.find(W=>W.id===K);if(!M)throw new Error(`deck inesistente: ${K}`);return T.current=!1,Q.current=!0,U(M)},add:async(K,M=null)=>{const W=M===un?b.current.find(se=>se.local):M?b.current.find(se=>se.ownerId===M):null;if(!W||W.available===!1)throw new Error("nodo owner non disponibile");const oe=await cm(e,K,W.ownerRoute),ae=ir(oe,Xs(W),W.ownerTopology,W.local,!0);return q([...b.current,ae],!1),ae},rename:async(K,M)=>{const W=b.current.find(_e=>_e.id===K);if(!W)throw new Error("deck inesistente");if(K===L.current&&T.current&&!await E(K))throw new Error(`salvataggio di "${W.name}" fallito: rinomina annullata`);const oe=b.current.find(_e=>_e.id===K);if(!oe)throw new Error("deck inesistente");const ae=await Xw(e,oe.name,M,oe.revision,oe.ownerRoute),se=ir(ae,Xs(oe),oe.ownerTopology,oe.local,!0),le=oe.local?un:oe.ownerId;return gu(Nx(Ma(),le,K,se.id)),q(b.current.map(_e=>_e.id===K?se:_e),!1),se},remove:async K=>{const M=b.current.find(oe=>oe.id===K);if(!M)throw new Error("deck inesistente");K===L.current&&(T.current=!1),await Gw(e,M.name,M.revision,M.ownerRoute);const W=M.local?un:M.ownerId;gu(Rx(Ma(),W,K)),q(b.current.filter(oe=>oe.id!==K),!1)},reorder:(K,M)=>{const W=b.current.find(ce=>ce.id===K),oe=b.current.find(ce=>ce.id===M);if(!W||!oe)return!1;const ae=W.local?un:W.ownerId,se=oe.local?un:oe.ownerId;if(ae!==se)return!1;const le=b.current.filter(ce=>(ce.local?un:ce.ownerId)===ae).map(ce=>ce.id),_e=gu(Ex(Ma(),ae,K,M,le));return q(Ng(b.current,_e),!1),!0},addTileTo:async(K,M)=>{const W=b.current.find(ce=>ce.id===K);if(!W)throw new Error("deck inesistente");if(W.available===!1)throw new Error(`nodo owner offline: ${W.ownerLabel}`);const oe=Y_(M,N.current,x.current);if(!oe)throw new Error("riferimento sessione non valido");const ae=U(W),se=kg(Uv(ae,oe),W.ownerId,W.ownerTopology),le=await Ca(e,W.name,se,W.revision,W.ownerRoute),_e=ir(le,Xs(W),W.ownerTopology,W.local,!0);return q(b.current.map(ce=>ce.id===K?_e:ce),!1),_e},localMainId:Yr(null,"main"),parseDeckId:ad}}const uE="/sw.js",Th="nc-sw-update";let Ah=null,Bh=!1,Ih=null,my=Object.freeze({needed:!1,kind:null,version:""}),gy=!1;function vy(){typeof window<"u"&&window.dispatchEvent(new Event(Th))}function _y(){const e=Ih||(Bh?{kind:"reload",version:""}:null);my=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function gv(){return my}function hE(e){return typeof window>"u"?()=>{}:(window.addEventListener(Th,e),()=>window.removeEventListener(Th,e))}function dd(e){Bh!==e&&(Bh=e,_y(),vy())}function dE(e,t,i){let s=null;e&&t&&e!==t?s={kind:"install",version:e}:t&&i&&t!==i&&(s={kind:"reload",version:t});const o=JSON.stringify(s)===JSON.stringify(Ih);Ih=s,_y(),o||vy()}function fE(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&dd(!0)})}function pE(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{gy&&location.reload()}),navigator.serviceWorker.register(uE).then(e=>{Ah=e,e.waiting&&dd(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&fE(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function mE(){gy=!0,dd(!1);const e=Ah&&Ah.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function gE({hash:e="",origin:t="",pathname:i="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),l=`${i||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:l};const c=new URLSearchParams(o),d=c.get("token")||"",m=c.get("pair")||"",p=m?`${t||""}${i||""}#pair=${m}`:"";return{token:d,pair:p,nextUrl:l}}const yy=9,Sy=24,wy="nc_side_w",vv="nc_side_min",vE=240,_v="(min-width:1024px) and (pointer:fine)";function _E(){const e=Number(localStorage.getItem(wy));return e>=180&&e<=480?e:vE}function yE(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=yy&&e<=Sy?e:13}function SE(){const e={token:"",pair:""};try{const{token:t,pair:i,nextUrl:s}=gE({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(t){e.token=t;try{localStorage.setItem("nc_token",t)}catch{}}if(i){e.pair=i;try{sessionStorage.setItem("nc_pair",i)}catch{}}if(location.hash)try{history.replaceState(null,"",s)}catch{}}catch{}if(e.token||(e.token=sessionStorage.getItem("nc_token")||localStorage.getItem("nc_token")||""),!e.pair){const t=sessionStorage.getItem("nc_pair");t&&(e.pair=t)}return e}function wE(e){try{return lr(Lh(e))}catch{return Vr()}}function yv(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 bE(){const[e,t]=P.useState(()=>window.matchMedia(_v).matches);return P.useEffect(()=>{const i=window.matchMedia(_v),s=o=>t(o.matches);return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[]),e}function Sv({session:e,node:t,ownerId:i,token:s,readonly:o=!1,onBack:l}){Si();const[c,d]=P.useState(!1),[m,p]=P.useState(()=>window.matchMedia("(pointer: coarse)").matches),[S,C]=P.useState(null),[_,v]=P.useState(yE),[w,b]=P.useState(""),x=q=>v(Y=>{const A=Math.max(yy,Math.min(Sy,Y+q));return localStorage.setItem("nc_fontsize",String(A)),A}),N=P.useRef(()=>{}),L=P.useRef(()=>!1),j=P.useRef(()=>{}),T=P.useRef(!1),[Q,H]=P.useState(!1),[I,G]=P.useState(!1),U=()=>{T.current=!T.current,H(T.current)};return P.useEffect(()=>{let q=!0;const Y=t?t.split("/"):[],A=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function E(){let F=null,D=null;try{const ne=await(await zt(`${A}/sessions`,s)).json();Array.isArray(ne.sessions)&&(F=ne.sessions.find(K=>K.name===e))}catch{}try{const z=await dr(s,Y);z.available&&Array.isArray(z.cells)&&(D=z.cells.find(ne=>ne.tmuxSession===e))}catch{}if(!q)return;let O="";D?O=`${D.engine}${D.key?`·${D.key}`:""}`:F&&(O=F.attached?`attached · ${yv(F.activity)}`:F.activity?yv(F.activity):""),b(O)}E();const R=setInterval(E,4e3);return()=>{q=!1,clearInterval(R)}},[e,t,s]),h.jsxs("div",{className:"nc-app",children:[h.jsxs("header",{className:"nc-bar nc-bar-single",children:[h.jsxs("button",{onClick:l,title:y("sessions"),children:[h.jsx(et,{name:"chevronLeft",size:18}),h.jsx("span",{className:"nc-bar-label",children:y("sessions")})]}),h.jsxs("span",{className:"nc-bar-center",children:[h.jsx("b",{children:t?`${t}:${e}`:e}),w&&h.jsx("small",{className:"nc-bar-sub",children:w})]}),h.jsxs("span",{className:"nc-bar-right",children:[h.jsx("button",{onClick:()=>x(-1),title:y("zoom-out"),children:h.jsx(et,{name:"zoomOut",size:18})}),h.jsx("button",{onClick:()=>x(1),title:y("zoom-in"),children:h.jsx(et,{name:"zoomIn",size:18})}),h.jsx("button",{onClick:()=>p(q=>!q),title:y("composer"),children:h.jsx(et,{name:"keyboard",size:20})}),h.jsx("button",{onClick:()=>d(q=>!q),title:y("files"),children:h.jsx(et,{name:"folder",size:20})})]})]}),h.jsx("div",{className:"nc-termwrap",children:h.jsx(B_,{session:e,node:t,token:s,readonly:o,takeSize:!0,sendRef:N,composerRef:L,actionRef:j,ctrlRef:T,setCtrlArmed:H,onFiles:C,fontSize:_,selectionMode:I,onSelectionModeChange:G})}),h.jsx(GC,{onKeyboard:()=>p(q=>!q),send:q=>N.current(q),action:q=>j.current(q),ctrlArmed:Q,onCtrl:U,selectionMode:I,onSelectionMode:G}),m&&h.jsx(q_,{submitText:q=>L.current(q),token:s,session:e,node:t,ownerId:i}),c&&h.jsx(I_,{session:e,node:t,token:s,filesEvent:S,onClose:()=>d(!1)})]})}function CE(){Si();const[e]=P.useState(SE),[t,i]=P.useState(e.token),[s,o]=P.useState(e.pair||""),l=P.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[c,d]=P.useState(!1),m=bE(),[p]=P.useState(()=>Cx(typeof location<"u"?location.pathname:"/")),[S,C]=P.useState(p.id),_=S===Yr(null,yi),[v,w]=P.useState(null),b=ue=>w(Hn(ue)),[x,N]=P.useState([]),[L,j]=P.useState([]),[T,Q]=P.useState(()=>p.ownerId?Vr():wE(p.name)),[H,I]=P.useState(null),[G,U]=P.useState(null),q=ue=>U(Hn(ue)),Y=qh(t,m),A=P.useMemo(()=>(Y||[]).filter(ue=>ue.instanceId).map(ue=>({instanceId:ue.instanceId,route:ue.route,label:ue.label,status:ue.status})),[Y]),E=cE(t,S,T,Q,A),R=E.decks;P.useEffect(()=>{const ue=new Map;for(const De of Y||[]){const Ue=(De.route||[De.name]).join("/"),Mt=new Set((De.sessions||[]).map(hi=>hi.name));for(const hi of De.cells||[])!hi.cell||!hi.tmuxSession||hi.cell===hi.tmuxSession||Mt.has(hi.cell)||ue.set(`${Ue}:${hi.cell}`,`${Ue}:${hi.tmuxSession}`)}Q(De=>S0(De,ue))},[Y]),P.useEffect(()=>{E.localNodeId&&Q(ue=>{const De=Mh(ue,E.localNodeId,A);return JSON.stringify(De)===JSON.stringify(ue)?ue:De})},[A,E.localNodeId]);const[F,D]=P.useState(null),[O,z]=P.useState(!1),[ne,K]=P.useState(_E),[M,W]=P.useState(!_),[oe,ae]=P.useState(()=>_?localStorage.getItem(vv)==="1":!0),[se,le]=P.useState(!1),[_e,ce]=P.useState("nodes"),[X,Z]=P.useState(!1),[je,Me]=P.useState(""),ye=(ue="nodes",De=!1,Ue="")=>{ce(ue),Z(De),Me(Ue),le(!0)},[ee,Ce]=P.useState(!1),[Te,xe]=P.useState(!1);P.useEffect(()=>{try{localStorage.setItem(wy,String(ne))}catch{}},[ne]),P.useEffect(()=>{try{localStorage.setItem(vv,oe?"1":"")}catch{}},[oe]),P.useEffect(()=>{if(!t)return;let ue=!1;return Promise.all([Rv(t),zt("/api/config",t).then(De=>De.json())]).then(([De,Ue])=>{ue||(xe(!!Ue.readonlyDefault),(De.firstRun===!0&&!Ue.readonlyDefault||s)&&Ce(!0))}).catch(()=>{}),()=>{ue=!0}},[t,s]);const qe=P.useCallback(async()=>{try{const De=await(await zt("/api/sessions",t)).json();De.error||N(De.sessions||[])}catch{}try{const ue=await dr(t);j(ue.available?ue.cells||[]:[])}catch{j([])}},[t]);P.useEffect(()=>{if(!m)return;qe();const ue=setInterval(qe,4e3);return()=>clearInterval(ue)},[m,qe]),P.useEffect(()=>{let ue=!1;return zt("/api/config",t).then(De=>De.json()).then(De=>{ue||dE(De.version,De.uiVersion,"0.8.18")}).catch(()=>{}),()=>{ue=!0}},[t]);const te=new Set([...x.map(ue=>ue.name),...Y.flatMap(ue=>ue.sessions.map(De=>De.key))]),ve=Gi(T),Be=ue=>Q(De=>{const Ue=Y_(ue,E.localNodeId,A)||ue,Mt=Uv(De,Ue);return Mt===De&&Gi(De).length>=9&&E.setError(y("grid-full")),Mt}),Ie=async(ue,De=[])=>{try{await $h(t,ue,De)}catch{return}const Ue=De.length?`${De.join("/")}:${ue}`:ue;Q(Mt=>qa(Mt,Ue)),qe()},Fe=async(ue,De,Ue=[])=>{try{await Ev(t,ue,De,Ue)}catch{return}qe()},gt=async ue=>{if(!F)return;const{cell:De}=F,Ue=Array.isArray(F.route)?F.route:[];ue.action==="up"?await Fh(t,{cell:De,boot:!!ue.boot,...ue.engine?{engine:ue.engine}:{},...ue.model!==void 0?{model:ue.model}:{},...ue.permissionPolicy?{permissionPolicy:ue.permissionPolicy}:{}},Ue):await Fa(t,{cell:De,boot:!!ue.boot},Ue),qe()},ge=async ue=>{if(!(!(ue!=null&&ue.direct)||O)){z(!0);try{await Uh(t,ue.name,ue.tunnelStatus==="up"?"down":"up")}finally{z(!1)}}},be=ue=>{const De=R.find(Ue=>Ue.id===ue);if(!De)return!1;try{const Ue=window.open(mu(De,t),"_blank");return Ue&&(Ue.opener=null),!!Ue}catch{return!1}},ke=async ue=>{if(!ue||ue===S)return;const De=await E.select(ue),Ue=E.records.find(Mt=>Mt.id===ue);C(ue),Q(De),I(null),U(null);try{history.replaceState(null,"",mu(Ue||ue,null))}catch{}},Xe=async(ue,De)=>{const Ue=await E.add(ue,De);await ke(Ue.id)},rt=async(ue,De)=>{const Ue=await E.rename(ue,De);if(ue===S){C(Ue.id),Q(Mh(Ue.layout,E.localNodeId,A)),I(null),U(null);try{history.replaceState(null,"",mu(Ue,null))}catch{}}},Ve=async ue=>{await E.remove(ue),ue===S&&await ke(E.localMainId)},de=async(ue,De)=>{!De||De===S||(await E.addTileTo(De,ue),Q(Ue=>qa(Ue,ue)))};if(!t)return h.jsxs("div",{className:"nc-auth",children:[h.jsx("p",{children:y("auth-prompt")}),h.jsx("input",{onChange:ue=>i(ue.target.value.trim()),placeholder:"token"}),h.jsxs("label",{children:[h.jsx("input",{type:"checkbox",checked:c,onChange:ue=>d(ue.target.checked)})," ",y("remember-device")]}),h.jsx("button",{onClick:()=>{(c?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const Ke=h.jsxs(h.Fragment,{children:[se&&h.jsx(eE,{token:t,initialTab:_e,initialLocation:je,startNewCell:X,onClose:()=>{le(!1),Z(!1),Me("")}}),ee&&h.jsx(tE,{token:t,initialPair:s,onPairDone:l,onDone:()=>Ce(!1)}),h.jsx(aE,{token:t})]});if(!m)return v?h.jsxs(h.Fragment,{children:[h.jsx(Sv,{session:v.session,node:v.node,ownerId:v.ownerId,token:t,readonly:Te,onBack:()=>w(null)}),Ke]}):h.jsxs(h.Fragment,{children:[h.jsx(k0,{onPick:b,token:t,onSettings:ye}),Ke]});const it=_||!M;return h.jsxs("div",{className:"nc-workspace",children:[it&&h.jsx(fx,{sessions:x,cells:L,activeSessions:ve,nodeGroups:Y,localNodeId:E.localNodeId,onPick:q,onAddTile:Be,onPower:D,onNodePower:ge,onKill:Ie,onVisibility:Fe,onNew:()=>ye("fleet",!0),onSettings:ye,width:ne,collapsed:oe,onResize:K,onToggleCollapse:()=>ae(ue=>!ue)}),h.jsxs("div",{className:"nc-workspace-main",children:[h.jsx(Mx,{decks:R,currentDeck:S,onCreate:Xe,onRename:rt,onDelete:Ve,onReorder:E.reorder,onOpenWindow:be,onNavigate:ke,saveState:E.saveState,error:E.error,sidebarVisible:it,onToggleSidebar:_?null:()=>W(ue=>!ue)}),h.jsx(_x,{layout:T,onLayoutChange:Q,token:t,readonly:Te,sessionsAlive:te,focusSession:H,onFocus:I,onOpenSingle:q,decks:R,currentDeck:S,onSendToDeck:de})]}),G&&h.jsx("div",{className:"nc-single-overlay",children:h.jsx(Sv,{session:G.session,node:G.node,ownerId:G.ownerId,token:t,readonly:Te,onBack:()=>U(null)})}),F&&h.jsx(Ha,{cell:F,token:t,route:Array.isArray(F.route)?F.route:[],onConfirm:gt,onClose:()=>D(null)}),Ke]})}function xE(){Si();const e=P.useSyncExternalStore(hE,gv,gv);if(!e.needed)return null;const t=e.kind==="install"?y("install-version-mismatch").replace("{v}",e.version):y("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:mE,children:y("reload")})]})}pE();Ew.createRoot(document.getElementById("root")).render(h.jsxs(yw.StrictMode,{children:[h.jsx(CE,{}),h.jsx(xE,{})]}));
|
|
86
|
+
Minimum version required to store current data is: `+X+`.
|
|
87
|
+
`);const A=j(I,G,q),E=e.getSymbolSize(I),R=new s(E);return v(R,I),w(R),b(R,I),N(R,G,0),I>=7&&x(R,I),L(R,A),isNaN(U)&&(U=c.getBestMask(R,N.bind(null,R,G))),c.applyMask(U,R),N(R,G,U),{modules:R,version:I,errorCorrectionLevel:G,maskPattern:U,segments:q}}return _u.create=function(I,G){if(typeof I>"u"||I==="")throw new Error("No input text");let U=t.M,q,X;return typeof G<"u"&&(U=t.from(G.errorCorrectionLevel,t.M),q=p.from(G.version),X=c.from(G.maskPattern),G.toSJISFunc&&e.setToSJISFunction(G.toSJISFunc)),Q(I,q,U,X)},_u}var Iu={},Ou={},ev;function sy(){return ev||(ev=1,(function(e){function t(i){if(typeof i=="number"&&(i=i.toString()),typeof i!="string")throw new Error("Color should be defined as hex string");let s=i.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+i);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(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,c=s.scale||4;return{width:l,scale:l?4:c,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 c=o.modules.size,d=o.modules.data,m=e.getScale(c,l),p=Math.floor((c+l.margin*2)*m),S=l.margin*m,C=[l.color.light,l.color.dark];for(let _=0;_<p;_++)for(let v=0;v<p;v++){let w=(_*p+v)*4,b=l.color.light;if(_>=S&&v>=S&&_<p-S&&v<p-S){const x=Math.floor((_-S)/m),N=Math.floor((v-S)/m);b=C[d[x*c+N]?1:0]}s[w++]=b.r,s[w++]=b.g,s[w++]=b.b,s[w]=b.a}}})(Ou)),Ou}var tv;function Jx(){return tv||(tv=1,(function(e){const t=sy();function i(o,l,c){o.clearRect(0,0,l.width,l.height),l.style||(l.style={}),l.height=c,l.width=c,l.style.height=c+"px",l.style.width=c+"px"}function s(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(l,c,d){let m=d,p=c;typeof m>"u"&&(!c||!c.getContext)&&(m=c,c=void 0),c||(p=s()),m=t.getOptions(m);const S=t.getImageWidth(l.modules.size,m),C=p.getContext("2d"),_=C.createImageData(S,S);return t.qrToImageData(_.data,l,m),i(C,p,S),C.putImageData(_,0,0),p},e.renderToDataURL=function(l,c,d){let m=d;typeof m>"u"&&(!c||!c.getContext)&&(m=c,c=void 0),m||(m={});const p=e.render(l,c,m),S=m.type||"image/png",C=m.rendererOpts||{};return p.toDataURL(S,C.quality)}})(Iu)),Iu}var zu={},iv;function Zx(){if(iv)return zu;iv=1;const e=sy();function t(o,l){const c=o.a/255,d=l+'="'+o.hex+'"';return c<1?d+" "+l+'-opacity="'+c.toFixed(2).slice(1)+'"':d}function i(o,l,c){let d=o+l;return typeof c<"u"&&(d+=" "+c),d}function s(o,l,c){let d="",m=0,p=!1,S=0;for(let C=0;C<o.length;C++){const _=Math.floor(C%l),v=Math.floor(C/l);!_&&!p&&(p=!0),o[C]?(S++,C>0&&_>0&&o[C-1]||(d+=p?i("M",_+c,.5+v+c):i("m",m,0),m=0,p=!1),_+1<l&&o[C+1]||(d+=i("h",S),S=0)):m++}return d}return zu.render=function(l,c,d){const m=e.getOptions(c),p=l.modules.size,S=l.modules.data,C=p+m.margin*2,_=m.color.light.a?"<path "+t(m.color.light,"fill")+' d="M0 0h'+C+"v"+C+'H0z"/>':"",v="<path "+t(m.color.dark,"stroke")+' d="'+s(S,p,m.margin)+'"/>',w='viewBox="0 0 '+C+" "+C+'"',x='<svg xmlns="http://www.w3.org/2000/svg" '+(m.width?'width="'+m.width+'" height="'+m.width+'" ':"")+w+' shape-rendering="crispEdges">'+_+v+`</svg>
|
|
88
|
+
`;return typeof d=="function"&&d(null,x),x},zu}var nv;function ek(){if(nv)return $r;nv=1;const e=Tx(),t=Qx(),i=Jx(),s=Zx();function o(l,c,d,m,p){const S=[].slice.call(arguments,1),C=S.length,_=typeof S[C-1]=="function";if(!_&&!e())throw new Error("Callback required as last argument");if(_){if(C<2)throw new Error("Too few arguments provided");C===2?(p=d,d=c,c=m=void 0):C===3&&(c.getContext&&typeof p>"u"?(p=m,m=void 0):(p=m,m=d,d=c,c=void 0))}else{if(C<1)throw new Error("Too few arguments provided");return C===1?(d=c,c=m=void 0):C===2&&!c.getContext&&(m=d,d=c,c=void 0),new Promise(function(v,w){try{const b=t.create(d,m);v(l(b,c,m))}catch(b){w(b)}})}try{const v=t.create(d,m);p(null,l(v,c,m))}catch(v){p(v)}}return $r.create=t.create,$r.toCanvas=o.bind(null,i.render),$r.toDataURL=o.bind(null,i.renderToDataURL),$r.toString=o.bind(null,function(l,c,d){return s.render(l,d)}),$r}var tk=ek();const ik=Oh(tk),oy=/^[a-z0-9-]{1,32}$/,nk=/^[A-Za-z0-9._-]{1,32}$/,rk=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,sk=320;function ok(e){return typeof e=="string"&&oy.test(e)}const ak=64;function jh(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=ak&&!/[\x00-\x1f\x7f]/.test(t)}function Xr(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function ay(e){if(typeof e!="string"||!e||e.length>sk||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:nk.test(e.slice(0,t))&&rk.test(e.slice(t+1))}function rv(e){if(e===""||e===null||e===void 0)return null;const t=String(e).trim();if(!/^[0-9]{1,5}$/.test(t))return;const i=Number(t);return Number.isInteger(i)&&i>=1&&i<=65535?i:void 0}function sv({name:e,ssh:t,sshPort:i,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,l=typeof t=="string"?t.trim():t;if(!ok(o))return{ok:!1,error:"err-node-name"};if(!ay(l))return{ok:!1,error:"err-ssh"};const c=rv(i);if(c===void 0)return{ok:!1,error:"err-ssh-port"};const d=rv(s);if(d===void 0)return{ok:!1,error:"err-node-port"};const m={name:o,ssh:l};return c!==null&&(m.sshPort=c),d!==null&&(m.remotePort=d),{ok:!0,value:m}}function lk(e,t){if(!e||!t||t<e)return null;const i=Math.floor((t-e)/1e3);return i<60?"ora":i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}g`}function ov(e,t){const i=!!(e&&e.status==="up"),s=!!(e&&e.status==="passive");return{up:i,...s?{passive:!0}:{},label:i?"tunnel-up":s?"node-passive":"tunnel-down",since:i?lk(e.since,t):null}}const ck=new Set(["v","instanceId","port","label","invite"]),uk=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function hk(e){const t=String(e).replace(/-/g,"+").replace(/_/g,"/"),i=t+"=".repeat((4-t.length%4)%4),s=typeof atob=="function"?atob(i):Buffer.from(i,"base64").toString("binary"),o=Uint8Array.from(s,l=>l.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function dk(e){let t="";try{const c=new URL(String(e));t=new URLSearchParams(c.hash.replace(/^#/,"")).get("pair")||""}catch{return{ok:!1}}if(!t)return{ok:!1};let i;try{i=JSON.parse(hk(t))}catch{return{ok:!1}}if(!i||typeof i!="object"||Array.isArray(i))return{ok:!1};const s=i.v===1?ck:i.v===2?uk:null;if(!s)return{ok:!1};for(const c of Object.keys(i))if(!s.has(c))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(i.instanceId)))return{ok:!1};const o=Number(i.port);if(!Number.isInteger(o)||o<1||o>65535)return{ok:!1};if(typeof i.label!="string")return{ok:!1};if(typeof i.invite!="string"||!i.invite)return{ok:!1};const l={ok:!0,version:i.v,label:i.label,invite:i.invite,instanceId:i.instanceId,port:o};if(i.v===2){if(i.name!==void 0){if(typeof i.name!="string"||!oy.test(i.name))return{ok:!1};l.name=i.name}if(i.ssh!==void 0){if(!ay(i.ssh))return{ok:!1};l.ssh=String(i.ssh).trim()}if(i.sshPort!==void 0){const c=Number(i.sshPort);if(!Number.isInteger(c)||c<1||c>65535)return{ok:!1};l.sshPort=c}}return l}function fk(e,t,i=new Set){if(!t||!t.ok)return e;const s={...e},o=(l,c)=>{c==null||c===""||i.has(l)||(s[l]=c)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?Xr(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}function av(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function pk(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const i=dk(t);if(!i||!i.ok)return{kind:"invalid"};const s=[];return i.ssh||s.push("ssh"),i.name||s.push("name"),s.length?{kind:"partial",decoded:i,missing:s}:{kind:"complete",decoded:i}}function mk(e,t,i=new Set,s=!1){if(!t||!t.ok)return e;const o=fk(e,t,i);return t.version===2&&t.name&&!i.has("name")&&!s&&(o.name=t.name),!i.has("label")&&!o.label&&t.label&&(o.label=t.label),o}function lv(e,t,i=new Set,s=!1){const o=String(t||"").trim(),l=pk(o);let c={...e,pairingUrl:o};return(l.kind==="complete"||l.kind==="partial")&&(c={...mk(c,l.decoded,i,s),pairingUrl:o}),{classification:l,form:c}}function gk(e,{deviceDefault:t=""}={}){const i={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&&(i.localLabel=s),i}function vk(){const e=new Set;let t=!1;return{canAuto(i){return!t&&!e.has(String(i||""))},start(i){return t?!1:(t=!0,e.add(String(i||"")),!0)},finish(){t=!1},reset(i){e.delete(String(i||""))},isBusy(){return t}}}const _k=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function yk(e){const t=e&&e.data||{},i=typeof t.stage=="string"&&t.stage?t.stage:"",s=typeof t.detail=="string"&&t.detail?t.detail:"";return{stage:i,code:typeof t.code=="string"?t.code:"",detail:s,hint:typeof t.hint=="string"?t.hint:"",retryable:typeof t.retryable=="boolean"?t.retryable:!i,message:s||String(e&&e.message||e)}}const Sk="modulepreload",wk=function(e){return"/"+e},cv={},bk=function(t,i,s){let o=Promise.resolve();if(i&&i.length>0){let c=function(p){return Promise.all(p.map(S=>Promise.resolve(S).then(C=>({status:"fulfilled",value:C}),C=>({status:"rejected",reason:C}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),m=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));o=c(i.map(p=>{if(p=wk(p),p in cv)return;cv[p]=!0;const S=p.endsWith(".css"),C=S?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${C}`))return;const _=document.createElement("link");if(_.rel=S?"stylesheet":Sk,S||(_.as="script"),_.crossOrigin="",_.href=p,m&&_.setAttribute("nonce",m),document.head.appendChild(_),S)return new Promise((v,w)=>{_.addEventListener("load",v),_.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${p}`)))})}))}function l(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return o.then(c=>{for(const d of c||[])d.status==="rejected"&&l(d.reason);return t().catch(l)})};class Xe{constructor(t,i,s,o,l){this._legacyCanvasSize=Xe.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),s&&typeof s=="object"?this._onDecode=i:(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=i),i=typeof s=="object"?s:{},this._onDecodeError=i.onDecodeError||(typeof s=="function"?s:this._onDecodeError),this._calculateScanRegion=i.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=i.preferredCamera||l||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=i.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let c=!1;if(t.hidden&&(t.hidden=!1,c=!0),document.body.contains(t)||(document.body.appendChild(t),c=!0),s=t.parentElement,i.highlightScanRegion||i.highlightCodeOutline){if(o=!!i.overlay,this.$overlay=i.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&&i.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}s.insertBefore(this.$overlay,this.$video.nextSibling)}i.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let d=window.getComputedStyle(t);d.display==="none"&&(t.style.setProperty("display","block","important"),c=!0),d.visibility!=="visible"&&(t.style.setProperty("visibility","visible","important"),c=!0),c&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),t.style.opacity="0",t.style.width="0",t.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),t.addEventListener("play",this._onPlay),t.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=Xe.createQrEngine()}static set WORKER_PATH(t){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await Xe.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let i=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),s;try{t&&(await i()).every(o=>!o.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await i()).map((o,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"),Xe._stopVideoStream(s))}}async hasFlash(){let t;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;t=this.$video.srcObject}else t=(await this._getCameraStream()).stream;return"torch"in t.getVideoTracks()[0].getSettings()}catch{return!1}finally{t&&t!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),Xe._stopVideoStream(t))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(t){throw this._flashOn=!1,t}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),Xe._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:i}=await this._getCameraStream();!this._active||this._paused?Xe._stopVideoStream(t):(this._setVideoMirror(i),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(t){if(!this._paused)throw this._active=!1,t}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let i=()=>{this.$video.srcObject instanceof MediaStream&&(Xe._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(i(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(i(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,i,s,o,l=!1,c=!1){let d,m=!1;i&&("scanRegion"in i||"qrEngine"in i||"canvas"in i||"disallowCanvasResizing"in i||"alsoTryWithoutScanRegion"in i||"returnDetailedScanResult"in i)?(d=i.scanRegion,s=i.qrEngine,o=i.canvas,l=i.disallowCanvasResizing||!1,c=i.alsoTryWithoutScanRegion||!1,m=!0):console.warn(i||s||o||l||c?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),i=!!s;try{let p,S;[s,p]=await Promise.all([s||Xe.createQrEngine(),Xe._loadImage(t)]),[o,S]=Xe._drawToCanvas(p,d,o,l);let C;if(s instanceof Worker){let _=s;i||Xe._postWorkerMessageSync(_,"inversionMode","both"),C=await new Promise((v,w)=>{let b,x,N,L=-1;x=T=>{T.data.id===L&&(_.removeEventListener("message",x),_.removeEventListener("error",N),clearTimeout(b),T.data.data!==null?v({data:T.data.data,cornerPoints:Xe._convertPoints(T.data.cornerPoints,d)}):w(Xe.NO_QR_CODE_FOUND))},N=T=>{_.removeEventListener("message",x),_.removeEventListener("error",N),clearTimeout(b),w("Scanner error: "+(T?T.message||T:"Unknown Error"))},_.addEventListener("message",x),_.addEventListener("error",N),b=setTimeout(()=>N("timeout"),1e4);let j=S.getImageData(0,0,o.width,o.height);L=Xe._postWorkerMessageSync(_,"decode",j,[j.data.buffer])})}else C=await Promise.race([new Promise((_,v)=>window.setTimeout(()=>v("Scanner error: timeout"),1e4)),(async()=>{try{var[_]=await s.detect(o);if(!_)throw Xe.NO_QR_CODE_FOUND;return{data:_.rawValue,cornerPoints:Xe._convertPoints(_.cornerPoints,d)}}catch(v){if(_=v.message||v,/not implemented|service unavailable/.test(_))return Xe._disableBarcodeDetector=!0,Xe.scanImage(t,{scanRegion:d,canvas:o,disallowCanvasResizing:l,alsoTryWithoutScanRegion:c});throw`Scanner error: ${_}`}})()]);return m?C:C.data}catch(p){if(!d||!c)throw p;let S=await Xe.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:l});return m?S:S.data}finally{i||Xe._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,i,s,o=!0){Xe._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:i,blue:s,useIntegerApproximation:o})}setInversionMode(t){Xe._postWorkerMessage(this._qrEnginePromise,"inversionMode",t)}static async createQrEngine(t){if(t&&console.warn("Specifying a worker path is not required and not supported anymore."),t=()=>bk(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!Xe._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let i=navigator.userAgentData;return i&&i.brands.some(({brand:s})=>/Chromium/i.test(s))&&/mac ?OS/i.test(i.platform)&&await i.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:s,platformVersion:o})=>/arm/i.test(s||"arm")&&13<=parseInt(o||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let i=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-i)/2),y:Math.round((t.videoHeight-i)/2),width:i,height:i,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,i=t.videoWidth,s=t.videoHeight,o=t.offsetWidth,l=t.offsetHeight,c=t.offsetLeft,d=t.offsetTop,m=window.getComputedStyle(t),p=m.objectFit,S=i/s,C=o/l;switch(p){case"none":var _=i,v=s;break;case"fill":_=o,v=l;break;default:(p==="cover"?S>C:S<C)?(v=l,_=v*S):(_=o,v=_/S),p==="scale-down"&&(_=Math.min(_,i),v=Math.min(v,s))}var[w,b]=m.objectPosition.split(" ").map((N,L)=>{const j=parseFloat(N);return N.endsWith("%")?(L?l-v:o-_)*j/100:j});m=this._scanRegion.width||i,C=this._scanRegion.height||s,p=this._scanRegion.x||0;var x=this._scanRegion.y||0;S=this.$overlay.style,S.width=`${m/i*_}px`,S.height=`${C/s*v}px`,S.top=`${d+b+x/s*v}px`,s=/scaleX\(-1\)/.test(t.style.transform),S.left=`${c+(s?o-w-_:w)+(s?i-p-m:p)/i*_}px`,S.transform=t.style.transform}})}static _convertPoints(t,i){if(!i)return t;let s=i.x||0,o=i.y||0,l=i.width&&i.downScaledWidth?i.width/i.downScaledWidth:1;i=i.height&&i.downScaledHeight?i.height/i.downScaledHeight:1;for(let c of t)c.x=c.x*l+s,c.y=c.y*i+o;return t}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,i=1e3/this._maxScansPerSecond;t<i&&await new Promise(o=>setTimeout(o,i-t)),this._lastScanTimestamp=Date.now();try{var s=await Xe.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!Xe._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=Xe.createQrEngine()),s?(this._onDecode?this._onDecode(s):this._legacyOnDecode&&this._legacyOnDecode(s.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",s.cornerPoints.map(({x:o,y: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!==Xe.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",i=[{width:{min:1024}},{width:{min:768}},{}],s=i.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...s,...i])try{let l=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),c=this._getFacingMode(l)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:l,facingMode:c}}catch{}throw"Camera not found."}async _restartVideoStream(){let t=this._paused;await this.pause(!0)&&!t&&this._active&&await this.start()}static _stopVideoStream(t){for(let i of t.getTracks())i.stop(),t.removeTrack(i)}_setVideoMirror(t){this.$video.style.transform="scaleX("+(t==="user"?-1:1)+")"}_getFacingMode(t){return(t=t.getVideoTracks()[0])?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(t,i,s,o=!1){s=s||document.createElement("canvas");let l=i&&i.x?i.x:0,c=i&&i.y?i.y:0,d=i&&i.width?i.width:t.videoWidth||t.width,m=i&&i.height?i.height:t.videoHeight||t.height;return o||(o=i&&i.downScaledWidth?i.downScaledWidth:d,i=i&&i.downScaledHeight?i.downScaledHeight:m,s.width!==o&&(s.width=o),s.height!==i&&(s.height=i)),i=s.getContext("2d",{alpha:!1}),i.imageSmoothingEnabled=!1,i.drawImage(t,l,c,d,m,0,0,s.width,s.height),[s,i]}static async _loadImage(t){if(t instanceof Image)return await Xe._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(t instanceof File||t instanceof Blob||t instanceof URL||typeof t=="string"){let i=new Image;i.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await Xe._awaitImageLoad(i),i}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(i.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((i,s)=>{let o=l=>{t.removeEventListener("load",o),t.removeEventListener("error",o),l instanceof ErrorEvent?s("Image load error"):i()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,i,s,o){return Xe._postWorkerMessageSync(await t,i,s,o)}static _postWorkerMessageSync(t,i,s,o){if(!(t instanceof Worker))return-1;let l=Xe._workerMessageId++;return t.postMessage({id:l,type:i,data:s},o),l}}Xe.DEFAULT_CANVAS_SIZE=400;Xe.NO_QR_CODE_FOUND="No QR code found";Xe._disableBarcodeDetector=!1;Xe._workerMessageId=0;function Ck({onResult:e,onClose:t}){const i=P.useRef(null),s=P.useRef(null),o=P.useRef(!1),[l,c]=P.useState("");P.useEffect(()=>{let m=!1;const p=i.current,S=C=>{m||o.current||(o.current=!0,e(C))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){c(y("qr-unsupported"));return}let C=!1;try{C=await Xe.hasCamera()}catch{C=!1}if(!C){c(y("qr-no-camera"));return}if(m||!p)return;const _=new Xe(p,v=>{const w=av(v);w&&S(w)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:v=>{const w=v.videoWidth||640,b=v.videoHeight||480,x=Math.max(1,Math.round(Math.min(w,b)*.92));return{x:Math.round((w-x)/2),y:Math.round((b-x)/2),width:x,height:x,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=_;try{await _.start()}catch(v){if(m)return;const w=v&&v.name||"";c(y(w==="NotAllowedError"||w==="SecurityError"?"qr-permission":w==="NotFoundError"||w==="OverconstrainedError"||w==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{m=!0;const C=s.current;if(C){try{C.stop()}catch{}try{C.destroy()}catch{}s.current=null}const _=p,v=_&&_.srcObject;if(v&&typeof v.getTracks=="function"){for(const w of v.getTracks())try{w.stop()}catch{}try{_.srcObject=null}catch{}}}},[]);const d=async m=>{const p=m.target.files&&m.target.files[0];if(m.target.value="",!!p)try{const S=await Xe.scanImage(p,{returnDetailedScanResult:!0}),C=av(S);if(!C)throw new Error("empty");o.current||(o.current=!0,e(C))}catch{c(y("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:m=>m.stopPropagation(),children:[h.jsx("div",{className:"nc-sheet-head",children:h.jsx("b",{children:y("scan-qr")})}),h.jsx("video",{ref:i,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:[y("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:y("cancel")})]})]})})}const uv=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:""});function ly({token:e,initial:t="",autoStart:i=!1,deviceDefault:s="",readonly:o=!1,onSuccess:l,onBusyChange:c}){const[d,m]=P.useState(uv),[p,S]=P.useState(!1),[C,_]=P.useState(!1),[v,w]=P.useState("idle"),[b,x]=P.useState(null),[N,L]=P.useState(""),[j,T]=P.useState(!1),Q=P.useRef(vk()),H=P.useRef(new Set),I=v==="busy";P.useEffect(()=>(c&&c(I),()=>{c&&c(!1)}),[I,c]);const G=async R=>{const F=String(R.pairingUrl||"").trim();if(Q.current.start(F)){w("busy"),x(null),L("");try{await $w(e,gk(R,{deviceDefault:s})),w("ok"),S(!1),m(uv()),H.current=new Set,T(!1),Q.current.finish(),l&&await l()}catch(D){const O=yk(D);x(O),w("idle"),Q.current.finish(),(O.stage==="validation"||O.stage==="conflict"||O.stage==="ssh-start"||O.stage==="ssh-ready"||String(O.code||"").startsWith("ssh-"))&&S(!0)}}},U=(R,F=!0)=>{const{classification:D,form:O}=lv(d,R,H.current,j),z=O.pairingUrl;if(x(null),L(""),v==="ok"&&w("idle"),m(O),D.kind==="invalid"){x({stage:"validation",code:"bad-link",message:y("pair-invalid-link"),hint:y("pair-invalid-hint"),retryable:!0});return}if(D.kind==="partial"){S(!0),L(D.missing.includes("ssh")?y("pair-missing-ssh"):y("pair-missing-name"));return}D.kind==="complete"&&F&&!o&&Q.current.canAuto(z)&&G(O)};P.useEffect(()=>{t&&U(t,i)},[]);const q=()=>{const R=String(d.pairingUrl||"").trim(),{classification:F,form:D}=lv(d,R,H.current,j);if(m(D),L(""),x(null),F.kind==="empty"){x({stage:"validation",message:y("pairing-required"),retryable:!0});return}if(F.kind==="invalid"){x({stage:"validation",code:"bad-link",message:y("pair-invalid-link"),hint:y("pair-invalid-hint"),retryable:!0});return}if(!D.ssh||!D.name){S(!0),L(D.ssh?y("pair-missing-name"):y("pair-missing-ssh"));return}if(D.label&&!jh(D.label)){x({stage:"validation",message:y("err-label"),retryable:!0});return}if(D.localLabel&&!jh(D.localLabel)){x({stage:"validation",message:y("err-label"),retryable:!0});return}Q.current.reset(R),G(D)},X=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const R=await navigator.clipboard.readText();R&&R.trim()?U(R):L(y("pair-clipboard-empty"))}catch{L(y("pair-clipboard-denied"))}},A=(R,F)=>{H.current.add(R),m(D=>({...D,[R]:F}))},E=b&&b.stage&&(_k.includes(b.stage)||b.stage==="internal")?y(`pair-stage-${b.stage}`):y("pair-stage-generic");return h.jsxs("div",{className:"nc-set-form nc-pair-card",children:[h.jsx("div",{className:"nc-sheet-label",children:y("pair-card-title")}),h.jsx("div",{className:"nc-set-info",children:y("pair-card-help")}),h.jsx("input",{className:"nc-pair-input",placeholder:y("pair-paste-ph"),value:d.pairingUrl,disabled:o||I,onChange:R=>{m({...d,pairingUrl:R.target.value}),x(null),L("")},onPaste:R=>{const F=R.clipboardData&&R.clipboardData.getData("text")||"";F.trim()&&(R.preventDefault(),U(F))},onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),q())}}),h.jsxs("div",{className:"nc-pair-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||I,onClick:X,children:y("pair-paste-btn")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||I,onClick:()=>_(!0),children:y("scan-qr")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||I,title:o?y("settings-readonly"):"",onClick:q,children:y("test-and-connect")})]}),h.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[I&&h.jsx("div",{className:"nc-pair-progress",children:y("pair-progress")}),v==="ok"&&h.jsx("div",{className:"nc-set-test ok",children:y("node-connected")}),N&&h.jsx("div",{className:"nc-set-hint nc-pair-notice",children:N}),b&&h.jsxs("div",{className:"nc-err",role:"alert",children:[h.jsx("b",{children:E})," — ",b.message,b.hint&&h.jsx("div",{className:"nc-pair-hint",children:b.hint}),b.retryable&&h.jsx("div",{children:h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||I,onClick:q,children:y("pair-retry")})})]})]}),h.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:I,onClick:()=>S(R=>!R),children:[p?"▾":"▸"," ",y("pair-advanced")]}),p&&h.jsxs("div",{className:"nc-pair-advanced",children:[h.jsxs("label",{className:"nc-field",children:[y("node-display-label"),h.jsx("input",{placeholder:"Home Relay",value:d.label,disabled:o||I,onChange:R=>{H.current.add("label"),m(F=>({...F,label:R.target.value,name:j?F.name:Xr(R.target.value)}))}})]}),h.jsxs("label",{className:"nc-field",children:[y("node-name-label"),h.jsx("input",{placeholder:y("node-name-ph"),value:d.name,disabled:o||I,onChange:R=>{T(!0),H.current.add("name"),m(F=>({...F,name:R.target.value?Xr(R.target.value):""}))}})]}),h.jsx("small",{className:"nc-set-hint",children:y("node-slug-hint").replace("{slug}",d.name||"home-relay")}),h.jsxs("label",{className:"nc-field",children:[y("pair-ssh-local-label"),h.jsx("input",{placeholder:"my-relay",value:d.ssh,disabled:o||I,onChange:R=>{H.current.add("ssh"),A("ssh",R.target.value)}}),h.jsx("small",{className:"nc-set-hint",children:y("node-ssh-local-help")})]}),h.jsxs("label",{className:"nc-field",children:[y("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:y("node-ssh-port-help"),value:d.sshPort,disabled:o||I,onChange:R=>A("sshPort",R.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),h.jsxs("label",{className:"nc-field",children:[y("device-name-label"),h.jsx("input",{placeholder:s||"NexusCrew",value:d.localLabel,disabled:o||I,onChange:R=>A("localLabel",R.target.value)}),h.jsx("small",{className:"nc-set-hint",children:y("device-name-hint")})]})]}),C&&h.jsx(Ck,{onResult:R=>{_(!1),U(R)},onClose:()=>_(!1)})]})}function ud(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function xk(e){const t="=".repeat((4-e.length%4)%4),i=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(i),o=new Uint8Array(s.length);for(let l=0;l<s.length;l+=1)o[l]=s.charCodeAt(l);return o}async function kk(){if(!ud())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function Ek(e){if(!ud())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const i=await zt("/api/push/vapid",e),{publicKey:s}=await i.json();if(!s)throw new Error("vapid non disponibile");const l=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:xk(s)}),c=await zt("/api/push/subscribe",e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:l.toJSON()})});if(!c.ok){try{await l.unsubscribe()}catch{}const d=await c.json().catch(()=>({}));throw new Error(d.error||`HTTP ${c.status}`)}return!0}async function Nk(e){if(!ud())return!1;const i=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!i)return!1;const s=i.endpoint;try{await i.unsubscribe()}catch{}try{await zt("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const cy="nexuscrew.fleet",uy=2,Rk="nexuscrew.cells",Pk=/^[A-Za-z0-9._-]{1,32}$/,hd=/^[a-z0-9._-]{1,32}$/,hy=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,Dk=new Set(["standard","unsafe"]),Mk=4096,hv=256,Lk=8192,jk=32,Tk=24,Ak=new Set(["format","version","exportedAt","cells","engines"]),Bk=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]),Ik=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag"]),Ok=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]);function sr(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function dy(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 dv(e,t){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))return null;const i=Object.entries(e);if(i.length>128)return null;const s={};for(const[o,l]of i){if(!hd.test(o)||!t(l))return null;s[o]=l}return s}function fy(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(l=>!Bk.has(l))||!Pk.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>Mk||!hd.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>hv)||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>Lk)return null;const i=dv(e.models,l=>typeof l=="string"&&!!l&&l.length<=hv),s=dv(e.permissionPolicies,l=>Dk.has(l));if(i===null||s===null)return null;const o={id:e.id,cwd:e.cwd,engine:e.engine,boot:e.boot===!0,systemPrompt:t};return e.model&&(o.model=e.model),Object.keys(i).length&&(o.models=i),Object.keys(s).length&&(o.permissionPolicies=s),o}function zk(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(i=>!Ok.has(i)))return null;const t={};for(const[i,s]of Object.entries(e)){if(typeof s!="string"||!sr(s,i==="baseUrl"?512:128)||dy(s))return null;t[i]=s}return!t.client||!t.provider||t.envKey&&!hy.test(t.envKey)?null:t}function py(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!Ik.has(s))||!hd.test(String(e.id||""))||!sr(e.label||e.id,64)||e.rc!==void 0&&typeof e.rc!="boolean")return null;const t={id:e.id,label:e.label||e.id,rc:e.rc===!0};if(e.managed!==void 0){const s=zk(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!sr(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!sr(s,1024)||dy(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!sr(e.promptFlag,32)||/\s/.test(e.promptFlag)))return null;if(e.model!==void 0){if(!e.model||typeof e.model!="object"||Array.isArray(e.model)||Object.keys(e.model).some(s=>s!=="flag"&&s!=="value")||!sr(e.model.flag,32)||/\s/.test(e.model.flag)||!sr(e.model.value||"",128))return null;t.model={flag:e.model.flag,value:e.model.value||""}}const i=e.envKeys===void 0?[]:e.envKeys;return!Array.isArray(i)||i.length>32||i.some(s=>!hy.test(s))?null:(Object.assign(t,{command:e.command,args:[...e.args],envKeys:[...new Set(i)].sort(),promptMode:e.promptMode}),e.promptMode==="flag"&&(t.promptFlag=e.promptFlag),t)}function my(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.managed?{id:e.id,label:e.label,rc:e.rc,managed:e.managed}:{id:e.id,label:e.label,rc:e.rc,command:e.command,args:e.args,envKeys:e.envKeys,model:e.model,promptMode:e.promptMode,promptFlag:e.promptFlag},i=py(t);return i||null}function Fk(e,t,i=[],s=[],o=new Date){i instanceof Date&&(o=i,i=[],s=[]);const l=t instanceof Set?t:new Set(t||[]),c=s instanceof Set?s:new Set(s||[]),d=[];for(const p of Array.isArray(e)?e:[]){if(!l.has(p.id))continue;const S=fy({id:p.id,cwd:p.cwd,engine:p.engine,boot:p.boot===!0,...p.model?{model:p.model}:{},...p.models?{models:p.models}:{},...p.permissionPolicies?{permissionPolicies:p.permissionPolicies}:{},systemPrompt:p.prompt||""});S&&d.push(S)}const m=[];for(const p of Array.isArray(i)?i:[]){if(!c.has(p.id))continue;const S=my(p);S&&m.push(S)}return{format:cy,version:uy,exportedAt:o.toISOString(),cells:d,engines:m}}function Hk(e){let t;try{t=JSON.parse(String(e||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const i=(t==null?void 0:t.format)===Rk&&(t==null?void 0:t.version)===1;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(d=>!Ak.has(d))||!i&&(t.format!==cy||t.version!==uy)||!Array.isArray(t.cells)||t.cells.length>jk||!i&&(!Array.isArray(t.engines)||t.engines.length>Tk))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const s=[],o=new Set;for(const d of t.cells){const m=fy(d);if(!m)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(o.has(m.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};o.add(m.id),s.push(m)}const l=[],c=new Set;for(const d of i?[]:t.engines){const m=py(d);if(!m)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(c.has(m.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};c.add(m.id),l.push(m)}return{ok:!0,cells:s,engines:l,legacy:i,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function $k(e,t,i){const s=new Set(i||[]);if(!s.has(t))return null;const o=m=>Object.fromEntries(Object.entries(m||{}).filter(([p])=>s.has(p))),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 c=o(e.models),d=o(e.permissionPolicies);return Object.keys(c).length&&(l.models=c),Object.keys(d).length&&(l.permissionPolicies=d),l}const Wk=()=>({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:[]}),fv=(e="")=>({id:"",cwd:"",engine:e,boot:!1,model:"",prompt:""}),gy=e=>e==="claude"?"unsafe":"standard",tl=(e,t)=>e.find(i=>i.client===t.client&&i.provider===t.provider&&(i.credentialProfile||"")===(t.credentialProfile||"")),Uk=(e,t)=>{var i;return((i=tl(e,t))==null?void 0:i.label)||`${t.client} · ${t.provider}`};function Kk(e){var t,i,s,o,l,c,d,m,p,S,C,_,v,w;return{kind:e.managed?"managed":"custom",id:e.id,label:e.label||"",command:e.command||"",argsText:(e.args||[]).join(`
|
|
89
|
+
`),rc:!!e.rc,client:((t=e.managed)==null?void 0:t.client)||"claude",provider:((i=e.managed)==null?void 0:i.provider)||"native",credentialProfile:((s=e.managed)==null?void 0:s.credentialProfile)||"",managedModel:((o=e.managed)==null?void 0:o.model)||"",permissionPolicy:((l=e.managed)==null?void 0:l.permissionPolicy)||gy((c=e.managed)==null?void 0:c.client),displayName:((d=e.managed)==null?void 0:d.displayName)||"",protocol:((m=e.managed)==null?void 0:m.protocol)||"",baseUrl:((p=e.managed)==null?void 0:p.baseUrl)||"",envKey:((S=e.managed)==null?void 0:S.envKey)||"",providerId:((C=e.managed)==null?void 0:C.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:((w=e.model)==null?void 0:w.value)||"",envRows:(e.envKeys||[]).map(b=>({key:b,value:"",configured:!0,remove:!1}))}}function qk(e,t,i=[]){if(e.kind==="managed"){const o={client:e.client,provider:e.provider,model:e.managedModel||"",permissionPolicy:e.permissionPolicy||gy(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile);const l=tl(i,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||Uk(i,e),rc:!!e.rc,managed:o}}const s={...t?{id:e.id}:{},label:e.label||e.id,rc:!!e.rc,command:e.command,args:e.argsText.split(`
|
|
90
|
+
`).filter(o=>o!==""),promptMode:e.promptMode};return e.modelFlag&&(s.model={flag:e.modelFlag,value:e.modelValue||""}),e.promptMode==="flag"&&(s.promptFlag=e.promptFlag),t&&(s.env=Object.fromEntries(e.envRows.filter(o=>!o.remove&&o.key).map(o=>[o.key,o.value]))),s}function Wr({children:e,onClose:t,label:i,error:s=""}){const o=P.useRef(null),l=P.useRef(null),c=P.useRef(t);return c.current=t,P.useEffect(()=>{const d=document.activeElement,m=o.current,p=()=>Array.from((m==null?void 0:m.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))||[]).filter(_=>_.offsetParent!==null),S=requestAnimationFrame(()=>{var _;return(_=p()[0]||m)==null?void 0:_.focus({preventScroll:!0})}),C=_=>{var x;if(_.key==="Escape"){_.preventDefault(),(x=c.current)==null||x.call(c);return}if(_.key!=="Tab")return;const v=p();if(!v.length){_.preventDefault(),m==null||m.focus();return}const w=v[0],b=v[v.length-1];_.shiftKey&&document.activeElement===w?(_.preventDefault(),b.focus()):!_.shiftKey&&document.activeElement===b&&(_.preventDefault(),w.focus())};return document.addEventListener("keydown",C),()=>{cancelAnimationFrame(S),document.removeEventListener("keydown",C),d&&d.isConnected&&typeof d.focus=="function"&&d.focus({preventScroll:!0})}},[]),P.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":i||y("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 pv({token:e,targets:t=[],readonly:i=!1,onPower:s,onImport:o}){const[l,c]=P.useState([]),[d,m]=P.useState(0);P.useEffect(()=>{let x=!0;async function N(){const j=[{route:[],label:y("local")}].concat((t||[]).map(Q=>({route:Array.isArray(Q.route)?Q.route:[],label:Q.label||(Q.route||[]).join(" › ")}))),T=await Promise.all(j.map(async Q=>{const H={...Q,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const I=await dr(e,Q.route);H.available=!!I.available,H.capabilities=I.capabilities||[],H.provider=I.provider||null,H.cells=(I.cells||[]).map(G=>({...G,route:Q.route}));try{H.readonly=!!(await Wh(e,Q.route)).readonlyDefault}catch{}try{const G=await Dv(e,Q.route),U=new Set(H.cells.map(q=>q.tmuxSession).filter(Boolean));H.unmanaged=(G.sessions||[]).filter(q=>q&&!U.has(q.name))}catch{}}catch(I){H.err=String(I&&I.message||I)}return H}));x&&c(T)}N();const L=setInterval(N,6e3);return()=>{x=!1,clearInterval(L)}},[e,t,d]);const p=(x,N)=>Array.isArray(x.capabilities)&&x.capabilities.includes(N)&&!i&&!x.readonly,S=()=>m(x=>x+1),C=(x,N)=>{s&&s({...x,route:N})},_=(x,N)=>{s&&s({...x,route:N})},v=async(x,N)=>{try{await Gs(e,x.cell,N)}catch{}S()},w=async(x,N)=>{if(window.confirm(y("fleet-remove-cell").replace("{id}",x.cell))){try{await kv(e,x.cell,!0,N)}catch{}S()}},b=async(x,N)=>{if(window.confirm(y("terminate-confirm").replace("{name}",x.name))){try{await $h(e,x.name,N)}catch{}S()}};return h.jsxs("div",{className:"nc-fleet-inventory",children:[h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:y("fleet-inventory")}),h.jsx("small",{children:y("fleet-inventory-help")})]}),l.map(x=>{const N=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} ${y("fleet-cells")} · ${x.unmanaged.length} ${y("fleet-tmux")}`:x.err||y("fleet-not-available")})]}),x.cells.map(L=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[h.jsxs("span",{children:[h.jsx("b",{children:L.cell}),h.jsx("small",{children:`${L.engine||""}${L.key?`·${L.key}`:""}${L.active?"":` · ${y("cell-off")}`}`})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[L.active&&p(x,"down")&&h.jsx("button",{className:"nc-btn ghost",title:y("power-off"),onClick:()=>_(L,x.route),children:y("stop")}),!L.active&&p(x,"up")&&h.jsx("button",{className:"nc-btn ghost",title:y("power-on"),onClick:()=>C(L,x.route),children:y("start")}),p(x,"restart")&&L.active&&h.jsx("button",{className:"nc-btn ghost",title:y("restart"),onClick:()=>v(L,x.route),children:y("restart")}),p(x,"remove")&&h.jsx("button",{className:"nc-btn danger",title:y("delete"),onClick:()=>w(L,x.route),children:"×"})]})]},`${N}:${L.cell}`)),x.unmanaged.map(L=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[h.jsxs("span",{children:[h.jsx("b",{children:L.name}),h.jsx("small",{children:y("fleet-tmux")})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[p(x,"import")&&o&&h.jsx("button",{className:"nc-btn ghost",title:y("import-as-cell"),onClick:()=>o(L,x.route),children:y("import-as-cell")}),h.jsx("button",{className:"nc-btn danger",title:y("terminate"),onClick:()=>b(L,x.route),children:"×"})]})]},`${N}:u:${L.name}`)),x.available&&x.cells.length===0&&x.unmanaged.length===0&&h.jsx("div",{className:"nc-empty",children:y("fleet-inventory-empty")})]},N)})]})}function Vk({cells:e=[],engines:t=[],busy:i,canRestore:s=!1,onRestore:o,onClose:l}){const[c,d]=P.useState("export"),[m,p]=P.useState(()=>new Set(e.map(E=>E.id))),[S,C]=P.useState(()=>new Set(t.map(E=>E.id))),[_,v]=P.useState([]),[w,b]=P.useState([]),[x,N]=P.useState(""),L=new Set(t.map(E=>E.id)),j=new Set(e.map(E=>E.id)),T=(E,R)=>E(F=>{const D=new Set(F);return D.has(R)?D.delete(R):D.add(R),D}),Q=()=>{const E=Fk(e,m,t,S),R=t.filter(z=>S.has(z.id)).length;if(E.engines.length!==R){N(y("fleet-backup-invalid-engine"));return}if(!E.cells.length&&!E.engines.length){N(y("fleet-backup-select-one"));return}const F=new Blob([`${JSON.stringify(E,null,2)}
|
|
91
|
+
`],{type:"application/json"}),D=URL.createObjectURL(F),O=document.createElement("a");O.href=D,O.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(O),O.click(),O.remove(),setTimeout(()=>URL.revokeObjectURL(D),0),N("")},H=async E=>{if(N(""),v([]),b([]),!!E){if(E.size>1024*1024){N(y("fleet-backup-too-large"));return}try{const R=Hk(await E.text());if(!R.ok){N(y(`fleet-backup-${R.error}`));return}const F=new Set(R.engines.map(D=>D.id));b(R.engines.map(D=>({engine:D,exists:L.has(D.id),selected:!L.has(D.id)}))),v(R.cells.map(D=>{const O=L.has(D.engine)||F.has(D.engine),z=j.has(D.id);return{cell:D,engine:O?D.engine:"",selected:O&&!z,exists:z}}))}catch(R){N(String(R.message||R))}}},I=(E,R)=>v(F=>F.map((D,O)=>O===E?{...D,...R}:D)),G=(E,R)=>b(F=>F.map((D,O)=>O===E?{...D,...R}:D)),U=new Set([...L,...w.filter(E=>E.selected).map(E=>E.engine.id)]),q=_.filter(E=>E.selected&&E.engine&&U.has(E.engine)),X=w.filter(E=>E.selected),A=[...new Map([...t.map(E=>[E.id,E.label||E.id]),...w.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:y("fleet-backup")}),h.jsx("small",{children:y("fleet-backup-help")}),h.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[h.jsx("button",{type:"button",className:`nc-set-tabbtn${c==="export"?" on":""}`,onClick:()=>{d("export"),N("")},children:y("fleet-backup-export")}),h.jsx("button",{type:"button",className:`nc-set-tabbtn${c==="import"?" on":""}`,disabled:!s,title:s?"":y("fleet-backup-restore-unavailable"),onClick:()=>{d("import"),N("")},children:y("fleet-backup-import")})]}),c==="export"?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{p(new Set(e.map(E=>E.id))),C(new Set(t.map(E=>E.id)))},children:y("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{p(new Set),C(new Set)},children:y("select-none")})]}),h.jsxs("div",{className:"nc-backup-list",children:[h.jsx("b",{children:y("fleet-engines")}),t.map(E=>{var R;return h.jsxs("label",{className:"nc-check nc-backup-row",children:[h.jsx("input",{type:"checkbox",checked:S.has(E.id),onChange:()=>T(C,E.id)}),h.jsxs("span",{children:[h.jsx("b",{children:E.label||E.id}),h.jsxs("small",{children:[E.id,(R=E.envKeys)!=null&&R.length?` · ${E.envKeys.length} ${y("fleet-backup-env-names")}`:""]})]})]},E.id)}),h.jsx("b",{children:y("fleet-cells")}),e.map(E=>h.jsxs("label",{className:"nc-check nc-backup-row",children:[h.jsx("input",{type:"checkbox",checked:m.has(E.id),onChange:()=>T(p,E.id)}),h.jsxs("span",{children:[h.jsx("b",{children:E.id}),h.jsxs("small",{children:[E.engine," · ",y("fleet-system-prompt")," ",(E.prompt||"").length," ",y("characters")]})]})]},E.id)),!e.length&&!t.length&&h.jsx("div",{className:"nc-empty",children:y("fleet-backup-empty")})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:y("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:!m.size&&!S.size,onClick:Q,children:y("fleet-backup-download")})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"file",accept:"application/json,.json",disabled:i,onChange:E=>H(E.target.files&&E.target.files[0])}),h.jsx("small",{children:y("fleet-backup-import-help")}),!!(_.length||w.length)&&h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{b(E=>E.map(R=>({...R,selected:!0}))),v(E=>E.map(R=>({...R,selected:!!R.engine})))},children:y("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{b(E=>E.map(R=>({...R,selected:!1}))),v(E=>E.map(R=>({...R,selected:!1})))},children:y("select-none")})]}),h.jsxs("div",{className:"nc-backup-list",children:[!!w.length&&h.jsx("b",{children:y("fleet-engines")}),w.map((E,R)=>{var F;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:D=>G(R,{selected:D.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?y("fleet-backup-overwrite"):y("fleet-backup-new"),(F=E.engine.envKeys)!=null&&F.length?` · ${y("fleet-backup-env-values-required")}`:""]})]})]})},E.engine.id)}),!!_.length&&h.jsx("b",{children:y("fleet-cells")}),_.map((E,R)=>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:F=>I(R,{selected:F.target.checked})}),h.jsxs("span",{children:[h.jsx("b",{children:E.cell.id}),h.jsxs("small",{children:[E.exists?y("fleet-backup-overwrite"):y("fleet-backup-new")," · ",y("fleet-system-prompt")," ",E.cell.systemPrompt.length," ",y("characters")]})]})]}),h.jsxs("select",{value:E.engine,onChange:F=>I(R,{engine:F.target.value,selected:!!F.target.value}),children:[h.jsx("option",{value:"",children:y("fleet-backup-engine-missing")}),A.map(([F,D])=>h.jsx("option",{value:F,children:D},F))]})]},E.cell.id))]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:y("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||!q.length&&!X.length,onClick:()=>o({engineRows:w,cellRows:_}),children:y("fleet-backup-restore")})]})]}),x&&h.jsx("div",{className:"nc-err",children:x})]})}function Yk({state:e,setState:t,busy:i,onSave:s,catalog:o}){var _;const l=e.form,c=v=>t({...e,form:{...l,...v}}),d=l.envRows||[],m=[...new Map(o.map(v=>[v.client,v.clientLabel||v.client])).entries()],p=o.filter(v=>v.client===l.client),S=tl(o,l),C=v=>{v&&c({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?y("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"?y("fleet-new-engine"):`${y("edit")} ${l.id}`}),h.jsx("input",{value:l.id,disabled:e.mode!=="new",placeholder:"id",onChange:v=>c({id:v.target.value})}),h.jsx("input",{value:l.label,placeholder:y("label"),onChange:v=>c({label:v.target.value})}),h.jsxs("select",{value:l.kind,disabled:e.mode!=="new",onChange:v=>c({kind:v.target.value}),children:[h.jsx("option",{value:"managed",children:y("fleet-managed")}),h.jsx("option",{value:"custom",children:y("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=>C(o.find(w=>w.client===v.target.value&&w.default)||o.find(w=>w.client===v.target.value)),children:m.map(([v,w])=>h.jsx("option",{value:v,children:w},v))}),h.jsx("select",{value:((_=tl(o,l))==null?void 0:_.id)||"",disabled:e.mode!=="new",onChange:v=>C(o.find(w=>w.id===v.target.value)),children:p.map(v=>h.jsx("option",{value:v.id,children:v.label},v.id))})]}),h.jsx("input",{value:l.managedModel,list:"nc-managed-models",placeholder:y(S!=null&&S.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:v=>c({managedModel:v.target.value})}),h.jsx("datalist",{id:"nc-managed-models",children:[...(S==null?void 0:S.models)||[],...l.modelOptions||[]].filter((v,w,b)=>v&&b.indexOf(v)===w).map(v=>h.jsx("option",{value:v},v))}),S!=null&&S.supportsUnsafe?h.jsxs("select",{value:l.permissionPolicy,onChange:v=>c({permissionPolicy:v.target.value}),children:[h.jsx("option",{value:"standard",children:y("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:y("fleet-unsafe-permissions")})]}):h.jsx("small",{children:y("fleet-standard-permissions")}),(S==null?void 0:S.supportsUnsafe)&&l.permissionPolicy==="unsafe"&&h.jsx("small",{className:"nc-err",children:y("fleet-unsafe-warning")}),(S==null?void 0:S.credentialEnv)&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.envKey,placeholder:y("fleet-api-key-env"),onChange:v=>c({envKey:v.target.value})}),h.jsx("small",{children:y("fleet-custom-secret-help")})]}),l.provider==="custom"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.displayName,placeholder:y("fleet-provider-display"),onChange:v=>c({displayName:v.target.value})}),h.jsx("input",{value:l.baseUrl,placeholder:"https://api.example.com/v1",onChange:v=>c({baseUrl:v.target.value})}),((S==null?void 0:S.protocols)||[]).length>1&&h.jsx("select",{value:l.protocol,onChange:v=>c({protocol:v.target.value}),children:S.protocols.map(v=>h.jsx("option",{value:v,children:v},v))}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:l.envKey,placeholder:y("fleet-api-key-env"),onChange:v=>c({envKey:v.target.value})}),h.jsx("input",{value:l.providerId,placeholder:y("fleet-provider-id"),onChange:v=>c({providerId:v.target.value})})]}),h.jsxs("small",{children:[l.protocol," · ",y("fleet-custom-secret-help")]})]}),h.jsx("small",{children:y("fleet-managed-help")})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.command,placeholder:y("command-path"),onChange:v=>c({command:v.target.value})}),h.jsx("textarea",{value:l.argsText,placeholder:y("args-lines"),onChange:v=>c({argsText:v.target.value})}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:l.rc,onChange:v=>c({rc:v.target.checked})})," remote control"]}),h.jsxs("select",{value:l.promptMode,onChange:v=>c({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=>c({promptFlag:v.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:l.modelFlag,placeholder:"model flag",onChange:v=>c({modelFlag:v.target.value})}),h.jsx("input",{value:l.modelValue,placeholder:"model default",onChange:v=>c({modelValue:v.target.value})})]}),h.jsx("small",{children:y("env-write-only")}),d.map((v,w)=>h.jsxs("div",{className:"nc-fleet-env",children:[h.jsx("input",{value:v.key,disabled:v.configured,placeholder:"ENV_KEY",onChange:b=>{const x=d.slice();x[w]={...v,key:b.target.value},c({envRows:x})}}),h.jsx("input",{type:"password",value:v.value,placeholder:v.configured?"•••••• (unchanged)":"value",onChange:b=>{const x=d.slice();x[w]={...v,value:b.target.value},c({envRows:x})}}),h.jsx("button",{className:"nc-btn danger",onClick:()=>c({envRows:d.filter((b,x)=>x!==w)}),children:"×"})]},`${v.key}-${w}`)),h.jsx("button",{className:"nc-btn ghost",onClick:()=>c({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:y("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:i||!l.id||l.kind==="custom"&&!l.command||l.kind==="managed"&&(S==null?void 0:S.requiresModel)&&!l.managedModel||l.kind==="managed"&&(S==null?void 0:S.credentialEnv)&&!l.envKey||l.kind==="managed"&&l.provider==="custom"&&(!l.displayName||!l.baseUrl||!l.envKey||!l.providerId),onClick:s,children:y("save")})]})]})}function Xk({token:e,route:t,targets:i=[],location:s,setLocation:o,state:l,setState:c,engines:d,busy:m,onSave:p}){const[S,C]=P.useState(null),[_,v]=P.useState(""),w=l.form,b=j=>c({...l,form:{...w,...j}}),x=d.find(j=>j.id===w.engine),N=j=>{var Q,H,I;const T=d.find(G=>G.id===j);b({engine:j,model:((Q=w.models)==null?void 0:Q[j])||((H=T==null?void 0:T.managed)==null?void 0:H.model)||((I=T==null?void 0:T.model)==null?void 0:I.value)||""})},L=async j=>{try{const T=await Nv(e,j,t);C(T),b({cwd:T.path}),v("")}catch(T){v(String(T.message||T))}};return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsx("b",{children:l.mode==="new"?y("fleet-new-cell"):`${y("edit")} ${w.id}`}),l.mode==="new"&&h.jsxs("label",{className:"nc-field",children:[y("location"),h.jsx("span",{className:"nc-req",children:" *"}),h.jsxs("select",{value:s,onChange:j=>{o(j.target.value),b({engine:""})},children:[h.jsx("option",{value:"",children:y("local")}),i.map(j=>h.jsxs("option",{value:j.route.join("/"),disabled:j.status&&j.status!=="up",children:[j.label,j.status&&j.status!=="up"?` · ${y("node-offline")}`:""]},j.route.join("/")))]})]}),h.jsx("input",{value:w.id,disabled:l.mode!=="new",placeholder:"id",onChange:j=>b({id:j.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:w.cwd,placeholder:y("cwd"),onChange:j=>b({cwd:j.target.value})}),h.jsx("button",{className:"nc-btn ghost",onClick:()=>S?C(null):L(w.cwd),children:y("browse")})]}),S&&h.jsxs("div",{className:"nc-fs",children:[h.jsx("div",{className:"nc-fs-path",children:S.path}),h.jsxs("div",{className:"nc-fs-list",children:[S.parent&&h.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>L(S.parent),children:["↑ ",y("fs-parent")]}),(S.dirs||[]).map(j=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>L(`${S.path.replace(/\/$/,"")}/${j}`),children:["📁 ",j]},j))]})]}),_&&h.jsx("div",{className:"nc-err",children:_}),h.jsx("select",{value:w.engine,onChange:j=>N(j.target.value),children:d.map(j=>h.jsx("option",{value:j.id,children:j.label},j.id))}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:!!w.boot,onChange:j=>b({boot:j.target.checked})})," boot"]}),h.jsx("input",{value:w.model||"",list:"nc-cell-models",placeholder:y("fleet-model-override"),onChange:j=>b({model:j.target.value})}),h.jsx("datalist",{id:"nc-cell-models",children:((x==null?void 0:x.availableModels)||[]).map(j=>h.jsx("option",{value:j},j))}),h.jsx("textarea",{value:w.prompt||"",placeholder:"prompt",onChange:j=>b({prompt:j.target.value})}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>c(null),children:y("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:m||!w.id||!w.cwd||!w.engine,onClick:p,children:y("save")})]})]})}function mv({token:e,route:t=[],state:i,setState:s,busy:o,onSave:l}){const[c,d]=P.useState(null),[m,p]=P.useState([]),[S,C]=P.useState(""),_=Array.isArray(t)?t.join("/"):"";P.useEffect(()=>{let N=!0;return Hh(e,_?_.split("/"):[]).then(L=>{N&&(p(L.engines||[]),C(""))}).catch(L=>{N&&(p([]),C(String(L.message||L)))}),()=>{N=!1}},[e,_]);const v=i.form,w=N=>s({...i,form:{...v,...N}}),b=async N=>{try{const L=await Nv(e,N,t);d(L),w({cwd:L.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:[y("import-as-cell")," · ",v.tmuxSession]}),h.jsx("small",{children:y("import-help")}),h.jsx("input",{value:v.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),h.jsx("input",{value:v.id,placeholder:y("name"),onChange:N=>w({id:N.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:v.cwd,placeholder:y("cwd"),onChange:N=>w({cwd:N.target.value})}),h.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>c?d(null):b(v.cwd),children:y("browse")})]}),c&&h.jsxs("div",{className:"nc-fs",children:[h.jsx("div",{className:"nc-fs-path",children:c.path}),h.jsxs("div",{className:"nc-fs-list",children:[c.parent&&h.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>b(c.parent),children:["↑ ",y("fs-parent")]}),(c.dirs||[]).map(N=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>b(`${c.path.replace(/\/$/,"")}/${N}`),children:["📁 ",N]},N))]})]}),h.jsxs("select",{value:v.engine,onChange:N=>w({engine:N.target.value}),children:[h.jsx("option",{value:"",children:y("import-engine-required")}),m.map(N=>h.jsx("option",{value:N.id,children:N.label},N.id))]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:!!v.boot,onChange:N=>w({boot:N.target.checked})})," boot"]}),(i.err||S)&&h.jsx("div",{className:"nc-err",children:i.err||S}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:y("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:o||!v.tmuxSession||!v.engine||!m.length,onClick:l,children:y(x?"import-as-cell":"save")})]})]})}function Gk({token:e,readonly:t,targets:i=[],startNewCell:s=!1,initialLocation:o=""}){const[l,c]=P.useState({engines:[],cells:[],managedCatalog:[]}),[d,m]=P.useState({available:!1,capabilities:[]}),[p,S]=P.useState(null),[C,_]=P.useState(null),[v,w]=P.useState(!1),[b,x]=P.useState(""),[N,L]=P.useState(""),[j,T]=P.useState(o),[Q,H]=P.useState(!1),[I,G]=P.useState(null),[U,q]=P.useState(null),[X,A]=P.useState(!1),[E,R]=P.useState([]),[F,D]=P.useState(null),[O,z]=P.useState("manage"),ie=P.useRef(!1),K=j?j.split("/"):[],M=P.useCallback(async()=>{try{const ee=await dr(e,K);m(ee);try{const _e=await Wh(e,K);H(!!_e.readonlyDefault)}catch{H(!1)}if(ee.provider==="builtin"&&(ee.capabilities||[]).includes("definitions")){const _e=await Hh(e,K),Be=new Map((ee.engines||[]).map(Ie=>[Ie.id,Ie]));if(_e.engines=(_e.engines||[]).map(Ie=>{var Fe;return{...Ie,availableModels:((Fe=Be.get(Ie.id))==null?void 0:Fe.models)||[]}}),c(_e),(ee.capabilities||[]).includes("credentials"))try{R((await Pw(e,K)).credentials||[])}catch{R([])}else R([])}}catch(ee){x(String(ee.message||ee))}},[e,j]);P.useEffect(()=>{M();const ee=setInterval(M,5e3);return()=>clearInterval(ee)},[M]);const W=new Set((d.cells||[]).filter(ee=>ee.active).map(ee=>ee.cell)),oe=d.provider==="builtin"&&(d.capabilities||[]).includes("edit"),ae=(d.capabilities||[]).includes("restore");P.useEffect(()=>{!s||ie.current||!oe||!l.engines.length||(ie.current=!0,_({mode:"new",form:fv(l.engines[0].id)}))},[s,oe,l.engines]);const se=async ee=>{w(!0),x(""),L("");try{await ee(),await M()}catch(_e){x(String(_e.message||_e))}w(!1)},le=()=>se(async()=>{const ee=p.mode==="new",_e=qk(p.form,ee,l.managedCatalog||[]);!ee&&p.form.kind==="custom"&&!p.form.modelFlag&&(_e.model=null),!ee&&p.form.kind==="custom"&&p.form.promptMode!=="flag"&&(_e.promptFlag=null);let Be;if(ee)Be=await Lw(e,_e,K);else{const Fe=p.original,gt=new Set(p.form.envRows.filter(Ee=>!Ee.remove).map(Ee=>Ee.key)),ve=(Fe.envKeys||[]).filter(Ee=>!gt.has(Ee)),be=Object.fromEntries(p.form.envRows.filter(Ee=>!Ee.remove&&Ee.key&&(!Ee.configured||Ee.value!=="")).map(Ee=>[Ee.key,Ee.value]));Be=await jw(e,Fe.id,_e,p.form.kind==="custom"?{set:be,remove:ve}:void 0,K)}S(null),L(y("fleet-saved"));const Ie=(Be==null?void 0:Be.activeCells)||[];if(Ie.length&&window.confirm(y("fleet-restart-confirm").replace("{cells}",Ie.join(", "))))for(const Fe of Ie)await Gs(e,Fe,K)}),ye=()=>se(async()=>{const ee=C.mode==="new",_e=C.form,Be={...ee?{id:_e.id}:{},cwd:_e.cwd,engine:_e.engine,boot:!!_e.boot};ee?(_e.model&&(Be.model=_e.model),_e.prompt&&(Be.prompt=_e.prompt)):(Be.model=_e.model||null,Be.prompt=_e.prompt||null);const Ie=ee?await Aw(e,Be,K):await Bw(e,C.original.id,Be,K),Fe=ee?_e.id:C.original.id;_(null),L(y("fleet-saved")),!ee&&(Ie!=null&&Ie.active)&&window.confirm(y("fleet-restart-confirm").replace("{cells}",Fe))&&await Gs(e,Fe,K)}),ce=t||Q,Y=ee=>E.find(_e=>{var Be;return(Be=_e.engines)==null?void 0:Be.includes(ee.id)})||null,ne=()=>se(async()=>{var Be;const ee=await Dw(e,F.envKey,F.value,K);R(ee.credentials||[]),D(null),L(y("fleet-credential-saved"));const _e=((Be=(ee.credentials||[]).find(Ie=>Ie.envKey===F.envKey))==null?void 0:Be.activeCells)||[];if(_e.length&&window.confirm(y("fleet-restart-confirm").replace("{cells}",_e.join(", "))))for(const Ie of _e)await Gs(e,Ie,K)}),Te=ee=>se(async()=>{if(!window.confirm(y("fleet-credential-remove-confirm").replace("{key}",ee.envKey)))return;const _e=await Mw(e,ee.envKey,K);R(_e.credentials||[]),L(y("fleet-credential-removed"))}),De=ee=>G({...ee,route:Array.isArray(ee==null?void 0:ee.route)?ee.route:K}),ge=async ee=>{if(!I)return;const _e=I.cell||I.id,Be=Array.isArray(I.route)?I.route:K;ee.action==="up"?await Fh(e,{cell:_e,boot:!!ee.boot,...ee.engine?{engine:ee.engine}:{},...ee.model!==void 0?{model:ee.model}:{},...ee.permissionPolicy?{permissionPolicy:ee.permissionPolicy}:{}},Be):await Fa(e,{cell:_e,boot:!!ee.boot},Be)},Z=(ee,_e)=>{x(""),q({mode:"new",route:Array.isArray(_e)?_e:K,form:{tmuxSession:ee.name,id:"",engine:"",cwd:"",boot:!1},err:""})},Ce=()=>se(async()=>{const ee=U.form;if(!ee.engine){q({...U,err:y("import-engine-required")});return}await Iw(e,{tmuxSession:ee.tmuxSession,id:ee.id||void 0,engine:ee.engine,cwd:ee.cwd||void 0,boot:!!ee.boot},ee.route||K),q(null),L(y("fleet-saved"))}),Pe=({engineRows:ee=[],cellRows:_e=[]})=>se(async()=>{const Be=ee.filter(We=>We.selected),Ie=Be.map(We=>my(We.engine));if(Ie.some(We=>!We))throw new Error(y("fleet-backup-invalid-engine"));const Fe=Be.filter(We=>We.exists).map(We=>We.engine.id);if(Fe.length&&!window.confirm(y("fleet-backup-confirm-engine-overwrite").replace("{engines}",Fe.join(", "))))return;const gt=[...new Set([...l.engines.map(We=>We.id),...Ie.map(We=>We.id)])],ve=[];for(const We of _e.filter(fe=>fe.selected)){const fe=$k(We.cell,We.engine,gt);if(!fe)throw new Error(`${We.cell.id}: ${y("fleet-backup-engine-missing")}`);ve.push(fe)}const be=_e.filter(We=>We.selected&&We.exists).map(We=>We.cell.id);if(be.length&&!window.confirm(y("fleet-backup-confirm-overwrite").replace("{cells}",be.join(", "))))return;const Ee=Ie.length?await zw(e,Ie,Fe.length>0,K):{needsRestart:[]},Ye=ve.length?await Ow(e,ve,K):{needsRestart:[]},rt=[...new Set([...Ee.needsRestart||[],...Ye.needsRestart||[]])];A(!1),L(`${y("fleet-backup-restored").replace("{n}",String(ve.length))}${Ie.length?` · ${Ie.length} ${y("fleet-engines").toLowerCase()}`:""}${rt.length?` · ${y("fleet-backup-needs-restart").replace("{cells}",rt.join(", "))}`:""}`)}),Ne=h.jsxs("label",{className:"nc-field",children:[y("location"),h.jsxs("select",{value:j,onChange:ee=>{T(ee.target.value),S(null),_(null),x(""),L(""),H(!1),m({available:!1,capabilities:[]}),c({engines:[],cells:[],managedCatalog:[]}),R([]),D(null)},children:[h.jsx("option",{value:"",children:y("local")}),i.map(ee=>h.jsxs("option",{value:ee.route.join("/"),disabled:ee.status&&ee.status!=="up",children:[ee.label,ee.status&&ee.status!=="up"?` · ${y("node-offline")}`:""]},ee.route.join("/")))]})]}),qe=h.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":y("tab-fleet"),children:[h.jsx("button",{type:"button",role:"tab","aria-selected":O==="manage",className:`nc-set-tabbtn${O==="manage"?" on":""}`,onClick:()=>z("manage"),children:y("fleet-manage-location")}),h.jsx("button",{type:"button",role:"tab","aria-selected":O==="overview",className:`nc-set-tabbtn${O==="overview"?" on":""}`,onClick:()=>z("overview"),children:y("fleet-network-overview")})]});return oe?h.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[qe,O==="overview"?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:y("fleet-overview-help")}),h.jsx(pv,{token:e,targets:i,readonly:t,onPower:De,onImport:Z})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:y("fleet-manage-help")}),Ne,h.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:ce||v,onClick:()=>{x(""),A(!0)},children:y("fleet-backup")}),h.jsx("small",{children:y("fleet-backup-help")})]}),h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:y("fleet-cells")}),h.jsx("span",{className:"nc-fleet-head-actions",children:h.jsxs("button",{className:"nc-btn primary",disabled:ce||v||!l.engines.length,onClick:()=>{var ee;x(""),_({mode:"new",form:fv((ee=l.engines[0])==null?void 0:ee.id)})},children:["+ ",y("add")]})})]}),l.cells.map(ee=>{const _e=W.has(ee.id),Be=d.capabilities||[];return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:ee.id}),h.jsxs("small",{children:[ee.engine," · ",ee.cwd,_e?` · ${y("service-active")}`:` · ${y("cell-off")}`]})]}),h.jsxs("span",{children:[_e&&Be.includes("down")&&h.jsx("button",{className:"nc-btn ghost",disabled:ce||v,onClick:()=>se(()=>Fa(e,{cell:ee.id},K)),children:y("stop")}),!_e&&Be.includes("up")&&h.jsx("button",{className:"nc-btn primary",disabled:ce||v,onClick:()=>De({cell:ee.id,id:ee.id,engine:ee.engine,model:ee.model,models:ee.models,permissionPolicies:ee.permissionPolicies,active:!1,boot:ee.boot}),children:y("start")}),_e&&Be.includes("restart")&&h.jsx("button",{className:"nc-btn ghost",disabled:ce||v,onClick:()=>se(()=>Gs(e,ee.id,K)),children:y("restart")}),h.jsx("button",{className:"nc-btn ghost",disabled:ce||v,onClick:()=>{x(""),_({mode:"edit",original:ee,form:{...ee}})},children:y("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:ce||v,onClick:()=>se(async()=>{window.confirm(y("fleet-remove-cell").replace("{id}",ee.id))&&await kv(e,ee.id,!0,K)}),children:"×"})]})]},ee.id)}),h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:y("fleet-engines")}),h.jsxs("button",{className:"nc-btn primary",disabled:ce||v,onClick:()=>{x(""),S({mode:"new",form:Wk()})},children:["+ ",y("add")]})]}),l.engines.map(ee=>{var Be,Ie;const _e=Y(ee);return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:ee.label}),h.jsx("small",{children:ee.managed?`${ee.id} · ${ee.managed.client} / ${ee.managed.provider} · ${(Be=ee.managedInfo)!=null&&Be.configured?y("fleet-ready"):((Ie=ee.managedInfo)==null?void 0:Ie.reason)||y("fleet-not-ready")}`:`${ee.id} · ${ee.command}`}),_e&&h.jsxs("small",{children:[_e.envKey," · ",y(`fleet-credential-source-${_e.source||"missing"}`)]})]}),h.jsxs("span",{children:[_e&&h.jsx("button",{className:"nc-btn ghost",disabled:ce||v,onClick:()=>{x(""),D({envKey:_e.envKey,value:""})},children:_e.configured?y("fleet-credential-change"):y("fleet-credential-set")}),(_e==null?void 0:_e.source)==="local"&&h.jsx("button",{className:"nc-btn danger",disabled:ce||v,onClick:()=>Te(_e),children:y("fleet-credential-forget")}),h.jsx("button",{className:"nc-btn ghost",disabled:ce||v,onClick:()=>{x(""),S({mode:"edit",original:ee,form:Kk(ee)})},children:y("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:ce||v,onClick:()=>se(async()=>{window.confirm(y("fleet-remove-engine").replace("{id}",ee.id))&&await Tw(e,ee.id,K)}),children:"×"})]})]},ee.id)})]}),p&&h.jsx(Wr,{onClose:()=>S(null),label:y("fleet-new-engine"),error:b,children:h.jsx(Yk,{state:p,setState:S,busy:v,onSave:le,catalog:l.managedCatalog||[]})}),C&&h.jsx(Wr,{onClose:()=>_(null),label:y("fleet-new-cell"),error:b,children:h.jsx(Xk,{token:e,route:K,targets:i,location:j,setLocation:T,state:C,setState:_,engines:l.engines,busy:v,onSave:ye})}),N&&h.jsx("div",{className:"nc-set-note",children:N}),b&&h.jsx("div",{className:"nc-err",children:b}),X&&h.jsx(Wr,{onClose:()=>A(!1),label:y("fleet-backup"),error:b,children:h.jsx(Vk,{cells:l.cells,engines:l.engines,busy:v,canRestore:ae,onRestore:Pe,onClose:()=>A(!1)})}),F&&h.jsx(Wr,{onClose:()=>D(null),label:y("fleet-credential-title"),error:b,children:h.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[h.jsx("b",{children:y("fleet-credential-title")}),h.jsx("small",{children:y("fleet-credential-help")}),h.jsxs("label",{className:"nc-field",children:[F.envKey,h.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:F.value,onChange:ee=>D({...F,value:ee.target.value})})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>D(null),children:y("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:v||!F.value,onClick:ne,children:y("save")})]})]})}),U&&h.jsx(Wr,{onClose:()=>q(null),label:y("import-as-cell"),error:b,children:h.jsx(mv,{token:e,route:U.route||K,state:U,setState:q,busy:v,onSave:Ce})}),I&&h.jsx(Ha,{cell:I,token:e,route:Array.isArray(I.route)?I.route:K,onConfirm:async ee=>{try{await ge(ee)}finally{await M()}},onClose:()=>G(null)})]}):h.jsxs("div",{className:"nc-set-tab",children:[qe,O==="overview"?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:y("fleet-overview-help")}),h.jsx(pv,{token:e,targets:i,readonly:t,onPower:De,onImport:Z})]}):h.jsxs(h.Fragment,{children:[Ne,h.jsx("div",{className:"nc-set-info",children:y("fleet-editor-unavailable")})]}),b&&h.jsx("div",{className:"nc-err",children:b}),U&&h.jsx(Wr,{onClose:()=>q(null),label:y("import-as-cell"),error:b,children:h.jsx(mv,{token:e,route:U.route||K,state:U,setState:q,busy:v,onSave:Ce})}),I&&h.jsx(Ha,{cell:I,token:e,route:Array.isArray(I.route)?I.route:K,onConfirm:async ee=>{try{await ge(ee)}finally{await M()}},onClose:()=>G(null)})]})}function Qk({text:e}){const[t,i]=P.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!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(et,{name:"copy",size:14})," ",y(t?"copied":"copy")]})]})}function Jk({value:e}){const[t,i]=P.useState("");return P.useEffect(()=>{let s=!0;return ik.toDataURL(e,{margin:1,width:220}).then(o=>{s&&i(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?h.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function Zk({token:e,nodes:t,settings:i,readonly:s,refresh:o}){const[l,c]=P.useState(null),[d,m]=P.useState(null),[p,S]=P.useState({}),[C,_]=P.useState(null),[v,w]=P.useState({ssh:"",sshPort:"",name:""}),[b,x]=P.useState(""),[N,L]=P.useState(""),[j,T]=P.useState(""),[Q,H]=P.useState(!1),I=Date.now(),G=i&&i.deviceName||"",U=(t||[]).filter(D=>D&&D.direction==="outbound"&&D.name&&D.ssh),q=U.find(D=>D.name===b)||U[0]||null,X=U.find(D=>D.name===N)||U[0]||null,A=X?ov(X.tunnel,I):null,E=async(D,O)=>{c(null),m(`${D}:${O}`);try{const z=await Uh(e,D,O);O==="test"&&S(ie=>({...ie,[D]:z})),await o()}catch(z){c(`${D}: ${String(z.message||z)}`)}m(null)},R=async D=>{if(window.confirm(y("node-remove-confirm").replace("{name}",D))){c(null),m(`${D}:remove`);try{await Uw(e,D),await o()}catch(O){c(`${D}: ${String(O.message||O)}`)}m(null)}},F=async()=>{if(c(null),q){const z=sv({name:q.name,ssh:q.ssh,sshPort:q.sshPort||""});if(!z.ok){c(y(z.error));return}m("invite");try{_(await am(e,{ssh:z.value.ssh,...z.value.sshPort?{sshPort:z.value.sshPort}:{}},[q.name]))}catch(ie){c(String(ie.message||ie))}m(null);return}const D=Xr(v.name||j||G||"NexusCrew"),O=sv({name:D,ssh:v.ssh,sshPort:v.sshPort});if(!O.ok){c(y(O.error));return}m("invite");try{_(await am(e,{...j||G?{label:j||G}:{},name:D,ssh:O.value.ssh,...O.value.sshPort?{sshPort:O.value.sshPort}:{}}))}catch(z){c(String(z.message||z))}m(null)};return h.jsxs("div",{className:"nc-set-tab",children:[h.jsx(ly,{token:e,deviceDefault:G,readonly:s,onSuccess:o}),X&&h.jsxs("div",{className:"nc-set-form nc-local-share",children:[h.jsx("div",{className:"nc-sheet-label",children:y("share-local-heading")}),U.length>1&&h.jsxs("label",{className:"nc-field",children:[y("share-local-hub"),h.jsx("select",{value:X.name,disabled:s||!!d,onChange:D=>L(D.target.value),children:U.map(D=>h.jsx("option",{value:D.name,children:D.label||D.name},D.name))})]}),h.jsxs("label",{className:"nc-check nc-node-share",children:[h.jsx("input",{type:"checkbox",checked:X.shared===!0,disabled:s||!!d||!(A!=null&&A.up)&&!X.shared,onChange:async D=>{c(null),m(`${X.name}:share`);try{await Kw(e,X.name,D.target.checked),await o()}catch(O){c(`${X.name}: ${String(O.message||O)}`)}m(null)}}),h.jsxs("span",{children:[h.jsx("b",{children:y("share-local-through").replace("{device}",G||y("local")).replace("{hub}",X.label||X.name)}),h.jsx("small",{children:y(X.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),h.jsx("div",{className:`nc-set-test${X.shared&&(A!=null&&A.up)?" ok":""}`,children:X.shared?y("share-local-active"):y("share-local-private")})]}),(t||[]).length===0&&h.jsx("div",{className:"nc-empty",children:y("no-nodes")}),(t||[]).map(D=>{var ie,K,M,W,oe;const O=ov(D.tunnel,I),z=p[D.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 ${O.up?"on":""}`}),h.jsx("b",{children:D.label||D.name}),h.jsxs("small",{children:[D.name,D.direction==="outbound"?` · SSH ${D.ssh||""}`:` · ${y("node-connected-client")}`,(ie=D.tunnel)!=null&&ie.transport?` · ${D.tunnel.transport} ${y("transport-used")}`:""]}),h.jsxs("span",{className:`nc-set-tunnel${O.up?" up":""}`,children:[y(O.label),O.since?` · ${O.since}`:""]})]}),D.direction==="inbound"&&h.jsx("div",{className:"nc-set-info",children:y(D.shared?"peer-shared":"peer-private")}),D.direction==="inbound"&&D.shared&&h.jsxs(h.Fragment,{children:[h.jsxs("select",{value:D.visibility||"network",disabled:s||!!d,onChange:async ae=>{m(`${D.name}:visibility`);try{await lm(e,D.name,ae.target.value),await o()}catch(se){c(String(se.message||se))}m(null)},children:[h.jsx("option",{value:"network",children:y("visibility-network")}),h.jsx("option",{value:"relay-only",children:y("visibility-relay")}),h.jsx("option",{value:"selected",children:y("visibility-selected")})]}),D.visibility==="selected"&&h.jsx("div",{className:"nc-set-row",children:(t||[]).filter(ae=>ae.name!==D.name&&ae.nodeId).map(ae=>{const se=(D.selected||[]).includes(ae.nodeId);return h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:se,disabled:s||!!d,onChange:async le=>{const ye=le.target.checked?[...D.selected||[],ae.nodeId]:(D.selected||[]).filter(ce=>ce!==ae.nodeId);m(`${D.name}:visibility`);try{await lm(e,D.name,"selected",ye),await o()}catch(ce){c(String(ce.message||ce))}m(null)}})," ",ae.label||ae.name]},ae.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 ae=window.prompt(y("node-display-label"),D.label||D.name);if(ae!=null){if(!jh(ae)){c(y("err-label"));return}m(`${D.name}:label`);try{await Ww(e,D.name,ae),await o()}catch(se){c(String(se.message||se))}m(null)}},children:y("edit")}),((K=D.health)==null?void 0:K.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(D.name,"test"),children:y("node-test")}),((M=D.health)==null?void 0:M.managed)!==!1&&(O.up?h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(D.name,"down"),children:y("tunnel-stop")}):h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(D.name,"up"),children:y("tunnel-start")})),((W=D.health)==null?void 0:W.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(D.name,"restart"),children:y("tunnel-restart")}),h.jsx("button",{type:"button",className:"nc-btn danger",disabled:s||!!d,title:y(s?"settings-readonly":"terminate"),onClick:()=>R(D.name),children:h.jsx(et,{name:"trash",size:14})})]}),((oe=D.health)==null?void 0:oe.detail)&&h.jsx("div",{className:`nc-set-test${D.health.status==="healthy"?" ok":D.health.status==="passive"?"":" ko"}`,children:D.health.detail}),z&&h.jsxs("div",{className:`nc-set-test${z.ok?" ok":" ko"}`,children:[z.result,z.detail?` — ${z.detail}`:""]})]},D.name)}),h.jsxs("div",{className:"nc-set-form",children:[h.jsx("div",{className:"nc-sheet-label",children:y("invite-node")}),h.jsx("small",{className:"nc-set-hint",children:y(q?"invite-network-hint":"invite-v2-hint")}),q?h.jsxs(h.Fragment,{children:[U.length>1&&h.jsxs("label",{className:"nc-field",children:[y("invite-network-label"),h.jsx("select",{value:q.name,disabled:s||!!d,onChange:D=>{x(D.target.value),_(null)},children:U.map(D=>h.jsx("option",{value:D.name,children:D.label||D.name},D.name))})]}),h.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[y("invite-network-via"),": ",h.jsx("b",{children:q.label||q.name})," · ",q.ssh,q.sshPort?`:${q.sshPort}`:""]}),h.jsx("small",{className:"nc-set-hint",children:y("invite-network-route")})]}):h.jsxs("label",{className:"nc-field",children:[y("invite-endpoint-label"),h.jsx("input",{placeholder:"user@host",value:v.ssh,disabled:s,onChange:D=>w({...v,ssh:D.target.value})}),h.jsx("small",{className:"nc-set-hint",children:y("invite-endpoint-needed")})]}),!q&&Q&&h.jsxs("div",{className:"nc-invite-advanced",children:[h.jsxs("label",{className:"nc-field",children:[y("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:"22",value:v.sshPort,disabled:s,onChange:D=>w({...v,sshPort:D.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),h.jsxs("label",{className:"nc-field",children:[y("device-name-label"),h.jsx("input",{placeholder:G||"NexusCrew",value:j,disabled:s,onChange:D=>T(D.target.value)}),h.jsx("small",{className:"nc-set-hint",children:y("device-name-hint")})]}),h.jsxs("label",{className:"nc-field",children:[y("node-name-label"),h.jsx("input",{placeholder:Xr(j||G||y("node-name-ph")),value:v.name,disabled:s,onChange:D=>w({...v,name:D.target.value?Xr(D.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||!q&&!v.ssh.trim(),onClick:F,children:y("create-pairing-link")}),!q&&h.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>H(D=>!D),children:[Q?"▾":"▸"," ",y("pair-advanced")]})]}),C&&h.jsxs(h.Fragment,{children:[h.jsx(Jk,{value:C.pairingUrl}),h.jsx(Qk,{text:C.pairingUrl}),h.jsx("div",{className:"nc-set-info",children:y("invite-next-steps")})]})]}),l&&h.jsx("div",{className:"nc-err",children:l})]})}function eE({token:e,readonly:t}){const[i,s]=P.useState("idle"),[o,l]=P.useState(!1),[c,d]=P.useState(null);P.useEffect(()=>{let p=!1;return kk().then(S=>{p||s(S)}),()=>{p=!0}},[]);const m=async()=>{d(null),l(!0);try{i==="subscribed"?(await Nk(e),s("idle")):(await Ek(e),s("subscribed"))}catch(p){const S=String(p.message||p);S==="push-denied"?(s("denied"),d(y("push-denied"))):S==="push-unsupported"?(s("unsupported"),d(y("push-unsupported"))):d(S)}l(!1)};return i==="unsupported"?h.jsx("div",{className:"nc-set-info",children:y("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||i==="denied",title:t?y("settings-readonly"):"",onClick:m,children:y(i==="subscribed"?"push-disable":"push-enable")}),h.jsx("span",{className:"nc-set-info",children:y(i==="subscribed"?"push-on":i==="denied"?"push-denied":"push-off")})]}),c&&h.jsx("div",{className:"nc-err",children:c})]})}function tE({token:e,settings:t,readonly:i,refresh:s}){const[o,l]=P.useState(null),[c,d]=P.useState(null),[m,p]=P.useState(!1),[S,C]=P.useState(!1),[_,v]=P.useState(null),[w,b]=P.useState(!0);P.useEffect(()=>{v(t&&t.update||null),b(!t||t.autoUpdate!==!1)},[t]);const x=async()=>{l(null),d(null),C(!0);try{const I=await Hw(e);d(I.note||"ok"),p(!1)}catch(I){l(String(I.message||I))}C(!1)},N=async()=>{l(null),d(null),C(!0);try{const I=await qw(e);d(`${I.note||"ok"}${I.target?` (${I.target})`:""}`)}catch(I){l(String(I.message||I))}C(!1)},L=async I=>{l(null),d(null),C(!0);try{await Mv(e,{autoUpdate:I}),b(I),s&&await s()}catch(G){l(String(G.message||G))}C(!1)},j=async()=>{l(null),d(null),C(!0);try{v(await Vw(e))}catch(I){l(String(I.message||I))}C(!1)},T=async()=>{l(null),d(null),C(!0);try{const I=await Yw(e);v(I),d(y("npm-update-restarting"))}catch(I){l(String(I.message||I))}C(!1)},Q=()=>{window.confirm(y("composer-clear-confirm"))&&(l(null),cx()?(window.dispatchEvent(new Event(Rh)),d(y("composer-clear-done"))):l(y("composer-clear-failed")))},H=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",{}),H&&H.installed?y("service-installed"):y("service-missing"),H&&H.installed?` · ${H.active?y("service-active"):y("service-inactive")}`:"",H?` · boot ${H.boot?"on":"off"}`:""]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||S,title:i?y("settings-readonly"):"",onClick:()=>{l(null),d(null),p(!0)},children:y("token-rotate")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||S,title:i?y("settings-readonly"):"",onClick:N,children:y("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:w,disabled:i||S||_&&!_.supported,onChange:I=>L(I.target.checked)}),h.jsxs("span",{children:[h.jsx("b",{children:y("npm-auto-update")}),h.jsx("small",{children:y("npm-auto-update-help")})]})]}),_&&h.jsxs("div",{className:"nc-set-info",children:[y("npm-update-current")," v",_.current,_.latest?` · ${y("npm-update-latest")} v${_.latest}`:""," · ",y(`npm-update-${_.supported?_.phase:"unsupported"}`)]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||S||!_||!_.supported,onClick:j,children:y("npm-update-check")}),_&&_.available&&h.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||S||_.phase==="installing",onClick:T,children:y("npm-update-install")})]}),_&&_.lastError&&h.jsx("div",{className:"nc-err",children:_.lastError})]}),h.jsx(eE,{token:e,readonly:i}),h.jsxs("div",{className:"nc-set-form",children:[h.jsx("div",{className:"nc-sheet-label",children:y("composer-clear-data")}),h.jsx("small",{className:"nc-set-hint",children:y("composer-clear-data-help")}),h.jsx("div",{className:"nc-set-row",children:h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:Q,children:y("composer-clear-data")})})]}),m&&h.jsxs("div",{className:"nc-set-confirm",children:[h.jsx("div",{children:y("token-rotate-explain")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:S,onClick:()=>p(!1),children:y("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:S,onClick:x,children:y("confirm")})]})]}),c&&h.jsx("div",{className:"nc-set-note",children:c}),o&&h.jsx("div",{className:"nc-err",children:o})]})}function iE({token:e,onClose:t,initialTab:i="nodes",initialLocation:s="",startNewCell:o=!1}){Si();const[l,c]=P.useState(i),[d,m]=P.useState(null),[p,S]=P.useState([]),[C,_]=P.useState(!1),[v,w]=P.useState(null),b=qh(e),x=P.useCallback(async()=>{try{const N=await Rv(e);m(N),w(null)}catch(N){w(String(N.message||N))}try{const N=await Pv(e);S(N.nodes||[])}catch(N){w(String(N.message||N))}},[e]);return P.useEffect(()=>{x();const N=setInterval(x,5e3);return()=>clearInterval(N)},[x]),P.useEffect(()=>{let N=!1;return zt("/api/config",e).then(L=>L.json()).then(L=>{N||_(!!L.readonlyDefault)}).catch(()=>{}),()=>{N=!0}},[e]),h.jsx("div",{className:"nc-set-overlay",onClick:t,children:h.jsxs("div",{className:"nc-set-panel",onClick:N=>N.stopPropagation(),children:[h.jsxs("div",{className:"nc-set-head",children:[h.jsx(et,{name:"gear",size:18}),h.jsx("b",{children:y("settings")}),h.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:y("close"),children:h.jsx(et,{name:"x",size:18})})]}),C&&h.jsx("div",{className:"nc-set-readonly",children:y("settings-readonly")}),v&&h.jsx("div",{className:"nc-err",children:v}),h.jsx("div",{className:"nc-set-tabs",children:["nodes","fleet","system"].map(N=>h.jsx("button",{type:"button",className:`nc-set-tabbtn${l===N?" on":""}`,onClick:()=>c(N),children:y(`tab-${N}`)},N))}),h.jsxs("div",{className:"nc-set-body",children:[l==="nodes"&&h.jsx(Zk,{token:e,nodes:p,settings:d,readonly:C,refresh:x}),l==="fleet"&&h.jsx(Gk,{token:e,readonly:C,startNewCell:o,initialLocation:s,targets:b.map(N=>({route:N.route,label:N.label||N.name,status:N.status}))}),l==="system"&&h.jsx(tE,{token:e,settings:d,readonly:C,refresh:x})]})]})})}function nE({token:e,initialPair:t,onPairDone:i,onDone:s}){Si();const[o,l]=P.useState(t?"pair":"welcome"),[c,d]=P.useState(!1),[m,p]=P.useState(null),S=async()=>{d(!0),p(null);try{await Mv(e,{wizardDone:!0}),i&&i(),s()}catch(C){p(String(C.message||C)),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:y("wizard-title")}),h.jsx("small",{children:y("hydra-simple")})]}),o==="welcome"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:y("local-ready")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:c,onClick:S,children:y("local-only")}),h.jsx("button",{className:"nc-btn primary",disabled:c,onClick:()=>l("pair"),children:y("add-node")})]})]}),o==="pair"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx(ly,{token:e,initial:t||"",autoStart:!!t,onBusyChange:d,onSuccess:async()=>{i&&i(),l("done")}}),h.jsx("div",{className:"nc-sheet-actions",children:h.jsx("button",{className:"nc-btn ghost",disabled:c,onClick:()=>{i&&i(),l("welcome")},children:y("back")})})]}),o==="done"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:y("node-connected")}),h.jsx("div",{className:"nc-sheet-actions",children:h.jsx("button",{className:"nc-btn primary",disabled:c,onClick:S,children:y("finish")})})]}),m&&h.jsx("div",{className:"nc-err",children:m})]})})}function rE(e,t){if(typeof EventSource>"u"||!e)return()=>{};const i=new EventSource(`/api/events?token=${encodeURIComponent(e)}`);return i.onmessage=s=>{try{const o=JSON.parse(s.data);o&&typeof o=="object"&&typeof o.type=="string"&&t(o)}catch{}},()=>{try{i.close()}catch{}}}const sE=6e3,oE=12e3;function aE({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:y("close"),children:h.jsx(et,{name:"x",size:14})})]})}function lE({ask:e,token:t,onAnswered:i}){const[s,o]=P.useState(""),[l,c]=P.useState(!1),[d,m]=P.useState(null),p=async S=>{const C=String(S||"").trim();if(!(!C||l)){m(null),c(!0);try{await Gw(t,e.id,C),i(e.id)}catch(_){m(String(_.message||_))}c(!1)}};return h.jsxs("div",{className:"nc-ask-card",children:[h.jsxs("div",{className:"nc-ask-head",children:[h.jsx("span",{className:"nc-ntf-from",children:e.session}),h.jsxs("code",{className:"nc-ask-id",children:["#",e.id]})]}),h.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&h.jsx("div",{className:"nc-ask-opts",children:e.options.map(S=>h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:l,onClick:()=>p(S),children:S},S))}),h.jsxs("div",{className:"nc-ask-reply",children:[h.jsx("textarea",{rows:2,placeholder:y("ask-reply-ph"),value:s,disabled:l,onChange:S=>o(S.target.value)}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:l||!s.trim(),onClick:()=>p(s),children:y("send")})]}),d&&h.jsx("div",{className:"nc-err",children:d})]})}function cE({token:e}){Si();const[t,i]=P.useState([]),[s,o]=P.useState([]),[l,c]=P.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),d=P.useRef(0),m=P.useCallback(C=>{i(_=>_.filter(v=>v.key!==C))},[]),p=P.useCallback(C=>{const _=`t${d.current+=1}`;i(v=>[...v.slice(-3),{...C,key:_}]),setTimeout(()=>m(_),C.urgency==="high"?oE:sE)},[m]);P.useEffect(()=>{if(!e)return;let C=!1;Xw(e).then(v=>{C||o(v.asks||[])}).catch(()=>{});const _=rE(e,v=>{v.type==="notify"?p(v):v.type==="ask"&&v.ask&&v.ask.id?o(w=>w.some(b=>b.id===v.ask.id)?w:[...w,v.ask]):v.type==="ask-answered"&&v.id&&o(w=>w.filter(b=>b.id!==v.id))});return()=>{C=!0,_()}},[e,p]);const S=C=>o(_=>_.filter(v=>v.id!==C));return h.jsxs(h.Fragment,{children:[t.length>0&&h.jsx("div",{className:"nc-ntf-toasts",children:t.map(C=>h.jsx(aE,{n:C,onClose:()=>m(C.key)},C.key))}),s.length>0&&!l&&h.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>c(!0),title:y("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:y("asks-title")}),h.jsx("span",{className:"nc-ask-count",children:s.length}),h.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>c(!1),title:y("close"),children:h.jsx(et,{name:"x",size:16})})]}),h.jsx("div",{className:"nc-ask-panel-body",children:s.map(C=>h.jsx(lE,{ask:C,token:e,onAnswered:S},C.id))})]})]})}const Fu=e=>Gi(lr(e)).length===0,Hu=e=>Array.isArray(e)?e.join("/"):"";function uE(e){const t=new Set,i=[];for(const s of Array.isArray(e)?e:[])!s||!Mi.test(String(s.instanceId||""))||!Array.isArray(s.route)||!s.route.length||t.has(s.instanceId)||(t.add(s.instanceId),i.push({instanceId:s.instanceId,route:[...s.route],label:String(s.label||s.name||s.route.join(" › ")),status:s.status||"offline"}));return i.sort((s,o)=>s.label.localeCompare(o.label))}function Xs(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function ir(e,t,i,s=!1,o=!0){const l=t.instanceId;return{...e,id:Yr(s?null:l,e.name),ownerId:l,ownerRoute:s?[]:[...t.route],ownerLabel:s?"Local":t.label,local:s,available:o,ownerTopology:Array.isArray(i)?i:[],layout:Dh(e.layout,l,i)}}function hE(e,t,i,s,o=[]){const[l,c]=P.useState([]),[d,m]=P.useState(!1),[p,S]=P.useState("idle"),[C,_]=P.useState(""),[v,w]=P.useState(""),b=P.useRef([]),x=P.useRef([]),N=P.useRef(""),L=P.useRef(t),j=P.useRef(i),T=P.useRef(!1),Q=P.useRef(!0),H=P.useRef(""),I=P.useMemo(()=>uE(o),[o]),G=I.map(K=>`${K.instanceId}:${Hu(K.route)}:${K.status}:${K.label}`).join("|");x.current=I,j.current=i,L.current=t,b.current=l;const U=P.useCallback(K=>Mh(K.layout,N.current,x.current),[]),q=P.useCallback((K,M=!0,W=L.current)=>{const oe=Ng(K,Ma()),ae=b.current.some(le=>le.id===W);b.current=oe,c(oe);const se=oe.find(le=>le.id===W);if(M&&se){Q.current=!0;const le=U(se);s(le),se.local&&Mx(se.name,le)}else ae&&!se&&(Q.current=!0,s(Vr()),_("deck non più condiviso dal nodo owner"));Nx(oe.filter(le=>le.local).map(le=>le.name))},[s,U]),X=P.useCallback(async K=>{let M=await ba(e);const W=M.decks.find(oe=>oe.name==="main");if(M.decks.length===1&&W&&W.revision===0&&Fu(W.layout)){const oe=Ex(),ae=lr(Lh("main")||Vr());if(!Fu(ae)){const se=Dh(ae,K,[]);M.decks[0]=await Ca(e,"main",se,0,[])}for(const se of oe.filter(le=>le!=="main"))try{let le=await cm(e,se,[]);const ye=lr(Lh(se)||Vr());Fu(ye)||(le=await Ca(e,se,Dh(ye,K,[]),le.revision,[]))}catch{}M=await ba(e)}return M},[e]),A=P.useCallback(async({migrate:K=!1}={})=>{const M=await Wh(e,[]),W=Mi.test(String(M.instanceId||""))?M.instanceId:"";if(!W)throw new Error("instanceId locale non disponibile");N.current=W,w(W);const[oe,ae]=await Promise.all([K?X(W):ba(e),om(e,[]).catch(()=>({nodes:[]}))]),se={instanceId:W,route:[],label:"Local"},le=oe.decks.map(ce=>ir(ce,se,ae.nodes,!0,!0)),ye=b.current;return await Promise.all(x.current.map(async ce=>{if(ce.status!=="up"){le.push(...ye.filter(Y=>!Y.local&&Y.ownerId===ce.instanceId).map(Y=>({...Y,ownerRoute:[...ce.route],ownerLabel:ce.label,available:!1})));return}try{const[Y,ne]=await Promise.all([ba(e,ce.route),om(e,ce.route).catch(()=>({nodes:[]}))]);le.push(...Y.decks.map(Te=>ir(Te,ce,ne.nodes,!1,!0)))}catch{le.push(...ye.filter(ne=>!ne.local&&ne.ownerId===ce.instanceId).map(ne=>({...ne,ownerRoute:[...ce.route],ownerLabel:ce.label,available:!1})))}})),le.sort((ce,Y)=>ce.local===Y.local?ce.ownerLabel.localeCompare(Y.ownerLabel)||(ce.name==="main"?-1:Y.name==="main"?1:ce.name.localeCompare(Y.name)):ce.local?-1:1),le},[e,X,G]);P.useEffect(()=>{if(!e)return;let K=!1;const M=H.current!==e;return H.current=e,A({migrate:M}).then(W=>{if(K)return;const oe=b.current.find(le=>le.id===L.current),ae=W.find(le=>le.id===L.current),se=ae&&(!oe||ae.revision>oe.revision||oe.available!==ae.available||Hu(oe.ownerRoute)!==Hu(ae.ownerRoute));q(W,M||!!se&&!T.current),m(!0),ae&&_("")}).catch(W=>{K||(m(!0),_(String(W.message||W)))}),()=>{K=!0}},[q,A,G,e]);const E=P.useCallback(async(K=L.current)=>{if(!d||!T.current)return!0;const M=b.current.find(W=>W.id===K);if(!M)return _(`deck inesistente: ${K}`),!1;if(M.available===!1)return _(`nodo owner offline: ${M.ownerLabel}`),!1;S("saving");try{const W=kg(lr(j.current),M.ownerId,M.ownerTopology),oe=await Ca(e,M.name,W,M.revision,M.ownerRoute),ae=ir(oe,Xs(M),M.ownerTopology,M.local,!0);return q(b.current.map(se=>se.id===K?ae:se),!1),T.current=!1,S("saved"),_(""),setTimeout(()=>S("idle"),1500),!0}catch(W){if(S("error"),_(String(W.message||W)),W.status===409&&W.data&&W.data.current){const oe=b.current.find(se=>se.id===K),ae=ir(W.data.current,Xs(oe),oe.ownerTopology,oe.local,!0);q(b.current.map(se=>se.id===K?ae:se),!1)}return!1}},[d,e,q]);return P.useEffect(()=>{if(!d)return;if(Q.current){Q.current=!1;return}T.current=!0,S("saving");const K=setTimeout(E,650);return()=>clearTimeout(K)},[i,d,E]),P.useEffect(()=>{if(!d)return;const K=setInterval(async()=>{try{const M=await A(),W=b.current.find(se=>se.id===L.current),oe=M.find(se=>se.id===L.current),ae=oe&&(!W||oe.revision>W.revision||W.available!==oe.available);q(M,ae&&!T.current)}catch{}},5e3);return()=>clearInterval(K)},[d,A,q]),{decks:l,records:l,localNodeId:v,ready:d,saveState:p,error:C,setError:_,saveNow:E,select:async K=>{if(T.current&&!await E(L.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const M=b.current.find(W=>W.id===K);if(!M)throw new Error(`deck inesistente: ${K}`);return T.current=!1,Q.current=!0,U(M)},add:async(K,M=null)=>{const W=M===un?b.current.find(se=>se.local):M?b.current.find(se=>se.ownerId===M):null;if(!W||W.available===!1)throw new Error("nodo owner non disponibile");const oe=await cm(e,K,W.ownerRoute),ae=ir(oe,Xs(W),W.ownerTopology,W.local,!0);return q([...b.current,ae],!1),ae},rename:async(K,M)=>{const W=b.current.find(ye=>ye.id===K);if(!W)throw new Error("deck inesistente");if(K===L.current&&T.current&&!await E(K))throw new Error(`salvataggio di "${W.name}" fallito: rinomina annullata`);const oe=b.current.find(ye=>ye.id===K);if(!oe)throw new Error("deck inesistente");const ae=await Qw(e,oe.name,M,oe.revision,oe.ownerRoute),se=ir(ae,Xs(oe),oe.ownerTopology,oe.local,!0),le=oe.local?un:oe.ownerId;return gu(Px(Ma(),le,K,se.id)),q(b.current.map(ye=>ye.id===K?se:ye),!1),se},remove:async K=>{const M=b.current.find(oe=>oe.id===K);if(!M)throw new Error("deck inesistente");K===L.current&&(T.current=!1),await Jw(e,M.name,M.revision,M.ownerRoute);const W=M.local?un:M.ownerId;gu(Dx(Ma(),W,K)),q(b.current.filter(oe=>oe.id!==K),!1)},reorder:(K,M)=>{const W=b.current.find(ce=>ce.id===K),oe=b.current.find(ce=>ce.id===M);if(!W||!oe)return!1;const ae=W.local?un:W.ownerId,se=oe.local?un:oe.ownerId;if(ae!==se)return!1;const le=b.current.filter(ce=>(ce.local?un:ce.ownerId)===ae).map(ce=>ce.id),ye=gu(Rx(Ma(),ae,K,M,le));return q(Ng(b.current,ye),!1),!0},addTileTo:async(K,M)=>{const W=b.current.find(ce=>ce.id===K);if(!W)throw new Error("deck inesistente");if(W.available===!1)throw new Error(`nodo owner offline: ${W.ownerLabel}`);const oe=G_(M,N.current,x.current);if(!oe)throw new Error("riferimento sessione non valido");const ae=U(W),se=kg(qv(ae,oe),W.ownerId,W.ownerTopology),le=await Ca(e,W.name,se,W.revision,W.ownerRoute),ye=ir(le,Xs(W),W.ownerTopology,W.local,!0);return q(b.current.map(ce=>ce.id===K?ye:ce),!1),ye},localMainId:Yr(null,"main"),parseDeckId:ad}}const dE="/sw.js",Th="nc-sw-update";let Ah=null,Bh=!1,Ih=null,vy=Object.freeze({needed:!1,kind:null,version:""}),_y=!1;function yy(){typeof window<"u"&&window.dispatchEvent(new Event(Th))}function Sy(){const e=Ih||(Bh?{kind:"reload",version:""}:null);vy=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function gv(){return vy}function fE(e){return typeof window>"u"?()=>{}:(window.addEventListener(Th,e),()=>window.removeEventListener(Th,e))}function dd(e){Bh!==e&&(Bh=e,Sy(),yy())}function pE(e,t,i){let s=null;e&&t&&e!==t?s={kind:"install",version:e}:t&&i&&t!==i&&(s={kind:"reload",version:t});const o=JSON.stringify(s)===JSON.stringify(Ih);Ih=s,Sy(),o||yy()}function mE(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&dd(!0)})}function gE(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{_y&&location.reload()}),navigator.serviceWorker.register(dE).then(e=>{Ah=e,e.waiting&&dd(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&mE(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function vE(){_y=!0,dd(!1);const e=Ah&&Ah.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function _E({hash:e="",origin:t="",pathname:i="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),l=`${i||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:l};const c=new URLSearchParams(o),d=c.get("token")||"",m=c.get("pair")||"",p=m?`${t||""}${i||""}#pair=${m}`:"";return{token:d,pair:p,nextUrl:l}}const wy=9,by=24,Cy="nc_side_w",vv="nc_side_min",yE=240,_v="(min-width:1024px) and (pointer:fine)";function SE(){const e=Number(localStorage.getItem(Cy));return e>=180&&e<=480?e:yE}function wE(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=wy&&e<=by?e:13}function bE(){const e={token:"",pair:""};try{const{token:t,pair:i,nextUrl:s}=_E({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(t){e.token=t;try{localStorage.setItem("nc_token",t)}catch{}}if(i){e.pair=i;try{sessionStorage.setItem("nc_pair",i)}catch{}}if(location.hash)try{history.replaceState(null,"",s)}catch{}}catch{}if(e.token||(e.token=sessionStorage.getItem("nc_token")||localStorage.getItem("nc_token")||""),!e.pair){const t=sessionStorage.getItem("nc_pair");t&&(e.pair=t)}return e}function CE(e){try{return lr(Lh(e))}catch{return Vr()}}function yv(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 xE(){const[e,t]=P.useState(()=>window.matchMedia(_v).matches);return P.useEffect(()=>{const i=window.matchMedia(_v),s=o=>t(o.matches);return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[]),e}function Sv({session:e,node:t,ownerId:i,token:s,readonly:o=!1,onBack:l}){Si();const[c,d]=P.useState(!1),[m,p]=P.useState(()=>window.matchMedia("(pointer: coarse)").matches),[S,C]=P.useState(null),[_,v]=P.useState(wE),[w,b]=P.useState(""),x=q=>v(X=>{const A=Math.max(wy,Math.min(by,X+q));return localStorage.setItem("nc_fontsize",String(A)),A}),N=P.useRef(()=>{}),L=P.useRef(()=>!1),j=P.useRef(()=>{}),T=P.useRef(!1),[Q,H]=P.useState(!1),[I,G]=P.useState(!1),U=()=>{T.current=!T.current,H(T.current)};return P.useEffect(()=>{let q=!0;const X=t?t.split("/"):[],A=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function E(){let F=null,D=null;try{const ie=await(await zt(`${A}/sessions`,s)).json();Array.isArray(ie.sessions)&&(F=ie.sessions.find(K=>K.name===e))}catch{}try{const z=await dr(s,X);z.available&&Array.isArray(z.cells)&&(D=z.cells.find(ie=>ie.tmuxSession===e))}catch{}if(!q)return;let O="";D?O=`${D.engine}${D.key?`·${D.key}`:""}`:F&&(O=F.attached?`attached · ${yv(F.activity)}`:F.activity?yv(F.activity):""),b(O)}E();const R=setInterval(E,4e3);return()=>{q=!1,clearInterval(R)}},[e,t,s]),h.jsxs("div",{className:"nc-app",children:[h.jsxs("header",{className:"nc-bar nc-bar-single",children:[h.jsxs("button",{onClick:l,title:y("sessions"),children:[h.jsx(et,{name:"chevronLeft",size:18}),h.jsx("span",{className:"nc-bar-label",children:y("sessions")})]}),h.jsxs("span",{className:"nc-bar-center",children:[h.jsx("b",{children:t?`${t}:${e}`:e}),w&&h.jsx("small",{className:"nc-bar-sub",children:w})]}),h.jsxs("span",{className:"nc-bar-right",children:[h.jsx("button",{onClick:()=>x(-1),title:y("zoom-out"),children:h.jsx(et,{name:"zoomOut",size:18})}),h.jsx("button",{onClick:()=>x(1),title:y("zoom-in"),children:h.jsx(et,{name:"zoomIn",size:18})}),h.jsx("button",{onClick:()=>p(q=>!q),title:y("composer"),children:h.jsx(et,{name:"keyboard",size:20})}),h.jsx("button",{onClick:()=>d(q=>!q),title:y("files"),children:h.jsx(et,{name:"folder",size:20})})]})]}),h.jsx("div",{className:"nc-termwrap",children:h.jsx(O_,{session:e,node:t,token:s,readonly:o,takeSize:!0,sendRef:N,composerRef:L,actionRef:j,ctrlRef:T,setCtrlArmed:H,onFiles:C,fontSize:_,selectionMode:I,onSelectionModeChange:G})}),h.jsx(JC,{onKeyboard:()=>p(q=>!q),send:q=>N.current(q),action:q=>j.current(q),ctrlArmed:Q,onCtrl:U,selectionMode:I,onSelectionMode:G}),m&&h.jsx(Y_,{submitText:q=>L.current(q),token:s,session:e,node:t,ownerId:i}),c&&h.jsx(z_,{session:e,node:t,token:s,filesEvent:S,onClose:()=>d(!1)})]})}function kE(){Si();const[e]=P.useState(bE),[t,i]=P.useState(e.token),[s,o]=P.useState(e.pair||""),l=P.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[c,d]=P.useState(!1),m=xE(),[p]=P.useState(()=>kx(typeof location<"u"?location.pathname:"/")),[S,C]=P.useState(p.id),_=S===Yr(null,yi),[v,w]=P.useState(null),b=ue=>w(Hn(ue)),[x,N]=P.useState([]),[L,j]=P.useState([]),[T,Q]=P.useState(()=>p.ownerId?Vr():CE(p.name)),[H,I]=P.useState(null),[G,U]=P.useState(null),q=ue=>U(Hn(ue)),X=qh(t,m),A=P.useMemo(()=>(X||[]).filter(ue=>ue.instanceId).map(ue=>({instanceId:ue.instanceId,route:ue.route,label:ue.label,status:ue.status})),[X]),E=hE(t,S,T,Q,A),R=E.decks;P.useEffect(()=>{const ue=new Map;for(const Le of X||[]){const Ke=(Le.route||[Le.name]).join("/"),Mt=new Set((Le.sessions||[]).map(hi=>hi.name));for(const hi of Le.cells||[])!hi.cell||!hi.tmuxSession||hi.cell===hi.tmuxSession||Mt.has(hi.cell)||ue.set(`${Ke}:${hi.cell}`,`${Ke}:${hi.tmuxSession}`)}Q(Le=>b0(Le,ue))},[X]),P.useEffect(()=>{E.localNodeId&&Q(ue=>{const Le=Mh(ue,E.localNodeId,A);return JSON.stringify(Le)===JSON.stringify(ue)?ue:Le})},[A,E.localNodeId]);const[F,D]=P.useState(null),[O,z]=P.useState(!1),[ie,K]=P.useState(SE),[M,W]=P.useState(!_),[oe,ae]=P.useState(()=>_?localStorage.getItem(vv)==="1":!0),[se,le]=P.useState(!1),[ye,ce]=P.useState("nodes"),[Y,ne]=P.useState(!1),[Te,De]=P.useState(""),ge=(ue="nodes",Le=!1,Ke="")=>{ce(ue),ne(Le),De(Ke),le(!0)},[Z,Ce]=P.useState(!1),[Pe,Ne]=P.useState(!1);P.useEffect(()=>{try{localStorage.setItem(Cy,String(ie))}catch{}},[ie]),P.useEffect(()=>{try{localStorage.setItem(vv,oe?"1":"")}catch{}},[oe]),P.useEffect(()=>{if(!t)return;let ue=!1;return Promise.all([Rv(t),zt("/api/config",t).then(Le=>Le.json())]).then(([Le,Ke])=>{ue||(Ne(!!Ke.readonlyDefault),(Le.firstRun===!0&&!Ke.readonlyDefault||s)&&Ce(!0))}).catch(()=>{}),()=>{ue=!0}},[t,s]);const qe=P.useCallback(async()=>{try{const Le=await(await zt("/api/sessions",t)).json();Le.error||N(Le.sessions||[])}catch{}try{const ue=await dr(t);j(ue.available?ue.cells||[]:[])}catch{j([])}},[t]);P.useEffect(()=>{if(!m)return;qe();const ue=setInterval(qe,4e3);return()=>clearInterval(ue)},[m,qe]),P.useEffect(()=>{let ue=!1;return zt("/api/config",t).then(Le=>Le.json()).then(Le=>{ue||pE(Le.version,Le.uiVersion,"0.8.19")}).catch(()=>{}),()=>{ue=!0}},[t]);const ee=new Set([...x.map(ue=>ue.name),...X.flatMap(ue=>ue.sessions.map(Le=>Le.key))]),_e=Gi(T),Be=ue=>Q(Le=>{const Ke=G_(ue,E.localNodeId,A)||ue,Mt=qv(Le,Ke);return Mt===Le&&Gi(Le).length>=9&&E.setError(y("grid-full")),Mt}),Ie=async(ue,Le=[])=>{try{await $h(t,ue,Le)}catch{return}const Ke=Le.length?`${Le.join("/")}:${ue}`:ue;Q(Mt=>qa(Mt,Ke)),qe()},Fe=async(ue,Le,Ke=[])=>{try{await Ev(t,ue,Le,Ke)}catch{return}qe()},gt=async ue=>{if(!F)return;const{cell:Le}=F,Ke=Array.isArray(F.route)?F.route:[];ue.action==="up"?await Fh(t,{cell:Le,boot:!!ue.boot,...ue.engine?{engine:ue.engine}:{},...ue.model!==void 0?{model:ue.model}:{},...ue.permissionPolicy?{permissionPolicy:ue.permissionPolicy}:{}},Ke):await Fa(t,{cell:Le,boot:!!ue.boot},Ke),qe()},ve=async ue=>{if(!(!(ue!=null&&ue.direct)||O)){z(!0);try{await Uh(t,ue.name,ue.tunnelStatus==="up"?"down":"up")}finally{z(!1)}}},be=ue=>{const Le=R.find(Ke=>Ke.id===ue);if(!Le)return!1;try{const Ke=window.open(mu(Le,t),"_blank");return Ke&&(Ke.opener=null),!!Ke}catch{return!1}},Ee=async ue=>{if(!ue||ue===S)return;const Le=await E.select(ue),Ke=E.records.find(Mt=>Mt.id===ue);C(ue),Q(Le),I(null),U(null);try{history.replaceState(null,"",mu(Ke||ue,null))}catch{}},Ye=async(ue,Le)=>{const Ke=await E.add(ue,Le);await Ee(Ke.id)},rt=async(ue,Le)=>{const Ke=await E.rename(ue,Le);if(ue===S){C(Ke.id),Q(Mh(Ke.layout,E.localNodeId,A)),I(null),U(null);try{history.replaceState(null,"",mu(Ke,null))}catch{}}},We=async ue=>{await E.remove(ue),ue===S&&await Ee(E.localMainId)},fe=async(ue,Le)=>{!Le||Le===S||(await E.addTileTo(Le,ue),Q(Ke=>qa(Ke,ue)))};if(!t)return h.jsxs("div",{className:"nc-auth",children:[h.jsx("p",{children:y("auth-prompt")}),h.jsx("input",{onChange:ue=>i(ue.target.value.trim()),placeholder:"token"}),h.jsxs("label",{children:[h.jsx("input",{type:"checkbox",checked:c,onChange:ue=>d(ue.target.checked)})," ",y("remember-device")]}),h.jsx("button",{onClick:()=>{(c?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const Ve=h.jsxs(h.Fragment,{children:[se&&h.jsx(iE,{token:t,initialTab:ye,initialLocation:Te,startNewCell:Y,onClose:()=>{le(!1),ne(!1),De("")}}),Z&&h.jsx(nE,{token:t,initialPair:s,onPairDone:l,onDone:()=>Ce(!1)}),h.jsx(cE,{token:t})]});if(!m)return v?h.jsxs(h.Fragment,{children:[h.jsx(Sv,{session:v.session,node:v.node,ownerId:v.ownerId,token:t,readonly:Pe,onBack:()=>w(null)}),Ve]}):h.jsxs(h.Fragment,{children:[h.jsx(N0,{onPick:b,token:t,onSettings:ge}),Ve]});const it=_||!M;return h.jsxs("div",{className:"nc-workspace",children:[it&&h.jsx(mx,{sessions:x,cells:L,activeSessions:_e,nodeGroups:X,localNodeId:E.localNodeId,onPick:q,onAddTile:Be,onPower:D,onNodePower:ve,onKill:Ie,onVisibility:Fe,onNew:()=>ge("fleet",!0),onSettings:ge,width:ie,collapsed:oe,onResize:K,onToggleCollapse:()=>ae(ue=>!ue)}),h.jsxs("div",{className:"nc-workspace-main",children:[h.jsx(jx,{decks:R,currentDeck:S,onCreate:Ye,onRename:rt,onDelete:We,onReorder:E.reorder,onOpenWindow:be,onNavigate:Ee,saveState:E.saveState,error:E.error,sidebarVisible:it,onToggleSidebar:_?null:()=>W(ue=>!ue)}),h.jsx(Sx,{layout:T,onLayoutChange:Q,token:t,readonly:Pe,sessionsAlive:ee,focusSession:H,onFocus:I,onOpenSingle:q,decks:R,currentDeck:S,onSendToDeck:fe})]}),G&&h.jsx("div",{className:"nc-single-overlay",children:h.jsx(Sv,{session:G.session,node:G.node,ownerId:G.ownerId,token:t,readonly:Pe,onBack:()=>U(null)})}),F&&h.jsx(Ha,{cell:F,token:t,route:Array.isArray(F.route)?F.route:[],onConfirm:gt,onClose:()=>D(null)}),Ve]})}function EE(){Si();const e=P.useSyncExternalStore(fE,gv,gv);if(!e.needed)return null;const t=e.kind==="install"?y("install-version-mismatch").replace("{v}",e.version):y("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:vE,children:y("reload")})]})}gE();Rw.createRoot(document.getElementById("root")).render(h.jsxs(ww.StrictMode,{children:[h.jsx(kE,{}),h.jsx(EE,{})]}));
|