@mmmbuto/nexuscrew 0.8.26 → 0.8.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +44 -9
- package/frontend/dist/assets/{index-DqG-mDnV.css → index-BAzlX2nP.css} +1 -1
- package/frontend/dist/assets/index-DiKMLCvW.js +93 -0
- package/frontend/dist/index.html +2 -2
- package/frontend/dist/version.json +1 -1
- package/lib/cli/commands.js +19 -2
- package/lib/cli/doctor.js +166 -1
- package/lib/cli/service.js +10 -5
- package/lib/diagnostics/routes.js +43 -0
- package/lib/diagnostics/store.js +139 -0
- package/lib/fleet/builtin.js +201 -16
- package/lib/fleet/causes.js +68 -0
- package/lib/fleet/cell-exec.js +17 -2
- package/lib/fleet/definitions.js +86 -4
- package/lib/fleet/launch.js +19 -1
- package/lib/fleet/managed.js +73 -12
- package/lib/fleet/routes.js +44 -5
- package/lib/fleet/runtime.js +69 -33
- package/lib/nodes/aliases.js +122 -0
- package/lib/proxy/federation.js +26 -2
- package/lib/runtime/env.js +60 -1
- package/lib/server.js +28 -5
- package/lib/settings/routes.js +32 -0
- package/lib/update/manager.js +8 -0
- package/package.json +1 -1
- package/frontend/dist/assets/index-DkIPrmX6.js +0 -91
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const c of a.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function i(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(o){if(o.ep)return;o.ep=!0;const a=i(o);fetch(o.href,a)}})();function Jd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ou={exports:{}},Zs={},au={exports:{}},Ze={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var sm;function Dw(){if(sm)return Ze;sm=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),S=Symbol.iterator;function _(j){return j===null||typeof j!="object"?null:(j=S&&j[S]||j["@@iterator"],typeof j=="function"?j:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,x={};function k(j,A,se){this.props=j,this.context=A,this.refs=x,this.updater=se||C}k.prototype.isReactComponent={},k.prototype.setState=function(j,A){if(typeof j!="object"&&typeof j!="function"&&j!=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,j,A,"setState")},k.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function b(){}b.prototype=k.prototype;function D(j,A,se){this.props=j,this.context=A,this.refs=x,this.updater=se||C}var L=D.prototype=new b;L.constructor=D,w(L,k.prototype),L.isPureReactComponent=!0;var M=Array.isArray,te=Object.prototype.hasOwnProperty,U={current:null},O={key:!0,ref:!0,__self:!0,__source:!0};function ee(j,A,se){var ge,G={},Z=null,ue=null;if(A!=null)for(ge in A.ref!==void 0&&(ue=A.ref),A.key!==void 0&&(Z=""+A.key),A)te.call(A,ge)&&!O.hasOwnProperty(ge)&&(G[ge]=A[ge]);var de=arguments.length-2;if(de===1)G.children=se;else if(1<de){for(var Ce=Array(de),Re=0;Re<de;Re++)Ce[Re]=arguments[Re+2];G.children=Ce}if(j&&j.defaultProps)for(ge in de=j.defaultProps,de)G[ge]===void 0&&(G[ge]=de[ge]);return{$$typeof:e,type:j,key:Z,ref:ue,props:G,_owner:U.current}}function q(j,A){return{$$typeof:e,type:j.type,key:A,ref:j.ref,props:j.props,_owner:j._owner}}function J(j){return typeof j=="object"&&j!==null&&j.$$typeof===e}function Q(j){var A={"=":"=0",":":"=2"};return"$"+j.replace(/[=:]/g,function(se){return A[se]})}var T=/\/+/g;function N(j,A){return typeof j=="object"&&j!==null&&j.key!=null?Q(""+j.key):A.toString(36)}function P(j,A,se,ge,G){var Z=typeof j;(Z==="undefined"||Z==="boolean")&&(j=null);var ue=!1;if(j===null)ue=!0;else switch(Z){case"string":case"number":ue=!0;break;case"object":switch(j.$$typeof){case e:case t:ue=!0}}if(ue)return ue=j,G=G(ue),j=ge===""?"."+N(ue,0):ge,M(G)?(se="",j!=null&&(se=j.replace(T,"$&/")+"/"),P(G,A,se,"",function(Re){return Re})):G!=null&&(J(G)&&(G=q(G,se+(!G.key||ue&&ue.key===G.key?"":(""+G.key).replace(T,"$&/")+"/")+j)),A.push(G)),1;if(ue=0,ge=ge===""?".":ge+":",M(j))for(var de=0;de<j.length;de++){Z=j[de];var Ce=ge+N(Z,de);ue+=P(Z,A,se,Ce,G)}else if(Ce=_(j),typeof Ce=="function")for(j=Ce.call(j),de=0;!(Z=j.next()).done;)Z=Z.value,Ce=ge+N(Z,de++),ue+=P(Z,A,se,Ce,G);else if(Z==="object")throw A=String(j),Error("Objects are not valid as a React child (found: "+(A==="[object Object]"?"object with keys {"+Object.keys(j).join(", ")+"}":A)+"). If you meant to render a collection of children, use an array instead.");return ue}function I(j,A,se){if(j==null)return j;var ge=[],G=0;return P(j,ge,"","",function(Z){return A.call(se,Z,G++)}),ge}function $(j){if(j._status===-1){var A=j._result;A=A(),A.then(function(se){(j._status===0||j._status===-1)&&(j._status=1,j._result=se)},function(se){(j._status===0||j._status===-1)&&(j._status=2,j._result=se)}),j._status===-1&&(j._status=0,j._result=A)}if(j._status===1)return j._result.default;throw j._result}var K={current:null},F={transition:null},ae={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:F,ReactCurrentOwner:U};function W(){throw Error("act(...) is not supported in production builds of React.")}return Ze.Children={map:I,forEach:function(j,A,se){I(j,function(){A.apply(this,arguments)},se)},count:function(j){var A=0;return I(j,function(){A++}),A},toArray:function(j){return I(j,function(A){return A})||[]},only:function(j){if(!J(j))throw Error("React.Children.only expected to receive a single React element child.");return j}},Ze.Component=k,Ze.Fragment=i,Ze.Profiler=o,Ze.PureComponent=D,Ze.StrictMode=s,Ze.Suspense=m,Ze.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ae,Ze.act=W,Ze.cloneElement=function(j,A,se){if(j==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+j+".");var ge=w({},j.props),G=j.key,Z=j.ref,ue=j._owner;if(A!=null){if(A.ref!==void 0&&(Z=A.ref,ue=U.current),A.key!==void 0&&(G=""+A.key),j.type&&j.type.defaultProps)var de=j.type.defaultProps;for(Ce in A)te.call(A,Ce)&&!O.hasOwnProperty(Ce)&&(ge[Ce]=A[Ce]===void 0&&de!==void 0?de[Ce]:A[Ce])}var Ce=arguments.length-2;if(Ce===1)ge.children=se;else if(1<Ce){de=Array(Ce);for(var Re=0;Re<Ce;Re++)de[Re]=arguments[Re+2];ge.children=de}return{$$typeof:e,type:j.type,key:G,ref:Z,props:ge,_owner:ue}},Ze.createContext=function(j){return j={$$typeof:c,_currentValue:j,_currentValue2:j,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},j.Provider={$$typeof:a,_context:j},j.Consumer=j},Ze.createElement=ee,Ze.createFactory=function(j){var A=ee.bind(null,j);return A.type=j,A},Ze.createRef=function(){return{current:null}},Ze.forwardRef=function(j){return{$$typeof:h,render:j}},Ze.isValidElement=J,Ze.lazy=function(j){return{$$typeof:y,_payload:{_status:-1,_result:j},_init:$}},Ze.memo=function(j,A){return{$$typeof:p,type:j,compare:A===void 0?null:A}},Ze.startTransition=function(j){var A=F.transition;F.transition={};try{j()}finally{F.transition=A}},Ze.unstable_act=W,Ze.useCallback=function(j,A){return K.current.useCallback(j,A)},Ze.useContext=function(j){return K.current.useContext(j)},Ze.useDebugValue=function(){},Ze.useDeferredValue=function(j){return K.current.useDeferredValue(j)},Ze.useEffect=function(j,A){return K.current.useEffect(j,A)},Ze.useId=function(){return K.current.useId()},Ze.useImperativeHandle=function(j,A,se){return K.current.useImperativeHandle(j,A,se)},Ze.useInsertionEffect=function(j,A){return K.current.useInsertionEffect(j,A)},Ze.useLayoutEffect=function(j,A){return K.current.useLayoutEffect(j,A)},Ze.useMemo=function(j,A){return K.current.useMemo(j,A)},Ze.useReducer=function(j,A,se){return K.current.useReducer(j,A,se)},Ze.useRef=function(j){return K.current.useRef(j)},Ze.useState=function(j){return K.current.useState(j)},Ze.useSyncExternalStore=function(j,A,se){return K.current.useSyncExternalStore(j,A,se)},Ze.useTransition=function(){return K.current.useTransition()},Ze.version="18.3.1",Ze}var om;function Zd(){return om||(om=1,au.exports=Dw()),au.exports}/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.production.min.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var am;function jw(){if(am)return Zs;am=1;var e=Zd(),t=Symbol.for("react.element"),i=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function c(h,m,p){var y,S={},_=null,C=null;p!==void 0&&(_=""+p),m.key!==void 0&&(_=""+m.key),m.ref!==void 0&&(C=m.ref);for(y in m)s.call(m,y)&&!a.hasOwnProperty(y)&&(S[y]=m[y]);if(h&&h.defaultProps)for(y in m=h.defaultProps,m)S[y]===void 0&&(S[y]=m[y]);return{$$typeof:t,type:h,key:_,ref:C,props:S,_owner:o.current}}return Zs.Fragment=i,Zs.jsx=c,Zs.jsxs=c,Zs}var lm;function Mw(){return lm||(lm=1,ou.exports=jw()),ou.exports}var u=Mw(),R=Zd();const Lw=Jd(R);var Ia={},lu={exports:{}},gi={},cu={exports:{}},uu={};/**
|
|
18
|
-
* @license React
|
|
19
|
-
* scheduler.production.min.js
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the MIT license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/var cm;function Tw(){return cm||(cm=1,(function(e){function t(F,ae){var W=F.length;F.push(ae);e:for(;0<W;){var j=W-1>>>1,A=F[j];if(0<o(A,ae))F[j]=ae,F[W]=A,W=j;else break e}}function i(F){return F.length===0?null:F[0]}function s(F){if(F.length===0)return null;var ae=F[0],W=F.pop();if(W!==ae){F[0]=W;e:for(var j=0,A=F.length,se=A>>>1;j<se;){var ge=2*(j+1)-1,G=F[ge],Z=ge+1,ue=F[Z];if(0>o(G,W))Z<A&&0>o(ue,G)?(F[j]=ue,F[Z]=W,j=Z):(F[j]=G,F[ge]=W,j=ge);else if(Z<A&&0>o(ue,W))F[j]=ue,F[Z]=W,j=Z;else break e}}return ae}function o(F,ae){var W=F.sortIndex-ae.sortIndex;return W!==0?W:F.id-ae.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var c=Date,h=c.now();e.unstable_now=function(){return c.now()-h}}var m=[],p=[],y=1,S=null,_=3,C=!1,w=!1,x=!1,k=typeof setTimeout=="function"?setTimeout:null,b=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function L(F){for(var ae=i(p);ae!==null;){if(ae.callback===null)s(p);else if(ae.startTime<=F)s(p),ae.sortIndex=ae.expirationTime,t(m,ae);else break;ae=i(p)}}function M(F){if(x=!1,L(F),!w)if(i(m)!==null)w=!0,$(te);else{var ae=i(p);ae!==null&&K(M,ae.startTime-F)}}function te(F,ae){w=!1,x&&(x=!1,b(ee),ee=-1),C=!0;var W=_;try{for(L(ae),S=i(m);S!==null&&(!(S.expirationTime>ae)||F&&!Q());){var j=S.callback;if(typeof j=="function"){S.callback=null,_=S.priorityLevel;var A=j(S.expirationTime<=ae);ae=e.unstable_now(),typeof A=="function"?S.callback=A:S===i(m)&&s(m),L(ae)}else s(m);S=i(m)}if(S!==null)var se=!0;else{var ge=i(p);ge!==null&&K(M,ge.startTime-ae),se=!1}return se}finally{S=null,_=W,C=!1}}var U=!1,O=null,ee=-1,q=5,J=-1;function Q(){return!(e.unstable_now()-J<q)}function T(){if(O!==null){var F=e.unstable_now();J=F;var ae=!0;try{ae=O(!0,F)}finally{ae?N():(U=!1,O=null)}}else U=!1}var N;if(typeof D=="function")N=function(){D(T)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,I=P.port2;P.port1.onmessage=T,N=function(){I.postMessage(null)}}else N=function(){k(T,0)};function $(F){O=F,U||(U=!0,N())}function K(F,ae){ee=k(function(){F(e.unstable_now())},ae)}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(F){F.callback=null},e.unstable_continueExecution=function(){w||C||(w=!0,$(te))},e.unstable_forceFrameRate=function(F){0>F||125<F?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):q=0<F?Math.floor(1e3/F):5},e.unstable_getCurrentPriorityLevel=function(){return _},e.unstable_getFirstCallbackNode=function(){return i(m)},e.unstable_next=function(F){switch(_){case 1:case 2:case 3:var ae=3;break;default:ae=_}var W=_;_=ae;try{return F()}finally{_=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(F,ae){switch(F){case 1:case 2:case 3:case 4:case 5:break;default:F=3}var W=_;_=F;try{return ae()}finally{_=W}},e.unstable_scheduleCallback=function(F,ae,W){var j=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?j+W:j):W=j,F){case 1:var A=-1;break;case 2:A=250;break;case 5:A=1073741823;break;case 4:A=1e4;break;default:A=5e3}return A=W+A,F={id:y++,callback:ae,priorityLevel:F,startTime:W,expirationTime:A,sortIndex:-1},W>j?(F.sortIndex=W,t(p,F),i(m)===null&&F===i(p)&&(x?(b(ee),ee=-1):x=!0,K(M,W-j))):(F.sortIndex=A,t(m,F),w||C||(w=!0,$(te))),F},e.unstable_shouldYield=Q,e.unstable_wrapCallback=function(F){var ae=_;return function(){var W=_;_=ae;try{return F.apply(this,arguments)}finally{_=W}}}})(uu)),uu}var um;function Aw(){return um||(um=1,cu.exports=Tw()),cu.exports}/**
|
|
26
|
-
* @license React
|
|
27
|
-
* react-dom.production.min.js
|
|
28
|
-
*
|
|
29
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
-
*
|
|
31
|
-
* This source code is licensed under the MIT license found in the
|
|
32
|
-
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/var dm;function Iw(){if(dm)return gi;dm=1;var e=Zd(),t=Aw();function i(n){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+n,l=1;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+n+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,o={};function a(n,r){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 h=!(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]*$/,y={},S={};function _(n){return m.call(S,n)?!0:m.call(y,n)?!1:p.test(n)?S[n]=!0:(y[n]=!0,!1)}function C(n,r,l,d){if(l!==null&&l.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return d?!1:l!==null?!l.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function w(n,r,l,d){if(r===null||typeof r>"u"||C(n,r,l,d))return!0;if(d)return!1;if(l!==null)switch(l.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function x(n,r,l,d,f,g,E){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=d,this.attributeNamespace=f,this.mustUseProperty=l,this.propertyName=n,this.type=r,this.sanitizeURL=g,this.removeEmptyString=E}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){k[n]=new x(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var r=n[0];k[r]=new x(r,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){k[n]=new x(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){k[n]=new x(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){k[n]=new x(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){k[n]=new x(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){k[n]=new x(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){k[n]=new x(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){k[n]=new x(n,5,!1,n.toLowerCase(),null,!1,!1)});var b=/[\-:]([a-z])/g;function D(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(b,D);k[r]=new x(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(b,D);k[r]=new x(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(b,D);k[r]=new x(r,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){k[n]=new x(n,1,!1,n.toLowerCase(),null,!1,!1)}),k.xlinkHref=new x("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){k[n]=new x(n,1,!1,n.toLowerCase(),null,!0,!0)});function L(n,r,l,d){var f=k.hasOwnProperty(r)?k[r]:null;(f!==null?f.type!==0:d||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(w(r,l,f,d)&&(l=null),d||f===null?_(r)&&(l===null?n.removeAttribute(r):n.setAttribute(r,""+l)):f.mustUseProperty?n[f.propertyName]=l===null?f.type===3?!1:"":l:(r=f.attributeName,d=f.attributeNamespace,l===null?n.removeAttribute(r):(f=f.type,l=f===3||f===4&&l===!0?"":""+l,d?n.setAttributeNS(d,r,l):n.setAttribute(r,l))))}var M=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,te=Symbol.for("react.element"),U=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),ee=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),J=Symbol.for("react.provider"),Q=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),K=Symbol.for("react.offscreen"),F=Symbol.iterator;function ae(n){return n===null||typeof n!="object"?null:(n=F&&n[F]||n["@@iterator"],typeof n=="function"?n:null)}var W=Object.assign,j;function A(n){if(j===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);j=r&&r[1]||""}return`
|
|
34
|
-
`+j+n}var se=!1;function ge(n,r){if(!n||se)return"";se=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(ce){var d=ce}Reflect.construct(n,[],r)}else{try{r.call()}catch(ce){d=ce}n.call(r.prototype)}else{try{throw Error()}catch(ce){d=ce}n()}}catch(ce){if(ce&&d&&typeof ce.stack=="string"){for(var f=ce.stack.split(`
|
|
35
|
-
`),g=d.stack.split(`
|
|
36
|
-
`),E=f.length-1,B=g.length-1;1<=E&&0<=B&&f[E]!==g[B];)B--;for(;1<=E&&0<=B;E--,B--)if(f[E]!==g[B]){if(E!==1||B!==1)do if(E--,B--,0>B||f[E]!==g[B]){var V=`
|
|
37
|
-
`+f[E].replace(" at new "," at ");return n.displayName&&V.includes("<anonymous>")&&(V=V.replace("<anonymous>",n.displayName)),V}while(1<=E&&0<=B);break}}}finally{se=!1,Error.prepareStackTrace=l}return(n=n?n.displayName||n.name:"")?A(n):""}function G(n){switch(n.tag){case 5:return A(n.type);case 16:return A("Lazy");case 13:return A("Suspense");case 19:return A("SuspenseList");case 0:case 2:case 15:return n=ge(n.type,!1),n;case 11:return n=ge(n.type.render,!1),n;case 1:return n=ge(n.type,!0),n;default:return""}}function Z(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 O:return"Fragment";case U:return"Portal";case q:return"Profiler";case ee:return"StrictMode";case N:return"Suspense";case P:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Q:return(n.displayName||"Context")+".Consumer";case J:return(n._context.displayName||"Context")+".Provider";case T:var r=n.render;return n=n.displayName,n||(n=r.displayName||r.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case I:return r=n.displayName||null,r!==null?r:Z(n.type)||"Memo";case $:r=n._payload,n=n._init;try{return Z(n(r))}catch{}}return null}function ue(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 Z(r);case 8:return r===ee?"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 de(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Ce(n){var r=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Re(n){var r=Ce(n)?"checked":"value",l=Object.getOwnPropertyDescriptor(n.constructor.prototype,r),d=""+n[r];if(!n.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var f=l.get,g=l.set;return Object.defineProperty(n,r,{configurable:!0,get:function(){return f.call(this)},set:function(E){d=""+E,g.call(this,E)}}),Object.defineProperty(n,r,{enumerable:l.enumerable}),{getValue:function(){return d},setValue:function(E){d=""+E},stopTracking:function(){n._valueTracker=null,delete n[r]}}}}function tt(n){n._valueTracker||(n._valueTracker=Re(n))}function Je(n){if(!n)return!1;var r=n._valueTracker;if(!r)return!0;var l=r.getValue(),d="";return n&&(d=Ce(n)?n.checked?"true":"false":n.value),n=d,n!==l?(r.setValue(n),!0):!1}function Ee(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 rt(n,r){var l=r.checked;return W({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??n._wrapperState.initialChecked})}function wt(n,r){var l=r.defaultValue==null?"":r.defaultValue,d=r.checked!=null?r.checked:r.defaultChecked;l=de(r.value!=null?r.value:l),n._wrapperState={initialChecked:d,initialValue:l,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Dt(n,r){r=r.checked,r!=null&&L(n,"checked",r,!1)}function st(n,r){Dt(n,r);var l=de(r.value),d=r.type;if(l!=null)d==="number"?(l===0&&n.value===""||n.value!=l)&&(n.value=""+l):n.value!==""+l&&(n.value=""+l);else if(d==="submit"||d==="reset"){n.removeAttribute("value");return}r.hasOwnProperty("value")?ct(n,r.type,l):r.hasOwnProperty("defaultValue")&&ct(n,r.type,de(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(n.defaultChecked=!!r.defaultChecked)}function gt(n,r,l){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var d=r.type;if(!(d!=="submit"&&d!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+n._wrapperState.initialValue,l||r===n.value||(n.value=r),n.defaultValue=r}l=n.name,l!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,l!==""&&(n.name=l)}function ct(n,r,l){(r!=="number"||Ee(n.ownerDocument)!==n)&&(l==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+l&&(n.defaultValue=""+l))}var at=Array.isArray;function le(n,r,l,d){if(n=n.options,r){r={};for(var f=0;f<l.length;f++)r["$"+l[f]]=!0;for(l=0;l<n.length;l++)f=r.hasOwnProperty("$"+n[l].value),n[l].selected!==f&&(n[l].selected=f),f&&d&&(n[l].defaultSelected=!0)}else{for(l=""+de(l),r=null,f=0;f<n.length;f++){if(n[f].value===l){n[f].selected=!0,d&&(n[f].defaultSelected=!0);return}r!==null||n[f].disabled||(r=n[f])}r!==null&&(r.selected=!0)}}function be(n,r){if(r.dangerouslySetInnerHTML!=null)throw Error(i(91));return W({},r,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function Fe(n,r){var l=r.value;if(l==null){if(l=r.children,r=r.defaultValue,l!=null){if(r!=null)throw Error(i(92));if(at(l)){if(1<l.length)throw Error(i(93));l=l[0]}r=l}r==null&&(r=""),l=r}n._wrapperState={initialValue:de(l)}}function $e(n,r){var l=de(r.value),d=de(r.defaultValue);l!=null&&(l=""+l,l!==n.value&&(n.value=l),r.defaultValue==null&&n.defaultValue!==l&&(n.defaultValue=l)),d!=null&&(n.defaultValue=""+d)}function pe(n){var r=n.textContent;r===n._wrapperState.initialValue&&r!==""&&r!==null&&(n.value=r)}function 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 Te(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 Y,ne=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,l,d,f){MSApp.execUnsafeLocalFunction(function(){return n(r,l,d,f)})}:n})(function(n,r){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=r;else{for(Y=Y||document.createElement("div"),Y.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=Y.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;r.firstChild;)n.appendChild(r.firstChild)}});function z(n,r){if(r){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=r;return}}n.textContent=r}var H={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},re=["Webkit","ms","Moz","O"];Object.keys(H).forEach(function(n){re.forEach(function(r){r=r+n.charAt(0).toUpperCase()+n.substring(1),H[r]=H[n]})});function me(n,r,l){return r==null||typeof r=="boolean"||r===""?"":l||typeof r!="number"||r===0||H.hasOwnProperty(n)&&H[n]?(""+r).trim():r+"px"}function Ae(n,r){n=n.style;for(var l in r)if(r.hasOwnProperty(l)){var d=l.indexOf("--")===0,f=me(l,r[l],d);l==="float"&&(l="cssFloat"),d?n.setProperty(l,f):n[l]=f}}var Se=W({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 xe(n,r){if(r){if(Se[n]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(i(137,n));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(i(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(i(61))}if(r.style!=null&&typeof r.style!="object")throw Error(i(62))}}function He(n,r){if(n.indexOf("-")===-1)return typeof r.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Zt=null;function Xe(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Di=null,Et=null,Ve=null;function ji(n){if(n=Os(n)){if(typeof Di!="function")throw Error(i(280));var r=n.stateNode;r&&(r=Qo(r),Di(n.stateNode,n.type,r))}}function he(n){Et?Ve?Ve.push(n):Ve=[n]:Et=n}function De(){if(Et){var n=Et,r=Ve;if(Ve=Et=null,ji(n),r)for(n=0;n<r.length;n++)ji(r[n])}}function qe(n,r){return n(r)}function bt(){}var si=!1;function gs(n,r,l){if(si)return n(r,l);si=!0;try{return qe(n,r,l)}finally{si=!1,(Et!==null||Ve!==null)&&(bt(),De())}}function Si(n,r){var l=n.stateNode;if(l===null)return null;var d=Qo(l);if(d===null)return null;l=d[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(d=!d.disabled)||(n=n.type,d=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!d;break e;default:n=!1}if(n)return null;if(l&&typeof l!="function")throw Error(i(231,r,typeof l));return l}var vs=!1;if(h)try{var _s={};Object.defineProperty(_s,"passive",{get:function(){vs=!0}}),window.addEventListener("test",_s,_s),window.removeEventListener("test",_s,_s)}catch{vs=!1}function Iy(n,r,l,d,f,g,E,B,V){var ce=Array.prototype.slice.call(arguments,3);try{r.apply(l,ce)}catch(_e){this.onError(_e)}}var ys=!1,Po=null,Do=!1,xl=null,By={onError:function(n){ys=!0,Po=n}};function Oy(n,r,l,d,f,g,E,B,V){ys=!1,Po=null,Iy.apply(By,arguments)}function zy(n,r,l,d,f,g,E,B,V){if(Oy.apply(this,arguments),ys){if(ys){var ce=Po;ys=!1,Po=null}else throw Error(i(198));Do||(Do=!0,xl=ce)}}function tr(n){var r=n,l=n;if(n.alternate)for(;r.return;)r=r.return;else{n=r;do r=n,(r.flags&4098)!==0&&(l=r.return),n=r.return;while(n)}return r.tag===3?l:null}function Nh(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 Rh(n){if(tr(n)!==n)throw Error(i(188))}function Fy(n){var r=n.alternate;if(!r){if(r=tr(n),r===null)throw Error(i(188));return r!==n?null:n}for(var l=n,d=r;;){var f=l.return;if(f===null)break;var g=f.alternate;if(g===null){if(d=f.return,d!==null){l=d;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===l)return Rh(f),n;if(g===d)return Rh(f),r;g=g.sibling}throw Error(i(188))}if(l.return!==d.return)l=f,d=g;else{for(var E=!1,B=f.child;B;){if(B===l){E=!0,l=f,d=g;break}if(B===d){E=!0,d=f,l=g;break}B=B.sibling}if(!E){for(B=g.child;B;){if(B===l){E=!0,l=g,d=f;break}if(B===d){E=!0,d=g,l=f;break}B=B.sibling}if(!E)throw Error(i(189))}}if(l.alternate!==d)throw Error(i(190))}if(l.tag!==3)throw Error(i(188));return l.stateNode.current===l?n:r}function Ph(n){return n=Fy(n),n!==null?Dh(n):null}function Dh(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var r=Dh(n);if(r!==null)return r;n=n.sibling}return null}var jh=t.unstable_scheduleCallback,Mh=t.unstable_cancelCallback,Hy=t.unstable_shouldYield,$y=t.unstable_requestPaint,Nt=t.unstable_now,Wy=t.unstable_getCurrentPriorityLevel,El=t.unstable_ImmediatePriority,Lh=t.unstable_UserBlockingPriority,jo=t.unstable_NormalPriority,Uy=t.unstable_LowPriority,Th=t.unstable_IdlePriority,Mo=null,Qi=null;function Ky(n){if(Qi&&typeof Qi.onCommitFiberRoot=="function")try{Qi.onCommitFiberRoot(Mo,n,void 0,(n.current.flags&128)===128)}catch{}}var Wi=Math.clz32?Math.clz32:Yy,qy=Math.log,Vy=Math.LN2;function Yy(n){return n>>>=0,n===0?32:31-(qy(n)/Vy|0)|0}var Lo=64,To=4194304;function Ss(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function Ao(n,r){var l=n.pendingLanes;if(l===0)return 0;var d=0,f=n.suspendedLanes,g=n.pingedLanes,E=l&268435455;if(E!==0){var B=E&~f;B!==0?d=Ss(B):(g&=E,g!==0&&(d=Ss(g)))}else E=l&~f,E!==0?d=Ss(E):g!==0&&(d=Ss(g));if(d===0)return 0;if(r!==0&&r!==d&&(r&f)===0&&(f=d&-d,g=r&-r,f>=g||f===16&&(g&4194240)!==0))return r;if((d&4)!==0&&(d|=l&16),r=n.entangledLanes,r!==0)for(n=n.entanglements,r&=d;0<r;)l=31-Wi(r),f=1<<l,d|=n[l],r&=~f;return d}function Xy(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 Gy(n,r){for(var l=n.suspendedLanes,d=n.pingedLanes,f=n.expirationTimes,g=n.pendingLanes;0<g;){var E=31-Wi(g),B=1<<E,V=f[E];V===-1?((B&l)===0||(B&d)!==0)&&(f[E]=Xy(B,r)):V<=r&&(n.expiredLanes|=B),g&=~B}}function Nl(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function Ah(){var n=Lo;return Lo<<=1,(Lo&4194240)===0&&(Lo=64),n}function Rl(n){for(var r=[],l=0;31>l;l++)r.push(n);return r}function ws(n,r,l){n.pendingLanes|=r,r!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,r=31-Wi(r),n[r]=l}function Qy(n,r){var l=n.pendingLanes&~r;n.pendingLanes=r,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=r,n.mutableReadLanes&=r,n.entangledLanes&=r,r=n.entanglements;var d=n.eventTimes;for(n=n.expirationTimes;0<l;){var f=31-Wi(l),g=1<<f;r[f]=0,d[f]=-1,n[f]=-1,l&=~g}}function Pl(n,r){var l=n.entangledLanes|=r;for(n=n.entanglements;l;){var d=31-Wi(l),f=1<<d;f&r|n[d]&r&&(n[d]|=r),l&=~f}}var ot=0;function Ih(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var Bh,Dl,Oh,zh,Fh,jl=!1,Io=[],xn=null,En=null,Nn=null,bs=new Map,ks=new Map,Rn=[],Jy="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 Hh(n,r){switch(n){case"focusin":case"focusout":xn=null;break;case"dragenter":case"dragleave":En=null;break;case"mouseover":case"mouseout":Nn=null;break;case"pointerover":case"pointerout":bs.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":ks.delete(r.pointerId)}}function Cs(n,r,l,d,f,g){return n===null||n.nativeEvent!==g?(n={blockedOn:r,domEventName:l,eventSystemFlags:d,nativeEvent:g,targetContainers:[f]},r!==null&&(r=Os(r),r!==null&&Dl(r)),n):(n.eventSystemFlags|=d,r=n.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),n)}function Zy(n,r,l,d,f){switch(r){case"focusin":return xn=Cs(xn,n,r,l,d,f),!0;case"dragenter":return En=Cs(En,n,r,l,d,f),!0;case"mouseover":return Nn=Cs(Nn,n,r,l,d,f),!0;case"pointerover":var g=f.pointerId;return bs.set(g,Cs(bs.get(g)||null,n,r,l,d,f)),!0;case"gotpointercapture":return g=f.pointerId,ks.set(g,Cs(ks.get(g)||null,n,r,l,d,f)),!0}return!1}function $h(n){var r=ir(n.target);if(r!==null){var l=tr(r);if(l!==null){if(r=l.tag,r===13){if(r=Nh(l),r!==null){n.blockedOn=r,Fh(n.priority,function(){Oh(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){n.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}n.blockedOn=null}function Bo(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var l=Ll(n.domEventName,n.eventSystemFlags,r[0],n.nativeEvent);if(l===null){l=n.nativeEvent;var d=new l.constructor(l.type,l);Zt=d,l.target.dispatchEvent(d),Zt=null}else return r=Os(l),r!==null&&Dl(r),n.blockedOn=l,!1;r.shift()}return!0}function Wh(n,r,l){Bo(n)&&l.delete(r)}function eS(){jl=!1,xn!==null&&Bo(xn)&&(xn=null),En!==null&&Bo(En)&&(En=null),Nn!==null&&Bo(Nn)&&(Nn=null),bs.forEach(Wh),ks.forEach(Wh)}function xs(n,r){n.blockedOn===r&&(n.blockedOn=null,jl||(jl=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,eS)))}function Es(n){function r(f){return xs(f,n)}if(0<Io.length){xs(Io[0],n);for(var l=1;l<Io.length;l++){var d=Io[l];d.blockedOn===n&&(d.blockedOn=null)}}for(xn!==null&&xs(xn,n),En!==null&&xs(En,n),Nn!==null&&xs(Nn,n),bs.forEach(r),ks.forEach(r),l=0;l<Rn.length;l++)d=Rn[l],d.blockedOn===n&&(d.blockedOn=null);for(;0<Rn.length&&(l=Rn[0],l.blockedOn===null);)$h(l),l.blockedOn===null&&Rn.shift()}var Dr=M.ReactCurrentBatchConfig,Oo=!0;function tS(n,r,l,d){var f=ot,g=Dr.transition;Dr.transition=null;try{ot=1,Ml(n,r,l,d)}finally{ot=f,Dr.transition=g}}function iS(n,r,l,d){var f=ot,g=Dr.transition;Dr.transition=null;try{ot=4,Ml(n,r,l,d)}finally{ot=f,Dr.transition=g}}function Ml(n,r,l,d){if(Oo){var f=Ll(n,r,l,d);if(f===null)Gl(n,r,d,zo,l),Hh(n,d);else if(Zy(f,n,r,l,d))d.stopPropagation();else if(Hh(n,d),r&4&&-1<Jy.indexOf(n)){for(;f!==null;){var g=Os(f);if(g!==null&&Bh(g),g=Ll(n,r,l,d),g===null&&Gl(n,r,d,zo,l),g===f)break;f=g}f!==null&&d.stopPropagation()}else Gl(n,r,d,null,l)}}var zo=null;function Ll(n,r,l,d){if(zo=null,n=Xe(d),n=ir(n),n!==null)if(r=tr(n),r===null)n=null;else if(l=r.tag,l===13){if(n=Nh(r),n!==null)return n;n=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;n=null}else r!==n&&(n=null);return zo=n,null}function Uh(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(Wy()){case El:return 1;case Lh:return 4;case jo:case Uy:return 16;case Th:return 536870912;default:return 16}default:return 16}}var Pn=null,Tl=null,Fo=null;function Kh(){if(Fo)return Fo;var n,r=Tl,l=r.length,d,f="value"in Pn?Pn.value:Pn.textContent,g=f.length;for(n=0;n<l&&r[n]===f[n];n++);var E=l-n;for(d=1;d<=E&&r[l-d]===f[g-d];d++);return Fo=f.slice(n,1<d?1-d:void 0)}function Ho(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 $o(){return!0}function qh(){return!1}function wi(n){function r(l,d,f,g,E){this._reactName=l,this._targetInst=f,this.type=d,this.nativeEvent=g,this.target=E,this.currentTarget=null;for(var B in n)n.hasOwnProperty(B)&&(l=n[B],this[B]=l?l(g):g[B]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?$o:qh,this.isPropagationStopped=qh,this}return W(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=$o)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=$o)},persist:function(){},isPersistent:$o}),r}var jr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Al=wi(jr),Ns=W({},jr,{view:0,detail:0}),nS=wi(Ns),Il,Bl,Rs,Wo=W({},Ns,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:zl,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!==Rs&&(Rs&&n.type==="mousemove"?(Il=n.screenX-Rs.screenX,Bl=n.screenY-Rs.screenY):Bl=Il=0,Rs=n),Il)},movementY:function(n){return"movementY"in n?n.movementY:Bl}}),Vh=wi(Wo),rS=W({},Wo,{dataTransfer:0}),sS=wi(rS),oS=W({},Ns,{relatedTarget:0}),Ol=wi(oS),aS=W({},jr,{animationName:0,elapsedTime:0,pseudoElement:0}),lS=wi(aS),cS=W({},jr,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),uS=wi(cS),dS=W({},jr,{data:0}),Yh=wi(dS),hS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},fS={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"},pS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mS(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=pS[n])?!!r[n]:!1}function zl(){return mS}var gS=W({},Ns,{key:function(n){if(n.key){var r=hS[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=Ho(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?fS[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:zl,charCode:function(n){return n.type==="keypress"?Ho(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Ho(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),vS=wi(gS),_S=W({},Wo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Xh=wi(_S),yS=W({},Ns,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:zl}),SS=wi(yS),wS=W({},jr,{propertyName:0,elapsedTime:0,pseudoElement:0}),bS=wi(wS),kS=W({},Wo,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),CS=wi(kS),xS=[9,13,27,32],Fl=h&&"CompositionEvent"in window,Ps=null;h&&"documentMode"in document&&(Ps=document.documentMode);var ES=h&&"TextEvent"in window&&!Ps,Gh=h&&(!Fl||Ps&&8<Ps&&11>=Ps),Qh=" ",Jh=!1;function Zh(n,r){switch(n){case"keyup":return xS.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ef(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Mr=!1;function NS(n,r){switch(n){case"compositionend":return ef(r);case"keypress":return r.which!==32?null:(Jh=!0,Qh);case"textInput":return n=r.data,n===Qh&&Jh?null:n;default:return null}}function RS(n,r){if(Mr)return n==="compositionend"||!Fl&&Zh(n,r)?(n=Kh(),Fo=Tl=Pn=null,Mr=!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 Gh&&r.locale!=="ko"?null:r.data;default:return null}}var PS={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 tf(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!PS[n.type]:r==="textarea"}function nf(n,r,l,d){he(d),r=Yo(r,"onChange"),0<r.length&&(l=new Al("onChange","change",null,l,d),n.push({event:l,listeners:r}))}var Ds=null,js=null;function DS(n){wf(n,0)}function Uo(n){var r=Br(n);if(Je(r))return n}function jS(n,r){if(n==="change")return r}var rf=!1;if(h){var Hl;if(h){var $l="oninput"in document;if(!$l){var sf=document.createElement("div");sf.setAttribute("oninput","return;"),$l=typeof sf.oninput=="function"}Hl=$l}else Hl=!1;rf=Hl&&(!document.documentMode||9<document.documentMode)}function of(){Ds&&(Ds.detachEvent("onpropertychange",af),js=Ds=null)}function af(n){if(n.propertyName==="value"&&Uo(js)){var r=[];nf(r,js,n,Xe(n)),gs(DS,r)}}function MS(n,r,l){n==="focusin"?(of(),Ds=r,js=l,Ds.attachEvent("onpropertychange",af)):n==="focusout"&&of()}function LS(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Uo(js)}function TS(n,r){if(n==="click")return Uo(r)}function AS(n,r){if(n==="input"||n==="change")return Uo(r)}function IS(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var Ui=typeof Object.is=="function"?Object.is:IS;function Ms(n,r){if(Ui(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;var l=Object.keys(n),d=Object.keys(r);if(l.length!==d.length)return!1;for(d=0;d<l.length;d++){var f=l[d];if(!m.call(r,f)||!Ui(n[f],r[f]))return!1}return!0}function lf(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function cf(n,r){var l=lf(n);n=0;for(var d;l;){if(l.nodeType===3){if(d=n+l.textContent.length,n<=r&&d>=r)return{node:l,offset:r-n};n=d}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=lf(l)}}function uf(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?uf(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function df(){for(var n=window,r=Ee();r instanceof n.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)n=r.contentWindow;else break;r=Ee(n.document)}return r}function Wl(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 BS(n){var r=df(),l=n.focusedElem,d=n.selectionRange;if(r!==l&&l&&l.ownerDocument&&uf(l.ownerDocument.documentElement,l)){if(d!==null&&Wl(l)){if(r=d.start,n=d.end,n===void 0&&(n=r),"selectionStart"in l)l.selectionStart=r,l.selectionEnd=Math.min(n,l.value.length);else if(n=(r=l.ownerDocument||document)&&r.defaultView||window,n.getSelection){n=n.getSelection();var f=l.textContent.length,g=Math.min(d.start,f);d=d.end===void 0?g:Math.min(d.end,f),!n.extend&&g>d&&(f=d,d=g,g=f),f=cf(l,g);var E=cf(l,d);f&&E&&(n.rangeCount!==1||n.anchorNode!==f.node||n.anchorOffset!==f.offset||n.focusNode!==E.node||n.focusOffset!==E.offset)&&(r=r.createRange(),r.setStart(f.node,f.offset),n.removeAllRanges(),g>d?(n.addRange(r),n.extend(E.node,E.offset)):(r.setEnd(E.node,E.offset),n.addRange(r)))}}for(r=[],n=l;n=n.parentNode;)n.nodeType===1&&r.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<r.length;l++)n=r[l],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var OS=h&&"documentMode"in document&&11>=document.documentMode,Lr=null,Ul=null,Ls=null,Kl=!1;function hf(n,r,l){var d=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Kl||Lr==null||Lr!==Ee(d)||(d=Lr,"selectionStart"in d&&Wl(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),Ls&&Ms(Ls,d)||(Ls=d,d=Yo(Ul,"onSelect"),0<d.length&&(r=new Al("onSelect","select",null,r,l),n.push({event:r,listeners:d}),r.target=Lr)))}function Ko(n,r){var l={};return l[n.toLowerCase()]=r.toLowerCase(),l["Webkit"+n]="webkit"+r,l["Moz"+n]="moz"+r,l}var Tr={animationend:Ko("Animation","AnimationEnd"),animationiteration:Ko("Animation","AnimationIteration"),animationstart:Ko("Animation","AnimationStart"),transitionend:Ko("Transition","TransitionEnd")},ql={},ff={};h&&(ff=document.createElement("div").style,"AnimationEvent"in window||(delete Tr.animationend.animation,delete Tr.animationiteration.animation,delete Tr.animationstart.animation),"TransitionEvent"in window||delete Tr.transitionend.transition);function qo(n){if(ql[n])return ql[n];if(!Tr[n])return n;var r=Tr[n],l;for(l in r)if(r.hasOwnProperty(l)&&l in ff)return ql[n]=r[l];return n}var pf=qo("animationend"),mf=qo("animationiteration"),gf=qo("animationstart"),vf=qo("transitionend"),_f=new Map,yf="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 Dn(n,r){_f.set(n,r),a(r,[n])}for(var Vl=0;Vl<yf.length;Vl++){var Yl=yf[Vl],zS=Yl.toLowerCase(),FS=Yl[0].toUpperCase()+Yl.slice(1);Dn(zS,"on"+FS)}Dn(pf,"onAnimationEnd"),Dn(mf,"onAnimationIteration"),Dn(gf,"onAnimationStart"),Dn("dblclick","onDoubleClick"),Dn("focusin","onFocus"),Dn("focusout","onBlur"),Dn(vf,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ts="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(" "),HS=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ts));function Sf(n,r,l){var d=n.type||"unknown-event";n.currentTarget=l,zy(d,r,void 0,n),n.currentTarget=null}function wf(n,r){r=(r&4)!==0;for(var l=0;l<n.length;l++){var d=n[l],f=d.event;d=d.listeners;e:{var g=void 0;if(r)for(var E=d.length-1;0<=E;E--){var B=d[E],V=B.instance,ce=B.currentTarget;if(B=B.listener,V!==g&&f.isPropagationStopped())break e;Sf(f,B,ce),g=V}else for(E=0;E<d.length;E++){if(B=d[E],V=B.instance,ce=B.currentTarget,B=B.listener,V!==g&&f.isPropagationStopped())break e;Sf(f,B,ce),g=V}}}if(Do)throw n=xl,Do=!1,xl=null,n}function dt(n,r){var l=r[ic];l===void 0&&(l=r[ic]=new Set);var d=n+"__bubble";l.has(d)||(bf(r,n,2,!1),l.add(d))}function Xl(n,r,l){var d=0;r&&(d|=4),bf(l,n,d,r)}var Vo="_reactListening"+Math.random().toString(36).slice(2);function As(n){if(!n[Vo]){n[Vo]=!0,s.forEach(function(l){l!=="selectionchange"&&(HS.has(l)||Xl(l,!1,n),Xl(l,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Vo]||(r[Vo]=!0,Xl("selectionchange",!1,r))}}function bf(n,r,l,d){switch(Uh(r)){case 1:var f=tS;break;case 4:f=iS;break;default:f=Ml}l=f.bind(null,r,l,n),f=void 0,!vs||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),d?f!==void 0?n.addEventListener(r,l,{capture:!0,passive:f}):n.addEventListener(r,l,!0):f!==void 0?n.addEventListener(r,l,{passive:f}):n.addEventListener(r,l,!1)}function Gl(n,r,l,d,f){var g=d;if((r&1)===0&&(r&2)===0&&d!==null)e:for(;;){if(d===null)return;var E=d.tag;if(E===3||E===4){var B=d.stateNode.containerInfo;if(B===f||B.nodeType===8&&B.parentNode===f)break;if(E===4)for(E=d.return;E!==null;){var V=E.tag;if((V===3||V===4)&&(V=E.stateNode.containerInfo,V===f||V.nodeType===8&&V.parentNode===f))return;E=E.return}for(;B!==null;){if(E=ir(B),E===null)return;if(V=E.tag,V===5||V===6){d=g=E;continue e}B=B.parentNode}}d=d.return}gs(function(){var ce=g,_e=Xe(l),ye=[];e:{var ve=_f.get(n);if(ve!==void 0){var Pe=Al,Me=n;switch(n){case"keypress":if(Ho(l)===0)break e;case"keydown":case"keyup":Pe=vS;break;case"focusin":Me="focus",Pe=Ol;break;case"focusout":Me="blur",Pe=Ol;break;case"beforeblur":case"afterblur":Pe=Ol;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Pe=Vh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Pe=sS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Pe=SS;break;case pf:case mf:case gf:Pe=lS;break;case vf:Pe=bS;break;case"scroll":Pe=nS;break;case"wheel":Pe=CS;break;case"copy":case"cut":case"paste":Pe=uS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Pe=Xh}var Le=(r&4)!==0,Rt=!Le&&n==="scroll",ie=Le?ve!==null?ve+"Capture":null:ve;Le=[];for(var X=ce,oe;X!==null;){oe=X;var we=oe.stateNode;if(oe.tag===5&&we!==null&&(oe=we,ie!==null&&(we=Si(X,ie),we!=null&&Le.push(Is(X,we,oe)))),Rt)break;X=X.return}0<Le.length&&(ve=new Pe(ve,Me,null,l,_e),ye.push({event:ve,listeners:Le}))}}if((r&7)===0){e:{if(ve=n==="mouseover"||n==="pointerover",Pe=n==="mouseout"||n==="pointerout",ve&&l!==Zt&&(Me=l.relatedTarget||l.fromElement)&&(ir(Me)||Me[hn]))break e;if((Pe||ve)&&(ve=_e.window===_e?_e:(ve=_e.ownerDocument)?ve.defaultView||ve.parentWindow:window,Pe?(Me=l.relatedTarget||l.toElement,Pe=ce,Me=Me?ir(Me):null,Me!==null&&(Rt=tr(Me),Me!==Rt||Me.tag!==5&&Me.tag!==6)&&(Me=null)):(Pe=null,Me=ce),Pe!==Me)){if(Le=Vh,we="onMouseLeave",ie="onMouseEnter",X="mouse",(n==="pointerout"||n==="pointerover")&&(Le=Xh,we="onPointerLeave",ie="onPointerEnter",X="pointer"),Rt=Pe==null?ve:Br(Pe),oe=Me==null?ve:Br(Me),ve=new Le(we,X+"leave",Pe,l,_e),ve.target=Rt,ve.relatedTarget=oe,we=null,ir(_e)===ce&&(Le=new Le(ie,X+"enter",Me,l,_e),Le.target=oe,Le.relatedTarget=Rt,we=Le),Rt=we,Pe&&Me)t:{for(Le=Pe,ie=Me,X=0,oe=Le;oe;oe=Ar(oe))X++;for(oe=0,we=ie;we;we=Ar(we))oe++;for(;0<X-oe;)Le=Ar(Le),X--;for(;0<oe-X;)ie=Ar(ie),oe--;for(;X--;){if(Le===ie||ie!==null&&Le===ie.alternate)break t;Le=Ar(Le),ie=Ar(ie)}Le=null}else Le=null;Pe!==null&&kf(ye,ve,Pe,Le,!1),Me!==null&&Rt!==null&&kf(ye,Rt,Me,Le,!0)}}e:{if(ve=ce?Br(ce):window,Pe=ve.nodeName&&ve.nodeName.toLowerCase(),Pe==="select"||Pe==="input"&&ve.type==="file")var Ie=jS;else if(tf(ve))if(rf)Ie=AS;else{Ie=LS;var Oe=MS}else(Pe=ve.nodeName)&&Pe.toLowerCase()==="input"&&(ve.type==="checkbox"||ve.type==="radio")&&(Ie=TS);if(Ie&&(Ie=Ie(n,ce))){nf(ye,Ie,l,_e);break e}Oe&&Oe(n,ve,ce),n==="focusout"&&(Oe=ve._wrapperState)&&Oe.controlled&&ve.type==="number"&&ct(ve,"number",ve.value)}switch(Oe=ce?Br(ce):window,n){case"focusin":(tf(Oe)||Oe.contentEditable==="true")&&(Lr=Oe,Ul=ce,Ls=null);break;case"focusout":Ls=Ul=Lr=null;break;case"mousedown":Kl=!0;break;case"contextmenu":case"mouseup":case"dragend":Kl=!1,hf(ye,l,_e);break;case"selectionchange":if(OS)break;case"keydown":case"keyup":hf(ye,l,_e)}var ze;if(Fl)e:{switch(n){case"compositionstart":var Ue="onCompositionStart";break e;case"compositionend":Ue="onCompositionEnd";break e;case"compositionupdate":Ue="onCompositionUpdate";break e}Ue=void 0}else Mr?Zh(n,l)&&(Ue="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(Ue="onCompositionStart");Ue&&(Gh&&l.locale!=="ko"&&(Mr||Ue!=="onCompositionStart"?Ue==="onCompositionEnd"&&Mr&&(ze=Kh()):(Pn=_e,Tl="value"in Pn?Pn.value:Pn.textContent,Mr=!0)),Oe=Yo(ce,Ue),0<Oe.length&&(Ue=new Yh(Ue,n,null,l,_e),ye.push({event:Ue,listeners:Oe}),ze?Ue.data=ze:(ze=ef(l),ze!==null&&(Ue.data=ze)))),(ze=ES?NS(n,l):RS(n,l))&&(ce=Yo(ce,"onBeforeInput"),0<ce.length&&(_e=new Yh("onBeforeInput","beforeinput",null,l,_e),ye.push({event:_e,listeners:ce}),_e.data=ze))}wf(ye,r)})}function Is(n,r,l){return{instance:n,listener:r,currentTarget:l}}function Yo(n,r){for(var l=r+"Capture",d=[];n!==null;){var f=n,g=f.stateNode;f.tag===5&&g!==null&&(f=g,g=Si(n,l),g!=null&&d.unshift(Is(n,g,f)),g=Si(n,r),g!=null&&d.push(Is(n,g,f))),n=n.return}return d}function Ar(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function kf(n,r,l,d,f){for(var g=r._reactName,E=[];l!==null&&l!==d;){var B=l,V=B.alternate,ce=B.stateNode;if(V!==null&&V===d)break;B.tag===5&&ce!==null&&(B=ce,f?(V=Si(l,g),V!=null&&E.unshift(Is(l,V,B))):f||(V=Si(l,g),V!=null&&E.push(Is(l,V,B)))),l=l.return}E.length!==0&&n.push({event:r,listeners:E})}var $S=/\r\n?/g,WS=/\u0000|\uFFFD/g;function Cf(n){return(typeof n=="string"?n:""+n).replace($S,`
|
|
38
|
-
`).replace(WS,"")}function Xo(n,r,l){if(r=Cf(r),Cf(n)!==r&&l)throw Error(i(425))}function Go(){}var Ql=null,Jl=null;function Zl(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 ec=typeof setTimeout=="function"?setTimeout:void 0,US=typeof clearTimeout=="function"?clearTimeout:void 0,xf=typeof Promise=="function"?Promise:void 0,KS=typeof queueMicrotask=="function"?queueMicrotask:typeof xf<"u"?function(n){return xf.resolve(null).then(n).catch(qS)}:ec;function qS(n){setTimeout(function(){throw n})}function tc(n,r){var l=r,d=0;do{var f=l.nextSibling;if(n.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"){if(d===0){n.removeChild(f),Es(r);return}d--}else l!=="$"&&l!=="$?"&&l!=="$!"||d++;l=f}while(l);Es(r)}function jn(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 Ef(n){n=n.previousSibling;for(var r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="$"||l==="$!"||l==="$?"){if(r===0)return n;r--}else l==="/$"&&r++}n=n.previousSibling}return null}var Ir=Math.random().toString(36).slice(2),Ji="__reactFiber$"+Ir,Bs="__reactProps$"+Ir,hn="__reactContainer$"+Ir,ic="__reactEvents$"+Ir,VS="__reactListeners$"+Ir,YS="__reactHandles$"+Ir;function ir(n){var r=n[Ji];if(r)return r;for(var l=n.parentNode;l;){if(r=l[hn]||l[Ji]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(n=Ef(n);n!==null;){if(l=n[Ji])return l;n=Ef(n)}return r}n=l,l=n.parentNode}return null}function Os(n){return n=n[Ji]||n[hn],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function Br(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(i(33))}function Qo(n){return n[Bs]||null}var nc=[],Or=-1;function Mn(n){return{current:n}}function ht(n){0>Or||(n.current=nc[Or],nc[Or]=null,Or--)}function ut(n,r){Or++,nc[Or]=n.current,n.current=r}var Ln={},ei=Mn(Ln),di=Mn(!1),nr=Ln;function zr(n,r){var l=n.type.contextTypes;if(!l)return Ln;var d=n.stateNode;if(d&&d.__reactInternalMemoizedUnmaskedChildContext===r)return d.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in l)f[g]=r[g];return d&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=r,n.__reactInternalMemoizedMaskedChildContext=f),f}function hi(n){return n=n.childContextTypes,n!=null}function Jo(){ht(di),ht(ei)}function Nf(n,r,l){if(ei.current!==Ln)throw Error(i(168));ut(ei,r),ut(di,l)}function Rf(n,r,l){var d=n.stateNode;if(r=r.childContextTypes,typeof d.getChildContext!="function")return l;d=d.getChildContext();for(var f in d)if(!(f in r))throw Error(i(108,ue(n)||"Unknown",f));return W({},l,d)}function Zo(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Ln,nr=ei.current,ut(ei,n),ut(di,di.current),!0}function Pf(n,r,l){var d=n.stateNode;if(!d)throw Error(i(169));l?(n=Rf(n,r,nr),d.__reactInternalMemoizedMergedChildContext=n,ht(di),ht(ei),ut(ei,n)):ht(di),ut(di,l)}var fn=null,ea=!1,rc=!1;function Df(n){fn===null?fn=[n]:fn.push(n)}function XS(n){ea=!0,Df(n)}function Tn(){if(!rc&&fn!==null){rc=!0;var n=0,r=ot;try{var l=fn;for(ot=1;n<l.length;n++){var d=l[n];do d=d(!0);while(d!==null)}fn=null,ea=!1}catch(f){throw fn!==null&&(fn=fn.slice(n+1)),jh(El,Tn),f}finally{ot=r,rc=!1}}return null}var Fr=[],Hr=0,ta=null,ia=0,Mi=[],Li=0,rr=null,pn=1,mn="";function sr(n,r){Fr[Hr++]=ia,Fr[Hr++]=ta,ta=n,ia=r}function jf(n,r,l){Mi[Li++]=pn,Mi[Li++]=mn,Mi[Li++]=rr,rr=n;var d=pn;n=mn;var f=32-Wi(d)-1;d&=~(1<<f),l+=1;var g=32-Wi(r)+f;if(30<g){var E=f-f%5;g=(d&(1<<E)-1).toString(32),d>>=E,f-=E,pn=1<<32-Wi(r)+f|l<<f|d,mn=g+n}else pn=1<<g|l<<f|d,mn=n}function sc(n){n.return!==null&&(sr(n,1),jf(n,1,0))}function oc(n){for(;n===ta;)ta=Fr[--Hr],Fr[Hr]=null,ia=Fr[--Hr],Fr[Hr]=null;for(;n===rr;)rr=Mi[--Li],Mi[Li]=null,mn=Mi[--Li],Mi[Li]=null,pn=Mi[--Li],Mi[Li]=null}var bi=null,ki=null,pt=!1,Ki=null;function Mf(n,r){var l=Bi(5,null,null,0);l.elementType="DELETED",l.stateNode=r,l.return=n,r=n.deletions,r===null?(n.deletions=[l],n.flags|=16):r.push(l)}function Lf(n,r){switch(n.tag){case 5:var l=n.type;return r=r.nodeType!==1||l.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(n.stateNode=r,bi=n,ki=jn(r.firstChild),!0):!1;case 6:return r=n.pendingProps===""||r.nodeType!==3?null:r,r!==null?(n.stateNode=r,bi=n,ki=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(l=rr!==null?{id:pn,overflow:mn}:null,n.memoizedState={dehydrated:r,treeContext:l,retryLane:1073741824},l=Bi(18,null,null,0),l.stateNode=r,l.return=n,n.child=l,bi=n,ki=null,!0):!1;default:return!1}}function ac(n){return(n.mode&1)!==0&&(n.flags&128)===0}function lc(n){if(pt){var r=ki;if(r){var l=r;if(!Lf(n,r)){if(ac(n))throw Error(i(418));r=jn(l.nextSibling);var d=bi;r&&Lf(n,r)?Mf(d,l):(n.flags=n.flags&-4097|2,pt=!1,bi=n)}}else{if(ac(n))throw Error(i(418));n.flags=n.flags&-4097|2,pt=!1,bi=n}}}function Tf(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;bi=n}function na(n){if(n!==bi)return!1;if(!pt)return Tf(n),pt=!0,!1;var r;if((r=n.tag!==3)&&!(r=n.tag!==5)&&(r=n.type,r=r!=="head"&&r!=="body"&&!Zl(n.type,n.memoizedProps)),r&&(r=ki)){if(ac(n))throw Af(),Error(i(418));for(;r;)Mf(n,r),r=jn(r.nextSibling)}if(Tf(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(317));e:{for(n=n.nextSibling,r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="/$"){if(r===0){ki=jn(n.nextSibling);break e}r--}else l!=="$"&&l!=="$!"&&l!=="$?"||r++}n=n.nextSibling}ki=null}}else ki=bi?jn(n.stateNode.nextSibling):null;return!0}function Af(){for(var n=ki;n;)n=jn(n.nextSibling)}function $r(){ki=bi=null,pt=!1}function cc(n){Ki===null?Ki=[n]:Ki.push(n)}var GS=M.ReactCurrentBatchConfig;function zs(n,r,l){if(n=l.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(i(309));var d=l.stateNode}if(!d)throw Error(i(147,n));var f=d,g=""+n;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===g?r.ref:(r=function(E){var B=f.refs;E===null?delete B[g]:B[g]=E},r._stringRef=g,r)}if(typeof n!="string")throw Error(i(284));if(!l._owner)throw Error(i(290,n))}return n}function ra(n,r){throw n=Object.prototype.toString.call(r),Error(i(31,n==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":n))}function If(n){var r=n._init;return r(n._payload)}function Bf(n){function r(ie,X){if(n){var oe=ie.deletions;oe===null?(ie.deletions=[X],ie.flags|=16):oe.push(X)}}function l(ie,X){if(!n)return null;for(;X!==null;)r(ie,X),X=X.sibling;return null}function d(ie,X){for(ie=new Map;X!==null;)X.key!==null?ie.set(X.key,X):ie.set(X.index,X),X=X.sibling;return ie}function f(ie,X){return ie=$n(ie,X),ie.index=0,ie.sibling=null,ie}function g(ie,X,oe){return ie.index=oe,n?(oe=ie.alternate,oe!==null?(oe=oe.index,oe<X?(ie.flags|=2,X):oe):(ie.flags|=2,X)):(ie.flags|=1048576,X)}function E(ie){return n&&ie.alternate===null&&(ie.flags|=2),ie}function B(ie,X,oe,we){return X===null||X.tag!==6?(X=eu(oe,ie.mode,we),X.return=ie,X):(X=f(X,oe),X.return=ie,X)}function V(ie,X,oe,we){var Ie=oe.type;return Ie===O?_e(ie,X,oe.props.children,we,oe.key):X!==null&&(X.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===$&&If(Ie)===X.type)?(we=f(X,oe.props),we.ref=zs(ie,X,oe),we.return=ie,we):(we=Ra(oe.type,oe.key,oe.props,null,ie.mode,we),we.ref=zs(ie,X,oe),we.return=ie,we)}function ce(ie,X,oe,we){return X===null||X.tag!==4||X.stateNode.containerInfo!==oe.containerInfo||X.stateNode.implementation!==oe.implementation?(X=tu(oe,ie.mode,we),X.return=ie,X):(X=f(X,oe.children||[]),X.return=ie,X)}function _e(ie,X,oe,we,Ie){return X===null||X.tag!==7?(X=fr(oe,ie.mode,we,Ie),X.return=ie,X):(X=f(X,oe),X.return=ie,X)}function ye(ie,X,oe){if(typeof X=="string"&&X!==""||typeof X=="number")return X=eu(""+X,ie.mode,oe),X.return=ie,X;if(typeof X=="object"&&X!==null){switch(X.$$typeof){case te:return oe=Ra(X.type,X.key,X.props,null,ie.mode,oe),oe.ref=zs(ie,null,X),oe.return=ie,oe;case U:return X=tu(X,ie.mode,oe),X.return=ie,X;case $:var we=X._init;return ye(ie,we(X._payload),oe)}if(at(X)||ae(X))return X=fr(X,ie.mode,oe,null),X.return=ie,X;ra(ie,X)}return null}function ve(ie,X,oe,we){var Ie=X!==null?X.key:null;if(typeof oe=="string"&&oe!==""||typeof oe=="number")return Ie!==null?null:B(ie,X,""+oe,we);if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case te:return oe.key===Ie?V(ie,X,oe,we):null;case U:return oe.key===Ie?ce(ie,X,oe,we):null;case $:return Ie=oe._init,ve(ie,X,Ie(oe._payload),we)}if(at(oe)||ae(oe))return Ie!==null?null:_e(ie,X,oe,we,null);ra(ie,oe)}return null}function Pe(ie,X,oe,we,Ie){if(typeof we=="string"&&we!==""||typeof we=="number")return ie=ie.get(oe)||null,B(X,ie,""+we,Ie);if(typeof we=="object"&&we!==null){switch(we.$$typeof){case te:return ie=ie.get(we.key===null?oe:we.key)||null,V(X,ie,we,Ie);case U:return ie=ie.get(we.key===null?oe:we.key)||null,ce(X,ie,we,Ie);case $:var Oe=we._init;return Pe(ie,X,oe,Oe(we._payload),Ie)}if(at(we)||ae(we))return ie=ie.get(oe)||null,_e(X,ie,we,Ie,null);ra(X,we)}return null}function Me(ie,X,oe,we){for(var Ie=null,Oe=null,ze=X,Ue=X=0,Ht=null;ze!==null&&Ue<oe.length;Ue++){ze.index>Ue?(Ht=ze,ze=null):Ht=ze.sibling;var nt=ve(ie,ze,oe[Ue],we);if(nt===null){ze===null&&(ze=Ht);break}n&&ze&&nt.alternate===null&&r(ie,ze),X=g(nt,X,Ue),Oe===null?Ie=nt:Oe.sibling=nt,Oe=nt,ze=Ht}if(Ue===oe.length)return l(ie,ze),pt&&sr(ie,Ue),Ie;if(ze===null){for(;Ue<oe.length;Ue++)ze=ye(ie,oe[Ue],we),ze!==null&&(X=g(ze,X,Ue),Oe===null?Ie=ze:Oe.sibling=ze,Oe=ze);return pt&&sr(ie,Ue),Ie}for(ze=d(ie,ze);Ue<oe.length;Ue++)Ht=Pe(ze,ie,Ue,oe[Ue],we),Ht!==null&&(n&&Ht.alternate!==null&&ze.delete(Ht.key===null?Ue:Ht.key),X=g(Ht,X,Ue),Oe===null?Ie=Ht:Oe.sibling=Ht,Oe=Ht);return n&&ze.forEach(function(Wn){return r(ie,Wn)}),pt&&sr(ie,Ue),Ie}function Le(ie,X,oe,we){var Ie=ae(oe);if(typeof Ie!="function")throw Error(i(150));if(oe=Ie.call(oe),oe==null)throw Error(i(151));for(var Oe=Ie=null,ze=X,Ue=X=0,Ht=null,nt=oe.next();ze!==null&&!nt.done;Ue++,nt=oe.next()){ze.index>Ue?(Ht=ze,ze=null):Ht=ze.sibling;var Wn=ve(ie,ze,nt.value,we);if(Wn===null){ze===null&&(ze=Ht);break}n&&ze&&Wn.alternate===null&&r(ie,ze),X=g(Wn,X,Ue),Oe===null?Ie=Wn:Oe.sibling=Wn,Oe=Wn,ze=Ht}if(nt.done)return l(ie,ze),pt&&sr(ie,Ue),Ie;if(ze===null){for(;!nt.done;Ue++,nt=oe.next())nt=ye(ie,nt.value,we),nt!==null&&(X=g(nt,X,Ue),Oe===null?Ie=nt:Oe.sibling=nt,Oe=nt);return pt&&sr(ie,Ue),Ie}for(ze=d(ie,ze);!nt.done;Ue++,nt=oe.next())nt=Pe(ze,ie,Ue,nt.value,we),nt!==null&&(n&&nt.alternate!==null&&ze.delete(nt.key===null?Ue:nt.key),X=g(nt,X,Ue),Oe===null?Ie=nt:Oe.sibling=nt,Oe=nt);return n&&ze.forEach(function(Pw){return r(ie,Pw)}),pt&&sr(ie,Ue),Ie}function Rt(ie,X,oe,we){if(typeof oe=="object"&&oe!==null&&oe.type===O&&oe.key===null&&(oe=oe.props.children),typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case te:e:{for(var Ie=oe.key,Oe=X;Oe!==null;){if(Oe.key===Ie){if(Ie=oe.type,Ie===O){if(Oe.tag===7){l(ie,Oe.sibling),X=f(Oe,oe.props.children),X.return=ie,ie=X;break e}}else if(Oe.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===$&&If(Ie)===Oe.type){l(ie,Oe.sibling),X=f(Oe,oe.props),X.ref=zs(ie,Oe,oe),X.return=ie,ie=X;break e}l(ie,Oe);break}else r(ie,Oe);Oe=Oe.sibling}oe.type===O?(X=fr(oe.props.children,ie.mode,we,oe.key),X.return=ie,ie=X):(we=Ra(oe.type,oe.key,oe.props,null,ie.mode,we),we.ref=zs(ie,X,oe),we.return=ie,ie=we)}return E(ie);case U:e:{for(Oe=oe.key;X!==null;){if(X.key===Oe)if(X.tag===4&&X.stateNode.containerInfo===oe.containerInfo&&X.stateNode.implementation===oe.implementation){l(ie,X.sibling),X=f(X,oe.children||[]),X.return=ie,ie=X;break e}else{l(ie,X);break}else r(ie,X);X=X.sibling}X=tu(oe,ie.mode,we),X.return=ie,ie=X}return E(ie);case $:return Oe=oe._init,Rt(ie,X,Oe(oe._payload),we)}if(at(oe))return Me(ie,X,oe,we);if(ae(oe))return Le(ie,X,oe,we);ra(ie,oe)}return typeof oe=="string"&&oe!==""||typeof oe=="number"?(oe=""+oe,X!==null&&X.tag===6?(l(ie,X.sibling),X=f(X,oe),X.return=ie,ie=X):(l(ie,X),X=eu(oe,ie.mode,we),X.return=ie,ie=X),E(ie)):l(ie,X)}return Rt}var Wr=Bf(!0),Of=Bf(!1),sa=Mn(null),oa=null,Ur=null,uc=null;function dc(){uc=Ur=oa=null}function hc(n){var r=sa.current;ht(sa),n._currentValue=r}function fc(n,r,l){for(;n!==null;){var d=n.alternate;if((n.childLanes&r)!==r?(n.childLanes|=r,d!==null&&(d.childLanes|=r)):d!==null&&(d.childLanes&r)!==r&&(d.childLanes|=r),n===l)break;n=n.return}}function Kr(n,r){oa=n,uc=Ur=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&r)!==0&&(fi=!0),n.firstContext=null)}function Ti(n){var r=n._currentValue;if(uc!==n)if(n={context:n,memoizedValue:r,next:null},Ur===null){if(oa===null)throw Error(i(308));Ur=n,oa.dependencies={lanes:0,firstContext:n}}else Ur=Ur.next=n;return r}var or=null;function pc(n){or===null?or=[n]:or.push(n)}function zf(n,r,l,d){var f=r.interleaved;return f===null?(l.next=l,pc(r)):(l.next=f.next,f.next=l),r.interleaved=l,gn(n,d)}function gn(n,r){n.lanes|=r;var l=n.alternate;for(l!==null&&(l.lanes|=r),l=n,n=n.return;n!==null;)n.childLanes|=r,l=n.alternate,l!==null&&(l.childLanes|=r),l=n,n=n.return;return l.tag===3?l.stateNode:null}var An=!1;function mc(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ff(n,r){n=n.updateQueue,r.updateQueue===n&&(r.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function vn(n,r){return{eventTime:n,lane:r,tag:0,payload:null,callback:null,next:null}}function In(n,r,l){var d=n.updateQueue;if(d===null)return null;if(d=d.shared,(it&2)!==0){var f=d.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),d.pending=r,gn(n,l)}return f=d.interleaved,f===null?(r.next=r,pc(d)):(r.next=f.next,f.next=r),d.interleaved=r,gn(n,l)}function aa(n,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194240)!==0)){var d=r.lanes;d&=n.pendingLanes,l|=d,r.lanes=l,Pl(n,l)}}function Hf(n,r){var l=n.updateQueue,d=n.alternate;if(d!==null&&(d=d.updateQueue,l===d)){var f=null,g=null;if(l=l.firstBaseUpdate,l!==null){do{var E={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};g===null?f=g=E:g=g.next=E,l=l.next}while(l!==null);g===null?f=g=r:g=g.next=r}else f=g=r;l={baseState:d.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:d.shared,effects:d.effects},n.updateQueue=l;return}n=l.lastBaseUpdate,n===null?l.firstBaseUpdate=r:n.next=r,l.lastBaseUpdate=r}function la(n,r,l,d){var f=n.updateQueue;An=!1;var g=f.firstBaseUpdate,E=f.lastBaseUpdate,B=f.shared.pending;if(B!==null){f.shared.pending=null;var V=B,ce=V.next;V.next=null,E===null?g=ce:E.next=ce,E=V;var _e=n.alternate;_e!==null&&(_e=_e.updateQueue,B=_e.lastBaseUpdate,B!==E&&(B===null?_e.firstBaseUpdate=ce:B.next=ce,_e.lastBaseUpdate=V))}if(g!==null){var ye=f.baseState;E=0,_e=ce=V=null,B=g;do{var ve=B.lane,Pe=B.eventTime;if((d&ve)===ve){_e!==null&&(_e=_e.next={eventTime:Pe,lane:0,tag:B.tag,payload:B.payload,callback:B.callback,next:null});e:{var Me=n,Le=B;switch(ve=r,Pe=l,Le.tag){case 1:if(Me=Le.payload,typeof Me=="function"){ye=Me.call(Pe,ye,ve);break e}ye=Me;break e;case 3:Me.flags=Me.flags&-65537|128;case 0:if(Me=Le.payload,ve=typeof Me=="function"?Me.call(Pe,ye,ve):Me,ve==null)break e;ye=W({},ye,ve);break e;case 2:An=!0}}B.callback!==null&&B.lane!==0&&(n.flags|=64,ve=f.effects,ve===null?f.effects=[B]:ve.push(B))}else Pe={eventTime:Pe,lane:ve,tag:B.tag,payload:B.payload,callback:B.callback,next:null},_e===null?(ce=_e=Pe,V=ye):_e=_e.next=Pe,E|=ve;if(B=B.next,B===null){if(B=f.shared.pending,B===null)break;ve=B,B=ve.next,ve.next=null,f.lastBaseUpdate=ve,f.shared.pending=null}}while(!0);if(_e===null&&(V=ye),f.baseState=V,f.firstBaseUpdate=ce,f.lastBaseUpdate=_e,r=f.shared.interleaved,r!==null){f=r;do E|=f.lane,f=f.next;while(f!==r)}else g===null&&(f.shared.lanes=0);cr|=E,n.lanes=E,n.memoizedState=ye}}function $f(n,r,l){if(n=r.effects,r.effects=null,n!==null)for(r=0;r<n.length;r++){var d=n[r],f=d.callback;if(f!==null){if(d.callback=null,d=l,typeof f!="function")throw Error(i(191,f));f.call(d)}}}var Fs={},Zi=Mn(Fs),Hs=Mn(Fs),$s=Mn(Fs);function ar(n){if(n===Fs)throw Error(i(174));return n}function gc(n,r){switch(ut($s,r),ut(Hs,n),ut(Zi,Fs),n=r.nodeType,n){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Te(null,"");break;default:n=n===8?r.parentNode:r,r=n.namespaceURI||null,n=n.tagName,r=Te(r,n)}ht(Zi),ut(Zi,r)}function qr(){ht(Zi),ht(Hs),ht($s)}function Wf(n){ar($s.current);var r=ar(Zi.current),l=Te(r,n.type);r!==l&&(ut(Hs,n),ut(Zi,l))}function vc(n){Hs.current===n&&(ht(Zi),ht(Hs))}var vt=Mn(0);function ca(n){for(var r=n;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var _c=[];function yc(){for(var n=0;n<_c.length;n++)_c[n]._workInProgressVersionPrimary=null;_c.length=0}var ua=M.ReactCurrentDispatcher,Sc=M.ReactCurrentBatchConfig,lr=0,_t=null,Tt=null,zt=null,da=!1,Ws=!1,Us=0,QS=0;function ti(){throw Error(i(321))}function wc(n,r){if(r===null)return!1;for(var l=0;l<r.length&&l<n.length;l++)if(!Ui(n[l],r[l]))return!1;return!0}function bc(n,r,l,d,f,g){if(lr=g,_t=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,ua.current=n===null||n.memoizedState===null?tw:iw,n=l(d,f),Ws){g=0;do{if(Ws=!1,Us=0,25<=g)throw Error(i(301));g+=1,zt=Tt=null,r.updateQueue=null,ua.current=nw,n=l(d,f)}while(Ws)}if(ua.current=pa,r=Tt!==null&&Tt.next!==null,lr=0,zt=Tt=_t=null,da=!1,r)throw Error(i(300));return n}function kc(){var n=Us!==0;return Us=0,n}function en(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return zt===null?_t.memoizedState=zt=n:zt=zt.next=n,zt}function Ai(){if(Tt===null){var n=_t.alternate;n=n!==null?n.memoizedState:null}else n=Tt.next;var r=zt===null?_t.memoizedState:zt.next;if(r!==null)zt=r,Tt=n;else{if(n===null)throw Error(i(310));Tt=n,n={memoizedState:Tt.memoizedState,baseState:Tt.baseState,baseQueue:Tt.baseQueue,queue:Tt.queue,next:null},zt===null?_t.memoizedState=zt=n:zt=zt.next=n}return zt}function Ks(n,r){return typeof r=="function"?r(n):r}function Cc(n){var r=Ai(),l=r.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=n;var d=Tt,f=d.baseQueue,g=l.pending;if(g!==null){if(f!==null){var E=f.next;f.next=g.next,g.next=E}d.baseQueue=f=g,l.pending=null}if(f!==null){g=f.next,d=d.baseState;var B=E=null,V=null,ce=g;do{var _e=ce.lane;if((lr&_e)===_e)V!==null&&(V=V.next={lane:0,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null}),d=ce.hasEagerState?ce.eagerState:n(d,ce.action);else{var ye={lane:_e,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null};V===null?(B=V=ye,E=d):V=V.next=ye,_t.lanes|=_e,cr|=_e}ce=ce.next}while(ce!==null&&ce!==g);V===null?E=d:V.next=B,Ui(d,r.memoizedState)||(fi=!0),r.memoizedState=d,r.baseState=E,r.baseQueue=V,l.lastRenderedState=d}if(n=l.interleaved,n!==null){f=n;do g=f.lane,_t.lanes|=g,cr|=g,f=f.next;while(f!==n)}else f===null&&(l.lanes=0);return[r.memoizedState,l.dispatch]}function xc(n){var r=Ai(),l=r.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=n;var d=l.dispatch,f=l.pending,g=r.memoizedState;if(f!==null){l.pending=null;var E=f=f.next;do g=n(g,E.action),E=E.next;while(E!==f);Ui(g,r.memoizedState)||(fi=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),l.lastRenderedState=g}return[g,d]}function Uf(){}function Kf(n,r){var l=_t,d=Ai(),f=r(),g=!Ui(d.memoizedState,f);if(g&&(d.memoizedState=f,fi=!0),d=d.queue,Ec(Yf.bind(null,l,d,n),[n]),d.getSnapshot!==r||g||zt!==null&&zt.memoizedState.tag&1){if(l.flags|=2048,qs(9,Vf.bind(null,l,d,f,r),void 0,null),Ft===null)throw Error(i(349));(lr&30)!==0||qf(l,r,f)}return f}function qf(n,r,l){n.flags|=16384,n={getSnapshot:r,value:l},r=_t.updateQueue,r===null?(r={lastEffect:null,stores:null},_t.updateQueue=r,r.stores=[n]):(l=r.stores,l===null?r.stores=[n]:l.push(n))}function Vf(n,r,l,d){r.value=l,r.getSnapshot=d,Xf(r)&&Gf(n)}function Yf(n,r,l){return l(function(){Xf(r)&&Gf(n)})}function Xf(n){var r=n.getSnapshot;n=n.value;try{var l=r();return!Ui(n,l)}catch{return!0}}function Gf(n){var r=gn(n,1);r!==null&&Xi(r,n,1,-1)}function Qf(n){var r=en();return typeof n=="function"&&(n=n()),r.memoizedState=r.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ks,lastRenderedState:n},r.queue=n,n=n.dispatch=ew.bind(null,_t,n),[r.memoizedState,n]}function qs(n,r,l,d){return n={tag:n,create:r,destroy:l,deps:d,next:null},r=_t.updateQueue,r===null?(r={lastEffect:null,stores:null},_t.updateQueue=r,r.lastEffect=n.next=n):(l=r.lastEffect,l===null?r.lastEffect=n.next=n:(d=l.next,l.next=n,n.next=d,r.lastEffect=n)),n}function Jf(){return Ai().memoizedState}function ha(n,r,l,d){var f=en();_t.flags|=n,f.memoizedState=qs(1|r,l,void 0,d===void 0?null:d)}function fa(n,r,l,d){var f=Ai();d=d===void 0?null:d;var g=void 0;if(Tt!==null){var E=Tt.memoizedState;if(g=E.destroy,d!==null&&wc(d,E.deps)){f.memoizedState=qs(r,l,g,d);return}}_t.flags|=n,f.memoizedState=qs(1|r,l,g,d)}function Zf(n,r){return ha(8390656,8,n,r)}function Ec(n,r){return fa(2048,8,n,r)}function ep(n,r){return fa(4,2,n,r)}function tp(n,r){return fa(4,4,n,r)}function ip(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 np(n,r,l){return l=l!=null?l.concat([n]):null,fa(4,4,ip.bind(null,r,n),l)}function Nc(){}function rp(n,r){var l=Ai();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&wc(r,d[1])?d[0]:(l.memoizedState=[n,r],n)}function sp(n,r){var l=Ai();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&wc(r,d[1])?d[0]:(n=n(),l.memoizedState=[n,r],n)}function op(n,r,l){return(lr&21)===0?(n.baseState&&(n.baseState=!1,fi=!0),n.memoizedState=l):(Ui(l,r)||(l=Ah(),_t.lanes|=l,cr|=l,n.baseState=!0),r)}function JS(n,r){var l=ot;ot=l!==0&&4>l?l:4,n(!0);var d=Sc.transition;Sc.transition={};try{n(!1),r()}finally{ot=l,Sc.transition=d}}function ap(){return Ai().memoizedState}function ZS(n,r,l){var d=Fn(n);if(l={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null},lp(n))cp(r,l);else if(l=zf(n,r,l,d),l!==null){var f=ai();Xi(l,n,d,f),up(l,r,d)}}function ew(n,r,l){var d=Fn(n),f={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null};if(lp(n))cp(r,f);else{var g=n.alternate;if(n.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var E=r.lastRenderedState,B=g(E,l);if(f.hasEagerState=!0,f.eagerState=B,Ui(B,E)){var V=r.interleaved;V===null?(f.next=f,pc(r)):(f.next=V.next,V.next=f),r.interleaved=f;return}}catch{}finally{}l=zf(n,r,f,d),l!==null&&(f=ai(),Xi(l,n,d,f),up(l,r,d))}}function lp(n){var r=n.alternate;return n===_t||r!==null&&r===_t}function cp(n,r){Ws=da=!0;var l=n.pending;l===null?r.next=r:(r.next=l.next,l.next=r),n.pending=r}function up(n,r,l){if((l&4194240)!==0){var d=r.lanes;d&=n.pendingLanes,l|=d,r.lanes=l,Pl(n,l)}}var pa={readContext:Ti,useCallback:ti,useContext:ti,useEffect:ti,useImperativeHandle:ti,useInsertionEffect:ti,useLayoutEffect:ti,useMemo:ti,useReducer:ti,useRef:ti,useState:ti,useDebugValue:ti,useDeferredValue:ti,useTransition:ti,useMutableSource:ti,useSyncExternalStore:ti,useId:ti,unstable_isNewReconciler:!1},tw={readContext:Ti,useCallback:function(n,r){return en().memoizedState=[n,r===void 0?null:r],n},useContext:Ti,useEffect:Zf,useImperativeHandle:function(n,r,l){return l=l!=null?l.concat([n]):null,ha(4194308,4,ip.bind(null,r,n),l)},useLayoutEffect:function(n,r){return ha(4194308,4,n,r)},useInsertionEffect:function(n,r){return ha(4,2,n,r)},useMemo:function(n,r){var l=en();return r=r===void 0?null:r,n=n(),l.memoizedState=[n,r],n},useReducer:function(n,r,l){var d=en();return r=l!==void 0?l(r):r,d.memoizedState=d.baseState=r,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:r},d.queue=n,n=n.dispatch=ZS.bind(null,_t,n),[d.memoizedState,n]},useRef:function(n){var r=en();return n={current:n},r.memoizedState=n},useState:Qf,useDebugValue:Nc,useDeferredValue:function(n){return en().memoizedState=n},useTransition:function(){var n=Qf(!1),r=n[0];return n=JS.bind(null,n[1]),en().memoizedState=n,[r,n]},useMutableSource:function(){},useSyncExternalStore:function(n,r,l){var d=_t,f=en();if(pt){if(l===void 0)throw Error(i(407));l=l()}else{if(l=r(),Ft===null)throw Error(i(349));(lr&30)!==0||qf(d,r,l)}f.memoizedState=l;var g={value:l,getSnapshot:r};return f.queue=g,Zf(Yf.bind(null,d,g,n),[n]),d.flags|=2048,qs(9,Vf.bind(null,d,g,l,r),void 0,null),l},useId:function(){var n=en(),r=Ft.identifierPrefix;if(pt){var l=mn,d=pn;l=(d&~(1<<32-Wi(d)-1)).toString(32)+l,r=":"+r+"R"+l,l=Us++,0<l&&(r+="H"+l.toString(32)),r+=":"}else l=QS++,r=":"+r+"r"+l.toString(32)+":";return n.memoizedState=r},unstable_isNewReconciler:!1},iw={readContext:Ti,useCallback:rp,useContext:Ti,useEffect:Ec,useImperativeHandle:np,useInsertionEffect:ep,useLayoutEffect:tp,useMemo:sp,useReducer:Cc,useRef:Jf,useState:function(){return Cc(Ks)},useDebugValue:Nc,useDeferredValue:function(n){var r=Ai();return op(r,Tt.memoizedState,n)},useTransition:function(){var n=Cc(Ks)[0],r=Ai().memoizedState;return[n,r]},useMutableSource:Uf,useSyncExternalStore:Kf,useId:ap,unstable_isNewReconciler:!1},nw={readContext:Ti,useCallback:rp,useContext:Ti,useEffect:Ec,useImperativeHandle:np,useInsertionEffect:ep,useLayoutEffect:tp,useMemo:sp,useReducer:xc,useRef:Jf,useState:function(){return xc(Ks)},useDebugValue:Nc,useDeferredValue:function(n){var r=Ai();return Tt===null?r.memoizedState=n:op(r,Tt.memoizedState,n)},useTransition:function(){var n=xc(Ks)[0],r=Ai().memoizedState;return[n,r]},useMutableSource:Uf,useSyncExternalStore:Kf,useId:ap,unstable_isNewReconciler:!1};function qi(n,r){if(n&&n.defaultProps){r=W({},r),n=n.defaultProps;for(var l in n)r[l]===void 0&&(r[l]=n[l]);return r}return r}function Rc(n,r,l,d){r=n.memoizedState,l=l(d,r),l=l==null?r:W({},r,l),n.memoizedState=l,n.lanes===0&&(n.updateQueue.baseState=l)}var ma={isMounted:function(n){return(n=n._reactInternals)?tr(n)===n:!1},enqueueSetState:function(n,r,l){n=n._reactInternals;var d=ai(),f=Fn(n),g=vn(d,f);g.payload=r,l!=null&&(g.callback=l),r=In(n,g,f),r!==null&&(Xi(r,n,f,d),aa(r,n,f))},enqueueReplaceState:function(n,r,l){n=n._reactInternals;var d=ai(),f=Fn(n),g=vn(d,f);g.tag=1,g.payload=r,l!=null&&(g.callback=l),r=In(n,g,f),r!==null&&(Xi(r,n,f,d),aa(r,n,f))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var l=ai(),d=Fn(n),f=vn(l,d);f.tag=2,r!=null&&(f.callback=r),r=In(n,f,d),r!==null&&(Xi(r,n,d,l),aa(r,n,d))}};function dp(n,r,l,d,f,g,E){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(d,g,E):r.prototype&&r.prototype.isPureReactComponent?!Ms(l,d)||!Ms(f,g):!0}function hp(n,r,l){var d=!1,f=Ln,g=r.contextType;return typeof g=="object"&&g!==null?g=Ti(g):(f=hi(r)?nr:ei.current,d=r.contextTypes,g=(d=d!=null)?zr(n,f):Ln),r=new r(l,g),n.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=ma,n.stateNode=r,r._reactInternals=n,d&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=f,n.__reactInternalMemoizedMaskedChildContext=g),r}function fp(n,r,l,d){n=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,d),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,d),r.state!==n&&ma.enqueueReplaceState(r,r.state,null)}function Pc(n,r,l,d){var f=n.stateNode;f.props=l,f.state=n.memoizedState,f.refs={},mc(n);var g=r.contextType;typeof g=="object"&&g!==null?f.context=Ti(g):(g=hi(r)?nr:ei.current,f.context=zr(n,g)),f.state=n.memoizedState,g=r.getDerivedStateFromProps,typeof g=="function"&&(Rc(n,r,g,l),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&&ma.enqueueReplaceState(f,f.state,null),la(n,l,f,d),f.state=n.memoizedState),typeof f.componentDidMount=="function"&&(n.flags|=4194308)}function Vr(n,r){try{var l="",d=r;do l+=G(d),d=d.return;while(d);var f=l}catch(g){f=`
|
|
39
|
-
Error generating stack: `+g.message+`
|
|
40
|
-
`+g.stack}return{value:n,source:r,stack:f,digest:null}}function Dc(n,r,l){return{value:n,source:null,stack:l??null,digest:r??null}}function jc(n,r){try{console.error(r.value)}catch(l){setTimeout(function(){throw l})}}var rw=typeof WeakMap=="function"?WeakMap:Map;function pp(n,r,l){l=vn(-1,l),l.tag=3,l.payload={element:null};var d=r.value;return l.callback=function(){ba||(ba=!0,qc=d),jc(n,r)},l}function mp(n,r,l){l=vn(-1,l),l.tag=3;var d=n.type.getDerivedStateFromError;if(typeof d=="function"){var f=r.value;l.payload=function(){return d(f)},l.callback=function(){jc(n,r)}}var g=n.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(l.callback=function(){jc(n,r),typeof d!="function"&&(On===null?On=new Set([this]):On.add(this));var E=r.stack;this.componentDidCatch(r.value,{componentStack:E!==null?E:""})}),l}function gp(n,r,l){var d=n.pingCache;if(d===null){d=n.pingCache=new rw;var f=new Set;d.set(r,f)}else f=d.get(r),f===void 0&&(f=new Set,d.set(r,f));f.has(l)||(f.add(l),n=_w.bind(null,n,r,l),r.then(n,n))}function vp(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 _p(n,r,l,d,f){return(n.mode&1)===0?(n===r?n.flags|=65536:(n.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(r=vn(-1,1),r.tag=2,In(l,r,1))),l.lanes|=1),n):(n.flags|=65536,n.lanes=f,n)}var sw=M.ReactCurrentOwner,fi=!1;function oi(n,r,l,d){r.child=n===null?Of(r,null,l,d):Wr(r,n.child,l,d)}function yp(n,r,l,d,f){l=l.render;var g=r.ref;return Kr(r,f),d=bc(n,r,l,d,g,f),l=kc(),n!==null&&!fi?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,_n(n,r,f)):(pt&&l&&sc(r),r.flags|=1,oi(n,r,d,f),r.child)}function Sp(n,r,l,d,f){if(n===null){var g=l.type;return typeof g=="function"&&!Zc(g)&&g.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(r.tag=15,r.type=g,wp(n,r,g,d,f)):(n=Ra(l.type,null,d,r,r.mode,f),n.ref=r.ref,n.return=r,r.child=n)}if(g=n.child,(n.lanes&f)===0){var E=g.memoizedProps;if(l=l.compare,l=l!==null?l:Ms,l(E,d)&&n.ref===r.ref)return _n(n,r,f)}return r.flags|=1,n=$n(g,d),n.ref=r.ref,n.return=r,r.child=n}function wp(n,r,l,d,f){if(n!==null){var g=n.memoizedProps;if(Ms(g,d)&&n.ref===r.ref)if(fi=!1,r.pendingProps=d=g,(n.lanes&f)!==0)(n.flags&131072)!==0&&(fi=!0);else return r.lanes=n.lanes,_n(n,r,f)}return Mc(n,r,l,d,f)}function bp(n,r,l){var d=r.pendingProps,f=d.children,g=n!==null?n.memoizedState:null;if(d.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},ut(Xr,Ci),Ci|=l;else{if((l&1073741824)===0)return n=g!==null?g.baseLanes|l:l,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:n,cachePool:null,transitions:null},r.updateQueue=null,ut(Xr,Ci),Ci|=n,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},d=g!==null?g.baseLanes:l,ut(Xr,Ci),Ci|=d}else g!==null?(d=g.baseLanes|l,r.memoizedState=null):d=l,ut(Xr,Ci),Ci|=d;return oi(n,r,f,l),r.child}function kp(n,r){var l=r.ref;(n===null&&l!==null||n!==null&&n.ref!==l)&&(r.flags|=512,r.flags|=2097152)}function Mc(n,r,l,d,f){var g=hi(l)?nr:ei.current;return g=zr(r,g),Kr(r,f),l=bc(n,r,l,d,g,f),d=kc(),n!==null&&!fi?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,_n(n,r,f)):(pt&&d&&sc(r),r.flags|=1,oi(n,r,l,f),r.child)}function Cp(n,r,l,d,f){if(hi(l)){var g=!0;Zo(r)}else g=!1;if(Kr(r,f),r.stateNode===null)va(n,r),hp(r,l,d),Pc(r,l,d,f),d=!0;else if(n===null){var E=r.stateNode,B=r.memoizedProps;E.props=B;var V=E.context,ce=l.contextType;typeof ce=="object"&&ce!==null?ce=Ti(ce):(ce=hi(l)?nr:ei.current,ce=zr(r,ce));var _e=l.getDerivedStateFromProps,ye=typeof _e=="function"||typeof E.getSnapshotBeforeUpdate=="function";ye||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(B!==d||V!==ce)&&fp(r,E,d,ce),An=!1;var ve=r.memoizedState;E.state=ve,la(r,d,E,f),V=r.memoizedState,B!==d||ve!==V||di.current||An?(typeof _e=="function"&&(Rc(r,l,_e,d),V=r.memoizedState),(B=An||dp(r,l,B,d,ve,V,ce))?(ye||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount()),typeof E.componentDidMount=="function"&&(r.flags|=4194308)):(typeof E.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=d,r.memoizedState=V),E.props=d,E.state=V,E.context=ce,d=B):(typeof E.componentDidMount=="function"&&(r.flags|=4194308),d=!1)}else{E=r.stateNode,Ff(n,r),B=r.memoizedProps,ce=r.type===r.elementType?B:qi(r.type,B),E.props=ce,ye=r.pendingProps,ve=E.context,V=l.contextType,typeof V=="object"&&V!==null?V=Ti(V):(V=hi(l)?nr:ei.current,V=zr(r,V));var Pe=l.getDerivedStateFromProps;(_e=typeof Pe=="function"||typeof E.getSnapshotBeforeUpdate=="function")||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(B!==ye||ve!==V)&&fp(r,E,d,V),An=!1,ve=r.memoizedState,E.state=ve,la(r,d,E,f);var Me=r.memoizedState;B!==ye||ve!==Me||di.current||An?(typeof Pe=="function"&&(Rc(r,l,Pe,d),Me=r.memoizedState),(ce=An||dp(r,l,ce,d,ve,Me,V)||!1)?(_e||typeof E.UNSAFE_componentWillUpdate!="function"&&typeof E.componentWillUpdate!="function"||(typeof E.componentWillUpdate=="function"&&E.componentWillUpdate(d,Me,V),typeof E.UNSAFE_componentWillUpdate=="function"&&E.UNSAFE_componentWillUpdate(d,Me,V)),typeof E.componentDidUpdate=="function"&&(r.flags|=4),typeof E.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof E.componentDidUpdate!="function"||B===n.memoizedProps&&ve===n.memoizedState||(r.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||B===n.memoizedProps&&ve===n.memoizedState||(r.flags|=1024),r.memoizedProps=d,r.memoizedState=Me),E.props=d,E.state=Me,E.context=V,d=ce):(typeof E.componentDidUpdate!="function"||B===n.memoizedProps&&ve===n.memoizedState||(r.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||B===n.memoizedProps&&ve===n.memoizedState||(r.flags|=1024),d=!1)}return Lc(n,r,l,d,g,f)}function Lc(n,r,l,d,f,g){kp(n,r);var E=(r.flags&128)!==0;if(!d&&!E)return f&&Pf(r,l,!1),_n(n,r,g);d=r.stateNode,sw.current=r;var B=E&&typeof l.getDerivedStateFromError!="function"?null:d.render();return r.flags|=1,n!==null&&E?(r.child=Wr(r,n.child,null,g),r.child=Wr(r,null,B,g)):oi(n,r,B,g),r.memoizedState=d.state,f&&Pf(r,l,!0),r.child}function xp(n){var r=n.stateNode;r.pendingContext?Nf(n,r.pendingContext,r.pendingContext!==r.context):r.context&&Nf(n,r.context,!1),gc(n,r.containerInfo)}function Ep(n,r,l,d,f){return $r(),cc(f),r.flags|=256,oi(n,r,l,d),r.child}var Tc={dehydrated:null,treeContext:null,retryLane:0};function Ac(n){return{baseLanes:n,cachePool:null,transitions:null}}function Np(n,r,l){var d=r.pendingProps,f=vt.current,g=!1,E=(r.flags&128)!==0,B;if((B=E)||(B=n!==null&&n.memoizedState===null?!1:(f&2)!==0),B?(g=!0,r.flags&=-129):(n===null||n.memoizedState!==null)&&(f|=1),ut(vt,f&1),n===null)return lc(r),n=r.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((r.mode&1)===0?r.lanes=1:n.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(E=d.children,n=d.fallback,g?(d=r.mode,g=r.child,E={mode:"hidden",children:E},(d&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=E):g=Pa(E,d,0,null),n=fr(n,d,l,null),g.return=r,n.return=r,g.sibling=n,r.child=g,r.child.memoizedState=Ac(l),r.memoizedState=Tc,n):Ic(r,E));if(f=n.memoizedState,f!==null&&(B=f.dehydrated,B!==null))return ow(n,r,E,d,B,f,l);if(g){g=d.fallback,E=r.mode,f=n.child,B=f.sibling;var V={mode:"hidden",children:d.children};return(E&1)===0&&r.child!==f?(d=r.child,d.childLanes=0,d.pendingProps=V,r.deletions=null):(d=$n(f,V),d.subtreeFlags=f.subtreeFlags&14680064),B!==null?g=$n(B,g):(g=fr(g,E,l,null),g.flags|=2),g.return=r,d.return=r,d.sibling=g,r.child=d,d=g,g=r.child,E=n.child.memoizedState,E=E===null?Ac(l):{baseLanes:E.baseLanes|l,cachePool:null,transitions:E.transitions},g.memoizedState=E,g.childLanes=n.childLanes&~l,r.memoizedState=Tc,d}return g=n.child,n=g.sibling,d=$n(g,{mode:"visible",children:d.children}),(r.mode&1)===0&&(d.lanes=l),d.return=r,d.sibling=null,n!==null&&(l=r.deletions,l===null?(r.deletions=[n],r.flags|=16):l.push(n)),r.child=d,r.memoizedState=null,d}function Ic(n,r){return r=Pa({mode:"visible",children:r},n.mode,0,null),r.return=n,n.child=r}function ga(n,r,l,d){return d!==null&&cc(d),Wr(r,n.child,null,l),n=Ic(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function ow(n,r,l,d,f,g,E){if(l)return r.flags&256?(r.flags&=-257,d=Dc(Error(i(422))),ga(n,r,E,d)):r.memoizedState!==null?(r.child=n.child,r.flags|=128,null):(g=d.fallback,f=r.mode,d=Pa({mode:"visible",children:d.children},f,0,null),g=fr(g,f,E,null),g.flags|=2,d.return=r,g.return=r,d.sibling=g,r.child=d,(r.mode&1)!==0&&Wr(r,n.child,null,E),r.child.memoizedState=Ac(E),r.memoizedState=Tc,g);if((r.mode&1)===0)return ga(n,r,E,null);if(f.data==="$!"){if(d=f.nextSibling&&f.nextSibling.dataset,d)var B=d.dgst;return d=B,g=Error(i(419)),d=Dc(g,d,void 0),ga(n,r,E,d)}if(B=(E&n.childLanes)!==0,fi||B){if(d=Ft,d!==null){switch(E&-E){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&(d.suspendedLanes|E))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,gn(n,f),Xi(d,n,f,-1))}return Jc(),d=Dc(Error(i(421))),ga(n,r,E,d)}return f.data==="$?"?(r.flags|=128,r.child=n.child,r=yw.bind(null,n),f._reactRetry=r,null):(n=g.treeContext,ki=jn(f.nextSibling),bi=r,pt=!0,Ki=null,n!==null&&(Mi[Li++]=pn,Mi[Li++]=mn,Mi[Li++]=rr,pn=n.id,mn=n.overflow,rr=r),r=Ic(r,d.children),r.flags|=4096,r)}function Rp(n,r,l){n.lanes|=r;var d=n.alternate;d!==null&&(d.lanes|=r),fc(n.return,r,l)}function Bc(n,r,l,d,f){var g=n.memoizedState;g===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:d,tail:l,tailMode:f}:(g.isBackwards=r,g.rendering=null,g.renderingStartTime=0,g.last=d,g.tail=l,g.tailMode=f)}function Pp(n,r,l){var d=r.pendingProps,f=d.revealOrder,g=d.tail;if(oi(n,r,d.children,l),d=vt.current,(d&2)!==0)d=d&1|2,r.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&Rp(n,l,r);else if(n.tag===19)Rp(n,l,r);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break e;for(;n.sibling===null;){if(n.return===null||n.return===r)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}d&=1}if(ut(vt,d),(r.mode&1)===0)r.memoizedState=null;else switch(f){case"forwards":for(l=r.child,f=null;l!==null;)n=l.alternate,n!==null&&ca(n)===null&&(f=l),l=l.sibling;l=f,l===null?(f=r.child,r.child=null):(f=l.sibling,l.sibling=null),Bc(r,!1,f,l,g);break;case"backwards":for(l=null,f=r.child,r.child=null;f!==null;){if(n=f.alternate,n!==null&&ca(n)===null){r.child=f;break}n=f.sibling,f.sibling=l,l=f,f=n}Bc(r,!0,l,null,g);break;case"together":Bc(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function va(n,r){(r.mode&1)===0&&n!==null&&(n.alternate=null,r.alternate=null,r.flags|=2)}function _n(n,r,l){if(n!==null&&(r.dependencies=n.dependencies),cr|=r.lanes,(l&r.childLanes)===0)return null;if(n!==null&&r.child!==n.child)throw Error(i(153));if(r.child!==null){for(n=r.child,l=$n(n,n.pendingProps),r.child=l,l.return=r;n.sibling!==null;)n=n.sibling,l=l.sibling=$n(n,n.pendingProps),l.return=r;l.sibling=null}return r.child}function aw(n,r,l){switch(r.tag){case 3:xp(r),$r();break;case 5:Wf(r);break;case 1:hi(r.type)&&Zo(r);break;case 4:gc(r,r.stateNode.containerInfo);break;case 10:var d=r.type._context,f=r.memoizedProps.value;ut(sa,d._currentValue),d._currentValue=f;break;case 13:if(d=r.memoizedState,d!==null)return d.dehydrated!==null?(ut(vt,vt.current&1),r.flags|=128,null):(l&r.child.childLanes)!==0?Np(n,r,l):(ut(vt,vt.current&1),n=_n(n,r,l),n!==null?n.sibling:null);ut(vt,vt.current&1);break;case 19:if(d=(l&r.childLanes)!==0,(n.flags&128)!==0){if(d)return Pp(n,r,l);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),ut(vt,vt.current),d)break;return null;case 22:case 23:return r.lanes=0,bp(n,r,l)}return _n(n,r,l)}var Dp,Oc,jp,Mp;Dp=function(n,r){for(var l=r.child;l!==null;){if(l.tag===5||l.tag===6)n.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===r)break;for(;l.sibling===null;){if(l.return===null||l.return===r)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},Oc=function(){},jp=function(n,r,l,d){var f=n.memoizedProps;if(f!==d){n=r.stateNode,ar(Zi.current);var g=null;switch(l){case"input":f=rt(n,f),d=rt(n,d),g=[];break;case"select":f=W({},f,{value:void 0}),d=W({},d,{value:void 0}),g=[];break;case"textarea":f=be(n,f),d=be(n,d),g=[];break;default:typeof f.onClick!="function"&&typeof d.onClick=="function"&&(n.onclick=Go)}xe(l,d);var E;l=null;for(ce in f)if(!d.hasOwnProperty(ce)&&f.hasOwnProperty(ce)&&f[ce]!=null)if(ce==="style"){var B=f[ce];for(E in B)B.hasOwnProperty(E)&&(l||(l={}),l[E]="")}else ce!=="dangerouslySetInnerHTML"&&ce!=="children"&&ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&ce!=="autoFocus"&&(o.hasOwnProperty(ce)?g||(g=[]):(g=g||[]).push(ce,null));for(ce in d){var V=d[ce];if(B=f!=null?f[ce]:void 0,d.hasOwnProperty(ce)&&V!==B&&(V!=null||B!=null))if(ce==="style")if(B){for(E in B)!B.hasOwnProperty(E)||V&&V.hasOwnProperty(E)||(l||(l={}),l[E]="");for(E in V)V.hasOwnProperty(E)&&B[E]!==V[E]&&(l||(l={}),l[E]=V[E])}else l||(g||(g=[]),g.push(ce,l)),l=V;else ce==="dangerouslySetInnerHTML"?(V=V?V.__html:void 0,B=B?B.__html:void 0,V!=null&&B!==V&&(g=g||[]).push(ce,V)):ce==="children"?typeof V!="string"&&typeof V!="number"||(g=g||[]).push(ce,""+V):ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&(o.hasOwnProperty(ce)?(V!=null&&ce==="onScroll"&&dt("scroll",n),g||B===V||(g=[])):(g=g||[]).push(ce,V))}l&&(g=g||[]).push("style",l);var ce=g;(r.updateQueue=ce)&&(r.flags|=4)}},Mp=function(n,r,l,d){l!==d&&(r.flags|=4)};function Vs(n,r){if(!pt)switch(n.tailMode){case"hidden":r=n.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?n.tail=null:l.sibling=null;break;case"collapsed":l=n.tail;for(var d=null;l!==null;)l.alternate!==null&&(d=l),l=l.sibling;d===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:d.sibling=null}}function ii(n){var r=n.alternate!==null&&n.alternate.child===n.child,l=0,d=0;if(r)for(var f=n.child;f!==null;)l|=f.lanes|f.childLanes,d|=f.subtreeFlags&14680064,d|=f.flags&14680064,f.return=n,f=f.sibling;else for(f=n.child;f!==null;)l|=f.lanes|f.childLanes,d|=f.subtreeFlags,d|=f.flags,f.return=n,f=f.sibling;return n.subtreeFlags|=d,n.childLanes=l,r}function lw(n,r,l){var d=r.pendingProps;switch(oc(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ii(r),null;case 1:return hi(r.type)&&Jo(),ii(r),null;case 3:return d=r.stateNode,qr(),ht(di),ht(ei),yc(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(n===null||n.child===null)&&(na(r)?r.flags|=4:n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Ki!==null&&(Xc(Ki),Ki=null))),Oc(n,r),ii(r),null;case 5:vc(r);var f=ar($s.current);if(l=r.type,n!==null&&r.stateNode!=null)jp(n,r,l,d,f),n.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!d){if(r.stateNode===null)throw Error(i(166));return ii(r),null}if(n=ar(Zi.current),na(r)){d=r.stateNode,l=r.type;var g=r.memoizedProps;switch(d[Ji]=r,d[Bs]=g,n=(r.mode&1)!==0,l){case"dialog":dt("cancel",d),dt("close",d);break;case"iframe":case"object":case"embed":dt("load",d);break;case"video":case"audio":for(f=0;f<Ts.length;f++)dt(Ts[f],d);break;case"source":dt("error",d);break;case"img":case"image":case"link":dt("error",d),dt("load",d);break;case"details":dt("toggle",d);break;case"input":wt(d,g),dt("invalid",d);break;case"select":d._wrapperState={wasMultiple:!!g.multiple},dt("invalid",d);break;case"textarea":Fe(d,g),dt("invalid",d)}xe(l,g),f=null;for(var E in g)if(g.hasOwnProperty(E)){var B=g[E];E==="children"?typeof B=="string"?d.textContent!==B&&(g.suppressHydrationWarning!==!0&&Xo(d.textContent,B,n),f=["children",B]):typeof B=="number"&&d.textContent!==""+B&&(g.suppressHydrationWarning!==!0&&Xo(d.textContent,B,n),f=["children",""+B]):o.hasOwnProperty(E)&&B!=null&&E==="onScroll"&&dt("scroll",d)}switch(l){case"input":tt(d),gt(d,g,!0);break;case"textarea":tt(d),pe(d);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(d.onclick=Go)}d=f,r.updateQueue=d,d!==null&&(r.flags|=4)}else{E=f.nodeType===9?f:f.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=Be(l)),n==="http://www.w3.org/1999/xhtml"?l==="script"?(n=E.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof d.is=="string"?n=E.createElement(l,{is:d.is}):(n=E.createElement(l),l==="select"&&(E=n,d.multiple?E.multiple=!0:d.size&&(E.size=d.size))):n=E.createElementNS(n,l),n[Ji]=r,n[Bs]=d,Dp(n,r,!1,!1),r.stateNode=n;e:{switch(E=He(l,d),l){case"dialog":dt("cancel",n),dt("close",n),f=d;break;case"iframe":case"object":case"embed":dt("load",n),f=d;break;case"video":case"audio":for(f=0;f<Ts.length;f++)dt(Ts[f],n);f=d;break;case"source":dt("error",n),f=d;break;case"img":case"image":case"link":dt("error",n),dt("load",n),f=d;break;case"details":dt("toggle",n),f=d;break;case"input":wt(n,d),f=rt(n,d),dt("invalid",n);break;case"option":f=d;break;case"select":n._wrapperState={wasMultiple:!!d.multiple},f=W({},d,{value:void 0}),dt("invalid",n);break;case"textarea":Fe(n,d),f=be(n,d),dt("invalid",n);break;default:f=d}xe(l,f),B=f;for(g in B)if(B.hasOwnProperty(g)){var V=B[g];g==="style"?Ae(n,V):g==="dangerouslySetInnerHTML"?(V=V?V.__html:void 0,V!=null&&ne(n,V)):g==="children"?typeof V=="string"?(l!=="textarea"||V!=="")&&z(n,V):typeof V=="number"&&z(n,""+V):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(o.hasOwnProperty(g)?V!=null&&g==="onScroll"&&dt("scroll",n):V!=null&&L(n,g,V,E))}switch(l){case"input":tt(n),gt(n,d,!1);break;case"textarea":tt(n),pe(n);break;case"option":d.value!=null&&n.setAttribute("value",""+de(d.value));break;case"select":n.multiple=!!d.multiple,g=d.value,g!=null?le(n,!!d.multiple,g,!1):d.defaultValue!=null&&le(n,!!d.multiple,d.defaultValue,!0);break;default:typeof f.onClick=="function"&&(n.onclick=Go)}switch(l){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}}d&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return ii(r),null;case 6:if(n&&r.stateNode!=null)Mp(n,r,n.memoizedProps,d);else{if(typeof d!="string"&&r.stateNode===null)throw Error(i(166));if(l=ar($s.current),ar(Zi.current),na(r)){if(d=r.stateNode,l=r.memoizedProps,d[Ji]=r,(g=d.nodeValue!==l)&&(n=bi,n!==null))switch(n.tag){case 3:Xo(d.nodeValue,l,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&Xo(d.nodeValue,l,(n.mode&1)!==0)}g&&(r.flags|=4)}else d=(l.nodeType===9?l:l.ownerDocument).createTextNode(d),d[Ji]=r,r.stateNode=d}return ii(r),null;case 13:if(ht(vt),d=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(pt&&ki!==null&&(r.mode&1)!==0&&(r.flags&128)===0)Af(),$r(),r.flags|=98560,g=!1;else if(g=na(r),d!==null&&d.dehydrated!==null){if(n===null){if(!g)throw Error(i(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(i(317));g[Ji]=r}else $r(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ii(r),g=!1}else Ki!==null&&(Xc(Ki),Ki=null),g=!0;if(!g)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=l,r):(d=d!==null,d!==(n!==null&&n.memoizedState!==null)&&d&&(r.child.flags|=8192,(r.mode&1)!==0&&(n===null||(vt.current&1)!==0?At===0&&(At=3):Jc())),r.updateQueue!==null&&(r.flags|=4),ii(r),null);case 4:return qr(),Oc(n,r),n===null&&As(r.stateNode.containerInfo),ii(r),null;case 10:return hc(r.type._context),ii(r),null;case 17:return hi(r.type)&&Jo(),ii(r),null;case 19:if(ht(vt),g=r.memoizedState,g===null)return ii(r),null;if(d=(r.flags&128)!==0,E=g.rendering,E===null)if(d)Vs(g,!1);else{if(At!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(E=ca(n),E!==null){for(r.flags|=128,Vs(g,!1),d=E.updateQueue,d!==null&&(r.updateQueue=d,r.flags|=4),r.subtreeFlags=0,d=l,l=r.child;l!==null;)g=l,n=d,g.flags&=14680066,E=g.alternate,E===null?(g.childLanes=0,g.lanes=n,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=E.childLanes,g.lanes=E.lanes,g.child=E.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=E.memoizedProps,g.memoizedState=E.memoizedState,g.updateQueue=E.updateQueue,g.type=E.type,n=E.dependencies,g.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),l=l.sibling;return ut(vt,vt.current&1|2),r.child}n=n.sibling}g.tail!==null&&Nt()>Gr&&(r.flags|=128,d=!0,Vs(g,!1),r.lanes=4194304)}else{if(!d)if(n=ca(E),n!==null){if(r.flags|=128,d=!0,l=n.updateQueue,l!==null&&(r.updateQueue=l,r.flags|=4),Vs(g,!0),g.tail===null&&g.tailMode==="hidden"&&!E.alternate&&!pt)return ii(r),null}else 2*Nt()-g.renderingStartTime>Gr&&l!==1073741824&&(r.flags|=128,d=!0,Vs(g,!1),r.lanes=4194304);g.isBackwards?(E.sibling=r.child,r.child=E):(l=g.last,l!==null?l.sibling=E:r.child=E,g.last=E)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=Nt(),r.sibling=null,l=vt.current,ut(vt,d?l&1|2:l&1),r):(ii(r),null);case 22:case 23:return Qc(),d=r.memoizedState!==null,n!==null&&n.memoizedState!==null!==d&&(r.flags|=8192),d&&(r.mode&1)!==0?(Ci&1073741824)!==0&&(ii(r),r.subtreeFlags&6&&(r.flags|=8192)):ii(r),null;case 24:return null;case 25:return null}throw Error(i(156,r.tag))}function cw(n,r){switch(oc(r),r.tag){case 1:return hi(r.type)&&Jo(),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return qr(),ht(di),ht(ei),yc(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 5:return vc(r),null;case 13:if(ht(vt),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(i(340));$r()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return ht(vt),null;case 4:return qr(),null;case 10:return hc(r.type._context),null;case 22:case 23:return Qc(),null;case 24:return null;default:return null}}var _a=!1,ni=!1,uw=typeof WeakSet=="function"?WeakSet:Set,je=null;function Yr(n,r){var l=n.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(d){kt(n,r,d)}else l.current=null}function zc(n,r,l){try{l()}catch(d){kt(n,r,d)}}var Lp=!1;function dw(n,r){if(Ql=Oo,n=df(),Wl(n)){if("selectionStart"in n)var l={start:n.selectionStart,end:n.selectionEnd};else e:{l=(l=n.ownerDocument)&&l.defaultView||window;var d=l.getSelection&&l.getSelection();if(d&&d.rangeCount!==0){l=d.anchorNode;var f=d.anchorOffset,g=d.focusNode;d=d.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var E=0,B=-1,V=-1,ce=0,_e=0,ye=n,ve=null;t:for(;;){for(var Pe;ye!==l||f!==0&&ye.nodeType!==3||(B=E+f),ye!==g||d!==0&&ye.nodeType!==3||(V=E+d),ye.nodeType===3&&(E+=ye.nodeValue.length),(Pe=ye.firstChild)!==null;)ve=ye,ye=Pe;for(;;){if(ye===n)break t;if(ve===l&&++ce===f&&(B=E),ve===g&&++_e===d&&(V=E),(Pe=ye.nextSibling)!==null)break;ye=ve,ve=ye.parentNode}ye=Pe}l=B===-1||V===-1?null:{start:B,end:V}}else l=null}l=l||{start:0,end:0}}else l=null;for(Jl={focusedElem:n,selectionRange:l},Oo=!1,je=r;je!==null;)if(r=je,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,je=n;else for(;je!==null;){r=je;try{var Me=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Me!==null){var Le=Me.memoizedProps,Rt=Me.memoizedState,ie=r.stateNode,X=ie.getSnapshotBeforeUpdate(r.elementType===r.type?Le:qi(r.type,Le),Rt);ie.__reactInternalSnapshotBeforeUpdate=X}break;case 3:var oe=r.stateNode.containerInfo;oe.nodeType===1?oe.textContent="":oe.nodeType===9&&oe.documentElement&&oe.removeChild(oe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(we){kt(r,r.return,we)}if(n=r.sibling,n!==null){n.return=r.return,je=n;break}je=r.return}return Me=Lp,Lp=!1,Me}function Ys(n,r,l){var d=r.updateQueue;if(d=d!==null?d.lastEffect:null,d!==null){var f=d=d.next;do{if((f.tag&n)===n){var g=f.destroy;f.destroy=void 0,g!==void 0&&zc(r,l,g)}f=f.next}while(f!==d)}}function ya(n,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&n)===n){var d=l.create;l.destroy=d()}l=l.next}while(l!==r)}}function Fc(n){var r=n.ref;if(r!==null){var l=n.stateNode;switch(n.tag){case 5:n=l;break;default:n=l}typeof r=="function"?r(n):r.current=n}}function Tp(n){var r=n.alternate;r!==null&&(n.alternate=null,Tp(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&(delete r[Ji],delete r[Bs],delete r[ic],delete r[VS],delete r[YS])),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 Ap(n){return n.tag===5||n.tag===3||n.tag===4}function Ip(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Ap(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function Hc(n,r,l){var d=n.tag;if(d===5||d===6)n=n.stateNode,r?l.nodeType===8?l.parentNode.insertBefore(n,r):l.insertBefore(n,r):(l.nodeType===8?(r=l.parentNode,r.insertBefore(n,l)):(r=l,r.appendChild(n)),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=Go));else if(d!==4&&(n=n.child,n!==null))for(Hc(n,r,l),n=n.sibling;n!==null;)Hc(n,r,l),n=n.sibling}function $c(n,r,l){var d=n.tag;if(d===5||d===6)n=n.stateNode,r?l.insertBefore(n,r):l.appendChild(n);else if(d!==4&&(n=n.child,n!==null))for($c(n,r,l),n=n.sibling;n!==null;)$c(n,r,l),n=n.sibling}var Xt=null,Vi=!1;function Bn(n,r,l){for(l=l.child;l!==null;)Bp(n,r,l),l=l.sibling}function Bp(n,r,l){if(Qi&&typeof Qi.onCommitFiberUnmount=="function")try{Qi.onCommitFiberUnmount(Mo,l)}catch{}switch(l.tag){case 5:ni||Yr(l,r);case 6:var d=Xt,f=Vi;Xt=null,Bn(n,r,l),Xt=d,Vi=f,Xt!==null&&(Vi?(n=Xt,l=l.stateNode,n.nodeType===8?n.parentNode.removeChild(l):n.removeChild(l)):Xt.removeChild(l.stateNode));break;case 18:Xt!==null&&(Vi?(n=Xt,l=l.stateNode,n.nodeType===8?tc(n.parentNode,l):n.nodeType===1&&tc(n,l),Es(n)):tc(Xt,l.stateNode));break;case 4:d=Xt,f=Vi,Xt=l.stateNode.containerInfo,Vi=!0,Bn(n,r,l),Xt=d,Vi=f;break;case 0:case 11:case 14:case 15:if(!ni&&(d=l.updateQueue,d!==null&&(d=d.lastEffect,d!==null))){f=d=d.next;do{var g=f,E=g.destroy;g=g.tag,E!==void 0&&((g&2)!==0||(g&4)!==0)&&zc(l,r,E),f=f.next}while(f!==d)}Bn(n,r,l);break;case 1:if(!ni&&(Yr(l,r),d=l.stateNode,typeof d.componentWillUnmount=="function"))try{d.props=l.memoizedProps,d.state=l.memoizedState,d.componentWillUnmount()}catch(B){kt(l,r,B)}Bn(n,r,l);break;case 21:Bn(n,r,l);break;case 22:l.mode&1?(ni=(d=ni)||l.memoizedState!==null,Bn(n,r,l),ni=d):Bn(n,r,l);break;default:Bn(n,r,l)}}function Op(n){var r=n.updateQueue;if(r!==null){n.updateQueue=null;var l=n.stateNode;l===null&&(l=n.stateNode=new uw),r.forEach(function(d){var f=Sw.bind(null,n,d);l.has(d)||(l.add(d),d.then(f,f))})}}function Yi(n,r){var l=r.deletions;if(l!==null)for(var d=0;d<l.length;d++){var f=l[d];try{var g=n,E=r,B=E;e:for(;B!==null;){switch(B.tag){case 5:Xt=B.stateNode,Vi=!1;break e;case 3:Xt=B.stateNode.containerInfo,Vi=!0;break e;case 4:Xt=B.stateNode.containerInfo,Vi=!0;break e}B=B.return}if(Xt===null)throw Error(i(160));Bp(g,E,f),Xt=null,Vi=!1;var V=f.alternate;V!==null&&(V.return=null),f.return=null}catch(ce){kt(f,r,ce)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)zp(r,n),r=r.sibling}function zp(n,r){var l=n.alternate,d=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Yi(r,n),tn(n),d&4){try{Ys(3,n,n.return),ya(3,n)}catch(Le){kt(n,n.return,Le)}try{Ys(5,n,n.return)}catch(Le){kt(n,n.return,Le)}}break;case 1:Yi(r,n),tn(n),d&512&&l!==null&&Yr(l,l.return);break;case 5:if(Yi(r,n),tn(n),d&512&&l!==null&&Yr(l,l.return),n.flags&32){var f=n.stateNode;try{z(f,"")}catch(Le){kt(n,n.return,Le)}}if(d&4&&(f=n.stateNode,f!=null)){var g=n.memoizedProps,E=l!==null?l.memoizedProps:g,B=n.type,V=n.updateQueue;if(n.updateQueue=null,V!==null)try{B==="input"&&g.type==="radio"&&g.name!=null&&Dt(f,g),He(B,E);var ce=He(B,g);for(E=0;E<V.length;E+=2){var _e=V[E],ye=V[E+1];_e==="style"?Ae(f,ye):_e==="dangerouslySetInnerHTML"?ne(f,ye):_e==="children"?z(f,ye):L(f,_e,ye,ce)}switch(B){case"input":st(f,g);break;case"textarea":$e(f,g);break;case"select":var ve=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!g.multiple;var Pe=g.value;Pe!=null?le(f,!!g.multiple,Pe,!1):ve!==!!g.multiple&&(g.defaultValue!=null?le(f,!!g.multiple,g.defaultValue,!0):le(f,!!g.multiple,g.multiple?[]:"",!1))}f[Bs]=g}catch(Le){kt(n,n.return,Le)}}break;case 6:if(Yi(r,n),tn(n),d&4){if(n.stateNode===null)throw Error(i(162));f=n.stateNode,g=n.memoizedProps;try{f.nodeValue=g}catch(Le){kt(n,n.return,Le)}}break;case 3:if(Yi(r,n),tn(n),d&4&&l!==null&&l.memoizedState.isDehydrated)try{Es(r.containerInfo)}catch(Le){kt(n,n.return,Le)}break;case 4:Yi(r,n),tn(n);break;case 13:Yi(r,n),tn(n),f=n.child,f.flags&8192&&(g=f.memoizedState!==null,f.stateNode.isHidden=g,!g||f.alternate!==null&&f.alternate.memoizedState!==null||(Kc=Nt())),d&4&&Op(n);break;case 22:if(_e=l!==null&&l.memoizedState!==null,n.mode&1?(ni=(ce=ni)||_e,Yi(r,n),ni=ce):Yi(r,n),tn(n),d&8192){if(ce=n.memoizedState!==null,(n.stateNode.isHidden=ce)&&!_e&&(n.mode&1)!==0)for(je=n,_e=n.child;_e!==null;){for(ye=je=_e;je!==null;){switch(ve=je,Pe=ve.child,ve.tag){case 0:case 11:case 14:case 15:Ys(4,ve,ve.return);break;case 1:Yr(ve,ve.return);var Me=ve.stateNode;if(typeof Me.componentWillUnmount=="function"){d=ve,l=ve.return;try{r=d,Me.props=r.memoizedProps,Me.state=r.memoizedState,Me.componentWillUnmount()}catch(Le){kt(d,l,Le)}}break;case 5:Yr(ve,ve.return);break;case 22:if(ve.memoizedState!==null){$p(ye);continue}}Pe!==null?(Pe.return=ve,je=Pe):$p(ye)}_e=_e.sibling}e:for(_e=null,ye=n;;){if(ye.tag===5){if(_e===null){_e=ye;try{f=ye.stateNode,ce?(g=f.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(B=ye.stateNode,V=ye.memoizedProps.style,E=V!=null&&V.hasOwnProperty("display")?V.display:null,B.style.display=me("display",E))}catch(Le){kt(n,n.return,Le)}}}else if(ye.tag===6){if(_e===null)try{ye.stateNode.nodeValue=ce?"":ye.memoizedProps}catch(Le){kt(n,n.return,Le)}}else if((ye.tag!==22&&ye.tag!==23||ye.memoizedState===null||ye===n)&&ye.child!==null){ye.child.return=ye,ye=ye.child;continue}if(ye===n)break e;for(;ye.sibling===null;){if(ye.return===null||ye.return===n)break e;_e===ye&&(_e=null),ye=ye.return}_e===ye&&(_e=null),ye.sibling.return=ye.return,ye=ye.sibling}}break;case 19:Yi(r,n),tn(n),d&4&&Op(n);break;case 21:break;default:Yi(r,n),tn(n)}}function tn(n){var r=n.flags;if(r&2){try{e:{for(var l=n.return;l!==null;){if(Ap(l)){var d=l;break e}l=l.return}throw Error(i(160))}switch(d.tag){case 5:var f=d.stateNode;d.flags&32&&(z(f,""),d.flags&=-33);var g=Ip(n);$c(n,g,f);break;case 3:case 4:var E=d.stateNode.containerInfo,B=Ip(n);Hc(n,B,E);break;default:throw Error(i(161))}}catch(V){kt(n,n.return,V)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function hw(n,r,l){je=n,Fp(n)}function Fp(n,r,l){for(var d=(n.mode&1)!==0;je!==null;){var f=je,g=f.child;if(f.tag===22&&d){var E=f.memoizedState!==null||_a;if(!E){var B=f.alternate,V=B!==null&&B.memoizedState!==null||ni;B=_a;var ce=ni;if(_a=E,(ni=V)&&!ce)for(je=f;je!==null;)E=je,V=E.child,E.tag===22&&E.memoizedState!==null?Wp(f):V!==null?(V.return=E,je=V):Wp(f);for(;g!==null;)je=g,Fp(g),g=g.sibling;je=f,_a=B,ni=ce}Hp(n)}else(f.subtreeFlags&8772)!==0&&g!==null?(g.return=f,je=g):Hp(n)}}function Hp(n){for(;je!==null;){var r=je;if((r.flags&8772)!==0){var l=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:ni||ya(5,r);break;case 1:var d=r.stateNode;if(r.flags&4&&!ni)if(l===null)d.componentDidMount();else{var f=r.elementType===r.type?l.memoizedProps:qi(r.type,l.memoizedProps);d.componentDidUpdate(f,l.memoizedState,d.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&$f(r,g,d);break;case 3:var E=r.updateQueue;if(E!==null){if(l=null,r.child!==null)switch(r.child.tag){case 5:l=r.child.stateNode;break;case 1:l=r.child.stateNode}$f(r,E,l)}break;case 5:var B=r.stateNode;if(l===null&&r.flags&4){l=B;var V=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":V.autoFocus&&l.focus();break;case"img":V.src&&(l.src=V.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var ce=r.alternate;if(ce!==null){var _e=ce.memoizedState;if(_e!==null){var ye=_e.dehydrated;ye!==null&&Es(ye)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(i(163))}ni||r.flags&512&&Fc(r)}catch(ve){kt(r,r.return,ve)}}if(r===n){je=null;break}if(l=r.sibling,l!==null){l.return=r.return,je=l;break}je=r.return}}function $p(n){for(;je!==null;){var r=je;if(r===n){je=null;break}var l=r.sibling;if(l!==null){l.return=r.return,je=l;break}je=r.return}}function Wp(n){for(;je!==null;){var r=je;try{switch(r.tag){case 0:case 11:case 15:var l=r.return;try{ya(4,r)}catch(V){kt(r,l,V)}break;case 1:var d=r.stateNode;if(typeof d.componentDidMount=="function"){var f=r.return;try{d.componentDidMount()}catch(V){kt(r,f,V)}}var g=r.return;try{Fc(r)}catch(V){kt(r,g,V)}break;case 5:var E=r.return;try{Fc(r)}catch(V){kt(r,E,V)}}}catch(V){kt(r,r.return,V)}if(r===n){je=null;break}var B=r.sibling;if(B!==null){B.return=r.return,je=B;break}je=r.return}}var fw=Math.ceil,Sa=M.ReactCurrentDispatcher,Wc=M.ReactCurrentOwner,Ii=M.ReactCurrentBatchConfig,it=0,Ft=null,jt=null,Gt=0,Ci=0,Xr=Mn(0),At=0,Xs=null,cr=0,wa=0,Uc=0,Gs=null,pi=null,Kc=0,Gr=1/0,yn=null,ba=!1,qc=null,On=null,ka=!1,zn=null,Ca=0,Qs=0,Vc=null,xa=-1,Ea=0;function ai(){return(it&6)!==0?Nt():xa!==-1?xa:xa=Nt()}function Fn(n){return(n.mode&1)===0?1:(it&2)!==0&&Gt!==0?Gt&-Gt:GS.transition!==null?(Ea===0&&(Ea=Ah()),Ea):(n=ot,n!==0||(n=window.event,n=n===void 0?16:Uh(n.type)),n)}function Xi(n,r,l,d){if(50<Qs)throw Qs=0,Vc=null,Error(i(185));ws(n,l,d),((it&2)===0||n!==Ft)&&(n===Ft&&((it&2)===0&&(wa|=l),At===4&&Hn(n,Gt)),mi(n,d),l===1&&it===0&&(r.mode&1)===0&&(Gr=Nt()+500,ea&&Tn()))}function mi(n,r){var l=n.callbackNode;Gy(n,r);var d=Ao(n,n===Ft?Gt:0);if(d===0)l!==null&&Mh(l),n.callbackNode=null,n.callbackPriority=0;else if(r=d&-d,n.callbackPriority!==r){if(l!=null&&Mh(l),r===1)n.tag===0?XS(Kp.bind(null,n)):Df(Kp.bind(null,n)),KS(function(){(it&6)===0&&Tn()}),l=null;else{switch(Ih(d)){case 1:l=El;break;case 4:l=Lh;break;case 16:l=jo;break;case 536870912:l=Th;break;default:l=jo}l=Zp(l,Up.bind(null,n))}n.callbackPriority=r,n.callbackNode=l}}function Up(n,r){if(xa=-1,Ea=0,(it&6)!==0)throw Error(i(327));var l=n.callbackNode;if(Qr()&&n.callbackNode!==l)return null;var d=Ao(n,n===Ft?Gt:0);if(d===0)return null;if((d&30)!==0||(d&n.expiredLanes)!==0||r)r=Na(n,d);else{r=d;var f=it;it|=2;var g=Vp();(Ft!==n||Gt!==r)&&(yn=null,Gr=Nt()+500,dr(n,r));do try{gw();break}catch(B){qp(n,B)}while(!0);dc(),Sa.current=g,it=f,jt!==null?r=0:(Ft=null,Gt=0,r=At)}if(r!==0){if(r===2&&(f=Nl(n),f!==0&&(d=f,r=Yc(n,f))),r===1)throw l=Xs,dr(n,0),Hn(n,d),mi(n,Nt()),l;if(r===6)Hn(n,d);else{if(f=n.current.alternate,(d&30)===0&&!pw(f)&&(r=Na(n,d),r===2&&(g=Nl(n),g!==0&&(d=g,r=Yc(n,g))),r===1))throw l=Xs,dr(n,0),Hn(n,d),mi(n,Nt()),l;switch(n.finishedWork=f,n.finishedLanes=d,r){case 0:case 1:throw Error(i(345));case 2:hr(n,pi,yn);break;case 3:if(Hn(n,d),(d&130023424)===d&&(r=Kc+500-Nt(),10<r)){if(Ao(n,0)!==0)break;if(f=n.suspendedLanes,(f&d)!==d){ai(),n.pingedLanes|=n.suspendedLanes&f;break}n.timeoutHandle=ec(hr.bind(null,n,pi,yn),r);break}hr(n,pi,yn);break;case 4:if(Hn(n,d),(d&4194240)===d)break;for(r=n.eventTimes,f=-1;0<d;){var E=31-Wi(d);g=1<<E,E=r[E],E>f&&(f=E),d&=~g}if(d=f,d=Nt()-d,d=(120>d?120:480>d?480:1080>d?1080:1920>d?1920:3e3>d?3e3:4320>d?4320:1960*fw(d/1960))-d,10<d){n.timeoutHandle=ec(hr.bind(null,n,pi,yn),d);break}hr(n,pi,yn);break;case 5:hr(n,pi,yn);break;default:throw Error(i(329))}}}return mi(n,Nt()),n.callbackNode===l?Up.bind(null,n):null}function Yc(n,r){var l=Gs;return n.current.memoizedState.isDehydrated&&(dr(n,r).flags|=256),n=Na(n,r),n!==2&&(r=pi,pi=l,r!==null&&Xc(r)),n}function Xc(n){pi===null?pi=n:pi.push.apply(pi,n)}function pw(n){for(var r=n;;){if(r.flags&16384){var l=r.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var d=0;d<l.length;d++){var f=l[d],g=f.getSnapshot;f=f.value;try{if(!Ui(g(),f))return!1}catch{return!1}}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Hn(n,r){for(r&=~Uc,r&=~wa,n.suspendedLanes|=r,n.pingedLanes&=~r,n=n.expirationTimes;0<r;){var l=31-Wi(r),d=1<<l;n[l]=-1,r&=~d}}function Kp(n){if((it&6)!==0)throw Error(i(327));Qr();var r=Ao(n,0);if((r&1)===0)return mi(n,Nt()),null;var l=Na(n,r);if(n.tag!==0&&l===2){var d=Nl(n);d!==0&&(r=d,l=Yc(n,d))}if(l===1)throw l=Xs,dr(n,0),Hn(n,r),mi(n,Nt()),l;if(l===6)throw Error(i(345));return n.finishedWork=n.current.alternate,n.finishedLanes=r,hr(n,pi,yn),mi(n,Nt()),null}function Gc(n,r){var l=it;it|=1;try{return n(r)}finally{it=l,it===0&&(Gr=Nt()+500,ea&&Tn())}}function ur(n){zn!==null&&zn.tag===0&&(it&6)===0&&Qr();var r=it;it|=1;var l=Ii.transition,d=ot;try{if(Ii.transition=null,ot=1,n)return n()}finally{ot=d,Ii.transition=l,it=r,(it&6)===0&&Tn()}}function Qc(){Ci=Xr.current,ht(Xr)}function dr(n,r){n.finishedWork=null,n.finishedLanes=0;var l=n.timeoutHandle;if(l!==-1&&(n.timeoutHandle=-1,US(l)),jt!==null)for(l=jt.return;l!==null;){var d=l;switch(oc(d),d.tag){case 1:d=d.type.childContextTypes,d!=null&&Jo();break;case 3:qr(),ht(di),ht(ei),yc();break;case 5:vc(d);break;case 4:qr();break;case 13:ht(vt);break;case 19:ht(vt);break;case 10:hc(d.type._context);break;case 22:case 23:Qc()}l=l.return}if(Ft=n,jt=n=$n(n.current,null),Gt=Ci=r,At=0,Xs=null,Uc=wa=cr=0,pi=Gs=null,or!==null){for(r=0;r<or.length;r++)if(l=or[r],d=l.interleaved,d!==null){l.interleaved=null;var f=d.next,g=l.pending;if(g!==null){var E=g.next;g.next=f,d.next=E}l.pending=d}or=null}return n}function qp(n,r){do{var l=jt;try{if(dc(),ua.current=pa,da){for(var d=_t.memoizedState;d!==null;){var f=d.queue;f!==null&&(f.pending=null),d=d.next}da=!1}if(lr=0,zt=Tt=_t=null,Ws=!1,Us=0,Wc.current=null,l===null||l.return===null){At=1,Xs=r,jt=null;break}e:{var g=n,E=l.return,B=l,V=r;if(r=Gt,B.flags|=32768,V!==null&&typeof V=="object"&&typeof V.then=="function"){var ce=V,_e=B,ye=_e.tag;if((_e.mode&1)===0&&(ye===0||ye===11||ye===15)){var ve=_e.alternate;ve?(_e.updateQueue=ve.updateQueue,_e.memoizedState=ve.memoizedState,_e.lanes=ve.lanes):(_e.updateQueue=null,_e.memoizedState=null)}var Pe=vp(E);if(Pe!==null){Pe.flags&=-257,_p(Pe,E,B,g,r),Pe.mode&1&&gp(g,ce,r),r=Pe,V=ce;var Me=r.updateQueue;if(Me===null){var Le=new Set;Le.add(V),r.updateQueue=Le}else Me.add(V);break e}else{if((r&1)===0){gp(g,ce,r),Jc();break e}V=Error(i(426))}}else if(pt&&B.mode&1){var Rt=vp(E);if(Rt!==null){(Rt.flags&65536)===0&&(Rt.flags|=256),_p(Rt,E,B,g,r),cc(Vr(V,B));break e}}g=V=Vr(V,B),At!==4&&(At=2),Gs===null?Gs=[g]:Gs.push(g),g=E;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var ie=pp(g,V,r);Hf(g,ie);break e;case 1:B=V;var X=g.type,oe=g.stateNode;if((g.flags&128)===0&&(typeof X.getDerivedStateFromError=="function"||oe!==null&&typeof oe.componentDidCatch=="function"&&(On===null||!On.has(oe)))){g.flags|=65536,r&=-r,g.lanes|=r;var we=mp(g,B,r);Hf(g,we);break e}}g=g.return}while(g!==null)}Xp(l)}catch(Ie){r=Ie,jt===l&&l!==null&&(jt=l=l.return);continue}break}while(!0)}function Vp(){var n=Sa.current;return Sa.current=pa,n===null?pa:n}function Jc(){(At===0||At===3||At===2)&&(At=4),Ft===null||(cr&268435455)===0&&(wa&268435455)===0||Hn(Ft,Gt)}function Na(n,r){var l=it;it|=2;var d=Vp();(Ft!==n||Gt!==r)&&(yn=null,dr(n,r));do try{mw();break}catch(f){qp(n,f)}while(!0);if(dc(),it=l,Sa.current=d,jt!==null)throw Error(i(261));return Ft=null,Gt=0,At}function mw(){for(;jt!==null;)Yp(jt)}function gw(){for(;jt!==null&&!Hy();)Yp(jt)}function Yp(n){var r=Jp(n.alternate,n,Ci);n.memoizedProps=n.pendingProps,r===null?Xp(n):jt=r,Wc.current=null}function Xp(n){var r=n;do{var l=r.alternate;if(n=r.return,(r.flags&32768)===0){if(l=lw(l,r,Ci),l!==null){jt=l;return}}else{if(l=cw(l,r),l!==null){l.flags&=32767,jt=l;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{At=6,jt=null;return}}if(r=r.sibling,r!==null){jt=r;return}jt=r=n}while(r!==null);At===0&&(At=5)}function hr(n,r,l){var d=ot,f=Ii.transition;try{Ii.transition=null,ot=1,vw(n,r,l,d)}finally{Ii.transition=f,ot=d}return null}function vw(n,r,l,d){do Qr();while(zn!==null);if((it&6)!==0)throw Error(i(327));l=n.finishedWork;var f=n.finishedLanes;if(l===null)return null;if(n.finishedWork=null,n.finishedLanes=0,l===n.current)throw Error(i(177));n.callbackNode=null,n.callbackPriority=0;var g=l.lanes|l.childLanes;if(Qy(n,g),n===Ft&&(jt=Ft=null,Gt=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||ka||(ka=!0,Zp(jo,function(){return Qr(),null})),g=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||g){g=Ii.transition,Ii.transition=null;var E=ot;ot=1;var B=it;it|=4,Wc.current=null,dw(n,l),zp(l,n),BS(Jl),Oo=!!Ql,Jl=Ql=null,n.current=l,hw(l),$y(),it=B,ot=E,Ii.transition=g}else n.current=l;if(ka&&(ka=!1,zn=n,Ca=f),g=n.pendingLanes,g===0&&(On=null),Ky(l.stateNode),mi(n,Nt()),r!==null)for(d=n.onRecoverableError,l=0;l<r.length;l++)f=r[l],d(f.value,{componentStack:f.stack,digest:f.digest});if(ba)throw ba=!1,n=qc,qc=null,n;return(Ca&1)!==0&&n.tag!==0&&Qr(),g=n.pendingLanes,(g&1)!==0?n===Vc?Qs++:(Qs=0,Vc=n):Qs=0,Tn(),null}function Qr(){if(zn!==null){var n=Ih(Ca),r=Ii.transition,l=ot;try{if(Ii.transition=null,ot=16>n?16:n,zn===null)var d=!1;else{if(n=zn,zn=null,Ca=0,(it&6)!==0)throw Error(i(331));var f=it;for(it|=4,je=n.current;je!==null;){var g=je,E=g.child;if((je.flags&16)!==0){var B=g.deletions;if(B!==null){for(var V=0;V<B.length;V++){var ce=B[V];for(je=ce;je!==null;){var _e=je;switch(_e.tag){case 0:case 11:case 15:Ys(8,_e,g)}var ye=_e.child;if(ye!==null)ye.return=_e,je=ye;else for(;je!==null;){_e=je;var ve=_e.sibling,Pe=_e.return;if(Tp(_e),_e===ce){je=null;break}if(ve!==null){ve.return=Pe,je=ve;break}je=Pe}}}var Me=g.alternate;if(Me!==null){var Le=Me.child;if(Le!==null){Me.child=null;do{var Rt=Le.sibling;Le.sibling=null,Le=Rt}while(Le!==null)}}je=g}}if((g.subtreeFlags&2064)!==0&&E!==null)E.return=g,je=E;else e:for(;je!==null;){if(g=je,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:Ys(9,g,g.return)}var ie=g.sibling;if(ie!==null){ie.return=g.return,je=ie;break e}je=g.return}}var X=n.current;for(je=X;je!==null;){E=je;var oe=E.child;if((E.subtreeFlags&2064)!==0&&oe!==null)oe.return=E,je=oe;else e:for(E=X;je!==null;){if(B=je,(B.flags&2048)!==0)try{switch(B.tag){case 0:case 11:case 15:ya(9,B)}}catch(Ie){kt(B,B.return,Ie)}if(B===E){je=null;break e}var we=B.sibling;if(we!==null){we.return=B.return,je=we;break e}je=B.return}}if(it=f,Tn(),Qi&&typeof Qi.onPostCommitFiberRoot=="function")try{Qi.onPostCommitFiberRoot(Mo,n)}catch{}d=!0}return d}finally{ot=l,Ii.transition=r}}return!1}function Gp(n,r,l){r=Vr(l,r),r=pp(n,r,1),n=In(n,r,1),r=ai(),n!==null&&(ws(n,1,r),mi(n,r))}function kt(n,r,l){if(n.tag===3)Gp(n,n,l);else for(;r!==null;){if(r.tag===3){Gp(r,n,l);break}else if(r.tag===1){var d=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(On===null||!On.has(d))){n=Vr(l,n),n=mp(r,n,1),r=In(r,n,1),n=ai(),r!==null&&(ws(r,1,n),mi(r,n));break}}r=r.return}}function _w(n,r,l){var d=n.pingCache;d!==null&&d.delete(r),r=ai(),n.pingedLanes|=n.suspendedLanes&l,Ft===n&&(Gt&l)===l&&(At===4||At===3&&(Gt&130023424)===Gt&&500>Nt()-Kc?dr(n,0):Uc|=l),mi(n,r)}function Qp(n,r){r===0&&((n.mode&1)===0?r=1:(r=To,To<<=1,(To&130023424)===0&&(To=4194304)));var l=ai();n=gn(n,r),n!==null&&(ws(n,r,l),mi(n,l))}function yw(n){var r=n.memoizedState,l=0;r!==null&&(l=r.retryLane),Qp(n,l)}function Sw(n,r){var l=0;switch(n.tag){case 13:var d=n.stateNode,f=n.memoizedState;f!==null&&(l=f.retryLane);break;case 19:d=n.stateNode;break;default:throw Error(i(314))}d!==null&&d.delete(r),Qp(n,l)}var Jp;Jp=function(n,r,l){if(n!==null)if(n.memoizedProps!==r.pendingProps||di.current)fi=!0;else{if((n.lanes&l)===0&&(r.flags&128)===0)return fi=!1,aw(n,r,l);fi=(n.flags&131072)!==0}else fi=!1,pt&&(r.flags&1048576)!==0&&jf(r,ia,r.index);switch(r.lanes=0,r.tag){case 2:var d=r.type;va(n,r),n=r.pendingProps;var f=zr(r,ei.current);Kr(r,l),f=bc(null,r,d,n,f,l);var g=kc();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,hi(d)?(g=!0,Zo(r)):g=!1,r.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,mc(r),f.updater=ma,r.stateNode=f,f._reactInternals=r,Pc(r,d,n,l),r=Lc(null,r,d,!0,g,l)):(r.tag=0,pt&&g&&sc(r),oi(null,r,f,l),r=r.child),r;case 16:d=r.elementType;e:{switch(va(n,r),n=r.pendingProps,f=d._init,d=f(d._payload),r.type=d,f=r.tag=bw(d),n=qi(d,n),f){case 0:r=Mc(null,r,d,n,l);break e;case 1:r=Cp(null,r,d,n,l);break e;case 11:r=yp(null,r,d,n,l);break e;case 14:r=Sp(null,r,d,qi(d.type,n),l);break e}throw Error(i(306,d,""))}return r;case 0:return d=r.type,f=r.pendingProps,f=r.elementType===d?f:qi(d,f),Mc(n,r,d,f,l);case 1:return d=r.type,f=r.pendingProps,f=r.elementType===d?f:qi(d,f),Cp(n,r,d,f,l);case 3:e:{if(xp(r),n===null)throw Error(i(387));d=r.pendingProps,g=r.memoizedState,f=g.element,Ff(n,r),la(r,d,null,l);var E=r.memoizedState;if(d=E.element,g.isDehydrated)if(g={element:d,isDehydrated:!1,cache:E.cache,pendingSuspenseBoundaries:E.pendingSuspenseBoundaries,transitions:E.transitions},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){f=Vr(Error(i(423)),r),r=Ep(n,r,d,l,f);break e}else if(d!==f){f=Vr(Error(i(424)),r),r=Ep(n,r,d,l,f);break e}else for(ki=jn(r.stateNode.containerInfo.firstChild),bi=r,pt=!0,Ki=null,l=Of(r,null,d,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if($r(),d===f){r=_n(n,r,l);break e}oi(n,r,d,l)}r=r.child}return r;case 5:return Wf(r),n===null&&lc(r),d=r.type,f=r.pendingProps,g=n!==null?n.memoizedProps:null,E=f.children,Zl(d,f)?E=null:g!==null&&Zl(d,g)&&(r.flags|=32),kp(n,r),oi(n,r,E,l),r.child;case 6:return n===null&&lc(r),null;case 13:return Np(n,r,l);case 4:return gc(r,r.stateNode.containerInfo),d=r.pendingProps,n===null?r.child=Wr(r,null,d,l):oi(n,r,d,l),r.child;case 11:return d=r.type,f=r.pendingProps,f=r.elementType===d?f:qi(d,f),yp(n,r,d,f,l);case 7:return oi(n,r,r.pendingProps,l),r.child;case 8:return oi(n,r,r.pendingProps.children,l),r.child;case 12:return oi(n,r,r.pendingProps.children,l),r.child;case 10:e:{if(d=r.type._context,f=r.pendingProps,g=r.memoizedProps,E=f.value,ut(sa,d._currentValue),d._currentValue=E,g!==null)if(Ui(g.value,E)){if(g.children===f.children&&!di.current){r=_n(n,r,l);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var B=g.dependencies;if(B!==null){E=g.child;for(var V=B.firstContext;V!==null;){if(V.context===d){if(g.tag===1){V=vn(-1,l&-l),V.tag=2;var ce=g.updateQueue;if(ce!==null){ce=ce.shared;var _e=ce.pending;_e===null?V.next=V:(V.next=_e.next,_e.next=V),ce.pending=V}}g.lanes|=l,V=g.alternate,V!==null&&(V.lanes|=l),fc(g.return,l,r),B.lanes|=l;break}V=V.next}}else if(g.tag===10)E=g.type===r.type?null:g.child;else if(g.tag===18){if(E=g.return,E===null)throw Error(i(341));E.lanes|=l,B=E.alternate,B!==null&&(B.lanes|=l),fc(E,l,r),E=g.sibling}else E=g.child;if(E!==null)E.return=g;else for(E=g;E!==null;){if(E===r){E=null;break}if(g=E.sibling,g!==null){g.return=E.return,E=g;break}E=E.return}g=E}oi(n,r,f.children,l),r=r.child}return r;case 9:return f=r.type,d=r.pendingProps.children,Kr(r,l),f=Ti(f),d=d(f),r.flags|=1,oi(n,r,d,l),r.child;case 14:return d=r.type,f=qi(d,r.pendingProps),f=qi(d.type,f),Sp(n,r,d,f,l);case 15:return wp(n,r,r.type,r.pendingProps,l);case 17:return d=r.type,f=r.pendingProps,f=r.elementType===d?f:qi(d,f),va(n,r),r.tag=1,hi(d)?(n=!0,Zo(r)):n=!1,Kr(r,l),hp(r,d,f),Pc(r,d,f,l),Lc(null,r,d,!0,n,l);case 19:return Pp(n,r,l);case 22:return bp(n,r,l)}throw Error(i(156,r.tag))};function Zp(n,r){return jh(n,r)}function ww(n,r,l,d){this.tag=n,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=d,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Bi(n,r,l,d){return new ww(n,r,l,d)}function Zc(n){return n=n.prototype,!(!n||!n.isReactComponent)}function bw(n){if(typeof n=="function")return Zc(n)?1:0;if(n!=null){if(n=n.$$typeof,n===T)return 11;if(n===I)return 14}return 2}function $n(n,r){var l=n.alternate;return l===null?(l=Bi(n.tag,r,n.key,n.mode),l.elementType=n.elementType,l.type=n.type,l.stateNode=n.stateNode,l.alternate=n,n.alternate=l):(l.pendingProps=r,l.type=n.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=n.flags&14680064,l.childLanes=n.childLanes,l.lanes=n.lanes,l.child=n.child,l.memoizedProps=n.memoizedProps,l.memoizedState=n.memoizedState,l.updateQueue=n.updateQueue,r=n.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=n.sibling,l.index=n.index,l.ref=n.ref,l}function Ra(n,r,l,d,f,g){var E=2;if(d=n,typeof n=="function")Zc(n)&&(E=1);else if(typeof n=="string")E=5;else e:switch(n){case O:return fr(l.children,f,g,r);case ee:E=8,f|=8;break;case q:return n=Bi(12,l,r,f|2),n.elementType=q,n.lanes=g,n;case N:return n=Bi(13,l,r,f),n.elementType=N,n.lanes=g,n;case P:return n=Bi(19,l,r,f),n.elementType=P,n.lanes=g,n;case K:return Pa(l,f,g,r);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case J:E=10;break e;case Q:E=9;break e;case T:E=11;break e;case I:E=14;break e;case $:E=16,d=null;break e}throw Error(i(130,n==null?n:typeof n,""))}return r=Bi(E,l,r,f),r.elementType=n,r.type=d,r.lanes=g,r}function fr(n,r,l,d){return n=Bi(7,n,d,r),n.lanes=l,n}function Pa(n,r,l,d){return n=Bi(22,n,d,r),n.elementType=K,n.lanes=l,n.stateNode={isHidden:!1},n}function eu(n,r,l){return n=Bi(6,n,null,r),n.lanes=l,n}function tu(n,r,l){return r=Bi(4,n.children!==null?n.children:[],n.key,r),r.lanes=l,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}function kw(n,r,l,d,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=Rl(0),this.expirationTimes=Rl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Rl(0),this.identifierPrefix=d,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function iu(n,r,l,d,f,g,E,B,V){return n=new kw(n,r,l,B,V),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Bi(3,null,null,r),n.current=g,g.stateNode=n,g.memoizedState={element:d,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},mc(g),n}function Cw(n,r,l){var d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:U,key:d==null?null:""+d,children:n,containerInfo:r,implementation:l}}function em(n){if(!n)return Ln;n=n._reactInternals;e:{if(tr(n)!==n||n.tag!==1)throw Error(i(170));var r=n;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(hi(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(i(171))}if(n.tag===1){var l=n.type;if(hi(l))return Rf(n,l,r)}return r}function tm(n,r,l,d,f,g,E,B,V){return n=iu(l,d,!0,n,f,g,E,B,V),n.context=em(null),l=n.current,d=ai(),f=Fn(l),g=vn(d,f),g.callback=r??null,In(l,g,f),n.current.lanes=f,ws(n,f,d),mi(n,d),n}function Da(n,r,l,d){var f=r.current,g=ai(),E=Fn(f);return l=em(l),r.context===null?r.context=l:r.pendingContext=l,r=vn(g,E),r.payload={element:n},d=d===void 0?null:d,d!==null&&(r.callback=d),n=In(f,r,E),n!==null&&(Xi(n,f,E,g),aa(n,f,E)),E}function ja(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 im(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<r?l:r}}function nu(n,r){im(n,r),(n=n.alternate)&&im(n,r)}function xw(){return null}var nm=typeof reportError=="function"?reportError:function(n){console.error(n)};function ru(n){this._internalRoot=n}Ma.prototype.render=ru.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(i(409));Da(n,r,null,null)},Ma.prototype.unmount=ru.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;ur(function(){Da(null,n,null,null)}),r[hn]=null}};function Ma(n){this._internalRoot=n}Ma.prototype.unstable_scheduleHydration=function(n){if(n){var r=zh();n={blockedOn:null,target:n,priority:r};for(var l=0;l<Rn.length&&r!==0&&r<Rn[l].priority;l++);Rn.splice(l,0,n),l===0&&$h(n)}};function su(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function La(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function rm(){}function Ew(n,r,l,d,f){if(f){if(typeof d=="function"){var g=d;d=function(){var ce=ja(E);g.call(ce)}}var E=tm(r,d,n,0,null,!1,!1,"",rm);return n._reactRootContainer=E,n[hn]=E.current,As(n.nodeType===8?n.parentNode:n),ur(),E}for(;f=n.lastChild;)n.removeChild(f);if(typeof d=="function"){var B=d;d=function(){var ce=ja(V);B.call(ce)}}var V=iu(n,0,!1,null,null,!1,!1,"",rm);return n._reactRootContainer=V,n[hn]=V.current,As(n.nodeType===8?n.parentNode:n),ur(function(){Da(r,V,l,d)}),V}function Ta(n,r,l,d,f){var g=l._reactRootContainer;if(g){var E=g;if(typeof f=="function"){var B=f;f=function(){var V=ja(E);B.call(V)}}Da(r,E,n,f)}else E=Ew(l,r,n,f,d);return ja(E)}Bh=function(n){switch(n.tag){case 3:var r=n.stateNode;if(r.current.memoizedState.isDehydrated){var l=Ss(r.pendingLanes);l!==0&&(Pl(r,l|1),mi(r,Nt()),(it&6)===0&&(Gr=Nt()+500,Tn()))}break;case 13:ur(function(){var d=gn(n,1);if(d!==null){var f=ai();Xi(d,n,1,f)}}),nu(n,1)}},Dl=function(n){if(n.tag===13){var r=gn(n,134217728);if(r!==null){var l=ai();Xi(r,n,134217728,l)}nu(n,134217728)}},Oh=function(n){if(n.tag===13){var r=Fn(n),l=gn(n,r);if(l!==null){var d=ai();Xi(l,n,r,d)}nu(n,r)}},zh=function(){return ot},Fh=function(n,r){var l=ot;try{return ot=n,r()}finally{ot=l}},Di=function(n,r,l){switch(r){case"input":if(st(n,l),r=l.name,l.type==="radio"&&r!=null){for(l=n;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<l.length;r++){var d=l[r];if(d!==n&&d.form===n.form){var f=Qo(d);if(!f)throw Error(i(90));Je(d),st(d,f)}}}break;case"textarea":$e(n,l);break;case"select":r=l.value,r!=null&&le(n,!!l.multiple,r,!1)}},qe=Gc,bt=ur;var Nw={usingClientEntryPoint:!1,Events:[Os,Br,Qo,he,De,Gc]},Js={findFiberByHostInstance:ir,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Rw={bundleType:Js.bundleType,version:Js.version,rendererPackageName:Js.rendererPackageName,rendererConfig:Js.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:M.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=Ph(n),n===null?null:n.stateNode},findFiberByHostInstance:Js.findFiberByHostInstance||xw,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Aa=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Aa.isDisabled&&Aa.supportsFiber)try{Mo=Aa.inject(Rw),Qi=Aa}catch{}}return gi.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Nw,gi.createPortal=function(n,r){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!su(r))throw Error(i(200));return Cw(n,r,null,l)},gi.createRoot=function(n,r){if(!su(n))throw Error(i(299));var l=!1,d="",f=nm;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onRecoverableError!==void 0&&(f=r.onRecoverableError)),r=iu(n,1,!1,null,null,l,!1,d,f),n[hn]=r.current,As(n.nodeType===8?n.parentNode:n),new ru(r)},gi.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=Ph(r),n=n===null?null:n.stateNode,n},gi.flushSync=function(n){return ur(n)},gi.hydrate=function(n,r,l){if(!La(r))throw Error(i(200));return Ta(null,n,r,!0,l)},gi.hydrateRoot=function(n,r,l){if(!su(n))throw Error(i(405));var d=l!=null&&l.hydratedSources||null,f=!1,g="",E=nm;if(l!=null&&(l.unstable_strictMode===!0&&(f=!0),l.identifierPrefix!==void 0&&(g=l.identifierPrefix),l.onRecoverableError!==void 0&&(E=l.onRecoverableError)),r=tm(r,null,n,1,l??null,f,!1,g,E),n[hn]=r.current,As(n),d)for(n=0;n<d.length;n++)l=d[n],f=l._getVersion,f=f(l._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[l,f]:r.mutableSourceEagerHydrationData.push(l,f);return new Ma(r)},gi.render=function(n,r,l){if(!La(r))throw Error(i(200));return Ta(null,n,r,!1,l)},gi.unmountComponentAtNode=function(n){if(!La(n))throw Error(i(40));return n._reactRootContainer?(ur(function(){Ta(null,null,n,!1,function(){n._reactRootContainer=null,n[hn]=null})}),!0):!1},gi.unstable_batchedUpdates=Gc,gi.unstable_renderSubtreeIntoContainer=function(n,r,l,d){if(!La(l))throw Error(i(200));if(n==null||n._reactInternals===void 0)throw Error(i(38));return Ta(n,r,l,!1,d)},gi.version="18.3.1-next-f1338f8080-20240426",gi}var hm;function Bw(){if(hm)return lu.exports;hm=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(),lu.exports=Iw(),lu.exports}var fm;function Ow(){if(fm)return Ia;fm=1;var e=Bw();return Ia.createRoot=e.createRoot,Ia.hydrateRoot=e.hydrateRoot,Ia}var zw=Ow();const Fw=Jd(zw);function qt(e,t,i={}){return fetch(e,{...i,headers:{...i.headers||{},Authorization:`Bearer ${t}`}})}const Tv=e=>`nc_seen_${e}`;async function We(e,t,i={}){const s=await qt(e,t,{method:i.method||"GET",headers:{"content-type":"application/json"},body:i.body?JSON.stringify(i.body):void 0}),o=await s.json().catch(()=>({}));if(!s.ok){const a=new Error(o.error||`HTTP ${s.status}`);throw a.status=s.status,a.data=o,a}return o}const yi=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",Vt=(e,t)=>`${yi(e)}/fleet/${t}`,Er=(e,t)=>We(Vt(t,"status"),e),eh=(e,t,i)=>We(Vt(i,"up"),e,{method:"POST",body:t}),il=(e,t,i)=>We(Vt(i,"down"),e,{method:"POST",body:t}),Av=(e,t,i)=>We(Vt(i,"boot"),e,{method:"POST",body:t}),co=(e,t,i)=>We(Vt(i,"restart"),e,{method:"POST",body:{cell:t}}),th=(e,t)=>We(Vt(t,"definitions"),e),Hw=(e,t)=>We(Vt(t,"credentials/status"),e),pm=(e,t,i,s)=>We(Vt(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:i}}),$w=(e,t,i)=>We(Vt(i,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),Ww=(e,t,i)=>We(Vt(i,"define-engine"),e,{method:"POST",body:{def:t}}),Uw=(e,t,i,s,o)=>We(Vt(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:i,envChanges:s}}),Kw=(e,t,i)=>We(Vt(i,"remove-engine"),e,{method:"POST",body:{id:t}}),qw=(e,t,i)=>We(Vt(i,"define-cell"),e,{method:"POST",body:{def:t}}),Vw=(e,t,i,s)=>We(Vt(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:i}}),Iv=(e,t,i=!1,s)=>We(Vt(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:i}}),Yw=(e,t,i)=>We(Vt(i,"import-cell"),e,{method:"POST",body:t}),Xw=(e,t,i)=>We(Vt(i,"restore-cells"),e,{method:"POST",body:{cells:t}}),Gw=(e,t,i,s)=>We(Vt(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!i}}),ih=(e,t,i)=>We(`${yi(i)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Bv=(e,t,i,s)=>We(`${yi(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!i}}),Ov=(e,t,i)=>We(`${yi(i)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),zv=e=>We("/api/settings",e),Qw=e=>We("/api/nodes",e),Jw=e=>We("/api/peers",e),Zw=e=>We("/api/topology",e),Fv=(e,t)=>We(`${yi(t)}/sessions`,e),nh=(e,t)=>We(`${yi(t)}/config`,e),mm=(e,t)=>We(`${yi(t)}/topology`,e),Hv=(e,t)=>We("/api/settings/config",e,{method:"POST",body:t}),e0=e=>We("/api/settings/token/rotate",e,{method:"POST"}),t0=(e,t)=>We("/api/settings/nodes/pair",e,{method:"POST",body:t}),gm=(e,t,i=[])=>We(`${yi(i)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),$v=(e,t,i)=>We(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:i}}),i0=(e,t,i)=>We(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"PATCH",body:i}),n0=(e,t)=>We(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),rh=(e,t,i)=>We(`/api/settings/nodes/${encodeURIComponent(t)}/${i}`,e,{method:"POST"}),r0=(e,t,i)=>We(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:i}}),vm=(e,t,i,s=[])=>We(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:i,selected:s}}),s0=e=>We("/api/settings/service/regenerate",e,{method:"POST"}),o0=e=>We("/api/settings/update/check",e,{method:"POST"}),a0=e=>We("/api/settings/update/apply",e,{method:"POST"}),l0=(e,t=!0)=>We(`/api/asks${t?"?open=1":""}`,e),c0=(e,t,i)=>We(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:i}}),Ba=(e,t=[])=>We(`${yi(t)}/decks`,e),_m=(e,t,i=[])=>We(`${yi(i)}/decks`,e,{method:"POST",body:{name:t}}),Oa=(e,t,i,s,o=[])=>We(`${yi(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:i,expectedRevision:s}}),u0=(e,t,i,s,o=[])=>We(`${yi(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:i,expectedRevision:s}}),d0=(e,t,i,s=[])=>We(`${yi(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:i}}),h0={power:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M12 3v8"}),u.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:u.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:u.jsxs(u.Fragment,{children:[u.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),u.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:u.jsxs(u.Fragment,{children:[u.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),u.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),u.jsx("path",{d:"M12 18v3"})]}),enter:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),u.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),u.jsx("path",{d:"M22 2 11 13"})]}),trash:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M4 7h16"}),u.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),u.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),u.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:u.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),refresh:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),u.jsx("polyline",{points:"21 3 21 8 16 8"})]}),boot:u.jsxs(u.Fragment,{children:[u.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),u.jsx("path",{d:"M8 21h8M12 17v4M12 12V7"}),u.jsx("polyline",{points:"9 10 12 7 15 10"})]}),upload:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M12 16V5"}),u.jsx("polyline",{points:"8 9 12 5 16 9"}),u.jsx("path",{d:"M5 20h14"})]}),chevronLeft:u.jsx("polyline",{points:"14 6 8 12 14 18"}),chevronUp:u.jsx("polyline",{points:"6 14 12 8 18 14"}),chevronDown:u.jsx("polyline",{points:"6 10 12 16 18 10"}),history:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),u.jsx("polyline",{points:"3 3 3 8 8 8"}),u.jsx("path",{d:"M12 7v5l3 2"})]}),attach:u.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:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),u.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:u.jsxs(u.Fragment,{children:[u.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"}),u.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:u.jsxs(u.Fragment,{children:[u.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),u.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),u.jsx("path",{d:"M21 15l-5-5L5 21"})]}),zoomIn:u.jsxs(u.Fragment,{children:[u.jsx("circle",{cx:"11",cy:"11",r:"7"}),u.jsx("path",{d:"M21 21l-4.35-4.35"}),u.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:u.jsxs(u.Fragment,{children:[u.jsx("circle",{cx:"11",cy:"11",r:"7"}),u.jsx("path",{d:"M21 21l-4.35-4.35"}),u.jsx("path",{d:"M8 11h6"})]}),gear:u.jsxs(u.Fragment,{children:[u.jsx("circle",{cx:"12",cy:"12",r:"3"}),u.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:u.jsxs(u.Fragment,{children:[u.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),u.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 u.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:h0[e]||null})}const f0=["all","pinned","active","off","technical"],Wv="nc_sidebar_views_v1",Uv="nc_sidebar_order_v1";function Kv(e){return f0.includes(e)?e:"all"}function p0(e,t=[],i="all"){const s=Kv(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 m0(e,t,i=[],s=[]){const o=i.indexOf(e.key),a=i.indexOf(t.key),c=o===-1?Number.MAX_SAFE_INTEGER:o,h=a===-1?Number.MAX_SAFE_INTEGER:a,m=s.indexOf(e.key),p=s.indexOf(t.key),y=m===-1?Number.MAX_SAFE_INTEGER:m,S=p===-1?Number.MAX_SAFE_INTEGER:p;return c-h||y-S||+!!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 g0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Uv));if(!t||typeof t!="object"||Array.isArray(t))return{};const i={};for(const[s,o]of Object.entries(t).slice(0,64)){if(typeof s!="string"||!s||s.length>160||!Array.isArray(o))continue;const a=[...new Set(o.filter(c=>typeof c=="string"&&c&&c.length<=256))].slice(0,128);a.length&&(i[s]=a)}return i}catch{return{}}}function Qn(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function v0(e,t=globalThis.localStorage){try{t.setItem(Uv,JSON.stringify(e))}catch{}return e}function _0(e,t,i,s,o=[]){if(typeof t!="string"||!t||i===s)return e;const a=[...new Set(o.filter(_=>typeof _=="string"&&_))];if(!a.includes(i)||!a.includes(s))return e;const c=Qn(e,t).filter(_=>a.includes(_)),h=[...c,...a.filter(_=>!c.includes(_))],m=h.indexOf(i),p=h.indexOf(s);h.splice(m,1);const y=h.indexOf(s),S=m<p?y+1:y;return h.splice(S,0,i),{...e,[t]:h}}function y0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Wv));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function ym(e,t){var i,s;return{open:((i=e==null?void 0:e[t])==null?void 0:i.open)!==!1,filter:Kv((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function S0(e,t=globalThis.localStorage){try{t.setItem(Wv,JSON.stringify(e))}catch{}return e}function Sm(e,t=""){const i=String(t||"").trim().toLocaleLowerCase();return i?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(i):!0}function wr(e=[],t=[],i="all",s=[]){return[...e].filter(o=>p0(o,t,i)).sort((o,a)=>m0(o,a,t,s))}const sh=["it","en","es"];function w0(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return sh.includes(t)?t:"en"}catch{return"en"}}const Ya=w0(),qv="nc_lang",ed="nc-lang";function Vv(){return typeof localStorage<"u"?localStorage:null}const za={it:{"update-available":"nuova versione {v} disponibile","install-version-mismatch":"installazione incompleta: frontend e server non coincidono (v{v})",reload:"ricarica","grid-empty":"trascina qui una sessione dalla sidebar, o doppio-clic per la vista singola","grid-full":"il deck può mostrare al massimo 9 sessioni",pin:"fissa in cima",reorder:"riordina","reorder-help":"trascina la maniglia; frecce su/giu da tastiera","rename-node":"rinomina nodo","rename-node-prompt":"Nuovo nome del nodo in NexusCrew","rename-node-invalid":"Nome non valido: massimo 64 caratteri, senza a capo.","reorder-deck-help":"trascina il deck; frecce sinistra/destra da tastiera",sessions:"sessioni","new-session":"nuova sessione",new:"nuova",fleet:"Flotta","fleet-tmux":"flotta tmux","other-sessions":"Altre sessioni","view-all":"tutte","view-pinned":"fissate","view-active":"attive","view-off":"spente","view-technical":"tecniche","mark-technical":"nascondi come sessione tecnica","mark-normal":"mostra come sessione normale","position-local":"Locale",files:"file",refresh:"aggiorna","filter-placeholder":"filtra sessioni…","loading-fleet":"carico la flotta…","no-sessions":"nessuna sessione tmux viva — la flotta parte al boot (systemd)","no-match":'nessuna sessione contiene "{q}"',"copy-url":"clicca per copiare l'URL","ssh-only":"solo tunnel SSH/VPN","new-files-outbox":"nuovi file in outbox",terminate:"termina","terminate-confirm":'Terminare la sessione "{name}"?',"cell-on":"tmux vivo","cell-off":"spenta","cell-working":"al lavoro","cell-idle":"in attesa","cell-degraded":"degradata: unit attiva, tmux morto","power-on":"accendi","power-off":"spegni","boot-enable":"attiva al boot","boot-disable":"disattiva al boot","state-on":"accesa","state-off":"spenta",engine:"Engine",model:"Modello","model-default":"Modello predefinito del provider","model-remembered":"Ultimo modello usato con questo engine","boot-persist":"avvia al boot","remove-boot":"togli anche dal boot","power-config-in-settings":"Engine, provider, profilo, modello e permessi si modificano in Impostazioni → Flotta.","no-remote-control":"⚠ engine non-native: niente RC da app claude.ai (da qui la piloti comunque)",cancel:"annulla",name:"nome","name-invalid":"nome non valido: a-zA-Z0-9._- max 64, senza '-' iniziale",cwd:"cartella",browse:"sfoglia","fs-home":"home","fs-parent":".. su",preset:"preset","preset-2x2":"griglia 2×2","preset-columns":"colonne","preset-equalize":"equalizza",collapse:"comprimi",expand:"espandi",create:"crea","auth-prompt":"Incolla il token (stampato dal server):","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande",composer:"composer",windows:"{n} finestre","empty-files":"vuota",upload:"carica","no-sessions-short":"nessuna sessione","composer-placeholder":"scrivi o detta…","composer-history-tools":"cronologia e dimensione input","composer-history":"cronologia della cella","composer-history-empty":"nessun input inviato","composer-history-clear":"cancella cronologia di questa cella","composer-expand":"espandi input","composer-collapse":"riduci input","composer-clear-data":"cancella bozze e cronologia","composer-clear-data-help":"Rimuove da questo browser tutte le bozze e la cronologia input delle celle.","composer-clear-confirm":"Cancellare tutte le bozze e la cronologia input salvate in questo browser?","composer-clear-done":"Bozze e cronologia cancellate.","composer-clear-failed":"Impossibile cancellare i dati del composer in questo browser.",attach:"allega","attach-file":"File","attach-camera":"Fotocamera","attach-gallery":"Galleria","attach-uploading":"carico…","attach-upload-progress":"allegato {n}/{total}…","attach-uploaded":"{n} allegati caricati",voice:"voice",send:"invia","composer-send-failed":"connessione non pronta — testo conservato, riprova",close:"chiudi","lang-label":"lingua",decks:"deck","new-deck":"nuovo deck","deck-name":"nome deck","open-deck-window":"apri in una nuova finestra","detach-deck":"stacca in una nuova finestra","deck-current":"questo deck (finestra corrente)","deck-owner-unavailable":"nodo owner non condiviso o non raggiungibile","rename-deck":"rinomina deck","delete-deck":"elimina deck","delete-deck-confirm":'Eliminare il deck "{name}"?',"send-to-deck":"manda al deck…","deck-autosave":"salvataggio automatico",saving:"salvataggio…",saved:"salvato","popup-blocked":"popup bloccato: apri qui","select-drag":"trascina per selezionare","copy-manual":"seleziona e copia manualmente","toggle-sidebar":"mostra/nascondi la barra laterale",settings:"impostazioni","tab-roles":"ruoli","tab-nodes":"nodi",local:"Locale",location:"Dove","pairing-link":"link di pairing","pairing-required":"nome, alias SSH e link di pairing sono obbligatori","pairing-connect-help":"Per collegare un nodo servono: nome, Host SSH già funzionante e link/QR creato sull’altra installazione NexusCrew.","pairing-localhost-hint":"127.0.0.1 nel link è corretto: non aprirlo qui. NexusCrew usa invito e porta attraverso l’Host SSH.","scan-qr":"scansiona QR","pairing-qr-invalid":"QR di pairing non valido","invite-node":"invita un nodo","create-pairing-link":"crea link / QR","visibility-network":"tutta la rete","visibility-relay":"solo relay","visibility-selected":"nodi selezionati","hydra-simple":"locale + nodi, una sola rete","local-ready":"Questo dispositivo è pronto. Puoi usarlo da solo o collegarlo a un nodo.","local-only":"solo locale","add-node":"aggiungi nodo",connect:"collega","node-connected":"Nodo collegato. La rete verrà sincronizzata automaticamente.","tab-system":"sistema","tab-fleet":"flotta","fleet-editor-loading":"Caricamento dell'editor Fleet…","fleet-editor-load-error":"Impossibile caricare l'editor Fleet.","fleet-editor-unavailable":"Editor Fleet non disponibile in questa posizione.","fleet-managed":"gestito da NexusCrew","fleet-custom":"comando personalizzato","fleet-managed-help":"Client, provider e avvio sono gestiti internamente; i segreti non vengono mostrati.","fleet-credential-title":"API key su questo dispositivo","fleet-credential-help":"La key resta solo sul nodo selezionato, non viene mostrata, esportata o condivisa con la rete.","fleet-credential-set":"imposta key","fleet-credential-change":"cambia key","fleet-credential-forget":"dimentica","fleet-credential-saved":"Key salvata localmente.","fleet-credential-removed":"Key locale rimossa.","fleet-credential-remove-confirm":"Rimuovere la key locale {key}?","fleet-credential-source-environment":"ambiente","fleet-credential-source-local":"store locale","fleet-credential-source-compatibility":"config compatibile","fleet-credential-source-missing":"mancante","fleet-key-section":"KEY","fleet-key-variable":"Variabile","fleet-key-value":"Valore per {key}","fleet-key-used-by":"Usata da: {engines}","fleet-key-used-by-none":"Non ancora usata da engine configurati su questo nodo.","fleet-key-shared-impact":"Sostituire o rimuovere {key} interessa tutti gli engine elencati: {engines}.","fleet-key-enter":"inserisci la key","fleet-key-blank-keeps":"vuoto = mantieni la fonte attuale","fleet-key-reveal":"mostra","fleet-key-hide":"nascondi","fleet-key-local-help":"Il valore resta write-only sul nodo selezionato e non entra in engine, backup o federazione.","fleet-key-create-missing":"Crea esplicitamente l’engine senza key (resterà “key richiesta”).","fleet-key-partial-create":"Engine creato; la key non è stata salvata. Puoi riprovare senza creare duplicati.","fleet-key-partial-edit":"Engine aggiornato; la key non è stata salvata. Le modifiche all’engine restano applicate.","fleet-provider-notice-claude-openrouter":"Claude Code è ottimizzato per modelli Anthropic: altri provider potrebbero non funzionare correttamente. Fast mode richiede il provider Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses è beta e stateless; Codex-VL non usa fallback Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configurazione Claude isolata con onboarding e fast mode dedicati; la configurazione Claude nativa non viene modificata.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY dal credential layer locale; qwen3.8-max-preview è il modello predefinito e non viene usato alcun fallback OpenAI/PAYG.","fleet-model-default":"modello predefinito (opzionale)","fleet-model-required":"modello (obbligatorio)","fleet-standard-permissions":"permessi standard","fleet-unsafe-permissions":"non sicuro · ignora approvazioni/sandbox","fleet-unsafe-warning":"Modalità non sicura esplicita: il worker può agire senza le normali approvazioni o protezioni sandbox.","fleet-provider-display":"nome visualizzato del provider","fleet-custom-provider-default":"Provider personalizzato","fleet-api-key-env":"NOME_VARIABILE_API_KEY","fleet-provider-id":"id-provider","fleet-custom-secret-help":"NexusCrew salva solo il nome della variabile d’ambiente, mai il suo valore.","fleet-model-override":"modello alternativo","fleet-ready":"pronto","fleet-not-ready":"non configurato","fleet-engines":"Engine","fleet-cells":"Celle / sessioni cloud","fleet-backup":"backup / ripristino","fleet-backup-help":"Esporta o ripristina selettivamente engine, celle e system prompt. Token, API key e segreti provider non entrano mai nel file.","fleet-backup-export":"esporta","fleet-backup-import":"importa","fleet-backup-download":"scarica backup","fleet-backup-restore":"ripristina selezionate","fleet-backup-import-help":"Scegli un backup JSON, controlla le celle e seleziona l’engine di destinazione prima del ripristino.","fleet-backup-overwrite":"sovrascrive la cella esistente","fleet-backup-new":"nuova cella","fleet-backup-engine-missing":"scegli un engine disponibile","fleet-backup-restore-unavailable":"Il nodo selezionato supporta solo l’esportazione; aggiornalo per ripristinare backup.","fleet-backup-restored":"{n} celle ripristinate","fleet-backup-confirm-overwrite":"Sovrascrivere queste celle? {cells}","fleet-backup-needs-restart":"riavvio necessario: {cells}","fleet-backup-empty":"nessuna cella da esportare","fleet-backup-select-one":"seleziona almeno una cella","fleet-backup-too-large":"backup troppo grande (massimo 1 MB)","fleet-backup-invalid-json":"il file non contiene JSON valido","fleet-backup-invalid-format":"formato o versione del backup non supportati","fleet-backup-invalid-cell":"il backup contiene una cella non valida","fleet-backup-duplicate-cell":"il backup contiene ID cella duplicati","fleet-backup-invalid-engine":"il backup contiene un engine non valido","fleet-backup-duplicate-engine":"il backup contiene ID engine duplicati","fleet-backup-confirm-engine-overwrite":"Sovrascrivere questi engine? I valori ambiente già configurati sul target restano invariati. {engines}","fleet-backup-env-names":"nomi ambiente","fleet-backup-env-values-required":"i valori ambiente vanno configurati sul dispositivo","fleet-system-prompt":"system prompt",characters:"caratteri","select-all":"seleziona tutte","select-none":"nessuna",edit:"modifica",save:"salva",label:"etichetta","command-path":"path assoluto del comando","args-lines":"argomenti, uno per riga","env-write-only":"I valori env sono write-only: vuoto mantiene il valore esistente.","fleet-new-engine":"Nuovo engine","fleet-new-cell":"Nuova cella","fleet-saved":"Definizione salvata.","fleet-restart-confirm":"Modifica salvata. Riavviare ora: {cells}?","fleet-remove-engine":'Eliminare l’engine "{id}"?',"fleet-remove-cell":'Eliminare la cella "{id}"? Se è attiva verrà prima fermata.',"settings-readonly":"READONLY attivo: le modifiche sono bloccate dal server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"questa macchina guarda altri nodi via tunnel SSH","role-node":"nodo (raggiungibile)","published-port":"porta pubblicata (opzionale)","no-nodes":"nessun nodo remoto configurato","node-add":"collega installazione NexusCrew","node-connect-help":"La porta SSH serve a raggiungere il server SSH. La porta NexusCrew è invece la porta locale mostrata da `nexuscrew status` sul nodo remoto.","node-name-label":"Nome del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH su questo dispositivo","node-ssh-local-help":"Puoi sostituire l’indirizzo del link con lo stesso alias che funziona usando ssh su questo dispositivo. Alias, agent e chiavi restano locali e non viaggiano nel link.","node-ssh-port-label":"Porta SSH","node-ssh-port-help":"Di solito 22; usa la porta pubblica del server SSH.","node-app-port-label":"Porta NexusCrew sul nodo","node-app-port-help":"È la porta mostrata da `nexuscrew status` sul nodo remoto.","node-name-ph":"nome (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"porta remota (opz.)","node-remove-confirm":'Rimuovere il nodo "{name}"?',"node-remove-warning":"Elimina associazione, credenziali e tunnel locale. Non spegne il dispositivo remoto.","peer-inventory-title":"Nodi collegati al hub","peer-group-hubs":"Hub diretti","peer-group-clients":"Client collegati","peer-group-routed":"Nodi raggiungibili tramite la rete","peer-routed":"instradato","peer-routed-stale":"instradato, non raggiungibile","peer-visibility":"Visibilità nella rete","node-test":"test","tunnel-start":"avvia tunnel","tunnel-stop":"ferma tunnel","tunnel-restart":"riavvia tunnel","share-node":"Condividi questo nodo","share-local-heading":"Condivisione di questo dispositivo","share-local-hub":"Hub di condivisione","share-local-through":"Condividi {device} tramite {hub}","share-local-active":"Condiviso e raggiungibile dalla rete collegata all’hub.","share-local-pending":"Condivisione richiesta, ma il tunnel è giù: questo dispositivo non è ancora raggiungibile.","share-local-private":"Privato: solo questo dispositivo può usare il collegamento all’hub.","share-local-private-down":"Privato, ma il collegamento all’hub è giù. Riconnetti per applicare e verificare la modalità privata.","share-local-reconnect":"Riconnetti e riconcilia","share-node-off-desc":"Privato: resta collegato al nodo hub, ma gli altri client non possono raggiungerlo.","share-node-on-desc":"Condiviso: il nodo hub può mostrarlo e smistare celle e deck autorizzati.","peer-shared":"Nodo client condiviso nella rete Hydra","peer-private":"Nodo client privato: collegato, non pubblicato nella rete Hydra","node-connected-client":"client collegato","transport-used":"in uso","tunnel-up":"tunnel su","tunnel-down":"tunnel giù","authorized-keys-hint":"incolla questa riga in ~/.ssh/authorized_keys sull'host remoto:",copy:"copia",copied:"copiato","token-rotate":"ruota token","token-rotate-explain":"Il nuovo token NON verrà mostrato: recuperalo con `nexuscrew show token`. La sessione corrente verrà invalidata.","service-regenerate":"rigenera service","npm-auto-update":"aggiornamenti automatici da npm","npm-auto-update-help":"Controlla periodicamente latest e installa solo versioni più recenti. Mai downgrade.","npm-update-current":"installata","npm-update-latest":"npm latest","npm-update-check":"controlla ora","npm-update-install":"aggiorna ora","npm-update-restarting":"Aggiornamento avviato; NexusCrew si riaprirà dopo il riavvio del servizio.","npm-update-idle":"aggiornato","npm-update-checking":"controllo in corso","npm-update-available":"aggiornamento disponibile","npm-update-installing":"installazione in corso","npm-update-installed":"installato, riavvio in corso","npm-update-error":"controllo fallito","npm-update-unsupported":"disponibile solo con installazione npm globale","service-installed":"service installato","service-missing":"service non installato","service-active":"attivo","service-inactive":"non attivo",confirm:"conferma",add:"aggiungi",enable:"attiva","wizard-title":"benvenuto in NexusCrew","wizard-skip":"configura dopo dai settings","wizard-step-roles":"ruoli di questa installazione","wizard-step-node":"primo nodo remoto (opzionale)","wizard-done":"tutto pronto","wizard-done-desc":"setup completato — puoi cambiare tutto dai settings",next:"continua",back:"indietro",skip:"salta",finish:"fine","err-node-name":"nome non valido (a-z, 0-9, -, max 32)","err-local-name":"nome locale non valido: usa uno slug univoco, non “localhost”","err-ssh":"ssh non valido (atteso user@host o alias)","err-port":"porta non valida (1–65535)","err-ssh-port":"porta SSH non valida (1–65535)","err-node-port":"porta NexusCrew non valida (1–65535)","node-sessions":"{n} sessioni","tunnel-down-since":"tunnel giù da {t}","node-unreachable":"nodo non raggiungibile","node-passive":"client offline · stato normale","node-offline":"nodo offline","node-offline-seen":"offline · visto {t} fa","node-needs-repair":"legacy · ripeti il pairing","asks-title":"domande dalle celle","ask-reply-ph":"scrivi la risposta…","push-enable":"attiva notifiche push","push-disable":"disattiva notifiche push","push-on":"push attive su questo device","push-off":"push non attive","push-denied":"permesso notifiche negato dal browser","push-unsupported":"push non supportate in questo browser","node-display-label":"Nome (etichetta)","node-slug-hint":"routing su slug: {slug}","device-name-label":"Nome dispositivo","device-name-hint":"come ti vedono i peer (modificabile)","local-route-name-label":"Nome locale / route","local-route-name-hint":"handle tecnico stabile: label leggibile + suffisso del nodeId; modificabile prima della connessione","err-label":"etichetta non valida (max 64 char, niente a capo)","fleet-inventory":"Celle e sessioni","fleet-inventory-help":"tutte le posizioni (Locale + route Hydra)","fleet-manage-location":"Gestisci posizione","fleet-network-overview":"Panoramica rete","fleet-manage-help":"crea e configura celle nella posizione selezionata","fleet-overview-help":"stato operativo di tutte le posizioni, senza duplicare l’editor","fleet-inventory-empty":"nessuna cella o sessione","fleet-not-available":"fleet non disponibile su questa posizione",start:"avvia",stop:"ferma",restart:"riavvia",delete:"elimina","copy-manual":"copia non riuscita — seleziona e Cmd+C, o copia a mano","copy-empty":"niente selezione: trascina con Shift per selezionare","save-and-start":"salva e avvia",permissions:"Permessi","power-on-hint":"Spegni la cella; puoi anche toglierla dal boot.","launch-engine-help":"Provider, credenziali e nuovi engine si creano in Impostazioni → Flotta. Modello e permessi sono per questa cella.","launch-unavailable-hint":"Configurazione engine non disponibile su questo nodo.","import-as-cell":"Importa come cella","import-help":"Riconcilia una sessione tmux esistente in una cella gestita. Scegli un engine già dichiarato: nessun engine viene inventato.","import-engine-required":"scegli un engine (obbligatorio)","test-and-connect":"testa e collega","pairing-v2-hint":"Incolla o scansiona UN solo link: precompila nome, Host SSH ed etichetta quando il link li include (v2).","invite-v2-hint":"Crea un invito monouso completo. Se sei già collegato a un hub, viene usato automaticamente; altrimenti serve solo il suo indirizzo SSH raggiungibile.","invite-network-hint":"Crea un invito per la rete a cui sei già collegato. Il nuovo dispositivo entrerà attraverso l’hub, non si collegherà direttamente a questo dispositivo.","invite-network-label":"Rete di destinazione","invite-network-via":"Hub","invite-network-route":"Un solo collegamento verso l’hub; nodi, celle e deck vengono smistati internamente.","invite-endpoint-label":"Indirizzo SSH di questo hub visto dagli altri dispositivi","invite-endpoint-auto":"Endpoint già configurato","invite-endpoint-needed":"Inserisci user@host o un alias SSH condiviso. Non è 127.0.0.1 e non è l’URL HTTP NexusCrew.","invite-ssh-hint":"Il target SSH con cui L’ALTRO dispositivo raggiunge QUESTA installazione (user@host o alias). Obbligatorio: viene incluso nel link.","invite-next-steps":"copia questo link, apri NexusCrew sull’altro dispositivo e incollalo in Impostazioni → Nodi (o scansiona il QR): al resto pensa NexusCrew","pair-card-title":"collega con un solo link","pair-card-help":"Incolla il link di pairing generato sull’altro dispositivo (o scansiona il suo QR): NexusCrew decodifica, prova la connessione SSH e collega da solo.","pair-paste-ph":"incolla qui il link di pairing","pair-paste-btn":"incolla","pair-advanced":"avanzate / modifica","pair-progress":"collegamento in corso: SSH → invito → conferma → verifica…","pair-retry":"riprova","pair-invalid-link":"questo non è un link di pairing valido","pair-invalid-hint":"serve il link completo (http://…#pair=…) generato dall’altro NexusCrew: non aprirlo, incollalo qui","pair-missing-ssh":"il link non include il target SSH (formato v1): indica in “avanzate” come questo dispositivo raggiunge l’altro via SSH — non viene mai inventato","pair-missing-name":"manca il nome del nodo: completalo in “avanzate”","pair-clipboard-denied":"lettura degli appunti non consentita: incolla manualmente nel campo","pair-clipboard-empty":"appunti vuoti: copia prima il link di pairing","pair-stage-validation":"dati non validi","pair-stage-conflict":"nome già in uso","pair-stage-ssh-start":"avvio del tunnel SSH fallito","pair-stage-ssh-ready":"peer non raggiungibile via SSH","pair-stage-join":"scambio dell’invito fallito","pair-stage-tunnel-final":"tunnel negoziato fallito","pair-stage-confirm":"conferma del pairing fallita","pair-stage-health":"verifica finale della federazione fallita","pair-stage-internal":"errore interno","pair-stage-generic":"connessione fallita","qr-no-camera":"nessuna camera disponibile su questo dispositivo: usa una foto del QR","qr-permission":"permesso camera negato: consentilo nel browser o usa una foto del QR","qr-unsupported":"scanner live non supportato qui: carica una foto del QR","qr-upload":"usa una foto"},en:{"update-available":"new version {v} available","install-version-mismatch":"incomplete installation: frontend and server do not match (v{v})",reload:"reload","grid-empty":"drag a session here from the sidebar, or double-click for single view","grid-full":"a deck can show at most 9 sessions",pin:"pin to top",reorder:"reorder","reorder-help":"drag the handle; keyboard up/down arrows","rename-node":"rename node","rename-node-prompt":"New node name in NexusCrew","rename-node-invalid":"Invalid name: maximum 64 characters, no line breaks.","reorder-deck-help":"drag the deck; keyboard left/right arrows",sessions:"sessions","new-session":"new session",new:"new",fleet:"Fleet","fleet-tmux":"tmux fleet","other-sessions":"Other sessions","view-all":"all","view-pinned":"pinned","view-active":"active","view-off":"off","view-technical":"technical","mark-technical":"hide as technical session","mark-normal":"show as normal session","position-local":"Local",files:"files",refresh:"refresh","filter-placeholder":"filter sessions…","loading-fleet":"loading fleet…","no-sessions":"no live tmux sessions — the fleet starts at boot (systemd)","no-match":'no session matches "{q}"',"copy-url":"click to copy URL","ssh-only":"SSH/VPN tunnel only","new-files-outbox":"new files in outbox",terminate:"terminate","terminate-confirm":'Terminate session "{name}"?',"cell-on":"tmux alive","cell-off":"off","cell-working":"working","cell-idle":"idle","cell-degraded":"degraded: unit active, tmux dead","power-on":"power on","power-off":"power off","boot-enable":"enable at boot","boot-disable":"disable at boot","state-on":"running","state-off":"stopped",engine:"Engine",model:"Model","model-default":"Provider default model","model-remembered":"Last model used with this engine","boot-persist":"start at boot","remove-boot":"also remove from boot","power-config-in-settings":"Edit engine, provider, profile, model and permissions in Settings → Fleet.","no-remote-control":"⚠ non-native engine: no claude.ai app RC (you can still drive it from here)",cancel:"cancel",name:"name","name-invalid":"invalid name: a-zA-Z0-9._- max 64, no leading '-'",cwd:"folder",browse:"browse","fs-home":"home","fs-parent":".. up",preset:"preset","preset-2x2":"2×2 grid","preset-columns":"columns","preset-equalize":"equalize",collapse:"collapse",expand:"expand",create:"create","auth-prompt":"Paste the token (printed by the server):","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text",composer:"composer",windows:"{n} windows","empty-files":"empty",upload:"upload","no-sessions-short":"no sessions","composer-placeholder":"type or dictate…","composer-history-tools":"input history and size","composer-history":"cell history","composer-history-empty":"no submitted input","composer-history-clear":"clear this cell history","composer-expand":"expand input","composer-collapse":"collapse input","composer-clear-data":"clear drafts and history","composer-clear-data-help":"Removes every saved cell draft and input-history entry from this browser.","composer-clear-confirm":"Clear every saved draft and input-history entry from this browser?","composer-clear-done":"Drafts and history cleared.","composer-clear-failed":"Could not clear composer data in this browser.",attach:"attach","attach-file":"File","attach-camera":"Camera","attach-gallery":"Gallery","attach-uploading":"uploading…","attach-upload-progress":"attachment {n}/{total}…","attach-uploaded":"{n} attachments uploaded",voice:"voice",send:"send","composer-send-failed":"connection not ready — text kept, try again",close:"close","lang-label":"language",decks:"decks","new-deck":"new deck","deck-name":"deck name","open-deck-window":"open in a new window","detach-deck":"detach into a new window","deck-current":"this deck (current window)","deck-owner-unavailable":"owner node is not shared or reachable","rename-deck":"rename deck","delete-deck":"delete deck","delete-deck-confirm":'Delete deck "{name}"?',"send-to-deck":"send to deck…","deck-autosave":"autosave",saving:"saving…",saved:"saved","popup-blocked":"popup blocked: open here","select-drag":"drag to select","copy-manual":"select and copy manually","toggle-sidebar":"show/hide the sidebar",settings:"settings","tab-roles":"roles","tab-nodes":"nodes",local:"Local",location:"Location","pairing-link":"pairing link","pairing-required":"name, SSH alias and pairing link are required","pairing-connect-help":"Connecting a node requires a name, a working SSH Host, and a link/QR created by the other NexusCrew installation.","pairing-localhost-hint":"127.0.0.1 in the link is correct: do not open it here. NexusCrew carries the invite and port through the SSH Host.","scan-qr":"scan QR","pairing-qr-invalid":"invalid pairing QR","invite-node":"invite a node","create-pairing-link":"create link / QR","visibility-network":"whole network","visibility-relay":"relay only","visibility-selected":"selected nodes","hydra-simple":"local + nodes, one network","local-ready":"This device is ready. Use it alone or connect it to a node.","local-only":"local only","add-node":"add node",connect:"connect","node-connected":"Node connected. The network will synchronize automatically.","tab-system":"system","tab-fleet":"fleet","fleet-editor-loading":"Loading the Fleet editor…","fleet-editor-load-error":"Unable to load the Fleet editor.","fleet-editor-unavailable":"The Fleet editor is unavailable at this location.","fleet-managed":"managed by NexusCrew","fleet-custom":"custom command","fleet-managed-help":"Client, provider and launch are managed internally; secrets are never displayed.","fleet-credential-title":"API key on this device","fleet-credential-help":"The key stays only on the selected node and is never displayed, exported or shared with the network.","fleet-credential-set":"set key","fleet-credential-change":"change key","fleet-credential-forget":"forget","fleet-credential-saved":"Key saved locally.","fleet-credential-removed":"Local key removed.","fleet-credential-remove-confirm":"Remove the local {key} key?","fleet-credential-source-environment":"environment","fleet-credential-source-local":"local store","fleet-credential-source-compatibility":"compatible config","fleet-credential-source-missing":"missing","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Value for {key}","fleet-key-used-by":"Used by: {engines}","fleet-key-used-by-none":"Not yet used by configured engines on this node.","fleet-key-shared-impact":"Replacing or removing {key} affects every listed engine: {engines}.","fleet-key-enter":"enter the key","fleet-key-blank-keeps":"blank = keep the current source","fleet-key-reveal":"reveal","fleet-key-hide":"hide","fleet-key-local-help":"The value stays write-only on the selected node and never enters engines, backups or federation.","fleet-key-create-missing":"Explicitly create the engine without a key (it will remain “key required”).","fleet-key-partial-create":"Engine created; the key was not saved. Retry without creating a duplicate.","fleet-key-partial-edit":"Engine updated; the key was not saved. The engine changes remain applied.","fleet-provider-notice-claude-openrouter":"Claude Code is optimized for Anthropic models; other providers may not work correctly. Fast mode requires the first-party Anthropic provider.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses is beta and stateless; Codex-VL has no Chat Completions fallback.","fleet-provider-notice-claude-kimi-code":"Kimi Code uses isolated Claude configuration with dedicated onboarding and fast-mode flags; native Claude configuration is not modified.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal uses only ALIBABA_CODE_API_KEY from the local credential layer; qwen3.8-max-preview is the default and no OpenAI/PAYG fallback is used.","fleet-model-default":"default model (optional)","fleet-model-required":"model (required)","fleet-standard-permissions":"standard permissions","fleet-unsafe-permissions":"unsafe · bypass approvals/sandbox","fleet-unsafe-warning":"Explicit unsafe mode: the worker can act without normal approval or sandbox gates.","fleet-provider-display":"provider display name","fleet-custom-provider-default":"Custom provider","fleet-api-key-env":"API_KEY_ENV_NAME","fleet-provider-id":"provider-id","fleet-custom-secret-help":"NexusCrew stores only the environment-variable name, never its value.","fleet-model-override":"model override","fleet-ready":"ready","fleet-not-ready":"not configured","fleet-engines":"Engines","fleet-cells":"Cells / cloud sessions","fleet-backup":"backup / restore","fleet-backup-help":"Selectively export or restore engines, cells, and system prompts. Tokens, API keys, and provider secrets never enter the file.","fleet-backup-export":"export","fleet-backup-import":"import","fleet-backup-download":"download backup","fleet-backup-restore":"restore selected","fleet-backup-import-help":"Choose a JSON backup, review the cells and select a destination engine before restoring.","fleet-backup-overwrite":"overwrites existing cell","fleet-backup-new":"new cell","fleet-backup-engine-missing":"choose an available engine","fleet-backup-restore-unavailable":"The selected node supports export only; update it to restore backups.","fleet-backup-restored":"{n} cells restored","fleet-backup-confirm-overwrite":"Overwrite these cells? {cells}","fleet-backup-needs-restart":"restart required: {cells}","fleet-backup-empty":"no cells to export","fleet-backup-select-one":"select at least one cell","fleet-backup-too-large":"backup is too large (1 MB maximum)","fleet-backup-invalid-json":"the file does not contain valid JSON","fleet-backup-invalid-format":"unsupported backup format or version","fleet-backup-invalid-cell":"the backup contains an invalid cell","fleet-backup-duplicate-cell":"the backup contains duplicate cell IDs","fleet-backup-invalid-engine":"the backup contains an invalid engine","fleet-backup-duplicate-engine":"the backup contains duplicate engine IDs","fleet-backup-confirm-engine-overwrite":"Overwrite these engines? Environment values already configured on the target stay unchanged. {engines}","fleet-backup-env-names":"environment names","fleet-backup-env-values-required":"environment values must be configured on this device","fleet-system-prompt":"system prompt",characters:"characters","select-all":"select all","select-none":"select none",edit:"edit",save:"save",label:"label","command-path":"absolute command path","args-lines":"arguments, one per line","env-write-only":"Environment values are write-only: blank keeps the existing value.","fleet-new-engine":"New engine","fleet-new-cell":"New cell","fleet-saved":"Definition saved.","fleet-restart-confirm":"Change saved. Restart now: {cells}?","fleet-remove-engine":'Delete engine "{id}"?',"fleet-remove-cell":'Delete cell "{id}"? If active it will be stopped first.',"settings-readonly":"READONLY active: changes are blocked by the server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"this machine watches other nodes via SSH tunnels","role-node":"node (reachable)","published-port":"published port (optional)","no-nodes":"no remote nodes configured","node-add":"connect a NexusCrew installation","node-connect-help":"The SSH port reaches the SSH server. The NexusCrew port is the local port reported by `nexuscrew status` on the remote node.","node-name-label":"Node name","node-ssh-label":"SSH host","pair-ssh-local-label":"SSH host or alias on this device","node-ssh-local-help":"You may replace the link address with the same alias that works with ssh on this device. Aliases, agents and private keys stay local and are never carried in the link.","node-ssh-port-label":"SSH port","node-ssh-port-help":"Usually 22; use the SSH server public port.","node-app-port-label":"NexusCrew port on node","node-app-port-help":"The port reported by `nexuscrew status` on the remote node.","node-name-ph":"name (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"remote port (opt.)","node-remove-confirm":'Remove node "{name}"?',"node-remove-warning":"Deletes the pairing, credentials and local tunnel. It does not power off the remote device.","peer-inventory-title":"Nodes connected to the hub","peer-group-hubs":"Direct hubs","peer-group-clients":"Connected clients","peer-group-routed":"Nodes reachable through the network","peer-routed":"routed","peer-routed-stale":"routed, unreachable","peer-visibility":"Network visibility","node-test":"test","tunnel-start":"start tunnel","tunnel-stop":"stop tunnel","tunnel-restart":"restart tunnel","share-node":"Share this node","share-local-heading":"Share this device","share-local-hub":"Sharing hub","share-local-through":"Share {device} through {hub}","share-local-active":"Shared and reachable by the network connected to the hub.","share-local-pending":"Sharing is requested, but the tunnel is down: this device is not reachable yet.","share-local-private":"Private: only this device can use its hub connection.","share-local-private-down":"Private, but the hub connection is down. Reconnect to apply and verify private mode.","share-local-reconnect":"Reconnect and reconcile","share-node-off-desc":"Private: it stays connected to the hub, but other clients cannot reach it.","share-node-on-desc":"Shared: the hub may advertise it and route authorized cells and decks.","peer-shared":"Client node shared on the Hydra network","peer-private":"Private client node: connected, not published on Hydra","node-connected-client":"connected client","transport-used":"in use","tunnel-up":"tunnel up","tunnel-down":"tunnel down","authorized-keys-hint":"paste this line into ~/.ssh/authorized_keys on the remote host:",copy:"copy",copied:"copied","token-rotate":"rotate token","token-rotate-explain":"The new token will NOT be shown: retrieve it with `nexuscrew show token`. The current session will be invalidated.","service-regenerate":"regenerate service","npm-auto-update":"automatic updates from npm","npm-auto-update-help":"Periodically checks latest and installs only newer versions. Never downgrades.","npm-update-current":"installed","npm-update-latest":"npm latest","npm-update-check":"check now","npm-update-install":"update now","npm-update-restarting":"Update started; NexusCrew will return after the service restarts.","npm-update-idle":"up to date","npm-update-checking":"checking","npm-update-available":"update available","npm-update-installing":"installing","npm-update-installed":"installed, restarting","npm-update-error":"check failed","npm-update-unsupported":"available only for global npm installations","service-installed":"service installed","service-missing":"service not installed","service-active":"active","service-inactive":"not active",confirm:"confirm",add:"add",enable:"enable","wizard-title":"welcome to NexusCrew","wizard-skip":"configure later from settings","wizard-step-roles":"roles of this install","wizard-step-node":"first remote node (optional)","wizard-done":"all set","wizard-done-desc":"setup complete — you can change everything from settings",next:"continue",back:"back",skip:"skip",finish:"finish","err-node-name":"invalid name (a-z, 0-9, -, max 32)","err-local-name":"invalid local name: use a unique slug, not “localhost”","err-ssh":"invalid ssh (expected user@host or alias)","err-port":"invalid port (1–65535)","err-ssh-port":"invalid SSH port (1–65535)","err-node-port":"invalid NexusCrew port (1–65535)","node-sessions":"{n} sessions","tunnel-down-since":"tunnel down for {t}","node-unreachable":"node unreachable","node-passive":"client offline · expected","node-offline":"node offline","node-offline-seen":"offline · seen {t} ago","node-needs-repair":"legacy · pair again","asks-title":"questions from the cells","ask-reply-ph":"type your answer…","push-enable":"enable push notifications","push-disable":"disable push notifications","push-on":"push active on this device","push-off":"push not active","push-denied":"notification permission denied by the browser","push-unsupported":"push not supported in this browser","node-display-label":"Name (label)","node-slug-hint":"routing on slug: {slug}","device-name-label":"Device name","device-name-hint":"how peers see you (editable)","local-route-name-label":"Local / route name","local-route-name-hint":"stable technical handle: readable label + nodeId suffix; editable before connecting","err-label":"invalid label (max 64 chars, no line breaks)","fleet-inventory":"Cells and sessions","fleet-inventory-help":"all positions (Local + Hydra routes)","fleet-manage-location":"Manage location","fleet-network-overview":"Network overview","fleet-manage-help":"create and configure cells at the selected location","fleet-overview-help":"operational state of every location, separate from the editor","fleet-inventory-empty":"no cells or sessions","fleet-not-available":"fleet not available on this position",start:"start",stop:"stop",restart:"restart",delete:"delete","copy-manual":"copy failed — select and press Cmd+C, or copy manually","copy-empty":"nothing selected: drag with Shift to select","save-and-start":"save and start",permissions:"Permissions","power-on-hint":"Stop the cell; you can also remove it from boot.","launch-engine-help":"Providers, credentials and new engines are created in Settings → Fleet. Model and permissions are per cell.","launch-unavailable-hint":"Engine configuration is unavailable on this node.","import-as-cell":"Import as cell","import-help":"Reconcile an existing tmux session into a managed cell. Pick an already-declared engine: no engine is invented.","import-engine-required":"pick an engine (required)","test-and-connect":"test and connect","pairing-v2-hint":"Paste or scan ONE link: it prefills name, SSH host and label when the link carries them (v2).","invite-v2-hint":"Create one complete one-time invitation. If this device already joined a hub, that hub is used automatically; otherwise only its reachable SSH address is required.","invite-network-hint":"Create an invitation for the network you already joined. The new device enters through the hub instead of connecting directly to this device.","invite-network-label":"Destination network","invite-network-via":"Hub","invite-network-route":"One connection to the hub; nodes, cells and decks are routed internally.","invite-endpoint-label":"This hub’s SSH address as seen by other devices","invite-endpoint-auto":"Configured endpoint","invite-endpoint-needed":"Enter user@host or a shared SSH alias. This is not 127.0.0.1 and not the NexusCrew HTTP URL.","invite-ssh-hint":"The SSH target the OTHER device uses to reach THIS installation (user@host or alias). Required: it is included in the link.","invite-next-steps":"copy this link, open NexusCrew on the other device and paste it in Settings → Nodes (or scan the QR): NexusCrew does the rest","pair-card-title":"connect with one link","pair-card-help":"Paste the pairing link generated on the other device (or scan its QR): NexusCrew decodes it, tests the SSH connection and connects on its own.","pair-paste-ph":"paste the pairing link here","pair-paste-btn":"paste","pair-advanced":"advanced / edit","pair-progress":"connecting: SSH → invite → confirm → verify…","pair-retry":"retry","pair-invalid-link":"this is not a valid pairing link","pair-invalid-hint":"you need the full link (http://…#pair=…) generated by the other NexusCrew: don’t open it, paste it here","pair-missing-ssh":"the link carries no SSH target (v1 format): set in “advanced” how this device reaches the other one over SSH — it is never invented","pair-missing-name":"the node name is missing: fill it in “advanced”","pair-clipboard-denied":"clipboard read not allowed: paste manually into the field","pair-clipboard-empty":"clipboard is empty: copy the pairing link first","pair-stage-validation":"invalid data","pair-stage-conflict":"name already in use","pair-stage-ssh-start":"SSH tunnel start failed","pair-stage-ssh-ready":"peer unreachable over SSH","pair-stage-join":"invite exchange failed","pair-stage-tunnel-final":"negotiated tunnel failed","pair-stage-confirm":"pairing confirmation failed","pair-stage-health":"final federation check failed","pair-stage-internal":"internal error","pair-stage-generic":"connection failed","qr-no-camera":"no camera available on this device: use a photo of the QR","qr-permission":"camera permission denied: allow it in the browser or use a photo of the QR","qr-unsupported":"live scanner not supported here: upload a photo of the QR","qr-upload":"use a photo"},es:{"update-available":"nueva versión {v} disponible","install-version-mismatch":"instalación incompleta: frontend y servidor no coinciden (v{v})",reload:"recargar","grid-empty":"arrastra aquí una sesión desde la barra lateral, o doble clic para vista única","grid-full":"un deck puede mostrar como máximo 9 sesiones",pin:"fijar arriba",reorder:"reordenar","reorder-help":"arrastra el control; flechas arriba/abajo","rename-node":"renombrar nodo","rename-node-prompt":"Nuevo nombre del nodo en NexusCrew","rename-node-invalid":"Nombre no válido: máximo 64 caracteres, sin saltos de línea.","reorder-deck-help":"arrastra el deck; flechas izquierda/derecha",sessions:"sesiones","new-session":"nueva sesión",new:"nueva",fleet:"Flota","fleet-tmux":"flota tmux","other-sessions":"Otras sesiones","view-all":"todas","view-pinned":"fijadas","view-active":"activas","view-off":"apagadas","view-technical":"técnicas","mark-technical":"ocultar como sesión técnica","mark-normal":"mostrar como sesión normal","position-local":"Local",files:"archivos",refresh:"actualizar","filter-placeholder":"filtrar sesiones…","loading-fleet":"cargando flota…","no-sessions":"sin sesiones tmux vivas — la flota arranca en el boot (systemd)","no-match":"ninguna sesión coincide con «{q}»","copy-url":"clic para copiar la URL","ssh-only":"solo túnel SSH/VPN","new-files-outbox":"archivos nuevos en outbox",terminate:"terminar","terminate-confirm":"¿Terminar la sesión «{name}»?","cell-on":"tmux activo","cell-off":"apagada","cell-working":"trabajando","cell-idle":"en espera","cell-degraded":"degradada: unit activa, tmux muerto","power-on":"encender","power-off":"apagar","boot-enable":"activar al iniciar","boot-disable":"desactivar al iniciar","state-on":"encendida","state-off":"apagada",engine:"Motor",model:"Modelo","model-default":"Modelo predeterminado del proveedor","model-remembered":"Último modelo usado con este motor","boot-persist":"iniciar en el boot","remove-boot":"quitar también del boot","power-config-in-settings":"Modifica motor, proveedor, perfil, modelo y permisos en Ajustes → Flota.","no-remote-control":"⚠ motor no nativo: sin RC de la app claude.ai (aquí puedes pilotarla igual)",cancel:"cancelar",name:"nombre","name-invalid":"nombre inválido: a-zA-Z0-9._- máx 64, sin '-' inicial",cwd:"carpeta",browse:"explorar","fs-home":"home","fs-parent":".. arriba",preset:"preset","preset-2x2":"cuadrícula 2×2","preset-columns":"columnas","preset-equalize":"igualar",collapse:"contraer",expand:"expandir",create:"crear","auth-prompt":"Pega el token (impreso por el servidor):","remember-device":"recordar en este dispositivo","zoom-out":"texto más pequeño","zoom-in":"texto más grande",composer:"composer",windows:"{n} ventanas","empty-files":"vacía",upload:"subir","no-sessions-short":"sin sesiones","composer-placeholder":"escribe o dicta…","composer-history-tools":"historial y tamaño de entrada","composer-history":"historial de la celda","composer-history-empty":"ninguna entrada enviada","composer-history-clear":"borrar historial de esta celda","composer-expand":"ampliar entrada","composer-collapse":"reducir entrada","composer-clear-data":"borrar borradores e historial","composer-clear-data-help":"Elimina de este navegador todos los borradores y el historial de entrada de las celdas.","composer-clear-confirm":"¿Borrar todos los borradores y el historial de entrada guardados en este navegador?","composer-clear-done":"Borradores e historial eliminados.","composer-clear-failed":"No se pudieron borrar los datos del composer en este navegador.",attach:"adjuntar","attach-file":"Archivo","attach-camera":"Cámara","attach-gallery":"Galería","attach-uploading":"subiendo…","attach-upload-progress":"adjunto {n}/{total}…","attach-uploaded":"{n} adjuntos subidos",voice:"voz",send:"enviar","composer-send-failed":"conexión no disponible — texto conservado, inténtalo de nuevo",close:"cerrar","lang-label":"idioma",decks:"decks","new-deck":"nuevo deck","deck-name":"nombre del deck","open-deck-window":"abrir en una ventana nueva","detach-deck":"separar en una ventana nueva","deck-current":"este deck (ventana actual)","deck-owner-unavailable":"el nodo propietario no está compartido o accesible","rename-deck":"renombrar deck","delete-deck":"eliminar deck","delete-deck-confirm":"¿Eliminar el deck «{name}»?","send-to-deck":"enviar al deck…","deck-autosave":"guardado automático",saving:"guardando…",saved:"guardado","popup-blocked":"ventana bloqueada: abrir aquí","select-drag":"arrastra para seleccionar","copy-manual":"selecciona y copia manualmente","toggle-sidebar":"mostrar/ocultar la barra lateral",settings:"ajustes","tab-roles":"roles","tab-nodes":"nodos",local:"Local",location:"Ubicación","pairing-link":"enlace de emparejamiento","pairing-required":"nombre, alias SSH y enlace son obligatorios","pairing-connect-help":"Para conectar un nodo necesitas un nombre, un Host SSH funcional y el enlace/QR creado por la otra instalación NexusCrew.","pairing-localhost-hint":"127.0.0.1 en el enlace es correcto: no lo abras aquí. NexusCrew usa la invitación y el puerto mediante el Host SSH.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","invite-node":"invitar un nodo","create-pairing-link":"crear enlace / QR","visibility-network":"toda la red","visibility-relay":"solo relay","visibility-selected":"nodos seleccionados","hydra-simple":"local + nodos, una red","local-ready":"Este dispositivo está listo. Úsalo solo o conéctalo a un nodo.","local-only":"solo local","add-node":"añadir nodo",connect:"conectar","node-connected":"Nodo conectado. La red se sincronizará automáticamente.","tab-system":"sistema","tab-fleet":"flota","fleet-editor-loading":"Cargando el editor de Fleet…","fleet-editor-load-error":"No se puede cargar el editor de Fleet.","fleet-editor-unavailable":"El editor de Fleet no está disponible en esta ubicación.","fleet-managed":"gestionado por NexusCrew","fleet-custom":"comando personalizado","fleet-managed-help":"Cliente, proveedor e inicio se gestionan internamente; los secretos nunca se muestran.","fleet-credential-title":"Clave API en este dispositivo","fleet-credential-help":"La clave permanece solo en el nodo seleccionado y nunca se muestra, exporta ni comparte con la red.","fleet-credential-set":"poner clave","fleet-credential-change":"cambiar clave","fleet-credential-forget":"olvidar","fleet-credential-saved":"Clave guardada localmente.","fleet-credential-removed":"Clave local eliminada.","fleet-credential-remove-confirm":"¿Eliminar la clave local {key}?","fleet-credential-source-environment":"entorno","fleet-credential-source-local":"almacén local","fleet-credential-source-compatibility":"config compatible","fleet-credential-source-missing":"ausente","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Valor para {key}","fleet-key-used-by":"Usada por: {engines}","fleet-key-used-by-none":"Aún no la usa ningún motor configurado en este nodo.","fleet-key-shared-impact":"Sustituir o eliminar {key} afecta a todos los motores listados: {engines}.","fleet-key-enter":"introduce la clave","fleet-key-blank-keeps":"vacío = mantener la fuente actual","fleet-key-reveal":"mostrar","fleet-key-hide":"ocultar","fleet-key-local-help":"El valor permanece write-only en el nodo seleccionado y nunca entra en motores, copias ni federación.","fleet-key-create-missing":"Crear explícitamente el motor sin clave (seguirá como “clave requerida”).","fleet-key-partial-create":"Motor creado; la clave no se guardó. Puedes reintentar sin crear un duplicado.","fleet-key-partial-edit":"Motor actualizado; la clave no se guardó. Los cambios del motor siguen aplicados.","fleet-provider-notice-claude-openrouter":"Claude Code está optimizado para modelos Anthropic; otros proveedores podrían no funcionar correctamente. Fast mode requiere el proveedor Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses es beta y stateless; Codex-VL no usa fallback de Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configuración Claude aislada con onboarding y fast mode dedicados; la configuración Claude nativa no se modifica.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY de la capa local de credenciales; qwen3.8-max-preview es el modelo predeterminado y no se usa fallback OpenAI/PAYG.","fleet-model-default":"modelo predeterminado (opcional)","fleet-model-required":"modelo (obligatorio)","fleet-standard-permissions":"permisos estándar","fleet-unsafe-permissions":"inseguro · omitir aprobaciones/sandbox","fleet-unsafe-warning":"Modo inseguro explícito: el worker puede actuar sin las aprobaciones normales ni las protecciones del sandbox.","fleet-provider-display":"nombre visible del proveedor","fleet-custom-provider-default":"Proveedor personalizado","fleet-api-key-env":"NOMBRE_VARIABLE_API_KEY","fleet-provider-id":"id-proveedor","fleet-custom-secret-help":"NexusCrew guarda solo el nombre de la variable de entorno, nunca su valor.","fleet-model-override":"modelo alternativo","fleet-ready":"listo","fleet-not-ready":"no configurado","fleet-engines":"Motores","fleet-cells":"Celdas / sesiones cloud","fleet-backup":"copia / restauración","fleet-backup-help":"Exporta o restaura selectivamente motores, celdas y system prompts. Tokens, claves API y secretos del proveedor nunca entran en el archivo.","fleet-backup-export":"exportar","fleet-backup-import":"importar","fleet-backup-download":"descargar copia","fleet-backup-restore":"restaurar seleccionadas","fleet-backup-import-help":"Elige una copia JSON, revisa las celdas y selecciona un motor de destino antes de restaurar.","fleet-backup-overwrite":"sobrescribe la celda existente","fleet-backup-new":"celda nueva","fleet-backup-engine-missing":"elige un motor disponible","fleet-backup-restore-unavailable":"El nodo seleccionado solo admite exportación; actualízalo para restaurar copias.","fleet-backup-restored":"{n} celdas restauradas","fleet-backup-confirm-overwrite":"¿Sobrescribir estas celdas? {cells}","fleet-backup-needs-restart":"reinicio necesario: {cells}","fleet-backup-empty":"no hay celdas para exportar","fleet-backup-select-one":"selecciona al menos una celda","fleet-backup-too-large":"copia demasiado grande (máximo 1 MB)","fleet-backup-invalid-json":"el archivo no contiene JSON válido","fleet-backup-invalid-format":"formato o versión de copia no compatible","fleet-backup-invalid-cell":"la copia contiene una celda no válida","fleet-backup-duplicate-cell":"la copia contiene IDs de celda duplicados","fleet-backup-invalid-engine":"la copia contiene un motor no válido","fleet-backup-duplicate-engine":"la copia contiene IDs de motor duplicados","fleet-backup-confirm-engine-overwrite":"¿Sobrescribir estos motores? Los valores de entorno ya configurados en el destino no cambian. {engines}","fleet-backup-env-names":"nombres de entorno","fleet-backup-env-values-required":"los valores de entorno deben configurarse en este dispositivo","fleet-system-prompt":"system prompt",characters:"caracteres","select-all":"seleccionar todas","select-none":"ninguna",edit:"editar",save:"guardar",label:"etiqueta","command-path":"ruta absoluta del comando","args-lines":"argumentos, uno por línea","env-write-only":"Los valores env son de solo escritura: vacío conserva el valor existente.","fleet-new-engine":"Nuevo motor","fleet-new-cell":"Nueva celda","fleet-saved":"Definición guardada.","fleet-restart-confirm":"Cambio guardado. ¿Reiniciar ahora: {cells}?","fleet-remove-engine":'¿Eliminar el motor "{id}"?',"fleet-remove-cell":'¿Eliminar la celda "{id}"? Si está activa se detendrá primero.',"settings-readonly":"READONLY activo: los cambios están bloqueados por el servidor (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"esta máquina observa otros nodos vía túneles SSH","role-node":"nodo (alcanzable)","published-port":"puerto publicado (opcional)","no-nodes":"sin nodos remotos configurados","node-add":"conectar una instalación NexusCrew","node-connect-help":"El puerto SSH conecta con el servidor SSH. El puerto NexusCrew es el puerto local indicado por `nexuscrew status` en el nodo remoto.","node-name-label":"Nombre del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH en este dispositivo","node-ssh-local-help":"Puedes sustituir la dirección del enlace por el mismo alias que funciona con ssh en este dispositivo. Los alias, agentes y claves permanecen locales y nunca viajan en el enlace.","node-ssh-port-label":"Puerto SSH","node-ssh-port-help":"Normalmente 22; usa el puerto público del servidor SSH.","node-app-port-label":"Puerto NexusCrew del nodo","node-app-port-help":"El puerto indicado por `nexuscrew status` en el nodo remoto.","node-name-ph":"nombre (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"puerto remoto (opc.)","node-remove-confirm":"¿Eliminar el nodo «{name}»?","node-remove-warning":"Elimina el emparejamiento, las credenciales y el túnel local. No apaga el dispositivo remoto.","peer-inventory-title":"Nodos conectados al hub","peer-group-hubs":"Hubs directos","peer-group-clients":"Clientes conectados","peer-group-routed":"Nodos accesibles a través de la red","peer-routed":"enrutado","peer-routed-stale":"enrutado, no accesible","peer-visibility":"Visibilidad en la red","node-test":"test","tunnel-start":"iniciar túnel","tunnel-stop":"detener túnel","tunnel-restart":"reiniciar túnel","share-node":"Compartir este nodo","share-local-heading":"Compartir este dispositivo","share-local-hub":"Hub para compartir","share-local-through":"Compartir {device} mediante {hub}","share-local-active":"Compartido y accesible para la red conectada al hub.","share-local-pending":"Se solicitó compartir, pero el túnel está caído: este dispositivo aún no es accesible.","share-local-private":"Privado: solo este dispositivo puede usar la conexión al hub.","share-local-private-down":"Privado, pero la conexión al hub está caída. Reconecta para aplicar y verificar el modo privado.","share-local-reconnect":"Reconectar y reconciliar","share-node-off-desc":"Privado: sigue conectado al hub, pero otros clientes no pueden alcanzarlo.","share-node-on-desc":"Compartido: el hub puede anunciarlo y enrutar celdas y decks autorizados.","peer-shared":"Nodo cliente compartido en la red Hydra","peer-private":"Nodo cliente privado: conectado, no publicado en Hydra","node-connected-client":"cliente conectado","transport-used":"en uso","tunnel-up":"túnel activo","tunnel-down":"túnel caído","authorized-keys-hint":"pega esta línea en ~/.ssh/authorized_keys del host remoto:",copy:"copiar",copied:"copiado","token-rotate":"rotar token","token-rotate-explain":"El nuevo token NO se mostrará: recupéralo con `nexuscrew show token`. La sesión actual quedará invalidada.","service-regenerate":"regenerar service","npm-auto-update":"actualizaciones automáticas desde npm","npm-auto-update-help":"Comprueba latest periódicamente e instala solo versiones más recientes. Nunca baja de versión.","npm-update-current":"instalada","npm-update-latest":"npm latest","npm-update-check":"comprobar ahora","npm-update-install":"actualizar ahora","npm-update-restarting":"Actualización iniciada; NexusCrew volverá después de reiniciar el servicio.","npm-update-idle":"actualizado","npm-update-checking":"comprobando","npm-update-available":"actualización disponible","npm-update-installing":"instalando","npm-update-installed":"instalada, reiniciando","npm-update-error":"comprobación fallida","npm-update-unsupported":"disponible solo con instalación npm global","service-installed":"service instalado","service-missing":"service no instalado","service-active":"activo","service-inactive":"no activo",confirm:"confirmar",add:"añadir",enable:"activar","wizard-title":"bienvenido a NexusCrew","wizard-skip":"configura después desde ajustes","wizard-step-roles":"roles de esta instalación","wizard-step-node":"primer nodo remoto (opcional)","wizard-done":"todo listo","wizard-done-desc":"configuración completa — puedes cambiarlo todo desde ajustes",next:"continuar",back:"atrás",skip:"omitir",finish:"terminar","err-node-name":"nombre inválido (a-z, 0-9, -, máx 32)","err-local-name":"nombre local inválido: usa un slug único, no “localhost”","err-ssh":"ssh inválido (se espera user@host o alias)","err-port":"puerto inválido (1–65535)","err-ssh-port":"puerto SSH inválido (1–65535)","err-node-port":"puerto NexusCrew inválido (1–65535)","node-sessions":"{n} sesiones","tunnel-down-since":"túnel caído desde hace {t}","node-unreachable":"nodo inalcanzable","node-passive":"cliente desconectado · estado normal","node-offline":"nodo desconectado","node-offline-seen":"sin conexión · visto hace {t}","node-needs-repair":"legacy · vuelve a enlazar","asks-title":"preguntas de las celdas","ask-reply-ph":"escribe la respuesta…","push-enable":"activar notificaciones push","push-disable":"desactivar notificaciones push","push-on":"push activas en este dispositivo","push-off":"push no activas","push-denied":"permiso de notificaciones denegado por el navegador","push-unsupported":"push no soportadas en este navegador","node-display-label":"Nombre (etiqueta)","node-slug-hint":"enrutado por slug: {slug}","device-name-label":"Nombre del dispositivo","device-name-hint":"cómo te ven los pares (editable)","local-route-name-label":"Nombre local / ruta","local-route-name-hint":"identificador técnico estable: etiqueta legible + sufijo del nodeId; editable antes de conectar","err-label":"etiqueta no válida (máx 64 caracteres, sin saltos de línea)","fleet-inventory":"Celdas y sesiones","fleet-inventory-help":"todas las posiciones (Local + rutas Hydra)","fleet-manage-location":"Gestionar ubicación","fleet-network-overview":"Vista de red","fleet-manage-help":"crea y configura celdas en la ubicación seleccionada","fleet-overview-help":"estado operativo de todas las ubicaciones, separado del editor","fleet-inventory-empty":"sin celdas ni sesiones","fleet-not-available":"fleet no disponible en esta posición",start:"iniciar",stop:"detener",restart:"reiniciar",delete:"eliminar","copy-manual":"copia fallida — selecciona y pulsa Cmd+C, o copia a mano","copy-empty":"nada seleccionado: arrastra con Shift para seleccionar","save-and-start":"guardar e iniciar",permissions:"Permisos","power-on-hint":"Detén la celda; también puedes quitarla del boot.","launch-engine-help":"Proveedores, credenciales y nuevos motores se crean en Ajustes → Flota. Modelo y permisos son por celda.","launch-unavailable-hint":"La configuración del motor no está disponible en este nodo.","import-as-cell":"Importar como celda","import-help":"Reconcilia una sesión tmux existente en una celda gestionada. Elige un motor ya declarado: no se inventa ninguno.","import-engine-required":"elige un motor (obligatorio)","test-and-connect":"probar y conectar","pairing-v2-hint":"Pega o escanea UN solo enlace: rellena nombre, Host SSH y etiqueta cuando los incluye (v2).","invite-v2-hint":"Crea una invitación completa de un solo uso. Si este dispositivo ya está unido a un hub, se usa automáticamente; si no, solo hace falta su dirección SSH alcanzable.","invite-network-hint":"Crea una invitación para la red a la que ya estás conectado. El nuevo dispositivo entra por el hub y no se conecta directamente a este dispositivo.","invite-network-label":"Red de destino","invite-network-via":"Hub","invite-network-route":"Una sola conexión al hub; nodos, celdas y decks se enrutan internamente.","invite-endpoint-label":"Dirección SSH de este hub vista por los otros dispositivos","invite-endpoint-auto":"Endpoint ya configurado","invite-endpoint-needed":"Introduce usuario@host o un alias SSH compartido. No es 127.0.0.1 ni la URL HTTP de NexusCrew.","invite-ssh-hint":"El destino SSH con el que el OTRO dispositivo alcanza ESTA instalación (usuario@host o alias). Obligatorio: se incluye en el enlace.","invite-next-steps":"copia este enlace, abre NexusCrew en el otro dispositivo y pégalo en Ajustes → Nodos (o escanea el QR): NexusCrew hace el resto","pair-card-title":"conectar con un solo enlace","pair-card-help":"Pega el enlace de emparejamiento generado en el otro dispositivo (o escanea su QR): NexusCrew lo decodifica, prueba la conexión SSH y conecta solo.","pair-paste-ph":"pega aquí el enlace de emparejamiento","pair-paste-btn":"pegar","pair-advanced":"avanzado / editar","pair-progress":"conectando: SSH → invitación → confirmación → verificación…","pair-retry":"reintentar","pair-invalid-link":"esto no es un enlace de emparejamiento válido","pair-invalid-hint":"se necesita el enlace completo (http://…#pair=…) generado por el otro NexusCrew: no lo abras, pégalo aquí","pair-missing-ssh":"el enlace no incluye el destino SSH (formato v1): indica en “avanzado” cómo este dispositivo alcanza al otro por SSH — nunca se inventa","pair-missing-name":"falta el nombre del nodo: complétalo en “avanzado”","pair-clipboard-denied":"lectura del portapapeles no permitida: pega manualmente en el campo","pair-clipboard-empty":"portapapeles vacío: copia primero el enlace","pair-stage-validation":"datos no válidos","pair-stage-conflict":"nombre ya en uso","pair-stage-ssh-start":"fallo al iniciar el túnel SSH","pair-stage-ssh-ready":"peer inaccesible por SSH","pair-stage-join":"intercambio de invitación fallido","pair-stage-tunnel-final":"túnel negociado fallido","pair-stage-confirm":"confirmación de emparejamiento fallida","pair-stage-health":"verificación final de la federación fallida","pair-stage-internal":"error interno","pair-stage-generic":"conexión fallida","qr-no-camera":"no hay cámara disponible en este dispositivo: usa una foto del QR","qr-permission":"permiso de cámara denegado: permítelo en el navegador o usa una foto del QR","qr-unsupported":"escáner en vivo no soportado aquí: sube una foto del QR","qr-upload":"usar una foto"}};function td(){const e=Vv(),t=e?e.getItem(qv):null;return sh.includes(t)?t:Ya}function b0(e){const t=Vv();if(t)try{t.setItem(qv,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(ed))}function v(e){const t=td(),i=za[t]||za[Ya];return Object.prototype.hasOwnProperty.call(i,e)?i[e]:Object.prototype.hasOwnProperty.call(za[Ya],e)?za[Ya][e]:e}function k0(e){return typeof window>"u"?()=>{}:(window.addEventListener(ed,e),()=>window.removeEventListener(ed,e))}const Yv=sh;function Pi(){return[R.useSyncExternalStore(k0,td,td),b0]}function nl({cell:e,token:t,route:i=[],onConfirm:s,onClose:o}){var I,$;Pi();const a=!!(e&&e.active),c=Array.isArray(i)?i.join("/"):"",[h,m]=R.useState([]),[p,y]=R.useState(!1);R.useEffect(()=>{let K=!0;return(async()=>{if(t)try{const F=await Er(t,c?c.split("/"):[]);if(!K)return;if(y(F.provider==="builtin"&&(F.capabilities||[]).includes("edit")),F.provider==="builtin"&&(F.capabilities||[]).includes("definitions")){const ae=await th(t,c?c.split("/"):[]);if(!K)return;const W=new Map((F.engines||[]).map(j=>[j.id,j]));m((ae.engines||[]).map(j=>{var A,se,ge,G,Z,ue,de;return{id:j.id,label:j.label||j.id,client:((A=j.managed)==null?void 0:A.client)||"",models:[...new Set([...((se=W.get(j.id))==null?void 0:se.models)||[],...((ge=j.managedInfo)==null?void 0:ge.models)||[]])].filter(Boolean),defaultModel:((G=j.managed)==null?void 0:G.model)||((Z=j.managedInfo)==null?void 0:Z.defaultModel)||"",policyDefault:((ue=j.managed)==null?void 0:ue.permissionPolicy)||((de=j.managed)!=null&&de.client&&j.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{K=!1}},[t,c]);const S=(e==null?void 0:e.engine)||((I=h[0])==null?void 0:I.id)||"",_=K=>(e==null?void 0:e.models)&&e.models[K]||"",C=K=>{const F=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[K];if(F==="standard"||F==="unsafe")return F;const ae=h.find(W=>W.id===K);return ae?ae.policyDefault:"standard"},[w,x]=R.useState(S),[k,b]=R.useState((e==null?void 0:e.model)||""),D=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:(($=e==null?void 0:e.permissionPolicies)==null?void 0:$[e==null?void 0:e.engine])||"",[L,M]=R.useState(D),[te,U]=R.useState((e==null?void 0:e.boot)??!0),[O,ee]=R.useState(!1),[q,J]=R.useState(null);R.useEffect(()=>{h.length&&(x(K=>K||S),b(K=>K||_((e==null?void 0:e.engine)||S)||""),M(K=>K==="standard"||K==="unsafe"?K:C((e==null?void 0:e.engine)||S)))},[h.length]);const Q=R.useMemo(()=>h.find(K=>K.id===w)||null,[h,w]),T=!!(Q&&["claude","codex","codex-vl"].includes(Q.client));function N(K){x(K);const F=h.find(ae=>ae.id===K);b(_(K)||(F==null?void 0:F.defaultModel)||""),M(C(K))}async function P(K){K.preventDefault(),ee(!0),J(null);try{if(a)await s({action:"down",boot:te});else{const F=L==="standard"||L==="unsafe"?L:(Q==null?void 0:Q.policyDefault)||"standard";await s({action:"up",...p?{engine:w,model:k||"",...T?{permissionPolicy:F}:(Q==null?void 0:Q.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:te})}o()}catch(F){J(String(F&&F.message||F)),ee(!1)}}return u.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:o,children:u.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:K=>K.stopPropagation(),onSubmit:P,children:[u.jsxs("div",{className:"nc-sheet-head",children:[u.jsx("b",{children:e==null?void 0:e.cell}),u.jsx("span",{className:"nc-sheet-state",children:v(a?"state-on":"state-off")})]}),a?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"nc-power-config",children:[u.jsx("span",{children:v("engine")}),u.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&u.jsxs("small",{children:[v("model"),": ",e.model]}),u.jsx("small",{children:v("power-on-hint")})]}),u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:te,onChange:K=>U(K.target.checked)}),v("remove-boot")]})]}):u.jsxs(u.Fragment,{children:[p&&h.length>0?u.jsxs("div",{className:"nc-launch-fields",children:[u.jsxs("label",{className:"nc-field",children:[v("engine"),u.jsx("select",{value:w,onChange:K=>N(K.target.value),children:h.map(K=>u.jsx("option",{value:K.id,children:K.label},K.id))})]}),u.jsxs("label",{className:"nc-field",children:[v("model"),u.jsx("input",{value:k,list:"nc-launch-models",placeholder:v("model-default"),onChange:K=>b(K.target.value)}),u.jsx("datalist",{id:"nc-launch-models",children:((Q==null?void 0:Q.models)||[]).map(K=>u.jsx("option",{value:K},K))})]}),T?u.jsxs("label",{className:"nc-field",children:[v("permissions"),u.jsxs("select",{value:L,onChange:K=>M(K.target.value),children:[u.jsx("option",{value:"standard",children:v("fleet-standard-permissions")}),u.jsx("option",{value:"unsafe",children:v("fleet-unsafe-permissions")})]})]}):u.jsx("small",{className:"nc-note",children:v("fleet-standard-permissions")}),T&&L==="unsafe"&&u.jsx("small",{className:"nc-err",children:v("fleet-unsafe-warning")}),u.jsx("small",{className:"nc-note",children:v("launch-engine-help")})]}):u.jsxs("div",{className:"nc-power-config",children:[u.jsx("span",{children:v("engine")}),u.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&u.jsxs("small",{children:[v("model"),": ",e.model]}),u.jsx("small",{children:v("launch-unavailable-hint")})]}),u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:te,onChange:K=>U(K.target.checked)}),v("boot-persist")]})]}),q&&u.jsx("div",{className:"nc-err",children:q}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:O,children:v("cancel")}),u.jsx("button",{type:"submit",className:"nc-btn primary",disabled:O,children:v(a?"power-off":"save-and-start")})]})]})})}const wm=/^[a-z0-9-]{1,32}$/;function rl(e,t){const i=Array.isArray(e)?e:[];return i.length?`${i.map(encodeURIComponent).join("/")}:${t}`:String(t)}function C0(e,t,i){const s={};for(const o of Array.isArray(t)?t:[]){const a=Array.isArray(o==null?void 0:o.route)?o.route:typeof(o==null?void 0:o.name)=="string"?[o.name]:[];if(!a.length)continue;const c=a.join("/"),h=o.status==="up"||o.tunnel&&o.tunnel.status==="up",m=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!h&&!m&&(s[c]=e&&e[c]||i)}return s}function bm(e,t,i){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${i}:${s.tmuxSession||s.cell}`}))}function km({nodes:e,topology:t,remote:i,down:s,fleet:o}={}){var m,p,y,S;const a=[],c=new Set,h=new Set;for(const _ of Array.isArray(e)?e:[]){if(!_||typeof _.name!="string"||!wm.test(_.name)||_.direction==="inbound"&&_.shared!==!0)continue;const C=[_.name],w=_.name;c.add(w);const x=((m=_.tunnel)==null?void 0:m.status)||"unknown",k=x==="up",b={name:_.name,label:_.label||_.name,route:C,direct:!0,instanceId:_.nodeId||null,shared:_.shared===!0,tunnelStatus:x,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:_.health||null,direction:_.direction||"outbound",roles:_.roles||null,rolesKnown:_.rolesKnown===!0};if(_.nodeId&&h.add(_.nodeId),!_.nodeId&&_.paired===!1){a.push({...b,status:"needs-repair",downSince:s&&s[w]||null});continue}if(((p=_.health)==null?void 0:p.auth)==="failed"||x==="degraded"&&((y=_.health)==null?void 0:y.status)==="degraded"){a.push({...b,status:"needs-repair",downSince:s&&s[w]||null});continue}if(x==="passive"||((S=_.health)==null?void 0:S.status)==="passive"){a.push({...b,status:"passive",downSince:null});continue}if(!k){a.push({...b,status:"down",downSince:s&&s[w]||null});continue}const D=i&&(i[w]||i[_.name])||null,L=o&&(o[w]||o[_.name]),M=!!(D&&!D.error&&Array.isArray(D.sessions)),te=!!(L&&L.available===!0&&Array.isArray(L.cells));if(!M&&!te){a.push({...b,status:"unreachable"});continue}const U=(M?D.sessions:[]).filter(q=>q&&typeof q.name=="string"&&q.name).map(q=>({...q,node:w,route:C,key:`${w}:${q.name}`})),O=bm(L,C,w),ee=new Set(O.map(q=>q.tmuxSession).filter(Boolean));a.push({...b,status:"up",sessions:U,cells:O,unmanaged:U.filter(q=>!ee.has(q.name)),fleetAvailable:!!(L&&L.available),capabilities:L&&L.capabilities||[],engines:L&&L.engines||[],fleetProvider:L&&L.provider||null,sessionsAvailable:M,inventoryPartial:!M})}for(const _ of Array.isArray(t)?t:[]){if(!_||!Array.isArray(_.route)||_.route.length<1||_.route.some(U=>!wm.test(U)))continue;const C=_.route.join("/");if(c.has(C)||_.instanceId&&h.has(_.instanceId))continue;_.instanceId&&h.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){a.push({...w,status:"offline",downSince:s&&s[C]||_.lastSeen||null});continue}const x=i&&i[C]||null,k=o&&o[C],b=!!(x&&!x.error&&Array.isArray(x.sessions)),D=!!(k&&k.available===!0&&Array.isArray(k.cells));if(!b&&!D){a.push({...w,status:"unreachable",downSince:s&&s[C]||null});continue}const L=(b?x.sessions:[]).filter(U=>U&&typeof U.name=="string"&&U.name).map(U=>({...U,node:C,route:_.route,key:`${C}:${U.name}`})),M=bm(k,_.route,C),te=new Set(M.map(U=>U.tmuxSession).filter(Boolean));a.push({...w,status:"up",sessions:L,cells:M,unmanaged:L.filter(U=>!te.has(U.name)),fleetAvailable:!!(k&&k.available),capabilities:k&&k.capabilities||[],engines:k&&k.engines||[],fleetProvider:k&&k.provider||null,lastSeen:_.lastSeen||null,sessionsAvailable:b,inventoryPartial:!b})}return a.sort((_,C)=>_.label.localeCompare(C.label))}const x0=4e3;function oh(e,t=!0){const[i,s]=R.useState([]),o=R.useRef({});return R.useEffect(()=>{if(!t||!e){s([]);return}let a=!0;async function c(){var x;let m=[],p=[];if(await Promise.all([Qw(e).then(k=>{m=Array.isArray(k.nodes)?k.nodes:[]}).catch(()=>{}),Zw(e).then(k=>{p=Array.isArray(k.nodes)?k.nodes:[]}).catch(()=>{})]),!a)return;const y={},S={},_=new Set(m.map(k=>k.name)),C=[];for(const k of m)((x=k.tunnel)==null?void 0:x.status)==="up"&&(k.nodeId||k.paired!==!1)&&(k.direction!=="inbound"||k.shared===!0)&&C.push([k.name]);for(const k of p)!k.stale&&Array.isArray(k.route)&&!(k.route.length===1&&_.has(k.route[0]))&&C.push(k.route);if(await Promise.all(C.map(async k=>{const b=k.join("/");try{y[b]=await Fv(e,k)}catch{y[b]={error:"unreachable"}}try{S[b]=await Er(e,k)}catch{S[b]={available:!1}}})),!a)return;const w=km({nodes:m,topology:p,remote:y,fleet:S,down:o.current});o.current=C0(o.current,w,Math.floor(Date.now()/1e3)),s(km({nodes:m,topology:p,remote:y,fleet:S,down:o.current}))}c();const h=setInterval(c,x0);return()=>{a=!1,clearInterval(h)}},[e,t]),i}const Cm=52,xm=14;function Xn({position:e,itemKey:t,label:i,onMove:s,onStep:o,canMove:a=()=>!0,scope:c="roster"}){const h=R.useRef(null),m=R.useRef(0),[p,y]=R.useState(!1),S=()=>{var b,D,L,M;const k=h.current;(D=(b=k==null?void 0:k.over)==null?void 0:b.classList)==null||D.remove("nc-roster-over"),(M=(L=k==null?void 0:k.source)==null?void 0:L.classList)==null||M.remove("nc-roster-dragging"),m.current&&cancelAnimationFrame(m.current),m.current=0},_=(k=!1)=>{const b=h.current;if(!b)return;const D=b.target;S(),h.current=null,y(!1);try{b.handle.releasePointerCapture(b.pointerId)}catch{}k&&D&&D!==t&&a(t,D)&&s(t,D)},C=(k,b)=>{var ee,q,J,Q,T,N,P,I,$;const D=h.current;if(!D)return;D.x=k,D.y=b;const L=c==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",M=(q=(ee=document.elementFromPoint(k,b))==null?void 0:ee.closest)==null?void 0:q.call(ee,L),te=c==="node"?(J=M==null?void 0:M.dataset)==null?void 0:J.nodeOrderKey:(Q=M==null?void 0:M.dataset)==null?void 0:Q.rosterKey,O=(c==="node"||((T=M==null?void 0:M.dataset)==null?void 0:T.position)===e)&&te&&te!==t&&a(t,te);D.over!==(O?M:null)&&((P=(N=D.over)==null?void 0:N.classList)==null||P.remove("nc-roster-over"),D.over=O?M:null,($=(I=D.over)==null?void 0:I.classList)==null||$.add("nc-roster-over")),D.target=O?te:null},w=()=>{const k=h.current;if(!k){m.current=0;return}const b=k.container;if(b){const D=b.getBoundingClientRect(),L=k.y<D.top+Cm?-xm:k.y>D.bottom-Cm?xm:0;L&&(b.scrollTop+=L,C(k.x,k.y))}m.current=requestAnimationFrame(w)};R.useEffect(()=>{const k=D=>{D.key==="Escape"&&h.current&&(D.preventDefault(),_(!1))},b=()=>_(!1);return window.addEventListener("keydown",k),window.addEventListener("blur",b),()=>{window.removeEventListener("keydown",k),window.removeEventListener("blur",b),S(),h.current=null}},[t,e,c]);const x=k=>{var M;if(k.pointerType==="mouse"&&k.button!==0)return;k.preventDefault(),k.stopPropagation(),k.currentTarget.focus({preventScroll:!0});const b=c==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",D=k.currentTarget.closest(b),L=k.currentTarget.closest(".nc-side-scroll, .nc-home-scroll");h.current={pointerId:k.pointerId,handle:k.currentTarget,source:D,container:L,target:null,over:null,x:k.clientX,y:k.clientY},(M=D==null?void 0:D.classList)==null||M.add("nc-roster-dragging");try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}y(!0),m.current=requestAnimationFrame(w)};return u.jsx("button",{type:"button",className:`nc-roster-handle${p?" active":""}`,"aria-label":`${v("reorder")} ${i}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:v("reorder-help"),onClick:k=>{k.preventDefault(),k.stopPropagation()},onDragStart:k=>k.preventDefault(),onKeyDown:k=>{k.key!=="ArrowUp"&&k.key!=="ArrowDown"||(k.preventDefault(),k.stopPropagation(),o(k.key==="ArrowUp"?-1:1))},onPointerDown:x,onPointerMove:k=>{!h.current||k.pointerId!==h.current.pointerId||(k.preventDefault(),k.stopPropagation(),C(k.clientX,k.clientY))},onPointerUp:k=>{!h.current||k.pointerId!==h.current.pointerId||(k.preventDefault(),k.stopPropagation(),_(!0))},onPointerCancel:()=>_(!1),onLostPointerCapture:()=>{h.current&&_(!1)},children:"↕"})}const ah="nc_pins";function E0(){try{const e=JSON.parse(localStorage.getItem(ah));return Array.isArray(e)?e:[]}catch{return[]}}function N0(e,t){const i=e.includes(t)?e.filter(s=>s!==t):[...e,t];try{localStorage.setItem(ah,JSON.stringify(i))}catch{}return i}function R0(e,t,i){if(!e.includes(t)||!e.includes(i)||t===i)return e;const s=[...e],o=s.indexOf(t),a=s.indexOf(i);s.splice(o,1);const c=s.indexOf(i);s.splice(o<a?c+1:c,0,t);try{localStorage.setItem(ah,JSON.stringify(s))}catch{}return s}function P0(e,t,i){const s=e.indexOf(t);return[s===-1?1e9:s,-(i||0)]}function D0(e,t){return e[0]-t[0]||e[1]-t[1]}function Xv(){const[e,t]=R.useState(E0),[i,s]=R.useState(y0),[o,a]=R.useState(g0),c=_=>t(C=>N0(C,_)),h=_=>ym(i,_),m=(_,C)=>s(w=>{const x={...w,[_]:{...ym(w,_),...C}};return S0(x)}),p=(_,C)=>e.includes(_)===e.includes(C);function y(_,C,w,x){const k=e.includes(C),b=e.includes(w);if(k===b){if(k){t(D=>R0(D,C,w));return}a(D=>{var te;const L=((te=x.find(U=>U.key===C))==null?void 0:te.technical)===!0,M=wr(x,e,L?"technical":"all",Qn(D,_)).map(U=>U.key);return v0(_0(D,_,C,w,M))})}}function S(_,C,w,x){var te;const k=((te=x.find(U=>U.key===C))==null?void 0:te.technical)===!0,b=e.includes(C),D=wr(x,e,k?"technical":"all",Qn(o,_)).map(U=>U.key).filter(U=>e.includes(U)===b),L=D.indexOf(C),M=D[L+w];L>=0&&M&&y(_,C,M,x)}return{pins:e,views:i,orders:o,togglePin:c,viewFor:h,updateView:m,canMoveRoster:p,moveRoster:y,stepRoster:S}}const Gv="nc_node_order_v1",j0=/^[a-f0-9]{16,64}$/;function yr(e){if(j0.test(String((e==null?void 0:e.instanceId)||"")))return`id:${e.instanceId}`;const t=Array.isArray(e==null?void 0:e.route)?e.route.filter(i=>typeof i=="string"&&i):[];return t.length?`route:${t.map(encodeURIComponent).join("/")}`:typeof(e==null?void 0:e.name)=="string"&&e.name?`name:${encodeURIComponent(e.name)}`:""}function Em(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Gv));return Array.isArray(t)?[...new Set(t.filter(i=>typeof i=="string"&&i&&i.length<=192))].slice(0,128):[]}catch{return[]}}function M0(e,t=globalThis.localStorage){try{t.setItem(Gv,JSON.stringify(e))}catch{}return e}function Nm(e=[],t=[]){const i=new Map(t.map((s,o)=>[s,o]));return e.map((s,o)=>({group:s,index:o})).sort((s,o)=>{const a=i.has(yr(s.group))?i.get(yr(s.group)):Number.MAX_SAFE_INTEGER,c=i.has(yr(o.group))?i.get(yr(o.group)):Number.MAX_SAFE_INTEGER;return a-c||s.index-o.index}).map(({group:s})=>s)}function L0(e,t,i,s=[]){if(!t||!i||t===i)return e;const o=s.map(yr).filter(Boolean);if(!o.includes(t)||!o.includes(i))return e;const a=[...e.filter(p=>o.includes(p)),...o.filter(p=>!e.includes(p))],c=a.indexOf(t),h=a.indexOf(i);a.splice(c,1);const m=a.indexOf(i);return a.splice(c<h?m+1:m,0,t),a}const id="nexuscrew-node-preferences";function T0(){try{window.dispatchEvent(new Event(id))}catch{}}function Qv(){const[e,t]=R.useState(Em);R.useEffect(()=>{const a=()=>t(Em());return window.addEventListener("storage",a),window.addEventListener(id,a),()=>{window.removeEventListener("storage",a),window.removeEventListener(id,a)}},[]);const i=a=>Nm(a,e),s=(a,c,h)=>t(m=>{const p=L0(m,a,c,h);return M0(p),T0(),p});return{order:e,groupsFor:i,moveNode:s,stepNode:(a,c,h)=>{const m=Nm(h,e).map(yr),p=m.indexOf(a),y=m[p+c];p>=0&&y&&s(a,y,h)},nodeKey:yr}}function ls(e,t=Math.floor(Date.now()/1e3)){if(!e)return"";const i=t-e;return i<0||i<60?"ora":i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}g`}function ss(e){return e.status==="passive"?v("node-passive"):e.status==="down"?e.downSince?v("tunnel-down-since").replace("{t}",ls(e.downSince)):v("tunnel-down"):e.status==="unreachable"?v("node-unreachable"):e.status==="offline"?e.lastSeen?v("node-offline-seen").replace("{t}",ls(e.lastSeen)):v("node-offline"):e.status==="needs-repair"?v("node-needs-repair"):""}function Jv(e,{passive:t=null}={}){return e?e.status==="passive"?t:e.status==="healthy"?"on":"warn":null}function sl(e){return e&&(e.detail||e.status)||""}function ol(e,t,i=globalThis.localStorage){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const s=Number(i.getItem(Tv(t))||0);return e.outbox.latest>s}function Zv(e,t={}){const i=e||{};if(!i.tmux){const s=`${i.engine||""}${i.key?`·${i.key}`:""}`,o=[s,i.model&&i.model!==s?i.model:""].filter(Boolean).join(" · ");return{working:!1,subtitle:String(o||v("cell-off")).trim()}}if(t.working===!0){const s=v("cell-working"),o=String(t.status||"").trim();return{working:!0,subtitle:!o||/^working(?:\.{3}|…)?$/i.test(o)?s:`${s} · ${o}`}}return t.working===!1?{working:!1,subtitle:v("cell-idle")}:{working:!1,subtitle:String(t.preview||i.preview||v("cell-on")).trim()}}function e_(e,t){return[...new Set([e.engine,e.model,e.key,t.preview,e.preview,t.status].filter(Boolean).map(String))].join(" ")}function t_(e,t,i,s=globalThis.localStorage){return[...(Array.isArray(e)?e:[]).map(o=>{const a=i.get(o.tmuxSession)||{},c=rl([],o.tmuxSession),h=Zv(o,a);return{type:"cell",value:o,key:c,label:o.cell,live:!!o.tmux,fresh:ol(a,c,s),activity:a.activity||0,working:h.working,subtitle:h.subtitle,searchText:e_(o,a)}}),...(Array.isArray(t)?t:[]).map(o=>{const a=rl([],o.name);return{type:"session",value:o,key:a,label:o.name,live:!0,technical:o.technical===!0,fresh:ol(o,a,s),activity:o.activity||0,searchText:`${o.preview||""} ${o.cmd||""}`}})]}function nd(e,t=globalThis.localStorage){const i=e||{},s=Array.isArray(i.route)?i.route:[],o=new Map((i.sessions||[]).map(c=>[c.name,c])),a=[...(i.cells||[]).map(c=>{const h=o.get(c.tmuxSession)||{},m=rl(s,c.tmuxSession||c.cell),p=Zv(c,h);return{type:"cell",value:c,key:m,label:c.cell,live:!!c.tmux,fresh:ol(h,m,t),activity:h.activity||c.activity||0,working:p.working,subtitle:p.subtitle,searchText:e_(c,h)}}),...(i.unmanaged||[]).map(c=>{const h=rl(s,c.name);return{type:"session",value:c,key:h,label:c.name,live:!0,technical:c.technical===!0,fresh:ol(c,h,t),activity:c.activity||0,searchText:`${c.preview||""} ${c.cmd||""}`}})];return{route:s,rawItems:a}}const lh=9,al=.2,A0=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,cs=/^[a-f0-9]{16,64}$/,rd=e=>A0.test(e)&&new Set(e.split("/")).size===e.split("/").length;function er(e){if(typeof e=="string"&&e){const t=e.indexOf(":");if(t<0)return{session:e};const i=e.slice(0,t),s=e.slice(t+1);return!rd(i)||!s?null:{session:s,node:i}}if(e&&typeof e=="object"&&typeof e.session=="string"&&e.session){const t=e.ownerId===void 0?void 0:typeof e.ownerId=="string"&&cs.test(e.ownerId)?e.ownerId:null;return t===null?null:e.node===void 0||e.node===null||e.node===""?{session:e.session,...t?{ownerId:t}:{}}:typeof e.node=="string"&&rd(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function Ni(e){const t=er(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const i_=9,n_=24,bo=11,I0=e=>{const t=Number(e);return t>=i_&&t<=n_?t:bo};function os(){return{columns:[]}}function ln(e){return e.columns.flatMap(t=>t.tiles.map(i=>Ni(i)))}function B0(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(Ni(o.tiles[s]));return t}const hs=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))});function ch(e,t,i,s){const o=er(t);if(!o||ln(e).includes(Ni(o))||ln(e).length>=lh)return e;const a=hs(e),c={session:o.session,height:1,fontSize:bo,...s||{}};if(o.node&&(c.node=o.node),o.ownerId&&(c.ownerId=o.ownerId),i==="end")return a.columns.push({width:1,tiles:[c]}),a;if(i&&typeof i.col=="number"&&typeof i.row=="number"&&a.columns[i.col])return a.columns[i.col].tiles.splice(i.row,0,c),a;if(i&&typeof i.col=="number"){const h=Math.max(0,Math.min(a.columns.length,i.col));return a.columns.splice(h,0,{width:1,tiles:[c]}),a}return a.columns.push({width:1,tiles:[c]}),a}function r_(e,t){const i=Ni(t);if(!i||ln(e).includes(i)||ln(e).length>=lh)return e;const s=ln(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let y=0;for(let S=1;S<e.columns.length;S+=1)e.columns[S].tiles.length<e.columns[y].tiles.length&&(y=S);return ch(e,t,{col:y,row:e.columns[y].tiles.length})}const a=[...B0(e),i],c=new Map(e.columns.flatMap(y=>y.tiles.map(S=>[Ni(S),S]))),h=er(t),m=e.columns.length?e.columns.reduce((y,S)=>y+(Number(S.width)||1),0)/e.columns.length:1,p=Array.from({length:o},(y,S)=>{var _;return{width:((_=e.columns[S])==null?void 0:_.width)||m,tiles:[]}});return a.forEach((y,S)=>{const _=er(y);if(!_)return;const C=c.get(y)||(y===i?h:{})||{},w={session:_.session,height:C.height||1,fontSize:C.fontSize||bo};_.node&&(w.node=_.node),C.ownerId&&(w.ownerId=C.ownerId),C.unavailable===!0&&(w.unavailable=!0),p[S%o].tiles.push(w)}),{columns:p.filter(y=>y.tiles.length)}}function ll(e,t){const i=Ni(t),s=hs(e);for(const o of s.columns)o.tiles=o.tiles.filter(a=>Ni(a)!==i);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function O0(e,t,i){const s=Ni(t);if(!ln(e).includes(s))return e;const o=e.columns.flatMap(a=>a.tiles).find(a=>Ni(a)===s);return ch(ll(e,s),s,i,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function z0(e,t){if(!(t instanceof Map)||t.size===0)return e;let i=!1;const s=hs(e);for(const o of s.columns)for(const a of o.tiles){const c=t.get(Ni(a));if(!c)continue;const h=er(c);h&&(a.session=h.session,h.node?a.node=h.node:delete a.node,h.ownerId&&(a.ownerId=h.ownerId),i=!0)}return i?br(s):e}function F0(e,t,i){const s=hs(e);return s.columns[t]&&(s.columns[t].width=Math.max(al,Number(i)||1)),s}function H0(e,t,i,s){const o=hs(e),a=o.columns[t]&&o.columns[t].tiles[i];return a&&(a.height=Math.max(al,Number(s)||1)),o}function $0(e,t,i,s){if(!(e.columns[t]&&e.columns[t].tiles[i]))return e;const a=hs(e),c=a.columns[t].tiles[i],h=Number(c.fontSize)||bo;return c.fontSize=Math.max(i_,Math.min(n_,h+(Number(s)||0))),a}function W0(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 Rm(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function br(e){if(!e||!Array.isArray(e.columns))return os();const t=e.columns.map(s=>({width:Math.max(al,Number(s&&s.width)||1),tiles:(Array.isArray(s&&s.tiles)?s.tiles:[]).filter(o=>o&&typeof o.session=="string"&&o.session).filter(o=>o.node==null||typeof o.node=="string"&&rd(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&cs.test(o.ownerId)).map(o=>{const a={session:o.session,height:Math.max(al,Number(o.height)||1),fontSize:I0(o.fontSize)};return o.node!=null&&(a.node=o.node),o.ownerId!=null&&(a.ownerId=o.ownerId),o.unavailable===!0&&(a.unavailable=!0),a})})).filter(s=>s.tiles.length>0),i=new Set;for(const s of t)s.tiles=s.tiles.filter(o=>!i.has(Ni(o))&&i.add(Ni(o))&&i.size<=lh);return{columns:t.filter(s=>s.tiles.length>0)}}const s_=/^[a-z0-9-]{1,32}$/,U0=/^[A-Za-z0-9._-]{1,32}$/,K0=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,q0=320;function sd(e){return typeof e=="string"&&s_.test(e)}const V0=64;function vo(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=V0&&!/[\x00-\x1f\x7f]/.test(t)}function Jn(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function o_(e){if(typeof e!="string"||!e||e.length>q0||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:U0.test(e.slice(0,t))&&K0.test(e.slice(t+1))}function Pm(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 Dm({name:e,ssh:t,sshPort:i,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,a=typeof t=="string"?t.trim():t;if(!sd(o))return{ok:!1,error:"err-node-name"};if(!o_(a))return{ok:!1,error:"err-ssh"};const c=Pm(i);if(c===void 0)return{ok:!1,error:"err-ssh-port"};const h=Pm(s);if(h===void 0)return{ok:!1,error:"err-node-port"};const m={name:o,ssh:a};return c!==null&&(m.sshPort=c),h!==null&&(m.remotePort=h),{ok:!0,value:m}}function Y0(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 jm(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?Y0(e.since,t):null}}const X0=new Set(["v","instanceId","port","label","invite"]),G0=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function Q0(e){const t=String(e).replace(/-/g,"+").replace(/_/g,"/"),i=t+"=".repeat((4-t.length%4)%4),s=typeof atob=="function"?atob(i):Buffer.from(i,"base64").toString("binary"),o=Uint8Array.from(s,a=>a.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function J0(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(Q0(t))}catch{return{ok:!1}}if(!i||typeof i!="object"||Array.isArray(i))return{ok:!1};const s=i.v===1?X0:i.v===2?G0: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 a={ok:!0,version:i.v,label:i.label,invite:i.invite,instanceId:i.instanceId,port:o};if(i.v===2){if(i.name!==void 0){if(typeof i.name!="string"||!s_.test(i.name))return{ok:!1};a.name=i.name}if(i.ssh!==void 0){if(!o_(i.ssh))return{ok:!1};a.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};a.sshPort=c}}return a}function Z0(e,t,i=new Set){if(!t||!t.ok)return e;const s={...e},o=(a,c)=>{c==null||c===""||i.has(a)||(s[a]=c)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?Jn(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}const Jr=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function eb({onPick:e,token:t,onSettings:i}){const[s,o]=Pi(),a=oh(t),[c,h]=R.useState(null),[m,p]=R.useState(null),[y,S]=R.useState(""),[_,C]=R.useState(""),[w,x]=R.useState({bind:"127.0.0.1",port:""}),[k,b]=R.useState(""),[D,L]=R.useState([]),[M,te]=R.useState([]),[U,O]=R.useState({}),[ee,q]=R.useState(new Set),[J,Q]=R.useState(null),[T,N]=R.useState(null),{pins:P,orders:I,togglePin:$,viewFor:K,updateView:F,canMoveRoster:ae,moveRoster:W,stepRoster:j}=Xv(),{groupsFor:A,moveNode:se,stepNode:ge,nodeKey:G}=Qv(),Z=A(a);R.useEffect(()=>{const z=new Map;for(const H of D)z.set(Jr(H.cell),!!H.boot);for(const H of a){const re=H.route||[H.name];for(const me of H.cells||[])z.set(Jr(me.cell,re),!!me.boot)}O(H=>{let re=!1;const me={...H};for(const[Ae,Se]of Object.entries(H))z.has(Ae)&&z.get(Ae)===Se&&(delete me[Ae],re=!0);return re?me:H})},[D,a]);async function ue(){try{const H=await(await qt("/api/sessions",t)).json();H.error?(p(H.error),h([])):(p(null),h(H.sessions||[]))}catch(z){p(String(z)),h([])}try{const z=await Er(t);L(z.available?z.cells||[]:[]),te(z.available?z.capabilities||[]:[])}catch{L([]),te([])}}R.useEffect(()=>{ue(),qt("/api/config",t).then(H=>H.json()).then(H=>{C(H.version||""),x({bind:H.bind||"127.0.0.1",port:H.port||""}),b(cs.test(String(H.instanceId||""))?H.instanceId:"")}).catch(()=>{});const z=setInterval(ue,4e3);return()=>clearInterval(z)},[]);async function de(){if(!w.port)return;const z=`http://${w.bind}:${w.port}/#token=${t}`;try{await navigator.clipboard.writeText(z)}catch{}}function Ce(z,H,re){const me=Jr(z,H);O(Ae=>({...Ae,[me]:!!re}))}function Re(z,H=[]){const re=Jr(z.cell,H);return Object.prototype.hasOwnProperty.call(U,re)?U[re]:!!z.boot}async function tt(z,H,re=[]){z.stopPropagation();const me=Jr(H.cell,re),Ae=!Re(H,re);Ce(H.cell,re,Ae),q(Se=>new Set(Se).add(me));try{await Av(t,{cell:H.cell,enabled:Ae},re),re.length||L(Se=>Se.map(xe=>xe.cell===H.cell?{...xe,boot:Ae}:xe))}catch(Se){O(xe=>{const He={...xe};return delete He[me],He}),p(String((Se==null?void 0:Se.message)||Se))}finally{q(Se=>{const xe=new Set(Se);return xe.delete(me),xe})}}async function Je(z){if(!J)return;const{cell:H}=J,re=Array.isArray(J.route)?J.route:[];z.action==="up"?(await eh(t,{cell:H,boot:!!z.boot,...z.engine?{engine:z.engine}:{},...z.model!==void 0?{model:z.model}:{},...z.permissionPolicy?{permissionPolicy:z.permissionPolicy}:{}},re),Ce(H,re,!!z.boot)):(await il(t,{cell:H,boot:!!z.boot},re),z.boot&&Ce(H,re,!1)),ue()}async function Ee(z,H=[]){try{await ih(t,z,H)}catch{return}ue()}async function rt(z,H,re=[]){try{await Bv(t,z,H,re)}catch{return}ue()}async function wt(z){if(!(!(z!=null&&z.direct)||T)){N(z.name);try{await rh(t,z.name,z.tunnelStatus==="up"?"down":"up")}catch{}N(null)}}async function Dt(z){if(!(z!=null&&z.direct))return;const H=window.prompt(v("rename-node-prompt"),z.label||z.name);if(H===null)return;const re=String(H).trim();if(!vo(re)){window.alert(v("rename-node-invalid"));return}try{await $v(t,z.name,re)}catch(me){window.alert(String((me==null?void 0:me.message)||me))}}const st=R.useMemo(()=>new Map((c||[]).map(z=>[z.name,z])),[c]),gt=R.useMemo(()=>new Set(D.map(z=>z.tmuxSession)),[D]),ct=R.useMemo(()=>(c||[]).filter(z=>!gt.has(z.name)),[c,gt]),at=R.useMemo(()=>t_(D,ct,st),[D,ct,st]),le=K("local"),be=R.useMemo(()=>wr(at,P,le.filter,Qn(I,"local")).filter(z=>Sm(z,y)),[at,P,le.filter,y,I]),Fe=Z.reduce((z,H)=>z+(H.cells||[]).length+(H.unmanaged||[]).filter(re=>!re.technical).length,0),$e=wr(at,P,"all",Qn(I,"local")).length+Fe,pe=at.filter(z=>z.live).length+Z.reduce((z,H)=>z+nd(H).rawItems.filter(re=>re.live).length,0),Be=(c||[]).filter(z=>z.attached).length+Z.reduce((z,H)=>z+(H.sessions||[]).filter(re=>re.attached).length,0),Te=Math.min(Be,pe),Y=w.port?`${w.bind}:${w.port}`:w.bind;function ne(z,H=null,re=at){var Di,Et;const me=Array.isArray(H==null?void 0:H.route)?H.route:[],Ae=me.join("/"),Se=Ae||"local",xe=me.length?H==null?void 0:H.instanceId:k,He=Ve=>e({session:Ve,...Ae?{node:Ae}:{},...cs.test(String(xe||""))?{ownerId:xe}:{}}),Zt=ae;if(z.type==="cell"){const Ve=z.value,ji=me.length?((H==null?void 0:H.sessions)||[]).find(Si=>Si.name===Ve.tmuxSession):st.get(Ve.tmuxSession),he=Ve.degraded?v("cell-degraded"):z.working?z.subtitle:Ve.tmux?v("cell-idle"):v("cell-off"),De=me.length===0||((H==null?void 0:H.capabilities)||[]).includes(Ve.active?"down":"up"),qe=me.length===0?M.includes("boot"):((H==null?void 0:H.capabilities)||[]).includes("boot"),bt=Re(Ve,me),si=Jr(Ve.cell,me),gs=`${v(bt?"boot-disable":"boot-enable")} ${Ve.cell}`;return u.jsxs("div",{className:"nc-mcard","data-roster-key":z.key,"data-position":Se,children:[u.jsx(Xn,{position:Se,itemKey:z.key,label:Ve.cell,canMove:Zt,onMove:(Si,vs)=>W(Se,Si,vs,re),onStep:Si=>j(Se,z.key,Si,re)}),u.jsxs("button",{className:"nc-mcard-main",onClick:()=>Ve.tmux&&He(Ve.tmuxSession),title:he,"aria-label":`${Ve.cell}, ${he}`,children:[u.jsx("span",{className:`dot ${Ve.degraded?"warn":Ve.tmux?`on${z.working?" working":""}`:""}`}),u.jsxs("span",{className:"nc-mcard-text",children:[u.jsx("b",{children:Ve.cell}),u.jsx("small",{title:z.subtitle,children:z.subtitle})]})]}),z.activity?u.jsx("span",{className:"nc-rel",children:ls(z.activity)}):null,z.fresh&&((Di=ji==null?void 0:ji.outbox)==null?void 0:Di.count)>0&&u.jsx("span",{className:"nc-badge",title:v("new-files-outbox"),children:ji.outbox.count}),u.jsx("button",{className:`nc-act pin${P.includes(z.key)?" on":""}`,"aria-label":`${v("pin")} ${Ve.cell}`,title:v("pin"),onClick:()=>$(z.key),children:P.includes(z.key)?"★":"☆"}),qe&&u.jsx("button",{className:`nc-act boot${bt?" on":""}`,disabled:ee.has(si),onClick:Si=>tt(Si,Ve,me),title:gs,"aria-label":gs,children:u.jsx(et,{name:"boot",size:16})}),De&&u.jsx("button",{className:`nc-act power${Ve.tmux?" on":""}${Ve.degraded?" warn":""}`,onClick:()=>Q(me.length?{...Ve,boot:bt,route:me,availableEngines:(H==null?void 0:H.engines)||[]}:{...Ve,boot:bt}),title:Ve.active?v("power-off"):v("power-on"),"aria-label":`${Ve.active?v("power-off"):v("power-on")} ${Ve.cell}`,children:u.jsx(et,{name:"power",size:16})})]},z.key)}const Xe=z.value;return u.jsxs("div",{className:"nc-mcard","data-roster-key":z.key,"data-position":Se,children:[u.jsx(Xn,{position:Se,itemKey:z.key,label:Xe.name,canMove:Zt,onMove:(Ve,ji)=>W(Se,Ve,ji,re),onStep:Ve=>j(Se,z.key,Ve,re)}),u.jsxs("button",{className:"nc-mcard-main",onClick:()=>He(Xe.name),children:[u.jsx("span",{className:Xe.attached?"dot on":"dot"}),u.jsxs("span",{className:"nc-mcard-text",children:[u.jsx("b",{children:Xe.name}),u.jsx("small",{children:Xe.preview?Xe.preview:Xe.cmd?Xe.cmd:v("windows").replace("{n}",String(Xe.windows||0))})]})]}),z.activity?u.jsx("span",{className:"nc-rel",children:ls(z.activity)}):null,z.fresh&&((Et=Xe.outbox)==null?void 0:Et.count)>0&&u.jsx("span",{className:"nc-badge",title:v("new-files-outbox"),children:Xe.outbox.count}),u.jsx("button",{className:`nc-act pin${P.includes(z.key)?" on":""}`,"aria-label":`${v("pin")} ${Xe.name}`,title:v("pin"),onClick:()=>$(z.key),children:P.includes(z.key)?"★":"☆"}),u.jsx("button",{className:`nc-act technical${Xe.technical?" on":""}`,title:Xe.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${Xe.technical?v("mark-normal"):v("mark-technical")} ${Xe.name}`,onClick:()=>rt(Xe.name,!Xe.technical,me),children:"T"}),u.jsx("button",{className:"nc-menu",title:v("terminate"),"aria-label":`${v("terminate")} ${Xe.name}`,onClick:()=>{window.confirm(v("terminate-confirm").replace("{name}",Xe.name))&&Ee(Xe.name,me)},children:"⋯"})]},z.key)}return u.jsxs("div",{className:"nc-home",children:[u.jsxs("header",{className:"nc-home-head",children:[u.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",u.jsx("span",{className:"nc-cursor"})]}),u.jsxs("div",{className:"nc-home-sub",children:[v("fleet-tmux")," · ",pe," ",v("sessions"),Te>0&&` · ${Te} attached`]}),u.jsxs("span",{className:"nc-head-actions",children:[u.jsx("button",{className:"nc-refresh",onClick:()=>i("nodes",!1),title:v("settings"),children:u.jsx(et,{name:"gear",size:18})}),u.jsx("button",{className:"nc-refresh",onClick:ue,title:v("refresh"),children:u.jsx(et,{name:"refresh",size:18})})]})]}),u.jsxs("main",{className:"nc-home-scroll",children:[$e>8&&u.jsx("input",{className:"nc-filter",type:"search",placeholder:v("filter-placeholder"),"aria-label":v("filter-placeholder"),value:y,onChange:z=>S(z.target.value)}),m&&u.jsx("div",{className:"nc-err",children:m}),u.jsxs("section",{className:"nc-group","data-position":"local",children:[u.jsx(Mm,{label:v("position-local"),count:be.length,state:le,dotClass:"on",onToggle:()=>F("local",{open:!le.open}),onFilter:z=>F("local",{filter:z})}),le.open&&be.map(z=>ne(z,null,at)),le.open&&c===null&&u.jsx("div",{className:"nc-empty",children:v("loading-fleet")}),le.open&&c!==null&&be.length===0&&!m&&u.jsx("div",{className:"nc-empty",children:y?v("no-match").replace("{q}",y):v("no-sessions-short")})]}),Z.map(z=>{const re=Jv(z.health,{passive:"warn"})||(z.status==="up"?"on":z.status==="passive"?"":"warn"),me=z.health?sl(z.health):z.status==="up"?"":ss(z),Se=(z.route||[z.name]).join("/"),xe=K(Se),{rawItems:He}=nd(z),Zt=wr(He,P,xe.filter,Qn(I,Se)).filter(Et=>Sm(Et,y)),Xe=z.direct&&z.health&&z.health.managed!==!1?u.jsx("button",{type:"button",className:`nc-act power${z.tunnelStatus==="up"?" on":""}`,disabled:T===z.name,title:z.tunnelStatus==="up"?v("power-off"):v("power-on"),"aria-label":`${z.tunnelStatus==="up"?v("power-off"):v("power-on")} ${z.label||z.name}`,onClick:()=>wt(z),children:u.jsx(et,{name:"power",size:15})}):null,Di=u.jsxs("span",{className:"nc-node-actions",children:[u.jsx(Xn,{scope:"node",position:"nodes",itemKey:G(z),label:z.label||z.name,onMove:(Et,Ve)=>se(Et,Ve,a),onStep:Et=>ge(G(z),Et,a)}),z.direct&&u.jsx("button",{type:"button",className:"nc-node-rename",title:v("rename-node"),"aria-label":`${v("rename-node")} ${z.label||z.name}`,onClick:()=>Dt(z),children:"✎"}),Xe]});return u.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":Se,"data-node-order-key":G(z),children:[u.jsx(Mm,{label:z.label||z.name,count:Zt.length,state:xe,dotClass:re,dotTitle:me,detail:z.status==="up"?"":z.health&&sl(z.health)||ss(z),onToggle:()=>F(Se,{open:!xe.open}),onFilter:Et=>F(Se,{filter:Et}),onRename:z.direct?()=>Dt(z):null,action:Di}),z.status==="up"&&xe.open&&Zt.map(Et=>ne(Et,z,He)),z.status==="up"&&xe.open&&Zt.length===0&&u.jsx("div",{className:"nc-empty",children:y?v("no-match").replace("{q}",y):v("no-sessions-short")})]},`nodo-${Se}`)}),u.jsxs("footer",{className:"nc-home-foot",onClick:de,title:v("copy-url"),children:[u.jsxs("span",{className:"nc-home-meta",children:[_&&u.jsxs("span",{className:"nc-home-version",children:["v",_]}),u.jsxs("span",{className:"nc-home-endpoint",children:[Y," · ",v("ssh-only")]})]}),u.jsx("span",{className:"nc-lang",onClick:z=>z.stopPropagation(),children:Yv.map((z,H)=>u.jsxs("span",{children:[H>0&&" · ",u.jsx("button",{className:`nc-lang-btn${s===z?" on":""}`,onClick:()=>o(z),title:z,children:z.toUpperCase()})]},z))})]})]}),u.jsx("button",{className:"nc-fab",onClick:()=>i("fleet",!0),title:v("fleet-new-cell"),"aria-label":v("fleet-new-cell"),children:"+"}),J&&u.jsx(nl,{cell:J,token:t,route:Array.isArray(J.route)?J.route:[],onConfirm:Je,onClose:()=>Q(null)})]})}function Mm({label:e,count:t,state:i,dotClass:s="",dotTitle:o="",detail:a="",onToggle:c,onFilter:h,onRename:m=null,action:p=null}){return u.jsxs("div",{className:"nc-mobile-position-head",onContextMenu:m?y=>{y.preventDefault(),m()}:void 0,children:[u.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:c,"aria-expanded":i.open,"aria-label":`${e} · ${v("node-sessions").replace("{n}",String(t))}`,children:[u.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:i.open?"⌄":"›"}),u.jsx("span",{className:`dot ${s}`,title:o}),u.jsxs("span",{className:"nc-mobile-position-copy",children:[u.jsx("b",{children:e}),u.jsx("small",{children:a||v("node-sessions").replace("{n}",String(t))})]})]}),u.jsxs("select",{className:"nc-mobile-position-filter",value:i.filter,"aria-label":`${e} · ${v("filter-placeholder")}`,title:v(`view-${i.filter}`),onChange:y=>h(y.target.value),children:[u.jsx("option",{value:"all",children:v("view-all")}),u.jsx("option",{value:"pinned",children:v("view-pinned")}),u.jsx("option",{value:"active",children:v("view-active")}),u.jsx("option",{value:"off",children:v("view-off")}),u.jsx("option",{value:"technical",children:v("view-technical")})]}),p]})}/**
|
|
41
|
-
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
42
|
-
* @license MIT
|
|
43
|
-
*
|
|
44
|
-
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
45
|
-
* @license MIT
|
|
46
|
-
*
|
|
47
|
-
* Originally forked from (with the author's permission):
|
|
48
|
-
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
49
|
-
* http://bellard.org/jslinux/
|
|
50
|
-
* Copyright (c) 2011 Fabrice Bellard
|
|
51
|
-
*/var a_=Object.defineProperty,tb=Object.getOwnPropertyDescriptor,ib=(e,t)=>{for(var i in t)a_(e,i,{get:t[i],enumerable:!0})},xt=(e,t,i,s)=>{for(var o=s>1?void 0:s?tb(t,i):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(o=(s?c(t,i,o):c(o))||o);return s&&o&&a_(t,i,o),o},Ne=(e,t)=>(i,s)=>t(i,s,e),Lm="Terminal input",od={get:()=>Lm,set:e=>Lm=e},Tm="Too much output to announce, navigate to rows manually to read",ad={get:()=>Tm,set:e=>Tm=e};function nb(e){return e.replace(/\r?\n/g,"\r")}function rb(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function sb(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function ob(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");l_(o,t,i,s)}}function l_(e,t,i,s){e=nb(e),e=rb(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function c_(e,t,i){let s=i.getBoundingClientRect(),o=e.clientX-s.left-10,a=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${a}px`,t.style.zIndex="1000",t.focus()}function Am(e,t,i,s,o){c_(e,t,i),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Yn(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function vl(e,t=0,i=e.length){let s="";for(let o=t;o<i;++o){let a=e[o];a>65535?(a-=65536,s+=String.fromCharCode((a>>10)+55296)+String.fromCharCode(a%1024+56320)):s+=String.fromCharCode(a)}return s}var ab=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,o=0;if(this._interim){let a=e.charCodeAt(o++);56320<=a&&a<=57343?t[s++]=(this._interim-55296)*1024+a-56320+65536:(t[s++]=this._interim,t[s++]=a),this._interim=0}for(let a=o;a<i;++a){let c=e.charCodeAt(a);if(55296<=c&&c<=56319){if(++a>=i)return this._interim=c,s;let h=e.charCodeAt(a);56320<=h&&h<=57343?t[s++]=(c-55296)*1024+h-56320+65536:(t[s++]=c,t[s++]=h);continue}c!==65279&&(t[s++]=c)}return s}},lb=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,o,a,c,h,m=0,p=0;if(this.interim[0]){let _=!1,C=this.interim[0];C&=(C&224)===192?31:(C&240)===224?15:7;let w=0,x;for(;(x=this.interim[++w]&63)&&w<4;)C<<=6,C|=x;let k=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,b=k-w;for(;p<b;){if(p>=i)return 0;if(x=e[p++],(x&192)!==128){p--,_=!0;break}else this.interim[w++]=x,C<<=6,C|=x&63}_||(k===2?C<128?p--:t[s++]=C:k===3?C<2048||C>=55296&&C<=57343||C===65279||(t[s++]=C):C<65536||C>1114111||(t[s++]=C)),this.interim.fill(0)}let y=i-4,S=p;for(;S<i;){for(;S<y&&!((o=e[S])&128)&&!((a=e[S+1])&128)&&!((c=e[S+2])&128)&&!((h=e[S+3])&128);)t[s++]=o,t[s++]=a,t[s++]=c,t[s++]=h,S+=4;if(o=e[S++],o<128)t[s++]=o;else if((o&224)===192){if(S>=i)return this.interim[0]=o,s;if(a=e[S++],(a&192)!==128){S--;continue}if(m=(o&31)<<6|a&63,m<128){S--;continue}t[s++]=m}else if((o&240)===224){if(S>=i)return this.interim[0]=o,s;if(a=e[S++],(a&192)!==128){S--;continue}if(S>=i)return this.interim[0]=o,this.interim[1]=a,s;if(c=e[S++],(c&192)!==128){S--;continue}if(m=(o&15)<<12|(a&63)<<6|c&63,m<2048||m>=55296&&m<=57343||m===65279)continue;t[s++]=m}else if((o&248)===240){if(S>=i)return this.interim[0]=o,s;if(a=e[S++],(a&192)!==128){S--;continue}if(S>=i)return this.interim[0]=o,this.interim[1]=a,s;if(c=e[S++],(c&192)!==128){S--;continue}if(S>=i)return this.interim[0]=o,this.interim[1]=a,this.interim[2]=c,s;if(h=e[S++],(h&192)!==128){S--;continue}if(m=(o&7)<<18|(a&63)<<12|(c&63)<<6|h&63,m<65536||m>1114111)continue;t[s++]=m}}return s}},u_="",Gn=" ",ko=class d_{constructor(){this.fg=0,this.bg=0,this.extended=new cl}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new d_;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},cl=class h_{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 h_(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Hi=class f_ extends ko{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new cl,this.combinedData=""}static fromCharData(t){let i=new f_;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Yn(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(s-55296)*1024+o-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Im="di$target",ld="di$dependencies",du=new Map;function cb(e){return e[ld]||[]}function Yt(e){if(du.has(e))return du.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");ub(t,i,o)};return t._id=e,du.set(e,t),t}function ub(e,t,i){t[Im]===t?t[ld].push({id:e,index:i}):(t[ld]=[{id:e,index:i}],t[Im]=t)}var ci=Yt("BufferService"),p_=Yt("CoreMouseService"),Nr=Yt("CoreService"),db=Yt("CharsetService"),uh=Yt("InstantiationService"),m_=Yt("LogService"),ui=Yt("OptionsService"),g_=Yt("OscLinkService"),hb=Yt("UnicodeService"),Co=Yt("DecorationService"),cd=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var y;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,a=new Hi,c=i.getTrimmedLength(),h=-1,m=-1,p=!1;for(let S=0;S<c;S++)if(!(m===-1&&!i.hasContent(S))){if(i.loadCell(S,a),a.hasExtendedAttrs()&&a.extended.urlId)if(m===-1){m=S,h=a.extended.urlId;continue}else p=a.extended.urlId!==h;else m!==-1&&(p=!0);if(p||m!==-1&&S===c-1){let _=(y=this._oscLinkService.getLinkData(h))==null?void 0:y.uri;if(_){let C={start:{x:m+1,y:e},end:{x:S+(!p&&S===c-1?1:0),y:e}},w=!1;if(!(o!=null&&o.allowNonHttpProtocols))try{let x=new URL(_);["http:","https:"].includes(x.protocol)||(w=!0)}catch{w=!0}w||s.push({text:_,range:C,activate:(x,k)=>o?o.activate(x,k,C):fb(x,k),hover:(x,k)=>{var b;return(b=o==null?void 0:o.hover)==null?void 0:b.call(o,x,k,C)},leave:(x,k)=>{var b;return(b=o==null?void 0:o.leave)==null?void 0:b.call(o,x,k,C)}})}p=!1,a.hasExtendedAttrs()&&a.extended.urlId?(m=S,h=a.extended.urlId):(m=-1,h=-1)}}t(s)}};cd=xt([Ne(0,ci),Ne(1,ui),Ne(2,g_)],cd);function fb(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
52
|
-
|
|
53
|
-
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var _l=Yt("CharSizeService"),kn=Yt("CoreBrowserService"),dh=Yt("MouseService"),Cn=Yt("RenderService"),pb=Yt("SelectionService"),v_=Yt("CharacterJoinerService"),fs=Yt("ThemeService"),__=Yt("LinkProviderService"),mb=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Bm.isErrorNoTelemetry(e)?new Bm(e.message+`
|
|
54
|
-
|
|
55
|
-
`+e.stack):new Error(e.message+`
|
|
56
|
-
|
|
57
|
-
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},gb=new mb;function Xa(e){vb(e)||gb.onUnexpectedError(e)}var ud="Canceled";function vb(e){return e instanceof _b?!0:e instanceof Error&&e.name===ud&&e.message===ud}var _b=class extends Error{constructor(){super(ud),this.name=this.message}};function yb(e){return new Error(`Illegal argument: ${e}`)}var Bm=class dd extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof dd)return t;let i=new dd;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},hd=class y_ extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,y_.prototype)}};function xi(e,t=0){return e[e.length-(1+t)]}var Sb;(e=>{function t(a){return a<0}e.isLessThan=t;function i(a){return a<=0}e.isLessThanOrEqual=i;function s(a){return a>0}e.isGreaterThan=s;function o(a){return a===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Sb||(Sb={}));function wb(e,t){let i=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(i,arguments))),o}}var S_;(e=>{function t(M){return M&&typeof M=="object"&&typeof M[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*o(M){yield M}e.single=o;function a(M){return t(M)?M:o(M)}e.wrap=a;function c(M){return M||i}e.from=c;function*h(M){for(let te=M.length-1;te>=0;te--)yield M[te]}e.reverse=h;function m(M){return!M||M[Symbol.iterator]().next().done===!0}e.isEmpty=m;function p(M){return M[Symbol.iterator]().next().value}e.first=p;function y(M,te){let U=0;for(let O of M)if(te(O,U++))return!0;return!1}e.some=y;function S(M,te){for(let U of M)if(te(U))return U}e.find=S;function*_(M,te){for(let U of M)te(U)&&(yield U)}e.filter=_;function*C(M,te){let U=0;for(let O of M)yield te(O,U++)}e.map=C;function*w(M,te){let U=0;for(let O of M)yield*te(O,U++)}e.flatMap=w;function*x(...M){for(let te of M)yield*te}e.concat=x;function k(M,te,U){let O=U;for(let ee of M)O=te(O,ee);return O}e.reduce=k;function*b(M,te,U=M.length){for(te<0&&(te+=M.length),U<0?U+=M.length:U>M.length&&(U=M.length);te<U;te++)yield M[te]}e.slice=b;function D(M,te=Number.POSITIVE_INFINITY){let U=[];if(te===0)return[U,M];let O=M[Symbol.iterator]();for(let ee=0;ee<te;ee++){let q=O.next();if(q.done)return[U,e.empty()];U.push(q.value)}return[U,{[Symbol.iterator](){return O}}]}e.consume=D;async function L(M){let te=[];for await(let U of M)te.push(U);return Promise.resolve(te)}e.asyncToArray=L})(S_||(S_={}));function Cr(e){if(S_.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 bb(...e){return mt(()=>Cr(e))}function mt(e){return{dispose:wb(()=>{e()})}}var w_=class b_{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Cr(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?b_.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)}};w_.DISABLE_DISPOSED_WARNING=!1;var Zn=w_,Qe=class{constructor(){this._store=new Zn,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Qe.None=Object.freeze({dispose(){}});var us=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},bn=typeof window=="object"?window:globalThis,fd=class pd{constructor(t){this.element=t,this.next=pd.Undefined,this.prev=pd.Undefined}};fd.Undefined=new fd(void 0);var yt=fd,Om=class{constructor(){this._first=yt.Undefined,this._last=yt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===yt.Undefined}clear(){let e=this._first;for(;e!==yt.Undefined;){let t=e.next;e.prev=yt.Undefined,e.next=yt.Undefined,e=t}this._first=yt.Undefined,this._last=yt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new yt(e);if(this._first===yt.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!==yt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==yt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==yt.Undefined&&e.next!==yt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===yt.Undefined&&e.next===yt.Undefined?(this._first=yt.Undefined,this._last=yt.Undefined):e.next===yt.Undefined?(this._last=this._last.prev,this._last.next=yt.Undefined):e.prev===yt.Undefined&&(this._first=this._first.next,this._first.prev=yt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==yt.Undefined;)yield e.element,e=e.next}},kb=globalThis.performance&&typeof globalThis.performance.now=="function",Cb=class k_{static create(t){return new k_(t)}constructor(t){this._now=kb&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Jt;(e=>{e.None=()=>Qe.None;function t(T,N){return S(T,()=>{},0,void 0,!0,void 0,N)}e.defer=t;function i(T){return(N,P=null,I)=>{let $=!1,K;return K=T(F=>{if(!$)return K?K.dispose():$=!0,N.call(P,F)},null,I),$&&K.dispose(),K}}e.once=i;function s(T,N,P){return p((I,$=null,K)=>T(F=>I.call($,N(F)),null,K),P)}e.map=s;function o(T,N,P){return p((I,$=null,K)=>T(F=>{N(F),I.call($,F)},null,K),P)}e.forEach=o;function a(T,N,P){return p((I,$=null,K)=>T(F=>N(F)&&I.call($,F),null,K),P)}e.filter=a;function c(T){return T}e.signal=c;function h(...T){return(N,P=null,I)=>{let $=bb(...T.map(K=>K(F=>N.call(P,F))));return y($,I)}}e.any=h;function m(T,N,P,I){let $=P;return s(T,K=>($=N($,K),$),I)}e.reduce=m;function p(T,N){let P,I={onWillAddFirstListener(){P=T($.fire,$)},onDidRemoveLastListener(){P==null||P.dispose()}},$=new ke(I);return N==null||N.add($),$.event}function y(T,N){return N instanceof Array?N.push(T):N&&N.add(T),T}function S(T,N,P=100,I=!1,$=!1,K,F){let ae,W,j,A=0,se,ge={leakWarningThreshold:K,onWillAddFirstListener(){ae=T(Z=>{A++,W=N(W,Z),I&&!j&&(G.fire(W),W=void 0),se=()=>{let ue=W;W=void 0,j=void 0,(!I||A>1)&&G.fire(ue),A=0},typeof P=="number"?(clearTimeout(j),j=setTimeout(se,P)):j===void 0&&(j=0,queueMicrotask(se))})},onWillRemoveListener(){$&&A>0&&(se==null||se())},onDidRemoveLastListener(){se=void 0,ae.dispose()}},G=new ke(ge);return F==null||F.add(G),G.event}e.debounce=S;function _(T,N=0,P){return e.debounce(T,(I,$)=>I?(I.push($),I):[$],N,void 0,!0,void 0,P)}e.accumulate=_;function C(T,N=(I,$)=>I===$,P){let I=!0,$;return a(T,K=>{let F=I||!N(K,$);return I=!1,$=K,F},P)}e.latch=C;function w(T,N,P){return[e.filter(T,N,P),e.filter(T,I=>!N(I),P)]}e.split=w;function x(T,N=!1,P=[],I){let $=P.slice(),K=T(W=>{$?$.push(W):ae.fire(W)});I&&I.add(K);let F=()=>{$==null||$.forEach(W=>ae.fire(W)),$=null},ae=new ke({onWillAddFirstListener(){K||(K=T(W=>ae.fire(W)),I&&I.add(K))},onDidAddFirstListener(){$&&(N?setTimeout(F):F())},onDidRemoveLastListener(){K&&K.dispose(),K=null}});return I&&I.add(ae),ae.event}e.buffer=x;function k(T,N){return(P,I,$)=>{let K=N(new D);return T(function(F){let ae=K.evaluate(F);ae!==b&&P.call(I,ae)},void 0,$)}}e.chain=k;let b=Symbol("HaltChainable");class D{constructor(){this.steps=[]}map(N){return this.steps.push(N),this}forEach(N){return this.steps.push(P=>(N(P),P)),this}filter(N){return this.steps.push(P=>N(P)?P:b),this}reduce(N,P){let I=P;return this.steps.push($=>(I=N(I,$),I)),this}latch(N=(P,I)=>P===I){let P=!0,I;return this.steps.push($=>{let K=P||!N($,I);return P=!1,I=$,K?$:b}),this}evaluate(N){for(let P of this.steps)if(N=P(N),N===b)break;return N}}function L(T,N,P=I=>I){let I=(...ae)=>F.fire(P(...ae)),$=()=>T.on(N,I),K=()=>T.removeListener(N,I),F=new ke({onWillAddFirstListener:$,onDidRemoveLastListener:K});return F.event}e.fromNodeEventEmitter=L;function M(T,N,P=I=>I){let I=(...ae)=>F.fire(P(...ae)),$=()=>T.addEventListener(N,I),K=()=>T.removeEventListener(N,I),F=new ke({onWillAddFirstListener:$,onDidRemoveLastListener:K});return F.event}e.fromDOMEventEmitter=M;function te(T){return new Promise(N=>i(T)(N))}e.toPromise=te;function U(T){let N=new ke;return T.then(P=>{N.fire(P)},()=>{N.fire(void 0)}).finally(()=>{N.dispose()}),N.event}e.fromPromise=U;function O(T,N){return T(P=>N.fire(P))}e.forward=O;function ee(T,N,P){return N(P),T(I=>N(I))}e.runAndSubscribe=ee;class q{constructor(N,P){this._observable=N,this._counter=0,this._hasChanged=!1;let I={onWillAddFirstListener:()=>{N.addObserver(this)},onDidRemoveLastListener:()=>{N.removeObserver(this)}};this.emitter=new ke(I),P&&P.add(this.emitter)}beginUpdate(N){this._counter++}handlePossibleChange(N){}handleChange(N,P){this._hasChanged=!0}endUpdate(N){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function J(T,N){return new q(T,N).emitter.event}e.fromObservable=J;function Q(T){return(N,P,I)=>{let $=0,K=!1,F={beginUpdate(){$++},endUpdate(){$--,$===0&&(T.reportChanges(),K&&(K=!1,N.call(P)))},handlePossibleChange(){},handleChange(){K=!0}};T.addObserver(F),T.reportChanges();let ae={dispose(){T.removeObserver(F)}};return I instanceof Zn?I.add(ae):Array.isArray(I)&&I.push(ae),ae}}e.fromObservableLight=Q})(Jt||(Jt={}));var md=class gd{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${gd._idPool++}`,gd.all.add(this)}start(t){this._stopWatch=new Cb,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}}};md.all=new Set,md._idPool=0;var xb=md,Eb=-1,C_=class x_{constructor(t,i,s=(x_._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[a,c]=this.getMostFrequentStack(),h=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${c}):`;console.warn(h),console.warn(a);let m=new Pb(h,a);this._errorHandler(m)}return()=>{let a=this._stacks.get(t.value)||0;this._stacks.set(t.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,o]of this._stacks)(!t||i<o)&&(t=[s,o],i=o);return t}};C_._idPool=1;var Nb=C_,Rb=class E_{constructor(t){this.value=t}static create(){let t=new Error;return new E_(t.stack??"")}print(){console.warn(this.value.split(`
|
|
58
|
-
`).slice(2).join(`
|
|
59
|
-
`))}},Pb=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Db=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},jb=0,hu=class{constructor(e){this.value=e,this.id=jb++}},Mb=2,Lb,ke=class{constructor(e){var t,i,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new Nb((e==null?void 0:e.onListenerError)??Xa,((i=this._options)==null?void 0:i.leakWarningThreshold)??Eb):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new xb(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,h,m,p,y;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let S=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(S);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],C=new Db(`${S}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((c=this._options)==null?void 0:c.onListenerError)||Xa)(C),Qe.None}if(this._disposed)return Qe.None;t&&(e=e.bind(t));let s=new hu(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Rb.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof hu?(this._deliveryQueue??(this._deliveryQueue=new Tb),this._listeners=[this._listeners,s]):this._listeners.push(s):((m=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||m.call(h,this),this._listeners=s,(y=(p=this._options)==null?void 0:p.onDidAddFirstListener)==null||y.call(p,this)),this._size++;let a=mt(()=>{o==null||o(),this._removeListener(s)});return i instanceof Zn?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(e){var o,a,c,h;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(c=this._options)==null?void 0:c.onDidRemoveLastListener)==null||h.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*Mb<=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)||Xa;if(!i){e.value(t);return}try{e.value(t)}catch(o){i(o)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,o;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof hu)this._deliver(this._listeners,e);else{let a=this._deliveryQueue;a.enqueue(this,e,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},Tb=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}},vd=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ke,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ke,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}};vd.INSTANCE=new vd;var hh=vd;function Ab(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}hh.INSTANCE.onDidChangeZoomLevel;function Ib(e){return hh.INSTANCE.getZoomFactor(e)}hh.INSTANCE.onDidChangeFullscreen;var ps=typeof navigator=="object"?navigator.userAgent:"",_d=ps.indexOf("Firefox")>=0,Bb=ps.indexOf("AppleWebKit")>=0,fh=ps.indexOf("Chrome")>=0,Ob=!fh&&ps.indexOf("Safari")>=0;ps.indexOf("Electron/")>=0;ps.indexOf("Android")>=0;var fu=!1;if(typeof bn.matchMedia=="function"){let e=bn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=bn.matchMedia("(display-mode: fullscreen)");fu=e.matches,Ab(bn,e,({matches:i})=>{fu&&t.matches||(fu=i)})}var rs="en",yd=!1,Sd=!1,Ga=!1,N_=!1,Fa,Qa=rs,zm=rs,zb,Gi,kr=globalThis,Qt,jv;typeof kr.vscode<"u"&&typeof kr.vscode.process<"u"?Qt=kr.vscode.process:typeof process<"u"&&typeof((jv=process==null?void 0:process.versions)==null?void 0:jv.node)=="string"&&(Qt=process);var Mv,Fb=typeof((Mv=Qt==null?void 0:Qt.versions)==null?void 0:Mv.electron)=="string",Hb=Fb&&(Qt==null?void 0:Qt.type)==="renderer",Lv;if(typeof Qt=="object"){yd=Qt.platform==="win32",Sd=Qt.platform==="darwin",Ga=Qt.platform==="linux",Ga&&Qt.env.SNAP&&Qt.env.SNAP_REVISION,Qt.env.CI||Qt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Fa=rs,Qa=rs;let e=Qt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Fa=t.userLocale,zm=t.osLocale,Qa=t.resolvedLanguage||rs,zb=(Lv=t.languagePack)==null?void 0:Lv.translationsConfigFile}catch{}N_=!0}else typeof navigator=="object"&&!Hb?(Gi=navigator.userAgent,yd=Gi.indexOf("Windows")>=0,Sd=Gi.indexOf("Macintosh")>=0,(Gi.indexOf("Macintosh")>=0||Gi.indexOf("iPad")>=0||Gi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ga=Gi.indexOf("Linux")>=0,(Gi==null?void 0:Gi.indexOf("Mobi"))>=0,Qa=globalThis._VSCODE_NLS_LANGUAGE||rs,Fa=navigator.language.toLowerCase(),zm=Fa):console.error("Unable to resolve platform.");var R_=yd,cn=Sd,$b=Ga,Fm=N_,dn=Gi,Un=Qa,Wb;(e=>{function t(){return Un}e.value=t;function i(){return Un.length===2?Un==="en":Un.length>=3?Un[0]==="e"&&Un[1]==="n"&&Un[2]==="-":!1}e.isDefaultVariant=i;function s(){return Un==="en"}e.isDefault=s})(Wb||(Wb={}));var Ub=typeof kr.postMessage=="function"&&!kr.importScripts;(()=>{if(Ub){let e=[];kr.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let a=e[s];if(a.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),a.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),kr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Kb=!!(dn&&dn.indexOf("Chrome")>=0);dn&&dn.indexOf("Firefox")>=0;!Kb&&dn&&dn.indexOf("Safari")>=0;dn&&dn.indexOf("Edg/")>=0;dn&&dn.indexOf("Android")>=0;var Zr=typeof navigator=="object"?navigator:{};Fm||document.queryCommandSupported&&document.queryCommandSupported("copy")||Zr&&Zr.clipboard&&Zr.clipboard.writeText,Fm||Zr&&Zr.clipboard&&Zr.clipboard.readText;var ph=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}},pu=new ph,Hm=new ph,$m=new ph,qb=new Array(230),P_;(e=>{function t(h){return pu.keyCodeToStr(h)}e.toString=t;function i(h){return pu.strToKeyCode(h)}e.fromString=i;function s(h){return Hm.keyCodeToStr(h)}e.toUserSettingsUS=s;function o(h){return $m.keyCodeToStr(h)}e.toUserSettingsGeneral=o;function a(h){return Hm.strToKeyCode(h)||$m.strToKeyCode(h)}e.fromUserSettings=a;function c(h){if(h>=98&&h<=113)return null;switch(h){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return pu.keyCodeToStr(h)}e.toElectronAccelerator=c})(P_||(P_={}));var Vb=class D_{constructor(t,i,s,o,a){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=o,this.keyCode=a}equals(t){return t instanceof D_&&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 yb("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 Xb(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return P_.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(_d)switch(t){case 59:return 85;case 60:if($b)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(cn)return 57;break}else if(Bb&&(cn&&t===93||!cn&&t===92))return 57;return qb[t]||0}var Gb=cn?256:2048,Qb=512,Jb=1024,Zb=cn?2048:256,Wm=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=Xb(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|=Gb),this.altKey&&(t|=Qb),this.shiftKey&&(t|=Jb),this.metaKey&&(t|=Zb),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Vb(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Um=new WeakMap;function e1(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 t1=class{static getSameOriginWindowChain(e){let t=Um.get(e);if(!t){t=[],Um.set(e,t);let i=e,s;do s=e1(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,o=this.getSameOriginWindowChain(e);for(let a of o){let c=a.window.deref();if(i+=(c==null?void 0:c.scrollY)??0,s+=(c==null?void 0:c.scrollX)??0,c===t||!a.iframeElement)break;let h=a.iframeElement.getBoundingClientRect();i+=h.top,s+=h.left}return{top:i,left:s}}},Ha=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=t1.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Km=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(fh){let a=navigator.userAgent.match(/Chrome\/(\d+)/);s=(a?parseInt(a[1]):123)<=122}if(e){let a=e,c=e,h=((o=e.view)==null?void 0:o.devicePixelRatio)||1;if(typeof a.wheelDeltaY<"u")s?this.deltaY=a.wheelDeltaY/(120*h):this.deltaY=a.wheelDeltaY/120;else if(typeof 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?_d&&!cn?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof a.wheelDeltaX<"u")Ob&&R_?this.deltaX=-(a.wheelDeltaX/120):s?this.deltaX=a.wheelDeltaX/(120*h):this.deltaX=a.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?_d&&!cn?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},j_=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),i1;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof n1?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Jt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:j_})})(i1||(i1={}));var n1=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?j_:(this._emitter||(this._emitter=new ke),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},mh=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 hd("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new hd("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},r1=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 hd("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=mt(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},s1;(e=>{async function t(s){let o,a=await Promise.all(s.map(c=>c.then(h=>h,h=>{o||(o=h)})));if(typeof o<"u")throw o;return a}e.settled=t;function i(s){return new Promise(async(o,a)=>{try{await s(o,a)}catch(c){a(c)}})}e.withAsyncBody=i})(s1||(s1={}));var qm=class zi{static fromArray(t){return new zi(i=>{i.emitMany(t)})}static fromPromise(t){return new zi(async i=>{i.emitMany(await t)})}static fromPromises(t){return new zi(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new zi(async i=>{await Promise.all(t.map(async s=>{for await(let o of s)i.emitOne(o)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new ke,queueMicrotask(async()=>{let s={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(s)),this.resolve()}catch(o){this.reject(o)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Jt.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new zi(async s=>{for await(let o of t)s.emitOne(i(o))})}map(t){return zi.map(this,t)}static filter(t,i){return new zi(async s=>{for await(let o of t)i(o)&&s.emitOne(o)})}filter(t){return zi.filter(this,t)}static coalesce(t){return zi.filter(t,i=>!!i)}coalesce(){return zi.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return zi.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};qm.EMPTY=qm.fromArray([]);var{getWindow:an,getWindowId:o1,onDidRegisterWindow:a1}=(function(){let e=new Map,t={window:bn,disposables:new Zn};e.set(bn.vscodeWindowId,t);let i=new ke,s=new ke,o=new ke;function a(c,h){return(typeof c=="number"?e.get(c):void 0)??(h?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return Qe.None;let h=new Zn,m={window:c,disposables:h.add(new Zn)};return e.set(c.vscodeWindowId,m),h.add(mt(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),h.add(Ke(c,$t.BEFORE_UNLOAD,()=>{o.fire(c)})),i.fire(m),h},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:a,getWindow(c){var p;let h=c;if((p=h==null?void 0:h.ownerDocument)!=null&&p.defaultView)return h.ownerDocument.defaultView.window;let m=c;return m!=null&&m.view?m.view.window:bn},getDocument(c){return an(c).document}}})(),l1=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ke(e,t,i,s){return new l1(e,t,i,s)}var Vm=function(e,t,i,s){return Ke(e,t,i,s)},gh,c1=class extends r1{constructor(e){super(),this.defaultTarget=e&&an(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Ym=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Xa(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,o=a=>{i.set(a,!1);let c=e.get(a)??[];for(t.set(a,c),e.set(a,[]),s.set(a,!0);c.length>0;)c.sort(Ym.sort),c.shift().execute();s.set(a,!1)};gh=(a,c,h=0)=>{let m=o1(a),p=new Ym(c,h),y=e.get(m);return y||(y=[],e.set(m,y)),y.push(p),i.get(m)||(i.set(m,!0),a.requestAnimationFrame(()=>o(m))),p}})();function u1(e){let t=e.getBoundingClientRect(),i=an(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var $t={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"},d1=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=vi(t);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let i=vi(t);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(t){let i=vi(t);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(t){let i=vi(t);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(t){let i=vi(t);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(t){let i=vi(t);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(t){let i=vi(t);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(t){let i=vi(t);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let i=vi(t);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let i=vi(t);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let i=vi(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=vi(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=vi(t);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let i=vi(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 vi(e){return typeof e=="number"?`${e}px`:e}function go(e){return new d1(e)}var M_=class{constructor(){this._hooks=new Zn,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let a=e;try{e.setPointerCapture(t),this._hooks.add(mt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=an(e)}this._hooks.add(Ke(a,$t.POINTER_MOVE,c=>{if(c.buttons!==i){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(Ke(a,$t.POINTER_UP,c=>this.stopMonitoring(!0)))}};function h1(e,t,i){let s=null,o=null;if(typeof i.value=="function"?(s="value",o=i.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",o=i.get),!o)throw new Error("not supported");let a=`$memoize$${t}`;i[s]=function(...c){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,c)}),this[a]}}var on;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(on||(on={}));var uo=class ri extends Qe{constructor(){super(),this.dispatched=!1,this.targets=new Om,this.ignoreTargets=new Om,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Jt.runAndSubscribe(a1,({window:t,disposables:i})=>{i.add(Ke(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(Ke(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(Ke(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:bn,disposables:this._store}))}static addTarget(t){if(!ri.isTouchDevice())return Qe.None;ri.INSTANCE||(ri.INSTANCE=new ri);let i=ri.INSTANCE.targets.push(t);return mt(i)}static ignoreTarget(t){if(!ri.isTouchDevice())return Qe.None;ri.INSTANCE||(ri.INSTANCE=new ri);let i=ri.INSTANCE.ignoreTargets.push(t);return mt(i)}static isTouchDevice(){return"ontouchstart"in bn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,o=t.targetTouches.length;s<o;s++){let a=t.targetTouches.item(s);this.activeTouches[a.identifier]={id:a.identifier,initialTarget:a.target,initialTimeStamp:i,initialPageX:a.pageX,initialPageY:a.pageY,rollingTimestamps:[i],rollingPageX:[a.pageX],rollingPageY:[a.pageY]};let c=this.newGestureEvent(on.Start,a.target);c.pageX=a.pageX,c.pageY=a.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 a=0,c=i.changedTouches.length;a<c;a++){let h=i.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(h.identifier))){console.warn("move of an UNKNOWN touch",h);continue}let m=this.activeTouches[h.identifier],p=Date.now()-m.initialTimeStamp;if(p<ri.HOLD_DELAY&&Math.abs(m.initialPageX-xi(m.rollingPageX))<30&&Math.abs(m.initialPageY-xi(m.rollingPageY))<30){let y=this.newGestureEvent(on.Tap,m.initialTarget);y.pageX=xi(m.rollingPageX),y.pageY=xi(m.rollingPageY),this.dispatchEvent(y)}else if(p>=ri.HOLD_DELAY&&Math.abs(m.initialPageX-xi(m.rollingPageX))<30&&Math.abs(m.initialPageY-xi(m.rollingPageY))<30){let y=this.newGestureEvent(on.Contextmenu,m.initialTarget);y.pageX=xi(m.rollingPageX),y.pageY=xi(m.rollingPageY),this.dispatchEvent(y)}else if(o===1){let y=xi(m.rollingPageX),S=xi(m.rollingPageY),_=xi(m.rollingTimestamps)-m.rollingTimestamps[0],C=y-m.rollingPageX[0],w=S-m.rollingPageY[0],x=[...this.targets].filter(k=>m.initialTarget instanceof Node&&k.contains(m.initialTarget));this.inertia(t,x,s,Math.abs(C)/_,C>0?1:-1,y,Math.abs(w)/_,w>0?1:-1,S)}this.dispatchEvent(this.newGestureEvent(on.End,m.initialTarget)),delete this.activeTouches[h.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===on.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>ri.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===on.Change||t.type===on.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let o=0,a=t.initialTarget;for(;a&&a!==s;)o++,a=a.parentElement;i.push([o,s])}i.sort((s,o)=>s[0]-o[0]);for(let[s,o]of i)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,o,a,c,h,m,p){this.handle=gh(t,()=>{let y=Date.now(),S=y-s,_=0,C=0,w=!0;o+=ri.SCROLL_FRICTION*S,h+=ri.SCROLL_FRICTION*S,o>0&&(w=!1,_=a*o*S),h>0&&(w=!1,C=m*h*S);let x=this.newGestureEvent(on.Change);x.translationX=_,x.translationY=C,i.forEach(k=>k.dispatchEvent(x)),w||this.inertia(t,i,y,o,a,c+_,h,m,p+C)})}onTouchMove(t){let i=Date.now();for(let s=0,o=t.changedTouches.length;s<o;s++){let a=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("end of an UNKNOWN touch",a);continue}let c=this.activeTouches[a.identifier],h=this.newGestureEvent(on.Change,c.initialTarget);h.translationX=a.pageX-xi(c.rollingPageX),h.translationY=a.pageY-xi(c.rollingPageY),h.pageX=a.pageX,h.pageY=a.pageY,this.dispatchEvent(h),c.rollingPageX.length>3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(a.pageX),c.rollingPageY.push(a.pageY),c.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};uo.SCROLL_FRICTION=-.005,uo.HOLD_DELAY=700,uo.CLEAR_TAP_COUNT_TIME=400,xt([h1],uo,"isTouchDevice",1);var f1=uo,vh=class extends Qe{onclick(e,t){this._register(Ke(e,$t.CLICK,i=>t(new Ha(an(e),i))))}onmousedown(e,t){this._register(Ke(e,$t.MOUSE_DOWN,i=>t(new Ha(an(e),i))))}onmouseover(e,t){this._register(Ke(e,$t.MOUSE_OVER,i=>t(new Ha(an(e),i))))}onmouseleave(e,t){this._register(Ke(e,$t.MOUSE_LEAVE,i=>t(new Ha(an(e),i))))}onkeydown(e,t){this._register(Ke(e,$t.KEY_DOWN,i=>t(new Wm(i))))}onkeyup(e,t){this._register(Ke(e,$t.KEY_UP,i=>t(new Wm(i))))}oninput(e,t){this._register(Ke(e,$t.INPUT,t))}onblur(e,t){this._register(Ke(e,$t.BLUR,t))}onfocus(e,t){this._register(Ke(e,$t.FOCUS,t))}onchange(e,t){this._register(Ke(e,$t.CHANGE,t))}ignoreGesture(e){return f1.ignoreTarget(e)}},Xm=11,p1=class extends vh{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=Xm+"px",this.domNode.style.height=Xm+"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 M_),this._register(Vm(this.bgDomNode,$t.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Vm(this.domNode,$t.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new c1),this._pointerdownScheduleRepeatTimer=this._register(new mh)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,an(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},m1=class wd{constructor(t,i,s,o,a,c,h){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,o=o|0,a=a|0,c=c|0,h=h|0),this.rawScrollLeft=o,this.rawScrollTop=h,i<0&&(i=0),o+i>s&&(o=s-i),o<0&&(o=0),a<0&&(a=0),h+a>c&&(h=c-a),h<0&&(h=0),this.width=i,this.scrollWidth=s,this.scrollLeft=o,this.height=a,this.scrollHeight=c,this.scrollTop=h}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new wd(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 wd(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,a=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,h=this.scrollHeight!==t.scrollHeight,m=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:o,scrollLeftChanged:a,heightChanged:c,scrollHeightChanged:h,scrollTopChanged:m}}},g1=class extends Qe{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new m1(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 Qm(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=Qm.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)))}},Gm=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function mu(e,t){let i=t-e;return function(s){return e+i*y1(s)}}function v1(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var Qm=class bd{constructor(t,i,s,o){this.from=t,this.to=i,this.duration=o,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,s){if(Math.abs(t-i)>2.5*s){let o,a;return t<i?(o=t+.75*s,a=i-.75*s):(o=t-.75*s,a=i+.75*s),v1(mu(t,o),mu(a,i),.33)}return mu(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 Gm(s,o,!1)}return new Gm(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return bd.start(t,i,s)}static start(t,i,s){s=s+10;let o=Date.now()-10;return new bd(t,i,o,s)}};function _1(e){return Math.pow(e,3)}function y1(e){return 1-_1(1-e)}var S1=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 mh)}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":"")))}},w1=140,L_=class extends vh{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new S1(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new M_),this._shouldRender=!0,this.domNode=go(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Ke(this.domNode.domNode,$t.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new p1(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=go(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ke(this.slider.domNode,$t.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=u1(this.domNode.domNode);t=e.pageX-o.left,i=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let a=this._sliderOrthogonalPointerPosition(o),c=Math.abs(a-i);if(R_&&c>w1){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let h=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(h))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},T_=class kd{constructor(t,i,s,o,a,c){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=a,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new kd(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,o,a){let c=Math.max(0,s-t),h=Math.max(0,c-2*i),m=o>0&&o>s;if(!m)return{computedAvailableSize:Math.round(c),computedIsNeeded:m,computedSliderSize:Math.round(h),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(s*h/o))),y=(h-p)/(o-s),S=a*y;return{computedAvailableSize:Math.round(c),computedIsNeeded:m,computedSliderSize:Math.round(p),computedSliderRatio:y,computedSliderPosition:Math.round(S)}}_refreshComputedValues(){let t=kd._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)}},b1=class extends L_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new T_(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}},k1=class extends L_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new T_(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,o.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},C1=500,Jm=50,x1=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},Cd=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,i=0,s=1,o=this._rear;do{let a=o===this._front?t:Math.pow(2,-s);if(t-=a,i+=this._memory[o].score*a,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(fh){let i=an(t.browserEvent),s=Ib(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let o=null,a=new x1(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=a,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=a),a.score=this._computeScore(a,o)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let o=Math.abs(t.deltaX),a=Math.abs(t.deltaY),c=Math.abs(i.deltaX),h=Math.abs(i.deltaY),m=Math.max(Math.min(o,c),1),p=Math.max(Math.min(a,h),1),y=Math.max(o,c),S=Math.max(a,h);y%m===0&&S%p===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Cd.INSTANCE=new Cd;var E1=Cd,N1=class extends vh{constructor(e,t,i){super(),this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ke),this.onWillScroll=this._onWillScroll.event,this._options=P1(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 k1(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new b1(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=go(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=go(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=go(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 mh),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Cr(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,cn&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Km(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Cr(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new Km(i))};this._mouseWheelToDispose.push(Ke(this._listenOnDomNode,$t.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=E1.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let a=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+a===0?c=a=0:Math.abs(a)>=Math.abs(c)?c=0:a=0),this._options.flipAxes&&([a,c]=[c,a]);let h=!cn&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!c&&(c=a,a=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,a=a*this._options.fastScrollSensitivity);let m=this._scrollable.getFutureScrollPosition(),p={};if(a){let y=Jm*a,S=m.scrollTop-(y<0?Math.floor(y):Math.ceil(y));this._verticalScrollbar.writeScrollPosition(p,S)}if(c){let y=Jm*c,S=m.scrollLeft-(y<0?Math.floor(y):Math.ceil(y));this._horizontalScrollbar.writeScrollPosition(p,S)}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":"",a=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${o}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),C1)}},R1=class extends N1{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 P1(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,cn&&(t.className+=" mac"),t}var xd=class extends Qe{constructor(e,t,i,s,o,a,c,h){super(),this._bufferService=i,this._optionsService=c,this._renderService=h,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let m=this._register(new g1({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>gh(s.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{m.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new R1(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(Jt.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(mt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(mt(()=>this._styleElement.remove())),this._register(Jt.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${a.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${a.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${a.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
60
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(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}};xd=xt([Ne(2,ci),Ne(3,kn),Ne(4,p_),Ne(5,fs),Ne(6,ui),Ne(7,Cn)],xd);var Ed=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(a=>this._removeDecoration(a))),this._register(mt(()=>{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()}};Ed=xt([Ne(1,ci),Ne(2,kn),Ne(3,Co),Ne(4,Cn)],Ed);var D1=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},nn={full:0,left:0,center:0,right:0},Kn={full:0,left:0,center:0,right:0},eo={full:0,left:0,center:0,right:0},ul=class extends Qe{constructor(e,t,i,s,o,a,c,h){var p;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=o,this._optionsService=a,this._themeService=c,this._coreBrowserService=h,this._colorZoneStore=new D1,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(mt(()=>{var y;return(y=this._canvas)==null?void 0:y.remove()}));let m=this._canvas.getContext("2d");if(m)this._ctx=m;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Kn.full=this._canvas.width,Kn.left=e,Kn.center=t,Kn.right=e,this._refreshDrawHeightConstants(),eo.full=1,eo.left=1,eo.center=1+Kn.left,eo.right=1+Kn.left+Kn.center}_refreshDrawHeightConstants(){nn.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);nn.left=t,nn.center=t,nn.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nn.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nn.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nn.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nn.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(eo[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-nn[e.position||"full"]/2),Kn[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+nn[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};ul=xt([Ne(2,ci),Ne(3,Co),Ne(4,Cn),Ne(5,ui),Ne(6,fs),Ne(7,kn)],ul);var fe;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
61
|
-
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(fe||(fe={}));var Ja;(e=>(e.PAD="",e.HOP="",e.BPH="",e.NBH="",e.IND="",e.NEL="
",e.SSA="",e.ESA="",e.HTS="",e.HTJ="",e.VTS="",e.PLD="",e.PLU="",e.RI="",e.SS2="",e.SS3="",e.DCS="",e.PU1="",e.PU2="",e.STS="",e.CCH="",e.MW="",e.SPA="",e.EPA="",e.SOS="",e.SGCI="",e.SCI="",e.CSI="",e.ST="",e.OSC="",e.PM="",e.APC=""))(Ja||(Ja={}));var A_;(e=>e.ST=`${fe.ESC}\\`)(A_||(A_={}));var Nd=class{constructor(e,t,i,s,o,a){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=o,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${fe.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let a=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(a.width,1)+"px",this._textarea.style.height=Math.max(a.height,1)+"px",this._textarea.style.lineHeight=a.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Nd=xt([Ne(2,ci),Ne(3,ui),Ne(4,Nr),Ne(5,Cn)],Nd);var Wt=0,Ut=0,Kt=0,Ct=0,Zm={css:"#00000000",rgba:0},Lt;(e=>{function t(o,a,c,h){return h!==void 0?`#${pr(o)}${pr(a)}${pr(c)}${pr(h)}`:`#${pr(o)}${pr(a)}${pr(c)}`}e.toCss=t;function i(o,a,c,h=255){return(o<<24|a<<16|c<<8|h)>>>0}e.toRgba=i;function s(o,a,c,h){return{css:e.toCss(o,a,c,h),rgba:e.toRgba(o,a,c,h)}}e.toColor=s})(Lt||(Lt={}));var ft;(e=>{function t(m,p){if(Ct=(p.rgba&255)/255,Ct===1)return{css:p.css,rgba:p.rgba};let y=p.rgba>>24&255,S=p.rgba>>16&255,_=p.rgba>>8&255,C=m.rgba>>24&255,w=m.rgba>>16&255,x=m.rgba>>8&255;Wt=C+Math.round((y-C)*Ct),Ut=w+Math.round((S-w)*Ct),Kt=x+Math.round((_-x)*Ct);let k=Lt.toCss(Wt,Ut,Kt),b=Lt.toRgba(Wt,Ut,Kt);return{css:k,rgba:b}}e.blend=t;function i(m){return(m.rgba&255)===255}e.isOpaque=i;function s(m,p,y){let S=Za.ensureContrastRatio(m.rgba,p.rgba,y);if(S)return Lt.toColor(S>>24&255,S>>16&255,S>>8&255)}e.ensureContrastRatio=s;function o(m){let p=(m.rgba|255)>>>0;return[Wt,Ut,Kt]=Za.toChannels(p),{css:Lt.toCss(Wt,Ut,Kt),rgba:p}}e.opaque=o;function a(m,p){return Ct=Math.round(p*255),[Wt,Ut,Kt]=Za.toChannels(m.rgba),{css:Lt.toCss(Wt,Ut,Kt,Ct),rgba:Lt.toRgba(Wt,Ut,Kt,Ct)}}e.opacity=a;function c(m,p){return Ct=m.rgba&255,a(m,Ct*p/255)}e.multiplyOpacity=c;function h(m){return[m.rgba>>24&255,m.rgba>>16&255,m.rgba>>8&255]}e.toColorRGB=h})(ft||(ft={}));var St;(e=>{let t,i;try{let o=document.createElement("canvas");o.width=1,o.height=1;let a=o.getContext("2d",{willReadFrequently:!0});a&&(t=a,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return Wt=parseInt(o.slice(1,2).repeat(2),16),Ut=parseInt(o.slice(2,3).repeat(2),16),Kt=parseInt(o.slice(3,4).repeat(2),16),Lt.toColor(Wt,Ut,Kt);case 5:return Wt=parseInt(o.slice(1,2).repeat(2),16),Ut=parseInt(o.slice(2,3).repeat(2),16),Kt=parseInt(o.slice(3,4).repeat(2),16),Ct=parseInt(o.slice(4,5).repeat(2),16),Lt.toColor(Wt,Ut,Kt,Ct);case 7:return{css:o,rgba:(parseInt(o.slice(1),16)<<8|255)>>>0};case 9:return{css:o,rgba:parseInt(o.slice(1),16)>>>0}}let a=o.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(a)return Wt=parseInt(a[1]),Ut=parseInt(a[2]),Kt=parseInt(a[3]),Ct=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),Lt.toColor(Wt,Ut,Kt,Ct);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Wt,Ut,Kt,Ct]=t.getImageData(0,0,1,1).data,Ct!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Lt.toRgba(Wt,Ut,Kt,Ct),css:o}}e.toColor=s})(St||(St={}));var li;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,o,a){let c=s/255,h=o/255,m=a/255,p=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),y=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),S=m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4);return p*.2126+y*.7152+S*.0722}e.relativeLuminance2=i})(li||(li={}));var Za;(e=>{function t(c,h){if(Ct=(h&255)/255,Ct===1)return h;let m=h>>24&255,p=h>>16&255,y=h>>8&255,S=c>>24&255,_=c>>16&255,C=c>>8&255;return Wt=S+Math.round((m-S)*Ct),Ut=_+Math.round((p-_)*Ct),Kt=C+Math.round((y-C)*Ct),Lt.toRgba(Wt,Ut,Kt)}e.blend=t;function i(c,h,m){let p=li.relativeLuminance(c>>8),y=li.relativeLuminance(h>>8);if(Sn(p,y)<m){if(y<p){let C=s(c,h,m),w=Sn(p,li.relativeLuminance(C>>8));if(w<m){let x=o(c,h,m),k=Sn(p,li.relativeLuminance(x>>8));return w>k?C:x}return C}let S=o(c,h,m),_=Sn(p,li.relativeLuminance(S>>8));if(_<m){let C=s(c,h,m),w=Sn(p,li.relativeLuminance(C>>8));return _>w?S:C}return S}}e.ensureContrastRatio=i;function s(c,h,m){let p=c>>24&255,y=c>>16&255,S=c>>8&255,_=h>>24&255,C=h>>16&255,w=h>>8&255,x=Sn(li.relativeLuminance2(_,C,w),li.relativeLuminance2(p,y,S));for(;x<m&&(_>0||C>0||w>0);)_-=Math.max(0,Math.ceil(_*.1)),C-=Math.max(0,Math.ceil(C*.1)),w-=Math.max(0,Math.ceil(w*.1)),x=Sn(li.relativeLuminance2(_,C,w),li.relativeLuminance2(p,y,S));return(_<<24|C<<16|w<<8|255)>>>0}e.reduceLuminance=s;function o(c,h,m){let p=c>>24&255,y=c>>16&255,S=c>>8&255,_=h>>24&255,C=h>>16&255,w=h>>8&255,x=Sn(li.relativeLuminance2(_,C,w),li.relativeLuminance2(p,y,S));for(;x<m&&(_<255||C<255||w<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),C=Math.min(255,C+Math.ceil((255-C)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),x=Sn(li.relativeLuminance2(_,C,w),li.relativeLuminance2(p,y,S));return(_<<24|C<<16|w<<8|255)>>>0}e.increaseLuminance=o;function a(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=a})(Za||(Za={}));function pr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Sn(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var j1=class extends ko{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},dl=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Hi}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let i=[],s=t.translateToString(!0),o=0,a=0,c=0,h=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!==h||this._workCell.bg!==m){if(p-o>1){let y=this._getJoinedRanges(s,c,a,t,o);for(let S=0;S<y.length;S++)i.push(y[S])}o=p,c=a,h=this._workCell.fg,m=this._workCell.bg}a+=this._workCell.getChars().length||Gn.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(s,c,a,t,o);for(let y=0;y<p.length;y++)i.push(p[y])}return i}_getJoinedRanges(e,t,i,s,o){let a=e.substring(t,i),c=[];try{c=this._characterJoiners[0].handler(a)}catch(h){console.error(h)}for(let h=1;h<this._characterJoiners.length;h++)try{let m=this._characterJoiners[h].handler(a);for(let p=0;p<m.length;p++)dl._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,a=0,c=e[s];if(c){for(let h=i;h<this._bufferService.cols;h++){let m=t.getWidth(h),p=t.getString(h).length||Gn.length;if(m!==0){if(!o&&c[0]<=a&&(c[0]=h,o=!0),c[1]<=a){if(c[1]=h,c=e[++s],!c)break;c[0]<=a?(c[0]=h,o=!0):o=!1}a+=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}};dl=xt([Ne(0,ci)],dl);function M1(e){return 57508<=e&&e<=57558}function L1(e){return 9472<=e&&e<=9631}function T1(e){return M1(e)||L1(e)}function A1(){return{css:{canvas:$a(),cell:$a()},device:{canvas:$a(),cell:$a(),char:{width:0,height:0,left:0,top:0}}}}function $a(){return{width:0,height:0}}var Rd=class{constructor(e,t,i,s,o,a,c){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=o,this._decorationService=a,this._themeService=c,this._workCell=new Hi,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,o,a,c,h,m,p,y){let S=[],_=this._characterJoinerService.getJoinedCharacters(t),C=this._themeService.colors,w=e.getNoBgTrimmedLength();i&&w<a+1&&(w=a+1);let x,k=0,b="",D=0,L=0,M=0,te=0,U=!1,O=0,ee=!1,q=0,J=0,Q=[],T=p!==-1&&y!==-1;for(let N=0;N<w;N++){e.loadCell(N,this._workCell);let P=this._workCell.getWidth();if(P===0)continue;let I=!1,$=N>=J,K=N,F=this._workCell;if(_.length>0&&N===_[0][0]&&$){let Ee=_.shift(),rt=this._isCellInSelection(Ee[0],t);for(D=Ee[0]+1;D<Ee[1];D++)$&&($=rt===this._isCellInSelection(D,t));$&&($=!i||a<Ee[0]||a>=Ee[1]),$?(I=!0,F=new j1(this._workCell,e.translateToString(!0,Ee[0],Ee[1]),Ee[1]-Ee[0]),K=Ee[1]-1,P=F.getWidth()):J=Ee[1]}let ae=this._isCellInSelection(N,t),W=i&&N===a,j=T&&N>=p&&N<=y,A=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,Ee=>{A=!0});let se=F.getChars()||Gn;if(se===" "&&(F.isUnderline()||F.isOverline())&&(se=" "),q=P*h-m.get(se,F.isBold(),F.isItalic()),!x)x=this._document.createElement("span");else if(k&&(ae&&ee||!ae&&!ee&&F.bg===L)&&(ae&&ee&&C.selectionForeground||F.fg===M)&&F.extended.ext===te&&j===U&&q===O&&!W&&!I&&!A&&$){F.isInvisible()?b+=Gn:b+=se,k++;continue}else k&&(x.textContent=b),x=this._document.createElement("span"),k=0,b="";if(L=F.bg,M=F.fg,te=F.extended.ext,U=j,O=q,ee=ae,I&&a>=N&&a<=K&&(a=N),!this._coreService.isCursorHidden&&W&&this._coreService.isCursorInitialized){if(Q.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&Q.push("xterm-cursor-blink"),Q.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":Q.push("xterm-cursor-outline");break;case"block":Q.push("xterm-cursor-block");break;case"bar":Q.push("xterm-cursor-bar");break;case"underline":Q.push("xterm-cursor-underline");break}}if(F.isBold()&&Q.push("xterm-bold"),F.isItalic()&&Q.push("xterm-italic"),F.isDim()&&Q.push("xterm-dim"),F.isInvisible()?b=Gn:b=F.getChars()||Gn,F.isUnderline()&&(Q.push(`xterm-underline-${F.extended.underlineStyle}`),b===" "&&(b=" "),!F.isUnderlineColorDefault()))if(F.isUnderlineColorRGB())x.style.textDecorationColor=`rgb(${ko.toColorRGB(F.getUnderlineColor()).join(",")})`;else{let Ee=F.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&F.isBold()&&Ee<8&&(Ee+=8),x.style.textDecorationColor=C.ansi[Ee].css}F.isOverline()&&(Q.push("xterm-overline"),b===" "&&(b=" ")),F.isStrikethrough()&&Q.push("xterm-strikethrough"),j&&(x.style.textDecoration="underline");let ge=F.getFgColor(),G=F.getFgColorMode(),Z=F.getBgColor(),ue=F.getBgColorMode(),de=!!F.isInverse();if(de){let Ee=ge;ge=Z,Z=Ee;let rt=G;G=ue,ue=rt}let Ce,Re,tt=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,Ee=>{Ee.options.layer!=="top"&&tt||(Ee.backgroundColorRGB&&(ue=50331648,Z=Ee.backgroundColorRGB.rgba>>8&16777215,Ce=Ee.backgroundColorRGB),Ee.foregroundColorRGB&&(G=50331648,ge=Ee.foregroundColorRGB.rgba>>8&16777215,Re=Ee.foregroundColorRGB),tt=Ee.options.layer==="top")}),!tt&&ae&&(Ce=this._coreBrowserService.isFocused?C.selectionBackgroundOpaque:C.selectionInactiveBackgroundOpaque,Z=Ce.rgba>>8&16777215,ue=50331648,tt=!0,C.selectionForeground&&(G=50331648,ge=C.selectionForeground.rgba>>8&16777215,Re=C.selectionForeground)),tt&&Q.push("xterm-decoration-top");let Je;switch(ue){case 16777216:case 33554432:Je=C.ansi[Z],Q.push(`xterm-bg-${Z}`);break;case 50331648:Je=Lt.toColor(Z>>16,Z>>8&255,Z&255),this._addStyle(x,`background-color:#${eg((Z>>>0).toString(16),"0",6)}`);break;case 0:default:de?(Je=C.foreground,Q.push("xterm-bg-257")):Je=C.background}switch(Ce||F.isDim()&&(Ce=ft.multiplyOpacity(Je,.5)),G){case 16777216:case 33554432:F.isBold()&&ge<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ge+=8),this._applyMinimumContrast(x,Je,C.ansi[ge],F,Ce,void 0)||Q.push(`xterm-fg-${ge}`);break;case 50331648:let Ee=Lt.toColor(ge>>16&255,ge>>8&255,ge&255);this._applyMinimumContrast(x,Je,Ee,F,Ce,Re)||this._addStyle(x,`color:#${eg(ge.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(x,Je,C.foreground,F,Ce,Re)||de&&Q.push("xterm-fg-257")}Q.length&&(x.className=Q.join(" "),Q.length=0),!W&&!I&&!A&&$?k++:x.textContent=b,q!==this.defaultSpacing&&(x.style.letterSpacing=`${q}px`),S.push(x),N=K}return x&&k&&(x.textContent=b),S}_applyMinimumContrast(e,t,i,s,o,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||T1(s.getCode()))return!1;let c=this._getContrastCache(s),h;if(!o&&!a&&(h=c.getColor(t.rgba,i.rgba)),h===void 0){let m=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);h=ft.ensureContrastRatio(o||t,a||i,m),c.setColor((o||t).rgba,(a||i).rgba,h??null)}return h?(this._addStyle(e,`color:${h.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};Rd=xt([Ne(1,v_),Ne(2,ui),Ne(3,kn),Ne(4,Nr),Ne(5,Co),Ne(6,fs)],Rd);function eg(e,t,i){for(;e.length<i;)e=t+e;return e}var I1=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontWeight="bold",a.style.fontStyle="italic",this._measureElements=[i,s,o,a],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(o),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let c=this._measure(e,0);return c>0&&(this._flat[s]=c),c}let o=e;t&&(o+="B"),i&&(o+="I");let a=this._holey.get(o);if(a===void 0){let c=0;t&&(c|=1),i&&(c|=2),a=this._measure(e,c),a>0&&this._holey.set(o,a)}return a}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},B1=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let o=e.buffers.active.ydisp,a=t[1]-o,c=i[1]-o,h=Math.max(a,0),m=Math.min(c,e.rows-1);if(h>=e.rows||m<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=a,this.viewportEndRow=c,this.viewportCappedStartRow=h,this.viewportCappedEndRow=m,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function O1(){return new B1}var gu="xterm-dom-renderer-owner-",Oi="xterm-rows",Wa="xterm-fg-",tg="xterm-bg-",to="xterm-focus",Ua="xterm-selection",z1=1,Pd=class extends Qe{constructor(e,t,i,s,o,a,c,h,m,p,y,S,_,C){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=o,this._helperContainer=a,this._linkifier2=c,this._charSizeService=m,this._optionsService=p,this._bufferService=y,this._coreService=S,this._coreBrowserService=_,this._themeService=C,this._terminalClass=z1++,this._rowElements=[],this._selectionRenderModel=O1(),this.onRequestRedraw=this._register(new ke).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Oi),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Ua),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=A1(),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=h.createInstance(Rd,document),this._element.classList.add(gu+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(mt(()=>{this._element.classList.remove(gu+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new I1(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Oi} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Oi} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Oi} .xterm-dim { color: ${ft.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Oi}.${to} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Oi}.${to} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Oi}.${to} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Oi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Oi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Oi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Oi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Oi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ua} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ua} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ua} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[a,c]of e.ansi.entries())t+=`${this._terminalSelector} .${Wa}${a} { color: ${c.css}; }${this._terminalSelector} .${Wa}${a}.xterm-dim { color: ${ft.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${tg}${a} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${Wa}257 { color: ${ft.opaque(e.background).css}; }${this._terminalSelector} .${Wa}257.xterm-dim { color: ${ft.multiplyOpacity(ft.opaque(e.background),.5).css}; }${this._terminalSelector} .${tg}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(to),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(to),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(i){let m=e[0]>t[0];h.appendChild(this._createSelectionElement(a,m?t[0]:e[0],m?e[0]:t[0],c-a+1))}else{let m=s===a?e[0]:0,p=a===o?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(a,m,p));let y=c-a-1;if(h.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,y)),a!==c){let S=o===c?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(c,0,S))}}this._selectionContainer.appendChild(h)}_createSelectionElement(e,t,i,s=1){let o=this._document.createElement("div"),a=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(i-t);return a+c>this.dimensions.css.canvas.width&&(c=this.dimensions.css.canvas.width-a),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${a}px`,o.style.width=`${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),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=e;m<=t;m++){let p=m+i.ydisp,y=this._rowElements[m],S=i.lines.get(p);if(!y||!S)break;y.replaceChildren(...this._rowFactory.createRow(S,p,p===s,c,h,o,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${gu}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,o,a){i<0&&(e=0),s<0&&(t=0);let 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 h=this._bufferService.buffer,m=h.ybase+h.y,p=Math.min(h.x,o-1),y=this._optionsService.rawOptions.cursorBlink,S=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let C=i;C<=s;++C){let w=C+h.ydisp,x=this._rowElements[C],k=h.lines.get(w);if(!x||!k)break;x.replaceChildren(...this._rowFactory.createRow(k,w,w===m,S,_,p,y,this.dimensions.css.cell.width,this._widthCache,a?C===i?e:0:-1,a?(C===s?t:o)-1:-1))}}};Pd=xt([Ne(7,uh),Ne(8,_l),Ne(9,ui),Ne(10,ci),Ne(11,Nr),Ne(12,kn),Ne(13,fs)],Pd);var Dd=class extends Qe{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ke),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new H1(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())}};Dd=xt([Ne(2,ui)],Dd);var I_=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 I_{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}},H1=class extends I_{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}},$1=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 W1(this._window)),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ke),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Jt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ke(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ke(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},W1=class extends Qe{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new us),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(mt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ke(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},U1=class extends Qe{constructor(){super(),this.linkProviders=[],this._register(mt(()=>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 _h(e,t,i){let s=i.getBoundingClientRect(),o=e.getComputedStyle(i),a=parseInt(o.getPropertyValue("padding-left")),c=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-a,t.clientY-s.top-c]}function K1(e,t,i,s,o,a,c,h,m){if(!a)return;let p=_h(e,t,i);if(p)return p[0]=Math.ceil((p[0]+(m?c/2:0))/c),p[1]=Math.ceil(p[1]/h),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 jd=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,o){return K1(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=_h(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])}}};jd=xt([Ne(0,Cn),Ne(1,_l)],jd);var q1=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=[]}},B_={};ib(B_,{getSafariVersion:()=>Y1,isChromeOS:()=>H_,isFirefox:()=>O_,isIpad:()=>X1,isIphone:()=>G1,isLegacyEdge:()=>V1,isLinux:()=>yh,isMac:()=>hl,isNode:()=>yl,isSafari:()=>z_,isWindows:()=>F_});var yl=typeof process<"u"&&"title"in process,xo=yl?"node":navigator.userAgent,Eo=yl?"node":navigator.platform,O_=xo.includes("Firefox"),V1=xo.includes("Edge"),z_=/^((?!chrome|android).)*safari/i.test(xo);function Y1(){if(!z_)return 0;let e=xo.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var hl=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Eo),X1=Eo==="iPad",G1=Eo==="iPhone",F_=["Windows","Win16","Win32","WinCE"].includes(Eo),yh=Eo.indexOf("Linux")>=0,H_=/\bCrOS\b/.test(xo),$_=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()}},Q1=class extends $_{_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())}}},J1=class extends $_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},fl=!yl&&"requestIdleCallback"in window?J1:Q1,Z1=class{constructor(){this._queue=new fl}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Md=class extends Qe{constructor(e,t,i,s,o,a,c,h,m){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=o,this._coreBrowserService=h,this._renderer=this._register(new us),this._pausedResizeTask=new Z1,this._observerDisposable=this._register(new us),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 ke),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ke),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ke),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new q1((p,y)=>this._renderRows(p,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new ek(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(mt(()=>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(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(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=mt(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Md=xt([Ne(2,ui),Ne(3,_l),Ne(4,Nr),Ne(5,Co),Ne(6,ci),Ne(7,kn),Ne(8,fs)],Md);var ek=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 tk(e,t,i,s){let o=i.buffer.x,a=i.buffer.y;if(!i.buffer.hasScrollback)return rk(o,a,e,t,i,s)+Sl(a,t,i,s)+sk(o,a,e,t,i,s);let c;if(a===t)return c=o>e?"D":"C",yo(Math.abs(o-e),_o(c,s));c=a>t?"D":"C";let h=Math.abs(a-t),m=nk(a>t?e:o,i)+(h-1)*i.cols+1+ik(a>t?o:e);return yo(m,_o(c,s))}function ik(e,t){return e-1}function nk(e,t){return t.cols-e}function rk(e,t,i,s,o,a){return Sl(t,s,o,a).length===0?"":yo(U_(e,t,e,t-xr(t,o),!1,o).length,_o("D",a))}function Sl(e,t,i,s){let o=e-xr(e,i),a=t-xr(t,i),c=Math.abs(o-a)-ok(e,t,i);return yo(c,_o(W_(e,t),s))}function sk(e,t,i,s,o,a){let c;Sl(t,s,o,a).length>0?c=s-xr(s,o):c=t;let h=s,m=ak(e,t,i,s,o,a);return yo(U_(e,c,i,h,m==="C",o).length,_o(m,a))}function ok(e,t,i){var c;let s=0,o=e-xr(e,i),a=t-xr(t,i);for(let h=0;h<Math.abs(o-a);h++){let m=W_(e,t)==="A"?-1:1;(c=i.buffer.lines.get(o+m*h))!=null&&c.isWrapped&&s++}return s}function xr(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 ak(e,t,i,s,o,a){let c;return Sl(i,s,o,a).length>0?c=s-xr(s,o):c=t,e<i&&c<=s||e>=i&&c<s?"C":"D"}function W_(e,t){return e>t?"A":"B"}function U_(e,t,i,s,o,a){let c=e,h=t,m="";for(;(c!==i||h!==s)&&h>=0&&h<a.buffer.lines.length;)c+=o?1:-1,o&&c>a.cols-1?(m+=a.buffer.translateBufferLineToString(h,!1,e,c),c=0,e=0,h++):!o&&c<0&&(m+=a.buffer.translateBufferLineToString(h,!1,0,e+1),c=a.cols-1,e=c,h--);return m+a.buffer.translateBufferLineToString(h,!1,e,c)}function _o(e,t){let i=t?"O":"[";return fe.ESC+i+e}function yo(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var lk=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 ig(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 vu=50,ck=15,uk=50,dk=500,hk=" ",fk=new RegExp(hk,"g"),Ld=class extends Qe{constructor(e,t,i,s,o,a,c,h,m){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=o,this._mouseService=a,this._optionsService=c,this._renderService=h,this._coreBrowserService=m,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Hi,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ke),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ke),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ke),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 lk(this._bufferService),this._activeSelectionMode=0,this._register(mt(()=>{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],a=e[0]<t[0]?t[0]:e[0];for(let c=e[1];c<=t[1];c++){let h=i.translateBufferLineToString(c,!0,o,a);s.push(h)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],o));for(let a=e[1]+1;a<=t[1]-1;a++){let c=i.lines.get(a),h=i.translateBufferLineToString(a,!0);c!=null&&c.isWrapped?s[s.length-1]+=h:s.push(h)}if(e[1]!==t[1]){let a=i.lines.get(t[1]),c=i.translateBufferLineToString(t[1],!0,0,t[0]);a&&a.isWrapped?s[s.length-1]+=c:s.push(c)}}return s.map(o=>o.replace(fk," ")).join(F_?`\r
|
|
62
|
-
`:`
|
|
63
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),yh&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var o,a;let i=(a=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:a.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=ig(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=_h(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,-vu),vu),t/=vu,t/Math.abs(t)+Math.round(t*(ck-1)))}shouldForceSelection(e){return hl?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),uk)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(hl&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<dk&&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=tk(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:o>1&&t!==s&&(i+=o-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,a=o.lines.get(e[1]);if(!a)return;let c=o.translateBufferLineToString(e[1],!1),h=this._convertViewportColToCharacterIndex(a,e[0]),m=h,p=e[0]-h,y=0,S=0,_=0,C=0;if(c.charAt(h)===" "){for(;h>0&&c.charAt(h-1)===" ";)h--;for(;m<c.length&&c.charAt(m+1)===" ";)m++}else{let k=e[0],b=e[0];a.getWidth(k)===0&&(y++,k--),a.getWidth(b)===2&&(S++,b++);let D=a.getString(b).length;for(D>1&&(C+=D-1,m+=D-1);k>0&&h>0&&!this._isCharWordSeparator(a.loadCell(k-1,this._workCell));){a.loadCell(k-1,this._workCell);let L=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,k--):L>1&&(_+=L-1,h-=L-1),h--,k--}for(;b<a.length&&m+1<c.length&&!this._isCharWordSeparator(a.loadCell(b+1,this._workCell));){a.loadCell(b+1,this._workCell);let L=this._workCell.getChars().length;this._workCell.getWidth()===2?(S++,b++):L>1&&(C+=L-1,m+=L-1),m++,b++}}m++;let w=h+p-y+_,x=Math.min(this._bufferService.cols,m-h+y+S-_-C);if(!(!t&&c.slice(h,m).trim()==="")){if(i&&w===0&&a.getCodePoint(0)!==32){let k=o.lines.get(e[1]-1);if(k&&a.isWrapped&&k.getCodePoint(this._bufferService.cols-1)!==32){let b=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(b){let D=this._bufferService.cols-b.start;w-=D,x+=D}}}if(s&&w+x===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let k=o.lines.get(e[1]+1);if(k!=null&&k.isWrapped&&k.getCodePoint(0)!==32){let b=this._getWordAt([0,e[1]+1],!1,!1,!0);b&&(x+=b.length)}}return{start:w,length:x}}}_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=ig(i,this._bufferService.cols)}};Ld=xt([Ne(3,ci),Ne(4,Nr),Ne(5,dh),Ne(6,ui),Ne(7,Cn),Ne(8,kn)],Ld);var ng=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={}}},rg=class{constructor(){this._color=new ng,this._css=new ng}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},It=Object.freeze((()=>{let e=[St.toColor("#2e3436"),St.toColor("#cc0000"),St.toColor("#4e9a06"),St.toColor("#c4a000"),St.toColor("#3465a4"),St.toColor("#75507b"),St.toColor("#06989a"),St.toColor("#d3d7cf"),St.toColor("#555753"),St.toColor("#ef2929"),St.toColor("#8ae234"),St.toColor("#fce94f"),St.toColor("#729fcf"),St.toColor("#ad7fa8"),St.toColor("#34e2e2"),St.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],o=t[i/6%6|0],a=t[i%6];e.push({css:Lt.toCss(s,o,a),rgba:Lt.toRgba(s,o,a)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:Lt.toCss(s,s,s),rgba:Lt.toRgba(s,s,s)})}return e})()),gr=St.toColor("#ffffff"),ho=St.toColor("#000000"),sg=St.toColor("#ffffff"),og=ho,io={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},pk=gr,Td=class extends Qe{constructor(e){super(),this._optionsService=e,this._contrastCache=new rg,this._halfContrastCache=new rg,this._onChangeColors=this._register(new ke),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:gr,background:ho,cursor:sg,cursorAccent:og,selectionForeground:void 0,selectionBackgroundTransparent:io,selectionBackgroundOpaque:ft.blend(ho,io),selectionInactiveBackgroundTransparent:io,selectionInactiveBackgroundOpaque:ft.blend(ho,io),scrollbarSliderBackground:ft.opacity(gr,.2),scrollbarSliderHoverBackground:ft.opacity(gr,.4),scrollbarSliderActiveBackground:ft.opacity(gr,.5),overviewRulerBorder:gr,ansi:It.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=lt(e.foreground,gr),t.background=lt(e.background,ho),t.cursor=ft.blend(t.background,lt(e.cursor,sg)),t.cursorAccent=ft.blend(t.background,lt(e.cursorAccent,og)),t.selectionBackgroundTransparent=lt(e.selectionBackground,io),t.selectionBackgroundOpaque=ft.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=lt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ft.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?lt(e.selectionForeground,Zm):void 0,t.selectionForeground===Zm&&(t.selectionForeground=void 0),ft.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ft.opacity(t.selectionBackgroundTransparent,.3)),ft.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ft.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=lt(e.scrollbarSliderBackground,ft.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=lt(e.scrollbarSliderHoverBackground,ft.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=lt(e.scrollbarSliderActiveBackground,ft.opacity(t.foreground,.5)),t.overviewRulerBorder=lt(e.overviewRulerBorder,pk),t.ansi=It.slice(),t.ansi[0]=lt(e.black,It[0]),t.ansi[1]=lt(e.red,It[1]),t.ansi[2]=lt(e.green,It[2]),t.ansi[3]=lt(e.yellow,It[3]),t.ansi[4]=lt(e.blue,It[4]),t.ansi[5]=lt(e.magenta,It[5]),t.ansi[6]=lt(e.cyan,It[6]),t.ansi[7]=lt(e.white,It[7]),t.ansi[8]=lt(e.brightBlack,It[8]),t.ansi[9]=lt(e.brightRed,It[9]),t.ansi[10]=lt(e.brightGreen,It[10]),t.ansi[11]=lt(e.brightYellow,It[11]),t.ansi[12]=lt(e.brightBlue,It[12]),t.ansi[13]=lt(e.brightMagenta,It[13]),t.ansi[14]=lt(e.brightCyan,It[14]),t.ansi[15]=lt(e.brightWhite,It[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=lt(e.extendedAnsi[s],It[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Td=xt([Ne(0,ui)],Td);function lt(e,t){if(e!==void 0)try{return St.toColor(e)}catch{}return t}var mk=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)}},gk=class{constructor(){this._services=new mk,this._services.set(uh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=cb(e).sort((a,c)=>a.index-c.index),s=[];for(let a of i){let c=this._services.get(a.id);if(!c)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${a.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)}},vk={trace:0,debug:1,info:2,warn:3,error:4,off:5},_k="xterm.js: ",Ad=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=vk[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?"":_k)+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)}};Ad=xt([Ne(0,ui)],Ad);var ag=class extends Qe{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ke),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ke),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ke),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,Mt=Object.freeze(new ko),Ka=0,_u=2,fo=class K_{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Ge);let o=i||Hi.fromCharData([0,u_,1,0]);for(let a=0;a<t;++a)this.setCell(a,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?Yn(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?Yn(i&2097151):""}isProtected(t){return this._data[t*Ge+2]&536870912}loadCell(t,i){return Ka=t*Ge,i.content=this._data[Ka+0],i.fg=this._data[Ka+1],i.bg=this._data[Ka+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*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]+=Yn(i):o&2097151?(this._combined[t]=Yn(o&2097151)+Yn(i),o&=-2097152,o|=2097152):o=i|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*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 Hi;for(let a=this.length-t-i-1;a>=0;--a)this.setCell(t+i+a,this.loadCell(t+a,o));for(let a=0;a<i;++a)this.setCell(t+a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let o=new Hi;for(let a=0;a<this.length-t-i;++a)this.setCell(t+a,this.loadCell(t+i+a,o));for(let a=this.length-i;a<this.length;++a)this.setCell(a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*_u<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 h=parseInt(o[c],10);h>=t&&delete this._combined[h]}let a=Object.keys(this._extendedAttrs);for(let c=0;c<a.length;c++){let h=parseInt(a[c],10);h>=t&&delete this._extendedAttrs[h]}}return this.length=t,s*4*_u<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*_u<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 K_(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,a){let c=t._data;if(a)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 h=Object.keys(t._combined);for(let m=0;m<h.length;m++){let p=parseInt(h[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 a="";for(;i<s;){let c=this._data[i*Ge+0],h=c&2097151,m=c&2097152?this._combined[i]:h?Yn(h):Gn;if(a+=m,o)for(let p=0;p<m.length;++p)o.push(i);i+=c>>22||1}return o&&o.push(i),a}};function yk(e,t,i,s,o,a){let c=[];for(let h=0;h<e.length-1;h++){let m=h,p=e.get(++m);if(!p.isWrapped)continue;let y=[e.get(h)];for(;m<e.length&&p.isWrapped;)y.push(p),p=e.get(++m);if(!a&&s>=h&&s<m){h+=y.length-1;continue}let S=0,_=So(y,S,t),C=1,w=0;for(;C<y.length;){let k=So(y,C,t),b=k-w,D=i-_,L=Math.min(b,D);y[S].copyCellsFrom(y[C],w,_,L,!1),_+=L,_===i&&(S++,_=0),w+=L,w===k&&(C++,w=0),_===0&&S!==0&&y[S-1].getWidth(i-1)===2&&(y[S].copyCellsFrom(y[S-1],i-1,_++,1,!1),y[S-1].setCell(i-1,o))}y[S].replaceCells(_,i,o);let x=0;for(let k=y.length-1;k>0&&(k>S||y[k].getTrimmedLength()===0);k--)x++;x>0&&(c.push(h+y.length-x),c.push(x)),h+=y.length-1}return c}function Sk(e,t){let i=[],s=0,o=t[s],a=0;for(let c=0;c<e.length;c++)if(o===c){let h=t[++s];e.onDeleteEmitter.fire({index:c-a,amount:h}),c+=h-1,a+=h,o=t[++s]}else i.push(c);return{layout:i,countRemoved:a}}function wk(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 bk(e,t,i){let s=[],o=e.map((m,p)=>So(e,p,t)).reduce((m,p)=>m+p),a=0,c=0,h=0;for(;h<o;){if(o-h<i){s.push(o-h);break}a+=i;let m=So(e,c,t);a>m&&(a-=m,c++);let p=e[c].getWidth(a-1)===2;p&&a--;let y=p?i-1:i;s.push(y),h+=y}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 q_=class V_{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=V_._nextId++,this._onDispose=this.register(new ke),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Cr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};q_._nextId=1;var kk=q_,Ot={},vr=Ot.B;Ot[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Ot.A={"#":"£"};Ot.B=void 0;Ot[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ot.C=Ot[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ot.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ot.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ot.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ot.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ot.E=Ot[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ot.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ot.H=Ot[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ot["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var lg=4294967295,cg=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=Mt.clone(),this.savedCharset=vr,this.markers=[],this._nullCell=Hi.fromCharData([0,u_,1,0]),this._whitespaceCell=Hi.fromCharData([0,Gn,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new fl,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new ag(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new cl),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new cl),this._whitespaceCell}getBlankLine(e,t){return new fo(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>lg?lg:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Mt);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 ag(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(Mt),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 a=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 fo(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new fo(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),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let a=0;a<this.lines.length;a++)s+=+this.lines.get(a).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=yk(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Mt),i);if(s.length>0){let o=Sk(this.lines,s);wk(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(Mt),o=i;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new fo(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(Mt),o=[],a=0;for(let c=this.lines.length-1;c>=0;c--){let h=this.lines.get(c);if(!h||!h.isWrapped&&h.getTrimmedLength()<=e)continue;let m=[h];for(;h.isWrapped&&c>0;)h=this.lines.get(--c),m.unshift(h);if(!i){let L=this.ybase+this.y;if(L>=c&&L<c+m.length)continue}let p=m[m.length-1].getTrimmedLength(),y=bk(m,this._cols,e),S=y.length-m.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+S):_=Math.max(0,this.lines.length-this.lines.maxLength+S);let C=[];for(let L=0;L<S;L++){let M=this.getBlankLine(Mt,!0);C.push(M)}C.length>0&&(o.push({start:c+m.length+a,newLines:C}),a+=C.length),m.push(...C);let w=y.length-1,x=y[w];x===0&&(w--,x=y[w]);let k=m.length-S-1,b=p;for(;k>=0;){let L=Math.min(b,x);if(m[w]===void 0)break;if(m[w].copyCellsFrom(m[k],b-L,x-L,L,!0),x-=L,x===0&&(w--,x=y[w]),b-=L,b===0){k--;let M=Math.max(k,0);b=So(m,M,this._cols)}}for(let L=0;L<m.length;L++)y[L]<e&&m[L].setCell(y[L],s);let D=S-_;for(;D-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+S,this.ybase+t-1)}if(o.length>0){let c=[],h=[];for(let x=0;x<this.lines.length;x++)h.push(this.lines.get(x));let m=this.lines.length,p=m-1,y=0,S=o[y];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let _=0;for(let x=Math.min(this.lines.maxLength-1,m+a-1);x>=0;x--)if(S&&S.start>p+_){for(let k=S.newLines.length-1;k>=0;k--)this.lines.set(x--,S.newLines[k]);x++,c.push({index:p+1,amount:S.newLines.length}),_+=S.newLines.length,S=o[++y]}else this.lines.set(x,h[p--]);let C=0;for(let x=c.length-1;x>=0;x--)c[x].index+=C,this.lines.onInsertEmitter.fire(c[x]),C+=c[x].amount;let w=Math.max(0,m+a-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 kk(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)}},Ck=class extends Qe{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ke),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 cg(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new cg(!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)}},Y_=2,X_=1,Id=class extends Qe{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Y_),this.rows=Math.max(e.rawOptions.rows||0,X_),this.buffers=this._register(new Ck(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=i.ybase+i.scrollTop,a=i.ybase+i.scrollBottom;if(i.scrollTop===0){let c=i.lines.isFull;a===i.lines.length-1?c?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(a+1,0,s.clone()),c?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let c=a-o+1;i.lines.shiftElements(o+1,c-1,-1),i.lines.set(a,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};Id=xt([Ne(0,ui)],Id);var es={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:hl,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},xk=["normal","bold","100","200","300","400","500","600","700","800","900"],Ek=class extends Qe{constructor(e){super(),this._onOptionChange=this._register(new ke),this.onOptionChange=this._onOptionChange.event;let t={...es};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(mt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in es))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in es))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=es[e]),!Nk(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=es[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=xk.includes(t)?t:es[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function Nk(e){return e==="block"||e==="underline"||e==="bar"}function po(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]&&po(e[s],t-1);return i}var ug=Object.freeze({insertMode:!1}),dg=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Bd=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 ke),this.onData=this._onData.event,this._onUserInput=this._register(new ke),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ke),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=po(ug),this.decPrivateModes=po(dg)}reset(){this.modes=po(ug),this.decPrivateModes=po(dg)}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))}};Bd=xt([Ne(0,ci),Ne(1,m_),Ne(2,ui)],Bd);var hg={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 yu(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 Su=String.fromCharCode,fg={DEFAULT:e=>{let t=[yu(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Su(t[0])}${Su(t[1])}${Su(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${yu(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${yu(e,!0)};${e.x};${e.y}${t}`}},Od=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 ke),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(hg))this.addProtocol(s,hg[s]);for(let s of Object.keys(fg))this.addEncoding(s,fg[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,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)}};Od=xt([Ne(0,ci),Ne(1,Nr),Ne(2,ui)],Od);var wu=[[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]],Rk=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Bt;function Pk(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 Dk=class{constructor(){if(this.version="6",!Bt){Bt=new Uint8Array(65536),Bt.fill(1),Bt[0]=0,Bt.fill(0,1,32),Bt.fill(0,127,160),Bt.fill(2,4352,4448),Bt[9001]=2,Bt[9002]=2,Bt.fill(2,11904,42192),Bt[12351]=1,Bt.fill(2,44032,55204),Bt.fill(2,63744,64256),Bt.fill(2,65040,65050),Bt.fill(2,65072,65136),Bt.fill(2,65280,65377),Bt.fill(2,65504,65511);for(let e=0;e<wu.length;++e)Bt.fill(0,wu[e][0],wu[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Bt[e]:Pk(e,Rk)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let o=Sr.extractWidth(t);o===0?s=!1:o>i&&(i=o)}return Sr.createPropertyValue(0,i,s)}},Sr=class el{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ke,this.onChange=this._onChange.event;let t=new Dk;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,o=t.length;for(let a=0;a<o;++a){let c=t.charCodeAt(a);if(55296<=c&&c<=56319){if(++a>=o)return i+this.wcwidth(c);let p=t.charCodeAt(a);56320<=p&&p<=57343?c=(c-55296)*1024+p-56320+65536:i+=this.wcwidth(p)}let h=this.charProperties(c,s),m=el.extractWidth(h);el.extractShouldJoin(h)&&(m-=el.extractWidth(s)),i+=m,s=h}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},jk=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 pg(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 no=2147483647,Mk=256,G_=class zd{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>Mk)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 zd;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let a=0;a<o.length;++a)i.addSubParam(o[a]);else i.addParam(o)}return i}clone(){let t=new zd(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let 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>no?no: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>no?no: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,no):t}},ro=[],Lk=class{constructor(){this._state=0,this._active=ro,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=ro}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=ro,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ro,!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",vl(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=ro,this._id=-1,this._state=0}}},Ei=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+=vl(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}},so=[],Tk=class{constructor(){this._handlers=Object.create(null),this._active=so,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=so}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=so,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||so,!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",vl(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=so,this._ident=0}},mo=new G_;mo.addParam(0);var mg=class{constructor(e){this._handler=e,this._data="",this._params=mo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():mo,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=vl(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=mo,this._data="",this._hitLimit=!1,i));return this._params=mo,this._data="",this._hitLimit=!1,t}},Ak=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=i<<4|s}},Fi=160,Ik=(function(){let e=new Ak(4095),t=Array.apply(null,Array(256)).map((h,m)=>m),i=(h,m)=>t.slice(h,m),s=i(32,127),o=i(0,24);o.push(25),o.push.apply(o,i(28,32));let a=i(0,14),c;e.setDefault(1,0),e.addMany(s,0,2,0);for(c in a)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(Fi,0,2,0),e.add(Fi,8,5,8),e.add(Fi,6,0,6),e.add(Fi,11,0,11),e.add(Fi,13,13,13),e})(),Bk=class extends Qe{constructor(e=Ik){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 G_,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(mt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Lk),this._dcsParser=this._register(new Tk),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let a=e.intermediates.charCodeAt(o);if(32>a||a>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=a}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,i){let s=0,o=0,a=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let h=this._parseStack.handlers,m=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&m>-1){for(;m>=0&&(c=h[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=h[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,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let h=a;h<t;++h){switch(s=e[h],o=this._transitions.table[this.currentState<<8|(s<160?s:Fi)],o>>4){case 2:for(let _=h+1;;++_){if(_>=t||(s=e[_])<32||s>126&&s<Fi){this._printHandler(e,h,_),h=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Fi){this._printHandler(e,h,_),h=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Fi){this._printHandler(e,h,_),h=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Fi){this._printHandler(e,h,_),h=_-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:h,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let m=this._csiHandlers[this._collect<<8|s],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,h),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(++h<t&&(s=e[h])>47&&s<60);h--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let y=this._escHandlers[this._collect<<8|s],S=y?y.length-1:-1;for(;S>=0&&(c=y[S](),c!==!0);S--)if(c instanceof Promise)return this._preserveStack(4,y,S,o,h),c;S<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 _=h+1;;++_)if(_>=t||(s=e[_])===24||s===26||s===27||s>127&&s<Fi){this._dcsParser.put(e,h,_),h=_-1;break}break;case 14:if(c=this._dcsParser.unhook(s!==24&&s!==26),c)return this._preserveStack(6,[],0,o,h),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 _=h+1;;_++)if(_>=t||(s=e[_])<32||s>127&&s<Fi){this._oscParser.put(e,h,_),h=_-1;break}break;case 6:if(c=this._oscParser.end(s!==24&&s!==26),c)return this._preserveStack(5,[],0,o,h),c;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},Ok=/^([\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})$/,zk=/^[\da-f]+$/;function gg(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=Ok.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),zk.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let a=parseInt(t.slice(i*o,i*o+i),16);s[o]=i===1?a<<4:i===2?a:i===3?a>>4:a>>8}return s}}function bu(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 Fk(e,t=16){let[i,s,o]=e;return`rgb:${bu(i,t)}/${bu(s,t)}/${bu(o,t)}`}var Hk={"(":0,")":1,"*":2,"+":3,"-":1,".":2},qn=131072,vg=10;function _g(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 yg=5e3,Sg=0,$k=class extends Qe{constructor(e,t,i,s,o,a,c,h,m=new Bk){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=o,this._oscLinkService=a,this._coreMouseService=c,this._unicodeService=h,this._parser=m,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new ab,this._utf8Decoder=new lb,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Mt.clone(),this._eraseAttrDataInternal=Mt.clone(),this._onRequestBell=this._register(new ke),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ke),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ke),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ke),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ke),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ke),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ke),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ke),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ke),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 Fd(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,y)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:y.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,y,S)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:y,data:S})}),this._parser.setDcsHandlerFallback((p,y,S)=>{y==="HOOK"&&(S=S.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:y,payload:S})}),this._parser.setPrintHandler((p,y,S)=>this.print(p,y,S)),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(fe.BEL,()=>this.bell()),this._parser.setExecuteHandler(fe.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(fe.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(fe.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(fe.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(fe.BS,()=>this.backspace()),this._parser.setExecuteHandler(fe.HT,()=>this.tab()),this._parser.setExecuteHandler(fe.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(fe.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ja.IND,()=>this.index()),this._parser.setExecuteHandler(Ja.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ja.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ei(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new Ei(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new Ei(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new Ei(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new Ei(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new Ei(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new Ei(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new Ei(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new Ei(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new Ei(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new Ei(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new Ei(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 Ot)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 mg((p,y)=>this.requestStatusString(p,y)))}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"),yg))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${yg} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,o=this._activeBuffer.y,a=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>qn&&(a=this._parseStack.position+qn)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,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<qn&&(this._parseBuffer=new Uint32Array(Math.min(e.length,qn))),c||this._dirtyRowTracker.clearRange(),e.length>qn)for(let p=a;p<e.length;p+=qn){let y=p+qn<e.length?p+qn:e.length,S=typeof e=="string"?this._stringDecoder.decode(e.substring(p,y),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,y),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,S))return this._preserveStack(s,o,S,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 h=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),m=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);m<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(m,this._bufferService.rows-1),end:Math.min(h,this._bufferService.rows-1)})}print(e,t,i){let s,o,a=this._charsetService.charset,c=this._optionsService.rawOptions.screenReaderMode,h=this._bufferService.cols,m=this._coreService.decPrivateModes.wraparound,p=this._coreService.modes.insertMode,y=this._curAttrData,S=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&S.getWidth(this._activeBuffer.x-1)===2&&S.setCellFromCodepoint(this._activeBuffer.x-1,0,1,y);let _=this._parser.precedingJoinState;for(let C=t;C<i;++C){if(s=e[C],s<127&&a){let b=a[String.fromCharCode(s)];b&&(s=b.charCodeAt(0))}let w=this._unicodeService.charProperties(s,_);o=Sr.extractWidth(w);let x=Sr.extractShouldJoin(w),k=x?Sr.extractWidth(_):0;if(_=w,c&&this._onA11yChar.fire(Yn(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-k>h){if(m){let b=S,D=this._activeBuffer.x-k;for(this._activeBuffer.x=k,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),S=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),k>0&&S instanceof fo&&S.copyCellsFrom(b,D,0,k,!1);D<h;)b.setCellFromCodepoint(D++,0,1,y)}else if(this._activeBuffer.x=h-1,o===2)continue}if(x&&this._activeBuffer.x){let b=S.getWidth(this._activeBuffer.x-1)?1:2;S.addCodepointToCell(this._activeBuffer.x-b,s,o);for(let D=o-k;--D>=0;)S.setCellFromCodepoint(this._activeBuffer.x++,0,0,y);continue}if(p&&(S.insertCells(this._activeBuffer.x,o-k,this._activeBuffer.getNullCell(y)),S.getWidth(h-1)===2&&S.setCellFromCodepoint(h-1,0,1,y)),S.setCellFromCodepoint(this._activeBuffer.x++,s,o,y),o>0)for(;--o;)S.setCellFromCodepoint(this._activeBuffer.x++,0,0,y)}this._parser.precedingJoinState=_,this._activeBuffer.x<h&&i-t>0&&S.getWidth(this._activeBuffer.x)===0&&!S.hasContent(this._activeBuffer.x)&&S.setCellFromCodepoint(this._activeBuffer.x,0,1,y),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>_g(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new mg(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ei(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,o=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let o=this._activeBuffer.lines.length-this._bufferService.rows;o>0&&(this._activeBuffer.lines.trimStart(o),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-o,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-o,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Mt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=Sr.extractWidth(t),o=this._activeBuffer.x-s,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),c=new Uint32Array(a.length*i),h=0;for(let p=0;p<a.length;){let y=a.codePointAt(p)||0;c[h++]=y,p+=y>65535?2:1}let m=h;for(let p=1;p<i;++p)c.copyWithin(m,0,h),m+=h;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(fe.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(fe.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(fe.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(fe.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(fe.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,vr),this._charsetService.setgCharset(1,vr),this._charsetService.setgCharset(2,vr),this._charsetService.setgCharset(3,vr);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(x=>(x[x.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",x[x.SET=1]="SET",x[x.RESET=2]="RESET",x[x.PERMANENTLY_SET=3]="PERMANENTLY_SET",x[x.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:a}=this._coreMouseService,c=this._coreService,{buffers:h,cols:m}=this._bufferService,{active:p,alt:y}=h,S=this._optionsService.rawOptions,_=(x,k)=>(c.triggerDataEvent(`${fe.ESC}[${t?"":"?"}${x};${k}$y`),!0),C=x=>x?1:2,w=e.params[0];return t?w===2?_(w,4):w===4?_(w,C(c.modes.insertMode)):w===12?_(w,3):w===20?_(w,C(S.convertEol)):_(w,0):w===1?_(w,C(s.applicationCursorKeys)):w===3?_(w,S.windowOptions.setWinLines?m===80?2:m===132?1:0:0):w===6?_(w,C(s.origin)):w===7?_(w,C(s.wraparound)):w===8?_(w,3):w===9?_(w,C(o==="X10")):w===12?_(w,C(S.cursorBlink)):w===25?_(w,C(!c.isCursorHidden)):w===45?_(w,C(s.reverseWraparound)):w===66?_(w,C(s.applicationKeypad)):w===67?_(w,4):w===1e3?_(w,C(o==="VT200")):w===1002?_(w,C(o==="DRAG")):w===1003?_(w,C(o==="ANY")):w===1004?_(w,C(s.sendFocus)):w===1005?_(w,4):w===1006?_(w,C(a==="SGR")):w===1015?_(w,4):w===1016?_(w,C(a==="SGR_PIXELS")):w===1048?_(w,1):w===47||w===1047||w===1049?_(w,C(p===y)):w===2004?_(w,C(s.bracketedPasteMode)):w===2026?_(w,C(s.synchronizedOutput)):_(w,0)}_updateAttrColor(e,t,i,s,o){return t===2?(e|=50331648,e&=-16777216,e|=ko.fromColorRGB([i,s,o])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],o=0,a=0;do{if(s[a+o]=e.params[t+a],e.hasSubParams(t+a)){let c=e.getSubParams(t+a),h=0;do s[1]===5&&(o=1),s[a+h+1+o]=c[h];while(++h<c.length&&h+a+1+o<s.length);break}if(s[1]===5&&a+o>=2||s[1]===2&&a+o>=5)break;s[1]&&(o=1)}while(++a+t<e.length&&a+o<s.length);for(let 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 a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Mt.fg,e.bg=Mt.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|=Mt.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=Mt.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|=Mt.fg&16777215,s.bg&=-67108864,s.bg|=Mt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${fe.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${fe.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(`${fe.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=Mt.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(!_g(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${fe.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>vg&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>vg&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),o=i.shift();if(/^\d+$/.exec(s)){let a=parseInt(s);if(wg(a))if(o==="?")t.push({type:0,index:a});else{let c=gg(o);c&&t.push({type:1,index:a,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(a=>a.startsWith("id="));return o!==-1&&(s=i[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=gg(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]);wg(o)&&t.push({type:2,index:o})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,vr),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Hk[e[0]],Ot[e[1]]||vr),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Mt.clone(),this._eraseAttrDataInternal=Mt.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 Hi;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(`${fe.ESC}${c}${fe.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)}},Fd=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&&(Sg=e,e=t,t=Sg),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Fd=xt([Ne(0,ci)],Fd);function wg(e){return 0<=e&&e<256}var Wk=5e7,bg=12,Uk=50,Kk=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 ke),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>Wk)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=h=>performance.now()-i>=bg?setTimeout(()=>this._innerWrite(0,h)):this._innerWrite(i,h);o.catch(h=>(queueMicrotask(()=>{throw h}),Promise.resolve(!1))).then(c);return}let a=this._callbacks[this._bufferOffset];if(a&&a(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=bg)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Uk&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Hd=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let h=t.addMarker(t.ybase+t.y),m={data:e,id:this._nextId++,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(m,h)),this._dataByLinkId.set(m.id,m),m.id}let i=e,s=this._getEntryIdKey(i),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let a=t.addMarker(t.ybase+t.y),c={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(c,a)),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)))}};Hd=xt([Ne(0,ci)],Hd);var kg=!1,qk=class extends Qe{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new us),this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onData=this._register(new ke),this.onData=this._onData.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ke),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ke),this._instantiationService=new gk,this.optionsService=this._register(new Ek(e)),this._instantiationService.setService(ui,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Id)),this._instantiationService.setService(ci,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ad)),this._instantiationService.setService(m_,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Bd)),this._instantiationService.setService(Nr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Od)),this._instantiationService.setService(p_,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Sr)),this._instantiationService.setService(hb,this.unicodeService),this._charsetService=this._instantiationService.createInstance(jk),this._instantiationService.setService(db,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Hd),this._instantiationService.setService(g_,this._oscLinkService),this._inputHandler=this._register(new $k(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Jt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Jt.forward(this._bufferService.onResize,this._onResize)),this._register(Jt.forward(this.coreService.onData,this._onData)),this._register(Jt.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Kk((t,i)=>this._inputHandler.parse(t,i))),this._register(Jt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ke),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&&!kg&&(this._logService.warn("writeSync is unreliable and will be removed soon."),kg=!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,Y_),t=Math.max(t,X_),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(pg.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(pg(this._bufferService),!1))),this._windowsWrappingHeuristics.value=mt(()=>{for(let t of e)t.dispose()})}}},Vk={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 Yk(e,t,i,s){var c;let o={type:0,cancel:!1,key:void 0},a=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?o.key=fe.ESC+"OA":o.key=fe.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=fe.ESC+"OD":o.key=fe.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=fe.ESC+"OC":o.key=fe.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=fe.ESC+"OB":o.key=fe.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":fe.DEL,e.altKey&&(o.key=fe.ESC+o.key);break;case 9:if(e.shiftKey){o.key=fe.ESC+"[Z";break}o.key=fe.HT,o.cancel=!0;break;case 13:o.key=e.altKey?fe.ESC+fe.CR:fe.CR,o.cancel=!0;break;case 27:o.key=fe.ESC,e.altKey&&(o.key=fe.ESC+fe.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;a?o.key=fe.ESC+"[1;"+(a+1)+"D":t?o.key=fe.ESC+"OD":o.key=fe.ESC+"[D";break;case 39:if(e.metaKey)break;a?o.key=fe.ESC+"[1;"+(a+1)+"C":t?o.key=fe.ESC+"OC":o.key=fe.ESC+"[C";break;case 38:if(e.metaKey)break;a?o.key=fe.ESC+"[1;"+(a+1)+"A":t?o.key=fe.ESC+"OA":o.key=fe.ESC+"[A";break;case 40:if(e.metaKey)break;a?o.key=fe.ESC+"[1;"+(a+1)+"B":t?o.key=fe.ESC+"OB":o.key=fe.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=fe.ESC+"[2~");break;case 46:a?o.key=fe.ESC+"[3;"+(a+1)+"~":o.key=fe.ESC+"[3~";break;case 36:a?o.key=fe.ESC+"[1;"+(a+1)+"H":t?o.key=fe.ESC+"OH":o.key=fe.ESC+"[H";break;case 35:a?o.key=fe.ESC+"[1;"+(a+1)+"F":t?o.key=fe.ESC+"OF":o.key=fe.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=fe.ESC+"[5;"+(a+1)+"~":o.key=fe.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=fe.ESC+"[6;"+(a+1)+"~":o.key=fe.ESC+"[6~";break;case 112:a?o.key=fe.ESC+"[1;"+(a+1)+"P":o.key=fe.ESC+"OP";break;case 113:a?o.key=fe.ESC+"[1;"+(a+1)+"Q":o.key=fe.ESC+"OQ";break;case 114:a?o.key=fe.ESC+"[1;"+(a+1)+"R":o.key=fe.ESC+"OR";break;case 115:a?o.key=fe.ESC+"[1;"+(a+1)+"S":o.key=fe.ESC+"OS";break;case 116:a?o.key=fe.ESC+"[15;"+(a+1)+"~":o.key=fe.ESC+"[15~";break;case 117:a?o.key=fe.ESC+"[17;"+(a+1)+"~":o.key=fe.ESC+"[17~";break;case 118:a?o.key=fe.ESC+"[18;"+(a+1)+"~":o.key=fe.ESC+"[18~";break;case 119:a?o.key=fe.ESC+"[19;"+(a+1)+"~":o.key=fe.ESC+"[19~";break;case 120:a?o.key=fe.ESC+"[20;"+(a+1)+"~":o.key=fe.ESC+"[20~";break;case 121:a?o.key=fe.ESC+"[21;"+(a+1)+"~":o.key=fe.ESC+"[21~";break;case 122:a?o.key=fe.ESC+"[23;"+(a+1)+"~":o.key=fe.ESC+"[23~";break;case 123:a?o.key=fe.ESC+"[24;"+(a+1)+"~":o.key=fe.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=fe.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=fe.DEL:e.keyCode===219?o.key=fe.ESC:e.keyCode===220?o.key=fe.FS:e.keyCode===221&&(o.key=fe.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let h=(c=Vk[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(h)o.key=fe.ESC+h;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=fe.ESC+p}else if(e.keyCode===32)o.key=fe.ESC+(e.ctrlKey?fe.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let m=e.code.slice(3,4);e.shiftKey||(m=m.toLowerCase()),o.key=fe.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=fe.US),e.key==="@"&&(o.key=fe.NUL));break}return o}var Pt=0,Xk=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new fl,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new fl,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((o,a)=>this._getKey(o)-this._getKey(a)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[o]=e[t],t++):s[o]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(Pt=this._search(t),Pt===-1)||this._getKey(this._array[Pt])!==t)return!1;do if(this._array[Pt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Pt),!0;while(++Pt<this._array.length&&this._getKey(this._array[Pt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,a)=>o-a),t=0,i=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:i[s++]=this._array[o];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Pt=this._search(e),!(Pt<0||Pt>=this._array.length)&&this._getKey(this._array[Pt])===e))do yield this._array[Pt];while(++Pt<this._array.length&&this._getKey(this._array[Pt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Pt=this._search(e),!(Pt<0||Pt>=this._array.length)&&this._getKey(this._array[Pt])===e))do t(this._array[Pt]);while(++Pt<this._array.length&&this._getKey(this._array[Pt])===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}},ku=0,Cg=0,Gk=class extends Qe{constructor(){super(),this._decorations=new Xk(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new ke),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ke),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(mt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Qk(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,o=0;for(let a of this._decorations.getKeyIterator(t))s=a.options.x??0,o=s+(a.options.width??1),e>=s&&e<o&&(!i||(a.options.layer??"bottom")===i)&&(yield a)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,o=>{ku=o.options.x??0,Cg=ku+(o.options.width??1),e>=ku&&e<Cg&&(!i||(o.options.layer??"bottom")===i)&&s(o)})}},Qk=class extends Zn{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ke),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ke),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=St.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=St.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Jk=1e3,Zk=class{constructor(e,t=Jk){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=s-this._lastRefreshMs,a=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},a)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},xg=20,pl=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 a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Zk(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(a=>this._handleResize(a.rows))),this._register(this._terminal.onRender(a=>this._refreshRows(a.start,a.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(a=>this._handleChar(a))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
64
|
-
`))),this._register(this._terminal.onA11yTab(a=>this._handleTab(a))),this._register(this._terminal.onKey(a=>this._handleKey(a.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ke(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(mt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<xg+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
65
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===xg+1&&(this._liveRegion.textContent+=ad.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let o=e;o<=t;o++){let a=i.lines.get(i.ydisp+o),c=[],h=(a==null?void 0:a.translateToString(!0,void 0,void 0,c))||"",m=(i.ydisp+o+1).toString(),p=this._rowElements[o];p&&(h.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=h,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"),a=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===a||e.relatedTarget!==s)return;let c,h;if(t===0?(c=i,h=this._rowElements.pop(),this._rowContainer.removeChild(h)):(c=this._rowElements.shift(),h=i,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),h.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let m=this._createAccessibilityTreeNode();this._rowElements.unshift(m),this._rowContainer.insertAdjacentElement("afterbegin",m)}else{let m=this._createAccessibilityTreeNode();this._rowElements.push(m),this._rowContainer.appendChild(m)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var h;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((h=s.textContent)==null?void 0:h.length)??0}),!this._rowContainer.contains(i.node))return;let o=({node:m,offset:p})=>{let y=m instanceof Text?m.parentNode:m,S=parseInt(y==null?void 0:y.getAttribute("aria-posinset"),10)-1;if(isNaN(S))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(y);if(!_)return console.warn("columns is null. Race condition?"),null;let C=p<_.length?_[p]:_.slice(-1)[0]+1;return C>=this._terminal.cols&&(++S,C=0),{row:S,column:C}},a=o(t),c=o(i);if(!(!a||!c)){if(a.row>c.row||a.row===c.row&&a.column>=c.column)throw new Error("invalid range");this._terminal.select(a.column,a.row,(c.row-a.row)*this._terminal.cols-a.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,a;e.style.transform="";let t=e.getBoundingClientRect().width,i=(a=(o=this._rowColumns.get(e))==null?void 0:o.slice(-1))==null?void 0:a[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};pl=xt([Ne(1,uh),Ne(2,kn),Ne(3,Cn)],pl);var $d=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 ke),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ke),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(mt(()=>{var a;Cr(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(a=this._activeProviderReplies)==null||a.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ke(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ke(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ke(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ke(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s<i.length;s++){let o=i[s];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var s,o;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(a=>{a==null||a.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[a,c]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(a)&&(i=this._checkLinkProviderResult(a,e,i)):c.provideLinks(e.y,h=>{var p,y;if(this._isMouseOut)return;let m=h==null?void 0:h.map(S=>({link:S}));(p=this._activeProviderReplies)==null||p.set(a,m),i=this._checkLinkProviderResult(a,e,i),((y=this._activeProviderReplies)==null?void 0:y.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let a=0;a<o.length;a++){let c=o[a],h=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=h;p<=m;p++){if(i.has(p)){o.splice(a--,1);break}i.add(p)}}}}_checkLinkProviderResult(e,t,i){var a;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(h=>this._linkAtPosition(h.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 h=(a=this._activeProviderReplies.get(c))==null?void 0:a.find(m=>this._linkAtPosition(m.link,t));if(h){i=!0,this._handleNewLink(h);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&eC(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Cr(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,o,a;(s=this._currentLink)!=null&&s.state&&((a=(o=this._currentLink)==null?void 0:o.state)==null?void 0:a.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return i<=o&&o<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,o){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:o}}};$d=xt([Ne(1,dh),Ne(2,Cn),Ne(3,ci),Ne(4,__)],$d);function eC(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 tC=class extends qk{constructor(e={}){super(e),this._linkifier=this._register(new us),this.browser=B_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new us),this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ke),this.onKey=this._onKey.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ke),this.onBell=this._onBell.event,this._onFocus=this._register(new ke),this._onBlur=this._register(new ke),this._onA11yCharEmitter=this._register(new ke),this._onA11yTabEmitter=this._register(new ke),this._onWillOpen=this._register(new ke),this._setup(),this._decorationService=this._instantiationService.createInstance(Gk),this._instantiationService.setService(Co,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(U1),this._instantiationService.setService(__,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(cd)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Jt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Jt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Jt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Jt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(mt(()=>{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=ft.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${fe.ESC}]${s};${Fk(o)}${A_.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(a=>a.ansi[t.index]=Lt.toColor(...t.color));else{let a=i;this._themeService.modifyColors(c=>c[a]=Lt.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(pl,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(fe.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(fe.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(i),a=this._renderService.dimensions.css.cell.width*o,c=this.buffer.y*this._renderService.dimensions.css.cell.height,h=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=c+"px",this.textarea.style.width=a+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ke(this.element,"copy",t=>{this.hasSelection()&&sb(t,this._selectionService)}));let e=t=>ob(t,this.textarea,this.coreService,this.optionsService);this._register(Ke(this.textarea,"paste",e)),this._register(Ke(this.element,"paste",e)),O_?this._register(Ke(this.element,"mousedown",t=>{t.button===2&&Am(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ke(this.element,"contextmenu",t=>{Am(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),yh&&this._register(Ke(this.element,"auxclick",t=>{t.button===1&&c_(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ke(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ke(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ke(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ke(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ke(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ke(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ke(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var o;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((o=this.element)==null?void 0:o.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ke(this.screenElement,"mousemove",a=>this.updateCursorStyle(a))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",od.get()),H_||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($1,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(kn,this._coreBrowserService),this._register(Ke(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(Ke(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Dd,this._document,this._helperContainer),this._instantiationService.setService(_l,this._charSizeService),this._themeService=this._instantiationService.createInstance(Td),this._instantiationService.setService(fs,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(dl),this._instantiationService.setService(v_,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Md,this.rows,this.screenElement)),this._instantiationService.setService(Cn,this._renderService),this._register(this._renderService.onRenderedViewportChange(a=>this._onRender.fire(a))),this.onResize(a=>this._renderService.resize(a.cols,a.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Nd,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(jd),this._instantiationService.setService(dh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance($d,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(xd,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(a=>{super.scrollLines(a,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Ld,this.element,this.screenElement,s)),this._instantiationService.setService(pb,this._selectionService),this._register(this._selectionService.onRequestScrollLines(a=>this.scrollLines(a.amount,a.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(a=>this._renderService.handleSelectionChanged(a.start,a.end,a.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(a=>{this.textarea.value=a,this.textarea.focus(),this.textarea.select()})),this._register(Jt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var a;this._selectionService.refresh(),(a=this._viewport)==null||a.queueSync()})),this._register(this._instantiationService.createInstance(Ed,this.screenElement)),this._register(Ke(this.element,"mousedown",a=>this._selectionService.handleMouseDown(a))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(pl,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ul,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ul,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Pd,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(a){var p,y,S,_,C;let c=e._mouseService.getMouseReportCoords(a,e.screenElement);if(!c)return!1;let h,m;switch(a.overrideType||a.type){case"mousemove":m=32,a.buttons===void 0?(h=3,a.button!==void 0&&(h=a.button<3?a.button:3)):h=a.buttons&1?0:a.buttons&4?1:a.buttons&2?2:3;break;case"mouseup":m=0,h=a.button<3?a.button:3;break;case"mousedown":m=1,h=a.button<3?a.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(a)===!1)return!1;let w=a.deltaY;if(w===0||e.coreMouseService.consumeWheelEvent(a,(_=(S=(y=(p=e._renderService)==null?void 0:p.dimensions)==null?void 0:y.device)==null?void 0:S.cell)==null?void 0:_.height,(C=e._coreBrowserService)==null?void 0:C.dpr)===0)return!1;m=w<0?0:1,h=4;break;default:return!1}return m===void 0||h===void 0||h>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:h,action:m,ctrl:a.ctrlKey,alt:a.altKey,shift:a.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:a=>(i(a),a.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(a)),wheel:a=>(i(a),this.cancel(a,!0)),mousedrag:a=>{a.buttons&&i(a)},mousemove:a=>{a.buttons||i(a)}};this._register(this.coreMouseService.onProtocolChange(a=>{a?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(a)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),a&8?s.mousemove||(t.addEventListener("mousemove",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),a&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),a&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),a&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ke(t,"mousedown",a=>{if(a.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(a)))return i(a),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(a)})),this._register(Ke(t,"wheel",a=>{var c,h,m,p,y;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(a)===!1)return!1;if(!this.buffer.hasScrollback){if(a.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(a,(p=(m=(h=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:h.device)==null?void 0:m.cell)==null?void 0:p.height,(y=e._coreBrowserService)==null?void 0:y.dpr)===0)return this.cancel(a,!0);let S=fe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(a.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(S,!0),this.cancel(a,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){l_(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=Yk(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===fe.ETX||i.key===fe.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)&&(iC(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(Mt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(fe.ESC+"[I"):this.coreService.triggerDataEvent(fe.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${fe.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(`${fe.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function iC(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var nC=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)}},rC=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 Hi)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Eg=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 rC(t)}getNullCell(){return new Hi}},sC=class extends Qe{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ke),this.onBufferChange=this._onBufferChange.event,this._normal=new Eg(this._core.buffers.normal,"normal"),this._alternate=new Eg(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)}},oC=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)}},aC=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}},lC=["cols","rows"],rn=0,cC=class extends Qe{constructor(e){super(),this._core=this._register(new tC(e)),this._addonManager=this._register(new nC),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(lC.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 oC(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new aC(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 sC(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
66
|
-
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return od.get()},set promptLabel(e){od.set(e)},get tooMuchOutput(){return ad.get()},set tooMuchOutput(e){ad.set(e)}}}_verifyIntegers(...e){for(rn of e)if(rn===1/0||isNaN(rn)||rn%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(rn of e)if(rn&&(rn===1/0||isNaN(rn)||rn%1!==0||rn<0))throw new Error("This API only accepts positive integers")}};/**
|
|
67
|
-
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
68
|
-
* @license MIT
|
|
69
|
-
*
|
|
70
|
-
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
71
|
-
* @license MIT
|
|
72
|
-
*
|
|
73
|
-
* Originally forked from (with the author's permission):
|
|
74
|
-
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
75
|
-
* http://bellard.org/jslinux/
|
|
76
|
-
* Copyright (c) 2011 Fabrice Bellard
|
|
77
|
-
*/var uC=2,dC=1,hC=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 S;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:((S=this._terminal.options.overviewRuler)==null?void 0:S.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),o=Math.max(0,parseInt(i.getPropertyValue("width"))),a=window.getComputedStyle(this._terminal.element),c={top:parseInt(a.getPropertyValue("padding-top")),bottom:parseInt(a.getPropertyValue("padding-bottom")),right:parseInt(a.getPropertyValue("padding-right")),left:parseInt(a.getPropertyValue("padding-left"))},h=c.top+c.bottom,m=c.right+c.left,p=s-h,y=o-m-t;return{cols:Math.max(uC,Math.floor(y/e.css.cell.width)),rows:Math.max(dC,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 pC({session:e,node:t,token:i,cols:s,rows:o,readonly:a=!1,takeSize:c,focused:h,onData:m,onExit:p,onFiles:y,retryBaseMs:S=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 x=null,k=!1,b=!1,D=null,L=0,M=h;const te=()=>{if(k||b||D)return;const O=Math.min(5e3,Math.max(0,S)*2**Math.min(L++,5));D=setTimeout(()=>{D=null,U()},O)},U=()=>{if(k||b)return;const O=new WebSocket(w);x=O,O.binaryType="arraybuffer",O.onopen=()=>{if(x!==O||k)return;L=0;const ee={type:"attach",session:e,token:i,cols:s,rows:o,readonly:a};c!==void 0&&(ee.takeSize=c),O.send(JSON.stringify(ee)),M!==void 0&&O.send(JSON.stringify({type:"focus",on:!!M}))},O.onmessage=ee=>{if(!(x!==O||k))if(typeof ee.data=="string"){let q;try{q=JSON.parse(ee.data)}catch{return}q.type==="exit"&&(b=!0,p&&p(q.code)),q.type==="files"&&y&&y(q)}else m&&m(new Uint8Array(ee.data))},O.onerror=()=>{if(x===O)try{O.close()}catch{}},O.onclose=ee=>{x!==O||k||b||[1e3,1002,4401,4404].includes(ee==null?void 0:ee.code)||te()}};return U(),{sendInput:O=>{if(!x||x.readyState!==1)return!1;try{return x.send(typeof O=="string"?new TextEncoder().encode(O):O),!0}catch{try{x.close()}catch{}return!1}},isReady:()=>!!x&&x.readyState===1,resize:(O,ee)=>{s=O,o=ee,(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"resize",cols:O,rows:ee}))},action:O=>{(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"action",name:O}))},focus:O=>{M=O,(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"focus",on:!!O}))},close:()=>{if(k=!0,D&&clearTimeout(D),D=null,x)try{x.close()}catch{}},get raw(){return x}}}async function Ng(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 mC="\r";function gC(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 vC({isReady:e,paste:t,send:i}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:i(mC)!==!1}catch{return!1}}}function _C(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function yC(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}const SC=450,Rg=8;function wC(e,t,i,s){return Math.abs(Number(i)-Number(e))>Rg||Math.abs(Number(s)-Number(t))>Rg}const bC=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function Cu(e){return e?e.files&&e.files.length>0||Array.from(e.items||[]).some(t=>t&&t.kind==="file")?!0:Array.from(e.types||[]).includes("Files"):!1}function Pg(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 kC(e,t=0,i=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=bC.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${i}-${t+1}.${o}`}async function Q_({files:e,token:t,session:i,node:s="",paste:o=!0,fetchImpl:a=qt,onProgress:c=()=>{},now:h=Date.now()}={}){const m=Array.from(e||[]).filter(Boolean),p=[],y=[];if(!i||!m.length)return{paths:p,errors:y};const S=yi(s?String(s).split("/"):[]);for(let _=0;_<m.length;_+=1){const C=m[_],w=kC(C,_,h);c({index:_,total:m.length,name:w,state:"uploading"});try{const x=new FormData;x.append("session",i),x.append("paste",o?"true":"false"),x.append("file",C,w);const k=await a(`${S}/files/upload`,t,{method:"POST",body:x}),b=await k.json().catch(()=>({}));if(!k.ok||b.error)throw new Error(b.error||`HTTP ${k.status}`);p.push(b.path),c({index:_,total:m.length,name:w,state:"done",path:b.path})}catch(x){const k=String((x==null?void 0:x.message)||x);y.push({name:w,message:k}),c({index:_,total:m.length,name:w,state:"error",error:k})}}return{paths:p,errors:y}}function J_({session:e,node:t,token:i,readonly:s,takeSize:o,focused:a,sendRef:c,composerRef:h,actionRef:m,ctrlRef:p,setCtrlArmed:y,onFiles:S,fontSize:_=13,selectionMode:C=!1,onSelectionModeChange:w}){const x=R.useRef(null),k=R.useRef(null),b=R.useRef(_);b.current=_;const D=R.useRef(a);D.current=a;const L=R.useRef(C);L.current=C;const[M,te]=R.useState(""),[U,O]=R.useState(""),[ee,q]=R.useState(null),J=async()=>{var P,I,$,K;const T=((I=(P=k.current)==null?void 0:P.term)==null?void 0:I.getSelection())||M;if(!T){O(v("copy-empty")),setTimeout(()=>O(""),1500);return}const N=await Ng(T);O(v(N?"copied":"copy-manual")),N&&((K=($=k.current)==null?void 0:$.term)==null||K.clearSelection(),w==null||w(!1)),setTimeout(()=>O(""),1800)},Q=R.useRef(J);return Q.current=J,R.useEffect(()=>{const T=k.current;T&&T.sock&&T.sock.focus&&T.sock.focus(!!a)},[a]),R.useEffect(()=>{const T=k.current;T&&(T.term.options.fontSize=_,T.fit.fit(),T.sock.resize(T.term.cols,T.term.rows))},[_]),R.useEffect(()=>{const T=new cC({cursorBlink:!0,fontSize:b.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),N=new hC;T.loadAddon(N),T.open(x.current),N.fit();const P=new TextDecoder;let I;try{I=pC({session:e,node:t,token:i,readonly:s,takeSize:o,focused:D.current,onFiles:S,cols:T.cols,rows:T.rows,onData:H=>T.write(P.decode(H)),onExit:()=>T.write(`\r
|
|
78
|
-
\x1B[33m[sessione finita]\x1B[0m\r
|
|
79
|
-
`)})}catch(H){return T.write(`\r
|
|
80
|
-
\x1B[31m${H.message}\x1B[0m\r
|
|
81
|
-
`),()=>T.dispose()}k.current={term:T,fit:N,sock:I};let $=null;const K=T.onData(H=>{if(s){$&&($.ok=!1);return}if(!$&&p&&p.current&&H.length===1){const me=H.charCodeAt(0);let Ae=me;me>=97&&me<=122?Ae=me-96:me>=64&&me<=95?Ae=me-64:me===32&&(Ae=0),H=String.fromCharCode(Ae),p.current=!1,y&&y(!1)}const re=I.sendInput(H);$&&($.seen=!0,$.ok=$.ok&&re)});c&&(c.current=H=>I.sendInput(H)),m&&(m.current=H=>I.action(H)),h&&(h.current=vC({isReady:()=>!s&&I.isReady(),paste:H=>{const re={seen:!1,ok:!0};$=re;try{T.paste(H)}catch{re.ok=!1}finally{$=null}return re.seen&&re.ok},send:H=>I.sendInput(H)}));const F=T.onSelectionChange(()=>te(T.getSelection()));T.attachCustomKeyEventHandler(H=>(H.ctrlKey||H.metaKey)&&H.key.toLowerCase()==="c"&&T.getSelection()?(H.type==="keydown"&&Ng(T.getSelection()),!1):!0);const ae=x.current;let W=!1;const j=async H=>{if(!H.length||W)return;if(s){q({error:v("settings-readonly")});return}W=!0,q({current:0,total:H.length,name:""});const re=await Q_({files:H,token:i,session:e,node:t,paste:!0,onProgress:({index:me,total:Ae,name:Se,state:xe,error:He})=>q({current:me+1,total:Ae,name:Se,...xe==="error"?{error:He}:{}})});W=!1,re.errors.length?q({error:re.errors.map(me=>`${me.name}: ${me.message}`).join(" · ")}):(q({done:!0,total:re.paths.length}),setTimeout(()=>q(null),1600))},A=H=>{const re=H.clipboardData;if(!Cu(re))return;const me=Pg(re);me.length&&(H.preventDefault(),H.stopPropagation(),j(me))},se=H=>{Cu(H.dataTransfer)&&(H.preventDefault(),H.stopPropagation())},ge=H=>{Cu(H.dataTransfer)&&(H.preventDefault(),H.stopPropagation(),j(Pg(H.dataTransfer)))};ae.addEventListener("paste",A,!0),ae.addEventListener("dragenter",se,!0),ae.addEventListener("dragover",se,!0),ae.addEventListener("drop",ge,!0);const G=24;let Z=null,ue=null,de=0,Ce=null,Re=null,tt=null,Je=!1;const Ee=()=>{tt&&clearTimeout(tt),tt=null},rt=(H,re)=>{const Ae=(ae.querySelector(".xterm-screen")||ae).getBoundingClientRect(),Se=Math.max(0,Math.min(T.cols-1,Math.floor((H-Ae.left)/Math.max(1,Ae.width)*T.cols))),xe=Math.max(0,Math.min(T.rows-1,Math.floor((re-Ae.top)/Math.max(1,Ae.height)*T.rows)));return{col:Se,row:T.buffer.active.viewportY+xe}},wt=H=>rt(H.clientX,H.clientY),Dt=H=>{if(Ee(),Je=!1,H.touches.length!==1){Z=null;return}if(L.current){H.preventDefault(),H.stopPropagation(),Re=wt(H.touches[0]),T.clearSelection();return}Z=H.touches[0].clientY,ue=H.touches[0].clientX,de=0,Ce=null;const re={x:ue,y:Z};tt=setTimeout(()=>{tt=null,Je=!0,L.current=!0,w==null||w(!0),Re=rt(re.x,re.y),T.clearSelection(),T.select(Re.col,Re.row,1),Z=null,ue=null,Ce=null,de=0},SC)},st=H=>{if((L.current||Je)&&Re&&H.touches.length===1){H.preventDefault(),H.stopPropagation();const me=wt(H.touches[0]),Ae=Re.row*T.cols+Re.col,Se=me.row*T.cols+me.col,xe=Ae<=Se?Re:me;T.select(xe.col,xe.row,Math.abs(Se-Ae)+1);return}if(Z===null||H.touches.length!==1)return;H.preventDefault(),H.stopPropagation();const re=H.touches[0];if(tt&&wC(ue,Z,re.clientX,re.clientY)&&Ee(),Ce===null&&(Math.abs(re.clientY-Z)>8||Math.abs(re.clientX-ue)>8)&&(Ce=Math.abs(re.clientY-Z)>Math.abs(re.clientX-ue)),!!Ce){for(de+=re.clientY-Z,Z=re.clientY;de>=G;)I.action("scroll-up"),de-=G;for(;de<=-G;)I.action("scroll-down"),de+=G}},gt=()=>{Ee(),Z=null,ue=null,Re=null,Je=!1};let ct=0;const at=H=>{for(H.preventDefault(),H.stopPropagation(),ct+=H.deltaY;ct<=-G;)I.action("scroll-up"),ct+=G;for(;ct>=G;)I.action("scroll-down"),ct-=G};ae.addEventListener("touchstart",Dt,{passive:!1}),ae.addEventListener("touchmove",st,{passive:!1,capture:!0}),ae.addEventListener("touchend",gt,{passive:!0}),ae.addEventListener("touchcancel",gt,{passive:!0});const le=H=>{(L.current||Je)&&(H.preventDefault(),H.stopPropagation())};ae.addEventListener("contextmenu",le,!0),ae.addEventListener("wheel",at,{passive:!1,capture:!0});let be=null;const Fe=H=>{_C(H)&&(H.preventDefault(),H.stopPropagation(),be=rt(H.clientX,H.clientY),T.clearSelection())},$e=H=>{if(!be)return;H.preventDefault(),H.stopPropagation();const re=rt(H.clientX,H.clientY),me=be.row*T.cols+be.col,Ae=re.row*T.cols+re.col,Se=me<=Ae?be:re;T.select(Se.col,Se.row,Math.abs(Ae-me)+1)},pe=H=>{be&&(H.stopPropagation(),be=null)};ae.addEventListener("mousedown",Fe,!0),ae.addEventListener("mousemove",$e,!0),ae.addEventListener("mouseup",pe,!0);const Be=H=>{!yC(H)||!(k.current&&k.current.term&&k.current.term.getSelection())||(H.preventDefault(),H.stopPropagation(),Q.current&&Q.current())};ae.addEventListener("keydown",Be,!0);const Te=()=>{N.fit(),I.resize(T.cols,T.rows)};window.addEventListener("resize",Te);const Y=window.visualViewport;Y&&(Y.addEventListener("resize",Te),Y.addEventListener("scroll",Te));let ne=null,z=0;return typeof ResizeObserver<"u"&&(ne=new ResizeObserver(()=>{z&&cancelAnimationFrame(z),z=requestAnimationFrame(Te)}),ne.observe(ae)),()=>{k.current=null,c&&(c.current=()=>!1),h&&(h.current=()=>!1),m&&(m.current=()=>!1),K.dispose(),F.dispose(),ae.removeEventListener("touchstart",Dt),ae.removeEventListener("touchmove",st,{capture:!0}),ae.removeEventListener("touchend",gt),ae.removeEventListener("touchcancel",gt),ae.removeEventListener("contextmenu",le,!0),Ee(),ae.removeEventListener("wheel",at,{capture:!0}),ae.removeEventListener("mousedown",Fe,!0),ae.removeEventListener("mousemove",$e,!0),ae.removeEventListener("mouseup",pe,!0),ae.removeEventListener("keydown",Be,!0),ae.removeEventListener("paste",A,!0),ae.removeEventListener("dragenter",se,!0),ae.removeEventListener("dragover",se,!0),ae.removeEventListener("drop",ge,!0),window.removeEventListener("resize",Te),Y&&(Y.removeEventListener("resize",Te),Y.removeEventListener("scroll",Te)),ne&&ne.disconnect(),z&&cancelAnimationFrame(z),I.close(),T.dispose()}},[e,t,i,s,o,c,h,m,p,y,S]),u.jsxs("div",{className:`nc-terminal${C?" selecting":""}`,children:[u.jsx("div",{className:"nc-terminal-host",ref:x}),ee&&u.jsx("div",{className:`nc-upload-state${ee.error?" error":""}`,role:"status",children:ee.error?ee.error:ee.done?v("attach-uploaded").replace("{n}",String(ee.total||0)):v("attach-upload-progress").replace("{n}",String(ee.current||0)).replace("{total}",String(ee.total||0))}),(M||C)&&u.jsxs("div",{className:"nc-selection-tools",children:[M?u.jsx("button",{type:"button",onClick:J,children:U||v("copy")}):u.jsx("span",{children:v("select-drag")}),u.jsx("button",{type:"button",onClick:()=>{var T,N;(N=(T=k.current)==null?void 0:T.term)==null||N.clearSelection(),te(""),w==null||w(!1)},children:v("cancel")}),U===v("copy-manual")&&u.jsx("textarea",{readOnly:!0,value:M,onFocus:T=>T.target.select()})]})]})}const Dg="",_i="\x1B",CC=[{label:"↑",seq:_i+"[A"},{label:"↓",seq:_i+"[B"},{label:"PGUP",seq:_i+"[5~"},{label:"PGDN",seq:_i+"[6~"}];function xC({send:e,action:t,ctrlArmed:i=!1,onCtrl:s,onKeyboard:o,selectionMode:a=!1,onSelectionMode:c}){const[h,m]=R.useState(!1),[p,y]=R.useState(!1),[S,_]=R.useState(!1),C=k=>{S?(e(_i+k),_(!1)):e(k)},w=(k,b,D)=>u.jsx("button",{onMouseDown:L=>{L.preventDefault(),C(b),D&&D()},children:k},k),x=(k,b)=>u.jsx("button",{onMouseDown:D=>{D.preventDefault(),t(b),y(!1)},children:k},k);return h?u.jsxs("div",{className:"nc-keybar copy",children:[u.jsx("span",{className:"tag",children:"copy-mode"}),CC.map(k=>w(k.label,k.seq)),w("ESCI (q)","q",()=>m(!1))]}):u.jsxs("div",{className:"nc-keybar termux",children:[p&&u.jsxs("div",{className:"nc-keymenu",children:[x("←WIN","prev-window"),x("WIN→","next-window"),x("⬅PANE","pane-left"),x("PANE➡","pane-right"),w("SCROLL",Dg+"[",()=>{m(!0),y(!1)}),u.jsx("button",{className:a?"armed":"",onMouseDown:k=>{k.preventDefault(),c==null||c(!a),y(!1)},children:"SELECT"}),w("⌃C","",()=>y(!1)),w("DETACH",Dg+"d",()=>y(!1))]}),u.jsxs("div",{className:"row",children:[w("ESC",_i),u.jsx("button",{className:p?"armed":"",onMouseDown:k=>{k.preventDefault(),y(b=>!b)},children:"☰"},"menu"),w("/","/"),w("—","-"),w("HOME",_i+"[H"),w("↑",_i+"[A"),w("END",_i+"[F"),w("PGUP",_i+"[5~")]}),u.jsxs("div",{className:"row",children:[w("⇥"," "),u.jsx("button",{onMouseDown:k=>{k.preventDefault(),o&&o()},children:"⌨"},"kbd"),u.jsx("button",{className:i?"armed":"",onMouseDown:k=>{k.preventDefault(),s&&s()},children:"CTRL"},"ctrl"),u.jsx("button",{className:S?"armed":"",onMouseDown:k=>{k.preventDefault(),_(b=>!b)},children:"ALT"},"alt"),w("←",_i+"[D"),w("↓",_i+"[B"),w("→",_i+"[C"),w("PGDN",_i+"[6~")]})]})}const EC=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}){Pi();const a=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",c=t?`${t}:${e}`:e,[h,m]=R.useState("outbox"),[p,y]=R.useState({inbox:[],outbox:[]}),[S,_]=R.useState(""),C=R.useRef(null);async function w(){try{const L=await(await qt(`${a}/files?session=${encodeURIComponent(e)}`,i)).json();if(L.error){_(L.error);return}y(L);const M=L.outbox[0]?L.outbox[0].mtime:0;localStorage.setItem(Tv(c),String(M))}catch(D){_(String(D))}}R.useEffect(()=>{w()},[e,t]),R.useEffect(()=>{s&&s.session===e&&w()},[s]);async function x(D){for(const L of D){_(`carico ${L.name}…`);const M=new FormData;M.append("session",e),M.append("file",L);try{const U=await(await qt(`${a}/files/upload`,i,{method:"POST",body:M})).json();_(U.error?`errore: ${U.error}`:"")}catch(te){_(String(te))}}w()}async function k(D){const L=await qt(`${a}/files/download?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(D)}`,i);if(!L.ok){_("errore download");return}const M=await L.blob(),te=URL.createObjectURL(M),U=document.createElement("a");U.href=te,U.download=D,U.click(),URL.revokeObjectURL(te)}async function b(D){await qt(`${a}/files?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(D)}`,i,{method:"DELETE"}),w()}return u.jsxs("div",{className:"nc-files",children:[u.jsxs("header",{children:[u.jsx("b",{children:t?`${t}:${e}`:e}),u.jsx("button",{onClick:o,title:v("close"),children:u.jsx(et,{name:"x",size:20})})]}),u.jsxs("nav",{children:[u.jsx("button",{className:h==="outbox"?"on":"",onClick:()=>m("outbox"),children:"outbox"}),u.jsx("button",{className:h==="inbox"?"on":"",onClick:()=>m("inbox"),children:"inbox"}),u.jsxs("button",{className:"up",onClick:()=>C.current&&C.current.click(),children:[u.jsx(et,{name:"upload",size:18})," ",v("upload")]}),u.jsx("input",{type:"file",multiple:!0,ref:C,style:{display:"none"},onChange:D=>{x(Array.from(D.target.files||[])),D.target.value=""}})]}),S&&u.jsx("div",{className:"nc-busy",children:S}),u.jsxs("ul",{children:[p[h].map(D=>u.jsxs("li",{children:[u.jsx("span",{className:"name",onClick:()=>k(D.name),children:D.name}),u.jsx("small",{children:EC(D.size)}),u.jsx("button",{onClick:()=>b(D.name),title:"elimina",children:u.jsx(et,{name:"trash",size:18})})]},D.name)),p[h].length===0&&u.jsx("li",{className:"empty",children:v("empty-files")})]})]})}const wl="nc_composer_v1",Wd="nc-composer-reset",NC=50,ey=256*1024,ty=512*1024,RC=768*1024,jg=2*1024*1024,iy=720*60*60*1e3,Ud=1;function ny(e){const t=Number(e);return Number.isFinite(t)&&t>0?t:0}function Sh(e){if(e!==void 0)return e;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function ml(){return{version:Ud,cells:{}}}function ry(e){const t=[];for(const s of Array.isArray(e)?e:[]){const o=typeof s=="string"?s:s&&s.text,a=ny(typeof s=="string"?0:s&&s.at);if(!(typeof o!="string"||!o||o.length>ey)&&!(t.length&&t[t.length-1].text===o)&&(t.push({text:o,at:a}),t.length>=NC))break}let i=0;return t.filter(s=>i+s.text.length>RC?!1:(i+=s.text.length,!0))}function gl(e){if(!e||typeof e!="object")return null;const t=typeof e.draft=="string"&&e.draft.length<=ty?e.draft:"",i=ry(e.history),s=ny(e.updatedAt),o=e.expanded===!0;return!t&&!i.length&&!o?null:{draft:t,history:i,expanded:o,updatedAt:s}}function PC(e){let t;try{t=typeof e=="string"?JSON.parse(e):e}catch{return ml()}if(!t||typeof t!="object"||t.version!==Ud||!t.cells||typeof t.cells!="object")return ml();const i=Object.create(null);for(const[s,o]of Object.entries(t.cells)){if(!s||typeof s!="string"||s.length>512||s==="__proto__"||s==="constructor"||s==="prototype")continue;const a=gl(o);a&&(i[s]=a)}return{version:Ud,cells:i}}function sy(e){const t=Sh(e);if(!t)return ml();try{return PC(t.getItem(wl))}catch{return ml()}}function Mg(e){try{return JSON.stringify(e).length}catch{return 1/0}}function DC(e,t,i){for(const[s,o]of Object.entries(e.cells))s!==i&&o.updatedAt>0&&t-o.updatedAt>iy&&delete e.cells[s]}function oy(e,t){return Object.entries(e.cells).filter(([i])=>i!==t).sort((i,s)=>i[1].updatedAt-s[1].updatedAt).map(([i])=>i)}function jC(e,t){for(;Mg(e)>jg;){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 oy(e,t)){if(Mg(e)<=jg)break;delete e.cells[i]}}function ay(e,t,i){const s=Sh(e);if(!s)return!1;jC(t,i);const o=()=>(s.setItem(wl,JSON.stringify(t)),!0);try{return o()}catch{for(const c of oy(t,i)){delete t.cells[c];try{return o()}catch{}}return!1}}function No(e,t,i,s){const o=sy(t);DC(o,i,e);const a=gl(o.cells[e])||{draft:"",history:[],expanded:!1,updatedAt:0},c=s({...a,history:[...a.history]}),h=gl(c);return h?o.cells[e]={...h,updatedAt:i}:delete o.cells[e],{ok:ay(t,o,e),cell:o.cells[e]||{draft:"",history:[],expanded:!1,updatedAt:i}}}function MC({ownerId:e,node:t,session:i}){const s=String(i||"");if(!s)return"";const o=cs.test(String(e||""))?String(e):t?`route:${String(t)}`:"local";return`${encodeURIComponent(o)}:${encodeURIComponent(s)}`}function oo(e,t,i=Date.now()){if(!e)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=sy(t),o=gl(s.cells[e]);return!o||o.updatedAt>0&&i-o.updatedAt>iy?(s.cells[e]&&(delete s.cells[e],ay(t,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...o,history:[...o.history]}}function Lg(e,t,i,s=Date.now()){const o=String(t||"");return!e||o.length>ty?!1:No(e,i,s,a=>({...a,draft:o})).ok}function Tg(e,t,i=Date.now()){return e?No(e,t,i,s=>({...s,draft:""})).ok:!1}function LC(e,t,i,s=Date.now()){return e?No(e,i,s,o=>({...o,expanded:!!t})).ok:!1}function TC(e,t,i,s=Date.now()){const o=String(t||"");return!e||!o||o.length>ey?!1:No(e,i,s,a=>{const c=a.history.filter(h=>h.text!==o);return c.unshift({text:o,at:s}),{...a,history:ry(c)}}).ok}function AC(e,t,i=Date.now()){return e?No(e,t,i,s=>({...s,history:[]})).ok:!1}function IC(e){const t=Sh(e);if(!t)return!1;try{return t.removeItem(wl),!0}catch{return!1}}const BC=300;function OC(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function zC({ownerId:e,node:t,session:i,storage:s=OC()}){const o=R.useMemo(()=>MC({ownerId:e,node:t,session:i}),[e,t,i]),a=R.useMemo(()=>oo(o,s),[]),[c,h]=R.useState(a.draft),[m,p]=R.useState(a.expanded),[y,S]=R.useState(a.history),[_,C]=R.useState(-1),w=R.useRef(o),x=R.useRef(a.draft),k=R.useRef(null),b=R.useRef(a.updatedAt||0),D=R.useRef(a.draft),L=R.useCallback(()=>{k.current&&clearTimeout(k.current),k.current=null},[]),M=R.useCallback(()=>{L(),Lg(w.current,x.current,s)},[L,s]),te=R.useCallback(()=>{L(),k.current=setTimeout(()=>{k.current=null,Lg(w.current,x.current,s)},BC)},[L,s]),U=R.useCallback(P=>{const I=String(typeof P=="function"?P(x.current):P||"");x.current=I,b.current=Date.now(),D.current=I,C(-1),h(I),te()},[te]),O=R.useCallback((P,I)=>{L(),x.current=P,b.current=Date.now(),h(P),C(I),te()},[L,te]),ee=R.useCallback(()=>{if(!y.length)return!1;const P=Math.min(_+1,y.length-1);return _<0&&(D.current=x.current),O(y[P].text,P),!0},[O,y,_]),q=R.useCallback(()=>{if(_<0)return!1;const P=_-1;return O(P<0?D.current:y[P].text,P),!0},[O,y,_]),J=R.useCallback(P=>{D.current=x.current;const I=y.findIndex($=>$.text===P);O(String(P||""),I)},[O,y]),Q=R.useCallback(()=>{p(P=>{const I=!P;return LC(w.current,I,s),I})},[s]),T=R.useCallback((P,I,$)=>{if(!P)return;if(TC(P,$,s),!(w.current===P)){oo(P,s).draft===I&&Tg(P,s);return}S(oo(P,s).history),D.current="",C(-1),x.current===I?(L(),x.current="",b.current=Date.now(),h(""),Tg(P,s)):te()},[L,te,s]),N=R.useCallback(()=>{AC(w.current,s),S([]),C(-1),D.current=x.current},[s]);return R.useEffect(()=>{if(w.current===o)return;M(),w.current=o;const P=oo(o,s);x.current=P.draft,b.current=P.updatedAt||0,D.current=P.draft,h(P.draft),p(P.expanded),S(P.history),C(-1)},[o,M,s]),R.useEffect(()=>{const P=()=>M(),I=()=>{document.visibilityState==="hidden"&&M()};return window.addEventListener("pagehide",P),document.addEventListener("visibilitychange",I),()=>{window.removeEventListener("pagehide",P),document.removeEventListener("visibilitychange",I),M()}},[M]),R.useEffect(()=>{const P=()=>{L(),x.current="",b.current=0,D.current="",h(""),p(!1),S([]),C(-1)},I=K=>{if(K.key!==wl)return;if(K.newValue==null){P();return}const F=oo(w.current,s);F.updatedAt<b.current||(L(),x.current=F.draft,b.current=F.updatedAt,D.current=F.draft,h(F.draft),p(F.expanded),S(F.history),C(-1))},$=()=>P();return window.addEventListener("storage",I),window.addEventListener(Wd,$),()=>{window.removeEventListener("storage",I),window.removeEventListener(Wd,$)}},[L,s]),{cellKey:o,text:c,setText:U,expanded:m,toggleExpanded:Q,history:y,historyCursor:_,recallPrevious:ee,recallNext:q,selectHistory:J,confirmSubmitted:T,clearHistory:N,flush:M}}function ly({submitText:e,token:t,session:i,node:s,ownerId:o}){Pi();const a=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:c,text:h,setText:m,expanded:p,toggleExpanded:y,history:S,historyCursor:_,recallPrevious:C,recallNext:w,selectHistory:x,confirmSubmitted:k,clearHistory:b,flush:D}=zC({ownerId:o,node:s,session:i}),[L,M]=R.useState(!1),[te,U]=R.useState(""),[O,ee]=R.useState(!1),q=R.useRef(null),J=R.useRef(null),Q=R.useRef(null),[T,N]=R.useState(!1),[P,I]=R.useState({left:0,bottom:0}),[$,K]=R.useState(!1),[F,ae]=R.useState(!1),W=R.useRef(null),j=R.useRef(null),A=R.useRef(null),se=R.useRef(null),ge=R.useRef(null),G=R.useRef(null),Z=R.useRef(null),ue=R.useRef(!1),[de,Ce]=R.useState(!1),[Re,tt]=R.useState({left:0,bottom:0,width:320}),Je=R.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);R.useEffect(()=>{let pe=!1;if(s){ee(!1);return}return qt(`${a}/voice/status`,t).then(Be=>Be.json()).then(Be=>{pe||ee(!!Be.serverSttConfigured)}).catch(()=>{pe||ee(!1)}),()=>{pe=!0}},[t,a]);const rt=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||O);async function wt(){const pe=h,Be=gC(pe);if(!Be||F)return;ae(!0),U("");let Te=!1;try{Te=!!await e(Be)}catch{Te=!1}Te?k(c,pe,Be):U(v("composer-send-failed")),ae(!1),requestAnimationFrame(()=>{var Y;return(Y=Q.current)==null?void 0:Y.focus({preventScroll:!0})})}function Dt(){const pe=W.current&&W.current.getBoundingClientRect();pe&&I({left:Math.max(6,Math.min(pe.left,window.innerWidth-186)),bottom:window.innerHeight-pe.top+6}),N(!0)}function st(pe){N(!1),pe&&W.current&&W.current.focus()}function gt(){const pe=A.current&&A.current.getBoundingClientRect();if(pe){const Be=Math.max(220,Math.min(360,window.innerWidth-12));tt({left:Math.max(6,Math.min(pe.right-Be,window.innerWidth-Be-6)),bottom:window.innerHeight-pe.top+6,width:Be})}Ce(!0)}function ct(pe){Ce(!1),pe&&A.current&&A.current.focus()}R.useEffect(()=>{if(!T)return;const pe=Te=>{Te.key==="Escape"&&st(!0)},Be=Te=>{const Y=j.current&&j.current.contains(Te.target),ne=W.current&&W.current.contains(Te.target);!Y&&!ne&&st(!1)};return document.addEventListener("keydown",pe),document.addEventListener("pointerdown",Be),()=>{document.removeEventListener("keydown",pe),document.removeEventListener("pointerdown",Be)}},[T]),R.useEffect(()=>{if(!de)return;const pe=Te=>{Te.key==="Escape"&&ct(!0)},Be=Te=>{const Y=se.current&&se.current.contains(Te.target),ne=A.current&&A.current.contains(Te.target);!Y&&!ne&&ct(!1)};return document.addEventListener("keydown",pe),document.addEventListener("pointerdown",Be),()=>{document.removeEventListener("keydown",pe),document.removeEventListener("pointerdown",Be)}},[de]);function at(pe){if(!(pe.isComposing||ue.current||pe.altKey||pe.ctrlKey||pe.metaKey)){if(pe.key==="ArrowUp"&&pe.currentTarget.selectionStart===0&&pe.currentTarget.selectionEnd===0){C()&&pe.preventDefault();return}pe.key==="ArrowDown"&&_>=0&&pe.currentTarget.selectionStart===h.length&&pe.currentTarget.selectionEnd===h.length&&w()&&pe.preventDefault()}}function le(pe){st(!1),pe.current&&pe.current.click()}async function be(pe){if(!pe.length||!i)return;K(!0),U("");const{paths:Be,errors:Te}=await Q_({files:pe,token:t,session:i,node:s,paste:!1});Te.length&&U(Te.map(Y=>`${Y.name}: ${Y.message}`).join(" · ")),Be.length&&m(Y=>Y+(Y&&!Y.endsWith(" ")?" ":"")+Be.join(" ")),K(!1)}function Fe(){q.current&&q.current.stop(),J.current&&J.current.stop(),M(!1)}async function $e(){U("");const pe=window.SpeechRecognition||window.webkitSpeechRecognition;if(pe){const Be=new pe;Be.lang="it-IT",Be.continuous=!1,Be.interimResults=!0;const Te=h?`${h} `:"";Be.onresult=Y=>{const ne=Array.from(Y.results).map(z=>z[0].transcript).join("");m(Te+ne)},Be.onend=()=>M(!1),Be.onerror=Y=>{U(`voice: ${Y.error||"errore"}`),M(!1)},q.current=Be,Be.start(),M(!0);return}try{const Be=await navigator.mediaDevices.getUserMedia({audio:!0}),Te=new MediaRecorder(Be),Y=[];Te.ondataavailable=ne=>Y.push(ne.data),Te.onstop=async()=>{Be.getTracks().forEach(ne=>ne.stop()),M(!1),U("trascrivo…");try{const ne=new Blob(Y,{type:Te.mimeType||"audio/webm"}),H=await(await qt(`${a}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:ne})).json();H.error?U(H.error):(U(""),m(re=>re+(re?" ":"")+(H.text||"")))}catch(ne){U(String(ne))}},J.current={stop:()=>Te.state!=="inactive"&&Te.stop()},Te.start(),M(!0)}catch{U("microfono non disponibile"),M(!1)}}return u.jsxs("div",{className:"nc-composer",children:[te&&u.jsx("div",{className:"nc-composer-err",children:te}),u.jsxs("div",{className:"nc-composer-row",children:[i&&u.jsx("button",{ref:W,className:$?"attach busy":"attach",disabled:$,onClick:()=>T?st(!1):Dt(),title:v($?"attach-uploading":"attach"),"aria-label":v("attach"),"aria-haspopup":"menu","aria-expanded":T,"aria-controls":Je.current,children:u.jsx(et,{name:"attach",size:22})}),T&&u.jsxs("div",{ref:j,id:Je.current,role:"menu",className:"nc-attach-menu",style:{left:P.left,bottom:P.bottom},children:[u.jsxs("button",{role:"menuitem",onClick:()=>le(ge),children:[u.jsx(et,{name:"file",size:18})," ",v("attach-file")]}),u.jsxs("button",{role:"menuitem",onClick:()=>le(G),children:[u.jsx(et,{name:"camera",size:18})," ",v("attach-camera")]}),u.jsxs("button",{role:"menuitem",onClick:()=>le(Z),children:[u.jsx(et,{name:"image",size:18})," ",v("attach-gallery")]})]}),u.jsx("button",{ref:A,type:"button",className:"history",onPointerDown:pe=>pe.preventDefault(),onClick:()=>de?ct(!1):gt(),title:v("composer-history-tools"),"aria-label":v("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":de,children:u.jsx(et,{name:"history",size:21})}),de&&u.jsxs("div",{ref:se,role:"menu",className:"nc-composer-history-menu",style:{left:Re.left,bottom:Re.bottom,width:Re.width},children:[u.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:pe=>pe.preventDefault(),onClick:()=>{y(),ct(!1),requestAnimationFrame(()=>{var pe;return(pe=Q.current)==null?void 0:pe.focus({preventScroll:!0})})},children:[u.jsx(et,{name:p?"chevronDown":"chevronUp",size:18}),v(p?"composer-collapse":"composer-expand")]}),u.jsx("div",{className:"nc-composer-history-title",children:v("composer-history")}),S.length===0&&u.jsx("div",{className:"nc-composer-history-empty",children:v("composer-history-empty")}),S.map((pe,Be)=>u.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:Te=>Te.preventDefault(),onClick:()=>{x(pe.text),ct(!1),requestAnimationFrame(()=>{var Te;return(Te=Q.current)==null?void 0:Te.focus({preventScroll:!0})})},children:[u.jsx("span",{children:pe.text.replace(/\s+/g," ").slice(0,180)}),pe.at>0&&u.jsx("small",{children:new Date(pe.at).toLocaleString()})]},`${pe.at}:${Be}`)),S.length>0&&u.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:pe=>pe.preventDefault(),onClick:()=>{b(),ct(!1)},children:v("composer-history-clear")})]}),u.jsx("input",{ref:ge,type:"file",multiple:!0,hidden:!0,onChange:pe=>{be(Array.from(pe.target.files||[])),pe.target.value=""}}),u.jsx("input",{ref:G,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:pe=>{be(Array.from(pe.target.files||[])),pe.target.value=""}}),u.jsx("input",{ref:Z,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:pe=>{be(Array.from(pe.target.files||[])),pe.target.value=""}}),u.jsx("textarea",{ref:Q,className:p?"expanded":"",rows:p?8:2,value:h,placeholder:v("composer-placeholder"),onChange:pe=>m(pe.target.value),onKeyDown:at,onCompositionStart:()=>{ue.current=!0},onCompositionEnd:()=>{ue.current=!1},onBlur:D}),rt&&u.jsx("button",{className:L?"mic on":"mic",onClick:L?Fe:$e,title:v("voice"),children:u.jsx(et,{name:"mic",size:22})}),u.jsx("button",{type:"button",className:"go",disabled:F,onPointerDown:pe=>pe.preventDefault(),onClick:wt,title:v("send"),children:u.jsx(et,{name:"enter",size:22})})]})]})}function Ag(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const FC=180,HC=480,ts=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function $C({sessions:e=[],cells:t=[],activeSessions:i=[],nodeGroups:s=[],onPick:o,onAddTile:a,onPower:c,onBoot:h,onNodePower:m,onKill:p,onVisibility:y,onNew:S,onNodeRename:_,onSettings:C,onBootError:w,localNodeId:x,fleetCapabilities:k=[],bootSettlement:b=null,onBootSettlementApplied:D,width:L=240,collapsed:M=!1,onResize:te,onToggleCollapse:U}){const[O,ee]=Pi(),{pins:q,orders:J,togglePin:Q,viewFor:T,updateView:N,canMoveRoster:P,moveRoster:I,stepRoster:$}=Xv(),{groupsFor:K,moveNode:F,stepNode:ae,nodeKey:W}=Qv(),j=new Set((t||[]).map(Y=>Y.tmuxSession)),A=new Map((e||[]).map(Y=>[Y.name,Y])),se=(Y,ne)=>P0(q,Y,ne),ge=D0,G=[...t||[]].sort((Y,ne)=>ge(se(Y.tmuxSession,(A.get(Y.tmuxSession)||{}).activity),se(ne.tmuxSession,(A.get(ne.tmuxSession)||{}).activity))),Z=(e||[]).filter(Y=>!j.has(Y.name)).sort((Y,ne)=>ge(se(Y.name,Y.activity),se(ne.name,ne.activity))||Y.name.localeCompare(ne.name)),ue=new Set(i||[]),de=t_(G,Z,A),Ce=wr(de,q,T("local").filter,Qn(J,"local")),tt=K(s||[]).map(Y=>{const ne=(Y.route||[Y.name]).join("/"),z=T(ne),{rawItems:H}=nd(Y),re=wr(H,q,z.filter,Qn(J,ne));return{g:Y,nodeRoute:ne,groupView:z,rawItems:H,items:re}}),Je=(Y,ne,z)=>o&&o({session:Y,...ne?{node:ne}:{},...cs.test(String(z||""))?{ownerId:z}:{}}),Ee=async Y=>{if(!(Y!=null&&Y.direct)||!_)return;const ne=window.prompt(v("rename-node-prompt"),Y.label||Y.name);if(ne!==null)try{await _(Y,ne)||window.alert(v("rename-node-invalid"))}catch(z){window.alert(String((z==null?void 0:z.message)||z))}},[rt,wt]=R.useState({}),[Dt,st]=R.useState(new Set);R.useEffect(()=>{const Y=new Map;for(const ne of t||[])Y.set(ts(ne.cell),!!ne.boot);for(const ne of s||[]){const z=ne.route||[ne.name];for(const H of ne.cells||[])Y.set(ts(H.cell,z),!!H.boot)}wt(ne=>{let z=!1;const H={...ne};for(const[re,me]of Object.entries(ne))Y.has(re)&&Y.get(re)===me&&(delete H[re],z=!0);return z?H:ne})},[t,s]),R.useEffect(()=>{if(!(b!=null&&b.cell))return;const Y=Array.isArray(b.route)?b.route:[],ne=ts(b.cell,Y);wt(z=>({...z,[ne]:!!b.enabled})),D&&D(b.id)},[b,D]);const gt=(Y,ne=[])=>{const z=ts(Y.cell,ne);return Object.prototype.hasOwnProperty.call(rt,z)?rt[z]:!!Y.boot},ct=async(Y,ne,z=[])=>{if(Y.stopPropagation(),!h)return;const H=ts(ne.cell,z),re=!gt(ne,z);wt(me=>({...me,[H]:re})),st(me=>new Set(me).add(H));try{await h(ne.cell,re,z)}catch(me){wt(Ae=>{const Se={...Ae};return delete Se[H],Se}),w&&w(me)}finally{st(me=>{const Ae=new Set(me);return Ae.delete(H),Ae})}},at=(Y,ne=[])=>{const z=ts(Y.cell,ne),H=gt(Y,ne),re=`${v(H?"boot-disable":"boot-enable")} ${Y.cell}`;return u.jsx("button",{className:`nc-boot${H?" on":""}`,disabled:Dt.has(z),onClick:me=>ct(me,Y,ne),title:re,"aria-label":re,children:u.jsx(et,{name:"boot",size:14})})},[le,be]=R.useState(null),Fe=(Y,ne)=>{const z=Y.currentTarget.getBoundingClientRect();be({text:ne,y:z.top+z.height/2})},$e=()=>be(null),pe=R.useRef(null);R.useEffect(()=>()=>{pe.current&&pe.current()},[]);function Be(Y){Y.preventDefault(),Y.stopPropagation();const ne=Y.clientX,z=L,H=me=>{const Ae=Math.max(FC,Math.min(HC,z+(me.clientX-ne)));te&&te(Ae)},re=()=>{window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",re),window.removeEventListener("pointercancel",re),window.removeEventListener("blur",re),pe.current=null};window.addEventListener("pointermove",H),window.addEventListener("pointerup",re),window.addEventListener("pointercancel",re),window.addEventListener("blur",re),pe.current=re}const Te=M?{width:48,flex:"0 0 48px"}:{width:L,flex:`0 0 ${L}px`};return M?u.jsxs("aside",{className:"nc-sidebar mini",style:Te,children:[u.jsx("div",{className:"nc-side-head mini",children:u.jsx("button",{className:"nc-collapse-btn",onClick:U,title:v("expand"),children:"⟩"})}),u.jsx("button",{className:"nc-side-gear mini",onClick:()=>C&&C("nodes",!1),title:v("settings"),onMouseEnter:Y=>Fe(Y,v("settings")),onMouseLeave:$e,children:u.jsx(et,{name:"gear",size:16})}),u.jsx("div",{className:"nc-side-scroll mini",children:u.jsxs("div",{className:"nc-side-group mini",children:[T("local").open&&Ce.map(Y=>Y.type==="cell"?(()=>{const ne=Y.value,z=ne.degraded?"warn":ne.tmux?"on":"",H=!!ne.tmux;return u.jsx("button",{type:"button",className:`nc-mini-dot${ue.has(ne.tmuxSession)?" active":""}`,onMouseEnter:re=>Fe(re,`${ne.cell}: ${Y.subtitle}`),onMouseLeave:$e,draggable:H,onDragStart:H?re=>re.dataTransfer.setData("text/nc-session",ne.tmuxSession):void 0,onClick:H?()=>a&&a(ne.tmuxSession):()=>c&&c(ne),onDoubleClick:H?()=>Je(ne.tmuxSession,"",x):void 0,children:u.jsx("span",{className:`nc-dot ${z}${Y.working?" working":""}`})},Y.key)})():(()=>{const ne=Y.value;return u.jsx("button",{type:"button",className:`nc-mini-init${ue.has(ne.name)?" active":""}`,onMouseEnter:z=>Fe(z,ne.name),onMouseLeave:$e,draggable:!0,onDragStart:z=>z.dataTransfer.setData("text/nc-session",ne.name),onClick:()=>a&&a(ne.name),onDoubleClick:()=>Je(ne.name,"",x),children:Ag(ne.name)},Y.key)})()),tt.flatMap(({g:Y,nodeRoute:ne,groupView:z,items:H})=>Y.status==="up"?z.open?H.map(re=>re.type==="cell"?(()=>{const me=re.value,Ae=!!me.tmux;return u.jsx("button",{type:"button",className:`nc-mini-dot${ue.has(re.key)?" active":""}`,onMouseEnter:Se=>Fe(Se,`${Y.label||ne}: ${me.cell} · ${re.subtitle}`),onMouseLeave:$e,draggable:Ae,onDragStart:Ae?Se=>Se.dataTransfer.setData("text/nc-session",re.key):void 0,onClick:Ae?()=>a&&a(re.key):()=>c&&c({...me,route:Y.route,availableEngines:Y.engines||[]}),onDoubleClick:Ae?()=>Je(me.tmuxSession,ne,Y.instanceId):void 0,children:u.jsx("span",{className:`nc-dot ${me.degraded?"warn":Ae?`on${re.working?" working":""}`:""}`})},re.key)})():(()=>{const me=re.value;return u.jsx("button",{type:"button",className:`nc-mini-init${ue.has(re.key)?" active":""}`,onMouseEnter:Ae=>Fe(Ae,`${Y.label||ne}: ${me.name}`),onMouseLeave:$e,draggable:!0,onDragStart:Ae=>Ae.dataTransfer.setData("text/nc-session",re.key),onClick:()=>a&&a(re.key),onDoubleClick:()=>Je(me.name,ne,Y.instanceId),children:Ag(me.name)},re.key)})()):[]:[u.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:re=>Fe(re,`${Y.label||(Y.route||[Y.name]).join(" › ")}: ${ss(Y)}`),onMouseLeave:$e,children:u.jsx("span",{className:`nc-dot${Y.status==="passive"?"":" warn"}`})},`nodo-${(Y.route||[Y.name]).join("/")}`)])]})}),le&&u.jsx("div",{className:"nc-mini-tip",style:{top:le.y},children:le.text})]}):u.jsxs("aside",{className:"nc-sidebar",style:Te,children:[u.jsxs("div",{className:"nc-side-head",children:[u.jsx("button",{className:"nc-collapse-btn",onClick:U,title:v("collapse"),children:"⟨"}),u.jsx("span",{className:"nc-side-title",children:v("fleet")}),u.jsxs("button",{className:"nc-new-btn",onClick:S,title:v("fleet-new-cell"),children:["+ ",v("new")]})]}),u.jsxs("button",{className:"nc-side-gear",onClick:()=>C&&C("nodes",!1),title:v("settings"),children:[u.jsx(et,{name:"gear",size:15})," ",v("settings")]}),u.jsxs("div",{className:"nc-side-scroll",children:[u.jsx(WC,{label:v("position-local"),count:Ce.length,state:T("local"),onToggle:()=>N("local",{open:!T("local").open}),onFilter:Y=>N("local",{filter:Y})}),T("local").open&&u.jsxs("div",{className:"nc-side-group",children:[Ce.map(Y=>Y.type==="cell"?(()=>{const ne=Y.value,z=ne.degraded?"warn":ne.tmux?"on":"",H=ne.degraded?v("cell-degraded"):Y.working?Y.subtitle:ne.tmux?v("cell-idle"):v("cell-off"),re=!!ne.tmux;return u.jsxs("div",{"data-roster-key":Y.key,"data-position":"local",className:`nc-cell${re?" live":""}${ue.has(ne.tmuxSession)?" active":""}`,title:`${ne.cell} · ${Y.subtitle}${H===Y.subtitle?"":` · ${H}`}`,"aria-label":`${ne.cell}, ${Y.subtitle}${H===Y.subtitle?"":`, ${H}`}`,draggable:re,onDragStart:re?me=>me.dataTransfer.setData("text/nc-session",ne.tmuxSession):void 0,onClick:re?()=>a&&a(ne.tmuxSession):void 0,onDoubleClick:re?()=>Je(ne.tmuxSession,"",x):void 0,children:[u.jsx(Xn,{position:"local",itemKey:Y.key,label:ne.cell,canMove:P,onMove:(me,Ae)=>I("local",me,Ae,de),onStep:me=>$("local",Y.key,me,de)}),u.jsx("span",{className:`nc-dot ${z}${Y.working?" working":""}`}),u.jsxs("span",{className:"nc-cell-main",children:[u.jsx("b",{title:ne.cell,children:ne.cell}),u.jsx("small",{title:Y.subtitle,children:Y.subtitle})]}),u.jsx("button",{className:`nc-pin${q.includes(Y.key)?" on":""}`,title:v("pin"),onClick:me=>{me.stopPropagation(),Q(Y.key)},children:q.includes(Y.key)?"★":"☆"}),h&&k.includes("boot")&&at(ne),u.jsx("button",{className:`nc-power${ne.tmux?" on":""}${ne.degraded?" warn":""}`,onClick:me=>{me.stopPropagation(),c&&c({...ne,boot:gt(ne)})},title:ne.active?v("power-off"):v("power-on"),children:u.jsx(et,{name:"power",size:14})})]},Y.key)})():(()=>{var z;const ne=Y.value;return u.jsxs("div",{"data-roster-key":Y.key,"data-position":"local",className:`nc-side-card${ue.has(ne.name)?" active":""}`,draggable:!0,onDragStart:H=>H.dataTransfer.setData("text/nc-session",ne.name),onClick:()=>a&&a(ne.name),onDoubleClick:()=>Je(ne.name,"",x),children:[u.jsx(Xn,{position:"local",itemKey:Y.key,label:ne.name,canMove:P,onMove:(H,re)=>I("local",H,re,de),onStep:H=>$("local",Y.key,H,de)}),u.jsx("span",{className:ne.attached?"nc-dot on":"nc-dot"}),u.jsxs("span",{className:"nc-card-main",children:[u.jsx("b",{children:ne.name}),u.jsxs("small",{children:[ne.preview||ne.cmd||v("windows").replace("{n}",String(ne.windows||0)),((z=ne.outbox)==null?void 0:z.count)>0?` · 📦${ne.outbox.count}`:""]})]}),ne.activity?u.jsx("span",{className:"nc-rel",children:ls(ne.activity)}):null,u.jsx("button",{className:`nc-pin${q.includes(Y.key)?" on":""}`,title:v("pin"),onClick:H=>{H.stopPropagation(),Q(Y.key)},children:q.includes(Y.key)?"★":"☆"}),u.jsx("button",{className:`nc-technical${ne.technical?" on":""}`,title:ne.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${ne.technical?v("mark-normal"):v("mark-technical")} ${ne.name}`,onClick:H=>{H.stopPropagation(),y&&y(ne.name,!ne.technical,[])},children:"T"}),u.jsx("button",{className:"nc-menu",title:v("terminate"),onClick:H=>{H.stopPropagation(),window.confirm(v("terminate-confirm").replace("{name}",ne.name))&&p&&p(ne.name)},children:"⋯"})]},Y.key)})()),Ce.length===0&&u.jsx("div",{className:"nc-empty",children:v("no-sessions-short")})]}),tt.map(({g:Y,nodeRoute:ne,groupView:z,rawItems:H,items:re})=>{const Ae=Jv(Y.health)||(Y.status==="up"?"on":Y.status==="passive"?"":"warn");return u.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":W(Y),children:[u.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:Y.direct&&_?Se=>{Se.preventDefault(),Ee(Y)}:void 0,onClick:()=>N(ne,{open:!z.open}),onKeyDown:Se=>{(Se.key==="Enter"||Se.key===" ")&&(Se.preventDefault(),N(ne,{open:!z.open}))},children:[u.jsx(Xn,{scope:"node",position:"nodes",itemKey:W(Y),label:Y.label||Y.name,onMove:(Se,xe)=>F(Se,xe,s||[]),onStep:Se=>ae(W(Y),Se,s||[])}),u.jsx("span",{className:"nc-node-chevron",children:z.open?"⌄":"›"}),u.jsx("span",{className:`nc-dot ${Ae}`,title:Y.health?sl(Y.health):""}),u.jsx("b",{children:Y.label||Y.name}),u.jsxs("small",{children:[" · ",Y.status==="up"?v("node-sessions").replace("{n}",String(re.length)):Y.health&&sl(Y.health)||ss(Y)]}),u.jsxs("select",{className:"nc-node-filter",value:z.filter,title:v(`view-${z.filter}`),onClick:Se=>Se.stopPropagation(),onChange:Se=>N(ne,{filter:Se.target.value}),children:[u.jsx("option",{value:"all",children:v("view-all")}),u.jsx("option",{value:"pinned",children:v("view-pinned")}),u.jsx("option",{value:"active",children:v("view-active")}),u.jsx("option",{value:"off",children:v("view-off")}),u.jsx("option",{value:"technical",children:v("view-technical")})]}),Y.direct&&_&&u.jsx("button",{type:"button",className:"nc-node-rename",title:v("rename-node"),"aria-label":`${v("rename-node")} ${Y.label||Y.name}`,onClick:Se=>{Se.stopPropagation(),Ee(Y)},children:"✎"}),Y.direct&&Y.health&&Y.health.managed!==!1&&u.jsx("button",{type:"button",className:`nc-power${Y.tunnelStatus==="up"?" on":""}`,title:Y.tunnelStatus==="up"?v("power-off"):v("power-on"),onClick:Se=>{Se.stopPropagation(),m&&m(Y)},children:u.jsx(et,{name:"power",size:14})})]}),Y.status==="up"&&z.open&&u.jsxs("div",{className:"nc-side-group",children:[re.map(Se=>Se.type==="cell"?(()=>{const xe=Se.value,He=!!xe.tmux,Zt=xe.degraded?"warn":xe.tmux?"on":"";return u.jsxs("div",{"data-roster-key":Se.key,"data-position":ne,className:`nc-side-card nc-cell${He?" live":""}${ue.has(xe.key)?" active":""}`,title:Se.working?Se.subtitle:xe.tmux?v("cell-idle"):v("cell-off"),draggable:He,onDragStart:He?Xe=>Xe.dataTransfer.setData("text/nc-session",xe.key):void 0,onClick:He?()=>a&&a(xe.key):void 0,onDoubleClick:He?()=>Je(xe.tmuxSession,ne,Y.instanceId):void 0,children:[u.jsx(Xn,{position:ne,itemKey:Se.key,label:xe.cell,canMove:P,onMove:(Xe,Di)=>I(ne,Xe,Di,H),onStep:Xe=>$(ne,Se.key,Xe,H)}),u.jsx("span",{className:`nc-dot ${Zt}${Se.working?" working":""}`}),u.jsxs("span",{className:"nc-card-main",children:[u.jsx("b",{children:xe.cell}),u.jsx("small",{title:Se.subtitle,children:Se.subtitle})]}),u.jsx("button",{className:`nc-pin${q.includes(Se.key)?" on":""}`,title:v("pin"),onClick:Xe=>{Xe.stopPropagation(),Q(Se.key)},children:q.includes(Se.key)?"★":"☆"}),h&&(Y.capabilities||[]).includes("boot")&&at(xe,Y.route||[]),(Y.capabilities||[]).includes(xe.active?"down":"up")&&u.jsx("button",{className:`nc-power${xe.active?" on":""}${xe.degraded?" warn":""}`,onClick:Xe=>{Xe.stopPropagation(),c&&c({...xe,boot:gt(xe,Y.route||[]),route:Y.route,availableEngines:Y.engines||[]})},title:xe.active?v("power-off"):v("power-on"),children:u.jsx(et,{name:"power",size:14})})]},Se.key)})():(()=>{const xe=Se.value;return u.jsxs("div",{"data-roster-key":Se.key,"data-position":ne,className:`nc-side-card${ue.has(xe.key)?" active":""}`,draggable:!0,onDragStart:He=>He.dataTransfer.setData("text/nc-session",xe.key),onClick:()=>a&&a(xe.key),onDoubleClick:()=>Je(xe.name,xe.node||ne,Y.instanceId),children:[u.jsx(Xn,{position:ne,itemKey:Se.key,label:xe.name,canMove:P,onMove:(He,Zt)=>I(ne,He,Zt,H),onStep:He=>$(ne,Se.key,He,H)}),u.jsx("span",{className:xe.attached?"nc-dot on":"nc-dot"}),u.jsxs("span",{className:"nc-card-main",children:[u.jsx("b",{children:xe.name}),u.jsx("small",{children:xe.preview?xe.preview:xe.cmd?xe.cmd:v("windows").replace("{n}",String(xe.windows||0))})]}),xe.activity?u.jsx("span",{className:"nc-rel",children:ls(xe.activity)}):null,u.jsx("button",{className:`nc-pin${q.includes(Se.key)?" on":""}`,title:v("pin"),onClick:He=>{He.stopPropagation(),Q(Se.key)},children:q.includes(Se.key)?"★":"☆"}),u.jsx("button",{className:`nc-technical${xe.technical?" on":""}`,title:xe.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${xe.technical?v("mark-normal"):v("mark-technical")} ${xe.name}`,onClick:He=>{He.stopPropagation(),y&&y(xe.name,!xe.technical,Y.route||[])},children:"T"}),u.jsx("button",{className:"nc-menu",title:v("terminate"),onClick:He=>{He.stopPropagation(),window.confirm(v("terminate-confirm").replace("{name}",xe.name))&&p&&p(xe.name,Y.route)},children:"⋯"})]},Se.key)})()),re.length===0&&u.jsx("div",{className:"nc-empty",children:v("no-sessions-short")})]})]},`nodo-${(Y.route||[Y.name]).join("/")}`)})]}),u.jsx("div",{className:"nc-side-lang",children:Yv.map((Y,ne)=>u.jsxs("span",{children:[ne>0&&" · ",u.jsx("button",{className:`nc-lang-btn${O===Y?" on":""}`,onClick:()=>ee(Y),title:Y,children:Y.toUpperCase()})]},Y))}),u.jsx("div",{className:"nc-side-resize",onPointerDown:Be,title:""})]})}function WC({label:e,count:t,state:i,onToggle:s,onFilter:o}){return u.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:s,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),s())},children:[u.jsx("span",{className:"nc-node-chevron",children:i.open?"⌄":"›"}),u.jsx("span",{className:"nc-dot on"}),u.jsx("b",{children:e}),u.jsxs("small",{children:[" · ",v("node-sessions").replace("{n}",String(t))]}),u.jsxs("select",{className:"nc-node-filter",value:i.filter,title:v(`view-${i.filter}`),onClick:a=>a.stopPropagation(),onChange:a=>o(a.target.value),children:[u.jsx("option",{value:"all",children:v("view-all")}),u.jsx("option",{value:"pinned",children:v("view-pinned")}),u.jsx("option",{value:"active",children:v("view-active")}),u.jsx("option",{value:"off",children:v("view-off")}),u.jsx("option",{value:"technical",children:v("view-technical")})]})]})}function UC(e,t,i){return!e&&t?i+1:i}function KC({session:e,node:t,ownerId:i,token:s,readonly:o=!1,focused:a,onFocus:c,onClose:h,onOpenSingle:m,alive:p=!0,available:y=!0,fontSize:S=bo,onZoom:_,decks:C=[],currentDeck:w,onSendToDeck:x}){const k=R.useRef(()=>{}),b=R.useRef(()=>!1),D=R.useRef(()=>{}),L=R.useRef(!1),[M,te]=R.useState(!1),[U,O]=R.useState(!1),[ee,q]=R.useState(!1),[J,Q]=R.useState(null),[T,N]=R.useState(0),P=R.useRef(p),I=t?`${t}:${e}`:e,$=C.filter(K=>K.id!==w&&K.available!==!1);return R.useEffect(()=>{const K=P.current;!K&&p&&N(F=>UC(K,p,F)),P.current=p},[p]),u.jsxs("div",{className:`nc-tile${a?" focused":""}`,onMouseDown:()=>c&&c(I),children:[u.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:K=>{K.dataTransfer.setData("text/nc-session",I),K.dataTransfer.effectAllowed="move"},children:[u.jsxs("button",{className:"nc-tile-name",onClick:()=>c&&c(I),children:[u.jsx("span",{className:p?"nc-dot on":"nc-dot"}),u.jsx("b",{children:e}),t&&u.jsxs("small",{className:"nc-tile-node",children:["@",t]})]}),u.jsxs("span",{className:"nc-tile-actions",children:[_&&u.jsx("button",{onClick:()=>_(-1),title:v("zoom-out"),children:u.jsx(et,{name:"zoomOut",size:14})}),_&&u.jsx("button",{onClick:()=>_(1),title:v("zoom-in"),children:u.jsx(et,{name:"zoomIn",size:14})}),x&&$.length>0&&u.jsxs("select",{className:"nc-tile-deck",title:v("send-to-deck"),value:"",onMouseDown:K=>K.stopPropagation(),onChange:K=>{const F=K.target.value;F&&x(I,F),K.target.value=""},children:[u.jsx("option",{value:"",children:v("send-to-deck")}),$.map(K=>u.jsxs("option",{value:K.id,children:[K.ownerLabel," · ",K.name]},K.id))]}),u.jsx("button",{onClick:()=>O(K=>!K),title:"composer",children:"⌨"}),u.jsx("button",{onClick:()=>q(K=>!K),title:"file",children:"📁"}),m&&u.jsx("button",{onClick:()=>m({session:e,node:t,ownerId:i}),title:"vista singola",children:"↗"}),h&&u.jsx("button",{className:"nc-tile-close",onClick:()=>h(I),title:"chiudi",children:"✕"})]})]}),u.jsxs("div",{className:"nc-tile-body",children:[y?u.jsx(J_,{session:e,node:t,token:s,readonly:o,takeSize:!1,focused:a,sendRef:k,composerRef:b,actionRef:D,ctrlRef:L,setCtrlArmed:te,onFiles:Q,fontSize:S},`${I}:${T}`):u.jsx("div",{className:"nc-tile-unavailable",children:v("deck-owner-unavailable")}),y&&ee&&u.jsx("div",{className:"nc-tile-files",onMouseDown:K=>K.stopPropagation(),children:u.jsx(Z_,{session:e,node:t,token:s,filesEvent:J,onClose:()=>q(!1)})})]}),y&&U&&u.jsx("div",{className:"nc-tile-composer",onMouseDown:K=>K.stopPropagation(),children:u.jsx(ly,{submitText:K=>b.current(K),token:s,session:e,node:t,ownerId:i})})]})}const Ig=.2,Bg=.28,cy=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),xu=e=>cy(e,"text/nc-session"),Og=e=>{var t;return cy(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function qC(e,t,i){const s=(e-i.left)/(i.width||1),o=(t-i.top)/(i.height||1);return s<Bg?"left":s>1-Bg?"right":o<.5?"top":"bottom"}function VC({layout:e,onLayoutChange:t,token:i,readonly:s=!1,sessionsAlive:o,focusSession:a,onFocus:c,onOpenSingle:h,decks:m=[],currentDeck:p,onSendToDeck:y}){Pi();const[S,_]=R.useState(null),C=R.useRef(null),w=R.useRef([]),x=R.useRef(null);function k(q,J){const Q=()=>{window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",Q),window.removeEventListener("pointercancel",Q),window.removeEventListener("blur",Q),x.current=null};window.addEventListener("pointermove",q),window.addEventListener("pointerup",Q),window.addEventListener("pointercancel",Q),window.addEventListener("blur",Q),x.current=Q}R.useEffect(()=>()=>{x.current&&x.current()},[]),R.useEffect(()=>{const q=()=>_(null);return window.addEventListener("dragend",q),window.addEventListener("drop",q),()=>{window.removeEventListener("dragend",q),window.removeEventListener("drop",q)}},[]);const b=e.columns.length,D=q=>S&&S.col===q&&S.row===void 0,L=!!S&&S.col===b,M=(q,J)=>S&&S.col===q&&S.row===J&&S.quadrant?` drop-${S.quadrant}`:"";function te(q){if(q.preventDefault(),Og(q.dataTransfer)){_(null);return}const J=q.dataTransfer.getData("text/nc-session"),Q=S;if(_(null),!J||!Q)return;let T;if(Q.quadrant){if(T=W0(e,Q.col,Q.row,Q.quadrant),!T)return}else T={col:Q.col};t(ln(e).includes(J)?O0(e,J,T):ch(e,J,T))}function U(q,J){q.preventDefault(),q.stopPropagation();const Q=q.clientX,T=e.columns[J].width,N=C.current&&C.current.clientWidth||1,P=e.columns[J+1];k($=>{let K=Math.max(Ig,T+($.clientX-Q)/N);if(P){const F=Rm(K/(K+P.width));K=F/(1-F)*P.width}t(F0(e,J,K))})}function O(q,J,Q){q.preventDefault(),q.stopPropagation();const T=q.clientY,N=e.columns[J].tiles[Q].height,P=w.current[J],I=P&&P.clientHeight||1,$=e.columns[J].tiles[Q+1];k(F=>{let ae=Math.max(Ig,N+(F.clientY-T)/I);if($){const W=Rm(ae/(ae+$.height));ae=W/(1-W)*$.height}t(H0(e,J,Q,ae))})}function ee(q){t(ll(e,q))}return u.jsxs("div",{className:"nc-grid",ref:C,onDragOver:q=>{if(Og(q.dataTransfer)){q.preventDefault(),_(null);return}xu(q.dataTransfer)&&(q.preventDefault(),S&&S.col===b||_({col:b}))},onDrop:te,onDragLeave:q=>{const J=q.relatedTarget;(!J||!(C.current&&C.current.contains(J)))&&_(null)},children:[e.columns.flatMap((q,J)=>{const Q=[];return Q.push(u.jsx("div",{className:`nc-col${D(J)?" drop-newcol":""}`,ref:T=>{w.current[J]=T},style:{flexGrow:q.width,flexBasis:0},onDragOver:T=>{xu(T.dataTransfer)&&(T.preventDefault(),T.stopPropagation(),S&&S.col===J&&S.row===void 0||_({col:J}))},children:q.tiles.flatMap((T,N)=>{const P=[],I=Ni(T);return P.push(u.jsx("div",{className:`nc-tile-slot${M(J,N)}`,style:{flexGrow:T.height,flexBasis:0},onDragOver:$=>{if(!xu($.dataTransfer))return;$.preventDefault(),$.stopPropagation();const K=qC($.clientX,$.clientY,$.currentTarget.getBoundingClientRect());S&&S.col===J&&S.row===N&&S.quadrant===K||_({col:J,row:N,quadrant:K})},children:u.jsx(KC,{session:T.session,node:T.node,ownerId:T.ownerId,token:i,readonly:s,focused:a===I,onFocus:c,onClose:ee,onOpenSingle:h,available:T.unavailable!==!0,alive:T.unavailable!==!0&&(!o||o.has(I)),fontSize:T.fontSize,onZoom:$=>t($0(e,J,N,$)),decks:m,currentDeck:p,onSendToDeck:y})},I)),N<q.tiles.length-1&&P.push(u.jsx("div",{className:"nc-divider-h",onPointerDown:$=>O($,J,N)},`h${N}`)),P})},`c${J}`)),J<b-1&&Q.push(u.jsx("div",{className:"nc-divider-v",onPointerDown:T=>U(T,J)},`v${J}`)),Q}),L&&u.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),b===0&&u.jsx("div",{className:"nc-grid-empty",children:v("grid-empty")})]})}const wn="local",$i=/^[a-f0-9]{16,64}$/;function as(e,t){return`${e&&$i.test(e)?e:wn}:${t}`}function wh(e){const t=String(e||""),i=t.indexOf(":");if(i<1)return null;const s=t.slice(0,i),o=t.slice(i+1);return s!==wn&&!$i.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===wn?null:s,name:o}}function bl(e){return Array.isArray(e)&&e.length?e.join("/"):""}function bh(e){return{columns:br(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))}}function YC(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&$i.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(bl(i.route),i.instanceId);return t}function XC(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&$i.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(i.instanceId,[...i.route]);return t}function Kd(e,t,i=[]){const s=bh(e),o=YC(i);for(const a of s.columns)for(const c of a.tiles)c.ownerId||(!c.node&&$i.test(String(t||""))?c.ownerId=t:c.node&&o.has(c.node)&&(c.ownerId=o.get(c.node)));return s}function qd(e,t,i=[]){const s=bh(e),o=new Map;for(const a of i)a&&$i.test(String(a.instanceId||""))&&Array.isArray(a.route)&&o.set(a.instanceId,[...a.route]);for(const a of s.columns)for(const c of a.tiles)c.ownerId&&(c.ownerId===t?(delete c.node,delete c.unavailable):o.has(c.ownerId)?(c.node=bl(o.get(c.ownerId)),delete c.unavailable):c.unavailable=!0);return s}function zg(e,t,i=[]){const s=bh(e),o=XC(i);for(const a of s.columns)for(const c of a.tiles)delete c.unavailable,c.ownerId&&(c.ownerId===t?delete c.node:o.has(c.ownerId)&&(c.node=bl(o.get(c.ownerId))));return s}function uy(e,t,i=[]){const s=er(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...$i.test(String(t||""))?{ownerId:t}:{}};const o=i.find(a=>bl(a&&a.route)===s.node);return{...s,...o&&$i.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const GC=/^[a-z0-9-]{1,32}$/,Ri="main",dy="nc_decks",hy="nc_deck_order_v1",fy=24;function Fg(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function ds(e){return typeof e=="string"&&GC.test(e)}function QC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let i;try{i=decodeURIComponent(t[1])}catch{i=t[1]}return ds(i)?i:Ri}return Ri}function JC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:as(null,Ri),ownerId:null,name:Ri}}if($i.test(s)&&ds(o))return{id:as(s,o),ownerId:s,name:o}}const i=QC(e);return{id:as(null,i),ownerId:null,name:i}}function Eu(e,t){const i=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:wh(e)||{ownerId:null,name:e},s=ds(i.name)?i.name:Ri,o=i.ownerId?`/deck/${encodeURIComponent(i.ownerId)}/${encodeURIComponent(s)}`:s===Ri?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function py(e){return e===Ri?"nc_grid_v1":`nc_grid_v1__${e}`}function my(e){const t=[Ri];if(Array.isArray(e)){for(const i of e)if(ds(i)&&i!==Ri&&!t.includes(i)&&t.push(i),t.length>=fy)break}return t}function ms(){return typeof localStorage<"u"?localStorage:null}function ZC(){const e=ms();if(!e)return[Ri];try{return my(JSON.parse(e.getItem(dy)||"null"))}catch{return[Ri]}}function ex(e){const t=ms();if(t)try{t.setItem(dy,JSON.stringify(my(e)))}catch{}}function Ro(e){return e==="local"||$i.test(String(e||""))}function kl(e,t){const i=wh(e);return!!i&&(i.ownerId||"local")===t}function un(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[i,s]of Object.entries(e).slice(0,64)){if(!Ro(i)||!Array.isArray(s))continue;const o=[...new Set(s.filter(a=>typeof a=="string"&&a.length<=100&&kl(a,i)))].slice(0,fy);o.length&&(t[i]=o)}return t}function qa(e=ms()){if(!e)return{};try{return un(JSON.parse(e.getItem(hy)||"null"))}catch{return{}}}function Nu(e,t=ms()){const i=un(e);if(t)try{t.setItem(hy,JSON.stringify(i))}catch{}return i}function Cl(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function tx(e,t,i,s,o=[]){if(!Ro(t)||i===s)return un(e);const a=[...new Set(o.filter(S=>kl(S,t)))];if(!a.includes(i)||!a.includes(s))return un(e);const c=Cl(e,t).filter(S=>a.includes(S)),h=[...c,...a.filter(S=>!c.includes(S))],m=h.indexOf(i),p=h.indexOf(s);h.splice(m,1);const y=h.indexOf(s);return h.splice(m<p?y+1:y,0,i),un({...e,[t]:h})}function ix(e,t,i,s){if(!Ro(t)||!kl(s,t))return un(e);const o=Cl(e,t);return o.includes(i)?un({...e,[t]:o.map(a=>a===i?s:a)}):un(e)}function nx(e,t,i){return Ro(t)?un({...e,[t]:Cl(e,t).filter(s=>s!==i)}):un(e)}function Hg(e,t={}){const i=new Map;for(const o of Array.isArray(e)?e:[]){const a=o!=null&&o.local?"local":String((o==null?void 0:o.ownerId)||"");!Ro(a)||!kl(o==null?void 0:o.id,a)||(i.has(a)||i.set(a,[]),i.get(a).push(o))}const s=[];for(const[,o]of i){const a=o[0].local?"local":o[0].ownerId,c=Cl(t,a),h=new Map(c.map((m,p)=>[m,p]));o.sort((m,p)=>{const y=h.has(m.id)?h.get(m.id):Number.MAX_SAFE_INTEGER,S=h.has(p.id)?h.get(p.id):Number.MAX_SAFE_INTEGER;return y-S}),s.push(...o)}return s}function Vd(e){const t=ms();if(!t)return null;try{return JSON.parse(t.getItem(py(e))||"null")}catch{return null}}function rx(e,t){const i=ms();if(i)try{i.setItem(py(e),JSON.stringify(t))}catch{}}const $g=52,Wg=18;function sx({ownerKey:e,deckId:t,label:i,onMove:s,onStep:o}){const a=R.useRef(null),c=R.useRef(0),[h,m]=R.useState(!1),p=()=>{var x,k,b,D;const w=a.current;(k=(x=w==null?void 0:w.over)==null?void 0:x.classList)==null||k.remove("nc-deck-over"),(D=(b=w==null?void 0:w.source)==null?void 0:b.classList)==null||D.remove("nc-deck-dragging"),c.current&&cancelAnimationFrame(c.current),c.current=0},y=(w=!1)=>{const x=a.current;if(!x)return;const k=x.target;p(),a.current=null,m(!1);try{x.handle.releasePointerCapture(x.pointerId)}catch{}w&&k&&k!==t&&s(t,k)},S=(w,x)=>{var M,te,U,O,ee,q,J,Q;const k=a.current;if(!k)return;k.x=w,k.y=x;const b=(te=(M=document.elementFromPoint(w,x))==null?void 0:M.closest)==null?void 0:te.call(M,"[data-deck-id][data-owner-key]"),D=(U=b==null?void 0:b.dataset)==null?void 0:U.deckId,L=((O=b==null?void 0:b.dataset)==null?void 0:O.ownerKey)===e&&D&&D!==t;k.over!==(L?b:null)&&((q=(ee=k.over)==null?void 0:ee.classList)==null||q.remove("nc-deck-over"),k.over=L?b:null,(Q=(J=k.over)==null?void 0:J.classList)==null||Q.add("nc-deck-over")),k.target=L?D:null},_=()=>{var k,b;const w=a.current;if(!w){c.current=0;return}const x=(b=(k=w.container)==null?void 0:k.getBoundingClientRect)==null?void 0:b.call(k);if(x){const D=w.x<x.left+$g?-Wg:w.x>x.right-$g?Wg:0;D&&(w.container.scrollLeft+=D,S(w.x,w.y))}c.current=requestAnimationFrame(_)};R.useEffect(()=>{const w=k=>{k.key==="Escape"&&a.current&&(k.preventDefault(),y(!1))},x=()=>y(!1);return window.addEventListener("keydown",w),window.addEventListener("blur",x),()=>{window.removeEventListener("keydown",w),window.removeEventListener("blur",x),p(),a.current=null}},[t,e]);const C=w=>{var b;if(w.pointerType==="mouse"&&w.button!==0)return;w.preventDefault(),w.stopPropagation(),w.currentTarget.focus({preventScroll:!0});const x=w.currentTarget.closest("[data-deck-id][data-owner-key]"),k=w.currentTarget.closest(".nc-deckbar");a.current={pointerId:w.pointerId,handle:w.currentTarget,source:x,container:k,target:null,over:null,x:w.clientX,y:w.clientY},(b=x==null?void 0:x.classList)==null||b.add("nc-deck-dragging");try{w.currentTarget.setPointerCapture(w.pointerId)}catch{}m(!0),c.current=requestAnimationFrame(_)};return u.jsx("button",{type:"button",className:`nc-deck-handle${h?" active":""}`,"aria-label":`${v("reorder")} ${i}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:v("reorder-deck-help"),onClick: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:C,onPointerMove:w=>{!a.current||w.pointerId!==a.current.pointerId||(w.preventDefault(),w.stopPropagation(),S(w.clientX,w.clientY))},onPointerUp:w=>{!a.current||w.pointerId!==a.current.pointerId||(w.preventDefault(),w.stopPropagation(),y(!0))},onPointerCancel:()=>y(!1),onLostPointerCapture:()=>{a.current&&y(!1)},children:"↔"})}function ox({decks:e=[],currentDeck:t="local:main",onCreate:i,onRename:s,onDelete:o,onReorder:a,onOpenWindow:c,onNavigate:h,saveState:m="idle",error:p="",sidebarVisible:y,onToggleSidebar:S}){Pi();const[_,C]=R.useState(null),[w,x]=R.useState(""),[k,b]=R.useState(!1),[D,L]=R.useState(""),[M,te]=R.useState(""),U=Fg(w),O=ds(U),ee=[];for(const N of e){const P=N.local?"local":N.ownerId;let I=ee.find($=>$.key===P);I||(I={key:P,label:N.ownerLabel||(N.local?"Local":P),local:!!N.local,decks:[]},ee.push(I)),I.decks.push(N)}const q=async()=>{if(O){b(!0),L("");try{i&&await i(U,_),x(""),C(null)}catch(N){L(String(N.message||N))}b(!1)}},J=N=>{te(""),c&&c(N.id)||te(N.id)},Q=async N=>{if(!(N.id===t||!h||k||N.available===!1)){b(!0),L("");try{await h(N.id)}catch(P){L(String((P==null?void 0:P.message)||P))}b(!1)}},T=(N,P,I)=>{const $=N.decks.findIndex(F=>F.id===P.id),K=N.decks[$+I];$>=0&&K&&a&&!k&&a(P.id,K.id)};return u.jsxs("div",{className:"nc-deckbar",children:[S&&u.jsx("button",{className:"nc-deck-sidebar-toggle",title:v("toggle-sidebar"),onClick:S,children:y?"◀":"☰"}),u.jsx("span",{className:"nc-deckbar-label",children:v("decks")}),u.jsx("div",{className:"nc-deck-chips",children:ee.map(N=>u.jsxs("span",{className:"nc-deck-owner-group",children:[u.jsx("span",{className:"nc-deck-owner",children:N.local?"Local":N.label}),N.decks.map(P=>u.jsxs("span",{"data-deck-id":P.id,"data-owner-key":N.key,className:`nc-deck-chip${P.id===t?" current":""}${P.available===!1?" offline":""}`,children:[u.jsx(sx,{ownerKey:N.key,deckId:P.id,label:`${N.label} · ${P.name}`,onMove:(I,$)=>{a&&!k&&a(I,$)},onStep:I=>T(N,P,I)}),u.jsxs("button",{className:"nc-deck-open",title:P.available===!1?`${P.ownerLabel} offline`:P.id===t?v("deck-current"):`${P.ownerLabel} · ${P.name}`,disabled:k||P.available===!1,onClick:()=>Q(P),children:[P.name,P.id===t?" •":""]}),u.jsx("button",{className:"nc-deck-mini",disabled:P.available===!1,title:v("detach-deck"),onClick:()=>J(P),children:"↗"}),P.name!==Ri&&u.jsxs(u.Fragment,{children:[u.jsx("button",{className:"nc-deck-mini",disabled:P.available===!1,title:v("rename-deck"),onClick:()=>{const I=(typeof window<"u"?window.prompt(v("rename-deck"),P.name):"")||"",$=Fg(I);ds($)&&$!==P.name&&s&&s(P.id,$).catch(K=>L(String(K.message||K)))},children:"✎"}),u.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:P.available===!1,title:v("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(v("delete-deck-confirm").replace("{name}",`${P.ownerLabel} · ${P.name}`)))&&o&&o(P.id).catch(I=>L(String(I.message||I)))},children:"✕"})]})]},P.id)),_===N.key?u.jsxs("span",{className:"nc-deck-add",children:[u.jsx("input",{autoFocus:!0,className:O||!w?"":"invalid",placeholder:v("deck-name"),value:w,onChange:P=>x(P.target.value),onKeyDown:P=>{P.key==="Enter"&&q(),P.key==="Escape"&&(x(""),C(null))}}),w&&O&&U!==w&&u.jsxs("span",{className:"nc-deck-slug",children:["→ ",U]}),u.jsx("button",{className:"nc-deck-ok",disabled:!O||k,onClick:q,children:v("create")}),u.jsx("button",{className:"nc-deck-cancel",onClick:()=>{x(""),C(null)},children:v("cancel")})]}):u.jsxs("button",{className:"nc-deck-newbtn",disabled:k||N.decks.every(P=>P.available===!1),title:`${v("new-deck")} · ${N.label}`,onClick:()=>{x(""),C(N.key)},children:["+ ",v("new")]})]},N.key))}),u.jsx("span",{className:`nc-deck-state ${m}`,title:v("deck-autosave"),children:v(m==="saving"?"saving":m==="saved"?"saved":"deck-autosave")}),(D||p)&&u.jsx("span",{className:"nc-deck-error",children:D||p}),M&&u.jsx("button",{className:"nc-deck-fallback",onClick:()=>c&&c(M),children:v("popup-blocked")})]})}var is={},Ru,Ug;function ax(){return Ug||(Ug=1,Ru=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Ru}var Pu={},Vn={},Kg;function Rr(){if(Kg)return Vn;Kg=1;let e;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Vn.getSymbolSize=function(s){if(!s)throw new Error('"version" cannot be null or undefined');if(s<1||s>40)throw new Error('"version" should be in range from 1 to 40');return s*4+17},Vn.getSymbolTotalCodewords=function(s){return t[s]},Vn.getBCHDigit=function(i){let s=0;for(;i!==0;)s++,i>>>=1;return s},Vn.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},Vn.isKanjiModeEnabled=function(){return typeof e<"u"},Vn.toSJIS=function(s){return e(s)},Vn}var Du={},qg;function kh(){return qg||(qg=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+i)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,o){if(e.isValid(s))return s;try{return t(s)}catch{return o}}})(Du)),Du}var ju,Vg;function lx(){if(Vg)return ju;Vg=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++}},ju=e,ju}var Mu,Yg;function cx(){if(Yg)return Mu;Yg=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,i,s,o){const a=t*this.size+i;this.data[a]=s,o&&(this.reservedBit[a]=!0)},e.prototype.get=function(t,i){return this.data[t*this.size+i]},e.prototype.xor=function(t,i,s){this.data[t*this.size+i]^=s},e.prototype.isReserved=function(t,i){return this.reservedBit[t*this.size+i]},Mu=e,Mu}var Lu={},Xg;function ux(){return Xg||(Xg=1,(function(e){const t=Rr().getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const o=Math.floor(s/7)+2,a=t(s),c=a===145?26:Math.ceil((a-13)/(2*o-2))*2,h=[a-7];for(let m=1;m<o-1;m++)h[m]=h[m-1]-c;return h.push(6),h.reverse()},e.getPositions=function(s){const o=[],a=e.getRowColCoords(s),c=a.length;for(let h=0;h<c;h++)for(let m=0;m<c;m++)h===0&&m===0||h===0&&m===c-1||h===c-1&&m===0||o.push([a[h],a[m]]);return o}})(Lu)),Lu}var Tu={},Gg;function dx(){if(Gg)return Tu;Gg=1;const e=Rr().getSymbolSize,t=7;return Tu.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},Tu}var Au={},Qg;function hx(){return Qg||(Qg=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.getPenaltyN1=function(o){const a=o.size;let c=0,h=0,m=0,p=null,y=null;for(let S=0;S<a;S++){h=m=0,p=y=null;for(let _=0;_<a;_++){let C=o.get(S,_);C===p?h++:(h>=5&&(c+=t.N1+(h-5)),p=C,h=1),C=o.get(_,S),C===y?m++:(m>=5&&(c+=t.N1+(m-5)),y=C,m=1)}h>=5&&(c+=t.N1+(h-5)),m>=5&&(c+=t.N1+(m-5))}return c},e.getPenaltyN2=function(o){const a=o.size;let c=0;for(let h=0;h<a-1;h++)for(let m=0;m<a-1;m++){const p=o.get(h,m)+o.get(h,m+1)+o.get(h+1,m)+o.get(h+1,m+1);(p===4||p===0)&&c++}return c*t.N2},e.getPenaltyN3=function(o){const a=o.size;let c=0,h=0,m=0;for(let p=0;p<a;p++){h=m=0;for(let y=0;y<a;y++)h=h<<1&2047|o.get(p,y),y>=10&&(h===1488||h===93)&&c++,m=m<<1&2047|o.get(y,p),y>=10&&(m===1488||m===93)&&c++}return c*t.N3},e.getPenaltyN4=function(o){let a=0;const c=o.data.length;for(let m=0;m<c;m++)a+=o.data[m];return Math.abs(Math.ceil(a*100/c/5)-10)*t.N4};function i(s,o,a){switch(s){case e.Patterns.PATTERN000:return(o+a)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return a%3===0;case e.Patterns.PATTERN011:return(o+a)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(a/3))%2===0;case e.Patterns.PATTERN101:return o*a%2+o*a%3===0;case e.Patterns.PATTERN110:return(o*a%2+o*a%3)%2===0;case e.Patterns.PATTERN111:return(o*a%3+(o+a)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}e.applyMask=function(o,a){const c=a.size;for(let h=0;h<c;h++)for(let m=0;m<c;m++)a.isReserved(m,h)||a.xor(m,h,i(o,m,h))},e.getBestMask=function(o,a){const c=Object.keys(e.Patterns).length;let h=0,m=1/0;for(let p=0;p<c;p++){a(p),e.applyMask(p,o);const y=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(p,o),y<m&&(m=y,h=p)}return h}})(Au)),Au}var Va={},Jg;function gy(){if(Jg)return Va;Jg=1;const e=kh(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Va.getBlocksCount=function(o,a){switch(a){case e.L:return t[(o-1)*4+0];case e.M:return t[(o-1)*4+1];case e.Q:return t[(o-1)*4+2];case e.H:return t[(o-1)*4+3];default:return}},Va.getTotalCodewordsCount=function(o,a){switch(a){case e.L:return i[(o-1)*4+0];case e.M:return i[(o-1)*4+1];case e.Q:return i[(o-1)*4+2];case e.H:return i[(o-1)*4+3];default:return}},Va}var Iu={},ao={},Zg;function fx(){if(Zg)return ao;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]})(),ao.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},ao.exp=function(s){return e[s]},ao.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},ao}var ev;function px(){return ev||(ev=1,(function(e){const t=fx();e.mul=function(s,o){const a=new Uint8Array(s.length+o.length-1);for(let c=0;c<s.length;c++)for(let h=0;h<o.length;h++)a[c+h]^=t.mul(s[c],o[h]);return a},e.mod=function(s,o){let a=new Uint8Array(s);for(;a.length-o.length>=0;){const c=a[0];for(let m=0;m<o.length;m++)a[m]^=t.mul(o[m],c);let h=0;for(;h<a.length&&a[h]===0;)h++;a=a.slice(h)}return a},e.generateECPolynomial=function(s){let o=new Uint8Array([1]);for(let a=0;a<s;a++)o=e.mul(o,new Uint8Array([1,t.exp(a)]));return o}})(Iu)),Iu}var Bu,tv;function mx(){if(tv)return Bu;tv=1;const e=px();function t(i){this.genPoly=void 0,this.degree=i,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(s){this.degree=s,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(s.length+this.degree);o.set(s);const a=e.mod(o,this.genPoly),c=this.degree-a.length;if(c>0){const h=new Uint8Array(this.degree);return h.set(a,c),h}return a},Bu=t,Bu}var Ou={},zu={},Fu={},iv;function vy(){return iv||(iv=1,Fu.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Fu}var sn={},nv;function _y(){if(nv)return sn;nv=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+`)(?:.|[\r
|
|
82
|
-
]))+`;sn.KANJI=new RegExp(i,"g"),sn.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),sn.BYTE=new RegExp(s,"g"),sn.NUMERIC=new RegExp(e,"g"),sn.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+i+"$"),a=new RegExp("^"+e+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return sn.testKanji=function(m){return o.test(m)},sn.testNumeric=function(m){return a.test(m)},sn.testAlphanumeric=function(m){return c.test(m)},sn}var rv;function Pr(){return rv||(rv=1,(function(e){const t=vy(),i=_y();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(a,c){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!t.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?a.ccBits[0]:c<27?a.ccBits[1]:a.ccBits[2]},e.getBestModeForData=function(a){return i.testNumeric(a)?e.NUMERIC:i.testAlphanumeric(a)?e.ALPHANUMERIC:i.testKanji(a)?e.KANJI:e.BYTE},e.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},e.isValid=function(a){return a&&a.bit&&a.ccBits};function s(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+o)}}e.from=function(a,c){if(e.isValid(a))return a;try{return s(a)}catch{return c}}})(zu)),zu}var sv;function gx(){return sv||(sv=1,(function(e){const t=Rr(),i=gy(),s=kh(),o=Pr(),a=vy(),c=7973,h=t.getBCHDigit(c);function m(_,C,w){for(let x=1;x<=40;x++)if(C<=e.getCapacity(x,w,_))return x}function p(_,C){return o.getCharCountIndicator(_,C)+4}function y(_,C){let w=0;return _.forEach(function(x){const k=p(x.mode,C);w+=k+x.getBitsLength()}),w}function S(_,C){for(let w=1;w<=40;w++)if(y(_,w)<=e.getCapacity(w,C,o.MIXED))return w}e.from=function(C,w){return a.isValid(C)?parseInt(C,10):w},e.getCapacity=function(C,w,x){if(!a.isValid(C))throw new Error("Invalid QR Code version");typeof x>"u"&&(x=o.BYTE);const k=t.getSymbolTotalCodewords(C),b=i.getTotalCodewordsCount(C,w),D=(k-b)*8;if(x===o.MIXED)return D;const L=D-p(x,C);switch(x){case o.NUMERIC:return Math.floor(L/10*3);case o.ALPHANUMERIC:return Math.floor(L/11*2);case o.KANJI:return Math.floor(L/13);case o.BYTE:default:return Math.floor(L/8)}},e.getBestVersionForData=function(C,w){let x;const k=s.from(w,s.M);if(Array.isArray(C)){if(C.length>1)return S(C,k);if(C.length===0)return 1;x=C[0]}else x=C;return m(x.mode,x.getLength(),k)},e.getEncodedBits=function(C){if(!a.isValid(C)||C<7)throw new Error("Invalid QR Code version");let w=C<<12;for(;t.getBCHDigit(w)-h>=0;)w^=c<<t.getBCHDigit(w)-h;return C<<12|w}})(Ou)),Ou}var Hu={},ov;function vx(){if(ov)return Hu;ov=1;const e=Rr(),t=1335,i=21522,s=e.getBCHDigit(t);return Hu.getEncodedBits=function(a,c){const h=a.bit<<3|c;let m=h<<10;for(;e.getBCHDigit(m)-s>=0;)m^=t<<e.getBCHDigit(m)-s;return(h<<10|m)^i},Hu}var $u={},Wu,av;function _x(){if(av)return Wu;av=1;const e=Pr();function t(i){this.mode=e.NUMERIC,this.data=i.toString()}return t.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){let o,a,c;for(o=0;o+3<=this.data.length;o+=3)a=this.data.substr(o,3),c=parseInt(a,10),s.put(c,10);const h=this.data.length-o;h>0&&(a=this.data.substr(o),c=parseInt(a,10),s.put(c,h*3+1))},Wu=t,Wu}var Uu,lv;function yx(){if(lv)return Uu;lv=1;const e=Pr(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(s){this.mode=e.ALPHANUMERIC,this.data=s}return i.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(o){let a;for(a=0;a+2<=this.data.length;a+=2){let c=t.indexOf(this.data[a])*45;c+=t.indexOf(this.data[a+1]),o.put(c,11)}this.data.length%2&&o.put(t.indexOf(this.data[a]),6)},Uu=i,Uu}var Ku,cv;function Sx(){if(cv)return Ku;cv=1;const e=Pr();function t(i){this.mode=e.BYTE,typeof i=="string"?this.data=new TextEncoder().encode(i):this.data=new Uint8Array(i)}return t.getBitsLength=function(s){return s*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(i){for(let s=0,o=this.data.length;s<o;s++)i.put(this.data[s],8)},Ku=t,Ku}var qu,uv;function wx(){if(uv)return qu;uv=1;const e=Pr(),t=Rr();function i(s){this.mode=e.KANJI,this.data=s}return i.getBitsLength=function(o){return o*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(s){let o;for(o=0;o<this.data.length;o++){let a=t.toSJIS(this.data[o]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
|
|
83
|
-
Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),s.put(a,13)}},qu=i,qu}var Vu={exports:{}},dv;function bx(){return dv||(dv=1,(function(e){var t={single_source_shortest_paths:function(i,s,o){var a={},c={};c[s]=0;var h=t.PriorityQueue.make();h.push(s,0);for(var m,p,y,S,_,C,w,x,k;!h.empty();){m=h.pop(),p=m.value,S=m.cost,_=i[p]||{};for(y in _)_.hasOwnProperty(y)&&(C=_[y],w=S+C,x=c[y],k=typeof c[y]>"u",(k||x>w)&&(c[y]=w,h.push(y,w),a[y]=p))}if(typeof o<"u"&&typeof c[o]>"u"){var b=["Could not find a path from ",s," to ",o,"."].join("");throw new Error(b)}return a},extract_shortest_path_from_predecessor_list:function(i,s){for(var o=[],a=s;a;)o.push(a),i[a],a=i[a];return o.reverse(),o},find_path:function(i,s,o){var a=t.single_source_shortest_paths(i,s,o);return t.extract_shortest_path_from_predecessor_list(a,o)},PriorityQueue:{make:function(i){var s=t.PriorityQueue,o={},a;i=i||{};for(a in s)s.hasOwnProperty(a)&&(o[a]=s[a]);return o.queue=[],o.sorter=i.sorter||s.default_sorter,o},default_sorter:function(i,s){return i.cost-s.cost},push:function(i,s){var o={value:i,cost:s};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(Vu)),Vu.exports}var hv;function kx(){return hv||(hv=1,(function(e){const t=Pr(),i=_x(),s=yx(),o=Sx(),a=wx(),c=_y(),h=Rr(),m=bx();function p(b){return unescape(encodeURIComponent(b)).length}function y(b,D,L){const M=[];let te;for(;(te=b.exec(L))!==null;)M.push({data:te[0],index:te.index,mode:D,length:te[0].length});return M}function S(b){const D=y(c.NUMERIC,t.NUMERIC,b),L=y(c.ALPHANUMERIC,t.ALPHANUMERIC,b);let M,te;return h.isKanjiModeEnabled()?(M=y(c.BYTE,t.BYTE,b),te=y(c.KANJI,t.KANJI,b)):(M=y(c.BYTE_KANJI,t.BYTE,b),te=[]),D.concat(L,M,te).sort(function(O,ee){return O.index-ee.index}).map(function(O){return{data:O.data,mode:O.mode,length:O.length}})}function _(b,D){switch(D){case t.NUMERIC:return i.getBitsLength(b);case t.ALPHANUMERIC:return s.getBitsLength(b);case t.KANJI:return a.getBitsLength(b);case t.BYTE:return o.getBitsLength(b)}}function C(b){return b.reduce(function(D,L){const M=D.length-1>=0?D[D.length-1]:null;return M&&M.mode===L.mode?(D[D.length-1].data+=L.data,D):(D.push(L),D)},[])}function w(b){const D=[];for(let L=0;L<b.length;L++){const M=b[L];switch(M.mode){case t.NUMERIC:D.push([M,{data:M.data,mode:t.ALPHANUMERIC,length:M.length},{data:M.data,mode:t.BYTE,length:M.length}]);break;case t.ALPHANUMERIC:D.push([M,{data:M.data,mode:t.BYTE,length:M.length}]);break;case t.KANJI:D.push([M,{data:M.data,mode:t.BYTE,length:p(M.data)}]);break;case t.BYTE:D.push([{data:M.data,mode:t.BYTE,length:p(M.data)}])}}return D}function x(b,D){const L={},M={start:{}};let te=["start"];for(let U=0;U<b.length;U++){const O=b[U],ee=[];for(let q=0;q<O.length;q++){const J=O[q],Q=""+U+q;ee.push(Q),L[Q]={node:J,lastCount:0},M[Q]={};for(let T=0;T<te.length;T++){const N=te[T];L[N]&&L[N].node.mode===J.mode?(M[N][Q]=_(L[N].lastCount+J.length,J.mode)-_(L[N].lastCount,J.mode),L[N].lastCount+=J.length):(L[N]&&(L[N].lastCount=J.length),M[N][Q]=_(J.length,J.mode)+4+t.getCharCountIndicator(J.mode,D))}}te=ee}for(let U=0;U<te.length;U++)M[te[U]].end=0;return{map:M,table:L}}function k(b,D){let L;const M=t.getBestModeForData(b);if(L=t.from(D,M),L!==t.BYTE&&L.bit<M.bit)throw new Error('"'+b+'" cannot be encoded with mode '+t.toString(L)+`.
|
|
84
|
-
Suggested mode is: `+t.toString(M));switch(L===t.KANJI&&!h.isKanjiModeEnabled()&&(L=t.BYTE),L){case t.NUMERIC:return new i(b);case t.ALPHANUMERIC:return new s(b);case t.KANJI:return new a(b);case t.BYTE:return new o(b)}}e.fromArray=function(D){return D.reduce(function(L,M){return typeof M=="string"?L.push(k(M,null)):M.data&&L.push(k(M.data,M.mode)),L},[])},e.fromString=function(D,L){const M=S(D,h.isKanjiModeEnabled()),te=w(M),U=x(te,L),O=m.find_path(U.map,"start","end"),ee=[];for(let q=1;q<O.length-1;q++)ee.push(U.table[O[q]].node);return e.fromArray(C(ee))},e.rawSplit=function(D){return e.fromArray(S(D,h.isKanjiModeEnabled()))}})($u)),$u}var fv;function Cx(){if(fv)return Pu;fv=1;const e=Rr(),t=kh(),i=lx(),s=cx(),o=ux(),a=dx(),c=hx(),h=gy(),m=mx(),p=gx(),y=vx(),S=Pr(),_=kx();function C(U,O){const ee=U.size,q=a.getPositions(O);for(let J=0;J<q.length;J++){const Q=q[J][0],T=q[J][1];for(let N=-1;N<=7;N++)if(!(Q+N<=-1||ee<=Q+N))for(let P=-1;P<=7;P++)T+P<=-1||ee<=T+P||(N>=0&&N<=6&&(P===0||P===6)||P>=0&&P<=6&&(N===0||N===6)||N>=2&&N<=4&&P>=2&&P<=4?U.set(Q+N,T+P,!0,!0):U.set(Q+N,T+P,!1,!0))}}function w(U){const O=U.size;for(let ee=8;ee<O-8;ee++){const q=ee%2===0;U.set(ee,6,q,!0),U.set(6,ee,q,!0)}}function x(U,O){const ee=o.getPositions(O);for(let q=0;q<ee.length;q++){const J=ee[q][0],Q=ee[q][1];for(let T=-2;T<=2;T++)for(let N=-2;N<=2;N++)T===-2||T===2||N===-2||N===2||T===0&&N===0?U.set(J+T,Q+N,!0,!0):U.set(J+T,Q+N,!1,!0)}}function k(U,O){const ee=U.size,q=p.getEncodedBits(O);let J,Q,T;for(let N=0;N<18;N++)J=Math.floor(N/3),Q=N%3+ee-8-3,T=(q>>N&1)===1,U.set(J,Q,T,!0),U.set(Q,J,T,!0)}function b(U,O,ee){const q=U.size,J=y.getEncodedBits(O,ee);let Q,T;for(Q=0;Q<15;Q++)T=(J>>Q&1)===1,Q<6?U.set(Q,8,T,!0):Q<8?U.set(Q+1,8,T,!0):U.set(q-15+Q,8,T,!0),Q<8?U.set(8,q-Q-1,T,!0):Q<9?U.set(8,15-Q-1+1,T,!0):U.set(8,15-Q-1,T,!0);U.set(q-8,8,1,!0)}function D(U,O){const ee=U.size;let q=-1,J=ee-1,Q=7,T=0;for(let N=ee-1;N>0;N-=2)for(N===6&&N--;;){for(let P=0;P<2;P++)if(!U.isReserved(J,N-P)){let I=!1;T<O.length&&(I=(O[T]>>>Q&1)===1),U.set(J,N-P,I),Q--,Q===-1&&(T++,Q=7)}if(J+=q,J<0||ee<=J){J-=q,q=-q;break}}}function L(U,O,ee){const q=new i;ee.forEach(function(P){q.put(P.mode.bit,4),q.put(P.getLength(),S.getCharCountIndicator(P.mode,U)),P.write(q)});const J=e.getSymbolTotalCodewords(U),Q=h.getTotalCodewordsCount(U,O),T=(J-Q)*8;for(q.getLengthInBits()+4<=T&&q.put(0,4);q.getLengthInBits()%8!==0;)q.putBit(0);const N=(T-q.getLengthInBits())/8;for(let P=0;P<N;P++)q.put(P%2?17:236,8);return M(q,U,O)}function M(U,O,ee){const q=e.getSymbolTotalCodewords(O),J=h.getTotalCodewordsCount(O,ee),Q=q-J,T=h.getBlocksCount(O,ee),N=q%T,P=T-N,I=Math.floor(q/T),$=Math.floor(Q/T),K=$+1,F=I-$,ae=new m(F);let W=0;const j=new Array(T),A=new Array(T);let se=0;const ge=new Uint8Array(U.buffer);for(let Ce=0;Ce<T;Ce++){const Re=Ce<P?$:K;j[Ce]=ge.slice(W,W+Re),A[Ce]=ae.encode(j[Ce]),W+=Re,se=Math.max(se,Re)}const G=new Uint8Array(q);let Z=0,ue,de;for(ue=0;ue<se;ue++)for(de=0;de<T;de++)ue<j[de].length&&(G[Z++]=j[de][ue]);for(ue=0;ue<F;ue++)for(de=0;de<T;de++)G[Z++]=A[de][ue];return G}function te(U,O,ee,q){let J;if(Array.isArray(U))J=_.fromArray(U);else if(typeof U=="string"){let I=O;if(!I){const $=_.rawSplit(U);I=p.getBestVersionForData($,ee)}J=_.fromString(U,I||40)}else throw new Error("Invalid data");const Q=p.getBestVersionForData(J,ee);if(!Q)throw new Error("The amount of data is too big to be stored in a QR Code");if(!O)O=Q;else if(O<Q)throw new Error(`
|
|
85
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
86
|
-
Minimum version required to store current data is: `+Q+`.
|
|
87
|
-
`);const T=L(O,ee,J),N=e.getSymbolSize(O),P=new s(N);return C(P,O),w(P),x(P,O),b(P,ee,0),O>=7&&k(P,O),D(P,T),isNaN(q)&&(q=c.getBestMask(P,b.bind(null,P,ee))),c.applyMask(q,P),b(P,ee,q),{modules:P,version:O,errorCorrectionLevel:ee,maskPattern:q,segments:J}}return Pu.create=function(O,ee){if(typeof O>"u"||O==="")throw new Error("No input text");let q=t.M,J,Q;return typeof ee<"u"&&(q=t.from(ee.errorCorrectionLevel,t.M),J=p.from(ee.version),Q=c.from(ee.maskPattern),ee.toSJISFunc&&e.setToSJISFunction(ee.toSJISFunc)),te(O,J,q,Q)},Pu}var Yu={},Xu={},pv;function yy(){return pv||(pv=1,(function(e){function t(i){if(typeof i=="number"&&(i=i.toString()),typeof i!="string")throw new Error("Color should be defined as hex string");let s=i.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+i);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(a){return[a,a]}))),s.length===6&&s.push("F","F");const o=parseInt(s.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+s.slice(0,6).join("")}}e.getOptions=function(s){s||(s={}),s.color||(s.color={});const o=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,a=s.width&&s.width>=21?s.width:void 0,c=s.scale||4;return{width:a,scale:a?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 a=e.getScale(s,o);return Math.floor((s+o.margin*2)*a)},e.qrToImageData=function(s,o,a){const c=o.modules.size,h=o.modules.data,m=e.getScale(c,a),p=Math.floor((c+a.margin*2)*m),y=a.margin*m,S=[a.color.light,a.color.dark];for(let _=0;_<p;_++)for(let C=0;C<p;C++){let w=(_*p+C)*4,x=a.color.light;if(_>=y&&C>=y&&_<p-y&&C<p-y){const k=Math.floor((_-y)/m),b=Math.floor((C-y)/m);x=S[h[k*c+b]?1:0]}s[w++]=x.r,s[w++]=x.g,s[w++]=x.b,s[w]=x.a}}})(Xu)),Xu}var mv;function xx(){return mv||(mv=1,(function(e){const t=yy();function i(o,a,c){o.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=c,a.width=c,a.style.height=c+"px",a.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(a,c,h){let m=h,p=c;typeof m>"u"&&(!c||!c.getContext)&&(m=c,c=void 0),c||(p=s()),m=t.getOptions(m);const y=t.getImageWidth(a.modules.size,m),S=p.getContext("2d"),_=S.createImageData(y,y);return t.qrToImageData(_.data,a,m),i(S,p,y),S.putImageData(_,0,0),p},e.renderToDataURL=function(a,c,h){let m=h;typeof m>"u"&&(!c||!c.getContext)&&(m=c,c=void 0),m||(m={});const p=e.render(a,c,m),y=m.type||"image/png",S=m.rendererOpts||{};return p.toDataURL(y,S.quality)}})(Yu)),Yu}var Gu={},gv;function Ex(){if(gv)return Gu;gv=1;const e=yy();function t(o,a){const c=o.a/255,h=a+'="'+o.hex+'"';return c<1?h+" "+a+'-opacity="'+c.toFixed(2).slice(1)+'"':h}function i(o,a,c){let h=o+a;return typeof c<"u"&&(h+=" "+c),h}function s(o,a,c){let h="",m=0,p=!1,y=0;for(let S=0;S<o.length;S++){const _=Math.floor(S%a),C=Math.floor(S/a);!_&&!p&&(p=!0),o[S]?(y++,S>0&&_>0&&o[S-1]||(h+=p?i("M",_+c,.5+C+c):i("m",m,0),m=0,p=!1),_+1<a&&o[S+1]||(h+=i("h",y),y=0)):m++}return h}return Gu.render=function(a,c,h){const m=e.getOptions(c),p=a.modules.size,y=a.modules.data,S=p+m.margin*2,_=m.color.light.a?"<path "+t(m.color.light,"fill")+' d="M0 0h'+S+"v"+S+'H0z"/>':"",C="<path "+t(m.color.dark,"stroke")+' d="'+s(y,p,m.margin)+'"/>',w='viewBox="0 0 '+S+" "+S+'"',k='<svg xmlns="http://www.w3.org/2000/svg" '+(m.width?'width="'+m.width+'" height="'+m.width+'" ':"")+w+' shape-rendering="crispEdges">'+_+C+`</svg>
|
|
88
|
-
`;return typeof h=="function"&&h(null,k),k},Gu}var vv;function Nx(){if(vv)return is;vv=1;const e=ax(),t=Cx(),i=xx(),s=Ex();function o(a,c,h,m,p){const y=[].slice.call(arguments,1),S=y.length,_=typeof y[S-1]=="function";if(!_&&!e())throw new Error("Callback required as last argument");if(_){if(S<2)throw new Error("Too few arguments provided");S===2?(p=h,h=c,c=m=void 0):S===3&&(c.getContext&&typeof p>"u"?(p=m,m=void 0):(p=m,m=h,h=c,c=void 0))}else{if(S<1)throw new Error("Too few arguments provided");return S===1?(h=c,c=m=void 0):S===2&&!c.getContext&&(m=h,h=c,c=void 0),new Promise(function(C,w){try{const x=t.create(h,m);C(a(x,c,m))}catch(x){w(x)}})}try{const C=t.create(h,m);p(null,a(C,c,m))}catch(C){p(C)}}return is.create=t.create,is.toCanvas=o.bind(null,i.render),is.toDataURL=o.bind(null,i.renderToDataURL),is.toString=o.bind(null,function(a,c,h){return s.render(a,h)}),is}var Rx=Nx();const Px=Jd(Rx);function _v(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function Dx(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const i=J0(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 jx(e,t,i=new Set,s=!1){if(!t||!t.ok)return e;const o=Z0(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 yv(e,t,i=new Set,s=!1){const o=String(t||"").trim(),a=Dx(o);let c={...e,pairingUrl:o};return(a.kind==="complete"||a.kind==="partial")&&(c={...jx(c,a.decoded,i,s),pairingUrl:o}),{classification:a,form:c}}function tl(e,t){const i=String(t||"").toLowerCase();if(!/^[a-f0-9]{16,64}$/.test(i))return"";const s=String(e||"NexusCrew").replace(/([a-z0-9])([A-Z])/g,"$1 $2");let o=Jn(s);(o==="localhost"||o==="node")&&(o="nexuscrew");const a=i.slice(0,4),c=Math.max(1,32-a.length-1);return`${o.slice(0,c).replace(/-+$/g,"")||"n"}-${a}`}function Mx(e,{deviceDefault:t="",localNodeId:i="",localNameDefault:s=""}={}){const o={name:e.name,ssh:e.ssh,pairingUrl:e.pairingUrl,...e.label?{label:e.label}:{},...e.sshPort?{sshPort:Number(e.sshPort)}:{}},a=e.localLabel||t;a&&(o.localLabel=a);const c=String(e.localName||tl(a,i)||s||"").trim();return c&&(o.localName=c),o}function Lx(){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 Tx=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function Ax(e){const t=e&&e.data||{},i=typeof t.stage=="string"&&t.stage?t.stage:"",s=typeof t.detail=="string"&&t.detail?t.detail:"";return{stage:i,code:typeof t.code=="string"?t.code:"",detail:s,hint:typeof t.hint=="string"?t.hint:"",suggestedName:typeof t.suggestedName=="string"?t.suggestedName:"",retryable:typeof t.retryable=="boolean"?t.retryable:!i,message:s||String(e&&e.message||e)}}const Ix="modulepreload",Bx=function(e){return"/"+e},Sv={},Ox=function(t,i,s){let o=Promise.resolve();if(i&&i.length>0){let c=function(p){return Promise.all(p.map(y=>Promise.resolve(y).then(S=>({status:"fulfilled",value:S}),S=>({status:"rejected",reason:S}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),m=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));o=c(i.map(p=>{if(p=Bx(p),p in Sv)return;Sv[p]=!0;const y=p.endsWith(".css"),S=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${S}`))return;const _=document.createElement("link");if(_.rel=y?"stylesheet":Ix,y||(_.as="script"),_.crossOrigin="",_.href=p,m&&_.setAttribute("nonce",m),document.head.appendChild(_),y)return new Promise((C,w)=>{_.addEventListener("load",C),_.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${p}`)))})}))}function a(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return o.then(c=>{for(const h of c||[])h.status==="rejected"&&a(h.reason);return t().catch(a)})};class Ye{constructor(t,i,s,o,a){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||a?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=i),i=typeof s=="object"?s:{},this._onDecodeError=i.onDecodeError||(typeof s=="function"?s:this._onDecodeError),this._calculateScanRegion=i.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=i.preferredCamera||a||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=i.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let 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"),a=this.$overlay.style,a.position="absolute",a.display="none",a.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!o&&i.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}s.insertBefore(this.$overlay,this.$video.nextSibling)}i.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let h=window.getComputedStyle(t);h.display==="none"&&(t.style.setProperty("display","block","important"),c=!0),h.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,a)=>({id:o.deviceId,label:o.label||(a===0?"Default Camera":`Camera ${a+1}`)}))}finally{s&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),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,a=!1,c=!1){let h,m=!1;i&&("scanRegion"in i||"qrEngine"in i||"canvas"in i||"disallowCanvasResizing"in i||"alsoTryWithoutScanRegion"in i||"returnDetailedScanResult"in i)?(h=i.scanRegion,s=i.qrEngine,o=i.canvas,a=i.disallowCanvasResizing||!1,c=i.alsoTryWithoutScanRegion||!1,m=!0):console.warn(i||s||o||a||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,y;[s,p]=await Promise.all([s||Ye.createQrEngine(),Ye._loadImage(t)]),[o,y]=Ye._drawToCanvas(p,h,o,a);let S;if(s instanceof Worker){let _=s;i||Ye._postWorkerMessageSync(_,"inversionMode","both"),S=await new Promise((C,w)=>{let x,k,b,D=-1;k=M=>{M.data.id===D&&(_.removeEventListener("message",k),_.removeEventListener("error",b),clearTimeout(x),M.data.data!==null?C({data:M.data.data,cornerPoints:Ye._convertPoints(M.data.cornerPoints,h)}):w(Ye.NO_QR_CODE_FOUND))},b=M=>{_.removeEventListener("message",k),_.removeEventListener("error",b),clearTimeout(x),w("Scanner error: "+(M?M.message||M:"Unknown Error"))},_.addEventListener("message",k),_.addEventListener("error",b),x=setTimeout(()=>b("timeout"),1e4);let L=y.getImageData(0,0,o.width,o.height);D=Ye._postWorkerMessageSync(_,"decode",L,[L.data.buffer])})}else S=await Promise.race([new Promise((_,C)=>window.setTimeout(()=>C("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,h)}}catch(C){if(_=C.message||C,/not implemented|service unavailable/.test(_))return Ye._disableBarcodeDetector=!0,Ye.scanImage(t,{scanRegion:h,canvas:o,disallowCanvasResizing:a,alsoTryWithoutScanRegion:c});throw`Scanner error: ${_}`}})()]);return m?S:S.data}catch(p){if(!h||!c)throw p;let y=await Ye.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:a});return m?y:y.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=()=>Ox(()=>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,a=t.offsetHeight,c=t.offsetLeft,h=t.offsetTop,m=window.getComputedStyle(t),p=m.objectFit,y=i/s,S=o/a;switch(p){case"none":var _=i,C=s;break;case"fill":_=o,C=a;break;default:(p==="cover"?y>S:y<S)?(C=a,_=C*y):(_=o,C=_/y),p==="scale-down"&&(_=Math.min(_,i),C=Math.min(C,s))}var[w,x]=m.objectPosition.split(" ").map((b,D)=>{const L=parseFloat(b);return b.endsWith("%")?(D?a-C:o-_)*L/100:L});m=this._scanRegion.width||i,S=this._scanRegion.height||s,p=this._scanRegion.x||0;var k=this._scanRegion.y||0;y=this.$overlay.style,y.width=`${m/i*_}px`,y.height=`${S/s*C}px`,y.top=`${h+x+k/s*C}px`,s=/scaleX\(-1\)/.test(t.style.transform),y.left=`${c+(s?o-w-_:w)+(s?i-p-m:p)/i*_}px`,y.transform=t.style.transform}})}static _convertPoints(t,i){if(!i)return t;let s=i.x||0,o=i.y||0,a=i.width&&i.downScaledWidth?i.width/i.downScaledWidth:1;i=i.height&&i.downScaledHeight?i.height/i.downScaledHeight:1;for(let c of t)c.x=c.x*a+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:a})=>`${o},${a}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(t){t!==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 a=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),c=this._getFacingMode(a)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:a,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 a=i&&i.x?i.x:0,c=i&&i.y?i.y:0,h=i&&i.width?i.width:t.videoWidth||t.width,m=i&&i.height?i.height:t.videoHeight||t.height;return o||(o=i&&i.downScaledWidth?i.downScaledWidth:h,i=i&&i.downScaledHeight?i.downScaledHeight:m,s.width!==o&&(s.width=o),s.height!==i&&(s.height=i)),i=s.getContext("2d",{alpha:!1}),i.imageSmoothingEnabled=!1,i.drawImage(t,a,c,h,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=a=>{t.removeEventListener("load",o),t.removeEventListener("error",o),a instanceof ErrorEvent?s("Image load error"):i()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,i,s,o){return Ye._postWorkerMessageSync(await t,i,s,o)}static _postWorkerMessageSync(t,i,s,o){if(!(t instanceof Worker))return-1;let a=Ye._workerMessageId++;return t.postMessage({id:a,type:i,data:s},o),a}}Ye.DEFAULT_CANVAS_SIZE=400;Ye.NO_QR_CODE_FOUND="No QR code found";Ye._disableBarcodeDetector=!1;Ye._workerMessageId=0;function zx({onResult:e,onClose:t}){const i=R.useRef(null),s=R.useRef(null),o=R.useRef(!1),[a,c]=R.useState("");R.useEffect(()=>{let m=!1;const p=i.current,y=S=>{m||o.current||(o.current=!0,e(S))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){c(v("qr-unsupported"));return}let S=!1;try{S=await Ye.hasCamera()}catch{S=!1}if(!S){c(v("qr-no-camera"));return}if(m||!p)return;const _=new Ye(p,C=>{const w=_v(C);w&&y(w)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:C=>{const w=C.videoWidth||640,x=C.videoHeight||480,k=Math.max(1,Math.round(Math.min(w,x)*.92));return{x:Math.round((w-k)/2),y:Math.round((x-k)/2),width:k,height:k,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=_;try{await _.start()}catch(C){if(m)return;const w=C&&C.name||"";c(v(w==="NotAllowedError"||w==="SecurityError"?"qr-permission":w==="NotFoundError"||w==="OverconstrainedError"||w==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{m=!0;const S=s.current;if(S){try{S.stop()}catch{}try{S.destroy()}catch{}s.current=null}const _=p,C=_&&_.srcObject;if(C&&typeof C.getTracks=="function"){for(const w of C.getTracks())try{w.stop()}catch{}try{_.srcObject=null}catch{}}}},[]);const h=async m=>{const p=m.target.files&&m.target.files[0];if(m.target.value="",!!p)try{const y=await Ye.scanImage(p,{returnDetailedScanResult:!0}),S=_v(y);if(!S)throw new Error("empty");o.current||(o.current=!0,e(S))}catch{c(v("pairing-qr-invalid"))}};return u.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:t,children:u.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:m=>m.stopPropagation(),children:[u.jsx("div",{className:"nc-sheet-head",children:u.jsx("b",{children:v("scan-qr")})}),u.jsx("video",{ref:i,className:"nc-qr-video",playsInline:!0,muted:!0}),a&&u.jsx("div",{className:"nc-err",role:"alert",children:a}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[v("qr-upload"),u.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:h})]}),u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:t,children:v("cancel")})]})]})})}const wv=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:"",localName:""});function Sy({token:e,initial:t="",autoStart:i=!1,deviceDefault:s="",localNodeId:o="",localNameDefault:a="",readonly:c=!1,onSuccess:h,onBusyChange:m}){const[p,y]=R.useState(wv),[S,_]=R.useState(!1),[C,w]=R.useState(!1),[x,k]=R.useState("idle"),[b,D]=R.useState(null),[L,M]=R.useState(""),[te,U]=R.useState(!1),[O,ee]=R.useState(!1),q=R.useRef(Lx()),J=R.useRef(new Set),Q=x==="busy",T=tl(p.localLabel||s,o)||a,N=O?p.localName:T;R.useEffect(()=>(m&&m(Q),()=>{m&&m(!1)}),[Q,m]);const P=async W=>{const j=String(W.pairingUrl||"").trim();if(q.current.start(j)){k("busy"),D(null),M("");try{await t0(e,Mx({...W,localName:O?W.localName:tl(W.localLabel||s,o)||a},{deviceDefault:s,localNodeId:o,localNameDefault:a})),k("ok"),_(!1),y(wv()),J.current=new Set,U(!1),ee(!1),q.current.finish(),h&&await h()}catch(A){const se=Ax(A);D(se),k("idle"),q.current.finish(),se.code==="peer-name-conflict"&&sd(se.suggestedName)&&(ee(!0),J.current.add("localName"),y(ge=>({...ge,localName:se.suggestedName}))),(se.stage==="validation"||se.stage==="conflict"||se.stage==="ssh-start"||se.stage==="ssh-ready"||String(se.code||"").startsWith("ssh-"))&&_(!0)}}},I=(W,j=!0)=>{const{classification:A,form:se}=yv(p,W,J.current,te),ge=se.pairingUrl;if(D(null),M(""),x==="ok"&&k("idle"),y(se),A.kind==="invalid"){D({stage:"validation",code:"bad-link",message:v("pair-invalid-link"),hint:v("pair-invalid-hint"),retryable:!0});return}if(A.kind==="partial"){_(!0),M(A.missing.includes("ssh")?v("pair-missing-ssh"):v("pair-missing-name"));return}A.kind==="complete"&&j&&!c&&q.current.canAuto(ge)&&P(se)};R.useEffect(()=>{t&&I(t,i)},[]);const $=()=>{const W=String(p.pairingUrl||"").trim(),{classification:j,form:A}=yv(p,W,J.current,te);if(y(A),M(""),D(null),j.kind==="empty"){D({stage:"validation",message:v("pairing-required"),retryable:!0});return}if(j.kind==="invalid"){D({stage:"validation",code:"bad-link",message:v("pair-invalid-link"),hint:v("pair-invalid-hint"),retryable:!0});return}if(!A.ssh||!A.name){_(!0),M(A.ssh?v("pair-missing-name"):v("pair-missing-ssh"));return}if(A.label&&!vo(A.label)){D({stage:"validation",message:v("err-label"),retryable:!0});return}if(A.localLabel&&!vo(A.localLabel)){D({stage:"validation",message:v("err-label"),retryable:!0});return}const se=O?A.localName:tl(A.localLabel||s,o)||a;if(!sd(se)||se==="localhost"){_(!0),D({stage:"validation",code:"bad-local-name",message:v("err-local-name"),retryable:!0});return}q.current.reset(W),P(A)},K=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const W=await navigator.clipboard.readText();W&&W.trim()?I(W):M(v("pair-clipboard-empty"))}catch{M(v("pair-clipboard-denied"))}},F=(W,j)=>{J.current.add(W),y(A=>({...A,[W]:j}))},ae=b&&b.stage&&(Tx.includes(b.stage)||b.stage==="internal")?v(`pair-stage-${b.stage}`):v("pair-stage-generic");return u.jsxs("div",{className:"nc-set-form nc-pair-card",children:[u.jsx("div",{className:"nc-sheet-label",children:v("pair-card-title")}),u.jsx("div",{className:"nc-set-info",children:v("pair-card-help")}),u.jsx("input",{className:"nc-pair-input",placeholder:v("pair-paste-ph"),value:p.pairingUrl,disabled:c||Q,onChange:W=>{y({...p,pairingUrl:W.target.value}),D(null),M("")},onPaste:W=>{const j=W.clipboardData&&W.clipboardData.getData("text")||"";j.trim()&&(W.preventDefault(),I(j))},onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),$())}}),u.jsxs("div",{className:"nc-pair-actions",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||Q,onClick:K,children:v("pair-paste-btn")}),u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||Q,onClick:()=>w(!0),children:v("scan-qr")}),u.jsx("button",{type:"button",className:"nc-btn primary",disabled:c||Q,title:c?v("settings-readonly"):"",onClick:$,children:v("test-and-connect")})]}),u.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[Q&&u.jsx("div",{className:"nc-pair-progress",children:v("pair-progress")}),x==="ok"&&u.jsx("div",{className:"nc-set-test ok",children:v("node-connected")}),L&&u.jsx("div",{className:"nc-set-hint nc-pair-notice",children:L}),b&&u.jsxs("div",{className:"nc-err",role:"alert",children:[u.jsx("b",{children:ae})," — ",b.message,b.hint&&u.jsx("div",{className:"nc-pair-hint",children:b.hint}),b.retryable&&u.jsx("div",{children:u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||Q,onClick:$,children:v("pair-retry")})})]})]}),u.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:Q,onClick:()=>_(W=>!W),children:[S?"▾":"▸"," ",v("pair-advanced")]}),S&&u.jsxs("div",{className:"nc-pair-advanced",children:[u.jsxs("label",{className:"nc-field",children:[v("node-display-label"),u.jsx("input",{placeholder:"Home Relay",value:p.label,disabled:c||Q,onChange:W=>{J.current.add("label"),y(j=>({...j,label:W.target.value,name:te?j.name:Jn(W.target.value)}))}})]}),u.jsxs("label",{className:"nc-field",children:[v("node-name-label"),u.jsx("input",{placeholder:v("node-name-ph"),value:p.name,disabled:c||Q,onChange:W=>{U(!0),J.current.add("name"),y(j=>({...j,name:W.target.value?Jn(W.target.value):""}))}})]}),u.jsx("small",{className:"nc-set-hint",children:v("node-slug-hint").replace("{slug}",p.name||"home-relay")}),u.jsxs("label",{className:"nc-field",children:[v("pair-ssh-local-label"),u.jsx("input",{placeholder:"my-relay",value:p.ssh,disabled:c||Q,onChange:W=>{J.current.add("ssh"),F("ssh",W.target.value)}}),u.jsx("small",{className:"nc-set-hint",children:v("node-ssh-local-help")})]}),u.jsxs("label",{className:"nc-field",children:[v("node-ssh-port-label"),u.jsx("input",{inputMode:"numeric",placeholder:v("node-ssh-port-help"),value:p.sshPort,disabled:c||Q,onChange:W=>F("sshPort",W.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),u.jsxs("label",{className:"nc-field",children:[v("device-name-label"),u.jsx("input",{placeholder:s||"NexusCrew",value:p.localLabel,disabled:c||Q,onChange:W=>F("localLabel",W.target.value)}),u.jsx("small",{className:"nc-set-hint",children:v("device-name-hint")})]}),u.jsxs("label",{className:"nc-field",children:[v("local-route-name-label"),u.jsx("input",{placeholder:T||"nexuscrew-5bd6",value:N,disabled:c||Q,onChange:W=>{ee(!0),J.current.add("localName"),y(j=>({...j,localName:W.target.value?Jn(W.target.value):""}))}}),u.jsx("small",{className:"nc-set-hint",children:v("local-route-name-hint")})]})]}),C&&u.jsx(zx,{onResult:W=>{w(!1),I(W)},onClose:()=>w(!1)})]})}function Ch(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function Fx(e){const t="=".repeat((4-e.length%4)%4),i=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(i),o=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)o[a]=s.charCodeAt(a);return o}async function Hx(){if(!Ch())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function $x(e){if(!Ch())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const i=await qt("/api/push/vapid",e),{publicKey:s}=await i.json();if(!s)throw new Error("vapid non disponibile");const a=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Fx(s)}),c=await qt("/api/push/subscribe",e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:a.toJSON()})});if(!c.ok){try{await a.unsubscribe()}catch{}const h=await c.json().catch(()=>({}));throw new Error(h.error||`HTTP ${c.status}`)}return!0}async function Wx(e){if(!Ch())return!1;const i=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!i)return!1;const s=i.endpoint;try{await i.unsubscribe()}catch{}try{await qt("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const wy="nexuscrew.fleet",by=2,Ux="nexuscrew.cells",Kx=/^[A-Za-z0-9._-]{1,32}$/,xh=/^[a-z0-9._-]{1,32}$/,ky=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,qx=new Set(["standard","unsafe"]),Vx=4096,bv=256,Yx=8192,Xx=32,Gx=24,Qx=new Set(["format","version","exportedAt","cells","engines"]),Jx=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]),Zx=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag"]),eE=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]);function _r(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function Cy(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 kv(e,t){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))return null;const i=Object.entries(e);if(i.length>128)return null;const s={};for(const[o,a]of i){if(!xh.test(o)||!t(a))return null;s[o]=a}return s}function xy(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(a=>!Jx.has(a))||!Kx.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>Vx||!xh.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>bv)||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>Yx)return null;const i=kv(e.models,a=>typeof a=="string"&&!!a&&a.length<=bv),s=kv(e.permissionPolicies,a=>qx.has(a));if(i===null||s===null)return null;const o={id:e.id,cwd:e.cwd,engine:e.engine,boot:e.boot===!0,systemPrompt:t};return e.model&&(o.model=e.model),Object.keys(i).length&&(o.models=i),Object.keys(s).length&&(o.permissionPolicies=s),o}function tE(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(i=>!eE.has(i)))return null;const t={};for(const[i,s]of Object.entries(e)){if(typeof s!="string"||!_r(s,i==="baseUrl"?512:128)||Cy(s))return null;t[i]=s}return!t.client||!t.provider||t.envKey&&!ky.test(t.envKey)?null:t}function Ey(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!Zx.has(s))||!xh.test(String(e.id||""))||!_r(e.label||e.id,64)||e.rc!==void 0&&typeof e.rc!="boolean")return null;const t={id:e.id,label:e.label||e.id,rc:e.rc===!0};if(e.managed!==void 0){const s=tE(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!_r(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!_r(s,1024)||Cy(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!_r(e.promptFlag,32)||/\s/.test(e.promptFlag)))return null;if(e.model!==void 0){if(!e.model||typeof e.model!="object"||Array.isArray(e.model)||Object.keys(e.model).some(s=>s!=="flag"&&s!=="value")||!_r(e.model.flag,32)||/\s/.test(e.model.flag)||!_r(e.model.value||"",128))return null;t.model={flag:e.model.flag,value:e.model.value||""}}const i=e.envKeys===void 0?[]:e.envKeys;return!Array.isArray(i)||i.length>32||i.some(s=>!ky.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 Ny(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=Ey(t);return i||null}function iE(e,t,i=[],s=[],o=new Date){i instanceof Date&&(o=i,i=[],s=[]);const a=t instanceof Set?t:new Set(t||[]),c=s instanceof Set?s:new Set(s||[]),h=[];for(const p of Array.isArray(e)?e:[]){if(!a.has(p.id))continue;const y=xy({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||""});y&&h.push(y)}const m=[];for(const p of Array.isArray(i)?i:[]){if(!c.has(p.id))continue;const y=Ny(p);y&&m.push(y)}return{format:wy,version:by,exportedAt:o.toISOString(),cells:h,engines:m}}function nE(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)===Ux&&(t==null?void 0:t.version)===1;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(h=>!Qx.has(h))||!i&&(t.format!==wy||t.version!==by)||!Array.isArray(t.cells)||t.cells.length>Xx||!i&&(!Array.isArray(t.engines)||t.engines.length>Gx))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const s=[],o=new Set;for(const h of t.cells){const m=xy(h);if(!m)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(o.has(m.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};o.add(m.id),s.push(m)}const a=[],c=new Set;for(const h of i?[]:t.engines){const m=Ey(h);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),a.push(m)}return{ok:!0,cells:s,engines:a,legacy:i,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function rE(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))),a={id:e.id,cwd:e.cwd,engine:t,boot:e.boot===!0,prompt:e.systemPrompt||""};t===e.engine&&e.model?a.model=e.model:e.models&&e.models[t]&&(a.model=e.models[t]);const c=o(e.models),h=o(e.permissionPolicies);return Object.keys(c).length&&(a.models=c),Object.keys(h).length&&(a.permissionPolicies=h),a}const sE=()=>({kind:"managed",id:"claude.native",label:"",client:"claude",provider:"native",credentialProfile:"",managedModel:"",permissionPolicy:"unsafe",displayName:"",protocol:"anthropic_messages",baseUrl:"",envKey:"",providerId:"nexuscrew-custom",command:"",argsText:"",rc:!0,promptMode:"send-keys",promptFlag:"",modelFlag:"",modelValue:"",envRows:[],credentialValue:"",credentialReveal:!1,allowMissingCredential:!1}),Cv=(e="")=>({id:"",cwd:"",engine:e,boot:!1,model:"",prompt:""}),Ry=e=>e==="claude"?"unsafe":"standard",wo=(e,t)=>e.find(i=>i.client===t.client&&i.provider===t.provider&&(i.credentialProfile||"")===(t.credentialProfile||"")),oE=(e,t)=>{var i;return((i=wo(e,t))==null?void 0:i.label)||`${t.client} · ${t.provider}`};function aE(e){var t,i,s,o,a,c,h,m,p,y,S,_,C,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:((a=e.managed)==null?void 0:a.permissionPolicy)||Ry((c=e.managed)==null?void 0:c.client),displayName:((h=e.managed)==null?void 0:h.displayName)||"",protocol:((m=e.managed)==null?void 0:m.protocol)||"",baseUrl:((p=e.managed)==null?void 0:p.baseUrl)||"",envKey:((y=e.managed)==null?void 0:y.envKey)||"",providerId:((S=e.managed)==null?void 0:S.providerId)||"nexuscrew-custom",modelOptions:e.availableModels||((_=e.managedInfo)==null?void 0:_.models)||[],promptMode:e.promptMode||"send-keys",promptFlag:e.promptFlag||"",modelFlag:((C=e.model)==null?void 0:C.flag)||"",modelValue:((w=e.model)==null?void 0:w.value)||"",envRows:(e.envKeys||[]).map(x=>({key:x,value:"",configured:!0,remove:!1})),credentialValue:"",credentialReveal:!1,allowMissingCredential:!1}}function lE(e,t,i=[]){if(e.kind==="managed"){const o={client:e.client,provider:e.provider,model:e.managedModel||"",permissionPolicy:e.permissionPolicy||Ry(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile);const a=wo(i,e);return(a==null?void 0:a.credentialEnv)===!0&&(o.envKey=e.envKey),e.provider==="custom"&&Object.assign(o,{displayName:e.displayName,protocol:e.protocol,baseUrl:e.baseUrl,envKey:e.envKey,providerId:e.providerId}),{...t?{id:e.id}:{},label:e.label||oE(i,e),rc:!!e.rc,managed:o}}const s={...t?{id:e.id}:{},label:e.label||e.id,rc:!!e.rc,command:e.command,args:e.argsText.split(`
|
|
90
|
-
`).filter(o=>o!==""),promptMode:e.promptMode};return e.modelFlag&&(s.model={flag:e.modelFlag,value:e.modelValue||""}),e.promptMode==="flag"&&(s.promptFlag=e.promptFlag),t&&(s.env=Object.fromEntries(e.envRows.filter(o=>!o.remove&&o.key).map(o=>[o.key,o.value]))),s}function ns({children:e,onClose:t,label:i,error:s=""}){const o=R.useRef(null),a=R.useRef(null),c=R.useRef(t);return c.current=t,R.useEffect(()=>{const h=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),y=requestAnimationFrame(()=>{var _;return(_=p()[0]||m)==null?void 0:_.focus({preventScroll:!0})}),S=_=>{var k;if(_.key==="Escape"){_.preventDefault(),(k=c.current)==null||k.call(c);return}if(_.key!=="Tab")return;const C=p();if(!C.length){_.preventDefault(),m==null||m.focus();return}const w=C[0],x=C[C.length-1];_.shiftKey&&document.activeElement===w?(_.preventDefault(),x.focus()):!_.shiftKey&&document.activeElement===x&&(_.preventDefault(),w.focus())};return document.addEventListener("keydown",S),()=>{cancelAnimationFrame(y),document.removeEventListener("keydown",S),h&&h.isConnected&&typeof h.focus=="function"&&h.focus({preventScroll:!0})}},[]),R.useEffect(()=>{s&&requestAnimationFrame(()=>{var h;return(h=a.current)==null?void 0:h.scrollIntoView({block:"nearest"})})},[s]),u.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:h=>{h.target===h.currentTarget&&t()},children:u.jsxs("div",{ref:o,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":i||v("settings"),tabIndex:-1,children:[e,s&&u.jsx("div",{ref:a,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:s})]})})}function Qu({token:e,targets:t=[],readonly:i=!1,onPower:s,onImport:o}){const[a,c]=R.useState([]),[h,m]=R.useState(0);R.useEffect(()=>{let k=!0;async function b(){const L=[{route:[],label:v("local")}].concat((t||[]).map(te=>({route:Array.isArray(te.route)?te.route:[],label:te.label||(te.route||[]).join(" › ")}))),M=await Promise.all(L.map(async te=>{const U={...te,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const O=await Er(e,te.route);U.available=!!O.available,U.capabilities=O.capabilities||[],U.provider=O.provider||null,U.cells=(O.cells||[]).map(ee=>({...ee,route:te.route}));try{U.readonly=!!(await nh(e,te.route)).readonlyDefault}catch{}try{const ee=await Fv(e,te.route),q=new Set(U.cells.map(J=>J.tmuxSession).filter(Boolean));U.unmanaged=(ee.sessions||[]).filter(J=>J&&!q.has(J.name))}catch{}}catch(O){U.err=String(O&&O.message||O)}return U}));k&&c(M)}b();const D=setInterval(b,6e3);return()=>{k=!1,clearInterval(D)}},[e,t,h]);const p=(k,b)=>Array.isArray(k.capabilities)&&k.capabilities.includes(b)&&!i&&!k.readonly,y=()=>m(k=>k+1),S=(k,b)=>{s&&s({...k,route:b})},_=(k,b)=>{s&&s({...k,route:b})},C=async(k,b)=>{try{await co(e,k.cell,b)}catch{}y()},w=async(k,b)=>{if(window.confirm(v("fleet-remove-cell").replace("{id}",k.cell))){try{await Iv(e,k.cell,!0,b)}catch{}y()}},x=async(k,b)=>{if(window.confirm(v("terminate-confirm").replace("{name}",k.name))){try{await ih(e,k.name,b)}catch{}y()}};return u.jsxs("div",{className:"nc-fleet-inventory",children:[u.jsxs("div",{className:"nc-fleet-section-head",children:[u.jsx("b",{children:v("fleet-inventory")}),u.jsx("small",{children:v("fleet-inventory-help")})]}),a.map(k=>{const b=k.route.length?k.route.join("/"):"local";return u.jsxs("div",{className:"nc-fleet-pos",children:[u.jsxs("div",{className:"nc-fleet-pos-title",children:[u.jsx("span",{className:`dot ${k.available?"on":"warn"}`}),u.jsx("b",{children:k.label}),u.jsx("small",{children:k.available?`${k.cells.length} ${v("fleet-cells")} · ${k.unmanaged.length} ${v("fleet-tmux")}`:k.err||v("fleet-not-available")})]}),k.cells.map(D=>u.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[u.jsxs("span",{children:[u.jsx("b",{children:D.cell}),u.jsx("small",{children:`${D.engine||""}${D.key?`·${D.key}`:""}${D.active?"":` · ${v("cell-off")}`}`})]}),u.jsxs("span",{className:"nc-fleet-cell-actions",children:[D.active&&p(k,"down")&&u.jsx("button",{className:"nc-btn ghost",title:v("power-off"),onClick:()=>_(D,k.route),children:v("stop")}),!D.active&&p(k,"up")&&u.jsx("button",{className:"nc-btn ghost",title:v("power-on"),onClick:()=>S(D,k.route),children:v("start")}),p(k,"restart")&&D.active&&u.jsx("button",{className:"nc-btn ghost",title:v("restart"),onClick:()=>C(D,k.route),children:v("restart")}),p(k,"remove")&&u.jsx("button",{className:"nc-btn danger",title:v("delete"),onClick:()=>w(D,k.route),children:"×"})]})]},`${b}:${D.cell}`)),k.unmanaged.map(D=>u.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[u.jsxs("span",{children:[u.jsx("b",{children:D.name}),u.jsx("small",{children:v("fleet-tmux")})]}),u.jsxs("span",{className:"nc-fleet-cell-actions",children:[p(k,"import")&&o&&u.jsx("button",{className:"nc-btn ghost",title:v("import-as-cell"),onClick:()=>o(D,k.route),children:v("import-as-cell")}),u.jsx("button",{className:"nc-btn danger",title:v("terminate"),onClick:()=>x(D,k.route),children:"×"})]})]},`${b}:u:${D.name}`)),k.available&&k.cells.length===0&&k.unmanaged.length===0&&u.jsx("div",{className:"nc-empty",children:v("fleet-inventory-empty")})]},b)})]})}function cE({cells:e=[],engines:t=[],busy:i,canRestore:s=!1,onRestore:o,onClose:a}){const[c,h]=R.useState("export"),[m,p]=R.useState(()=>new Set(e.map(N=>N.id))),[y,S]=R.useState(()=>new Set(t.map(N=>N.id))),[_,C]=R.useState([]),[w,x]=R.useState([]),[k,b]=R.useState(""),D=new Set(t.map(N=>N.id)),L=new Set(e.map(N=>N.id)),M=(N,P)=>N(I=>{const $=new Set(I);return $.has(P)?$.delete(P):$.add(P),$}),te=()=>{const N=iE(e,m,t,y),P=t.filter(F=>y.has(F.id)).length;if(N.engines.length!==P){b(v("fleet-backup-invalid-engine"));return}if(!N.cells.length&&!N.engines.length){b(v("fleet-backup-select-one"));return}const I=new Blob([`${JSON.stringify(N,null,2)}
|
|
91
|
-
`],{type:"application/json"}),$=URL.createObjectURL(I),K=document.createElement("a");K.href=$,K.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(K),K.click(),K.remove(),setTimeout(()=>URL.revokeObjectURL($),0),b("")},U=async N=>{if(b(""),C([]),x([]),!!N){if(N.size>1024*1024){b(v("fleet-backup-too-large"));return}try{const P=nE(await N.text());if(!P.ok){b(v(`fleet-backup-${P.error}`));return}const I=new Set(P.engines.map($=>$.id));x(P.engines.map($=>({engine:$,exists:D.has($.id),selected:!D.has($.id)}))),C(P.cells.map($=>{const K=D.has($.engine)||I.has($.engine),F=L.has($.id);return{cell:$,engine:K?$.engine:"",selected:K&&!F,exists:F}}))}catch(P){b(String(P.message||P))}}},O=(N,P)=>C(I=>I.map(($,K)=>K===N?{...$,...P}:$)),ee=(N,P)=>x(I=>I.map(($,K)=>K===N?{...$,...P}:$)),q=new Set([...D,...w.filter(N=>N.selected).map(N=>N.engine.id)]),J=_.filter(N=>N.selected&&N.engine&&q.has(N.engine)),Q=w.filter(N=>N.selected),T=[...new Map([...t.map(N=>[N.id,N.label||N.id]),...w.filter(N=>N.selected).map(N=>[N.engine.id,N.engine.label||N.engine.id])]).entries()];return u.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[u.jsx("b",{children:v("fleet-backup")}),u.jsx("small",{children:v("fleet-backup-help")}),u.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[u.jsx("button",{type:"button",className:`nc-set-tabbtn${c==="export"?" on":""}`,onClick:()=>{h("export"),b("")},children:v("fleet-backup-export")}),u.jsx("button",{type:"button",className:`nc-set-tabbtn${c==="import"?" on":""}`,disabled:!s,title:s?"":v("fleet-backup-restore-unavailable"),onClick:()=>{h("import"),b("")},children:v("fleet-backup-import")})]}),c==="export"?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"nc-set-row",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{p(new Set(e.map(N=>N.id))),S(new Set(t.map(N=>N.id)))},children:v("select-all")}),u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{p(new Set),S(new Set)},children:v("select-none")})]}),u.jsxs("div",{className:"nc-backup-list",children:[u.jsx("b",{children:v("fleet-engines")}),t.map(N=>{var P;return u.jsxs("label",{className:"nc-check nc-backup-row",children:[u.jsx("input",{type:"checkbox",checked:y.has(N.id),onChange:()=>M(S,N.id)}),u.jsxs("span",{children:[u.jsx("b",{children:N.label||N.id}),u.jsxs("small",{children:[N.id,(P=N.envKeys)!=null&&P.length?` · ${N.envKeys.length} ${v("fleet-backup-env-names")}`:""]})]})]},N.id)}),u.jsx("b",{children:v("fleet-cells")}),e.map(N=>u.jsxs("label",{className:"nc-check nc-backup-row",children:[u.jsx("input",{type:"checkbox",checked:m.has(N.id),onChange:()=>M(p,N.id)}),u.jsxs("span",{children:[u.jsx("b",{children:N.id}),u.jsxs("small",{children:[N.engine," · ",v("fleet-system-prompt")," ",(N.prompt||"").length," ",v("characters")]})]})]},N.id)),!e.length&&!t.length&&u.jsx("div",{className:"nc-empty",children:v("fleet-backup-empty")})]}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:v("cancel")}),u.jsx("button",{type:"button",className:"nc-btn primary",disabled:!m.size&&!y.size,onClick:te,children:v("fleet-backup-download")})]})]}):u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"file",accept:"application/json,.json",disabled:i,onChange:N=>U(N.target.files&&N.target.files[0])}),u.jsx("small",{children:v("fleet-backup-import-help")}),!!(_.length||w.length)&&u.jsxs("div",{className:"nc-set-row",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{x(N=>N.map(P=>({...P,selected:!0}))),C(N=>N.map(P=>({...P,selected:!!P.engine})))},children:v("select-all")}),u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{x(N=>N.map(P=>({...P,selected:!1}))),C(N=>N.map(P=>({...P,selected:!1})))},children:v("select-none")})]}),u.jsxs("div",{className:"nc-backup-list",children:[!!w.length&&u.jsx("b",{children:v("fleet-engines")}),w.map((N,P)=>{var I;return u.jsx("div",{className:"nc-backup-import-row",children:u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:N.selected,onChange:$=>ee(P,{selected:$.target.checked})}),u.jsxs("span",{children:[u.jsx("b",{children:N.engine.label||N.engine.id}),u.jsxs("small",{children:[N.engine.id," · ",N.exists?v("fleet-backup-overwrite"):v("fleet-backup-new"),(I=N.engine.envKeys)!=null&&I.length?` · ${v("fleet-backup-env-values-required")}`:""]})]})]})},N.engine.id)}),!!_.length&&u.jsx("b",{children:v("fleet-cells")}),_.map((N,P)=>u.jsxs("div",{className:"nc-backup-import-row",children:[u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:N.selected,disabled:!N.engine||!q.has(N.engine),onChange:I=>O(P,{selected:I.target.checked})}),u.jsxs("span",{children:[u.jsx("b",{children:N.cell.id}),u.jsxs("small",{children:[N.exists?v("fleet-backup-overwrite"):v("fleet-backup-new")," · ",v("fleet-system-prompt")," ",N.cell.systemPrompt.length," ",v("characters")]})]})]}),u.jsxs("select",{value:N.engine,onChange:I=>O(P,{engine:I.target.value,selected:!!I.target.value}),children:[u.jsx("option",{value:"",children:v("fleet-backup-engine-missing")}),T.map(([I,$])=>u.jsx("option",{value:I,children:$},I))]})]},N.cell.id))]}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:v("cancel")}),u.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||!J.length&&!Q.length,onClick:()=>o({engineRows:w,cellRows:_}),children:v("fleet-backup-restore")})]})]}),k&&u.jsx("div",{className:"nc-err",children:k})]})}function uE({state:e,setState:t,busy:i,onSave:s,catalog:o}){var k;const a=e.form,c=b=>t({...e,form:{...a,...b}}),h=a.envRows||[],m=[...new Map(o.map(b=>[b.client,b.clientLabel||b.client])).entries()],p=o.filter(b=>b.client===a.client),y=wo(o,a),S=typeof(y==null?void 0:y.credentialEnv)=="string"?y.credentialEnv:"",_=Array.isArray(y==null?void 0:y.credentialUsedBy)?y.credentialUsedBy:[],C=(y==null?void 0:y.credentialSource)||"missing",w=!!S&&e.mode==="new"&&(y==null?void 0:y.authConfigured)!==!0&&!a.credentialValue&&!a.allowMissingCredential,x=b=>{b&&c({client:b.client,provider:b.provider,credentialProfile:b.credentialProfile||"",managedModel:b.model||"",protocol:b.protocol||"",permissionPolicy:b.permissionPolicyDefault||"standard",rc:!!b.rc,displayName:b.custom?v("fleet-custom-provider-default"):"",baseUrl:b.custom?"":b.endpoint||"",envKey:b.defaultEnvKey||"",providerId:"nexuscrew-custom",credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,...e.mode==="new"?{id:b.id,label:""}:{}})};return u.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[u.jsx("b",{children:e.mode==="new"?v("fleet-new-engine"):`${v("edit")} ${a.id}`}),u.jsx("input",{value:a.id,disabled:e.mode!=="new",placeholder:"id",onChange:b=>c({id:b.target.value})}),u.jsx("input",{value:a.label,placeholder:v("label"),onChange:b=>c({label:b.target.value})}),u.jsxs("select",{value:a.kind,disabled:e.mode!=="new",onChange:b=>c({kind:b.target.value}),children:[u.jsx("option",{value:"managed",children:v("fleet-managed")}),u.jsx("option",{value:"custom",children:v("fleet-custom")})]}),a.kind==="managed"?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"nc-fleet-pair",children:[u.jsx("select",{value:a.client,disabled:e.mode!=="new",onChange:b=>x(o.find(D=>D.client===b.target.value&&D.default)||o.find(D=>D.client===b.target.value)),children:m.map(([b,D])=>u.jsx("option",{value:b,children:D},b))}),u.jsx("select",{value:((k=wo(o,a))==null?void 0:k.id)||"",disabled:e.mode!=="new",onChange:b=>x(o.find(D=>D.id===b.target.value)),children:p.map(b=>u.jsx("option",{value:b.id,children:b.label},b.id))})]}),u.jsx("input",{value:a.managedModel,list:"nc-managed-models",placeholder:v(y!=null&&y.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:b=>c({managedModel:b.target.value})}),u.jsx("datalist",{id:"nc-managed-models",children:[...(y==null?void 0:y.models)||[],...a.modelOptions||[]].filter((b,D,L)=>b&&L.indexOf(b)===D).map(b=>u.jsx("option",{value:b},b))}),y!=null&&y.supportsUnsafe?u.jsxs("select",{value:a.permissionPolicy,onChange:b=>c({permissionPolicy:b.target.value}),children:[u.jsx("option",{value:"standard",children:v("fleet-standard-permissions")}),u.jsx("option",{value:"unsafe",children:v("fleet-unsafe-permissions")})]}):u.jsx("small",{children:v("fleet-standard-permissions")}),(y==null?void 0:y.supportsUnsafe)&&a.permissionPolicy==="unsafe"&&u.jsx("small",{className:"nc-err",children:v("fleet-unsafe-warning")}),(y==null?void 0:y.credentialEnv)===!0&&u.jsxs(u.Fragment,{children:[u.jsx("input",{value:a.envKey,placeholder:v("fleet-api-key-env"),onChange:b=>c({envKey:b.target.value})}),u.jsx("small",{children:v("fleet-custom-secret-help")})]}),S&&u.jsxs("section",{className:"nc-fleet-key","aria-label":v("fleet-key-section"),children:[u.jsxs("div",{className:"nc-fleet-key-head",children:[u.jsx("b",{children:v("fleet-key-section")}),u.jsx("span",{children:v(`fleet-credential-source-${C}`)})]}),u.jsxs("label",{className:"nc-field",children:[v("fleet-key-variable"),u.jsx("input",{value:S,readOnly:!0,"aria-label":v("fleet-key-variable")})]}),u.jsx("small",{children:_.length?v("fleet-key-used-by").replace("{engines}",_.join(", ")):v("fleet-key-used-by-none")}),_.length>0&&u.jsx("small",{children:v("fleet-key-shared-impact").replace("{key}",S).replace("{engines}",_.join(", "))}),u.jsxs("div",{className:"nc-fleet-key-input",children:[u.jsx("input",{type:a.credentialReveal?"text":"password",value:a.credentialValue||"","aria-label":v("fleet-key-value").replace("{key}",S),autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:y!=null&&y.authConfigured||e.mode==="edit"?v("fleet-key-blank-keeps"):v("fleet-key-enter"),onChange:b=>c({credentialValue:b.target.value,allowMissingCredential:b.target.value?!1:a.allowMissingCredential})}),u.jsx("button",{type:"button",className:"nc-btn ghost","aria-label":v(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal"),onClick:()=>c({credentialReveal:!a.credentialReveal}),children:v(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal")})]}),u.jsx("small",{children:v("fleet-key-local-help")}),e.mode==="new"&&(y==null?void 0:y.authConfigured)!==!0&&!a.credentialValue&&u.jsxs("label",{className:"nc-check nc-fleet-key-missing",children:[u.jsx("input",{type:"checkbox",checked:!!a.allowMissingCredential,onChange:b=>c({allowMissingCredential:b.target.checked})}),v("fleet-key-create-missing")]}),(y==null?void 0:y.notice)&&u.jsx("small",{className:"nc-fleet-provider-notice",children:v(`fleet-provider-notice-${y.notice}`)})]}),a.provider==="custom"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{value:a.displayName,placeholder:v("fleet-provider-display"),onChange:b=>c({displayName:b.target.value})}),u.jsx("input",{value:a.baseUrl,placeholder:"https://api.example.com/v1",onChange:b=>c({baseUrl:b.target.value})}),((y==null?void 0:y.protocols)||[]).length>1&&u.jsx("select",{value:a.protocol,onChange:b=>c({protocol:b.target.value}),children:y.protocols.map(b=>u.jsx("option",{value:b,children:b},b))}),u.jsxs("div",{className:"nc-fleet-pair",children:[u.jsx("input",{value:a.envKey,placeholder:v("fleet-api-key-env"),onChange:b=>c({envKey:b.target.value})}),u.jsx("input",{value:a.providerId,placeholder:v("fleet-provider-id"),onChange:b=>c({providerId:b.target.value})})]}),u.jsxs("small",{children:[a.protocol," · ",v("fleet-custom-secret-help")]})]}),u.jsx("small",{children:v("fleet-managed-help")})]}):u.jsxs(u.Fragment,{children:[u.jsx("input",{value:a.command,placeholder:v("command-path"),onChange:b=>c({command:b.target.value})}),u.jsx("textarea",{value:a.argsText,placeholder:v("args-lines"),onChange:b=>c({argsText:b.target.value})}),u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:a.rc,onChange:b=>c({rc:b.target.checked})})," remote control"]}),u.jsxs("select",{value:a.promptMode,onChange:b=>c({promptMode:b.target.value}),children:[u.jsx("option",{value:"send-keys",children:"send-keys"}),u.jsx("option",{value:"flag",children:"flag"})]}),a.promptMode==="flag"&&u.jsx("input",{value:a.promptFlag,placeholder:"prompt flag",onChange:b=>c({promptFlag:b.target.value})}),u.jsxs("div",{className:"nc-fleet-pair",children:[u.jsx("input",{value:a.modelFlag,placeholder:"model flag",onChange:b=>c({modelFlag:b.target.value})}),u.jsx("input",{value:a.modelValue,placeholder:"model default",onChange:b=>c({modelValue:b.target.value})})]}),u.jsx("small",{children:v("env-write-only")}),h.map((b,D)=>u.jsxs("div",{className:"nc-fleet-env",children:[u.jsx("input",{value:b.key,disabled:b.configured,placeholder:"ENV_KEY",onChange:L=>{const M=h.slice();M[D]={...b,key:L.target.value},c({envRows:M})}}),u.jsx("input",{type:"password",value:b.value,placeholder:b.configured?"•••••• (unchanged)":"value",onChange:L=>{const M=h.slice();M[D]={...b,value:L.target.value},c({envRows:M})}}),u.jsx("button",{className:"nc-btn danger",onClick:()=>c({envRows:h.filter((L,M)=>M!==D)}),children:"×"})]},`${b.key}-${D}`)),u.jsx("button",{className:"nc-btn ghost",onClick:()=>c({envRows:[...h,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{className:"nc-btn ghost",onClick:()=>t(null),children:v("cancel")}),u.jsx("button",{className:"nc-btn primary",disabled:i||!a.id||w||a.kind==="custom"&&!a.command||a.kind==="managed"&&(y==null?void 0:y.requiresModel)&&!a.managedModel||a.kind==="managed"&&(y==null?void 0:y.credentialEnv)===!0&&!a.envKey||a.kind==="managed"&&a.provider==="custom"&&(!a.displayName||!a.baseUrl||!a.envKey||!a.providerId),onClick:s,children:v("save")})]})]})}function dE({token:e,route:t,targets:i=[],location:s,setLocation:o,state:a,setState:c,engines:h,busy:m,onSave:p}){const[y,S]=R.useState(null),[_,C]=R.useState(""),w=a.form,x=L=>c({...a,form:{...w,...L}}),k=h.find(L=>L.id===w.engine),b=L=>{var te,U,O;const M=h.find(ee=>ee.id===L);x({engine:L,model:((te=w.models)==null?void 0:te[L])||((U=M==null?void 0:M.managed)==null?void 0:U.model)||((O=M==null?void 0:M.model)==null?void 0:O.value)||""})},D=async L=>{try{const M=await Ov(e,L,t);S(M),x({cwd:M.path}),C("")}catch(M){C(String(M.message||M))}};return u.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[u.jsx("b",{children:a.mode==="new"?v("fleet-new-cell"):`${v("edit")} ${w.id}`}),a.mode==="new"&&u.jsxs("label",{className:"nc-field",children:[v("location"),u.jsx("span",{className:"nc-req",children:" *"}),u.jsxs("select",{value:s,onChange:L=>{o(L.target.value),x({engine:""})},children:[u.jsx("option",{value:"",children:v("local")}),i.map(L=>u.jsxs("option",{value:L.route.join("/"),disabled:L.status&&L.status!=="up",children:[L.label,L.status&&L.status!=="up"?` · ${v("node-offline")}`:""]},L.route.join("/")))]})]}),u.jsx("input",{value:w.id,disabled:a.mode!=="new",placeholder:"id",onChange:L=>x({id:L.target.value})}),u.jsxs("div",{className:"nc-fleet-pair",children:[u.jsx("input",{value:w.cwd,placeholder:v("cwd"),onChange:L=>x({cwd:L.target.value})}),u.jsx("button",{className:"nc-btn ghost",onClick:()=>y?S(null):D(w.cwd),children:v("browse")})]}),y&&u.jsxs("div",{className:"nc-fs",children:[u.jsx("div",{className:"nc-fs-path",children:y.path}),u.jsxs("div",{className:"nc-fs-list",children:[y.parent&&u.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>D(y.parent),children:["↑ ",v("fs-parent")]}),(y.dirs||[]).map(L=>u.jsxs("button",{className:"nc-fs-item",onClick:()=>D(`${y.path.replace(/\/$/,"")}/${L}`),children:["📁 ",L]},L))]})]}),_&&u.jsx("div",{className:"nc-err",children:_}),u.jsx("select",{value:w.engine,onChange:L=>b(L.target.value),children:h.map(L=>u.jsx("option",{value:L.id,children:L.label},L.id))}),u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:!!w.boot,onChange:L=>x({boot:L.target.checked})})," boot"]}),u.jsx("input",{value:w.model||"",list:"nc-cell-models",placeholder:v("fleet-model-override"),onChange:L=>x({model:L.target.value})}),u.jsx("datalist",{id:"nc-cell-models",children:((k==null?void 0:k.availableModels)||[]).map(L=>u.jsx("option",{value:L},L))}),u.jsx("textarea",{value:w.prompt||"",placeholder:"prompt",onChange:L=>x({prompt:L.target.value})}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{className:"nc-btn ghost",onClick:()=>c(null),children:v("cancel")}),u.jsx("button",{className:"nc-btn primary",disabled:m||!w.id||!w.cwd||!w.engine,onClick:p,children:v("save")})]})]})}function xv({token:e,route:t=[],state:i,setState:s,busy:o,onSave:a}){const[c,h]=R.useState(null),[m,p]=R.useState([]),[y,S]=R.useState(""),_=Array.isArray(t)?t.join("/"):"";R.useEffect(()=>{let b=!0;return th(e,_?_.split("/"):[]).then(D=>{b&&(p(D.engines||[]),S(""))}).catch(D=>{b&&(p([]),S(String(D.message||D)))}),()=>{b=!1}},[e,_]);const C=i.form,w=b=>s({...i,form:{...C,...b}}),x=async b=>{try{const D=await Ov(e,b,t);h(D),w({cwd:D.path})}catch{}},k=!C.id&&C.tmuxSession?C.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):C.id;return u.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[u.jsxs("b",{children:[v("import-as-cell")," · ",C.tmuxSession]}),u.jsx("small",{children:v("import-help")}),u.jsx("input",{value:C.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),u.jsx("input",{value:C.id,placeholder:v("name"),onChange:b=>w({id:b.target.value})}),u.jsxs("div",{className:"nc-fleet-pair",children:[u.jsx("input",{value:C.cwd,placeholder:v("cwd"),onChange:b=>w({cwd:b.target.value})}),u.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>c?h(null):x(C.cwd),children:v("browse")})]}),c&&u.jsxs("div",{className:"nc-fs",children:[u.jsx("div",{className:"nc-fs-path",children:c.path}),u.jsxs("div",{className:"nc-fs-list",children:[c.parent&&u.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>x(c.parent),children:["↑ ",v("fs-parent")]}),(c.dirs||[]).map(b=>u.jsxs("button",{className:"nc-fs-item",onClick:()=>x(`${c.path.replace(/\/$/,"")}/${b}`),children:["📁 ",b]},b))]})]}),u.jsxs("select",{value:C.engine,onChange:b=>w({engine:b.target.value}),children:[u.jsx("option",{value:"",children:v("import-engine-required")}),m.map(b=>u.jsx("option",{value:b.id,children:b.label},b.id))]}),u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:!!C.boot,onChange:b=>w({boot:b.target.checked})})," boot"]}),(i.err||y)&&u.jsx("div",{className:"nc-err",children:i.err||y}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:v("cancel")}),u.jsx("button",{className:"nc-btn primary",disabled:o||!C.tmuxSession||!C.engine||!m.length,onClick:a,children:v(k?"import-as-cell":"save")})]})]})}function hE({token:e,readonly:t,targets:i=[],startNewCell:s=!1,initialLocation:o=""}){const[a,c]=R.useState({engines:[],cells:[],managedCatalog:[]}),[h,m]=R.useState({available:!1,capabilities:[]}),[p,y]=R.useState(!1),[S,_]=R.useState(null),[C,w]=R.useState(null),[x,k]=R.useState(!1),[b,D]=R.useState(""),[L,M]=R.useState(""),[te,U]=R.useState(o),[O,ee]=R.useState(!1),[q,J]=R.useState(null),[Q,T]=R.useState(null),[N,P]=R.useState(!1),[I,$]=R.useState([]),[K,F]=R.useState(null),[ae,W]=R.useState("manage"),j=R.useRef(!1),A=te?te.split("/"):[],se=R.useCallback(async()=>{try{const le=await Er(e,A);m(le);try{const be=await nh(e,A);ee(!!be.readonlyDefault)}catch{ee(!1)}if(le.provider==="builtin"&&(le.capabilities||[]).includes("definitions")){const be=await th(e,A),Fe=new Map((le.engines||[]).map($e=>[$e.id,$e]));if(be.engines=(be.engines||[]).map($e=>{var pe;return{...$e,availableModels:((pe=Fe.get($e.id))==null?void 0:pe.models)||[]}}),c(be),(le.capabilities||[]).includes("credentials"))try{$((await Hw(e,A)).credentials||[])}catch{$([])}else $([])}D("")}catch(le){D(String(le.message||le))}finally{y(!0)}},[e,te]);R.useEffect(()=>{se();const le=setInterval(se,5e3);return()=>clearInterval(le)},[se]);const ge=new Set((h.cells||[]).filter(le=>le.active).map(le=>le.cell)),G=h.provider==="builtin"&&(h.capabilities||[]).includes("edit"),Z=(h.capabilities||[]).includes("restore");R.useEffect(()=>{!s||j.current||!G||!a.engines.length||(j.current=!0,w({mode:"new",form:Cv(a.engines[0].id)}))},[s,G,a.engines]);const ue=async le=>{k(!0),D(""),M("");try{await le(),await se()}catch(be){D(String(be.message||be))}k(!1)},de=()=>ue(async()=>{var re;const le=S.mode==="new",be=S.form,Fe=a.managedCatalog||[],$e=be.kind==="managed"?wo(Fe,be):null,pe=typeof($e==null?void 0:$e.credentialEnv)=="string"?$e.credentialEnv:"",Be=pe&&be.credentialValue||"",Te=lE(be,le,Fe);!le&&S.form.kind==="custom"&&!S.form.modelFlag&&(Te.model=null),!le&&S.form.kind==="custom"&&S.form.promptMode!=="flag"&&(Te.promptFlag=null);let Y;if(le)Y=await Ww(e,Te,A);else{const me=S.original,Ae=new Set(S.form.envRows.filter(He=>!He.remove).map(He=>He.key)),Se=(me.envKeys||[]).filter(He=>!Ae.has(He)),xe=Object.fromEntries(S.form.envRows.filter(He=>!He.remove&&He.key&&(!He.configured||He.value!=="")).map(He=>[He.key,He.value]));Y=await Uw(e,me.id,Te,S.form.kind==="custom"?{set:xe,remove:Se}:void 0,A)}let ne=null;if(pe&&Be)try{ne=await pm(e,pe,Be,A),$(ne.credentials||[])}catch{throw await se(),le&&_({mode:"edit",original:{...Te,id:be.id},form:{...be,credentialReveal:!1}}),new Error(v(le?"fleet-key-partial-create":"fleet-key-partial-edit"))}await se(),_(null),M(v("fleet-saved"));const z=((re=((ne==null?void 0:ne.credentials)||[]).find(me=>me.envKey===pe))==null?void 0:re.activeCells)||[],H=[...new Set([...(Y==null?void 0:Y.activeCells)||[],...z])];if(H.length&&window.confirm(v("fleet-restart-confirm").replace("{cells}",H.join(", "))))for(const me of H)await co(e,me,A)}),Ce=()=>ue(async()=>{const le=C.mode==="new",be=C.form,Fe={...le?{id:be.id}:{},cwd:be.cwd,engine:be.engine,boot:!!be.boot};le?(be.model&&(Fe.model=be.model),be.prompt&&(Fe.prompt=be.prompt)):(Fe.model=be.model||null,Fe.prompt=be.prompt||null);const $e=le?await qw(e,Fe,A):await Vw(e,C.original.id,Fe,A),pe=le?be.id:C.original.id;w(null),M(v("fleet-saved")),!le&&($e!=null&&$e.active)&&window.confirm(v("fleet-restart-confirm").replace("{cells}",pe))&&await co(e,pe,A)}),Re=t||O,tt=le=>I.find(be=>{var Fe;return(Fe=be.engines)==null?void 0:Fe.includes(le.id)})||null,Je=()=>ue(async()=>{var Fe;const le=await pm(e,K.envKey,K.value,A);$(le.credentials||[]),F(null),M(v("fleet-credential-saved"));const be=((Fe=(le.credentials||[]).find($e=>$e.envKey===K.envKey))==null?void 0:Fe.activeCells)||[];if(be.length&&window.confirm(v("fleet-restart-confirm").replace("{cells}",be.join(", "))))for(const $e of be)await co(e,$e,A)}),Ee=le=>ue(async()=>{if(!window.confirm(v("fleet-credential-remove-confirm").replace("{key}",le.envKey)))return;const be=await $w(e,le.envKey,A);$(be.credentials||[]),M(v("fleet-credential-removed"))}),rt=le=>J({...le,route:Array.isArray(le==null?void 0:le.route)?le.route:A}),wt=async le=>{if(!q)return;const be=q.cell||q.id,Fe=Array.isArray(q.route)?q.route:A;le.action==="up"?await eh(e,{cell:be,boot:!!le.boot,...le.engine?{engine:le.engine}:{},...le.model!==void 0?{model:le.model}:{},...le.permissionPolicy?{permissionPolicy:le.permissionPolicy}:{}},Fe):await il(e,{cell:be,boot:!!le.boot},Fe)},Dt=(le,be)=>{D(""),T({mode:"new",route:Array.isArray(be)?be:A,form:{tmuxSession:le.name,id:"",engine:"",cwd:"",boot:!1},err:""})},st=()=>ue(async()=>{const le=Q.form;if(!le.engine){T({...Q,err:v("import-engine-required")});return}await Yw(e,{tmuxSession:le.tmuxSession,id:le.id||void 0,engine:le.engine,cwd:le.cwd||void 0,boot:!!le.boot},le.route||A),T(null),M(v("fleet-saved"))}),gt=({engineRows:le=[],cellRows:be=[]})=>ue(async()=>{const Fe=le.filter(re=>re.selected),$e=Fe.map(re=>Ny(re.engine));if($e.some(re=>!re))throw new Error(v("fleet-backup-invalid-engine"));const pe=Fe.filter(re=>re.exists).map(re=>re.engine.id);if(pe.length&&!window.confirm(v("fleet-backup-confirm-engine-overwrite").replace("{engines}",pe.join(", "))))return;const Be=[...new Set([...a.engines.map(re=>re.id),...$e.map(re=>re.id)])],Te=[];for(const re of be.filter(me=>me.selected)){const me=rE(re.cell,re.engine,Be);if(!me)throw new Error(`${re.cell.id}: ${v("fleet-backup-engine-missing")}`);Te.push(me)}const Y=be.filter(re=>re.selected&&re.exists).map(re=>re.cell.id);if(Y.length&&!window.confirm(v("fleet-backup-confirm-overwrite").replace("{cells}",Y.join(", "))))return;const ne=$e.length?await Gw(e,$e,pe.length>0,A):{needsRestart:[]},z=Te.length?await Xw(e,Te,A):{needsRestart:[]},H=[...new Set([...ne.needsRestart||[],...z.needsRestart||[]])];P(!1),M(`${v("fleet-backup-restored").replace("{n}",String(Te.length))}${$e.length?` · ${$e.length} ${v("fleet-engines").toLowerCase()}`:""}${H.length?` · ${v("fleet-backup-needs-restart").replace("{cells}",H.join(", "))}`:""}`)}),ct=u.jsxs("label",{className:"nc-field",children:[v("location"),u.jsxs("select",{value:te,onChange:le=>{U(le.target.value),_(null),w(null),D(""),M(""),ee(!1),y(!1),m({available:!1,capabilities:[]}),c({engines:[],cells:[],managedCatalog:[]}),$([]),F(null)},children:[u.jsx("option",{value:"",children:v("local")}),i.map(le=>u.jsxs("option",{value:le.route.join("/"),disabled:le.status&&le.status!=="up",children:[le.label,le.status&&le.status!=="up"?` · ${v("node-offline")}`:""]},le.route.join("/")))]})]}),at=u.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":v("tab-fleet"),children:[u.jsx("button",{type:"button",role:"tab","aria-selected":ae==="manage",className:`nc-set-tabbtn${ae==="manage"?" on":""}`,onClick:()=>W("manage"),children:v("fleet-manage-location")}),u.jsx("button",{type:"button",role:"tab","aria-selected":ae==="overview",className:`nc-set-tabbtn${ae==="overview"?" on":""}`,onClick:()=>W("overview"),children:v("fleet-network-overview")})]});return p?G?u.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[at,ae==="overview"?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"nc-set-info",children:v("fleet-overview-help")}),u.jsx(Qu,{token:e,targets:i,readonly:t,onPower:rt,onImport:Dt})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"nc-set-info",children:v("fleet-manage-help")}),ct,u.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[u.jsx("button",{className:"nc-btn ghost",disabled:Re||x,onClick:()=>{D(""),P(!0)},children:v("fleet-backup")}),u.jsx("small",{children:v("fleet-backup-help")})]}),u.jsxs("div",{className:"nc-fleet-section-head",children:[u.jsx("b",{children:v("fleet-cells")}),u.jsx("span",{className:"nc-fleet-head-actions",children:u.jsxs("button",{className:"nc-btn primary",disabled:Re||x||!a.engines.length,onClick:()=>{var le;D(""),w({mode:"new",form:Cv((le=a.engines[0])==null?void 0:le.id)})},children:["+ ",v("add")]})})]}),a.cells.map(le=>{const be=ge.has(le.id),Fe=h.capabilities||[];return u.jsxs("div",{className:"nc-fleet-item",children:[u.jsxs("span",{children:[u.jsx("b",{children:le.id}),u.jsxs("small",{children:[le.engine," · ",le.cwd,be?` · ${v("service-active")}`:` · ${v("cell-off")}`]})]}),u.jsxs("span",{children:[be&&Fe.includes("down")&&u.jsx("button",{className:"nc-btn ghost",disabled:Re||x,onClick:()=>ue(()=>il(e,{cell:le.id},A)),children:v("stop")}),!be&&Fe.includes("up")&&u.jsx("button",{className:"nc-btn primary",disabled:Re||x,onClick:()=>rt({cell:le.id,id:le.id,engine:le.engine,model:le.model,models:le.models,permissionPolicies:le.permissionPolicies,active:!1,boot:le.boot}),children:v("start")}),be&&Fe.includes("restart")&&u.jsx("button",{className:"nc-btn ghost",disabled:Re||x,onClick:()=>ue(()=>co(e,le.id,A)),children:v("restart")}),u.jsx("button",{className:"nc-btn ghost",disabled:Re||x,onClick:()=>{D(""),w({mode:"edit",original:le,form:{...le}})},children:v("edit")}),u.jsx("button",{className:"nc-btn danger",disabled:Re||x,onClick:()=>ue(async()=>{window.confirm(v("fleet-remove-cell").replace("{id}",le.id))&&await Iv(e,le.id,!0,A)}),children:"×"})]})]},le.id)}),u.jsxs("div",{className:"nc-fleet-section-head",children:[u.jsx("b",{children:v("fleet-engines")}),u.jsxs("button",{className:"nc-btn primary",disabled:Re||x,onClick:()=>{D(""),_({mode:"new",form:sE()})},children:["+ ",v("add")]})]}),a.engines.map(le=>{var Fe,$e;const be=tt(le);return u.jsxs("div",{className:"nc-fleet-item",children:[u.jsxs("span",{children:[u.jsx("b",{children:le.label}),u.jsx("small",{children:le.managed?`${le.id} · ${le.managed.client} / ${le.managed.provider} · ${(Fe=le.managedInfo)!=null&&Fe.configured?v("fleet-ready"):(($e=le.managedInfo)==null?void 0:$e.reason)||v("fleet-not-ready")}`:`${le.id} · ${le.command}`}),be&&u.jsxs("small",{children:[be.envKey," · ",v(`fleet-credential-source-${be.source||"missing"}`)]})]}),u.jsxs("span",{children:[be&&u.jsx("button",{className:"nc-btn ghost",disabled:Re||x,onClick:()=>{D(""),F({envKey:be.envKey,value:""})},children:be.configured?v("fleet-credential-change"):v("fleet-credential-set")}),(be==null?void 0:be.source)==="local"&&u.jsx("button",{className:"nc-btn danger",disabled:Re||x,onClick:()=>Ee(be),children:v("fleet-credential-forget")}),u.jsx("button",{className:"nc-btn ghost",disabled:Re||x,onClick:()=>{D(""),_({mode:"edit",original:le,form:aE(le)})},children:v("edit")}),u.jsx("button",{className:"nc-btn danger",disabled:Re||x,onClick:()=>ue(async()=>{window.confirm(v("fleet-remove-engine").replace("{id}",le.id))&&await Kw(e,le.id,A)}),children:"×"})]})]},le.id)})]}),S&&u.jsx(ns,{onClose:()=>_(null),label:v("fleet-new-engine"),error:b,children:u.jsx(uE,{state:S,setState:_,busy:x,onSave:de,catalog:a.managedCatalog||[]})}),C&&u.jsx(ns,{onClose:()=>w(null),label:v("fleet-new-cell"),error:b,children:u.jsx(dE,{token:e,route:A,targets:i,location:te,setLocation:U,state:C,setState:w,engines:a.engines,busy:x,onSave:Ce})}),L&&u.jsx("div",{className:"nc-set-note",children:L}),b&&u.jsx("div",{className:"nc-err",children:b}),N&&u.jsx(ns,{onClose:()=>P(!1),label:v("fleet-backup"),error:b,children:u.jsx(cE,{cells:a.cells,engines:a.engines,busy:x,canRestore:Z,onRestore:gt,onClose:()=>P(!1)})}),K&&u.jsx(ns,{onClose:()=>F(null),label:v("fleet-credential-title"),error:b,children:u.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[u.jsx("b",{children:v("fleet-credential-title")}),u.jsx("small",{children:v("fleet-credential-help")}),u.jsxs("label",{className:"nc-field",children:[K.envKey,u.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:K.value,onChange:le=>F({...K,value:le.target.value})})]}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{className:"nc-btn ghost",onClick:()=>F(null),children:v("cancel")}),u.jsx("button",{className:"nc-btn primary",disabled:x||!K.value,onClick:Je,children:v("save")})]})]})}),Q&&u.jsx(ns,{onClose:()=>T(null),label:v("import-as-cell"),error:b,children:u.jsx(xv,{token:e,route:Q.route||A,state:Q,setState:T,busy:x,onSave:st})}),q&&u.jsx(nl,{cell:q,token:e,route:Array.isArray(q.route)?q.route:A,onConfirm:async le=>{try{await wt(le)}finally{await se()}},onClose:()=>J(null)})]}):u.jsxs("div",{className:"nc-set-tab",children:[at,ae==="overview"?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"nc-set-info",children:v("fleet-overview-help")}),u.jsx(Qu,{token:e,targets:i,readonly:t,onPower:rt,onImport:Dt})]}):u.jsxs(u.Fragment,{children:[ct,u.jsxs("div",{className:"nc-set-info",children:[v(b?"fleet-editor-load-error":"fleet-editor-unavailable"),!b&&h.reason?` ${h.reason}`:""]})]}),b&&u.jsx("div",{className:"nc-err",children:b}),Q&&u.jsx(ns,{onClose:()=>T(null),label:v("import-as-cell"),error:b,children:u.jsx(xv,{token:e,route:Q.route||A,state:Q,setState:T,busy:x,onSave:st})}),q&&u.jsx(nl,{cell:q,token:e,route:Array.isArray(q.route)?q.route:A,onConfirm:async le=>{try{await wt(le)}finally{await se()}},onClose:()=>J(null)})]}):u.jsxs("div",{className:"nc-set-tab",children:[at,ae==="overview"?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"nc-set-info",children:v("fleet-overview-help")}),u.jsx(Qu,{token:e,targets:i,readonly:t,onPower:rt,onImport:Dt})]}):u.jsxs(u.Fragment,{children:[ct,u.jsx("div",{className:"nc-set-info",children:v("fleet-editor-loading")})]})]})}function fE({text:e}){const[t,i]=R.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)}catch{}};return u.jsxs("div",{className:"nc-set-copyline",children:[u.jsx("code",{children:e}),u.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:s,children:[u.jsx(et,{name:"copy",size:14})," ",v(t?"copied":"copy")]})]})}function pE({value:e}){const[t,i]=R.useState("");return R.useEffect(()=>{let s=!0;return Px.toDataURL(e,{margin:1,width:220}).then(o=>{s&&i(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?u.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function mE({token:e,nodes:t,settings:i,readonly:s,refresh:o}){const[a,c]=R.useState(null),[h,m]=R.useState(null),[p,y]=R.useState({}),[S,_]=R.useState(null),[C,w]=R.useState({ssh:"",sshPort:"",name:""}),[x,k]=R.useState(""),[b,D]=R.useState(""),[L,M]=R.useState(""),[te,U]=R.useState(!1),[O,ee]=R.useState(null),[q,J]=R.useState(null),Q=Date.now(),T=i&&i.deviceName||"",N=(t||[]).filter(G=>G&&G.direction==="outbound"&&G.name&&G.ssh),P=N.find(G=>G.name===x)||N[0]||null,I=N.find(G=>G.name===b)||N[0]||null,$=I?jm(I.tunnel,Q):null,K=I!=null&&I.shared?$!=null&&$.up?"share-local-active":"share-local-pending":$!=null&&$.up?"share-local-private":"share-local-private-down",F=[{key:"peer-group-hubs",rows:(t||[]).filter(G=>G.kind!=="transitive"&&G.relation!=="client")},{key:"peer-group-clients",rows:(t||[]).filter(G=>G.kind!=="transitive"&&G.relation==="client")},{key:"peer-group-routed",rows:(t||[]).filter(G=>G.kind==="transitive")}],ae=async(G,Z)=>{c(null),m(`${G}:${Z}`);try{const ue=await rh(e,G,Z);Z==="test"&&y(de=>({...de,[G]:ue})),await o()}catch(ue){c(`${G}: ${String(ue.message||ue)}`)}m(null)},W=async G=>{c(null),m(`${G}:remove`);try{await n0(e,G),J(null),await o()}catch(Z){c(`${G}: ${String(Z.message||Z)}`)}m(null)},j=G=>ee({name:G.name,direction:G.direction,label:G.label||G.name,ssh:G.ssh||"",sshPort:G.sshPort?String(G.sshPort):"",autostart:G.autostart===!0,visibility:G.visibility||"network",selected:[...G.selected||[]]}),A=async()=>{if(!O||!vo(O.label)){c(v("err-label"));return}const G=O.direction==="inbound"?{label:O.label,visibility:O.visibility,selected:O.visibility==="selected"?O.selected:[]}:{label:O.label,ssh:O.ssh,autostart:O.autostart,...O.sshPort?{sshPort:Number(O.sshPort)}:{}};c(null),m(`${O.name}:edit`);try{await i0(e,O.name,G),ee(null),await o()}catch(Z){c(`${O.name}: ${String(Z.message||Z)}`)}m(null)},se=async G=>{if(I){c(null),m(`${I.name}:share`);try{await r0(e,I.name,G),await o()}catch(Z){const ue=Z!=null&&Z.data&&typeof Z.data.hint=="string"?Z.data.hint:"";c(`${I.name}: ${String(Z.message||Z)}${ue?` — ${ue}`:""}`)}m(null)}},ge=async()=>{if(c(null),P){const ue=Dm({name:P.name,ssh:P.ssh,sshPort:P.sshPort||""});if(!ue.ok){c(v(ue.error));return}m("invite");try{_(await gm(e,{ssh:ue.value.ssh,...ue.value.sshPort?{sshPort:ue.value.sshPort}:{}},[P.name]))}catch(de){c(String(de.message||de))}m(null);return}const G=Jn(C.name||L||T||"NexusCrew"),Z=Dm({name:G,ssh:C.ssh,sshPort:C.sshPort});if(!Z.ok){c(v(Z.error));return}m("invite");try{_(await gm(e,{...L||T?{label:L||T}:{},name:G,ssh:Z.value.ssh,...Z.value.sshPort?{sshPort:Z.value.sshPort}:{}}))}catch(ue){c(String(ue.message||ue))}m(null)};return u.jsxs("div",{className:"nc-set-tab",children:[u.jsx("div",{className:"nc-sheet-label",children:v("peer-inventory-title")}),(t||[]).length===0&&u.jsx("div",{className:"nc-empty",children:v("no-nodes")}),F.map(G=>G.rows.length>0&&u.jsxs("div",{className:"nc-peer-group",children:[u.jsxs("div",{className:"nc-peer-group-title",children:[v(G.key)," ",u.jsx("span",{children:G.rows.length})]}),G.rows.map(Z=>{var tt,Je;const ue=Z.kind==="transitive",de=ue?{up:Z.stale!==!0,label:Z.stale===!0?"peer-routed-stale":"peer-routed"}:jm(Z.tunnel,Q),Ce=p[Z.name],Re=Z.actions||{};return u.jsxs("div",{className:`nc-set-node${ue?" routed":""}`,children:[u.jsxs("div",{className:"nc-set-node-head",children:[u.jsx("span",{className:`nc-dot ${de.up?"on":""}`}),u.jsx("b",{children:Z.label||Z.name}),u.jsxs("small",{children:[Z.name,ue?` · ${Z.route.join(" → ")}`:Z.direction==="outbound"?` · SSH ${Z.ssh||""}`:` · ${v("node-connected-client")}`,(tt=Z.tunnel)!=null&&tt.transport?` · ${Z.tunnel.transport} ${v("transport-used")}`:""]}),u.jsxs("span",{className:`nc-set-tunnel${de.up?" up":""}`,children:[v(de.label),de.since?` · ${de.since}`:""]})]}),!ue&&Z.direction==="inbound"&&u.jsx("div",{className:"nc-set-info",children:v(Z.shared?"peer-shared":"peer-private")}),Re.visibility&&Z.shared&&u.jsxs(u.Fragment,{children:[u.jsxs("select",{value:Z.visibility||"network",disabled:s||!!h,onChange:async Ee=>{m(`${Z.name}:visibility`);try{await vm(e,Z.name,Ee.target.value),await o()}catch(rt){c(String(rt.message||rt))}m(null)},children:[u.jsx("option",{value:"network",children:v("visibility-network")}),u.jsx("option",{value:"relay-only",children:v("visibility-relay")}),u.jsx("option",{value:"selected",children:v("visibility-selected")})]}),Z.visibility==="selected"&&u.jsx("div",{className:"nc-set-row",children:(t||[]).filter(Ee=>Ee.name!==Z.name&&Ee.nodeId).map(Ee=>{const rt=(Z.selected||[]).includes(Ee.nodeId);return u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:rt,disabled:s||!!h,onChange:async wt=>{const Dt=wt.target.checked?[...Z.selected||[],Ee.nodeId]:(Z.selected||[]).filter(st=>st!==Ee.nodeId);m(`${Z.name}:visibility`);try{await vm(e,Z.name,"selected",Dt),await o()}catch(st){c(String(st.message||st))}m(null)}})," ",Ee.label||Ee.name]},Ee.nodeId)})})]}),u.jsxs("div",{className:"nc-set-node-actions",children:[Re.edit&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!h,onClick:()=>j(Z),children:v("edit")}),Re.test&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!h,onClick:()=>ae(Z.name,"test"),children:v("node-test")}),Re.disconnect&&de.up&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!h,onClick:()=>ae(Z.name,"down"),children:v("tunnel-stop")}),Re.connect&&!de.up&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!h,onClick:()=>ae(Z.name,"up"),children:v("tunnel-start")}),Re.restart&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!h,onClick:()=>ae(Z.name,"restart"),children:v("tunnel-restart")}),Re.remove&&u.jsxs("button",{type:"button",className:"nc-btn danger",disabled:s||!!h,title:v(s?"settings-readonly":"delete"),onClick:()=>J(Z.name),children:[u.jsx(et,{name:"trash",size:14})," ",v("delete")]})]}),(O==null?void 0:O.name)===Z.name&&u.jsxs("div",{className:"nc-set-form nc-node-editor",children:[u.jsxs("label",{className:"nc-field",children:[v("node-display-label"),u.jsx("input",{value:O.label,disabled:!!h,onChange:Ee=>ee({...O,label:Ee.target.value})})]}),O.direction==="outbound"?u.jsxs(u.Fragment,{children:[u.jsxs("label",{className:"nc-field",children:[v("node-ssh-label"),u.jsx("input",{value:O.ssh,disabled:!!h,onChange:Ee=>ee({...O,ssh:Ee.target.value})})]}),u.jsxs("label",{className:"nc-field",children:[v("node-ssh-port-label"),u.jsx("input",{inputMode:"numeric",value:O.sshPort,disabled:!!h,onChange:Ee=>ee({...O,sshPort:Ee.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:O.autostart,disabled:!!h,onChange:Ee=>ee({...O,autostart:Ee.target.checked})})," ",v("boot-persist")]})]}):u.jsxs("label",{className:"nc-field",children:[v("peer-visibility"),u.jsxs("select",{value:O.visibility,disabled:!!h,onChange:Ee=>ee({...O,visibility:Ee.target.value}),children:[u.jsx("option",{value:"network",children:v("visibility-network")}),u.jsx("option",{value:"relay-only",children:v("visibility-relay")}),u.jsx("option",{value:"selected",children:v("visibility-selected")})]})]}),u.jsxs("div",{className:"nc-set-row",children:[u.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!h,onClick:A,children:v("save")}),u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!h,onClick:()=>ee(null),children:v("cancel")})]})]}),q===Z.name&&u.jsxs("div",{className:"nc-set-confirm",children:[u.jsx("b",{children:v("node-remove-confirm").replace("{name}",Z.label||Z.name)}),u.jsx("small",{children:v("node-remove-warning")}),u.jsxs("div",{className:"nc-set-row",children:[u.jsx("button",{type:"button",className:"nc-btn danger",disabled:!!h,onClick:()=>W(Z.name),children:v("delete")}),u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!h,onClick:()=>J(null),children:v("cancel")})]})]}),((Je=Z.health)==null?void 0:Je.detail)&&u.jsx("div",{className:`nc-set-test${Z.health.status==="healthy"?" ok":Z.health.status==="passive"?"":" ko"}`,children:Z.health.detail}),Ce&&u.jsxs("div",{className:`nc-set-test${Ce.ok?" ok":" ko"}`,children:[Ce.result,Ce.detail?` — ${Ce.detail}`:""]})]},`${Z.kind||"direct"}:${Z.nodeId||Z.name}`)})]},G.key)),I&&u.jsxs("div",{className:"nc-set-form nc-local-share",children:[u.jsx("div",{className:"nc-sheet-label",children:v("share-local-heading")}),N.length>1&&u.jsxs("label",{className:"nc-field",children:[v("share-local-hub"),u.jsx("select",{value:I.name,disabled:s||!!h,onChange:G=>D(G.target.value),children:N.map(G=>u.jsx("option",{value:G.name,children:G.label||G.name},G.name))})]}),u.jsxs("label",{className:"nc-check nc-node-share",children:[u.jsx("input",{type:"checkbox",checked:I.shared===!0,disabled:s||!!h,onChange:G=>se(G.target.checked)}),u.jsxs("span",{children:[u.jsx("b",{children:v("share-local-through").replace("{device}",T||v("local")).replace("{hub}",I.label||I.name)}),u.jsx("small",{children:v(I.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),u.jsx("div",{className:`nc-set-test${I.shared&&($!=null&&$.up)?" ok":$!=null&&$.up?"":" ko"}`,children:v(K)}),!($!=null&&$.up)&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!h,onClick:()=>se(I.shared===!0),children:v("share-local-reconnect")})]}),u.jsx(Sy,{token:e,deviceDefault:T,localNodeId:i&&i.nodeId||"",localNameDefault:i&&i.localName||"",readonly:s,onSuccess:o}),u.jsxs("div",{className:"nc-set-form",children:[u.jsx("div",{className:"nc-sheet-label",children:v("invite-node")}),u.jsx("small",{className:"nc-set-hint",children:v(P?"invite-network-hint":"invite-v2-hint")}),P?u.jsxs(u.Fragment,{children:[N.length>1&&u.jsxs("label",{className:"nc-field",children:[v("invite-network-label"),u.jsx("select",{value:P.name,disabled:s||!!h,onChange:G=>{k(G.target.value),_(null)},children:N.map(G=>u.jsx("option",{value:G.name,children:G.label||G.name},G.name))})]}),u.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[v("invite-network-via"),": ",u.jsx("b",{children:P.label||P.name})," · ",P.ssh,P.sshPort?`:${P.sshPort}`:""]}),u.jsx("small",{className:"nc-set-hint",children:v("invite-network-route")})]}):u.jsxs("label",{className:"nc-field",children:[v("invite-endpoint-label"),u.jsx("input",{placeholder:"user@host",value:C.ssh,disabled:s,onChange:G=>w({...C,ssh:G.target.value})}),u.jsx("small",{className:"nc-set-hint",children:v("invite-endpoint-needed")})]}),!P&&te&&u.jsxs("div",{className:"nc-invite-advanced",children:[u.jsxs("label",{className:"nc-field",children:[v("node-ssh-port-label"),u.jsx("input",{inputMode:"numeric",placeholder:"22",value:C.sshPort,disabled:s,onChange:G=>w({...C,sshPort:G.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),u.jsxs("label",{className:"nc-field",children:[v("device-name-label"),u.jsx("input",{placeholder:T||"NexusCrew",value:L,disabled:s,onChange:G=>M(G.target.value)}),u.jsx("small",{className:"nc-set-hint",children:v("device-name-hint")})]}),u.jsxs("label",{className:"nc-field",children:[v("node-name-label"),u.jsx("input",{placeholder:Jn(L||T||v("node-name-ph")),value:C.name,disabled:s,onChange:G=>w({...C,name:G.target.value?Jn(G.target.value):""})})]})]}),u.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[u.jsx("button",{type:"button",className:"nc-btn primary",disabled:s||!!h||!P&&!C.ssh.trim(),onClick:ge,children:v("create-pairing-link")}),!P&&u.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!h,onClick:()=>U(G=>!G),children:[te?"▾":"▸"," ",v("pair-advanced")]})]}),S&&u.jsxs(u.Fragment,{children:[u.jsx(pE,{value:S.pairingUrl}),u.jsx(fE,{text:S.pairingUrl}),u.jsx("div",{className:"nc-set-info",children:v("invite-next-steps")})]})]}),a&&u.jsx("div",{className:"nc-err",children:a})]})}function gE({token:e,readonly:t}){const[i,s]=R.useState("idle"),[o,a]=R.useState(!1),[c,h]=R.useState(null);R.useEffect(()=>{let p=!1;return Hx().then(y=>{p||s(y)}),()=>{p=!0}},[]);const m=async()=>{h(null),a(!0);try{i==="subscribed"?(await Wx(e),s("idle")):(await $x(e),s("subscribed"))}catch(p){const y=String(p.message||p);y==="push-denied"?(s("denied"),h(v("push-denied"))):y==="push-unsupported"?(s("unsupported"),h(v("push-unsupported"))):h(y)}a(!1)};return i==="unsupported"?u.jsx("div",{className:"nc-set-info",children:v("push-unsupported")}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"nc-set-row",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||o||i==="denied",title:t?v("settings-readonly"):"",onClick:m,children:v(i==="subscribed"?"push-disable":"push-enable")}),u.jsx("span",{className:"nc-set-info",children:v(i==="subscribed"?"push-on":i==="denied"?"push-denied":"push-off")})]}),c&&u.jsx("div",{className:"nc-err",children:c})]})}function vE({token:e,settings:t,readonly:i,refresh:s}){const[o,a]=R.useState(null),[c,h]=R.useState(null),[m,p]=R.useState(!1),[y,S]=R.useState(!1),[_,C]=R.useState(null),[w,x]=R.useState(!0);R.useEffect(()=>{C(t&&t.update||null),x(!t||t.autoUpdate!==!1)},[t]);const k=async()=>{a(null),h(null),S(!0);try{const O=await e0(e);h(O.note||"ok"),p(!1)}catch(O){a(String(O.message||O))}S(!1)},b=async()=>{a(null),h(null),S(!0);try{const O=await s0(e);h(`${O.note||"ok"}${O.target?` (${O.target})`:""}`)}catch(O){a(String(O.message||O))}S(!1)},D=async O=>{a(null),h(null),S(!0);try{await Hv(e,{autoUpdate:O}),x(O),s&&await s()}catch(ee){a(String(ee.message||ee))}S(!1)},L=async()=>{a(null),h(null),S(!0);try{C(await o0(e))}catch(O){a(String(O.message||O))}S(!1)},M=async()=>{a(null),h(null),S(!0);try{const O=await a0(e);C(O),h(v("npm-update-restarting"))}catch(O){a(String(O.message||O))}S(!1)},te=()=>{window.confirm(v("composer-clear-confirm"))&&(a(null),IC()?(window.dispatchEvent(new Event(Wd)),h(v("composer-clear-done"))):a(v("composer-clear-failed")))},U=t&&t.service;return u.jsxs("div",{className:"nc-set-tab",children:[t&&u.jsxs("div",{className:"nc-set-info",children:["v",t.version," · ",t.platform," · :",t.port,u.jsx("br",{}),U&&U.installed?v("service-installed"):v("service-missing"),U&&U.installed?` · ${U.active?v("service-active"):v("service-inactive")}`:"",U?` · boot ${U.boot?"on":"off"}`:""]}),u.jsxs("div",{className:"nc-set-row",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||y,title:i?v("settings-readonly"):"",onClick:()=>{a(null),h(null),p(!0)},children:v("token-rotate")}),u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||y,title:i?v("settings-readonly"):"",onClick:b,children:v("service-regenerate")})]}),u.jsxs("div",{className:"nc-set-form nc-update-settings",children:[u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:w,disabled:i||y||_&&!_.supported,onChange:O=>D(O.target.checked)}),u.jsxs("span",{children:[u.jsx("b",{children:v("npm-auto-update")}),u.jsx("small",{children:v("npm-auto-update-help")})]})]}),_&&u.jsxs("div",{className:"nc-set-info",children:[v("npm-update-current")," v",_.current,_.latest?` · ${v("npm-update-latest")} v${_.latest}`:""," · ",v(`npm-update-${_.supported?_.phase:"unsupported"}`)]}),u.jsxs("div",{className:"nc-set-row",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||y||!_||!_.supported,onClick:L,children:v("npm-update-check")}),_&&_.available&&u.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||y||_.phase==="installing",onClick:M,children:v("npm-update-install")})]}),_&&_.lastError&&u.jsx("div",{className:"nc-err",children:_.lastError})]}),u.jsx(gE,{token:e,readonly:i}),u.jsxs("div",{className:"nc-set-form",children:[u.jsx("div",{className:"nc-sheet-label",children:v("composer-clear-data")}),u.jsx("small",{className:"nc-set-hint",children:v("composer-clear-data-help")}),u.jsx("div",{className:"nc-set-row",children:u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:te,children:v("composer-clear-data")})})]}),m&&u.jsxs("div",{className:"nc-set-confirm",children:[u.jsx("div",{children:v("token-rotate-explain")}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:y,onClick:()=>p(!1),children:v("cancel")}),u.jsx("button",{type:"button",className:"nc-btn primary",disabled:y,onClick:k,children:v("confirm")})]})]}),c&&u.jsx("div",{className:"nc-set-note",children:c}),o&&u.jsx("div",{className:"nc-err",children:o})]})}function _E({token:e,onClose:t,initialTab:i="nodes",initialLocation:s="",startNewCell:o=!1}){Pi();const[a,c]=R.useState(i),[h,m]=R.useState(null),[p,y]=R.useState([]),[S,_]=R.useState(!1),[C,w]=R.useState(null),x=oh(e),k=R.useCallback(async()=>{try{const b=await zv(e);m(b),w(null)}catch(b){w(String(b.message||b))}try{const b=await Jw(e);y(b.peers||[])}catch(b){w(String(b.message||b))}},[e]);return R.useEffect(()=>{k();const b=setInterval(k,5e3);return()=>clearInterval(b)},[k]),R.useEffect(()=>{let b=!1;return qt("/api/config",e).then(D=>D.json()).then(D=>{b||_(!!D.readonlyDefault)}).catch(()=>{}),()=>{b=!0}},[e]),u.jsx("div",{className:"nc-set-overlay",onClick:t,children:u.jsxs("div",{className:"nc-set-panel",onClick:b=>b.stopPropagation(),children:[u.jsxs("div",{className:"nc-set-head",children:[u.jsx(et,{name:"gear",size:18}),u.jsx("b",{children:v("settings")}),u.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:v("close"),children:u.jsx(et,{name:"x",size:18})})]}),S&&u.jsx("div",{className:"nc-set-readonly",children:v("settings-readonly")}),C&&u.jsx("div",{className:"nc-err",children:C}),u.jsx("div",{className:"nc-set-tabs",children:["nodes","fleet","system"].map(b=>u.jsx("button",{type:"button",className:`nc-set-tabbtn${a===b?" on":""}`,onClick:()=>c(b),children:v(`tab-${b}`)},b))}),u.jsxs("div",{className:"nc-set-body",children:[a==="nodes"&&u.jsx(mE,{token:e,nodes:p,settings:h,readonly:S,refresh:k}),a==="fleet"&&u.jsx(hE,{token:e,readonly:S,startNewCell:o,initialLocation:s,targets:x.map(b=>({route:b.route,label:b.label||b.name,status:b.status}))}),a==="system"&&u.jsx(vE,{token:e,settings:h,readonly:S,refresh:k})]})]})})}function yE({token:e,initialPair:t,deviceDefault:i="",localNodeId:s="",localNameDefault:o="",onPairDone:a,onDone:c}){Pi();const[h,m]=R.useState(t?"pair":"welcome"),[p,y]=R.useState(!1),[S,_]=R.useState(null),C=async()=>{y(!0),_(null);try{await Hv(e,{wizardDone:!0}),a&&a(),c()}catch(w){_(String(w.message||w)),y(!1)}};return u.jsx("div",{className:"nc-wiz-overlay",children:u.jsxs("div",{className:"nc-wiz",children:[u.jsxs("div",{className:"nc-wiz-head",children:[u.jsx("b",{children:v("wizard-title")}),u.jsx("small",{children:v("hydra-simple")})]}),h==="welcome"&&u.jsxs("div",{className:"nc-wiz-body",children:[u.jsx("div",{className:"nc-wiz-done",children:v("local-ready")}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{className:"nc-btn ghost",disabled:p,onClick:C,children:v("local-only")}),u.jsx("button",{className:"nc-btn primary",disabled:p,onClick:()=>m("pair"),children:v("add-node")})]})]}),h==="pair"&&u.jsxs("div",{className:"nc-wiz-body",children:[u.jsx(Sy,{token:e,initial:t||"",autoStart:!!t,deviceDefault:i,localNodeId:s,localNameDefault:o,onBusyChange:y,onSuccess:async()=>{a&&a(),m("done")}}),u.jsx("div",{className:"nc-sheet-actions",children:u.jsx("button",{className:"nc-btn ghost",disabled:p,onClick:()=>{a&&a(),m("welcome")},children:v("back")})})]}),h==="done"&&u.jsxs("div",{className:"nc-wiz-body",children:[u.jsx("div",{className:"nc-wiz-done",children:v("node-connected")}),u.jsx("div",{className:"nc-sheet-actions",children:u.jsx("button",{className:"nc-btn primary",disabled:p,onClick:C,children:v("finish")})})]}),S&&u.jsx("div",{className:"nc-err",children:S})]})})}function SE(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 wE=6e3,bE=12e3;function kE({n:e,onClose:t}){return u.jsxs("div",{className:`nc-ntf-toast${e.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[u.jsxs("div",{className:"nc-ntf-toast-txt",children:[u.jsx("b",{children:e.title}),e.body&&u.jsx("small",{children:e.body}),e.session&&u.jsx("span",{className:"nc-ntf-from",children:e.session})]}),u.jsx("button",{type:"button",className:"nc-ntf-x",onClick:t,title:v("close"),children:u.jsx(et,{name:"x",size:14})})]})}function CE({ask:e,token:t,onAnswered:i}){const[s,o]=R.useState(""),[a,c]=R.useState(!1),[h,m]=R.useState(null),p=async y=>{const S=String(y||"").trim();if(!(!S||a)){m(null),c(!0);try{await c0(t,e.id,S),i(e.id)}catch(_){m(String(_.message||_))}c(!1)}};return u.jsxs("div",{className:"nc-ask-card",children:[u.jsxs("div",{className:"nc-ask-head",children:[u.jsx("span",{className:"nc-ntf-from",children:e.session}),u.jsxs("code",{className:"nc-ask-id",children:["#",e.id]})]}),u.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&u.jsx("div",{className:"nc-ask-opts",children:e.options.map(y=>u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:a,onClick:()=>p(y),children:y},y))}),u.jsxs("div",{className:"nc-ask-reply",children:[u.jsx("textarea",{rows:2,placeholder:v("ask-reply-ph"),value:s,disabled:a,onChange:y=>o(y.target.value)}),u.jsx("button",{type:"button",className:"nc-btn primary",disabled:a||!s.trim(),onClick:()=>p(s),children:v("send")})]}),h&&u.jsx("div",{className:"nc-err",children:h})]})}function xE({token:e}){Pi();const[t,i]=R.useState([]),[s,o]=R.useState([]),[a,c]=R.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),h=R.useRef(0),m=R.useCallback(S=>{i(_=>_.filter(C=>C.key!==S))},[]),p=R.useCallback(S=>{const _=`t${h.current+=1}`;i(C=>[...C.slice(-3),{...S,key:_}]),setTimeout(()=>m(_),S.urgency==="high"?bE:wE)},[m]);R.useEffect(()=>{if(!e)return;let S=!1;l0(e).then(C=>{S||o(C.asks||[])}).catch(()=>{});const _=SE(e,C=>{C.type==="notify"?p(C):C.type==="ask"&&C.ask&&C.ask.id?o(w=>w.some(x=>x.id===C.ask.id)?w:[...w,C.ask]):C.type==="ask-answered"&&C.id&&o(w=>w.filter(x=>x.id!==C.id))});return()=>{S=!0,_()}},[e,p]);const y=S=>o(_=>_.filter(C=>C.id!==S));return u.jsxs(u.Fragment,{children:[t.length>0&&u.jsx("div",{className:"nc-ntf-toasts",children:t.map(S=>u.jsx(kE,{n:S,onClose:()=>m(S.key)},S.key))}),s.length>0&&!a&&u.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>c(!0),title:v("asks-title"),children:["? ",u.jsx("span",{className:"nc-ask-count",children:s.length})]}),s.length>0&&a&&u.jsxs("div",{className:"nc-ask-panel",children:[u.jsxs("div",{className:"nc-ask-panel-head",children:[u.jsx("b",{children:v("asks-title")}),u.jsx("span",{className:"nc-ask-count",children:s.length}),u.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>c(!1),title:v("close"),children:u.jsx(et,{name:"x",size:16})})]}),u.jsx("div",{className:"nc-ask-panel-body",children:s.map(S=>u.jsx(CE,{ask:S,token:e,onAnswered:y},S.id))})]})]})}const Ju=e=>ln(br(e)).length===0,Zu=e=>Array.isArray(e)?e.join("/"):"";function EE(e){const t=new Set,i=[];for(const s of Array.isArray(e)?e:[])!s||!$i.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 lo(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function mr(e,t,i,s=!1,o=!0){const a=t.instanceId;return{...e,id:as(s?null:a,e.name),ownerId:a,ownerRoute:s?[]:[...t.route],ownerLabel:s?"Local":t.label,local:s,available:o,ownerTopology:Array.isArray(i)?i:[],layout:Kd(e.layout,a,i)}}function NE(e,t,i,s,o=[]){const[a,c]=R.useState([]),[h,m]=R.useState(!1),[p,y]=R.useState("idle"),[S,_]=R.useState(""),[C,w]=R.useState(""),x=R.useRef([]),k=R.useRef([]),b=R.useRef(""),D=R.useRef(t),L=R.useRef(i),M=R.useRef(!1),te=R.useRef(!0),U=R.useRef(""),O=R.useMemo(()=>EE(o),[o]),ee=O.map(W=>`${W.instanceId}:${Zu(W.route)}:${W.status}:${W.label}`).join("|");k.current=O,L.current=i,D.current=t,x.current=a;const q=R.useCallback(W=>qd(W.layout,b.current,k.current),[]),J=R.useCallback((W,j=!0,A=D.current)=>{const se=Hg(W,qa()),ge=x.current.some(Z=>Z.id===A);x.current=se,c(se);const G=se.find(Z=>Z.id===A);if(j&&G){te.current=!0;const Z=q(G);s(Z),G.local&&rx(G.name,Z)}else ge&&!G&&(te.current=!0,s(os()),_("deck non più condiviso dal nodo owner"));ex(se.filter(Z=>Z.local).map(Z=>Z.name))},[s,q]),Q=R.useCallback(async W=>{let j=await Ba(e);const A=j.decks.find(se=>se.name==="main");if(j.decks.length===1&&A&&A.revision===0&&Ju(A.layout)){const se=ZC(),ge=br(Vd("main")||os());if(!Ju(ge)){const G=Kd(ge,W,[]);j.decks[0]=await Oa(e,"main",G,0,[])}for(const G of se.filter(Z=>Z!=="main"))try{let Z=await _m(e,G,[]);const ue=br(Vd(G)||os());Ju(ue)||(Z=await Oa(e,G,Kd(ue,W,[]),Z.revision,[]))}catch{}j=await Ba(e)}return j},[e]),T=R.useCallback(async({migrate:W=!1}={})=>{const j=await nh(e,[]),A=$i.test(String(j.instanceId||""))?j.instanceId:"";if(!A)throw new Error("instanceId locale non disponibile");b.current=A,w(A);const[se,ge]=await Promise.all([W?Q(A):Ba(e),mm(e,[]).catch(()=>({nodes:[]}))]),G={instanceId:A,route:[],label:"Local"},Z=se.decks.map(de=>mr(de,G,ge.nodes,!0,!0)),ue=x.current;return await Promise.all(k.current.map(async de=>{if(de.status!=="up"){Z.push(...ue.filter(Ce=>!Ce.local&&Ce.ownerId===de.instanceId).map(Ce=>({...Ce,ownerRoute:[...de.route],ownerLabel:de.label,available:!1})));return}try{const[Ce,Re]=await Promise.all([Ba(e,de.route),mm(e,de.route).catch(()=>({nodes:[]}))]);Z.push(...Ce.decks.map(tt=>mr(tt,de,Re.nodes,!1,!0)))}catch{Z.push(...ue.filter(Re=>!Re.local&&Re.ownerId===de.instanceId).map(Re=>({...Re,ownerRoute:[...de.route],ownerLabel:de.label,available:!1})))}})),Z.sort((de,Ce)=>de.local===Ce.local?de.ownerLabel.localeCompare(Ce.ownerLabel)||(de.name==="main"?-1:Ce.name==="main"?1:de.name.localeCompare(Ce.name)):de.local?-1:1),Z},[e,Q,ee]);R.useEffect(()=>{if(!e)return;let W=!1;const j=U.current!==e;return U.current=e,T({migrate:j}).then(A=>{if(W)return;const se=x.current.find(Z=>Z.id===D.current),ge=A.find(Z=>Z.id===D.current),G=ge&&(!se||ge.revision>se.revision||se.available!==ge.available||Zu(se.ownerRoute)!==Zu(ge.ownerRoute));J(A,j||!!G&&!M.current),m(!0),ge&&_("")}).catch(A=>{W||(m(!0),_(String(A.message||A)))}),()=>{W=!0}},[J,T,ee,e]);const N=R.useCallback(async(W=D.current)=>{if(!h||!M.current)return!0;const j=x.current.find(A=>A.id===W);if(!j)return _(`deck inesistente: ${W}`),!1;if(j.available===!1)return _(`nodo owner offline: ${j.ownerLabel}`),!1;y("saving");try{const A=zg(br(L.current),j.ownerId,j.ownerTopology),se=await Oa(e,j.name,A,j.revision,j.ownerRoute),ge=mr(se,lo(j),j.ownerTopology,j.local,!0);return J(x.current.map(G=>G.id===W?ge:G),!1),M.current=!1,y("saved"),_(""),setTimeout(()=>y("idle"),1500),!0}catch(A){if(y("error"),_(String(A.message||A)),A.status===409&&A.data&&A.data.current){const se=x.current.find(G=>G.id===W),ge=mr(A.data.current,lo(se),se.ownerTopology,se.local,!0);J(x.current.map(G=>G.id===W?ge:G),!1)}return!1}},[h,e,J]);return R.useEffect(()=>{if(!h)return;if(te.current){te.current=!1;return}M.current=!0,y("saving");const W=setTimeout(N,650);return()=>clearTimeout(W)},[i,h,N]),R.useEffect(()=>{if(!h)return;const W=setInterval(async()=>{try{const j=await T(),A=x.current.find(G=>G.id===D.current),se=j.find(G=>G.id===D.current),ge=se&&(!A||se.revision>A.revision||A.available!==se.available);J(j,ge&&!M.current)}catch{}},5e3);return()=>clearInterval(W)},[h,T,J]),{decks:a,records:a,localNodeId:C,ready:h,saveState:p,error:S,setError:_,saveNow:N,select:async W=>{if(M.current&&!await N(D.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const j=x.current.find(A=>A.id===W);if(!j)throw new Error(`deck inesistente: ${W}`);return M.current=!1,te.current=!0,q(j)},add:async(W,j=null)=>{const A=j===wn?x.current.find(G=>G.local):j?x.current.find(G=>G.ownerId===j):null;if(!A||A.available===!1)throw new Error("nodo owner non disponibile");const se=await _m(e,W,A.ownerRoute),ge=mr(se,lo(A),A.ownerTopology,A.local,!0);return J([...x.current,ge],!1),ge},rename:async(W,j)=>{const A=x.current.find(ue=>ue.id===W);if(!A)throw new Error("deck inesistente");if(W===D.current&&M.current&&!await N(W))throw new Error(`salvataggio di "${A.name}" fallito: rinomina annullata`);const se=x.current.find(ue=>ue.id===W);if(!se)throw new Error("deck inesistente");const ge=await u0(e,se.name,j,se.revision,se.ownerRoute),G=mr(ge,lo(se),se.ownerTopology,se.local,!0),Z=se.local?wn:se.ownerId;return Nu(ix(qa(),Z,W,G.id)),J(x.current.map(ue=>ue.id===W?G:ue),!1),G},remove:async W=>{const j=x.current.find(se=>se.id===W);if(!j)throw new Error("deck inesistente");W===D.current&&(M.current=!1),await d0(e,j.name,j.revision,j.ownerRoute);const A=j.local?wn:j.ownerId;Nu(nx(qa(),A,W)),J(x.current.filter(se=>se.id!==W),!1)},reorder:(W,j)=>{const A=x.current.find(de=>de.id===W),se=x.current.find(de=>de.id===j);if(!A||!se)return!1;const ge=A.local?wn:A.ownerId,G=se.local?wn:se.ownerId;if(ge!==G)return!1;const Z=x.current.filter(de=>(de.local?wn:de.ownerId)===ge).map(de=>de.id),ue=Nu(tx(qa(),ge,W,j,Z));return J(Hg(x.current,ue),!1),!0},addTileTo:async(W,j)=>{const A=x.current.find(de=>de.id===W);if(!A)throw new Error("deck inesistente");if(A.available===!1)throw new Error(`nodo owner offline: ${A.ownerLabel}`);const se=uy(j,b.current,k.current);if(!se)throw new Error("riferimento sessione non valido");const ge=q(A),G=zg(r_(ge,se),A.ownerId,A.ownerTopology),Z=await Oa(e,A.name,G,A.revision,A.ownerRoute),ue=mr(Z,lo(A),A.ownerTopology,A.local,!0);return J(x.current.map(de=>de.id===W?ue:de),!1),ue},localMainId:as(null,"main"),parseDeckId:wh}}const RE="/sw.js",Yd="nc-sw-update";let Xd=null,Gd=!1,Qd=null,Py=Object.freeze({needed:!1,kind:null,version:""}),Dy=!1;function jy(){typeof window<"u"&&window.dispatchEvent(new Event(Yd))}function My(){const e=Qd||(Gd?{kind:"reload",version:""}:null);Py=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function Ev(){return Py}function PE(e){return typeof window>"u"?()=>{}:(window.addEventListener(Yd,e),()=>window.removeEventListener(Yd,e))}function Eh(e){Gd!==e&&(Gd=e,My(),jy())}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(Qd);Qd=s,My(),o||jy()}function jE(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&Eh(!0)})}function ME(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{Dy&&location.reload()}),navigator.serviceWorker.register(RE).then(e=>{Xd=e,e.waiting&&Eh(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&jE(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function LE(){Dy=!0,Eh(!1);const e=Xd&&Xd.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function TE({hash:e="",origin:t="",pathname:i="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),a=`${i||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:a};const c=new URLSearchParams(o),h=c.get("token")||"",m=c.get("pair")||"",p=m?`${t||""}${i||""}#pair=${m}`:"";return{token:h,pair:p,nextUrl:a}}const Ly=9,Ty=24,Ay="nc_side_w",Nv="nc_side_min",AE=240,Rv="(min-width:1024px) and (pointer:fine)";function IE(){const e=Number(localStorage.getItem(Ay));return e>=180&&e<=480?e:AE}function BE(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=Ly&&e<=Ty?e:13}function OE(){const e={token:"",pair:""};try{const{token:t,pair:i,nextUrl:s}=TE({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 zE(e){try{return br(Vd(e))}catch{return os()}}function Pv(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 FE(){const[e,t]=R.useState(()=>window.matchMedia(Rv).matches);return R.useEffect(()=>{const i=window.matchMedia(Rv),s=o=>t(o.matches);return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[]),e}function Dv({session:e,node:t,ownerId:i,token:s,readonly:o=!1,onBack:a}){Pi();const[c,h]=R.useState(!1),[m,p]=R.useState(()=>window.matchMedia("(pointer: coarse)").matches),[y,S]=R.useState(null),[_,C]=R.useState(BE),[w,x]=R.useState(""),k=J=>C(Q=>{const T=Math.max(Ly,Math.min(Ty,Q+J));return localStorage.setItem("nc_fontsize",String(T)),T}),b=R.useRef(()=>{}),D=R.useRef(()=>!1),L=R.useRef(()=>{}),M=R.useRef(!1),[te,U]=R.useState(!1),[O,ee]=R.useState(!1),q=()=>{M.current=!M.current,U(M.current)};return R.useEffect(()=>{let J=!0;const Q=t?t.split("/"):[],T=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function N(){let I=null,$=null;try{const ae=await(await qt(`${T}/sessions`,s)).json();Array.isArray(ae.sessions)&&(I=ae.sessions.find(W=>W.name===e))}catch{}try{const F=await Er(s,Q);F.available&&Array.isArray(F.cells)&&($=F.cells.find(ae=>ae.tmuxSession===e))}catch{}if(!J)return;let K="";$?K=`${$.engine}${$.key?`·${$.key}`:""}`:I&&(K=I.attached?`attached · ${Pv(I.activity)}`:I.activity?Pv(I.activity):""),x(K)}N();const P=setInterval(N,4e3);return()=>{J=!1,clearInterval(P)}},[e,t,s]),u.jsxs("div",{className:"nc-app",children:[u.jsxs("header",{className:"nc-bar nc-bar-single",children:[u.jsxs("button",{onClick:a,title:v("sessions"),children:[u.jsx(et,{name:"chevronLeft",size:18}),u.jsx("span",{className:"nc-bar-label",children:v("sessions")})]}),u.jsxs("span",{className:"nc-bar-center",children:[u.jsx("b",{children:t?`${t}:${e}`:e}),w&&u.jsx("small",{className:"nc-bar-sub",children:w})]}),u.jsxs("span",{className:"nc-bar-right",children:[u.jsx("button",{onClick:()=>k(-1),title:v("zoom-out"),children:u.jsx(et,{name:"zoomOut",size:18})}),u.jsx("button",{onClick:()=>k(1),title:v("zoom-in"),children:u.jsx(et,{name:"zoomIn",size:18})}),u.jsx("button",{onClick:()=>p(J=>!J),title:v("composer"),children:u.jsx(et,{name:"keyboard",size:20})}),u.jsx("button",{onClick:()=>h(J=>!J),title:v("files"),children:u.jsx(et,{name:"folder",size:20})})]})]}),u.jsx("div",{className:"nc-termwrap",children:u.jsx(J_,{session:e,node:t,token:s,readonly:o,takeSize:!0,sendRef:b,composerRef:D,actionRef:L,ctrlRef:M,setCtrlArmed:U,onFiles:S,fontSize:_,selectionMode:O,onSelectionModeChange:ee})}),u.jsx(xC,{onKeyboard:()=>p(J=>!J),send:J=>b.current(J),action:J=>L.current(J),ctrlArmed:te,onCtrl:q,selectionMode:O,onSelectionMode:ee}),m&&u.jsx(ly,{submitText:J=>D.current(J),token:s,session:e,node:t,ownerId:i}),c&&u.jsx(Z_,{session:e,node:t,token:s,filesEvent:y,onClose:()=>h(!1)})]})}function HE(){Pi();const[e]=R.useState(OE),[t,i]=R.useState(e.token),[s,o]=R.useState(e.pair||""),a=R.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[c,h]=R.useState(!1),m=FE(),[p]=R.useState(()=>JC(typeof location<"u"?location.pathname:"/")),[y,S]=R.useState(p.id),_=y===as(null,Ri),[C,w]=R.useState(null),x=he=>w(er(he)),[k,b]=R.useState([]),[D,L]=R.useState([]),[M,te]=R.useState([]),[U,O]=R.useState(()=>p.ownerId?os():zE(p.name)),[ee,q]=R.useState(null),[J,Q]=R.useState(null),T=he=>Q(er(he)),N=oh(t,m),P=R.useMemo(()=>(N||[]).filter(he=>he.instanceId).map(he=>({instanceId:he.instanceId,route:he.route,label:he.label,status:he.status})),[N]),I=NE(t,y,U,O,P),$=I.decks;R.useEffect(()=>{const he=new Map;for(const De of N||[]){const qe=(De.route||[De.name]).join("/"),bt=new Set((De.sessions||[]).map(si=>si.name));for(const si of De.cells||[])!si.cell||!si.tmuxSession||si.cell===si.tmuxSession||bt.has(si.cell)||he.set(`${qe}:${si.cell}`,`${qe}:${si.tmuxSession}`)}O(De=>z0(De,he))},[N]),R.useEffect(()=>{I.localNodeId&&O(he=>{const De=qd(he,I.localNodeId,P);return JSON.stringify(De)===JSON.stringify(he)?he:De})},[P,I.localNodeId]);const[K,F]=R.useState(null),[ae,W]=R.useState(null),j=R.useRef(0),[A,se]=R.useState(!1),[ge,G]=R.useState(IE),[Z,ue]=R.useState(!_),[de,Ce]=R.useState(()=>_?localStorage.getItem(Nv)==="1":!0),[Re,tt]=R.useState(!1),[Je,Ee]=R.useState("nodes"),[rt,wt]=R.useState(!1),[Dt,st]=R.useState(""),gt=(he="nodes",De=!1,qe="")=>{Ee(he),wt(De),st(qe),tt(!0)},[ct,at]=R.useState(!1),[le,be]=R.useState({deviceDefault:"",localNodeId:"",localNameDefault:""}),[Fe,$e]=R.useState(!1);R.useEffect(()=>{try{localStorage.setItem(Ay,String(ge))}catch{}},[ge]),R.useEffect(()=>{try{localStorage.setItem(Nv,de?"1":"")}catch{}},[de]),R.useEffect(()=>{if(!t)return;let he=!1;return Promise.all([zv(t),qt("/api/config",t).then(De=>De.json())]).then(([De,qe])=>{he||(be({deviceDefault:De.deviceName||"",localNodeId:De.nodeId||"",localNameDefault:De.localName||""}),$e(!!qe.readonlyDefault),(De.firstRun===!0&&!qe.readonlyDefault||s)&&at(!0))}).catch(()=>{}),()=>{he=!0}},[t,s]);const pe=R.useCallback(async()=>{try{const De=await(await qt("/api/sessions",t)).json();De.error||b(De.sessions||[])}catch{}try{const he=await Er(t);L(he.available?he.cells||[]:[]),te(he.available?he.capabilities||[]:[])}catch{L([]),te([])}},[t]);R.useEffect(()=>{if(!m)return;pe();const he=setInterval(pe,4e3);return()=>clearInterval(he)},[m,pe]),R.useEffect(()=>{let he=!1;return qt("/api/config",t).then(De=>De.json()).then(De=>{he||DE(De.version,De.uiVersion,"0.8.26")}).catch(()=>{}),()=>{he=!0}},[t]);const Be=new Set([...k.map(he=>he.name),...N.flatMap(he=>he.sessions.map(De=>De.key))]),Te=ln(U),Y=he=>O(De=>{const qe=uy(he,I.localNodeId,P)||he,bt=r_(De,qe);return bt===De&&ln(De).length>=9&&I.setError(v("grid-full")),bt}),ne=async(he,De=[])=>{try{await ih(t,he,De)}catch{return}const qe=De.length?`${De.join("/")}:${he}`:he;O(bt=>ll(bt,qe)),pe()},z=async(he,De,qe=[])=>{try{await Bv(t,he,De,qe)}catch{return}pe()},H=async(he,De,qe=[])=>{await Av(t,{cell:he,enabled:!!De},qe),pe()},re=async he=>{if(!K)return;const{cell:De}=K,qe=Array.isArray(K.route)?K.route:[];he.action==="up"?await eh(t,{cell:De,boot:!!he.boot,...he.engine?{engine:he.engine}:{},...he.model!==void 0?{model:he.model}:{},...he.permissionPolicy?{permissionPolicy:he.permissionPolicy}:{}},qe):await il(t,{cell:De,boot:!!he.boot},qe);const bt=he.action==="up"?!!he.boot:he.boot?!1:!!K.boot;W({id:++j.current,cell:De,route:qe,enabled:bt}),pe()},me=R.useCallback(he=>{W(De=>(De==null?void 0:De.id)===he?null:De)},[]),Ae=async he=>{if(!(!(he!=null&&he.direct)||A)){se(!0);try{await rh(t,he.name,he.tunnelStatus==="up"?"down":"up")}finally{se(!1)}}},Se=async(he,De)=>{const qe=String(De||"").trim();return!(he!=null&&he.direct)||!vo(qe)?!1:(await $v(t,he.name,qe),!0)},xe=he=>{const De=$.find(qe=>qe.id===he);if(!De)return!1;try{const qe=window.open(Eu(De,t),"_blank");return qe&&(qe.opener=null),!!qe}catch{return!1}},He=async he=>{if(!he||he===y)return;const De=await I.select(he),qe=I.records.find(bt=>bt.id===he);S(he),O(De),q(null),Q(null);try{history.replaceState(null,"",Eu(qe||he,null))}catch{}},Zt=async(he,De)=>{const qe=await I.add(he,De);await He(qe.id)},Xe=async(he,De)=>{const qe=await I.rename(he,De);if(he===y){S(qe.id),O(qd(qe.layout,I.localNodeId,P)),q(null),Q(null);try{history.replaceState(null,"",Eu(qe,null))}catch{}}},Di=async he=>{await I.remove(he),he===y&&await He(I.localMainId)},Et=async(he,De)=>{!De||De===y||(await I.addTileTo(De,he),O(qe=>ll(qe,he)))};if(!t)return u.jsxs("div",{className:"nc-auth",children:[u.jsx("p",{children:v("auth-prompt")}),u.jsx("input",{onChange:he=>i(he.target.value.trim()),placeholder:"token"}),u.jsxs("label",{children:[u.jsx("input",{type:"checkbox",checked:c,onChange:he=>h(he.target.checked)})," ",v("remember-device")]}),u.jsx("button",{onClick:()=>{(c?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const Ve=u.jsxs(u.Fragment,{children:[Re&&u.jsx(_E,{token:t,initialTab:Je,initialLocation:Dt,startNewCell:rt,onClose:()=>{tt(!1),wt(!1),st("")}}),ct&&u.jsx(yE,{token:t,initialPair:s,...le,onPairDone:a,onDone:()=>at(!1)}),u.jsx(xE,{token:t})]});if(!m)return C?u.jsxs(u.Fragment,{children:[u.jsx(Dv,{session:C.session,node:C.node,ownerId:C.ownerId,token:t,readonly:Fe,onBack:()=>w(null)}),Ve]}):u.jsxs(u.Fragment,{children:[u.jsx(eb,{onPick:x,token:t,onSettings:gt}),Ve]});const ji=_||!Z;return u.jsxs("div",{className:"nc-workspace",children:[ji&&u.jsx($C,{sessions:k,cells:D,activeSessions:Te,nodeGroups:N,fleetCapabilities:M,bootSettlement:ae,onBootSettlementApplied:me,localNodeId:I.localNodeId,onPick:T,onAddTile:Y,onPower:F,onBoot:H,onBootError:he=>I.setError(String((he==null?void 0:he.message)||he)),onNodePower:Ae,onNodeRename:Se,onKill:ne,onVisibility:z,onNew:()=>gt("fleet",!0),onSettings:gt,width:ge,collapsed:de,onResize:G,onToggleCollapse:()=>Ce(he=>!he)}),u.jsxs("div",{className:"nc-workspace-main",children:[u.jsx(ox,{decks:$,currentDeck:y,onCreate:Zt,onRename:Xe,onDelete:Di,onReorder:I.reorder,onOpenWindow:xe,onNavigate:He,saveState:I.saveState,error:I.error,sidebarVisible:ji,onToggleSidebar:_?null:()=>ue(he=>!he)}),u.jsx(VC,{layout:U,onLayoutChange:O,token:t,readonly:Fe,sessionsAlive:Be,focusSession:ee,onFocus:q,onOpenSingle:T,decks:$,currentDeck:y,onSendToDeck:Et})]}),J&&u.jsx("div",{className:"nc-single-overlay",children:u.jsx(Dv,{session:J.session,node:J.node,ownerId:J.ownerId,token:t,readonly:Fe,onBack:()=>Q(null)})}),K&&u.jsx(nl,{cell:K,token:t,route:Array.isArray(K.route)?K.route:[],onConfirm:re,onClose:()=>F(null)}),Ve]})}function $E(){Pi();const e=R.useSyncExternalStore(PE,Ev,Ev);if(!e.needed)return null;const t=e.kind==="install"?v("install-version-mismatch").replace("{v}",e.version):v("update-available").replace("{v}",e.version).replace(" "," ").trim();return u.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[u.jsx("span",{className:"nc-update-msg",children:t}),e.kind==="reload"&&u.jsx("button",{className:"nc-update-btn",onClick:LE,children:v("reload")})]})}ME();Fw.createRoot(document.getElementById("root")).render(u.jsxs(Lw.StrictMode,{children:[u.jsx(HE,{}),u.jsx($E,{})]}));
|