@mmmbuto/nexuscrew 0.8.23 → 0.8.24

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.
@@ -0,0 +1,91 @@
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 Wd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Jc={exports:{}},Ws={},Zc={exports:{}},Je={};/**
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 im;function Nw(){if(im)return Je;im=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 _(L){return L===null||typeof L!="object"?null:(L=S&&L[S]||L["@@iterator"],typeof L=="function"?L:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,x={};function k(L,A,ie){this.props=L,this.context=A,this.refs=x,this.updater=ie||C}k.prototype.isReactComponent={},k.prototype.setState=function(L,A){if(typeof L!="object"&&typeof L!="function"&&L!=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,L,A,"setState")},k.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function b(){}b.prototype=k.prototype;function D(L,A,ie){this.props=L,this.context=A,this.refs=x,this.updater=ie||C}var j=D.prototype=new b;j.constructor=D,w(j,k.prototype),j.isPureReactComponent=!0;var M=Array.isArray,ee=Object.prototype.hasOwnProperty,F={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function J(L,A,ie){var me,G={},Z=null,ce=null;if(A!=null)for(me in A.ref!==void 0&&(ce=A.ref),A.key!==void 0&&(Z=""+A.key),A)ee.call(A,me)&&!B.hasOwnProperty(me)&&(G[me]=A[me]);var de=arguments.length-2;if(de===1)G.children=ie;else if(1<de){for(var Ce=Array(de),Ee=0;Ee<de;Ee++)Ce[Ee]=arguments[Ee+2];G.children=Ce}if(L&&L.defaultProps)for(me in de=L.defaultProps,de)G[me]===void 0&&(G[me]=de[me]);return{$$typeof:e,type:L,key:Z,ref:ce,props:G,_owner:F.current}}function K(L,A){return{$$typeof:e,type:L.type,key:A,ref:L.ref,props:L.props,_owner:L._owner}}function Q(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function X(L){var A={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(ie){return A[ie]})}var T=/\/+/g;function N(L,A){return typeof L=="object"&&L!==null&&L.key!=null?X(""+L.key):A.toString(36)}function P(L,A,ie,me,G){var Z=typeof L;(Z==="undefined"||Z==="boolean")&&(L=null);var ce=!1;if(L===null)ce=!0;else switch(Z){case"string":case"number":ce=!0;break;case"object":switch(L.$$typeof){case e:case t:ce=!0}}if(ce)return ce=L,G=G(ce),L=me===""?"."+N(ce,0):me,M(G)?(ie="",L!=null&&(ie=L.replace(T,"$&/")+"/"),P(G,A,ie,"",function(Ee){return Ee})):G!=null&&(Q(G)&&(G=K(G,ie+(!G.key||ce&&ce.key===G.key?"":(""+G.key).replace(T,"$&/")+"/")+L)),A.push(G)),1;if(ce=0,me=me===""?".":me+":",M(L))for(var de=0;de<L.length;de++){Z=L[de];var Ce=me+N(Z,de);ce+=P(Z,A,ie,Ce,G)}else if(Ce=_(L),typeof Ce=="function")for(L=Ce.call(L),de=0;!(Z=L.next()).done;)Z=Z.value,Ce=me+N(Z,de++),ce+=P(Z,A,ie,Ce,G);else if(Z==="object")throw A=String(L),Error("Objects are not valid as a React child (found: "+(A==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":A)+"). If you meant to render a collection of children, use an array instead.");return ce}function O(L,A,ie){if(L==null)return L;var me=[],G=0;return P(L,me,"","",function(Z){return A.call(ie,Z,G++)}),me}function $(L){if(L._status===-1){var A=L._result;A=A(),A.then(function(ie){(L._status===0||L._status===-1)&&(L._status=1,L._result=ie)},function(ie){(L._status===0||L._status===-1)&&(L._status=2,L._result=ie)}),L._status===-1&&(L._status=0,L._result=A)}if(L._status===1)return L._result.default;throw L._result}var W={current:null},z={transition:null},ne={ReactCurrentDispatcher:W,ReactCurrentBatchConfig:z,ReactCurrentOwner:F};function H(){throw Error("act(...) is not supported in production builds of React.")}return Je.Children={map:O,forEach:function(L,A,ie){O(L,function(){A.apply(this,arguments)},ie)},count:function(L){var A=0;return O(L,function(){A++}),A},toArray:function(L){return O(L,function(A){return A})||[]},only:function(L){if(!Q(L))throw Error("React.Children.only expected to receive a single React element child.");return L}},Je.Component=k,Je.Fragment=i,Je.Profiler=o,Je.PureComponent=D,Je.StrictMode=s,Je.Suspense=m,Je.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ne,Je.act=H,Je.cloneElement=function(L,A,ie){if(L==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+L+".");var me=w({},L.props),G=L.key,Z=L.ref,ce=L._owner;if(A!=null){if(A.ref!==void 0&&(Z=A.ref,ce=F.current),A.key!==void 0&&(G=""+A.key),L.type&&L.type.defaultProps)var de=L.type.defaultProps;for(Ce in A)ee.call(A,Ce)&&!B.hasOwnProperty(Ce)&&(me[Ce]=A[Ce]===void 0&&de!==void 0?de[Ce]:A[Ce])}var Ce=arguments.length-2;if(Ce===1)me.children=ie;else if(1<Ce){de=Array(Ce);for(var Ee=0;Ee<Ce;Ee++)de[Ee]=arguments[Ee+2];me.children=de}return{$$typeof:e,type:L.type,key:G,ref:Z,props:me,_owner:ce}},Je.createContext=function(L){return L={$$typeof:c,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},L.Provider={$$typeof:a,_context:L},L.Consumer=L},Je.createElement=J,Je.createFactory=function(L){var A=J.bind(null,L);return A.type=L,A},Je.createRef=function(){return{current:null}},Je.forwardRef=function(L){return{$$typeof:h,render:L}},Je.isValidElement=Q,Je.lazy=function(L){return{$$typeof:y,_payload:{_status:-1,_result:L},_init:$}},Je.memo=function(L,A){return{$$typeof:p,type:L,compare:A===void 0?null:A}},Je.startTransition=function(L){var A=z.transition;z.transition={};try{L()}finally{z.transition=A}},Je.unstable_act=H,Je.useCallback=function(L,A){return W.current.useCallback(L,A)},Je.useContext=function(L){return W.current.useContext(L)},Je.useDebugValue=function(){},Je.useDeferredValue=function(L){return W.current.useDeferredValue(L)},Je.useEffect=function(L,A){return W.current.useEffect(L,A)},Je.useId=function(){return W.current.useId()},Je.useImperativeHandle=function(L,A,ie){return W.current.useImperativeHandle(L,A,ie)},Je.useInsertionEffect=function(L,A){return W.current.useInsertionEffect(L,A)},Je.useLayoutEffect=function(L,A){return W.current.useLayoutEffect(L,A)},Je.useMemo=function(L,A){return W.current.useMemo(L,A)},Je.useReducer=function(L,A,ie){return W.current.useReducer(L,A,ie)},Je.useRef=function(L){return W.current.useRef(L)},Je.useState=function(L){return W.current.useState(L)},Je.useSyncExternalStore=function(L,A,ie){return W.current.useSyncExternalStore(L,A,ie)},Je.useTransition=function(){return W.current.useTransition()},Je.version="18.3.1",Je}var nm;function Ud(){return nm||(nm=1,Zc.exports=Nw()),Zc.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 rm;function Rw(){if(rm)return Ws;rm=1;var e=Ud(),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 Ws.Fragment=i,Ws.jsx=c,Ws.jsxs=c,Ws}var sm;function Pw(){return sm||(sm=1,Jc.exports=Rw()),Jc.exports}var u=Pw(),R=Ud();const Dw=Wd(R);var Ea={},eu={exports:{}},di={},tu={exports:{}},iu={};/**
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 om;function Lw(){return om||(om=1,(function(e){function t(z,ne){var H=z.length;z.push(ne);e:for(;0<H;){var L=H-1>>>1,A=z[L];if(0<o(A,ne))z[L]=ne,z[H]=A,H=L;else break e}}function i(z){return z.length===0?null:z[0]}function s(z){if(z.length===0)return null;var ne=z[0],H=z.pop();if(H!==ne){z[0]=H;e:for(var L=0,A=z.length,ie=A>>>1;L<ie;){var me=2*(L+1)-1,G=z[me],Z=me+1,ce=z[Z];if(0>o(G,H))Z<A&&0>o(ce,G)?(z[L]=ce,z[Z]=H,L=Z):(z[L]=G,z[me]=H,L=me);else if(Z<A&&0>o(ce,H))z[L]=ce,z[Z]=H,L=Z;else break e}}return ne}function o(z,ne){var H=z.sortIndex-ne.sortIndex;return H!==0?H:z.id-ne.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 j(z){for(var ne=i(p);ne!==null;){if(ne.callback===null)s(p);else if(ne.startTime<=z)s(p),ne.sortIndex=ne.expirationTime,t(m,ne);else break;ne=i(p)}}function M(z){if(x=!1,j(z),!w)if(i(m)!==null)w=!0,$(ee);else{var ne=i(p);ne!==null&&W(M,ne.startTime-z)}}function ee(z,ne){w=!1,x&&(x=!1,b(J),J=-1),C=!0;var H=_;try{for(j(ne),S=i(m);S!==null&&(!(S.expirationTime>ne)||z&&!X());){var L=S.callback;if(typeof L=="function"){S.callback=null,_=S.priorityLevel;var A=L(S.expirationTime<=ne);ne=e.unstable_now(),typeof A=="function"?S.callback=A:S===i(m)&&s(m),j(ne)}else s(m);S=i(m)}if(S!==null)var ie=!0;else{var me=i(p);me!==null&&W(M,me.startTime-ne),ie=!1}return ie}finally{S=null,_=H,C=!1}}var F=!1,B=null,J=-1,K=5,Q=-1;function X(){return!(e.unstable_now()-Q<K)}function T(){if(B!==null){var z=e.unstable_now();Q=z;var ne=!0;try{ne=B(!0,z)}finally{ne?N():(F=!1,B=null)}}else F=!1}var N;if(typeof D=="function")N=function(){D(T)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,O=P.port2;P.port1.onmessage=T,N=function(){O.postMessage(null)}}else N=function(){k(T,0)};function $(z){B=z,F||(F=!0,N())}function W(z,ne){J=k(function(){z(e.unstable_now())},ne)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_continueExecution=function(){w||C||(w=!0,$(ee))},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):K=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return _},e.unstable_getFirstCallbackNode=function(){return i(m)},e.unstable_next=function(z){switch(_){case 1:case 2:case 3:var ne=3;break;default:ne=_}var H=_;_=ne;try{return z()}finally{_=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(z,ne){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var H=_;_=z;try{return ne()}finally{_=H}},e.unstable_scheduleCallback=function(z,ne,H){var L=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?L+H:L):H=L,z){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=H+A,z={id:y++,callback:ne,priorityLevel:z,startTime:H,expirationTime:A,sortIndex:-1},H>L?(z.sortIndex=H,t(p,z),i(m)===null&&z===i(p)&&(x?(b(J),J=-1):x=!0,W(M,H-L))):(z.sortIndex=A,t(m,z),w||C||(w=!0,$(ee))),z},e.unstable_shouldYield=X,e.unstable_wrapCallback=function(z){var ne=_;return function(){var H=_;_=ne;try{return z.apply(this,arguments)}finally{_=H}}}})(iu)),iu}var am;function Mw(){return am||(am=1,tu.exports=Lw()),tu.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 lm;function jw(){if(lm)return di;lm=1;var e=Ud(),t=Mw();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 j(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,ee=Symbol.for("react.element"),F=Symbol.for("react.portal"),B=Symbol.for("react.fragment"),J=Symbol.for("react.strict_mode"),K=Symbol.for("react.profiler"),Q=Symbol.for("react.provider"),X=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),W=Symbol.for("react.offscreen"),z=Symbol.iterator;function ne(n){return n===null||typeof n!="object"?null:(n=z&&n[z]||n["@@iterator"],typeof n=="function"?n:null)}var H=Object.assign,L;function A(n){if(L===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);L=r&&r[1]||""}return`
34
+ `+L+n}var ie=!1;function me(n,r){if(!n||ie)return"";ie=!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(oe){var d=oe}Reflect.construct(n,[],r)}else{try{r.call()}catch(oe){d=oe}n.call(r.prototype)}else{try{throw Error()}catch(oe){d=oe}n()}}catch(oe){if(oe&&d&&typeof oe.stack=="string"){for(var f=oe.stack.split(`
35
+ `),g=d.stack.split(`
36
+ `),E=f.length-1,I=g.length-1;1<=E&&0<=I&&f[E]!==g[I];)I--;for(;1<=E&&0<=I;E--,I--)if(f[E]!==g[I]){if(E!==1||I!==1)do if(E--,I--,0>I||f[E]!==g[I]){var U=`
37
+ `+f[E].replace(" at new "," at ");return n.displayName&&U.includes("<anonymous>")&&(U=U.replace("<anonymous>",n.displayName)),U}while(1<=E&&0<=I);break}}}finally{ie=!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=me(n.type,!1),n;case 11:return n=me(n.type.render,!1),n;case 1:return n=me(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 B:return"Fragment";case F:return"Portal";case K:return"Profiler";case J:return"StrictMode";case N:return"Suspense";case P:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case X:return(n.displayName||"Context")+".Consumer";case Q:return(n._context.displayName||"Context")+".Provider";case T:var r=n.render;return n=n.displayName,n||(n=r.displayName||r.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case O: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 ce(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===J?"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 Ee(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 Ve(n){n._valueTracker||(n._valueTracker=Ee(n))}function qe(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 xe(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 it(n,r){var l=r.checked;return H({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??n._wrapperState.initialChecked})}function St(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 se(n,r){r=r.checked,r!=null&&j(n,"checked",r,!1)}function le(n,r){se(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")?Te(n,r.type,l):r.hasOwnProperty("defaultValue")&&Te(n,r.type,de(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(n.defaultChecked=!!r.defaultChecked)}function Oe(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 Te(n,r,l){(r!=="number"||xe(n.ownerDocument)!==n)&&(l==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+l&&(n.defaultValue=""+l))}var V=Array.isArray;function q(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 pe(n,r){if(r.dangerouslySetInnerHTML!=null)throw Error(i(91));return H({},r,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function ve(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(V(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 be(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 ae(n){var r=n.textContent;r===n._wrapperState.initialValue&&r!==""&&r!==null&&(n.value=r)}function je(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 Ne(n,r){return n==null||n==="http://www.w3.org/1999/xhtml"?je(r):n==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var ze,Be=(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(ze=ze||document.createElement("div"),ze.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=ze.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;r.firstChild;)n.appendChild(r.firstChild)}});function st(n,r){if(r){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=r;return}}n.textContent=r}var he={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},Se=["Webkit","ms","Moz","O"];Object.keys(he).forEach(function(n){Se.forEach(function(r){r=r+n.charAt(0).toUpperCase()+n.substring(1),he[r]=he[n]})});function $e(n,r,l){return r==null||typeof r=="boolean"||r===""?"":l||typeof r!="number"||r===0||he.hasOwnProperty(n)&&he[n]?(""+r).trim():r+"px"}function ot(n,r){n=n.style;for(var l in r)if(r.hasOwnProperty(l)){var d=l.indexOf("--")===0,f=$e(l,r[l],d);l==="float"&&(l="cssFloat"),d?n.setProperty(l,f):n[l]=f}}var Rt=H({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 wt(n,r){if(r){if(Rt[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 ue(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 Ae=null;function Ye(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Yt=null,Xt=null,br=null;function _h(n){if(n=Rs(n)){if(typeof Yt!="function")throw Error(i(280));var r=n.stateNode;r&&(r=Ho(r),Yt(n.stateNode,n.type,r))}}function yh(n){Xt?br?br.push(n):br=[n]:Xt=n}function Sh(){if(Xt){var n=Xt,r=br;if(br=Xt=null,_h(n),r)for(n=0;n<r.length;n++)_h(r[n])}}function wh(n,r){return n(r)}function bh(){}var ml=!1;function kh(n,r,l){if(ml)return n(r,l);ml=!0;try{return wh(n,r,l)}finally{ml=!1,(Xt!==null||br!==null)&&(bh(),Sh())}}function as(n,r){var l=n.stateNode;if(l===null)return null;var d=Ho(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 gl=!1;if(h)try{var ls={};Object.defineProperty(ls,"passive",{get:function(){gl=!0}}),window.addEventListener("test",ls,ls),window.removeEventListener("test",ls,ls)}catch{gl=!1}function jy(n,r,l,d,f,g,E,I,U){var oe=Array.prototype.slice.call(arguments,3);try{r.apply(l,oe)}catch(_e){this.onError(_e)}}var cs=!1,yo=null,So=!1,vl=null,Ty={onError:function(n){cs=!0,yo=n}};function Ay(n,r,l,d,f,g,E,I,U){cs=!1,yo=null,jy.apply(Ty,arguments)}function Iy(n,r,l,d,f,g,E,I,U){if(Ay.apply(this,arguments),cs){if(cs){var oe=yo;cs=!1,yo=null}else throw Error(i(198));So||(So=!0,vl=oe)}}function Vn(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 Ch(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 xh(n){if(Vn(n)!==n)throw Error(i(188))}function By(n){var r=n.alternate;if(!r){if(r=Vn(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 xh(f),n;if(g===d)return xh(f),r;g=g.sibling}throw Error(i(188))}if(l.return!==d.return)l=f,d=g;else{for(var E=!1,I=f.child;I;){if(I===l){E=!0,l=f,d=g;break}if(I===d){E=!0,d=f,l=g;break}I=I.sibling}if(!E){for(I=g.child;I;){if(I===l){E=!0,l=g,d=f;break}if(I===d){E=!0,d=g,l=f;break}I=I.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 Eh(n){return n=By(n),n!==null?Nh(n):null}function Nh(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var r=Nh(n);if(r!==null)return r;n=n.sibling}return null}var Rh=t.unstable_scheduleCallback,Ph=t.unstable_cancelCallback,Oy=t.unstable_shouldYield,zy=t.unstable_requestPaint,bt=t.unstable_now,Fy=t.unstable_getCurrentPriorityLevel,_l=t.unstable_ImmediatePriority,Dh=t.unstable_UserBlockingPriority,wo=t.unstable_NormalPriority,Hy=t.unstable_LowPriority,Lh=t.unstable_IdlePriority,bo=null,Wi=null;function $y(n){if(Wi&&typeof Wi.onCommitFiberRoot=="function")try{Wi.onCommitFiberRoot(bo,n,void 0,(n.current.flags&128)===128)}catch{}}var Ai=Math.clz32?Math.clz32:Ky,Wy=Math.log,Uy=Math.LN2;function Ky(n){return n>>>=0,n===0?32:31-(Wy(n)/Uy|0)|0}var ko=64,Co=4194304;function us(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 xo(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 I=E&~f;I!==0?d=us(I):(g&=E,g!==0&&(d=us(g)))}else E=l&~f,E!==0?d=us(E):g!==0&&(d=us(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-Ai(r),f=1<<l,d|=n[l],r&=~f;return d}function qy(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 Vy(n,r){for(var l=n.suspendedLanes,d=n.pingedLanes,f=n.expirationTimes,g=n.pendingLanes;0<g;){var E=31-Ai(g),I=1<<E,U=f[E];U===-1?((I&l)===0||(I&d)!==0)&&(f[E]=qy(I,r)):U<=r&&(n.expiredLanes|=I),g&=~I}}function yl(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function Mh(){var n=ko;return ko<<=1,(ko&4194240)===0&&(ko=64),n}function Sl(n){for(var r=[],l=0;31>l;l++)r.push(n);return r}function ds(n,r,l){n.pendingLanes|=r,r!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,r=31-Ai(r),n[r]=l}function Yy(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-Ai(l),g=1<<f;r[f]=0,d[f]=-1,n[f]=-1,l&=~g}}function wl(n,r){var l=n.entangledLanes|=r;for(n=n.entanglements;l;){var d=31-Ai(l),f=1<<d;f&r|n[d]&r&&(n[d]|=r),l&=~f}}var nt=0;function jh(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var Th,bl,Ah,Ih,Bh,kl=!1,Eo=[],vn=null,_n=null,yn=null,hs=new Map,fs=new Map,Sn=[],Xy="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 Oh(n,r){switch(n){case"focusin":case"focusout":vn=null;break;case"dragenter":case"dragleave":_n=null;break;case"mouseover":case"mouseout":yn=null;break;case"pointerover":case"pointerout":hs.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":fs.delete(r.pointerId)}}function ps(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=Rs(r),r!==null&&bl(r)),n):(n.eventSystemFlags|=d,r=n.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),n)}function Gy(n,r,l,d,f){switch(r){case"focusin":return vn=ps(vn,n,r,l,d,f),!0;case"dragenter":return _n=ps(_n,n,r,l,d,f),!0;case"mouseover":return yn=ps(yn,n,r,l,d,f),!0;case"pointerover":var g=f.pointerId;return hs.set(g,ps(hs.get(g)||null,n,r,l,d,f)),!0;case"gotpointercapture":return g=f.pointerId,fs.set(g,ps(fs.get(g)||null,n,r,l,d,f)),!0}return!1}function zh(n){var r=Yn(n.target);if(r!==null){var l=Vn(r);if(l!==null){if(r=l.tag,r===13){if(r=Ch(l),r!==null){n.blockedOn=r,Bh(n.priority,function(){Ah(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 No(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var l=xl(n.domEventName,n.eventSystemFlags,r[0],n.nativeEvent);if(l===null){l=n.nativeEvent;var d=new l.constructor(l.type,l);Ae=d,l.target.dispatchEvent(d),Ae=null}else return r=Rs(l),r!==null&&bl(r),n.blockedOn=l,!1;r.shift()}return!0}function Fh(n,r,l){No(n)&&l.delete(r)}function Qy(){kl=!1,vn!==null&&No(vn)&&(vn=null),_n!==null&&No(_n)&&(_n=null),yn!==null&&No(yn)&&(yn=null),hs.forEach(Fh),fs.forEach(Fh)}function ms(n,r){n.blockedOn===r&&(n.blockedOn=null,kl||(kl=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Qy)))}function gs(n){function r(f){return ms(f,n)}if(0<Eo.length){ms(Eo[0],n);for(var l=1;l<Eo.length;l++){var d=Eo[l];d.blockedOn===n&&(d.blockedOn=null)}}for(vn!==null&&ms(vn,n),_n!==null&&ms(_n,n),yn!==null&&ms(yn,n),hs.forEach(r),fs.forEach(r),l=0;l<Sn.length;l++)d=Sn[l],d.blockedOn===n&&(d.blockedOn=null);for(;0<Sn.length&&(l=Sn[0],l.blockedOn===null);)zh(l),l.blockedOn===null&&Sn.shift()}var kr=M.ReactCurrentBatchConfig,Ro=!0;function Jy(n,r,l,d){var f=nt,g=kr.transition;kr.transition=null;try{nt=1,Cl(n,r,l,d)}finally{nt=f,kr.transition=g}}function Zy(n,r,l,d){var f=nt,g=kr.transition;kr.transition=null;try{nt=4,Cl(n,r,l,d)}finally{nt=f,kr.transition=g}}function Cl(n,r,l,d){if(Ro){var f=xl(n,r,l,d);if(f===null)$l(n,r,d,Po,l),Oh(n,d);else if(Gy(f,n,r,l,d))d.stopPropagation();else if(Oh(n,d),r&4&&-1<Xy.indexOf(n)){for(;f!==null;){var g=Rs(f);if(g!==null&&Th(g),g=xl(n,r,l,d),g===null&&$l(n,r,d,Po,l),g===f)break;f=g}f!==null&&d.stopPropagation()}else $l(n,r,d,null,l)}}var Po=null;function xl(n,r,l,d){if(Po=null,n=Ye(d),n=Yn(n),n!==null)if(r=Vn(n),r===null)n=null;else if(l=r.tag,l===13){if(n=Ch(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 Po=n,null}function Hh(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(Fy()){case _l:return 1;case Dh:return 4;case wo:case Hy:return 16;case Lh:return 536870912;default:return 16}default:return 16}}var wn=null,El=null,Do=null;function $h(){if(Do)return Do;var n,r=El,l=r.length,d,f="value"in wn?wn.value:wn.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 Do=f.slice(n,1<d?1-d:void 0)}function Lo(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 Mo(){return!0}function Wh(){return!1}function mi(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 I in n)n.hasOwnProperty(I)&&(l=n[I],this[I]=l?l(g):g[I]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Mo:Wh,this.isPropagationStopped=Wh,this}return H(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=Mo)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Mo)},persist:function(){},isPersistent:Mo}),r}var Cr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Nl=mi(Cr),vs=H({},Cr,{view:0,detail:0}),eS=mi(vs),Rl,Pl,_s,jo=H({},vs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ll,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!==_s&&(_s&&n.type==="mousemove"?(Rl=n.screenX-_s.screenX,Pl=n.screenY-_s.screenY):Pl=Rl=0,_s=n),Rl)},movementY:function(n){return"movementY"in n?n.movementY:Pl}}),Uh=mi(jo),tS=H({},jo,{dataTransfer:0}),iS=mi(tS),nS=H({},vs,{relatedTarget:0}),Dl=mi(nS),rS=H({},Cr,{animationName:0,elapsedTime:0,pseudoElement:0}),sS=mi(rS),oS=H({},Cr,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),aS=mi(oS),lS=H({},Cr,{data:0}),Kh=mi(lS),cS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},uS={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"},dS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function hS(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=dS[n])?!!r[n]:!1}function Ll(){return hS}var fS=H({},vs,{key:function(n){if(n.key){var r=cS[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=Lo(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?uS[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ll,charCode:function(n){return n.type==="keypress"?Lo(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Lo(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),pS=mi(fS),mS=H({},jo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),qh=mi(mS),gS=H({},vs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ll}),vS=mi(gS),_S=H({},Cr,{propertyName:0,elapsedTime:0,pseudoElement:0}),yS=mi(_S),SS=H({},jo,{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}),wS=mi(SS),bS=[9,13,27,32],Ml=h&&"CompositionEvent"in window,ys=null;h&&"documentMode"in document&&(ys=document.documentMode);var kS=h&&"TextEvent"in window&&!ys,Vh=h&&(!Ml||ys&&8<ys&&11>=ys),Yh=" ",Xh=!1;function Gh(n,r){switch(n){case"keyup":return bS.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Qh(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var xr=!1;function CS(n,r){switch(n){case"compositionend":return Qh(r);case"keypress":return r.which!==32?null:(Xh=!0,Yh);case"textInput":return n=r.data,n===Yh&&Xh?null:n;default:return null}}function xS(n,r){if(xr)return n==="compositionend"||!Ml&&Gh(n,r)?(n=$h(),Do=El=wn=null,xr=!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 Vh&&r.locale!=="ko"?null:r.data;default:return null}}var ES={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 Jh(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!ES[n.type]:r==="textarea"}function Zh(n,r,l,d){yh(d),r=Oo(r,"onChange"),0<r.length&&(l=new Nl("onChange","change",null,l,d),n.push({event:l,listeners:r}))}var Ss=null,ws=null;function NS(n){_f(n,0)}function To(n){var r=Dr(n);if(qe(r))return n}function RS(n,r){if(n==="change")return r}var ef=!1;if(h){var jl;if(h){var Tl="oninput"in document;if(!Tl){var tf=document.createElement("div");tf.setAttribute("oninput","return;"),Tl=typeof tf.oninput=="function"}jl=Tl}else jl=!1;ef=jl&&(!document.documentMode||9<document.documentMode)}function nf(){Ss&&(Ss.detachEvent("onpropertychange",rf),ws=Ss=null)}function rf(n){if(n.propertyName==="value"&&To(ws)){var r=[];Zh(r,ws,n,Ye(n)),kh(NS,r)}}function PS(n,r,l){n==="focusin"?(nf(),Ss=r,ws=l,Ss.attachEvent("onpropertychange",rf)):n==="focusout"&&nf()}function DS(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return To(ws)}function LS(n,r){if(n==="click")return To(r)}function MS(n,r){if(n==="input"||n==="change")return To(r)}function jS(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var Ii=typeof Object.is=="function"?Object.is:jS;function bs(n,r){if(Ii(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)||!Ii(n[f],r[f]))return!1}return!0}function sf(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function of(n,r){var l=sf(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=sf(l)}}function af(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?af(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function lf(){for(var n=window,r=xe();r instanceof n.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)n=r.contentWindow;else break;r=xe(n.document)}return r}function Al(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 TS(n){var r=lf(),l=n.focusedElem,d=n.selectionRange;if(r!==l&&l&&l.ownerDocument&&af(l.ownerDocument.documentElement,l)){if(d!==null&&Al(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=of(l,g);var E=of(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 AS=h&&"documentMode"in document&&11>=document.documentMode,Er=null,Il=null,ks=null,Bl=!1;function cf(n,r,l){var d=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Bl||Er==null||Er!==xe(d)||(d=Er,"selectionStart"in d&&Al(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}),ks&&bs(ks,d)||(ks=d,d=Oo(Il,"onSelect"),0<d.length&&(r=new Nl("onSelect","select",null,r,l),n.push({event:r,listeners:d}),r.target=Er)))}function Ao(n,r){var l={};return l[n.toLowerCase()]=r.toLowerCase(),l["Webkit"+n]="webkit"+r,l["Moz"+n]="moz"+r,l}var Nr={animationend:Ao("Animation","AnimationEnd"),animationiteration:Ao("Animation","AnimationIteration"),animationstart:Ao("Animation","AnimationStart"),transitionend:Ao("Transition","TransitionEnd")},Ol={},uf={};h&&(uf=document.createElement("div").style,"AnimationEvent"in window||(delete Nr.animationend.animation,delete Nr.animationiteration.animation,delete Nr.animationstart.animation),"TransitionEvent"in window||delete Nr.transitionend.transition);function Io(n){if(Ol[n])return Ol[n];if(!Nr[n])return n;var r=Nr[n],l;for(l in r)if(r.hasOwnProperty(l)&&l in uf)return Ol[n]=r[l];return n}var df=Io("animationend"),hf=Io("animationiteration"),ff=Io("animationstart"),pf=Io("transitionend"),mf=new Map,gf="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 bn(n,r){mf.set(n,r),a(r,[n])}for(var zl=0;zl<gf.length;zl++){var Fl=gf[zl],IS=Fl.toLowerCase(),BS=Fl[0].toUpperCase()+Fl.slice(1);bn(IS,"on"+BS)}bn(df,"onAnimationEnd"),bn(hf,"onAnimationIteration"),bn(ff,"onAnimationStart"),bn("dblclick","onDoubleClick"),bn("focusin","onFocus"),bn("focusout","onBlur"),bn(pf,"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 Cs="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(" "),OS=new Set("cancel close invalid load scroll toggle".split(" ").concat(Cs));function vf(n,r,l){var d=n.type||"unknown-event";n.currentTarget=l,Iy(d,r,void 0,n),n.currentTarget=null}function _f(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 I=d[E],U=I.instance,oe=I.currentTarget;if(I=I.listener,U!==g&&f.isPropagationStopped())break e;vf(f,I,oe),g=U}else for(E=0;E<d.length;E++){if(I=d[E],U=I.instance,oe=I.currentTarget,I=I.listener,U!==g&&f.isPropagationStopped())break e;vf(f,I,oe),g=U}}}if(So)throw n=vl,So=!1,vl=null,n}function lt(n,r){var l=r[Yl];l===void 0&&(l=r[Yl]=new Set);var d=n+"__bubble";l.has(d)||(yf(r,n,2,!1),l.add(d))}function Hl(n,r,l){var d=0;r&&(d|=4),yf(l,n,d,r)}var Bo="_reactListening"+Math.random().toString(36).slice(2);function xs(n){if(!n[Bo]){n[Bo]=!0,s.forEach(function(l){l!=="selectionchange"&&(OS.has(l)||Hl(l,!1,n),Hl(l,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Bo]||(r[Bo]=!0,Hl("selectionchange",!1,r))}}function yf(n,r,l,d){switch(Hh(r)){case 1:var f=Jy;break;case 4:f=Zy;break;default:f=Cl}l=f.bind(null,r,l,n),f=void 0,!gl||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 $l(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 I=d.stateNode.containerInfo;if(I===f||I.nodeType===8&&I.parentNode===f)break;if(E===4)for(E=d.return;E!==null;){var U=E.tag;if((U===3||U===4)&&(U=E.stateNode.containerInfo,U===f||U.nodeType===8&&U.parentNode===f))return;E=E.return}for(;I!==null;){if(E=Yn(I),E===null)return;if(U=E.tag,U===5||U===6){d=g=E;continue e}I=I.parentNode}}d=d.return}kh(function(){var oe=g,_e=Ye(l),ye=[];e:{var ge=mf.get(n);if(ge!==void 0){var Pe=Nl,Le=n;switch(n){case"keypress":if(Lo(l)===0)break e;case"keydown":case"keyup":Pe=pS;break;case"focusin":Le="focus",Pe=Dl;break;case"focusout":Le="blur",Pe=Dl;break;case"beforeblur":case"afterblur":Pe=Dl;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=Uh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Pe=iS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Pe=vS;break;case df:case hf:case ff:Pe=sS;break;case pf:Pe=yS;break;case"scroll":Pe=eS;break;case"wheel":Pe=wS;break;case"copy":case"cut":case"paste":Pe=aS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Pe=qh}var Me=(r&4)!==0,kt=!Me&&n==="scroll",te=Me?ge!==null?ge+"Capture":null:ge;Me=[];for(var Y=oe,re;Y!==null;){re=Y;var we=re.stateNode;if(re.tag===5&&we!==null&&(re=we,te!==null&&(we=as(Y,te),we!=null&&Me.push(Es(Y,we,re)))),kt)break;Y=Y.return}0<Me.length&&(ge=new Pe(ge,Le,null,l,_e),ye.push({event:ge,listeners:Me}))}}if((r&7)===0){e:{if(ge=n==="mouseover"||n==="pointerover",Pe=n==="mouseout"||n==="pointerout",ge&&l!==Ae&&(Le=l.relatedTarget||l.fromElement)&&(Yn(Le)||Le[rn]))break e;if((Pe||ge)&&(ge=_e.window===_e?_e:(ge=_e.ownerDocument)?ge.defaultView||ge.parentWindow:window,Pe?(Le=l.relatedTarget||l.toElement,Pe=oe,Le=Le?Yn(Le):null,Le!==null&&(kt=Vn(Le),Le!==kt||Le.tag!==5&&Le.tag!==6)&&(Le=null)):(Pe=null,Le=oe),Pe!==Le)){if(Me=Uh,we="onMouseLeave",te="onMouseEnter",Y="mouse",(n==="pointerout"||n==="pointerover")&&(Me=qh,we="onPointerLeave",te="onPointerEnter",Y="pointer"),kt=Pe==null?ge:Dr(Pe),re=Le==null?ge:Dr(Le),ge=new Me(we,Y+"leave",Pe,l,_e),ge.target=kt,ge.relatedTarget=re,we=null,Yn(_e)===oe&&(Me=new Me(te,Y+"enter",Le,l,_e),Me.target=re,Me.relatedTarget=kt,we=Me),kt=we,Pe&&Le)t:{for(Me=Pe,te=Le,Y=0,re=Me;re;re=Rr(re))Y++;for(re=0,we=te;we;we=Rr(we))re++;for(;0<Y-re;)Me=Rr(Me),Y--;for(;0<re-Y;)te=Rr(te),re--;for(;Y--;){if(Me===te||te!==null&&Me===te.alternate)break t;Me=Rr(Me),te=Rr(te)}Me=null}else Me=null;Pe!==null&&Sf(ye,ge,Pe,Me,!1),Le!==null&&kt!==null&&Sf(ye,kt,Le,Me,!0)}}e:{if(ge=oe?Dr(oe):window,Pe=ge.nodeName&&ge.nodeName.toLowerCase(),Pe==="select"||Pe==="input"&&ge.type==="file")var Ie=RS;else if(Jh(ge))if(ef)Ie=MS;else{Ie=DS;var Fe=PS}else(Pe=ge.nodeName)&&Pe.toLowerCase()==="input"&&(ge.type==="checkbox"||ge.type==="radio")&&(Ie=LS);if(Ie&&(Ie=Ie(n,oe))){Zh(ye,Ie,l,_e);break e}Fe&&Fe(n,ge,oe),n==="focusout"&&(Fe=ge._wrapperState)&&Fe.controlled&&ge.type==="number"&&Te(ge,"number",ge.value)}switch(Fe=oe?Dr(oe):window,n){case"focusin":(Jh(Fe)||Fe.contentEditable==="true")&&(Er=Fe,Il=oe,ks=null);break;case"focusout":ks=Il=Er=null;break;case"mousedown":Bl=!0;break;case"contextmenu":case"mouseup":case"dragend":Bl=!1,cf(ye,l,_e);break;case"selectionchange":if(AS)break;case"keydown":case"keyup":cf(ye,l,_e)}var He;if(Ml)e:{switch(n){case"compositionstart":var We="onCompositionStart";break e;case"compositionend":We="onCompositionEnd";break e;case"compositionupdate":We="onCompositionUpdate";break e}We=void 0}else xr?Gh(n,l)&&(We="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(We="onCompositionStart");We&&(Vh&&l.locale!=="ko"&&(xr||We!=="onCompositionStart"?We==="onCompositionEnd"&&xr&&(He=$h()):(wn=_e,El="value"in wn?wn.value:wn.textContent,xr=!0)),Fe=Oo(oe,We),0<Fe.length&&(We=new Kh(We,n,null,l,_e),ye.push({event:We,listeners:Fe}),He?We.data=He:(He=Qh(l),He!==null&&(We.data=He)))),(He=kS?CS(n,l):xS(n,l))&&(oe=Oo(oe,"onBeforeInput"),0<oe.length&&(_e=new Kh("onBeforeInput","beforeinput",null,l,_e),ye.push({event:_e,listeners:oe}),_e.data=He))}_f(ye,r)})}function Es(n,r,l){return{instance:n,listener:r,currentTarget:l}}function Oo(n,r){for(var l=r+"Capture",d=[];n!==null;){var f=n,g=f.stateNode;f.tag===5&&g!==null&&(f=g,g=as(n,l),g!=null&&d.unshift(Es(n,g,f)),g=as(n,r),g!=null&&d.push(Es(n,g,f))),n=n.return}return d}function Rr(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function Sf(n,r,l,d,f){for(var g=r._reactName,E=[];l!==null&&l!==d;){var I=l,U=I.alternate,oe=I.stateNode;if(U!==null&&U===d)break;I.tag===5&&oe!==null&&(I=oe,f?(U=as(l,g),U!=null&&E.unshift(Es(l,U,I))):f||(U=as(l,g),U!=null&&E.push(Es(l,U,I)))),l=l.return}E.length!==0&&n.push({event:r,listeners:E})}var zS=/\r\n?/g,FS=/\u0000|\uFFFD/g;function wf(n){return(typeof n=="string"?n:""+n).replace(zS,`
38
+ `).replace(FS,"")}function zo(n,r,l){if(r=wf(r),wf(n)!==r&&l)throw Error(i(425))}function Fo(){}var Wl=null,Ul=null;function Kl(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 ql=typeof setTimeout=="function"?setTimeout:void 0,HS=typeof clearTimeout=="function"?clearTimeout:void 0,bf=typeof Promise=="function"?Promise:void 0,$S=typeof queueMicrotask=="function"?queueMicrotask:typeof bf<"u"?function(n){return bf.resolve(null).then(n).catch(WS)}:ql;function WS(n){setTimeout(function(){throw n})}function Vl(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),gs(r);return}d--}else l!=="$"&&l!=="$?"&&l!=="$!"||d++;l=f}while(l);gs(r)}function kn(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 kf(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 Pr=Math.random().toString(36).slice(2),Ui="__reactFiber$"+Pr,Ns="__reactProps$"+Pr,rn="__reactContainer$"+Pr,Yl="__reactEvents$"+Pr,US="__reactListeners$"+Pr,KS="__reactHandles$"+Pr;function Yn(n){var r=n[Ui];if(r)return r;for(var l=n.parentNode;l;){if(r=l[rn]||l[Ui]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(n=kf(n);n!==null;){if(l=n[Ui])return l;n=kf(n)}return r}n=l,l=n.parentNode}return null}function Rs(n){return n=n[Ui]||n[rn],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function Dr(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(i(33))}function Ho(n){return n[Ns]||null}var Xl=[],Lr=-1;function Cn(n){return{current:n}}function ct(n){0>Lr||(n.current=Xl[Lr],Xl[Lr]=null,Lr--)}function at(n,r){Lr++,Xl[Lr]=n.current,n.current=r}var xn={},Gt=Cn(xn),oi=Cn(!1),Xn=xn;function Mr(n,r){var l=n.type.contextTypes;if(!l)return xn;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 ai(n){return n=n.childContextTypes,n!=null}function $o(){ct(oi),ct(Gt)}function Cf(n,r,l){if(Gt.current!==xn)throw Error(i(168));at(Gt,r),at(oi,l)}function xf(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,ce(n)||"Unknown",f));return H({},l,d)}function Wo(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||xn,Xn=Gt.current,at(Gt,n),at(oi,oi.current),!0}function Ef(n,r,l){var d=n.stateNode;if(!d)throw Error(i(169));l?(n=xf(n,r,Xn),d.__reactInternalMemoizedMergedChildContext=n,ct(oi),ct(Gt),at(Gt,n)):ct(oi),at(oi,l)}var sn=null,Uo=!1,Gl=!1;function Nf(n){sn===null?sn=[n]:sn.push(n)}function qS(n){Uo=!0,Nf(n)}function En(){if(!Gl&&sn!==null){Gl=!0;var n=0,r=nt;try{var l=sn;for(nt=1;n<l.length;n++){var d=l[n];do d=d(!0);while(d!==null)}sn=null,Uo=!1}catch(f){throw sn!==null&&(sn=sn.slice(n+1)),Rh(_l,En),f}finally{nt=r,Gl=!1}}return null}var jr=[],Tr=0,Ko=null,qo=0,Ci=[],xi=0,Gn=null,on=1,an="";function Qn(n,r){jr[Tr++]=qo,jr[Tr++]=Ko,Ko=n,qo=r}function Rf(n,r,l){Ci[xi++]=on,Ci[xi++]=an,Ci[xi++]=Gn,Gn=n;var d=on;n=an;var f=32-Ai(d)-1;d&=~(1<<f),l+=1;var g=32-Ai(r)+f;if(30<g){var E=f-f%5;g=(d&(1<<E)-1).toString(32),d>>=E,f-=E,on=1<<32-Ai(r)+f|l<<f|d,an=g+n}else on=1<<g|l<<f|d,an=n}function Ql(n){n.return!==null&&(Qn(n,1),Rf(n,1,0))}function Jl(n){for(;n===Ko;)Ko=jr[--Tr],jr[Tr]=null,qo=jr[--Tr],jr[Tr]=null;for(;n===Gn;)Gn=Ci[--xi],Ci[xi]=null,an=Ci[--xi],Ci[xi]=null,on=Ci[--xi],Ci[xi]=null}var gi=null,vi=null,dt=!1,Bi=null;function Pf(n,r){var l=Pi(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 Df(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,gi=n,vi=kn(r.firstChild),!0):!1;case 6:return r=n.pendingProps===""||r.nodeType!==3?null:r,r!==null?(n.stateNode=r,gi=n,vi=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(l=Gn!==null?{id:on,overflow:an}:null,n.memoizedState={dehydrated:r,treeContext:l,retryLane:1073741824},l=Pi(18,null,null,0),l.stateNode=r,l.return=n,n.child=l,gi=n,vi=null,!0):!1;default:return!1}}function Zl(n){return(n.mode&1)!==0&&(n.flags&128)===0}function ec(n){if(dt){var r=vi;if(r){var l=r;if(!Df(n,r)){if(Zl(n))throw Error(i(418));r=kn(l.nextSibling);var d=gi;r&&Df(n,r)?Pf(d,l):(n.flags=n.flags&-4097|2,dt=!1,gi=n)}}else{if(Zl(n))throw Error(i(418));n.flags=n.flags&-4097|2,dt=!1,gi=n}}}function Lf(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;gi=n}function Vo(n){if(n!==gi)return!1;if(!dt)return Lf(n),dt=!0,!1;var r;if((r=n.tag!==3)&&!(r=n.tag!==5)&&(r=n.type,r=r!=="head"&&r!=="body"&&!Kl(n.type,n.memoizedProps)),r&&(r=vi)){if(Zl(n))throw Mf(),Error(i(418));for(;r;)Pf(n,r),r=kn(r.nextSibling)}if(Lf(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){vi=kn(n.nextSibling);break e}r--}else l!=="$"&&l!=="$!"&&l!=="$?"||r++}n=n.nextSibling}vi=null}}else vi=gi?kn(n.stateNode.nextSibling):null;return!0}function Mf(){for(var n=vi;n;)n=kn(n.nextSibling)}function Ar(){vi=gi=null,dt=!1}function tc(n){Bi===null?Bi=[n]:Bi.push(n)}var VS=M.ReactCurrentBatchConfig;function Ps(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 I=f.refs;E===null?delete I[g]:I[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 Yo(n,r){throw n=Object.prototype.toString.call(r),Error(i(31,n==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":n))}function jf(n){var r=n._init;return r(n._payload)}function Tf(n){function r(te,Y){if(n){var re=te.deletions;re===null?(te.deletions=[Y],te.flags|=16):re.push(Y)}}function l(te,Y){if(!n)return null;for(;Y!==null;)r(te,Y),Y=Y.sibling;return null}function d(te,Y){for(te=new Map;Y!==null;)Y.key!==null?te.set(Y.key,Y):te.set(Y.index,Y),Y=Y.sibling;return te}function f(te,Y){return te=Tn(te,Y),te.index=0,te.sibling=null,te}function g(te,Y,re){return te.index=re,n?(re=te.alternate,re!==null?(re=re.index,re<Y?(te.flags|=2,Y):re):(te.flags|=2,Y)):(te.flags|=1048576,Y)}function E(te){return n&&te.alternate===null&&(te.flags|=2),te}function I(te,Y,re,we){return Y===null||Y.tag!==6?(Y=qc(re,te.mode,we),Y.return=te,Y):(Y=f(Y,re),Y.return=te,Y)}function U(te,Y,re,we){var Ie=re.type;return Ie===B?_e(te,Y,re.props.children,we,re.key):Y!==null&&(Y.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===$&&jf(Ie)===Y.type)?(we=f(Y,re.props),we.ref=Ps(te,Y,re),we.return=te,we):(we=_a(re.type,re.key,re.props,null,te.mode,we),we.ref=Ps(te,Y,re),we.return=te,we)}function oe(te,Y,re,we){return Y===null||Y.tag!==4||Y.stateNode.containerInfo!==re.containerInfo||Y.stateNode.implementation!==re.implementation?(Y=Vc(re,te.mode,we),Y.return=te,Y):(Y=f(Y,re.children||[]),Y.return=te,Y)}function _e(te,Y,re,we,Ie){return Y===null||Y.tag!==7?(Y=sr(re,te.mode,we,Ie),Y.return=te,Y):(Y=f(Y,re),Y.return=te,Y)}function ye(te,Y,re){if(typeof Y=="string"&&Y!==""||typeof Y=="number")return Y=qc(""+Y,te.mode,re),Y.return=te,Y;if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case ee:return re=_a(Y.type,Y.key,Y.props,null,te.mode,re),re.ref=Ps(te,null,Y),re.return=te,re;case F:return Y=Vc(Y,te.mode,re),Y.return=te,Y;case $:var we=Y._init;return ye(te,we(Y._payload),re)}if(V(Y)||ne(Y))return Y=sr(Y,te.mode,re,null),Y.return=te,Y;Yo(te,Y)}return null}function ge(te,Y,re,we){var Ie=Y!==null?Y.key:null;if(typeof re=="string"&&re!==""||typeof re=="number")return Ie!==null?null:I(te,Y,""+re,we);if(typeof re=="object"&&re!==null){switch(re.$$typeof){case ee:return re.key===Ie?U(te,Y,re,we):null;case F:return re.key===Ie?oe(te,Y,re,we):null;case $:return Ie=re._init,ge(te,Y,Ie(re._payload),we)}if(V(re)||ne(re))return Ie!==null?null:_e(te,Y,re,we,null);Yo(te,re)}return null}function Pe(te,Y,re,we,Ie){if(typeof we=="string"&&we!==""||typeof we=="number")return te=te.get(re)||null,I(Y,te,""+we,Ie);if(typeof we=="object"&&we!==null){switch(we.$$typeof){case ee:return te=te.get(we.key===null?re:we.key)||null,U(Y,te,we,Ie);case F:return te=te.get(we.key===null?re:we.key)||null,oe(Y,te,we,Ie);case $:var Fe=we._init;return Pe(te,Y,re,Fe(we._payload),Ie)}if(V(we)||ne(we))return te=te.get(re)||null,_e(Y,te,we,Ie,null);Yo(Y,we)}return null}function Le(te,Y,re,we){for(var Ie=null,Fe=null,He=Y,We=Y=0,It=null;He!==null&&We<re.length;We++){He.index>We?(It=He,He=null):It=He.sibling;var tt=ge(te,He,re[We],we);if(tt===null){He===null&&(He=It);break}n&&He&&tt.alternate===null&&r(te,He),Y=g(tt,Y,We),Fe===null?Ie=tt:Fe.sibling=tt,Fe=tt,He=It}if(We===re.length)return l(te,He),dt&&Qn(te,We),Ie;if(He===null){for(;We<re.length;We++)He=ye(te,re[We],we),He!==null&&(Y=g(He,Y,We),Fe===null?Ie=He:Fe.sibling=He,Fe=He);return dt&&Qn(te,We),Ie}for(He=d(te,He);We<re.length;We++)It=Pe(He,te,We,re[We],we),It!==null&&(n&&It.alternate!==null&&He.delete(It.key===null?We:It.key),Y=g(It,Y,We),Fe===null?Ie=It:Fe.sibling=It,Fe=It);return n&&He.forEach(function(An){return r(te,An)}),dt&&Qn(te,We),Ie}function Me(te,Y,re,we){var Ie=ne(re);if(typeof Ie!="function")throw Error(i(150));if(re=Ie.call(re),re==null)throw Error(i(151));for(var Fe=Ie=null,He=Y,We=Y=0,It=null,tt=re.next();He!==null&&!tt.done;We++,tt=re.next()){He.index>We?(It=He,He=null):It=He.sibling;var An=ge(te,He,tt.value,we);if(An===null){He===null&&(He=It);break}n&&He&&An.alternate===null&&r(te,He),Y=g(An,Y,We),Fe===null?Ie=An:Fe.sibling=An,Fe=An,He=It}if(tt.done)return l(te,He),dt&&Qn(te,We),Ie;if(He===null){for(;!tt.done;We++,tt=re.next())tt=ye(te,tt.value,we),tt!==null&&(Y=g(tt,Y,We),Fe===null?Ie=tt:Fe.sibling=tt,Fe=tt);return dt&&Qn(te,We),Ie}for(He=d(te,He);!tt.done;We++,tt=re.next())tt=Pe(He,te,We,tt.value,we),tt!==null&&(n&&tt.alternate!==null&&He.delete(tt.key===null?We:tt.key),Y=g(tt,Y,We),Fe===null?Ie=tt:Fe.sibling=tt,Fe=tt);return n&&He.forEach(function(Ew){return r(te,Ew)}),dt&&Qn(te,We),Ie}function kt(te,Y,re,we){if(typeof re=="object"&&re!==null&&re.type===B&&re.key===null&&(re=re.props.children),typeof re=="object"&&re!==null){switch(re.$$typeof){case ee:e:{for(var Ie=re.key,Fe=Y;Fe!==null;){if(Fe.key===Ie){if(Ie=re.type,Ie===B){if(Fe.tag===7){l(te,Fe.sibling),Y=f(Fe,re.props.children),Y.return=te,te=Y;break e}}else if(Fe.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===$&&jf(Ie)===Fe.type){l(te,Fe.sibling),Y=f(Fe,re.props),Y.ref=Ps(te,Fe,re),Y.return=te,te=Y;break e}l(te,Fe);break}else r(te,Fe);Fe=Fe.sibling}re.type===B?(Y=sr(re.props.children,te.mode,we,re.key),Y.return=te,te=Y):(we=_a(re.type,re.key,re.props,null,te.mode,we),we.ref=Ps(te,Y,re),we.return=te,te=we)}return E(te);case F:e:{for(Fe=re.key;Y!==null;){if(Y.key===Fe)if(Y.tag===4&&Y.stateNode.containerInfo===re.containerInfo&&Y.stateNode.implementation===re.implementation){l(te,Y.sibling),Y=f(Y,re.children||[]),Y.return=te,te=Y;break e}else{l(te,Y);break}else r(te,Y);Y=Y.sibling}Y=Vc(re,te.mode,we),Y.return=te,te=Y}return E(te);case $:return Fe=re._init,kt(te,Y,Fe(re._payload),we)}if(V(re))return Le(te,Y,re,we);if(ne(re))return Me(te,Y,re,we);Yo(te,re)}return typeof re=="string"&&re!==""||typeof re=="number"?(re=""+re,Y!==null&&Y.tag===6?(l(te,Y.sibling),Y=f(Y,re),Y.return=te,te=Y):(l(te,Y),Y=qc(re,te.mode,we),Y.return=te,te=Y),E(te)):l(te,Y)}return kt}var Ir=Tf(!0),Af=Tf(!1),Xo=Cn(null),Go=null,Br=null,ic=null;function nc(){ic=Br=Go=null}function rc(n){var r=Xo.current;ct(Xo),n._currentValue=r}function sc(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 Or(n,r){Go=n,ic=Br=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&r)!==0&&(li=!0),n.firstContext=null)}function Ei(n){var r=n._currentValue;if(ic!==n)if(n={context:n,memoizedValue:r,next:null},Br===null){if(Go===null)throw Error(i(308));Br=n,Go.dependencies={lanes:0,firstContext:n}}else Br=Br.next=n;return r}var Jn=null;function oc(n){Jn===null?Jn=[n]:Jn.push(n)}function If(n,r,l,d){var f=r.interleaved;return f===null?(l.next=l,oc(r)):(l.next=f.next,f.next=l),r.interleaved=l,ln(n,d)}function ln(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 Nn=!1;function ac(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Bf(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 cn(n,r){return{eventTime:n,lane:r,tag:0,payload:null,callback:null,next:null}}function Rn(n,r,l){var d=n.updateQueue;if(d===null)return null;if(d=d.shared,(Ze&2)!==0){var f=d.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),d.pending=r,ln(n,l)}return f=d.interleaved,f===null?(r.next=r,oc(d)):(r.next=f.next,f.next=r),d.interleaved=r,ln(n,l)}function Qo(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,wl(n,l)}}function Of(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 Jo(n,r,l,d){var f=n.updateQueue;Nn=!1;var g=f.firstBaseUpdate,E=f.lastBaseUpdate,I=f.shared.pending;if(I!==null){f.shared.pending=null;var U=I,oe=U.next;U.next=null,E===null?g=oe:E.next=oe,E=U;var _e=n.alternate;_e!==null&&(_e=_e.updateQueue,I=_e.lastBaseUpdate,I!==E&&(I===null?_e.firstBaseUpdate=oe:I.next=oe,_e.lastBaseUpdate=U))}if(g!==null){var ye=f.baseState;E=0,_e=oe=U=null,I=g;do{var ge=I.lane,Pe=I.eventTime;if((d&ge)===ge){_e!==null&&(_e=_e.next={eventTime:Pe,lane:0,tag:I.tag,payload:I.payload,callback:I.callback,next:null});e:{var Le=n,Me=I;switch(ge=r,Pe=l,Me.tag){case 1:if(Le=Me.payload,typeof Le=="function"){ye=Le.call(Pe,ye,ge);break e}ye=Le;break e;case 3:Le.flags=Le.flags&-65537|128;case 0:if(Le=Me.payload,ge=typeof Le=="function"?Le.call(Pe,ye,ge):Le,ge==null)break e;ye=H({},ye,ge);break e;case 2:Nn=!0}}I.callback!==null&&I.lane!==0&&(n.flags|=64,ge=f.effects,ge===null?f.effects=[I]:ge.push(I))}else Pe={eventTime:Pe,lane:ge,tag:I.tag,payload:I.payload,callback:I.callback,next:null},_e===null?(oe=_e=Pe,U=ye):_e=_e.next=Pe,E|=ge;if(I=I.next,I===null){if(I=f.shared.pending,I===null)break;ge=I,I=ge.next,ge.next=null,f.lastBaseUpdate=ge,f.shared.pending=null}}while(!0);if(_e===null&&(U=ye),f.baseState=U,f.firstBaseUpdate=oe,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);tr|=E,n.lanes=E,n.memoizedState=ye}}function zf(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 Ds={},Ki=Cn(Ds),Ls=Cn(Ds),Ms=Cn(Ds);function Zn(n){if(n===Ds)throw Error(i(174));return n}function lc(n,r){switch(at(Ms,r),at(Ls,n),at(Ki,Ds),n=r.nodeType,n){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Ne(null,"");break;default:n=n===8?r.parentNode:r,r=n.namespaceURI||null,n=n.tagName,r=Ne(r,n)}ct(Ki),at(Ki,r)}function zr(){ct(Ki),ct(Ls),ct(Ms)}function Ff(n){Zn(Ms.current);var r=Zn(Ki.current),l=Ne(r,n.type);r!==l&&(at(Ls,n),at(Ki,l))}function cc(n){Ls.current===n&&(ct(Ki),ct(Ls))}var ft=Cn(0);function Zo(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 uc=[];function dc(){for(var n=0;n<uc.length;n++)uc[n]._workInProgressVersionPrimary=null;uc.length=0}var ea=M.ReactCurrentDispatcher,hc=M.ReactCurrentBatchConfig,er=0,pt=null,Pt=null,Tt=null,ta=!1,js=!1,Ts=0,YS=0;function Qt(){throw Error(i(321))}function fc(n,r){if(r===null)return!1;for(var l=0;l<r.length&&l<n.length;l++)if(!Ii(n[l],r[l]))return!1;return!0}function pc(n,r,l,d,f,g){if(er=g,pt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,ea.current=n===null||n.memoizedState===null?JS:ZS,n=l(d,f),js){g=0;do{if(js=!1,Ts=0,25<=g)throw Error(i(301));g+=1,Tt=Pt=null,r.updateQueue=null,ea.current=ew,n=l(d,f)}while(js)}if(ea.current=ra,r=Pt!==null&&Pt.next!==null,er=0,Tt=Pt=pt=null,ta=!1,r)throw Error(i(300));return n}function mc(){var n=Ts!==0;return Ts=0,n}function qi(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Tt===null?pt.memoizedState=Tt=n:Tt=Tt.next=n,Tt}function Ni(){if(Pt===null){var n=pt.alternate;n=n!==null?n.memoizedState:null}else n=Pt.next;var r=Tt===null?pt.memoizedState:Tt.next;if(r!==null)Tt=r,Pt=n;else{if(n===null)throw Error(i(310));Pt=n,n={memoizedState:Pt.memoizedState,baseState:Pt.baseState,baseQueue:Pt.baseQueue,queue:Pt.queue,next:null},Tt===null?pt.memoizedState=Tt=n:Tt=Tt.next=n}return Tt}function As(n,r){return typeof r=="function"?r(n):r}function gc(n){var r=Ni(),l=r.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=n;var d=Pt,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 I=E=null,U=null,oe=g;do{var _e=oe.lane;if((er&_e)===_e)U!==null&&(U=U.next={lane:0,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null}),d=oe.hasEagerState?oe.eagerState:n(d,oe.action);else{var ye={lane:_e,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null};U===null?(I=U=ye,E=d):U=U.next=ye,pt.lanes|=_e,tr|=_e}oe=oe.next}while(oe!==null&&oe!==g);U===null?E=d:U.next=I,Ii(d,r.memoizedState)||(li=!0),r.memoizedState=d,r.baseState=E,r.baseQueue=U,l.lastRenderedState=d}if(n=l.interleaved,n!==null){f=n;do g=f.lane,pt.lanes|=g,tr|=g,f=f.next;while(f!==n)}else f===null&&(l.lanes=0);return[r.memoizedState,l.dispatch]}function vc(n){var r=Ni(),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);Ii(g,r.memoizedState)||(li=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),l.lastRenderedState=g}return[g,d]}function Hf(){}function $f(n,r){var l=pt,d=Ni(),f=r(),g=!Ii(d.memoizedState,f);if(g&&(d.memoizedState=f,li=!0),d=d.queue,_c(Kf.bind(null,l,d,n),[n]),d.getSnapshot!==r||g||Tt!==null&&Tt.memoizedState.tag&1){if(l.flags|=2048,Is(9,Uf.bind(null,l,d,f,r),void 0,null),At===null)throw Error(i(349));(er&30)!==0||Wf(l,r,f)}return f}function Wf(n,r,l){n.flags|=16384,n={getSnapshot:r,value:l},r=pt.updateQueue,r===null?(r={lastEffect:null,stores:null},pt.updateQueue=r,r.stores=[n]):(l=r.stores,l===null?r.stores=[n]:l.push(n))}function Uf(n,r,l,d){r.value=l,r.getSnapshot=d,qf(r)&&Vf(n)}function Kf(n,r,l){return l(function(){qf(r)&&Vf(n)})}function qf(n){var r=n.getSnapshot;n=n.value;try{var l=r();return!Ii(n,l)}catch{return!0}}function Vf(n){var r=ln(n,1);r!==null&&Hi(r,n,1,-1)}function Yf(n){var r=qi();return typeof n=="function"&&(n=n()),r.memoizedState=r.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:As,lastRenderedState:n},r.queue=n,n=n.dispatch=QS.bind(null,pt,n),[r.memoizedState,n]}function Is(n,r,l,d){return n={tag:n,create:r,destroy:l,deps:d,next:null},r=pt.updateQueue,r===null?(r={lastEffect:null,stores:null},pt.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 Xf(){return Ni().memoizedState}function ia(n,r,l,d){var f=qi();pt.flags|=n,f.memoizedState=Is(1|r,l,void 0,d===void 0?null:d)}function na(n,r,l,d){var f=Ni();d=d===void 0?null:d;var g=void 0;if(Pt!==null){var E=Pt.memoizedState;if(g=E.destroy,d!==null&&fc(d,E.deps)){f.memoizedState=Is(r,l,g,d);return}}pt.flags|=n,f.memoizedState=Is(1|r,l,g,d)}function Gf(n,r){return ia(8390656,8,n,r)}function _c(n,r){return na(2048,8,n,r)}function Qf(n,r){return na(4,2,n,r)}function Jf(n,r){return na(4,4,n,r)}function Zf(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 ep(n,r,l){return l=l!=null?l.concat([n]):null,na(4,4,Zf.bind(null,r,n),l)}function yc(){}function tp(n,r){var l=Ni();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&fc(r,d[1])?d[0]:(l.memoizedState=[n,r],n)}function ip(n,r){var l=Ni();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&fc(r,d[1])?d[0]:(n=n(),l.memoizedState=[n,r],n)}function np(n,r,l){return(er&21)===0?(n.baseState&&(n.baseState=!1,li=!0),n.memoizedState=l):(Ii(l,r)||(l=Mh(),pt.lanes|=l,tr|=l,n.baseState=!0),r)}function XS(n,r){var l=nt;nt=l!==0&&4>l?l:4,n(!0);var d=hc.transition;hc.transition={};try{n(!1),r()}finally{nt=l,hc.transition=d}}function rp(){return Ni().memoizedState}function GS(n,r,l){var d=Mn(n);if(l={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null},sp(n))op(r,l);else if(l=If(n,r,l,d),l!==null){var f=ii();Hi(l,n,d,f),ap(l,r,d)}}function QS(n,r,l){var d=Mn(n),f={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null};if(sp(n))op(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,I=g(E,l);if(f.hasEagerState=!0,f.eagerState=I,Ii(I,E)){var U=r.interleaved;U===null?(f.next=f,oc(r)):(f.next=U.next,U.next=f),r.interleaved=f;return}}catch{}finally{}l=If(n,r,f,d),l!==null&&(f=ii(),Hi(l,n,d,f),ap(l,r,d))}}function sp(n){var r=n.alternate;return n===pt||r!==null&&r===pt}function op(n,r){js=ta=!0;var l=n.pending;l===null?r.next=r:(r.next=l.next,l.next=r),n.pending=r}function ap(n,r,l){if((l&4194240)!==0){var d=r.lanes;d&=n.pendingLanes,l|=d,r.lanes=l,wl(n,l)}}var ra={readContext:Ei,useCallback:Qt,useContext:Qt,useEffect:Qt,useImperativeHandle:Qt,useInsertionEffect:Qt,useLayoutEffect:Qt,useMemo:Qt,useReducer:Qt,useRef:Qt,useState:Qt,useDebugValue:Qt,useDeferredValue:Qt,useTransition:Qt,useMutableSource:Qt,useSyncExternalStore:Qt,useId:Qt,unstable_isNewReconciler:!1},JS={readContext:Ei,useCallback:function(n,r){return qi().memoizedState=[n,r===void 0?null:r],n},useContext:Ei,useEffect:Gf,useImperativeHandle:function(n,r,l){return l=l!=null?l.concat([n]):null,ia(4194308,4,Zf.bind(null,r,n),l)},useLayoutEffect:function(n,r){return ia(4194308,4,n,r)},useInsertionEffect:function(n,r){return ia(4,2,n,r)},useMemo:function(n,r){var l=qi();return r=r===void 0?null:r,n=n(),l.memoizedState=[n,r],n},useReducer:function(n,r,l){var d=qi();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=GS.bind(null,pt,n),[d.memoizedState,n]},useRef:function(n){var r=qi();return n={current:n},r.memoizedState=n},useState:Yf,useDebugValue:yc,useDeferredValue:function(n){return qi().memoizedState=n},useTransition:function(){var n=Yf(!1),r=n[0];return n=XS.bind(null,n[1]),qi().memoizedState=n,[r,n]},useMutableSource:function(){},useSyncExternalStore:function(n,r,l){var d=pt,f=qi();if(dt){if(l===void 0)throw Error(i(407));l=l()}else{if(l=r(),At===null)throw Error(i(349));(er&30)!==0||Wf(d,r,l)}f.memoizedState=l;var g={value:l,getSnapshot:r};return f.queue=g,Gf(Kf.bind(null,d,g,n),[n]),d.flags|=2048,Is(9,Uf.bind(null,d,g,l,r),void 0,null),l},useId:function(){var n=qi(),r=At.identifierPrefix;if(dt){var l=an,d=on;l=(d&~(1<<32-Ai(d)-1)).toString(32)+l,r=":"+r+"R"+l,l=Ts++,0<l&&(r+="H"+l.toString(32)),r+=":"}else l=YS++,r=":"+r+"r"+l.toString(32)+":";return n.memoizedState=r},unstable_isNewReconciler:!1},ZS={readContext:Ei,useCallback:tp,useContext:Ei,useEffect:_c,useImperativeHandle:ep,useInsertionEffect:Qf,useLayoutEffect:Jf,useMemo:ip,useReducer:gc,useRef:Xf,useState:function(){return gc(As)},useDebugValue:yc,useDeferredValue:function(n){var r=Ni();return np(r,Pt.memoizedState,n)},useTransition:function(){var n=gc(As)[0],r=Ni().memoizedState;return[n,r]},useMutableSource:Hf,useSyncExternalStore:$f,useId:rp,unstable_isNewReconciler:!1},ew={readContext:Ei,useCallback:tp,useContext:Ei,useEffect:_c,useImperativeHandle:ep,useInsertionEffect:Qf,useLayoutEffect:Jf,useMemo:ip,useReducer:vc,useRef:Xf,useState:function(){return vc(As)},useDebugValue:yc,useDeferredValue:function(n){var r=Ni();return Pt===null?r.memoizedState=n:np(r,Pt.memoizedState,n)},useTransition:function(){var n=vc(As)[0],r=Ni().memoizedState;return[n,r]},useMutableSource:Hf,useSyncExternalStore:$f,useId:rp,unstable_isNewReconciler:!1};function Oi(n,r){if(n&&n.defaultProps){r=H({},r),n=n.defaultProps;for(var l in n)r[l]===void 0&&(r[l]=n[l]);return r}return r}function Sc(n,r,l,d){r=n.memoizedState,l=l(d,r),l=l==null?r:H({},r,l),n.memoizedState=l,n.lanes===0&&(n.updateQueue.baseState=l)}var sa={isMounted:function(n){return(n=n._reactInternals)?Vn(n)===n:!1},enqueueSetState:function(n,r,l){n=n._reactInternals;var d=ii(),f=Mn(n),g=cn(d,f);g.payload=r,l!=null&&(g.callback=l),r=Rn(n,g,f),r!==null&&(Hi(r,n,f,d),Qo(r,n,f))},enqueueReplaceState:function(n,r,l){n=n._reactInternals;var d=ii(),f=Mn(n),g=cn(d,f);g.tag=1,g.payload=r,l!=null&&(g.callback=l),r=Rn(n,g,f),r!==null&&(Hi(r,n,f,d),Qo(r,n,f))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var l=ii(),d=Mn(n),f=cn(l,d);f.tag=2,r!=null&&(f.callback=r),r=Rn(n,f,d),r!==null&&(Hi(r,n,d,l),Qo(r,n,d))}};function lp(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?!bs(l,d)||!bs(f,g):!0}function cp(n,r,l){var d=!1,f=xn,g=r.contextType;return typeof g=="object"&&g!==null?g=Ei(g):(f=ai(r)?Xn:Gt.current,d=r.contextTypes,g=(d=d!=null)?Mr(n,f):xn),r=new r(l,g),n.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=sa,n.stateNode=r,r._reactInternals=n,d&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=f,n.__reactInternalMemoizedMaskedChildContext=g),r}function up(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&&sa.enqueueReplaceState(r,r.state,null)}function wc(n,r,l,d){var f=n.stateNode;f.props=l,f.state=n.memoizedState,f.refs={},ac(n);var g=r.contextType;typeof g=="object"&&g!==null?f.context=Ei(g):(g=ai(r)?Xn:Gt.current,f.context=Mr(n,g)),f.state=n.memoizedState,g=r.getDerivedStateFromProps,typeof g=="function"&&(Sc(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&&sa.enqueueReplaceState(f,f.state,null),Jo(n,l,f,d),f.state=n.memoizedState),typeof f.componentDidMount=="function"&&(n.flags|=4194308)}function Fr(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 bc(n,r,l){return{value:n,source:null,stack:l??null,digest:r??null}}function kc(n,r){try{console.error(r.value)}catch(l){setTimeout(function(){throw l})}}var tw=typeof WeakMap=="function"?WeakMap:Map;function dp(n,r,l){l=cn(-1,l),l.tag=3,l.payload={element:null};var d=r.value;return l.callback=function(){ha||(ha=!0,Oc=d),kc(n,r)},l}function hp(n,r,l){l=cn(-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(){kc(n,r)}}var g=n.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(l.callback=function(){kc(n,r),typeof d!="function"&&(Dn===null?Dn=new Set([this]):Dn.add(this));var E=r.stack;this.componentDidCatch(r.value,{componentStack:E!==null?E:""})}),l}function fp(n,r,l){var d=n.pingCache;if(d===null){d=n.pingCache=new tw;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=mw.bind(null,n,r,l),r.then(n,n))}function pp(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 mp(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=cn(-1,1),r.tag=2,Rn(l,r,1))),l.lanes|=1),n):(n.flags|=65536,n.lanes=f,n)}var iw=M.ReactCurrentOwner,li=!1;function ti(n,r,l,d){r.child=n===null?Af(r,null,l,d):Ir(r,n.child,l,d)}function gp(n,r,l,d,f){l=l.render;var g=r.ref;return Or(r,f),d=pc(n,r,l,d,g,f),l=mc(),n!==null&&!li?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,un(n,r,f)):(dt&&l&&Ql(r),r.flags|=1,ti(n,r,d,f),r.child)}function vp(n,r,l,d,f){if(n===null){var g=l.type;return typeof g=="function"&&!Kc(g)&&g.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(r.tag=15,r.type=g,_p(n,r,g,d,f)):(n=_a(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:bs,l(E,d)&&n.ref===r.ref)return un(n,r,f)}return r.flags|=1,n=Tn(g,d),n.ref=r.ref,n.return=r,r.child=n}function _p(n,r,l,d,f){if(n!==null){var g=n.memoizedProps;if(bs(g,d)&&n.ref===r.ref)if(li=!1,r.pendingProps=d=g,(n.lanes&f)!==0)(n.flags&131072)!==0&&(li=!0);else return r.lanes=n.lanes,un(n,r,f)}return Cc(n,r,l,d,f)}function yp(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},at($r,_i),_i|=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,at($r,_i),_i|=n,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},d=g!==null?g.baseLanes:l,at($r,_i),_i|=d}else g!==null?(d=g.baseLanes|l,r.memoizedState=null):d=l,at($r,_i),_i|=d;return ti(n,r,f,l),r.child}function Sp(n,r){var l=r.ref;(n===null&&l!==null||n!==null&&n.ref!==l)&&(r.flags|=512,r.flags|=2097152)}function Cc(n,r,l,d,f){var g=ai(l)?Xn:Gt.current;return g=Mr(r,g),Or(r,f),l=pc(n,r,l,d,g,f),d=mc(),n!==null&&!li?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,un(n,r,f)):(dt&&d&&Ql(r),r.flags|=1,ti(n,r,l,f),r.child)}function wp(n,r,l,d,f){if(ai(l)){var g=!0;Wo(r)}else g=!1;if(Or(r,f),r.stateNode===null)aa(n,r),cp(r,l,d),wc(r,l,d,f),d=!0;else if(n===null){var E=r.stateNode,I=r.memoizedProps;E.props=I;var U=E.context,oe=l.contextType;typeof oe=="object"&&oe!==null?oe=Ei(oe):(oe=ai(l)?Xn:Gt.current,oe=Mr(r,oe));var _e=l.getDerivedStateFromProps,ye=typeof _e=="function"||typeof E.getSnapshotBeforeUpdate=="function";ye||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(I!==d||U!==oe)&&up(r,E,d,oe),Nn=!1;var ge=r.memoizedState;E.state=ge,Jo(r,d,E,f),U=r.memoizedState,I!==d||ge!==U||oi.current||Nn?(typeof _e=="function"&&(Sc(r,l,_e,d),U=r.memoizedState),(I=Nn||lp(r,l,I,d,ge,U,oe))?(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=U),E.props=d,E.state=U,E.context=oe,d=I):(typeof E.componentDidMount=="function"&&(r.flags|=4194308),d=!1)}else{E=r.stateNode,Bf(n,r),I=r.memoizedProps,oe=r.type===r.elementType?I:Oi(r.type,I),E.props=oe,ye=r.pendingProps,ge=E.context,U=l.contextType,typeof U=="object"&&U!==null?U=Ei(U):(U=ai(l)?Xn:Gt.current,U=Mr(r,U));var Pe=l.getDerivedStateFromProps;(_e=typeof Pe=="function"||typeof E.getSnapshotBeforeUpdate=="function")||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(I!==ye||ge!==U)&&up(r,E,d,U),Nn=!1,ge=r.memoizedState,E.state=ge,Jo(r,d,E,f);var Le=r.memoizedState;I!==ye||ge!==Le||oi.current||Nn?(typeof Pe=="function"&&(Sc(r,l,Pe,d),Le=r.memoizedState),(oe=Nn||lp(r,l,oe,d,ge,Le,U)||!1)?(_e||typeof E.UNSAFE_componentWillUpdate!="function"&&typeof E.componentWillUpdate!="function"||(typeof E.componentWillUpdate=="function"&&E.componentWillUpdate(d,Le,U),typeof E.UNSAFE_componentWillUpdate=="function"&&E.UNSAFE_componentWillUpdate(d,Le,U)),typeof E.componentDidUpdate=="function"&&(r.flags|=4),typeof E.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof E.componentDidUpdate!="function"||I===n.memoizedProps&&ge===n.memoizedState||(r.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||I===n.memoizedProps&&ge===n.memoizedState||(r.flags|=1024),r.memoizedProps=d,r.memoizedState=Le),E.props=d,E.state=Le,E.context=U,d=oe):(typeof E.componentDidUpdate!="function"||I===n.memoizedProps&&ge===n.memoizedState||(r.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||I===n.memoizedProps&&ge===n.memoizedState||(r.flags|=1024),d=!1)}return xc(n,r,l,d,g,f)}function xc(n,r,l,d,f,g){Sp(n,r);var E=(r.flags&128)!==0;if(!d&&!E)return f&&Ef(r,l,!1),un(n,r,g);d=r.stateNode,iw.current=r;var I=E&&typeof l.getDerivedStateFromError!="function"?null:d.render();return r.flags|=1,n!==null&&E?(r.child=Ir(r,n.child,null,g),r.child=Ir(r,null,I,g)):ti(n,r,I,g),r.memoizedState=d.state,f&&Ef(r,l,!0),r.child}function bp(n){var r=n.stateNode;r.pendingContext?Cf(n,r.pendingContext,r.pendingContext!==r.context):r.context&&Cf(n,r.context,!1),lc(n,r.containerInfo)}function kp(n,r,l,d,f){return Ar(),tc(f),r.flags|=256,ti(n,r,l,d),r.child}var Ec={dehydrated:null,treeContext:null,retryLane:0};function Nc(n){return{baseLanes:n,cachePool:null,transitions:null}}function Cp(n,r,l){var d=r.pendingProps,f=ft.current,g=!1,E=(r.flags&128)!==0,I;if((I=E)||(I=n!==null&&n.memoizedState===null?!1:(f&2)!==0),I?(g=!0,r.flags&=-129):(n===null||n.memoizedState!==null)&&(f|=1),at(ft,f&1),n===null)return ec(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=ya(E,d,0,null),n=sr(n,d,l,null),g.return=r,n.return=r,g.sibling=n,r.child=g,r.child.memoizedState=Nc(l),r.memoizedState=Ec,n):Rc(r,E));if(f=n.memoizedState,f!==null&&(I=f.dehydrated,I!==null))return nw(n,r,E,d,I,f,l);if(g){g=d.fallback,E=r.mode,f=n.child,I=f.sibling;var U={mode:"hidden",children:d.children};return(E&1)===0&&r.child!==f?(d=r.child,d.childLanes=0,d.pendingProps=U,r.deletions=null):(d=Tn(f,U),d.subtreeFlags=f.subtreeFlags&14680064),I!==null?g=Tn(I,g):(g=sr(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?Nc(l):{baseLanes:E.baseLanes|l,cachePool:null,transitions:E.transitions},g.memoizedState=E,g.childLanes=n.childLanes&~l,r.memoizedState=Ec,d}return g=n.child,n=g.sibling,d=Tn(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 Rc(n,r){return r=ya({mode:"visible",children:r},n.mode,0,null),r.return=n,n.child=r}function oa(n,r,l,d){return d!==null&&tc(d),Ir(r,n.child,null,l),n=Rc(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function nw(n,r,l,d,f,g,E){if(l)return r.flags&256?(r.flags&=-257,d=bc(Error(i(422))),oa(n,r,E,d)):r.memoizedState!==null?(r.child=n.child,r.flags|=128,null):(g=d.fallback,f=r.mode,d=ya({mode:"visible",children:d.children},f,0,null),g=sr(g,f,E,null),g.flags|=2,d.return=r,g.return=r,d.sibling=g,r.child=d,(r.mode&1)!==0&&Ir(r,n.child,null,E),r.child.memoizedState=Nc(E),r.memoizedState=Ec,g);if((r.mode&1)===0)return oa(n,r,E,null);if(f.data==="$!"){if(d=f.nextSibling&&f.nextSibling.dataset,d)var I=d.dgst;return d=I,g=Error(i(419)),d=bc(g,d,void 0),oa(n,r,E,d)}if(I=(E&n.childLanes)!==0,li||I){if(d=At,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,ln(n,f),Hi(d,n,f,-1))}return Uc(),d=bc(Error(i(421))),oa(n,r,E,d)}return f.data==="$?"?(r.flags|=128,r.child=n.child,r=gw.bind(null,n),f._reactRetry=r,null):(n=g.treeContext,vi=kn(f.nextSibling),gi=r,dt=!0,Bi=null,n!==null&&(Ci[xi++]=on,Ci[xi++]=an,Ci[xi++]=Gn,on=n.id,an=n.overflow,Gn=r),r=Rc(r,d.children),r.flags|=4096,r)}function xp(n,r,l){n.lanes|=r;var d=n.alternate;d!==null&&(d.lanes|=r),sc(n.return,r,l)}function Pc(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 Ep(n,r,l){var d=r.pendingProps,f=d.revealOrder,g=d.tail;if(ti(n,r,d.children,l),d=ft.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&&xp(n,l,r);else if(n.tag===19)xp(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(at(ft,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&&Zo(n)===null&&(f=l),l=l.sibling;l=f,l===null?(f=r.child,r.child=null):(f=l.sibling,l.sibling=null),Pc(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&&Zo(n)===null){r.child=f;break}n=f.sibling,f.sibling=l,l=f,f=n}Pc(r,!0,l,null,g);break;case"together":Pc(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function aa(n,r){(r.mode&1)===0&&n!==null&&(n.alternate=null,r.alternate=null,r.flags|=2)}function un(n,r,l){if(n!==null&&(r.dependencies=n.dependencies),tr|=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=Tn(n,n.pendingProps),r.child=l,l.return=r;n.sibling!==null;)n=n.sibling,l=l.sibling=Tn(n,n.pendingProps),l.return=r;l.sibling=null}return r.child}function rw(n,r,l){switch(r.tag){case 3:bp(r),Ar();break;case 5:Ff(r);break;case 1:ai(r.type)&&Wo(r);break;case 4:lc(r,r.stateNode.containerInfo);break;case 10:var d=r.type._context,f=r.memoizedProps.value;at(Xo,d._currentValue),d._currentValue=f;break;case 13:if(d=r.memoizedState,d!==null)return d.dehydrated!==null?(at(ft,ft.current&1),r.flags|=128,null):(l&r.child.childLanes)!==0?Cp(n,r,l):(at(ft,ft.current&1),n=un(n,r,l),n!==null?n.sibling:null);at(ft,ft.current&1);break;case 19:if(d=(l&r.childLanes)!==0,(n.flags&128)!==0){if(d)return Ep(n,r,l);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),at(ft,ft.current),d)break;return null;case 22:case 23:return r.lanes=0,yp(n,r,l)}return un(n,r,l)}var Np,Dc,Rp,Pp;Np=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}},Dc=function(){},Rp=function(n,r,l,d){var f=n.memoizedProps;if(f!==d){n=r.stateNode,Zn(Ki.current);var g=null;switch(l){case"input":f=it(n,f),d=it(n,d),g=[];break;case"select":f=H({},f,{value:void 0}),d=H({},d,{value:void 0}),g=[];break;case"textarea":f=pe(n,f),d=pe(n,d),g=[];break;default:typeof f.onClick!="function"&&typeof d.onClick=="function"&&(n.onclick=Fo)}wt(l,d);var E;l=null;for(oe in f)if(!d.hasOwnProperty(oe)&&f.hasOwnProperty(oe)&&f[oe]!=null)if(oe==="style"){var I=f[oe];for(E in I)I.hasOwnProperty(E)&&(l||(l={}),l[E]="")}else oe!=="dangerouslySetInnerHTML"&&oe!=="children"&&oe!=="suppressContentEditableWarning"&&oe!=="suppressHydrationWarning"&&oe!=="autoFocus"&&(o.hasOwnProperty(oe)?g||(g=[]):(g=g||[]).push(oe,null));for(oe in d){var U=d[oe];if(I=f!=null?f[oe]:void 0,d.hasOwnProperty(oe)&&U!==I&&(U!=null||I!=null))if(oe==="style")if(I){for(E in I)!I.hasOwnProperty(E)||U&&U.hasOwnProperty(E)||(l||(l={}),l[E]="");for(E in U)U.hasOwnProperty(E)&&I[E]!==U[E]&&(l||(l={}),l[E]=U[E])}else l||(g||(g=[]),g.push(oe,l)),l=U;else oe==="dangerouslySetInnerHTML"?(U=U?U.__html:void 0,I=I?I.__html:void 0,U!=null&&I!==U&&(g=g||[]).push(oe,U)):oe==="children"?typeof U!="string"&&typeof U!="number"||(g=g||[]).push(oe,""+U):oe!=="suppressContentEditableWarning"&&oe!=="suppressHydrationWarning"&&(o.hasOwnProperty(oe)?(U!=null&&oe==="onScroll"&&lt("scroll",n),g||I===U||(g=[])):(g=g||[]).push(oe,U))}l&&(g=g||[]).push("style",l);var oe=g;(r.updateQueue=oe)&&(r.flags|=4)}},Pp=function(n,r,l,d){l!==d&&(r.flags|=4)};function Bs(n,r){if(!dt)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 Jt(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 sw(n,r,l){var d=r.pendingProps;switch(Jl(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Jt(r),null;case 1:return ai(r.type)&&$o(),Jt(r),null;case 3:return d=r.stateNode,zr(),ct(oi),ct(Gt),dc(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(n===null||n.child===null)&&(Vo(r)?r.flags|=4:n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Bi!==null&&(Hc(Bi),Bi=null))),Dc(n,r),Jt(r),null;case 5:cc(r);var f=Zn(Ms.current);if(l=r.type,n!==null&&r.stateNode!=null)Rp(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 Jt(r),null}if(n=Zn(Ki.current),Vo(r)){d=r.stateNode,l=r.type;var g=r.memoizedProps;switch(d[Ui]=r,d[Ns]=g,n=(r.mode&1)!==0,l){case"dialog":lt("cancel",d),lt("close",d);break;case"iframe":case"object":case"embed":lt("load",d);break;case"video":case"audio":for(f=0;f<Cs.length;f++)lt(Cs[f],d);break;case"source":lt("error",d);break;case"img":case"image":case"link":lt("error",d),lt("load",d);break;case"details":lt("toggle",d);break;case"input":St(d,g),lt("invalid",d);break;case"select":d._wrapperState={wasMultiple:!!g.multiple},lt("invalid",d);break;case"textarea":ve(d,g),lt("invalid",d)}wt(l,g),f=null;for(var E in g)if(g.hasOwnProperty(E)){var I=g[E];E==="children"?typeof I=="string"?d.textContent!==I&&(g.suppressHydrationWarning!==!0&&zo(d.textContent,I,n),f=["children",I]):typeof I=="number"&&d.textContent!==""+I&&(g.suppressHydrationWarning!==!0&&zo(d.textContent,I,n),f=["children",""+I]):o.hasOwnProperty(E)&&I!=null&&E==="onScroll"&&lt("scroll",d)}switch(l){case"input":Ve(d),Oe(d,g,!0);break;case"textarea":Ve(d),ae(d);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(d.onclick=Fo)}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=je(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[Ui]=r,n[Ns]=d,Np(n,r,!1,!1),r.stateNode=n;e:{switch(E=ue(l,d),l){case"dialog":lt("cancel",n),lt("close",n),f=d;break;case"iframe":case"object":case"embed":lt("load",n),f=d;break;case"video":case"audio":for(f=0;f<Cs.length;f++)lt(Cs[f],n);f=d;break;case"source":lt("error",n),f=d;break;case"img":case"image":case"link":lt("error",n),lt("load",n),f=d;break;case"details":lt("toggle",n),f=d;break;case"input":St(n,d),f=it(n,d),lt("invalid",n);break;case"option":f=d;break;case"select":n._wrapperState={wasMultiple:!!d.multiple},f=H({},d,{value:void 0}),lt("invalid",n);break;case"textarea":ve(n,d),f=pe(n,d),lt("invalid",n);break;default:f=d}wt(l,f),I=f;for(g in I)if(I.hasOwnProperty(g)){var U=I[g];g==="style"?ot(n,U):g==="dangerouslySetInnerHTML"?(U=U?U.__html:void 0,U!=null&&Be(n,U)):g==="children"?typeof U=="string"?(l!=="textarea"||U!=="")&&st(n,U):typeof U=="number"&&st(n,""+U):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(o.hasOwnProperty(g)?U!=null&&g==="onScroll"&&lt("scroll",n):U!=null&&j(n,g,U,E))}switch(l){case"input":Ve(n),Oe(n,d,!1);break;case"textarea":Ve(n),ae(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?q(n,!!d.multiple,g,!1):d.defaultValue!=null&&q(n,!!d.multiple,d.defaultValue,!0);break;default:typeof f.onClick=="function"&&(n.onclick=Fo)}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 Jt(r),null;case 6:if(n&&r.stateNode!=null)Pp(n,r,n.memoizedProps,d);else{if(typeof d!="string"&&r.stateNode===null)throw Error(i(166));if(l=Zn(Ms.current),Zn(Ki.current),Vo(r)){if(d=r.stateNode,l=r.memoizedProps,d[Ui]=r,(g=d.nodeValue!==l)&&(n=gi,n!==null))switch(n.tag){case 3:zo(d.nodeValue,l,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&zo(d.nodeValue,l,(n.mode&1)!==0)}g&&(r.flags|=4)}else d=(l.nodeType===9?l:l.ownerDocument).createTextNode(d),d[Ui]=r,r.stateNode=d}return Jt(r),null;case 13:if(ct(ft),d=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(dt&&vi!==null&&(r.mode&1)!==0&&(r.flags&128)===0)Mf(),Ar(),r.flags|=98560,g=!1;else if(g=Vo(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[Ui]=r}else Ar(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Jt(r),g=!1}else Bi!==null&&(Hc(Bi),Bi=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||(ft.current&1)!==0?Dt===0&&(Dt=3):Uc())),r.updateQueue!==null&&(r.flags|=4),Jt(r),null);case 4:return zr(),Dc(n,r),n===null&&xs(r.stateNode.containerInfo),Jt(r),null;case 10:return rc(r.type._context),Jt(r),null;case 17:return ai(r.type)&&$o(),Jt(r),null;case 19:if(ct(ft),g=r.memoizedState,g===null)return Jt(r),null;if(d=(r.flags&128)!==0,E=g.rendering,E===null)if(d)Bs(g,!1);else{if(Dt!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(E=Zo(n),E!==null){for(r.flags|=128,Bs(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 at(ft,ft.current&1|2),r.child}n=n.sibling}g.tail!==null&&bt()>Wr&&(r.flags|=128,d=!0,Bs(g,!1),r.lanes=4194304)}else{if(!d)if(n=Zo(E),n!==null){if(r.flags|=128,d=!0,l=n.updateQueue,l!==null&&(r.updateQueue=l,r.flags|=4),Bs(g,!0),g.tail===null&&g.tailMode==="hidden"&&!E.alternate&&!dt)return Jt(r),null}else 2*bt()-g.renderingStartTime>Wr&&l!==1073741824&&(r.flags|=128,d=!0,Bs(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=bt(),r.sibling=null,l=ft.current,at(ft,d?l&1|2:l&1),r):(Jt(r),null);case 22:case 23:return Wc(),d=r.memoizedState!==null,n!==null&&n.memoizedState!==null!==d&&(r.flags|=8192),d&&(r.mode&1)!==0?(_i&1073741824)!==0&&(Jt(r),r.subtreeFlags&6&&(r.flags|=8192)):Jt(r),null;case 24:return null;case 25:return null}throw Error(i(156,r.tag))}function ow(n,r){switch(Jl(r),r.tag){case 1:return ai(r.type)&&$o(),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return zr(),ct(oi),ct(Gt),dc(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 5:return cc(r),null;case 13:if(ct(ft),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(i(340));Ar()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return ct(ft),null;case 4:return zr(),null;case 10:return rc(r.type._context),null;case 22:case 23:return Wc(),null;case 24:return null;default:return null}}var la=!1,Zt=!1,aw=typeof WeakSet=="function"?WeakSet:Set,De=null;function Hr(n,r){var l=n.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(d){vt(n,r,d)}else l.current=null}function Lc(n,r,l){try{l()}catch(d){vt(n,r,d)}}var Dp=!1;function lw(n,r){if(Wl=Ro,n=lf(),Al(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,I=-1,U=-1,oe=0,_e=0,ye=n,ge=null;t:for(;;){for(var Pe;ye!==l||f!==0&&ye.nodeType!==3||(I=E+f),ye!==g||d!==0&&ye.nodeType!==3||(U=E+d),ye.nodeType===3&&(E+=ye.nodeValue.length),(Pe=ye.firstChild)!==null;)ge=ye,ye=Pe;for(;;){if(ye===n)break t;if(ge===l&&++oe===f&&(I=E),ge===g&&++_e===d&&(U=E),(Pe=ye.nextSibling)!==null)break;ye=ge,ge=ye.parentNode}ye=Pe}l=I===-1||U===-1?null:{start:I,end:U}}else l=null}l=l||{start:0,end:0}}else l=null;for(Ul={focusedElem:n,selectionRange:l},Ro=!1,De=r;De!==null;)if(r=De,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,De=n;else for(;De!==null;){r=De;try{var Le=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Le!==null){var Me=Le.memoizedProps,kt=Le.memoizedState,te=r.stateNode,Y=te.getSnapshotBeforeUpdate(r.elementType===r.type?Me:Oi(r.type,Me),kt);te.__reactInternalSnapshotBeforeUpdate=Y}break;case 3:var re=r.stateNode.containerInfo;re.nodeType===1?re.textContent="":re.nodeType===9&&re.documentElement&&re.removeChild(re.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(we){vt(r,r.return,we)}if(n=r.sibling,n!==null){n.return=r.return,De=n;break}De=r.return}return Le=Dp,Dp=!1,Le}function Os(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&&Lc(r,l,g)}f=f.next}while(f!==d)}}function ca(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 Mc(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 Lp(n){var r=n.alternate;r!==null&&(n.alternate=null,Lp(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&(delete r[Ui],delete r[Ns],delete r[Yl],delete r[US],delete r[KS])),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 Mp(n){return n.tag===5||n.tag===3||n.tag===4}function jp(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Mp(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 jc(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=Fo));else if(d!==4&&(n=n.child,n!==null))for(jc(n,r,l),n=n.sibling;n!==null;)jc(n,r,l),n=n.sibling}function Tc(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(Tc(n,r,l),n=n.sibling;n!==null;)Tc(n,r,l),n=n.sibling}var Wt=null,zi=!1;function Pn(n,r,l){for(l=l.child;l!==null;)Tp(n,r,l),l=l.sibling}function Tp(n,r,l){if(Wi&&typeof Wi.onCommitFiberUnmount=="function")try{Wi.onCommitFiberUnmount(bo,l)}catch{}switch(l.tag){case 5:Zt||Hr(l,r);case 6:var d=Wt,f=zi;Wt=null,Pn(n,r,l),Wt=d,zi=f,Wt!==null&&(zi?(n=Wt,l=l.stateNode,n.nodeType===8?n.parentNode.removeChild(l):n.removeChild(l)):Wt.removeChild(l.stateNode));break;case 18:Wt!==null&&(zi?(n=Wt,l=l.stateNode,n.nodeType===8?Vl(n.parentNode,l):n.nodeType===1&&Vl(n,l),gs(n)):Vl(Wt,l.stateNode));break;case 4:d=Wt,f=zi,Wt=l.stateNode.containerInfo,zi=!0,Pn(n,r,l),Wt=d,zi=f;break;case 0:case 11:case 14:case 15:if(!Zt&&(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)&&Lc(l,r,E),f=f.next}while(f!==d)}Pn(n,r,l);break;case 1:if(!Zt&&(Hr(l,r),d=l.stateNode,typeof d.componentWillUnmount=="function"))try{d.props=l.memoizedProps,d.state=l.memoizedState,d.componentWillUnmount()}catch(I){vt(l,r,I)}Pn(n,r,l);break;case 21:Pn(n,r,l);break;case 22:l.mode&1?(Zt=(d=Zt)||l.memoizedState!==null,Pn(n,r,l),Zt=d):Pn(n,r,l);break;default:Pn(n,r,l)}}function Ap(n){var r=n.updateQueue;if(r!==null){n.updateQueue=null;var l=n.stateNode;l===null&&(l=n.stateNode=new aw),r.forEach(function(d){var f=vw.bind(null,n,d);l.has(d)||(l.add(d),d.then(f,f))})}}function Fi(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,I=E;e:for(;I!==null;){switch(I.tag){case 5:Wt=I.stateNode,zi=!1;break e;case 3:Wt=I.stateNode.containerInfo,zi=!0;break e;case 4:Wt=I.stateNode.containerInfo,zi=!0;break e}I=I.return}if(Wt===null)throw Error(i(160));Tp(g,E,f),Wt=null,zi=!1;var U=f.alternate;U!==null&&(U.return=null),f.return=null}catch(oe){vt(f,r,oe)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)Ip(r,n),r=r.sibling}function Ip(n,r){var l=n.alternate,d=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Fi(r,n),Vi(n),d&4){try{Os(3,n,n.return),ca(3,n)}catch(Me){vt(n,n.return,Me)}try{Os(5,n,n.return)}catch(Me){vt(n,n.return,Me)}}break;case 1:Fi(r,n),Vi(n),d&512&&l!==null&&Hr(l,l.return);break;case 5:if(Fi(r,n),Vi(n),d&512&&l!==null&&Hr(l,l.return),n.flags&32){var f=n.stateNode;try{st(f,"")}catch(Me){vt(n,n.return,Me)}}if(d&4&&(f=n.stateNode,f!=null)){var g=n.memoizedProps,E=l!==null?l.memoizedProps:g,I=n.type,U=n.updateQueue;if(n.updateQueue=null,U!==null)try{I==="input"&&g.type==="radio"&&g.name!=null&&se(f,g),ue(I,E);var oe=ue(I,g);for(E=0;E<U.length;E+=2){var _e=U[E],ye=U[E+1];_e==="style"?ot(f,ye):_e==="dangerouslySetInnerHTML"?Be(f,ye):_e==="children"?st(f,ye):j(f,_e,ye,oe)}switch(I){case"input":le(f,g);break;case"textarea":be(f,g);break;case"select":var ge=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!g.multiple;var Pe=g.value;Pe!=null?q(f,!!g.multiple,Pe,!1):ge!==!!g.multiple&&(g.defaultValue!=null?q(f,!!g.multiple,g.defaultValue,!0):q(f,!!g.multiple,g.multiple?[]:"",!1))}f[Ns]=g}catch(Me){vt(n,n.return,Me)}}break;case 6:if(Fi(r,n),Vi(n),d&4){if(n.stateNode===null)throw Error(i(162));f=n.stateNode,g=n.memoizedProps;try{f.nodeValue=g}catch(Me){vt(n,n.return,Me)}}break;case 3:if(Fi(r,n),Vi(n),d&4&&l!==null&&l.memoizedState.isDehydrated)try{gs(r.containerInfo)}catch(Me){vt(n,n.return,Me)}break;case 4:Fi(r,n),Vi(n);break;case 13:Fi(r,n),Vi(n),f=n.child,f.flags&8192&&(g=f.memoizedState!==null,f.stateNode.isHidden=g,!g||f.alternate!==null&&f.alternate.memoizedState!==null||(Bc=bt())),d&4&&Ap(n);break;case 22:if(_e=l!==null&&l.memoizedState!==null,n.mode&1?(Zt=(oe=Zt)||_e,Fi(r,n),Zt=oe):Fi(r,n),Vi(n),d&8192){if(oe=n.memoizedState!==null,(n.stateNode.isHidden=oe)&&!_e&&(n.mode&1)!==0)for(De=n,_e=n.child;_e!==null;){for(ye=De=_e;De!==null;){switch(ge=De,Pe=ge.child,ge.tag){case 0:case 11:case 14:case 15:Os(4,ge,ge.return);break;case 1:Hr(ge,ge.return);var Le=ge.stateNode;if(typeof Le.componentWillUnmount=="function"){d=ge,l=ge.return;try{r=d,Le.props=r.memoizedProps,Le.state=r.memoizedState,Le.componentWillUnmount()}catch(Me){vt(d,l,Me)}}break;case 5:Hr(ge,ge.return);break;case 22:if(ge.memoizedState!==null){zp(ye);continue}}Pe!==null?(Pe.return=ge,De=Pe):zp(ye)}_e=_e.sibling}e:for(_e=null,ye=n;;){if(ye.tag===5){if(_e===null){_e=ye;try{f=ye.stateNode,oe?(g=f.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(I=ye.stateNode,U=ye.memoizedProps.style,E=U!=null&&U.hasOwnProperty("display")?U.display:null,I.style.display=$e("display",E))}catch(Me){vt(n,n.return,Me)}}}else if(ye.tag===6){if(_e===null)try{ye.stateNode.nodeValue=oe?"":ye.memoizedProps}catch(Me){vt(n,n.return,Me)}}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:Fi(r,n),Vi(n),d&4&&Ap(n);break;case 21:break;default:Fi(r,n),Vi(n)}}function Vi(n){var r=n.flags;if(r&2){try{e:{for(var l=n.return;l!==null;){if(Mp(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&&(st(f,""),d.flags&=-33);var g=jp(n);Tc(n,g,f);break;case 3:case 4:var E=d.stateNode.containerInfo,I=jp(n);jc(n,I,E);break;default:throw Error(i(161))}}catch(U){vt(n,n.return,U)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function cw(n,r,l){De=n,Bp(n)}function Bp(n,r,l){for(var d=(n.mode&1)!==0;De!==null;){var f=De,g=f.child;if(f.tag===22&&d){var E=f.memoizedState!==null||la;if(!E){var I=f.alternate,U=I!==null&&I.memoizedState!==null||Zt;I=la;var oe=Zt;if(la=E,(Zt=U)&&!oe)for(De=f;De!==null;)E=De,U=E.child,E.tag===22&&E.memoizedState!==null?Fp(f):U!==null?(U.return=E,De=U):Fp(f);for(;g!==null;)De=g,Bp(g),g=g.sibling;De=f,la=I,Zt=oe}Op(n)}else(f.subtreeFlags&8772)!==0&&g!==null?(g.return=f,De=g):Op(n)}}function Op(n){for(;De!==null;){var r=De;if((r.flags&8772)!==0){var l=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Zt||ca(5,r);break;case 1:var d=r.stateNode;if(r.flags&4&&!Zt)if(l===null)d.componentDidMount();else{var f=r.elementType===r.type?l.memoizedProps:Oi(r.type,l.memoizedProps);d.componentDidUpdate(f,l.memoizedState,d.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&zf(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}zf(r,E,l)}break;case 5:var I=r.stateNode;if(l===null&&r.flags&4){l=I;var U=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":U.autoFocus&&l.focus();break;case"img":U.src&&(l.src=U.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var oe=r.alternate;if(oe!==null){var _e=oe.memoizedState;if(_e!==null){var ye=_e.dehydrated;ye!==null&&gs(ye)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(i(163))}Zt||r.flags&512&&Mc(r)}catch(ge){vt(r,r.return,ge)}}if(r===n){De=null;break}if(l=r.sibling,l!==null){l.return=r.return,De=l;break}De=r.return}}function zp(n){for(;De!==null;){var r=De;if(r===n){De=null;break}var l=r.sibling;if(l!==null){l.return=r.return,De=l;break}De=r.return}}function Fp(n){for(;De!==null;){var r=De;try{switch(r.tag){case 0:case 11:case 15:var l=r.return;try{ca(4,r)}catch(U){vt(r,l,U)}break;case 1:var d=r.stateNode;if(typeof d.componentDidMount=="function"){var f=r.return;try{d.componentDidMount()}catch(U){vt(r,f,U)}}var g=r.return;try{Mc(r)}catch(U){vt(r,g,U)}break;case 5:var E=r.return;try{Mc(r)}catch(U){vt(r,E,U)}}}catch(U){vt(r,r.return,U)}if(r===n){De=null;break}var I=r.sibling;if(I!==null){I.return=r.return,De=I;break}De=r.return}}var uw=Math.ceil,ua=M.ReactCurrentDispatcher,Ac=M.ReactCurrentOwner,Ri=M.ReactCurrentBatchConfig,Ze=0,At=null,xt=null,Ut=0,_i=0,$r=Cn(0),Dt=0,zs=null,tr=0,da=0,Ic=0,Fs=null,ci=null,Bc=0,Wr=1/0,dn=null,ha=!1,Oc=null,Dn=null,fa=!1,Ln=null,pa=0,Hs=0,zc=null,ma=-1,ga=0;function ii(){return(Ze&6)!==0?bt():ma!==-1?ma:ma=bt()}function Mn(n){return(n.mode&1)===0?1:(Ze&2)!==0&&Ut!==0?Ut&-Ut:VS.transition!==null?(ga===0&&(ga=Mh()),ga):(n=nt,n!==0||(n=window.event,n=n===void 0?16:Hh(n.type)),n)}function Hi(n,r,l,d){if(50<Hs)throw Hs=0,zc=null,Error(i(185));ds(n,l,d),((Ze&2)===0||n!==At)&&(n===At&&((Ze&2)===0&&(da|=l),Dt===4&&jn(n,Ut)),ui(n,d),l===1&&Ze===0&&(r.mode&1)===0&&(Wr=bt()+500,Uo&&En()))}function ui(n,r){var l=n.callbackNode;Vy(n,r);var d=xo(n,n===At?Ut:0);if(d===0)l!==null&&Ph(l),n.callbackNode=null,n.callbackPriority=0;else if(r=d&-d,n.callbackPriority!==r){if(l!=null&&Ph(l),r===1)n.tag===0?qS($p.bind(null,n)):Nf($p.bind(null,n)),$S(function(){(Ze&6)===0&&En()}),l=null;else{switch(jh(d)){case 1:l=_l;break;case 4:l=Dh;break;case 16:l=wo;break;case 536870912:l=Lh;break;default:l=wo}l=Gp(l,Hp.bind(null,n))}n.callbackPriority=r,n.callbackNode=l}}function Hp(n,r){if(ma=-1,ga=0,(Ze&6)!==0)throw Error(i(327));var l=n.callbackNode;if(Ur()&&n.callbackNode!==l)return null;var d=xo(n,n===At?Ut:0);if(d===0)return null;if((d&30)!==0||(d&n.expiredLanes)!==0||r)r=va(n,d);else{r=d;var f=Ze;Ze|=2;var g=Up();(At!==n||Ut!==r)&&(dn=null,Wr=bt()+500,nr(n,r));do try{fw();break}catch(I){Wp(n,I)}while(!0);nc(),ua.current=g,Ze=f,xt!==null?r=0:(At=null,Ut=0,r=Dt)}if(r!==0){if(r===2&&(f=yl(n),f!==0&&(d=f,r=Fc(n,f))),r===1)throw l=zs,nr(n,0),jn(n,d),ui(n,bt()),l;if(r===6)jn(n,d);else{if(f=n.current.alternate,(d&30)===0&&!dw(f)&&(r=va(n,d),r===2&&(g=yl(n),g!==0&&(d=g,r=Fc(n,g))),r===1))throw l=zs,nr(n,0),jn(n,d),ui(n,bt()),l;switch(n.finishedWork=f,n.finishedLanes=d,r){case 0:case 1:throw Error(i(345));case 2:rr(n,ci,dn);break;case 3:if(jn(n,d),(d&130023424)===d&&(r=Bc+500-bt(),10<r)){if(xo(n,0)!==0)break;if(f=n.suspendedLanes,(f&d)!==d){ii(),n.pingedLanes|=n.suspendedLanes&f;break}n.timeoutHandle=ql(rr.bind(null,n,ci,dn),r);break}rr(n,ci,dn);break;case 4:if(jn(n,d),(d&4194240)===d)break;for(r=n.eventTimes,f=-1;0<d;){var E=31-Ai(d);g=1<<E,E=r[E],E>f&&(f=E),d&=~g}if(d=f,d=bt()-d,d=(120>d?120:480>d?480:1080>d?1080:1920>d?1920:3e3>d?3e3:4320>d?4320:1960*uw(d/1960))-d,10<d){n.timeoutHandle=ql(rr.bind(null,n,ci,dn),d);break}rr(n,ci,dn);break;case 5:rr(n,ci,dn);break;default:throw Error(i(329))}}}return ui(n,bt()),n.callbackNode===l?Hp.bind(null,n):null}function Fc(n,r){var l=Fs;return n.current.memoizedState.isDehydrated&&(nr(n,r).flags|=256),n=va(n,r),n!==2&&(r=ci,ci=l,r!==null&&Hc(r)),n}function Hc(n){ci===null?ci=n:ci.push.apply(ci,n)}function dw(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(!Ii(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 jn(n,r){for(r&=~Ic,r&=~da,n.suspendedLanes|=r,n.pingedLanes&=~r,n=n.expirationTimes;0<r;){var l=31-Ai(r),d=1<<l;n[l]=-1,r&=~d}}function $p(n){if((Ze&6)!==0)throw Error(i(327));Ur();var r=xo(n,0);if((r&1)===0)return ui(n,bt()),null;var l=va(n,r);if(n.tag!==0&&l===2){var d=yl(n);d!==0&&(r=d,l=Fc(n,d))}if(l===1)throw l=zs,nr(n,0),jn(n,r),ui(n,bt()),l;if(l===6)throw Error(i(345));return n.finishedWork=n.current.alternate,n.finishedLanes=r,rr(n,ci,dn),ui(n,bt()),null}function $c(n,r){var l=Ze;Ze|=1;try{return n(r)}finally{Ze=l,Ze===0&&(Wr=bt()+500,Uo&&En())}}function ir(n){Ln!==null&&Ln.tag===0&&(Ze&6)===0&&Ur();var r=Ze;Ze|=1;var l=Ri.transition,d=nt;try{if(Ri.transition=null,nt=1,n)return n()}finally{nt=d,Ri.transition=l,Ze=r,(Ze&6)===0&&En()}}function Wc(){_i=$r.current,ct($r)}function nr(n,r){n.finishedWork=null,n.finishedLanes=0;var l=n.timeoutHandle;if(l!==-1&&(n.timeoutHandle=-1,HS(l)),xt!==null)for(l=xt.return;l!==null;){var d=l;switch(Jl(d),d.tag){case 1:d=d.type.childContextTypes,d!=null&&$o();break;case 3:zr(),ct(oi),ct(Gt),dc();break;case 5:cc(d);break;case 4:zr();break;case 13:ct(ft);break;case 19:ct(ft);break;case 10:rc(d.type._context);break;case 22:case 23:Wc()}l=l.return}if(At=n,xt=n=Tn(n.current,null),Ut=_i=r,Dt=0,zs=null,Ic=da=tr=0,ci=Fs=null,Jn!==null){for(r=0;r<Jn.length;r++)if(l=Jn[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}Jn=null}return n}function Wp(n,r){do{var l=xt;try{if(nc(),ea.current=ra,ta){for(var d=pt.memoizedState;d!==null;){var f=d.queue;f!==null&&(f.pending=null),d=d.next}ta=!1}if(er=0,Tt=Pt=pt=null,js=!1,Ts=0,Ac.current=null,l===null||l.return===null){Dt=1,zs=r,xt=null;break}e:{var g=n,E=l.return,I=l,U=r;if(r=Ut,I.flags|=32768,U!==null&&typeof U=="object"&&typeof U.then=="function"){var oe=U,_e=I,ye=_e.tag;if((_e.mode&1)===0&&(ye===0||ye===11||ye===15)){var ge=_e.alternate;ge?(_e.updateQueue=ge.updateQueue,_e.memoizedState=ge.memoizedState,_e.lanes=ge.lanes):(_e.updateQueue=null,_e.memoizedState=null)}var Pe=pp(E);if(Pe!==null){Pe.flags&=-257,mp(Pe,E,I,g,r),Pe.mode&1&&fp(g,oe,r),r=Pe,U=oe;var Le=r.updateQueue;if(Le===null){var Me=new Set;Me.add(U),r.updateQueue=Me}else Le.add(U);break e}else{if((r&1)===0){fp(g,oe,r),Uc();break e}U=Error(i(426))}}else if(dt&&I.mode&1){var kt=pp(E);if(kt!==null){(kt.flags&65536)===0&&(kt.flags|=256),mp(kt,E,I,g,r),tc(Fr(U,I));break e}}g=U=Fr(U,I),Dt!==4&&(Dt=2),Fs===null?Fs=[g]:Fs.push(g),g=E;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var te=dp(g,U,r);Of(g,te);break e;case 1:I=U;var Y=g.type,re=g.stateNode;if((g.flags&128)===0&&(typeof Y.getDerivedStateFromError=="function"||re!==null&&typeof re.componentDidCatch=="function"&&(Dn===null||!Dn.has(re)))){g.flags|=65536,r&=-r,g.lanes|=r;var we=hp(g,I,r);Of(g,we);break e}}g=g.return}while(g!==null)}qp(l)}catch(Ie){r=Ie,xt===l&&l!==null&&(xt=l=l.return);continue}break}while(!0)}function Up(){var n=ua.current;return ua.current=ra,n===null?ra:n}function Uc(){(Dt===0||Dt===3||Dt===2)&&(Dt=4),At===null||(tr&268435455)===0&&(da&268435455)===0||jn(At,Ut)}function va(n,r){var l=Ze;Ze|=2;var d=Up();(At!==n||Ut!==r)&&(dn=null,nr(n,r));do try{hw();break}catch(f){Wp(n,f)}while(!0);if(nc(),Ze=l,ua.current=d,xt!==null)throw Error(i(261));return At=null,Ut=0,Dt}function hw(){for(;xt!==null;)Kp(xt)}function fw(){for(;xt!==null&&!Oy();)Kp(xt)}function Kp(n){var r=Xp(n.alternate,n,_i);n.memoizedProps=n.pendingProps,r===null?qp(n):xt=r,Ac.current=null}function qp(n){var r=n;do{var l=r.alternate;if(n=r.return,(r.flags&32768)===0){if(l=sw(l,r,_i),l!==null){xt=l;return}}else{if(l=ow(l,r),l!==null){l.flags&=32767,xt=l;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{Dt=6,xt=null;return}}if(r=r.sibling,r!==null){xt=r;return}xt=r=n}while(r!==null);Dt===0&&(Dt=5)}function rr(n,r,l){var d=nt,f=Ri.transition;try{Ri.transition=null,nt=1,pw(n,r,l,d)}finally{Ri.transition=f,nt=d}return null}function pw(n,r,l,d){do Ur();while(Ln!==null);if((Ze&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(Yy(n,g),n===At&&(xt=At=null,Ut=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||fa||(fa=!0,Gp(wo,function(){return Ur(),null})),g=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||g){g=Ri.transition,Ri.transition=null;var E=nt;nt=1;var I=Ze;Ze|=4,Ac.current=null,lw(n,l),Ip(l,n),TS(Ul),Ro=!!Wl,Ul=Wl=null,n.current=l,cw(l),zy(),Ze=I,nt=E,Ri.transition=g}else n.current=l;if(fa&&(fa=!1,Ln=n,pa=f),g=n.pendingLanes,g===0&&(Dn=null),$y(l.stateNode),ui(n,bt()),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(ha)throw ha=!1,n=Oc,Oc=null,n;return(pa&1)!==0&&n.tag!==0&&Ur(),g=n.pendingLanes,(g&1)!==0?n===zc?Hs++:(Hs=0,zc=n):Hs=0,En(),null}function Ur(){if(Ln!==null){var n=jh(pa),r=Ri.transition,l=nt;try{if(Ri.transition=null,nt=16>n?16:n,Ln===null)var d=!1;else{if(n=Ln,Ln=null,pa=0,(Ze&6)!==0)throw Error(i(331));var f=Ze;for(Ze|=4,De=n.current;De!==null;){var g=De,E=g.child;if((De.flags&16)!==0){var I=g.deletions;if(I!==null){for(var U=0;U<I.length;U++){var oe=I[U];for(De=oe;De!==null;){var _e=De;switch(_e.tag){case 0:case 11:case 15:Os(8,_e,g)}var ye=_e.child;if(ye!==null)ye.return=_e,De=ye;else for(;De!==null;){_e=De;var ge=_e.sibling,Pe=_e.return;if(Lp(_e),_e===oe){De=null;break}if(ge!==null){ge.return=Pe,De=ge;break}De=Pe}}}var Le=g.alternate;if(Le!==null){var Me=Le.child;if(Me!==null){Le.child=null;do{var kt=Me.sibling;Me.sibling=null,Me=kt}while(Me!==null)}}De=g}}if((g.subtreeFlags&2064)!==0&&E!==null)E.return=g,De=E;else e:for(;De!==null;){if(g=De,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:Os(9,g,g.return)}var te=g.sibling;if(te!==null){te.return=g.return,De=te;break e}De=g.return}}var Y=n.current;for(De=Y;De!==null;){E=De;var re=E.child;if((E.subtreeFlags&2064)!==0&&re!==null)re.return=E,De=re;else e:for(E=Y;De!==null;){if(I=De,(I.flags&2048)!==0)try{switch(I.tag){case 0:case 11:case 15:ca(9,I)}}catch(Ie){vt(I,I.return,Ie)}if(I===E){De=null;break e}var we=I.sibling;if(we!==null){we.return=I.return,De=we;break e}De=I.return}}if(Ze=f,En(),Wi&&typeof Wi.onPostCommitFiberRoot=="function")try{Wi.onPostCommitFiberRoot(bo,n)}catch{}d=!0}return d}finally{nt=l,Ri.transition=r}}return!1}function Vp(n,r,l){r=Fr(l,r),r=dp(n,r,1),n=Rn(n,r,1),r=ii(),n!==null&&(ds(n,1,r),ui(n,r))}function vt(n,r,l){if(n.tag===3)Vp(n,n,l);else for(;r!==null;){if(r.tag===3){Vp(r,n,l);break}else if(r.tag===1){var d=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(Dn===null||!Dn.has(d))){n=Fr(l,n),n=hp(r,n,1),r=Rn(r,n,1),n=ii(),r!==null&&(ds(r,1,n),ui(r,n));break}}r=r.return}}function mw(n,r,l){var d=n.pingCache;d!==null&&d.delete(r),r=ii(),n.pingedLanes|=n.suspendedLanes&l,At===n&&(Ut&l)===l&&(Dt===4||Dt===3&&(Ut&130023424)===Ut&&500>bt()-Bc?nr(n,0):Ic|=l),ui(n,r)}function Yp(n,r){r===0&&((n.mode&1)===0?r=1:(r=Co,Co<<=1,(Co&130023424)===0&&(Co=4194304)));var l=ii();n=ln(n,r),n!==null&&(ds(n,r,l),ui(n,l))}function gw(n){var r=n.memoizedState,l=0;r!==null&&(l=r.retryLane),Yp(n,l)}function vw(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),Yp(n,l)}var Xp;Xp=function(n,r,l){if(n!==null)if(n.memoizedProps!==r.pendingProps||oi.current)li=!0;else{if((n.lanes&l)===0&&(r.flags&128)===0)return li=!1,rw(n,r,l);li=(n.flags&131072)!==0}else li=!1,dt&&(r.flags&1048576)!==0&&Rf(r,qo,r.index);switch(r.lanes=0,r.tag){case 2:var d=r.type;aa(n,r),n=r.pendingProps;var f=Mr(r,Gt.current);Or(r,l),f=pc(null,r,d,n,f,l);var g=mc();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,ai(d)?(g=!0,Wo(r)):g=!1,r.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,ac(r),f.updater=sa,r.stateNode=f,f._reactInternals=r,wc(r,d,n,l),r=xc(null,r,d,!0,g,l)):(r.tag=0,dt&&g&&Ql(r),ti(null,r,f,l),r=r.child),r;case 16:d=r.elementType;e:{switch(aa(n,r),n=r.pendingProps,f=d._init,d=f(d._payload),r.type=d,f=r.tag=yw(d),n=Oi(d,n),f){case 0:r=Cc(null,r,d,n,l);break e;case 1:r=wp(null,r,d,n,l);break e;case 11:r=gp(null,r,d,n,l);break e;case 14:r=vp(null,r,d,Oi(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:Oi(d,f),Cc(n,r,d,f,l);case 1:return d=r.type,f=r.pendingProps,f=r.elementType===d?f:Oi(d,f),wp(n,r,d,f,l);case 3:e:{if(bp(r),n===null)throw Error(i(387));d=r.pendingProps,g=r.memoizedState,f=g.element,Bf(n,r),Jo(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=Fr(Error(i(423)),r),r=kp(n,r,d,l,f);break e}else if(d!==f){f=Fr(Error(i(424)),r),r=kp(n,r,d,l,f);break e}else for(vi=kn(r.stateNode.containerInfo.firstChild),gi=r,dt=!0,Bi=null,l=Af(r,null,d,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Ar(),d===f){r=un(n,r,l);break e}ti(n,r,d,l)}r=r.child}return r;case 5:return Ff(r),n===null&&ec(r),d=r.type,f=r.pendingProps,g=n!==null?n.memoizedProps:null,E=f.children,Kl(d,f)?E=null:g!==null&&Kl(d,g)&&(r.flags|=32),Sp(n,r),ti(n,r,E,l),r.child;case 6:return n===null&&ec(r),null;case 13:return Cp(n,r,l);case 4:return lc(r,r.stateNode.containerInfo),d=r.pendingProps,n===null?r.child=Ir(r,null,d,l):ti(n,r,d,l),r.child;case 11:return d=r.type,f=r.pendingProps,f=r.elementType===d?f:Oi(d,f),gp(n,r,d,f,l);case 7:return ti(n,r,r.pendingProps,l),r.child;case 8:return ti(n,r,r.pendingProps.children,l),r.child;case 12:return ti(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,at(Xo,d._currentValue),d._currentValue=E,g!==null)if(Ii(g.value,E)){if(g.children===f.children&&!oi.current){r=un(n,r,l);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var I=g.dependencies;if(I!==null){E=g.child;for(var U=I.firstContext;U!==null;){if(U.context===d){if(g.tag===1){U=cn(-1,l&-l),U.tag=2;var oe=g.updateQueue;if(oe!==null){oe=oe.shared;var _e=oe.pending;_e===null?U.next=U:(U.next=_e.next,_e.next=U),oe.pending=U}}g.lanes|=l,U=g.alternate,U!==null&&(U.lanes|=l),sc(g.return,l,r),I.lanes|=l;break}U=U.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,I=E.alternate,I!==null&&(I.lanes|=l),sc(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}ti(n,r,f.children,l),r=r.child}return r;case 9:return f=r.type,d=r.pendingProps.children,Or(r,l),f=Ei(f),d=d(f),r.flags|=1,ti(n,r,d,l),r.child;case 14:return d=r.type,f=Oi(d,r.pendingProps),f=Oi(d.type,f),vp(n,r,d,f,l);case 15:return _p(n,r,r.type,r.pendingProps,l);case 17:return d=r.type,f=r.pendingProps,f=r.elementType===d?f:Oi(d,f),aa(n,r),r.tag=1,ai(d)?(n=!0,Wo(r)):n=!1,Or(r,l),cp(r,d,f),wc(r,d,f,l),xc(null,r,d,!0,n,l);case 19:return Ep(n,r,l);case 22:return yp(n,r,l)}throw Error(i(156,r.tag))};function Gp(n,r){return Rh(n,r)}function _w(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 Pi(n,r,l,d){return new _w(n,r,l,d)}function Kc(n){return n=n.prototype,!(!n||!n.isReactComponent)}function yw(n){if(typeof n=="function")return Kc(n)?1:0;if(n!=null){if(n=n.$$typeof,n===T)return 11;if(n===O)return 14}return 2}function Tn(n,r){var l=n.alternate;return l===null?(l=Pi(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 _a(n,r,l,d,f,g){var E=2;if(d=n,typeof n=="function")Kc(n)&&(E=1);else if(typeof n=="string")E=5;else e:switch(n){case B:return sr(l.children,f,g,r);case J:E=8,f|=8;break;case K:return n=Pi(12,l,r,f|2),n.elementType=K,n.lanes=g,n;case N:return n=Pi(13,l,r,f),n.elementType=N,n.lanes=g,n;case P:return n=Pi(19,l,r,f),n.elementType=P,n.lanes=g,n;case W:return ya(l,f,g,r);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case Q:E=10;break e;case X:E=9;break e;case T:E=11;break e;case O:E=14;break e;case $:E=16,d=null;break e}throw Error(i(130,n==null?n:typeof n,""))}return r=Pi(E,l,r,f),r.elementType=n,r.type=d,r.lanes=g,r}function sr(n,r,l,d){return n=Pi(7,n,d,r),n.lanes=l,n}function ya(n,r,l,d){return n=Pi(22,n,d,r),n.elementType=W,n.lanes=l,n.stateNode={isHidden:!1},n}function qc(n,r,l){return n=Pi(6,n,null,r),n.lanes=l,n}function Vc(n,r,l){return r=Pi(4,n.children!==null?n.children:[],n.key,r),r.lanes=l,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}function Sw(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=Sl(0),this.expirationTimes=Sl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Sl(0),this.identifierPrefix=d,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Yc(n,r,l,d,f,g,E,I,U){return n=new Sw(n,r,l,I,U),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Pi(3,null,null,r),n.current=g,g.stateNode=n,g.memoizedState={element:d,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},ac(g),n}function ww(n,r,l){var d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:F,key:d==null?null:""+d,children:n,containerInfo:r,implementation:l}}function Qp(n){if(!n)return xn;n=n._reactInternals;e:{if(Vn(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(ai(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(ai(l))return xf(n,l,r)}return r}function Jp(n,r,l,d,f,g,E,I,U){return n=Yc(l,d,!0,n,f,g,E,I,U),n.context=Qp(null),l=n.current,d=ii(),f=Mn(l),g=cn(d,f),g.callback=r??null,Rn(l,g,f),n.current.lanes=f,ds(n,f,d),ui(n,d),n}function Sa(n,r,l,d){var f=r.current,g=ii(),E=Mn(f);return l=Qp(l),r.context===null?r.context=l:r.pendingContext=l,r=cn(g,E),r.payload={element:n},d=d===void 0?null:d,d!==null&&(r.callback=d),n=Rn(f,r,E),n!==null&&(Hi(n,f,E,g),Qo(n,f,E)),E}function wa(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 Zp(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<r?l:r}}function Xc(n,r){Zp(n,r),(n=n.alternate)&&Zp(n,r)}function bw(){return null}var em=typeof reportError=="function"?reportError:function(n){console.error(n)};function Gc(n){this._internalRoot=n}ba.prototype.render=Gc.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(i(409));Sa(n,r,null,null)},ba.prototype.unmount=Gc.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;ir(function(){Sa(null,n,null,null)}),r[rn]=null}};function ba(n){this._internalRoot=n}ba.prototype.unstable_scheduleHydration=function(n){if(n){var r=Ih();n={blockedOn:null,target:n,priority:r};for(var l=0;l<Sn.length&&r!==0&&r<Sn[l].priority;l++);Sn.splice(l,0,n),l===0&&zh(n)}};function Qc(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function ka(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function tm(){}function kw(n,r,l,d,f){if(f){if(typeof d=="function"){var g=d;d=function(){var oe=wa(E);g.call(oe)}}var E=Jp(r,d,n,0,null,!1,!1,"",tm);return n._reactRootContainer=E,n[rn]=E.current,xs(n.nodeType===8?n.parentNode:n),ir(),E}for(;f=n.lastChild;)n.removeChild(f);if(typeof d=="function"){var I=d;d=function(){var oe=wa(U);I.call(oe)}}var U=Yc(n,0,!1,null,null,!1,!1,"",tm);return n._reactRootContainer=U,n[rn]=U.current,xs(n.nodeType===8?n.parentNode:n),ir(function(){Sa(r,U,l,d)}),U}function Ca(n,r,l,d,f){var g=l._reactRootContainer;if(g){var E=g;if(typeof f=="function"){var I=f;f=function(){var U=wa(E);I.call(U)}}Sa(r,E,n,f)}else E=kw(l,r,n,f,d);return wa(E)}Th=function(n){switch(n.tag){case 3:var r=n.stateNode;if(r.current.memoizedState.isDehydrated){var l=us(r.pendingLanes);l!==0&&(wl(r,l|1),ui(r,bt()),(Ze&6)===0&&(Wr=bt()+500,En()))}break;case 13:ir(function(){var d=ln(n,1);if(d!==null){var f=ii();Hi(d,n,1,f)}}),Xc(n,1)}},bl=function(n){if(n.tag===13){var r=ln(n,134217728);if(r!==null){var l=ii();Hi(r,n,134217728,l)}Xc(n,134217728)}},Ah=function(n){if(n.tag===13){var r=Mn(n),l=ln(n,r);if(l!==null){var d=ii();Hi(l,n,r,d)}Xc(n,r)}},Ih=function(){return nt},Bh=function(n,r){var l=nt;try{return nt=n,r()}finally{nt=l}},Yt=function(n,r,l){switch(r){case"input":if(le(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=Ho(d);if(!f)throw Error(i(90));qe(d),le(d,f)}}}break;case"textarea":be(n,l);break;case"select":r=l.value,r!=null&&q(n,!!l.multiple,r,!1)}},wh=$c,bh=ir;var Cw={usingClientEntryPoint:!1,Events:[Rs,Dr,Ho,yh,Sh,$c]},$s={findFiberByHostInstance:Yn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},xw={bundleType:$s.bundleType,version:$s.version,rendererPackageName:$s.rendererPackageName,rendererConfig:$s.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=Eh(n),n===null?null:n.stateNode},findFiberByHostInstance:$s.findFiberByHostInstance||bw,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 xa=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!xa.isDisabled&&xa.supportsFiber)try{bo=xa.inject(xw),Wi=xa}catch{}}return di.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Cw,di.createPortal=function(n,r){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Qc(r))throw Error(i(200));return ww(n,r,null,l)},di.createRoot=function(n,r){if(!Qc(n))throw Error(i(299));var l=!1,d="",f=em;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onRecoverableError!==void 0&&(f=r.onRecoverableError)),r=Yc(n,1,!1,null,null,l,!1,d,f),n[rn]=r.current,xs(n.nodeType===8?n.parentNode:n),new Gc(r)},di.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=Eh(r),n=n===null?null:n.stateNode,n},di.flushSync=function(n){return ir(n)},di.hydrate=function(n,r,l){if(!ka(r))throw Error(i(200));return Ca(null,n,r,!0,l)},di.hydrateRoot=function(n,r,l){if(!Qc(n))throw Error(i(405));var d=l!=null&&l.hydratedSources||null,f=!1,g="",E=em;if(l!=null&&(l.unstable_strictMode===!0&&(f=!0),l.identifierPrefix!==void 0&&(g=l.identifierPrefix),l.onRecoverableError!==void 0&&(E=l.onRecoverableError)),r=Jp(r,null,n,1,l??null,f,!1,g,E),n[rn]=r.current,xs(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 ba(r)},di.render=function(n,r,l){if(!ka(r))throw Error(i(200));return Ca(null,n,r,!1,l)},di.unmountComponentAtNode=function(n){if(!ka(n))throw Error(i(40));return n._reactRootContainer?(ir(function(){Ca(null,null,n,!1,function(){n._reactRootContainer=null,n[rn]=null})}),!0):!1},di.unstable_batchedUpdates=$c,di.unstable_renderSubtreeIntoContainer=function(n,r,l,d){if(!ka(l))throw Error(i(200));if(n==null||n._reactInternals===void 0)throw Error(i(38));return Ca(n,r,l,!1,d)},di.version="18.3.1-next-f1338f8080-20240426",di}var cm;function Tw(){if(cm)return eu.exports;cm=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(),eu.exports=jw(),eu.exports}var um;function Aw(){if(um)return Ea;um=1;var e=Tw();return Ea.createRoot=e.createRoot,Ea.hydrateRoot=e.hydrateRoot,Ea}var Iw=Aw();const Bw=Wd(Iw);function Ht(e,t,i={}){return fetch(e,{...i,headers:{...i.headers||{},Authorization:`Bearer ${t}`}})}const Lv=e=>`nc_seen_${e}`;async function Ke(e,t,i={}){const s=await Ht(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 pi=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",Vt=(e,t)=>`${pi(e)}/fleet/${t}`,_r=(e,t)=>Ke(Vt(t,"status"),e),Kd=(e,t,i)=>Ke(Vt(i,"up"),e,{method:"POST",body:t}),qa=(e,t,i)=>Ke(Vt(i,"down"),e,{method:"POST",body:t}),Zs=(e,t,i)=>Ke(Vt(i,"restart"),e,{method:"POST",body:{cell:t}}),qd=(e,t)=>Ke(Vt(t,"definitions"),e),Ow=(e,t)=>Ke(Vt(t,"credentials/status"),e),dm=(e,t,i,s)=>Ke(Vt(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:i}}),zw=(e,t,i)=>Ke(Vt(i,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),Fw=(e,t,i)=>Ke(Vt(i,"define-engine"),e,{method:"POST",body:{def:t}}),Hw=(e,t,i,s,o)=>Ke(Vt(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:i,envChanges:s}}),$w=(e,t,i)=>Ke(Vt(i,"remove-engine"),e,{method:"POST",body:{id:t}}),Ww=(e,t,i)=>Ke(Vt(i,"define-cell"),e,{method:"POST",body:{def:t}}),Uw=(e,t,i,s)=>Ke(Vt(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:i}}),Mv=(e,t,i=!1,s)=>Ke(Vt(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:i}}),Kw=(e,t,i)=>Ke(Vt(i,"import-cell"),e,{method:"POST",body:t}),qw=(e,t,i)=>Ke(Vt(i,"restore-cells"),e,{method:"POST",body:{cells:t}}),Vw=(e,t,i,s)=>Ke(Vt(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!i}}),Vd=(e,t,i)=>Ke(`${pi(i)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),jv=(e,t,i,s)=>Ke(`${pi(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!i}}),Tv=(e,t,i)=>Ke(`${pi(i)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),Av=e=>Ke("/api/settings",e),Yw=e=>Ke("/api/nodes",e),Xw=e=>Ke("/api/peers",e),Gw=e=>Ke("/api/topology",e),Iv=(e,t)=>Ke(`${pi(t)}/sessions`,e),Yd=(e,t)=>Ke(`${pi(t)}/config`,e),hm=(e,t)=>Ke(`${pi(t)}/topology`,e),Bv=(e,t)=>Ke("/api/settings/config",e,{method:"POST",body:t}),Qw=e=>Ke("/api/settings/token/rotate",e,{method:"POST"}),Jw=(e,t)=>Ke("/api/settings/nodes/pair",e,{method:"POST",body:t}),fm=(e,t,i=[])=>Ke(`${pi(i)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),Ov=(e,t,i)=>Ke(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:i}}),Zw=(e,t,i)=>Ke(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"PATCH",body:i}),e0=(e,t)=>Ke(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Xd=(e,t,i)=>Ke(`/api/settings/nodes/${encodeURIComponent(t)}/${i}`,e,{method:"POST"}),t0=(e,t,i)=>Ke(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:i}}),pm=(e,t,i,s=[])=>Ke(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:i,selected:s}}),i0=e=>Ke("/api/settings/service/regenerate",e,{method:"POST"}),n0=e=>Ke("/api/settings/update/check",e,{method:"POST"}),r0=e=>Ke("/api/settings/update/apply",e,{method:"POST"}),s0=(e,t=!0)=>Ke(`/api/asks${t?"?open=1":""}`,e),o0=(e,t,i)=>Ke(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:i}}),Na=(e,t=[])=>Ke(`${pi(t)}/decks`,e),mm=(e,t,i=[])=>Ke(`${pi(i)}/decks`,e,{method:"POST",body:{name:t}}),Ra=(e,t,i,s,o=[])=>Ke(`${pi(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:i,expectedRevision:s}}),a0=(e,t,i,s,o=[])=>Ke(`${pi(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:i,expectedRevision:s}}),l0=(e,t,i,s=[])=>Ke(`${pi(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:i}}),c0={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"})]}),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:c0[e]||null})}const u0=["all","pinned","active","off","technical"],zv="nc_sidebar_views_v1",Fv="nc_sidebar_order_v1";function Hv(e){return u0.includes(e)?e:"all"}function d0(e,t=[],i="all"){const s=Hv(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 h0(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 f0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Fv));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 Wn(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function p0(e,t=globalThis.localStorage){try{t.setItem(Fv,JSON.stringify(e))}catch{}return e}function m0(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=Wn(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 g0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(zv));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function gm(e,t){var i,s;return{open:((i=e==null?void 0:e[t])==null?void 0:i.open)!==!1,filter:Hv((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function v0(e,t=globalThis.localStorage){try{t.setItem(zv,JSON.stringify(e))}catch{}return e}function vm(e,t=""){const i=String(t||"").trim().toLocaleLowerCase();return i?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(i):!0}function fr(e=[],t=[],i="all",s=[]){return[...e].filter(o=>d0(o,t,i)).sort((o,a)=>h0(o,a,t,s))}const Gd=["it","en","es"];function _0(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return Gd.includes(t)?t:"en"}catch{return"en"}}const Oa=_0(),$v="nc_lang",qu="nc-lang";function Wv(){return typeof localStorage<"u"?localStorage:null}const Pa={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","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-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","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-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","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-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 Vu(){const e=Wv(),t=e?e.getItem($v):null;return Gd.includes(t)?t:Oa}function y0(e){const t=Wv();if(t)try{t.setItem($v,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(qu))}function v(e){const t=Vu(),i=Pa[t]||Pa[Oa];return Object.prototype.hasOwnProperty.call(i,e)?i[e]:Object.prototype.hasOwnProperty.call(Pa[Oa],e)?Pa[Oa][e]:e}function S0(e){return typeof window>"u"?()=>{}:(window.addEventListener(qu,e),()=>window.removeEventListener(qu,e))}const Uv=Gd;function ki(){return[R.useSyncExternalStore(S0,Vu,Vu),y0]}function Va({cell:e,token:t,route:i=[],onConfirm:s,onClose:o}){var O,$;ki();const a=!!(e&&e.active),c=Array.isArray(i)?i.join("/"):"",[h,m]=R.useState([]),[p,y]=R.useState(!1);R.useEffect(()=>{let W=!0;return(async()=>{if(t)try{const z=await _r(t,c?c.split("/"):[]);if(!W)return;if(y(z.provider==="builtin"&&(z.capabilities||[]).includes("edit")),z.provider==="builtin"&&(z.capabilities||[]).includes("definitions")){const ne=await qd(t,c?c.split("/"):[]);if(!W)return;const H=new Map((z.engines||[]).map(L=>[L.id,L]));m((ne.engines||[]).map(L=>{var A,ie,me,G,Z,ce,de;return{id:L.id,label:L.label||L.id,client:((A=L.managed)==null?void 0:A.client)||"",models:[...new Set([...((ie=H.get(L.id))==null?void 0:ie.models)||[],...((me=L.managedInfo)==null?void 0:me.models)||[]])].filter(Boolean),defaultModel:((G=L.managed)==null?void 0:G.model)||((Z=L.managedInfo)==null?void 0:Z.defaultModel)||"",policyDefault:((ce=L.managed)==null?void 0:ce.permissionPolicy)||((de=L.managed)!=null&&de.client&&L.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{W=!1}},[t,c]);const S=(e==null?void 0:e.engine)||((O=h[0])==null?void 0:O.id)||"",_=W=>(e==null?void 0:e.models)&&e.models[W]||"",C=W=>{const z=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[W];if(z==="standard"||z==="unsafe")return z;const ne=h.find(H=>H.id===W);return ne?ne.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])||"",[j,M]=R.useState(D),[ee,F]=R.useState((e==null?void 0:e.boot)??!0),[B,J]=R.useState(!1),[K,Q]=R.useState(null);R.useEffect(()=>{h.length&&(x(W=>W||S),b(W=>W||_((e==null?void 0:e.engine)||S)||""),M(W=>W==="standard"||W==="unsafe"?W:C((e==null?void 0:e.engine)||S)))},[h.length]);const X=R.useMemo(()=>h.find(W=>W.id===w)||null,[h,w]),T=!!(X&&["claude","codex","codex-vl"].includes(X.client));function N(W){x(W);const z=h.find(ne=>ne.id===W);b(_(W)||(z==null?void 0:z.defaultModel)||""),M(C(W))}async function P(W){W.preventDefault(),J(!0),Q(null);try{if(a)await s({action:"down",boot:ee});else{const z=j==="standard"||j==="unsafe"?j:(X==null?void 0:X.policyDefault)||"standard";await s({action:"up",...p?{engine:w,model:k||"",...T?{permissionPolicy:z}:(X==null?void 0:X.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:ee})}o()}catch(z){Q(String(z&&z.message||z)),J(!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:W=>W.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:ee,onChange:W=>F(W.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:W=>N(W.target.value),children:h.map(W=>u.jsx("option",{value:W.id,children:W.label},W.id))})]}),u.jsxs("label",{className:"nc-field",children:[v("model"),u.jsx("input",{value:k,list:"nc-launch-models",placeholder:v("model-default"),onChange:W=>b(W.target.value)}),u.jsx("datalist",{id:"nc-launch-models",children:((X==null?void 0:X.models)||[]).map(W=>u.jsx("option",{value:W},W))})]}),T?u.jsxs("label",{className:"nc-field",children:[v("permissions"),u.jsxs("select",{value:j,onChange:W=>M(W.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&&j==="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:ee,onChange:W=>F(W.target.checked)}),v("boot-persist")]})]}),K&&u.jsx("div",{className:"nc-err",children:K}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:B,children:v("cancel")}),u.jsx("button",{type:"submit",className:"nc-btn primary",disabled:B,children:v(a?"power-off":"save-and-start")})]})]})})}const _m=/^[a-z0-9-]{1,32}$/;function Ya(e,t){const i=Array.isArray(e)?e:[];return i.length?`${i.map(encodeURIComponent).join("/")}:${t}`:String(t)}function w0(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 ym(e,t,i){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${i}:${s.tmuxSession||s.cell}`}))}function Sm({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"||!_m.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,j=o&&(o[w]||o[_.name]),M=!!(D&&!D.error&&Array.isArray(D.sessions)),ee=!!(j&&j.available===!0&&Array.isArray(j.cells));if(!M&&!ee){a.push({...b,status:"unreachable"});continue}const F=(M?D.sessions:[]).filter(K=>K&&typeof K.name=="string"&&K.name).map(K=>({...K,node:w,route:C,key:`${w}:${K.name}`})),B=ym(j,C,w),J=new Set(B.map(K=>K.tmuxSession).filter(Boolean));a.push({...b,status:"up",sessions:F,cells:B,unmanaged:F.filter(K=>!J.has(K.name)),fleetAvailable:!!(j&&j.available),capabilities:j&&j.capabilities||[],engines:j&&j.engines||[],fleetProvider:j&&j.provider||null,sessionsAvailable:M,inventoryPartial:!M})}for(const _ of Array.isArray(t)?t:[]){if(!_||!Array.isArray(_.route)||_.route.length<1||_.route.some(F=>!_m.test(F)))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 j=(b?x.sessions:[]).filter(F=>F&&typeof F.name=="string"&&F.name).map(F=>({...F,node:C,route:_.route,key:`${C}:${F.name}`})),M=ym(k,_.route,C),ee=new Set(M.map(F=>F.tmuxSession).filter(Boolean));a.push({...w,status:"up",sessions:j,cells:M,unmanaged:j.filter(F=>!ee.has(F.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 b0=4e3;function Qd(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([Yw(e).then(k=>{m=Array.isArray(k.nodes)?k.nodes:[]}).catch(()=>{}),Gw(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 Iv(e,k)}catch{y[b]={error:"unreachable"}}try{S[b]=await _r(e,k)}catch{S[b]={available:!1}}})),!a)return;const w=Sm({nodes:m,topology:p,remote:y,fleet:S,down:o.current});o.current=w0(o.current,w,Math.floor(Date.now()/1e3)),s(Sm({nodes:m,topology:p,remote:y,fleet:S,down:o.current}))}c();const h=setInterval(c,b0);return()=>{a=!1,clearInterval(h)}},[e,t]),i}const wm=52,bm=14;function Hn({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,j,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=(j=k==null?void 0:k.source)==null?void 0:j.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 J,K,Q,X,T,N,P,O,$;const D=h.current;if(!D)return;D.x=k,D.y=b;const j=c==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",M=(K=(J=document.elementFromPoint(k,b))==null?void 0:J.closest)==null?void 0:K.call(J,j),ee=c==="node"?(Q=M==null?void 0:M.dataset)==null?void 0:Q.nodeOrderKey:(X=M==null?void 0:M.dataset)==null?void 0:X.rosterKey,B=(c==="node"||((T=M==null?void 0:M.dataset)==null?void 0:T.position)===e)&&ee&&ee!==t&&a(t,ee);D.over!==(B?M:null)&&((P=(N=D.over)==null?void 0:N.classList)==null||P.remove("nc-roster-over"),D.over=B?M:null,($=(O=D.over)==null?void 0:O.classList)==null||$.add("nc-roster-over")),D.target=B?ee:null},w=()=>{const k=h.current;if(!k){m.current=0;return}const b=k.container;if(b){const D=b.getBoundingClientRect(),j=k.y<D.top+wm?-bm:k.y>D.bottom-wm?bm:0;j&&(b.scrollTop+=j,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),j=k.currentTarget.closest(".nc-side-scroll, .nc-home-scroll");h.current={pointerId:k.pointerId,handle:k.currentTarget,source:D,container:j,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 Jd="nc_pins";function k0(){try{const e=JSON.parse(localStorage.getItem(Jd));return Array.isArray(e)?e:[]}catch{return[]}}function C0(e,t){const i=e.includes(t)?e.filter(s=>s!==t):[...e,t];try{localStorage.setItem(Jd,JSON.stringify(i))}catch{}return i}function x0(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(Jd,JSON.stringify(s))}catch{}return s}function E0(e,t,i){const s=e.indexOf(t);return[s===-1?1e9:s,-(i||0)]}function N0(e,t){return e[0]-t[0]||e[1]-t[1]}function Kv(){const[e,t]=R.useState(k0),[i,s]=R.useState(g0),[o,a]=R.useState(f0),c=_=>t(C=>C0(C,_)),h=_=>gm(i,_),m=(_,C)=>s(w=>{const x={...w,[_]:{...gm(w,_),...C}};return v0(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=>x0(D,C,w));return}a(D=>{var ee;const j=((ee=x.find(F=>F.key===C))==null?void 0:ee.technical)===!0,M=fr(x,e,j?"technical":"all",Wn(D,_)).map(F=>F.key);return p0(m0(D,_,C,w,M))})}}function S(_,C,w,x){var ee;const k=((ee=x.find(F=>F.key===C))==null?void 0:ee.technical)===!0,b=e.includes(C),D=fr(x,e,k?"technical":"all",Wn(o,_)).map(F=>F.key).filter(F=>e.includes(F)===b),j=D.indexOf(C),M=D[j+w];j>=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 qv="nc_node_order_v1",R0=/^[a-f0-9]{16,64}$/;function dr(e){if(R0.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 km(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(qv));return Array.isArray(t)?[...new Set(t.filter(i=>typeof i=="string"&&i&&i.length<=192))].slice(0,128):[]}catch{return[]}}function P0(e,t=globalThis.localStorage){try{t.setItem(qv,JSON.stringify(e))}catch{}return e}function Cm(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(dr(s.group))?i.get(dr(s.group)):Number.MAX_SAFE_INTEGER,c=i.has(dr(o.group))?i.get(dr(o.group)):Number.MAX_SAFE_INTEGER;return a-c||s.index-o.index}).map(({group:s})=>s)}function D0(e,t,i,s=[]){if(!t||!i||t===i)return e;const o=s.map(dr).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 Yu="nexuscrew-node-preferences";function L0(){try{window.dispatchEvent(new Event(Yu))}catch{}}function Vv(){const[e,t]=R.useState(km);R.useEffect(()=>{const a=()=>t(km());return window.addEventListener("storage",a),window.addEventListener(Yu,a),()=>{window.removeEventListener("storage",a),window.removeEventListener(Yu,a)}},[]);const i=a=>Cm(a,e),s=(a,c,h)=>t(m=>{const p=D0(m,a,c,h);return P0(p),L0(),p});return{order:e,groupsFor:i,moveNode:s,stepNode:(a,c,h)=>{const m=Cm(h,e).map(dr),p=m.indexOf(a),y=m[p+c];p>=0&&y&&s(a,y,h)},nodeKey:dr}}function Zr(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 Gr(e){return e.status==="passive"?v("node-passive"):e.status==="down"?e.downSince?v("tunnel-down-since").replace("{t}",Zr(e.downSince)):v("tunnel-down"):e.status==="unreachable"?v("node-unreachable"):e.status==="offline"?e.lastSeen?v("node-offline-seen").replace("{t}",Zr(e.lastSeen)):v("node-offline"):e.status==="needs-repair"?v("node-needs-repair"):""}function Yv(e,{passive:t=null}={}){return e?e.status==="passive"?t:e.status==="healthy"?"on":"warn":null}function Xa(e){return e&&(e.detail||e.status)||""}function Ga(e,t,i=globalThis.localStorage){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const s=Number(i.getItem(Lv(t))||0);return e.outbox.latest>s}function Xv(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 Gv(e,t){return[...new Set([e.engine,e.model,e.key,t.preview,e.preview,t.status].filter(Boolean).map(String))].join(" ")}function Qv(e,t,i,s=globalThis.localStorage){return[...(Array.isArray(e)?e:[]).map(o=>{const a=i.get(o.tmuxSession)||{},c=Ya([],o.tmuxSession),h=Xv(o,a);return{type:"cell",value:o,key:c,label:o.cell,live:!!o.tmux,fresh:Ga(a,c,s),activity:a.activity||0,working:h.working,subtitle:h.subtitle,searchText:Gv(o,a)}}),...(Array.isArray(t)?t:[]).map(o=>{const a=Ya([],o.name);return{type:"session",value:o,key:a,label:o.name,live:!0,technical:o.technical===!0,fresh:Ga(o,a,s),activity:o.activity||0,searchText:`${o.preview||""} ${o.cmd||""}`}})]}function Jv(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=Ya(s,c.tmuxSession||c.cell),p=Xv(c,h);return{type:"cell",value:c,key:m,label:c.cell,live:!!c.tmux,fresh:Ga(h,m,t),activity:h.activity||c.activity||0,working:p.working,subtitle:p.subtitle,searchText:Gv(c,h)}}),...(i.unmanaged||[]).map(c=>{const h=Ya(s,c.name);return{type:"session",value:c,key:h,label:c.name,live:!0,technical:c.technical===!0,fresh:Ga(c,h,t),activity:c.activity||0,searchText:`${c.preview||""} ${c.cmd||""}`}})];return{route:s,rawItems:a}}const Zd=9,Qa=.2,M0=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,es=/^[a-f0-9]{16,64}$/,Xu=e=>M0.test(e)&&new Set(e.split("/")).size===e.split("/").length;function qn(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!Xu(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"&&es.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"&&Xu(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function wi(e){const t=qn(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const Zv=9,e_=24,ho=11,j0=e=>{const t=Number(e);return t>=Zv&&t<=e_?t:ho};function Qr(){return{columns:[]}}function Zi(e){return e.columns.flatMap(t=>t.tiles.map(i=>wi(i)))}function T0(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(wi(o.tiles[s]));return t}const ns=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))});function eh(e,t,i,s){const o=qn(t);if(!o||Zi(e).includes(wi(o))||Zi(e).length>=Zd)return e;const a=ns(e),c={session:o.session,height:1,fontSize:ho,...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 t_(e,t){const i=wi(t);if(!i||Zi(e).includes(i)||Zi(e).length>=Zd)return e;const s=Zi(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 eh(e,t,{col:y,row:e.columns[y].tiles.length})}const a=[...T0(e),i],c=new Map(e.columns.flatMap(y=>y.tiles.map(S=>[wi(S),S]))),h=qn(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 _=qn(y);if(!_)return;const C=c.get(y)||(y===i?h:{})||{},w={session:_.session,height:C.height||1,fontSize:C.fontSize||ho};_.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 Ja(e,t){const i=wi(t),s=ns(e);for(const o of s.columns)o.tiles=o.tiles.filter(a=>wi(a)!==i);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function A0(e,t,i){const s=wi(t);if(!Zi(e).includes(s))return e;const o=e.columns.flatMap(a=>a.tiles).find(a=>wi(a)===s);return eh(Ja(e,s),s,i,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function I0(e,t){if(!(t instanceof Map)||t.size===0)return e;let i=!1;const s=ns(e);for(const o of s.columns)for(const a of o.tiles){const c=t.get(wi(a));if(!c)continue;const h=qn(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?pr(s):e}function B0(e,t,i){const s=ns(e);return s.columns[t]&&(s.columns[t].width=Math.max(Qa,Number(i)||1)),s}function O0(e,t,i,s){const o=ns(e),a=o.columns[t]&&o.columns[t].tiles[i];return a&&(a.height=Math.max(Qa,Number(s)||1)),o}function z0(e,t,i,s){if(!(e.columns[t]&&e.columns[t].tiles[i]))return e;const a=ns(e),c=a.columns[t].tiles[i],h=Number(c.fontSize)||ho;return c.fontSize=Math.max(Zv,Math.min(e_,h+(Number(s)||0))),a}function F0(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 xm(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function pr(e){if(!e||!Array.isArray(e.columns))return Qr();const t=e.columns.map(s=>({width:Math.max(Qa,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"&&Xu(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&es.test(o.ownerId)).map(o=>{const a={session:o.session,height:Math.max(Qa,Number(o.height)||1),fontSize:j0(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(wi(o))&&i.add(wi(o))&&i.size<=Zd);return{columns:t.filter(s=>s.tiles.length>0)}}const i_=/^[a-z0-9-]{1,32}$/,H0=/^[A-Za-z0-9._-]{1,32}$/,$0=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,W0=320;function Gu(e){return typeof e=="string"&&i_.test(e)}const U0=64;function oo(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=U0&&!/[\x00-\x1f\x7f]/.test(t)}function Un(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function n_(e){if(typeof e!="string"||!e||e.length>W0||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:H0.test(e.slice(0,t))&&$0.test(e.slice(t+1))}function Em(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 Nm({name:e,ssh:t,sshPort:i,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,a=typeof t=="string"?t.trim():t;if(!Gu(o))return{ok:!1,error:"err-node-name"};if(!n_(a))return{ok:!1,error:"err-ssh"};const c=Em(i);if(c===void 0)return{ok:!1,error:"err-ssh-port"};const h=Em(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 K0(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 Rm(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?K0(e.since,t):null}}const q0=new Set(["v","instanceId","port","label","invite"]),V0=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function Y0(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 X0(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(Y0(t))}catch{return{ok:!1}}if(!i||typeof i!="object"||Array.isArray(i))return{ok:!1};const s=i.v===1?q0:i.v===2?V0: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"||!i_.test(i.name))return{ok:!1};a.name=i.name}if(i.ssh!==void 0){if(!n_(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 G0(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?Un(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}function Q0({onPick:e,token:t,onSettings:i}){const[s,o]=ki(),a=Qd(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,j]=R.useState([]),[M,ee]=R.useState(null),[F,B]=R.useState(null),{pins:J,orders:K,togglePin:Q,viewFor:X,updateView:T,canMoveRoster:N,moveRoster:P,stepRoster:O}=Kv(),{groupsFor:$,moveNode:W,stepNode:z,nodeKey:ne}=Vv(),H=$(a);async function L(){try{const q=await(await Ht("/api/sessions",t)).json();q.error?(p(q.error),h([])):(p(null),h(q.sessions||[]))}catch(V){p(String(V)),h([])}try{const V=await _r(t);j(V.available?V.cells||[]:[])}catch{j([])}}R.useEffect(()=>{L(),Ht("/api/config",t).then(q=>q.json()).then(q=>{C(q.version||""),x({bind:q.bind||"127.0.0.1",port:q.port||""}),b(es.test(String(q.instanceId||""))?q.instanceId:"")}).catch(()=>{});const V=setInterval(L,4e3);return()=>clearInterval(V)},[]);async function A(){if(!w.port)return;const V=`http://${w.bind}:${w.port}/#token=${t}`;try{await navigator.clipboard.writeText(V)}catch{}}async function ie(V){if(!M)return;const{cell:q}=M,pe=Array.isArray(M.route)?M.route:[];V.action==="up"?await Kd(t,{cell:q,boot:!!V.boot,...V.engine?{engine:V.engine}:{},...V.model!==void 0?{model:V.model}:{},...V.permissionPolicy?{permissionPolicy:V.permissionPolicy}:{}},pe):await qa(t,{cell:q,boot:!!V.boot},pe),L()}async function me(V,q=[]){try{await Vd(t,V,q)}catch{return}L()}async function G(V,q,pe=[]){try{await jv(t,V,q,pe)}catch{return}L()}async function Z(V){if(!(!(V!=null&&V.direct)||F)){B(V.name);try{await Xd(t,V.name,V.tunnelStatus==="up"?"down":"up")}catch{}B(null)}}async function ce(V){if(!(V!=null&&V.direct))return;const q=window.prompt(v("rename-node-prompt"),V.label||V.name);if(q===null)return;const pe=String(q).trim();if(!oo(pe)){window.alert(v("rename-node-invalid"));return}try{await Ov(t,V.name,pe)}catch(ve){window.alert(String((ve==null?void 0:ve.message)||ve))}}const de=R.useMemo(()=>new Map((c||[]).map(V=>[V.name,V])),[c]),Ce=R.useMemo(()=>new Set(D.map(V=>V.tmuxSession)),[D]),Ee=R.useMemo(()=>(c||[]).filter(V=>!Ce.has(V.name)),[c,Ce]),Ve=R.useMemo(()=>Qv(D,Ee,de),[D,Ee,de]),qe=X("local"),xe=R.useMemo(()=>fr(Ve,J,qe.filter,Wn(K,"local")).filter(V=>vm(V,y)),[Ve,J,qe.filter,y,K]),it=H.reduce((V,q)=>V+(q.cells||[]).length+(q.unmanaged||[]).filter(pe=>!pe.technical).length,0),St=fr(Ve,J,"all",Wn(K,"local")).length+it,se=c?c.length:0,le=(c||[]).filter(V=>V.attached).length,Oe=w.port?`${w.bind}:${w.port}`:w.bind;function Te(V,q=null,pe=Ve){var st,he;const ve=Array.isArray(q==null?void 0:q.route)?q.route:[],be=ve.join("/"),ae=be||"local",je=ve.length?q==null?void 0:q.instanceId:k,Ne=Se=>e({session:Se,...be?{node:be}:{},...es.test(String(je||""))?{ownerId:je}:{}}),ze=N;if(V.type==="cell"){const Se=V.value,$e=ve.length?((q==null?void 0:q.sessions)||[]).find(wt=>wt.name===Se.tmuxSession):de.get(Se.tmuxSession),ot=Se.degraded?v("cell-degraded"):V.working?V.subtitle:Se.tmux?v("cell-idle"):v("cell-off"),Rt=ve.length===0||((q==null?void 0:q.capabilities)||[]).includes(Se.active?"down":"up");return u.jsxs("div",{className:"nc-mcard","data-roster-key":V.key,"data-position":ae,children:[u.jsx(Hn,{position:ae,itemKey:V.key,label:Se.cell,canMove:ze,onMove:(wt,ue)=>P(ae,wt,ue,pe),onStep:wt=>O(ae,V.key,wt,pe)}),u.jsxs("button",{className:"nc-mcard-main",onClick:()=>Se.tmux&&Ne(Se.tmuxSession),title:ot,"aria-label":`${Se.cell}, ${ot}`,children:[u.jsx("span",{className:`dot ${Se.degraded?"warn":Se.tmux?`on${V.working?" working":""}`:""}`}),u.jsxs("span",{className:"nc-mcard-text",children:[u.jsx("b",{children:Se.cell}),u.jsx("small",{title:V.subtitle,children:V.subtitle})]})]}),V.activity?u.jsx("span",{className:"nc-rel",children:Zr(V.activity)}):null,V.fresh&&((st=$e==null?void 0:$e.outbox)==null?void 0:st.count)>0&&u.jsx("span",{className:"nc-badge",title:v("new-files-outbox"),children:$e.outbox.count}),u.jsx("button",{className:`nc-act pin${J.includes(V.key)?" on":""}`,"aria-label":`${v("pin")} ${Se.cell}`,title:v("pin"),onClick:()=>Q(V.key),children:J.includes(V.key)?"★":"☆"}),Rt&&u.jsx("button",{className:`nc-act power${Se.tmux?" on":""}${Se.degraded?" warn":""}`,onClick:()=>ee(ve.length?{...Se,route:ve,availableEngines:(q==null?void 0:q.engines)||[]}:Se),title:Se.active?v("power-off"):v("power-on"),"aria-label":`${Se.active?v("power-off"):v("power-on")} ${Se.cell}`,children:u.jsx(et,{name:"power",size:16})})]},V.key)}const Be=V.value;return u.jsxs("div",{className:"nc-mcard","data-roster-key":V.key,"data-position":ae,children:[u.jsx(Hn,{position:ae,itemKey:V.key,label:Be.name,canMove:ze,onMove:(Se,$e)=>P(ae,Se,$e,pe),onStep:Se=>O(ae,V.key,Se,pe)}),u.jsxs("button",{className:"nc-mcard-main",onClick:()=>Ne(Be.name),children:[u.jsx("span",{className:Be.attached?"dot on":"dot"}),u.jsxs("span",{className:"nc-mcard-text",children:[u.jsx("b",{children:Be.name}),u.jsx("small",{children:Be.preview?Be.preview:Be.cmd?Be.cmd:v("windows").replace("{n}",String(Be.windows||0))})]})]}),V.activity?u.jsx("span",{className:"nc-rel",children:Zr(V.activity)}):null,V.fresh&&((he=Be.outbox)==null?void 0:he.count)>0&&u.jsx("span",{className:"nc-badge",title:v("new-files-outbox"),children:Be.outbox.count}),u.jsx("button",{className:`nc-act pin${J.includes(V.key)?" on":""}`,"aria-label":`${v("pin")} ${Be.name}`,title:v("pin"),onClick:()=>Q(V.key),children:J.includes(V.key)?"★":"☆"}),u.jsx("button",{className:`nc-act technical${Be.technical?" on":""}`,title:Be.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${Be.technical?v("mark-normal"):v("mark-technical")} ${Be.name}`,onClick:()=>G(Be.name,!Be.technical,ve),children:"T"}),u.jsx("button",{className:"nc-menu",title:v("terminate"),"aria-label":`${v("terminate")} ${Be.name}`,onClick:()=>{window.confirm(v("terminate-confirm").replace("{name}",Be.name))&&me(Be.name,ve)},children:"⋯"})]},V.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")," · ",se," ",v("sessions"),le>0&&` · ${le} 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:L,title:v("refresh"),children:u.jsx(et,{name:"refresh",size:18})})]})]}),u.jsxs("main",{className:"nc-home-scroll",children:[St>8&&u.jsx("input",{className:"nc-filter",type:"search",placeholder:v("filter-placeholder"),"aria-label":v("filter-placeholder"),value:y,onChange:V=>S(V.target.value)}),m&&u.jsx("div",{className:"nc-err",children:m}),u.jsxs("section",{className:"nc-group","data-position":"local",children:[u.jsx(Pm,{label:v("position-local"),count:xe.length,state:qe,dotClass:"on",onToggle:()=>T("local",{open:!qe.open}),onFilter:V=>T("local",{filter:V})}),qe.open&&xe.map(V=>Te(V,null,Ve)),qe.open&&c===null&&u.jsx("div",{className:"nc-empty",children:v("loading-fleet")}),qe.open&&c!==null&&xe.length===0&&!m&&u.jsx("div",{className:"nc-empty",children:y?v("no-match").replace("{q}",y):v("no-sessions-short")})]}),H.map(V=>{const pe=Yv(V.health,{passive:"warn"})||(V.status==="up"?"on":V.status==="passive"?"":"warn"),ve=V.health?Xa(V.health):V.status==="up"?"":Gr(V),ae=(V.route||[V.name]).join("/"),je=X(ae),{rawItems:Ne}=Jv(V),ze=fr(Ne,J,je.filter,Wn(K,ae)).filter(he=>vm(he,y)),Be=V.direct&&V.health&&V.health.managed!==!1?u.jsx("button",{type:"button",className:`nc-act power${V.tunnelStatus==="up"?" on":""}`,disabled:F===V.name,title:V.tunnelStatus==="up"?v("power-off"):v("power-on"),"aria-label":`${V.tunnelStatus==="up"?v("power-off"):v("power-on")} ${V.label||V.name}`,onClick:()=>Z(V),children:u.jsx(et,{name:"power",size:15})}):null,st=u.jsxs("span",{className:"nc-node-actions",children:[u.jsx(Hn,{scope:"node",position:"nodes",itemKey:ne(V),label:V.label||V.name,onMove:(he,Se)=>W(he,Se,a),onStep:he=>z(ne(V),he,a)}),V.direct&&u.jsx("button",{type:"button",className:"nc-node-rename",title:v("rename-node"),"aria-label":`${v("rename-node")} ${V.label||V.name}`,onClick:()=>ce(V),children:"✎"}),Be]});return u.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":ae,"data-node-order-key":ne(V),children:[u.jsx(Pm,{label:V.label||V.name,count:ze.length,state:je,dotClass:pe,dotTitle:ve,detail:V.status==="up"?"":V.health&&Xa(V.health)||Gr(V),onToggle:()=>T(ae,{open:!je.open}),onFilter:he=>T(ae,{filter:he}),onRename:V.direct?()=>ce(V):null,action:st}),V.status==="up"&&je.open&&ze.map(he=>Te(he,V,Ne)),V.status==="up"&&je.open&&ze.length===0&&u.jsx("div",{className:"nc-empty",children:y?v("no-match").replace("{q}",y):v("no-sessions-short")})]},`nodo-${ae}`)}),u.jsxs("footer",{className:"nc-home-foot",onClick:A,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:[Oe," · ",v("ssh-only")]})]}),u.jsx("span",{className:"nc-lang",onClick:V=>V.stopPropagation(),children:Uv.map((V,q)=>u.jsxs("span",{children:[q>0&&" · ",u.jsx("button",{className:`nc-lang-btn${s===V?" on":""}`,onClick:()=>o(V),title:V,children:V.toUpperCase()})]},V))})]})]}),u.jsx("button",{className:"nc-fab",onClick:()=>i("fleet",!0),title:v("fleet-new-cell"),"aria-label":v("fleet-new-cell"),children:"+"}),M&&u.jsx(Va,{cell:M,token:t,route:Array.isArray(M.route)?M.route:[],onConfirm:ie,onClose:()=>ee(null)})]})}function Pm({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 r_=Object.defineProperty,J0=Object.getOwnPropertyDescriptor,Z0=(e,t)=>{for(var i in t)r_(e,i,{get:t[i],enumerable:!0})},yt=(e,t,i,s)=>{for(var o=s>1?void 0:s?J0(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&&r_(t,i,o),o},Re=(e,t)=>(i,s)=>t(i,s,e),Dm="Terminal input",Qu={get:()=>Dm,set:e=>Dm=e},Lm="Too much output to announce, navigate to rows manually to read",Ju={get:()=>Lm,set:e=>Lm=e};function eb(e){return e.replace(/\r?\n/g,"\r")}function tb(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function ib(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function nb(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");s_(o,t,i,s)}}function s_(e,t,i,s){e=eb(e),e=tb(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function o_(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 Mm(e,t,i,s,o){o_(e,t,i),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Fn(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function al(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 rb=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}},sb=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}},a_="",$n=" ",fo=class l_{constructor(){this.fg=0,this.bg=0,this.extended=new Za}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 l_;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}},Za=class c_{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 c_(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},ji=class u_ extends fo{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Za,this.combinedData=""}static fromCharData(t){let i=new u_;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?Fn(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()]}},jm="di$target",Zu="di$dependencies",nu=new Map;function ob(e){return e[Zu]||[]}function $t(e){if(nu.has(e))return nu.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");ab(t,i,o)};return t._id=e,nu.set(e,t),t}function ab(e,t,i){t[jm]===t?t[Zu].push({id:e,index:i}):(t[Zu]=[{id:e,index:i}],t[jm]=t)}var ri=$t("BufferService"),d_=$t("CoreMouseService"),yr=$t("CoreService"),lb=$t("CharsetService"),th=$t("InstantiationService"),h_=$t("LogService"),si=$t("OptionsService"),f_=$t("OscLinkService"),cb=$t("UnicodeService"),po=$t("DecorationService"),ed=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 ji,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):ub(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)}};ed=yt([Re(0,ri),Re(1,si),Re(2,f_)],ed);function ub(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 ll=$t("CharSizeService"),mn=$t("CoreBrowserService"),ih=$t("MouseService"),gn=$t("RenderService"),db=$t("SelectionService"),p_=$t("CharacterJoinerService"),rs=$t("ThemeService"),m_=$t("LinkProviderService"),hb=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Tm.isErrorNoTelemetry(e)?new Tm(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)}},fb=new hb;function za(e){pb(e)||fb.onUnexpectedError(e)}var td="Canceled";function pb(e){return e instanceof mb?!0:e instanceof Error&&e.name===td&&e.message===td}var mb=class extends Error{constructor(){super(td),this.name=this.message}};function gb(e){return new Error(`Illegal argument: ${e}`)}var Tm=class id extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof id)return t;let i=new id;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},nd=class g_ extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,g_.prototype)}};function yi(e,t=0){return e[e.length-(1+t)]}var vb;(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})(vb||(vb={}));function _b(e,t){let i=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(i,arguments))),o}}var v_;(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 ee=M.length-1;ee>=0;ee--)yield M[ee]}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,ee){let F=0;for(let B of M)if(ee(B,F++))return!0;return!1}e.some=y;function S(M,ee){for(let F of M)if(ee(F))return F}e.find=S;function*_(M,ee){for(let F of M)ee(F)&&(yield F)}e.filter=_;function*C(M,ee){let F=0;for(let B of M)yield ee(B,F++)}e.map=C;function*w(M,ee){let F=0;for(let B of M)yield*ee(B,F++)}e.flatMap=w;function*x(...M){for(let ee of M)yield*ee}e.concat=x;function k(M,ee,F){let B=F;for(let J of M)B=ee(B,J);return B}e.reduce=k;function*b(M,ee,F=M.length){for(ee<0&&(ee+=M.length),F<0?F+=M.length:F>M.length&&(F=M.length);ee<F;ee++)yield M[ee]}e.slice=b;function D(M,ee=Number.POSITIVE_INFINITY){let F=[];if(ee===0)return[F,M];let B=M[Symbol.iterator]();for(let J=0;J<ee;J++){let K=B.next();if(K.done)return[F,e.empty()];F.push(K.value)}return[F,{[Symbol.iterator](){return B}}]}e.consume=D;async function j(M){let ee=[];for await(let F of M)ee.push(F);return Promise.resolve(ee)}e.asyncToArray=j})(v_||(v_={}));function gr(e){if(v_.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 yb(...e){return ht(()=>gr(e))}function ht(e){return{dispose:_b(()=>{e()})}}var __=class y_{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{gr(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?y_.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)}};__.DISABLE_DISPOSED_WARNING=!1;var Kn=__,Qe=class{constructor(){this._store=new Kn,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 ts=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}},pn=typeof window=="object"?window:globalThis,rd=class sd{constructor(t){this.element=t,this.next=sd.Undefined,this.prev=sd.Undefined}};rd.Undefined=new rd(void 0);var mt=rd,Am=class{constructor(){this._first=mt.Undefined,this._last=mt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===mt.Undefined}clear(){let e=this._first;for(;e!==mt.Undefined;){let t=e.next;e.prev=mt.Undefined,e.next=mt.Undefined,e=t}this._first=mt.Undefined,this._last=mt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new mt(e);if(this._first===mt.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!==mt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==mt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==mt.Undefined&&e.next!==mt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===mt.Undefined&&e.next===mt.Undefined?(this._first=mt.Undefined,this._last=mt.Undefined):e.next===mt.Undefined?(this._last=this._last.prev,this._last.next=mt.Undefined):e.prev===mt.Undefined&&(this._first=this._first.next,this._first.prev=mt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==mt.Undefined;)yield e.element,e=e.next}},Sb=globalThis.performance&&typeof globalThis.performance.now=="function",wb=class S_{static create(t){return new S_(t)}constructor(t){this._now=Sb&&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}},qt;(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,O)=>{let $=!1,W;return W=T(z=>{if(!$)return W?W.dispose():$=!0,N.call(P,z)},null,O),$&&W.dispose(),W}}e.once=i;function s(T,N,P){return p((O,$=null,W)=>T(z=>O.call($,N(z)),null,W),P)}e.map=s;function o(T,N,P){return p((O,$=null,W)=>T(z=>{N(z),O.call($,z)},null,W),P)}e.forEach=o;function a(T,N,P){return p((O,$=null,W)=>T(z=>N(z)&&O.call($,z),null,W),P)}e.filter=a;function c(T){return T}e.signal=c;function h(...T){return(N,P=null,O)=>{let $=yb(...T.map(W=>W(z=>N.call(P,z))));return y($,O)}}e.any=h;function m(T,N,P,O){let $=P;return s(T,W=>($=N($,W),$),O)}e.reduce=m;function p(T,N){let P,O={onWillAddFirstListener(){P=T($.fire,$)},onDidRemoveLastListener(){P==null||P.dispose()}},$=new ke(O);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,O=!1,$=!1,W,z){let ne,H,L,A=0,ie,me={leakWarningThreshold:W,onWillAddFirstListener(){ne=T(Z=>{A++,H=N(H,Z),O&&!L&&(G.fire(H),H=void 0),ie=()=>{let ce=H;H=void 0,L=void 0,(!O||A>1)&&G.fire(ce),A=0},typeof P=="number"?(clearTimeout(L),L=setTimeout(ie,P)):L===void 0&&(L=0,queueMicrotask(ie))})},onWillRemoveListener(){$&&A>0&&(ie==null||ie())},onDidRemoveLastListener(){ie=void 0,ne.dispose()}},G=new ke(me);return z==null||z.add(G),G.event}e.debounce=S;function _(T,N=0,P){return e.debounce(T,(O,$)=>O?(O.push($),O):[$],N,void 0,!0,void 0,P)}e.accumulate=_;function C(T,N=(O,$)=>O===$,P){let O=!0,$;return a(T,W=>{let z=O||!N(W,$);return O=!1,$=W,z},P)}e.latch=C;function w(T,N,P){return[e.filter(T,N,P),e.filter(T,O=>!N(O),P)]}e.split=w;function x(T,N=!1,P=[],O){let $=P.slice(),W=T(H=>{$?$.push(H):ne.fire(H)});O&&O.add(W);let z=()=>{$==null||$.forEach(H=>ne.fire(H)),$=null},ne=new ke({onWillAddFirstListener(){W||(W=T(H=>ne.fire(H)),O&&O.add(W))},onDidAddFirstListener(){$&&(N?setTimeout(z):z())},onDidRemoveLastListener(){W&&W.dispose(),W=null}});return O&&O.add(ne),ne.event}e.buffer=x;function k(T,N){return(P,O,$)=>{let W=N(new D);return T(function(z){let ne=W.evaluate(z);ne!==b&&P.call(O,ne)},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 O=P;return this.steps.push($=>(O=N(O,$),O)),this}latch(N=(P,O)=>P===O){let P=!0,O;return this.steps.push($=>{let W=P||!N($,O);return P=!1,O=$,W?$:b}),this}evaluate(N){for(let P of this.steps)if(N=P(N),N===b)break;return N}}function j(T,N,P=O=>O){let O=(...ne)=>z.fire(P(...ne)),$=()=>T.on(N,O),W=()=>T.removeListener(N,O),z=new ke({onWillAddFirstListener:$,onDidRemoveLastListener:W});return z.event}e.fromNodeEventEmitter=j;function M(T,N,P=O=>O){let O=(...ne)=>z.fire(P(...ne)),$=()=>T.addEventListener(N,O),W=()=>T.removeEventListener(N,O),z=new ke({onWillAddFirstListener:$,onDidRemoveLastListener:W});return z.event}e.fromDOMEventEmitter=M;function ee(T){return new Promise(N=>i(T)(N))}e.toPromise=ee;function F(T){let N=new ke;return T.then(P=>{N.fire(P)},()=>{N.fire(void 0)}).finally(()=>{N.dispose()}),N.event}e.fromPromise=F;function B(T,N){return T(P=>N.fire(P))}e.forward=B;function J(T,N,P){return N(P),T(O=>N(O))}e.runAndSubscribe=J;class K{constructor(N,P){this._observable=N,this._counter=0,this._hasChanged=!1;let O={onWillAddFirstListener:()=>{N.addObserver(this)},onDidRemoveLastListener:()=>{N.removeObserver(this)}};this.emitter=new ke(O),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 Q(T,N){return new K(T,N).emitter.event}e.fromObservable=Q;function X(T){return(N,P,O)=>{let $=0,W=!1,z={beginUpdate(){$++},endUpdate(){$--,$===0&&(T.reportChanges(),W&&(W=!1,N.call(P)))},handlePossibleChange(){},handleChange(){W=!0}};T.addObserver(z),T.reportChanges();let ne={dispose(){T.removeObserver(z)}};return O instanceof Kn?O.add(ne):Array.isArray(O)&&O.push(ne),ne}}e.fromObservableLight=X})(qt||(qt={}));var od=class ad{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${ad._idPool++}`,ad.all.add(this)}start(t){this._stopWatch=new wb,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}}};od.all=new Set,od._idPool=0;var bb=od,kb=-1,w_=class b_{constructor(t,i,s=(b_._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 Eb(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}};w_._idPool=1;var Cb=w_,xb=class k_{constructor(t){this.value=t}static create(){let t=new Error;return new k_(t.stack??"")}print(){console.warn(this.value.split(`
58
+ `).slice(2).join(`
59
+ `))}},Eb=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Nb=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Rb=0,ru=class{constructor(e){this.value=e,this.id=Rb++}},Pb=2,Db,ke=class{constructor(e){var t,i,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new Cb((e==null?void 0:e.onListenerError)??za,((i=this._options)==null?void 0:i.leakWarningThreshold)??kb):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new bb(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 Nb(`${S}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((c=this._options)==null?void 0:c.onListenerError)||za)(C),Qe.None}if(this._disposed)return Qe.None;t&&(e=e.bind(t));let s=new ru(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=xb.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof ru?(this._deliveryQueue??(this._deliveryQueue=new Lb),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=ht(()=>{o==null||o(),this._removeListener(s)});return i instanceof Kn?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*Pb<=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)||za;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 ru)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}},Lb=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}},ld=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}};ld.INSTANCE=new ld;var nh=ld;function Mb(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}nh.INSTANCE.onDidChangeZoomLevel;function jb(e){return nh.INSTANCE.getZoomFactor(e)}nh.INSTANCE.onDidChangeFullscreen;var ss=typeof navigator=="object"?navigator.userAgent:"",cd=ss.indexOf("Firefox")>=0,Tb=ss.indexOf("AppleWebKit")>=0,rh=ss.indexOf("Chrome")>=0,Ab=!rh&&ss.indexOf("Safari")>=0;ss.indexOf("Electron/")>=0;ss.indexOf("Android")>=0;var su=!1;if(typeof pn.matchMedia=="function"){let e=pn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=pn.matchMedia("(display-mode: fullscreen)");su=e.matches,Mb(pn,e,({matches:i})=>{su&&t.matches||(su=i)})}var Xr="en",ud=!1,dd=!1,Fa=!1,C_=!1,Da,Ha=Xr,Im=Xr,Ib,$i,mr=globalThis,Kt,Rv;typeof mr.vscode<"u"&&typeof mr.vscode.process<"u"?Kt=mr.vscode.process:typeof process<"u"&&typeof((Rv=process==null?void 0:process.versions)==null?void 0:Rv.node)=="string"&&(Kt=process);var Pv,Bb=typeof((Pv=Kt==null?void 0:Kt.versions)==null?void 0:Pv.electron)=="string",Ob=Bb&&(Kt==null?void 0:Kt.type)==="renderer",Dv;if(typeof Kt=="object"){ud=Kt.platform==="win32",dd=Kt.platform==="darwin",Fa=Kt.platform==="linux",Fa&&Kt.env.SNAP&&Kt.env.SNAP_REVISION,Kt.env.CI||Kt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Da=Xr,Ha=Xr;let e=Kt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Da=t.userLocale,Im=t.osLocale,Ha=t.resolvedLanguage||Xr,Ib=(Dv=t.languagePack)==null?void 0:Dv.translationsConfigFile}catch{}C_=!0}else typeof navigator=="object"&&!Ob?($i=navigator.userAgent,ud=$i.indexOf("Windows")>=0,dd=$i.indexOf("Macintosh")>=0,($i.indexOf("Macintosh")>=0||$i.indexOf("iPad")>=0||$i.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Fa=$i.indexOf("Linux")>=0,($i==null?void 0:$i.indexOf("Mobi"))>=0,Ha=globalThis._VSCODE_NLS_LANGUAGE||Xr,Da=navigator.language.toLowerCase(),Im=Da):console.error("Unable to resolve platform.");var x_=ud,en=dd,zb=Fa,Bm=C_,nn=$i,In=Ha,Fb;(e=>{function t(){return In}e.value=t;function i(){return In.length===2?In==="en":In.length>=3?In[0]==="e"&&In[1]==="n"&&In[2]==="-":!1}e.isDefaultVariant=i;function s(){return In==="en"}e.isDefault=s})(Fb||(Fb={}));var Hb=typeof mr.postMessage=="function"&&!mr.importScripts;(()=>{if(Hb){let e=[];mr.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}),mr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var $b=!!(nn&&nn.indexOf("Chrome")>=0);nn&&nn.indexOf("Firefox")>=0;!$b&&nn&&nn.indexOf("Safari")>=0;nn&&nn.indexOf("Edg/")>=0;nn&&nn.indexOf("Android")>=0;var Kr=typeof navigator=="object"?navigator:{};Bm||document.queryCommandSupported&&document.queryCommandSupported("copy")||Kr&&Kr.clipboard&&Kr.clipboard.writeText,Bm||Kr&&Kr.clipboard&&Kr.clipboard.readText;var sh=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}},ou=new sh,Om=new sh,zm=new sh,Wb=new Array(230),E_;(e=>{function t(h){return ou.keyCodeToStr(h)}e.toString=t;function i(h){return ou.strToKeyCode(h)}e.fromString=i;function s(h){return Om.keyCodeToStr(h)}e.toUserSettingsUS=s;function o(h){return zm.keyCodeToStr(h)}e.toUserSettingsGeneral=o;function a(h){return Om.strToKeyCode(h)||zm.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 ou.keyCodeToStr(h)}e.toElectronAccelerator=c})(E_||(E_={}));var Ub=class N_{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 N_&&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 Kb([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Kb=class{constructor(e){if(e.length===0)throw gb("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 qb(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return E_.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(cd)switch(t){case 59:return 85;case 60:if(zb)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(en)return 57;break}else if(Tb&&(en&&t===93||!en&&t===92))return 57;return Wb[t]||0}var Vb=en?256:2048,Yb=512,Xb=1024,Gb=en?2048:256,Fm=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=qb(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|=Vb),this.altKey&&(t|=Yb),this.shiftKey&&(t|=Xb),this.metaKey&&(t|=Gb),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Ub(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Hm=new WeakMap;function Qb(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 Jb=class{static getSameOriginWindowChain(e){let t=Hm.get(e);if(!t){t=[],Hm.set(e,t);let i=e,s;do s=Qb(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}}},La=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=Jb.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},$m=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(rh){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?cd&&!en?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof a.wheelDeltaX<"u")Ab&&x_?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?cd&&!en?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()}},R_=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Zb;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof e1?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:qt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:R_})})(Zb||(Zb={}));var e1=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?R_:(this._emitter||(this._emitter=new ke),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},oh=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 nd("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new nd("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},t1=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 nd("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=ht(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},i1;(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})(i1||(i1={}));var Wm=class Li{static fromArray(t){return new Li(i=>{i.emitMany(t)})}static fromPromise(t){return new Li(async i=>{i.emitMany(await t)})}static fromPromises(t){return new Li(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new Li(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 qt.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 Li(async s=>{for await(let o of t)s.emitOne(i(o))})}map(t){return Li.map(this,t)}static filter(t,i){return new Li(async s=>{for await(let o of t)i(o)&&s.emitOne(o)})}filter(t){return Li.filter(this,t)}static coalesce(t){return Li.filter(t,i=>!!i)}coalesce(){return Li.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return Li.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())}};Wm.EMPTY=Wm.fromArray([]);var{getWindow:Ji,getWindowId:n1,onDidRegisterWindow:r1}=(function(){let e=new Map,t={window:pn,disposables:new Kn};e.set(pn.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 Kn,m={window:c,disposables:h.add(new Kn)};return e.set(c.vscodeWindowId,m),h.add(ht(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),h.add(Ue(c,Bt.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:pn},getDocument(c){return Ji(c).document}}})(),s1=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 Ue(e,t,i,s){return new s1(e,t,i,s)}var Um=function(e,t,i,s){return Ue(e,t,i,s)},ah,o1=class extends t1{constructor(e){super(),this.defaultTarget=e&&Ji(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Km=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){za(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(Km.sort),c.shift().execute();s.set(a,!1)};ah=(a,c,h=0)=>{let m=n1(a),p=new Km(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 a1(e){let t=e.getBoundingClientRect(),i=Ji(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var Bt={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},l1=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=hi(t);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let i=hi(t);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(t){let i=hi(t);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(t){let i=hi(t);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(t){let i=hi(t);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(t){let i=hi(t);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(t){let i=hi(t);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(t){let i=hi(t);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let i=hi(t);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let i=hi(t);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let i=hi(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=hi(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=hi(t);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let i=hi(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 hi(e){return typeof e=="number"?`${e}px`:e}function so(e){return new l1(e)}var P_=class{constructor(){this._hooks=new Kn,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(ht(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=Ji(e)}this._hooks.add(Ue(a,Bt.POINTER_MOVE,c=>{if(c.buttons!==i){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(Ue(a,Bt.POINTER_UP,c=>this.stopMonitoring(!0)))}};function c1(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 Qi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Qi||(Qi={}));var eo=class ei extends Qe{constructor(){super(),this.dispatched=!1,this.targets=new Am,this.ignoreTargets=new Am,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(qt.runAndSubscribe(r1,({window:t,disposables:i})=>{i.add(Ue(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(Ue(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(Ue(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:pn,disposables:this._store}))}static addTarget(t){if(!ei.isTouchDevice())return Qe.None;ei.INSTANCE||(ei.INSTANCE=new ei);let i=ei.INSTANCE.targets.push(t);return ht(i)}static ignoreTarget(t){if(!ei.isTouchDevice())return Qe.None;ei.INSTANCE||(ei.INSTANCE=new ei);let i=ei.INSTANCE.ignoreTargets.push(t);return ht(i)}static isTouchDevice(){return"ontouchstart"in pn||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(Qi.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<ei.HOLD_DELAY&&Math.abs(m.initialPageX-yi(m.rollingPageX))<30&&Math.abs(m.initialPageY-yi(m.rollingPageY))<30){let y=this.newGestureEvent(Qi.Tap,m.initialTarget);y.pageX=yi(m.rollingPageX),y.pageY=yi(m.rollingPageY),this.dispatchEvent(y)}else if(p>=ei.HOLD_DELAY&&Math.abs(m.initialPageX-yi(m.rollingPageX))<30&&Math.abs(m.initialPageY-yi(m.rollingPageY))<30){let y=this.newGestureEvent(Qi.Contextmenu,m.initialTarget);y.pageX=yi(m.rollingPageX),y.pageY=yi(m.rollingPageY),this.dispatchEvent(y)}else if(o===1){let y=yi(m.rollingPageX),S=yi(m.rollingPageY),_=yi(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(Qi.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===Qi.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>ei.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===Qi.Change||t.type===Qi.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=ah(t,()=>{let y=Date.now(),S=y-s,_=0,C=0,w=!0;o+=ei.SCROLL_FRICTION*S,h+=ei.SCROLL_FRICTION*S,o>0&&(w=!1,_=a*o*S),h>0&&(w=!1,C=m*h*S);let x=this.newGestureEvent(Qi.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(Qi.Change,c.initialTarget);h.translationX=a.pageX-yi(c.rollingPageX),h.translationY=a.pageY-yi(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)}};eo.SCROLL_FRICTION=-.005,eo.HOLD_DELAY=700,eo.CLEAR_TAP_COUNT_TIME=400,yt([c1],eo,"isTouchDevice",1);var u1=eo,lh=class extends Qe{onclick(e,t){this._register(Ue(e,Bt.CLICK,i=>t(new La(Ji(e),i))))}onmousedown(e,t){this._register(Ue(e,Bt.MOUSE_DOWN,i=>t(new La(Ji(e),i))))}onmouseover(e,t){this._register(Ue(e,Bt.MOUSE_OVER,i=>t(new La(Ji(e),i))))}onmouseleave(e,t){this._register(Ue(e,Bt.MOUSE_LEAVE,i=>t(new La(Ji(e),i))))}onkeydown(e,t){this._register(Ue(e,Bt.KEY_DOWN,i=>t(new Fm(i))))}onkeyup(e,t){this._register(Ue(e,Bt.KEY_UP,i=>t(new Fm(i))))}oninput(e,t){this._register(Ue(e,Bt.INPUT,t))}onblur(e,t){this._register(Ue(e,Bt.BLUR,t))}onfocus(e,t){this._register(Ue(e,Bt.FOCUS,t))}onchange(e,t){this._register(Ue(e,Bt.CHANGE,t))}ignoreGesture(e){return u1.ignoreTarget(e)}},qm=11,d1=class extends lh{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=qm+"px",this.domNode.style.height=qm+"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 P_),this._register(Um(this.bgDomNode,Bt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Um(this.domNode,Bt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new o1),this._pointerdownScheduleRepeatTimer=this._register(new oh)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Ji(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()}},h1=class hd{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 hd(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 hd(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}}},f1=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 h1(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 Ym(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=Ym.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)))}},Vm=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function au(e,t){let i=t-e;return function(s){return e+i*g1(s)}}function p1(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var Ym=class fd{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),p1(au(t,o),au(a,i),.33)}return au(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 Vm(s,o,!1)}return new Vm(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return fd.start(t,i,s)}static start(t,i,s){s=s+10;let o=Date.now()-10;return new fd(t,i,o,s)}};function m1(e){return Math.pow(e,3)}function g1(e){return 1-m1(1-e)}var v1=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 oh)}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":"")))}},_1=140,D_=class extends lh{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 v1(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new P_),this._shouldRender=!0,this.domNode=so(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(Ue(this.domNode.domNode,Bt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new d1(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=so(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(Ue(this.slider.domNode,Bt.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,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=a1(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(x_&&c>_1){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()}},L_=class pd{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 pd(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=pd._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)}},y1=class extends D_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new L_(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}},S1=class extends D_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new L_(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}},w1=500,Xm=50,b1=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},md=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(rh){let i=Ji(t.browserEvent),s=jb(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 b1(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}};md.INSTANCE=new md;var k1=md,C1=class extends lh{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=E1(t),this._scrollable=i,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let s={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new S1(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new y1(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=so(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=so(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=so(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 oh),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=gr(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,en&&(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 $m(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=gr(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new $m(i))};this._mouseWheelToDispose.push(Ue(this._listenOnDomNode,Bt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=k1.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=!en&&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=Xm*a,S=m.scrollTop-(y<0?Math.floor(y):Math.ceil(y));this._verticalScrollbar.writeScrollPosition(p,S)}if(c){let y=Xm*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(),w1)}},x1=class extends C1{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function E1(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,en&&(t.className+=" mac"),t}var gd=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 f1({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>ah(s.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{m.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new x1(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(qt.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ht(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ht(()=>this._styleElement.remove())),this._register(qt.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}};gd=yt([Re(2,ri),Re(3,mn),Re(4,d_),Re(5,rs),Re(6,si),Re(7,gn)],gd);var vd=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(ht(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};vd=yt([Re(1,ri),Re(2,mn),Re(3,po),Re(4,gn)],vd);var N1=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Yi={full:0,left:0,center:0,right:0},Bn={full:0,left:0,center:0,right:0},Us={full:0,left:0,center:0,right:0},el=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 N1,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(p=this._viewportElement.parentElement)==null||p.insertBefore(this._canvas,this._viewportElement),this._register(ht(()=>{var 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);Bn.full=this._canvas.width,Bn.left=e,Bn.center=t,Bn.right=e,this._refreshDrawHeightConstants(),Us.full=1,Us.left=1,Us.center=1+Bn.left,Us.right=1+Bn.left+Bn.center}_refreshDrawHeightConstants(){Yi.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);Yi.left=t,Yi.center=t,Yi.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yi.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yi.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yi.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yi.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(Us[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Yi[e.position||"full"]/2),Bn[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Yi[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}))}};el=yt([Re(2,ri),Re(3,po),Re(4,gn),Re(5,si),Re(6,rs),Re(7,mn)],el);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 $a;(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="Ÿ"))($a||($a={}));var M_;(e=>e.ST=`${fe.ESC}\\`)(M_||(M_={}));var _d=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)}}};_d=yt([Re(2,ri),Re(3,si),Re(4,yr),Re(5,gn)],_d);var Ot=0,zt=0,Ft=0,_t=0,Gm={css:"#00000000",rgba:0},Nt;(e=>{function t(o,a,c,h){return h!==void 0?`#${or(o)}${or(a)}${or(c)}${or(h)}`:`#${or(o)}${or(a)}${or(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})(Nt||(Nt={}));var ut;(e=>{function t(m,p){if(_t=(p.rgba&255)/255,_t===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;Ot=C+Math.round((y-C)*_t),zt=w+Math.round((S-w)*_t),Ft=x+Math.round((_-x)*_t);let k=Nt.toCss(Ot,zt,Ft),b=Nt.toRgba(Ot,zt,Ft);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=Wa.ensureContrastRatio(m.rgba,p.rgba,y);if(S)return Nt.toColor(S>>24&255,S>>16&255,S>>8&255)}e.ensureContrastRatio=s;function o(m){let p=(m.rgba|255)>>>0;return[Ot,zt,Ft]=Wa.toChannels(p),{css:Nt.toCss(Ot,zt,Ft),rgba:p}}e.opaque=o;function a(m,p){return _t=Math.round(p*255),[Ot,zt,Ft]=Wa.toChannels(m.rgba),{css:Nt.toCss(Ot,zt,Ft,_t),rgba:Nt.toRgba(Ot,zt,Ft,_t)}}e.opacity=a;function c(m,p){return _t=m.rgba&255,a(m,_t*p/255)}e.multiplyOpacity=c;function h(m){return[m.rgba>>24&255,m.rgba>>16&255,m.rgba>>8&255]}e.toColorRGB=h})(ut||(ut={}));var gt;(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 Ot=parseInt(o.slice(1,2).repeat(2),16),zt=parseInt(o.slice(2,3).repeat(2),16),Ft=parseInt(o.slice(3,4).repeat(2),16),Nt.toColor(Ot,zt,Ft);case 5:return Ot=parseInt(o.slice(1,2).repeat(2),16),zt=parseInt(o.slice(2,3).repeat(2),16),Ft=parseInt(o.slice(3,4).repeat(2),16),_t=parseInt(o.slice(4,5).repeat(2),16),Nt.toColor(Ot,zt,Ft,_t);case 7:return{css:o,rgba:(parseInt(o.slice(1),16)<<8|255)>>>0};case 9:return{css:o,rgba:parseInt(o.slice(1),16)>>>0}}let 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 Ot=parseInt(a[1]),zt=parseInt(a[2]),Ft=parseInt(a[3]),_t=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),Nt.toColor(Ot,zt,Ft,_t);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ot,zt,Ft,_t]=t.getImageData(0,0,1,1).data,_t!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Nt.toRgba(Ot,zt,Ft,_t),css:o}}e.toColor=s})(gt||(gt={}));var ni;(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})(ni||(ni={}));var Wa;(e=>{function t(c,h){if(_t=(h&255)/255,_t===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 Ot=S+Math.round((m-S)*_t),zt=_+Math.round((p-_)*_t),Ft=C+Math.round((y-C)*_t),Nt.toRgba(Ot,zt,Ft)}e.blend=t;function i(c,h,m){let p=ni.relativeLuminance(c>>8),y=ni.relativeLuminance(h>>8);if(hn(p,y)<m){if(y<p){let C=s(c,h,m),w=hn(p,ni.relativeLuminance(C>>8));if(w<m){let x=o(c,h,m),k=hn(p,ni.relativeLuminance(x>>8));return w>k?C:x}return C}let S=o(c,h,m),_=hn(p,ni.relativeLuminance(S>>8));if(_<m){let C=s(c,h,m),w=hn(p,ni.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=hn(ni.relativeLuminance2(_,C,w),ni.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=hn(ni.relativeLuminance2(_,C,w),ni.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=hn(ni.relativeLuminance2(_,C,w),ni.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=hn(ni.relativeLuminance2(_,C,w),ni.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})(Wa||(Wa={}));function or(e){let t=e.toString(16);return t.length<2?"0"+t:t}function hn(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var R1=class extends fo{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()]}},tl=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ji}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||$n.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++)tl._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||$n.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}};tl=yt([Re(0,ri)],tl);function P1(e){return 57508<=e&&e<=57558}function D1(e){return 9472<=e&&e<=9631}function L1(e){return P1(e)||D1(e)}function M1(){return{css:{canvas:Ma(),cell:Ma()},device:{canvas:Ma(),cell:Ma(),char:{width:0,height:0,left:0,top:0}}}}function Ma(){return{width:0,height:0}}var yd=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 ji,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,j=0,M=0,ee=0,F=!1,B=0,J=!1,K=0,Q=0,X=[],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 O=!1,$=N>=Q,W=N,z=this._workCell;if(_.length>0&&N===_[0][0]&&$){let xe=_.shift(),it=this._isCellInSelection(xe[0],t);for(D=xe[0]+1;D<xe[1];D++)$&&($=it===this._isCellInSelection(D,t));$&&($=!i||a<xe[0]||a>=xe[1]),$?(O=!0,z=new R1(this._workCell,e.translateToString(!0,xe[0],xe[1]),xe[1]-xe[0]),W=xe[1]-1,P=z.getWidth()):Q=xe[1]}let ne=this._isCellInSelection(N,t),H=i&&N===a,L=T&&N>=p&&N<=y,A=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,xe=>{A=!0});let ie=z.getChars()||$n;if(ie===" "&&(z.isUnderline()||z.isOverline())&&(ie=" "),K=P*h-m.get(ie,z.isBold(),z.isItalic()),!x)x=this._document.createElement("span");else if(k&&(ne&&J||!ne&&!J&&z.bg===j)&&(ne&&J&&C.selectionForeground||z.fg===M)&&z.extended.ext===ee&&L===F&&K===B&&!H&&!O&&!A&&$){z.isInvisible()?b+=$n:b+=ie,k++;continue}else k&&(x.textContent=b),x=this._document.createElement("span"),k=0,b="";if(j=z.bg,M=z.fg,ee=z.extended.ext,F=L,B=K,J=ne,O&&a>=N&&a<=W&&(a=N),!this._coreService.isCursorHidden&&H&&this._coreService.isCursorInitialized){if(X.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&X.push("xterm-cursor-blink"),X.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":X.push("xterm-cursor-outline");break;case"block":X.push("xterm-cursor-block");break;case"bar":X.push("xterm-cursor-bar");break;case"underline":X.push("xterm-cursor-underline");break}}if(z.isBold()&&X.push("xterm-bold"),z.isItalic()&&X.push("xterm-italic"),z.isDim()&&X.push("xterm-dim"),z.isInvisible()?b=$n:b=z.getChars()||$n,z.isUnderline()&&(X.push(`xterm-underline-${z.extended.underlineStyle}`),b===" "&&(b=" "),!z.isUnderlineColorDefault()))if(z.isUnderlineColorRGB())x.style.textDecorationColor=`rgb(${fo.toColorRGB(z.getUnderlineColor()).join(",")})`;else{let xe=z.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&z.isBold()&&xe<8&&(xe+=8),x.style.textDecorationColor=C.ansi[xe].css}z.isOverline()&&(X.push("xterm-overline"),b===" "&&(b=" ")),z.isStrikethrough()&&X.push("xterm-strikethrough"),L&&(x.style.textDecoration="underline");let me=z.getFgColor(),G=z.getFgColorMode(),Z=z.getBgColor(),ce=z.getBgColorMode(),de=!!z.isInverse();if(de){let xe=me;me=Z,Z=xe;let it=G;G=ce,ce=it}let Ce,Ee,Ve=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,xe=>{xe.options.layer!=="top"&&Ve||(xe.backgroundColorRGB&&(ce=50331648,Z=xe.backgroundColorRGB.rgba>>8&16777215,Ce=xe.backgroundColorRGB),xe.foregroundColorRGB&&(G=50331648,me=xe.foregroundColorRGB.rgba>>8&16777215,Ee=xe.foregroundColorRGB),Ve=xe.options.layer==="top")}),!Ve&&ne&&(Ce=this._coreBrowserService.isFocused?C.selectionBackgroundOpaque:C.selectionInactiveBackgroundOpaque,Z=Ce.rgba>>8&16777215,ce=50331648,Ve=!0,C.selectionForeground&&(G=50331648,me=C.selectionForeground.rgba>>8&16777215,Ee=C.selectionForeground)),Ve&&X.push("xterm-decoration-top");let qe;switch(ce){case 16777216:case 33554432:qe=C.ansi[Z],X.push(`xterm-bg-${Z}`);break;case 50331648:qe=Nt.toColor(Z>>16,Z>>8&255,Z&255),this._addStyle(x,`background-color:#${Qm((Z>>>0).toString(16),"0",6)}`);break;case 0:default:de?(qe=C.foreground,X.push("xterm-bg-257")):qe=C.background}switch(Ce||z.isDim()&&(Ce=ut.multiplyOpacity(qe,.5)),G){case 16777216:case 33554432:z.isBold()&&me<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(me+=8),this._applyMinimumContrast(x,qe,C.ansi[me],z,Ce,void 0)||X.push(`xterm-fg-${me}`);break;case 50331648:let xe=Nt.toColor(me>>16&255,me>>8&255,me&255);this._applyMinimumContrast(x,qe,xe,z,Ce,Ee)||this._addStyle(x,`color:#${Qm(me.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(x,qe,C.foreground,z,Ce,Ee)||de&&X.push("xterm-fg-257")}X.length&&(x.className=X.join(" "),X.length=0),!H&&!O&&!A&&$?k++:x.textContent=b,K!==this.defaultSpacing&&(x.style.letterSpacing=`${K}px`),S.push(x),N=W}return x&&k&&(x.textContent=b),S}_applyMinimumContrast(e,t,i,s,o,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||L1(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=ut.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]}};yd=yt([Re(1,p_),Re(2,si),Re(3,mn),Re(4,yr),Re(5,po),Re(6,rs)],yd);function Qm(e,t,i){for(;e.length<i;)e=t+e;return e}var j1=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}},T1=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 A1(){return new T1}var lu="xterm-dom-renderer-owner-",Di="xterm-rows",ja="xterm-fg-",Jm="xterm-bg-",Ks="xterm-focus",Ta="xterm-selection",I1=1,Sd=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=I1++,this._rowElements=[],this._selectionRenderModel=A1(),this.onRequestRedraw=this._register(new ke).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Di),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(Ta),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=M1(),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(yd,document),this._element.classList.add(lu+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(w=>this._handleLinkHover(w))),this._register(this._linkifier2.onHideLinkUnderline(w=>this._handleLinkLeave(w))),this._register(ht(()=>{this._element.classList.remove(lu+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new j1(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} .${Di} 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} .${Di} { 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} .${Di} .xterm-dim { color: ${ut.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} .${Di}.${Ks} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Di}.${Ks} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Di}.${Ks} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Di} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Di} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Di} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Di} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Di} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ta} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ta} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ta} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[a,c]of e.ansi.entries())t+=`${this._terminalSelector} .${ja}${a} { color: ${c.css}; }${this._terminalSelector} .${ja}${a}.xterm-dim { color: ${ut.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Jm}${a} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${ja}257 { color: ${ut.opaque(e.background).css}; }${this._terminalSelector} .${ja}257.xterm-dim { color: ${ut.multiplyOpacity(ut.opaque(e.background),.5).css}; }${this._terminalSelector} .${Jm}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(Ks),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ks),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`.${lu}${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))}}};Sd=yt([Re(7,th),Re(8,ll),Re(9,si),Re(10,ri),Re(11,yr),Re(12,mn),Re(13,rs)],Sd);var wd=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 O1(this._optionsService))}catch{this._measureStrategy=this._register(new B1(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())}};wd=yt([Re(2,si)],wd);var j_=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)}},B1=class extends j_{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}},O1=class extends j_{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}},z1=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 F1(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(qt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ue(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ue(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}},F1=class extends Qe{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ts),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(ht(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ue(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)}},H1=class extends Qe{constructor(){super(),this.linkProviders=[],this._register(ht(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function ch(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 $1(e,t,i,s,o,a,c,h,m){if(!a)return;let p=ch(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 bd=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,o){return $1(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let i=ch(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])}}};bd=yt([Re(0,gn),Re(1,ll)],bd);var W1=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=[]}},T_={};Z0(T_,{getSafariVersion:()=>K1,isChromeOS:()=>O_,isFirefox:()=>A_,isIpad:()=>q1,isIphone:()=>V1,isLegacyEdge:()=>U1,isLinux:()=>uh,isMac:()=>il,isNode:()=>cl,isSafari:()=>I_,isWindows:()=>B_});var cl=typeof process<"u"&&"title"in process,mo=cl?"node":navigator.userAgent,go=cl?"node":navigator.platform,A_=mo.includes("Firefox"),U1=mo.includes("Edge"),I_=/^((?!chrome|android).)*safari/i.test(mo);function K1(){if(!I_)return 0;let e=mo.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var il=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(go),q1=go==="iPad",V1=go==="iPhone",B_=["Windows","Win16","Win32","WinCE"].includes(go),uh=go.indexOf("Linux")>=0,O_=/\bCrOS\b/.test(mo),z_=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()}},Y1=class extends z_{_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())}}},X1=class extends z_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},nl=!cl&&"requestIdleCallback"in window?X1:Y1,G1=class{constructor(){this._queue=new nl}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},kd=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 ts),this._pausedResizeTask=new G1,this._observerDisposable=this._register(new ts),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 W1((p,y)=>this._renderRows(p,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Q1(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ht(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var p;return(p=this._renderer.value)==null?void 0:p.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(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=ht(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};kd=yt([Re(2,si),Re(3,ll),Re(4,yr),Re(5,po),Re(6,ri),Re(7,mn),Re(8,rs)],kd);var Q1=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 J1(e,t,i,s){let o=i.buffer.x,a=i.buffer.y;if(!i.buffer.hasScrollback)return tk(o,a,e,t,i,s)+ul(a,t,i,s)+ik(o,a,e,t,i,s);let c;if(a===t)return c=o>e?"D":"C",lo(Math.abs(o-e),ao(c,s));c=a>t?"D":"C";let h=Math.abs(a-t),m=ek(a>t?e:o,i)+(h-1)*i.cols+1+Z1(a>t?o:e);return lo(m,ao(c,s))}function Z1(e,t){return e-1}function ek(e,t){return t.cols-e}function tk(e,t,i,s,o,a){return ul(t,s,o,a).length===0?"":lo(H_(e,t,e,t-vr(t,o),!1,o).length,ao("D",a))}function ul(e,t,i,s){let o=e-vr(e,i),a=t-vr(t,i),c=Math.abs(o-a)-nk(e,t,i);return lo(c,ao(F_(e,t),s))}function ik(e,t,i,s,o,a){let c;ul(t,s,o,a).length>0?c=s-vr(s,o):c=t;let h=s,m=rk(e,t,i,s,o,a);return lo(H_(e,c,i,h,m==="C",o).length,ao(m,a))}function nk(e,t,i){var c;let s=0,o=e-vr(e,i),a=t-vr(t,i);for(let h=0;h<Math.abs(o-a);h++){let m=F_(e,t)==="A"?-1:1;(c=i.buffer.lines.get(o+m*h))!=null&&c.isWrapped&&s++}return s}function vr(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 rk(e,t,i,s,o,a){let c;return ul(i,s,o,a).length>0?c=s-vr(s,o):c=t,e<i&&c<=s||e>=i&&c<s?"C":"D"}function F_(e,t){return e>t?"A":"B"}function H_(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 ao(e,t){let i=t?"O":"[";return fe.ESC+i+e}function lo(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var sk=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 Zm(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 cu=50,ok=15,ak=50,lk=500,ck=" ",uk=new RegExp(ck,"g"),Cd=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 ji,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 sk(this._bufferService),this._activeSelectionMode=0,this._register(ht(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(p=>{p.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],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(uk," ")).join(B_?`\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())),uh&&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=Zm(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=ch(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,-cu),cu),t/=cu,t/Math.abs(t)+Math.round(t*(ok-1)))}shouldForceSelection(e){return il?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(),ak)}_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&&!(il&&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<lk&&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=J1(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 j=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,k--):j>1&&(_+=j-1,h-=j-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 j=this._workCell.getChars().length;this._workCell.getWidth()===2?(S++,b++):j>1&&(C+=j-1,m+=j-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=Zm(i,this._bufferService.cols)}};Cd=yt([Re(3,ri),Re(4,yr),Re(5,ih),Re(6,si),Re(7,gn),Re(8,mn)],Cd);var eg=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={}}},tg=class{constructor(){this._color=new eg,this._css=new eg}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()}},Lt=Object.freeze((()=>{let e=[gt.toColor("#2e3436"),gt.toColor("#cc0000"),gt.toColor("#4e9a06"),gt.toColor("#c4a000"),gt.toColor("#3465a4"),gt.toColor("#75507b"),gt.toColor("#06989a"),gt.toColor("#d3d7cf"),gt.toColor("#555753"),gt.toColor("#ef2929"),gt.toColor("#8ae234"),gt.toColor("#fce94f"),gt.toColor("#729fcf"),gt.toColor("#ad7fa8"),gt.toColor("#34e2e2"),gt.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:Nt.toCss(s,o,a),rgba:Nt.toRgba(s,o,a)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:Nt.toCss(s,s,s),rgba:Nt.toRgba(s,s,s)})}return e})()),lr=gt.toColor("#ffffff"),to=gt.toColor("#000000"),ig=gt.toColor("#ffffff"),ng=to,qs={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},dk=lr,xd=class extends Qe{constructor(e){super(),this._optionsService=e,this._contrastCache=new tg,this._halfContrastCache=new tg,this._onChangeColors=this._register(new ke),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:lr,background:to,cursor:ig,cursorAccent:ng,selectionForeground:void 0,selectionBackgroundTransparent:qs,selectionBackgroundOpaque:ut.blend(to,qs),selectionInactiveBackgroundTransparent:qs,selectionInactiveBackgroundOpaque:ut.blend(to,qs),scrollbarSliderBackground:ut.opacity(lr,.2),scrollbarSliderHoverBackground:ut.opacity(lr,.4),scrollbarSliderActiveBackground:ut.opacity(lr,.5),overviewRulerBorder:lr,ansi:Lt.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=rt(e.foreground,lr),t.background=rt(e.background,to),t.cursor=ut.blend(t.background,rt(e.cursor,ig)),t.cursorAccent=ut.blend(t.background,rt(e.cursorAccent,ng)),t.selectionBackgroundTransparent=rt(e.selectionBackground,qs),t.selectionBackgroundOpaque=ut.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=rt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ut.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?rt(e.selectionForeground,Gm):void 0,t.selectionForeground===Gm&&(t.selectionForeground=void 0),ut.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ut.opacity(t.selectionBackgroundTransparent,.3)),ut.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ut.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=rt(e.scrollbarSliderBackground,ut.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=rt(e.scrollbarSliderHoverBackground,ut.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=rt(e.scrollbarSliderActiveBackground,ut.opacity(t.foreground,.5)),t.overviewRulerBorder=rt(e.overviewRulerBorder,dk),t.ansi=Lt.slice(),t.ansi[0]=rt(e.black,Lt[0]),t.ansi[1]=rt(e.red,Lt[1]),t.ansi[2]=rt(e.green,Lt[2]),t.ansi[3]=rt(e.yellow,Lt[3]),t.ansi[4]=rt(e.blue,Lt[4]),t.ansi[5]=rt(e.magenta,Lt[5]),t.ansi[6]=rt(e.cyan,Lt[6]),t.ansi[7]=rt(e.white,Lt[7]),t.ansi[8]=rt(e.brightBlack,Lt[8]),t.ansi[9]=rt(e.brightRed,Lt[9]),t.ansi[10]=rt(e.brightGreen,Lt[10]),t.ansi[11]=rt(e.brightYellow,Lt[11]),t.ansi[12]=rt(e.brightBlue,Lt[12]),t.ansi[13]=rt(e.brightMagenta,Lt[13]),t.ansi[14]=rt(e.brightCyan,Lt[14]),t.ansi[15]=rt(e.brightWhite,Lt[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]=rt(e.extendedAnsi[s],Lt[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()}}};xd=yt([Re(0,si)],xd);function rt(e,t){if(e!==void 0)try{return gt.toColor(e)}catch{}return t}var hk=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)}},fk=class{constructor(){this._services=new hk,this._services.set(th,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=ob(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)}},pk={trace:0,debug:1,info:2,warn:3,error:4,off:5},mk="xterm.js: ",Ed=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=pk[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?"":mk)+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)}};Ed=yt([Re(0,si)],Ed);var rg=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,Et=Object.freeze(new fo),Aa=0,uu=2,io=class $_{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Ge);let o=i||ji.fromCharData([0,a_,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?Fn(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?Fn(i&2097151):""}isProtected(t){return this._data[t*Ge+2]&536870912}loadCell(t,i){return Aa=t*Ge,i.content=this._data[Aa+0],i.fg=this._data[Aa+1],i.bg=this._data[Aa+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]+=Fn(i):o&2097151?(this._combined[t]=Fn(o&2097151)+Fn(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 ji;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 ji;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*uu<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*uu<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*uu<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 $_(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?Fn(h):$n;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 gk(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,_=co(y,S,t),C=1,w=0;for(;C<y.length;){let k=co(y,C,t),b=k-w,D=i-_,j=Math.min(b,D);y[S].copyCellsFrom(y[C],w,_,j,!1),_+=j,_===i&&(S++,_=0),w+=j,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 vk(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 _k(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 yk(e,t,i){let s=[],o=e.map((m,p)=>co(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=co(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 co(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 W_=class U_{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=U_._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(),gr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};W_._nextId=1;var Sk=W_,jt={},cr=jt.B;jt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};jt.A={"#":"£"};jt.B=void 0;jt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};jt.C=jt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};jt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};jt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};jt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};jt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};jt.E=jt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};jt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};jt.H=jt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};jt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var sg=4294967295,og=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=Et.clone(),this.savedCharset=cr,this.markers=[],this._nullCell=ji.fromCharData([0,a_,1,0]),this._whitespaceCell=ji.fromCharData([0,$n,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new nl,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new rg(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 Za),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 Za),this._whitespaceCell}getBlankLine(e,t){return new io(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>sg?sg:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Et);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 rg(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(Et),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 io(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 io(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=gk(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Et),i);if(s.length>0){let o=vk(this.lines,s);_k(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(Et),o=i;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new io(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(Et),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 j=this.ybase+this.y;if(j>=c&&j<c+m.length)continue}let p=m[m.length-1].getTrimmedLength(),y=yk(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 j=0;j<S;j++){let M=this.getBlankLine(Et,!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 j=Math.min(b,x);if(m[w]===void 0)break;if(m[w].copyCellsFrom(m[k],b-j,x-j,j,!0),x-=j,x===0&&(w--,x=y[w]),b-=j,b===0){k--;let M=Math.max(k,0);b=co(m,M,this._cols)}}for(let j=0;j<m.length;j++)y[j]<e&&m[j].setCell(y[j],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 Sk(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)}},wk=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 og(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new og(!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)}},K_=2,q_=1,Nd=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,K_),this.rows=Math.max(e.rawOptions.rows||0,q_),this.buffers=this._register(new wk(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))}};Nd=yt([Re(0,si)],Nd);var qr={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:il,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},bk=["normal","bold","100","200","300","400","500","600","700","800","900"],kk=class extends Qe{constructor(e){super(),this._onOptionChange=this._register(new ke),this.onOptionChange=this._onOptionChange.event;let t={...qr};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ht(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in qr))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in qr))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=qr[e]),!Ck(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=qr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=bk.includes(t)?t:qr[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 Ck(e){return e==="block"||e==="underline"||e==="bar"}function no(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]&&no(e[s],t-1);return i}var ag=Object.freeze({insertMode:!1}),lg=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Rd=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=no(ag),this.decPrivateModes=no(lg)}reset(){this.modes=no(ag),this.decPrivateModes=no(lg)}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))}};Rd=yt([Re(0,ri),Re(1,h_),Re(2,si)],Rd);var cg={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 du(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 hu=String.fromCharCode,ug={DEFAULT:e=>{let t=[du(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${hu(t[0])}${hu(t[1])}${hu(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${du(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${du(e,!0)};${e.x};${e.y}${t}`}},Pd=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(cg))this.addProtocol(s,cg[s]);for(let s of Object.keys(ug))this.addEncoding(s,ug[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)}};Pd=yt([Re(0,ri),Re(1,yr),Re(2,si)],Pd);var fu=[[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]],xk=[[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]],Mt;function Ek(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 Nk=class{constructor(){if(this.version="6",!Mt){Mt=new Uint8Array(65536),Mt.fill(1),Mt[0]=0,Mt.fill(0,1,32),Mt.fill(0,127,160),Mt.fill(2,4352,4448),Mt[9001]=2,Mt[9002]=2,Mt.fill(2,11904,42192),Mt[12351]=1,Mt.fill(2,44032,55204),Mt.fill(2,63744,64256),Mt.fill(2,65040,65050),Mt.fill(2,65072,65136),Mt.fill(2,65280,65377),Mt.fill(2,65504,65511);for(let e=0;e<fu.length;++e)Mt.fill(0,fu[e][0],fu[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Mt[e]:Ek(e,xk)?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=hr.extractWidth(t);o===0?s=!1:o>i&&(i=o)}return hr.createPropertyValue(0,i,s)}},hr=class Ua{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ke,this.onChange=this._onChange.event;let t=new Nk;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=Ua.extractWidth(h);Ua.extractShouldJoin(h)&&(m-=Ua.extractWidth(s)),i+=m,s=h}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},Rk=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 dg(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 Vs=2147483647,Pk=256,V_=class Dd{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>Pk)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 Dd;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 Dd(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>Vs?Vs: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>Vs?Vs: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,Vs):t}},Ys=[],Dk=class{constructor(){this._state=0,this._active=Ys,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=Ys}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=Ys,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Ys,!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",al(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=Ys,this._id=-1,this._state=0}}},Si=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+=al(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}},Xs=[],Lk=class{constructor(){this._handlers=Object.create(null),this._active=Xs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Xs}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=Xs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Xs,!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",al(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=Xs,this._ident=0}},ro=new V_;ro.addParam(0);var hg=class{constructor(e){this._handler=e,this._data="",this._params=ro,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ro,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=al(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=ro,this._data="",this._hitLimit=!1,i));return this._params=ro,this._data="",this._hitLimit=!1,t}},Mk=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}},Mi=160,jk=(function(){let e=new Mk(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(Mi,0,2,0),e.add(Mi,8,5,8),e.add(Mi,6,0,6),e.add(Mi,11,0,11),e.add(Mi,13,13,13),e})(),Tk=class extends Qe{constructor(e=jk){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 V_,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ht(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Dk),this._dcsParser=this._register(new Lk),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:Mi)],o>>4){case 2:for(let _=h+1;;++_){if(_>=t||(s=e[_])<32||s>126&&s<Mi){this._printHandler(e,h,_),h=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Mi){this._printHandler(e,h,_),h=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Mi){this._printHandler(e,h,_),h=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Mi){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<Mi){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<Mi){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}}},Ak=/^([\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})$/,Ik=/^[\da-f]+$/;function fg(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=Ak.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),Ik.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 pu(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 Bk(e,t=16){let[i,s,o]=e;return`rgb:${pu(i,t)}/${pu(s,t)}/${pu(o,t)}`}var Ok={"(":0,")":1,"*":2,"+":3,"-":1,".":2},On=131072,pg=10;function mg(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 gg=5e3,vg=0,zk=class extends Qe{constructor(e,t,i,s,o,a,c,h,m=new Tk){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 rb,this._utf8Decoder=new sb,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Et.clone(),this._eraseAttrDataInternal=Et.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 Ld(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($a.IND,()=>this.index()),this._parser.setExecuteHandler($a.NEL,()=>this.nextLine()),this._parser.setExecuteHandler($a.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Si(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new Si(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new Si(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new Si(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new Si(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new Si(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new Si(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new Si(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new Si(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new Si(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new Si(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new Si(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 jt)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 hg((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"),gg))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${gg} 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>On&&(a=this._parseStack.position+On)}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<On&&(this._parseBuffer=new Uint32Array(Math.min(e.length,On))),c||this._dirtyRowTracker.clearRange(),e.length>On)for(let p=a;p<e.length;p+=On){let y=p+On<e.length?p+On: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=hr.extractWidth(w);let x=hr.extractShouldJoin(w),k=x?hr.extractWidth(_):0;if(_=w,c&&this._onA11yChar.fire(Fn(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 io&&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=>mg(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new hg(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Si(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(Et));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=hr.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,cr),this._charsetService.setgCharset(1,cr),this._charsetService.setgCharset(2,cr),this._charsetService.setgCharset(3,cr);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|=fo.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=Et.fg,e.bg=Et.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|=Et.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=Et.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|=Et.fg&16777215,s.bg&=-67108864,s.bg|=Et.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=Et.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(!mg(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>pg&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>pg&&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(_g(a))if(o==="?")t.push({type:0,index:a});else{let c=fg(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=fg(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]);_g(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,cr),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Ok[e[0]],jt[e[1]]||cr),!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=Et.clone(),this._eraseAttrDataInternal=Et.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 ji;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)}},Ld=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&&(vg=e,e=t,t=vg),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Ld=yt([Re(0,ri)],Ld);function _g(e){return 0<=e&&e<256}var Fk=5e7,yg=12,Hk=50,$k=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>Fk)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>=yg?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>=yg)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Hk&&(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()}},Md=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)))}};Md=yt([Re(0,ri)],Md);var Sg=!1,Wk=class extends Qe{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ts),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 fk,this.optionsService=this._register(new kk(e)),this._instantiationService.setService(si,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Nd)),this._instantiationService.setService(ri,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ed)),this._instantiationService.setService(h_,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Rd)),this._instantiationService.setService(yr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Pd)),this._instantiationService.setService(d_,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(hr)),this._instantiationService.setService(cb,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Rk),this._instantiationService.setService(lb,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Md),this._instantiationService.setService(f_,this._oscLinkService),this._inputHandler=this._register(new zk(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(qt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(qt.forward(this._bufferService.onResize,this._onResize)),this._register(qt.forward(this.coreService.onData,this._onData)),this._register(qt.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 $k((t,i)=>this._inputHandler.parse(t,i))),this._register(qt.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&&!Sg&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Sg=!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,K_),t=Math.max(t,q_),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(dg.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(dg(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ht(()=>{for(let t of e)t.dispose()})}}},Uk={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 Kk(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=Uk[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 Ct=0,qk=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new nl,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new nl,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||(Ct=this._search(t),Ct===-1)||this._getKey(this._array[Ct])!==t)return!1;do if(this._array[Ct]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ct),!0;while(++Ct<this._array.length&&this._getKey(this._array[Ct])===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&&(Ct=this._search(e),!(Ct<0||Ct>=this._array.length)&&this._getKey(this._array[Ct])===e))do yield this._array[Ct];while(++Ct<this._array.length&&this._getKey(this._array[Ct])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ct=this._search(e),!(Ct<0||Ct>=this._array.length)&&this._getKey(this._array[Ct])===e))do t(this._array[Ct]);while(++Ct<this._array.length&&this._getKey(this._array[Ct])===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}},mu=0,wg=0,Vk=class extends Qe{constructor(){super(),this._decorations=new qk(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(ht(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Yk(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=>{mu=o.options.x??0,wg=mu+(o.options.width??1),e>=mu&&e<wg&&(!i||(o.options.layer??"bottom")===i)&&s(o)})}},Yk=class extends Kn{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=gt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=gt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Xk=1e3,Gk=class{constructor(e,t=Xk){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)}},bg=20,rl=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 Gk(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(Ue(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ht(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<bg+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
65
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===bg+1&&(this._liveRegion.textContent+=Ju.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})`}};rl=yt([Re(1,th),Re(2,mn),Re(3,gn)],rl);var jd=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(ht(()=>{var a;gr(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(Ue(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ue(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ue(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ue(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&&Qk(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,gr(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}}};jd=yt([Re(1,ih),Re(2,gn),Re(3,ri),Re(4,m_)],jd);function Qk(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 Jk=class extends Wk{constructor(e={}){super(e),this._linkifier=this._register(new ts),this.browser=T_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ts),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(Vk),this._instantiationService.setService(po,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(H1),this._instantiationService.setService(m_,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ed)),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(qt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(qt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(qt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(qt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ht(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let o=ut.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${fe.ESC}]${s};${Bk(o)}${M_.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(a=>a.ansi[t.index]=Nt.toColor(...t.color));else{let a=i;this._themeService.modifyColors(c=>c[a]=Nt.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(rl,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(Ue(this.element,"copy",t=>{this.hasSelection()&&ib(t,this._selectionService)}));let e=t=>nb(t,this.textarea,this.coreService,this.optionsService);this._register(Ue(this.textarea,"paste",e)),this._register(Ue(this.element,"paste",e)),A_?this._register(Ue(this.element,"mousedown",t=>{t.button===2&&Mm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ue(this.element,"contextmenu",t=>{Mm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),uh&&this._register(Ue(this.element,"auxclick",t=>{t.button===1&&o_(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ue(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ue(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ue(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ue(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ue(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ue(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ue(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(Ue(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",Qu.get()),O_||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(z1,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(mn,this._coreBrowserService),this._register(Ue(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(Ue(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(wd,this._document,this._helperContainer),this._instantiationService.setService(ll,this._charSizeService),this._themeService=this._instantiationService.createInstance(xd),this._instantiationService.setService(rs,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(tl),this._instantiationService.setService(p_,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(kd,this.rows,this.screenElement)),this._instantiationService.setService(gn,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(_d,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(bd),this._instantiationService.setService(ih,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(jd,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(gd,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(Cd,this.element,this.screenElement,s)),this._instantiationService.setService(db,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(qt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var a;this._selectionService.refresh(),(a=this._viewport)==null||a.queueSync()})),this._register(this._instantiationService.createInstance(vd,this.screenElement)),this._register(Ue(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(rl,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(el,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(el,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Sd,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(Ue(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(Ue(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){s_(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=Kk(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)&&(Zk(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(Et));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 Zk(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var eC=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)}},tC=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 ji)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},kg=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 tC(t)}getNullCell(){return new ji}},iC=class extends Qe{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ke),this.onBufferChange=this._onBufferChange.event,this._normal=new kg(this._core.buffers.normal,"normal"),this._alternate=new kg(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)}},nC=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)}},rC=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}},sC=["cols","rows"],Xi=0,oC=class extends Qe{constructor(e){super(),this._core=this._register(new Jk(e)),this._addonManager=this._register(new eC),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(sC.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 nC(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new rC(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 iC(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 Qu.get()},set promptLabel(e){Qu.set(e)},get tooMuchOutput(){return Ju.get()},set tooMuchOutput(e){Ju.set(e)}}}_verifyIntegers(...e){for(Xi of e)if(Xi===1/0||isNaN(Xi)||Xi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Xi of e)if(Xi&&(Xi===1/0||isNaN(Xi)||Xi%1!==0||Xi<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 aC=2,lC=1,cC=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(aC,Math.floor(y/e.css.cell.width)),rows:Math.max(lC,Math.floor(p/e.css.cell.height))}}};function uC(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function dC({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}${uC(t,i)}`;let x=null,k=!1,b=!1,D=null,j=0,M=h;const ee=()=>{if(k||b||D)return;const B=Math.min(5e3,Math.max(0,S)*2**Math.min(j++,5));D=setTimeout(()=>{D=null,F()},B)},F=()=>{if(k||b)return;const B=new WebSocket(w);x=B,B.binaryType="arraybuffer",B.onopen=()=>{if(x!==B||k)return;j=0;const J={type:"attach",session:e,token:i,cols:s,rows:o,readonly:a};c!==void 0&&(J.takeSize=c),B.send(JSON.stringify(J)),M!==void 0&&B.send(JSON.stringify({type:"focus",on:!!M}))},B.onmessage=J=>{if(!(x!==B||k))if(typeof J.data=="string"){let K;try{K=JSON.parse(J.data)}catch{return}K.type==="exit"&&(b=!0,p&&p(K.code)),K.type==="files"&&y&&y(K)}else m&&m(new Uint8Array(J.data))},B.onerror=()=>{if(x===B)try{B.close()}catch{}},B.onclose=J=>{x!==B||k||b||[1e3,1002,4401,4404].includes(J==null?void 0:J.code)||ee()}};return F(),{sendInput:B=>{if(!x||x.readyState!==1)return!1;try{return x.send(typeof B=="string"?new TextEncoder().encode(B):B),!0}catch{try{x.close()}catch{}return!1}},isReady:()=>!!x&&x.readyState===1,resize:(B,J)=>{s=B,o=J,(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"resize",cols:B,rows:J}))},action:B=>{(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"action",name:B}))},focus:B=>{M=B,(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"focus",on:!!B}))},close:()=>{if(k=!0,D&&clearTimeout(D),D=null,x)try{x.close()}catch{}},get raw(){return x}}}async function Cg(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 hC="\r";function fC(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 pC({isReady:e,paste:t,send:i}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:i(hC)!==!1}catch{return!1}}}function mC(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function gC(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}const vC=450,xg=8;function _C(e,t,i,s){return Math.abs(Number(i)-Number(e))>xg||Math.abs(Number(s)-Number(t))>xg}const yC=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function gu(e){return e?e.files&&e.files.length>0||Array.from(e.items||[]).some(t=>t&&t.kind==="file")?!0:Array.from(e.types||[]).includes("Files"):!1}function Eg(e){if(!e)return[];const t=Array.from(e.files||[]).filter(Boolean);return t.length?t:Array.from(e.items||[]).filter(i=>i&&i.kind==="file"&&typeof i.getAsFile=="function").map(i=>i.getAsFile()).filter(Boolean)}function SC(e,t=0,i=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=yC.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${i}-${t+1}.${o}`}async function Y_({files:e,token:t,session:i,node:s="",paste:o=!0,fetchImpl:a=Ht,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=pi(s?String(s).split("/"):[]);for(let _=0;_<m.length;_+=1){const C=m[_],w=SC(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 X_({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 j=R.useRef(C);j.current=C;const[M,ee]=R.useState(""),[F,B]=R.useState(""),[J,K]=R.useState(null),Q=async()=>{var P,O,$,W;const T=((O=(P=k.current)==null?void 0:P.term)==null?void 0:O.getSelection())||M;if(!T){B(v("copy-empty")),setTimeout(()=>B(""),1500);return}const N=await Cg(T);B(v(N?"copied":"copy-manual")),N&&((W=($=k.current)==null?void 0:$.term)==null||W.clearSelection(),w==null||w(!1)),setTimeout(()=>B(""),1800)},X=R.useRef(Q);return X.current=Q,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 oC({cursorBlink:!0,fontSize:b.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),N=new cC;T.loadAddon(N),T.open(x.current),N.fit();const P=new TextDecoder;let O;try{O=dC({session:e,node:t,token:i,readonly:s,takeSize:o,focused:D.current,onFiles:S,cols:T.cols,rows:T.rows,onData:he=>T.write(P.decode(he)),onExit:()=>T.write(`\r
78
+ \x1B[33m[sessione finita]\x1B[0m\r
79
+ `)})}catch(he){return T.write(`\r
80
+ \x1B[31m${he.message}\x1B[0m\r
81
+ `),()=>T.dispose()}k.current={term:T,fit:N,sock:O};let $=null;const W=T.onData(he=>{if(s){$&&($.ok=!1);return}if(!$&&p&&p.current&&he.length===1){const $e=he.charCodeAt(0);let ot=$e;$e>=97&&$e<=122?ot=$e-96:$e>=64&&$e<=95?ot=$e-64:$e===32&&(ot=0),he=String.fromCharCode(ot),p.current=!1,y&&y(!1)}const Se=O.sendInput(he);$&&($.seen=!0,$.ok=$.ok&&Se)});c&&(c.current=he=>O.sendInput(he)),m&&(m.current=he=>O.action(he)),h&&(h.current=pC({isReady:()=>!s&&O.isReady(),paste:he=>{const Se={seen:!1,ok:!0};$=Se;try{T.paste(he)}catch{Se.ok=!1}finally{$=null}return Se.seen&&Se.ok},send:he=>O.sendInput(he)}));const z=T.onSelectionChange(()=>ee(T.getSelection()));T.attachCustomKeyEventHandler(he=>(he.ctrlKey||he.metaKey)&&he.key.toLowerCase()==="c"&&T.getSelection()?(he.type==="keydown"&&Cg(T.getSelection()),!1):!0);const ne=x.current;let H=!1;const L=async he=>{if(!he.length||H)return;if(s){K({error:v("settings-readonly")});return}H=!0,K({current:0,total:he.length,name:""});const Se=await Y_({files:he,token:i,session:e,node:t,paste:!0,onProgress:({index:$e,total:ot,name:Rt,state:wt,error:ue})=>K({current:$e+1,total:ot,name:Rt,...wt==="error"?{error:ue}:{}})});H=!1,Se.errors.length?K({error:Se.errors.map($e=>`${$e.name}: ${$e.message}`).join(" · ")}):(K({done:!0,total:Se.paths.length}),setTimeout(()=>K(null),1600))},A=he=>{const Se=he.clipboardData;if(!gu(Se))return;const $e=Eg(Se);$e.length&&(he.preventDefault(),he.stopPropagation(),L($e))},ie=he=>{gu(he.dataTransfer)&&(he.preventDefault(),he.stopPropagation())},me=he=>{gu(he.dataTransfer)&&(he.preventDefault(),he.stopPropagation(),L(Eg(he.dataTransfer)))};ne.addEventListener("paste",A,!0),ne.addEventListener("dragenter",ie,!0),ne.addEventListener("dragover",ie,!0),ne.addEventListener("drop",me,!0);const G=24;let Z=null,ce=null,de=0,Ce=null,Ee=null,Ve=null,qe=!1;const xe=()=>{Ve&&clearTimeout(Ve),Ve=null},it=(he,Se)=>{const ot=(ne.querySelector(".xterm-screen")||ne).getBoundingClientRect(),Rt=Math.max(0,Math.min(T.cols-1,Math.floor((he-ot.left)/Math.max(1,ot.width)*T.cols))),wt=Math.max(0,Math.min(T.rows-1,Math.floor((Se-ot.top)/Math.max(1,ot.height)*T.rows)));return{col:Rt,row:T.buffer.active.viewportY+wt}},St=he=>it(he.clientX,he.clientY),se=he=>{if(xe(),qe=!1,he.touches.length!==1){Z=null;return}if(j.current){he.preventDefault(),he.stopPropagation(),Ee=St(he.touches[0]),T.clearSelection();return}Z=he.touches[0].clientY,ce=he.touches[0].clientX,de=0,Ce=null;const Se={x:ce,y:Z};Ve=setTimeout(()=>{Ve=null,qe=!0,j.current=!0,w==null||w(!0),Ee=it(Se.x,Se.y),T.clearSelection(),T.select(Ee.col,Ee.row,1),Z=null,ce=null,Ce=null,de=0},vC)},le=he=>{if((j.current||qe)&&Ee&&he.touches.length===1){he.preventDefault(),he.stopPropagation();const $e=St(he.touches[0]),ot=Ee.row*T.cols+Ee.col,Rt=$e.row*T.cols+$e.col,wt=ot<=Rt?Ee:$e;T.select(wt.col,wt.row,Math.abs(Rt-ot)+1);return}if(Z===null||he.touches.length!==1)return;he.preventDefault(),he.stopPropagation();const Se=he.touches[0];if(Ve&&_C(ce,Z,Se.clientX,Se.clientY)&&xe(),Ce===null&&(Math.abs(Se.clientY-Z)>8||Math.abs(Se.clientX-ce)>8)&&(Ce=Math.abs(Se.clientY-Z)>Math.abs(Se.clientX-ce)),!!Ce){for(de+=Se.clientY-Z,Z=Se.clientY;de>=G;)O.action("scroll-up"),de-=G;for(;de<=-G;)O.action("scroll-down"),de+=G}},Oe=()=>{xe(),Z=null,ce=null,Ee=null,qe=!1};let Te=0;const V=he=>{for(he.preventDefault(),he.stopPropagation(),Te+=he.deltaY;Te<=-G;)O.action("scroll-up"),Te+=G;for(;Te>=G;)O.action("scroll-down"),Te-=G};ne.addEventListener("touchstart",se,{passive:!1}),ne.addEventListener("touchmove",le,{passive:!1,capture:!0}),ne.addEventListener("touchend",Oe,{passive:!0}),ne.addEventListener("touchcancel",Oe,{passive:!0});const q=he=>{(j.current||qe)&&(he.preventDefault(),he.stopPropagation())};ne.addEventListener("contextmenu",q,!0),ne.addEventListener("wheel",V,{passive:!1,capture:!0});let pe=null;const ve=he=>{mC(he)&&(he.preventDefault(),he.stopPropagation(),pe=it(he.clientX,he.clientY),T.clearSelection())},be=he=>{if(!pe)return;he.preventDefault(),he.stopPropagation();const Se=it(he.clientX,he.clientY),$e=pe.row*T.cols+pe.col,ot=Se.row*T.cols+Se.col,Rt=$e<=ot?pe:Se;T.select(Rt.col,Rt.row,Math.abs(ot-$e)+1)},ae=he=>{pe&&(he.stopPropagation(),pe=null)};ne.addEventListener("mousedown",ve,!0),ne.addEventListener("mousemove",be,!0),ne.addEventListener("mouseup",ae,!0);const je=he=>{!gC(he)||!(k.current&&k.current.term&&k.current.term.getSelection())||(he.preventDefault(),he.stopPropagation(),X.current&&X.current())};ne.addEventListener("keydown",je,!0);const Ne=()=>{N.fit(),O.resize(T.cols,T.rows)};window.addEventListener("resize",Ne);const ze=window.visualViewport;ze&&(ze.addEventListener("resize",Ne),ze.addEventListener("scroll",Ne));let Be=null,st=0;return typeof ResizeObserver<"u"&&(Be=new ResizeObserver(()=>{st&&cancelAnimationFrame(st),st=requestAnimationFrame(Ne)}),Be.observe(ne)),()=>{k.current=null,c&&(c.current=()=>!1),h&&(h.current=()=>!1),m&&(m.current=()=>!1),W.dispose(),z.dispose(),ne.removeEventListener("touchstart",se),ne.removeEventListener("touchmove",le,{capture:!0}),ne.removeEventListener("touchend",Oe),ne.removeEventListener("touchcancel",Oe),ne.removeEventListener("contextmenu",q,!0),xe(),ne.removeEventListener("wheel",V,{capture:!0}),ne.removeEventListener("mousedown",ve,!0),ne.removeEventListener("mousemove",be,!0),ne.removeEventListener("mouseup",ae,!0),ne.removeEventListener("keydown",je,!0),ne.removeEventListener("paste",A,!0),ne.removeEventListener("dragenter",ie,!0),ne.removeEventListener("dragover",ie,!0),ne.removeEventListener("drop",me,!0),window.removeEventListener("resize",Ne),ze&&(ze.removeEventListener("resize",Ne),ze.removeEventListener("scroll",Ne)),Be&&Be.disconnect(),st&&cancelAnimationFrame(st),O.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}),J&&u.jsx("div",{className:`nc-upload-state${J.error?" error":""}`,role:"status",children:J.error?J.error:J.done?v("attach-uploaded").replace("{n}",String(J.total||0)):v("attach-upload-progress").replace("{n}",String(J.current||0)).replace("{total}",String(J.total||0))}),(M||C)&&u.jsxs("div",{className:"nc-selection-tools",children:[M?u.jsx("button",{type:"button",onClick:Q,children:F||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(),ee(""),w==null||w(!1)},children:v("cancel")}),F===v("copy-manual")&&u.jsx("textarea",{readOnly:!0,value:M,onFocus:T=>T.target.select()})]})]})}const Ng="",fi="\x1B",wC=[{label:"↑",seq:fi+"[A"},{label:"↓",seq:fi+"[B"},{label:"PGUP",seq:fi+"[5~"},{label:"PGDN",seq:fi+"[6~"}];function bC({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(fi+k),_(!1)):e(k)},w=(k,b,D)=>u.jsx("button",{onMouseDown:j=>{j.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"}),wC.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",Ng+"[",()=>{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",Ng+"d",()=>y(!1))]}),u.jsxs("div",{className:"row",children:[w("ESC",fi),u.jsx("button",{className:p?"armed":"",onMouseDown:k=>{k.preventDefault(),y(b=>!b)},children:"☰"},"menu"),w("/","/"),w("—","-"),w("HOME",fi+"[H"),w("↑",fi+"[A"),w("END",fi+"[F"),w("PGUP",fi+"[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("←",fi+"[D"),w("↓",fi+"[B"),w("→",fi+"[C"),w("PGDN",fi+"[6~")]})]})}const kC=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function G_({session:e,node:t,token:i,filesEvent:s,onClose:o}){ki();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 j=await(await Ht(`${a}/files?session=${encodeURIComponent(e)}`,i)).json();if(j.error){_(j.error);return}y(j);const M=j.outbox[0]?j.outbox[0].mtime:0;localStorage.setItem(Lv(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 j of D){_(`carico ${j.name}…`);const M=new FormData;M.append("session",e),M.append("file",j);try{const F=await(await Ht(`${a}/files/upload`,i,{method:"POST",body:M})).json();_(F.error?`errore: ${F.error}`:"")}catch(ee){_(String(ee))}}w()}async function k(D){const j=await Ht(`${a}/files/download?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(D)}`,i);if(!j.ok){_("errore download");return}const M=await j.blob(),ee=URL.createObjectURL(M),F=document.createElement("a");F.href=ee,F.download=D,F.click(),URL.revokeObjectURL(ee)}async function b(D){await Ht(`${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:kC(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 dl="nc_composer_v1",Td="nc-composer-reset",CC=50,Q_=256*1024,J_=512*1024,xC=768*1024,Rg=2*1024*1024,Z_=720*60*60*1e3,Ad=1;function ey(e){const t=Number(e);return Number.isFinite(t)&&t>0?t:0}function dh(e){if(e!==void 0)return e;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function sl(){return{version:Ad,cells:{}}}function ty(e){const t=[];for(const s of Array.isArray(e)?e:[]){const o=typeof s=="string"?s:s&&s.text,a=ey(typeof s=="string"?0:s&&s.at);if(!(typeof o!="string"||!o||o.length>Q_)&&!(t.length&&t[t.length-1].text===o)&&(t.push({text:o,at:a}),t.length>=CC))break}let i=0;return t.filter(s=>i+s.text.length>xC?!1:(i+=s.text.length,!0))}function ol(e){if(!e||typeof e!="object")return null;const t=typeof e.draft=="string"&&e.draft.length<=J_?e.draft:"",i=ty(e.history),s=ey(e.updatedAt),o=e.expanded===!0;return!t&&!i.length&&!o?null:{draft:t,history:i,expanded:o,updatedAt:s}}function EC(e){let t;try{t=typeof e=="string"?JSON.parse(e):e}catch{return sl()}if(!t||typeof t!="object"||t.version!==Ad||!t.cells||typeof t.cells!="object")return sl();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=ol(o);a&&(i[s]=a)}return{version:Ad,cells:i}}function iy(e){const t=dh(e);if(!t)return sl();try{return EC(t.getItem(dl))}catch{return sl()}}function Pg(e){try{return JSON.stringify(e).length}catch{return 1/0}}function NC(e,t,i){for(const[s,o]of Object.entries(e.cells))s!==i&&o.updatedAt>0&&t-o.updatedAt>Z_&&delete e.cells[s]}function ny(e,t){return Object.entries(e.cells).filter(([i])=>i!==t).sort((i,s)=>i[1].updatedAt-s[1].updatedAt).map(([i])=>i)}function RC(e,t){for(;Pg(e)>Rg;){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 ny(e,t)){if(Pg(e)<=Rg)break;delete e.cells[i]}}function ry(e,t,i){const s=dh(e);if(!s)return!1;RC(t,i);const o=()=>(s.setItem(dl,JSON.stringify(t)),!0);try{return o()}catch{for(const c of ny(t,i)){delete t.cells[c];try{return o()}catch{}}return!1}}function vo(e,t,i,s){const o=iy(t);NC(o,i,e);const a=ol(o.cells[e])||{draft:"",history:[],expanded:!1,updatedAt:0},c=s({...a,history:[...a.history]}),h=ol(c);return h?o.cells[e]={...h,updatedAt:i}:delete o.cells[e],{ok:ry(t,o,e),cell:o.cells[e]||{draft:"",history:[],expanded:!1,updatedAt:i}}}function PC({ownerId:e,node:t,session:i}){const s=String(i||"");if(!s)return"";const o=es.test(String(e||""))?String(e):t?`route:${String(t)}`:"local";return`${encodeURIComponent(o)}:${encodeURIComponent(s)}`}function Gs(e,t,i=Date.now()){if(!e)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=iy(t),o=ol(s.cells[e]);return!o||o.updatedAt>0&&i-o.updatedAt>Z_?(s.cells[e]&&(delete s.cells[e],ry(t,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...o,history:[...o.history]}}function Dg(e,t,i,s=Date.now()){const o=String(t||"");return!e||o.length>J_?!1:vo(e,i,s,a=>({...a,draft:o})).ok}function Lg(e,t,i=Date.now()){return e?vo(e,t,i,s=>({...s,draft:""})).ok:!1}function DC(e,t,i,s=Date.now()){return e?vo(e,i,s,o=>({...o,expanded:!!t})).ok:!1}function LC(e,t,i,s=Date.now()){const o=String(t||"");return!e||!o||o.length>Q_?!1:vo(e,i,s,a=>{const c=a.history.filter(h=>h.text!==o);return c.unshift({text:o,at:s}),{...a,history:ty(c)}}).ok}function MC(e,t,i=Date.now()){return e?vo(e,t,i,s=>({...s,history:[]})).ok:!1}function jC(e){const t=dh(e);if(!t)return!1;try{return t.removeItem(dl),!0}catch{return!1}}const TC=300;function AC(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function IC({ownerId:e,node:t,session:i,storage:s=AC()}){const o=R.useMemo(()=>PC({ownerId:e,node:t,session:i}),[e,t,i]),a=R.useMemo(()=>Gs(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),j=R.useCallback(()=>{k.current&&clearTimeout(k.current),k.current=null},[]),M=R.useCallback(()=>{j(),Dg(w.current,x.current,s)},[j,s]),ee=R.useCallback(()=>{j(),k.current=setTimeout(()=>{k.current=null,Dg(w.current,x.current,s)},TC)},[j,s]),F=R.useCallback(P=>{const O=String(typeof P=="function"?P(x.current):P||"");x.current=O,b.current=Date.now(),D.current=O,C(-1),h(O),ee()},[ee]),B=R.useCallback((P,O)=>{j(),x.current=P,b.current=Date.now(),h(P),C(O),ee()},[j,ee]),J=R.useCallback(()=>{if(!y.length)return!1;const P=Math.min(_+1,y.length-1);return _<0&&(D.current=x.current),B(y[P].text,P),!0},[B,y,_]),K=R.useCallback(()=>{if(_<0)return!1;const P=_-1;return B(P<0?D.current:y[P].text,P),!0},[B,y,_]),Q=R.useCallback(P=>{D.current=x.current;const O=y.findIndex($=>$.text===P);B(String(P||""),O)},[B,y]),X=R.useCallback(()=>{p(P=>{const O=!P;return DC(w.current,O,s),O})},[s]),T=R.useCallback((P,O,$)=>{if(!P)return;if(LC(P,$,s),!(w.current===P)){Gs(P,s).draft===O&&Lg(P,s);return}S(Gs(P,s).history),D.current="",C(-1),x.current===O?(j(),x.current="",b.current=Date.now(),h(""),Lg(P,s)):ee()},[j,ee,s]),N=R.useCallback(()=>{MC(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=Gs(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(),O=()=>{document.visibilityState==="hidden"&&M()};return window.addEventListener("pagehide",P),document.addEventListener("visibilitychange",O),()=>{window.removeEventListener("pagehide",P),document.removeEventListener("visibilitychange",O),M()}},[M]),R.useEffect(()=>{const P=()=>{j(),x.current="",b.current=0,D.current="",h(""),p(!1),S([]),C(-1)},O=W=>{if(W.key!==dl)return;if(W.newValue==null){P();return}const z=Gs(w.current,s);z.updatedAt<b.current||(j(),x.current=z.draft,b.current=z.updatedAt,D.current=z.draft,h(z.draft),p(z.expanded),S(z.history),C(-1))},$=()=>P();return window.addEventListener("storage",O),window.addEventListener(Td,$),()=>{window.removeEventListener("storage",O),window.removeEventListener(Td,$)}},[j,s]),{cellKey:o,text:c,setText:F,expanded:m,toggleExpanded:X,history:y,historyCursor:_,recallPrevious:J,recallNext:K,selectHistory:Q,confirmSubmitted:T,clearHistory:N,flush:M}}function sy({submitText:e,token:t,session:i,node:s,ownerId:o}){ki();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}=IC({ownerId:o,node:s,session:i}),[j,M]=R.useState(!1),[ee,F]=R.useState(""),[B,J]=R.useState(!1),K=R.useRef(null),Q=R.useRef(null),X=R.useRef(null),[T,N]=R.useState(!1),[P,O]=R.useState({left:0,bottom:0}),[$,W]=R.useState(!1),[z,ne]=R.useState(!1),H=R.useRef(null),L=R.useRef(null),A=R.useRef(null),ie=R.useRef(null),me=R.useRef(null),G=R.useRef(null),Z=R.useRef(null),ce=R.useRef(!1),[de,Ce]=R.useState(!1),[Ee,Ve]=R.useState({left:0,bottom:0,width:320}),qe=R.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);R.useEffect(()=>{let ae=!1;if(s){J(!1);return}return Ht(`${a}/voice/status`,t).then(je=>je.json()).then(je=>{ae||J(!!je.serverSttConfigured)}).catch(()=>{ae||J(!1)}),()=>{ae=!0}},[t,a]);const it=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||B);async function St(){const ae=h,je=fC(ae);if(!je||z)return;ne(!0),F("");let Ne=!1;try{Ne=!!await e(je)}catch{Ne=!1}Ne?k(c,ae,je):F(v("composer-send-failed")),ne(!1),requestAnimationFrame(()=>{var ze;return(ze=X.current)==null?void 0:ze.focus({preventScroll:!0})})}function se(){const ae=H.current&&H.current.getBoundingClientRect();ae&&O({left:Math.max(6,Math.min(ae.left,window.innerWidth-186)),bottom:window.innerHeight-ae.top+6}),N(!0)}function le(ae){N(!1),ae&&H.current&&H.current.focus()}function Oe(){const ae=A.current&&A.current.getBoundingClientRect();if(ae){const je=Math.max(220,Math.min(360,window.innerWidth-12));Ve({left:Math.max(6,Math.min(ae.right-je,window.innerWidth-je-6)),bottom:window.innerHeight-ae.top+6,width:je})}Ce(!0)}function Te(ae){Ce(!1),ae&&A.current&&A.current.focus()}R.useEffect(()=>{if(!T)return;const ae=Ne=>{Ne.key==="Escape"&&le(!0)},je=Ne=>{const ze=L.current&&L.current.contains(Ne.target),Be=H.current&&H.current.contains(Ne.target);!ze&&!Be&&le(!1)};return document.addEventListener("keydown",ae),document.addEventListener("pointerdown",je),()=>{document.removeEventListener("keydown",ae),document.removeEventListener("pointerdown",je)}},[T]),R.useEffect(()=>{if(!de)return;const ae=Ne=>{Ne.key==="Escape"&&Te(!0)},je=Ne=>{const ze=ie.current&&ie.current.contains(Ne.target),Be=A.current&&A.current.contains(Ne.target);!ze&&!Be&&Te(!1)};return document.addEventListener("keydown",ae),document.addEventListener("pointerdown",je),()=>{document.removeEventListener("keydown",ae),document.removeEventListener("pointerdown",je)}},[de]);function V(ae){if(!(ae.isComposing||ce.current||ae.altKey||ae.ctrlKey||ae.metaKey)){if(ae.key==="ArrowUp"&&ae.currentTarget.selectionStart===0&&ae.currentTarget.selectionEnd===0){C()&&ae.preventDefault();return}ae.key==="ArrowDown"&&_>=0&&ae.currentTarget.selectionStart===h.length&&ae.currentTarget.selectionEnd===h.length&&w()&&ae.preventDefault()}}function q(ae){le(!1),ae.current&&ae.current.click()}async function pe(ae){if(!ae.length||!i)return;W(!0),F("");const{paths:je,errors:Ne}=await Y_({files:ae,token:t,session:i,node:s,paste:!1});Ne.length&&F(Ne.map(ze=>`${ze.name}: ${ze.message}`).join(" · ")),je.length&&m(ze=>ze+(ze&&!ze.endsWith(" ")?" ":"")+je.join(" ")),W(!1)}function ve(){K.current&&K.current.stop(),Q.current&&Q.current.stop(),M(!1)}async function be(){F("");const ae=window.SpeechRecognition||window.webkitSpeechRecognition;if(ae){const je=new ae;je.lang="it-IT",je.continuous=!1,je.interimResults=!0;const Ne=h?`${h} `:"";je.onresult=ze=>{const Be=Array.from(ze.results).map(st=>st[0].transcript).join("");m(Ne+Be)},je.onend=()=>M(!1),je.onerror=ze=>{F(`voice: ${ze.error||"errore"}`),M(!1)},K.current=je,je.start(),M(!0);return}try{const je=await navigator.mediaDevices.getUserMedia({audio:!0}),Ne=new MediaRecorder(je),ze=[];Ne.ondataavailable=Be=>ze.push(Be.data),Ne.onstop=async()=>{je.getTracks().forEach(Be=>Be.stop()),M(!1),F("trascrivo…");try{const Be=new Blob(ze,{type:Ne.mimeType||"audio/webm"}),he=await(await Ht(`${a}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:Be})).json();he.error?F(he.error):(F(""),m(Se=>Se+(Se?" ":"")+(he.text||"")))}catch(Be){F(String(Be))}},Q.current={stop:()=>Ne.state!=="inactive"&&Ne.stop()},Ne.start(),M(!0)}catch{F("microfono non disponibile"),M(!1)}}return u.jsxs("div",{className:"nc-composer",children:[ee&&u.jsx("div",{className:"nc-composer-err",children:ee}),u.jsxs("div",{className:"nc-composer-row",children:[i&&u.jsx("button",{ref:H,className:$?"attach busy":"attach",disabled:$,onClick:()=>T?le(!1):se(),title:v($?"attach-uploading":"attach"),"aria-label":v("attach"),"aria-haspopup":"menu","aria-expanded":T,"aria-controls":qe.current,children:u.jsx(et,{name:"attach",size:22})}),T&&u.jsxs("div",{ref:L,id:qe.current,role:"menu",className:"nc-attach-menu",style:{left:P.left,bottom:P.bottom},children:[u.jsxs("button",{role:"menuitem",onClick:()=>q(me),children:[u.jsx(et,{name:"file",size:18})," ",v("attach-file")]}),u.jsxs("button",{role:"menuitem",onClick:()=>q(G),children:[u.jsx(et,{name:"camera",size:18})," ",v("attach-camera")]}),u.jsxs("button",{role:"menuitem",onClick:()=>q(Z),children:[u.jsx(et,{name:"image",size:18})," ",v("attach-gallery")]})]}),u.jsx("button",{ref:A,type:"button",className:"history",onPointerDown:ae=>ae.preventDefault(),onClick:()=>de?Te(!1):Oe(),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:ie,role:"menu",className:"nc-composer-history-menu",style:{left:Ee.left,bottom:Ee.bottom,width:Ee.width},children:[u.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:ae=>ae.preventDefault(),onClick:()=>{y(),Te(!1),requestAnimationFrame(()=>{var ae;return(ae=X.current)==null?void 0:ae.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((ae,je)=>u.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:Ne=>Ne.preventDefault(),onClick:()=>{x(ae.text),Te(!1),requestAnimationFrame(()=>{var Ne;return(Ne=X.current)==null?void 0:Ne.focus({preventScroll:!0})})},children:[u.jsx("span",{children:ae.text.replace(/\s+/g," ").slice(0,180)}),ae.at>0&&u.jsx("small",{children:new Date(ae.at).toLocaleString()})]},`${ae.at}:${je}`)),S.length>0&&u.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:ae=>ae.preventDefault(),onClick:()=>{b(),Te(!1)},children:v("composer-history-clear")})]}),u.jsx("input",{ref:me,type:"file",multiple:!0,hidden:!0,onChange:ae=>{pe(Array.from(ae.target.files||[])),ae.target.value=""}}),u.jsx("input",{ref:G,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:ae=>{pe(Array.from(ae.target.files||[])),ae.target.value=""}}),u.jsx("input",{ref:Z,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:ae=>{pe(Array.from(ae.target.files||[])),ae.target.value=""}}),u.jsx("textarea",{ref:X,className:p?"expanded":"",rows:p?8:2,value:h,placeholder:v("composer-placeholder"),onChange:ae=>m(ae.target.value),onKeyDown:V,onCompositionStart:()=>{ce.current=!0},onCompositionEnd:()=>{ce.current=!1},onBlur:D}),it&&u.jsx("button",{className:j?"mic on":"mic",onClick:j?ve:be,title:v("voice"),children:u.jsx(et,{name:"mic",size:22})}),u.jsx("button",{type:"button",className:"go",disabled:z,onPointerDown:ae=>ae.preventDefault(),onClick:St,title:v("send"),children:u.jsx(et,{name:"enter",size:22})})]})]})}function Mg(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const BC=180,OC=480;function zC({sessions:e=[],cells:t=[],activeSessions:i=[],nodeGroups:s=[],onPick:o,onAddTile:a,onPower:c,onNodePower:h,onKill:m,onVisibility:p,onNew:y,onNodeRename:S,onSettings:_,localNodeId:C,width:w=240,collapsed:x=!1,onResize:k,onToggleCollapse:b}){const[D,j]=ki(),{pins:M,orders:ee,togglePin:F,viewFor:B,updateView:J,canMoveRoster:K,moveRoster:Q,stepRoster:X}=Kv(),{groupsFor:T,moveNode:N,stepNode:P,nodeKey:O}=Vv(),$=new Set((t||[]).map(se=>se.tmuxSession)),W=new Map((e||[]).map(se=>[se.name,se])),z=(se,le)=>E0(M,se,le),ne=N0,H=[...t||[]].sort((se,le)=>ne(z(se.tmuxSession,(W.get(se.tmuxSession)||{}).activity),z(le.tmuxSession,(W.get(le.tmuxSession)||{}).activity))),L=(e||[]).filter(se=>!$.has(se.name)).sort((se,le)=>ne(z(se.name,se.activity),z(le.name,le.activity))||se.name.localeCompare(le.name)),A=new Set(i||[]),ie=Qv(H,L,W),me=fr(ie,M,B("local").filter,Wn(ee,"local")),Z=T(s||[]).map(se=>{const le=(se.route||[se.name]).join("/"),Oe=B(le),{rawItems:Te}=Jv(se),V=fr(Te,M,Oe.filter,Wn(ee,le));return{g:se,nodeRoute:le,groupView:Oe,rawItems:Te,items:V}}),ce=(se,le,Oe)=>o&&o({session:se,...le?{node:le}:{},...es.test(String(Oe||""))?{ownerId:Oe}:{}}),de=async se=>{if(!(se!=null&&se.direct)||!S)return;const le=window.prompt(v("rename-node-prompt"),se.label||se.name);if(le!==null)try{await S(se,le)||window.alert(v("rename-node-invalid"))}catch(Oe){window.alert(String((Oe==null?void 0:Oe.message)||Oe))}},[Ce,Ee]=R.useState(null),Ve=(se,le)=>{const Oe=se.currentTarget.getBoundingClientRect();Ee({text:le,y:Oe.top+Oe.height/2})},qe=()=>Ee(null),xe=R.useRef(null);R.useEffect(()=>()=>{xe.current&&xe.current()},[]);function it(se){se.preventDefault(),se.stopPropagation();const le=se.clientX,Oe=w,Te=q=>{const pe=Math.max(BC,Math.min(OC,Oe+(q.clientX-le)));k&&k(pe)},V=()=>{window.removeEventListener("pointermove",Te),window.removeEventListener("pointerup",V),window.removeEventListener("pointercancel",V),window.removeEventListener("blur",V),xe.current=null};window.addEventListener("pointermove",Te),window.addEventListener("pointerup",V),window.addEventListener("pointercancel",V),window.addEventListener("blur",V),xe.current=V}const St=x?{width:48,flex:"0 0 48px"}:{width:w,flex:`0 0 ${w}px`};return x?u.jsxs("aside",{className:"nc-sidebar mini",style:St,children:[u.jsx("div",{className:"nc-side-head mini",children:u.jsx("button",{className:"nc-collapse-btn",onClick:b,title:v("expand"),children:"⟩"})}),u.jsx("button",{className:"nc-side-gear mini",onClick:()=>_&&_("nodes",!1),title:v("settings"),onMouseEnter:se=>Ve(se,v("settings")),onMouseLeave:qe,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:[B("local").open&&me.map(se=>se.type==="cell"?(()=>{const le=se.value,Oe=le.degraded?"warn":le.tmux?"on":"",Te=!!le.tmux;return u.jsx("button",{type:"button",className:`nc-mini-dot${A.has(le.tmuxSession)?" active":""}`,onMouseEnter:V=>Ve(V,`${le.cell}: ${se.subtitle}`),onMouseLeave:qe,draggable:Te,onDragStart:Te?V=>V.dataTransfer.setData("text/nc-session",le.tmuxSession):void 0,onClick:Te?()=>a&&a(le.tmuxSession):()=>c&&c(le),onDoubleClick:Te?()=>ce(le.tmuxSession,"",C):void 0,children:u.jsx("span",{className:`nc-dot ${Oe}${se.working?" working":""}`})},se.key)})():(()=>{const le=se.value;return u.jsx("button",{type:"button",className:`nc-mini-init${A.has(le.name)?" active":""}`,onMouseEnter:Oe=>Ve(Oe,le.name),onMouseLeave:qe,draggable:!0,onDragStart:Oe=>Oe.dataTransfer.setData("text/nc-session",le.name),onClick:()=>a&&a(le.name),onDoubleClick:()=>ce(le.name,"",C),children:Mg(le.name)},se.key)})()),Z.flatMap(({g:se,nodeRoute:le,groupView:Oe,items:Te})=>se.status==="up"?Oe.open?Te.map(V=>V.type==="cell"?(()=>{const q=V.value,pe=!!q.tmux;return u.jsx("button",{type:"button",className:`nc-mini-dot${A.has(V.key)?" active":""}`,onMouseEnter:ve=>Ve(ve,`${se.label||le}: ${q.cell} · ${V.subtitle}`),onMouseLeave:qe,draggable:pe,onDragStart:pe?ve=>ve.dataTransfer.setData("text/nc-session",V.key):void 0,onClick:pe?()=>a&&a(V.key):()=>c&&c({...q,route:se.route,availableEngines:se.engines||[]}),onDoubleClick:pe?()=>ce(q.tmuxSession,le,se.instanceId):void 0,children:u.jsx("span",{className:`nc-dot ${q.degraded?"warn":pe?`on${V.working?" working":""}`:""}`})},V.key)})():(()=>{const q=V.value;return u.jsx("button",{type:"button",className:`nc-mini-init${A.has(V.key)?" active":""}`,onMouseEnter:pe=>Ve(pe,`${se.label||le}: ${q.name}`),onMouseLeave:qe,draggable:!0,onDragStart:pe=>pe.dataTransfer.setData("text/nc-session",V.key),onClick:()=>a&&a(V.key),onDoubleClick:()=>ce(q.name,le,se.instanceId),children:Mg(q.name)},V.key)})()):[]:[u.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:V=>Ve(V,`${se.label||(se.route||[se.name]).join(" › ")}: ${Gr(se)}`),onMouseLeave:qe,children:u.jsx("span",{className:`nc-dot${se.status==="passive"?"":" warn"}`})},`nodo-${(se.route||[se.name]).join("/")}`)])]})}),Ce&&u.jsx("div",{className:"nc-mini-tip",style:{top:Ce.y},children:Ce.text})]}):u.jsxs("aside",{className:"nc-sidebar",style:St,children:[u.jsxs("div",{className:"nc-side-head",children:[u.jsx("button",{className:"nc-collapse-btn",onClick:b,title:v("collapse"),children:"⟨"}),u.jsx("span",{className:"nc-side-title",children:v("fleet")}),u.jsxs("button",{className:"nc-new-btn",onClick:y,title:v("fleet-new-cell"),children:["+ ",v("new")]})]}),u.jsxs("button",{className:"nc-side-gear",onClick:()=>_&&_("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(FC,{label:v("position-local"),count:me.length,state:B("local"),onToggle:()=>J("local",{open:!B("local").open}),onFilter:se=>J("local",{filter:se})}),B("local").open&&u.jsxs("div",{className:"nc-side-group",children:[me.map(se=>se.type==="cell"?(()=>{const le=se.value,Oe=le.degraded?"warn":le.tmux?"on":"",Te=le.degraded?v("cell-degraded"):se.working?se.subtitle:le.tmux?v("cell-idle"):v("cell-off"),V=!!le.tmux;return u.jsxs("div",{"data-roster-key":se.key,"data-position":"local",className:`nc-cell${V?" live":""}${A.has(le.tmuxSession)?" active":""}`,title:`${le.cell} · ${se.subtitle}${Te===se.subtitle?"":` · ${Te}`}`,"aria-label":`${le.cell}, ${se.subtitle}${Te===se.subtitle?"":`, ${Te}`}`,draggable:V,onDragStart:V?q=>q.dataTransfer.setData("text/nc-session",le.tmuxSession):void 0,onClick:V?()=>a&&a(le.tmuxSession):void 0,onDoubleClick:V?()=>ce(le.tmuxSession,"",C):void 0,children:[u.jsx(Hn,{position:"local",itemKey:se.key,label:le.cell,canMove:K,onMove:(q,pe)=>Q("local",q,pe,ie),onStep:q=>X("local",se.key,q,ie)}),u.jsx("span",{className:`nc-dot ${Oe}${se.working?" working":""}`}),u.jsxs("span",{className:"nc-cell-main",children:[u.jsx("b",{title:le.cell,children:le.cell}),u.jsx("small",{title:se.subtitle,children:se.subtitle})]}),u.jsx("button",{className:`nc-pin${M.includes(se.key)?" on":""}`,title:v("pin"),onClick:q=>{q.stopPropagation(),F(se.key)},children:M.includes(se.key)?"★":"☆"}),u.jsx("button",{className:`nc-power${le.tmux?" on":""}${le.degraded?" warn":""}`,onClick:q=>{q.stopPropagation(),c&&c(le)},title:le.active?v("power-off"):v("power-on"),children:u.jsx(et,{name:"power",size:14})})]},se.key)})():(()=>{var Oe;const le=se.value;return u.jsxs("div",{"data-roster-key":se.key,"data-position":"local",className:`nc-side-card${A.has(le.name)?" active":""}`,draggable:!0,onDragStart:Te=>Te.dataTransfer.setData("text/nc-session",le.name),onClick:()=>a&&a(le.name),onDoubleClick:()=>ce(le.name,"",C),children:[u.jsx(Hn,{position:"local",itemKey:se.key,label:le.name,canMove:K,onMove:(Te,V)=>Q("local",Te,V,ie),onStep:Te=>X("local",se.key,Te,ie)}),u.jsx("span",{className:le.attached?"nc-dot on":"nc-dot"}),u.jsxs("span",{className:"nc-card-main",children:[u.jsx("b",{children:le.name}),u.jsxs("small",{children:[le.preview||le.cmd||v("windows").replace("{n}",String(le.windows||0)),((Oe=le.outbox)==null?void 0:Oe.count)>0?` · 📦${le.outbox.count}`:""]})]}),le.activity?u.jsx("span",{className:"nc-rel",children:Zr(le.activity)}):null,u.jsx("button",{className:`nc-pin${M.includes(se.key)?" on":""}`,title:v("pin"),onClick:Te=>{Te.stopPropagation(),F(se.key)},children:M.includes(se.key)?"★":"☆"}),u.jsx("button",{className:`nc-technical${le.technical?" on":""}`,title:le.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${le.technical?v("mark-normal"):v("mark-technical")} ${le.name}`,onClick:Te=>{Te.stopPropagation(),p&&p(le.name,!le.technical,[])},children:"T"}),u.jsx("button",{className:"nc-menu",title:v("terminate"),onClick:Te=>{Te.stopPropagation(),window.confirm(v("terminate-confirm").replace("{name}",le.name))&&m&&m(le.name)},children:"⋯"})]},se.key)})()),me.length===0&&u.jsx("div",{className:"nc-empty",children:v("no-sessions-short")})]}),Z.map(({g:se,nodeRoute:le,groupView:Oe,rawItems:Te,items:V})=>{const pe=Yv(se.health)||(se.status==="up"?"on":se.status==="passive"?"":"warn");return u.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":O(se),children:[u.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:se.direct&&S?ve=>{ve.preventDefault(),de(se)}:void 0,onClick:()=>J(le,{open:!Oe.open}),onKeyDown:ve=>{(ve.key==="Enter"||ve.key===" ")&&(ve.preventDefault(),J(le,{open:!Oe.open}))},children:[u.jsx(Hn,{scope:"node",position:"nodes",itemKey:O(se),label:se.label||se.name,onMove:(ve,be)=>N(ve,be,s||[]),onStep:ve=>P(O(se),ve,s||[])}),u.jsx("span",{className:"nc-node-chevron",children:Oe.open?"⌄":"›"}),u.jsx("span",{className:`nc-dot ${pe}`,title:se.health?Xa(se.health):""}),u.jsx("b",{children:se.label||se.name}),u.jsxs("small",{children:[" · ",se.status==="up"?v("node-sessions").replace("{n}",String(V.length)):se.health&&Xa(se.health)||Gr(se)]}),u.jsxs("select",{className:"nc-node-filter",value:Oe.filter,title:v(`view-${Oe.filter}`),onClick:ve=>ve.stopPropagation(),onChange:ve=>J(le,{filter:ve.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")})]}),se.direct&&S&&u.jsx("button",{type:"button",className:"nc-node-rename",title:v("rename-node"),"aria-label":`${v("rename-node")} ${se.label||se.name}`,onClick:ve=>{ve.stopPropagation(),de(se)},children:"✎"}),se.direct&&se.health&&se.health.managed!==!1&&u.jsx("button",{type:"button",className:`nc-power${se.tunnelStatus==="up"?" on":""}`,title:se.tunnelStatus==="up"?v("power-off"):v("power-on"),onClick:ve=>{ve.stopPropagation(),h&&h(se)},children:u.jsx(et,{name:"power",size:14})})]}),se.status==="up"&&Oe.open&&u.jsxs("div",{className:"nc-side-group",children:[V.map(ve=>ve.type==="cell"?(()=>{const be=ve.value,ae=!!be.tmux,je=be.degraded?"warn":be.tmux?"on":"";return u.jsxs("div",{"data-roster-key":ve.key,"data-position":le,className:`nc-side-card nc-cell${ae?" live":""}${A.has(be.key)?" active":""}`,title:ve.working?ve.subtitle:be.tmux?v("cell-idle"):v("cell-off"),draggable:ae,onDragStart:ae?Ne=>Ne.dataTransfer.setData("text/nc-session",be.key):void 0,onClick:ae?()=>a&&a(be.key):void 0,onDoubleClick:ae?()=>ce(be.tmuxSession,le,se.instanceId):void 0,children:[u.jsx(Hn,{position:le,itemKey:ve.key,label:be.cell,canMove:K,onMove:(Ne,ze)=>Q(le,Ne,ze,Te),onStep:Ne=>X(le,ve.key,Ne,Te)}),u.jsx("span",{className:`nc-dot ${je}${ve.working?" working":""}`}),u.jsxs("span",{className:"nc-card-main",children:[u.jsx("b",{children:be.cell}),u.jsx("small",{title:ve.subtitle,children:ve.subtitle})]}),u.jsx("button",{className:`nc-pin${M.includes(ve.key)?" on":""}`,title:v("pin"),onClick:Ne=>{Ne.stopPropagation(),F(ve.key)},children:M.includes(ve.key)?"★":"☆"}),(se.capabilities||[]).includes(be.active?"down":"up")&&u.jsx("button",{className:`nc-power${be.active?" on":""}${be.degraded?" warn":""}`,onClick:Ne=>{Ne.stopPropagation(),c&&c({...be,route:se.route,availableEngines:se.engines||[]})},title:be.active?v("power-off"):v("power-on"),children:u.jsx(et,{name:"power",size:14})})]},ve.key)})():(()=>{const be=ve.value;return u.jsxs("div",{"data-roster-key":ve.key,"data-position":le,className:`nc-side-card${A.has(be.key)?" active":""}`,draggable:!0,onDragStart:ae=>ae.dataTransfer.setData("text/nc-session",be.key),onClick:()=>a&&a(be.key),onDoubleClick:()=>ce(be.name,be.node||le,se.instanceId),children:[u.jsx(Hn,{position:le,itemKey:ve.key,label:be.name,canMove:K,onMove:(ae,je)=>Q(le,ae,je,Te),onStep:ae=>X(le,ve.key,ae,Te)}),u.jsx("span",{className:be.attached?"nc-dot on":"nc-dot"}),u.jsxs("span",{className:"nc-card-main",children:[u.jsx("b",{children:be.name}),u.jsx("small",{children:be.preview?be.preview:be.cmd?be.cmd:v("windows").replace("{n}",String(be.windows||0))})]}),be.activity?u.jsx("span",{className:"nc-rel",children:Zr(be.activity)}):null,u.jsx("button",{className:`nc-pin${M.includes(ve.key)?" on":""}`,title:v("pin"),onClick:ae=>{ae.stopPropagation(),F(ve.key)},children:M.includes(ve.key)?"★":"☆"}),u.jsx("button",{className:`nc-technical${be.technical?" on":""}`,title:be.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${be.technical?v("mark-normal"):v("mark-technical")} ${be.name}`,onClick:ae=>{ae.stopPropagation(),p&&p(be.name,!be.technical,se.route||[])},children:"T"}),u.jsx("button",{className:"nc-menu",title:v("terminate"),onClick:ae=>{ae.stopPropagation(),window.confirm(v("terminate-confirm").replace("{name}",be.name))&&m&&m(be.name,se.route)},children:"⋯"})]},ve.key)})()),V.length===0&&u.jsx("div",{className:"nc-empty",children:v("no-sessions-short")})]})]},`nodo-${(se.route||[se.name]).join("/")}`)})]}),u.jsx("div",{className:"nc-side-lang",children:Uv.map((se,le)=>u.jsxs("span",{children:[le>0&&" · ",u.jsx("button",{className:`nc-lang-btn${D===se?" on":""}`,onClick:()=>j(se),title:se,children:se.toUpperCase()})]},se))}),u.jsx("div",{className:"nc-side-resize",onPointerDown:it,title:""})]})}function FC({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 HC(e,t,i){return!e&&t?i+1:i}function $C({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=ho,onZoom:_,decks:C=[],currentDeck:w,onSendToDeck:x}){const k=R.useRef(()=>{}),b=R.useRef(()=>!1),D=R.useRef(()=>{}),j=R.useRef(!1),[M,ee]=R.useState(!1),[F,B]=R.useState(!1),[J,K]=R.useState(!1),[Q,X]=R.useState(null),[T,N]=R.useState(0),P=R.useRef(p),O=t?`${t}:${e}`:e,$=C.filter(W=>W.id!==w&&W.available!==!1);return R.useEffect(()=>{const W=P.current;!W&&p&&N(z=>HC(W,p,z)),P.current=p},[p]),u.jsxs("div",{className:`nc-tile${a?" focused":""}`,onMouseDown:()=>c&&c(O),children:[u.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:W=>{W.dataTransfer.setData("text/nc-session",O),W.dataTransfer.effectAllowed="move"},children:[u.jsxs("button",{className:"nc-tile-name",onClick:()=>c&&c(O),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:W=>W.stopPropagation(),onChange:W=>{const z=W.target.value;z&&x(O,z),W.target.value=""},children:[u.jsx("option",{value:"",children:v("send-to-deck")}),$.map(W=>u.jsxs("option",{value:W.id,children:[W.ownerLabel," · ",W.name]},W.id))]}),u.jsx("button",{onClick:()=>B(W=>!W),title:"composer",children:"⌨"}),u.jsx("button",{onClick:()=>K(W=>!W),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(O),title:"chiudi",children:"✕"})]})]}),u.jsxs("div",{className:"nc-tile-body",children:[y?u.jsx(X_,{session:e,node:t,token:s,readonly:o,takeSize:!1,focused:a,sendRef:k,composerRef:b,actionRef:D,ctrlRef:j,setCtrlArmed:ee,onFiles:X,fontSize:S},`${O}:${T}`):u.jsx("div",{className:"nc-tile-unavailable",children:v("deck-owner-unavailable")}),y&&J&&u.jsx("div",{className:"nc-tile-files",onMouseDown:W=>W.stopPropagation(),children:u.jsx(G_,{session:e,node:t,token:s,filesEvent:Q,onClose:()=>K(!1)})})]}),y&&F&&u.jsx("div",{className:"nc-tile-composer",onMouseDown:W=>W.stopPropagation(),children:u.jsx(sy,{submitText:W=>b.current(W),token:s,session:e,node:t,ownerId:i})})]})}const jg=.2,Tg=.28,oy=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),vu=e=>oy(e,"text/nc-session"),Ag=e=>{var t;return oy(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function WC(e,t,i){const s=(e-i.left)/(i.width||1),o=(t-i.top)/(i.height||1);return s<Tg?"left":s>1-Tg?"right":o<.5?"top":"bottom"}function UC({layout:e,onLayoutChange:t,token:i,readonly:s=!1,sessionsAlive:o,focusSession:a,onFocus:c,onOpenSingle:h,decks:m=[],currentDeck:p,onSendToDeck:y}){ki();const[S,_]=R.useState(null),C=R.useRef(null),w=R.useRef([]),x=R.useRef(null);function k(K,Q){const X=()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),window.removeEventListener("blur",X),x.current=null};window.addEventListener("pointermove",K),window.addEventListener("pointerup",X),window.addEventListener("pointercancel",X),window.addEventListener("blur",X),x.current=X}R.useEffect(()=>()=>{x.current&&x.current()},[]),R.useEffect(()=>{const K=()=>_(null);return window.addEventListener("dragend",K),window.addEventListener("drop",K),()=>{window.removeEventListener("dragend",K),window.removeEventListener("drop",K)}},[]);const b=e.columns.length,D=K=>S&&S.col===K&&S.row===void 0,j=!!S&&S.col===b,M=(K,Q)=>S&&S.col===K&&S.row===Q&&S.quadrant?` drop-${S.quadrant}`:"";function ee(K){if(K.preventDefault(),Ag(K.dataTransfer)){_(null);return}const Q=K.dataTransfer.getData("text/nc-session"),X=S;if(_(null),!Q||!X)return;let T;if(X.quadrant){if(T=F0(e,X.col,X.row,X.quadrant),!T)return}else T={col:X.col};t(Zi(e).includes(Q)?A0(e,Q,T):eh(e,Q,T))}function F(K,Q){K.preventDefault(),K.stopPropagation();const X=K.clientX,T=e.columns[Q].width,N=C.current&&C.current.clientWidth||1,P=e.columns[Q+1];k($=>{let W=Math.max(jg,T+($.clientX-X)/N);if(P){const z=xm(W/(W+P.width));W=z/(1-z)*P.width}t(B0(e,Q,W))})}function B(K,Q,X){K.preventDefault(),K.stopPropagation();const T=K.clientY,N=e.columns[Q].tiles[X].height,P=w.current[Q],O=P&&P.clientHeight||1,$=e.columns[Q].tiles[X+1];k(z=>{let ne=Math.max(jg,N+(z.clientY-T)/O);if($){const H=xm(ne/(ne+$.height));ne=H/(1-H)*$.height}t(O0(e,Q,X,ne))})}function J(K){t(Ja(e,K))}return u.jsxs("div",{className:"nc-grid",ref:C,onDragOver:K=>{if(Ag(K.dataTransfer)){K.preventDefault(),_(null);return}vu(K.dataTransfer)&&(K.preventDefault(),S&&S.col===b||_({col:b}))},onDrop:ee,onDragLeave:K=>{const Q=K.relatedTarget;(!Q||!(C.current&&C.current.contains(Q)))&&_(null)},children:[e.columns.flatMap((K,Q)=>{const X=[];return X.push(u.jsx("div",{className:`nc-col${D(Q)?" drop-newcol":""}`,ref:T=>{w.current[Q]=T},style:{flexGrow:K.width,flexBasis:0},onDragOver:T=>{vu(T.dataTransfer)&&(T.preventDefault(),T.stopPropagation(),S&&S.col===Q&&S.row===void 0||_({col:Q}))},children:K.tiles.flatMap((T,N)=>{const P=[],O=wi(T);return P.push(u.jsx("div",{className:`nc-tile-slot${M(Q,N)}`,style:{flexGrow:T.height,flexBasis:0},onDragOver:$=>{if(!vu($.dataTransfer))return;$.preventDefault(),$.stopPropagation();const W=WC($.clientX,$.clientY,$.currentTarget.getBoundingClientRect());S&&S.col===Q&&S.row===N&&S.quadrant===W||_({col:Q,row:N,quadrant:W})},children:u.jsx($C,{session:T.session,node:T.node,ownerId:T.ownerId,token:i,readonly:s,focused:a===O,onFocus:c,onClose:J,onOpenSingle:h,available:T.unavailable!==!0,alive:T.unavailable!==!0&&(!o||o.has(O)),fontSize:T.fontSize,onZoom:$=>t(z0(e,Q,N,$)),decks:m,currentDeck:p,onSendToDeck:y})},O)),N<K.tiles.length-1&&P.push(u.jsx("div",{className:"nc-divider-h",onPointerDown:$=>B($,Q,N)},`h${N}`)),P})},`c${Q}`)),Q<b-1&&X.push(u.jsx("div",{className:"nc-divider-v",onPointerDown:T=>F(T,Q)},`v${Q}`)),X}),j&&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 fn="local",Ti=/^[a-f0-9]{16,64}$/;function Jr(e,t){return`${e&&Ti.test(e)?e:fn}:${t}`}function hh(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!==fn&&!Ti.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===fn?null:s,name:o}}function hl(e){return Array.isArray(e)&&e.length?e.join("/"):""}function fh(e){return{columns:pr(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))}}function KC(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&Ti.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(hl(i.route),i.instanceId);return t}function qC(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&Ti.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(i.instanceId,[...i.route]);return t}function Id(e,t,i=[]){const s=fh(e),o=KC(i);for(const a of s.columns)for(const c of a.tiles)c.ownerId||(!c.node&&Ti.test(String(t||""))?c.ownerId=t:c.node&&o.has(c.node)&&(c.ownerId=o.get(c.node)));return s}function Bd(e,t,i=[]){const s=fh(e),o=new Map;for(const a of i)a&&Ti.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=hl(o.get(c.ownerId)),delete c.unavailable):c.unavailable=!0);return s}function Ig(e,t,i=[]){const s=fh(e),o=qC(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=hl(o.get(c.ownerId))));return s}function ay(e,t,i=[]){const s=qn(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...Ti.test(String(t||""))?{ownerId:t}:{}};const o=i.find(a=>hl(a&&a.route)===s.node);return{...s,...o&&Ti.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const VC=/^[a-z0-9-]{1,32}$/,bi="main",ly="nc_decks",cy="nc_deck_order_v1",uy=24;function Bg(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function is(e){return typeof e=="string"&&VC.test(e)}function YC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let i;try{i=decodeURIComponent(t[1])}catch{i=t[1]}return is(i)?i:bi}return bi}function XC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:Jr(null,bi),ownerId:null,name:bi}}if(Ti.test(s)&&is(o))return{id:Jr(s,o),ownerId:s,name:o}}const i=YC(e);return{id:Jr(null,i),ownerId:null,name:i}}function _u(e,t){const i=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:hh(e)||{ownerId:null,name:e},s=is(i.name)?i.name:bi,o=i.ownerId?`/deck/${encodeURIComponent(i.ownerId)}/${encodeURIComponent(s)}`:s===bi?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function dy(e){return e===bi?"nc_grid_v1":`nc_grid_v1__${e}`}function hy(e){const t=[bi];if(Array.isArray(e)){for(const i of e)if(is(i)&&i!==bi&&!t.includes(i)&&t.push(i),t.length>=uy)break}return t}function os(){return typeof localStorage<"u"?localStorage:null}function GC(){const e=os();if(!e)return[bi];try{return hy(JSON.parse(e.getItem(ly)||"null"))}catch{return[bi]}}function QC(e){const t=os();if(t)try{t.setItem(ly,JSON.stringify(hy(e)))}catch{}}function _o(e){return e==="local"||Ti.test(String(e||""))}function fl(e,t){const i=hh(e);return!!i&&(i.ownerId||"local")===t}function tn(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[i,s]of Object.entries(e).slice(0,64)){if(!_o(i)||!Array.isArray(s))continue;const o=[...new Set(s.filter(a=>typeof a=="string"&&a.length<=100&&fl(a,i)))].slice(0,uy);o.length&&(t[i]=o)}return t}function Ia(e=os()){if(!e)return{};try{return tn(JSON.parse(e.getItem(cy)||"null"))}catch{return{}}}function yu(e,t=os()){const i=tn(e);if(t)try{t.setItem(cy,JSON.stringify(i))}catch{}return i}function pl(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function JC(e,t,i,s,o=[]){if(!_o(t)||i===s)return tn(e);const a=[...new Set(o.filter(S=>fl(S,t)))];if(!a.includes(i)||!a.includes(s))return tn(e);const c=pl(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),tn({...e,[t]:h})}function ZC(e,t,i,s){if(!_o(t)||!fl(s,t))return tn(e);const o=pl(e,t);return o.includes(i)?tn({...e,[t]:o.map(a=>a===i?s:a)}):tn(e)}function ex(e,t,i){return _o(t)?tn({...e,[t]:pl(e,t).filter(s=>s!==i)}):tn(e)}function Og(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)||"");!_o(a)||!fl(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=pl(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 Od(e){const t=os();if(!t)return null;try{return JSON.parse(t.getItem(dy(e))||"null")}catch{return null}}function tx(e,t){const i=os();if(i)try{i.setItem(dy(e),JSON.stringify(t))}catch{}}const zg=52,Fg=18;function ix({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,ee,F,B,J,K,Q,X;const k=a.current;if(!k)return;k.x=w,k.y=x;const b=(ee=(M=document.elementFromPoint(w,x))==null?void 0:M.closest)==null?void 0:ee.call(M,"[data-deck-id][data-owner-key]"),D=(F=b==null?void 0:b.dataset)==null?void 0:F.deckId,j=((B=b==null?void 0:b.dataset)==null?void 0:B.ownerKey)===e&&D&&D!==t;k.over!==(j?b:null)&&((K=(J=k.over)==null?void 0:J.classList)==null||K.remove("nc-deck-over"),k.over=j?b:null,(X=(Q=k.over)==null?void 0:Q.classList)==null||X.add("nc-deck-over")),k.target=j?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+zg?-Fg:w.x>x.right-zg?Fg: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 nx({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}){ki();const[_,C]=R.useState(null),[w,x]=R.useState(""),[k,b]=R.useState(!1),[D,j]=R.useState(""),[M,ee]=R.useState(""),F=Bg(w),B=is(F),J=[];for(const N of e){const P=N.local?"local":N.ownerId;let O=J.find($=>$.key===P);O||(O={key:P,label:N.ownerLabel||(N.local?"Local":P),local:!!N.local,decks:[]},J.push(O)),O.decks.push(N)}const K=async()=>{if(B){b(!0),j("");try{i&&await i(F,_),x(""),C(null)}catch(N){j(String(N.message||N))}b(!1)}},Q=N=>{ee(""),c&&c(N.id)||ee(N.id)},X=async N=>{if(!(N.id===t||!h||k||N.available===!1)){b(!0),j("");try{await h(N.id)}catch(P){j(String((P==null?void 0:P.message)||P))}b(!1)}},T=(N,P,O)=>{const $=N.decks.findIndex(z=>z.id===P.id),W=N.decks[$+O];$>=0&&W&&a&&!k&&a(P.id,W.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:J.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(ix,{ownerKey:N.key,deckId:P.id,label:`${N.label} · ${P.name}`,onMove:(O,$)=>{a&&!k&&a(O,$)},onStep:O=>T(N,P,O)}),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:()=>X(P),children:[P.name,P.id===t?" •":""]}),u.jsx("button",{className:"nc-deck-mini",disabled:P.available===!1,title:v("detach-deck"),onClick:()=>Q(P),children:"↗"}),P.name!==bi&&u.jsxs(u.Fragment,{children:[u.jsx("button",{className:"nc-deck-mini",disabled:P.available===!1,title:v("rename-deck"),onClick:()=>{const O=(typeof window<"u"?window.prompt(v("rename-deck"),P.name):"")||"",$=Bg(O);is($)&&$!==P.name&&s&&s(P.id,$).catch(W=>j(String(W.message||W)))},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(O=>j(String(O.message||O)))},children:"✕"})]})]},P.id)),_===N.key?u.jsxs("span",{className:"nc-deck-add",children:[u.jsx("input",{autoFocus:!0,className:B||!w?"":"invalid",placeholder:v("deck-name"),value:w,onChange:P=>x(P.target.value),onKeyDown:P=>{P.key==="Enter"&&K(),P.key==="Escape"&&(x(""),C(null))}}),w&&B&&F!==w&&u.jsxs("span",{className:"nc-deck-slug",children:["→ ",F]}),u.jsx("button",{className:"nc-deck-ok",disabled:!B||k,onClick:K,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 Vr={},Su,Hg;function rx(){return Hg||(Hg=1,Su=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Su}var wu={},zn={},$g;function Sr(){if($g)return zn;$g=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 zn.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},zn.getSymbolTotalCodewords=function(s){return t[s]},zn.getBCHDigit=function(i){let s=0;for(;i!==0;)s++,i>>>=1;return s},zn.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},zn.isKanjiModeEnabled=function(){return typeof e<"u"},zn.toSJIS=function(s){return e(s)},zn}var bu={},Wg;function ph(){return Wg||(Wg=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}}})(bu)),bu}var ku,Ug;function sx(){if(Ug)return ku;Ug=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++}},ku=e,ku}var Cu,Kg;function ox(){if(Kg)return Cu;Kg=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]},Cu=e,Cu}var xu={},qg;function ax(){return qg||(qg=1,(function(e){const t=Sr().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}})(xu)),xu}var Eu={},Vg;function lx(){if(Vg)return Eu;Vg=1;const e=Sr().getSymbolSize,t=7;return Eu.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},Eu}var Nu={},Yg;function cx(){return Yg||(Yg=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}})(Nu)),Nu}var Ba={},Xg;function fy(){if(Xg)return Ba;Xg=1;const e=ph(),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 Ba.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}},Ba.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}},Ba}var Ru={},Qs={},Gg;function ux(){if(Gg)return Qs;Gg=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]})(),Qs.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},Qs.exp=function(s){return e[s]},Qs.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},Qs}var Qg;function dx(){return Qg||(Qg=1,(function(e){const t=ux();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}})(Ru)),Ru}var Pu,Jg;function hx(){if(Jg)return Pu;Jg=1;const e=dx();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},Pu=t,Pu}var Du={},Lu={},Mu={},Zg;function py(){return Zg||(Zg=1,Mu.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Mu}var Gi={},ev;function my(){if(ev)return Gi;ev=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
+ ]))+`;Gi.KANJI=new RegExp(i,"g"),Gi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Gi.BYTE=new RegExp(s,"g"),Gi.NUMERIC=new RegExp(e,"g"),Gi.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+i+"$"),a=new RegExp("^"+e+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Gi.testKanji=function(m){return o.test(m)},Gi.testNumeric=function(m){return a.test(m)},Gi.testAlphanumeric=function(m){return c.test(m)},Gi}var tv;function wr(){return tv||(tv=1,(function(e){const t=py(),i=my();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}}})(Lu)),Lu}var iv;function fx(){return iv||(iv=1,(function(e){const t=Sr(),i=fy(),s=ph(),o=wr(),a=py(),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 j=D-p(x,C);switch(x){case o.NUMERIC:return Math.floor(j/10*3);case o.ALPHANUMERIC:return Math.floor(j/11*2);case o.KANJI:return Math.floor(j/13);case o.BYTE:default:return Math.floor(j/8)}},e.getBestVersionForData=function(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}})(Du)),Du}var ju={},nv;function px(){if(nv)return ju;nv=1;const e=Sr(),t=1335,i=21522,s=e.getBCHDigit(t);return ju.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},ju}var Tu={},Au,rv;function mx(){if(rv)return Au;rv=1;const e=wr();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))},Au=t,Au}var Iu,sv;function gx(){if(sv)return Iu;sv=1;const e=wr(),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)},Iu=i,Iu}var Bu,ov;function vx(){if(ov)return Bu;ov=1;const e=wr();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)},Bu=t,Bu}var Ou,av;function _x(){if(av)return Ou;av=1;const e=wr(),t=Sr();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)}},Ou=i,Ou}var zu={exports:{}},lv;function yx(){return lv||(lv=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})(zu)),zu.exports}var cv;function Sx(){return cv||(cv=1,(function(e){const t=wr(),i=mx(),s=gx(),o=vx(),a=_x(),c=my(),h=Sr(),m=yx();function p(b){return unescape(encodeURIComponent(b)).length}function y(b,D,j){const M=[];let ee;for(;(ee=b.exec(j))!==null;)M.push({data:ee[0],index:ee.index,mode:D,length:ee[0].length});return M}function S(b){const D=y(c.NUMERIC,t.NUMERIC,b),j=y(c.ALPHANUMERIC,t.ALPHANUMERIC,b);let M,ee;return h.isKanjiModeEnabled()?(M=y(c.BYTE,t.BYTE,b),ee=y(c.KANJI,t.KANJI,b)):(M=y(c.BYTE_KANJI,t.BYTE,b),ee=[]),D.concat(j,M,ee).sort(function(B,J){return B.index-J.index}).map(function(B){return{data:B.data,mode:B.mode,length:B.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,j){const M=D.length-1>=0?D[D.length-1]:null;return M&&M.mode===j.mode?(D[D.length-1].data+=j.data,D):(D.push(j),D)},[])}function w(b){const D=[];for(let j=0;j<b.length;j++){const M=b[j];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 j={},M={start:{}};let ee=["start"];for(let F=0;F<b.length;F++){const B=b[F],J=[];for(let K=0;K<B.length;K++){const Q=B[K],X=""+F+K;J.push(X),j[X]={node:Q,lastCount:0},M[X]={};for(let T=0;T<ee.length;T++){const N=ee[T];j[N]&&j[N].node.mode===Q.mode?(M[N][X]=_(j[N].lastCount+Q.length,Q.mode)-_(j[N].lastCount,Q.mode),j[N].lastCount+=Q.length):(j[N]&&(j[N].lastCount=Q.length),M[N][X]=_(Q.length,Q.mode)+4+t.getCharCountIndicator(Q.mode,D))}}ee=J}for(let F=0;F<ee.length;F++)M[ee[F]].end=0;return{map:M,table:j}}function k(b,D){let j;const M=t.getBestModeForData(b);if(j=t.from(D,M),j!==t.BYTE&&j.bit<M.bit)throw new Error('"'+b+'" cannot be encoded with mode '+t.toString(j)+`.
84
+ Suggested mode is: `+t.toString(M));switch(j===t.KANJI&&!h.isKanjiModeEnabled()&&(j=t.BYTE),j){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(j,M){return typeof M=="string"?j.push(k(M,null)):M.data&&j.push(k(M.data,M.mode)),j},[])},e.fromString=function(D,j){const M=S(D,h.isKanjiModeEnabled()),ee=w(M),F=x(ee,j),B=m.find_path(F.map,"start","end"),J=[];for(let K=1;K<B.length-1;K++)J.push(F.table[B[K]].node);return e.fromArray(C(J))},e.rawSplit=function(D){return e.fromArray(S(D,h.isKanjiModeEnabled()))}})(Tu)),Tu}var uv;function wx(){if(uv)return wu;uv=1;const e=Sr(),t=ph(),i=sx(),s=ox(),o=ax(),a=lx(),c=cx(),h=fy(),m=hx(),p=fx(),y=px(),S=wr(),_=Sx();function C(F,B){const J=F.size,K=a.getPositions(B);for(let Q=0;Q<K.length;Q++){const X=K[Q][0],T=K[Q][1];for(let N=-1;N<=7;N++)if(!(X+N<=-1||J<=X+N))for(let P=-1;P<=7;P++)T+P<=-1||J<=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?F.set(X+N,T+P,!0,!0):F.set(X+N,T+P,!1,!0))}}function w(F){const B=F.size;for(let J=8;J<B-8;J++){const K=J%2===0;F.set(J,6,K,!0),F.set(6,J,K,!0)}}function x(F,B){const J=o.getPositions(B);for(let K=0;K<J.length;K++){const Q=J[K][0],X=J[K][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?F.set(Q+T,X+N,!0,!0):F.set(Q+T,X+N,!1,!0)}}function k(F,B){const J=F.size,K=p.getEncodedBits(B);let Q,X,T;for(let N=0;N<18;N++)Q=Math.floor(N/3),X=N%3+J-8-3,T=(K>>N&1)===1,F.set(Q,X,T,!0),F.set(X,Q,T,!0)}function b(F,B,J){const K=F.size,Q=y.getEncodedBits(B,J);let X,T;for(X=0;X<15;X++)T=(Q>>X&1)===1,X<6?F.set(X,8,T,!0):X<8?F.set(X+1,8,T,!0):F.set(K-15+X,8,T,!0),X<8?F.set(8,K-X-1,T,!0):X<9?F.set(8,15-X-1+1,T,!0):F.set(8,15-X-1,T,!0);F.set(K-8,8,1,!0)}function D(F,B){const J=F.size;let K=-1,Q=J-1,X=7,T=0;for(let N=J-1;N>0;N-=2)for(N===6&&N--;;){for(let P=0;P<2;P++)if(!F.isReserved(Q,N-P)){let O=!1;T<B.length&&(O=(B[T]>>>X&1)===1),F.set(Q,N-P,O),X--,X===-1&&(T++,X=7)}if(Q+=K,Q<0||J<=Q){Q-=K,K=-K;break}}}function j(F,B,J){const K=new i;J.forEach(function(P){K.put(P.mode.bit,4),K.put(P.getLength(),S.getCharCountIndicator(P.mode,F)),P.write(K)});const Q=e.getSymbolTotalCodewords(F),X=h.getTotalCodewordsCount(F,B),T=(Q-X)*8;for(K.getLengthInBits()+4<=T&&K.put(0,4);K.getLengthInBits()%8!==0;)K.putBit(0);const N=(T-K.getLengthInBits())/8;for(let P=0;P<N;P++)K.put(P%2?17:236,8);return M(K,F,B)}function M(F,B,J){const K=e.getSymbolTotalCodewords(B),Q=h.getTotalCodewordsCount(B,J),X=K-Q,T=h.getBlocksCount(B,J),N=K%T,P=T-N,O=Math.floor(K/T),$=Math.floor(X/T),W=$+1,z=O-$,ne=new m(z);let H=0;const L=new Array(T),A=new Array(T);let ie=0;const me=new Uint8Array(F.buffer);for(let Ce=0;Ce<T;Ce++){const Ee=Ce<P?$:W;L[Ce]=me.slice(H,H+Ee),A[Ce]=ne.encode(L[Ce]),H+=Ee,ie=Math.max(ie,Ee)}const G=new Uint8Array(K);let Z=0,ce,de;for(ce=0;ce<ie;ce++)for(de=0;de<T;de++)ce<L[de].length&&(G[Z++]=L[de][ce]);for(ce=0;ce<z;ce++)for(de=0;de<T;de++)G[Z++]=A[de][ce];return G}function ee(F,B,J,K){let Q;if(Array.isArray(F))Q=_.fromArray(F);else if(typeof F=="string"){let O=B;if(!O){const $=_.rawSplit(F);O=p.getBestVersionForData($,J)}Q=_.fromString(F,O||40)}else throw new Error("Invalid data");const X=p.getBestVersionForData(Q,J);if(!X)throw new Error("The amount of data is too big to be stored in a QR Code");if(!B)B=X;else if(B<X)throw new Error(`
85
+ The chosen QR Code version cannot contain this amount of data.
86
+ Minimum version required to store current data is: `+X+`.
87
+ `);const T=j(B,J,Q),N=e.getSymbolSize(B),P=new s(N);return C(P,B),w(P),x(P,B),b(P,J,0),B>=7&&k(P,B),D(P,T),isNaN(K)&&(K=c.getBestMask(P,b.bind(null,P,J))),c.applyMask(K,P),b(P,J,K),{modules:P,version:B,errorCorrectionLevel:J,maskPattern:K,segments:Q}}return wu.create=function(B,J){if(typeof B>"u"||B==="")throw new Error("No input text");let K=t.M,Q,X;return typeof J<"u"&&(K=t.from(J.errorCorrectionLevel,t.M),Q=p.from(J.version),X=c.from(J.maskPattern),J.toSJISFunc&&e.setToSJISFunction(J.toSJISFunc)),ee(B,Q,K,X)},wu}var Fu={},Hu={},dv;function gy(){return dv||(dv=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}}})(Hu)),Hu}var hv;function bx(){return hv||(hv=1,(function(e){const t=gy();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)}})(Fu)),Fu}var $u={},fv;function kx(){if(fv)return $u;fv=1;const e=gy();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 $u.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},$u}var pv;function Cx(){if(pv)return Vr;pv=1;const e=rx(),t=wx(),i=bx(),s=kx();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 Vr.create=t.create,Vr.toCanvas=o.bind(null,i.render),Vr.toDataURL=o.bind(null,i.renderToDataURL),Vr.toString=o.bind(null,function(a,c,h){return s.render(a,h)}),Vr}var xx=Cx();const Ex=Wd(xx);function mv(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function Nx(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const i=X0(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 Rx(e,t,i=new Set,s=!1){if(!t||!t.ok)return e;const o=G0(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 gv(e,t,i=new Set,s=!1){const o=String(t||"").trim(),a=Nx(o);let c={...e,pairingUrl:o};return(a.kind==="complete"||a.kind==="partial")&&(c={...Rx(c,a.decoded,i,s),pairingUrl:o}),{classification:a,form:c}}function Ka(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=Un(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 Px(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||Ka(a,i)||s||"").trim();return c&&(o.localName=c),o}function Dx(){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 Lx=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function Mx(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 jx="modulepreload",Tx=function(e){return"/"+e},vv={},Ax=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=Tx(p),p in vv)return;vv[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":jx,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 Xe{constructor(t,i,s,o,a){this._legacyCanvasSize=Xe.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),s&&typeof s=="object"?this._onDecode=i:(console.warn(s||o||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=Xe.createQrEngine()}static set WORKER_PATH(t){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await Xe.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let i=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),s;try{t&&(await i()).every(o=>!o.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await i()).map((o,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"),Xe._stopVideoStream(s))}}async hasFlash(){let t;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;t=this.$video.srcObject}else t=(await this._getCameraStream()).stream;return"torch"in t.getVideoTracks()[0].getSettings()}catch{return!1}finally{t&&t!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),Xe._stopVideoStream(t))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(t){throw this._flashOn=!1,t}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),Xe._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:i}=await this._getCameraStream();!this._active||this._paused?Xe._stopVideoStream(t):(this._setVideoMirror(i),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(t){if(!this._paused)throw this._active=!1,t}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let i=()=>{this.$video.srcObject instanceof MediaStream&&(Xe._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(i(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(i(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,i,s,o,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||Xe.createQrEngine(),Xe._loadImage(t)]),[o,y]=Xe._drawToCanvas(p,h,o,a);let S;if(s instanceof Worker){let _=s;i||Xe._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:Xe._convertPoints(M.data.cornerPoints,h)}):w(Xe.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 j=y.getImageData(0,0,o.width,o.height);D=Xe._postWorkerMessageSync(_,"decode",j,[j.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 Xe.NO_QR_CODE_FOUND;return{data:_.rawValue,cornerPoints:Xe._convertPoints(_.cornerPoints,h)}}catch(C){if(_=C.message||C,/not implemented|service unavailable/.test(_))return Xe._disableBarcodeDetector=!0,Xe.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 Xe.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:a});return m?y:y.data}finally{i||Xe._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,i,s,o=!0){Xe._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:i,blue:s,useIntegerApproximation:o})}setInversionMode(t){Xe._postWorkerMessage(this._qrEnginePromise,"inversionMode",t)}static async createQrEngine(t){if(t&&console.warn("Specifying a worker path is not required and not supported anymore."),t=()=>Ax(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!Xe._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let i=navigator.userAgentData;return i&&i.brands.some(({brand:s})=>/Chromium/i.test(s))&&/mac ?OS/i.test(i.platform)&&await i.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:s,platformVersion:o})=>/arm/i.test(s||"arm")&&13<=parseInt(o||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let i=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-i)/2),y:Math.round((t.videoHeight-i)/2),width:i,height:i,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,i=t.videoWidth,s=t.videoHeight,o=t.offsetWidth,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 j=parseFloat(b);return b.endsWith("%")?(D?a-C:o-_)*j/100:j});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 Xe.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!Xe._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=Xe.createQrEngine()),s?(this._onDecode?this._onDecode(s):this._legacyOnDecode&&this._legacyOnDecode(s.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",s.cornerPoints.map(({x:o,y: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!==Xe.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",i=[{width:{min:1024}},{width:{min:768}},{}],s=i.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...s,...i])try{let 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 Xe._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(t instanceof File||t instanceof Blob||t instanceof URL||typeof t=="string"){let i=new Image;i.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await Xe._awaitImageLoad(i),i}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(i.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((i,s)=>{let o=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 Xe._postWorkerMessageSync(await t,i,s,o)}static _postWorkerMessageSync(t,i,s,o){if(!(t instanceof Worker))return-1;let a=Xe._workerMessageId++;return t.postMessage({id:a,type:i,data:s},o),a}}Xe.DEFAULT_CANVAS_SIZE=400;Xe.NO_QR_CODE_FOUND="No QR code found";Xe._disableBarcodeDetector=!1;Xe._workerMessageId=0;function Ix({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 Xe.hasCamera()}catch{S=!1}if(!S){c(v("qr-no-camera"));return}if(m||!p)return;const _=new Xe(p,C=>{const w=mv(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 Xe.scanImage(p,{returnDetailedScanResult:!0}),S=mv(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 _v=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:"",localName:""});function vy({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(_v),[S,_]=R.useState(!1),[C,w]=R.useState(!1),[x,k]=R.useState("idle"),[b,D]=R.useState(null),[j,M]=R.useState(""),[ee,F]=R.useState(!1),[B,J]=R.useState(!1),K=R.useRef(Dx()),Q=R.useRef(new Set),X=x==="busy",T=Ka(p.localLabel||s,o)||a,N=B?p.localName:T;R.useEffect(()=>(m&&m(X),()=>{m&&m(!1)}),[X,m]);const P=async H=>{const L=String(H.pairingUrl||"").trim();if(K.current.start(L)){k("busy"),D(null),M("");try{await Jw(e,Px({...H,localName:B?H.localName:Ka(H.localLabel||s,o)||a},{deviceDefault:s,localNodeId:o,localNameDefault:a})),k("ok"),_(!1),y(_v()),Q.current=new Set,F(!1),J(!1),K.current.finish(),h&&await h()}catch(A){const ie=Mx(A);D(ie),k("idle"),K.current.finish(),ie.code==="peer-name-conflict"&&Gu(ie.suggestedName)&&(J(!0),Q.current.add("localName"),y(me=>({...me,localName:ie.suggestedName}))),(ie.stage==="validation"||ie.stage==="conflict"||ie.stage==="ssh-start"||ie.stage==="ssh-ready"||String(ie.code||"").startsWith("ssh-"))&&_(!0)}}},O=(H,L=!0)=>{const{classification:A,form:ie}=gv(p,H,Q.current,ee),me=ie.pairingUrl;if(D(null),M(""),x==="ok"&&k("idle"),y(ie),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"&&L&&!c&&K.current.canAuto(me)&&P(ie)};R.useEffect(()=>{t&&O(t,i)},[]);const $=()=>{const H=String(p.pairingUrl||"").trim(),{classification:L,form:A}=gv(p,H,Q.current,ee);if(y(A),M(""),D(null),L.kind==="empty"){D({stage:"validation",message:v("pairing-required"),retryable:!0});return}if(L.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&&!oo(A.label)){D({stage:"validation",message:v("err-label"),retryable:!0});return}if(A.localLabel&&!oo(A.localLabel)){D({stage:"validation",message:v("err-label"),retryable:!0});return}const ie=B?A.localName:Ka(A.localLabel||s,o)||a;if(!Gu(ie)||ie==="localhost"){_(!0),D({stage:"validation",code:"bad-local-name",message:v("err-local-name"),retryable:!0});return}K.current.reset(H),P(A)},W=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const H=await navigator.clipboard.readText();H&&H.trim()?O(H):M(v("pair-clipboard-empty"))}catch{M(v("pair-clipboard-denied"))}},z=(H,L)=>{Q.current.add(H),y(A=>({...A,[H]:L}))},ne=b&&b.stage&&(Lx.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||X,onChange:H=>{y({...p,pairingUrl:H.target.value}),D(null),M("")},onPaste:H=>{const L=H.clipboardData&&H.clipboardData.getData("text")||"";L.trim()&&(H.preventDefault(),O(L))},onKeyDown:H=>{H.key==="Enter"&&(H.preventDefault(),$())}}),u.jsxs("div",{className:"nc-pair-actions",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||X,onClick:W,children:v("pair-paste-btn")}),u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||X,onClick:()=>w(!0),children:v("scan-qr")}),u.jsx("button",{type:"button",className:"nc-btn primary",disabled:c||X,title:c?v("settings-readonly"):"",onClick:$,children:v("test-and-connect")})]}),u.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[X&&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")}),j&&u.jsx("div",{className:"nc-set-hint nc-pair-notice",children:j}),b&&u.jsxs("div",{className:"nc-err",role:"alert",children:[u.jsx("b",{children:ne})," — ",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||X,onClick:$,children:v("pair-retry")})})]})]}),u.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:X,onClick:()=>_(H=>!H),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||X,onChange:H=>{Q.current.add("label"),y(L=>({...L,label:H.target.value,name:ee?L.name:Un(H.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||X,onChange:H=>{F(!0),Q.current.add("name"),y(L=>({...L,name:H.target.value?Un(H.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||X,onChange:H=>{Q.current.add("ssh"),z("ssh",H.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||X,onChange:H=>z("sshPort",H.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||X,onChange:H=>z("localLabel",H.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||X,onChange:H=>{J(!0),Q.current.add("localName"),y(L=>({...L,localName:H.target.value?Un(H.target.value):""}))}}),u.jsx("small",{className:"nc-set-hint",children:v("local-route-name-hint")})]})]}),C&&u.jsx(Ix,{onResult:H=>{w(!1),O(H)},onClose:()=>w(!1)})]})}function mh(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function Bx(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 Ox(){if(!mh())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function zx(e){if(!mh())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const i=await Ht("/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:Bx(s)}),c=await Ht("/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 Fx(e){if(!mh())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 Ht("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const _y="nexuscrew.fleet",yy=2,Hx="nexuscrew.cells",$x=/^[A-Za-z0-9._-]{1,32}$/,gh=/^[a-z0-9._-]{1,32}$/,Sy=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,Wx=new Set(["standard","unsafe"]),Ux=4096,yv=256,Kx=8192,qx=32,Vx=24,Yx=new Set(["format","version","exportedAt","cells","engines"]),Xx=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]),Gx=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag"]),Qx=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]);function ur(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function wy(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 Sv(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(!gh.test(o)||!t(a))return null;s[o]=a}return s}function by(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(a=>!Xx.has(a))||!$x.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>Ux||!gh.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>yv)||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>Kx)return null;const i=Sv(e.models,a=>typeof a=="string"&&!!a&&a.length<=yv),s=Sv(e.permissionPolicies,a=>Wx.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 Jx(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(i=>!Qx.has(i)))return null;const t={};for(const[i,s]of Object.entries(e)){if(typeof s!="string"||!ur(s,i==="baseUrl"?512:128)||wy(s))return null;t[i]=s}return!t.client||!t.provider||t.envKey&&!Sy.test(t.envKey)?null:t}function ky(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!Gx.has(s))||!gh.test(String(e.id||""))||!ur(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=Jx(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!ur(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!ur(s,1024)||wy(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!ur(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")||!ur(e.model.flag,32)||/\s/.test(e.model.flag)||!ur(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=>!Sy.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 Cy(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=ky(t);return i||null}function Zx(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=by({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=Cy(p);y&&m.push(y)}return{format:_y,version:yy,exportedAt:o.toISOString(),cells:h,engines:m}}function eE(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)===Hx&&(t==null?void 0:t.version)===1;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(h=>!Yx.has(h))||!i&&(t.format!==_y||t.version!==yy)||!Array.isArray(t.cells)||t.cells.length>qx||!i&&(!Array.isArray(t.engines)||t.engines.length>Vx))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const s=[],o=new Set;for(const h of t.cells){const m=by(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=ky(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 tE(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 iE=()=>({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}),wv=(e="")=>({id:"",cwd:"",engine:e,boot:!1,model:"",prompt:""}),xy=e=>e==="claude"?"unsafe":"standard",uo=(e,t)=>e.find(i=>i.client===t.client&&i.provider===t.provider&&(i.credentialProfile||"")===(t.credentialProfile||"")),nE=(e,t)=>{var i;return((i=uo(e,t))==null?void 0:i.label)||`${t.client} · ${t.provider}`};function rE(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)||xy((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 sE(e,t,i=[]){if(e.kind==="managed"){const o={client:e.client,provider:e.provider,model:e.managedModel||"",permissionPolicy:e.permissionPolicy||xy(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile);const a=uo(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||nE(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 Yr({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 Wu({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 j=[{route:[],label:v("local")}].concat((t||[]).map(ee=>({route:Array.isArray(ee.route)?ee.route:[],label:ee.label||(ee.route||[]).join(" › ")}))),M=await Promise.all(j.map(async ee=>{const F={...ee,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const B=await _r(e,ee.route);F.available=!!B.available,F.capabilities=B.capabilities||[],F.provider=B.provider||null,F.cells=(B.cells||[]).map(J=>({...J,route:ee.route}));try{F.readonly=!!(await Yd(e,ee.route)).readonlyDefault}catch{}try{const J=await Iv(e,ee.route),K=new Set(F.cells.map(Q=>Q.tmuxSession).filter(Boolean));F.unmanaged=(J.sessions||[]).filter(Q=>Q&&!K.has(Q.name))}catch{}}catch(B){F.err=String(B&&B.message||B)}return F}));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 Zs(e,k.cell,b)}catch{}y()},w=async(k,b)=>{if(window.confirm(v("fleet-remove-cell").replace("{id}",k.cell))){try{await Mv(e,k.cell,!0,b)}catch{}y()}},x=async(k,b)=>{if(window.confirm(v("terminate-confirm").replace("{name}",k.name))){try{await Vd(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 oE({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)),j=new Set(e.map(N=>N.id)),M=(N,P)=>N(O=>{const $=new Set(O);return $.has(P)?$.delete(P):$.add(P),$}),ee=()=>{const N=Zx(e,m,t,y),P=t.filter(z=>y.has(z.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 O=new Blob([`${JSON.stringify(N,null,2)}
91
+ `],{type:"application/json"}),$=URL.createObjectURL(O),W=document.createElement("a");W.href=$,W.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(W),W.click(),W.remove(),setTimeout(()=>URL.revokeObjectURL($),0),b("")},F=async N=>{if(b(""),C([]),x([]),!!N){if(N.size>1024*1024){b(v("fleet-backup-too-large"));return}try{const P=eE(await N.text());if(!P.ok){b(v(`fleet-backup-${P.error}`));return}const O=new Set(P.engines.map($=>$.id));x(P.engines.map($=>({engine:$,exists:D.has($.id),selected:!D.has($.id)}))),C(P.cells.map($=>{const W=D.has($.engine)||O.has($.engine),z=j.has($.id);return{cell:$,engine:W?$.engine:"",selected:W&&!z,exists:z}}))}catch(P){b(String(P.message||P))}}},B=(N,P)=>C(O=>O.map(($,W)=>W===N?{...$,...P}:$)),J=(N,P)=>x(O=>O.map(($,W)=>W===N?{...$,...P}:$)),K=new Set([...D,...w.filter(N=>N.selected).map(N=>N.engine.id)]),Q=_.filter(N=>N.selected&&N.engine&&K.has(N.engine)),X=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:ee,children:v("fleet-backup-download")})]})]}):u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"file",accept:"application/json,.json",disabled:i,onChange:N=>F(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 O;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:$=>J(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"),(O=N.engine.envKeys)!=null&&O.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||!K.has(N.engine),onChange:O=>B(P,{selected:O.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:O=>B(P,{engine:O.target.value,selected:!!O.target.value}),children:[u.jsx("option",{value:"",children:v("fleet-backup-engine-missing")}),T.map(([O,$])=>u.jsx("option",{value:O,children:$},O))]})]},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||!Q.length&&!X.length,onClick:()=>o({engineRows:w,cellRows:_}),children:v("fleet-backup-restore")})]})]}),k&&u.jsx("div",{className:"nc-err",children:k})]})}function aE({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=uo(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=uo(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,j)=>b&&j.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:j=>{const M=h.slice();M[D]={...b,key:j.target.value},c({envRows:M})}}),u.jsx("input",{type:"password",value:b.value,placeholder:b.configured?"•••••• (unchanged)":"value",onChange:j=>{const M=h.slice();M[D]={...b,value:j.target.value},c({envRows:M})}}),u.jsx("button",{className:"nc-btn danger",onClick:()=>c({envRows:h.filter((j,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 lE({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=j=>c({...a,form:{...w,...j}}),k=h.find(j=>j.id===w.engine),b=j=>{var ee,F,B;const M=h.find(J=>J.id===j);x({engine:j,model:((ee=w.models)==null?void 0:ee[j])||((F=M==null?void 0:M.managed)==null?void 0:F.model)||((B=M==null?void 0:M.model)==null?void 0:B.value)||""})},D=async j=>{try{const M=await Tv(e,j,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:j=>{o(j.target.value),x({engine:""})},children:[u.jsx("option",{value:"",children:v("local")}),i.map(j=>u.jsxs("option",{value:j.route.join("/"),disabled:j.status&&j.status!=="up",children:[j.label,j.status&&j.status!=="up"?` · ${v("node-offline")}`:""]},j.route.join("/")))]})]}),u.jsx("input",{value:w.id,disabled:a.mode!=="new",placeholder:"id",onChange:j=>x({id:j.target.value})}),u.jsxs("div",{className:"nc-fleet-pair",children:[u.jsx("input",{value:w.cwd,placeholder:v("cwd"),onChange:j=>x({cwd:j.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(j=>u.jsxs("button",{className:"nc-fs-item",onClick:()=>D(`${y.path.replace(/\/$/,"")}/${j}`),children:["📁 ",j]},j))]})]}),_&&u.jsx("div",{className:"nc-err",children:_}),u.jsx("select",{value:w.engine,onChange:j=>b(j.target.value),children:h.map(j=>u.jsx("option",{value:j.id,children:j.label},j.id))}),u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:!!w.boot,onChange:j=>x({boot:j.target.checked})})," boot"]}),u.jsx("input",{value:w.model||"",list:"nc-cell-models",placeholder:v("fleet-model-override"),onChange:j=>x({model:j.target.value})}),u.jsx("datalist",{id:"nc-cell-models",children:((k==null?void 0:k.availableModels)||[]).map(j=>u.jsx("option",{value:j},j))}),u.jsx("textarea",{value:w.prompt||"",placeholder:"prompt",onChange:j=>x({prompt:j.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 bv({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 qd(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 Tv(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 cE({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(""),[j,M]=R.useState(""),[ee,F]=R.useState(o),[B,J]=R.useState(!1),[K,Q]=R.useState(null),[X,T]=R.useState(null),[N,P]=R.useState(!1),[O,$]=R.useState([]),[W,z]=R.useState(null),[ne,H]=R.useState("manage"),L=R.useRef(!1),A=ee?ee.split("/"):[],ie=R.useCallback(async()=>{try{const q=await _r(e,A);m(q);try{const pe=await Yd(e,A);J(!!pe.readonlyDefault)}catch{J(!1)}if(q.provider==="builtin"&&(q.capabilities||[]).includes("definitions")){const pe=await qd(e,A),ve=new Map((q.engines||[]).map(be=>[be.id,be]));if(pe.engines=(pe.engines||[]).map(be=>{var ae;return{...be,availableModels:((ae=ve.get(be.id))==null?void 0:ae.models)||[]}}),c(pe),(q.capabilities||[]).includes("credentials"))try{$((await Ow(e,A)).credentials||[])}catch{$([])}else $([])}D("")}catch(q){D(String(q.message||q))}finally{y(!0)}},[e,ee]);R.useEffect(()=>{ie();const q=setInterval(ie,5e3);return()=>clearInterval(q)},[ie]);const me=new Set((h.cells||[]).filter(q=>q.active).map(q=>q.cell)),G=h.provider==="builtin"&&(h.capabilities||[]).includes("edit"),Z=(h.capabilities||[]).includes("restore");R.useEffect(()=>{!s||L.current||!G||!a.engines.length||(L.current=!0,w({mode:"new",form:wv(a.engines[0].id)}))},[s,G,a.engines]);const ce=async q=>{k(!0),D(""),M("");try{await q(),await ie()}catch(pe){D(String(pe.message||pe))}k(!1)},de=()=>ce(async()=>{var Se;const q=S.mode==="new",pe=S.form,ve=a.managedCatalog||[],be=pe.kind==="managed"?uo(ve,pe):null,ae=typeof(be==null?void 0:be.credentialEnv)=="string"?be.credentialEnv:"",je=ae&&pe.credentialValue||"",Ne=sE(pe,q,ve);!q&&S.form.kind==="custom"&&!S.form.modelFlag&&(Ne.model=null),!q&&S.form.kind==="custom"&&S.form.promptMode!=="flag"&&(Ne.promptFlag=null);let ze;if(q)ze=await Fw(e,Ne,A);else{const $e=S.original,ot=new Set(S.form.envRows.filter(ue=>!ue.remove).map(ue=>ue.key)),Rt=($e.envKeys||[]).filter(ue=>!ot.has(ue)),wt=Object.fromEntries(S.form.envRows.filter(ue=>!ue.remove&&ue.key&&(!ue.configured||ue.value!=="")).map(ue=>[ue.key,ue.value]));ze=await Hw(e,$e.id,Ne,S.form.kind==="custom"?{set:wt,remove:Rt}:void 0,A)}let Be=null;if(ae&&je)try{Be=await dm(e,ae,je,A),$(Be.credentials||[])}catch{throw await ie(),q&&_({mode:"edit",original:{...Ne,id:pe.id},form:{...pe,credentialReveal:!1}}),new Error(v(q?"fleet-key-partial-create":"fleet-key-partial-edit"))}await ie(),_(null),M(v("fleet-saved"));const st=((Se=((Be==null?void 0:Be.credentials)||[]).find($e=>$e.envKey===ae))==null?void 0:Se.activeCells)||[],he=[...new Set([...(ze==null?void 0:ze.activeCells)||[],...st])];if(he.length&&window.confirm(v("fleet-restart-confirm").replace("{cells}",he.join(", "))))for(const $e of he)await Zs(e,$e,A)}),Ce=()=>ce(async()=>{const q=C.mode==="new",pe=C.form,ve={...q?{id:pe.id}:{},cwd:pe.cwd,engine:pe.engine,boot:!!pe.boot};q?(pe.model&&(ve.model=pe.model),pe.prompt&&(ve.prompt=pe.prompt)):(ve.model=pe.model||null,ve.prompt=pe.prompt||null);const be=q?await Ww(e,ve,A):await Uw(e,C.original.id,ve,A),ae=q?pe.id:C.original.id;w(null),M(v("fleet-saved")),!q&&(be!=null&&be.active)&&window.confirm(v("fleet-restart-confirm").replace("{cells}",ae))&&await Zs(e,ae,A)}),Ee=t||B,Ve=q=>O.find(pe=>{var ve;return(ve=pe.engines)==null?void 0:ve.includes(q.id)})||null,qe=()=>ce(async()=>{var ve;const q=await dm(e,W.envKey,W.value,A);$(q.credentials||[]),z(null),M(v("fleet-credential-saved"));const pe=((ve=(q.credentials||[]).find(be=>be.envKey===W.envKey))==null?void 0:ve.activeCells)||[];if(pe.length&&window.confirm(v("fleet-restart-confirm").replace("{cells}",pe.join(", "))))for(const be of pe)await Zs(e,be,A)}),xe=q=>ce(async()=>{if(!window.confirm(v("fleet-credential-remove-confirm").replace("{key}",q.envKey)))return;const pe=await zw(e,q.envKey,A);$(pe.credentials||[]),M(v("fleet-credential-removed"))}),it=q=>Q({...q,route:Array.isArray(q==null?void 0:q.route)?q.route:A}),St=async q=>{if(!K)return;const pe=K.cell||K.id,ve=Array.isArray(K.route)?K.route:A;q.action==="up"?await Kd(e,{cell:pe,boot:!!q.boot,...q.engine?{engine:q.engine}:{},...q.model!==void 0?{model:q.model}:{},...q.permissionPolicy?{permissionPolicy:q.permissionPolicy}:{}},ve):await qa(e,{cell:pe,boot:!!q.boot},ve)},se=(q,pe)=>{D(""),T({mode:"new",route:Array.isArray(pe)?pe:A,form:{tmuxSession:q.name,id:"",engine:"",cwd:"",boot:!1},err:""})},le=()=>ce(async()=>{const q=X.form;if(!q.engine){T({...X,err:v("import-engine-required")});return}await Kw(e,{tmuxSession:q.tmuxSession,id:q.id||void 0,engine:q.engine,cwd:q.cwd||void 0,boot:!!q.boot},q.route||A),T(null),M(v("fleet-saved"))}),Oe=({engineRows:q=[],cellRows:pe=[]})=>ce(async()=>{const ve=q.filter(Se=>Se.selected),be=ve.map(Se=>Cy(Se.engine));if(be.some(Se=>!Se))throw new Error(v("fleet-backup-invalid-engine"));const ae=ve.filter(Se=>Se.exists).map(Se=>Se.engine.id);if(ae.length&&!window.confirm(v("fleet-backup-confirm-engine-overwrite").replace("{engines}",ae.join(", "))))return;const je=[...new Set([...a.engines.map(Se=>Se.id),...be.map(Se=>Se.id)])],Ne=[];for(const Se of pe.filter($e=>$e.selected)){const $e=tE(Se.cell,Se.engine,je);if(!$e)throw new Error(`${Se.cell.id}: ${v("fleet-backup-engine-missing")}`);Ne.push($e)}const ze=pe.filter(Se=>Se.selected&&Se.exists).map(Se=>Se.cell.id);if(ze.length&&!window.confirm(v("fleet-backup-confirm-overwrite").replace("{cells}",ze.join(", "))))return;const Be=be.length?await Vw(e,be,ae.length>0,A):{needsRestart:[]},st=Ne.length?await qw(e,Ne,A):{needsRestart:[]},he=[...new Set([...Be.needsRestart||[],...st.needsRestart||[]])];P(!1),M(`${v("fleet-backup-restored").replace("{n}",String(Ne.length))}${be.length?` · ${be.length} ${v("fleet-engines").toLowerCase()}`:""}${he.length?` · ${v("fleet-backup-needs-restart").replace("{cells}",he.join(", "))}`:""}`)}),Te=u.jsxs("label",{className:"nc-field",children:[v("location"),u.jsxs("select",{value:ee,onChange:q=>{F(q.target.value),_(null),w(null),D(""),M(""),J(!1),y(!1),m({available:!1,capabilities:[]}),c({engines:[],cells:[],managedCatalog:[]}),$([]),z(null)},children:[u.jsx("option",{value:"",children:v("local")}),i.map(q=>u.jsxs("option",{value:q.route.join("/"),disabled:q.status&&q.status!=="up",children:[q.label,q.status&&q.status!=="up"?` · ${v("node-offline")}`:""]},q.route.join("/")))]})]}),V=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":ne==="manage",className:`nc-set-tabbtn${ne==="manage"?" on":""}`,onClick:()=>H("manage"),children:v("fleet-manage-location")}),u.jsx("button",{type:"button",role:"tab","aria-selected":ne==="overview",className:`nc-set-tabbtn${ne==="overview"?" on":""}`,onClick:()=>H("overview"),children:v("fleet-network-overview")})]});return p?G?u.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[V,ne==="overview"?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"nc-set-info",children:v("fleet-overview-help")}),u.jsx(Wu,{token:e,targets:i,readonly:t,onPower:it,onImport:se})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"nc-set-info",children:v("fleet-manage-help")}),Te,u.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[u.jsx("button",{className:"nc-btn ghost",disabled:Ee||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:Ee||x||!a.engines.length,onClick:()=>{var q;D(""),w({mode:"new",form:wv((q=a.engines[0])==null?void 0:q.id)})},children:["+ ",v("add")]})})]}),a.cells.map(q=>{const pe=me.has(q.id),ve=h.capabilities||[];return u.jsxs("div",{className:"nc-fleet-item",children:[u.jsxs("span",{children:[u.jsx("b",{children:q.id}),u.jsxs("small",{children:[q.engine," · ",q.cwd,pe?` · ${v("service-active")}`:` · ${v("cell-off")}`]})]}),u.jsxs("span",{children:[pe&&ve.includes("down")&&u.jsx("button",{className:"nc-btn ghost",disabled:Ee||x,onClick:()=>ce(()=>qa(e,{cell:q.id},A)),children:v("stop")}),!pe&&ve.includes("up")&&u.jsx("button",{className:"nc-btn primary",disabled:Ee||x,onClick:()=>it({cell:q.id,id:q.id,engine:q.engine,model:q.model,models:q.models,permissionPolicies:q.permissionPolicies,active:!1,boot:q.boot}),children:v("start")}),pe&&ve.includes("restart")&&u.jsx("button",{className:"nc-btn ghost",disabled:Ee||x,onClick:()=>ce(()=>Zs(e,q.id,A)),children:v("restart")}),u.jsx("button",{className:"nc-btn ghost",disabled:Ee||x,onClick:()=>{D(""),w({mode:"edit",original:q,form:{...q}})},children:v("edit")}),u.jsx("button",{className:"nc-btn danger",disabled:Ee||x,onClick:()=>ce(async()=>{window.confirm(v("fleet-remove-cell").replace("{id}",q.id))&&await Mv(e,q.id,!0,A)}),children:"×"})]})]},q.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:Ee||x,onClick:()=>{D(""),_({mode:"new",form:iE()})},children:["+ ",v("add")]})]}),a.engines.map(q=>{var ve,be;const pe=Ve(q);return u.jsxs("div",{className:"nc-fleet-item",children:[u.jsxs("span",{children:[u.jsx("b",{children:q.label}),u.jsx("small",{children:q.managed?`${q.id} · ${q.managed.client} / ${q.managed.provider} · ${(ve=q.managedInfo)!=null&&ve.configured?v("fleet-ready"):((be=q.managedInfo)==null?void 0:be.reason)||v("fleet-not-ready")}`:`${q.id} · ${q.command}`}),pe&&u.jsxs("small",{children:[pe.envKey," · ",v(`fleet-credential-source-${pe.source||"missing"}`)]})]}),u.jsxs("span",{children:[pe&&u.jsx("button",{className:"nc-btn ghost",disabled:Ee||x,onClick:()=>{D(""),z({envKey:pe.envKey,value:""})},children:pe.configured?v("fleet-credential-change"):v("fleet-credential-set")}),(pe==null?void 0:pe.source)==="local"&&u.jsx("button",{className:"nc-btn danger",disabled:Ee||x,onClick:()=>xe(pe),children:v("fleet-credential-forget")}),u.jsx("button",{className:"nc-btn ghost",disabled:Ee||x,onClick:()=>{D(""),_({mode:"edit",original:q,form:rE(q)})},children:v("edit")}),u.jsx("button",{className:"nc-btn danger",disabled:Ee||x,onClick:()=>ce(async()=>{window.confirm(v("fleet-remove-engine").replace("{id}",q.id))&&await $w(e,q.id,A)}),children:"×"})]})]},q.id)})]}),S&&u.jsx(Yr,{onClose:()=>_(null),label:v("fleet-new-engine"),error:b,children:u.jsx(aE,{state:S,setState:_,busy:x,onSave:de,catalog:a.managedCatalog||[]})}),C&&u.jsx(Yr,{onClose:()=>w(null),label:v("fleet-new-cell"),error:b,children:u.jsx(lE,{token:e,route:A,targets:i,location:ee,setLocation:F,state:C,setState:w,engines:a.engines,busy:x,onSave:Ce})}),j&&u.jsx("div",{className:"nc-set-note",children:j}),b&&u.jsx("div",{className:"nc-err",children:b}),N&&u.jsx(Yr,{onClose:()=>P(!1),label:v("fleet-backup"),error:b,children:u.jsx(oE,{cells:a.cells,engines:a.engines,busy:x,canRestore:Z,onRestore:Oe,onClose:()=>P(!1)})}),W&&u.jsx(Yr,{onClose:()=>z(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:[W.envKey,u.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:W.value,onChange:q=>z({...W,value:q.target.value})})]}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{className:"nc-btn ghost",onClick:()=>z(null),children:v("cancel")}),u.jsx("button",{className:"nc-btn primary",disabled:x||!W.value,onClick:qe,children:v("save")})]})]})}),X&&u.jsx(Yr,{onClose:()=>T(null),label:v("import-as-cell"),error:b,children:u.jsx(bv,{token:e,route:X.route||A,state:X,setState:T,busy:x,onSave:le})}),K&&u.jsx(Va,{cell:K,token:e,route:Array.isArray(K.route)?K.route:A,onConfirm:async q=>{try{await St(q)}finally{await ie()}},onClose:()=>Q(null)})]}):u.jsxs("div",{className:"nc-set-tab",children:[V,ne==="overview"?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"nc-set-info",children:v("fleet-overview-help")}),u.jsx(Wu,{token:e,targets:i,readonly:t,onPower:it,onImport:se})]}):u.jsxs(u.Fragment,{children:[Te,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}),X&&u.jsx(Yr,{onClose:()=>T(null),label:v("import-as-cell"),error:b,children:u.jsx(bv,{token:e,route:X.route||A,state:X,setState:T,busy:x,onSave:le})}),K&&u.jsx(Va,{cell:K,token:e,route:Array.isArray(K.route)?K.route:A,onConfirm:async q=>{try{await St(q)}finally{await ie()}},onClose:()=>Q(null)})]}):u.jsxs("div",{className:"nc-set-tab",children:[V,ne==="overview"?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"nc-set-info",children:v("fleet-overview-help")}),u.jsx(Wu,{token:e,targets:i,readonly:t,onPower:it,onImport:se})]}):u.jsxs(u.Fragment,{children:[Te,u.jsx("div",{className:"nc-set-info",children:v("fleet-editor-loading")})]})]})}function uE({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 dE({value:e}){const[t,i]=R.useState("");return R.useEffect(()=>{let s=!0;return Ex.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 hE({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(""),[j,M]=R.useState(""),[ee,F]=R.useState(!1),[B,J]=R.useState(null),[K,Q]=R.useState(null),X=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,O=N.find(G=>G.name===b)||N[0]||null,$=O?Rm(O.tunnel,X):null,W=O!=null&&O.shared?$!=null&&$.up?"share-local-active":"share-local-pending":$!=null&&$.up?"share-local-private":"share-local-private-down",z=[{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")}],ne=async(G,Z)=>{c(null),m(`${G}:${Z}`);try{const ce=await Xd(e,G,Z);Z==="test"&&y(de=>({...de,[G]:ce})),await o()}catch(ce){c(`${G}: ${String(ce.message||ce)}`)}m(null)},H=async G=>{c(null),m(`${G}:remove`);try{await e0(e,G),Q(null),await o()}catch(Z){c(`${G}: ${String(Z.message||Z)}`)}m(null)},L=G=>J({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(!B||!oo(B.label)){c(v("err-label"));return}const G=B.direction==="inbound"?{label:B.label,visibility:B.visibility,selected:B.visibility==="selected"?B.selected:[]}:{label:B.label,ssh:B.ssh,autostart:B.autostart,...B.sshPort?{sshPort:Number(B.sshPort)}:{}};c(null),m(`${B.name}:edit`);try{await Zw(e,B.name,G),J(null),await o()}catch(Z){c(`${B.name}: ${String(Z.message||Z)}`)}m(null)},ie=async G=>{if(O){c(null),m(`${O.name}:share`);try{await t0(e,O.name,G),await o()}catch(Z){const ce=Z!=null&&Z.data&&typeof Z.data.hint=="string"?Z.data.hint:"";c(`${O.name}: ${String(Z.message||Z)}${ce?` — ${ce}`:""}`)}m(null)}},me=async()=>{if(c(null),P){const ce=Nm({name:P.name,ssh:P.ssh,sshPort:P.sshPort||""});if(!ce.ok){c(v(ce.error));return}m("invite");try{_(await fm(e,{ssh:ce.value.ssh,...ce.value.sshPort?{sshPort:ce.value.sshPort}:{}},[P.name]))}catch(de){c(String(de.message||de))}m(null);return}const G=Un(C.name||j||T||"NexusCrew"),Z=Nm({name:G,ssh:C.ssh,sshPort:C.sshPort});if(!Z.ok){c(v(Z.error));return}m("invite");try{_(await fm(e,{...j||T?{label:j||T}:{},name:G,ssh:Z.value.ssh,...Z.value.sshPort?{sshPort:Z.value.sshPort}:{}}))}catch(ce){c(String(ce.message||ce))}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")}),z.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 Ve,qe;const ce=Z.kind==="transitive",de=ce?{up:Z.stale!==!0,label:Z.stale===!0?"peer-routed-stale":"peer-routed"}:Rm(Z.tunnel,X),Ce=p[Z.name],Ee=Z.actions||{};return u.jsxs("div",{className:`nc-set-node${ce?" 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,ce?` · ${Z.route.join(" → ")}`:Z.direction==="outbound"?` · SSH ${Z.ssh||""}`:` · ${v("node-connected-client")}`,(Ve=Z.tunnel)!=null&&Ve.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}`:""]})]}),!ce&&Z.direction==="inbound"&&u.jsx("div",{className:"nc-set-info",children:v(Z.shared?"peer-shared":"peer-private")}),Ee.visibility&&Z.shared&&u.jsxs(u.Fragment,{children:[u.jsxs("select",{value:Z.visibility||"network",disabled:s||!!h,onChange:async xe=>{m(`${Z.name}:visibility`);try{await pm(e,Z.name,xe.target.value),await o()}catch(it){c(String(it.message||it))}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(xe=>xe.name!==Z.name&&xe.nodeId).map(xe=>{const it=(Z.selected||[]).includes(xe.nodeId);return u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:it,disabled:s||!!h,onChange:async St=>{const se=St.target.checked?[...Z.selected||[],xe.nodeId]:(Z.selected||[]).filter(le=>le!==xe.nodeId);m(`${Z.name}:visibility`);try{await pm(e,Z.name,"selected",se),await o()}catch(le){c(String(le.message||le))}m(null)}})," ",xe.label||xe.name]},xe.nodeId)})})]}),u.jsxs("div",{className:"nc-set-node-actions",children:[Ee.edit&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!h,onClick:()=>L(Z),children:v("edit")}),Ee.test&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!h,onClick:()=>ne(Z.name,"test"),children:v("node-test")}),Ee.disconnect&&de.up&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!h,onClick:()=>ne(Z.name,"down"),children:v("tunnel-stop")}),Ee.connect&&!de.up&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!h,onClick:()=>ne(Z.name,"up"),children:v("tunnel-start")}),Ee.restart&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!h,onClick:()=>ne(Z.name,"restart"),children:v("tunnel-restart")}),Ee.remove&&u.jsxs("button",{type:"button",className:"nc-btn danger",disabled:s||!!h,title:v(s?"settings-readonly":"delete"),onClick:()=>Q(Z.name),children:[u.jsx(et,{name:"trash",size:14})," ",v("delete")]})]}),(B==null?void 0:B.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:B.label,disabled:!!h,onChange:xe=>J({...B,label:xe.target.value})})]}),B.direction==="outbound"?u.jsxs(u.Fragment,{children:[u.jsxs("label",{className:"nc-field",children:[v("node-ssh-label"),u.jsx("input",{value:B.ssh,disabled:!!h,onChange:xe=>J({...B,ssh:xe.target.value})})]}),u.jsxs("label",{className:"nc-field",children:[v("node-ssh-port-label"),u.jsx("input",{inputMode:"numeric",value:B.sshPort,disabled:!!h,onChange:xe=>J({...B,sshPort:xe.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:B.autostart,disabled:!!h,onChange:xe=>J({...B,autostart:xe.target.checked})})," ",v("boot-persist")]})]}):u.jsxs("label",{className:"nc-field",children:[v("peer-visibility"),u.jsxs("select",{value:B.visibility,disabled:!!h,onChange:xe=>J({...B,visibility:xe.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:()=>J(null),children:v("cancel")})]})]}),K===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:()=>H(Z.name),children:v("delete")}),u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!h,onClick:()=>Q(null),children:v("cancel")})]})]}),((qe=Z.health)==null?void 0:qe.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)),O&&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:O.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:O.shared===!0,disabled:s||!!h,onChange:G=>ie(G.target.checked)}),u.jsxs("span",{children:[u.jsx("b",{children:v("share-local-through").replace("{device}",T||v("local")).replace("{hub}",O.label||O.name)}),u.jsx("small",{children:v(O.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),u.jsx("div",{className:`nc-set-test${O.shared&&($!=null&&$.up)?" ok":$!=null&&$.up?"":" ko"}`,children:v(W)}),!($!=null&&$.up)&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!h,onClick:()=>ie(O.shared===!0),children:v("share-local-reconnect")})]}),u.jsx(vy,{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&&ee&&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:j,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:Un(j||T||v("node-name-ph")),value:C.name,disabled:s,onChange:G=>w({...C,name:G.target.value?Un(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:me,children:v("create-pairing-link")}),!P&&u.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!h,onClick:()=>F(G=>!G),children:[ee?"▾":"▸"," ",v("pair-advanced")]})]}),S&&u.jsxs(u.Fragment,{children:[u.jsx(dE,{value:S.pairingUrl}),u.jsx(uE,{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 fE({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 Ox().then(y=>{p||s(y)}),()=>{p=!0}},[]);const m=async()=>{h(null),a(!0);try{i==="subscribed"?(await Fx(e),s("idle")):(await zx(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 pE({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 B=await Qw(e);h(B.note||"ok"),p(!1)}catch(B){a(String(B.message||B))}S(!1)},b=async()=>{a(null),h(null),S(!0);try{const B=await i0(e);h(`${B.note||"ok"}${B.target?` (${B.target})`:""}`)}catch(B){a(String(B.message||B))}S(!1)},D=async B=>{a(null),h(null),S(!0);try{await Bv(e,{autoUpdate:B}),x(B),s&&await s()}catch(J){a(String(J.message||J))}S(!1)},j=async()=>{a(null),h(null),S(!0);try{C(await n0(e))}catch(B){a(String(B.message||B))}S(!1)},M=async()=>{a(null),h(null),S(!0);try{const B=await r0(e);C(B),h(v("npm-update-restarting"))}catch(B){a(String(B.message||B))}S(!1)},ee=()=>{window.confirm(v("composer-clear-confirm"))&&(a(null),jC()?(window.dispatchEvent(new Event(Td)),h(v("composer-clear-done"))):a(v("composer-clear-failed")))},F=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",{}),F&&F.installed?v("service-installed"):v("service-missing"),F&&F.installed?` · ${F.active?v("service-active"):v("service-inactive")}`:"",F?` · boot ${F.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:B=>D(B.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:j,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(fE,{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:ee,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 mE({token:e,onClose:t,initialTab:i="nodes",initialLocation:s="",startNewCell:o=!1}){ki();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=Qd(e),k=R.useCallback(async()=>{try{const b=await Av(e);m(b),w(null)}catch(b){w(String(b.message||b))}try{const b=await Xw(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 Ht("/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(hE,{token:e,nodes:p,settings:h,readonly:S,refresh:k}),a==="fleet"&&u.jsx(cE,{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(pE,{token:e,settings:h,readonly:S,refresh:k})]})]})})}function gE({token:e,initialPair:t,deviceDefault:i="",localNodeId:s="",localNameDefault:o="",onPairDone:a,onDone:c}){ki();const[h,m]=R.useState(t?"pair":"welcome"),[p,y]=R.useState(!1),[S,_]=R.useState(null),C=async()=>{y(!0),_(null);try{await Bv(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(vy,{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 vE(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 _E=6e3,yE=12e3;function SE({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 wE({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 o0(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 bE({token:e}){ki();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"?yE:_E)},[m]);R.useEffect(()=>{if(!e)return;let S=!1;s0(e).then(C=>{S||o(C.asks||[])}).catch(()=>{});const _=vE(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(SE,{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(wE,{ask:S,token:e,onAnswered:y},S.id))})]})]})}const Uu=e=>Zi(pr(e)).length===0,Ku=e=>Array.isArray(e)?e.join("/"):"";function kE(e){const t=new Set,i=[];for(const s of Array.isArray(e)?e:[])!s||!Ti.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 Js(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function ar(e,t,i,s=!1,o=!0){const a=t.instanceId;return{...e,id:Jr(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:Id(e.layout,a,i)}}function CE(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),j=R.useRef(i),M=R.useRef(!1),ee=R.useRef(!0),F=R.useRef(""),B=R.useMemo(()=>kE(o),[o]),J=B.map(H=>`${H.instanceId}:${Ku(H.route)}:${H.status}:${H.label}`).join("|");k.current=B,j.current=i,D.current=t,x.current=a;const K=R.useCallback(H=>Bd(H.layout,b.current,k.current),[]),Q=R.useCallback((H,L=!0,A=D.current)=>{const ie=Og(H,Ia()),me=x.current.some(Z=>Z.id===A);x.current=ie,c(ie);const G=ie.find(Z=>Z.id===A);if(L&&G){ee.current=!0;const Z=K(G);s(Z),G.local&&tx(G.name,Z)}else me&&!G&&(ee.current=!0,s(Qr()),_("deck non più condiviso dal nodo owner"));QC(ie.filter(Z=>Z.local).map(Z=>Z.name))},[s,K]),X=R.useCallback(async H=>{let L=await Na(e);const A=L.decks.find(ie=>ie.name==="main");if(L.decks.length===1&&A&&A.revision===0&&Uu(A.layout)){const ie=GC(),me=pr(Od("main")||Qr());if(!Uu(me)){const G=Id(me,H,[]);L.decks[0]=await Ra(e,"main",G,0,[])}for(const G of ie.filter(Z=>Z!=="main"))try{let Z=await mm(e,G,[]);const ce=pr(Od(G)||Qr());Uu(ce)||(Z=await Ra(e,G,Id(ce,H,[]),Z.revision,[]))}catch{}L=await Na(e)}return L},[e]),T=R.useCallback(async({migrate:H=!1}={})=>{const L=await Yd(e,[]),A=Ti.test(String(L.instanceId||""))?L.instanceId:"";if(!A)throw new Error("instanceId locale non disponibile");b.current=A,w(A);const[ie,me]=await Promise.all([H?X(A):Na(e),hm(e,[]).catch(()=>({nodes:[]}))]),G={instanceId:A,route:[],label:"Local"},Z=ie.decks.map(de=>ar(de,G,me.nodes,!0,!0)),ce=x.current;return await Promise.all(k.current.map(async de=>{if(de.status!=="up"){Z.push(...ce.filter(Ce=>!Ce.local&&Ce.ownerId===de.instanceId).map(Ce=>({...Ce,ownerRoute:[...de.route],ownerLabel:de.label,available:!1})));return}try{const[Ce,Ee]=await Promise.all([Na(e,de.route),hm(e,de.route).catch(()=>({nodes:[]}))]);Z.push(...Ce.decks.map(Ve=>ar(Ve,de,Ee.nodes,!1,!0)))}catch{Z.push(...ce.filter(Ee=>!Ee.local&&Ee.ownerId===de.instanceId).map(Ee=>({...Ee,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,X,J]);R.useEffect(()=>{if(!e)return;let H=!1;const L=F.current!==e;return F.current=e,T({migrate:L}).then(A=>{if(H)return;const ie=x.current.find(Z=>Z.id===D.current),me=A.find(Z=>Z.id===D.current),G=me&&(!ie||me.revision>ie.revision||ie.available!==me.available||Ku(ie.ownerRoute)!==Ku(me.ownerRoute));Q(A,L||!!G&&!M.current),m(!0),me&&_("")}).catch(A=>{H||(m(!0),_(String(A.message||A)))}),()=>{H=!0}},[Q,T,J,e]);const N=R.useCallback(async(H=D.current)=>{if(!h||!M.current)return!0;const L=x.current.find(A=>A.id===H);if(!L)return _(`deck inesistente: ${H}`),!1;if(L.available===!1)return _(`nodo owner offline: ${L.ownerLabel}`),!1;y("saving");try{const A=Ig(pr(j.current),L.ownerId,L.ownerTopology),ie=await Ra(e,L.name,A,L.revision,L.ownerRoute),me=ar(ie,Js(L),L.ownerTopology,L.local,!0);return Q(x.current.map(G=>G.id===H?me: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 ie=x.current.find(G=>G.id===H),me=ar(A.data.current,Js(ie),ie.ownerTopology,ie.local,!0);Q(x.current.map(G=>G.id===H?me:G),!1)}return!1}},[h,e,Q]);return R.useEffect(()=>{if(!h)return;if(ee.current){ee.current=!1;return}M.current=!0,y("saving");const H=setTimeout(N,650);return()=>clearTimeout(H)},[i,h,N]),R.useEffect(()=>{if(!h)return;const H=setInterval(async()=>{try{const L=await T(),A=x.current.find(G=>G.id===D.current),ie=L.find(G=>G.id===D.current),me=ie&&(!A||ie.revision>A.revision||A.available!==ie.available);Q(L,me&&!M.current)}catch{}},5e3);return()=>clearInterval(H)},[h,T,Q]),{decks:a,records:a,localNodeId:C,ready:h,saveState:p,error:S,setError:_,saveNow:N,select:async H=>{if(M.current&&!await N(D.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const L=x.current.find(A=>A.id===H);if(!L)throw new Error(`deck inesistente: ${H}`);return M.current=!1,ee.current=!0,K(L)},add:async(H,L=null)=>{const A=L===fn?x.current.find(G=>G.local):L?x.current.find(G=>G.ownerId===L):null;if(!A||A.available===!1)throw new Error("nodo owner non disponibile");const ie=await mm(e,H,A.ownerRoute),me=ar(ie,Js(A),A.ownerTopology,A.local,!0);return Q([...x.current,me],!1),me},rename:async(H,L)=>{const A=x.current.find(ce=>ce.id===H);if(!A)throw new Error("deck inesistente");if(H===D.current&&M.current&&!await N(H))throw new Error(`salvataggio di "${A.name}" fallito: rinomina annullata`);const ie=x.current.find(ce=>ce.id===H);if(!ie)throw new Error("deck inesistente");const me=await a0(e,ie.name,L,ie.revision,ie.ownerRoute),G=ar(me,Js(ie),ie.ownerTopology,ie.local,!0),Z=ie.local?fn:ie.ownerId;return yu(ZC(Ia(),Z,H,G.id)),Q(x.current.map(ce=>ce.id===H?G:ce),!1),G},remove:async H=>{const L=x.current.find(ie=>ie.id===H);if(!L)throw new Error("deck inesistente");H===D.current&&(M.current=!1),await l0(e,L.name,L.revision,L.ownerRoute);const A=L.local?fn:L.ownerId;yu(ex(Ia(),A,H)),Q(x.current.filter(ie=>ie.id!==H),!1)},reorder:(H,L)=>{const A=x.current.find(de=>de.id===H),ie=x.current.find(de=>de.id===L);if(!A||!ie)return!1;const me=A.local?fn:A.ownerId,G=ie.local?fn:ie.ownerId;if(me!==G)return!1;const Z=x.current.filter(de=>(de.local?fn:de.ownerId)===me).map(de=>de.id),ce=yu(JC(Ia(),me,H,L,Z));return Q(Og(x.current,ce),!1),!0},addTileTo:async(H,L)=>{const A=x.current.find(de=>de.id===H);if(!A)throw new Error("deck inesistente");if(A.available===!1)throw new Error(`nodo owner offline: ${A.ownerLabel}`);const ie=ay(L,b.current,k.current);if(!ie)throw new Error("riferimento sessione non valido");const me=K(A),G=Ig(t_(me,ie),A.ownerId,A.ownerTopology),Z=await Ra(e,A.name,G,A.revision,A.ownerRoute),ce=ar(Z,Js(A),A.ownerTopology,A.local,!0);return Q(x.current.map(de=>de.id===H?ce:de),!1),ce},localMainId:Jr(null,"main"),parseDeckId:hh}}const xE="/sw.js",zd="nc-sw-update";let Fd=null,Hd=!1,$d=null,Ey=Object.freeze({needed:!1,kind:null,version:""}),Ny=!1;function Ry(){typeof window<"u"&&window.dispatchEvent(new Event(zd))}function Py(){const e=$d||(Hd?{kind:"reload",version:""}:null);Ey=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function kv(){return Ey}function EE(e){return typeof window>"u"?()=>{}:(window.addEventListener(zd,e),()=>window.removeEventListener(zd,e))}function vh(e){Hd!==e&&(Hd=e,Py(),Ry())}function NE(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($d);$d=s,Py(),o||Ry()}function RE(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&vh(!0)})}function PE(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{Ny&&location.reload()}),navigator.serviceWorker.register(xE).then(e=>{Fd=e,e.waiting&&vh(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&RE(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function DE(){Ny=!0,vh(!1);const e=Fd&&Fd.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function LE({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 Dy=9,Ly=24,My="nc_side_w",Cv="nc_side_min",ME=240,xv="(min-width:1024px) and (pointer:fine)";function jE(){const e=Number(localStorage.getItem(My));return e>=180&&e<=480?e:ME}function TE(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=Dy&&e<=Ly?e:13}function AE(){const e={token:"",pair:""};try{const{token:t,pair:i,nextUrl:s}=LE({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 IE(e){try{return pr(Od(e))}catch{return Qr()}}function Ev(e){if(!e)return"";const t=Math.floor(Date.now()/1e3)-e;return t<0||t<60?"ora":t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}g`}function BE(){const[e,t]=R.useState(()=>window.matchMedia(xv).matches);return R.useEffect(()=>{const i=window.matchMedia(xv),s=o=>t(o.matches);return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[]),e}function Nv({session:e,node:t,ownerId:i,token:s,readonly:o=!1,onBack:a}){ki();const[c,h]=R.useState(!1),[m,p]=R.useState(()=>window.matchMedia("(pointer: coarse)").matches),[y,S]=R.useState(null),[_,C]=R.useState(TE),[w,x]=R.useState(""),k=Q=>C(X=>{const T=Math.max(Dy,Math.min(Ly,X+Q));return localStorage.setItem("nc_fontsize",String(T)),T}),b=R.useRef(()=>{}),D=R.useRef(()=>!1),j=R.useRef(()=>{}),M=R.useRef(!1),[ee,F]=R.useState(!1),[B,J]=R.useState(!1),K=()=>{M.current=!M.current,F(M.current)};return R.useEffect(()=>{let Q=!0;const X=t?t.split("/"):[],T=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function N(){let O=null,$=null;try{const ne=await(await Ht(`${T}/sessions`,s)).json();Array.isArray(ne.sessions)&&(O=ne.sessions.find(H=>H.name===e))}catch{}try{const z=await _r(s,X);z.available&&Array.isArray(z.cells)&&($=z.cells.find(ne=>ne.tmuxSession===e))}catch{}if(!Q)return;let W="";$?W=`${$.engine}${$.key?`·${$.key}`:""}`:O&&(W=O.attached?`attached · ${Ev(O.activity)}`:O.activity?Ev(O.activity):""),x(W)}N();const P=setInterval(N,4e3);return()=>{Q=!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(Q=>!Q),title:v("composer"),children:u.jsx(et,{name:"keyboard",size:20})}),u.jsx("button",{onClick:()=>h(Q=>!Q),title:v("files"),children:u.jsx(et,{name:"folder",size:20})})]})]}),u.jsx("div",{className:"nc-termwrap",children:u.jsx(X_,{session:e,node:t,token:s,readonly:o,takeSize:!0,sendRef:b,composerRef:D,actionRef:j,ctrlRef:M,setCtrlArmed:F,onFiles:S,fontSize:_,selectionMode:B,onSelectionModeChange:J})}),u.jsx(bC,{onKeyboard:()=>p(Q=>!Q),send:Q=>b.current(Q),action:Q=>j.current(Q),ctrlArmed:ee,onCtrl:K,selectionMode:B,onSelectionMode:J}),m&&u.jsx(sy,{submitText:Q=>D.current(Q),token:s,session:e,node:t,ownerId:i}),c&&u.jsx(G_,{session:e,node:t,token:s,filesEvent:y,onClose:()=>h(!1)})]})}function OE(){ki();const[e]=R.useState(AE),[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=BE(),[p]=R.useState(()=>XC(typeof location<"u"?location.pathname:"/")),[y,S]=R.useState(p.id),_=y===Jr(null,bi),[C,w]=R.useState(null),x=ue=>w(qn(ue)),[k,b]=R.useState([]),[D,j]=R.useState([]),[M,ee]=R.useState(()=>p.ownerId?Qr():IE(p.name)),[F,B]=R.useState(null),[J,K]=R.useState(null),Q=ue=>K(qn(ue)),X=Qd(t,m),T=R.useMemo(()=>(X||[]).filter(ue=>ue.instanceId).map(ue=>({instanceId:ue.instanceId,route:ue.route,label:ue.label,status:ue.status})),[X]),N=CE(t,y,M,ee,T),P=N.decks;R.useEffect(()=>{const ue=new Map;for(const Ae of X||[]){const Ye=(Ae.route||[Ae.name]).join("/"),Yt=new Set((Ae.sessions||[]).map(Xt=>Xt.name));for(const Xt of Ae.cells||[])!Xt.cell||!Xt.tmuxSession||Xt.cell===Xt.tmuxSession||Yt.has(Xt.cell)||ue.set(`${Ye}:${Xt.cell}`,`${Ye}:${Xt.tmuxSession}`)}ee(Ae=>I0(Ae,ue))},[X]),R.useEffect(()=>{N.localNodeId&&ee(ue=>{const Ae=Bd(ue,N.localNodeId,T);return JSON.stringify(Ae)===JSON.stringify(ue)?ue:Ae})},[T,N.localNodeId]);const[O,$]=R.useState(null),[W,z]=R.useState(!1),[ne,H]=R.useState(jE),[L,A]=R.useState(!_),[ie,me]=R.useState(()=>_?localStorage.getItem(Cv)==="1":!0),[G,Z]=R.useState(!1),[ce,de]=R.useState("nodes"),[Ce,Ee]=R.useState(!1),[Ve,qe]=R.useState(""),xe=(ue="nodes",Ae=!1,Ye="")=>{de(ue),Ee(Ae),qe(Ye),Z(!0)},[it,St]=R.useState(!1),[se,le]=R.useState({deviceDefault:"",localNodeId:"",localNameDefault:""}),[Oe,Te]=R.useState(!1);R.useEffect(()=>{try{localStorage.setItem(My,String(ne))}catch{}},[ne]),R.useEffect(()=>{try{localStorage.setItem(Cv,ie?"1":"")}catch{}},[ie]),R.useEffect(()=>{if(!t)return;let ue=!1;return Promise.all([Av(t),Ht("/api/config",t).then(Ae=>Ae.json())]).then(([Ae,Ye])=>{ue||(le({deviceDefault:Ae.deviceName||"",localNodeId:Ae.nodeId||"",localNameDefault:Ae.localName||""}),Te(!!Ye.readonlyDefault),(Ae.firstRun===!0&&!Ye.readonlyDefault||s)&&St(!0))}).catch(()=>{}),()=>{ue=!0}},[t,s]);const V=R.useCallback(async()=>{try{const Ae=await(await Ht("/api/sessions",t)).json();Ae.error||b(Ae.sessions||[])}catch{}try{const ue=await _r(t);j(ue.available?ue.cells||[]:[])}catch{j([])}},[t]);R.useEffect(()=>{if(!m)return;V();const ue=setInterval(V,4e3);return()=>clearInterval(ue)},[m,V]),R.useEffect(()=>{let ue=!1;return Ht("/api/config",t).then(Ae=>Ae.json()).then(Ae=>{ue||NE(Ae.version,Ae.uiVersion,"0.8.24")}).catch(()=>{}),()=>{ue=!0}},[t]);const q=new Set([...k.map(ue=>ue.name),...X.flatMap(ue=>ue.sessions.map(Ae=>Ae.key))]),pe=Zi(M),ve=ue=>ee(Ae=>{const Ye=ay(ue,N.localNodeId,T)||ue,Yt=t_(Ae,Ye);return Yt===Ae&&Zi(Ae).length>=9&&N.setError(v("grid-full")),Yt}),be=async(ue,Ae=[])=>{try{await Vd(t,ue,Ae)}catch{return}const Ye=Ae.length?`${Ae.join("/")}:${ue}`:ue;ee(Yt=>Ja(Yt,Ye)),V()},ae=async(ue,Ae,Ye=[])=>{try{await jv(t,ue,Ae,Ye)}catch{return}V()},je=async ue=>{if(!O)return;const{cell:Ae}=O,Ye=Array.isArray(O.route)?O.route:[];ue.action==="up"?await Kd(t,{cell:Ae,boot:!!ue.boot,...ue.engine?{engine:ue.engine}:{},...ue.model!==void 0?{model:ue.model}:{},...ue.permissionPolicy?{permissionPolicy:ue.permissionPolicy}:{}},Ye):await qa(t,{cell:Ae,boot:!!ue.boot},Ye),V()},Ne=async ue=>{if(!(!(ue!=null&&ue.direct)||W)){z(!0);try{await Xd(t,ue.name,ue.tunnelStatus==="up"?"down":"up")}finally{z(!1)}}},ze=async(ue,Ae)=>{const Ye=String(Ae||"").trim();return!(ue!=null&&ue.direct)||!oo(Ye)?!1:(await Ov(t,ue.name,Ye),!0)},Be=ue=>{const Ae=P.find(Ye=>Ye.id===ue);if(!Ae)return!1;try{const Ye=window.open(_u(Ae,t),"_blank");return Ye&&(Ye.opener=null),!!Ye}catch{return!1}},st=async ue=>{if(!ue||ue===y)return;const Ae=await N.select(ue),Ye=N.records.find(Yt=>Yt.id===ue);S(ue),ee(Ae),B(null),K(null);try{history.replaceState(null,"",_u(Ye||ue,null))}catch{}},he=async(ue,Ae)=>{const Ye=await N.add(ue,Ae);await st(Ye.id)},Se=async(ue,Ae)=>{const Ye=await N.rename(ue,Ae);if(ue===y){S(Ye.id),ee(Bd(Ye.layout,N.localNodeId,T)),B(null),K(null);try{history.replaceState(null,"",_u(Ye,null))}catch{}}},$e=async ue=>{await N.remove(ue),ue===y&&await st(N.localMainId)},ot=async(ue,Ae)=>{!Ae||Ae===y||(await N.addTileTo(Ae,ue),ee(Ye=>Ja(Ye,ue)))};if(!t)return u.jsxs("div",{className:"nc-auth",children:[u.jsx("p",{children:v("auth-prompt")}),u.jsx("input",{onChange:ue=>i(ue.target.value.trim()),placeholder:"token"}),u.jsxs("label",{children:[u.jsx("input",{type:"checkbox",checked:c,onChange:ue=>h(ue.target.checked)})," ",v("remember-device")]}),u.jsx("button",{onClick:()=>{(c?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const Rt=u.jsxs(u.Fragment,{children:[G&&u.jsx(mE,{token:t,initialTab:ce,initialLocation:Ve,startNewCell:Ce,onClose:()=>{Z(!1),Ee(!1),qe("")}}),it&&u.jsx(gE,{token:t,initialPair:s,...se,onPairDone:a,onDone:()=>St(!1)}),u.jsx(bE,{token:t})]});if(!m)return C?u.jsxs(u.Fragment,{children:[u.jsx(Nv,{session:C.session,node:C.node,ownerId:C.ownerId,token:t,readonly:Oe,onBack:()=>w(null)}),Rt]}):u.jsxs(u.Fragment,{children:[u.jsx(Q0,{onPick:x,token:t,onSettings:xe}),Rt]});const wt=_||!L;return u.jsxs("div",{className:"nc-workspace",children:[wt&&u.jsx(zC,{sessions:k,cells:D,activeSessions:pe,nodeGroups:X,localNodeId:N.localNodeId,onPick:Q,onAddTile:ve,onPower:$,onNodePower:Ne,onNodeRename:ze,onKill:be,onVisibility:ae,onNew:()=>xe("fleet",!0),onSettings:xe,width:ne,collapsed:ie,onResize:H,onToggleCollapse:()=>me(ue=>!ue)}),u.jsxs("div",{className:"nc-workspace-main",children:[u.jsx(nx,{decks:P,currentDeck:y,onCreate:he,onRename:Se,onDelete:$e,onReorder:N.reorder,onOpenWindow:Be,onNavigate:st,saveState:N.saveState,error:N.error,sidebarVisible:wt,onToggleSidebar:_?null:()=>A(ue=>!ue)}),u.jsx(UC,{layout:M,onLayoutChange:ee,token:t,readonly:Oe,sessionsAlive:q,focusSession:F,onFocus:B,onOpenSingle:Q,decks:P,currentDeck:y,onSendToDeck:ot})]}),J&&u.jsx("div",{className:"nc-single-overlay",children:u.jsx(Nv,{session:J.session,node:J.node,ownerId:J.ownerId,token:t,readonly:Oe,onBack:()=>K(null)})}),O&&u.jsx(Va,{cell:O,token:t,route:Array.isArray(O.route)?O.route:[],onConfirm:je,onClose:()=>$(null)}),Rt]})}function zE(){ki();const e=R.useSyncExternalStore(EE,kv,kv);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:DE,children:v("reload")})]})}PE();Bw.createRoot(document.getElementById("root")).render(u.jsxs(Dw.StrictMode,{children:[u.jsx(OE,{}),u.jsx(zE,{})]}));