@mmmbuto/nexuscrew 0.8.9 → 0.8.10

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.
@@ -1,91 +0,0 @@
1
- (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&n(u)}).observe(document,{childList:!0,subtree:!0});function r(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function n(o){if(o.ep)return;o.ep=!0;const l=r(o);fetch(o.href,l)}})();function dh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var kc={exports:{}},Cn={},Ec={exports:{}},Te={};/**
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 yp;function oS(){if(yp)return Te;yp=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),u=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),S=Symbol.iterator;function v(I){return I===null||typeof I!="object"?null:(I=S&&I[S]||I["@@iterator"],typeof I=="function"?I:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,x={};function E(I,K,ne){this.props=I,this.context=K,this.refs=x,this.updater=ne||_}E.prototype.isReactComponent={},E.prototype.setState=function(I,K){if(typeof I!="object"&&typeof I!="function"&&I!=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,I,K,"setState")},E.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function N(){}N.prototype=E.prototype;function $(I,K,ne){this.props=I,this.context=K,this.refs=x,this.updater=ne||_}var z=$.prototype=new N;z.constructor=$,b(z,E.prototype),z.isPureReactComponent=!0;var j=Array.isArray,U=Object.prototype.hasOwnProperty,O={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function Z(I,K,ne){var B,se={},ae=null,me=null;if(K!=null)for(B in K.ref!==void 0&&(me=K.ref),K.key!==void 0&&(ae=""+K.key),K)U.call(K,B)&&!F.hasOwnProperty(B)&&(se[B]=K[B]);var ue=arguments.length-2;if(ue===1)se.children=ne;else if(1<ue){for(var ee=Array(ue),ge=0;ge<ue;ge++)ee[ge]=arguments[ge+2];se.children=ee}if(I&&I.defaultProps)for(B in ue=I.defaultProps,ue)se[B]===void 0&&(se[B]=ue[B]);return{$$typeof:e,type:I,key:ae,ref:me,props:se,_owner:O.current}}function R(I,K){return{$$typeof:e,type:I.type,key:K,ref:I.ref,props:I.props,_owner:I._owner}}function H(I){return typeof I=="object"&&I!==null&&I.$$typeof===e}function A(I){var K={"=":"=0",":":"=2"};return"$"+I.replace(/[=:]/g,function(ne){return K[ne]})}var P=/\/+/g;function L(I,K){return typeof I=="object"&&I!==null&&I.key!=null?A(""+I.key):K.toString(36)}function T(I,K,ne,B,se){var ae=typeof I;(ae==="undefined"||ae==="boolean")&&(I=null);var me=!1;if(I===null)me=!0;else switch(ae){case"string":case"number":me=!0;break;case"object":switch(I.$$typeof){case e:case t:me=!0}}if(me)return me=I,se=se(me),I=B===""?"."+L(me,0):B,j(se)?(ne="",I!=null&&(ne=I.replace(P,"$&/")+"/"),T(se,K,ne,"",function(ge){return ge})):se!=null&&(H(se)&&(se=R(se,ne+(!se.key||me&&me.key===se.key?"":(""+se.key).replace(P,"$&/")+"/")+I)),K.push(se)),1;if(me=0,B=B===""?".":B+":",j(I))for(var ue=0;ue<I.length;ue++){ae=I[ue];var ee=B+L(ae,ue);me+=T(ae,K,ne,ee,se)}else if(ee=v(I),typeof ee=="function")for(I=ee.call(I),ue=0;!(ae=I.next()).done;)ae=ae.value,ee=B+L(ae,ue++),me+=T(ae,K,ne,ee,se);else if(ae==="object")throw K=String(I),Error("Objects are not valid as a React child (found: "+(K==="[object Object]"?"object with keys {"+Object.keys(I).join(", ")+"}":K)+"). If you meant to render a collection of children, use an array instead.");return me}function Y(I,K,ne){if(I==null)return I;var B=[],se=0;return T(I,B,"","",function(ae){return K.call(ne,ae,se++)}),B}function Q(I){if(I._status===-1){var K=I._result;K=K(),K.then(function(ne){(I._status===0||I._status===-1)&&(I._status=1,I._result=ne)},function(ne){(I._status===0||I._status===-1)&&(I._status=2,I._result=ne)}),I._status===-1&&(I._status=0,I._result=K)}if(I._status===1)return I._result.default;throw I._result}var G={current:null},k={transition:null},V={ReactCurrentDispatcher:G,ReactCurrentBatchConfig:k,ReactCurrentOwner:O};function re(){throw Error("act(...) is not supported in production builds of React.")}return Te.Children={map:Y,forEach:function(I,K,ne){Y(I,function(){K.apply(this,arguments)},ne)},count:function(I){var K=0;return Y(I,function(){K++}),K},toArray:function(I){return Y(I,function(K){return K})||[]},only:function(I){if(!H(I))throw Error("React.Children.only expected to receive a single React element child.");return I}},Te.Component=E,Te.Fragment=r,Te.Profiler=o,Te.PureComponent=$,Te.StrictMode=n,Te.Suspense=m,Te.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,Te.act=re,Te.cloneElement=function(I,K,ne){if(I==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+I+".");var B=b({},I.props),se=I.key,ae=I.ref,me=I._owner;if(K!=null){if(K.ref!==void 0&&(ae=K.ref,me=O.current),K.key!==void 0&&(se=""+K.key),I.type&&I.type.defaultProps)var ue=I.type.defaultProps;for(ee in K)U.call(K,ee)&&!F.hasOwnProperty(ee)&&(B[ee]=K[ee]===void 0&&ue!==void 0?ue[ee]:K[ee])}var ee=arguments.length-2;if(ee===1)B.children=ne;else if(1<ee){ue=Array(ee);for(var ge=0;ge<ee;ge++)ue[ge]=arguments[ge+2];B.children=ue}return{$$typeof:e,type:I.type,key:se,ref:ae,props:B,_owner:me}},Te.createContext=function(I){return I={$$typeof:u,_currentValue:I,_currentValue2:I,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},I.Provider={$$typeof:l,_context:I},I.Consumer=I},Te.createElement=Z,Te.createFactory=function(I){var K=Z.bind(null,I);return K.type=I,K},Te.createRef=function(){return{current:null}},Te.forwardRef=function(I){return{$$typeof:f,render:I}},Te.isValidElement=H,Te.lazy=function(I){return{$$typeof:y,_payload:{_status:-1,_result:I},_init:Q}},Te.memo=function(I,K){return{$$typeof:p,type:I,compare:K===void 0?null:K}},Te.startTransition=function(I){var K=k.transition;k.transition={};try{I()}finally{k.transition=K}},Te.unstable_act=re,Te.useCallback=function(I,K){return G.current.useCallback(I,K)},Te.useContext=function(I){return G.current.useContext(I)},Te.useDebugValue=function(){},Te.useDeferredValue=function(I){return G.current.useDeferredValue(I)},Te.useEffect=function(I,K){return G.current.useEffect(I,K)},Te.useId=function(){return G.current.useId()},Te.useImperativeHandle=function(I,K,ne){return G.current.useImperativeHandle(I,K,ne)},Te.useInsertionEffect=function(I,K){return G.current.useInsertionEffect(I,K)},Te.useLayoutEffect=function(I,K){return G.current.useLayoutEffect(I,K)},Te.useMemo=function(I,K){return G.current.useMemo(I,K)},Te.useReducer=function(I,K,ne){return G.current.useReducer(I,K,ne)},Te.useRef=function(I){return G.current.useRef(I)},Te.useState=function(I){return G.current.useState(I)},Te.useSyncExternalStore=function(I,K,ne){return G.current.useSyncExternalStore(I,K,ne)},Te.useTransition=function(){return G.current.useTransition()},Te.version="18.3.1",Te}var Sp;function fh(){return Sp||(Sp=1,Ec.exports=oS()),Ec.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 wp;function aS(){if(wp)return Cn;wp=1;var e=fh(),t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function u(f,m,p){var y,S={},v=null,_=null;p!==void 0&&(v=""+p),m.key!==void 0&&(v=""+m.key),m.ref!==void 0&&(_=m.ref);for(y in m)n.call(m,y)&&!l.hasOwnProperty(y)&&(S[y]=m[y]);if(f&&f.defaultProps)for(y in m=f.defaultProps,m)S[y]===void 0&&(S[y]=m[y]);return{$$typeof:t,type:f,key:v,ref:_,props:S,_owner:o.current}}return Cn.Fragment=r,Cn.jsx=u,Cn.jsxs=u,Cn}var bp;function lS(){return bp||(bp=1,kc.exports=aS()),kc.exports}var h=lS(),M=fh();const cS=dh(M);var ia={},Nc={exports:{}},Kt={},Rc={exports:{}},Pc={};/**
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 Cp;function uS(){return Cp||(Cp=1,(function(e){function t(k,V){var re=k.length;k.push(V);e:for(;0<re;){var I=re-1>>>1,K=k[I];if(0<o(K,V))k[I]=V,k[re]=K,re=I;else break e}}function r(k){return k.length===0?null:k[0]}function n(k){if(k.length===0)return null;var V=k[0],re=k.pop();if(re!==V){k[0]=re;e:for(var I=0,K=k.length,ne=K>>>1;I<ne;){var B=2*(I+1)-1,se=k[B],ae=B+1,me=k[ae];if(0>o(se,re))ae<K&&0>o(me,se)?(k[I]=me,k[ae]=re,I=ae):(k[I]=se,k[B]=re,I=B);else if(ae<K&&0>o(me,re))k[I]=me,k[ae]=re,I=ae;else break e}}return V}function o(k,V){var re=k.sortIndex-V.sortIndex;return re!==0?re:k.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var u=Date,f=u.now();e.unstable_now=function(){return u.now()-f}}var m=[],p=[],y=1,S=null,v=3,_=!1,b=!1,x=!1,E=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,$=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function z(k){for(var V=r(p);V!==null;){if(V.callback===null)n(p);else if(V.startTime<=k)n(p),V.sortIndex=V.expirationTime,t(m,V);else break;V=r(p)}}function j(k){if(x=!1,z(k),!b)if(r(m)!==null)b=!0,Q(U);else{var V=r(p);V!==null&&G(j,V.startTime-k)}}function U(k,V){b=!1,x&&(x=!1,N(Z),Z=-1),_=!0;var re=v;try{for(z(V),S=r(m);S!==null&&(!(S.expirationTime>V)||k&&!A());){var I=S.callback;if(typeof I=="function"){S.callback=null,v=S.priorityLevel;var K=I(S.expirationTime<=V);V=e.unstable_now(),typeof K=="function"?S.callback=K:S===r(m)&&n(m),z(V)}else n(m);S=r(m)}if(S!==null)var ne=!0;else{var B=r(p);B!==null&&G(j,B.startTime-V),ne=!1}return ne}finally{S=null,v=re,_=!1}}var O=!1,F=null,Z=-1,R=5,H=-1;function A(){return!(e.unstable_now()-H<R)}function P(){if(F!==null){var k=e.unstable_now();H=k;var V=!0;try{V=F(!0,k)}finally{V?L():(O=!1,F=null)}}else O=!1}var L;if(typeof $=="function")L=function(){$(P)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,Y=T.port2;T.port1.onmessage=P,L=function(){Y.postMessage(null)}}else L=function(){E(P,0)};function Q(k){F=k,O||(O=!0,L())}function G(k,V){Z=E(function(){k(e.unstable_now())},V)}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(k){k.callback=null},e.unstable_continueExecution=function(){b||_||(b=!0,Q(U))},e.unstable_forceFrameRate=function(k){0>k||125<k?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<k?Math.floor(1e3/k):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_getFirstCallbackNode=function(){return r(m)},e.unstable_next=function(k){switch(v){case 1:case 2:case 3:var V=3;break;default:V=v}var re=v;v=V;try{return k()}finally{v=re}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(k,V){switch(k){case 1:case 2:case 3:case 4:case 5:break;default:k=3}var re=v;v=k;try{return V()}finally{v=re}},e.unstable_scheduleCallback=function(k,V,re){var I=e.unstable_now();switch(typeof re=="object"&&re!==null?(re=re.delay,re=typeof re=="number"&&0<re?I+re:I):re=I,k){case 1:var K=-1;break;case 2:K=250;break;case 5:K=1073741823;break;case 4:K=1e4;break;default:K=5e3}return K=re+K,k={id:y++,callback:V,priorityLevel:k,startTime:re,expirationTime:K,sortIndex:-1},re>I?(k.sortIndex=re,t(p,k),r(m)===null&&k===r(p)&&(x?(N(Z),Z=-1):x=!0,G(j,re-I))):(k.sortIndex=K,t(m,k),b||_||(b=!0,Q(U))),k},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(k){var V=v;return function(){var re=v;v=V;try{return k.apply(this,arguments)}finally{v=re}}}})(Pc)),Pc}var xp;function hS(){return xp||(xp=1,Rc.exports=uS()),Rc.exports}/**
26
- * @license React
27
- * react-dom.production.min.js
28
- *
29
- * Copyright (c) Facebook, Inc. and its affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- */var kp;function dS(){if(kp)return Kt;kp=1;var e=fh(),t=hS();function r(i){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+i,a=1;a<arguments.length;a++)s+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var n=new Set,o={};function l(i,s){u(i,s),u(i+"Capture",s)}function u(i,s){for(o[i]=s,i=0;i<s.length;i++)n.add(s[i])}var f=!(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 v(i){return m.call(S,i)?!0:m.call(y,i)?!1:p.test(i)?S[i]=!0:(y[i]=!0,!1)}function _(i,s,a,c){if(a!==null&&a.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return c?!1:a!==null?!a.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function b(i,s,a,c){if(s===null||typeof s>"u"||_(i,s,a,c))return!0;if(c)return!1;if(a!==null)switch(a.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function x(i,s,a,c,d,g,C){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=c,this.attributeNamespace=d,this.mustUseProperty=a,this.propertyName=i,this.type=s,this.sanitizeURL=g,this.removeEmptyString=C}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){E[i]=new x(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var s=i[0];E[s]=new x(s,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){E[i]=new x(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){E[i]=new x(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){E[i]=new x(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){E[i]=new x(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){E[i]=new x(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){E[i]=new x(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){E[i]=new x(i,5,!1,i.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function $(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var s=i.replace(N,$);E[s]=new x(s,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var s=i.replace(N,$);E[s]=new x(s,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var s=i.replace(N,$);E[s]=new x(s,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){E[i]=new x(i,1,!1,i.toLowerCase(),null,!1,!1)}),E.xlinkHref=new x("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){E[i]=new x(i,1,!1,i.toLowerCase(),null,!0,!0)});function z(i,s,a,c){var d=E.hasOwnProperty(s)?E[s]:null;(d!==null?d.type!==0:c||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(b(s,a,d,c)&&(a=null),c||d===null?v(s)&&(a===null?i.removeAttribute(s):i.setAttribute(s,""+a)):d.mustUseProperty?i[d.propertyName]=a===null?d.type===3?!1:"":a:(s=d.attributeName,c=d.attributeNamespace,a===null?i.removeAttribute(s):(d=d.type,a=d===3||d===4&&a===!0?"":""+a,c?i.setAttributeNS(c,s,a):i.setAttribute(s,a))))}var j=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,U=Symbol.for("react.element"),O=Symbol.for("react.portal"),F=Symbol.for("react.fragment"),Z=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),H=Symbol.for("react.provider"),A=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),G=Symbol.for("react.offscreen"),k=Symbol.iterator;function V(i){return i===null||typeof i!="object"?null:(i=k&&i[k]||i["@@iterator"],typeof i=="function"?i:null)}var re=Object.assign,I;function K(i){if(I===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);I=s&&s[1]||""}return`
34
- `+I+i}var ne=!1;function B(i,s){if(!i||ne)return"";ne=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(s)if(s=function(){throw Error()},Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(ie){var c=ie}Reflect.construct(i,[],s)}else{try{s.call()}catch(ie){c=ie}i.call(s.prototype)}else{try{throw Error()}catch(ie){c=ie}i()}}catch(ie){if(ie&&c&&typeof ie.stack=="string"){for(var d=ie.stack.split(`
35
- `),g=c.stack.split(`
36
- `),C=d.length-1,D=g.length-1;1<=C&&0<=D&&d[C]!==g[D];)D--;for(;1<=C&&0<=D;C--,D--)if(d[C]!==g[D]){if(C!==1||D!==1)do if(C--,D--,0>D||d[C]!==g[D]){var W=`
37
- `+d[C].replace(" at new "," at ");return i.displayName&&W.includes("<anonymous>")&&(W=W.replace("<anonymous>",i.displayName)),W}while(1<=C&&0<=D);break}}}finally{ne=!1,Error.prepareStackTrace=a}return(i=i?i.displayName||i.name:"")?K(i):""}function se(i){switch(i.tag){case 5:return K(i.type);case 16:return K("Lazy");case 13:return K("Suspense");case 19:return K("SuspenseList");case 0:case 2:case 15:return i=B(i.type,!1),i;case 11:return i=B(i.type.render,!1),i;case 1:return i=B(i.type,!0),i;default:return""}}function ae(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case F:return"Fragment";case O:return"Portal";case R:return"Profiler";case Z:return"StrictMode";case L:return"Suspense";case T:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case A:return(i.displayName||"Context")+".Consumer";case H:return(i._context.displayName||"Context")+".Provider";case P:var s=i.render;return i=i.displayName,i||(i=s.displayName||s.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case Y:return s=i.displayName||null,s!==null?s:ae(i.type)||"Memo";case Q:s=i._payload,i=i._init;try{return ae(i(s))}catch{}}return null}function me(i){var s=i.type;switch(i.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=s.render,i=i.displayName||i.name||"",s.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ae(s);case 8:return s===Z?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function ue(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function ee(i){var s=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function ge(i){var s=ee(i)?"checked":"value",a=Object.getOwnPropertyDescriptor(i.constructor.prototype,s),c=""+i[s];if(!i.hasOwnProperty(s)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var d=a.get,g=a.set;return Object.defineProperty(i,s,{configurable:!0,get:function(){return d.call(this)},set:function(C){c=""+C,g.call(this,C)}}),Object.defineProperty(i,s,{enumerable:a.enumerable}),{getValue:function(){return c},setValue:function(C){c=""+C},stopTracking:function(){i._valueTracker=null,delete i[s]}}}}function Ee(i){i._valueTracker||(i._valueTracker=ge(i))}function Be(i){if(!i)return!1;var s=i._valueTracker;if(!s)return!0;var a=s.getValue(),c="";return i&&(c=ee(i)?i.checked?"true":"false":i.value),i=c,i!==a?(s.setValue(i),!0):!1}function Ce(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}function it(i,s){var a=s.checked;return re({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??i._wrapperState.initialChecked})}function ut(i,s){var a=s.defaultValue==null?"":s.defaultValue,c=s.checked!=null?s.checked:s.defaultChecked;a=ue(s.value!=null?s.value:a),i._wrapperState={initialChecked:c,initialValue:a,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function Pt(i,s){s=s.checked,s!=null&&z(i,"checked",s,!1)}function Je(i,s){Pt(i,s);var a=ue(s.value),c=s.type;if(a!=null)c==="number"?(a===0&&i.value===""||i.value!=a)&&(i.value=""+a):i.value!==""+a&&(i.value=""+a);else if(c==="submit"||c==="reset"){i.removeAttribute("value");return}s.hasOwnProperty("value")?vi(i,s.type,a):s.hasOwnProperty("defaultValue")&&vi(i,s.type,ue(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(i.defaultChecked=!!s.defaultChecked)}function qi(i,s,a){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var c=s.type;if(!(c!=="submit"&&c!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+i._wrapperState.initialValue,a||s===i.value||(i.value=s),i.defaultValue=s}a=i.name,a!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,a!==""&&(i.name=a)}function vi(i,s,a){(s!=="number"||Ce(i.ownerDocument)!==i)&&(a==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+a&&(i.defaultValue=""+a))}var Di=Array.isArray;function yi(i,s,a,c){if(i=i.options,s){s={};for(var d=0;d<a.length;d++)s["$"+a[d]]=!0;for(a=0;a<i.length;a++)d=s.hasOwnProperty("$"+i[a].value),i[a].selected!==d&&(i[a].selected=d),d&&c&&(i[a].defaultSelected=!0)}else{for(a=""+ue(a),s=null,d=0;d<i.length;d++){if(i[d].value===a){i[d].selected=!0,c&&(i[d].defaultSelected=!0);return}s!==null||i[d].disabled||(s=i[d])}s!==null&&(s.selected=!0)}}function Xt(i,s){if(s.dangerouslySetInnerHTML!=null)throw Error(r(91));return re({},s,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function Mr(i,s){var a=s.value;if(a==null){if(a=s.children,s=s.defaultValue,a!=null){if(s!=null)throw Error(r(92));if(Di(a)){if(1<a.length)throw Error(r(93));a=a[0]}s=a}s==null&&(s=""),a=s}i._wrapperState={initialValue:ue(a)}}function Ki(i,s){var a=ue(s.value),c=ue(s.defaultValue);a!=null&&(a=""+a,a!==i.value&&(i.value=a),s.defaultValue==null&&i.defaultValue!==a&&(i.defaultValue=a)),c!=null&&(i.defaultValue=""+c)}function Lr(i){var s=i.textContent;s===i._wrapperState.initialValue&&s!==""&&s!==null&&(i.value=s)}function Tr(i){switch(i){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Gt(i,s){return i==null||i==="http://www.w3.org/1999/xhtml"?Tr(s):i==="http://www.w3.org/2000/svg"&&s==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var Qt,Si=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(s,a,c,d){MSApp.execUnsafeLocalFunction(function(){return i(s,a,c,d)})}:i})(function(i,s){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=s;else{for(Qt=Qt||document.createElement("div"),Qt.innerHTML="<svg>"+s.valueOf().toString()+"</svg>",s=Qt.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;s.firstChild;)i.appendChild(s.firstChild)}});function Ft(i,s){if(s){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=s;return}}i.textContent=s}var X={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},pe=["Webkit","ms","Moz","O"];Object.keys(X).forEach(function(i){pe.forEach(function(s){s=s+i.charAt(0).toUpperCase()+i.substring(1),X[s]=X[i]})});function Ne(i,s,a){return s==null||typeof s=="boolean"||s===""?"":a||typeof s!="number"||s===0||X.hasOwnProperty(i)&&X[i]?(""+s).trim():s+"px"}function He(i,s){i=i.style;for(var a in s)if(s.hasOwnProperty(a)){var c=a.indexOf("--")===0,d=Ne(a,s[a],c);a==="float"&&(a="cssFloat"),c?i.setProperty(a,d):i[a]=d}}var rt=re({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 Mi(i,s){if(s){if(rt[i]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(r(137,i));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(r(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(r(61))}if(s.style!=null&&typeof s.style!="object")throw Error(r(62))}}function zs(i,s){if(i.indexOf("-")===-1)return typeof s.is=="string";switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var za=null;function Fa(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Ha=null,ss=null,ns=null;function Bh(i){if(i=ln(i)){if(typeof Ha!="function")throw Error(r(280));var s=i.stateNode;s&&(s=_o(s),Ha(i.stateNode,i.type,s))}}function Ah(i){ss?ns?ns.push(i):ns=[i]:ss=i}function Ih(){if(ss){var i=ss,s=ns;if(ns=ss=null,Bh(i),s)for(i=0;i<s.length;i++)Bh(s[i])}}function Oh(i,s){return i(s)}function zh(){}var $a=!1;function Fh(i,s,a){if($a)return i(s,a);$a=!0;try{return Oh(i,s,a)}finally{$a=!1,(ss!==null||ns!==null)&&(zh(),Ih())}}function Fs(i,s){var a=i.stateNode;if(a===null)return null;var c=_o(a);if(c===null)return null;a=c[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(i=i.type,c=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!c;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(r(231,s,typeof a));return a}var Wa=!1;if(f)try{var Hs={};Object.defineProperty(Hs,"passive",{get:function(){Wa=!0}}),window.addEventListener("test",Hs,Hs),window.removeEventListener("test",Hs,Hs)}catch{Wa=!1}function dv(i,s,a,c,d,g,C,D,W){var ie=Array.prototype.slice.call(arguments,3);try{s.apply(a,ie)}catch(ce){this.onError(ce)}}var $s=!1,Yn=null,Xn=!1,Ua=null,fv={onError:function(i){$s=!0,Yn=i}};function pv(i,s,a,c,d,g,C,D,W){$s=!1,Yn=null,dv.apply(fv,arguments)}function mv(i,s,a,c,d,g,C,D,W){if(pv.apply(this,arguments),$s){if($s){var ie=Yn;$s=!1,Yn=null}else throw Error(r(198));Xn||(Xn=!0,Ua=ie)}}function jr(i){var s=i,a=i;if(i.alternate)for(;s.return;)s=s.return;else{i=s;do s=i,(s.flags&4098)!==0&&(a=s.return),i=s.return;while(i)}return s.tag===3?a:null}function Hh(i){if(i.tag===13){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function $h(i){if(jr(i)!==i)throw Error(r(188))}function gv(i){var s=i.alternate;if(!s){if(s=jr(i),s===null)throw Error(r(188));return s!==i?null:i}for(var a=i,c=s;;){var d=a.return;if(d===null)break;var g=d.alternate;if(g===null){if(c=d.return,c!==null){a=c;continue}break}if(d.child===g.child){for(g=d.child;g;){if(g===a)return $h(d),i;if(g===c)return $h(d),s;g=g.sibling}throw Error(r(188))}if(a.return!==c.return)a=d,c=g;else{for(var C=!1,D=d.child;D;){if(D===a){C=!0,a=d,c=g;break}if(D===c){C=!0,c=d,a=g;break}D=D.sibling}if(!C){for(D=g.child;D;){if(D===a){C=!0,a=g,c=d;break}if(D===c){C=!0,c=g,a=d;break}D=D.sibling}if(!C)throw Error(r(189))}}if(a.alternate!==c)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?i:s}function Wh(i){return i=gv(i),i!==null?Uh(i):null}function Uh(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var s=Uh(i);if(s!==null)return s;i=i.sibling}return null}var qh=t.unstable_scheduleCallback,Kh=t.unstable_cancelCallback,_v=t.unstable_shouldYield,vv=t.unstable_requestPaint,st=t.unstable_now,yv=t.unstable_getCurrentPriorityLevel,qa=t.unstable_ImmediatePriority,Vh=t.unstable_UserBlockingPriority,Gn=t.unstable_NormalPriority,Sv=t.unstable_LowPriority,Yh=t.unstable_IdlePriority,Qn=null,Li=null;function wv(i){if(Li&&typeof Li.onCommitFiberRoot=="function")try{Li.onCommitFiberRoot(Qn,i,void 0,(i.current.flags&128)===128)}catch{}}var wi=Math.clz32?Math.clz32:xv,bv=Math.log,Cv=Math.LN2;function xv(i){return i>>>=0,i===0?32:31-(bv(i)/Cv|0)|0}var Jn=64,Zn=4194304;function Ws(i){switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function eo(i,s){var a=i.pendingLanes;if(a===0)return 0;var c=0,d=i.suspendedLanes,g=i.pingedLanes,C=a&268435455;if(C!==0){var D=C&~d;D!==0?c=Ws(D):(g&=C,g!==0&&(c=Ws(g)))}else C=a&~d,C!==0?c=Ws(C):g!==0&&(c=Ws(g));if(c===0)return 0;if(s!==0&&s!==c&&(s&d)===0&&(d=c&-c,g=s&-s,d>=g||d===16&&(g&4194240)!==0))return s;if((c&4)!==0&&(c|=a&16),s=i.entangledLanes,s!==0)for(i=i.entanglements,s&=c;0<s;)a=31-wi(s),d=1<<a,c|=i[a],s&=~d;return c}function kv(i,s){switch(i){case 1:case 2:case 4:return s+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 s+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 Ev(i,s){for(var a=i.suspendedLanes,c=i.pingedLanes,d=i.expirationTimes,g=i.pendingLanes;0<g;){var C=31-wi(g),D=1<<C,W=d[C];W===-1?((D&a)===0||(D&c)!==0)&&(d[C]=kv(D,s)):W<=s&&(i.expiredLanes|=D),g&=~D}}function Ka(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function Xh(){var i=Jn;return Jn<<=1,(Jn&4194240)===0&&(Jn=64),i}function Va(i){for(var s=[],a=0;31>a;a++)s.push(i);return s}function Us(i,s,a){i.pendingLanes|=s,s!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,s=31-wi(s),i[s]=a}function Nv(i,s){var a=i.pendingLanes&~s;i.pendingLanes=s,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=s,i.mutableReadLanes&=s,i.entangledLanes&=s,s=i.entanglements;var c=i.eventTimes;for(i=i.expirationTimes;0<a;){var d=31-wi(a),g=1<<d;s[d]=0,c[d]=-1,i[d]=-1,a&=~g}}function Ya(i,s){var a=i.entangledLanes|=s;for(i=i.entanglements;a;){var c=31-wi(a),d=1<<c;d&s|i[c]&s&&(i[c]|=s),a&=~d}}var ze=0;function Gh(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var Qh,Xa,Jh,Zh,ed,Ga=!1,to=[],nr=null,or=null,ar=null,qs=new Map,Ks=new Map,lr=[],Rv="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 td(i,s){switch(i){case"focusin":case"focusout":nr=null;break;case"dragenter":case"dragleave":or=null;break;case"mouseover":case"mouseout":ar=null;break;case"pointerover":case"pointerout":qs.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ks.delete(s.pointerId)}}function Vs(i,s,a,c,d,g){return i===null||i.nativeEvent!==g?(i={blockedOn:s,domEventName:a,eventSystemFlags:c,nativeEvent:g,targetContainers:[d]},s!==null&&(s=ln(s),s!==null&&Xa(s)),i):(i.eventSystemFlags|=c,s=i.targetContainers,d!==null&&s.indexOf(d)===-1&&s.push(d),i)}function Pv(i,s,a,c,d){switch(s){case"focusin":return nr=Vs(nr,i,s,a,c,d),!0;case"dragenter":return or=Vs(or,i,s,a,c,d),!0;case"mouseover":return ar=Vs(ar,i,s,a,c,d),!0;case"pointerover":var g=d.pointerId;return qs.set(g,Vs(qs.get(g)||null,i,s,a,c,d)),!0;case"gotpointercapture":return g=d.pointerId,Ks.set(g,Vs(Ks.get(g)||null,i,s,a,c,d)),!0}return!1}function id(i){var s=Br(i.target);if(s!==null){var a=jr(s);if(a!==null){if(s=a.tag,s===13){if(s=Hh(a),s!==null){i.blockedOn=s,ed(i.priority,function(){Jh(a)});return}}else if(s===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function io(i){if(i.blockedOn!==null)return!1;for(var s=i.targetContainers;0<s.length;){var a=Ja(i.domEventName,i.eventSystemFlags,s[0],i.nativeEvent);if(a===null){a=i.nativeEvent;var c=new a.constructor(a.type,a);za=c,a.target.dispatchEvent(c),za=null}else return s=ln(a),s!==null&&Xa(s),i.blockedOn=a,!1;s.shift()}return!0}function rd(i,s,a){io(i)&&a.delete(s)}function Dv(){Ga=!1,nr!==null&&io(nr)&&(nr=null),or!==null&&io(or)&&(or=null),ar!==null&&io(ar)&&(ar=null),qs.forEach(rd),Ks.forEach(rd)}function Ys(i,s){i.blockedOn===s&&(i.blockedOn=null,Ga||(Ga=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Dv)))}function Xs(i){function s(d){return Ys(d,i)}if(0<to.length){Ys(to[0],i);for(var a=1;a<to.length;a++){var c=to[a];c.blockedOn===i&&(c.blockedOn=null)}}for(nr!==null&&Ys(nr,i),or!==null&&Ys(or,i),ar!==null&&Ys(ar,i),qs.forEach(s),Ks.forEach(s),a=0;a<lr.length;a++)c=lr[a],c.blockedOn===i&&(c.blockedOn=null);for(;0<lr.length&&(a=lr[0],a.blockedOn===null);)id(a),a.blockedOn===null&&lr.shift()}var os=j.ReactCurrentBatchConfig,ro=!0;function Mv(i,s,a,c){var d=ze,g=os.transition;os.transition=null;try{ze=1,Qa(i,s,a,c)}finally{ze=d,os.transition=g}}function Lv(i,s,a,c){var d=ze,g=os.transition;os.transition=null;try{ze=4,Qa(i,s,a,c)}finally{ze=d,os.transition=g}}function Qa(i,s,a,c){if(ro){var d=Ja(i,s,a,c);if(d===null)ml(i,s,c,so,a),td(i,c);else if(Pv(d,i,s,a,c))c.stopPropagation();else if(td(i,c),s&4&&-1<Rv.indexOf(i)){for(;d!==null;){var g=ln(d);if(g!==null&&Qh(g),g=Ja(i,s,a,c),g===null&&ml(i,s,c,so,a),g===d)break;d=g}d!==null&&c.stopPropagation()}else ml(i,s,c,null,a)}}var so=null;function Ja(i,s,a,c){if(so=null,i=Fa(c),i=Br(i),i!==null)if(s=jr(i),s===null)i=null;else if(a=s.tag,a===13){if(i=Hh(s),i!==null)return i;i=null}else if(a===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;i=null}else s!==i&&(i=null);return so=i,null}function sd(i){switch(i){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(yv()){case qa:return 1;case Vh:return 4;case Gn:case Sv:return 16;case Yh:return 536870912;default:return 16}default:return 16}}var cr=null,Za=null,no=null;function nd(){if(no)return no;var i,s=Za,a=s.length,c,d="value"in cr?cr.value:cr.textContent,g=d.length;for(i=0;i<a&&s[i]===d[i];i++);var C=a-i;for(c=1;c<=C&&s[a-c]===d[g-c];c++);return no=d.slice(i,1<c?1-c:void 0)}function oo(i){var s=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&s===13&&(i=13)):i=s,i===10&&(i=13),32<=i||i===13?i:0}function ao(){return!0}function od(){return!1}function Jt(i){function s(a,c,d,g,C){this._reactName=a,this._targetInst=d,this.type=c,this.nativeEvent=g,this.target=C,this.currentTarget=null;for(var D in i)i.hasOwnProperty(D)&&(a=i[D],this[D]=a?a(g):g[D]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?ao:od,this.isPropagationStopped=od,this}return re(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=ao)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=ao)},persist:function(){},isPersistent:ao}),s}var as={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},el=Jt(as),Gs=re({},as,{view:0,detail:0}),Tv=Jt(Gs),tl,il,Qs,lo=re({},Gs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:sl,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==Qs&&(Qs&&i.type==="mousemove"?(tl=i.screenX-Qs.screenX,il=i.screenY-Qs.screenY):il=tl=0,Qs=i),tl)},movementY:function(i){return"movementY"in i?i.movementY:il}}),ad=Jt(lo),jv=re({},lo,{dataTransfer:0}),Bv=Jt(jv),Av=re({},Gs,{relatedTarget:0}),rl=Jt(Av),Iv=re({},as,{animationName:0,elapsedTime:0,pseudoElement:0}),Ov=Jt(Iv),zv=re({},as,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Fv=Jt(zv),Hv=re({},as,{data:0}),ld=Jt(Hv),$v={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Wv={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"},Uv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function qv(i){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(i):(i=Uv[i])?!!s[i]:!1}function sl(){return qv}var Kv=re({},Gs,{key:function(i){if(i.key){var s=$v[i.key]||i.key;if(s!=="Unidentified")return s}return i.type==="keypress"?(i=oo(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Wv[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:sl,charCode:function(i){return i.type==="keypress"?oo(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?oo(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Vv=Jt(Kv),Yv=re({},lo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),cd=Jt(Yv),Xv=re({},Gs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:sl}),Gv=Jt(Xv),Qv=re({},as,{propertyName:0,elapsedTime:0,pseudoElement:0}),Jv=Jt(Qv),Zv=re({},lo,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),ey=Jt(Zv),ty=[9,13,27,32],nl=f&&"CompositionEvent"in window,Js=null;f&&"documentMode"in document&&(Js=document.documentMode);var iy=f&&"TextEvent"in window&&!Js,ud=f&&(!nl||Js&&8<Js&&11>=Js),hd=" ",dd=!1;function fd(i,s){switch(i){case"keyup":return ty.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function pd(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var ls=!1;function ry(i,s){switch(i){case"compositionend":return pd(s);case"keypress":return s.which!==32?null:(dd=!0,hd);case"textInput":return i=s.data,i===hd&&dd?null:i;default:return null}}function sy(i,s){if(ls)return i==="compositionend"||!nl&&fd(i,s)?(i=nd(),no=Za=cr=null,ls=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return ud&&s.locale!=="ko"?null:s.data;default:return null}}var ny={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 md(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s==="input"?!!ny[i.type]:s==="textarea"}function gd(i,s,a,c){Ah(c),s=po(s,"onChange"),0<s.length&&(a=new el("onChange","change",null,a,c),i.push({event:a,listeners:s}))}var Zs=null,en=null;function oy(i){jd(i,0)}function co(i){var s=fs(i);if(Be(s))return i}function ay(i,s){if(i==="change")return s}var _d=!1;if(f){var ol;if(f){var al="oninput"in document;if(!al){var vd=document.createElement("div");vd.setAttribute("oninput","return;"),al=typeof vd.oninput=="function"}ol=al}else ol=!1;_d=ol&&(!document.documentMode||9<document.documentMode)}function yd(){Zs&&(Zs.detachEvent("onpropertychange",Sd),en=Zs=null)}function Sd(i){if(i.propertyName==="value"&&co(en)){var s=[];gd(s,en,i,Fa(i)),Fh(oy,s)}}function ly(i,s,a){i==="focusin"?(yd(),Zs=s,en=a,Zs.attachEvent("onpropertychange",Sd)):i==="focusout"&&yd()}function cy(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return co(en)}function uy(i,s){if(i==="click")return co(s)}function hy(i,s){if(i==="input"||i==="change")return co(s)}function dy(i,s){return i===s&&(i!==0||1/i===1/s)||i!==i&&s!==s}var bi=typeof Object.is=="function"?Object.is:dy;function tn(i,s){if(bi(i,s))return!0;if(typeof i!="object"||i===null||typeof s!="object"||s===null)return!1;var a=Object.keys(i),c=Object.keys(s);if(a.length!==c.length)return!1;for(c=0;c<a.length;c++){var d=a[c];if(!m.call(s,d)||!bi(i[d],s[d]))return!1}return!0}function wd(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function bd(i,s){var a=wd(i);i=0;for(var c;a;){if(a.nodeType===3){if(c=i+a.textContent.length,i<=s&&c>=s)return{node:a,offset:s-i};i=c}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=wd(a)}}function Cd(i,s){return i&&s?i===s?!0:i&&i.nodeType===3?!1:s&&s.nodeType===3?Cd(i,s.parentNode):"contains"in i?i.contains(s):i.compareDocumentPosition?!!(i.compareDocumentPosition(s)&16):!1:!1}function xd(){for(var i=window,s=Ce();s instanceof i.HTMLIFrameElement;){try{var a=typeof s.contentWindow.location.href=="string"}catch{a=!1}if(a)i=s.contentWindow;else break;s=Ce(i.document)}return s}function ll(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s&&(s==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||s==="textarea"||i.contentEditable==="true")}function fy(i){var s=xd(),a=i.focusedElem,c=i.selectionRange;if(s!==a&&a&&a.ownerDocument&&Cd(a.ownerDocument.documentElement,a)){if(c!==null&&ll(a)){if(s=c.start,i=c.end,i===void 0&&(i=s),"selectionStart"in a)a.selectionStart=s,a.selectionEnd=Math.min(i,a.value.length);else if(i=(s=a.ownerDocument||document)&&s.defaultView||window,i.getSelection){i=i.getSelection();var d=a.textContent.length,g=Math.min(c.start,d);c=c.end===void 0?g:Math.min(c.end,d),!i.extend&&g>c&&(d=c,c=g,g=d),d=bd(a,g);var C=bd(a,c);d&&C&&(i.rangeCount!==1||i.anchorNode!==d.node||i.anchorOffset!==d.offset||i.focusNode!==C.node||i.focusOffset!==C.offset)&&(s=s.createRange(),s.setStart(d.node,d.offset),i.removeAllRanges(),g>c?(i.addRange(s),i.extend(C.node,C.offset)):(s.setEnd(C.node,C.offset),i.addRange(s)))}}for(s=[],i=a;i=i.parentNode;)i.nodeType===1&&s.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<s.length;a++)i=s[a],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var py=f&&"documentMode"in document&&11>=document.documentMode,cs=null,cl=null,rn=null,ul=!1;function kd(i,s,a){var c=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;ul||cs==null||cs!==Ce(c)||(c=cs,"selectionStart"in c&&ll(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),rn&&tn(rn,c)||(rn=c,c=po(cl,"onSelect"),0<c.length&&(s=new el("onSelect","select",null,s,a),i.push({event:s,listeners:c}),s.target=cs)))}function uo(i,s){var a={};return a[i.toLowerCase()]=s.toLowerCase(),a["Webkit"+i]="webkit"+s,a["Moz"+i]="moz"+s,a}var us={animationend:uo("Animation","AnimationEnd"),animationiteration:uo("Animation","AnimationIteration"),animationstart:uo("Animation","AnimationStart"),transitionend:uo("Transition","TransitionEnd")},hl={},Ed={};f&&(Ed=document.createElement("div").style,"AnimationEvent"in window||(delete us.animationend.animation,delete us.animationiteration.animation,delete us.animationstart.animation),"TransitionEvent"in window||delete us.transitionend.transition);function ho(i){if(hl[i])return hl[i];if(!us[i])return i;var s=us[i],a;for(a in s)if(s.hasOwnProperty(a)&&a in Ed)return hl[i]=s[a];return i}var Nd=ho("animationend"),Rd=ho("animationiteration"),Pd=ho("animationstart"),Dd=ho("transitionend"),Md=new Map,Ld="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 ur(i,s){Md.set(i,s),l(s,[i])}for(var dl=0;dl<Ld.length;dl++){var fl=Ld[dl],my=fl.toLowerCase(),gy=fl[0].toUpperCase()+fl.slice(1);ur(my,"on"+gy)}ur(Nd,"onAnimationEnd"),ur(Rd,"onAnimationIteration"),ur(Pd,"onAnimationStart"),ur("dblclick","onDoubleClick"),ur("focusin","onFocus"),ur("focusout","onBlur"),ur(Dd,"onTransitionEnd"),u("onMouseEnter",["mouseout","mouseover"]),u("onMouseLeave",["mouseout","mouseover"]),u("onPointerEnter",["pointerout","pointerover"]),u("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var sn="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(" "),_y=new Set("cancel close invalid load scroll toggle".split(" ").concat(sn));function Td(i,s,a){var c=i.type||"unknown-event";i.currentTarget=a,mv(c,s,void 0,i),i.currentTarget=null}function jd(i,s){s=(s&4)!==0;for(var a=0;a<i.length;a++){var c=i[a],d=c.event;c=c.listeners;e:{var g=void 0;if(s)for(var C=c.length-1;0<=C;C--){var D=c[C],W=D.instance,ie=D.currentTarget;if(D=D.listener,W!==g&&d.isPropagationStopped())break e;Td(d,D,ie),g=W}else for(C=0;C<c.length;C++){if(D=c[C],W=D.instance,ie=D.currentTarget,D=D.listener,W!==g&&d.isPropagationStopped())break e;Td(d,D,ie),g=W}}}if(Xn)throw i=Ua,Xn=!1,Ua=null,i}function We(i,s){var a=s[wl];a===void 0&&(a=s[wl]=new Set);var c=i+"__bubble";a.has(c)||(Bd(s,i,2,!1),a.add(c))}function pl(i,s,a){var c=0;s&&(c|=4),Bd(a,i,c,s)}var fo="_reactListening"+Math.random().toString(36).slice(2);function nn(i){if(!i[fo]){i[fo]=!0,n.forEach(function(a){a!=="selectionchange"&&(_y.has(a)||pl(a,!1,i),pl(a,!0,i))});var s=i.nodeType===9?i:i.ownerDocument;s===null||s[fo]||(s[fo]=!0,pl("selectionchange",!1,s))}}function Bd(i,s,a,c){switch(sd(s)){case 1:var d=Mv;break;case 4:d=Lv;break;default:d=Qa}a=d.bind(null,s,a,i),d=void 0,!Wa||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(d=!0),c?d!==void 0?i.addEventListener(s,a,{capture:!0,passive:d}):i.addEventListener(s,a,!0):d!==void 0?i.addEventListener(s,a,{passive:d}):i.addEventListener(s,a,!1)}function ml(i,s,a,c,d){var g=c;if((s&1)===0&&(s&2)===0&&c!==null)e:for(;;){if(c===null)return;var C=c.tag;if(C===3||C===4){var D=c.stateNode.containerInfo;if(D===d||D.nodeType===8&&D.parentNode===d)break;if(C===4)for(C=c.return;C!==null;){var W=C.tag;if((W===3||W===4)&&(W=C.stateNode.containerInfo,W===d||W.nodeType===8&&W.parentNode===d))return;C=C.return}for(;D!==null;){if(C=Br(D),C===null)return;if(W=C.tag,W===5||W===6){c=g=C;continue e}D=D.parentNode}}c=c.return}Fh(function(){var ie=g,ce=Fa(a),he=[];e:{var le=Md.get(i);if(le!==void 0){var ve=el,Se=i;switch(i){case"keypress":if(oo(a)===0)break e;case"keydown":case"keyup":ve=Vv;break;case"focusin":Se="focus",ve=rl;break;case"focusout":Se="blur",ve=rl;break;case"beforeblur":case"afterblur":ve=rl;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ve=ad;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ve=Bv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ve=Gv;break;case Nd:case Rd:case Pd:ve=Ov;break;case Dd:ve=Jv;break;case"scroll":ve=Tv;break;case"wheel":ve=ey;break;case"copy":case"cut":case"paste":ve=Fv;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ve=cd}var we=(s&4)!==0,nt=!we&&i==="scroll",J=we?le!==null?le+"Capture":null:le;we=[];for(var q=ie,te;q!==null;){te=q;var de=te.stateNode;if(te.tag===5&&de!==null&&(te=de,J!==null&&(de=Fs(q,J),de!=null&&we.push(on(q,de,te)))),nt)break;q=q.return}0<we.length&&(le=new ve(le,Se,null,a,ce),he.push({event:le,listeners:we}))}}if((s&7)===0){e:{if(le=i==="mouseover"||i==="pointerover",ve=i==="mouseout"||i==="pointerout",le&&a!==za&&(Se=a.relatedTarget||a.fromElement)&&(Br(Se)||Se[Vi]))break e;if((ve||le)&&(le=ce.window===ce?ce:(le=ce.ownerDocument)?le.defaultView||le.parentWindow:window,ve?(Se=a.relatedTarget||a.toElement,ve=ie,Se=Se?Br(Se):null,Se!==null&&(nt=jr(Se),Se!==nt||Se.tag!==5&&Se.tag!==6)&&(Se=null)):(ve=null,Se=ie),ve!==Se)){if(we=ad,de="onMouseLeave",J="onMouseEnter",q="mouse",(i==="pointerout"||i==="pointerover")&&(we=cd,de="onPointerLeave",J="onPointerEnter",q="pointer"),nt=ve==null?le:fs(ve),te=Se==null?le:fs(Se),le=new we(de,q+"leave",ve,a,ce),le.target=nt,le.relatedTarget=te,de=null,Br(ce)===ie&&(we=new we(J,q+"enter",Se,a,ce),we.target=te,we.relatedTarget=nt,de=we),nt=de,ve&&Se)t:{for(we=ve,J=Se,q=0,te=we;te;te=hs(te))q++;for(te=0,de=J;de;de=hs(de))te++;for(;0<q-te;)we=hs(we),q--;for(;0<te-q;)J=hs(J),te--;for(;q--;){if(we===J||J!==null&&we===J.alternate)break t;we=hs(we),J=hs(J)}we=null}else we=null;ve!==null&&Ad(he,le,ve,we,!1),Se!==null&&nt!==null&&Ad(he,nt,Se,we,!0)}}e:{if(le=ie?fs(ie):window,ve=le.nodeName&&le.nodeName.toLowerCase(),ve==="select"||ve==="input"&&le.type==="file")var be=ay;else if(md(le))if(_d)be=hy;else{be=cy;var xe=ly}else(ve=le.nodeName)&&ve.toLowerCase()==="input"&&(le.type==="checkbox"||le.type==="radio")&&(be=uy);if(be&&(be=be(i,ie))){gd(he,be,a,ce);break e}xe&&xe(i,le,ie),i==="focusout"&&(xe=le._wrapperState)&&xe.controlled&&le.type==="number"&&vi(le,"number",le.value)}switch(xe=ie?fs(ie):window,i){case"focusin":(md(xe)||xe.contentEditable==="true")&&(cs=xe,cl=ie,rn=null);break;case"focusout":rn=cl=cs=null;break;case"mousedown":ul=!0;break;case"contextmenu":case"mouseup":case"dragend":ul=!1,kd(he,a,ce);break;case"selectionchange":if(py)break;case"keydown":case"keyup":kd(he,a,ce)}var ke;if(nl)e:{switch(i){case"compositionstart":var Re="onCompositionStart";break e;case"compositionend":Re="onCompositionEnd";break e;case"compositionupdate":Re="onCompositionUpdate";break e}Re=void 0}else ls?fd(i,a)&&(Re="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(Re="onCompositionStart");Re&&(ud&&a.locale!=="ko"&&(ls||Re!=="onCompositionStart"?Re==="onCompositionEnd"&&ls&&(ke=nd()):(cr=ce,Za="value"in cr?cr.value:cr.textContent,ls=!0)),xe=po(ie,Re),0<xe.length&&(Re=new ld(Re,i,null,a,ce),he.push({event:Re,listeners:xe}),ke?Re.data=ke:(ke=pd(a),ke!==null&&(Re.data=ke)))),(ke=iy?ry(i,a):sy(i,a))&&(ie=po(ie,"onBeforeInput"),0<ie.length&&(ce=new ld("onBeforeInput","beforeinput",null,a,ce),he.push({event:ce,listeners:ie}),ce.data=ke))}jd(he,s)})}function on(i,s,a){return{instance:i,listener:s,currentTarget:a}}function po(i,s){for(var a=s+"Capture",c=[];i!==null;){var d=i,g=d.stateNode;d.tag===5&&g!==null&&(d=g,g=Fs(i,a),g!=null&&c.unshift(on(i,g,d)),g=Fs(i,s),g!=null&&c.push(on(i,g,d))),i=i.return}return c}function hs(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function Ad(i,s,a,c,d){for(var g=s._reactName,C=[];a!==null&&a!==c;){var D=a,W=D.alternate,ie=D.stateNode;if(W!==null&&W===c)break;D.tag===5&&ie!==null&&(D=ie,d?(W=Fs(a,g),W!=null&&C.unshift(on(a,W,D))):d||(W=Fs(a,g),W!=null&&C.push(on(a,W,D)))),a=a.return}C.length!==0&&i.push({event:s,listeners:C})}var vy=/\r\n?/g,yy=/\u0000|\uFFFD/g;function Id(i){return(typeof i=="string"?i:""+i).replace(vy,`
38
- `).replace(yy,"")}function mo(i,s,a){if(s=Id(s),Id(i)!==s&&a)throw Error(r(425))}function go(){}var gl=null,_l=null;function vl(i,s){return i==="textarea"||i==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var yl=typeof setTimeout=="function"?setTimeout:void 0,Sy=typeof clearTimeout=="function"?clearTimeout:void 0,Od=typeof Promise=="function"?Promise:void 0,wy=typeof queueMicrotask=="function"?queueMicrotask:typeof Od<"u"?function(i){return Od.resolve(null).then(i).catch(by)}:yl;function by(i){setTimeout(function(){throw i})}function Sl(i,s){var a=s,c=0;do{var d=a.nextSibling;if(i.removeChild(a),d&&d.nodeType===8)if(a=d.data,a==="/$"){if(c===0){i.removeChild(d),Xs(s);return}c--}else a!=="$"&&a!=="$?"&&a!=="$!"||c++;a=d}while(a);Xs(s)}function hr(i){for(;i!=null;i=i.nextSibling){var s=i.nodeType;if(s===1||s===3)break;if(s===8){if(s=i.data,s==="$"||s==="$!"||s==="$?")break;if(s==="/$")return null}}return i}function zd(i){i=i.previousSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"){if(s===0)return i;s--}else a==="/$"&&s++}i=i.previousSibling}return null}var ds=Math.random().toString(36).slice(2),Ti="__reactFiber$"+ds,an="__reactProps$"+ds,Vi="__reactContainer$"+ds,wl="__reactEvents$"+ds,Cy="__reactListeners$"+ds,xy="__reactHandles$"+ds;function Br(i){var s=i[Ti];if(s)return s;for(var a=i.parentNode;a;){if(s=a[Vi]||a[Ti]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(i=zd(i);i!==null;){if(a=i[Ti])return a;i=zd(i)}return s}i=a,a=i.parentNode}return null}function ln(i){return i=i[Ti]||i[Vi],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function fs(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(r(33))}function _o(i){return i[an]||null}var bl=[],ps=-1;function dr(i){return{current:i}}function Ue(i){0>ps||(i.current=bl[ps],bl[ps]=null,ps--)}function $e(i,s){ps++,bl[ps]=i.current,i.current=s}var fr={},Dt=dr(fr),Ht=dr(!1),Ar=fr;function ms(i,s){var a=i.type.contextTypes;if(!a)return fr;var c=i.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===s)return c.__reactInternalMemoizedMaskedChildContext;var d={},g;for(g in a)d[g]=s[g];return c&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=s,i.__reactInternalMemoizedMaskedChildContext=d),d}function $t(i){return i=i.childContextTypes,i!=null}function vo(){Ue(Ht),Ue(Dt)}function Fd(i,s,a){if(Dt.current!==fr)throw Error(r(168));$e(Dt,s),$e(Ht,a)}function Hd(i,s,a){var c=i.stateNode;if(s=s.childContextTypes,typeof c.getChildContext!="function")return a;c=c.getChildContext();for(var d in c)if(!(d in s))throw Error(r(108,me(i)||"Unknown",d));return re({},a,c)}function yo(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||fr,Ar=Dt.current,$e(Dt,i),$e(Ht,Ht.current),!0}function $d(i,s,a){var c=i.stateNode;if(!c)throw Error(r(169));a?(i=Hd(i,s,Ar),c.__reactInternalMemoizedMergedChildContext=i,Ue(Ht),Ue(Dt),$e(Dt,i)):Ue(Ht),$e(Ht,a)}var Yi=null,So=!1,Cl=!1;function Wd(i){Yi===null?Yi=[i]:Yi.push(i)}function ky(i){So=!0,Wd(i)}function pr(){if(!Cl&&Yi!==null){Cl=!0;var i=0,s=ze;try{var a=Yi;for(ze=1;i<a.length;i++){var c=a[i];do c=c(!0);while(c!==null)}Yi=null,So=!1}catch(d){throw Yi!==null&&(Yi=Yi.slice(i+1)),qh(qa,pr),d}finally{ze=s,Cl=!1}}return null}var gs=[],_s=0,wo=null,bo=0,li=[],ci=0,Ir=null,Xi=1,Gi="";function Or(i,s){gs[_s++]=bo,gs[_s++]=wo,wo=i,bo=s}function Ud(i,s,a){li[ci++]=Xi,li[ci++]=Gi,li[ci++]=Ir,Ir=i;var c=Xi;i=Gi;var d=32-wi(c)-1;c&=~(1<<d),a+=1;var g=32-wi(s)+d;if(30<g){var C=d-d%5;g=(c&(1<<C)-1).toString(32),c>>=C,d-=C,Xi=1<<32-wi(s)+d|a<<d|c,Gi=g+i}else Xi=1<<g|a<<d|c,Gi=i}function xl(i){i.return!==null&&(Or(i,1),Ud(i,1,0))}function kl(i){for(;i===wo;)wo=gs[--_s],gs[_s]=null,bo=gs[--_s],gs[_s]=null;for(;i===Ir;)Ir=li[--ci],li[ci]=null,Gi=li[--ci],li[ci]=null,Xi=li[--ci],li[ci]=null}var Zt=null,ei=null,Ke=!1,Ci=null;function qd(i,s){var a=fi(5,null,null,0);a.elementType="DELETED",a.stateNode=s,a.return=i,s=i.deletions,s===null?(i.deletions=[a],i.flags|=16):s.push(a)}function Kd(i,s){switch(i.tag){case 5:var a=i.type;return s=s.nodeType!==1||a.toLowerCase()!==s.nodeName.toLowerCase()?null:s,s!==null?(i.stateNode=s,Zt=i,ei=hr(s.firstChild),!0):!1;case 6:return s=i.pendingProps===""||s.nodeType!==3?null:s,s!==null?(i.stateNode=s,Zt=i,ei=null,!0):!1;case 13:return s=s.nodeType!==8?null:s,s!==null?(a=Ir!==null?{id:Xi,overflow:Gi}:null,i.memoizedState={dehydrated:s,treeContext:a,retryLane:1073741824},a=fi(18,null,null,0),a.stateNode=s,a.return=i,i.child=a,Zt=i,ei=null,!0):!1;default:return!1}}function El(i){return(i.mode&1)!==0&&(i.flags&128)===0}function Nl(i){if(Ke){var s=ei;if(s){var a=s;if(!Kd(i,s)){if(El(i))throw Error(r(418));s=hr(a.nextSibling);var c=Zt;s&&Kd(i,s)?qd(c,a):(i.flags=i.flags&-4097|2,Ke=!1,Zt=i)}}else{if(El(i))throw Error(r(418));i.flags=i.flags&-4097|2,Ke=!1,Zt=i}}}function Vd(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;Zt=i}function Co(i){if(i!==Zt)return!1;if(!Ke)return Vd(i),Ke=!0,!1;var s;if((s=i.tag!==3)&&!(s=i.tag!==5)&&(s=i.type,s=s!=="head"&&s!=="body"&&!vl(i.type,i.memoizedProps)),s&&(s=ei)){if(El(i))throw Yd(),Error(r(418));for(;s;)qd(i,s),s=hr(s.nextSibling)}if(Vd(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));e:{for(i=i.nextSibling,s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"){if(s===0){ei=hr(i.nextSibling);break e}s--}else a!=="$"&&a!=="$!"&&a!=="$?"||s++}i=i.nextSibling}ei=null}}else ei=Zt?hr(i.stateNode.nextSibling):null;return!0}function Yd(){for(var i=ei;i;)i=hr(i.nextSibling)}function vs(){ei=Zt=null,Ke=!1}function Rl(i){Ci===null?Ci=[i]:Ci.push(i)}var Ey=j.ReactCurrentBatchConfig;function cn(i,s,a){if(i=a.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(a._owner){if(a=a._owner,a){if(a.tag!==1)throw Error(r(309));var c=a.stateNode}if(!c)throw Error(r(147,i));var d=c,g=""+i;return s!==null&&s.ref!==null&&typeof s.ref=="function"&&s.ref._stringRef===g?s.ref:(s=function(C){var D=d.refs;C===null?delete D[g]:D[g]=C},s._stringRef=g,s)}if(typeof i!="string")throw Error(r(284));if(!a._owner)throw Error(r(290,i))}return i}function xo(i,s){throw i=Object.prototype.toString.call(s),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":i))}function Xd(i){var s=i._init;return s(i._payload)}function Gd(i){function s(J,q){if(i){var te=J.deletions;te===null?(J.deletions=[q],J.flags|=16):te.push(q)}}function a(J,q){if(!i)return null;for(;q!==null;)s(J,q),q=q.sibling;return null}function c(J,q){for(J=new Map;q!==null;)q.key!==null?J.set(q.key,q):J.set(q.index,q),q=q.sibling;return J}function d(J,q){return J=br(J,q),J.index=0,J.sibling=null,J}function g(J,q,te){return J.index=te,i?(te=J.alternate,te!==null?(te=te.index,te<q?(J.flags|=2,q):te):(J.flags|=2,q)):(J.flags|=1048576,q)}function C(J){return i&&J.alternate===null&&(J.flags|=2),J}function D(J,q,te,de){return q===null||q.tag!==6?(q=yc(te,J.mode,de),q.return=J,q):(q=d(q,te),q.return=J,q)}function W(J,q,te,de){var be=te.type;return be===F?ce(J,q,te.props.children,de,te.key):q!==null&&(q.elementType===be||typeof be=="object"&&be!==null&&be.$$typeof===Q&&Xd(be)===q.type)?(de=d(q,te.props),de.ref=cn(J,q,te),de.return=J,de):(de=Yo(te.type,te.key,te.props,null,J.mode,de),de.ref=cn(J,q,te),de.return=J,de)}function ie(J,q,te,de){return q===null||q.tag!==4||q.stateNode.containerInfo!==te.containerInfo||q.stateNode.implementation!==te.implementation?(q=Sc(te,J.mode,de),q.return=J,q):(q=d(q,te.children||[]),q.return=J,q)}function ce(J,q,te,de,be){return q===null||q.tag!==7?(q=Kr(te,J.mode,de,be),q.return=J,q):(q=d(q,te),q.return=J,q)}function he(J,q,te){if(typeof q=="string"&&q!==""||typeof q=="number")return q=yc(""+q,J.mode,te),q.return=J,q;if(typeof q=="object"&&q!==null){switch(q.$$typeof){case U:return te=Yo(q.type,q.key,q.props,null,J.mode,te),te.ref=cn(J,null,q),te.return=J,te;case O:return q=Sc(q,J.mode,te),q.return=J,q;case Q:var de=q._init;return he(J,de(q._payload),te)}if(Di(q)||V(q))return q=Kr(q,J.mode,te,null),q.return=J,q;xo(J,q)}return null}function le(J,q,te,de){var be=q!==null?q.key:null;if(typeof te=="string"&&te!==""||typeof te=="number")return be!==null?null:D(J,q,""+te,de);if(typeof te=="object"&&te!==null){switch(te.$$typeof){case U:return te.key===be?W(J,q,te,de):null;case O:return te.key===be?ie(J,q,te,de):null;case Q:return be=te._init,le(J,q,be(te._payload),de)}if(Di(te)||V(te))return be!==null?null:ce(J,q,te,de,null);xo(J,te)}return null}function ve(J,q,te,de,be){if(typeof de=="string"&&de!==""||typeof de=="number")return J=J.get(te)||null,D(q,J,""+de,be);if(typeof de=="object"&&de!==null){switch(de.$$typeof){case U:return J=J.get(de.key===null?te:de.key)||null,W(q,J,de,be);case O:return J=J.get(de.key===null?te:de.key)||null,ie(q,J,de,be);case Q:var xe=de._init;return ve(J,q,te,xe(de._payload),be)}if(Di(de)||V(de))return J=J.get(te)||null,ce(q,J,de,be,null);xo(q,de)}return null}function Se(J,q,te,de){for(var be=null,xe=null,ke=q,Re=q=0,vt=null;ke!==null&&Re<te.length;Re++){ke.index>Re?(vt=ke,ke=null):vt=ke.sibling;var Ie=le(J,ke,te[Re],de);if(Ie===null){ke===null&&(ke=vt);break}i&&ke&&Ie.alternate===null&&s(J,ke),q=g(Ie,q,Re),xe===null?be=Ie:xe.sibling=Ie,xe=Ie,ke=vt}if(Re===te.length)return a(J,ke),Ke&&Or(J,Re),be;if(ke===null){for(;Re<te.length;Re++)ke=he(J,te[Re],de),ke!==null&&(q=g(ke,q,Re),xe===null?be=ke:xe.sibling=ke,xe=ke);return Ke&&Or(J,Re),be}for(ke=c(J,ke);Re<te.length;Re++)vt=ve(ke,J,Re,te[Re],de),vt!==null&&(i&&vt.alternate!==null&&ke.delete(vt.key===null?Re:vt.key),q=g(vt,q,Re),xe===null?be=vt:xe.sibling=vt,xe=vt);return i&&ke.forEach(function(Cr){return s(J,Cr)}),Ke&&Or(J,Re),be}function we(J,q,te,de){var be=V(te);if(typeof be!="function")throw Error(r(150));if(te=be.call(te),te==null)throw Error(r(151));for(var xe=be=null,ke=q,Re=q=0,vt=null,Ie=te.next();ke!==null&&!Ie.done;Re++,Ie=te.next()){ke.index>Re?(vt=ke,ke=null):vt=ke.sibling;var Cr=le(J,ke,Ie.value,de);if(Cr===null){ke===null&&(ke=vt);break}i&&ke&&Cr.alternate===null&&s(J,ke),q=g(Cr,q,Re),xe===null?be=Cr:xe.sibling=Cr,xe=Cr,ke=vt}if(Ie.done)return a(J,ke),Ke&&Or(J,Re),be;if(ke===null){for(;!Ie.done;Re++,Ie=te.next())Ie=he(J,Ie.value,de),Ie!==null&&(q=g(Ie,q,Re),xe===null?be=Ie:xe.sibling=Ie,xe=Ie);return Ke&&Or(J,Re),be}for(ke=c(J,ke);!Ie.done;Re++,Ie=te.next())Ie=ve(ke,J,Re,Ie.value,de),Ie!==null&&(i&&Ie.alternate!==null&&ke.delete(Ie.key===null?Re:Ie.key),q=g(Ie,q,Re),xe===null?be=Ie:xe.sibling=Ie,xe=Ie);return i&&ke.forEach(function(nS){return s(J,nS)}),Ke&&Or(J,Re),be}function nt(J,q,te,de){if(typeof te=="object"&&te!==null&&te.type===F&&te.key===null&&(te=te.props.children),typeof te=="object"&&te!==null){switch(te.$$typeof){case U:e:{for(var be=te.key,xe=q;xe!==null;){if(xe.key===be){if(be=te.type,be===F){if(xe.tag===7){a(J,xe.sibling),q=d(xe,te.props.children),q.return=J,J=q;break e}}else if(xe.elementType===be||typeof be=="object"&&be!==null&&be.$$typeof===Q&&Xd(be)===xe.type){a(J,xe.sibling),q=d(xe,te.props),q.ref=cn(J,xe,te),q.return=J,J=q;break e}a(J,xe);break}else s(J,xe);xe=xe.sibling}te.type===F?(q=Kr(te.props.children,J.mode,de,te.key),q.return=J,J=q):(de=Yo(te.type,te.key,te.props,null,J.mode,de),de.ref=cn(J,q,te),de.return=J,J=de)}return C(J);case O:e:{for(xe=te.key;q!==null;){if(q.key===xe)if(q.tag===4&&q.stateNode.containerInfo===te.containerInfo&&q.stateNode.implementation===te.implementation){a(J,q.sibling),q=d(q,te.children||[]),q.return=J,J=q;break e}else{a(J,q);break}else s(J,q);q=q.sibling}q=Sc(te,J.mode,de),q.return=J,J=q}return C(J);case Q:return xe=te._init,nt(J,q,xe(te._payload),de)}if(Di(te))return Se(J,q,te,de);if(V(te))return we(J,q,te,de);xo(J,te)}return typeof te=="string"&&te!==""||typeof te=="number"?(te=""+te,q!==null&&q.tag===6?(a(J,q.sibling),q=d(q,te),q.return=J,J=q):(a(J,q),q=yc(te,J.mode,de),q.return=J,J=q),C(J)):a(J,q)}return nt}var ys=Gd(!0),Qd=Gd(!1),ko=dr(null),Eo=null,Ss=null,Pl=null;function Dl(){Pl=Ss=Eo=null}function Ml(i){var s=ko.current;Ue(ko),i._currentValue=s}function Ll(i,s,a){for(;i!==null;){var c=i.alternate;if((i.childLanes&s)!==s?(i.childLanes|=s,c!==null&&(c.childLanes|=s)):c!==null&&(c.childLanes&s)!==s&&(c.childLanes|=s),i===a)break;i=i.return}}function ws(i,s){Eo=i,Pl=Ss=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&s)!==0&&(Wt=!0),i.firstContext=null)}function ui(i){var s=i._currentValue;if(Pl!==i)if(i={context:i,memoizedValue:s,next:null},Ss===null){if(Eo===null)throw Error(r(308));Ss=i,Eo.dependencies={lanes:0,firstContext:i}}else Ss=Ss.next=i;return s}var zr=null;function Tl(i){zr===null?zr=[i]:zr.push(i)}function Jd(i,s,a,c){var d=s.interleaved;return d===null?(a.next=a,Tl(s)):(a.next=d.next,d.next=a),s.interleaved=a,Qi(i,c)}function Qi(i,s){i.lanes|=s;var a=i.alternate;for(a!==null&&(a.lanes|=s),a=i,i=i.return;i!==null;)i.childLanes|=s,a=i.alternate,a!==null&&(a.childLanes|=s),a=i,i=i.return;return a.tag===3?a.stateNode:null}var mr=!1;function jl(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Zd(i,s){i=i.updateQueue,s.updateQueue===i&&(s.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function Ji(i,s){return{eventTime:i,lane:s,tag:0,payload:null,callback:null,next:null}}function gr(i,s,a){var c=i.updateQueue;if(c===null)return null;if(c=c.shared,(Ae&2)!==0){var d=c.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),c.pending=s,Qi(i,a)}return d=c.interleaved,d===null?(s.next=s,Tl(c)):(s.next=d.next,d.next=s),c.interleaved=s,Qi(i,a)}function No(i,s,a){if(s=s.updateQueue,s!==null&&(s=s.shared,(a&4194240)!==0)){var c=s.lanes;c&=i.pendingLanes,a|=c,s.lanes=a,Ya(i,a)}}function ef(i,s){var a=i.updateQueue,c=i.alternate;if(c!==null&&(c=c.updateQueue,a===c)){var d=null,g=null;if(a=a.firstBaseUpdate,a!==null){do{var C={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};g===null?d=g=C:g=g.next=C,a=a.next}while(a!==null);g===null?d=g=s:g=g.next=s}else d=g=s;a={baseState:c.baseState,firstBaseUpdate:d,lastBaseUpdate:g,shared:c.shared,effects:c.effects},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=s:i.next=s,a.lastBaseUpdate=s}function Ro(i,s,a,c){var d=i.updateQueue;mr=!1;var g=d.firstBaseUpdate,C=d.lastBaseUpdate,D=d.shared.pending;if(D!==null){d.shared.pending=null;var W=D,ie=W.next;W.next=null,C===null?g=ie:C.next=ie,C=W;var ce=i.alternate;ce!==null&&(ce=ce.updateQueue,D=ce.lastBaseUpdate,D!==C&&(D===null?ce.firstBaseUpdate=ie:D.next=ie,ce.lastBaseUpdate=W))}if(g!==null){var he=d.baseState;C=0,ce=ie=W=null,D=g;do{var le=D.lane,ve=D.eventTime;if((c&le)===le){ce!==null&&(ce=ce.next={eventTime:ve,lane:0,tag:D.tag,payload:D.payload,callback:D.callback,next:null});e:{var Se=i,we=D;switch(le=s,ve=a,we.tag){case 1:if(Se=we.payload,typeof Se=="function"){he=Se.call(ve,he,le);break e}he=Se;break e;case 3:Se.flags=Se.flags&-65537|128;case 0:if(Se=we.payload,le=typeof Se=="function"?Se.call(ve,he,le):Se,le==null)break e;he=re({},he,le);break e;case 2:mr=!0}}D.callback!==null&&D.lane!==0&&(i.flags|=64,le=d.effects,le===null?d.effects=[D]:le.push(D))}else ve={eventTime:ve,lane:le,tag:D.tag,payload:D.payload,callback:D.callback,next:null},ce===null?(ie=ce=ve,W=he):ce=ce.next=ve,C|=le;if(D=D.next,D===null){if(D=d.shared.pending,D===null)break;le=D,D=le.next,le.next=null,d.lastBaseUpdate=le,d.shared.pending=null}}while(!0);if(ce===null&&(W=he),d.baseState=W,d.firstBaseUpdate=ie,d.lastBaseUpdate=ce,s=d.shared.interleaved,s!==null){d=s;do C|=d.lane,d=d.next;while(d!==s)}else g===null&&(d.shared.lanes=0);$r|=C,i.lanes=C,i.memoizedState=he}}function tf(i,s,a){if(i=s.effects,s.effects=null,i!==null)for(s=0;s<i.length;s++){var c=i[s],d=c.callback;if(d!==null){if(c.callback=null,c=a,typeof d!="function")throw Error(r(191,d));d.call(c)}}}var un={},ji=dr(un),hn=dr(un),dn=dr(un);function Fr(i){if(i===un)throw Error(r(174));return i}function Bl(i,s){switch($e(dn,s),$e(hn,i),$e(ji,un),i=s.nodeType,i){case 9:case 11:s=(s=s.documentElement)?s.namespaceURI:Gt(null,"");break;default:i=i===8?s.parentNode:s,s=i.namespaceURI||null,i=i.tagName,s=Gt(s,i)}Ue(ji),$e(ji,s)}function bs(){Ue(ji),Ue(hn),Ue(dn)}function rf(i){Fr(dn.current);var s=Fr(ji.current),a=Gt(s,i.type);s!==a&&($e(hn,i),$e(ji,a))}function Al(i){hn.current===i&&(Ue(ji),Ue(hn))}var Ye=dr(0);function Po(i){for(var s=i;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||a.data==="$?"||a.data==="$!"))return s}else if(s.tag===19&&s.memoizedProps.revealOrder!==void 0){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var Il=[];function Ol(){for(var i=0;i<Il.length;i++)Il[i]._workInProgressVersionPrimary=null;Il.length=0}var Do=j.ReactCurrentDispatcher,zl=j.ReactCurrentBatchConfig,Hr=0,Xe=null,ht=null,gt=null,Mo=!1,fn=!1,pn=0,Ny=0;function Mt(){throw Error(r(321))}function Fl(i,s){if(s===null)return!1;for(var a=0;a<s.length&&a<i.length;a++)if(!bi(i[a],s[a]))return!1;return!0}function Hl(i,s,a,c,d,g){if(Hr=g,Xe=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,Do.current=i===null||i.memoizedState===null?My:Ly,i=a(c,d),fn){g=0;do{if(fn=!1,pn=0,25<=g)throw Error(r(301));g+=1,gt=ht=null,s.updateQueue=null,Do.current=Ty,i=a(c,d)}while(fn)}if(Do.current=jo,s=ht!==null&&ht.next!==null,Hr=0,gt=ht=Xe=null,Mo=!1,s)throw Error(r(300));return i}function $l(){var i=pn!==0;return pn=0,i}function Bi(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return gt===null?Xe.memoizedState=gt=i:gt=gt.next=i,gt}function hi(){if(ht===null){var i=Xe.alternate;i=i!==null?i.memoizedState:null}else i=ht.next;var s=gt===null?Xe.memoizedState:gt.next;if(s!==null)gt=s,ht=i;else{if(i===null)throw Error(r(310));ht=i,i={memoizedState:ht.memoizedState,baseState:ht.baseState,baseQueue:ht.baseQueue,queue:ht.queue,next:null},gt===null?Xe.memoizedState=gt=i:gt=gt.next=i}return gt}function mn(i,s){return typeof s=="function"?s(i):s}function Wl(i){var s=hi(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=i;var c=ht,d=c.baseQueue,g=a.pending;if(g!==null){if(d!==null){var C=d.next;d.next=g.next,g.next=C}c.baseQueue=d=g,a.pending=null}if(d!==null){g=d.next,c=c.baseState;var D=C=null,W=null,ie=g;do{var ce=ie.lane;if((Hr&ce)===ce)W!==null&&(W=W.next={lane:0,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null}),c=ie.hasEagerState?ie.eagerState:i(c,ie.action);else{var he={lane:ce,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null};W===null?(D=W=he,C=c):W=W.next=he,Xe.lanes|=ce,$r|=ce}ie=ie.next}while(ie!==null&&ie!==g);W===null?C=c:W.next=D,bi(c,s.memoizedState)||(Wt=!0),s.memoizedState=c,s.baseState=C,s.baseQueue=W,a.lastRenderedState=c}if(i=a.interleaved,i!==null){d=i;do g=d.lane,Xe.lanes|=g,$r|=g,d=d.next;while(d!==i)}else d===null&&(a.lanes=0);return[s.memoizedState,a.dispatch]}function Ul(i){var s=hi(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=i;var c=a.dispatch,d=a.pending,g=s.memoizedState;if(d!==null){a.pending=null;var C=d=d.next;do g=i(g,C.action),C=C.next;while(C!==d);bi(g,s.memoizedState)||(Wt=!0),s.memoizedState=g,s.baseQueue===null&&(s.baseState=g),a.lastRenderedState=g}return[g,c]}function sf(){}function nf(i,s){var a=Xe,c=hi(),d=s(),g=!bi(c.memoizedState,d);if(g&&(c.memoizedState=d,Wt=!0),c=c.queue,ql(lf.bind(null,a,c,i),[i]),c.getSnapshot!==s||g||gt!==null&&gt.memoizedState.tag&1){if(a.flags|=2048,gn(9,af.bind(null,a,c,d,s),void 0,null),_t===null)throw Error(r(349));(Hr&30)!==0||of(a,s,d)}return d}function of(i,s,a){i.flags|=16384,i={getSnapshot:s,value:a},s=Xe.updateQueue,s===null?(s={lastEffect:null,stores:null},Xe.updateQueue=s,s.stores=[i]):(a=s.stores,a===null?s.stores=[i]:a.push(i))}function af(i,s,a,c){s.value=a,s.getSnapshot=c,cf(s)&&uf(i)}function lf(i,s,a){return a(function(){cf(s)&&uf(i)})}function cf(i){var s=i.getSnapshot;i=i.value;try{var a=s();return!bi(i,a)}catch{return!0}}function uf(i){var s=Qi(i,1);s!==null&&Ni(s,i,1,-1)}function hf(i){var s=Bi();return typeof i=="function"&&(i=i()),s.memoizedState=s.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:mn,lastRenderedState:i},s.queue=i,i=i.dispatch=Dy.bind(null,Xe,i),[s.memoizedState,i]}function gn(i,s,a,c){return i={tag:i,create:s,destroy:a,deps:c,next:null},s=Xe.updateQueue,s===null?(s={lastEffect:null,stores:null},Xe.updateQueue=s,s.lastEffect=i.next=i):(a=s.lastEffect,a===null?s.lastEffect=i.next=i:(c=a.next,a.next=i,i.next=c,s.lastEffect=i)),i}function df(){return hi().memoizedState}function Lo(i,s,a,c){var d=Bi();Xe.flags|=i,d.memoizedState=gn(1|s,a,void 0,c===void 0?null:c)}function To(i,s,a,c){var d=hi();c=c===void 0?null:c;var g=void 0;if(ht!==null){var C=ht.memoizedState;if(g=C.destroy,c!==null&&Fl(c,C.deps)){d.memoizedState=gn(s,a,g,c);return}}Xe.flags|=i,d.memoizedState=gn(1|s,a,g,c)}function ff(i,s){return Lo(8390656,8,i,s)}function ql(i,s){return To(2048,8,i,s)}function pf(i,s){return To(4,2,i,s)}function mf(i,s){return To(4,4,i,s)}function gf(i,s){if(typeof s=="function")return i=i(),s(i),function(){s(null)};if(s!=null)return i=i(),s.current=i,function(){s.current=null}}function _f(i,s,a){return a=a!=null?a.concat([i]):null,To(4,4,gf.bind(null,s,i),a)}function Kl(){}function vf(i,s){var a=hi();s=s===void 0?null:s;var c=a.memoizedState;return c!==null&&s!==null&&Fl(s,c[1])?c[0]:(a.memoizedState=[i,s],i)}function yf(i,s){var a=hi();s=s===void 0?null:s;var c=a.memoizedState;return c!==null&&s!==null&&Fl(s,c[1])?c[0]:(i=i(),a.memoizedState=[i,s],i)}function Sf(i,s,a){return(Hr&21)===0?(i.baseState&&(i.baseState=!1,Wt=!0),i.memoizedState=a):(bi(a,s)||(a=Xh(),Xe.lanes|=a,$r|=a,i.baseState=!0),s)}function Ry(i,s){var a=ze;ze=a!==0&&4>a?a:4,i(!0);var c=zl.transition;zl.transition={};try{i(!1),s()}finally{ze=a,zl.transition=c}}function wf(){return hi().memoizedState}function Py(i,s,a){var c=Sr(i);if(a={lane:c,action:a,hasEagerState:!1,eagerState:null,next:null},bf(i))Cf(s,a);else if(a=Jd(i,s,a,c),a!==null){var d=At();Ni(a,i,c,d),xf(a,s,c)}}function Dy(i,s,a){var c=Sr(i),d={lane:c,action:a,hasEagerState:!1,eagerState:null,next:null};if(bf(i))Cf(s,d);else{var g=i.alternate;if(i.lanes===0&&(g===null||g.lanes===0)&&(g=s.lastRenderedReducer,g!==null))try{var C=s.lastRenderedState,D=g(C,a);if(d.hasEagerState=!0,d.eagerState=D,bi(D,C)){var W=s.interleaved;W===null?(d.next=d,Tl(s)):(d.next=W.next,W.next=d),s.interleaved=d;return}}catch{}finally{}a=Jd(i,s,d,c),a!==null&&(d=At(),Ni(a,i,c,d),xf(a,s,c))}}function bf(i){var s=i.alternate;return i===Xe||s!==null&&s===Xe}function Cf(i,s){fn=Mo=!0;var a=i.pending;a===null?s.next=s:(s.next=a.next,a.next=s),i.pending=s}function xf(i,s,a){if((a&4194240)!==0){var c=s.lanes;c&=i.pendingLanes,a|=c,s.lanes=a,Ya(i,a)}}var jo={readContext:ui,useCallback:Mt,useContext:Mt,useEffect:Mt,useImperativeHandle:Mt,useInsertionEffect:Mt,useLayoutEffect:Mt,useMemo:Mt,useReducer:Mt,useRef:Mt,useState:Mt,useDebugValue:Mt,useDeferredValue:Mt,useTransition:Mt,useMutableSource:Mt,useSyncExternalStore:Mt,useId:Mt,unstable_isNewReconciler:!1},My={readContext:ui,useCallback:function(i,s){return Bi().memoizedState=[i,s===void 0?null:s],i},useContext:ui,useEffect:ff,useImperativeHandle:function(i,s,a){return a=a!=null?a.concat([i]):null,Lo(4194308,4,gf.bind(null,s,i),a)},useLayoutEffect:function(i,s){return Lo(4194308,4,i,s)},useInsertionEffect:function(i,s){return Lo(4,2,i,s)},useMemo:function(i,s){var a=Bi();return s=s===void 0?null:s,i=i(),a.memoizedState=[i,s],i},useReducer:function(i,s,a){var c=Bi();return s=a!==void 0?a(s):s,c.memoizedState=c.baseState=s,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:s},c.queue=i,i=i.dispatch=Py.bind(null,Xe,i),[c.memoizedState,i]},useRef:function(i){var s=Bi();return i={current:i},s.memoizedState=i},useState:hf,useDebugValue:Kl,useDeferredValue:function(i){return Bi().memoizedState=i},useTransition:function(){var i=hf(!1),s=i[0];return i=Ry.bind(null,i[1]),Bi().memoizedState=i,[s,i]},useMutableSource:function(){},useSyncExternalStore:function(i,s,a){var c=Xe,d=Bi();if(Ke){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),_t===null)throw Error(r(349));(Hr&30)!==0||of(c,s,a)}d.memoizedState=a;var g={value:a,getSnapshot:s};return d.queue=g,ff(lf.bind(null,c,g,i),[i]),c.flags|=2048,gn(9,af.bind(null,c,g,a,s),void 0,null),a},useId:function(){var i=Bi(),s=_t.identifierPrefix;if(Ke){var a=Gi,c=Xi;a=(c&~(1<<32-wi(c)-1)).toString(32)+a,s=":"+s+"R"+a,a=pn++,0<a&&(s+="H"+a.toString(32)),s+=":"}else a=Ny++,s=":"+s+"r"+a.toString(32)+":";return i.memoizedState=s},unstable_isNewReconciler:!1},Ly={readContext:ui,useCallback:vf,useContext:ui,useEffect:ql,useImperativeHandle:_f,useInsertionEffect:pf,useLayoutEffect:mf,useMemo:yf,useReducer:Wl,useRef:df,useState:function(){return Wl(mn)},useDebugValue:Kl,useDeferredValue:function(i){var s=hi();return Sf(s,ht.memoizedState,i)},useTransition:function(){var i=Wl(mn)[0],s=hi().memoizedState;return[i,s]},useMutableSource:sf,useSyncExternalStore:nf,useId:wf,unstable_isNewReconciler:!1},Ty={readContext:ui,useCallback:vf,useContext:ui,useEffect:ql,useImperativeHandle:_f,useInsertionEffect:pf,useLayoutEffect:mf,useMemo:yf,useReducer:Ul,useRef:df,useState:function(){return Ul(mn)},useDebugValue:Kl,useDeferredValue:function(i){var s=hi();return ht===null?s.memoizedState=i:Sf(s,ht.memoizedState,i)},useTransition:function(){var i=Ul(mn)[0],s=hi().memoizedState;return[i,s]},useMutableSource:sf,useSyncExternalStore:nf,useId:wf,unstable_isNewReconciler:!1};function xi(i,s){if(i&&i.defaultProps){s=re({},s),i=i.defaultProps;for(var a in i)s[a]===void 0&&(s[a]=i[a]);return s}return s}function Vl(i,s,a,c){s=i.memoizedState,a=a(c,s),a=a==null?s:re({},s,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Bo={isMounted:function(i){return(i=i._reactInternals)?jr(i)===i:!1},enqueueSetState:function(i,s,a){i=i._reactInternals;var c=At(),d=Sr(i),g=Ji(c,d);g.payload=s,a!=null&&(g.callback=a),s=gr(i,g,d),s!==null&&(Ni(s,i,d,c),No(s,i,d))},enqueueReplaceState:function(i,s,a){i=i._reactInternals;var c=At(),d=Sr(i),g=Ji(c,d);g.tag=1,g.payload=s,a!=null&&(g.callback=a),s=gr(i,g,d),s!==null&&(Ni(s,i,d,c),No(s,i,d))},enqueueForceUpdate:function(i,s){i=i._reactInternals;var a=At(),c=Sr(i),d=Ji(a,c);d.tag=2,s!=null&&(d.callback=s),s=gr(i,d,c),s!==null&&(Ni(s,i,c,a),No(s,i,c))}};function kf(i,s,a,c,d,g,C){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(c,g,C):s.prototype&&s.prototype.isPureReactComponent?!tn(a,c)||!tn(d,g):!0}function Ef(i,s,a){var c=!1,d=fr,g=s.contextType;return typeof g=="object"&&g!==null?g=ui(g):(d=$t(s)?Ar:Dt.current,c=s.contextTypes,g=(c=c!=null)?ms(i,d):fr),s=new s(a,g),i.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,s.updater=Bo,i.stateNode=s,s._reactInternals=i,c&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=d,i.__reactInternalMemoizedMaskedChildContext=g),s}function Nf(i,s,a,c){i=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(a,c),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(a,c),s.state!==i&&Bo.enqueueReplaceState(s,s.state,null)}function Yl(i,s,a,c){var d=i.stateNode;d.props=a,d.state=i.memoizedState,d.refs={},jl(i);var g=s.contextType;typeof g=="object"&&g!==null?d.context=ui(g):(g=$t(s)?Ar:Dt.current,d.context=ms(i,g)),d.state=i.memoizedState,g=s.getDerivedStateFromProps,typeof g=="function"&&(Vl(i,s,g,a),d.state=i.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(s=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),s!==d.state&&Bo.enqueueReplaceState(d,d.state,null),Ro(i,a,d,c),d.state=i.memoizedState),typeof d.componentDidMount=="function"&&(i.flags|=4194308)}function Cs(i,s){try{var a="",c=s;do a+=se(c),c=c.return;while(c);var d=a}catch(g){d=`
39
- Error generating stack: `+g.message+`
40
- `+g.stack}return{value:i,source:s,stack:d,digest:null}}function Xl(i,s,a){return{value:i,source:null,stack:a??null,digest:s??null}}function Gl(i,s){try{console.error(s.value)}catch(a){setTimeout(function(){throw a})}}var jy=typeof WeakMap=="function"?WeakMap:Map;function Rf(i,s,a){a=Ji(-1,a),a.tag=3,a.payload={element:null};var c=s.value;return a.callback=function(){$o||($o=!0,hc=c),Gl(i,s)},a}function Pf(i,s,a){a=Ji(-1,a),a.tag=3;var c=i.type.getDerivedStateFromError;if(typeof c=="function"){var d=s.value;a.payload=function(){return c(d)},a.callback=function(){Gl(i,s)}}var g=i.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(a.callback=function(){Gl(i,s),typeof c!="function"&&(vr===null?vr=new Set([this]):vr.add(this));var C=s.stack;this.componentDidCatch(s.value,{componentStack:C!==null?C:""})}),a}function Df(i,s,a){var c=i.pingCache;if(c===null){c=i.pingCache=new jy;var d=new Set;c.set(s,d)}else d=c.get(s),d===void 0&&(d=new Set,c.set(s,d));d.has(a)||(d.add(a),i=Yy.bind(null,i,s,a),s.then(i,i))}function Mf(i){do{var s;if((s=i.tag===13)&&(s=i.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return i;i=i.return}while(i!==null);return null}function Lf(i,s,a,c,d){return(i.mode&1)===0?(i===s?i.flags|=65536:(i.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(s=Ji(-1,1),s.tag=2,gr(a,s,1))),a.lanes|=1),i):(i.flags|=65536,i.lanes=d,i)}var By=j.ReactCurrentOwner,Wt=!1;function Bt(i,s,a,c){s.child=i===null?Qd(s,null,a,c):ys(s,i.child,a,c)}function Tf(i,s,a,c,d){a=a.render;var g=s.ref;return ws(s,d),c=Hl(i,s,a,c,g,d),a=$l(),i!==null&&!Wt?(s.updateQueue=i.updateQueue,s.flags&=-2053,i.lanes&=~d,Zi(i,s,d)):(Ke&&a&&xl(s),s.flags|=1,Bt(i,s,c,d),s.child)}function jf(i,s,a,c,d){if(i===null){var g=a.type;return typeof g=="function"&&!vc(g)&&g.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(s.tag=15,s.type=g,Bf(i,s,g,c,d)):(i=Yo(a.type,null,c,s,s.mode,d),i.ref=s.ref,i.return=s,s.child=i)}if(g=i.child,(i.lanes&d)===0){var C=g.memoizedProps;if(a=a.compare,a=a!==null?a:tn,a(C,c)&&i.ref===s.ref)return Zi(i,s,d)}return s.flags|=1,i=br(g,c),i.ref=s.ref,i.return=s,s.child=i}function Bf(i,s,a,c,d){if(i!==null){var g=i.memoizedProps;if(tn(g,c)&&i.ref===s.ref)if(Wt=!1,s.pendingProps=c=g,(i.lanes&d)!==0)(i.flags&131072)!==0&&(Wt=!0);else return s.lanes=i.lanes,Zi(i,s,d)}return Ql(i,s,a,c,d)}function Af(i,s,a){var c=s.pendingProps,d=c.children,g=i!==null?i.memoizedState:null;if(c.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},$e(ks,ti),ti|=a;else{if((a&1073741824)===0)return i=g!==null?g.baseLanes|a:a,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:i,cachePool:null,transitions:null},s.updateQueue=null,$e(ks,ti),ti|=i,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=g!==null?g.baseLanes:a,$e(ks,ti),ti|=c}else g!==null?(c=g.baseLanes|a,s.memoizedState=null):c=a,$e(ks,ti),ti|=c;return Bt(i,s,d,a),s.child}function If(i,s){var a=s.ref;(i===null&&a!==null||i!==null&&i.ref!==a)&&(s.flags|=512,s.flags|=2097152)}function Ql(i,s,a,c,d){var g=$t(a)?Ar:Dt.current;return g=ms(s,g),ws(s,d),a=Hl(i,s,a,c,g,d),c=$l(),i!==null&&!Wt?(s.updateQueue=i.updateQueue,s.flags&=-2053,i.lanes&=~d,Zi(i,s,d)):(Ke&&c&&xl(s),s.flags|=1,Bt(i,s,a,d),s.child)}function Of(i,s,a,c,d){if($t(a)){var g=!0;yo(s)}else g=!1;if(ws(s,d),s.stateNode===null)Io(i,s),Ef(s,a,c),Yl(s,a,c,d),c=!0;else if(i===null){var C=s.stateNode,D=s.memoizedProps;C.props=D;var W=C.context,ie=a.contextType;typeof ie=="object"&&ie!==null?ie=ui(ie):(ie=$t(a)?Ar:Dt.current,ie=ms(s,ie));var ce=a.getDerivedStateFromProps,he=typeof ce=="function"||typeof C.getSnapshotBeforeUpdate=="function";he||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(D!==c||W!==ie)&&Nf(s,C,c,ie),mr=!1;var le=s.memoizedState;C.state=le,Ro(s,c,C,d),W=s.memoizedState,D!==c||le!==W||Ht.current||mr?(typeof ce=="function"&&(Vl(s,a,ce,c),W=s.memoizedState),(D=mr||kf(s,a,D,c,le,W,ie))?(he||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount()),typeof C.componentDidMount=="function"&&(s.flags|=4194308)):(typeof C.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=c,s.memoizedState=W),C.props=c,C.state=W,C.context=ie,c=D):(typeof C.componentDidMount=="function"&&(s.flags|=4194308),c=!1)}else{C=s.stateNode,Zd(i,s),D=s.memoizedProps,ie=s.type===s.elementType?D:xi(s.type,D),C.props=ie,he=s.pendingProps,le=C.context,W=a.contextType,typeof W=="object"&&W!==null?W=ui(W):(W=$t(a)?Ar:Dt.current,W=ms(s,W));var ve=a.getDerivedStateFromProps;(ce=typeof ve=="function"||typeof C.getSnapshotBeforeUpdate=="function")||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(D!==he||le!==W)&&Nf(s,C,c,W),mr=!1,le=s.memoizedState,C.state=le,Ro(s,c,C,d);var Se=s.memoizedState;D!==he||le!==Se||Ht.current||mr?(typeof ve=="function"&&(Vl(s,a,ve,c),Se=s.memoizedState),(ie=mr||kf(s,a,ie,c,le,Se,W)||!1)?(ce||typeof C.UNSAFE_componentWillUpdate!="function"&&typeof C.componentWillUpdate!="function"||(typeof C.componentWillUpdate=="function"&&C.componentWillUpdate(c,Se,W),typeof C.UNSAFE_componentWillUpdate=="function"&&C.UNSAFE_componentWillUpdate(c,Se,W)),typeof C.componentDidUpdate=="function"&&(s.flags|=4),typeof C.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof C.componentDidUpdate!="function"||D===i.memoizedProps&&le===i.memoizedState||(s.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||D===i.memoizedProps&&le===i.memoizedState||(s.flags|=1024),s.memoizedProps=c,s.memoizedState=Se),C.props=c,C.state=Se,C.context=W,c=ie):(typeof C.componentDidUpdate!="function"||D===i.memoizedProps&&le===i.memoizedState||(s.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||D===i.memoizedProps&&le===i.memoizedState||(s.flags|=1024),c=!1)}return Jl(i,s,a,c,g,d)}function Jl(i,s,a,c,d,g){If(i,s);var C=(s.flags&128)!==0;if(!c&&!C)return d&&$d(s,a,!1),Zi(i,s,g);c=s.stateNode,By.current=s;var D=C&&typeof a.getDerivedStateFromError!="function"?null:c.render();return s.flags|=1,i!==null&&C?(s.child=ys(s,i.child,null,g),s.child=ys(s,null,D,g)):Bt(i,s,D,g),s.memoizedState=c.state,d&&$d(s,a,!0),s.child}function zf(i){var s=i.stateNode;s.pendingContext?Fd(i,s.pendingContext,s.pendingContext!==s.context):s.context&&Fd(i,s.context,!1),Bl(i,s.containerInfo)}function Ff(i,s,a,c,d){return vs(),Rl(d),s.flags|=256,Bt(i,s,a,c),s.child}var Zl={dehydrated:null,treeContext:null,retryLane:0};function ec(i){return{baseLanes:i,cachePool:null,transitions:null}}function Hf(i,s,a){var c=s.pendingProps,d=Ye.current,g=!1,C=(s.flags&128)!==0,D;if((D=C)||(D=i!==null&&i.memoizedState===null?!1:(d&2)!==0),D?(g=!0,s.flags&=-129):(i===null||i.memoizedState!==null)&&(d|=1),$e(Ye,d&1),i===null)return Nl(s),i=s.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((s.mode&1)===0?s.lanes=1:i.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(C=c.children,i=c.fallback,g?(c=s.mode,g=s.child,C={mode:"hidden",children:C},(c&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=C):g=Xo(C,c,0,null),i=Kr(i,c,a,null),g.return=s,i.return=s,g.sibling=i,s.child=g,s.child.memoizedState=ec(a),s.memoizedState=Zl,i):tc(s,C));if(d=i.memoizedState,d!==null&&(D=d.dehydrated,D!==null))return Ay(i,s,C,c,D,d,a);if(g){g=c.fallback,C=s.mode,d=i.child,D=d.sibling;var W={mode:"hidden",children:c.children};return(C&1)===0&&s.child!==d?(c=s.child,c.childLanes=0,c.pendingProps=W,s.deletions=null):(c=br(d,W),c.subtreeFlags=d.subtreeFlags&14680064),D!==null?g=br(D,g):(g=Kr(g,C,a,null),g.flags|=2),g.return=s,c.return=s,c.sibling=g,s.child=c,c=g,g=s.child,C=i.child.memoizedState,C=C===null?ec(a):{baseLanes:C.baseLanes|a,cachePool:null,transitions:C.transitions},g.memoizedState=C,g.childLanes=i.childLanes&~a,s.memoizedState=Zl,c}return g=i.child,i=g.sibling,c=br(g,{mode:"visible",children:c.children}),(s.mode&1)===0&&(c.lanes=a),c.return=s,c.sibling=null,i!==null&&(a=s.deletions,a===null?(s.deletions=[i],s.flags|=16):a.push(i)),s.child=c,s.memoizedState=null,c}function tc(i,s){return s=Xo({mode:"visible",children:s},i.mode,0,null),s.return=i,i.child=s}function Ao(i,s,a,c){return c!==null&&Rl(c),ys(s,i.child,null,a),i=tc(s,s.pendingProps.children),i.flags|=2,s.memoizedState=null,i}function Ay(i,s,a,c,d,g,C){if(a)return s.flags&256?(s.flags&=-257,c=Xl(Error(r(422))),Ao(i,s,C,c)):s.memoizedState!==null?(s.child=i.child,s.flags|=128,null):(g=c.fallback,d=s.mode,c=Xo({mode:"visible",children:c.children},d,0,null),g=Kr(g,d,C,null),g.flags|=2,c.return=s,g.return=s,c.sibling=g,s.child=c,(s.mode&1)!==0&&ys(s,i.child,null,C),s.child.memoizedState=ec(C),s.memoizedState=Zl,g);if((s.mode&1)===0)return Ao(i,s,C,null);if(d.data==="$!"){if(c=d.nextSibling&&d.nextSibling.dataset,c)var D=c.dgst;return c=D,g=Error(r(419)),c=Xl(g,c,void 0),Ao(i,s,C,c)}if(D=(C&i.childLanes)!==0,Wt||D){if(c=_t,c!==null){switch(C&-C){case 4:d=2;break;case 16:d=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:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(c.suspendedLanes|C))!==0?0:d,d!==0&&d!==g.retryLane&&(g.retryLane=d,Qi(i,d),Ni(c,i,d,-1))}return _c(),c=Xl(Error(r(421))),Ao(i,s,C,c)}return d.data==="$?"?(s.flags|=128,s.child=i.child,s=Xy.bind(null,i),d._reactRetry=s,null):(i=g.treeContext,ei=hr(d.nextSibling),Zt=s,Ke=!0,Ci=null,i!==null&&(li[ci++]=Xi,li[ci++]=Gi,li[ci++]=Ir,Xi=i.id,Gi=i.overflow,Ir=s),s=tc(s,c.children),s.flags|=4096,s)}function $f(i,s,a){i.lanes|=s;var c=i.alternate;c!==null&&(c.lanes|=s),Ll(i.return,s,a)}function ic(i,s,a,c,d){var g=i.memoizedState;g===null?i.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:c,tail:a,tailMode:d}:(g.isBackwards=s,g.rendering=null,g.renderingStartTime=0,g.last=c,g.tail=a,g.tailMode=d)}function Wf(i,s,a){var c=s.pendingProps,d=c.revealOrder,g=c.tail;if(Bt(i,s,c.children,a),c=Ye.current,(c&2)!==0)c=c&1|2,s.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=s.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&$f(i,a,s);else if(i.tag===19)$f(i,a,s);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===s)break e;for(;i.sibling===null;){if(i.return===null||i.return===s)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}c&=1}if($e(Ye,c),(s.mode&1)===0)s.memoizedState=null;else switch(d){case"forwards":for(a=s.child,d=null;a!==null;)i=a.alternate,i!==null&&Po(i)===null&&(d=a),a=a.sibling;a=d,a===null?(d=s.child,s.child=null):(d=a.sibling,a.sibling=null),ic(s,!1,d,a,g);break;case"backwards":for(a=null,d=s.child,s.child=null;d!==null;){if(i=d.alternate,i!==null&&Po(i)===null){s.child=d;break}i=d.sibling,d.sibling=a,a=d,d=i}ic(s,!0,a,null,g);break;case"together":ic(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function Io(i,s){(s.mode&1)===0&&i!==null&&(i.alternate=null,s.alternate=null,s.flags|=2)}function Zi(i,s,a){if(i!==null&&(s.dependencies=i.dependencies),$r|=s.lanes,(a&s.childLanes)===0)return null;if(i!==null&&s.child!==i.child)throw Error(r(153));if(s.child!==null){for(i=s.child,a=br(i,i.pendingProps),s.child=a,a.return=s;i.sibling!==null;)i=i.sibling,a=a.sibling=br(i,i.pendingProps),a.return=s;a.sibling=null}return s.child}function Iy(i,s,a){switch(s.tag){case 3:zf(s),vs();break;case 5:rf(s);break;case 1:$t(s.type)&&yo(s);break;case 4:Bl(s,s.stateNode.containerInfo);break;case 10:var c=s.type._context,d=s.memoizedProps.value;$e(ko,c._currentValue),c._currentValue=d;break;case 13:if(c=s.memoizedState,c!==null)return c.dehydrated!==null?($e(Ye,Ye.current&1),s.flags|=128,null):(a&s.child.childLanes)!==0?Hf(i,s,a):($e(Ye,Ye.current&1),i=Zi(i,s,a),i!==null?i.sibling:null);$e(Ye,Ye.current&1);break;case 19:if(c=(a&s.childLanes)!==0,(i.flags&128)!==0){if(c)return Wf(i,s,a);s.flags|=128}if(d=s.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),$e(Ye,Ye.current),c)break;return null;case 22:case 23:return s.lanes=0,Af(i,s,a)}return Zi(i,s,a)}var Uf,rc,qf,Kf;Uf=function(i,s){for(var a=s.child;a!==null;){if(a.tag===5||a.tag===6)i.appendChild(a.stateNode);else if(a.tag!==4&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===s)break;for(;a.sibling===null;){if(a.return===null||a.return===s)return;a=a.return}a.sibling.return=a.return,a=a.sibling}},rc=function(){},qf=function(i,s,a,c){var d=i.memoizedProps;if(d!==c){i=s.stateNode,Fr(ji.current);var g=null;switch(a){case"input":d=it(i,d),c=it(i,c),g=[];break;case"select":d=re({},d,{value:void 0}),c=re({},c,{value:void 0}),g=[];break;case"textarea":d=Xt(i,d),c=Xt(i,c),g=[];break;default:typeof d.onClick!="function"&&typeof c.onClick=="function"&&(i.onclick=go)}Mi(a,c);var C;a=null;for(ie in d)if(!c.hasOwnProperty(ie)&&d.hasOwnProperty(ie)&&d[ie]!=null)if(ie==="style"){var D=d[ie];for(C in D)D.hasOwnProperty(C)&&(a||(a={}),a[C]="")}else ie!=="dangerouslySetInnerHTML"&&ie!=="children"&&ie!=="suppressContentEditableWarning"&&ie!=="suppressHydrationWarning"&&ie!=="autoFocus"&&(o.hasOwnProperty(ie)?g||(g=[]):(g=g||[]).push(ie,null));for(ie in c){var W=c[ie];if(D=d!=null?d[ie]:void 0,c.hasOwnProperty(ie)&&W!==D&&(W!=null||D!=null))if(ie==="style")if(D){for(C in D)!D.hasOwnProperty(C)||W&&W.hasOwnProperty(C)||(a||(a={}),a[C]="");for(C in W)W.hasOwnProperty(C)&&D[C]!==W[C]&&(a||(a={}),a[C]=W[C])}else a||(g||(g=[]),g.push(ie,a)),a=W;else ie==="dangerouslySetInnerHTML"?(W=W?W.__html:void 0,D=D?D.__html:void 0,W!=null&&D!==W&&(g=g||[]).push(ie,W)):ie==="children"?typeof W!="string"&&typeof W!="number"||(g=g||[]).push(ie,""+W):ie!=="suppressContentEditableWarning"&&ie!=="suppressHydrationWarning"&&(o.hasOwnProperty(ie)?(W!=null&&ie==="onScroll"&&We("scroll",i),g||D===W||(g=[])):(g=g||[]).push(ie,W))}a&&(g=g||[]).push("style",a);var ie=g;(s.updateQueue=ie)&&(s.flags|=4)}},Kf=function(i,s,a,c){a!==c&&(s.flags|=4)};function _n(i,s){if(!Ke)switch(i.tailMode){case"hidden":s=i.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var c=null;a!==null;)a.alternate!==null&&(c=a),a=a.sibling;c===null?s||i.tail===null?i.tail=null:i.tail.sibling=null:c.sibling=null}}function Lt(i){var s=i.alternate!==null&&i.alternate.child===i.child,a=0,c=0;if(s)for(var d=i.child;d!==null;)a|=d.lanes|d.childLanes,c|=d.subtreeFlags&14680064,c|=d.flags&14680064,d.return=i,d=d.sibling;else for(d=i.child;d!==null;)a|=d.lanes|d.childLanes,c|=d.subtreeFlags,c|=d.flags,d.return=i,d=d.sibling;return i.subtreeFlags|=c,i.childLanes=a,s}function Oy(i,s,a){var c=s.pendingProps;switch(kl(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Lt(s),null;case 1:return $t(s.type)&&vo(),Lt(s),null;case 3:return c=s.stateNode,bs(),Ue(Ht),Ue(Dt),Ol(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(i===null||i.child===null)&&(Co(s)?s.flags|=4:i===null||i.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Ci!==null&&(pc(Ci),Ci=null))),rc(i,s),Lt(s),null;case 5:Al(s);var d=Fr(dn.current);if(a=s.type,i!==null&&s.stateNode!=null)qf(i,s,a,c,d),i.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!c){if(s.stateNode===null)throw Error(r(166));return Lt(s),null}if(i=Fr(ji.current),Co(s)){c=s.stateNode,a=s.type;var g=s.memoizedProps;switch(c[Ti]=s,c[an]=g,i=(s.mode&1)!==0,a){case"dialog":We("cancel",c),We("close",c);break;case"iframe":case"object":case"embed":We("load",c);break;case"video":case"audio":for(d=0;d<sn.length;d++)We(sn[d],c);break;case"source":We("error",c);break;case"img":case"image":case"link":We("error",c),We("load",c);break;case"details":We("toggle",c);break;case"input":ut(c,g),We("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!g.multiple},We("invalid",c);break;case"textarea":Mr(c,g),We("invalid",c)}Mi(a,g),d=null;for(var C in g)if(g.hasOwnProperty(C)){var D=g[C];C==="children"?typeof D=="string"?c.textContent!==D&&(g.suppressHydrationWarning!==!0&&mo(c.textContent,D,i),d=["children",D]):typeof D=="number"&&c.textContent!==""+D&&(g.suppressHydrationWarning!==!0&&mo(c.textContent,D,i),d=["children",""+D]):o.hasOwnProperty(C)&&D!=null&&C==="onScroll"&&We("scroll",c)}switch(a){case"input":Ee(c),qi(c,g,!0);break;case"textarea":Ee(c),Lr(c);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(c.onclick=go)}c=d,s.updateQueue=c,c!==null&&(s.flags|=4)}else{C=d.nodeType===9?d:d.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=Tr(a)),i==="http://www.w3.org/1999/xhtml"?a==="script"?(i=C.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof c.is=="string"?i=C.createElement(a,{is:c.is}):(i=C.createElement(a),a==="select"&&(C=i,c.multiple?C.multiple=!0:c.size&&(C.size=c.size))):i=C.createElementNS(i,a),i[Ti]=s,i[an]=c,Uf(i,s,!1,!1),s.stateNode=i;e:{switch(C=zs(a,c),a){case"dialog":We("cancel",i),We("close",i),d=c;break;case"iframe":case"object":case"embed":We("load",i),d=c;break;case"video":case"audio":for(d=0;d<sn.length;d++)We(sn[d],i);d=c;break;case"source":We("error",i),d=c;break;case"img":case"image":case"link":We("error",i),We("load",i),d=c;break;case"details":We("toggle",i),d=c;break;case"input":ut(i,c),d=it(i,c),We("invalid",i);break;case"option":d=c;break;case"select":i._wrapperState={wasMultiple:!!c.multiple},d=re({},c,{value:void 0}),We("invalid",i);break;case"textarea":Mr(i,c),d=Xt(i,c),We("invalid",i);break;default:d=c}Mi(a,d),D=d;for(g in D)if(D.hasOwnProperty(g)){var W=D[g];g==="style"?He(i,W):g==="dangerouslySetInnerHTML"?(W=W?W.__html:void 0,W!=null&&Si(i,W)):g==="children"?typeof W=="string"?(a!=="textarea"||W!=="")&&Ft(i,W):typeof W=="number"&&Ft(i,""+W):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(o.hasOwnProperty(g)?W!=null&&g==="onScroll"&&We("scroll",i):W!=null&&z(i,g,W,C))}switch(a){case"input":Ee(i),qi(i,c,!1);break;case"textarea":Ee(i),Lr(i);break;case"option":c.value!=null&&i.setAttribute("value",""+ue(c.value));break;case"select":i.multiple=!!c.multiple,g=c.value,g!=null?yi(i,!!c.multiple,g,!1):c.defaultValue!=null&&yi(i,!!c.multiple,c.defaultValue,!0);break;default:typeof d.onClick=="function"&&(i.onclick=go)}switch(a){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(s.flags|=4)}s.ref!==null&&(s.flags|=512,s.flags|=2097152)}return Lt(s),null;case 6:if(i&&s.stateNode!=null)Kf(i,s,i.memoizedProps,c);else{if(typeof c!="string"&&s.stateNode===null)throw Error(r(166));if(a=Fr(dn.current),Fr(ji.current),Co(s)){if(c=s.stateNode,a=s.memoizedProps,c[Ti]=s,(g=c.nodeValue!==a)&&(i=Zt,i!==null))switch(i.tag){case 3:mo(c.nodeValue,a,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&mo(c.nodeValue,a,(i.mode&1)!==0)}g&&(s.flags|=4)}else c=(a.nodeType===9?a:a.ownerDocument).createTextNode(c),c[Ti]=s,s.stateNode=c}return Lt(s),null;case 13:if(Ue(Ye),c=s.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(Ke&&ei!==null&&(s.mode&1)!==0&&(s.flags&128)===0)Yd(),vs(),s.flags|=98560,g=!1;else if(g=Co(s),c!==null&&c.dehydrated!==null){if(i===null){if(!g)throw Error(r(318));if(g=s.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(r(317));g[Ti]=s}else vs(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Lt(s),g=!1}else Ci!==null&&(pc(Ci),Ci=null),g=!0;if(!g)return s.flags&65536?s:null}return(s.flags&128)!==0?(s.lanes=a,s):(c=c!==null,c!==(i!==null&&i.memoizedState!==null)&&c&&(s.child.flags|=8192,(s.mode&1)!==0&&(i===null||(Ye.current&1)!==0?dt===0&&(dt=3):_c())),s.updateQueue!==null&&(s.flags|=4),Lt(s),null);case 4:return bs(),rc(i,s),i===null&&nn(s.stateNode.containerInfo),Lt(s),null;case 10:return Ml(s.type._context),Lt(s),null;case 17:return $t(s.type)&&vo(),Lt(s),null;case 19:if(Ue(Ye),g=s.memoizedState,g===null)return Lt(s),null;if(c=(s.flags&128)!==0,C=g.rendering,C===null)if(c)_n(g,!1);else{if(dt!==0||i!==null&&(i.flags&128)!==0)for(i=s.child;i!==null;){if(C=Po(i),C!==null){for(s.flags|=128,_n(g,!1),c=C.updateQueue,c!==null&&(s.updateQueue=c,s.flags|=4),s.subtreeFlags=0,c=a,a=s.child;a!==null;)g=a,i=c,g.flags&=14680066,C=g.alternate,C===null?(g.childLanes=0,g.lanes=i,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=C.childLanes,g.lanes=C.lanes,g.child=C.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=C.memoizedProps,g.memoizedState=C.memoizedState,g.updateQueue=C.updateQueue,g.type=C.type,i=C.dependencies,g.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),a=a.sibling;return $e(Ye,Ye.current&1|2),s.child}i=i.sibling}g.tail!==null&&st()>Es&&(s.flags|=128,c=!0,_n(g,!1),s.lanes=4194304)}else{if(!c)if(i=Po(C),i!==null){if(s.flags|=128,c=!0,a=i.updateQueue,a!==null&&(s.updateQueue=a,s.flags|=4),_n(g,!0),g.tail===null&&g.tailMode==="hidden"&&!C.alternate&&!Ke)return Lt(s),null}else 2*st()-g.renderingStartTime>Es&&a!==1073741824&&(s.flags|=128,c=!0,_n(g,!1),s.lanes=4194304);g.isBackwards?(C.sibling=s.child,s.child=C):(a=g.last,a!==null?a.sibling=C:s.child=C,g.last=C)}return g.tail!==null?(s=g.tail,g.rendering=s,g.tail=s.sibling,g.renderingStartTime=st(),s.sibling=null,a=Ye.current,$e(Ye,c?a&1|2:a&1),s):(Lt(s),null);case 22:case 23:return gc(),c=s.memoizedState!==null,i!==null&&i.memoizedState!==null!==c&&(s.flags|=8192),c&&(s.mode&1)!==0?(ti&1073741824)!==0&&(Lt(s),s.subtreeFlags&6&&(s.flags|=8192)):Lt(s),null;case 24:return null;case 25:return null}throw Error(r(156,s.tag))}function zy(i,s){switch(kl(s),s.tag){case 1:return $t(s.type)&&vo(),i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 3:return bs(),Ue(Ht),Ue(Dt),Ol(),i=s.flags,(i&65536)!==0&&(i&128)===0?(s.flags=i&-65537|128,s):null;case 5:return Al(s),null;case 13:if(Ue(Ye),i=s.memoizedState,i!==null&&i.dehydrated!==null){if(s.alternate===null)throw Error(r(340));vs()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 19:return Ue(Ye),null;case 4:return bs(),null;case 10:return Ml(s.type._context),null;case 22:case 23:return gc(),null;case 24:return null;default:return null}}var Oo=!1,Tt=!1,Fy=typeof WeakSet=="function"?WeakSet:Set,ye=null;function xs(i,s){var a=i.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(c){Ze(i,s,c)}else a.current=null}function sc(i,s,a){try{a()}catch(c){Ze(i,s,c)}}var Vf=!1;function Hy(i,s){if(gl=ro,i=xd(),ll(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var c=a.getSelection&&a.getSelection();if(c&&c.rangeCount!==0){a=c.anchorNode;var d=c.anchorOffset,g=c.focusNode;c=c.focusOffset;try{a.nodeType,g.nodeType}catch{a=null;break e}var C=0,D=-1,W=-1,ie=0,ce=0,he=i,le=null;t:for(;;){for(var ve;he!==a||d!==0&&he.nodeType!==3||(D=C+d),he!==g||c!==0&&he.nodeType!==3||(W=C+c),he.nodeType===3&&(C+=he.nodeValue.length),(ve=he.firstChild)!==null;)le=he,he=ve;for(;;){if(he===i)break t;if(le===a&&++ie===d&&(D=C),le===g&&++ce===c&&(W=C),(ve=he.nextSibling)!==null)break;he=le,le=he.parentNode}he=ve}a=D===-1||W===-1?null:{start:D,end:W}}else a=null}a=a||{start:0,end:0}}else a=null;for(_l={focusedElem:i,selectionRange:a},ro=!1,ye=s;ye!==null;)if(s=ye,i=s.child,(s.subtreeFlags&1028)!==0&&i!==null)i.return=s,ye=i;else for(;ye!==null;){s=ye;try{var Se=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(Se!==null){var we=Se.memoizedProps,nt=Se.memoizedState,J=s.stateNode,q=J.getSnapshotBeforeUpdate(s.elementType===s.type?we:xi(s.type,we),nt);J.__reactInternalSnapshotBeforeUpdate=q}break;case 3:var te=s.stateNode.containerInfo;te.nodeType===1?te.textContent="":te.nodeType===9&&te.documentElement&&te.removeChild(te.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(de){Ze(s,s.return,de)}if(i=s.sibling,i!==null){i.return=s.return,ye=i;break}ye=s.return}return Se=Vf,Vf=!1,Se}function vn(i,s,a){var c=s.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var d=c=c.next;do{if((d.tag&i)===i){var g=d.destroy;d.destroy=void 0,g!==void 0&&sc(s,a,g)}d=d.next}while(d!==c)}}function zo(i,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var a=s=s.next;do{if((a.tag&i)===i){var c=a.create;a.destroy=c()}a=a.next}while(a!==s)}}function nc(i){var s=i.ref;if(s!==null){var a=i.stateNode;switch(i.tag){case 5:i=a;break;default:i=a}typeof s=="function"?s(i):s.current=i}}function Yf(i){var s=i.alternate;s!==null&&(i.alternate=null,Yf(s)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(s=i.stateNode,s!==null&&(delete s[Ti],delete s[an],delete s[wl],delete s[Cy],delete s[xy])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function Xf(i){return i.tag===5||i.tag===3||i.tag===4}function Gf(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Xf(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function oc(i,s,a){var c=i.tag;if(c===5||c===6)i=i.stateNode,s?a.nodeType===8?a.parentNode.insertBefore(i,s):a.insertBefore(i,s):(a.nodeType===8?(s=a.parentNode,s.insertBefore(i,a)):(s=a,s.appendChild(i)),a=a._reactRootContainer,a!=null||s.onclick!==null||(s.onclick=go));else if(c!==4&&(i=i.child,i!==null))for(oc(i,s,a),i=i.sibling;i!==null;)oc(i,s,a),i=i.sibling}function ac(i,s,a){var c=i.tag;if(c===5||c===6)i=i.stateNode,s?a.insertBefore(i,s):a.appendChild(i);else if(c!==4&&(i=i.child,i!==null))for(ac(i,s,a),i=i.sibling;i!==null;)ac(i,s,a),i=i.sibling}var kt=null,ki=!1;function _r(i,s,a){for(a=a.child;a!==null;)Qf(i,s,a),a=a.sibling}function Qf(i,s,a){if(Li&&typeof Li.onCommitFiberUnmount=="function")try{Li.onCommitFiberUnmount(Qn,a)}catch{}switch(a.tag){case 5:Tt||xs(a,s);case 6:var c=kt,d=ki;kt=null,_r(i,s,a),kt=c,ki=d,kt!==null&&(ki?(i=kt,a=a.stateNode,i.nodeType===8?i.parentNode.removeChild(a):i.removeChild(a)):kt.removeChild(a.stateNode));break;case 18:kt!==null&&(ki?(i=kt,a=a.stateNode,i.nodeType===8?Sl(i.parentNode,a):i.nodeType===1&&Sl(i,a),Xs(i)):Sl(kt,a.stateNode));break;case 4:c=kt,d=ki,kt=a.stateNode.containerInfo,ki=!0,_r(i,s,a),kt=c,ki=d;break;case 0:case 11:case 14:case 15:if(!Tt&&(c=a.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){d=c=c.next;do{var g=d,C=g.destroy;g=g.tag,C!==void 0&&((g&2)!==0||(g&4)!==0)&&sc(a,s,C),d=d.next}while(d!==c)}_r(i,s,a);break;case 1:if(!Tt&&(xs(a,s),c=a.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=a.memoizedProps,c.state=a.memoizedState,c.componentWillUnmount()}catch(D){Ze(a,s,D)}_r(i,s,a);break;case 21:_r(i,s,a);break;case 22:a.mode&1?(Tt=(c=Tt)||a.memoizedState!==null,_r(i,s,a),Tt=c):_r(i,s,a);break;default:_r(i,s,a)}}function Jf(i){var s=i.updateQueue;if(s!==null){i.updateQueue=null;var a=i.stateNode;a===null&&(a=i.stateNode=new Fy),s.forEach(function(c){var d=Gy.bind(null,i,c);a.has(c)||(a.add(c),c.then(d,d))})}}function Ei(i,s){var a=s.deletions;if(a!==null)for(var c=0;c<a.length;c++){var d=a[c];try{var g=i,C=s,D=C;e:for(;D!==null;){switch(D.tag){case 5:kt=D.stateNode,ki=!1;break e;case 3:kt=D.stateNode.containerInfo,ki=!0;break e;case 4:kt=D.stateNode.containerInfo,ki=!0;break e}D=D.return}if(kt===null)throw Error(r(160));Qf(g,C,d),kt=null,ki=!1;var W=d.alternate;W!==null&&(W.return=null),d.return=null}catch(ie){Ze(d,s,ie)}}if(s.subtreeFlags&12854)for(s=s.child;s!==null;)Zf(s,i),s=s.sibling}function Zf(i,s){var a=i.alternate,c=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(Ei(s,i),Ai(i),c&4){try{vn(3,i,i.return),zo(3,i)}catch(we){Ze(i,i.return,we)}try{vn(5,i,i.return)}catch(we){Ze(i,i.return,we)}}break;case 1:Ei(s,i),Ai(i),c&512&&a!==null&&xs(a,a.return);break;case 5:if(Ei(s,i),Ai(i),c&512&&a!==null&&xs(a,a.return),i.flags&32){var d=i.stateNode;try{Ft(d,"")}catch(we){Ze(i,i.return,we)}}if(c&4&&(d=i.stateNode,d!=null)){var g=i.memoizedProps,C=a!==null?a.memoizedProps:g,D=i.type,W=i.updateQueue;if(i.updateQueue=null,W!==null)try{D==="input"&&g.type==="radio"&&g.name!=null&&Pt(d,g),zs(D,C);var ie=zs(D,g);for(C=0;C<W.length;C+=2){var ce=W[C],he=W[C+1];ce==="style"?He(d,he):ce==="dangerouslySetInnerHTML"?Si(d,he):ce==="children"?Ft(d,he):z(d,ce,he,ie)}switch(D){case"input":Je(d,g);break;case"textarea":Ki(d,g);break;case"select":var le=d._wrapperState.wasMultiple;d._wrapperState.wasMultiple=!!g.multiple;var ve=g.value;ve!=null?yi(d,!!g.multiple,ve,!1):le!==!!g.multiple&&(g.defaultValue!=null?yi(d,!!g.multiple,g.defaultValue,!0):yi(d,!!g.multiple,g.multiple?[]:"",!1))}d[an]=g}catch(we){Ze(i,i.return,we)}}break;case 6:if(Ei(s,i),Ai(i),c&4){if(i.stateNode===null)throw Error(r(162));d=i.stateNode,g=i.memoizedProps;try{d.nodeValue=g}catch(we){Ze(i,i.return,we)}}break;case 3:if(Ei(s,i),Ai(i),c&4&&a!==null&&a.memoizedState.isDehydrated)try{Xs(s.containerInfo)}catch(we){Ze(i,i.return,we)}break;case 4:Ei(s,i),Ai(i);break;case 13:Ei(s,i),Ai(i),d=i.child,d.flags&8192&&(g=d.memoizedState!==null,d.stateNode.isHidden=g,!g||d.alternate!==null&&d.alternate.memoizedState!==null||(uc=st())),c&4&&Jf(i);break;case 22:if(ce=a!==null&&a.memoizedState!==null,i.mode&1?(Tt=(ie=Tt)||ce,Ei(s,i),Tt=ie):Ei(s,i),Ai(i),c&8192){if(ie=i.memoizedState!==null,(i.stateNode.isHidden=ie)&&!ce&&(i.mode&1)!==0)for(ye=i,ce=i.child;ce!==null;){for(he=ye=ce;ye!==null;){switch(le=ye,ve=le.child,le.tag){case 0:case 11:case 14:case 15:vn(4,le,le.return);break;case 1:xs(le,le.return);var Se=le.stateNode;if(typeof Se.componentWillUnmount=="function"){c=le,a=le.return;try{s=c,Se.props=s.memoizedProps,Se.state=s.memoizedState,Se.componentWillUnmount()}catch(we){Ze(c,a,we)}}break;case 5:xs(le,le.return);break;case 22:if(le.memoizedState!==null){ip(he);continue}}ve!==null?(ve.return=le,ye=ve):ip(he)}ce=ce.sibling}e:for(ce=null,he=i;;){if(he.tag===5){if(ce===null){ce=he;try{d=he.stateNode,ie?(g=d.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(D=he.stateNode,W=he.memoizedProps.style,C=W!=null&&W.hasOwnProperty("display")?W.display:null,D.style.display=Ne("display",C))}catch(we){Ze(i,i.return,we)}}}else if(he.tag===6){if(ce===null)try{he.stateNode.nodeValue=ie?"":he.memoizedProps}catch(we){Ze(i,i.return,we)}}else if((he.tag!==22&&he.tag!==23||he.memoizedState===null||he===i)&&he.child!==null){he.child.return=he,he=he.child;continue}if(he===i)break e;for(;he.sibling===null;){if(he.return===null||he.return===i)break e;ce===he&&(ce=null),he=he.return}ce===he&&(ce=null),he.sibling.return=he.return,he=he.sibling}}break;case 19:Ei(s,i),Ai(i),c&4&&Jf(i);break;case 21:break;default:Ei(s,i),Ai(i)}}function Ai(i){var s=i.flags;if(s&2){try{e:{for(var a=i.return;a!==null;){if(Xf(a)){var c=a;break e}a=a.return}throw Error(r(160))}switch(c.tag){case 5:var d=c.stateNode;c.flags&32&&(Ft(d,""),c.flags&=-33);var g=Gf(i);ac(i,g,d);break;case 3:case 4:var C=c.stateNode.containerInfo,D=Gf(i);oc(i,D,C);break;default:throw Error(r(161))}}catch(W){Ze(i,i.return,W)}i.flags&=-3}s&4096&&(i.flags&=-4097)}function $y(i,s,a){ye=i,ep(i)}function ep(i,s,a){for(var c=(i.mode&1)!==0;ye!==null;){var d=ye,g=d.child;if(d.tag===22&&c){var C=d.memoizedState!==null||Oo;if(!C){var D=d.alternate,W=D!==null&&D.memoizedState!==null||Tt;D=Oo;var ie=Tt;if(Oo=C,(Tt=W)&&!ie)for(ye=d;ye!==null;)C=ye,W=C.child,C.tag===22&&C.memoizedState!==null?rp(d):W!==null?(W.return=C,ye=W):rp(d);for(;g!==null;)ye=g,ep(g),g=g.sibling;ye=d,Oo=D,Tt=ie}tp(i)}else(d.subtreeFlags&8772)!==0&&g!==null?(g.return=d,ye=g):tp(i)}}function tp(i){for(;ye!==null;){var s=ye;if((s.flags&8772)!==0){var a=s.alternate;try{if((s.flags&8772)!==0)switch(s.tag){case 0:case 11:case 15:Tt||zo(5,s);break;case 1:var c=s.stateNode;if(s.flags&4&&!Tt)if(a===null)c.componentDidMount();else{var d=s.elementType===s.type?a.memoizedProps:xi(s.type,a.memoizedProps);c.componentDidUpdate(d,a.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var g=s.updateQueue;g!==null&&tf(s,g,c);break;case 3:var C=s.updateQueue;if(C!==null){if(a=null,s.child!==null)switch(s.child.tag){case 5:a=s.child.stateNode;break;case 1:a=s.child.stateNode}tf(s,C,a)}break;case 5:var D=s.stateNode;if(a===null&&s.flags&4){a=D;var W=s.memoizedProps;switch(s.type){case"button":case"input":case"select":case"textarea":W.autoFocus&&a.focus();break;case"img":W.src&&(a.src=W.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(s.memoizedState===null){var ie=s.alternate;if(ie!==null){var ce=ie.memoizedState;if(ce!==null){var he=ce.dehydrated;he!==null&&Xs(he)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}Tt||s.flags&512&&nc(s)}catch(le){Ze(s,s.return,le)}}if(s===i){ye=null;break}if(a=s.sibling,a!==null){a.return=s.return,ye=a;break}ye=s.return}}function ip(i){for(;ye!==null;){var s=ye;if(s===i){ye=null;break}var a=s.sibling;if(a!==null){a.return=s.return,ye=a;break}ye=s.return}}function rp(i){for(;ye!==null;){var s=ye;try{switch(s.tag){case 0:case 11:case 15:var a=s.return;try{zo(4,s)}catch(W){Ze(s,a,W)}break;case 1:var c=s.stateNode;if(typeof c.componentDidMount=="function"){var d=s.return;try{c.componentDidMount()}catch(W){Ze(s,d,W)}}var g=s.return;try{nc(s)}catch(W){Ze(s,g,W)}break;case 5:var C=s.return;try{nc(s)}catch(W){Ze(s,C,W)}}}catch(W){Ze(s,s.return,W)}if(s===i){ye=null;break}var D=s.sibling;if(D!==null){D.return=s.return,ye=D;break}ye=s.return}}var Wy=Math.ceil,Fo=j.ReactCurrentDispatcher,lc=j.ReactCurrentOwner,di=j.ReactCurrentBatchConfig,Ae=0,_t=null,at=null,Et=0,ti=0,ks=dr(0),dt=0,yn=null,$r=0,Ho=0,cc=0,Sn=null,Ut=null,uc=0,Es=1/0,er=null,$o=!1,hc=null,vr=null,Wo=!1,yr=null,Uo=0,wn=0,dc=null,qo=-1,Ko=0;function At(){return(Ae&6)!==0?st():qo!==-1?qo:qo=st()}function Sr(i){return(i.mode&1)===0?1:(Ae&2)!==0&&Et!==0?Et&-Et:Ey.transition!==null?(Ko===0&&(Ko=Xh()),Ko):(i=ze,i!==0||(i=window.event,i=i===void 0?16:sd(i.type)),i)}function Ni(i,s,a,c){if(50<wn)throw wn=0,dc=null,Error(r(185));Us(i,a,c),((Ae&2)===0||i!==_t)&&(i===_t&&((Ae&2)===0&&(Ho|=a),dt===4&&wr(i,Et)),qt(i,c),a===1&&Ae===0&&(s.mode&1)===0&&(Es=st()+500,So&&pr()))}function qt(i,s){var a=i.callbackNode;Ev(i,s);var c=eo(i,i===_t?Et:0);if(c===0)a!==null&&Kh(a),i.callbackNode=null,i.callbackPriority=0;else if(s=c&-c,i.callbackPriority!==s){if(a!=null&&Kh(a),s===1)i.tag===0?ky(np.bind(null,i)):Wd(np.bind(null,i)),wy(function(){(Ae&6)===0&&pr()}),a=null;else{switch(Gh(c)){case 1:a=qa;break;case 4:a=Vh;break;case 16:a=Gn;break;case 536870912:a=Yh;break;default:a=Gn}a=fp(a,sp.bind(null,i))}i.callbackPriority=s,i.callbackNode=a}}function sp(i,s){if(qo=-1,Ko=0,(Ae&6)!==0)throw Error(r(327));var a=i.callbackNode;if(Ns()&&i.callbackNode!==a)return null;var c=eo(i,i===_t?Et:0);if(c===0)return null;if((c&30)!==0||(c&i.expiredLanes)!==0||s)s=Vo(i,c);else{s=c;var d=Ae;Ae|=2;var g=ap();(_t!==i||Et!==s)&&(er=null,Es=st()+500,Ur(i,s));do try{Ky();break}catch(D){op(i,D)}while(!0);Dl(),Fo.current=g,Ae=d,at!==null?s=0:(_t=null,Et=0,s=dt)}if(s!==0){if(s===2&&(d=Ka(i),d!==0&&(c=d,s=fc(i,d))),s===1)throw a=yn,Ur(i,0),wr(i,c),qt(i,st()),a;if(s===6)wr(i,c);else{if(d=i.current.alternate,(c&30)===0&&!Uy(d)&&(s=Vo(i,c),s===2&&(g=Ka(i),g!==0&&(c=g,s=fc(i,g))),s===1))throw a=yn,Ur(i,0),wr(i,c),qt(i,st()),a;switch(i.finishedWork=d,i.finishedLanes=c,s){case 0:case 1:throw Error(r(345));case 2:qr(i,Ut,er);break;case 3:if(wr(i,c),(c&130023424)===c&&(s=uc+500-st(),10<s)){if(eo(i,0)!==0)break;if(d=i.suspendedLanes,(d&c)!==c){At(),i.pingedLanes|=i.suspendedLanes&d;break}i.timeoutHandle=yl(qr.bind(null,i,Ut,er),s);break}qr(i,Ut,er);break;case 4:if(wr(i,c),(c&4194240)===c)break;for(s=i.eventTimes,d=-1;0<c;){var C=31-wi(c);g=1<<C,C=s[C],C>d&&(d=C),c&=~g}if(c=d,c=st()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*Wy(c/1960))-c,10<c){i.timeoutHandle=yl(qr.bind(null,i,Ut,er),c);break}qr(i,Ut,er);break;case 5:qr(i,Ut,er);break;default:throw Error(r(329))}}}return qt(i,st()),i.callbackNode===a?sp.bind(null,i):null}function fc(i,s){var a=Sn;return i.current.memoizedState.isDehydrated&&(Ur(i,s).flags|=256),i=Vo(i,s),i!==2&&(s=Ut,Ut=a,s!==null&&pc(s)),i}function pc(i){Ut===null?Ut=i:Ut.push.apply(Ut,i)}function Uy(i){for(var s=i;;){if(s.flags&16384){var a=s.updateQueue;if(a!==null&&(a=a.stores,a!==null))for(var c=0;c<a.length;c++){var d=a[c],g=d.getSnapshot;d=d.value;try{if(!bi(g(),d))return!1}catch{return!1}}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function wr(i,s){for(s&=~cc,s&=~Ho,i.suspendedLanes|=s,i.pingedLanes&=~s,i=i.expirationTimes;0<s;){var a=31-wi(s),c=1<<a;i[a]=-1,s&=~c}}function np(i){if((Ae&6)!==0)throw Error(r(327));Ns();var s=eo(i,0);if((s&1)===0)return qt(i,st()),null;var a=Vo(i,s);if(i.tag!==0&&a===2){var c=Ka(i);c!==0&&(s=c,a=fc(i,c))}if(a===1)throw a=yn,Ur(i,0),wr(i,s),qt(i,st()),a;if(a===6)throw Error(r(345));return i.finishedWork=i.current.alternate,i.finishedLanes=s,qr(i,Ut,er),qt(i,st()),null}function mc(i,s){var a=Ae;Ae|=1;try{return i(s)}finally{Ae=a,Ae===0&&(Es=st()+500,So&&pr())}}function Wr(i){yr!==null&&yr.tag===0&&(Ae&6)===0&&Ns();var s=Ae;Ae|=1;var a=di.transition,c=ze;try{if(di.transition=null,ze=1,i)return i()}finally{ze=c,di.transition=a,Ae=s,(Ae&6)===0&&pr()}}function gc(){ti=ks.current,Ue(ks)}function Ur(i,s){i.finishedWork=null,i.finishedLanes=0;var a=i.timeoutHandle;if(a!==-1&&(i.timeoutHandle=-1,Sy(a)),at!==null)for(a=at.return;a!==null;){var c=a;switch(kl(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&vo();break;case 3:bs(),Ue(Ht),Ue(Dt),Ol();break;case 5:Al(c);break;case 4:bs();break;case 13:Ue(Ye);break;case 19:Ue(Ye);break;case 10:Ml(c.type._context);break;case 22:case 23:gc()}a=a.return}if(_t=i,at=i=br(i.current,null),Et=ti=s,dt=0,yn=null,cc=Ho=$r=0,Ut=Sn=null,zr!==null){for(s=0;s<zr.length;s++)if(a=zr[s],c=a.interleaved,c!==null){a.interleaved=null;var d=c.next,g=a.pending;if(g!==null){var C=g.next;g.next=d,c.next=C}a.pending=c}zr=null}return i}function op(i,s){do{var a=at;try{if(Dl(),Do.current=jo,Mo){for(var c=Xe.memoizedState;c!==null;){var d=c.queue;d!==null&&(d.pending=null),c=c.next}Mo=!1}if(Hr=0,gt=ht=Xe=null,fn=!1,pn=0,lc.current=null,a===null||a.return===null){dt=1,yn=s,at=null;break}e:{var g=i,C=a.return,D=a,W=s;if(s=Et,D.flags|=32768,W!==null&&typeof W=="object"&&typeof W.then=="function"){var ie=W,ce=D,he=ce.tag;if((ce.mode&1)===0&&(he===0||he===11||he===15)){var le=ce.alternate;le?(ce.updateQueue=le.updateQueue,ce.memoizedState=le.memoizedState,ce.lanes=le.lanes):(ce.updateQueue=null,ce.memoizedState=null)}var ve=Mf(C);if(ve!==null){ve.flags&=-257,Lf(ve,C,D,g,s),ve.mode&1&&Df(g,ie,s),s=ve,W=ie;var Se=s.updateQueue;if(Se===null){var we=new Set;we.add(W),s.updateQueue=we}else Se.add(W);break e}else{if((s&1)===0){Df(g,ie,s),_c();break e}W=Error(r(426))}}else if(Ke&&D.mode&1){var nt=Mf(C);if(nt!==null){(nt.flags&65536)===0&&(nt.flags|=256),Lf(nt,C,D,g,s),Rl(Cs(W,D));break e}}g=W=Cs(W,D),dt!==4&&(dt=2),Sn===null?Sn=[g]:Sn.push(g),g=C;do{switch(g.tag){case 3:g.flags|=65536,s&=-s,g.lanes|=s;var J=Rf(g,W,s);ef(g,J);break e;case 1:D=W;var q=g.type,te=g.stateNode;if((g.flags&128)===0&&(typeof q.getDerivedStateFromError=="function"||te!==null&&typeof te.componentDidCatch=="function"&&(vr===null||!vr.has(te)))){g.flags|=65536,s&=-s,g.lanes|=s;var de=Pf(g,D,s);ef(g,de);break e}}g=g.return}while(g!==null)}cp(a)}catch(be){s=be,at===a&&a!==null&&(at=a=a.return);continue}break}while(!0)}function ap(){var i=Fo.current;return Fo.current=jo,i===null?jo:i}function _c(){(dt===0||dt===3||dt===2)&&(dt=4),_t===null||($r&268435455)===0&&(Ho&268435455)===0||wr(_t,Et)}function Vo(i,s){var a=Ae;Ae|=2;var c=ap();(_t!==i||Et!==s)&&(er=null,Ur(i,s));do try{qy();break}catch(d){op(i,d)}while(!0);if(Dl(),Ae=a,Fo.current=c,at!==null)throw Error(r(261));return _t=null,Et=0,dt}function qy(){for(;at!==null;)lp(at)}function Ky(){for(;at!==null&&!_v();)lp(at)}function lp(i){var s=dp(i.alternate,i,ti);i.memoizedProps=i.pendingProps,s===null?cp(i):at=s,lc.current=null}function cp(i){var s=i;do{var a=s.alternate;if(i=s.return,(s.flags&32768)===0){if(a=Oy(a,s,ti),a!==null){at=a;return}}else{if(a=zy(a,s),a!==null){a.flags&=32767,at=a;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{dt=6,at=null;return}}if(s=s.sibling,s!==null){at=s;return}at=s=i}while(s!==null);dt===0&&(dt=5)}function qr(i,s,a){var c=ze,d=di.transition;try{di.transition=null,ze=1,Vy(i,s,a,c)}finally{di.transition=d,ze=c}return null}function Vy(i,s,a,c){do Ns();while(yr!==null);if((Ae&6)!==0)throw Error(r(327));a=i.finishedWork;var d=i.finishedLanes;if(a===null)return null;if(i.finishedWork=null,i.finishedLanes=0,a===i.current)throw Error(r(177));i.callbackNode=null,i.callbackPriority=0;var g=a.lanes|a.childLanes;if(Nv(i,g),i===_t&&(at=_t=null,Et=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||Wo||(Wo=!0,fp(Gn,function(){return Ns(),null})),g=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||g){g=di.transition,di.transition=null;var C=ze;ze=1;var D=Ae;Ae|=4,lc.current=null,Hy(i,a),Zf(a,i),fy(_l),ro=!!gl,_l=gl=null,i.current=a,$y(a),vv(),Ae=D,ze=C,di.transition=g}else i.current=a;if(Wo&&(Wo=!1,yr=i,Uo=d),g=i.pendingLanes,g===0&&(vr=null),wv(a.stateNode),qt(i,st()),s!==null)for(c=i.onRecoverableError,a=0;a<s.length;a++)d=s[a],c(d.value,{componentStack:d.stack,digest:d.digest});if($o)throw $o=!1,i=hc,hc=null,i;return(Uo&1)!==0&&i.tag!==0&&Ns(),g=i.pendingLanes,(g&1)!==0?i===dc?wn++:(wn=0,dc=i):wn=0,pr(),null}function Ns(){if(yr!==null){var i=Gh(Uo),s=di.transition,a=ze;try{if(di.transition=null,ze=16>i?16:i,yr===null)var c=!1;else{if(i=yr,yr=null,Uo=0,(Ae&6)!==0)throw Error(r(331));var d=Ae;for(Ae|=4,ye=i.current;ye!==null;){var g=ye,C=g.child;if((ye.flags&16)!==0){var D=g.deletions;if(D!==null){for(var W=0;W<D.length;W++){var ie=D[W];for(ye=ie;ye!==null;){var ce=ye;switch(ce.tag){case 0:case 11:case 15:vn(8,ce,g)}var he=ce.child;if(he!==null)he.return=ce,ye=he;else for(;ye!==null;){ce=ye;var le=ce.sibling,ve=ce.return;if(Yf(ce),ce===ie){ye=null;break}if(le!==null){le.return=ve,ye=le;break}ye=ve}}}var Se=g.alternate;if(Se!==null){var we=Se.child;if(we!==null){Se.child=null;do{var nt=we.sibling;we.sibling=null,we=nt}while(we!==null)}}ye=g}}if((g.subtreeFlags&2064)!==0&&C!==null)C.return=g,ye=C;else e:for(;ye!==null;){if(g=ye,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:vn(9,g,g.return)}var J=g.sibling;if(J!==null){J.return=g.return,ye=J;break e}ye=g.return}}var q=i.current;for(ye=q;ye!==null;){C=ye;var te=C.child;if((C.subtreeFlags&2064)!==0&&te!==null)te.return=C,ye=te;else e:for(C=q;ye!==null;){if(D=ye,(D.flags&2048)!==0)try{switch(D.tag){case 0:case 11:case 15:zo(9,D)}}catch(be){Ze(D,D.return,be)}if(D===C){ye=null;break e}var de=D.sibling;if(de!==null){de.return=D.return,ye=de;break e}ye=D.return}}if(Ae=d,pr(),Li&&typeof Li.onPostCommitFiberRoot=="function")try{Li.onPostCommitFiberRoot(Qn,i)}catch{}c=!0}return c}finally{ze=a,di.transition=s}}return!1}function up(i,s,a){s=Cs(a,s),s=Rf(i,s,1),i=gr(i,s,1),s=At(),i!==null&&(Us(i,1,s),qt(i,s))}function Ze(i,s,a){if(i.tag===3)up(i,i,a);else for(;s!==null;){if(s.tag===3){up(s,i,a);break}else if(s.tag===1){var c=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(vr===null||!vr.has(c))){i=Cs(a,i),i=Pf(s,i,1),s=gr(s,i,1),i=At(),s!==null&&(Us(s,1,i),qt(s,i));break}}s=s.return}}function Yy(i,s,a){var c=i.pingCache;c!==null&&c.delete(s),s=At(),i.pingedLanes|=i.suspendedLanes&a,_t===i&&(Et&a)===a&&(dt===4||dt===3&&(Et&130023424)===Et&&500>st()-uc?Ur(i,0):cc|=a),qt(i,s)}function hp(i,s){s===0&&((i.mode&1)===0?s=1:(s=Zn,Zn<<=1,(Zn&130023424)===0&&(Zn=4194304)));var a=At();i=Qi(i,s),i!==null&&(Us(i,s,a),qt(i,a))}function Xy(i){var s=i.memoizedState,a=0;s!==null&&(a=s.retryLane),hp(i,a)}function Gy(i,s){var a=0;switch(i.tag){case 13:var c=i.stateNode,d=i.memoizedState;d!==null&&(a=d.retryLane);break;case 19:c=i.stateNode;break;default:throw Error(r(314))}c!==null&&c.delete(s),hp(i,a)}var dp;dp=function(i,s,a){if(i!==null)if(i.memoizedProps!==s.pendingProps||Ht.current)Wt=!0;else{if((i.lanes&a)===0&&(s.flags&128)===0)return Wt=!1,Iy(i,s,a);Wt=(i.flags&131072)!==0}else Wt=!1,Ke&&(s.flags&1048576)!==0&&Ud(s,bo,s.index);switch(s.lanes=0,s.tag){case 2:var c=s.type;Io(i,s),i=s.pendingProps;var d=ms(s,Dt.current);ws(s,a),d=Hl(null,s,c,i,d,a);var g=$l();return s.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,$t(c)?(g=!0,yo(s)):g=!1,s.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,jl(s),d.updater=Bo,s.stateNode=d,d._reactInternals=s,Yl(s,c,i,a),s=Jl(null,s,c,!0,g,a)):(s.tag=0,Ke&&g&&xl(s),Bt(null,s,d,a),s=s.child),s;case 16:c=s.elementType;e:{switch(Io(i,s),i=s.pendingProps,d=c._init,c=d(c._payload),s.type=c,d=s.tag=Jy(c),i=xi(c,i),d){case 0:s=Ql(null,s,c,i,a);break e;case 1:s=Of(null,s,c,i,a);break e;case 11:s=Tf(null,s,c,i,a);break e;case 14:s=jf(null,s,c,xi(c.type,i),a);break e}throw Error(r(306,c,""))}return s;case 0:return c=s.type,d=s.pendingProps,d=s.elementType===c?d:xi(c,d),Ql(i,s,c,d,a);case 1:return c=s.type,d=s.pendingProps,d=s.elementType===c?d:xi(c,d),Of(i,s,c,d,a);case 3:e:{if(zf(s),i===null)throw Error(r(387));c=s.pendingProps,g=s.memoizedState,d=g.element,Zd(i,s),Ro(s,c,null,a);var C=s.memoizedState;if(c=C.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:C.cache,pendingSuspenseBoundaries:C.pendingSuspenseBoundaries,transitions:C.transitions},s.updateQueue.baseState=g,s.memoizedState=g,s.flags&256){d=Cs(Error(r(423)),s),s=Ff(i,s,c,a,d);break e}else if(c!==d){d=Cs(Error(r(424)),s),s=Ff(i,s,c,a,d);break e}else for(ei=hr(s.stateNode.containerInfo.firstChild),Zt=s,Ke=!0,Ci=null,a=Qd(s,null,c,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(vs(),c===d){s=Zi(i,s,a);break e}Bt(i,s,c,a)}s=s.child}return s;case 5:return rf(s),i===null&&Nl(s),c=s.type,d=s.pendingProps,g=i!==null?i.memoizedProps:null,C=d.children,vl(c,d)?C=null:g!==null&&vl(c,g)&&(s.flags|=32),If(i,s),Bt(i,s,C,a),s.child;case 6:return i===null&&Nl(s),null;case 13:return Hf(i,s,a);case 4:return Bl(s,s.stateNode.containerInfo),c=s.pendingProps,i===null?s.child=ys(s,null,c,a):Bt(i,s,c,a),s.child;case 11:return c=s.type,d=s.pendingProps,d=s.elementType===c?d:xi(c,d),Tf(i,s,c,d,a);case 7:return Bt(i,s,s.pendingProps,a),s.child;case 8:return Bt(i,s,s.pendingProps.children,a),s.child;case 12:return Bt(i,s,s.pendingProps.children,a),s.child;case 10:e:{if(c=s.type._context,d=s.pendingProps,g=s.memoizedProps,C=d.value,$e(ko,c._currentValue),c._currentValue=C,g!==null)if(bi(g.value,C)){if(g.children===d.children&&!Ht.current){s=Zi(i,s,a);break e}}else for(g=s.child,g!==null&&(g.return=s);g!==null;){var D=g.dependencies;if(D!==null){C=g.child;for(var W=D.firstContext;W!==null;){if(W.context===c){if(g.tag===1){W=Ji(-1,a&-a),W.tag=2;var ie=g.updateQueue;if(ie!==null){ie=ie.shared;var ce=ie.pending;ce===null?W.next=W:(W.next=ce.next,ce.next=W),ie.pending=W}}g.lanes|=a,W=g.alternate,W!==null&&(W.lanes|=a),Ll(g.return,a,s),D.lanes|=a;break}W=W.next}}else if(g.tag===10)C=g.type===s.type?null:g.child;else if(g.tag===18){if(C=g.return,C===null)throw Error(r(341));C.lanes|=a,D=C.alternate,D!==null&&(D.lanes|=a),Ll(C,a,s),C=g.sibling}else C=g.child;if(C!==null)C.return=g;else for(C=g;C!==null;){if(C===s){C=null;break}if(g=C.sibling,g!==null){g.return=C.return,C=g;break}C=C.return}g=C}Bt(i,s,d.children,a),s=s.child}return s;case 9:return d=s.type,c=s.pendingProps.children,ws(s,a),d=ui(d),c=c(d),s.flags|=1,Bt(i,s,c,a),s.child;case 14:return c=s.type,d=xi(c,s.pendingProps),d=xi(c.type,d),jf(i,s,c,d,a);case 15:return Bf(i,s,s.type,s.pendingProps,a);case 17:return c=s.type,d=s.pendingProps,d=s.elementType===c?d:xi(c,d),Io(i,s),s.tag=1,$t(c)?(i=!0,yo(s)):i=!1,ws(s,a),Ef(s,c,d),Yl(s,c,d,a),Jl(null,s,c,!0,i,a);case 19:return Wf(i,s,a);case 22:return Af(i,s,a)}throw Error(r(156,s.tag))};function fp(i,s){return qh(i,s)}function Qy(i,s,a,c){this.tag=i,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fi(i,s,a,c){return new Qy(i,s,a,c)}function vc(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Jy(i){if(typeof i=="function")return vc(i)?1:0;if(i!=null){if(i=i.$$typeof,i===P)return 11;if(i===Y)return 14}return 2}function br(i,s){var a=i.alternate;return a===null?(a=fi(i.tag,s,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=s,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&14680064,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,s=i.dependencies,a.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a}function Yo(i,s,a,c,d,g){var C=2;if(c=i,typeof i=="function")vc(i)&&(C=1);else if(typeof i=="string")C=5;else e:switch(i){case F:return Kr(a.children,d,g,s);case Z:C=8,d|=8;break;case R:return i=fi(12,a,s,d|2),i.elementType=R,i.lanes=g,i;case L:return i=fi(13,a,s,d),i.elementType=L,i.lanes=g,i;case T:return i=fi(19,a,s,d),i.elementType=T,i.lanes=g,i;case G:return Xo(a,d,g,s);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case H:C=10;break e;case A:C=9;break e;case P:C=11;break e;case Y:C=14;break e;case Q:C=16,c=null;break e}throw Error(r(130,i==null?i:typeof i,""))}return s=fi(C,a,s,d),s.elementType=i,s.type=c,s.lanes=g,s}function Kr(i,s,a,c){return i=fi(7,i,c,s),i.lanes=a,i}function Xo(i,s,a,c){return i=fi(22,i,c,s),i.elementType=G,i.lanes=a,i.stateNode={isHidden:!1},i}function yc(i,s,a){return i=fi(6,i,null,s),i.lanes=a,i}function Sc(i,s,a){return s=fi(4,i.children!==null?i.children:[],i.key,s),s.lanes=a,s.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},s}function Zy(i,s,a,c,d){this.tag=s,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Va(0),this.expirationTimes=Va(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Va(0),this.identifierPrefix=c,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function wc(i,s,a,c,d,g,C,D,W){return i=new Zy(i,s,a,D,W),s===1?(s=1,g===!0&&(s|=8)):s=0,g=fi(3,null,null,s),i.current=g,g.stateNode=i,g.memoizedState={element:c,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},jl(g),i}function eS(i,s,a){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:c==null?null:""+c,children:i,containerInfo:s,implementation:a}}function pp(i){if(!i)return fr;i=i._reactInternals;e:{if(jr(i)!==i||i.tag!==1)throw Error(r(170));var s=i;do{switch(s.tag){case 3:s=s.stateNode.context;break e;case 1:if($t(s.type)){s=s.stateNode.__reactInternalMemoizedMergedChildContext;break e}}s=s.return}while(s!==null);throw Error(r(171))}if(i.tag===1){var a=i.type;if($t(a))return Hd(i,a,s)}return s}function mp(i,s,a,c,d,g,C,D,W){return i=wc(a,c,!0,i,d,g,C,D,W),i.context=pp(null),a=i.current,c=At(),d=Sr(a),g=Ji(c,d),g.callback=s??null,gr(a,g,d),i.current.lanes=d,Us(i,d,c),qt(i,c),i}function Go(i,s,a,c){var d=s.current,g=At(),C=Sr(d);return a=pp(a),s.context===null?s.context=a:s.pendingContext=a,s=Ji(g,C),s.payload={element:i},c=c===void 0?null:c,c!==null&&(s.callback=c),i=gr(d,s,C),i!==null&&(Ni(i,d,C,g),No(i,d,C)),C}function Qo(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function gp(i,s){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<s?a:s}}function bc(i,s){gp(i,s),(i=i.alternate)&&gp(i,s)}function tS(){return null}var _p=typeof reportError=="function"?reportError:function(i){console.error(i)};function Cc(i){this._internalRoot=i}Jo.prototype.render=Cc.prototype.render=function(i){var s=this._internalRoot;if(s===null)throw Error(r(409));Go(i,s,null,null)},Jo.prototype.unmount=Cc.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var s=i.containerInfo;Wr(function(){Go(null,i,null,null)}),s[Vi]=null}};function Jo(i){this._internalRoot=i}Jo.prototype.unstable_scheduleHydration=function(i){if(i){var s=Zh();i={blockedOn:null,target:i,priority:s};for(var a=0;a<lr.length&&s!==0&&s<lr[a].priority;a++);lr.splice(a,0,i),a===0&&id(i)}};function xc(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function Zo(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function vp(){}function iS(i,s,a,c,d){if(d){if(typeof c=="function"){var g=c;c=function(){var ie=Qo(C);g.call(ie)}}var C=mp(s,c,i,0,null,!1,!1,"",vp);return i._reactRootContainer=C,i[Vi]=C.current,nn(i.nodeType===8?i.parentNode:i),Wr(),C}for(;d=i.lastChild;)i.removeChild(d);if(typeof c=="function"){var D=c;c=function(){var ie=Qo(W);D.call(ie)}}var W=wc(i,0,!1,null,null,!1,!1,"",vp);return i._reactRootContainer=W,i[Vi]=W.current,nn(i.nodeType===8?i.parentNode:i),Wr(function(){Go(s,W,a,c)}),W}function ea(i,s,a,c,d){var g=a._reactRootContainer;if(g){var C=g;if(typeof d=="function"){var D=d;d=function(){var W=Qo(C);D.call(W)}}Go(s,C,i,d)}else C=iS(a,s,i,d,c);return Qo(C)}Qh=function(i){switch(i.tag){case 3:var s=i.stateNode;if(s.current.memoizedState.isDehydrated){var a=Ws(s.pendingLanes);a!==0&&(Ya(s,a|1),qt(s,st()),(Ae&6)===0&&(Es=st()+500,pr()))}break;case 13:Wr(function(){var c=Qi(i,1);if(c!==null){var d=At();Ni(c,i,1,d)}}),bc(i,1)}},Xa=function(i){if(i.tag===13){var s=Qi(i,134217728);if(s!==null){var a=At();Ni(s,i,134217728,a)}bc(i,134217728)}},Jh=function(i){if(i.tag===13){var s=Sr(i),a=Qi(i,s);if(a!==null){var c=At();Ni(a,i,s,c)}bc(i,s)}},Zh=function(){return ze},ed=function(i,s){var a=ze;try{return ze=i,s()}finally{ze=a}},Ha=function(i,s,a){switch(s){case"input":if(Je(i,a),s=a.name,a.type==="radio"&&s!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll("input[name="+JSON.stringify(""+s)+'][type="radio"]'),s=0;s<a.length;s++){var c=a[s];if(c!==i&&c.form===i.form){var d=_o(c);if(!d)throw Error(r(90));Be(c),Je(c,d)}}}break;case"textarea":Ki(i,a);break;case"select":s=a.value,s!=null&&yi(i,!!a.multiple,s,!1)}},Oh=mc,zh=Wr;var rS={usingClientEntryPoint:!1,Events:[ln,fs,_o,Ah,Ih,mc]},bn={findFiberByHostInstance:Br,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},sS={bundleType:bn.bundleType,version:bn.version,rendererPackageName:bn.rendererPackageName,rendererConfig:bn.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:j.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=Wh(i),i===null?null:i.stateNode},findFiberByHostInstance:bn.findFiberByHostInstance||tS,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 ta=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ta.isDisabled&&ta.supportsFiber)try{Qn=ta.inject(sS),Li=ta}catch{}}return Kt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=rS,Kt.createPortal=function(i,s){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!xc(s))throw Error(r(200));return eS(i,s,null,a)},Kt.createRoot=function(i,s){if(!xc(i))throw Error(r(299));var a=!1,c="",d=_p;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(c=s.identifierPrefix),s.onRecoverableError!==void 0&&(d=s.onRecoverableError)),s=wc(i,1,!1,null,null,a,!1,c,d),i[Vi]=s.current,nn(i.nodeType===8?i.parentNode:i),new Cc(s)},Kt.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var s=i._reactInternals;if(s===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=Wh(s),i=i===null?null:i.stateNode,i},Kt.flushSync=function(i){return Wr(i)},Kt.hydrate=function(i,s,a){if(!Zo(s))throw Error(r(200));return ea(null,i,s,!0,a)},Kt.hydrateRoot=function(i,s,a){if(!xc(i))throw Error(r(405));var c=a!=null&&a.hydratedSources||null,d=!1,g="",C=_p;if(a!=null&&(a.unstable_strictMode===!0&&(d=!0),a.identifierPrefix!==void 0&&(g=a.identifierPrefix),a.onRecoverableError!==void 0&&(C=a.onRecoverableError)),s=mp(s,null,i,1,a??null,d,!1,g,C),i[Vi]=s.current,nn(i),c)for(i=0;i<c.length;i++)a=c[i],d=a._getVersion,d=d(a._source),s.mutableSourceEagerHydrationData==null?s.mutableSourceEagerHydrationData=[a,d]:s.mutableSourceEagerHydrationData.push(a,d);return new Jo(s)},Kt.render=function(i,s,a){if(!Zo(s))throw Error(r(200));return ea(null,i,s,!1,a)},Kt.unmountComponentAtNode=function(i){if(!Zo(i))throw Error(r(40));return i._reactRootContainer?(Wr(function(){ea(null,null,i,!1,function(){i._reactRootContainer=null,i[Vi]=null})}),!0):!1},Kt.unstable_batchedUpdates=mc,Kt.unstable_renderSubtreeIntoContainer=function(i,s,a,c){if(!Zo(a))throw Error(r(200));if(i==null||i._reactInternals===void 0)throw Error(r(38));return ea(i,s,a,!1,c)},Kt.version="18.3.1-next-f1338f8080-20240426",Kt}var Ep;function fS(){if(Ep)return Nc.exports;Ep=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(),Nc.exports=dS(),Nc.exports}var Np;function pS(){if(Np)return ia;Np=1;var e=fS();return ia.createRoot=e.createRoot,ia.hydrateRoot=e.hydrateRoot,ia}var mS=pS();const gS=dh(mS);function Ct(e,t,r={}){return fetch(e,{...r,headers:{...r.headers||{},Authorization:`Bearer ${t}`}})}const Lg=e=>`nc_seen_${e}`;async function je(e,t,r={}){const n=await Ct(e,t,{method:r.method||"GET",headers:{"content-type":"application/json"},body:r.body?JSON.stringify(r.body):void 0}),o=await n.json().catch(()=>({}));if(!n.ok){const l=new Error(o.error||`HTTP ${n.status}`);throw l.status=n.status,l.data=o,l}return o}const Bs=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",oi=(e,t)=>`${Bs(e)}/fleet/${t}`,es=(e,t)=>je(oi(t,"status"),e),ph=(e,t,r)=>je(oi(r,"up"),e,{method:"POST",body:t}),Sa=(e,t,r)=>je(oi(r,"down"),e,{method:"POST",body:t}),da=(e,t,r)=>je(oi(r,"restart"),e,{method:"POST",body:{cell:t}}),mh=(e,t)=>je(oi(t,"definitions"),e),_S=(e,t,r)=>je(oi(r,"define-engine"),e,{method:"POST",body:{def:t}}),vS=(e,t,r,n,o)=>je(oi(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:r,envChanges:n}}),yS=(e,t,r)=>je(oi(r,"remove-engine"),e,{method:"POST",body:{id:t}}),SS=(e,t,r)=>je(oi(r,"define-cell"),e,{method:"POST",body:{def:t}}),wS=(e,t,r,n)=>je(oi(n,"edit-cell"),e,{method:"POST",body:{id:t,patch:r}}),Tg=(e,t,r=!1,n)=>je(oi(n,"remove-cell"),e,{method:"POST",body:{id:t,stop:r}}),bS=(e,t,r)=>je(oi(r,"import-cell"),e,{method:"POST",body:t}),CS=(e,t,r)=>je(oi(r,"restore-cells"),e,{method:"POST",body:{cells:t}}),gh=(e,t,r)=>je(`${Bs(r)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),jg=(e,t,r)=>je(`${Bs(r)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),Bg=e=>je("/api/settings",e),Ag=e=>je("/api/nodes",e),xS=e=>je("/api/topology",e),Ig=(e,t)=>je(`${Bs(t)}/sessions`,e),Og=(e,t)=>je(`${Bs(t)}/config`,e),zg=(e,t)=>je("/api/settings/config",e,{method:"POST",body:t}),kS=e=>je("/api/settings/token/rotate",e,{method:"POST"}),ES=(e,t)=>je("/api/settings/nodes/pair",e,{method:"POST",body:t}),NS=(e,t)=>je("/api/settings/peering/invite",e,{method:"POST",body:t||{}}),RS=(e,t,r)=>je(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:r}}),PS=(e,t)=>je(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),_h=(e,t,r)=>je(`/api/settings/nodes/${encodeURIComponent(t)}/${r}`,e,{method:"POST"}),Rp=(e,t,r,n=[])=>je(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:r,selected:n}}),DS=e=>je("/api/settings/service/regenerate",e,{method:"POST"}),MS=e=>je("/api/settings/update/check",e,{method:"POST"}),LS=e=>je("/api/settings/update/apply",e,{method:"POST"}),TS=(e,t=!0)=>je(`/api/asks${t?"?open=1":""}`,e),jS=(e,t,r)=>je(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:r}}),Dc=e=>je("/api/decks",e),Pp=(e,t)=>je("/api/decks",e,{method:"POST",body:{name:t}}),ra=(e,t,r,n)=>je(`/api/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:r,expectedRevision:n}}),BS=(e,t,r,n)=>je(`/api/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:r,expectedRevision:n}}),AS=(e,t,r)=>je(`/api/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:r}}),IS={power:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M12 3v8"}),h.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:h.jsx("path",{d:"M4 6a2 2 0 0 1 2-2h3.6a2 2 0 0 1 1.4.6L12.4 6H18a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z"}),keyboard:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),h.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),h.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),h.jsx("path",{d:"M12 18v3"})]}),enter:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),h.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),h.jsx("path",{d:"M22 2 11 13"})]}),trash:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M4 7h16"}),h.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),h.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),h.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:h.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),refresh:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),h.jsx("polyline",{points:"21 3 21 8 16 8"})]}),upload:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M12 16V5"}),h.jsx("polyline",{points:"8 9 12 5 16 9"}),h.jsx("path",{d:"M5 20h14"})]}),chevronLeft:h.jsx("polyline",{points:"14 6 8 12 14 18"}),attach:h.jsx("path",{d:"M21.44 11.05 12.25 20.24a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"}),file:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),h.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M14.5 4h-5L7.5 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.5z"}),h.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),h.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),h.jsx("path",{d:"M21 15l-5-5L5 21"})]}),zoomIn:h.jsxs(h.Fragment,{children:[h.jsx("circle",{cx:"11",cy:"11",r:"7"}),h.jsx("path",{d:"M21 21l-4.35-4.35"}),h.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:h.jsxs(h.Fragment,{children:[h.jsx("circle",{cx:"11",cy:"11",r:"7"}),h.jsx("path",{d:"M21 21l-4.35-4.35"}),h.jsx("path",{d:"M8 11h6"})]}),gear:h.jsxs(h.Fragment,{children:[h.jsx("circle",{cx:"12",cy:"12",r:"3"}),h.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),copy:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),h.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})};function Oe({name:e,size:t=20}){return h.jsx("svg",{className:"nc-icon",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:IS[e]||null})}const Fg="nc_pins";function Hg(){try{const e=JSON.parse(localStorage.getItem(Fg));return Array.isArray(e)?e:[]}catch{return[]}}function $g(e,t){const r=e.includes(t)?e.filter(n=>n!==t):[...e,t];try{localStorage.setItem(Fg,JSON.stringify(r))}catch{}return r}function Ln(e,t,r){const n=e.indexOf(t);return[n===-1?1e9:n,-(r||0)]}function yu(e,t){return e[0]-t[0]||e[1]-t[1]}const vh=["it","en","es"];function OS(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return vh.includes(t)?t:"en"}catch{return"en"}}const fa=OS(),Wg="nc_lang",Su="nc-lang";function Ug(){return typeof localStorage<"u"?localStorage:null}const sa={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",sessions:"sessioni","new-session":"nuova sessione",new:"nuova",fleet:"Flotta","fleet-tmux":"flotta tmux","other-sessions":"Altre sessioni",files:"file",refresh:"aggiorna","filter-placeholder":"filtra sessioni…","loading-fleet":"carico la flotta…","no-sessions":"nessuna sessione tmux viva — la flotta parte al boot (systemd)","no-match":'nessuna sessione contiene "{q}"',"copy-url":"clicca per copiare l'URL","ssh-only":"solo tunnel SSH/VPN","new-files-outbox":"nuovi file in outbox",terminate:"termina","terminate-confirm":'Terminare la sessione "{name}"?',"cell-on":"tmux vivo","cell-off":"spenta","cell-degraded":"degradata: unit attiva, tmux morto","power-on":"accendi","power-off":"spegni","state-on":"accesa","state-off":"spenta",engine:"Engine",model:"Modello","model-default":"Modello predefinito del provider","model-remembered":"Ultimo modello usato con questo engine","boot-persist":"avvia al boot","remove-boot":"togli anche dal boot","power-config-in-settings":"Engine, provider, profilo, modello e permessi si modificano in Impostazioni → Flotta.","no-remote-control":"⚠ engine non-native: niente RC da app claude.ai (da qui la piloti comunque)",cancel:"annulla",name:"nome","name-invalid":"nome non valido: a-zA-Z0-9._- max 64, senza '-' iniziale",cwd:"cartella",browse:"sfoglia","fs-home":"home","fs-parent":".. su",preset:"preset","preset-2x2":"griglia 2×2","preset-columns":"colonne","preset-equalize":"equalizza",collapse:"comprimi",expand:"espandi",create:"crea","auth-prompt":"Incolla il token (stampato dal server):","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande",composer:"composer",windows:"{n} finestre","empty-files":"vuota",upload:"carica","no-sessions-short":"nessuna sessione","composer-placeholder":"scrivi o detta…",attach:"allega","attach-file":"File","attach-camera":"Fotocamera","attach-gallery":"Galleria","attach-uploading":"carico…","attach-upload-progress":"allegato {n}/{total}…","attach-uploaded":"{n} allegati caricati",voice:"voice",send:"invia","composer-send-failed":"connessione non pronta — testo conservato, riprova",close:"chiudi","lang-label":"lingua",decks:"deck","new-deck":"nuovo deck","deck-name":"nome deck","open-deck-window":"apri in una nuova finestra","detach-deck":"stacca in una nuova finestra","deck-current":"questo deck (finestra corrente)","rename-deck":"rinomina deck","delete-deck":"elimina deck","delete-deck-confirm":'Eliminare il deck "{name}"?',"send-to-deck":"manda al deck…","deck-autosave":"salvataggio automatico",saving:"salvataggio…",saved:"salvato","popup-blocked":"popup bloccato: apri qui","select-drag":"trascina per selezionare","copy-manual":"seleziona e copia manualmente","toggle-sidebar":"mostra/nascondi la barra laterale",settings:"impostazioni","tab-roles":"ruoli","tab-nodes":"nodi",local:"Locale",location:"Dove","pairing-link":"link di pairing","pairing-required":"nome, alias SSH e link di pairing sono obbligatori","pairing-connect-help":"Per collegare un nodo servono: nome, Host SSH già funzionante e link/QR creato sull’altra installazione NexusCrew.","pairing-localhost-hint":"127.0.0.1 nel link è corretto: non aprirlo qui. NexusCrew usa invito e porta attraverso l’Host SSH.","scan-qr":"scansiona QR","pairing-qr-invalid":"QR di pairing non valido","invite-node":"invita un nodo","create-pairing-link":"crea link / QR","visibility-network":"tutta la rete","visibility-relay":"solo relay","visibility-selected":"nodi selezionati","hydra-simple":"locale + nodi, una sola rete","local-ready":"Questo dispositivo è pronto. Puoi usarlo da solo o collegarlo a un nodo.","local-only":"solo locale","add-node":"aggiungi nodo",connect:"collega","node-connected":"Nodo collegato. La rete verrà sincronizzata automaticamente.","tab-system":"sistema","tab-fleet":"flotta","fleet-editor-unavailable":"Editor disponibile solo con il provider fleet builtin.","fleet-managed":"gestito da NexusCrew","fleet-custom":"comando personalizzato","fleet-managed-help":"Client, provider e avvio sono gestiti internamente; i segreti non vengono mostrati.","fleet-model-default":"modello predefinito (opzionale)","fleet-model-required":"modello (obbligatorio)","fleet-standard-permissions":"permessi standard","fleet-unsafe-permissions":"non sicuro · ignora approvazioni/sandbox","fleet-unsafe-warning":"Modalità non sicura esplicita: il worker può agire senza le normali approvazioni o protezioni sandbox.","fleet-provider-display":"nome visualizzato del provider","fleet-custom-provider-default":"Provider personalizzato","fleet-api-key-env":"NOME_VARIABILE_API_KEY","fleet-provider-id":"id-provider","fleet-custom-secret-help":"NexusCrew salva solo il nome della variabile d’ambiente, mai il suo valore.","fleet-model-override":"modello alternativo","fleet-ready":"pronto","fleet-not-ready":"non configurato","fleet-engines":"Engine","fleet-cells":"Celle / sessioni cloud","fleet-backup":"backup / ripristino","fleet-backup-help":"Esporta o ripristina selettivamente 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-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)","role-node-desc":"questa macchina si pubblica via reverse tunnel su un rendezvous","rendezvous-ssh":"rendezvous ssh (user@host)","published-port":"porta pubblicata (opzionale)","no-nodes":"nessun nodo remoto configurato","node-add":"collega installazione NexusCrew","node-connect-help":"La porta SSH serve a raggiungere il server SSH. La porta NexusCrew è invece la porta locale mostrata da `nexuscrew status` sul nodo remoto.","node-name-label":"Nome del nodo","node-ssh-label":"Host SSH","node-ssh-port-label":"Porta SSH","node-ssh-port-help":"Di solito 22; usa la porta pubblica del server SSH.","node-app-port-label":"Porta NexusCrew sul nodo","node-app-port-help":"È la porta mostrata da `nexuscrew status` sul nodo remoto.","node-name-ph":"nome (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"porta remota (opz.)","node-remove-confirm":'Rimuovere il nodo "{name}"?',"node-test":"test","tunnel-start":"avvia tunnel","tunnel-stop":"ferma tunnel","tunnel-restart":"riavvia tunnel","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 url`. La sessione si invalida al riavvio del service.","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-step-rendezvous":"rendezvous per il ruolo nodo","wizard-done":"tutto pronto","wizard-done-desc":"setup completato — puoi cambiare tutto dai settings",next:"continua",back:"indietro",skip:"salta",finish:"fine","err-node-name":"nome non valido (a-z, 0-9, -, max 32)","err-ssh":"ssh non valido (atteso user@host o alias)","err-port":"porta non valida (1–65535)","err-ssh-port":"porta SSH non valida (1–65535)","err-node-port":"porta NexusCrew non valida (1–65535)","err-rendezvous-required":"serve un rendezvous ssh (user@host) per attivare il ruolo nodo","node-sessions":"{n} sessioni","tunnel-down-since":"tunnel giù da {t}","node-unreachable":"nodo non raggiungibile","node-passive":"client offline · stato normale","node-offline":"nodo offline","node-offline-seen":"offline · visto {t} fa","node-needs-repair":"legacy · ripeti il pairing","asks-title":"domande dalle celle","ask-reply-ph":"scrivi la risposta…","push-enable":"attiva notifiche push","push-disable":"disattiva notifiche push","push-on":"push attive su questo device","push-off":"push non attive","push-denied":"permesso notifiche negato dal browser","push-unsupported":"push non supportate in questo browser","node-display-label":"Nome (etichetta)","node-slug-hint":"routing su slug: {slug}","device-name-label":"Nome dispositivo","device-name-hint":"come ti vedono i peer (modificabile)","err-label":"etichetta non valida (max 64 char, niente a capo)","fleet-inventory":"Celle e sessioni","fleet-inventory-help":"tutte le posizioni (Locale + route Hydra)","fleet-inventory-empty":"nessuna cella o sessione","fleet-not-available":"fleet non disponibile su questa posizione",start:"avvia",stop:"ferma",restart:"riavvia",delete:"elimina","copy-manual":"copia non riuscita — seleziona e Cmd+C, o copia a mano","copy-empty":"niente selezione: trascina con Shift per selezionare","save-and-start":"salva e avvia",permissions:"Permessi","power-on-hint":"Spegni la cella; puoi anche toglierla dal boot.","launch-engine-help":"Provider, credenziali e nuovi engine si creano in Impostazioni → Flotta. Modello e permessi sono per questa cella.","launch-external-hint":"Provider esterno: engine/modello si configurano nel fleet esterno.","import-as-cell":"Importa come cella","import-help":"Riconcilia una sessione tmux esistente in una cella gestita. Scegli un engine già dichiarato: nessun engine viene inventato.","import-engine-required":"scegli un engine (obbligatorio)","test-and-connect":"testa e collega","pairing-v2-hint":"Incolla o scansiona UN solo link: precompila nome, Host SSH ed etichetta quando il link li include (v2).","invite-v2-hint":"Crea un invito monouso. Nome e porta sono automatici; se questo nodo è già pubblicato non devi compilare nulla.","invite-endpoint-label":"Come può essere raggiunto questo dispositivo?","invite-endpoint-auto":"Endpoint già configurato","invite-endpoint-needed":"Unico dato necessario: indirizzo SSH raggiungibile dall’altro dispositivo (user@host o alias condiviso).","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",sessions:"sessions","new-session":"new session",new:"new",fleet:"Fleet","fleet-tmux":"tmux fleet","other-sessions":"Other sessions",files:"files",refresh:"refresh","filter-placeholder":"filter sessions…","loading-fleet":"loading fleet…","no-sessions":"no live tmux sessions — the fleet starts at boot (systemd)","no-match":'no session matches "{q}"',"copy-url":"click to copy URL","ssh-only":"SSH/VPN tunnel only","new-files-outbox":"new files in outbox",terminate:"terminate","terminate-confirm":'Terminate session "{name}"?',"cell-on":"tmux alive","cell-off":"off","cell-degraded":"degraded: unit active, tmux dead","power-on":"power on","power-off":"power off","state-on":"running","state-off":"stopped",engine:"Engine",model:"Model","model-default":"Provider default model","model-remembered":"Last model used with this engine","boot-persist":"start at boot","remove-boot":"also remove from boot","power-config-in-settings":"Edit engine, provider, profile, model and permissions in Settings → Fleet.","no-remote-control":"⚠ non-native engine: no claude.ai app RC (you can still drive it from here)",cancel:"cancel",name:"name","name-invalid":"invalid name: a-zA-Z0-9._- max 64, no leading '-'",cwd:"folder",browse:"browse","fs-home":"home","fs-parent":".. up",preset:"preset","preset-2x2":"2×2 grid","preset-columns":"columns","preset-equalize":"equalize",collapse:"collapse",expand:"expand",create:"create","auth-prompt":"Paste the token (printed by the server):","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text",composer:"composer",windows:"{n} windows","empty-files":"empty",upload:"upload","no-sessions-short":"no sessions","composer-placeholder":"type or dictate…",attach:"attach","attach-file":"File","attach-camera":"Camera","attach-gallery":"Gallery","attach-uploading":"uploading…","attach-upload-progress":"attachment {n}/{total}…","attach-uploaded":"{n} attachments uploaded",voice:"voice",send:"send","composer-send-failed":"connection not ready — text kept, try again",close:"close","lang-label":"language",decks:"decks","new-deck":"new deck","deck-name":"deck name","open-deck-window":"open in a new window","detach-deck":"detach into a new window","deck-current":"this deck (current window)","rename-deck":"rename deck","delete-deck":"delete deck","delete-deck-confirm":'Delete deck "{name}"?',"send-to-deck":"send to deck…","deck-autosave":"autosave",saving:"saving…",saved:"saved","popup-blocked":"popup blocked: open here","select-drag":"drag to select","copy-manual":"select and copy manually","toggle-sidebar":"show/hide the sidebar",settings:"settings","tab-roles":"roles","tab-nodes":"nodes",local:"Local",location:"Location","pairing-link":"pairing link","pairing-required":"name, SSH alias and pairing link are required","pairing-connect-help":"Connecting a node requires a name, a working SSH Host, and a link/QR created by the other NexusCrew installation.","pairing-localhost-hint":"127.0.0.1 in the link is correct: do not open it here. NexusCrew carries the invite and port through the SSH Host.","scan-qr":"scan QR","pairing-qr-invalid":"invalid pairing QR","invite-node":"invite a node","create-pairing-link":"create link / QR","visibility-network":"whole network","visibility-relay":"relay only","visibility-selected":"selected nodes","hydra-simple":"local + nodes, one network","local-ready":"This device is ready. Use it alone or connect it to a node.","local-only":"local only","add-node":"add node",connect:"connect","node-connected":"Node connected. The network will synchronize automatically.","tab-system":"system","tab-fleet":"fleet","fleet-editor-unavailable":"The editor is available only with the builtin fleet provider.","fleet-managed":"managed by NexusCrew","fleet-custom":"custom command","fleet-managed-help":"Client, provider and launch are managed internally; secrets are never displayed.","fleet-model-default":"default model (optional)","fleet-model-required":"model (required)","fleet-standard-permissions":"standard permissions","fleet-unsafe-permissions":"unsafe · bypass approvals/sandbox","fleet-unsafe-warning":"Explicit unsafe mode: the worker can act without normal approval or sandbox gates.","fleet-provider-display":"provider display name","fleet-custom-provider-default":"Custom provider","fleet-api-key-env":"API_KEY_ENV_NAME","fleet-provider-id":"provider-id","fleet-custom-secret-help":"NexusCrew stores only the environment-variable name, never its value.","fleet-model-override":"model override","fleet-ready":"ready","fleet-not-ready":"not configured","fleet-engines":"Engines","fleet-cells":"Cells / cloud sessions","fleet-backup":"backup / restore","fleet-backup-help":"Selectively export or restore 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-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)","role-node-desc":"this machine publishes itself via reverse tunnel to a rendezvous","rendezvous-ssh":"rendezvous ssh (user@host)","published-port":"published port (optional)","no-nodes":"no remote nodes configured","node-add":"connect a NexusCrew installation","node-connect-help":"The SSH port reaches the SSH server. The NexusCrew port is the local port reported by `nexuscrew status` on the remote node.","node-name-label":"Node name","node-ssh-label":"SSH host","node-ssh-port-label":"SSH port","node-ssh-port-help":"Usually 22; use the SSH server public port.","node-app-port-label":"NexusCrew port on node","node-app-port-help":"The port reported by `nexuscrew status` on the remote node.","node-name-ph":"name (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"remote port (opt.)","node-remove-confirm":'Remove node "{name}"?',"node-test":"test","tunnel-start":"start tunnel","tunnel-stop":"stop tunnel","tunnel-restart":"restart tunnel","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 url`. The session is invalidated when the service restarts.","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-step-rendezvous":"rendezvous for the node role","wizard-done":"all set","wizard-done-desc":"setup complete — you can change everything from settings",next:"continue",back:"back",skip:"skip",finish:"finish","err-node-name":"invalid name (a-z, 0-9, -, max 32)","err-ssh":"invalid ssh (expected user@host or alias)","err-port":"invalid port (1–65535)","err-ssh-port":"invalid SSH port (1–65535)","err-node-port":"invalid NexusCrew port (1–65535)","err-rendezvous-required":"a rendezvous ssh (user@host) is required to enable the node role","node-sessions":"{n} sessions","tunnel-down-since":"tunnel down for {t}","node-unreachable":"node unreachable","node-passive":"client offline · expected","node-offline":"node offline","node-offline-seen":"offline · seen {t} ago","node-needs-repair":"legacy · pair again","asks-title":"questions from the cells","ask-reply-ph":"type your answer…","push-enable":"enable push notifications","push-disable":"disable push notifications","push-on":"push active on this device","push-off":"push not active","push-denied":"notification permission denied by the browser","push-unsupported":"push not supported in this browser","node-display-label":"Name (label)","node-slug-hint":"routing on slug: {slug}","device-name-label":"Device name","device-name-hint":"how peers see you (editable)","err-label":"invalid label (max 64 chars, no line breaks)","fleet-inventory":"Cells and sessions","fleet-inventory-help":"all positions (Local + Hydra routes)","fleet-inventory-empty":"no cells or sessions","fleet-not-available":"fleet not available on this position",start:"start",stop:"stop",restart:"restart",delete:"delete","copy-manual":"copy failed — select and press Cmd+C, or copy manually","copy-empty":"nothing selected: drag with Shift to select","save-and-start":"save and start",permissions:"Permissions","power-on-hint":"Stop the cell; you can also remove it from boot.","launch-engine-help":"Providers, credentials and new engines are created in Settings → Fleet. Model and permissions are per cell.","launch-external-hint":"External provider: engine/model are configured in the external fleet.","import-as-cell":"Import as cell","import-help":"Reconcile an existing tmux session into a managed cell. Pick an already-declared engine: no engine is invented.","import-engine-required":"pick an engine (required)","test-and-connect":"test and connect","pairing-v2-hint":"Paste or scan ONE link: it prefills name, SSH host and label when the link carries them (v2).","invite-v2-hint":"Create a one-time invitation. Name and port are automatic; if this node is already published there is nothing to fill in.","invite-endpoint-label":"How can this device be reached?","invite-endpoint-auto":"Configured endpoint","invite-endpoint-needed":"The only required value: an SSH address reachable from the other device (user@host or a shared alias).","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",sessions:"sesiones","new-session":"nueva sesión",new:"nueva",fleet:"Flota","fleet-tmux":"flota tmux","other-sessions":"Otras sesiones",files:"archivos",refresh:"actualizar","filter-placeholder":"filtrar sesiones…","loading-fleet":"cargando flota…","no-sessions":"sin sesiones tmux vivas — la flota arranca en el boot (systemd)","no-match":"ninguna sesión coincide con «{q}»","copy-url":"clic para copiar la URL","ssh-only":"solo túnel SSH/VPN","new-files-outbox":"archivos nuevos en outbox",terminate:"terminar","terminate-confirm":"¿Terminar la sesión «{name}»?","cell-on":"tmux activo","cell-off":"apagada","cell-degraded":"degradada: unit activa, tmux muerto","power-on":"encender","power-off":"apagar","state-on":"encendida","state-off":"apagada",engine:"Motor",model:"Modelo","model-default":"Modelo predeterminado del proveedor","model-remembered":"Último modelo usado con este motor","boot-persist":"iniciar en el boot","remove-boot":"quitar también del boot","power-config-in-settings":"Modifica motor, proveedor, perfil, modelo y permisos en Ajustes → Flota.","no-remote-control":"⚠ motor no nativo: sin RC de la app claude.ai (aquí puedes pilotarla igual)",cancel:"cancelar",name:"nombre","name-invalid":"nombre inválido: a-zA-Z0-9._- máx 64, sin '-' inicial",cwd:"carpeta",browse:"explorar","fs-home":"home","fs-parent":".. arriba",preset:"preset","preset-2x2":"cuadrícula 2×2","preset-columns":"columnas","preset-equalize":"igualar",collapse:"contraer",expand:"expandir",create:"crear","auth-prompt":"Pega el token (impreso por el servidor):","remember-device":"recordar en este dispositivo","zoom-out":"texto más pequeño","zoom-in":"texto más grande",composer:"composer",windows:"{n} ventanas","empty-files":"vacía",upload:"subir","no-sessions-short":"sin sesiones","composer-placeholder":"escribe o dicta…",attach:"adjuntar","attach-file":"Archivo","attach-camera":"Cámara","attach-gallery":"Galería","attach-uploading":"subiendo…","attach-upload-progress":"adjunto {n}/{total}…","attach-uploaded":"{n} adjuntos subidos",voice:"voz",send:"enviar","composer-send-failed":"conexión no disponible — texto conservado, inténtalo de nuevo",close:"cerrar","lang-label":"idioma",decks:"decks","new-deck":"nuevo deck","deck-name":"nombre del deck","open-deck-window":"abrir en una ventana nueva","detach-deck":"separar en una ventana nueva","deck-current":"este deck (ventana actual)","rename-deck":"renombrar deck","delete-deck":"eliminar deck","delete-deck-confirm":"¿Eliminar el deck «{name}»?","send-to-deck":"enviar al deck…","deck-autosave":"guardado automático",saving:"guardando…",saved:"guardado","popup-blocked":"ventana bloqueada: abrir aquí","select-drag":"arrastra para seleccionar","copy-manual":"selecciona y copia manualmente","toggle-sidebar":"mostrar/ocultar la barra lateral",settings:"ajustes","tab-roles":"roles","tab-nodes":"nodos",local:"Local",location:"Ubicación","pairing-link":"enlace de emparejamiento","pairing-required":"nombre, alias SSH y enlace son obligatorios","pairing-connect-help":"Para conectar un nodo necesitas un nombre, un Host SSH funcional y el enlace/QR creado por la otra instalación NexusCrew.","pairing-localhost-hint":"127.0.0.1 en el enlace es correcto: no lo abras aquí. NexusCrew usa la invitación y el puerto mediante el Host SSH.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","invite-node":"invitar un nodo","create-pairing-link":"crear enlace / QR","visibility-network":"toda la red","visibility-relay":"solo relay","visibility-selected":"nodos seleccionados","hydra-simple":"local + nodos, una red","local-ready":"Este dispositivo está listo. Úsalo solo o conéctalo a un nodo.","local-only":"solo local","add-node":"añadir nodo",connect:"conectar","node-connected":"Nodo conectado. La red se sincronizará automáticamente.","tab-system":"sistema","tab-fleet":"flota","fleet-editor-unavailable":"El editor solo está disponible con el proveedor builtin.","fleet-managed":"gestionado por NexusCrew","fleet-custom":"comando personalizado","fleet-managed-help":"Cliente, proveedor e inicio se gestionan internamente; los secretos nunca se muestran.","fleet-model-default":"modelo predeterminado (opcional)","fleet-model-required":"modelo (obligatorio)","fleet-standard-permissions":"permisos estándar","fleet-unsafe-permissions":"inseguro · omitir aprobaciones/sandbox","fleet-unsafe-warning":"Modo inseguro explícito: el worker puede actuar sin las aprobaciones normales ni las protecciones del sandbox.","fleet-provider-display":"nombre visible del proveedor","fleet-custom-provider-default":"Proveedor personalizado","fleet-api-key-env":"NOMBRE_VARIABLE_API_KEY","fleet-provider-id":"id-proveedor","fleet-custom-secret-help":"NexusCrew guarda solo el nombre de la variable de entorno, nunca su valor.","fleet-model-override":"modelo alternativo","fleet-ready":"listo","fleet-not-ready":"no configurado","fleet-engines":"Motores","fleet-cells":"Celdas / sesiones cloud","fleet-backup":"copia / restauración","fleet-backup-help":"Exporta o restaura selectivamente 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-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)","role-node-desc":"esta máquina se publica vía túnel inverso hacia un rendezvous","rendezvous-ssh":"rendezvous ssh (user@host)","published-port":"puerto publicado (opcional)","no-nodes":"sin nodos remotos configurados","node-add":"conectar una instalación NexusCrew","node-connect-help":"El puerto SSH conecta con el servidor SSH. El puerto NexusCrew es el puerto local indicado por `nexuscrew status` en el nodo remoto.","node-name-label":"Nombre del nodo","node-ssh-label":"Host SSH","node-ssh-port-label":"Puerto SSH","node-ssh-port-help":"Normalmente 22; usa el puerto público del servidor SSH.","node-app-port-label":"Puerto NexusCrew del nodo","node-app-port-help":"El puerto indicado por `nexuscrew status` en el nodo remoto.","node-name-ph":"nombre (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"puerto remoto (opc.)","node-remove-confirm":"¿Eliminar el nodo «{name}»?","node-test":"test","tunnel-start":"iniciar túnel","tunnel-stop":"detener túnel","tunnel-restart":"reiniciar túnel","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 url`. La sesión se invalida al reiniciar el service.","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-step-rendezvous":"rendezvous para el rol nodo","wizard-done":"todo listo","wizard-done-desc":"configuración completa — puedes cambiarlo todo desde ajustes",next:"continuar",back:"atrás",skip:"omitir",finish:"terminar","err-node-name":"nombre inválido (a-z, 0-9, -, máx 32)","err-ssh":"ssh inválido (se espera user@host o alias)","err-port":"puerto inválido (1–65535)","err-ssh-port":"puerto SSH inválido (1–65535)","err-node-port":"puerto NexusCrew inválido (1–65535)","err-rendezvous-required":"se necesita un rendezvous ssh (user@host) para activar el rol nodo","node-sessions":"{n} sesiones","tunnel-down-since":"túnel caído desde hace {t}","node-unreachable":"nodo inalcanzable","node-passive":"cliente desconectado · estado normal","node-offline":"nodo desconectado","node-offline-seen":"sin conexión · visto hace {t}","node-needs-repair":"legacy · vuelve a enlazar","asks-title":"preguntas de las celdas","ask-reply-ph":"escribe la respuesta…","push-enable":"activar notificaciones push","push-disable":"desactivar notificaciones push","push-on":"push activas en este dispositivo","push-off":"push no activas","push-denied":"permiso de notificaciones denegado por el navegador","push-unsupported":"push no soportadas en este navegador","node-display-label":"Nombre (etiqueta)","node-slug-hint":"enrutado por slug: {slug}","device-name-label":"Nombre del dispositivo","device-name-hint":"cómo te ven los pares (editable)","err-label":"etiqueta no válida (máx 64 caracteres, sin saltos de línea)","fleet-inventory":"Celdas y sesiones","fleet-inventory-help":"todas las posiciones (Local + rutas Hydra)","fleet-inventory-empty":"sin celdas ni sesiones","fleet-not-available":"fleet no disponible en esta posición",start:"iniciar",stop:"detener",restart:"reiniciar",delete:"eliminar","copy-manual":"copia fallida — selecciona y pulsa Cmd+C, o copia a mano","copy-empty":"nada seleccionado: arrastra con Shift para seleccionar","save-and-start":"guardar e iniciar",permissions:"Permisos","power-on-hint":"Detén la celda; también puedes quitarla del boot.","launch-engine-help":"Proveedores, credenciales y nuevos motores se crean en Ajustes → Flota. Modelo y permisos son por celda.","launch-external-hint":"Proveedor externo: motor/modelo se configuran en el fleet externo.","import-as-cell":"Importar como celda","import-help":"Reconcilia una sesión tmux existente en una celda gestionada. Elige un motor ya declarado: no se inventa ninguno.","import-engine-required":"elige un motor (obligatorio)","test-and-connect":"probar y conectar","pairing-v2-hint":"Pega o escanea UN solo enlace: rellena nombre, Host SSH y etiqueta cuando los incluye (v2).","invite-v2-hint":"Crea una invitación de un solo uso. El nombre y el puerto son automáticos; si este nodo ya está publicado no hay nada que rellenar.","invite-endpoint-label":"¿Cómo se puede alcanzar este dispositivo?","invite-endpoint-auto":"Endpoint ya configurado","invite-endpoint-needed":"Único dato necesario: una dirección SSH alcanzable desde el otro dispositivo (usuario@host o alias compartido).","invite-ssh-hint":"El destino SSH con el que el OTRO dispositivo alcanza ESTA instalación (usuario@host o alias). Obligatorio: se incluye en el enlace.","invite-next-steps":"copia este enlace, abre NexusCrew en el otro dispositivo y pégalo en Ajustes → Nodos (o escanea el QR): NexusCrew hace el resto","pair-card-title":"conectar con un solo enlace","pair-card-help":"Pega el enlace de emparejamiento generado en el otro dispositivo (o escanea su QR): NexusCrew lo decodifica, prueba la conexión SSH y conecta solo.","pair-paste-ph":"pega aquí el enlace de emparejamiento","pair-paste-btn":"pegar","pair-advanced":"avanzado / editar","pair-progress":"conectando: SSH → invitación → confirmación → verificación…","pair-retry":"reintentar","pair-invalid-link":"esto no es un enlace de emparejamiento válido","pair-invalid-hint":"se necesita el enlace completo (http://…#pair=…) generado por el otro NexusCrew: no lo abras, pégalo aquí","pair-missing-ssh":"el enlace no incluye el destino SSH (formato v1): indica en “avanzado” cómo este dispositivo alcanza al otro por SSH — nunca se inventa","pair-missing-name":"falta el nombre del nodo: complétalo en “avanzado”","pair-clipboard-denied":"lectura del portapapeles no permitida: pega manualmente en el campo","pair-clipboard-empty":"portapapeles vacío: copia primero el enlace","pair-stage-validation":"datos no válidos","pair-stage-conflict":"nombre ya en uso","pair-stage-ssh-start":"fallo al iniciar el túnel SSH","pair-stage-ssh-ready":"peer inaccesible por SSH","pair-stage-join":"intercambio de invitación fallido","pair-stage-tunnel-final":"túnel negociado fallido","pair-stage-confirm":"confirmación de emparejamiento fallida","pair-stage-health":"verificación final de la federación fallida","pair-stage-internal":"error interno","pair-stage-generic":"conexión fallida","qr-no-camera":"no hay cámara disponible en este dispositivo: usa una foto del QR","qr-permission":"permiso de cámara denegado: permítelo en el navegador o usa una foto del QR","qr-unsupported":"escáner en vivo no soportado aquí: sube una foto del QR","qr-upload":"usar una foto"}};function wu(){const e=Ug(),t=e?e.getItem(Wg):null;return vh.includes(t)?t:fa}function zS(e){const t=Ug();if(t)try{t.setItem(Wg,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(Su))}function w(e){const t=wu(),r=sa[t]||sa[fa];return Object.prototype.hasOwnProperty.call(r,e)?r[e]:Object.prototype.hasOwnProperty.call(sa[fa],e)?sa[fa][e]:e}function FS(e){return typeof window>"u"?()=>{}:(window.addEventListener(Su,e),()=>window.removeEventListener(Su,e))}const qg=vh;function ai(){return[M.useSyncExternalStore(FS,wu,wu),zS]}function wa({cell:e,token:t,route:r=[],onConfirm:n,onClose:o}){var Y,Q;ai();const l=!!(e&&e.active),u=Array.isArray(r)?r.join("/"):"",[f,m]=M.useState([]),[p,y]=M.useState(!1);M.useEffect(()=>{let G=!0;return(async()=>{if(t)try{const k=await es(t,u?u.split("/"):[]);if(!G)return;if(y(k.provider==="builtin"&&(k.capabilities||[]).includes("edit")),k.provider==="builtin"&&(k.capabilities||[]).includes("definitions")){const V=await mh(t,u?u.split("/"):[]);if(!G)return;const re=new Map((k.engines||[]).map(I=>[I.id,I]));m((V.engines||[]).map(I=>{var K,ne,B,se,ae,me,ue;return{id:I.id,label:I.label||I.id,client:((K=I.managed)==null?void 0:K.client)||"",models:[...new Set([...((ne=re.get(I.id))==null?void 0:ne.models)||[],...((B=I.managedInfo)==null?void 0:B.models)||[]])].filter(Boolean),defaultModel:((se=I.managed)==null?void 0:se.model)||((ae=I.managedInfo)==null?void 0:ae.defaultModel)||"",policyDefault:((me=I.managed)==null?void 0:me.permissionPolicy)||((ue=I.managed)!=null&&ue.client&&I.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{G=!1}},[t,u]);const S=(e==null?void 0:e.engine)||((Y=f[0])==null?void 0:Y.id)||"",v=G=>(e==null?void 0:e.models)&&e.models[G]||"",_=G=>{const k=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[G];if(k==="standard"||k==="unsafe")return k;const V=f.find(re=>re.id===G);return V?V.policyDefault:"standard"},[b,x]=M.useState(S),[E,N]=M.useState((e==null?void 0:e.model)||""),$=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((Q=e==null?void 0:e.permissionPolicies)==null?void 0:Q[e==null?void 0:e.engine])||"",[z,j]=M.useState($),[U,O]=M.useState((e==null?void 0:e.boot)??!0),[F,Z]=M.useState(!1),[R,H]=M.useState(null);M.useEffect(()=>{f.length&&(x(G=>G||S),N(G=>G||v((e==null?void 0:e.engine)||S)||""),j(G=>G==="standard"||G==="unsafe"?G:_((e==null?void 0:e.engine)||S)))},[f.length]);const A=M.useMemo(()=>f.find(G=>G.id===b)||null,[f,b]),P=!!(A&&["claude","codex","codex-vl"].includes(A.client));function L(G){x(G);const k=f.find(V=>V.id===G);N(v(G)||(k==null?void 0:k.defaultModel)||""),j(_(G))}async function T(G){G.preventDefault(),Z(!0),H(null);try{if(l)await n({action:"down",boot:U});else{const k=z==="standard"||z==="unsafe"?z:(A==null?void 0:A.policyDefault)||"standard";await n({action:"up",...p?{engine:b,model:E||"",...P?{permissionPolicy:k}:(A==null?void 0:A.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:U})}o()}catch(k){H(String(k&&k.message||k)),Z(!1)}}return h.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:o,children:h.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:G=>G.stopPropagation(),onSubmit:T,children:[h.jsxs("div",{className:"nc-sheet-head",children:[h.jsx("b",{children:e==null?void 0:e.cell}),h.jsx("span",{className:"nc-sheet-state",children:w(l?"state-on":"state-off")})]}),l?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:w("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[w("model"),": ",e.model]}),h.jsx("small",{children:w("power-on-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:U,onChange:G=>O(G.target.checked)}),w("remove-boot")]})]}):h.jsxs(h.Fragment,{children:[p&&f.length>0?h.jsxs("div",{className:"nc-launch-fields",children:[h.jsxs("label",{className:"nc-field",children:[w("engine"),h.jsx("select",{value:b,onChange:G=>L(G.target.value),children:f.map(G=>h.jsx("option",{value:G.id,children:G.label},G.id))})]}),h.jsxs("label",{className:"nc-field",children:[w("model"),h.jsx("input",{value:E,list:"nc-launch-models",placeholder:w("model-default"),onChange:G=>N(G.target.value)}),h.jsx("datalist",{id:"nc-launch-models",children:((A==null?void 0:A.models)||[]).map(G=>h.jsx("option",{value:G},G))})]}),P?h.jsxs("label",{className:"nc-field",children:[w("permissions"),h.jsxs("select",{value:z,onChange:G=>j(G.target.value),children:[h.jsx("option",{value:"standard",children:w("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:w("fleet-unsafe-permissions")})]})]}):h.jsx("small",{className:"nc-note",children:w("fleet-standard-permissions")}),P&&z==="unsafe"&&h.jsx("small",{className:"nc-err",children:w("fleet-unsafe-warning")}),h.jsx("small",{className:"nc-note",children:w("launch-engine-help")})]}):h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:w("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[w("model"),": ",e.model]}),h.jsx("small",{children:w("launch-external-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:U,onChange:G=>O(G.target.checked)}),w("boot-persist")]})]}),R&&h.jsx("div",{className:"nc-err",children:R}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:F,children:w("cancel")}),h.jsx("button",{type:"submit",className:"nc-btn primary",disabled:F,children:w(l?"power-off":"save-and-start")})]})]})})}const Dp=/^[a-z0-9-]{1,32}$/;function HS(e,t,r){const n={};for(const o of Array.isArray(t)?t:[]){const l=Array.isArray(o==null?void 0:o.route)?o.route:typeof(o==null?void 0:o.name)=="string"?[o.name]:[];if(!l.length)continue;const u=l.join("/"),f=o.status==="up"||o.tunnel&&o.tunnel.status==="up",m=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!f&&!m&&(n[u]=e&&e[u]||r)}return n}function Mp(e,t,r){return!e||!Array.isArray(e.cells)?[]:e.cells.map(n=>({...n,route:t,key:`${r}:${n.tmuxSession||n.cell}`}))}function Lp({nodes:e,topology:t,remote:r,down:n,fleet:o}={}){var m,p,y,S;const l=[],u=new Set,f=new Set;for(const v of Array.isArray(e)?e:[]){if(!v||typeof v.name!="string"||!Dp.test(v.name))continue;const _=[v.name],b=v.name;u.add(b);const x=((m=v.tunnel)==null?void 0:m.status)||"unknown",E=x==="up",N={name:v.name,label:v.label||v.name,route:_,direct:!0,tunnelStatus:x,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:v.health||null,direction:v.direction||"outbound",roles:v.roles||null,rolesKnown:v.rolesKnown===!0};if(v.nodeId&&f.add(v.nodeId),!v.nodeId&&v.paired===!1){l.push({...N,status:"needs-repair",downSince:n&&n[b]||null});continue}if(((p=v.health)==null?void 0:p.auth)==="failed"||x==="degraded"&&((y=v.health)==null?void 0:y.status)==="degraded"){l.push({...N,status:"needs-repair",downSince:n&&n[b]||null});continue}if(x==="passive"||((S=v.health)==null?void 0:S.status)==="passive"){l.push({...N,status:"passive",downSince:null});continue}if(!E){l.push({...N,status:"down",downSince:n&&n[b]||null});continue}const $=r&&(r[b]||r[v.name])||null;if(!$||$.error||!Array.isArray($.sessions)){l.push({...N,status:"unreachable"});continue}const z=$.sessions.filter(F=>F&&typeof F.name=="string"&&F.name).map(F=>({...F,node:b,route:_,key:`${b}:${F.name}`})),j=o&&(o[b]||o[v.name]),U=Mp(j,_,b),O=new Set(U.map(F=>F.tmuxSession).filter(Boolean));l.push({...N,status:"up",sessions:z,cells:U,unmanaged:z.filter(F=>!O.has(F.name)),fleetAvailable:!!(j&&j.available),capabilities:j&&j.capabilities||[],engines:j&&j.engines||[],fleetProvider:j&&j.provider||null})}for(const v of Array.isArray(t)?t:[]){if(!v||!Array.isArray(v.route)||v.route.length<1||v.route.some(j=>!Dp.test(j)))continue;const _=v.route.join("/");if(u.has(_)||v.instanceId&&f.has(v.instanceId))continue;v.instanceId&&f.add(v.instanceId);const b={name:v.name,label:v.label||v.route.join(" › "),route:[...v.route],direct:!1,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:v.health||null,lastSeen:v.lastSeen||null};if(v.stale){l.push({...b,status:"offline",downSince:n&&n[_]||v.lastSeen||null});continue}const x=r&&r[_]||null;if(!x||x.error||!Array.isArray(x.sessions)){l.push({...b,status:"unreachable",downSince:n&&n[_]||null});continue}const E=x.sessions.filter(j=>j&&typeof j.name=="string"&&j.name).map(j=>({...j,node:_,route:v.route,key:`${_}:${j.name}`})),N=o&&o[_],$=Mp(N,v.route,_),z=new Set($.map(j=>j.tmuxSession).filter(Boolean));l.push({...b,status:"up",sessions:E,cells:$,unmanaged:E.filter(j=>!z.has(j.name)),fleetAvailable:!!(N&&N.available),capabilities:N&&N.capabilities||[],engines:N&&N.engines||[],fleetProvider:N&&N.provider||null,lastSeen:v.lastSeen||null})}return l.sort((v,_)=>v.label.localeCompare(_.label))}const $S=4e3;function yh(e,t=!0){const[r,n]=M.useState([]),o=M.useRef({});return M.useEffect(()=>{if(!t||!e){n([]);return}let l=!0;async function u(){var x;let m=[],p=[];if(await Promise.all([Ag(e).then(E=>{m=Array.isArray(E.nodes)?E.nodes:[]}).catch(()=>{}),xS(e).then(E=>{p=Array.isArray(E.nodes)?E.nodes:[]}).catch(()=>{})]),!l)return;const y={},S={},v=new Set(m.map(E=>E.name)),_=[];for(const E of m)((x=E.tunnel)==null?void 0:x.status)==="up"&&(E.nodeId||E.paired!==!1)&&_.push([E.name]);for(const E of p)!E.stale&&Array.isArray(E.route)&&!(E.route.length===1&&v.has(E.route[0]))&&_.push(E.route);if(await Promise.all(_.map(async E=>{const N=E.join("/");try{y[N]=await Ig(e,E)}catch{y[N]={error:"unreachable"}}try{S[N]=await es(e,E)}catch{S[N]={available:!1}}})),!l)return;const b=Lp({nodes:m,topology:p,remote:y,fleet:S,down:o.current});o.current=HS(o.current,b,Math.floor(Date.now()/1e3)),n(Lp({nodes:m,topology:p,remote:y,fleet:S,down:o.current}))}u();const f=setInterval(u,$S);return()=>{l=!1,clearInterval(f)}},[e,t]),r}function Tp(e,t){return t?0:e.attached?1:2}function On(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 Mc(e){return e.status==="down"?e.downSince?w("tunnel-down-since").replace("{t}",On(e.downSince)):w("tunnel-down"):e.status==="unreachable"?w("node-unreachable"):e.status==="offline"?e.lastSeen?w("node-offline-seen").replace("{t}",On(e.lastSeen)):w("node-offline"):e.status==="needs-repair"?w("node-needs-repair"):""}function WS(e){return e?e.status==="healthy"?"on":"warn":null}function jp(e){return e&&(e.detail||e.status)||""}function US({onPick:e,token:t,onSettings:r}){const[n,o]=ai(),l=yh(t),[u,f]=M.useState(null),[m,p]=M.useState(null),[y,S]=M.useState(""),[v,_]=M.useState(""),[b,x]=M.useState({bind:"127.0.0.1",port:""}),[E,N]=M.useState([]),[$,z]=M.useState(!1),[j,U]=M.useState(null),[O,F]=M.useState(null);async function Z(){try{const se=await(await Ct("/api/sessions",t)).json();se.error?(p(se.error),f([])):(p(null),f(se.sessions||[]))}catch(B){p(String(B)),f([])}try{const B=await es(t);z(!!B.available),N(B.available?B.cells||[]:[])}catch{z(!1),N([])}}M.useEffect(()=>{Z(),Ct("/api/config",t).then(se=>se.json()).then(se=>{_(se.version||""),x({bind:se.bind||"127.0.0.1",port:se.port||""})}).catch(()=>{});const B=setInterval(Z,4e3);return()=>clearInterval(B)},[]);async function R(){if(!b.port)return;const B=`http://${b.bind}:${b.port}/#token=${t}`;try{await navigator.clipboard.writeText(B)}catch{}}async function H(B){if(!j)return;const{cell:se}=j,ae=Array.isArray(j.route)?j.route:[];B.action==="up"?await ph(t,{cell:se,boot:!!B.boot,...B.engine?{engine:B.engine}:{},...B.model!==void 0?{model:B.model}:{},...B.permissionPolicy?{permissionPolicy:B.permissionPolicy}:{}},ae):await Sa(t,{cell:se,boot:!!B.boot},ae),Z()}async function A(B,se=[]){try{await gh(t,B,se)}catch{return}Z()}async function P(B){if(!(!(B!=null&&B.direct)||O)){F(B.name);try{await _h(t,B.name,B.tunnelStatus==="up"?"down":"up")}catch{}F(null)}}const L=M.useMemo(()=>{const B=new Map;for(const se of u||[])B.set(se.name,se);return B},[u]),T=M.useMemo(()=>new Set(E.map(B=>B.tmuxSession)),[E]),[Y,Q]=M.useState(Hg),G=B=>Q(se=>$g(se,B)),k=M.useMemo(()=>{const B=(u||[]).map(ae=>{const me=Number(localStorage.getItem(Lg(ae.name))||0),ue=!!(ae.outbox&&ae.outbox.count>0&&ae.outbox.latest>me);return{...ae,fresh:ue}}),se=y.trim().toLowerCase();return B.filter(ae=>!se||ae.name.toLowerCase().includes(se)).sort((ae,me)=>yu(Ln(Y,ae.name,ae.activity),Ln(Y,me.name,me.activity))||Tp(ae,ae.fresh)-Tp(me,me.fresh)||ae.name.localeCompare(me.name))},[u,y,Y]),V=k.filter(B=>!T.has(B.name)),re=M.useMemo(()=>[...E].sort((B,se)=>yu(Ln(Y,B.tmuxSession,(L.get(B.tmuxSession)||{}).activity),Ln(Y,se.tmuxSession,(L.get(se.tmuxSession)||{}).activity))||Number(se.active)-Number(B.active)||B.cell.localeCompare(se.cell)),[E,Y,L]),I=u?u.length:0,K=(u||[]).filter(B=>B.attached).length,ne=b.port?`${b.bind}:${b.port}`:b.bind;return h.jsxs("div",{className:"nc-home",children:[h.jsxs("header",{className:"nc-home-head",children:[h.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",h.jsx("span",{className:"nc-cursor"})]}),h.jsxs("div",{className:"nc-home-sub",children:[w("fleet-tmux")," · ",I," ",w("sessions"),K>0&&` · ${K} attached`]}),h.jsxs("span",{className:"nc-head-actions",children:[h.jsx("button",{className:"nc-refresh",onClick:()=>r("nodes",!1),title:w("settings"),children:h.jsx(Oe,{name:"gear",size:18})}),h.jsx("button",{className:"nc-refresh",onClick:Z,title:w("refresh"),children:h.jsx(Oe,{name:"refresh",size:18})})]})]}),I>8&&h.jsx("input",{className:"nc-filter",type:"search",placeholder:w("filter-placeholder"),value:y,onChange:B=>S(B.target.value)}),m&&h.jsx("div",{className:"nc-err",children:m}),$&&E.length>0&&h.jsxs("section",{className:"nc-group",children:[h.jsx("div",{className:"nc-group-title",children:w("fleet")}),re.map(B=>{const se=L.get(B.tmuxSession)||{},ae=B.degraded?"warn":B.tmux?"on":"",me=[`${B.engine}${B.key?`·${B.key}`:""}`,se.preview].filter(Boolean).join(" · ");return h.jsxs("div",{className:"nc-mcard",children:[h.jsxs("button",{className:"nc-mcard-main",onClick:()=>B.tmux&&e(B.tmuxSession),title:B.degraded?w("cell-degraded"):B.tmux?w("cell-on"):w("cell-off"),children:[h.jsx("span",{className:`dot ${ae}`}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:B.cell}),h.jsx("small",{children:me})]})]}),se.activity?h.jsx("span",{className:"nc-rel",children:On(se.activity)}):null,se.outbox&&se.outbox.count>0&&h.jsx("span",{className:"nc-badge",title:w("new-files-outbox"),children:se.outbox.count}),h.jsx("button",{className:`nc-act pin${Y.includes(B.tmuxSession)?" on":""}`,title:w("pin"),onClick:()=>G(B.tmuxSession),children:Y.includes(B.tmuxSession)?"★":"☆"}),h.jsx("button",{className:`nc-act power${B.tmux?" on":""}${B.degraded?" warn":""}`,onClick:()=>U(B),title:B.active?w("power-off"):w("power-on"),children:h.jsx(Oe,{name:"power",size:16})})]},B.cell)})]}),h.jsxs("section",{className:"nc-group",children:[h.jsx("div",{className:"nc-group-title",children:w("local")}),V.map(B=>h.jsxs("div",{className:"nc-mcard",children:[h.jsxs("button",{className:"nc-mcard-main",onClick:()=>e(B.name),children:[h.jsx("span",{className:B.attached?"dot on":"dot"}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:B.name}),h.jsx("small",{children:B.preview?B.preview:B.cmd?B.cmd:w("windows").replace("{n}",String(B.windows||0))})]})]}),B.activity?h.jsx("span",{className:"nc-rel",children:On(B.activity)}):null,B.fresh&&h.jsx("span",{className:"nc-badge",title:w("new-files-outbox"),children:B.outbox.count}),h.jsx("button",{className:`nc-act pin${Y.includes(B.name)?" on":""}`,title:w("pin"),onClick:()=>G(B.name),children:Y.includes(B.name)?"★":"☆"}),h.jsx("button",{className:"nc-menu",title:w("terminate"),onClick:()=>{window.confirm(w("terminate-confirm").replace("{name}",B.name))&&A(B.name)},children:"⋯"})]},B.name)),u===null&&h.jsx("div",{className:"nc-empty",children:w("loading-fleet")}),u!==null&&V.length===0&&k.length===0&&!m&&h.jsx("div",{className:"nc-empty",children:y?w("no-match").replace("{q}",y):w("no-sessions")})]}),l.map(B=>{const ae=WS(B.health)||(B.status==="up"?"on":"warn"),me=B.health?jp(B.health):B.status==="up"?"":Mc(B);return h.jsxs("section",{className:"nc-group",children:[h.jsxs("div",{className:"nc-group-title nc-node-title",children:[h.jsx("span",{className:`dot ${ae}`,title:me}),B.label||B.name," · ",B.status==="up"?w("node-sessions").replace("{n}",String(B.cells.length+B.unmanaged.length)):B.health&&jp(B.health)||Mc(B),B.direct&&B.health&&B.health.managed!==!1&&h.jsx("button",{type:"button",className:`nc-act power${B.tunnelStatus==="up"?" on":""}`,disabled:O===B.name,title:B.tunnelStatus==="up"?w("power-off"):w("power-on"),onClick:()=>P(B),children:h.jsx(Oe,{name:"power",size:15})})]}),B.status==="up"&&B.cells.length>0&&B.cells.map(ue=>h.jsxs("div",{className:"nc-mcard",children:[h.jsxs("button",{className:"nc-mcard-main",onClick:()=>ue.tmux&&e({session:ue.tmuxSession,node:(B.route||[B.name]).join("/")}),title:ue.active?w("cell-on"):w("cell-off"),children:[h.jsx("span",{className:`dot ${ue.degraded?"warn":ue.tmux?"on":""}`}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:ue.cell}),h.jsxs("small",{children:[`${ue.engine}${ue.key?`·${ue.key}`:""}`,ue.active?"":` · ${w("cell-off")}`]})]})]}),(B.capabilities||[]).includes(ue.active?"down":"up")&&h.jsx("button",{className:`nc-act power${ue.active?" on":""}${ue.degraded?" warn":""}`,title:ue.active?w("power-off"):w("power-on"),onClick:()=>U({...ue,route:B.route}),children:h.jsx(Oe,{name:"power",size:15})})]},ue.key)),B.status==="up"&&B.unmanaged.map(ue=>h.jsxs("div",{className:"nc-mcard",children:[h.jsxs("button",{className:"nc-mcard-main",onClick:()=>e({session:ue.name,node:ue.node}),children:[h.jsx("span",{className:ue.attached?"dot on":"dot"}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:ue.name}),h.jsx("small",{children:ue.preview?ue.preview:ue.cmd?ue.cmd:w("windows").replace("{n}",String(ue.windows||0))})]})]}),ue.activity?h.jsx("span",{className:"nc-rel",children:On(ue.activity)}):null,h.jsx("button",{className:"nc-menu",title:w("terminate"),onClick:()=>{window.confirm(w("terminate-confirm").replace("{name}",ue.name))&&A(ue.name,B.route)},children:"⋯"})]},ue.key)),B.status==="up"&&B.cells.length===0&&B.unmanaged.length===0&&h.jsx("div",{className:"nc-empty",children:w("no-sessions-short")})]},`nodo-${(B.route||[B.name]).join("/")}`)}),h.jsxs("footer",{className:"nc-home-foot",onClick:R,title:w("copy-url"),children:[v&&h.jsxs("span",{children:["v",v]}),h.jsxs("span",{children:[ne," · ",w("ssh-only")]}),h.jsx("span",{className:"nc-lang",onClick:B=>B.stopPropagation(),children:qg.map((B,se)=>h.jsxs("span",{children:[se>0&&" · ",h.jsx("button",{className:`nc-lang-btn${n===B?" on":""}`,onClick:()=>o(B),title:B,children:B.toUpperCase()})]},B))})]}),h.jsx("button",{className:"nc-fab",onClick:()=>r("fleet",!0),title:w("fleet-new-cell"),"aria-label":w("fleet-new-cell"),children:"+"}),j&&h.jsx(wa,{cell:j,token:t,route:Array.isArray(j.route)?j.route:[],onConfirm:H,onClose:()=>U(null)})]})}/**
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 Kg=Object.defineProperty,qS=Object.getOwnPropertyDescriptor,KS=(e,t)=>{for(var r in t)Kg(e,r,{get:t[r],enumerable:!0})},tt=(e,t,r,n)=>{for(var o=n>1?void 0:n?qS(t,r):t,l=e.length-1,u;l>=0;l--)(u=e[l])&&(o=(n?u(t,r,o):u(o))||o);return n&&o&&Kg(t,r,o),o},_e=(e,t)=>(r,n)=>t(r,n,e),Bp="Terminal input",bu={get:()=>Bp,set:e=>Bp=e},Ap="Too much output to announce, navigate to rows manually to read",Cu={get:()=>Ap,set:e=>Ap=e};function VS(e){return e.replace(/\r?\n/g,"\r")}function YS(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function XS(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function GS(e,t,r,n){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");Vg(o,t,r,n)}}function Vg(e,t,r,n){e=VS(e),e=YS(e,r.decPrivateModes.bracketedPasteMode&&n.rawOptions.ignoreBracketedPasteMode!==!0),r.triggerDataEvent(e,!0),t.value=""}function Yg(e,t,r){let n=r.getBoundingClientRect(),o=e.clientX-n.left-10,l=e.clientY-n.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${l}px`,t.style.zIndex="1000",t.focus()}function Ip(e,t,r,n,o){Yg(e,t,r),o&&n.rightClickSelect(e),t.value=n.selectionText,t.select()}function Rr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ja(e,t=0,r=e.length){let n="";for(let o=t;o<r;++o){let l=e[o];l>65535?(l-=65536,n+=String.fromCharCode((l>>10)+55296)+String.fromCharCode(l%1024+56320)):n+=String.fromCharCode(l)}return n}var QS=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let r=e.length;if(!r)return 0;let n=0,o=0;if(this._interim){let l=e.charCodeAt(o++);56320<=l&&l<=57343?t[n++]=(this._interim-55296)*1024+l-56320+65536:(t[n++]=this._interim,t[n++]=l),this._interim=0}for(let l=o;l<r;++l){let u=e.charCodeAt(l);if(55296<=u&&u<=56319){if(++l>=r)return this._interim=u,n;let f=e.charCodeAt(l);56320<=f&&f<=57343?t[n++]=(u-55296)*1024+f-56320+65536:(t[n++]=u,t[n++]=f);continue}u!==65279&&(t[n++]=u)}return n}},JS=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let r=e.length;if(!r)return 0;let n=0,o,l,u,f,m=0,p=0;if(this.interim[0]){let v=!1,_=this.interim[0];_&=(_&224)===192?31:(_&240)===224?15:7;let b=0,x;for(;(x=this.interim[++b]&63)&&b<4;)_<<=6,_|=x;let E=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,N=E-b;for(;p<N;){if(p>=r)return 0;if(x=e[p++],(x&192)!==128){p--,v=!0;break}else this.interim[b++]=x,_<<=6,_|=x&63}v||(E===2?_<128?p--:t[n++]=_:E===3?_<2048||_>=55296&&_<=57343||_===65279||(t[n++]=_):_<65536||_>1114111||(t[n++]=_)),this.interim.fill(0)}let y=r-4,S=p;for(;S<r;){for(;S<y&&!((o=e[S])&128)&&!((l=e[S+1])&128)&&!((u=e[S+2])&128)&&!((f=e[S+3])&128);)t[n++]=o,t[n++]=l,t[n++]=u,t[n++]=f,S+=4;if(o=e[S++],o<128)t[n++]=o;else if((o&224)===192){if(S>=r)return this.interim[0]=o,n;if(l=e[S++],(l&192)!==128){S--;continue}if(m=(o&31)<<6|l&63,m<128){S--;continue}t[n++]=m}else if((o&240)===224){if(S>=r)return this.interim[0]=o,n;if(l=e[S++],(l&192)!==128){S--;continue}if(S>=r)return this.interim[0]=o,this.interim[1]=l,n;if(u=e[S++],(u&192)!==128){S--;continue}if(m=(o&15)<<12|(l&63)<<6|u&63,m<2048||m>=55296&&m<=57343||m===65279)continue;t[n++]=m}else if((o&248)===240){if(S>=r)return this.interim[0]=o,n;if(l=e[S++],(l&192)!==128){S--;continue}if(S>=r)return this.interim[0]=o,this.interim[1]=l,n;if(u=e[S++],(u&192)!==128){S--;continue}if(S>=r)return this.interim[0]=o,this.interim[1]=l,this.interim[2]=u,n;if(f=e[S++],(f&192)!==128){S--;continue}if(m=(o&7)<<18|(l&63)<<12|(u&63)<<6|f&63,m<65536||m>1114111)continue;t[n++]=m}}return n}},Xg="",Pr=" ",Wn=class Gg{constructor(){this.fg=0,this.bg=0,this.extended=new ba}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 Gg;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}},ba=class Qg{constructor(t=0,r=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=r}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 Qg(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},_i=class Jg extends Wn{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ba,this.combinedData=""}static fromCharData(t){let r=new Jg;return r.setFromCharData(t),r}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Rr(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 r=!1;if(t[1].length>2)r=!0;else if(t[1].length===2){let n=t[1].charCodeAt(0);if(55296<=n&&n<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(n-55296)*1024+o-56320+65536|t[2]<<22:r=!0}else r=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;r&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Op="di$target",xu="di$dependencies",Lc=new Map;function ZS(e){return e[xu]||[]}function xt(e){if(Lc.has(e))return Lc.get(e);let t=function(r,n,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");e0(t,r,o)};return t._id=e,Lc.set(e,t),t}function e0(e,t,r){t[Op]===t?t[xu].push({id:e,index:r}):(t[xu]=[{id:e,index:r}],t[Op]=t)}var Ot=xt("BufferService"),Zg=xt("CoreMouseService"),ts=xt("CoreService"),t0=xt("CharsetService"),Sh=xt("InstantiationService"),e_=xt("LogService"),zt=xt("OptionsService"),t_=xt("OscLinkService"),i0=xt("UnicodeService"),Un=xt("DecorationService"),ku=class{constructor(e,t,r){this._bufferService=e,this._optionsService=t,this._oscLinkService=r}provideLinks(e,t){var y;let r=this._bufferService.buffer.lines.get(e-1);if(!r){t(void 0);return}let n=[],o=this._optionsService.rawOptions.linkHandler,l=new _i,u=r.getTrimmedLength(),f=-1,m=-1,p=!1;for(let S=0;S<u;S++)if(!(m===-1&&!r.hasContent(S))){if(r.loadCell(S,l),l.hasExtendedAttrs()&&l.extended.urlId)if(m===-1){m=S,f=l.extended.urlId;continue}else p=l.extended.urlId!==f;else m!==-1&&(p=!0);if(p||m!==-1&&S===u-1){let v=(y=this._oscLinkService.getLinkData(f))==null?void 0:y.uri;if(v){let _={start:{x:m+1,y:e},end:{x:S+(!p&&S===u-1?1:0),y:e}},b=!1;if(!(o!=null&&o.allowNonHttpProtocols))try{let x=new URL(v);["http:","https:"].includes(x.protocol)||(b=!0)}catch{b=!0}b||n.push({text:v,range:_,activate:(x,E)=>o?o.activate(x,E,_):r0(x,E),hover:(x,E)=>{var N;return(N=o==null?void 0:o.hover)==null?void 0:N.call(o,x,E,_)},leave:(x,E)=>{var N;return(N=o==null?void 0:o.leave)==null?void 0:N.call(o,x,E,_)}})}p=!1,l.hasExtendedAttrs()&&l.extended.urlId?(m=S,f=l.extended.urlId):(m=-1,f=-1)}}t(n)}};ku=tt([_e(0,Ot),_e(1,zt),_e(2,t_)],ku);function r0(e,t){if(confirm(`Do you want to navigate to ${t}?
52
-
53
- WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Ba=xt("CharSizeService"),rr=xt("CoreBrowserService"),wh=xt("MouseService"),sr=xt("RenderService"),s0=xt("SelectionService"),i_=xt("CharacterJoinerService"),As=xt("ThemeService"),r_=xt("LinkProviderService"),n0=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?zp.isErrorNoTelemetry(e)?new zp(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)}},o0=new n0;function pa(e){a0(e)||o0.onUnexpectedError(e)}var Eu="Canceled";function a0(e){return e instanceof l0?!0:e instanceof Error&&e.name===Eu&&e.message===Eu}var l0=class extends Error{constructor(){super(Eu),this.name=this.message}};function c0(e){return new Error(`Illegal argument: ${e}`)}var zp=class Nu extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Nu)return t;let r=new Nu;return r.message=t.message,r.stack=t.stack,r}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Ru=class s_ extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,s_.prototype)}};function ii(e,t=0){return e[e.length-(1+t)]}var u0;(e=>{function t(l){return l<0}e.isLessThan=t;function r(l){return l<=0}e.isLessThanOrEqual=r;function n(l){return l>0}e.isGreaterThan=n;function o(l){return l===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(u0||(u0={}));function h0(e,t){let r=this,n=!1,o;return function(){return n||(n=!0,t||(o=e.apply(r,arguments))),o}}var n_;(e=>{function t(j){return j&&typeof j=="object"&&typeof j[Symbol.iterator]=="function"}e.is=t;let r=Object.freeze([]);function n(){return r}e.empty=n;function*o(j){yield j}e.single=o;function l(j){return t(j)?j:o(j)}e.wrap=l;function u(j){return j||r}e.from=u;function*f(j){for(let U=j.length-1;U>=0;U--)yield j[U]}e.reverse=f;function m(j){return!j||j[Symbol.iterator]().next().done===!0}e.isEmpty=m;function p(j){return j[Symbol.iterator]().next().value}e.first=p;function y(j,U){let O=0;for(let F of j)if(U(F,O++))return!0;return!1}e.some=y;function S(j,U){for(let O of j)if(U(O))return O}e.find=S;function*v(j,U){for(let O of j)U(O)&&(yield O)}e.filter=v;function*_(j,U){let O=0;for(let F of j)yield U(F,O++)}e.map=_;function*b(j,U){let O=0;for(let F of j)yield*U(F,O++)}e.flatMap=b;function*x(...j){for(let U of j)yield*U}e.concat=x;function E(j,U,O){let F=O;for(let Z of j)F=U(F,Z);return F}e.reduce=E;function*N(j,U,O=j.length){for(U<0&&(U+=j.length),O<0?O+=j.length:O>j.length&&(O=j.length);U<O;U++)yield j[U]}e.slice=N;function $(j,U=Number.POSITIVE_INFINITY){let O=[];if(U===0)return[O,j];let F=j[Symbol.iterator]();for(let Z=0;Z<U;Z++){let R=F.next();if(R.done)return[O,e.empty()];O.push(R.value)}return[O,{[Symbol.iterator](){return F}}]}e.consume=$;async function z(j){let U=[];for await(let O of j)U.push(O);return Promise.resolve(U)}e.asyncToArray=z})(n_||(n_={}));function Jr(e){if(n_.is(e)){let t=[];for(let r of e)if(r)try{r.dispose()}catch(n){t.push(n)}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 d0(...e){return Ve(()=>Jr(e))}function Ve(e){return{dispose:h0(()=>{e()})}}var o_=class a_{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{Jr(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?a_.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)}};o_.DISABLE_DISPOSED_WARNING=!1;var Dr=o_,Le=class{constructor(){this._store=new Dr,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)}};Le.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}},ir=typeof window=="object"?window:globalThis,Pu=class Du{constructor(t){this.element=t,this.next=Du.Undefined,this.prev=Du.Undefined}};Pu.Undefined=new Pu(void 0);var Ge=Pu,Fp=class{constructor(){this._first=Ge.Undefined,this._last=Ge.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Ge.Undefined}clear(){let e=this._first;for(;e!==Ge.Undefined;){let t=e.next;e.prev=Ge.Undefined,e.next=Ge.Undefined,e=t}this._first=Ge.Undefined,this._last=Ge.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new Ge(e);if(this._first===Ge.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==Ge.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Ge.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Ge.Undefined&&e.next!==Ge.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Ge.Undefined&&e.next===Ge.Undefined?(this._first=Ge.Undefined,this._last=Ge.Undefined):e.next===Ge.Undefined?(this._last=this._last.prev,this._last.next=Ge.Undefined):e.prev===Ge.Undefined&&(this._first=this._first.next,this._first.prev=Ge.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Ge.Undefined;)yield e.element,e=e.next}},f0=globalThis.performance&&typeof globalThis.performance.now=="function",p0=class l_{static create(t){return new l_(t)}constructor(t){this._now=f0&&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}},Rt;(e=>{e.None=()=>Le.None;function t(P,L){return S(P,()=>{},0,void 0,!0,void 0,L)}e.defer=t;function r(P){return(L,T=null,Y)=>{let Q=!1,G;return G=P(k=>{if(!Q)return G?G.dispose():Q=!0,L.call(T,k)},null,Y),Q&&G.dispose(),G}}e.once=r;function n(P,L,T){return p((Y,Q=null,G)=>P(k=>Y.call(Q,L(k)),null,G),T)}e.map=n;function o(P,L,T){return p((Y,Q=null,G)=>P(k=>{L(k),Y.call(Q,k)},null,G),T)}e.forEach=o;function l(P,L,T){return p((Y,Q=null,G)=>P(k=>L(k)&&Y.call(Q,k),null,G),T)}e.filter=l;function u(P){return P}e.signal=u;function f(...P){return(L,T=null,Y)=>{let Q=d0(...P.map(G=>G(k=>L.call(T,k))));return y(Q,Y)}}e.any=f;function m(P,L,T,Y){let Q=T;return n(P,G=>(Q=L(Q,G),Q),Y)}e.reduce=m;function p(P,L){let T,Y={onWillAddFirstListener(){T=P(Q.fire,Q)},onDidRemoveLastListener(){T==null||T.dispose()}},Q=new fe(Y);return L==null||L.add(Q),Q.event}function y(P,L){return L instanceof Array?L.push(P):L&&L.add(P),P}function S(P,L,T=100,Y=!1,Q=!1,G,k){let V,re,I,K=0,ne,B={leakWarningThreshold:G,onWillAddFirstListener(){V=P(ae=>{K++,re=L(re,ae),Y&&!I&&(se.fire(re),re=void 0),ne=()=>{let me=re;re=void 0,I=void 0,(!Y||K>1)&&se.fire(me),K=0},typeof T=="number"?(clearTimeout(I),I=setTimeout(ne,T)):I===void 0&&(I=0,queueMicrotask(ne))})},onWillRemoveListener(){Q&&K>0&&(ne==null||ne())},onDidRemoveLastListener(){ne=void 0,V.dispose()}},se=new fe(B);return k==null||k.add(se),se.event}e.debounce=S;function v(P,L=0,T){return e.debounce(P,(Y,Q)=>Y?(Y.push(Q),Y):[Q],L,void 0,!0,void 0,T)}e.accumulate=v;function _(P,L=(Y,Q)=>Y===Q,T){let Y=!0,Q;return l(P,G=>{let k=Y||!L(G,Q);return Y=!1,Q=G,k},T)}e.latch=_;function b(P,L,T){return[e.filter(P,L,T),e.filter(P,Y=>!L(Y),T)]}e.split=b;function x(P,L=!1,T=[],Y){let Q=T.slice(),G=P(re=>{Q?Q.push(re):V.fire(re)});Y&&Y.add(G);let k=()=>{Q==null||Q.forEach(re=>V.fire(re)),Q=null},V=new fe({onWillAddFirstListener(){G||(G=P(re=>V.fire(re)),Y&&Y.add(G))},onDidAddFirstListener(){Q&&(L?setTimeout(k):k())},onDidRemoveLastListener(){G&&G.dispose(),G=null}});return Y&&Y.add(V),V.event}e.buffer=x;function E(P,L){return(T,Y,Q)=>{let G=L(new $);return P(function(k){let V=G.evaluate(k);V!==N&&T.call(Y,V)},void 0,Q)}}e.chain=E;let N=Symbol("HaltChainable");class ${constructor(){this.steps=[]}map(L){return this.steps.push(L),this}forEach(L){return this.steps.push(T=>(L(T),T)),this}filter(L){return this.steps.push(T=>L(T)?T:N),this}reduce(L,T){let Y=T;return this.steps.push(Q=>(Y=L(Y,Q),Y)),this}latch(L=(T,Y)=>T===Y){let T=!0,Y;return this.steps.push(Q=>{let G=T||!L(Q,Y);return T=!1,Y=Q,G?Q:N}),this}evaluate(L){for(let T of this.steps)if(L=T(L),L===N)break;return L}}function z(P,L,T=Y=>Y){let Y=(...V)=>k.fire(T(...V)),Q=()=>P.on(L,Y),G=()=>P.removeListener(L,Y),k=new fe({onWillAddFirstListener:Q,onDidRemoveLastListener:G});return k.event}e.fromNodeEventEmitter=z;function j(P,L,T=Y=>Y){let Y=(...V)=>k.fire(T(...V)),Q=()=>P.addEventListener(L,Y),G=()=>P.removeEventListener(L,Y),k=new fe({onWillAddFirstListener:Q,onDidRemoveLastListener:G});return k.event}e.fromDOMEventEmitter=j;function U(P){return new Promise(L=>r(P)(L))}e.toPromise=U;function O(P){let L=new fe;return P.then(T=>{L.fire(T)},()=>{L.fire(void 0)}).finally(()=>{L.dispose()}),L.event}e.fromPromise=O;function F(P,L){return P(T=>L.fire(T))}e.forward=F;function Z(P,L,T){return L(T),P(Y=>L(Y))}e.runAndSubscribe=Z;class R{constructor(L,T){this._observable=L,this._counter=0,this._hasChanged=!1;let Y={onWillAddFirstListener:()=>{L.addObserver(this)},onDidRemoveLastListener:()=>{L.removeObserver(this)}};this.emitter=new fe(Y),T&&T.add(this.emitter)}beginUpdate(L){this._counter++}handlePossibleChange(L){}handleChange(L,T){this._hasChanged=!0}endUpdate(L){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function H(P,L){return new R(P,L).emitter.event}e.fromObservable=H;function A(P){return(L,T,Y)=>{let Q=0,G=!1,k={beginUpdate(){Q++},endUpdate(){Q--,Q===0&&(P.reportChanges(),G&&(G=!1,L.call(T)))},handlePossibleChange(){},handleChange(){G=!0}};P.addObserver(k),P.reportChanges();let V={dispose(){P.removeObserver(k)}};return Y instanceof Dr?Y.add(V):Array.isArray(Y)&&Y.push(V),V}}e.fromObservableLight=A})(Rt||(Rt={}));var Mu=class Lu{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Lu._idPool++}`,Lu.all.add(this)}start(t){this._stopWatch=new p0,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}}};Mu.all=new Set,Mu._idPool=0;var m0=Mu,g0=-1,c_=class u_{constructor(t,r,n=(u_._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=r,this.name=n,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,r){let n=this.threshold;if(n<=0||r<n)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=n*.5;let[l,u]=this.getMostFrequentStack(),f=`[${this.name}] potential listener LEAK detected, having ${r} listeners already. MOST frequent listener (${u}):`;console.warn(f),console.warn(l);let m=new y0(f,l);this._errorHandler(m)}return()=>{let l=this._stacks.get(t.value)||0;this._stacks.set(t.value,l-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,r=0;for(let[n,o]of this._stacks)(!t||r<o)&&(t=[n,o],r=o);return t}};c_._idPool=1;var _0=c_,v0=class h_{constructor(t){this.value=t}static create(){let t=new Error;return new h_(t.stack??"")}print(){console.warn(this.value.split(`
58
- `).slice(2).join(`
59
- `))}},y0=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},S0=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},w0=0,Tc=class{constructor(e){this.value=e,this.id=w0++}},b0=2,C0,fe=class{constructor(e){var t,r,n,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new _0((e==null?void 0:e.onListenerError)??pa,((r=this._options)==null?void 0:r.leakWarningThreshold)??g0):void 0,this._perfMon=(n=this._options)!=null&&n._profName?new m0(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var e,t,r,n;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),(r=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t),(n=this._leakageMon)==null||n.dispose())}get event(){return this._event??(this._event=(e,t,r)=>{var u,f,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 v=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],_=new S0(`${S}. HINT: Stack shows most frequent listener (${v[1]}-times)`,v[0]);return(((u=this._options)==null?void 0:u.onListenerError)||pa)(_),Le.None}if(this._disposed)return Le.None;t&&(e=e.bind(t));let n=new Tc(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=v0.create(),o=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof Tc?(this._deliveryQueue??(this._deliveryQueue=new x0),this._listeners=[this._listeners,n]):this._listeners.push(n):((m=(f=this._options)==null?void 0:f.onWillAddFirstListener)==null||m.call(f,this),this._listeners=n,(y=(p=this._options)==null?void 0:p.onDidAddFirstListener)==null||y.call(p,this)),this._size++;let l=Ve(()=>{o==null||o(),this._removeListener(n)});return r instanceof Dr?r.add(l):Array.isArray(r)&&r.push(l),l}),this._event}_removeListener(e){var o,l,u,f;if((l=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||l.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(f=(u=this._options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u,this),this._size=0;return}let t=this._listeners,r=t.indexOf(e);if(r===-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[r]=void 0;let n=this._deliveryQueue.current===this;if(this._size*b0<=t.length){let m=0;for(let p=0;p<t.length;p++)t[p]?t[m++]=t[p]:n&&(this._deliveryQueue.end--,m<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=m}}_deliver(e,t){var n;if(!e)return;let r=((n=this._options)==null?void 0:n.onListenerError)||pa;if(!r){e.value(t);return}try{e.value(t)}catch(o){r(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,r,n,o;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(r=this._perfMon)==null||r.stop()),(n=this._perfMon)==null||n.start(this._size),this._listeners)if(this._listeners instanceof Tc)this._deliver(this._listeners,e);else{let l=this._deliveryQueue;l.enqueue(this,e,this._listeners.length),this._deliverQueue(l)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},x0=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,r){this.i=0,this.end=r,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Tu=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new fe,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new fe,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,r){if(this.getZoomLevel(r)===t)return;let n=this.getWindowId(r);this.mapWindowIdToZoomLevel.set(n,t),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,r){this.mapWindowIdToZoomFactor.set(this.getWindowId(r),t)}setFullscreen(t,r){if(this.isFullscreen(r)===t)return;let n=this.getWindowId(r);this.mapWindowIdToFullScreen.set(n,t),this._onDidChangeFullscreen.fire(n)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Tu.INSTANCE=new Tu;var bh=Tu;function k0(e,t,r){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",r)}bh.INSTANCE.onDidChangeZoomLevel;function E0(e){return bh.INSTANCE.getZoomFactor(e)}bh.INSTANCE.onDidChangeFullscreen;var Is=typeof navigator=="object"?navigator.userAgent:"",ju=Is.indexOf("Firefox")>=0,N0=Is.indexOf("AppleWebKit")>=0,Ch=Is.indexOf("Chrome")>=0,R0=!Ch&&Is.indexOf("Safari")>=0;Is.indexOf("Electron/")>=0;Is.indexOf("Android")>=0;var jc=!1;if(typeof ir.matchMedia=="function"){let e=ir.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=ir.matchMedia("(display-mode: fullscreen)");jc=e.matches,k0(ir,e,({matches:r})=>{jc&&t.matches||(jc=r)})}var Ms="en",Bu=!1,Au=!1,ma=!1,d_=!1,na,ga=Ms,Hp=Ms,P0,Ri,Qr=globalThis,Nt,Pg;typeof Qr.vscode<"u"&&typeof Qr.vscode.process<"u"?Nt=Qr.vscode.process:typeof process<"u"&&typeof((Pg=process==null?void 0:process.versions)==null?void 0:Pg.node)=="string"&&(Nt=process);var Dg,D0=typeof((Dg=Nt==null?void 0:Nt.versions)==null?void 0:Dg.electron)=="string",M0=D0&&(Nt==null?void 0:Nt.type)==="renderer",Mg;if(typeof Nt=="object"){Bu=Nt.platform==="win32",Au=Nt.platform==="darwin",ma=Nt.platform==="linux",ma&&Nt.env.SNAP&&Nt.env.SNAP_REVISION,Nt.env.CI||Nt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,na=Ms,ga=Ms;let e=Nt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);na=t.userLocale,Hp=t.osLocale,ga=t.resolvedLanguage||Ms,P0=(Mg=t.languagePack)==null?void 0:Mg.translationsConfigFile}catch{}d_=!0}else typeof navigator=="object"&&!M0?(Ri=navigator.userAgent,Bu=Ri.indexOf("Windows")>=0,Au=Ri.indexOf("Macintosh")>=0,(Ri.indexOf("Macintosh")>=0||Ri.indexOf("iPad")>=0||Ri.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,ma=Ri.indexOf("Linux")>=0,(Ri==null?void 0:Ri.indexOf("Mobi"))>=0,ga=globalThis._VSCODE_NLS_LANGUAGE||Ms,na=navigator.language.toLowerCase(),Hp=na):console.error("Unable to resolve platform.");var f_=Bu,Wi=Au,L0=ma,$p=d_,Ui=Ri,xr=ga,T0;(e=>{function t(){return xr}e.value=t;function r(){return xr.length===2?xr==="en":xr.length>=3?xr[0]==="e"&&xr[1]==="n"&&xr[2]==="-":!1}e.isDefaultVariant=r;function n(){return xr==="en"}e.isDefault=n})(T0||(T0={}));var j0=typeof Qr.postMessage=="function"&&!Qr.importScripts;(()=>{if(j0){let e=[];Qr.addEventListener("message",r=>{if(r.data&&r.data.vscodeScheduleAsyncWork)for(let n=0,o=e.length;n<o;n++){let l=e[n];if(l.id===r.data.vscodeScheduleAsyncWork){e.splice(n,1),l.callback();return}}});let t=0;return r=>{let n=++t;e.push({id:n,callback:r}),Qr.postMessage({vscodeScheduleAsyncWork:n},"*")}}return e=>setTimeout(e)})();var B0=!!(Ui&&Ui.indexOf("Chrome")>=0);Ui&&Ui.indexOf("Firefox")>=0;!B0&&Ui&&Ui.indexOf("Safari")>=0;Ui&&Ui.indexOf("Edg/")>=0;Ui&&Ui.indexOf("Android")>=0;var Rs=typeof navigator=="object"?navigator:{};$p||document.queryCommandSupported&&document.queryCommandSupported("copy")||Rs&&Rs.clipboard&&Rs.clipboard.writeText,$p||Rs&&Rs.clipboard&&Rs.clipboard.readText;var xh=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}},Bc=new xh,Wp=new xh,Up=new xh,A0=new Array(230),p_;(e=>{function t(f){return Bc.keyCodeToStr(f)}e.toString=t;function r(f){return Bc.strToKeyCode(f)}e.fromString=r;function n(f){return Wp.keyCodeToStr(f)}e.toUserSettingsUS=n;function o(f){return Up.keyCodeToStr(f)}e.toUserSettingsGeneral=o;function l(f){return Wp.strToKeyCode(f)||Up.strToKeyCode(f)}e.fromUserSettings=l;function u(f){if(f>=98&&f<=113)return null;switch(f){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Bc.keyCodeToStr(f)}e.toElectronAccelerator=u})(p_||(p_={}));var I0=class m_{constructor(t,r,n,o,l){this.ctrlKey=t,this.shiftKey=r,this.altKey=n,this.metaKey=o,this.keyCode=l}equals(t){return t instanceof m_&&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",r=this.shiftKey?"1":"0",n=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${r}${n}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new O0([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},O0=class{constructor(e){if(e.length===0)throw c0("chords");this.chords=e}getHashCode(){let e="";for(let t=0,r=this.chords.length;t<r;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 z0(e){if(e.charCode){let r=String.fromCharCode(e.charCode).toUpperCase();return p_.fromString(r)}let t=e.keyCode;if(t===3)return 7;if(ju)switch(t){case 59:return 85;case 60:if(L0)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Wi)return 57;break}else if(N0&&(Wi&&t===93||!Wi&&t===92))return 57;return A0[t]||0}var F0=Wi?256:2048,H0=512,$0=1024,W0=Wi?2048:256,qp=class{constructor(e){var r;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=(r=t.getModifierState)==null?void 0:r.call(t,"AltGraph"),this.keyCode=z0(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|=F0),this.altKey&&(t|=H0),this.shiftKey&&(t|=$0),this.metaKey&&(t|=W0),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new I0(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Kp=new WeakMap;function U0(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,r=e.parent.location;if(t.origin!=="null"&&r.origin!=="null"&&t.origin!==r.origin)return null}catch{return null}return e.parent}var q0=class{static getSameOriginWindowChain(e){let t=Kp.get(e);if(!t){t=[],Kp.set(e,t);let r=e,n;do n=U0(r),n?t.push({window:new WeakRef(r),iframeElement:r.frameElement||null}):t.push({window:new WeakRef(r),iframeElement:null}),r=n;while(r)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let r=0,n=0,o=this.getSameOriginWindowChain(e);for(let l of o){let u=l.window.deref();if(r+=(u==null?void 0:u.scrollY)??0,n+=(u==null?void 0:u.scrollX)??0,u===t||!l.iframeElement)break;let f=l.iframeElement.getBoundingClientRect();r+=f.top,n+=f.left}return{top:r,left:n}}},oa=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 r=q0.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=r.left,this.posy-=r.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Vp=class{constructor(e,t=0,r=0){var o;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=r,this.deltaX=t;let n=!1;if(Ch){let l=navigator.userAgent.match(/Chrome\/(\d+)/);n=(l?parseInt(l[1]):123)<=122}if(e){let l=e,u=e,f=((o=e.view)==null?void 0:o.devicePixelRatio)||1;if(typeof l.wheelDeltaY<"u")n?this.deltaY=l.wheelDeltaY/(120*f):this.deltaY=l.wheelDeltaY/120;else if(typeof u.VERTICAL_AXIS<"u"&&u.axis===u.VERTICAL_AXIS)this.deltaY=-u.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?ju&&!Wi?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof l.wheelDeltaX<"u")R0&&f_?this.deltaX=-(l.wheelDeltaX/120):n?this.deltaX=l.wheelDeltaX/(120*f):this.deltaX=l.wheelDeltaX/120;else if(typeof u.HORIZONTAL_AXIS<"u"&&u.axis===u.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?ju&&!Wi?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(n?this.deltaY=e.wheelDelta/(120*f):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},g_=Object.freeze(function(e,t){let r=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(r)}}}),K0;(e=>{function t(r){return r===e.None||r===e.Cancelled||r instanceof V0?!0:!r||typeof r!="object"?!1:typeof r.isCancellationRequested=="boolean"&&typeof r.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Rt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:g_})})(K0||(K0={}));var V0=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?g_:(this._emitter||(this._emitter=new fe),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},kh=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 Ru("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Ru("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Y0=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,r=globalThis){if(this.isDisposed)throw new Ru("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let n=r.setInterval(()=>{e()},t);this.disposable=Ve(()=>{r.clearInterval(n),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},X0;(e=>{async function t(n){let o,l=await Promise.all(n.map(u=>u.then(f=>f,f=>{o||(o=f)})));if(typeof o<"u")throw o;return l}e.settled=t;function r(n){return new Promise(async(o,l)=>{try{await n(o,l)}catch(u){l(u)}})}e.withAsyncBody=r})(X0||(X0={}));var Yp=class mi{static fromArray(t){return new mi(r=>{r.emitMany(t)})}static fromPromise(t){return new mi(async r=>{r.emitMany(await t)})}static fromPromises(t){return new mi(async r=>{await Promise.all(t.map(async n=>r.emitOne(await n)))})}static merge(t){return new mi(async r=>{await Promise.all(t.map(async n=>{for await(let o of n)r.emitOne(o)}))})}constructor(t,r){this._state=0,this._results=[],this._error=null,this._onReturn=r,this._onStateChanged=new fe,queueMicrotask(async()=>{let n={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(n)),this.resolve()}catch(o){this.reject(o)}finally{n.emitOne=void 0,n.emitMany=void 0,n.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 Rt.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var r;return(r=this._onReturn)==null||r.call(this),{done:!0,value:void 0}}}}static map(t,r){return new mi(async n=>{for await(let o of t)n.emitOne(r(o))})}map(t){return mi.map(this,t)}static filter(t,r){return new mi(async n=>{for await(let o of t)r(o)&&n.emitOne(o)})}filter(t){return mi.filter(this,t)}static coalesce(t){return mi.filter(t,r=>!!r)}coalesce(){return mi.coalesce(this)}static async toPromise(t){let r=[];for await(let n of t)r.push(n);return r}toPromise(){return mi.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())}};Yp.EMPTY=Yp.fromArray([]);var{getWindow:$i,getWindowId:G0,onDidRegisterWindow:Q0}=(function(){let e=new Map,t={window:ir,disposables:new Dr};e.set(ir.vscodeWindowId,t);let r=new fe,n=new fe,o=new fe;function l(u,f){return(typeof u=="number"?e.get(u):void 0)??(f?t:void 0)}return{onDidRegisterWindow:r.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:n.event,registerWindow(u){if(e.has(u.vscodeWindowId))return Le.None;let f=new Dr,m={window:u,disposables:f.add(new Dr)};return e.set(u.vscodeWindowId,m),f.add(Ve(()=>{e.delete(u.vscodeWindowId),n.fire(u)})),f.add(Pe(u,yt.BEFORE_UNLOAD,()=>{o.fire(u)})),r.fire(m),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:l,getWindow(u){var p;let f=u;if((p=f==null?void 0:f.ownerDocument)!=null&&p.defaultView)return f.ownerDocument.defaultView.window;let m=u;return m!=null&&m.view?m.view.window:ir},getDocument(u){return $i(u).document}}})(),J0=class{constructor(e,t,r,n){this._node=e,this._type=t,this._handler=r,this._options=n||!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 Pe(e,t,r,n){return new J0(e,t,r,n)}var Xp=function(e,t,r,n){return Pe(e,t,r,n)},Eh,Z0=class extends Y0{constructor(e){super(),this.defaultTarget=e&&$i(e)}cancelAndSet(e,t,r){return super.cancelAndSet(e,t,r??this.defaultTarget)}},Gp=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){pa(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,r=new Map,n=new Map,o=l=>{r.set(l,!1);let u=e.get(l)??[];for(t.set(l,u),e.set(l,[]),n.set(l,!0);u.length>0;)u.sort(Gp.sort),u.shift().execute();n.set(l,!1)};Eh=(l,u,f=0)=>{let m=G0(l),p=new Gp(u,f),y=e.get(m);return y||(y=[],e.set(m,y)),y.push(p),r.get(m)||(r.set(m,!0),l.requestAnimationFrame(()=>o(m))),p}})();function ew(e){let t=e.getBoundingClientRect(),r=$i(e);return{left:t.left+r.scrollX,top:t.top+r.scrollY,width:t.width,height:t.height}}var yt={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"},tw=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 r=Vt(t);this._maxWidth!==r&&(this._maxWidth=r,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let r=Vt(t);this._width!==r&&(this._width=r,this.domNode.style.width=this._width)}setHeight(t){let r=Vt(t);this._height!==r&&(this._height=r,this.domNode.style.height=this._height)}setTop(t){let r=Vt(t);this._top!==r&&(this._top=r,this.domNode.style.top=this._top)}setLeft(t){let r=Vt(t);this._left!==r&&(this._left=r,this.domNode.style.left=this._left)}setBottom(t){let r=Vt(t);this._bottom!==r&&(this._bottom=r,this.domNode.style.bottom=this._bottom)}setRight(t){let r=Vt(t);this._right!==r&&(this._right=r,this.domNode.style.right=this._right)}setPaddingTop(t){let r=Vt(t);this._paddingTop!==r&&(this._paddingTop=r,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let r=Vt(t);this._paddingLeft!==r&&(this._paddingLeft=r,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let r=Vt(t);this._paddingBottom!==r&&(this._paddingBottom=r,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let r=Vt(t);this._paddingRight!==r&&(this._paddingRight=r,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 r=Vt(t);this._fontSize!==r&&(this._fontSize=r,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 r=Vt(t);this._lineHeight!==r&&(this._lineHeight=r,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let r=Vt(t);this._letterSpacing!==r&&(this._letterSpacing=r,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,r){this.domNode.classList.toggle(t,r),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,r){this.domNode.setAttribute(t,r)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function Vt(e){return typeof e=="number"?`${e}px`:e}function zn(e){return new tw(e)}var __=class{constructor(){this._hooks=new Dr,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 r=this._onStopCallback;this._onStopCallback=null,e&&r&&r(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,r,n,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=n,this._onStopCallback=o;let l=e;try{e.setPointerCapture(t),this._hooks.add(Ve(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{l=$i(e)}this._hooks.add(Pe(l,yt.POINTER_MOVE,u=>{if(u.buttons!==r){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(Pe(l,yt.POINTER_UP,u=>this.stopMonitoring(!0)))}};function iw(e,t,r){let n=null,o=null;if(typeof r.value=="function"?(n="value",o=r.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof r.get=="function"&&(n="get",o=r.get),!o)throw new Error("not supported");let l=`$memoize$${t}`;r[n]=function(...u){return this.hasOwnProperty(l)||Object.defineProperty(this,l,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,u)}),this[l]}}var Fi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Fi||(Fi={}));var Tn=class jt extends Le{constructor(){super(),this.dispatched=!1,this.targets=new Fp,this.ignoreTargets=new Fp,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Rt.runAndSubscribe(Q0,({window:t,disposables:r})=>{r.add(Pe(t.document,"touchstart",n=>this.onTouchStart(n),{passive:!1})),r.add(Pe(t.document,"touchend",n=>this.onTouchEnd(t,n))),r.add(Pe(t.document,"touchmove",n=>this.onTouchMove(n),{passive:!1}))},{window:ir,disposables:this._store}))}static addTarget(t){if(!jt.isTouchDevice())return Le.None;jt.INSTANCE||(jt.INSTANCE=new jt);let r=jt.INSTANCE.targets.push(t);return Ve(r)}static ignoreTarget(t){if(!jt.isTouchDevice())return Le.None;jt.INSTANCE||(jt.INSTANCE=new jt);let r=jt.INSTANCE.ignoreTargets.push(t);return Ve(r)}static isTouchDevice(){return"ontouchstart"in ir||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let r=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let n=0,o=t.targetTouches.length;n<o;n++){let l=t.targetTouches.item(n);this.activeTouches[l.identifier]={id:l.identifier,initialTarget:l.target,initialTimeStamp:r,initialPageX:l.pageX,initialPageY:l.pageY,rollingTimestamps:[r],rollingPageX:[l.pageX],rollingPageY:[l.pageY]};let u=this.newGestureEvent(Fi.Start,l.target);u.pageX=l.pageX,u.pageY=l.pageY,this.dispatchEvent(u)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,r){let n=Date.now(),o=Object.keys(this.activeTouches).length;for(let l=0,u=r.changedTouches.length;l<u;l++){let f=r.changedTouches.item(l);if(!this.activeTouches.hasOwnProperty(String(f.identifier))){console.warn("move of an UNKNOWN touch",f);continue}let m=this.activeTouches[f.identifier],p=Date.now()-m.initialTimeStamp;if(p<jt.HOLD_DELAY&&Math.abs(m.initialPageX-ii(m.rollingPageX))<30&&Math.abs(m.initialPageY-ii(m.rollingPageY))<30){let y=this.newGestureEvent(Fi.Tap,m.initialTarget);y.pageX=ii(m.rollingPageX),y.pageY=ii(m.rollingPageY),this.dispatchEvent(y)}else if(p>=jt.HOLD_DELAY&&Math.abs(m.initialPageX-ii(m.rollingPageX))<30&&Math.abs(m.initialPageY-ii(m.rollingPageY))<30){let y=this.newGestureEvent(Fi.Contextmenu,m.initialTarget);y.pageX=ii(m.rollingPageX),y.pageY=ii(m.rollingPageY),this.dispatchEvent(y)}else if(o===1){let y=ii(m.rollingPageX),S=ii(m.rollingPageY),v=ii(m.rollingTimestamps)-m.rollingTimestamps[0],_=y-m.rollingPageX[0],b=S-m.rollingPageY[0],x=[...this.targets].filter(E=>m.initialTarget instanceof Node&&E.contains(m.initialTarget));this.inertia(t,x,n,Math.abs(_)/v,_>0?1:-1,y,Math.abs(b)/v,b>0?1:-1,S)}this.dispatchEvent(this.newGestureEvent(Fi.End,m.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(r.preventDefault(),r.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,r){let n=document.createEvent("CustomEvent");return n.initEvent(t,!1,!0),n.initialTarget=r,n.tapCount=0,n}dispatchEvent(t){if(t.type===Fi.Tap){let r=new Date().getTime(),n=0;r-this._lastSetTapCountTime>jt.CLEAR_TAP_COUNT_TIME?n=1:n=2,this._lastSetTapCountTime=r,t.tapCount=n}else(t.type===Fi.Change||t.type===Fi.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let n of this.ignoreTargets)if(n.contains(t.initialTarget))return;let r=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let o=0,l=t.initialTarget;for(;l&&l!==n;)o++,l=l.parentElement;r.push([o,n])}r.sort((n,o)=>n[0]-o[0]);for(let[n,o]of r)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,r,n,o,l,u,f,m,p){this.handle=Eh(t,()=>{let y=Date.now(),S=y-n,v=0,_=0,b=!0;o+=jt.SCROLL_FRICTION*S,f+=jt.SCROLL_FRICTION*S,o>0&&(b=!1,v=l*o*S),f>0&&(b=!1,_=m*f*S);let x=this.newGestureEvent(Fi.Change);x.translationX=v,x.translationY=_,r.forEach(E=>E.dispatchEvent(x)),b||this.inertia(t,r,y,o,l,u+v,f,m,p+_)})}onTouchMove(t){let r=Date.now();for(let n=0,o=t.changedTouches.length;n<o;n++){let l=t.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("end of an UNKNOWN touch",l);continue}let u=this.activeTouches[l.identifier],f=this.newGestureEvent(Fi.Change,u.initialTarget);f.translationX=l.pageX-ii(u.rollingPageX),f.translationY=l.pageY-ii(u.rollingPageY),f.pageX=l.pageX,f.pageY=l.pageY,this.dispatchEvent(f),u.rollingPageX.length>3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(l.pageX),u.rollingPageY.push(l.pageY),u.rollingTimestamps.push(r)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Tn.SCROLL_FRICTION=-.005,Tn.HOLD_DELAY=700,Tn.CLEAR_TAP_COUNT_TIME=400,tt([iw],Tn,"isTouchDevice",1);var rw=Tn,Nh=class extends Le{onclick(e,t){this._register(Pe(e,yt.CLICK,r=>t(new oa($i(e),r))))}onmousedown(e,t){this._register(Pe(e,yt.MOUSE_DOWN,r=>t(new oa($i(e),r))))}onmouseover(e,t){this._register(Pe(e,yt.MOUSE_OVER,r=>t(new oa($i(e),r))))}onmouseleave(e,t){this._register(Pe(e,yt.MOUSE_LEAVE,r=>t(new oa($i(e),r))))}onkeydown(e,t){this._register(Pe(e,yt.KEY_DOWN,r=>t(new qp(r))))}onkeyup(e,t){this._register(Pe(e,yt.KEY_UP,r=>t(new qp(r))))}oninput(e,t){this._register(Pe(e,yt.INPUT,t))}onblur(e,t){this._register(Pe(e,yt.BLUR,t))}onfocus(e,t){this._register(Pe(e,yt.FOCUS,t))}onchange(e,t){this._register(Pe(e,yt.CHANGE,t))}ignoreGesture(e){return rw.ignoreTarget(e)}},Qp=11,sw=class extends Nh{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=Qp+"px",this.domNode.style.height=Qp+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new __),this._register(Xp(this.bgDomNode,yt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Xp(this.domNode,yt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Z0),this._pointerdownScheduleRepeatTimer=this._register(new kh)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,$i(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},nw=class Iu{constructor(t,r,n,o,l,u,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(r=r|0,n=n|0,o=o|0,l=l|0,u=u|0,f=f|0),this.rawScrollLeft=o,this.rawScrollTop=f,r<0&&(r=0),o+r>n&&(o=n-r),o<0&&(o=0),l<0&&(l=0),f+l>u&&(f=u-l),f<0&&(f=0),this.width=r,this.scrollWidth=n,this.scrollLeft=o,this.height=l,this.scrollHeight=u,this.scrollTop=f}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,r){return new Iu(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,r?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,r?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Iu(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,r){let n=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,l=this.scrollLeft!==t.scrollLeft,u=this.height!==t.height,f=this.scrollHeight!==t.scrollHeight,m=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:r,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:n,scrollWidthChanged:o,scrollLeftChanged:l,heightChanged:u,scrollHeightChanged:f,scrollTopChanged:m}}},ow=class extends Le{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new nw(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 n;let r=this._state.withScrollDimensions(e,t);this._setState(r,!!this._smoothScrolling),(n=this._smoothScrolling)==null||n.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 r=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===r.scrollLeft&&this._smoothScrolling.to.scrollTop===r.scrollTop)return;let n;t?n=new Zp(this._smoothScrolling.from,r,this._smoothScrolling.startTime,this._smoothScrolling.duration):n=this._smoothScrolling.combine(this._state,r,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=n}else{let r=this._state.withScrollPosition(e);this._smoothScrolling=Zp.start(this._state,r,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 r=this._state;r.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(r,t)))}},Jp=class{constructor(e,t,r){this.scrollLeft=e,this.scrollTop=t,this.isDone=r}};function Ac(e,t){let r=t-e;return function(n){return e+r*cw(n)}}function aw(e,t,r){return function(n){return n<r?e(n/r):t((n-r)/(1-r))}}var Zp=class Ou{constructor(t,r,n,o){this.from=t,this.to=r,this.duration=o,this.startTime=n,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,r,n){if(Math.abs(t-r)>2.5*n){let o,l;return t<r?(o=t+.75*n,l=r-.75*n):(o=t-.75*n,l=r+.75*n),aw(Ac(t,o),Ac(l,r),.33)}return Ac(t,r)}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 r=(t-this.startTime)/this.duration;if(r<1){let n=this.scrollLeft(r),o=this.scrollTop(r);return new Jp(n,o,!1)}return new Jp(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,r,n){return Ou.start(t,r,n)}static start(t,r,n){n=n+10;let o=Date.now()-10;return new Ou(t,r,o,n)}};function lw(e){return Math.pow(e,3)}function cw(e){return 1-lw(1-e)}var uw=class extends Le{constructor(e,t,r){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=r,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new kh)}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":"")))}},hw=140,v_=class extends Nh{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 uw(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new __),this._shouldRender=!0,this.domNode=zn(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(Pe(this.domNode.domNode,yt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new sw(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,r,n){this.slider=zn(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof r=="number"&&this.slider.setWidth(r),typeof n=="number"&&this.slider.setHeight(n),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Pe(this.slider.domNode,yt.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,r=t+this._scrollbarState.getSliderPosition(),n=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);r<=o&&o<=n?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,r;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,r=e.offsetY;else{let o=ew(this.domNode.domNode);t=e.pageX-o.left,r=e.pageY-o.top}let n=this._pointerDownRelativePosition(t,r);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),r=this._sliderOrthogonalPointerPosition(e),n=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let l=this._sliderOrthogonalPointerPosition(o),u=Math.abs(l-r);if(f_&&u>hw){this._setDesiredScrollPositionNow(n.getScrollPosition());return}let f=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(n.getDesiredScrollPositionFromDelta(f))},()=>{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()}},y_=class zu{constructor(t,r,n,o,l,u){this._scrollbarSize=Math.round(r),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=l,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new zu(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let r=Math.round(t);return this._visibleSize!==r?(this._visibleSize=r,this._refreshComputedValues(),!0):!1}setScrollSize(t){let r=Math.round(t);return this._scrollSize!==r?(this._scrollSize=r,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let r=Math.round(t);return this._scrollPosition!==r?(this._scrollPosition=r,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,r,n,o,l){let u=Math.max(0,n-t),f=Math.max(0,u-2*r),m=o>0&&o>n;if(!m)return{computedAvailableSize:Math.round(u),computedIsNeeded:m,computedSliderSize:Math.round(f),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(n*f/o))),y=(f-p)/(o-n),S=l*y;return{computedAvailableSize:Math.round(u),computedIsNeeded:m,computedSliderSize:Math.round(p),computedSliderRatio:y,computedSliderPosition:Math.round(S)}}_refreshComputedValues(){let t=zu._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 r=t-this._arrowSize-this._computedSliderSize/2;return Math.round(r/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let r=t-this._arrowSize,n=this._scrollPosition;return r<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let r=this._computedSliderPosition+t;return Math.round(r/this._computedSliderRatio)}},dw=class extends v_{constructor(e,t,r){let n=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:r,scrollbarState:new y_(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,n.width,n.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}},fw=class extends v_{constructor(e,t,r){let n=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:r,scrollbarState:new y_(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,n.height,n.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}},pw=500,em=50,mw=class{constructor(e,t,r){this.timestamp=e,this.deltaX=t,this.deltaY=r,this.score=0}},Fu=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,r=0,n=1,o=this._rear;do{let l=o===this._front?t:Math.pow(2,-n);if(t-=l,r+=this._memory[o].score*l,o===this._front)break;o=(this._capacity+o-1)%this._capacity,n++}while(!0);return r<=.5}acceptStandardWheelEvent(t){if(Ch){let r=$i(t.browserEvent),n=E0(r);this.accept(Date.now(),t.deltaX*n,t.deltaY*n)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,r,n){let o=null,l=new mw(t,r,n);this._front===-1&&this._rear===-1?(this._memory[0]=l,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=l),l.score=this._computeScore(l,o)}_computeScore(t,r){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(n+=.25),r){let o=Math.abs(t.deltaX),l=Math.abs(t.deltaY),u=Math.abs(r.deltaX),f=Math.abs(r.deltaY),m=Math.max(Math.min(o,u),1),p=Math.max(Math.min(l,f),1),y=Math.max(o,u),S=Math.max(l,f);y%m===0&&S%p===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Fu.INSTANCE=new Fu;var gw=Fu,_w=class extends Nh{constructor(e,t,r){super(),this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new fe),this.onWillScroll=this._onWillScroll.event,this._options=yw(t),this._scrollable=r,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let n={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new fw(this._scrollable,this._options,n)),this._horizontalScrollbar=this._register(new dw(this._scrollable,this._options,n)),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=zn(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=zn(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=zn(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 kh),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Jr(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,Wi&&(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 Vp(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Jr(this._mouseWheelToDispose),e)){let t=r=>{this._onMouseWheel(new Vp(r))};this._mouseWheelToDispose.push(Pe(this._listenOnDomNode,yt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=gw.INSTANCE;t.acceptStandardWheelEvent(e);let r=!1;if(e.deltaY||e.deltaX){let l=e.deltaY*this._options.mouseWheelScrollSensitivity,u=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&u+l===0?u=l=0:Math.abs(l)>=Math.abs(u)?u=0:l=0),this._options.flipAxes&&([l,u]=[u,l]);let f=!Wi&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||f)&&!u&&(u=l,l=0),e.browserEvent&&e.browserEvent.altKey&&(u=u*this._options.fastScrollSensitivity,l=l*this._options.fastScrollSensitivity);let m=this._scrollable.getFutureScrollPosition(),p={};if(l){let y=em*l,S=m.scrollTop-(y<0?Math.floor(y):Math.ceil(y));this._verticalScrollbar.writeScrollPosition(p,S)}if(u){let y=em*u,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),r=!0)}let n=r;!n&&this._options.alwaysConsumeMouseWheel&&(n=!0),!n&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(n=!0),n&&(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,r=e.scrollLeft>0,n=r?" left":"",o=t?" top":"",l=r||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${n}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${l}${o}${n}`)}}_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(),pw)}},vw=class extends _w{constructor(e,t,r){super(e,t,r)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function yw(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,Wi&&(t.className+=" mac"),t}var Hu=class extends Le{constructor(e,t,r,n,o,l,u,f){super(),this._bufferService=r,this._optionsService=u,this._renderService=f,this._onRequestScrollLines=this._register(new fe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let m=this._register(new ow({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>Eh(n.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{m.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new vw(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(Rt.runAndSubscribe(l.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=l.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Ve(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=n.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Ve(()=>this._styleElement.remove())),this._register(Rt.runAndSubscribe(l.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${l.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${l.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${l.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
60
- `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(p=>this._handleScroll(p)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),r=t-this._bufferService.buffer.ydisp;r!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(r)),this._isHandlingScroll=!1}};Hu=tt([_e(2,Ot),_e(3,rr),_e(4,Zg),_e(5,As),_e(6,zt),_e(7,sr)],Hu);var $u=class extends Le{constructor(e,t,r,n,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=r,this._decorationService=n,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(l=>this._removeDecoration(l))),this._register(Ve(()=>{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 n;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((n=e==null?void 0:e.options)==null?void 0:n.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 r=e.options.x??0;return r&&r>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 r=this._decorationElements.get(e);r||(r=this._createElement(e),e.element=r,this._decorationElements.set(e,r),this._container.appendChild(r),e.onDispose(()=>{this._decorationElements.delete(e),r.remove()})),r.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(r.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,r.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,r.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,r.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(r)}}_refreshXPosition(e,t=e.element){if(!t)return;let r=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=r?`${r*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=r?`${r*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()}};$u=tt([_e(1,Ot),_e(2,rr),_e(3,Un),_e(4,sr)],$u);var Sw=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,r){return t>=e.startBufferLine-this._linePadding[r||"full"]&&t<=e.endBufferLine+this._linePadding[r||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Ii={full:0,left:0,center:0,right:0},kr={full:0,left:0,center:0,right:0},xn={full:0,left:0,center:0,right:0},Ca=class extends Le{constructor(e,t,r,n,o,l,u,f){var p;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=r,this._decorationService=n,this._renderService=o,this._optionsService=l,this._themeService=u,this._coreBrowserService=f,this._colorZoneStore=new Sw,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(Ve(()=>{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);kr.full=this._canvas.width,kr.left=e,kr.center=t,kr.right=e,this._refreshDrawHeightConstants(),xn.full=1,xn.left=1,xn.center=1+kr.left,xn.right=1+kr.left+kr.center}_refreshDrawHeightConstants(){Ii.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);Ii.left=t,Ii.center=t,Ii.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ii.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ii.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ii.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ii.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(xn[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ii[e.position||"full"]/2),kr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ii[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}))}};Ca=tt([_e(2,Ot),_e(3,Un),_e(4,sr),_e(5,zt),_e(6,As),_e(7,rr)],Ca);var oe;(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=""))(oe||(oe={}));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 S_;(e=>e.ST=`${oe.ESC}\\`)(S_||(S_={}));var Wu=class{constructor(e,t,r,n,o,l){this._textarea=e,this._compositionView=t,this._bufferService=r,this._optionsService=n,this._coreService=o,this._renderService=l,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let r;t.start+=this._dataAlreadySent.length,this._isComposing?r=this._textarea.value.substring(t.start,this._compositionPosition.start):r=this._textarea.value.substring(t.start),r.length>0&&this._coreService.triggerDataEvent(r,!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,r=t.replace(e,"");this._dataAlreadySent=r,t.length>e.length?this._coreService.triggerDataEvent(r,!0):t.length<e.length?this._coreService.triggerDataEvent(`${oe.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),r=this._renderService.dimensions.css.cell.height,n=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=n+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let l=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=n+"px",this._textarea.style.width=Math.max(l.width,1)+"px",this._textarea.style.height=Math.max(l.height,1)+"px",this._textarea.style.lineHeight=l.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Wu=tt([_e(2,Ot),_e(3,zt),_e(4,ts),_e(5,sr)],Wu);var St=0,wt=0,bt=0,et=0,tm={css:"#00000000",rgba:0},ct;(e=>{function t(o,l,u,f){return f!==void 0?`#${Vr(o)}${Vr(l)}${Vr(u)}${Vr(f)}`:`#${Vr(o)}${Vr(l)}${Vr(u)}`}e.toCss=t;function r(o,l,u,f=255){return(o<<24|l<<16|u<<8|f)>>>0}e.toRgba=r;function n(o,l,u,f){return{css:e.toCss(o,l,u,f),rgba:e.toRgba(o,l,u,f)}}e.toColor=n})(ct||(ct={}));var qe;(e=>{function t(m,p){if(et=(p.rgba&255)/255,et===1)return{css:p.css,rgba:p.rgba};let y=p.rgba>>24&255,S=p.rgba>>16&255,v=p.rgba>>8&255,_=m.rgba>>24&255,b=m.rgba>>16&255,x=m.rgba>>8&255;St=_+Math.round((y-_)*et),wt=b+Math.round((S-b)*et),bt=x+Math.round((v-x)*et);let E=ct.toCss(St,wt,bt),N=ct.toRgba(St,wt,bt);return{css:E,rgba:N}}e.blend=t;function r(m){return(m.rgba&255)===255}e.isOpaque=r;function n(m,p,y){let S=va.ensureContrastRatio(m.rgba,p.rgba,y);if(S)return ct.toColor(S>>24&255,S>>16&255,S>>8&255)}e.ensureContrastRatio=n;function o(m){let p=(m.rgba|255)>>>0;return[St,wt,bt]=va.toChannels(p),{css:ct.toCss(St,wt,bt),rgba:p}}e.opaque=o;function l(m,p){return et=Math.round(p*255),[St,wt,bt]=va.toChannels(m.rgba),{css:ct.toCss(St,wt,bt,et),rgba:ct.toRgba(St,wt,bt,et)}}e.opacity=l;function u(m,p){return et=m.rgba&255,l(m,et*p/255)}e.multiplyOpacity=u;function f(m){return[m.rgba>>24&255,m.rgba>>16&255,m.rgba>>8&255]}e.toColorRGB=f})(qe||(qe={}));var Qe;(e=>{let t,r;try{let o=document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d",{willReadFrequently:!0});l&&(t=l,t.globalCompositeOperation="copy",r=t.createLinearGradient(0,0,1,1))}catch{}function n(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return St=parseInt(o.slice(1,2).repeat(2),16),wt=parseInt(o.slice(2,3).repeat(2),16),bt=parseInt(o.slice(3,4).repeat(2),16),ct.toColor(St,wt,bt);case 5:return St=parseInt(o.slice(1,2).repeat(2),16),wt=parseInt(o.slice(2,3).repeat(2),16),bt=parseInt(o.slice(3,4).repeat(2),16),et=parseInt(o.slice(4,5).repeat(2),16),ct.toColor(St,wt,bt,et);case 7:return{css:o,rgba:(parseInt(o.slice(1),16)<<8|255)>>>0};case 9:return{css:o,rgba:parseInt(o.slice(1),16)>>>0}}let l=o.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(l)return St=parseInt(l[1]),wt=parseInt(l[2]),bt=parseInt(l[3]),et=Math.round((l[5]===void 0?1:parseFloat(l[5]))*255),ct.toColor(St,wt,bt,et);if(!t||!r)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=r,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[St,wt,bt,et]=t.getImageData(0,0,1,1).data,et!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ct.toRgba(St,wt,bt,et),css:o}}e.toColor=n})(Qe||(Qe={}));var It;(e=>{function t(n){return r(n>>16&255,n>>8&255,n&255)}e.relativeLuminance=t;function r(n,o,l){let u=n/255,f=o/255,m=l/255,p=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),y=f<=.03928?f/12.92:Math.pow((f+.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=r})(It||(It={}));var va;(e=>{function t(u,f){if(et=(f&255)/255,et===1)return f;let m=f>>24&255,p=f>>16&255,y=f>>8&255,S=u>>24&255,v=u>>16&255,_=u>>8&255;return St=S+Math.round((m-S)*et),wt=v+Math.round((p-v)*et),bt=_+Math.round((y-_)*et),ct.toRgba(St,wt,bt)}e.blend=t;function r(u,f,m){let p=It.relativeLuminance(u>>8),y=It.relativeLuminance(f>>8);if(tr(p,y)<m){if(y<p){let _=n(u,f,m),b=tr(p,It.relativeLuminance(_>>8));if(b<m){let x=o(u,f,m),E=tr(p,It.relativeLuminance(x>>8));return b>E?_:x}return _}let S=o(u,f,m),v=tr(p,It.relativeLuminance(S>>8));if(v<m){let _=n(u,f,m),b=tr(p,It.relativeLuminance(_>>8));return v>b?S:_}return S}}e.ensureContrastRatio=r;function n(u,f,m){let p=u>>24&255,y=u>>16&255,S=u>>8&255,v=f>>24&255,_=f>>16&255,b=f>>8&255,x=tr(It.relativeLuminance2(v,_,b),It.relativeLuminance2(p,y,S));for(;x<m&&(v>0||_>0||b>0);)v-=Math.max(0,Math.ceil(v*.1)),_-=Math.max(0,Math.ceil(_*.1)),b-=Math.max(0,Math.ceil(b*.1)),x=tr(It.relativeLuminance2(v,_,b),It.relativeLuminance2(p,y,S));return(v<<24|_<<16|b<<8|255)>>>0}e.reduceLuminance=n;function o(u,f,m){let p=u>>24&255,y=u>>16&255,S=u>>8&255,v=f>>24&255,_=f>>16&255,b=f>>8&255,x=tr(It.relativeLuminance2(v,_,b),It.relativeLuminance2(p,y,S));for(;x<m&&(v<255||_<255||b<255);)v=Math.min(255,v+Math.ceil((255-v)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),x=tr(It.relativeLuminance2(v,_,b),It.relativeLuminance2(p,y,S));return(v<<24|_<<16|b<<8|255)>>>0}e.increaseLuminance=o;function l(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=l})(va||(va={}));function Vr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function tr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var ww=class extends Wn{constructor(e,t,r){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=r}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},xa=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new _i}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 r=[],n=t.translateToString(!0),o=0,l=0,u=0,f=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!==f||this._workCell.bg!==m){if(p-o>1){let y=this._getJoinedRanges(n,u,l,t,o);for(let S=0;S<y.length;S++)r.push(y[S])}o=p,u=l,f=this._workCell.fg,m=this._workCell.bg}l+=this._workCell.getChars().length||Pr.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(n,u,l,t,o);for(let y=0;y<p.length;y++)r.push(p[y])}return r}_getJoinedRanges(e,t,r,n,o){let l=e.substring(t,r),u=[];try{u=this._characterJoiners[0].handler(l)}catch(f){console.error(f)}for(let f=1;f<this._characterJoiners.length;f++)try{let m=this._characterJoiners[f].handler(l);for(let p=0;p<m.length;p++)xa._mergeRanges(u,m[p])}catch(m){console.error(m)}return this._stringRangesToCellRanges(u,n,o),u}_stringRangesToCellRanges(e,t,r){let n=0,o=!1,l=0,u=e[n];if(u){for(let f=r;f<this._bufferService.cols;f++){let m=t.getWidth(f),p=t.getString(f).length||Pr.length;if(m!==0){if(!o&&u[0]<=l&&(u[0]=f,o=!0),u[1]<=l){if(u[1]=f,u=e[++n],!u)break;u[0]<=l?(u[0]=f,o=!0):o=!1}l+=p}}u&&(u[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let r=!1;for(let n=0;n<e.length;n++){let o=e[n];if(r){if(t[1]<=o[0])return e[n-1][1]=t[1],e;if(t[1]<=o[1])return e[n-1][1]=Math.max(t[1],o[1]),e.splice(n,1),e;e.splice(n,1),n--}else{if(t[1]<=o[0])return e.splice(n,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]),r=!0);continue}}return r?e[e.length-1][1]=t[1]:e.push(t),e}};xa=tt([_e(0,Ot)],xa);function bw(e){return 57508<=e&&e<=57558}function Cw(e){return 9472<=e&&e<=9631}function xw(e){return bw(e)||Cw(e)}function kw(){return{css:{canvas:aa(),cell:aa()},device:{canvas:aa(),cell:aa(),char:{width:0,height:0,left:0,top:0}}}}function aa(){return{width:0,height:0}}var Uu=class{constructor(e,t,r,n,o,l,u){this._document=e,this._characterJoinerService=t,this._optionsService=r,this._coreBrowserService=n,this._coreService=o,this._decorationService=l,this._themeService=u,this._workCell=new _i,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,r){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=r}createRow(e,t,r,n,o,l,u,f,m,p,y){let S=[],v=this._characterJoinerService.getJoinedCharacters(t),_=this._themeService.colors,b=e.getNoBgTrimmedLength();r&&b<l+1&&(b=l+1);let x,E=0,N="",$=0,z=0,j=0,U=0,O=!1,F=0,Z=!1,R=0,H=0,A=[],P=p!==-1&&y!==-1;for(let L=0;L<b;L++){e.loadCell(L,this._workCell);let T=this._workCell.getWidth();if(T===0)continue;let Y=!1,Q=L>=H,G=L,k=this._workCell;if(v.length>0&&L===v[0][0]&&Q){let Ce=v.shift(),it=this._isCellInSelection(Ce[0],t);for($=Ce[0]+1;$<Ce[1];$++)Q&&(Q=it===this._isCellInSelection($,t));Q&&(Q=!r||l<Ce[0]||l>=Ce[1]),Q?(Y=!0,k=new ww(this._workCell,e.translateToString(!0,Ce[0],Ce[1]),Ce[1]-Ce[0]),G=Ce[1]-1,T=k.getWidth()):H=Ce[1]}let V=this._isCellInSelection(L,t),re=r&&L===l,I=P&&L>=p&&L<=y,K=!1;this._decorationService.forEachDecorationAtCell(L,t,void 0,Ce=>{K=!0});let ne=k.getChars()||Pr;if(ne===" "&&(k.isUnderline()||k.isOverline())&&(ne=" "),R=T*f-m.get(ne,k.isBold(),k.isItalic()),!x)x=this._document.createElement("span");else if(E&&(V&&Z||!V&&!Z&&k.bg===z)&&(V&&Z&&_.selectionForeground||k.fg===j)&&k.extended.ext===U&&I===O&&R===F&&!re&&!Y&&!K&&Q){k.isInvisible()?N+=Pr:N+=ne,E++;continue}else E&&(x.textContent=N),x=this._document.createElement("span"),E=0,N="";if(z=k.bg,j=k.fg,U=k.extended.ext,O=I,F=R,Z=V,Y&&l>=L&&l<=G&&(l=L),!this._coreService.isCursorHidden&&re&&this._coreService.isCursorInitialized){if(A.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&A.push("xterm-cursor-blink"),A.push(n==="bar"?"xterm-cursor-bar":n==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":A.push("xterm-cursor-outline");break;case"block":A.push("xterm-cursor-block");break;case"bar":A.push("xterm-cursor-bar");break;case"underline":A.push("xterm-cursor-underline");break}}if(k.isBold()&&A.push("xterm-bold"),k.isItalic()&&A.push("xterm-italic"),k.isDim()&&A.push("xterm-dim"),k.isInvisible()?N=Pr:N=k.getChars()||Pr,k.isUnderline()&&(A.push(`xterm-underline-${k.extended.underlineStyle}`),N===" "&&(N=" "),!k.isUnderlineColorDefault()))if(k.isUnderlineColorRGB())x.style.textDecorationColor=`rgb(${Wn.toColorRGB(k.getUnderlineColor()).join(",")})`;else{let Ce=k.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&k.isBold()&&Ce<8&&(Ce+=8),x.style.textDecorationColor=_.ansi[Ce].css}k.isOverline()&&(A.push("xterm-overline"),N===" "&&(N=" ")),k.isStrikethrough()&&A.push("xterm-strikethrough"),I&&(x.style.textDecoration="underline");let B=k.getFgColor(),se=k.getFgColorMode(),ae=k.getBgColor(),me=k.getBgColorMode(),ue=!!k.isInverse();if(ue){let Ce=B;B=ae,ae=Ce;let it=se;se=me,me=it}let ee,ge,Ee=!1;this._decorationService.forEachDecorationAtCell(L,t,void 0,Ce=>{Ce.options.layer!=="top"&&Ee||(Ce.backgroundColorRGB&&(me=50331648,ae=Ce.backgroundColorRGB.rgba>>8&16777215,ee=Ce.backgroundColorRGB),Ce.foregroundColorRGB&&(se=50331648,B=Ce.foregroundColorRGB.rgba>>8&16777215,ge=Ce.foregroundColorRGB),Ee=Ce.options.layer==="top")}),!Ee&&V&&(ee=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,ae=ee.rgba>>8&16777215,me=50331648,Ee=!0,_.selectionForeground&&(se=50331648,B=_.selectionForeground.rgba>>8&16777215,ge=_.selectionForeground)),Ee&&A.push("xterm-decoration-top");let Be;switch(me){case 16777216:case 33554432:Be=_.ansi[ae],A.push(`xterm-bg-${ae}`);break;case 50331648:Be=ct.toColor(ae>>16,ae>>8&255,ae&255),this._addStyle(x,`background-color:#${im((ae>>>0).toString(16),"0",6)}`);break;case 0:default:ue?(Be=_.foreground,A.push("xterm-bg-257")):Be=_.background}switch(ee||k.isDim()&&(ee=qe.multiplyOpacity(Be,.5)),se){case 16777216:case 33554432:k.isBold()&&B<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(B+=8),this._applyMinimumContrast(x,Be,_.ansi[B],k,ee,void 0)||A.push(`xterm-fg-${B}`);break;case 50331648:let Ce=ct.toColor(B>>16&255,B>>8&255,B&255);this._applyMinimumContrast(x,Be,Ce,k,ee,ge)||this._addStyle(x,`color:#${im(B.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(x,Be,_.foreground,k,ee,ge)||ue&&A.push("xterm-fg-257")}A.length&&(x.className=A.join(" "),A.length=0),!re&&!Y&&!K&&Q?E++:x.textContent=N,R!==this.defaultSpacing&&(x.style.letterSpacing=`${R}px`),S.push(x),L=G}return x&&E&&(x.textContent=N),S}_applyMinimumContrast(e,t,r,n,o,l){if(this._optionsService.rawOptions.minimumContrastRatio===1||xw(n.getCode()))return!1;let u=this._getContrastCache(n),f;if(!o&&!l&&(f=u.getColor(t.rgba,r.rgba)),f===void 0){let m=this._optionsService.rawOptions.minimumContrastRatio/(n.isDim()?2:1);f=qe.ensureContrastRatio(o||t,l||r,m),u.setColor((o||t).rgba,(l||r).rgba,f??null)}return f?(this._addStyle(e,`color:${f.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 r=this._selectionStart,n=this._selectionEnd;return!r||!n?!1:this._columnSelectMode?r[0]<=n[0]?e>=r[0]&&t>=r[1]&&e<n[0]&&t<=n[1]:e<r[0]&&t>=r[1]&&e>=n[0]&&t<=n[1]:t>r[1]&&t<n[1]||r[1]===n[1]&&t===r[1]&&e>=r[0]&&e<n[0]||r[1]<n[1]&&t===n[1]&&e<n[0]||r[1]<n[1]&&t===r[1]&&e>=r[0]}};Uu=tt([_e(1,i_),_e(2,zt),_e(3,rr),_e(4,ts),_e(5,Un),_e(6,As)],Uu);function im(e,t,r){for(;e.length<r;)e=t+e;return e}var Ew=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 r=e.createElement("span");r.classList.add("xterm-char-measure-element");let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.style.fontWeight="bold",l.style.fontStyle="italic",this._measureElements=[r,n,o,l],this._container.appendChild(r),this._container.appendChild(n),this._container.appendChild(o),this._container.appendChild(l),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,r,n){e===this._font&&t===this._fontSize&&r===this._weight&&n===this._weightBold||(this._font=e,this._fontSize=t,this._weight=r,this._weightBold=n,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${r}`,this._measureElements[1].style.fontWeight=`${n}`,this._measureElements[2].style.fontWeight=`${r}`,this._measureElements[3].style.fontWeight=`${n}`,this.clear())}get(e,t,r){let n=0;if(!t&&!r&&e.length===1&&(n=e.charCodeAt(0))<256){if(this._flat[n]!==-9999)return this._flat[n];let u=this._measure(e,0);return u>0&&(this._flat[n]=u),u}let o=e;t&&(o+="B"),r&&(o+="I");let l=this._holey.get(o);if(l===void 0){let u=0;t&&(u|=1),r&&(u|=2),l=this._measure(e,u),l>0&&this._holey.set(o,l)}return l}_measure(e,t){let r=this._measureElements[t];return r.textContent=e.repeat(32),r.offsetWidth/32}},Nw=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,r,n=!1){if(this.selectionStart=t,this.selectionEnd=r,!t||!r||t[0]===r[0]&&t[1]===r[1]){this.clear();return}let o=e.buffers.active.ydisp,l=t[1]-o,u=r[1]-o,f=Math.max(l,0),m=Math.min(u,e.rows-1);if(f>=e.rows||m<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=n,this.viewportStartRow=l,this.viewportEndRow=u,this.viewportCappedStartRow=f,this.viewportCappedEndRow=m,this.startCol=t[0],this.endCol=r[0]}isCellSelected(e,t,r){return this.hasSelection?(r-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&r>=this.viewportCappedStartRow&&t<this.endCol&&r<=this.viewportCappedEndRow:t<this.startCol&&r>=this.viewportCappedStartRow&&t>=this.endCol&&r<=this.viewportCappedEndRow:r>this.viewportStartRow&&r<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&r===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportStartRow&&t>=this.startCol):!1}};function Rw(){return new Nw}var Ic="xterm-dom-renderer-owner-",pi="xterm-rows",la="xterm-fg-",rm="xterm-bg-",kn="xterm-focus",ca="xterm-selection",Pw=1,qu=class extends Le{constructor(e,t,r,n,o,l,u,f,m,p,y,S,v,_){super(),this._terminal=e,this._document=t,this._element=r,this._screenElement=n,this._viewportElement=o,this._helperContainer=l,this._linkifier2=u,this._charSizeService=m,this._optionsService=p,this._bufferService=y,this._coreService=S,this._coreBrowserService=v,this._themeService=_,this._terminalClass=Pw++,this._rowElements=[],this._selectionRenderModel=Rw(),this.onRequestRedraw=this._register(new fe).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(pi),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(ca),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=kw(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(b=>this._injectCss(b))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance(Uu,document),this._element.classList.add(Ic+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(b=>this._handleLinkHover(b))),this._register(this._linkifier2.onHideLinkUnderline(b=>this._handleLinkLeave(b))),this._register(Ve(()=>{this._element.classList.remove(Ic+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Ew(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 r of this._rowElements)r.style.width=`${this.dimensions.css.canvas.width}px`,r.style.height=`${this.dimensions.css.cell.height}px`,r.style.lineHeight=`${this.dimensions.css.cell.height}px`,r.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${pi} 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} .${pi} { 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} .${pi} .xterm-dim { color: ${qe.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 r=`blink_underline_${this._terminalClass}`,n=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${r} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${n} { 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} .${pi}.${kn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${pi}.${kn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${pi}.${kn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${pi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${pi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${pi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${pi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${pi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${ca} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${ca} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${ca} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[l,u]of e.ansi.entries())t+=`${this._terminalSelector} .${la}${l} { color: ${u.css}; }${this._terminalSelector} .${la}${l}.xterm-dim { color: ${qe.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${rm}${l} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${la}257 { color: ${qe.opaque(e.background).css}; }${this._terminalSelector} .${la}257.xterm-dim { color: ${qe.multiplyOpacity(qe.opaque(e.background),.5).css}; }${this._terminalSelector} .${rm}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 r=this._rowElements.length;r<=t;r++){let n=this._document.createElement("div");this._rowContainer.appendChild(n),this._rowElements.push(n)}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(kn),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(kn),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,r){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,r),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,r),!this._selectionRenderModel.hasSelection))return;let n=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,l=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,f=this._document.createDocumentFragment();if(r){let m=e[0]>t[0];f.appendChild(this._createSelectionElement(l,m?t[0]:e[0],m?e[0]:t[0],u-l+1))}else{let m=n===l?e[0]:0,p=l===o?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(l,m,p));let y=u-l-1;if(f.appendChild(this._createSelectionElement(l+1,0,this._bufferService.cols,y)),l!==u){let S=o===u?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(u,0,S))}}this._selectionContainer.appendChild(f)}_createSelectionElement(e,t,r,n=1){let o=this._document.createElement("div"),l=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(r-t);return l+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-l),o.style.height=`${n*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${l}px`,o.style.width=`${u}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let r=this._bufferService.buffer,n=r.ybase+r.y,o=Math.min(r.x,this._bufferService.cols-1),l=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=e;m<=t;m++){let p=m+r.ydisp,y=this._rowElements[m],S=r.lines.get(p);if(!y||!S)break;y.replaceChildren(...this._rowFactory.createRow(S,p,p===n,u,f,o,l,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ic}${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,r,n,o,l){r<0&&(e=0),n<0&&(t=0);let u=this._bufferService.rows-1;r=Math.max(Math.min(r,u),0),n=Math.max(Math.min(n,u),0),o=Math.min(o,this._bufferService.cols);let f=this._bufferService.buffer,m=f.ybase+f.y,p=Math.min(f.x,o-1),y=this._optionsService.rawOptions.cursorBlink,S=this._optionsService.rawOptions.cursorStyle,v=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=r;_<=n;++_){let b=_+f.ydisp,x=this._rowElements[_],E=f.lines.get(b);if(!x||!E)break;x.replaceChildren(...this._rowFactory.createRow(E,b,b===m,S,v,p,y,this.dimensions.css.cell.width,this._widthCache,l?_===r?e:0:-1,l?(_===n?t:o)-1:-1))}}};qu=tt([_e(7,Sh),_e(8,Ba),_e(9,zt),_e(10,Ot),_e(11,ts),_e(12,rr),_e(13,As)],qu);var Ku=class extends Le{constructor(e,t,r){super(),this._optionsService=r,this.width=0,this.height=0,this._onCharSizeChange=this._register(new fe),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Mw(this._optionsService))}catch{this._measureStrategy=this._register(new Dw(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())}};Ku=tt([_e(2,zt)],Ku);var w_=class extends Le{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)}},Dw=class extends w_{constructor(e,t,r){super(),this._document=e,this._parentElement=t,this._optionsService=r,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}},Mw=class extends w_{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}},Lw=class extends Le{constructor(e,t,r){super(),this._textarea=e,this._window=t,this.mainDocument=r,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Tw(this._window)),this._onDprChange=this._register(new fe),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new fe),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(n=>this._screenDprMonitor.setWindow(n))),this._register(Rt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Pe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Pe(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}},Tw=class extends Le{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ts),this._onDprChange=this._register(new fe),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Ve(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Pe(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)}},jw=class extends Le{constructor(){super(),this.linkProviders=[],this._register(Ve(()=>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 Rh(e,t,r){let n=r.getBoundingClientRect(),o=e.getComputedStyle(r),l=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-n.left-l,t.clientY-n.top-u]}function Bw(e,t,r,n,o,l,u,f,m){if(!l)return;let p=Rh(e,t,r);if(p)return p[0]=Math.ceil((p[0]+(m?u/2:0))/u),p[1]=Math.ceil(p[1]/f),p[0]=Math.min(Math.max(p[0],1),n+(m?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var Vu=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,r,n,o){return Bw(window,e,t,r,n,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let r=Rh(window,e,t);if(this._charSizeService.hasValidSize)return r[0]=Math.min(Math.max(r[0],0),this._renderService.dimensions.css.canvas.width-1),r[1]=Math.min(Math.max(r[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(r[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(r[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(r[0]),y:Math.floor(r[1])}}};Vu=tt([_e(0,sr),_e(1,Ba)],Vu);var Aw=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,r){this._rowCount=r,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},b_={};KS(b_,{getSafariVersion:()=>Ow,isChromeOS:()=>E_,isFirefox:()=>C_,isIpad:()=>zw,isIphone:()=>Fw,isLegacyEdge:()=>Iw,isLinux:()=>Ph,isMac:()=>ka,isNode:()=>Aa,isSafari:()=>x_,isWindows:()=>k_});var Aa=typeof process<"u"&&"title"in process,qn=Aa?"node":navigator.userAgent,Kn=Aa?"node":navigator.platform,C_=qn.includes("Firefox"),Iw=qn.includes("Edge"),x_=/^((?!chrome|android).)*safari/i.test(qn);function Ow(){if(!x_)return 0;let e=qn.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ka=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Kn),zw=Kn==="iPad",Fw=Kn==="iPhone",k_=["Windows","Win16","Win32","WinCE"].includes(Kn),Ph=Kn.indexOf("Linux")>=0,E_=/\bCrOS\b/.test(qn),N_=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,r=0,n=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),r=Math.max(t,r),o=e.timeRemaining(),r*1.5>o){n-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-t))}ms`),this._start();return}n=o}this.clear()}},Hw=class extends N_{_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())}}},$w=class extends N_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Ea=!Aa&&"requestIdleCallback"in window?$w:Hw,Ww=class{constructor(){this._queue=new Ea}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Yu=class extends Le{constructor(e,t,r,n,o,l,u,f,m){super(),this._rowCount=e,this._optionsService=r,this._charSizeService=n,this._coreService=o,this._coreBrowserService=f,this._renderer=this._register(new Ts),this._pausedResizeTask=new Ww,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 fe),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new fe),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new fe),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new fe),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Aw((p,y)=>this._renderRows(p,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Uw(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Ve(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>{var p;return(p=this._renderer.value)==null?void 0:p.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(l.onDecorationRegistered(()=>this._fullRefresh())),this._register(l.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.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 r=new e.IntersectionObserver(n=>this._handleIntersectionChange(n[n.length-1]),{threshold:0});r.observe(t),this._observerDisposable.value=Ve(()=>r.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,r=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let n=this._syncOutputHandler.flush();n&&(e=Math.min(e,n.start),t=Math.max(t,n.end)),r||(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 r;return(r=this._renderer.value)==null?void 0:r.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,r){var n;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=r,(n=this._renderer.value)==null||n.handleSelectionChanged(e,t,r)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Yu=tt([_e(2,zt),_e(3,Ba),_e(4,ts),_e(5,Un),_e(6,Ot),_e(7,rr),_e(8,As)],Yu);var Uw=class{constructor(e,t,r){this._coreBrowserService=e,this._coreService=t,this._onTimeout=r,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 qw(e,t,r,n){let o=r.buffer.x,l=r.buffer.y;if(!r.buffer.hasScrollback)return Yw(o,l,e,t,r,n)+Ia(l,t,r,n)+Xw(o,l,e,t,r,n);let u;if(l===t)return u=o>e?"D":"C",Hn(Math.abs(o-e),Fn(u,n));u=l>t?"D":"C";let f=Math.abs(l-t),m=Vw(l>t?e:o,r)+(f-1)*r.cols+1+Kw(l>t?o:e);return Hn(m,Fn(u,n))}function Kw(e,t){return e-1}function Vw(e,t){return t.cols-e}function Yw(e,t,r,n,o,l){return Ia(t,n,o,l).length===0?"":Hn(P_(e,t,e,t-Zr(t,o),!1,o).length,Fn("D",l))}function Ia(e,t,r,n){let o=e-Zr(e,r),l=t-Zr(t,r),u=Math.abs(o-l)-Gw(e,t,r);return Hn(u,Fn(R_(e,t),n))}function Xw(e,t,r,n,o,l){let u;Ia(t,n,o,l).length>0?u=n-Zr(n,o):u=t;let f=n,m=Qw(e,t,r,n,o,l);return Hn(P_(e,u,r,f,m==="C",o).length,Fn(m,l))}function Gw(e,t,r){var u;let n=0,o=e-Zr(e,r),l=t-Zr(t,r);for(let f=0;f<Math.abs(o-l);f++){let m=R_(e,t)==="A"?-1:1;(u=r.buffer.lines.get(o+m*f))!=null&&u.isWrapped&&n++}return n}function Zr(e,t){let r=0,n=t.buffer.lines.get(e),o=n==null?void 0:n.isWrapped;for(;o&&e>=0&&e<t.rows;)r++,n=t.buffer.lines.get(--e),o=n==null?void 0:n.isWrapped;return r}function Qw(e,t,r,n,o,l){let u;return Ia(r,n,o,l).length>0?u=n-Zr(n,o):u=t,e<r&&u<=n||e>=r&&u<n?"C":"D"}function R_(e,t){return e>t?"A":"B"}function P_(e,t,r,n,o,l){let u=e,f=t,m="";for(;(u!==r||f!==n)&&f>=0&&f<l.buffer.lines.length;)u+=o?1:-1,o&&u>l.cols-1?(m+=l.buffer.translateBufferLineToString(f,!1,e,u),u=0,e=0,f++):!o&&u<0&&(m+=l.buffer.translateBufferLineToString(f,!1,0,e+1),u=l.cols-1,e=u,f--);return m+l.buffer.translateBufferLineToString(f,!1,e,u)}function Fn(e,t){let r=t?"O":"[";return oe.ESC+r+e}function Hn(e,t){e=Math.floor(e);let r="";for(let n=0;n<e;n++)r+=t;return r}var Jw=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 sm(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 Oc=50,Zw=15,e1=50,t1=500,i1=" ",r1=new RegExp(i1,"g"),Xu=class extends Le{constructor(e,t,r,n,o,l,u,f,m){super(),this._element=e,this._screenElement=t,this._linkifier=r,this._bufferService=n,this._coreService=o,this._mouseService=l,this._optionsService=u,this._renderService=f,this._coreBrowserService=m,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new _i,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new fe),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new fe),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new fe),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new fe),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 Jw(this._bufferService),this._activeSelectionMode=0,this._register(Ve(()=>{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 r=this._bufferService.buffer,n=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],l=e[0]<t[0]?t[0]:e[0];for(let u=e[1];u<=t[1];u++){let f=r.translateBufferLineToString(u,!0,o,l);n.push(f)}}else{let o=e[1]===t[1]?t[0]:void 0;n.push(r.translateBufferLineToString(e[1],!0,e[0],o));for(let l=e[1]+1;l<=t[1]-1;l++){let u=r.lines.get(l),f=r.translateBufferLineToString(l,!0);u!=null&&u.isWrapped?n[n.length-1]+=f:n.push(f)}if(e[1]!==t[1]){let l=r.lines.get(t[1]),u=r.translateBufferLineToString(t[1],!0,0,t[0]);l&&l.isWrapped?n[n.length-1]+=u:n.push(u)}}return n.map(o=>o.replace(r1," ")).join(k_?`\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())),Ph&&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),r=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!r||!n||!t?!1:this._areCoordsInSelection(t,r,n)}isCellInSelection(e,t){let r=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!r||!n?!1:this._areCoordsInSelection([e,t],r,n)}_areCoordsInSelection(e,t,r){return e[1]>t[1]&&e[1]<r[1]||t[1]===r[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<r[0]||t[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||t[1]<r[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var o,l;let r=(l=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:l.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=sm(r,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let n=this._getMouseBufferCoords(e);return n?(this._selectWordAt(n,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=Rh(this._coreBrowserService.window,e,this._screenElement)[1],r=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=r?0:(t>r&&(t-=r),t=Math.min(Math.max(t,-Oc),Oc),t/=Oc,t/Math.abs(t)+Math.round(t*(Zw-1)))}shouldForceSelection(e){return ka?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(),e1)}_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&&!(ka&&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 r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){let n=r.lines.get(this._model.selectionEnd[1]);n&&n.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<t1&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&r[0]!==void 0&&r[1]!==void 0){let n=qw(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(n,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,r=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!r){this._oldHasSelection&&this._fireOnSelectionChange(e,t,r);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,r)}_fireOnSelectionChange(e,t,r){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=r,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let r=t;for(let n=0;t>=n;n++){let o=e.loadCell(n,this._workCell).getChars().length;this._workCell.getWidth()===0?r--:o>1&&t!==n&&(r+=o-1)}return r}setSelection(e,t,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=r,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,r=!0,n=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,l=o.lines.get(e[1]);if(!l)return;let u=o.translateBufferLineToString(e[1],!1),f=this._convertViewportColToCharacterIndex(l,e[0]),m=f,p=e[0]-f,y=0,S=0,v=0,_=0;if(u.charAt(f)===" "){for(;f>0&&u.charAt(f-1)===" ";)f--;for(;m<u.length&&u.charAt(m+1)===" ";)m++}else{let E=e[0],N=e[0];l.getWidth(E)===0&&(y++,E--),l.getWidth(N)===2&&(S++,N++);let $=l.getString(N).length;for($>1&&(_+=$-1,m+=$-1);E>0&&f>0&&!this._isCharWordSeparator(l.loadCell(E-1,this._workCell));){l.loadCell(E-1,this._workCell);let z=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,E--):z>1&&(v+=z-1,f-=z-1),f--,E--}for(;N<l.length&&m+1<u.length&&!this._isCharWordSeparator(l.loadCell(N+1,this._workCell));){l.loadCell(N+1,this._workCell);let z=this._workCell.getChars().length;this._workCell.getWidth()===2?(S++,N++):z>1&&(_+=z-1,m+=z-1),m++,N++}}m++;let b=f+p-y+v,x=Math.min(this._bufferService.cols,m-f+y+S-v-_);if(!(!t&&u.slice(f,m).trim()==="")){if(r&&b===0&&l.getCodePoint(0)!==32){let E=o.lines.get(e[1]-1);if(E&&l.isWrapped&&E.getCodePoint(this._bufferService.cols-1)!==32){let N=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(N){let $=this._bufferService.cols-N.start;b-=$,x+=$}}}if(n&&b+x===this._bufferService.cols&&l.getCodePoint(this._bufferService.cols-1)!==32){let E=o.lines.get(e[1]+1);if(E!=null&&E.isWrapped&&E.getCodePoint(0)!==32){let N=this._getWordAt([0,e[1]+1],!1,!1,!0);N&&(x+=N.length)}}return{start:b,length:x}}}_selectWordAt(e,t){let r=this._getWordAt(e,t);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let r=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,r]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),r={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=sm(r,this._bufferService.cols)}};Xu=tt([_e(3,Ot),_e(4,ts),_e(5,wh),_e(6,zt),_e(7,sr),_e(8,rr)],Xu);var nm=class{constructor(){this._data={}}set(e,t,r){this._data[e]||(this._data[e]={}),this._data[e][t]=r}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},om=class{constructor(){this._color=new nm,this._css=new nm}setCss(e,t,r){this._css.set(e,t,r)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,r){this._color.set(e,t,r)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},ft=Object.freeze((()=>{let e=[Qe.toColor("#2e3436"),Qe.toColor("#cc0000"),Qe.toColor("#4e9a06"),Qe.toColor("#c4a000"),Qe.toColor("#3465a4"),Qe.toColor("#75507b"),Qe.toColor("#06989a"),Qe.toColor("#d3d7cf"),Qe.toColor("#555753"),Qe.toColor("#ef2929"),Qe.toColor("#8ae234"),Qe.toColor("#fce94f"),Qe.toColor("#729fcf"),Qe.toColor("#ad7fa8"),Qe.toColor("#34e2e2"),Qe.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let r=0;r<216;r++){let n=t[r/36%6|0],o=t[r/6%6|0],l=t[r%6];e.push({css:ct.toCss(n,o,l),rgba:ct.toRgba(n,o,l)})}for(let r=0;r<24;r++){let n=8+r*10;e.push({css:ct.toCss(n,n,n),rgba:ct.toRgba(n,n,n)})}return e})()),Yr=Qe.toColor("#ffffff"),jn=Qe.toColor("#000000"),am=Qe.toColor("#ffffff"),lm=jn,En={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},s1=Yr,Gu=class extends Le{constructor(e){super(),this._optionsService=e,this._contrastCache=new om,this._halfContrastCache=new om,this._onChangeColors=this._register(new fe),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Yr,background:jn,cursor:am,cursorAccent:lm,selectionForeground:void 0,selectionBackgroundTransparent:En,selectionBackgroundOpaque:qe.blend(jn,En),selectionInactiveBackgroundTransparent:En,selectionInactiveBackgroundOpaque:qe.blend(jn,En),scrollbarSliderBackground:qe.opacity(Yr,.2),scrollbarSliderHoverBackground:qe.opacity(Yr,.4),scrollbarSliderActiveBackground:qe.opacity(Yr,.5),overviewRulerBorder:Yr,ansi:ft.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=Fe(e.foreground,Yr),t.background=Fe(e.background,jn),t.cursor=qe.blend(t.background,Fe(e.cursor,am)),t.cursorAccent=qe.blend(t.background,Fe(e.cursorAccent,lm)),t.selectionBackgroundTransparent=Fe(e.selectionBackground,En),t.selectionBackgroundOpaque=qe.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Fe(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=qe.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Fe(e.selectionForeground,tm):void 0,t.selectionForeground===tm&&(t.selectionForeground=void 0),qe.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=qe.opacity(t.selectionBackgroundTransparent,.3)),qe.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=qe.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Fe(e.scrollbarSliderBackground,qe.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Fe(e.scrollbarSliderHoverBackground,qe.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Fe(e.scrollbarSliderActiveBackground,qe.opacity(t.foreground,.5)),t.overviewRulerBorder=Fe(e.overviewRulerBorder,s1),t.ansi=ft.slice(),t.ansi[0]=Fe(e.black,ft[0]),t.ansi[1]=Fe(e.red,ft[1]),t.ansi[2]=Fe(e.green,ft[2]),t.ansi[3]=Fe(e.yellow,ft[3]),t.ansi[4]=Fe(e.blue,ft[4]),t.ansi[5]=Fe(e.magenta,ft[5]),t.ansi[6]=Fe(e.cyan,ft[6]),t.ansi[7]=Fe(e.white,ft[7]),t.ansi[8]=Fe(e.brightBlack,ft[8]),t.ansi[9]=Fe(e.brightRed,ft[9]),t.ansi[10]=Fe(e.brightGreen,ft[10]),t.ansi[11]=Fe(e.brightYellow,ft[11]),t.ansi[12]=Fe(e.brightBlue,ft[12]),t.ansi[13]=Fe(e.brightMagenta,ft[13]),t.ansi[14]=Fe(e.brightCyan,ft[14]),t.ansi[15]=Fe(e.brightWhite,ft[15]),e.extendedAnsi){let r=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let n=0;n<r;n++)t.ansi[n+16]=Fe(e.extendedAnsi[n],ft[n+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()}}};Gu=tt([_e(0,zt)],Gu);function Fe(e,t){if(e!==void 0)try{return Qe.toColor(e)}catch{}return t}var n1=class{constructor(...e){this._entries=new Map;for(let[t,r]of e)this.set(t,r)}set(e,t){let r=this._entries.get(e);return this._entries.set(e,t),r}forEach(e){for(let[t,r]of this._entries.entries())e(t,r)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},o1=class{constructor(){this._services=new n1,this._services.set(Sh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let r=ZS(e).sort((l,u)=>l.index-u.index),n=[];for(let l of r){let u=this._services.get(l.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${l.id._id}.`);n.push(u)}let o=r.length>0?r[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,...n)}},a1={trace:0,debug:1,info:2,warn:3,error:4,off:5},l1="xterm.js: ",Qu=class extends Le{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=a1[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,r){this._evalLazyOptionalParams(r),e.call(console,(this._optionsService.options.logger?"":l1)+t,...r)}trace(e,...t){var r;this._logLevel<=0&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var r;this._logLevel<=1&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var r;this._logLevel<=2&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var r;this._logLevel<=3&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var r;this._logLevel<=4&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Qu=tt([_e(0,zt)],Qu);var cm=class extends Le{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new fe),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new fe),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new fe),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 r=0;r<Math.min(e,this.length);r++)t[r]=this._array[this._getCyclicIndex(r)];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,...r){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let n=this._length-1;n>=e;n--)this._array[this._getCyclicIndex(n+r.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<r.length;n++)this._array[this._getCyclicIndex(e+n)]=r[n];if(r.length&&this.onInsertEmitter.fire({index:e,amount:r.length}),this._length+r.length>this._maxLength){let n=this._length+r.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=r.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,r){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(let o=t-1;o>=0;o--)this.set(e+o+r,this.get(e+o));let n=e+t+r-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<t;n++)this.set(e+n+r,this.get(e+n))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Me=3,lt=Object.freeze(new Wn),ua=0,zc=2,Bn=class D_{constructor(t,r,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Me);let o=r||_i.fromCharData([0,Xg,1,0]);for(let l=0;l<t;++l)this.setCell(l,o);this.length=t}get(t){let r=this._data[t*Me+0],n=r&2097151;return[this._data[t*Me+1],r&2097152?this._combined[t]:n?Rr(n):"",r>>22,r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n]}set(t,r){this._data[t*Me+1]=r[0],r[1].length>1?(this._combined[t]=r[1],this._data[t*Me+0]=t|2097152|r[2]<<22):this._data[t*Me+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(t){return this._data[t*Me+0]>>22}hasWidth(t){return this._data[t*Me+0]&12582912}getFg(t){return this._data[t*Me+1]}getBg(t){return this._data[t*Me+2]}hasContent(t){return this._data[t*Me+0]&4194303}getCodePoint(t){let r=this._data[t*Me+0];return r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r&2097151}isCombined(t){return this._data[t*Me+0]&2097152}getString(t){let r=this._data[t*Me+0];return r&2097152?this._combined[t]:r&2097151?Rr(r&2097151):""}isProtected(t){return this._data[t*Me+2]&536870912}loadCell(t,r){return ua=t*Me,r.content=this._data[ua+0],r.fg=this._data[ua+1],r.bg=this._data[ua+2],r.content&2097152&&(r.combinedData=this._combined[t]),r.bg&268435456&&(r.extended=this._extendedAttrs[t]),r}setCell(t,r){r.content&2097152&&(this._combined[t]=r.combinedData),r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*Me+0]=r.content,this._data[t*Me+1]=r.fg,this._data[t*Me+2]=r.bg}setCellFromCodepoint(t,r,n,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*Me+0]=r|n<<22,this._data[t*Me+1]=o.fg,this._data[t*Me+2]=o.bg}addCodepointToCell(t,r,n){let o=this._data[t*Me+0];o&2097152?this._combined[t]+=Rr(r):o&2097151?(this._combined[t]=Rr(o&2097151)+Rr(r),o&=-2097152,o|=2097152):o=r|1<<22,n&&(o&=-12582913,o|=n<<22),this._data[t*Me+0]=o}insertCells(t,r,n){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),r<this.length-t){let o=new _i;for(let l=this.length-t-r-1;l>=0;--l)this.setCell(t+r+l,this.loadCell(t+l,o));for(let l=0;l<r;++l)this.setCell(t+l,n)}else for(let o=t;o<this.length;++o)this.setCell(o,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(t,r,n){if(t%=this.length,r<this.length-t){let o=new _i;for(let l=0;l<this.length-t-r;++l)this.setCell(t+l,this.loadCell(t+r+l,o));for(let l=this.length-r;l<this.length;++l)this.setCell(l,n)}else for(let o=t;o<this.length;++o)this.setCell(o,n);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,n)}replaceCells(t,r,n,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,n),r<this.length&&this.getWidth(r-1)===2&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,n);t<r&&t<this.length;)this.isProtected(t)||this.setCell(t,n),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),r<this.length&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r,0,1,n);t<r&&t<this.length;)this.setCell(t++,n)}resize(t,r){if(t===this.length)return this._data.length*4*zc<this._data.buffer.byteLength;let n=t*Me;if(t>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let o=new Uint32Array(n);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,r)}else{this._data=this._data.subarray(0,n);let o=Object.keys(this._combined);for(let u=0;u<o.length;u++){let f=parseInt(o[u],10);f>=t&&delete this._combined[f]}let l=Object.keys(this._extendedAttrs);for(let u=0;u<l.length;u++){let f=parseInt(l[u],10);f>=t&&delete this._extendedAttrs[f]}}return this.length=t,n*4*zc<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*zc<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,r=!1){if(r){for(let n=0;n<this.length;++n)this.isProtected(n)||this.setCell(n,t);return}this._combined={},this._extendedAttrs={};for(let n=0;n<this.length;++n)this.setCell(n,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 r in t._combined)this._combined[r]=t._combined[r];this._extendedAttrs={};for(let r in t._extendedAttrs)this._extendedAttrs[r]=t._extendedAttrs[r];this.isWrapped=t.isWrapped}clone(){let t=new D_(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let r in this._combined)t._combined[r]=this._combined[r];for(let r in this._extendedAttrs)t._extendedAttrs[r]=this._extendedAttrs[r];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Me+0]&4194303)return t+(this._data[t*Me+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Me+0]&4194303||this._data[t*Me+2]&50331648)return t+(this._data[t*Me+0]>>22);return 0}copyCellsFrom(t,r,n,o,l){let u=t._data;if(l)for(let m=o-1;m>=0;m--){for(let p=0;p<Me;p++)this._data[(n+m)*Me+p]=u[(r+m)*Me+p];u[(r+m)*Me+2]&268435456&&(this._extendedAttrs[n+m]=t._extendedAttrs[r+m])}else for(let m=0;m<o;m++){for(let p=0;p<Me;p++)this._data[(n+m)*Me+p]=u[(r+m)*Me+p];u[(r+m)*Me+2]&268435456&&(this._extendedAttrs[n+m]=t._extendedAttrs[r+m])}let f=Object.keys(t._combined);for(let m=0;m<f.length;m++){let p=parseInt(f[m],10);p>=r&&(this._combined[p-r+n]=t._combined[p])}}translateToString(t,r,n,o){r=r??0,n=n??this.length,t&&(n=Math.min(n,this.getTrimmedLength())),o&&(o.length=0);let l="";for(;r<n;){let u=this._data[r*Me+0],f=u&2097151,m=u&2097152?this._combined[r]:f?Rr(f):Pr;if(l+=m,o)for(let p=0;p<m.length;++p)o.push(r);r+=u>>22||1}return o&&o.push(r),l}};function c1(e,t,r,n,o,l){let u=[];for(let f=0;f<e.length-1;f++){let m=f,p=e.get(++m);if(!p.isWrapped)continue;let y=[e.get(f)];for(;m<e.length&&p.isWrapped;)y.push(p),p=e.get(++m);if(!l&&n>=f&&n<m){f+=y.length-1;continue}let S=0,v=$n(y,S,t),_=1,b=0;for(;_<y.length;){let E=$n(y,_,t),N=E-b,$=r-v,z=Math.min(N,$);y[S].copyCellsFrom(y[_],b,v,z,!1),v+=z,v===r&&(S++,v=0),b+=z,b===E&&(_++,b=0),v===0&&S!==0&&y[S-1].getWidth(r-1)===2&&(y[S].copyCellsFrom(y[S-1],r-1,v++,1,!1),y[S-1].setCell(r-1,o))}y[S].replaceCells(v,r,o);let x=0;for(let E=y.length-1;E>0&&(E>S||y[E].getTrimmedLength()===0);E--)x++;x>0&&(u.push(f+y.length-x),u.push(x)),f+=y.length-1}return u}function u1(e,t){let r=[],n=0,o=t[n],l=0;for(let u=0;u<e.length;u++)if(o===u){let f=t[++n];e.onDeleteEmitter.fire({index:u-l,amount:f}),u+=f-1,l+=f,o=t[++n]}else r.push(u);return{layout:r,countRemoved:l}}function h1(e,t){let r=[];for(let n=0;n<t.length;n++)r.push(e.get(t[n]));for(let n=0;n<r.length;n++)e.set(n,r[n]);e.length=t.length}function d1(e,t,r){let n=[],o=e.map((m,p)=>$n(e,p,t)).reduce((m,p)=>m+p),l=0,u=0,f=0;for(;f<o;){if(o-f<r){n.push(o-f);break}l+=r;let m=$n(e,u,t);l>m&&(l-=m,u++);let p=e[u].getWidth(l-1)===2;p&&l--;let y=p?r-1:r;n.push(y),f+=y}return n}function $n(e,t,r){if(t===e.length-1)return e[t].getTrimmedLength();let n=!e[t].hasContent(r-1)&&e[t].getWidth(r-1)===1,o=e[t+1].getWidth(0)===2;return n&&o?r-1:r}var M_=class L_{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=L_._nextId++,this._onDispose=this.register(new fe),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Jr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};M_._nextId=1;var f1=M_,mt={},Xr=mt.B;mt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};mt.A={"#":"£"};mt.B=void 0;mt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};mt.C=mt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};mt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};mt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};mt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};mt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};mt.E=mt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};mt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};mt.H=mt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};mt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var um=4294967295,hm=class{constructor(e,t,r){this._hasScrollback=e,this._optionsService=t,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=lt.clone(),this.savedCharset=Xr,this.markers=[],this._nullCell=_i.fromCharData([0,Xg,1,0]),this._whitespaceCell=_i.fromCharData([0,Pr,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Ea,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new cm(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 ba),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 ba),this._whitespaceCell}getBlankLine(e,t){return new Bn(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>um?um:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=lt);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 cm(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let r=this.getNullCell(lt),n=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let u=0;u<this.lines.length;u++)n+=+this.lines.get(u).resize(e,r);let l=0;if(this._rows<t)for(let u=this._rows;u<t;u++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Bn(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+l+1?(this.ybase--,l++,this.ydisp>0&&this.ydisp--):this.lines.push(new Bn(e,r)));else for(let u=this._rows;u>t;u--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let u=this.lines.length-o;u>0&&(this.lines.trimStart(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),l&&(this.y+=l),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let l=0;l<this.lines.length;l++)n+=+this.lines.get(l).resize(e,r);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),n>.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 r=this._optionsService.rawOptions.reflowCursorLine,n=c1(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(lt),r);if(n.length>0){let o=u1(this.lines,n);h1(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,r){let n=this.getNullCell(lt),o=r;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Bn(e,n))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)}_reflowSmaller(e,t){let r=this._optionsService.rawOptions.reflowCursorLine,n=this.getNullCell(lt),o=[],l=0;for(let u=this.lines.length-1;u>=0;u--){let f=this.lines.get(u);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let m=[f];for(;f.isWrapped&&u>0;)f=this.lines.get(--u),m.unshift(f);if(!r){let z=this.ybase+this.y;if(z>=u&&z<u+m.length)continue}let p=m[m.length-1].getTrimmedLength(),y=d1(m,this._cols,e),S=y.length-m.length,v;this.ybase===0&&this.y!==this.lines.length-1?v=Math.max(0,this.y-this.lines.maxLength+S):v=Math.max(0,this.lines.length-this.lines.maxLength+S);let _=[];for(let z=0;z<S;z++){let j=this.getBlankLine(lt,!0);_.push(j)}_.length>0&&(o.push({start:u+m.length+l,newLines:_}),l+=_.length),m.push(..._);let b=y.length-1,x=y[b];x===0&&(b--,x=y[b]);let E=m.length-S-1,N=p;for(;E>=0;){let z=Math.min(N,x);if(m[b]===void 0)break;if(m[b].copyCellsFrom(m[E],N-z,x-z,z,!0),x-=z,x===0&&(b--,x=y[b]),N-=z,N===0){E--;let j=Math.max(E,0);N=$n(m,j,this._cols)}}for(let z=0;z<m.length;z++)y[z]<e&&m[z].setCell(y[z],n);let $=S-v;for(;$-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+l)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+S,this.ybase+t-1)}if(o.length>0){let u=[],f=[];for(let x=0;x<this.lines.length;x++)f.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+l);let v=0;for(let x=Math.min(this.lines.maxLength-1,m+l-1);x>=0;x--)if(S&&S.start>p+v){for(let E=S.newLines.length-1;E>=0;E--)this.lines.set(x--,S.newLines[E]);x++,u.push({index:p+1,amount:S.newLines.length}),v+=S.newLines.length,S=o[++y]}else this.lines.set(x,f[p--]);let _=0;for(let x=u.length-1;x>=0;x--)u[x].index+=_,this.lines.onInsertEmitter.fire(u[x]),_+=u[x].amount;let b=Math.max(0,m+l-this.lines.maxLength);b>0&&this.lines.onTrimEmitter.fire(b)}}translateBufferLineToString(e,t,r=0,n){let o=this.lines.get(e);return o?o.translateToString(t,r,n):""}getWrappedRangeForLine(e){let t=e,r=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:t,last:r}}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 f1(e);return this.markers.push(t),t.register(this.lines.onTrim(r=>{t.line-=r,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(r=>{t.line>=r.index&&(t.line+=r.amount)})),t.register(this.lines.onDelete(r=>{t.line>=r.index&&t.line<r.index+r.amount&&t.dispose(),t.line>r.index&&(t.line-=r.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},p1=class extends Le{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new fe),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 hm(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new hm(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},T_=2,j_=1,Ju=class extends Le{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new fe),this.onResize=this._onResize.event,this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,T_),this.rows=Math.max(e.rawOptions.rows||0,j_),this.buffers=this._register(new p1(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let r=this.cols!==e,n=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:r,rowsChanged:n})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let r=this.buffer,n;n=this._cachedBlankLine,(!n||n.length!==this.cols||n.getFg(0)!==e.fg||n.getBg(0)!==e.bg)&&(n=r.getBlankLine(e,t),this._cachedBlankLine=n),n.isWrapped=t;let o=r.ybase+r.scrollTop,l=r.ybase+r.scrollBottom;if(r.scrollTop===0){let u=r.lines.isFull;l===r.lines.length-1?u?r.lines.recycle().copyFrom(n):r.lines.push(n.clone()):r.lines.splice(l+1,0,n.clone()),u?this.isUserScrolling&&(r.ydisp=Math.max(r.ydisp-1,0)):(r.ybase++,this.isUserScrolling||r.ydisp++)}else{let u=l-o+1;r.lines.shiftElements(o+1,u-1,-1),r.lines.set(l,n.clone())}this.isUserScrolling||(r.ydisp=r.ybase),this._onScroll.fire(r.ydisp)}scrollLines(e,t){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let n=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),n!==r.ydisp&&(t||this._onScroll.fire(r.ydisp))}};Ju=tt([_e(0,zt)],Ju);var Ps={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:ka,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},m1=["normal","bold","100","200","300","400","500","600","700","800","900"],g1=class extends Le{constructor(e){super(),this._onOptionChange=this._register(new fe),this.onOptionChange=this._onOptionChange.event;let t={...Ps};for(let r in e)if(r in t)try{let n=e[r];t[r]=this._sanitizeAndValidateOption(r,n)}catch(n){console.error(n)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Ve(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(r=>{r===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(r=>{e.indexOf(r)!==-1&&t()})}_setupOptions(){let e=r=>{if(!(r in Ps))throw new Error(`No option with key "${r}"`);return this.rawOptions[r]},t=(r,n)=>{if(!(r in Ps))throw new Error(`No option with key "${r}"`);n=this._sanitizeAndValidateOption(r,n),this.rawOptions[r]!==n&&(this.rawOptions[r]=n,this._onOptionChange.fire(r))};for(let r in this.rawOptions){let n={get:e.bind(this,r),set:t.bind(this,r)};Object.defineProperty(this.options,r,n)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Ps[e]),!_1(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Ps[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=m1.includes(t)?t:Ps[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 _1(e){return e==="block"||e==="underline"||e==="bar"}function An(e,t=5){if(typeof e!="object")return e;let r=Array.isArray(e)?[]:{};for(let n in e)r[n]=t<=1?e[n]:e[n]&&An(e[n],t-1);return r}var dm=Object.freeze({insertMode:!1}),fm=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Zu=class extends Le{constructor(e,t,r){super(),this._bufferService=e,this._logService=t,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new fe),this.onData=this._onData.event,this._onUserInput=this._register(new fe),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new fe),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new fe),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=An(dm),this.decPrivateModes=An(fm)}reset(){this.modes=An(dm),this.decPrivateModes=An(fm)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(n=>n.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))}};Zu=tt([_e(0,Ot),_e(1,e_),_e(2,zt)],Zu);var pm={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 Fc(e,t){let r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(r|=64,r|=e.action):(r|=e.button&3,e.button&4&&(r|=64),e.button&8&&(r|=128),e.action===32?r|=32:e.action===0&&!t&&(r|=3)),r}var Hc=String.fromCharCode,mm={DEFAULT:e=>{let t=[Fc(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Hc(t[0])}${Hc(t[1])}${Hc(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Fc(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Fc(e,!0)};${e.x};${e.y}${t}`}},eh=class extends Le{constructor(e,t,r){super(),this._bufferService=e,this._coreService=t,this._optionsService=r,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new fe),this.onProtocolChange=this._onProtocolChange.event;for(let n of Object.keys(pm))this.addProtocol(n,pm[n]);for(let n of Object.keys(mm))this.addEncoding(n,mm[n]);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,r){if(e.deltaY===0||e.shiftKey||t===void 0||r===void 0)return 0;let n=t/r,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=n+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,r){if(r){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)}};eh=tt([_e(0,Ot),_e(1,ts),_e(2,zt)],eh);var $c=[[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]],v1=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],pt;function y1(e,t){let r=0,n=t.length-1,o;if(e<t[0][0]||e>t[n][1])return!1;for(;n>=r;)if(o=r+n>>1,e>t[o][1])r=o+1;else if(e<t[o][0])n=o-1;else return!0;return!1}var S1=class{constructor(){if(this.version="6",!pt){pt=new Uint8Array(65536),pt.fill(1),pt[0]=0,pt.fill(0,1,32),pt.fill(0,127,160),pt.fill(2,4352,4448),pt[9001]=2,pt[9002]=2,pt.fill(2,11904,42192),pt[12351]=1,pt.fill(2,44032,55204),pt.fill(2,63744,64256),pt.fill(2,65040,65050),pt.fill(2,65072,65136),pt.fill(2,65280,65377),pt.fill(2,65504,65511);for(let e=0;e<$c.length;++e)pt.fill(0,$c[e][0],$c[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?pt[e]:y1(e,v1)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let r=this.wcwidth(e),n=r===0&&t!==0;if(n){let o=Gr.extractWidth(t);o===0?n=!1:o>r&&(r=o)}return Gr.createPropertyValue(0,r,n)}},Gr=class ya{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new fe,this.onChange=this._onChange.event;let t=new S1;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,r,n=!1){return(t&16777215)<<3|(r&3)<<1|(n?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 r=0,n=0,o=t.length;for(let l=0;l<o;++l){let u=t.charCodeAt(l);if(55296<=u&&u<=56319){if(++l>=o)return r+this.wcwidth(u);let p=t.charCodeAt(l);56320<=p&&p<=57343?u=(u-55296)*1024+p-56320+65536:r+=this.wcwidth(p)}let f=this.charProperties(u,n),m=ya.extractWidth(f);ya.extractShouldJoin(f)&&(m-=ya.extractWidth(n)),r+=m,n=f}return r}charProperties(t,r){return this._activeProvider.charProperties(t,r)}},w1=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 gm(e){var n;let t=(n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:n.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&t&&(r.isWrapped=t[3]!==0&&t[3]!==32)}var Nn=2147483647,b1=256,B_=class th{constructor(t=32,r=32){if(this.maxLength=t,this.maxSubParamsLength=r,r>b1)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let r=new th;if(!t.length)return r;for(let n=Array.isArray(t[0])?1:0;n<t.length;++n){let o=t[n];if(Array.isArray(o))for(let l=0;l<o.length;++l)r.addSubParam(o[l]);else r.addParam(o)}return r}clone(){let t=new th(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 r=0;r<this.length;++r){t.push(this.params[r]);let n=this._subParamsIdx[r]>>8,o=this._subParamsIdx[r]&255;o-n>0&&t.push(Array.prototype.slice.call(this._subParams,n,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>Nn?Nn: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>Nn?Nn:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let r=this._subParamsIdx[t]>>8,n=this._subParamsIdx[t]&255;return n-r>0?this._subParams.subarray(r,n):null}getSubParamsAll(){let t={};for(let r=0;r<this.length;++r){let n=this._subParamsIdx[r]>>8,o=this._subParamsIdx[r]&255;o-n>0&&(t[r]=this._subParams.slice(n,o))}return t}addDigit(t){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,o=n[r-1];n[r-1]=~o?Math.min(o*10+t,Nn):t}},Rn=[],C1=class{constructor(){this._state=0,this._active=Rn,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 r=this._handlers[e];return r.push(t),{dispose:()=>{let n=r.indexOf(t);n!==-1&&r.splice(n,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=Rn}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=Rn,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Rn,!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,r){if(!this._active.length)this._handlerFb(this._id,"PUT",ja(e,t,r));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,r)}start(){this.reset(),this._state=1}put(e,t,r){if(this._state!==3){if(this._state===1)for(;t<r;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&r-t>0&&this._put(e,t,r)}}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 r=!1,n=this._active.length-1,o=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,r=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&r===!1){for(;n>=0&&(r=this._active[n].end(e),r!==!0);n--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,r;n--}for(;n>=0;n--)if(r=this._active[n].end(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,r}this._active=Rn,this._id=-1,this._state=0}}},ri=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=ja(e,t,r),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(r=>(this._data="",this._hitLimit=!1,r));return this._data="",this._hitLimit=!1,t}},Pn=[],x1=class{constructor(){this._handlers=Object.create(null),this._active=Pn,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Pn}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(t),{dispose:()=>{let n=r.indexOf(t);n!==-1&&r.splice(n,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=Pn,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Pn,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let r=this._active.length-1;r>=0;r--)this._active[r].hook(t)}put(e,t,r){if(!this._active.length)this._handlerFb(this._ident,"PUT",ja(e,t,r));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,r)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let r=!1,n=this._active.length-1,o=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,r=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&r===!1){for(;n>=0&&(r=this._active[n].unhook(e),r!==!0);n--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,r;n--}for(;n>=0;n--)if(r=this._active[n].unhook(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,r}this._active=Pn,this._ident=0}},In=new B_;In.addParam(0);var _m=class{constructor(e){this._handler=e,this._data="",this._params=In,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():In,this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=ja(e,t,r),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(r=>(this._params=In,this._data="",this._hitLimit=!1,r));return this._params=In,this._data="",this._hitLimit=!1,t}},k1=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,r,n){this.table[t<<8|e]=r<<4|n}addMany(e,t,r,n){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=r<<4|n}},gi=160,E1=(function(){let e=new k1(4095),t=Array.apply(null,Array(256)).map((f,m)=>m),r=(f,m)=>t.slice(f,m),n=r(32,127),o=r(0,24);o.push(25),o.push.apply(o,r(28,32));let l=r(0,14),u;e.setDefault(1,0),e.addMany(n,0,2,0);for(u in l)e.addMany([24,26,153,154],u,3,0),e.addMany(r(128,144),u,3,0),e.addMany(r(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(n,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(n,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(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(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(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(n,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(gi,0,2,0),e.add(gi,8,5,8),e.add(gi,6,0,6),e.add(gi,11,0,11),e.add(gi,13,13,13),e})(),N1=class extends Le{constructor(e=E1){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new B_,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,r,n)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,r)=>{},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(Ve(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new C1),this._dcsParser=this._register(new x1),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let r=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(r=e.prefix.charCodeAt(0),r&&60>r||r>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let l=e.intermediates.charCodeAt(o);if(32>l||l>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=l}}if(e.final.length!==1)throw new Error("final must be a single byte");let n=e.final.charCodeAt(0);if(t[0]>n||n>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return r<<=8,r|=n,r}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 r=this._identifier(e,[48,126]);this._escHandlers[r]===void 0&&(this._escHandlers[r]=[]);let n=this._escHandlers[r];return n.push(t),{dispose:()=>{let o=n.indexOf(t);o!==-1&&n.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 r=this._identifier(e);this._csiHandlers[r]===void 0&&(this._csiHandlers[r]=[]);let n=this._csiHandlers[r];return n.push(t),{dispose:()=>{let o=n.indexOf(t);o!==-1&&n.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,r,n,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=r,this._parseStack.transition=n,this._parseStack.chunkPos=o}parse(e,t,r){let n=0,o=0,l=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,l=this._parseStack.chunkPos+1;else{if(r===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,m=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(r===!1&&m>-1){for(;m>=0&&(u=f[m](this._params),u!==!0);m--)if(u instanceof Promise)return this._parseStack.handlerPos=m,u}this._parseStack.handlers=[];break;case 4:if(r===!1&&m>-1){for(;m>=0&&(u=f[m](),u!==!0);m--)if(u instanceof Promise)return this._parseStack.handlerPos=m,u}this._parseStack.handlers=[];break;case 6:if(n=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(n!==24&&n!==26,r),u)return u;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(n=e[this._parseStack.chunkPos],u=this._oscParser.end(n!==24&&n!==26,r),u)return u;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,l=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let f=l;f<t;++f){switch(n=e[f],o=this._transitions.table[this.currentState<<8|(n<160?n:gi)],o>>4){case 2:for(let v=f+1;;++v){if(v>=t||(n=e[v])<32||n>126&&n<gi){this._printHandler(e,f,v),f=v-1;break}if(++v>=t||(n=e[v])<32||n>126&&n<gi){this._printHandler(e,f,v),f=v-1;break}if(++v>=t||(n=e[v])<32||n>126&&n<gi){this._printHandler(e,f,v),f=v-1;break}if(++v>=t||(n=e[v])<32||n>126&&n<gi){this._printHandler(e,f,v),f=v-1;break}}break;case 3:this._executeHandlers[n]?this._executeHandlers[n]():this._executeHandlerFb(n),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:f,code:n,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let m=this._csiHandlers[this._collect<<8|n],p=m?m.length-1:-1;for(;p>=0&&(u=m[p](this._params),u!==!0);p--)if(u instanceof Promise)return this._preserveStack(3,m,p,o,f),u;p<0&&this._csiHandlerFb(this._collect<<8|n,this._params),this.precedingJoinState=0;break;case 8:do switch(n){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(n-48)}while(++f<t&&(n=e[f])>47&&n<60);f--;break;case 9:this._collect<<=8,this._collect|=n;break;case 10:let y=this._escHandlers[this._collect<<8|n],S=y?y.length-1:-1;for(;S>=0&&(u=y[S](),u!==!0);S--)if(u instanceof Promise)return this._preserveStack(4,y,S,o,f),u;S<0&&this._escHandlerFb(this._collect<<8|n),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|n,this._params);break;case 13:for(let v=f+1;;++v)if(v>=t||(n=e[v])===24||n===26||n===27||n>127&&n<gi){this._dcsParser.put(e,f,v),f=v-1;break}break;case 14:if(u=this._dcsParser.unhook(n!==24&&n!==26),u)return this._preserveStack(6,[],0,o,f),u;n===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 v=f+1;;v++)if(v>=t||(n=e[v])<32||n>127&&n<gi){this._oscParser.put(e,f,v),f=v-1;break}break;case 6:if(u=this._oscParser.end(n!==24&&n!==26),u)return this._preserveStack(5,[],0,o,f),u;n===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},R1=/^([\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})$/,P1=/^[\da-f]+$/;function vm(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let r=R1.exec(t);if(r){let n=r[1]?15:r[4]?255:r[7]?4095:65535;return[Math.round(parseInt(r[1]||r[4]||r[7]||r[10],16)/n*255),Math.round(parseInt(r[2]||r[5]||r[8]||r[11],16)/n*255),Math.round(parseInt(r[3]||r[6]||r[9]||r[12],16)/n*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),P1.exec(t)&&[3,6,9,12].includes(t.length))){let r=t.length/3,n=[0,0,0];for(let o=0;o<3;++o){let l=parseInt(t.slice(r*o,r*o+r),16);n[o]=r===1?l<<4:r===2?l:r===3?l>>4:l>>8}return n}}function Wc(e,t){let r=e.toString(16),n=r.length<2?"0"+r:r;switch(t){case 4:return r[0];case 8:return n;case 12:return(n+n).slice(0,3);default:return n+n}}function D1(e,t=16){let[r,n,o]=e;return`rgb:${Wc(r,t)}/${Wc(n,t)}/${Wc(o,t)}`}var M1={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Er=131072,ym=10;function Sm(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 wm=5e3,bm=0,L1=class extends Le{constructor(e,t,r,n,o,l,u,f,m=new N1){super(),this._bufferService=e,this._charsetService=t,this._coreService=r,this._logService=n,this._optionsService=o,this._oscLinkService=l,this._coreMouseService=u,this._unicodeService=f,this._parser=m,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new QS,this._utf8Decoder=new JS,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=lt.clone(),this._eraseAttrDataInternal=lt.clone(),this._onRequestBell=this._register(new fe),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new fe),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new fe),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new fe),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new fe),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new fe),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new fe),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new fe),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new fe),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new fe),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new fe),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new fe),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 ih(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(oe.BEL,()=>this.bell()),this._parser.setExecuteHandler(oe.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(oe.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(oe.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(oe.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(oe.BS,()=>this.backspace()),this._parser.setExecuteHandler(oe.HT,()=>this.tab()),this._parser.setExecuteHandler(oe.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(oe.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 ri(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new ri(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new ri(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new ri(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new ri(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new ri(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new ri(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new ri(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new ri(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new ri(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new ri(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new ri(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 mt)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 _m((p,y)=>this.requestStatusString(p,y)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,r,n){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=r,this._parseStack.position=n}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),wm))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${wm} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let r,n=this._activeBuffer.x,o=this._activeBuffer.y,l=0,u=this._parseStack.paused;if(u){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(r),r;n=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Er&&(l=this._parseStack.position+Er)}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<Er&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Er))),u||this._dirtyRowTracker.clearRange(),e.length>Er)for(let p=l;p<e.length;p+=Er){let y=p+Er<e.length?p+Er: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(r=this._parser.parse(this._parseBuffer,S))return this._preserveStack(n,o,S,p),this._logSlowResolvingAsync(r),r}else if(!u){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,p))return this._preserveStack(n,o,p,0),this._logSlowResolvingAsync(r),r}(this._activeBuffer.x!==n||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let f=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(f,this._bufferService.rows-1)})}print(e,t,r){let n,o,l=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,f=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&&r-t>0&&S.getWidth(this._activeBuffer.x-1)===2&&S.setCellFromCodepoint(this._activeBuffer.x-1,0,1,y);let v=this._parser.precedingJoinState;for(let _=t;_<r;++_){if(n=e[_],n<127&&l){let N=l[String.fromCharCode(n)];N&&(n=N.charCodeAt(0))}let b=this._unicodeService.charProperties(n,v);o=Gr.extractWidth(b);let x=Gr.extractShouldJoin(b),E=x?Gr.extractWidth(v):0;if(v=b,u&&this._onA11yChar.fire(Rr(n)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-E>f){if(m){let N=S,$=this._activeBuffer.x-E;for(this._activeBuffer.x=E,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),E>0&&S instanceof Bn&&S.copyCellsFrom(N,$,0,E,!1);$<f;)N.setCellFromCodepoint($++,0,1,y)}else if(this._activeBuffer.x=f-1,o===2)continue}if(x&&this._activeBuffer.x){let N=S.getWidth(this._activeBuffer.x-1)?1:2;S.addCodepointToCell(this._activeBuffer.x-N,n,o);for(let $=o-E;--$>=0;)S.setCellFromCodepoint(this._activeBuffer.x++,0,0,y);continue}if(p&&(S.insertCells(this._activeBuffer.x,o-E,this._activeBuffer.getNullCell(y)),S.getWidth(f-1)===2&&S.setCellFromCodepoint(f-1,0,1,y)),S.setCellFromCodepoint(this._activeBuffer.x++,n,o,y),o>0)for(;--o;)S.setCellFromCodepoint(this._activeBuffer.x++,0,0,y)}this._parser.precedingJoinState=v,this._activeBuffer.x<f&&r-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,r=>Sm(r.params[0],this._optionsService.rawOptions.windowOptions)?t(r):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new _m(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new ri(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,r,n=!1,o=!1){let l=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);l.replaceCells(t,r,this._activeBuffer.getNullCell(this._eraseAttrData()),o),n&&(l.isWrapped=!1)}_resetBufferLine(e,t=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r&&(r.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),r.isWrapped=!1)}eraseInDisplay(e,t=!1){var n;this._restrictCursor(this._bufferService.cols);let r;switch(e.params[0]){case 0:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);r<this._bufferService.rows;r++)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(r);break;case 1:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(r+1).isWrapped=!1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(r=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,r-1);r--&&!((n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r))!=null&&n.getTrimmedLength()););for(;r>=0;r--)this._bufferService.scroll(this._eraseAttrData())}else{for(r=this._bufferService.rows,this._dirtyRowTracker.markDirty(r-1);r--;)this._resetBufferLine(r,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 r=this._activeBuffer.ybase+this._activeBuffer.y,n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-n+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(r,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 r=this._activeBuffer.ybase+this._activeBuffer.y,n;for(n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-n;t--;)this._activeBuffer.lines.splice(r,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}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(lt));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 r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.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 r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.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 r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.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 r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.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 r=e.params[0]||1,n=Gr.extractWidth(t),o=this._activeBuffer.x-n,l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(l.length*r),f=0;for(let p=0;p<l.length;){let y=l.codePointAt(p)||0;u[f++]=y,p+=y>65535?2:1}let m=f;for(let p=1;p<r;++p)u.copyWithin(m,0,f),m+=f;return this.print(u,0,m),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(oe.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(oe.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(oe.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(oe.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(oe.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,Xr),this._charsetService.setgCharset(1,Xr),this._charsetService.setgCharset(2,Xr),this._charsetService.setgCharset(3,Xr);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||(r={}));let n=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:l}=this._coreMouseService,u=this._coreService,{buffers:f,cols:m}=this._bufferService,{active:p,alt:y}=f,S=this._optionsService.rawOptions,v=(x,E)=>(u.triggerDataEvent(`${oe.ESC}[${t?"":"?"}${x};${E}$y`),!0),_=x=>x?1:2,b=e.params[0];return t?b===2?v(b,4):b===4?v(b,_(u.modes.insertMode)):b===12?v(b,3):b===20?v(b,_(S.convertEol)):v(b,0):b===1?v(b,_(n.applicationCursorKeys)):b===3?v(b,S.windowOptions.setWinLines?m===80?2:m===132?1:0:0):b===6?v(b,_(n.origin)):b===7?v(b,_(n.wraparound)):b===8?v(b,3):b===9?v(b,_(o==="X10")):b===12?v(b,_(S.cursorBlink)):b===25?v(b,_(!u.isCursorHidden)):b===45?v(b,_(n.reverseWraparound)):b===66?v(b,_(n.applicationKeypad)):b===67?v(b,4):b===1e3?v(b,_(o==="VT200")):b===1002?v(b,_(o==="DRAG")):b===1003?v(b,_(o==="ANY")):b===1004?v(b,_(n.sendFocus)):b===1005?v(b,4):b===1006?v(b,_(l==="SGR")):b===1015?v(b,4):b===1016?v(b,_(l==="SGR_PIXELS")):b===1048?v(b,1):b===47||b===1047||b===1049?v(b,_(p===y)):b===2004?v(b,_(n.bracketedPasteMode)):b===2026?v(b,_(n.synchronizedOutput)):v(b,0)}_updateAttrColor(e,t,r,n,o){return t===2?(e|=50331648,e&=-16777216,e|=Wn.fromColorRGB([r,n,o])):t===5&&(e&=-50331904,e|=33554432|r&255),e}_extractColor(e,t,r){let n=[0,0,-1,0,0,0],o=0,l=0;do{if(n[l+o]=e.params[t+l],e.hasSubParams(t+l)){let u=e.getSubParams(t+l),f=0;do n[1]===5&&(o=1),n[l+f+1+o]=u[f];while(++f<u.length&&f+l+1+o<n.length);break}if(n[1]===5&&l+o>=2||n[1]===2&&l+o>=5)break;n[1]&&(o=1)}while(++l+t<e.length&&l+o<n.length);for(let u=2;u<n.length;++u)n[u]===-1&&(n[u]=0);switch(n[0]){case 38:r.fg=this._updateAttrColor(r.fg,n[1],n[3],n[4],n[5]);break;case 48:r.bg=this._updateAttrColor(r.bg,n[1],n[3],n[4],n[5]);break;case 58:r.extended=r.extended.clone(),r.extended.underlineColor=this._updateAttrColor(r.extended.underlineColor,n[1],n[3],n[4],n[5])}return l}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=lt.fg,e.bg=lt.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,r,n=this._curAttrData;for(let o=0;o<t;o++)r=e.params[o],r>=30&&r<=37?(n.fg&=-50331904,n.fg|=16777216|r-30):r>=40&&r<=47?(n.bg&=-50331904,n.bg|=16777216|r-40):r>=90&&r<=97?(n.fg&=-50331904,n.fg|=16777216|r-90|8):r>=100&&r<=107?(n.bg&=-50331904,n.bg|=16777216|r-100|8):r===0?this._processSGR0(n):r===1?n.fg|=134217728:r===3?n.bg|=67108864:r===4?(n.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,n)):r===5?n.fg|=536870912:r===7?n.fg|=67108864:r===8?n.fg|=1073741824:r===9?n.fg|=2147483648:r===2?n.bg|=134217728:r===21?this._processUnderline(2,n):r===22?(n.fg&=-134217729,n.bg&=-134217729):r===23?n.bg&=-67108865:r===24?(n.fg&=-268435457,this._processUnderline(0,n)):r===25?n.fg&=-536870913:r===27?n.fg&=-67108865:r===28?n.fg&=-1073741825:r===29?n.fg&=2147483647:r===39?(n.fg&=-67108864,n.fg|=lt.fg&16777215):r===49?(n.bg&=-67108864,n.bg|=lt.bg&16777215):r===38||r===48||r===58?o+=this._extractColor(e,o,n):r===53?n.bg|=1073741824:r===55?n.bg&=-1073741825:r===59?(n.extended=n.extended.clone(),n.extended.underlineColor=-1,n.updateExtended()):r===100?(n.fg&=-67108864,n.fg|=lt.fg&16777215,n.bg&=-67108864,n.bg|=lt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",r);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${oe.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${oe.ESC}[${t};${r}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${oe.ESC}[?${t};${r}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=lt.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 r=t%2===1;this._coreService.decPrivateModes.cursorBlink=r}return!0}setScrollRegion(e){let t=e.params[0]||1,r;return(e.length<2||(r=e.params[1])>this._bufferService.rows||r===0)&&(r=this._bufferService.rows),r>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=r-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Sm(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(`${oe.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>ym&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>ym&&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=[],r=e.split(";");for(;r.length>1;){let n=r.shift(),o=r.shift();if(/^\d+$/.exec(n)){let l=parseInt(n);if(Cm(l))if(o==="?")t.push({type:0,index:l});else{let u=vm(o);u&&t.push({type:1,index:l,color:u})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let r=e.slice(0,t).trim(),n=e.slice(t+1);return n?this._createHyperlink(r,n):r.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let r=e.split(":"),n,o=r.findIndex(l=>l.startsWith("id="));return o!==-1&&(n=r[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:n,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 r=e.split(";");for(let n=0;n<r.length&&!(t>=this._specialColors.length);++n,++t)if(r[n]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=vm(r[n]);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=[],r=e.split(";");for(let n=0;n<r.length;++n)if(/^\d+$/.exec(r[n])){let o=parseInt(r[n]);Cm(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,Xr),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(M1[e[0]],mt[e[1]]||Xr),!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=lt.clone(),this._eraseAttrDataInternal=lt.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 _i;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 r=this._activeBuffer.ybase+this._activeBuffer.y+t,n=this._activeBuffer.lines.get(r);n&&(n.fill(e),n.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let r=u=>(this._coreService.triggerDataEvent(`${oe.ESC}${u}${oe.ESC}\\`),!0),n=this._bufferService.buffer,o=this._optionsService.rawOptions;return r(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${n.scrollTop+1};${n.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)}},ih=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&&(bm=e,e=t,t=bm),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ih=tt([_e(0,Ot)],ih);function Cm(e){return 0<=e&&e<256}var T1=5e7,xm=12,j1=50,B1=class extends Le{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 fe),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 r;for(;r=this._writeBuffer.shift();){this._action(r);let n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>T1)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 r=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let n=this._writeBuffer[this._bufferOffset],o=this._action(n,t);if(o){let u=f=>performance.now()-r>=xm?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(r,f);o.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(u);return}let l=this._callbacks[this._bufferOffset];if(l&&l(),this._bufferOffset++,this._pendingData-=n.length,performance.now()-r>=xm)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>j1&&(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()}},rh=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 f=t.addMarker(t.ybase+t.y),m={data:e,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(m,f)),this._dataByLinkId.set(m.id,m),m.id}let r=e,n=this._getEntryIdKey(r),o=this._entriesWithId.get(n);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let l=t.addMarker(t.ybase+t.y),u={id:this._nextId++,key:this._getEntryIdKey(r),data:r,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(u,l)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,t){let r=this._dataByLinkId.get(e);if(r&&r.lines.every(n=>n.line!==t)){let n=this._bufferService.buffer.addMarker(t);r.lines.push(n),n.onDispose(()=>this._removeMarkerFromLink(r,n))}}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 r=e.lines.indexOf(t);r!==-1&&(e.lines.splice(r,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};rh=tt([_e(0,Ot)],rh);var km=!1,A1=class extends Le{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ts),this._onBinary=this._register(new fe),this.onBinary=this._onBinary.event,this._onData=this._register(new fe),this.onData=this._onData.event,this._onLineFeed=this._register(new fe),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new fe),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new fe),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new fe),this._instantiationService=new o1,this.optionsService=this._register(new g1(e)),this._instantiationService.setService(zt,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Ju)),this._instantiationService.setService(Ot,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Qu)),this._instantiationService.setService(e_,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Zu)),this._instantiationService.setService(ts,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(eh)),this._instantiationService.setService(Zg,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Gr)),this._instantiationService.setService(i0,this.unicodeService),this._charsetService=this._instantiationService.createInstance(w1),this._instantiationService.setService(t0,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(rh),this._instantiationService.setService(t_,this._oscLinkService),this._inputHandler=this._register(new L1(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Rt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Rt.forward(this._bufferService.onResize,this._onResize)),this._register(Rt.forward(this.coreService.onData,this._onData)),this._register(Rt.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 B1((t,r)=>this._inputHandler.parse(t,r))),this._register(Rt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new fe),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&&!km&&(this._logService.warn("writeSync is unreliable and will be removed soon."),km=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,T_),t=Math.max(t,j_),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(gm.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(gm(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ve(()=>{for(let t of e)t.dispose()})}}},I1={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 O1(e,t,r,n){var u;let o={type:0,cancel:!1,key:void 0},l=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?o.key=oe.ESC+"OA":o.key=oe.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=oe.ESC+"OD":o.key=oe.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=oe.ESC+"OC":o.key=oe.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=oe.ESC+"OB":o.key=oe.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":oe.DEL,e.altKey&&(o.key=oe.ESC+o.key);break;case 9:if(e.shiftKey){o.key=oe.ESC+"[Z";break}o.key=oe.HT,o.cancel=!0;break;case 13:o.key=e.altKey?oe.ESC+oe.CR:oe.CR,o.cancel=!0;break;case 27:o.key=oe.ESC,e.altKey&&(o.key=oe.ESC+oe.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;l?o.key=oe.ESC+"[1;"+(l+1)+"D":t?o.key=oe.ESC+"OD":o.key=oe.ESC+"[D";break;case 39:if(e.metaKey)break;l?o.key=oe.ESC+"[1;"+(l+1)+"C":t?o.key=oe.ESC+"OC":o.key=oe.ESC+"[C";break;case 38:if(e.metaKey)break;l?o.key=oe.ESC+"[1;"+(l+1)+"A":t?o.key=oe.ESC+"OA":o.key=oe.ESC+"[A";break;case 40:if(e.metaKey)break;l?o.key=oe.ESC+"[1;"+(l+1)+"B":t?o.key=oe.ESC+"OB":o.key=oe.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=oe.ESC+"[2~");break;case 46:l?o.key=oe.ESC+"[3;"+(l+1)+"~":o.key=oe.ESC+"[3~";break;case 36:l?o.key=oe.ESC+"[1;"+(l+1)+"H":t?o.key=oe.ESC+"OH":o.key=oe.ESC+"[H";break;case 35:l?o.key=oe.ESC+"[1;"+(l+1)+"F":t?o.key=oe.ESC+"OF":o.key=oe.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=oe.ESC+"[5;"+(l+1)+"~":o.key=oe.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=oe.ESC+"[6;"+(l+1)+"~":o.key=oe.ESC+"[6~";break;case 112:l?o.key=oe.ESC+"[1;"+(l+1)+"P":o.key=oe.ESC+"OP";break;case 113:l?o.key=oe.ESC+"[1;"+(l+1)+"Q":o.key=oe.ESC+"OQ";break;case 114:l?o.key=oe.ESC+"[1;"+(l+1)+"R":o.key=oe.ESC+"OR";break;case 115:l?o.key=oe.ESC+"[1;"+(l+1)+"S":o.key=oe.ESC+"OS";break;case 116:l?o.key=oe.ESC+"[15;"+(l+1)+"~":o.key=oe.ESC+"[15~";break;case 117:l?o.key=oe.ESC+"[17;"+(l+1)+"~":o.key=oe.ESC+"[17~";break;case 118:l?o.key=oe.ESC+"[18;"+(l+1)+"~":o.key=oe.ESC+"[18~";break;case 119:l?o.key=oe.ESC+"[19;"+(l+1)+"~":o.key=oe.ESC+"[19~";break;case 120:l?o.key=oe.ESC+"[20;"+(l+1)+"~":o.key=oe.ESC+"[20~";break;case 121:l?o.key=oe.ESC+"[21;"+(l+1)+"~":o.key=oe.ESC+"[21~";break;case 122:l?o.key=oe.ESC+"[23;"+(l+1)+"~":o.key=oe.ESC+"[23~";break;case 123:l?o.key=oe.ESC+"[24;"+(l+1)+"~":o.key=oe.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=oe.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=oe.DEL:e.keyCode===219?o.key=oe.ESC:e.keyCode===220?o.key=oe.FS:e.keyCode===221&&(o.key=oe.GS);else if((!r||n)&&e.altKey&&!e.metaKey){let f=(u=I1[e.keyCode])==null?void 0:u[e.shiftKey?1:0];if(f)o.key=oe.ESC+f;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=oe.ESC+p}else if(e.keyCode===32)o.key=oe.ESC+(e.ctrlKey?oe.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let m=e.code.slice(3,4);e.shiftKey||(m=m.toLowerCase()),o.key=oe.ESC+m,o.cancel=!0}}else r&&!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=oe.US),e.key==="@"&&(o.key=oe.NUL));break}return o}var ot=0,z1=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Ea,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Ea,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((o,l)=>this._getKey(o)-this._getKey(l)),t=0,r=0,n=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<n.length;o++)r>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[r])?(n[o]=e[t],t++):n[o]=this._array[r++];this._array=n,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||(ot=this._search(t),ot===-1)||this._getKey(this._array[ot])!==t)return!1;do if(this._array[ot]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ot),!0;while(++ot<this._array.length&&this._getKey(this._array[ot])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,l)=>o-l),t=0,r=new Array(this._array.length-e.length),n=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:r[n++]=this._array[o];this._array=r,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&&(ot=this._search(e),!(ot<0||ot>=this._array.length)&&this._getKey(this._array[ot])===e))do yield this._array[ot];while(++ot<this._array.length&&this._getKey(this._array[ot])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ot=this._search(e),!(ot<0||ot>=this._array.length)&&this._getKey(this._array[ot])===e))do t(this._array[ot]);while(++ot<this._array.length&&this._getKey(this._array[ot])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,r=this._array.length-1;for(;r>=t;){let n=t+r>>1,o=this._getKey(this._array[n]);if(o>e)r=n-1;else if(o<e)t=n+1;else{for(;n>0&&this._getKey(this._array[n-1])===e;)n--;return n}}return t}},Uc=0,Em=0,F1=class extends Le{constructor(){super(),this._decorations=new z1(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new fe),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new fe),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ve(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new H1(e);if(t){let r=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),r.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,r){let n=0,o=0;for(let l of this._decorations.getKeyIterator(t))n=l.options.x??0,o=n+(l.options.width??1),e>=n&&e<o&&(!r||(l.options.layer??"bottom")===r)&&(yield l)}forEachDecorationAtCell(e,t,r,n){this._decorations.forEachByKey(t,o=>{Uc=o.options.x??0,Em=Uc+(o.options.width??1),e>=Uc&&e<Em&&(!r||(o.options.layer??"bottom")===r)&&n(o)})}},H1=class extends Dr{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new fe),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new fe),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=Qe.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Qe.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},$1=1e3,W1=class{constructor(e,t=$1){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,r){this._rowCount=r,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 n=performance.now();if(n-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=n,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=n-this._lastRefreshMs,l=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},l)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Nm=20,Na=class extends Le{constructor(e,t,r,n){super(),this._terminal=e,this._coreBrowserService=r,this._renderService=n,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let l=0;l<this._terminal.rows;l++)this._rowElements[l]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[l]);if(this._topBoundaryFocusListener=l=>this._handleBoundaryFocus(l,0),this._bottomBoundaryFocusListener=l=>this._handleBoundaryFocus(l,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new W1(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(l=>this._handleResize(l.rows))),this._register(this._terminal.onRender(l=>this._refreshRows(l.start,l.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(l=>this._handleChar(l))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
64
- `))),this._register(this._terminal.onA11yTab(l=>this._handleTab(l))),this._register(this._terminal.onKey(l=>this._handleKey(l.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Pe(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Ve(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Nm+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
65
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Nm+1&&(this._liveRegion.textContent+=Cu.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 r=this._terminal.buffer,n=r.lines.length.toString();for(let o=e;o<=t;o++){let l=r.lines.get(r.ydisp+o),u=[],f=(l==null?void 0:l.translateToString(!0,void 0,void 0,u))||"",m=(r.ydisp+o+1).toString(),p=this._rowElements[o];p&&(f.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=f,this._rowColumns.set(p,u)),p.setAttribute("aria-posinset",m),p.setAttribute("aria-setsize",n),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let r=e.target,n=this._rowElements[t===0?1:this._rowElements.length-2],o=r.getAttribute("aria-posinset"),l=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===l||e.relatedTarget!==n)return;let u,f;if(t===0?(u=r,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(u=this._rowElements.shift(),f=r,this._rowContainer.removeChild(u)),u.removeEventListener("focus",this._topBoundaryFocusListener),f.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 f;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},r={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(r.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===r.node&&t.offset>r.offset)&&([t,r]=[r,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 n=this._rowElements.slice(-1)[0];if(r.node.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(r={node:n,offset:((f=n.textContent)==null?void 0:f.length)??0}),!this._rowContainer.contains(r.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 v=this._rowColumns.get(y);if(!v)return console.warn("columns is null. Race condition?"),null;let _=p<v.length?v[p]:v.slice(-1)[0]+1;return _>=this._terminal.cols&&(++S,_=0),{row:S,column:_}},l=o(t),u=o(r);if(!(!l||!u)){if(l.row>u.row||l.row===u.row&&l.column>=u.column)throw new Error("invalid range");this._terminal.select(l.column,l.row,(u.row-l.row)*this._terminal.cols-l.column+u.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var o,l;e.style.transform="";let t=e.getBoundingClientRect().width,r=(l=(o=this._rowColumns.get(e))==null?void 0:o.slice(-1))==null?void 0:l[0];if(!r)return;let n=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${n/t})`}};Na=tt([_e(1,Sh),_e(2,rr),_e(3,sr)],Na);var sh=class extends Le{constructor(e,t,r,n,o){super(),this._element=e,this._mouseService=t,this._renderService=r,this._bufferService=n,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new fe),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new fe),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Ve(()=>{var l;Jr(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(l=this._activeProviderReplies)==null||l.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Pe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Pe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Pe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Pe(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 r=e.composedPath();for(let n=0;n<r.length;n++){let o=r[n];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 n,o;(!this._activeProviderReplies||!t)&&((n=this._activeProviderReplies)==null||n.forEach(l=>{l==null||l.forEach(u=>{u.link.dispose&&u.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[l,u]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(l)&&(r=this._checkLinkProviderResult(l,e,r)):u.provideLinks(e.y,f=>{var p,y;if(this._isMouseOut)return;let m=f==null?void 0:f.map(S=>({link:S}));(p=this._activeProviderReplies)==null||p.set(l,m),r=this._checkLinkProviderResult(l,e,r),((y=this._activeProviderReplies)==null?void 0:y.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let r=new Set;for(let n=0;n<t.size;n++){let o=t.get(n);if(o)for(let l=0;l<o.length;l++){let u=o[l],f=u.link.range.start.y<e?0:u.link.range.start.x,m=u.link.range.end.y>e?this._bufferService.cols:u.link.range.end.x;for(let p=f;p<=m;p++){if(r.has(p)){o.splice(l--,1);break}r.add(p)}}}}_checkLinkProviderResult(e,t,r){var l;if(!this._activeProviderReplies)return r;let n=this._activeProviderReplies.get(e),o=!1;for(let u=0;u<e;u++)(!this._activeProviderReplies.has(u)||this._activeProviderReplies.get(u))&&(o=!0);if(!o&&n){let u=n.find(f=>this._linkAtPosition(f.link,t));u&&(r=!0,this._handleNewLink(u))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!r)for(let u=0;u<this._activeProviderReplies.size;u++){let f=(l=this._activeProviderReplies.get(u))==null?void 0:l.find(m=>this._linkAtPosition(m.link,t));if(f){r=!0,this._handleNewLink(f);break}}return r}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&U1(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,Jr(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 r,n;return(n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.pointerCursor},set:r=>{var n;(n=this._currentLink)!=null&&n.state&&this._currentLink.state.decorations.pointerCursor!==r&&(this._currentLink.state.decorations.pointerCursor=r,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",r))}},underline:{get:()=>{var r,n;return(n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline},set:r=>{var n,o,l;(n=this._currentLink)!=null&&n.state&&((l=(o=this._currentLink)==null?void 0:o.state)==null?void 0:l.decorations.underline)!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(r=>{if(!this._currentLink)return;let n=r.start===0?0:r.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+r.end;if(this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(n,o),this._lastMouseEvent)){let l=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);l&&this._askForLink(l,!1)}})))}_linkHover(e,t,r){var n;(n=this._currentLink)!=null&&n.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(r,t.text)}_fireUnderlineEvent(e,t){let r=e.range,n=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-n-1,r.end.x,r.end.y-n-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,r){var n;(n=this._currentLink)!=null&&n.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(r,t.text)}_linkAtPosition(e,t){let r=e.range.start.y*this._bufferService.cols+e.range.start.x,n=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return r<=o&&o<=n}_positionFromMouseEvent(e,t,r){let n=r.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(n)return{x:n[0],y:n[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,r,n,o){return{x1:e,y1:t,x2:r,y2:n,cols:this._bufferService.cols,fg:o}}};sh=tt([_e(1,wh),_e(2,sr),_e(3,Ot),_e(4,r_)],sh);function U1(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 q1=class extends A1{constructor(e={}){super(e),this._linkifier=this._register(new Ts),this.browser=b_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ts),this._onCursorMove=this._register(new fe),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new fe),this.onKey=this._onKey.event,this._onRender=this._register(new fe),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new fe),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new fe),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new fe),this.onBell=this._onBell.event,this._onFocus=this._register(new fe),this._onBlur=this._register(new fe),this._onA11yCharEmitter=this._register(new fe),this._onA11yTabEmitter=this._register(new fe),this._onWillOpen=this._register(new fe),this._setup(),this._decorationService=this._instantiationService.createInstance(F1),this._instantiationService.setService(Un,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(jw),this._instantiationService.setService(r_,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ku)),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(Rt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Rt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Rt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Rt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Ve(()=>{var t,r;this._customKeyEventHandler=void 0,(r=(t=this.element)==null?void 0:t.parentNode)==null||r.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 r,n="";switch(t.index){case 256:r="foreground",n="10";break;case 257:r="background",n="11";break;case 258:r="cursor",n="12";break;default:r="ansi",n="4;"+t.index}switch(t.type){case 0:let o=qe.toColorRGB(r==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[r]);this.coreService.triggerDataEvent(`${oe.ESC}]${n};${D1(o)}${S_.ST}`);break;case 1:if(r==="ansi")this._themeService.modifyColors(l=>l.ansi[t.index]=ct.toColor(...t.color));else{let l=r;this._themeService.modifyColors(u=>u[l]=ct.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(Na,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(oe.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(oe.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 r=Math.min(this.buffer.x,this.cols-1),n=this._renderService.dimensions.css.cell.height,o=t.getWidth(r),l=this._renderService.dimensions.css.cell.width*o,u=this.buffer.y*this._renderService.dimensions.css.cell.height,f=r*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"px",this.textarea.style.top=u+"px",this.textarea.style.width=l+"px",this.textarea.style.height=n+"px",this.textarea.style.lineHeight=n+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Pe(this.element,"copy",t=>{this.hasSelection()&&XS(t,this._selectionService)}));let e=t=>GS(t,this.textarea,this.coreService,this.optionsService);this._register(Pe(this.textarea,"paste",e)),this._register(Pe(this.element,"paste",e)),C_?this._register(Pe(this.element,"mousedown",t=>{t.button===2&&Ip(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Pe(this.element,"contextmenu",t=>{Ip(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Ph&&this._register(Pe(this.element,"auxclick",t=>{t.button===1&&Yg(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Pe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Pe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Pe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Pe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Pe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Pe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Pe(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(Pe(this.screenElement,"mousemove",l=>this.updateCursorStyle(l))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let r=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",bu.get()),E_||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",()=>r.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Lw,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(rr,this._coreBrowserService),this._register(Pe(this.textarea,"focus",l=>this._handleTextAreaFocus(l))),this._register(Pe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Ku,this._document,this._helperContainer),this._instantiationService.setService(Ba,this._charSizeService),this._themeService=this._instantiationService.createInstance(Gu),this._instantiationService.setService(As,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(xa),this._instantiationService.setService(i_,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Yu,this.rows,this.screenElement)),this._instantiationService.setService(sr,this._renderService),this._register(this._renderService.onRenderedViewportChange(l=>this._onRender.fire(l))),this.onResize(l=>this._renderService.resize(l.cols,l.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Wu,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Vu),this._instantiationService.setService(wh,this._mouseService);let n=this._linkifier.value=this._register(this._instantiationService.createInstance(sh,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(Hu,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(l=>{super.scrollLines(l,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Xu,this.element,this.screenElement,n)),this._instantiationService.setService(s0,this._selectionService),this._register(this._selectionService.onRequestScrollLines(l=>this.scrollLines(l.amount,l.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(l=>this._renderService.handleSelectionChanged(l.start,l.end,l.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(l=>{this.textarea.value=l,this.textarea.focus(),this.textarea.select()})),this._register(Rt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var l;this._selectionService.refresh(),(l=this._viewport)==null||l.queueSync()})),this._register(this._instantiationService.createInstance($u,this.screenElement)),this._register(Pe(this.element,"mousedown",l=>this._selectionService.handleMouseDown(l))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Na,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",l=>this._handleScreenReaderModeOptionChange(l))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ca,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",l=>{!this._overviewRulerRenderer&&l&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ca,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(qu,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function r(l){var p,y,S,v,_;let u=e._mouseService.getMouseReportCoords(l,e.screenElement);if(!u)return!1;let f,m;switch(l.overrideType||l.type){case"mousemove":m=32,l.buttons===void 0?(f=3,l.button!==void 0&&(f=l.button<3?l.button:3)):f=l.buttons&1?0:l.buttons&4?1:l.buttons&2?2:3;break;case"mouseup":m=0,f=l.button<3?l.button:3;break;case"mousedown":m=1,f=l.button<3?l.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(l)===!1)return!1;let b=l.deltaY;if(b===0||e.coreMouseService.consumeWheelEvent(l,(v=(S=(y=(p=e._renderService)==null?void 0:p.dimensions)==null?void 0:y.device)==null?void 0:S.cell)==null?void 0:v.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return!1;m=b<0?0:1,f=4;break;default:return!1}return m===void 0||f===void 0||f>4?!1:e.coreMouseService.triggerMouseEvent({col:u.col,row:u.row,x:u.x,y:u.y,button:f,action:m,ctrl:l.ctrlKey,alt:l.altKey,shift:l.shiftKey})}let n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:l=>(r(l),l.buttons||(this._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.removeEventListener("mousemove",n.mousedrag)),this.cancel(l)),wheel:l=>(r(l),this.cancel(l,!0)),mousedrag:l=>{l.buttons&&r(l)},mousemove:l=>{l.buttons||r(l)}};this._register(this.coreMouseService.onProtocolChange(l=>{l?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(l)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),l&8?n.mousemove||(t.addEventListener("mousemove",o.mousemove),n.mousemove=o.mousemove):(t.removeEventListener("mousemove",n.mousemove),n.mousemove=null),l&16?n.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),n.wheel=o.wheel):(t.removeEventListener("wheel",n.wheel),n.wheel=null),l&2?n.mouseup||(n.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),l&4?n.mousedrag||(n.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Pe(t,"mousedown",l=>{if(l.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(l)))return r(l),n.mouseup&&this._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.addEventListener("mousemove",n.mousedrag),this.cancel(l)})),this._register(Pe(t,"wheel",l=>{var u,f,m,p,y;if(!n.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(l)===!1)return!1;if(!this.buffer.hasScrollback){if(l.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(l,(p=(m=(f=(u=e._renderService)==null?void 0:u.dimensions)==null?void 0:f.device)==null?void 0:m.cell)==null?void 0:p.height,(y=e._coreBrowserService)==null?void 0:y.dpr)===0)return this.cancel(l,!0);let S=oe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(l.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(S,!0),this.cancel(l,!0)}}},{passive:!1}))}refresh(e,t){var r;(r=this._renderService)==null||r.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){Vg(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,r){this._selectionService.setSelection(e,t,r)}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 r;(r=this._selectionService)==null||r.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 r=O1(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),r.type===3||r.type===2){let n=this.rows-1;return this.scrollLines(r.type===2?-n:n),this.cancel(e,!0)}if(r.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(r.cancel&&this.cancel(e,!0),!r.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((r.key===oe.ETX||r.key===oe.CR)&&(this.textarea.value=""),this._onKey.fire({key:r.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let r=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"?r:r&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(K1(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 r;(r=this._charSizeService)==null||r.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(lt));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(oe.ESC+"[I"):this.coreService.triggerDataEvent(oe.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),r=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${oe.ESC}[4;${r};${t}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${oe.ESC}[6;${o};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function K1(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var V1=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let r={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(r),t.dispose=()=>this._wrappedAddonDispose(r),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let r=0;r<this._addons.length;r++)if(this._addons[r]===e){t=r;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)}},Y1=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 _i)}translateToString(e,t,r){return this._line.translateToString(e,t,r)}},Rm=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 Y1(t)}getNullCell(){return new _i}},X1=class extends Le{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new fe),this.onBufferChange=this._onBufferChange.event,this._normal=new Rm(this._core.buffers.normal,"normal"),this._alternate=new Rm(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)}},G1=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,r=>t(r.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(r,n)=>t(r,n.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)}},Q1=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}},J1=["cols","rows"],Oi=0,Z1=class extends Le{constructor(e){super(),this._core=this._register(new q1(e)),this._addonManager=this._register(new V1),this._publicOptions={...this._core.options};let t=n=>this._core.options[n],r=(n,o)=>{this._checkReadonlyOptions(n),this._core.options[n]=o};for(let n in this._core.options){let o={get:t.bind(this,n),set:r.bind(this,n)};Object.defineProperty(this._publicOptions,n,o)}}_checkReadonlyOptions(e){if(J1.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 G1(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Q1(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 X1(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,r){this._verifyIntegers(e,t,r),this._core.select(e,t,r)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
66
- `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return bu.get()},set promptLabel(e){bu.set(e)},get tooMuchOutput(){return Cu.get()},set tooMuchOutput(e){Cu.set(e)}}}_verifyIntegers(...e){for(Oi of e)if(Oi===1/0||isNaN(Oi)||Oi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Oi of e)if(Oi&&(Oi===1/0||isNaN(Oi)||Oi%1!==0||Oi<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 eb=2,tb=1,ib=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,r=window.getComputedStyle(this._terminal.element.parentElement),n=parseInt(r.getPropertyValue("height")),o=Math.max(0,parseInt(r.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),u={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},f=u.top+u.bottom,m=u.right+u.left,p=n-f,y=o-m-t;return{cols:Math.max(eb,Math.floor(y/e.css.cell.width)),rows:Math.max(tb,Math.floor(p/e.css.cell.height))}}};function rb(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function sb({session:e,node:t,token:r,cols:n,rows:o,readonly:l=!1,takeSize:u,focused:f,onData:m,onExit:p,onFiles:y,retryBaseMs:S=250}){const v=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!v)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const b=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${rb(t,r)}`;let x=null,E=!1,N=!1,$=null,z=0,j=f;const U=()=>{if(E||N||$)return;const F=Math.min(5e3,Math.max(0,S)*2**Math.min(z++,5));$=setTimeout(()=>{$=null,O()},F)},O=()=>{if(E||N)return;const F=new WebSocket(b);x=F,F.binaryType="arraybuffer",F.onopen=()=>{if(x!==F||E)return;z=0;const Z={type:"attach",session:e,token:r,cols:n,rows:o,readonly:l};u!==void 0&&(Z.takeSize=u),F.send(JSON.stringify(Z)),j!==void 0&&F.send(JSON.stringify({type:"focus",on:!!j}))},F.onmessage=Z=>{if(!(x!==F||E))if(typeof Z.data=="string"){let R;try{R=JSON.parse(Z.data)}catch{return}R.type==="exit"&&(N=!0,p&&p(R.code)),R.type==="files"&&y&&y(R)}else m&&m(new Uint8Array(Z.data))},F.onerror=()=>{if(x===F)try{F.close()}catch{}},F.onclose=Z=>{x!==F||E||N||[1e3,1002,4401,4404].includes(Z==null?void 0:Z.code)||U()}};return O(),{sendInput:F=>{if(!x||x.readyState!==1)return!1;try{return x.send(typeof F=="string"?new TextEncoder().encode(F):F),!0}catch{try{x.close()}catch{}return!1}},isReady:()=>!!x&&x.readyState===1,resize:(F,Z)=>{n=F,o=Z,(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"resize",cols:F,rows:Z}))},action:F=>{(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"action",name:F}))},focus:F=>{j=F,(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"focus",on:!!F}))},close:()=>{if(E=!0,$&&clearTimeout($),$=null,x)try{x.close()}catch{}},get raw(){return x}}}async function Pm(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 r=document.createElement("textarea");r.value=t,r.readOnly=!0,r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),r.select();const n=document.execCommand&&document.execCommand("copy");if(r.remove(),n)return!0}catch{}return!1}const nb="\r";function ob(e){const t=String(e||"");let r=t.length;for(;r>0;){const n=t.charCodeAt(r-1);if(n===10||n===13)r-=1;else break}return t.slice(0,r)}function ab({isReady:e,paste:t,send:r}){return n=>{if(!n||!e())return!1;try{return t(n)===!1||!e()?!1:r(nb)!==!1}catch{return!1}}}function lb(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function cb(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}const ub=450,Dm=8;function hb(e,t,r,n){return Math.abs(Number(r)-Number(e))>Dm||Math.abs(Number(n)-Number(t))>Dm}const db=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function qc(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 Mm(e){if(!e)return[];const t=Array.from(e.files||[]).filter(Boolean);return t.length?t:Array.from(e.items||[]).filter(r=>r&&r.kind==="file"&&typeof r.getAsFile=="function").map(r=>r.getAsFile()).filter(Boolean)}function fb(e,t=0,r=Date.now()){const n=String((e==null?void 0:e.name)||"").trim();if(n)return n;const o=db.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${r}-${t+1}.${o}`}async function A_({files:e,token:t,session:r,node:n="",paste:o=!0,fetchImpl:l=Ct,onProgress:u=()=>{},now:f=Date.now()}={}){const m=Array.from(e||[]).filter(Boolean),p=[],y=[];if(!r||!m.length)return{paths:p,errors:y};const S=Bs(n?String(n).split("/"):[]);for(let v=0;v<m.length;v+=1){const _=m[v],b=fb(_,v,f);u({index:v,total:m.length,name:b,state:"uploading"});try{const x=new FormData;x.append("session",r),x.append("paste",o?"true":"false"),x.append("file",_,b);const E=await l(`${S}/files/upload`,t,{method:"POST",body:x}),N=await E.json().catch(()=>({}));if(!E.ok||N.error)throw new Error(N.error||`HTTP ${E.status}`);p.push(N.path),u({index:v,total:m.length,name:b,state:"done",path:N.path})}catch(x){const E=String((x==null?void 0:x.message)||x);y.push({name:b,message:E}),u({index:v,total:m.length,name:b,state:"error",error:E})}}return{paths:p,errors:y}}function I_({session:e,node:t,token:r,readonly:n,takeSize:o,focused:l,sendRef:u,composerRef:f,actionRef:m,ctrlRef:p,setCtrlArmed:y,onFiles:S,fontSize:v=13,selectionMode:_=!1,onSelectionModeChange:b}){const x=M.useRef(null),E=M.useRef(null),N=M.useRef(v);N.current=v;const $=M.useRef(l);$.current=l;const z=M.useRef(_);z.current=_;const[j,U]=M.useState(""),[O,F]=M.useState(""),[Z,R]=M.useState(null),H=async()=>{var T,Y,Q,G;const P=((Y=(T=E.current)==null?void 0:T.term)==null?void 0:Y.getSelection())||j;if(!P){F(w("copy-empty")),setTimeout(()=>F(""),1500);return}const L=await Pm(P);F(w(L?"copied":"copy-manual")),L&&((G=(Q=E.current)==null?void 0:Q.term)==null||G.clearSelection(),b==null||b(!1)),setTimeout(()=>F(""),1800)},A=M.useRef(H);return A.current=H,M.useEffect(()=>{const P=E.current;P&&P.sock&&P.sock.focus&&P.sock.focus(!!l)},[l]),M.useEffect(()=>{const P=E.current;P&&(P.term.options.fontSize=v,P.fit.fit(),P.sock.resize(P.term.cols,P.term.rows))},[v]),M.useEffect(()=>{const P=new Z1({cursorBlink:!0,fontSize:N.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),L=new ib;P.loadAddon(L),P.open(x.current),L.fit();const T=new TextDecoder;let Y;try{Y=sb({session:e,node:t,token:r,readonly:n,takeSize:o,focused:$.current,onFiles:S,cols:P.cols,rows:P.rows,onData:X=>P.write(T.decode(X)),onExit:()=>P.write(`\r
78
- \x1B[33m[sessione finita]\x1B[0m\r
79
- `)})}catch(X){return P.write(`\r
80
- \x1B[31m${X.message}\x1B[0m\r
81
- `),()=>P.dispose()}E.current={term:P,fit:L,sock:Y};let Q=null;const G=P.onData(X=>{if(n){Q&&(Q.ok=!1);return}if(!Q&&p&&p.current&&X.length===1){const Ne=X.charCodeAt(0);let He=Ne;Ne>=97&&Ne<=122?He=Ne-96:Ne>=64&&Ne<=95?He=Ne-64:Ne===32&&(He=0),X=String.fromCharCode(He),p.current=!1,y&&y(!1)}const pe=Y.sendInput(X);Q&&(Q.seen=!0,Q.ok=Q.ok&&pe)});u&&(u.current=X=>Y.sendInput(X)),m&&(m.current=X=>Y.action(X)),f&&(f.current=ab({isReady:()=>!n&&Y.isReady(),paste:X=>{const pe={seen:!1,ok:!0};Q=pe;try{P.paste(X)}catch{pe.ok=!1}finally{Q=null}return pe.seen&&pe.ok},send:X=>Y.sendInput(X)}));const k=P.onSelectionChange(()=>U(P.getSelection()));P.attachCustomKeyEventHandler(X=>(X.ctrlKey||X.metaKey)&&X.key.toLowerCase()==="c"&&P.getSelection()?(X.type==="keydown"&&Pm(P.getSelection()),!1):!0);const V=x.current;let re=!1;const I=async X=>{if(!X.length||re)return;if(n){R({error:w("settings-readonly")});return}re=!0,R({current:0,total:X.length,name:""});const pe=await A_({files:X,token:r,session:e,node:t,paste:!0,onProgress:({index:Ne,total:He,name:rt,state:Mi,error:zs})=>R({current:Ne+1,total:He,name:rt,...Mi==="error"?{error:zs}:{}})});re=!1,pe.errors.length?R({error:pe.errors.map(Ne=>`${Ne.name}: ${Ne.message}`).join(" · ")}):(R({done:!0,total:pe.paths.length}),setTimeout(()=>R(null),1600))},K=X=>{const pe=X.clipboardData;if(!qc(pe))return;const Ne=Mm(pe);Ne.length&&(X.preventDefault(),X.stopPropagation(),I(Ne))},ne=X=>{qc(X.dataTransfer)&&(X.preventDefault(),X.stopPropagation())},B=X=>{qc(X.dataTransfer)&&(X.preventDefault(),X.stopPropagation(),I(Mm(X.dataTransfer)))};V.addEventListener("paste",K,!0),V.addEventListener("dragenter",ne,!0),V.addEventListener("dragover",ne,!0),V.addEventListener("drop",B,!0);const se=24;let ae=null,me=null,ue=0,ee=null,ge=null,Ee=null,Be=!1;const Ce=()=>{Ee&&clearTimeout(Ee),Ee=null},it=(X,pe)=>{const He=(V.querySelector(".xterm-screen")||V).getBoundingClientRect(),rt=Math.max(0,Math.min(P.cols-1,Math.floor((X-He.left)/Math.max(1,He.width)*P.cols))),Mi=Math.max(0,Math.min(P.rows-1,Math.floor((pe-He.top)/Math.max(1,He.height)*P.rows)));return{col:rt,row:P.buffer.active.viewportY+Mi}},ut=X=>it(X.clientX,X.clientY),Pt=X=>{if(Ce(),Be=!1,X.touches.length!==1){ae=null;return}if(z.current){X.preventDefault(),X.stopPropagation(),ge=ut(X.touches[0]),P.clearSelection();return}ae=X.touches[0].clientY,me=X.touches[0].clientX,ue=0,ee=null;const pe={x:me,y:ae};Ee=setTimeout(()=>{Ee=null,Be=!0,z.current=!0,b==null||b(!0),ge=it(pe.x,pe.y),P.clearSelection(),P.select(ge.col,ge.row,1),ae=null,me=null,ee=null,ue=0},ub)},Je=X=>{if((z.current||Be)&&ge&&X.touches.length===1){X.preventDefault(),X.stopPropagation();const Ne=ut(X.touches[0]),He=ge.row*P.cols+ge.col,rt=Ne.row*P.cols+Ne.col,Mi=He<=rt?ge:Ne;P.select(Mi.col,Mi.row,Math.abs(rt-He)+1);return}if(ae===null||X.touches.length!==1)return;X.preventDefault(),X.stopPropagation();const pe=X.touches[0];if(Ee&&hb(me,ae,pe.clientX,pe.clientY)&&Ce(),ee===null&&(Math.abs(pe.clientY-ae)>8||Math.abs(pe.clientX-me)>8)&&(ee=Math.abs(pe.clientY-ae)>Math.abs(pe.clientX-me)),!!ee){for(ue+=pe.clientY-ae,ae=pe.clientY;ue>=se;)Y.action("scroll-up"),ue-=se;for(;ue<=-se;)Y.action("scroll-down"),ue+=se}},qi=()=>{Ce(),ae=null,me=null,ge=null,Be=!1};let vi=0;const Di=X=>{for(X.preventDefault(),X.stopPropagation(),vi+=X.deltaY;vi<=-se;)Y.action("scroll-up"),vi+=se;for(;vi>=se;)Y.action("scroll-down"),vi-=se};V.addEventListener("touchstart",Pt,{passive:!1}),V.addEventListener("touchmove",Je,{passive:!1,capture:!0}),V.addEventListener("touchend",qi,{passive:!0}),V.addEventListener("touchcancel",qi,{passive:!0});const yi=X=>{(z.current||Be)&&(X.preventDefault(),X.stopPropagation())};V.addEventListener("contextmenu",yi,!0),V.addEventListener("wheel",Di,{passive:!1,capture:!0});let Xt=null;const Mr=X=>{lb(X)&&(X.preventDefault(),X.stopPropagation(),Xt=it(X.clientX,X.clientY),P.clearSelection())},Ki=X=>{if(!Xt)return;X.preventDefault(),X.stopPropagation();const pe=it(X.clientX,X.clientY),Ne=Xt.row*P.cols+Xt.col,He=pe.row*P.cols+pe.col,rt=Ne<=He?Xt:pe;P.select(rt.col,rt.row,Math.abs(He-Ne)+1)},Lr=X=>{Xt&&(X.stopPropagation(),Xt=null)};V.addEventListener("mousedown",Mr,!0),V.addEventListener("mousemove",Ki,!0),V.addEventListener("mouseup",Lr,!0);const Tr=X=>{!cb(X)||!(E.current&&E.current.term&&E.current.term.getSelection())||(X.preventDefault(),X.stopPropagation(),A.current&&A.current())};V.addEventListener("keydown",Tr,!0);const Gt=()=>{L.fit(),Y.resize(P.cols,P.rows)};window.addEventListener("resize",Gt);const Qt=window.visualViewport;Qt&&(Qt.addEventListener("resize",Gt),Qt.addEventListener("scroll",Gt));let Si=null,Ft=0;return typeof ResizeObserver<"u"&&(Si=new ResizeObserver(()=>{Ft&&cancelAnimationFrame(Ft),Ft=requestAnimationFrame(Gt)}),Si.observe(V)),()=>{E.current=null,u&&(u.current=()=>!1),f&&(f.current=()=>!1),m&&(m.current=()=>!1),G.dispose(),k.dispose(),V.removeEventListener("touchstart",Pt),V.removeEventListener("touchmove",Je,{capture:!0}),V.removeEventListener("touchend",qi),V.removeEventListener("touchcancel",qi),V.removeEventListener("contextmenu",yi,!0),Ce(),V.removeEventListener("wheel",Di,{capture:!0}),V.removeEventListener("mousedown",Mr,!0),V.removeEventListener("mousemove",Ki,!0),V.removeEventListener("mouseup",Lr,!0),V.removeEventListener("keydown",Tr,!0),V.removeEventListener("paste",K,!0),V.removeEventListener("dragenter",ne,!0),V.removeEventListener("dragover",ne,!0),V.removeEventListener("drop",B,!0),window.removeEventListener("resize",Gt),Qt&&(Qt.removeEventListener("resize",Gt),Qt.removeEventListener("scroll",Gt)),Si&&Si.disconnect(),Ft&&cancelAnimationFrame(Ft),Y.close(),P.dispose()}},[e,t,r,n,o,u,f,m,p,y,S]),h.jsxs("div",{className:`nc-terminal${_?" selecting":""}`,children:[h.jsx("div",{className:"nc-terminal-host",ref:x}),Z&&h.jsx("div",{className:`nc-upload-state${Z.error?" error":""}`,role:"status",children:Z.error?Z.error:Z.done?w("attach-uploaded").replace("{n}",String(Z.total||0)):w("attach-upload-progress").replace("{n}",String(Z.current||0)).replace("{total}",String(Z.total||0))}),(j||_)&&h.jsxs("div",{className:"nc-selection-tools",children:[j?h.jsx("button",{type:"button",onClick:H,children:O||w("copy")}):h.jsx("span",{children:w("select-drag")}),h.jsx("button",{type:"button",onClick:()=>{var P,L;(L=(P=E.current)==null?void 0:P.term)==null||L.clearSelection(),U(""),b==null||b(!1)},children:w("cancel")}),O===w("copy-manual")&&h.jsx("textarea",{readOnly:!0,value:j,onFocus:P=>P.target.select()})]})]})}const Lm="",Yt="\x1B",pb=[{label:"↑",seq:Yt+"[A"},{label:"↓",seq:Yt+"[B"},{label:"PGUP",seq:Yt+"[5~"},{label:"PGDN",seq:Yt+"[6~"}];function mb({send:e,action:t,ctrlArmed:r=!1,onCtrl:n,onKeyboard:o,selectionMode:l=!1,onSelectionMode:u}){const[f,m]=M.useState(!1),[p,y]=M.useState(!1),[S,v]=M.useState(!1),_=E=>{S?(e(Yt+E),v(!1)):e(E)},b=(E,N,$)=>h.jsx("button",{onMouseDown:z=>{z.preventDefault(),_(N),$&&$()},children:E},E),x=(E,N)=>h.jsx("button",{onMouseDown:$=>{$.preventDefault(),t(N),y(!1)},children:E},E);return f?h.jsxs("div",{className:"nc-keybar copy",children:[h.jsx("span",{className:"tag",children:"copy-mode"}),pb.map(E=>b(E.label,E.seq)),b("ESCI (q)","q",()=>m(!1))]}):h.jsxs("div",{className:"nc-keybar termux",children:[p&&h.jsxs("div",{className:"nc-keymenu",children:[x("←WIN","prev-window"),x("WIN→","next-window"),x("⬅PANE","pane-left"),x("PANE➡","pane-right"),b("SCROLL",Lm+"[",()=>{m(!0),y(!1)}),h.jsx("button",{className:l?"armed":"",onMouseDown:E=>{E.preventDefault(),u==null||u(!l),y(!1)},children:"SELECT"}),b("⌃C","",()=>y(!1)),b("DETACH",Lm+"d",()=>y(!1))]}),h.jsxs("div",{className:"row",children:[b("ESC",Yt),h.jsx("button",{className:p?"armed":"",onMouseDown:E=>{E.preventDefault(),y(N=>!N)},children:"☰"},"menu"),b("/","/"),b("—","-"),b("HOME",Yt+"[H"),b("↑",Yt+"[A"),b("END",Yt+"[F"),b("PGUP",Yt+"[5~")]}),h.jsxs("div",{className:"row",children:[b("⇥"," "),h.jsx("button",{onMouseDown:E=>{E.preventDefault(),o&&o()},children:"⌨"},"kbd"),h.jsx("button",{className:r?"armed":"",onMouseDown:E=>{E.preventDefault(),n&&n()},children:"CTRL"},"ctrl"),h.jsx("button",{className:S?"armed":"",onMouseDown:E=>{E.preventDefault(),v(N=>!N)},children:"ALT"},"alt"),b("←",Yt+"[D"),b("↓",Yt+"[B"),b("→",Yt+"[C"),b("PGDN",Yt+"[6~")]})]})}const gb=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function O_({session:e,node:t,token:r,filesEvent:n,onClose:o}){ai();const l=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",u=t?`${t}:${e}`:e,[f,m]=M.useState("outbox"),[p,y]=M.useState({inbox:[],outbox:[]}),[S,v]=M.useState(""),_=M.useRef(null);async function b(){try{const z=await(await Ct(`${l}/files?session=${encodeURIComponent(e)}`,r)).json();if(z.error){v(z.error);return}y(z);const j=z.outbox[0]?z.outbox[0].mtime:0;localStorage.setItem(Lg(u),String(j))}catch($){v(String($))}}M.useEffect(()=>{b()},[e,t]),M.useEffect(()=>{n&&n.session===e&&b()},[n]);async function x($){for(const z of $){v(`carico ${z.name}…`);const j=new FormData;j.append("session",e),j.append("file",z);try{const O=await(await Ct(`${l}/files/upload`,r,{method:"POST",body:j})).json();v(O.error?`errore: ${O.error}`:"")}catch(U){v(String(U))}}b()}async function E($){const z=await Ct(`${l}/files/download?session=${encodeURIComponent(e)}&box=${f}&name=${encodeURIComponent($)}`,r);if(!z.ok){v("errore download");return}const j=await z.blob(),U=URL.createObjectURL(j),O=document.createElement("a");O.href=U,O.download=$,O.click(),URL.revokeObjectURL(U)}async function N($){await Ct(`${l}/files?session=${encodeURIComponent(e)}&box=${f}&name=${encodeURIComponent($)}`,r,{method:"DELETE"}),b()}return h.jsxs("div",{className:"nc-files",children:[h.jsxs("header",{children:[h.jsx("b",{children:t?`${t}:${e}`:e}),h.jsx("button",{onClick:o,title:w("close"),children:h.jsx(Oe,{name:"x",size:20})})]}),h.jsxs("nav",{children:[h.jsx("button",{className:f==="outbox"?"on":"",onClick:()=>m("outbox"),children:"outbox"}),h.jsx("button",{className:f==="inbox"?"on":"",onClick:()=>m("inbox"),children:"inbox"}),h.jsxs("button",{className:"up",onClick:()=>_.current&&_.current.click(),children:[h.jsx(Oe,{name:"upload",size:18})," ",w("upload")]}),h.jsx("input",{type:"file",multiple:!0,ref:_,style:{display:"none"},onChange:$=>{x(Array.from($.target.files||[])),$.target.value=""}})]}),S&&h.jsx("div",{className:"nc-busy",children:S}),h.jsxs("ul",{children:[p[f].map($=>h.jsxs("li",{children:[h.jsx("span",{className:"name",onClick:()=>E($.name),children:$.name}),h.jsx("small",{children:gb($.size)}),h.jsx("button",{onClick:()=>N($.name),title:"elimina",children:h.jsx(Oe,{name:"trash",size:18})})]},$.name)),p[f].length===0&&h.jsx("li",{className:"empty",children:w("empty-files")})]})]})}function z_({submitText:e,token:t,session:r,node:n}){ai();const o=n?`/api/route/${String(n).split("/").map(encodeURIComponent).join("/")}/_`:"/api",[l,u]=M.useState(""),[f,m]=M.useState(!1),[p,y]=M.useState(""),[S,v]=M.useState(!1),_=M.useRef(null),b=M.useRef(null),x=M.useRef(null),[E,N]=M.useState(!1),[$,z]=M.useState({left:0,bottom:0}),[j,U]=M.useState(!1),[O,F]=M.useState(!1),Z=M.useRef(null),R=M.useRef(null),H=M.useRef(null),A=M.useRef(null),P=M.useRef(null),L=M.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);M.useEffect(()=>{let ne=!1;if(n){v(!1);return}return Ct(`${o}/voice/status`,t).then(B=>B.json()).then(B=>{ne||v(!!B.serverSttConfigured)}).catch(()=>{ne||v(!1)}),()=>{ne=!0}},[t,o]);const Y=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||S);async function Q(){const ne=l,B=ob(ne);if(!B||O)return;F(!0),y("");let se=!1;try{se=!!await e(B)}catch{se=!1}se?u(ae=>ae===ne?"":ae):y(w("composer-send-failed")),F(!1),requestAnimationFrame(()=>{var ae;return(ae=x.current)==null?void 0:ae.focus({preventScroll:!0})})}function G(){const ne=Z.current&&Z.current.getBoundingClientRect();ne&&z({left:Math.max(6,Math.min(ne.left,window.innerWidth-186)),bottom:window.innerHeight-ne.top+6}),N(!0)}function k(ne){N(!1),ne&&Z.current&&Z.current.focus()}M.useEffect(()=>{if(!E)return;const ne=se=>{se.key==="Escape"&&k(!0)},B=se=>{const ae=R.current&&R.current.contains(se.target),me=Z.current&&Z.current.contains(se.target);!ae&&!me&&k(!1)};return document.addEventListener("keydown",ne),document.addEventListener("pointerdown",B),()=>{document.removeEventListener("keydown",ne),document.removeEventListener("pointerdown",B)}},[E]);function V(ne){k(!1),ne.current&&ne.current.click()}async function re(ne){if(!ne.length||!r)return;U(!0),y("");const{paths:B,errors:se}=await A_({files:ne,token:t,session:r,node:n,paste:!1});se.length&&y(se.map(ae=>`${ae.name}: ${ae.message}`).join(" · ")),B.length&&u(ae=>ae+(ae&&!ae.endsWith(" ")?" ":"")+B.join(" ")),U(!1)}function I(){_.current&&_.current.stop(),b.current&&b.current.stop(),m(!1)}async function K(){y("");const ne=window.SpeechRecognition||window.webkitSpeechRecognition;if(ne){const B=new ne;B.lang="it-IT",B.continuous=!1,B.interimResults=!0;const se=l?`${l} `:"";B.onresult=ae=>{const me=Array.from(ae.results).map(ue=>ue[0].transcript).join("");u(se+me)},B.onend=()=>m(!1),B.onerror=ae=>{y(`voice: ${ae.error||"errore"}`),m(!1)},_.current=B,B.start(),m(!0);return}try{const B=await navigator.mediaDevices.getUserMedia({audio:!0}),se=new MediaRecorder(B),ae=[];se.ondataavailable=me=>ae.push(me.data),se.onstop=async()=>{B.getTracks().forEach(me=>me.stop()),m(!1),y("trascrivo…");try{const me=new Blob(ae,{type:se.mimeType||"audio/webm"}),ee=await(await Ct(`${o}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:me})).json();ee.error?y(ee.error):(y(""),u(ge=>ge+(ge?" ":"")+(ee.text||"")))}catch(me){y(String(me))}},b.current={stop:()=>se.state!=="inactive"&&se.stop()},se.start(),m(!0)}catch{y("microfono non disponibile"),m(!1)}}return h.jsxs("div",{className:"nc-composer",children:[p&&h.jsx("div",{className:"nc-composer-err",children:p}),h.jsxs("div",{className:"nc-composer-row",children:[r&&h.jsx("button",{ref:Z,className:j?"attach busy":"attach",disabled:j,onClick:()=>E?k(!1):G(),title:w(j?"attach-uploading":"attach"),"aria-label":w("attach"),"aria-haspopup":"menu","aria-expanded":E,"aria-controls":L.current,children:h.jsx(Oe,{name:"attach",size:22})}),E&&h.jsxs("div",{ref:R,id:L.current,role:"menu",className:"nc-attach-menu",style:{left:$.left,bottom:$.bottom},children:[h.jsxs("button",{role:"menuitem",onClick:()=>V(H),children:[h.jsx(Oe,{name:"file",size:18})," ",w("attach-file")]}),h.jsxs("button",{role:"menuitem",onClick:()=>V(A),children:[h.jsx(Oe,{name:"camera",size:18})," ",w("attach-camera")]}),h.jsxs("button",{role:"menuitem",onClick:()=>V(P),children:[h.jsx(Oe,{name:"image",size:18})," ",w("attach-gallery")]})]}),h.jsx("input",{ref:H,type:"file",multiple:!0,hidden:!0,onChange:ne=>{re(Array.from(ne.target.files||[])),ne.target.value=""}}),h.jsx("input",{ref:A,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:ne=>{re(Array.from(ne.target.files||[])),ne.target.value=""}}),h.jsx("input",{ref:P,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:ne=>{re(Array.from(ne.target.files||[])),ne.target.value=""}}),h.jsx("textarea",{ref:x,rows:2,value:l,placeholder:w("composer-placeholder"),onChange:ne=>u(ne.target.value)}),Y&&h.jsx("button",{className:f?"mic on":"mic",onClick:f?I:K,title:w("voice"),children:h.jsx(Oe,{name:"mic",size:22})}),h.jsx("button",{type:"button",className:"go",disabled:O,onPointerDown:ne=>ne.preventDefault(),onClick:Q,title:w("send"),children:h.jsx(Oe,{name:"enter",size:22})})]})]})}function Ra(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 Tm(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const _b=180,vb=480;function Kc(e){return e.status==="passive"?w("node-passive"):e.status==="down"?e.downSince?w("tunnel-down-since").replace("{t}",Ra(e.downSince)):w("tunnel-down"):e.status==="unreachable"?w("node-unreachable"):e.status==="offline"?e.lastSeen?w("node-offline-seen").replace("{t}",Ra(e.lastSeen)):w("node-offline"):e.status==="needs-repair"?w("node-needs-repair"):""}function yb(e){return!e||e.status==="passive"?null:e.status==="healthy"?"on":"warn"}function jm(e){return e&&(e.detail||e.status)||""}function Sb({sessions:e=[],cells:t=[],activeSessions:r=[],nodeGroups:n=[],onPick:o,onAddTile:l,onPower:u,onNodePower:f,onKill:m,onNew:p,onSettings:y,width:S=240,collapsed:v=!1,onResize:_,onToggleCollapse:b}){const[x,E]=ai(),[N,$]=M.useState(Hg),z=k=>$(V=>$g(V,k)),j=new Set((t||[]).map(k=>k.tmuxSession)),U=new Map((e||[]).map(k=>[k.name,k])),O=(k,V)=>Ln(N,k,V),F=yu,Z=[...t||[]].sort((k,V)=>F(O(k.tmuxSession,(U.get(k.tmuxSession)||{}).activity),O(V.tmuxSession,(U.get(V.tmuxSession)||{}).activity))),R=(e||[]).filter(k=>!j.has(k.name)).sort((k,V)=>F(O(k.name,k.activity),O(V.name,V.activity))||k.name.localeCompare(V.name)),H=new Set(r||[]),[A,P]=M.useState(null),L=(k,V)=>{const re=k.currentTarget.getBoundingClientRect();P({text:V,y:re.top+re.height/2})},T=()=>P(null),Y=M.useRef(null);M.useEffect(()=>()=>{Y.current&&Y.current()},[]);function Q(k){k.preventDefault(),k.stopPropagation();const V=k.clientX,re=S,I=ne=>{const B=Math.max(_b,Math.min(vb,re+(ne.clientX-V)));_&&_(B)},K=()=>{window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",K),window.removeEventListener("pointercancel",K),window.removeEventListener("blur",K),Y.current=null};window.addEventListener("pointermove",I),window.addEventListener("pointerup",K),window.addEventListener("pointercancel",K),window.addEventListener("blur",K),Y.current=K}const G=v?{width:48,flex:"0 0 48px"}:{width:S,flex:`0 0 ${S}px`};return v?h.jsxs("aside",{className:"nc-sidebar mini",style:G,children:[h.jsx("div",{className:"nc-side-head mini",children:h.jsx("button",{className:"nc-collapse-btn",onClick:b,title:w("expand"),children:"⟩"})}),h.jsxs("div",{className:"nc-side-group mini",children:[Z.map(k=>{const V=k.degraded?"warn":k.tmux?"on":"",re=!!k.tmux;return h.jsx("button",{type:"button",className:`nc-mini-dot${H.has(k.tmuxSession)?" active":""}`,onMouseEnter:I=>L(I,k.cell),onMouseLeave:T,draggable:re,onDragStart:re?I=>I.dataTransfer.setData("text/nc-session",k.tmuxSession):void 0,onClick:re?()=>l&&l(k.tmuxSession):()=>u&&u(k),onDoubleClick:re?()=>o&&o(k.tmuxSession):void 0,children:h.jsx("span",{className:`nc-dot ${V}`})},k.cell)}),R.map(k=>h.jsx("button",{type:"button",className:`nc-mini-init${H.has(k.name)?" active":""}`,onMouseEnter:V=>L(V,k.name),onMouseLeave:T,draggable:!0,onDragStart:V=>V.dataTransfer.setData("text/nc-session",k.name),onClick:()=>l&&l(k.name),onDoubleClick:()=>o&&o(k.name),children:Tm(k.name)},k.name)),(n||[]).flatMap(k=>k.status==="up"?k.sessions.map(V=>h.jsx("button",{type:"button",className:`nc-mini-init${H.has(V.key)?" active":""}`,onMouseEnter:re=>L(re,V.key),onMouseLeave:T,draggable:!0,onDragStart:re=>re.dataTransfer.setData("text/nc-session",V.key),onClick:()=>l&&l(V.key),onDoubleClick:()=>o&&o({session:V.name,node:V.node}),children:Tm(V.name)},V.key)):[h.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:V=>L(V,`${k.label||(k.route||[k.name]).join(" › ")}: ${Kc(k)}`),onMouseLeave:T,children:h.jsx("span",{className:`nc-dot${k.status==="passive"?"":" warn"}`})},`nodo-${(k.route||[k.name]).join("/")}`)])]}),h.jsx("button",{className:"nc-side-gear mini",onClick:()=>y&&y("nodes",!1),title:w("settings"),onMouseEnter:k=>L(k,w("settings")),onMouseLeave:T,children:h.jsx(Oe,{name:"gear",size:16})}),A&&h.jsx("div",{className:"nc-mini-tip",style:{top:A.y},children:A.text})]}):h.jsxs("aside",{className:"nc-sidebar",style:G,children:[h.jsxs("div",{className:"nc-side-head",children:[h.jsx("button",{className:"nc-collapse-btn",onClick:b,title:w("collapse"),children:"⟨"}),h.jsx("span",{className:"nc-side-title",children:w("fleet")}),h.jsxs("button",{className:"nc-new-btn",onClick:p,title:w("fleet-new-cell"),children:["+ ",w("new")]})]}),(t||[]).length>0&&h.jsx("div",{className:"nc-side-group",children:Z.map(k=>{const V=k.degraded?"warn":k.tmux?"on":"",re=k.degraded?w("cell-degraded"):k.tmux?w("cell-on"):w("cell-off"),I=!!k.tmux;return h.jsxs("div",{className:`nc-cell${I?" live":""}${H.has(k.tmuxSession)?" active":""}`,title:`${k.cell} · ${k.engine}${k.key?`·${k.key}`:""} · ${re}`,"aria-label":`${k.cell}, ${k.engine}${k.key?` ${k.key}`:""}, ${re}`,draggable:I,onDragStart:I?K=>K.dataTransfer.setData("text/nc-session",k.tmuxSession):void 0,onClick:I?()=>l&&l(k.tmuxSession):void 0,onDoubleClick:I?()=>o&&o(k.tmuxSession):void 0,children:[h.jsx("span",{className:`nc-dot ${V}`}),h.jsxs("span",{className:"nc-cell-main",children:[h.jsx("b",{title:k.cell,children:k.cell}),h.jsxs("small",{title:`${k.engine}${k.key?`·${k.key}`:""}`,children:[k.engine,k.key?`·${k.key}`:""]})]}),h.jsx("button",{className:`nc-pin${N.includes(k.tmuxSession)?" on":""}`,title:w("pin"),onClick:K=>{K.stopPropagation(),z(k.tmuxSession)},children:N.includes(k.tmuxSession)?"★":"☆"}),h.jsx("button",{className:`nc-power${k.tmux?" on":""}${k.degraded?" warn":""}`,onClick:K=>{K.stopPropagation(),u&&u(k)},title:k.active?w("power-off"):w("power-on"),children:h.jsx(Oe,{name:"power",size:14})})]},k.cell)})}),h.jsxs("button",{className:"nc-side-gear",onClick:()=>y&&y("nodes",!1),title:w("settings"),children:[h.jsx(Oe,{name:"gear",size:15})," ",w("settings")]}),h.jsx("div",{className:"nc-side-group-title",children:w("other-sessions")}),h.jsxs("div",{className:"nc-side-group",children:[R.map(k=>h.jsxs("div",{className:`nc-side-card${H.has(k.name)?" active":""}`,draggable:!0,onDragStart:V=>V.dataTransfer.setData("text/nc-session",k.name),onClick:()=>l&&l(k.name),onDoubleClick:()=>o&&o(k.name),children:[h.jsx("span",{className:k.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:k.name}),h.jsxs("small",{children:[k.preview?k.preview:k.cmd?k.cmd:w("windows").replace("{n}",String(k.windows||0)),k.outbox&&k.outbox.count>0?` · 📦${k.outbox.count}`:""]})]}),k.activity?h.jsx("span",{className:"nc-rel",children:Ra(k.activity)}):null,h.jsx("button",{className:`nc-pin${N.includes(k.name)?" on":""}`,title:w("pin"),onClick:V=>{V.stopPropagation(),z(k.name)},children:N.includes(k.name)?"★":"☆"}),h.jsx("button",{className:"nc-menu",title:w("terminate"),onClick:V=>{V.stopPropagation(),window.confirm(w("terminate-confirm").replace("{name}",k.name))&&m&&m(k.name)},children:"⋯"})]},k.name)),R.length===0&&h.jsx("div",{className:"nc-empty",children:w("no-sessions-short")})]}),(n||[]).map(k=>{const re=yb(k.health)||(k.status==="up"?"on":k.status==="passive"?"":"warn"),I=(k.route||[k.name]).join("/");return h.jsxs("div",{children:[h.jsxs("div",{className:"nc-side-group-title nc-node-title",children:[h.jsx("span",{className:`nc-dot ${re}`,title:k.health?jm(k.health):""}),h.jsx("b",{children:k.label||k.name}),h.jsxs("small",{children:[" · ",k.status==="up"?w("node-sessions").replace("{n}",String((k.cells||[]).length+(k.unmanaged||[]).length)):k.health&&jm(k.health)||Kc(k)]}),k.direct&&k.health&&k.health.managed!==!1&&h.jsx("button",{type:"button",className:`nc-power${k.tunnelStatus==="up"?" on":""}`,title:k.tunnelStatus==="up"?w("power-off"):w("power-on"),onClick:()=>f&&f(k),children:h.jsx(Oe,{name:"power",size:14})})]}),k.status==="up"&&h.jsxs("div",{className:"nc-side-group",children:[(k.cells||[]).map(K=>{const ne=!!K.tmux,B=K.degraded?"warn":K.tmux?"on":"";return h.jsxs("div",{className:`nc-side-card nc-cell${ne?" live":""}${H.has(K.key)?" active":""}`,title:K.active?w("cell-on"):w("cell-off"),draggable:ne,onDragStart:ne?se=>se.dataTransfer.setData("text/nc-session",K.key):void 0,onClick:ne?()=>l&&l(K.key):void 0,onDoubleClick:ne?()=>o&&o({session:K.tmuxSession,node:I}):void 0,children:[h.jsx("span",{className:`nc-dot ${B}`}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:K.cell}),h.jsxs("small",{children:[K.engine,K.key?`·${K.key}`:"",K.active?"":` · ${w("cell-off")}`]})]}),(k.capabilities||[]).includes(K.active?"down":"up")&&h.jsx("button",{className:`nc-power${K.active?" on":""}${K.degraded?" warn":""}`,onClick:se=>{se.stopPropagation(),u&&u({...K,route:k.route,availableEngines:k.engines||[]})},title:K.active?w("power-off"):w("power-on"),children:h.jsx(Oe,{name:"power",size:14})})]},K.key)}),(k.unmanaged||[]).map(K=>h.jsxs("div",{className:`nc-side-card${H.has(K.key)?" active":""}`,draggable:!0,onDragStart:ne=>ne.dataTransfer.setData("text/nc-session",K.key),onClick:()=>l&&l(K.key),onDoubleClick:()=>o&&o({session:K.name,node:K.node}),children:[h.jsx("span",{className:K.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:K.name}),h.jsx("small",{children:K.preview?K.preview:K.cmd?K.cmd:w("windows").replace("{n}",String(K.windows||0))})]}),K.activity?h.jsx("span",{className:"nc-rel",children:Ra(K.activity)}):null,h.jsx("button",{className:"nc-menu",title:w("terminate"),onClick:ne=>{ne.stopPropagation(),window.confirm(w("terminate-confirm").replace("{name}",K.name))&&m&&m(K.name,k.route)},children:"⋯"})]},K.key)),(k.cells||[]).length===0&&(k.unmanaged||[]).length===0&&h.jsx("div",{className:"nc-empty",children:w("no-sessions-short")})]})]},`nodo-${(k.route||[k.name]).join("/")}`)}),h.jsx("div",{className:"nc-side-lang",children:qg.map((k,V)=>h.jsxs("span",{children:[V>0&&" · ",h.jsx("button",{className:`nc-lang-btn${x===k?" on":""}`,onClick:()=>E(k),title:k,children:k.toUpperCase()})]},k))}),h.jsx("div",{className:"nc-side-resize",onPointerDown:Q,title:""})]})}const Dh=9,Pa=.2,wb=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,nh=e=>wb.test(e)&&new Set(e.split("/")).size===e.split("/").length;function js(e){if(typeof e=="string"&&e){const t=e.indexOf(":");if(t<0)return{session:e};const r=e.slice(0,t),n=e.slice(t+1);return!nh(r)||!n?null:{session:n,node:r}}return e&&typeof e=="object"&&typeof e.session=="string"&&e.session?e.node===void 0||e.node===null||e.node===""?{session:e.session}:typeof e.node=="string"&&nh(e.node)?{session:e.session,node:e.node}:null:null}function ni(e){const t=js(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const F_=9,H_=24,Vn=11,bb=e=>{const t=Number(e);return t>=F_&&t<=H_?t:Vn};function Da(){return{columns:[]}}function Pi(e){return e.columns.flatMap(t=>t.tiles.map(r=>ni(r)))}function Cb(e){const t=[],r=Math.max(0,...e.columns.map(n=>n.tiles.length));for(let n=0;n<r;n+=1)for(const o of e.columns)o.tiles[n]&&t.push(ni(o.tiles[n]));return t}const Os=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(r=>({...r}))}))});function Mh(e,t,r,n){const o=js(t);if(!o||Pi(e).includes(ni(o))||Pi(e).length>=Dh)return e;const l=Os(e),u={session:o.session,height:1,fontSize:Vn,...n||{}};if(o.node&&(u.node=o.node),r==="end")return l.columns.push({width:1,tiles:[u]}),l;if(r&&typeof r.col=="number"&&typeof r.row=="number"&&l.columns[r.col])return l.columns[r.col].tiles.splice(r.row,0,u),l;if(r&&typeof r.col=="number"){const f=Math.max(0,Math.min(l.columns.length,r.col));return l.columns.splice(f,0,{width:1,tiles:[u]}),l}return l.columns.push({width:1,tiles:[u]}),l}function $_(e,t){const r=ni(t);if(!r||Pi(e).includes(r)||Pi(e).length>=Dh)return e;const n=Pi(e).length+1,o=Math.ceil(Math.sqrt(n));if(e.columns.length>=o){let p=0;for(let y=1;y<e.columns.length;y+=1)e.columns[y].tiles.length<e.columns[p].tiles.length&&(p=y);return Mh(e,t,{col:p,row:e.columns[p].tiles.length})}const l=[...Cb(e),r],u=new Map(e.columns.flatMap(p=>p.tiles.map(y=>[ni(y),y]))),f=e.columns.length?e.columns.reduce((p,y)=>p+(Number(y.width)||1),0)/e.columns.length:1,m=Array.from({length:o},(p,y)=>{var S;return{width:((S=e.columns[y])==null?void 0:S.width)||f,tiles:[]}});return l.forEach((p,y)=>{const S=js(p);if(!S)return;const v=u.get(p)||{},_={session:S.session,height:v.height||1,fontSize:v.fontSize||Vn};S.node&&(_.node=S.node),m[y%o].tiles.push(_)}),{columns:m.filter(p=>p.tiles.length)}}function Ma(e,t){const r=ni(t),n=Os(e);for(const o of n.columns)o.tiles=o.tiles.filter(l=>ni(l)!==r);return n.columns=n.columns.filter(o=>o.tiles.length>0),n}function xb(e,t,r){const n=ni(t);if(!Pi(e).includes(n))return e;const o=e.columns.flatMap(l=>l.tiles).find(l=>ni(l)===n);return Mh(Ma(e,n),n,r,{fontSize:o.fontSize,height:o.height})}function kb(e,t){if(!(t instanceof Map)||t.size===0)return e;let r=!1;const n=Os(e);for(const o of n.columns)for(const l of o.tiles){const u=t.get(ni(l));if(!u)continue;const f=js(u);f&&(l.session=f.session,f.node?l.node=f.node:delete l.node,r=!0)}return r?Hi(n):e}function Eb(e,t,r){const n=Os(e);return n.columns[t]&&(n.columns[t].width=Math.max(Pa,Number(r)||1)),n}function Nb(e,t,r,n){const o=Os(e),l=o.columns[t]&&o.columns[t].tiles[r];return l&&(l.height=Math.max(Pa,Number(n)||1)),o}function Rb(e,t,r,n){if(!(e.columns[t]&&e.columns[t].tiles[r]))return e;const l=Os(e),u=l.columns[t].tiles[r],f=Number(u.fontSize)||Vn;return u.fontSize=Math.max(F_,Math.min(H_,f+(Number(n)||0))),l}function Pb(e,t,r,n){const o=e.columns[t];if(!o||!o.tiles[r])return null;switch(n){case"left":return{col:t};case"right":return{col:t+1};case"top":return{col:t,row:r};case"bottom":return{col:t,row:r+1};default:return null}}function Bm(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function Hi(e){if(!e||!Array.isArray(e.columns))return Da();const t=e.columns.map(n=>({width:Math.max(Pa,Number(n&&n.width)||1),tiles:(Array.isArray(n&&n.tiles)?n.tiles:[]).filter(o=>o&&typeof o.session=="string"&&o.session).filter(o=>o.node==null||typeof o.node=="string"&&nh(o.node)).map(o=>{const l={session:o.session,height:Math.max(Pa,Number(o.height)||1),fontSize:bb(o.fontSize)};return o.node!=null&&(l.node=o.node),l})})).filter(n=>n.tiles.length>0),r=new Set;for(const n of t)n.tiles=n.tiles.filter(o=>!r.has(ni(o))&&r.add(ni(o))&&r.size<=Dh);return{columns:t.filter(n=>n.tiles.length>0)}}function Db({session:e,node:t,token:r,readonly:n=!1,focused:o,onFocus:l,onClose:u,onOpenSingle:f,alive:m=!0,fontSize:p=Vn,onZoom:y,decks:S=[],currentDeck:v,onSendToDeck:_}){const b=M.useRef(()=>{}),x=M.useRef(()=>!1),E=M.useRef(()=>{}),N=M.useRef(!1),[$,z]=M.useState(!1),[j,U]=M.useState(!1),[O,F]=M.useState(!1),[Z,R]=M.useState(null),H=t?`${t}:${e}`:e;return h.jsxs("div",{className:`nc-tile${o?" focused":""}`,onMouseDown:()=>l&&l(H),children:[h.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:A=>{A.dataTransfer.setData("text/nc-session",H),A.dataTransfer.effectAllowed="move"},children:[h.jsxs("button",{className:"nc-tile-name",onClick:()=>l&&l(H),children:[h.jsx("span",{className:m?"nc-dot on":"nc-dot"}),h.jsx("b",{children:e}),t&&h.jsxs("small",{className:"nc-tile-node",children:["@",t]})]}),h.jsxs("span",{className:"nc-tile-actions",children:[y&&h.jsx("button",{onClick:()=>y(-1),title:w("zoom-out"),children:h.jsx(Oe,{name:"zoomOut",size:14})}),y&&h.jsx("button",{onClick:()=>y(1),title:w("zoom-in"),children:h.jsx(Oe,{name:"zoomIn",size:14})}),_&&S.filter(A=>A!==v).length>0&&h.jsxs("select",{className:"nc-tile-deck",title:w("send-to-deck"),value:"",onMouseDown:A=>A.stopPropagation(),onChange:A=>{const P=A.target.value;P&&_(H,P),A.target.value=""},children:[h.jsx("option",{value:"",children:w("send-to-deck")}),S.filter(A=>A!==v).map(A=>h.jsx("option",{value:A,children:A},A))]}),h.jsx("button",{onClick:()=>U(A=>!A),title:"composer",children:"⌨"}),h.jsx("button",{onClick:()=>F(A=>!A),title:"file",children:"📁"}),f&&h.jsx("button",{onClick:()=>f({session:e,node:t}),title:"vista singola",children:"↗"}),u&&h.jsx("button",{className:"nc-tile-close",onClick:()=>u(H),title:"chiudi",children:"✕"})]})]}),h.jsxs("div",{className:"nc-tile-body",children:[h.jsx(I_,{session:e,node:t,token:r,readonly:n,takeSize:!1,focused:o,sendRef:b,composerRef:x,actionRef:E,ctrlRef:N,setCtrlArmed:z,onFiles:R,fontSize:p}),O&&h.jsx("div",{className:"nc-tile-files",onMouseDown:A=>A.stopPropagation(),children:h.jsx(O_,{session:e,node:t,token:r,filesEvent:Z,onClose:()=>F(!1)})})]}),j&&h.jsx("div",{className:"nc-tile-composer",onMouseDown:A=>A.stopPropagation(),children:h.jsx(z_,{submitText:A=>x.current(A),token:r,session:e,node:t})})]})}const Am=.2,Im=.28,W_=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),Vc=e=>W_(e,"text/nc-session"),Om=e=>{var t;return W_(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function Mb(e,t,r){const n=(e-r.left)/(r.width||1),o=(t-r.top)/(r.height||1);return n<Im?"left":n>1-Im?"right":o<.5?"top":"bottom"}function Lb({layout:e,onLayoutChange:t,token:r,readonly:n=!1,sessionsAlive:o,focusSession:l,onFocus:u,onOpenSingle:f,decks:m=[],currentDeck:p,onSendToDeck:y}){ai();const[S,v]=M.useState(null),_=M.useRef(null),b=M.useRef([]),x=M.useRef(null);function E(R,H){const A=()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",A),window.removeEventListener("pointercancel",A),window.removeEventListener("blur",A),x.current=null};window.addEventListener("pointermove",R),window.addEventListener("pointerup",A),window.addEventListener("pointercancel",A),window.addEventListener("blur",A),x.current=A}M.useEffect(()=>()=>{x.current&&x.current()},[]),M.useEffect(()=>{const R=()=>v(null);return window.addEventListener("dragend",R),window.addEventListener("drop",R),()=>{window.removeEventListener("dragend",R),window.removeEventListener("drop",R)}},[]);const N=e.columns.length,$=R=>S&&S.col===R&&S.row===void 0,z=!!S&&S.col===N,j=(R,H)=>S&&S.col===R&&S.row===H&&S.quadrant?` drop-${S.quadrant}`:"";function U(R){if(R.preventDefault(),Om(R.dataTransfer)){v(null);return}const H=R.dataTransfer.getData("text/nc-session"),A=S;if(v(null),!H||!A)return;let P;if(A.quadrant){if(P=Pb(e,A.col,A.row,A.quadrant),!P)return}else P={col:A.col};t(Pi(e).includes(H)?xb(e,H,P):Mh(e,H,P))}function O(R,H){R.preventDefault(),R.stopPropagation();const A=R.clientX,P=e.columns[H].width,L=_.current&&_.current.clientWidth||1,T=e.columns[H+1];E(Q=>{let G=Math.max(Am,P+(Q.clientX-A)/L);if(T){const k=Bm(G/(G+T.width));G=k/(1-k)*T.width}t(Eb(e,H,G))})}function F(R,H,A){R.preventDefault(),R.stopPropagation();const P=R.clientY,L=e.columns[H].tiles[A].height,T=b.current[H],Y=T&&T.clientHeight||1,Q=e.columns[H].tiles[A+1];E(k=>{let V=Math.max(Am,L+(k.clientY-P)/Y);if(Q){const re=Bm(V/(V+Q.height));V=re/(1-re)*Q.height}t(Nb(e,H,A,V))})}function Z(R){t(Ma(e,R))}return h.jsxs("div",{className:"nc-grid",ref:_,onDragOver:R=>{if(Om(R.dataTransfer)){R.preventDefault(),v(null);return}Vc(R.dataTransfer)&&(R.preventDefault(),S&&S.col===N||v({col:N}))},onDrop:U,onDragLeave:R=>{const H=R.relatedTarget;(!H||!(_.current&&_.current.contains(H)))&&v(null)},children:[e.columns.flatMap((R,H)=>{const A=[];return A.push(h.jsx("div",{className:`nc-col${$(H)?" drop-newcol":""}`,ref:P=>{b.current[H]=P},style:{flexGrow:R.width,flexBasis:0},onDragOver:P=>{Vc(P.dataTransfer)&&(P.preventDefault(),P.stopPropagation(),S&&S.col===H&&S.row===void 0||v({col:H}))},children:R.tiles.flatMap((P,L)=>{const T=[],Y=ni(P);return T.push(h.jsx("div",{className:`nc-tile-slot${j(H,L)}`,style:{flexGrow:P.height,flexBasis:0},onDragOver:Q=>{if(!Vc(Q.dataTransfer))return;Q.preventDefault(),Q.stopPropagation();const G=Mb(Q.clientX,Q.clientY,Q.currentTarget.getBoundingClientRect());S&&S.col===H&&S.row===L&&S.quadrant===G||v({col:H,row:L,quadrant:G})},children:h.jsx(Db,{session:P.session,node:P.node,token:r,readonly:n,focused:l===Y,onFocus:u,onClose:Z,onOpenSingle:f,alive:!o||o.has(Y),fontSize:P.fontSize,onZoom:Q=>t(Rb(e,H,L,Q)),decks:m,currentDeck:p,onSendToDeck:y})},Y)),L<R.tiles.length-1&&T.push(h.jsx("div",{className:"nc-divider-h",onPointerDown:Q=>F(Q,H,L)},`h${L}`)),T})},`c${H}`)),H<N-1&&A.push(h.jsx("div",{className:"nc-divider-v",onPointerDown:P=>O(P,H)},`v${H}`)),A}),z&&h.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),N===0&&h.jsx("div",{className:"nc-grid-empty",children:w("grid-empty")})]})}const Tb=/^[a-z0-9-]{1,32}$/,si="main",U_="nc_decks",jb=24;function zm(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function La(e){return typeof e=="string"&&Tb.test(e)}function Bb(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let r;try{r=decodeURIComponent(t[1])}catch{r=t[1]}return La(r)?r:si}return si}function Yc(e,t){const r=e===si?"/":`/deck/${encodeURIComponent(e)}`;return t?`${r}#token=${encodeURIComponent(t)}`:r}function q_(e){return e===si?"nc_grid_v1":`nc_grid_v1__${e}`}function K_(e){const t=[si];if(Array.isArray(e)){for(const r of e)if(La(r)&&r!==si&&!t.includes(r)&&t.push(r),t.length>=jb)break}return t}function Oa(){return typeof localStorage<"u"?localStorage:null}function Ab(){const e=Oa();if(!e)return[si];try{return K_(JSON.parse(e.getItem(U_)||"null"))}catch{return[si]}}function Ib(e){const t=Oa();if(t)try{t.setItem(U_,JSON.stringify(K_(e)))}catch{}}function oh(e){const t=Oa();if(!t)return null;try{return JSON.parse(t.getItem(q_(e))||"null")}catch{return null}}function Ob(e,t){const r=Oa();if(r)try{r.setItem(q_(e),JSON.stringify(t))}catch{}}function zb({decks:e=[],currentDeck:t=si,onCreate:r,onRename:n,onDelete:o,onOpenWindow:l,onNavigate:u,saveState:f="idle",error:m="",sidebarVisible:p,onToggleSidebar:y}){ai();const[S,v]=M.useState(!1),[_,b]=M.useState(""),[x,E]=M.useState(!1),[N,$]=M.useState(""),[z,j]=M.useState(""),U=zm(_),O=La(U),F=async()=>{if(O){E(!0),$("");try{r&&await r(U),b(""),v(!1)}catch(H){$(String(H.message||H))}E(!1)}},Z=H=>{j(""),l&&l(H)||j(H)},R=async H=>{if(!(H===t||!u||x)){E(!0),$("");try{await u(H)}catch(A){$(String((A==null?void 0:A.message)||A))}E(!1)}};return h.jsxs("div",{className:"nc-deckbar",children:[y&&h.jsx("button",{className:"nc-deck-sidebar-toggle",title:w("toggle-sidebar"),onClick:y,children:p?"◀":"☰"}),h.jsx("span",{className:"nc-deckbar-label",children:w("decks")}),h.jsx("div",{className:"nc-deck-chips",children:e.map(H=>h.jsxs("span",{className:`nc-deck-chip${H===t?" current":""}`,children:[h.jsxs("button",{className:"nc-deck-open",title:H===t?w("deck-current"):H,disabled:x,onClick:()=>R(H),children:[H,H===t?" •":""]}),h.jsx("button",{className:"nc-deck-mini",title:w("detach-deck"),onClick:()=>Z(H),children:"↗"}),H!==si&&h.jsxs(h.Fragment,{children:[h.jsx("button",{className:"nc-deck-mini",title:w("rename-deck"),onClick:()=>{const A=(typeof window<"u"?window.prompt(w("rename-deck"),H):"")||"",P=zm(A);La(P)&&P!==H&&n&&n(H,P).catch(L=>$(String(L.message||L)))},children:"✎"}),h.jsx("button",{className:"nc-deck-mini nc-deck-del",title:w("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(w("delete-deck-confirm").replace("{name}",H)))&&o&&o(H).catch(A=>$(String(A.message||A)))},children:"✕"})]})]},H))}),S?h.jsxs("span",{className:"nc-deck-add",children:[h.jsx("input",{autoFocus:!0,className:O||!_?"":"invalid",placeholder:w("deck-name"),value:_,onChange:H=>b(H.target.value),onKeyDown:H=>{H.key==="Enter"&&F(),H.key==="Escape"&&(b(""),v(!1))}}),_&&O&&U!==_&&h.jsxs("span",{className:"nc-deck-slug",children:["→ ",U]}),h.jsx("button",{className:"nc-deck-ok",disabled:!O||x,onClick:F,children:w("create")}),h.jsx("button",{className:"nc-deck-cancel",onClick:()=>{b(""),v(!1)},children:w("cancel")})]}):h.jsxs("button",{className:"nc-deck-newbtn",title:w("new-deck"),onClick:()=>v(!0),children:["+ ",w("new-deck")]}),h.jsx("span",{className:`nc-deck-state ${f}`,title:w("deck-autosave"),children:w(f==="saving"?"saving":f==="saved"?"saved":"deck-autosave")}),(N||m)&&h.jsx("span",{className:"nc-deck-error",children:N||m}),z&&h.jsx("a",{className:"nc-deck-fallback",href:`/deck/${encodeURIComponent(z)}`,target:"_blank",rel:"noreferrer",children:w("popup-blocked")})]})}var Ds={},Xc,Fm;function Fb(){return Fm||(Fm=1,Xc=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Xc}var Gc={},Nr={},Hm;function is(){if(Hm)return Nr;Hm=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 Nr.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17},Nr.getSymbolTotalCodewords=function(n){return t[n]},Nr.getBCHDigit=function(r){let n=0;for(;r!==0;)n++,r>>>=1;return n},Nr.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');e=n},Nr.isKanjiModeEnabled=function(){return typeof e<"u"},Nr.toSJIS=function(n){return e(n)},Nr}var Qc={},$m;function Lh(){return $m||($m=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.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: "+r)}}e.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},e.from=function(n,o){if(e.isValid(n))return n;try{return t(n)}catch{return o}}})(Qc)),Qc}var Jc,Wm;function Hb(){if(Wm)return Jc;Wm=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const r=Math.floor(t/8);return(this.buffer[r]>>>7-t%8&1)===1},put:function(t,r){for(let n=0;n<r;n++)this.putBit((t>>>r-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),t&&(this.buffer[r]|=128>>>this.length%8),this.length++}},Jc=e,Jc}var Zc,Um;function $b(){if(Um)return Zc;Um=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,r,n,o){const l=t*this.size+r;this.data[l]=n,o&&(this.reservedBit[l]=!0)},e.prototype.get=function(t,r){return this.data[t*this.size+r]},e.prototype.xor=function(t,r,n){this.data[t*this.size+r]^=n},e.prototype.isReserved=function(t,r){return this.reservedBit[t*this.size+r]},Zc=e,Zc}var eu={},qm;function Wb(){return qm||(qm=1,(function(e){const t=is().getSymbolSize;e.getRowColCoords=function(n){if(n===1)return[];const o=Math.floor(n/7)+2,l=t(n),u=l===145?26:Math.ceil((l-13)/(2*o-2))*2,f=[l-7];for(let m=1;m<o-1;m++)f[m]=f[m-1]-u;return f.push(6),f.reverse()},e.getPositions=function(n){const o=[],l=e.getRowColCoords(n),u=l.length;for(let f=0;f<u;f++)for(let m=0;m<u;m++)f===0&&m===0||f===0&&m===u-1||f===u-1&&m===0||o.push([l[f],l[m]]);return o}})(eu)),eu}var tu={},Km;function Ub(){if(Km)return tu;Km=1;const e=is().getSymbolSize,t=7;return tu.getPositions=function(n){const o=e(n);return[[0,0],[o-t,0],[0,o-t]]},tu}var iu={},Vm;function qb(){return Vm||(Vm=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.getPenaltyN1=function(o){const l=o.size;let u=0,f=0,m=0,p=null,y=null;for(let S=0;S<l;S++){f=m=0,p=y=null;for(let v=0;v<l;v++){let _=o.get(S,v);_===p?f++:(f>=5&&(u+=t.N1+(f-5)),p=_,f=1),_=o.get(v,S),_===y?m++:(m>=5&&(u+=t.N1+(m-5)),y=_,m=1)}f>=5&&(u+=t.N1+(f-5)),m>=5&&(u+=t.N1+(m-5))}return u},e.getPenaltyN2=function(o){const l=o.size;let u=0;for(let f=0;f<l-1;f++)for(let m=0;m<l-1;m++){const p=o.get(f,m)+o.get(f,m+1)+o.get(f+1,m)+o.get(f+1,m+1);(p===4||p===0)&&u++}return u*t.N2},e.getPenaltyN3=function(o){const l=o.size;let u=0,f=0,m=0;for(let p=0;p<l;p++){f=m=0;for(let y=0;y<l;y++)f=f<<1&2047|o.get(p,y),y>=10&&(f===1488||f===93)&&u++,m=m<<1&2047|o.get(y,p),y>=10&&(m===1488||m===93)&&u++}return u*t.N3},e.getPenaltyN4=function(o){let l=0;const u=o.data.length;for(let m=0;m<u;m++)l+=o.data[m];return Math.abs(Math.ceil(l*100/u/5)-10)*t.N4};function r(n,o,l){switch(n){case e.Patterns.PATTERN000:return(o+l)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return l%3===0;case e.Patterns.PATTERN011:return(o+l)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(l/3))%2===0;case e.Patterns.PATTERN101:return o*l%2+o*l%3===0;case e.Patterns.PATTERN110:return(o*l%2+o*l%3)%2===0;case e.Patterns.PATTERN111:return(o*l%3+(o+l)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}e.applyMask=function(o,l){const u=l.size;for(let f=0;f<u;f++)for(let m=0;m<u;m++)l.isReserved(m,f)||l.xor(m,f,r(o,m,f))},e.getBestMask=function(o,l){const u=Object.keys(e.Patterns).length;let f=0,m=1/0;for(let p=0;p<u;p++){l(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,f=p)}return f}})(iu)),iu}var ha={},Ym;function V_(){if(Ym)return ha;Ym=1;const e=Lh(),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],r=[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 ha.getBlocksCount=function(o,l){switch(l){case e.L:return t[(o-1)*4+0];case e.M:return t[(o-1)*4+1];case e.Q:return t[(o-1)*4+2];case e.H:return t[(o-1)*4+3];default:return}},ha.getTotalCodewordsCount=function(o,l){switch(l){case e.L:return r[(o-1)*4+0];case e.M:return r[(o-1)*4+1];case e.Q:return r[(o-1)*4+2];case e.H:return r[(o-1)*4+3];default:return}},ha}var ru={},Dn={},Xm;function Kb(){if(Xm)return Dn;Xm=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let n=1;for(let o=0;o<255;o++)e[o]=n,t[n]=o,n<<=1,n&256&&(n^=285);for(let o=255;o<512;o++)e[o]=e[o-255]})(),Dn.log=function(n){if(n<1)throw new Error("log("+n+")");return t[n]},Dn.exp=function(n){return e[n]},Dn.mul=function(n,o){return n===0||o===0?0:e[t[n]+t[o]]},Dn}var Gm;function Vb(){return Gm||(Gm=1,(function(e){const t=Kb();e.mul=function(n,o){const l=new Uint8Array(n.length+o.length-1);for(let u=0;u<n.length;u++)for(let f=0;f<o.length;f++)l[u+f]^=t.mul(n[u],o[f]);return l},e.mod=function(n,o){let l=new Uint8Array(n);for(;l.length-o.length>=0;){const u=l[0];for(let m=0;m<o.length;m++)l[m]^=t.mul(o[m],u);let f=0;for(;f<l.length&&l[f]===0;)f++;l=l.slice(f)}return l},e.generateECPolynomial=function(n){let o=new Uint8Array([1]);for(let l=0;l<n;l++)o=e.mul(o,new Uint8Array([1,t.exp(l)]));return o}})(ru)),ru}var su,Qm;function Yb(){if(Qm)return su;Qm=1;const e=Vb();function t(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(n){this.degree=n,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(n.length+this.degree);o.set(n);const l=e.mod(o,this.genPoly),u=this.degree-l.length;if(u>0){const f=new Uint8Array(this.degree);return f.set(l,u),f}return l},su=t,su}var nu={},ou={},au={},Jm;function Y_(){return Jm||(Jm=1,au.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),au}var zi={},Zm;function X_(){if(Zm)return zi;Zm=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";r=r.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+r+`)(?:.|[\r
82
- ]))+`;zi.KANJI=new RegExp(r,"g"),zi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),zi.BYTE=new RegExp(n,"g"),zi.NUMERIC=new RegExp(e,"g"),zi.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+r+"$"),l=new RegExp("^"+e+"$"),u=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return zi.testKanji=function(m){return o.test(m)},zi.testNumeric=function(m){return l.test(m)},zi.testAlphanumeric=function(m){return u.test(m)},zi}var eg;function rs(){return eg||(eg=1,(function(e){const t=Y_(),r=X_();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(l,u){if(!l.ccBits)throw new Error("Invalid mode: "+l);if(!t.isValid(u))throw new Error("Invalid version: "+u);return u>=1&&u<10?l.ccBits[0]:u<27?l.ccBits[1]:l.ccBits[2]},e.getBestModeForData=function(l){return r.testNumeric(l)?e.NUMERIC:r.testAlphanumeric(l)?e.ALPHANUMERIC:r.testKanji(l)?e.KANJI:e.BYTE},e.toString=function(l){if(l&&l.id)return l.id;throw new Error("Invalid mode")},e.isValid=function(l){return l&&l.bit&&l.ccBits};function n(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+o)}}e.from=function(l,u){if(e.isValid(l))return l;try{return n(l)}catch{return u}}})(ou)),ou}var tg;function Xb(){return tg||(tg=1,(function(e){const t=is(),r=V_(),n=Lh(),o=rs(),l=Y_(),u=7973,f=t.getBCHDigit(u);function m(v,_,b){for(let x=1;x<=40;x++)if(_<=e.getCapacity(x,b,v))return x}function p(v,_){return o.getCharCountIndicator(v,_)+4}function y(v,_){let b=0;return v.forEach(function(x){const E=p(x.mode,_);b+=E+x.getBitsLength()}),b}function S(v,_){for(let b=1;b<=40;b++)if(y(v,b)<=e.getCapacity(b,_,o.MIXED))return b}e.from=function(_,b){return l.isValid(_)?parseInt(_,10):b},e.getCapacity=function(_,b,x){if(!l.isValid(_))throw new Error("Invalid QR Code version");typeof x>"u"&&(x=o.BYTE);const E=t.getSymbolTotalCodewords(_),N=r.getTotalCodewordsCount(_,b),$=(E-N)*8;if(x===o.MIXED)return $;const z=$-p(x,_);switch(x){case o.NUMERIC:return Math.floor(z/10*3);case o.ALPHANUMERIC:return Math.floor(z/11*2);case o.KANJI:return Math.floor(z/13);case o.BYTE:default:return Math.floor(z/8)}},e.getBestVersionForData=function(_,b){let x;const E=n.from(b,n.M);if(Array.isArray(_)){if(_.length>1)return S(_,E);if(_.length===0)return 1;x=_[0]}else x=_;return m(x.mode,x.getLength(),E)},e.getEncodedBits=function(_){if(!l.isValid(_)||_<7)throw new Error("Invalid QR Code version");let b=_<<12;for(;t.getBCHDigit(b)-f>=0;)b^=u<<t.getBCHDigit(b)-f;return _<<12|b}})(nu)),nu}var lu={},ig;function Gb(){if(ig)return lu;ig=1;const e=is(),t=1335,r=21522,n=e.getBCHDigit(t);return lu.getEncodedBits=function(l,u){const f=l.bit<<3|u;let m=f<<10;for(;e.getBCHDigit(m)-n>=0;)m^=t<<e.getBCHDigit(m)-n;return(f<<10|m)^r},lu}var cu={},uu,rg;function Qb(){if(rg)return uu;rg=1;const e=rs();function t(r){this.mode=e.NUMERIC,this.data=r.toString()}return t.getBitsLength=function(n){return 10*Math.floor(n/3)+(n%3?n%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(n){let o,l,u;for(o=0;o+3<=this.data.length;o+=3)l=this.data.substr(o,3),u=parseInt(l,10),n.put(u,10);const f=this.data.length-o;f>0&&(l=this.data.substr(o),u=parseInt(l,10),n.put(u,f*3+1))},uu=t,uu}var hu,sg;function Jb(){if(sg)return hu;sg=1;const e=rs(),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 r(n){this.mode=e.ALPHANUMERIC,this.data=n}return r.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(o){let l;for(l=0;l+2<=this.data.length;l+=2){let u=t.indexOf(this.data[l])*45;u+=t.indexOf(this.data[l+1]),o.put(u,11)}this.data.length%2&&o.put(t.indexOf(this.data[l]),6)},hu=r,hu}var du,ng;function Zb(){if(ng)return du;ng=1;const e=rs();function t(r){this.mode=e.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}return t.getBitsLength=function(n){return n*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(r){for(let n=0,o=this.data.length;n<o;n++)r.put(this.data[n],8)},du=t,du}var fu,og;function eC(){if(og)return fu;og=1;const e=rs(),t=is();function r(n){this.mode=e.KANJI,this.data=n}return r.getBitsLength=function(o){return o*13},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(n){let o;for(o=0;o<this.data.length;o++){let l=t.toSJIS(this.data[o]);if(l>=33088&&l<=40956)l-=33088;else if(l>=57408&&l<=60351)l-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
83
- Make sure your charset is UTF-8`);l=(l>>>8&255)*192+(l&255),n.put(l,13)}},fu=r,fu}var pu={exports:{}},ag;function tC(){return ag||(ag=1,(function(e){var t={single_source_shortest_paths:function(r,n,o){var l={},u={};u[n]=0;var f=t.PriorityQueue.make();f.push(n,0);for(var m,p,y,S,v,_,b,x,E;!f.empty();){m=f.pop(),p=m.value,S=m.cost,v=r[p]||{};for(y in v)v.hasOwnProperty(y)&&(_=v[y],b=S+_,x=u[y],E=typeof u[y]>"u",(E||x>b)&&(u[y]=b,f.push(y,b),l[y]=p))}if(typeof o<"u"&&typeof u[o]>"u"){var N=["Could not find a path from ",n," to ",o,"."].join("");throw new Error(N)}return l},extract_shortest_path_from_predecessor_list:function(r,n){for(var o=[],l=n;l;)o.push(l),r[l],l=r[l];return o.reverse(),o},find_path:function(r,n,o){var l=t.single_source_shortest_paths(r,n,o);return t.extract_shortest_path_from_predecessor_list(l,o)},PriorityQueue:{make:function(r){var n=t.PriorityQueue,o={},l;r=r||{};for(l in n)n.hasOwnProperty(l)&&(o[l]=n[l]);return o.queue=[],o.sorter=r.sorter||n.default_sorter,o},default_sorter:function(r,n){return r.cost-n.cost},push:function(r,n){var o={value:r,cost:n};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})(pu)),pu.exports}var lg;function iC(){return lg||(lg=1,(function(e){const t=rs(),r=Qb(),n=Jb(),o=Zb(),l=eC(),u=X_(),f=is(),m=tC();function p(N){return unescape(encodeURIComponent(N)).length}function y(N,$,z){const j=[];let U;for(;(U=N.exec(z))!==null;)j.push({data:U[0],index:U.index,mode:$,length:U[0].length});return j}function S(N){const $=y(u.NUMERIC,t.NUMERIC,N),z=y(u.ALPHANUMERIC,t.ALPHANUMERIC,N);let j,U;return f.isKanjiModeEnabled()?(j=y(u.BYTE,t.BYTE,N),U=y(u.KANJI,t.KANJI,N)):(j=y(u.BYTE_KANJI,t.BYTE,N),U=[]),$.concat(z,j,U).sort(function(F,Z){return F.index-Z.index}).map(function(F){return{data:F.data,mode:F.mode,length:F.length}})}function v(N,$){switch($){case t.NUMERIC:return r.getBitsLength(N);case t.ALPHANUMERIC:return n.getBitsLength(N);case t.KANJI:return l.getBitsLength(N);case t.BYTE:return o.getBitsLength(N)}}function _(N){return N.reduce(function($,z){const j=$.length-1>=0?$[$.length-1]:null;return j&&j.mode===z.mode?($[$.length-1].data+=z.data,$):($.push(z),$)},[])}function b(N){const $=[];for(let z=0;z<N.length;z++){const j=N[z];switch(j.mode){case t.NUMERIC:$.push([j,{data:j.data,mode:t.ALPHANUMERIC,length:j.length},{data:j.data,mode:t.BYTE,length:j.length}]);break;case t.ALPHANUMERIC:$.push([j,{data:j.data,mode:t.BYTE,length:j.length}]);break;case t.KANJI:$.push([j,{data:j.data,mode:t.BYTE,length:p(j.data)}]);break;case t.BYTE:$.push([{data:j.data,mode:t.BYTE,length:p(j.data)}])}}return $}function x(N,$){const z={},j={start:{}};let U=["start"];for(let O=0;O<N.length;O++){const F=N[O],Z=[];for(let R=0;R<F.length;R++){const H=F[R],A=""+O+R;Z.push(A),z[A]={node:H,lastCount:0},j[A]={};for(let P=0;P<U.length;P++){const L=U[P];z[L]&&z[L].node.mode===H.mode?(j[L][A]=v(z[L].lastCount+H.length,H.mode)-v(z[L].lastCount,H.mode),z[L].lastCount+=H.length):(z[L]&&(z[L].lastCount=H.length),j[L][A]=v(H.length,H.mode)+4+t.getCharCountIndicator(H.mode,$))}}U=Z}for(let O=0;O<U.length;O++)j[U[O]].end=0;return{map:j,table:z}}function E(N,$){let z;const j=t.getBestModeForData(N);if(z=t.from($,j),z!==t.BYTE&&z.bit<j.bit)throw new Error('"'+N+'" cannot be encoded with mode '+t.toString(z)+`.
84
- Suggested mode is: `+t.toString(j));switch(z===t.KANJI&&!f.isKanjiModeEnabled()&&(z=t.BYTE),z){case t.NUMERIC:return new r(N);case t.ALPHANUMERIC:return new n(N);case t.KANJI:return new l(N);case t.BYTE:return new o(N)}}e.fromArray=function($){return $.reduce(function(z,j){return typeof j=="string"?z.push(E(j,null)):j.data&&z.push(E(j.data,j.mode)),z},[])},e.fromString=function($,z){const j=S($,f.isKanjiModeEnabled()),U=b(j),O=x(U,z),F=m.find_path(O.map,"start","end"),Z=[];for(let R=1;R<F.length-1;R++)Z.push(O.table[F[R]].node);return e.fromArray(_(Z))},e.rawSplit=function($){return e.fromArray(S($,f.isKanjiModeEnabled()))}})(cu)),cu}var cg;function rC(){if(cg)return Gc;cg=1;const e=is(),t=Lh(),r=Hb(),n=$b(),o=Wb(),l=Ub(),u=qb(),f=V_(),m=Yb(),p=Xb(),y=Gb(),S=rs(),v=iC();function _(O,F){const Z=O.size,R=l.getPositions(F);for(let H=0;H<R.length;H++){const A=R[H][0],P=R[H][1];for(let L=-1;L<=7;L++)if(!(A+L<=-1||Z<=A+L))for(let T=-1;T<=7;T++)P+T<=-1||Z<=P+T||(L>=0&&L<=6&&(T===0||T===6)||T>=0&&T<=6&&(L===0||L===6)||L>=2&&L<=4&&T>=2&&T<=4?O.set(A+L,P+T,!0,!0):O.set(A+L,P+T,!1,!0))}}function b(O){const F=O.size;for(let Z=8;Z<F-8;Z++){const R=Z%2===0;O.set(Z,6,R,!0),O.set(6,Z,R,!0)}}function x(O,F){const Z=o.getPositions(F);for(let R=0;R<Z.length;R++){const H=Z[R][0],A=Z[R][1];for(let P=-2;P<=2;P++)for(let L=-2;L<=2;L++)P===-2||P===2||L===-2||L===2||P===0&&L===0?O.set(H+P,A+L,!0,!0):O.set(H+P,A+L,!1,!0)}}function E(O,F){const Z=O.size,R=p.getEncodedBits(F);let H,A,P;for(let L=0;L<18;L++)H=Math.floor(L/3),A=L%3+Z-8-3,P=(R>>L&1)===1,O.set(H,A,P,!0),O.set(A,H,P,!0)}function N(O,F,Z){const R=O.size,H=y.getEncodedBits(F,Z);let A,P;for(A=0;A<15;A++)P=(H>>A&1)===1,A<6?O.set(A,8,P,!0):A<8?O.set(A+1,8,P,!0):O.set(R-15+A,8,P,!0),A<8?O.set(8,R-A-1,P,!0):A<9?O.set(8,15-A-1+1,P,!0):O.set(8,15-A-1,P,!0);O.set(R-8,8,1,!0)}function $(O,F){const Z=O.size;let R=-1,H=Z-1,A=7,P=0;for(let L=Z-1;L>0;L-=2)for(L===6&&L--;;){for(let T=0;T<2;T++)if(!O.isReserved(H,L-T)){let Y=!1;P<F.length&&(Y=(F[P]>>>A&1)===1),O.set(H,L-T,Y),A--,A===-1&&(P++,A=7)}if(H+=R,H<0||Z<=H){H-=R,R=-R;break}}}function z(O,F,Z){const R=new r;Z.forEach(function(T){R.put(T.mode.bit,4),R.put(T.getLength(),S.getCharCountIndicator(T.mode,O)),T.write(R)});const H=e.getSymbolTotalCodewords(O),A=f.getTotalCodewordsCount(O,F),P=(H-A)*8;for(R.getLengthInBits()+4<=P&&R.put(0,4);R.getLengthInBits()%8!==0;)R.putBit(0);const L=(P-R.getLengthInBits())/8;for(let T=0;T<L;T++)R.put(T%2?17:236,8);return j(R,O,F)}function j(O,F,Z){const R=e.getSymbolTotalCodewords(F),H=f.getTotalCodewordsCount(F,Z),A=R-H,P=f.getBlocksCount(F,Z),L=R%P,T=P-L,Y=Math.floor(R/P),Q=Math.floor(A/P),G=Q+1,k=Y-Q,V=new m(k);let re=0;const I=new Array(P),K=new Array(P);let ne=0;const B=new Uint8Array(O.buffer);for(let ee=0;ee<P;ee++){const ge=ee<T?Q:G;I[ee]=B.slice(re,re+ge),K[ee]=V.encode(I[ee]),re+=ge,ne=Math.max(ne,ge)}const se=new Uint8Array(R);let ae=0,me,ue;for(me=0;me<ne;me++)for(ue=0;ue<P;ue++)me<I[ue].length&&(se[ae++]=I[ue][me]);for(me=0;me<k;me++)for(ue=0;ue<P;ue++)se[ae++]=K[ue][me];return se}function U(O,F,Z,R){let H;if(Array.isArray(O))H=v.fromArray(O);else if(typeof O=="string"){let Y=F;if(!Y){const Q=v.rawSplit(O);Y=p.getBestVersionForData(Q,Z)}H=v.fromString(O,Y||40)}else throw new Error("Invalid data");const A=p.getBestVersionForData(H,Z);if(!A)throw new Error("The amount of data is too big to be stored in a QR Code");if(!F)F=A;else if(F<A)throw new Error(`
85
- The chosen QR Code version cannot contain this amount of data.
86
- Minimum version required to store current data is: `+A+`.
87
- `);const P=z(F,Z,H),L=e.getSymbolSize(F),T=new n(L);return _(T,F),b(T),x(T,F),N(T,Z,0),F>=7&&E(T,F),$(T,P),isNaN(R)&&(R=u.getBestMask(T,N.bind(null,T,Z))),u.applyMask(R,T),N(T,Z,R),{modules:T,version:F,errorCorrectionLevel:Z,maskPattern:R,segments:H}}return Gc.create=function(F,Z){if(typeof F>"u"||F==="")throw new Error("No input text");let R=t.M,H,A;return typeof Z<"u"&&(R=t.from(Z.errorCorrectionLevel,t.M),H=p.from(Z.version),A=u.from(Z.maskPattern),Z.toSJISFunc&&e.setToSJISFunction(Z.toSJISFunc)),U(F,H,R,A)},Gc}var mu={},gu={},ug;function G_(){return ug||(ug=1,(function(e){function t(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let n=r.slice().replace("#","").split("");if(n.length<3||n.length===5||n.length>8)throw new Error("Invalid hex color: "+r);(n.length===3||n.length===4)&&(n=Array.prototype.concat.apply([],n.map(function(l){return[l,l]}))),n.length===6&&n.push("F","F");const o=parseInt(n.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+n.slice(0,6).join("")}}e.getOptions=function(n){n||(n={}),n.color||(n.color={});const o=typeof n.margin>"u"||n.margin===null||n.margin<0?4:n.margin,l=n.width&&n.width>=21?n.width:void 0,u=n.scale||4;return{width:l,scale:l?4:u,margin:o,color:{dark:t(n.color.dark||"#000000ff"),light:t(n.color.light||"#ffffffff")},type:n.type,rendererOpts:n.rendererOpts||{}}},e.getScale=function(n,o){return o.width&&o.width>=n+o.margin*2?o.width/(n+o.margin*2):o.scale},e.getImageWidth=function(n,o){const l=e.getScale(n,o);return Math.floor((n+o.margin*2)*l)},e.qrToImageData=function(n,o,l){const u=o.modules.size,f=o.modules.data,m=e.getScale(u,l),p=Math.floor((u+l.margin*2)*m),y=l.margin*m,S=[l.color.light,l.color.dark];for(let v=0;v<p;v++)for(let _=0;_<p;_++){let b=(v*p+_)*4,x=l.color.light;if(v>=y&&_>=y&&v<p-y&&_<p-y){const E=Math.floor((v-y)/m),N=Math.floor((_-y)/m);x=S[f[E*u+N]?1:0]}n[b++]=x.r,n[b++]=x.g,n[b++]=x.b,n[b]=x.a}}})(gu)),gu}var hg;function sC(){return hg||(hg=1,(function(e){const t=G_();function r(o,l,u){o.clearRect(0,0,l.width,l.height),l.style||(l.style={}),l.height=u,l.width=u,l.style.height=u+"px",l.style.width=u+"px"}function n(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(l,u,f){let m=f,p=u;typeof m>"u"&&(!u||!u.getContext)&&(m=u,u=void 0),u||(p=n()),m=t.getOptions(m);const y=t.getImageWidth(l.modules.size,m),S=p.getContext("2d"),v=S.createImageData(y,y);return t.qrToImageData(v.data,l,m),r(S,p,y),S.putImageData(v,0,0),p},e.renderToDataURL=function(l,u,f){let m=f;typeof m>"u"&&(!u||!u.getContext)&&(m=u,u=void 0),m||(m={});const p=e.render(l,u,m),y=m.type||"image/png",S=m.rendererOpts||{};return p.toDataURL(y,S.quality)}})(mu)),mu}var _u={},dg;function nC(){if(dg)return _u;dg=1;const e=G_();function t(o,l){const u=o.a/255,f=l+'="'+o.hex+'"';return u<1?f+" "+l+'-opacity="'+u.toFixed(2).slice(1)+'"':f}function r(o,l,u){let f=o+l;return typeof u<"u"&&(f+=" "+u),f}function n(o,l,u){let f="",m=0,p=!1,y=0;for(let S=0;S<o.length;S++){const v=Math.floor(S%l),_=Math.floor(S/l);!v&&!p&&(p=!0),o[S]?(y++,S>0&&v>0&&o[S-1]||(f+=p?r("M",v+u,.5+_+u):r("m",m,0),m=0,p=!1),v+1<l&&o[S+1]||(f+=r("h",y),y=0)):m++}return f}return _u.render=function(l,u,f){const m=e.getOptions(u),p=l.modules.size,y=l.modules.data,S=p+m.margin*2,v=m.color.light.a?"<path "+t(m.color.light,"fill")+' d="M0 0h'+S+"v"+S+'H0z"/>':"",_="<path "+t(m.color.dark,"stroke")+' d="'+n(y,p,m.margin)+'"/>',b='viewBox="0 0 '+S+" "+S+'"',E='<svg xmlns="http://www.w3.org/2000/svg" '+(m.width?'width="'+m.width+'" height="'+m.width+'" ':"")+b+' shape-rendering="crispEdges">'+v+_+`</svg>
88
- `;return typeof f=="function"&&f(null,E),E},_u}var fg;function oC(){if(fg)return Ds;fg=1;const e=Fb(),t=rC(),r=sC(),n=nC();function o(l,u,f,m,p){const y=[].slice.call(arguments,1),S=y.length,v=typeof y[S-1]=="function";if(!v&&!e())throw new Error("Callback required as last argument");if(v){if(S<2)throw new Error("Too few arguments provided");S===2?(p=f,f=u,u=m=void 0):S===3&&(u.getContext&&typeof p>"u"?(p=m,m=void 0):(p=m,m=f,f=u,u=void 0))}else{if(S<1)throw new Error("Too few arguments provided");return S===1?(f=u,u=m=void 0):S===2&&!u.getContext&&(m=f,f=u,u=void 0),new Promise(function(_,b){try{const x=t.create(f,m);_(l(x,u,m))}catch(x){b(x)}})}try{const _=t.create(f,m);p(null,l(_,u,m))}catch(_){p(_)}}return Ds.create=t.create,Ds.toCanvas=o.bind(null,r.render),Ds.toDataURL=o.bind(null,r.renderToDataURL),Ds.toString=o.bind(null,function(l,u,f){return n.render(l,f)}),Ds}var aC=oC();const lC=dh(aC),Q_=/^[a-z0-9-]{1,32}$/,cC=/^[A-Za-z0-9._-]{1,32}$/,uC=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,hC=320;function dC(e){return typeof e=="string"&&Q_.test(e)}const fC=64;function ah(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=fC&&!/[\x00-\x1f\x7f]/.test(t)}function Ls(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function J_(e){if(typeof e!="string"||!e||e.length>hC||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:cC.test(e.slice(0,t))&&uC.test(e.slice(t+1))}function pg(e){if(e===""||e===null||e===void 0)return null;const t=String(e).trim();if(!/^[0-9]{1,5}$/.test(t))return;const r=Number(t);return Number.isInteger(r)&&r>=1&&r<=65535?r:void 0}function pC({name:e,ssh:t,sshPort:r,remotePort:n}={}){const o=typeof e=="string"?e.trim():e,l=typeof t=="string"?t.trim():t;if(!dC(o))return{ok:!1,error:"err-node-name"};if(!J_(l))return{ok:!1,error:"err-ssh"};const u=pg(r);if(u===void 0)return{ok:!1,error:"err-ssh-port"};const f=pg(n);if(f===void 0)return{ok:!1,error:"err-node-port"};const m={name:o,ssh:l};return u!==null&&(m.sshPort=u),f!==null&&(m.remotePort=f),{ok:!0,value:m}}function mC(e,t){if(!e||!t||t<e)return null;const r=Math.floor((t-e)/1e3);return r<60?"ora":r<3600?`${Math.floor(r/60)}m`:r<86400?`${Math.floor(r/3600)}h`:`${Math.floor(r/86400)}g`}function gC(e,t){const r=!!(e&&e.status==="up"),n=!!(e&&e.status==="passive");return{up:r,...n?{passive:!0}:{},label:r?"tunnel-up":n?"node-passive":"tunnel-down",since:r?mC(e.since,t):null}}const _C=new Set(["v","instanceId","port","label","invite"]),vC=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function yC(e){const t=String(e).replace(/-/g,"+").replace(/_/g,"/"),r=t+"=".repeat((4-t.length%4)%4),n=typeof atob=="function"?atob(r):Buffer.from(r,"base64").toString("binary"),o=Uint8Array.from(n,l=>l.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function SC(e){let t="";try{const u=new URL(String(e));t=new URLSearchParams(u.hash.replace(/^#/,"")).get("pair")||""}catch{return{ok:!1}}if(!t)return{ok:!1};let r;try{r=JSON.parse(yC(t))}catch{return{ok:!1}}if(!r||typeof r!="object"||Array.isArray(r))return{ok:!1};const n=r.v===1?_C:r.v===2?vC:null;if(!n)return{ok:!1};for(const u of Object.keys(r))if(!n.has(u))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(r.instanceId)))return{ok:!1};const o=Number(r.port);if(!Number.isInteger(o)||o<1||o>65535)return{ok:!1};if(typeof r.label!="string")return{ok:!1};if(typeof r.invite!="string"||!r.invite)return{ok:!1};const l={ok:!0,version:r.v,label:r.label,invite:r.invite,instanceId:r.instanceId,port:o};if(r.v===2){if(r.name!==void 0){if(typeof r.name!="string"||!Q_.test(r.name))return{ok:!1};l.name=r.name}if(r.ssh!==void 0){if(!J_(r.ssh))return{ok:!1};l.ssh=String(r.ssh).trim()}if(r.sshPort!==void 0){const u=Number(r.sshPort);if(!Number.isInteger(u)||u<1||u>65535)return{ok:!1};l.sshPort=u}}return l}function wC(e,t,r=new Set){if(!t||!t.ok)return e;const n={...e},o=(l,u)=>{u==null||u===""||r.has(l)||(n[l]=u)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?Ls(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),n}function mg(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function bC(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const r=SC(t);if(!r||!r.ok)return{kind:"invalid"};const n=[];return r.ssh||n.push("ssh"),r.name||n.push("name"),n.length?{kind:"partial",decoded:r,missing:n}:{kind:"complete",decoded:r}}function CC(e,t,r=new Set,n=!1){if(!t||!t.ok)return e;const o=wC(e,t,r);return t.version===2&&t.name&&!r.has("name")&&!n&&(o.name=t.name),!r.has("label")&&!o.label&&t.label&&(o.label=t.label),o}function gg(e,t,r=new Set,n=!1){const o=String(t||"").trim(),l=bC(o);let u={...e,pairingUrl:o};return(l.kind==="complete"||l.kind==="partial")&&(u={...CC(u,l.decoded,r,n),pairingUrl:o}),{classification:l,form:u}}function xC(e,{deviceDefault:t=""}={}){const r={name:e.name,ssh:e.ssh,pairingUrl:e.pairingUrl,...e.label?{label:e.label}:{},...e.sshPort?{sshPort:Number(e.sshPort)}:{}},n=e.localLabel||t;return n&&(r.localLabel=n),r}function kC(){const e=new Set;let t=!1;return{canAuto(r){return!t&&!e.has(String(r||""))},start(r){return t?!1:(t=!0,e.add(String(r||"")),!0)},finish(){t=!1},reset(r){e.delete(String(r||""))},isBusy(){return t}}}const EC=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function NC(e){const t=e&&e.data||{},r=typeof t.stage=="string"&&t.stage?t.stage:"",n=typeof t.detail=="string"&&t.detail?t.detail:"";return{stage:r,code:typeof t.code=="string"?t.code:"",detail:n,hint:typeof t.hint=="string"?t.hint:"",retryable:typeof t.retryable=="boolean"?t.retryable:!r,message:n||String(e&&e.message||e)}}const RC="modulepreload",PC=function(e){return"/"+e},_g={},DC=function(t,r,n){let o=Promise.resolve();if(r&&r.length>0){let u=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 f=document.querySelector("meta[property=csp-nonce]"),m=(f==null?void 0:f.nonce)||(f==null?void 0:f.getAttribute("nonce"));o=u(r.map(p=>{if(p=PC(p),p in _g)return;_g[p]=!0;const y=p.endsWith(".css"),S=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${S}`))return;const v=document.createElement("link");if(v.rel=y?"stylesheet":RC,y||(v.as="script"),v.crossOrigin="",v.href=p,m&&v.setAttribute("nonce",m),document.head.appendChild(v),y)return new Promise((_,b)=>{v.addEventListener("load",_),v.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${p}`)))})}))}function l(u){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=u,window.dispatchEvent(f),!f.defaultPrevented)throw u}return o.then(u=>{for(const f of u||[])f.status==="rejected"&&l(f.reason);return t().catch(l)})};class De{constructor(t,r,n,o,l){this._legacyCanvasSize=De.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"),n&&typeof n=="object"?this._onDecode=r:(console.warn(n||o||l?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=r),r=typeof n=="object"?n:{},this._onDecodeError=r.onDecodeError||(typeof n=="function"?n:this._onDecodeError),this._calculateScanRegion=r.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=r.preferredCamera||l||this._preferredCamera,this._legacyCanvasSize=typeof n=="number"?n:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=r.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let u=!1;if(t.hidden&&(t.hidden=!1,u=!0),document.body.contains(t)||(document.body.appendChild(t),u=!0),n=t.parentElement,r.highlightScanRegion||r.highlightCodeOutline){if(o=!!r.overlay,this.$overlay=r.overlay||document.createElement("div"),l=this.$overlay.style,l.position="absolute",l.display="none",l.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!o&&r.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{}n.insertBefore(this.$overlay,this.$video.nextSibling)}r.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 f=window.getComputedStyle(t);f.display==="none"&&(t.style.setProperty("display","block","important"),u=!0),f.visibility!=="visible"&&(t.style.setProperty("visibility","visible","important"),u=!0),u&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),t.style.opacity="0",t.style.width="0",t.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),t.addEventListener("play",this._onPlay),t.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=De.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 De.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let r=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),n;try{t&&(await r()).every(o=>!o.label)&&(n=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await r()).map((o,l)=>({id:o.deviceId,label:o.label||(l===0?"Default Camera":`Camera ${l+1}`)}))}finally{n&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),De._stopVideoStream(n))}}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"),De._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(),De._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:r}=await this._getCameraStream();!this._active||this._paused?De._stopVideoStream(t):(this._setVideoMirror(r),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 r=()=>{this.$video.srcObject instanceof MediaStream&&(De._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(r(),!0):(await new Promise(n=>setTimeout(n,300)),this._paused?(r(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,r,n,o,l=!1,u=!1){let f,m=!1;r&&("scanRegion"in r||"qrEngine"in r||"canvas"in r||"disallowCanvasResizing"in r||"alsoTryWithoutScanRegion"in r||"returnDetailedScanResult"in r)?(f=r.scanRegion,n=r.qrEngine,o=r.canvas,l=r.disallowCanvasResizing||!1,u=r.alsoTryWithoutScanRegion||!1,m=!0):console.warn(r||n||o||l||u?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),r=!!n;try{let p,y;[n,p]=await Promise.all([n||De.createQrEngine(),De._loadImage(t)]),[o,y]=De._drawToCanvas(p,f,o,l);let S;if(n instanceof Worker){let v=n;r||De._postWorkerMessageSync(v,"inversionMode","both"),S=await new Promise((_,b)=>{let x,E,N,$=-1;E=j=>{j.data.id===$&&(v.removeEventListener("message",E),v.removeEventListener("error",N),clearTimeout(x),j.data.data!==null?_({data:j.data.data,cornerPoints:De._convertPoints(j.data.cornerPoints,f)}):b(De.NO_QR_CODE_FOUND))},N=j=>{v.removeEventListener("message",E),v.removeEventListener("error",N),clearTimeout(x),b("Scanner error: "+(j?j.message||j:"Unknown Error"))},v.addEventListener("message",E),v.addEventListener("error",N),x=setTimeout(()=>N("timeout"),1e4);let z=y.getImageData(0,0,o.width,o.height);$=De._postWorkerMessageSync(v,"decode",z,[z.data.buffer])})}else S=await Promise.race([new Promise((v,_)=>window.setTimeout(()=>_("Scanner error: timeout"),1e4)),(async()=>{try{var[v]=await n.detect(o);if(!v)throw De.NO_QR_CODE_FOUND;return{data:v.rawValue,cornerPoints:De._convertPoints(v.cornerPoints,f)}}catch(_){if(v=_.message||_,/not implemented|service unavailable/.test(v))return De._disableBarcodeDetector=!0,De.scanImage(t,{scanRegion:f,canvas:o,disallowCanvasResizing:l,alsoTryWithoutScanRegion:u});throw`Scanner error: ${v}`}})()]);return m?S:S.data}catch(p){if(!f||!u)throw p;let y=await De.scanImage(t,{qrEngine:n,canvas:o,disallowCanvasResizing:l});return m?y:y.data}finally{r||De._postWorkerMessage(n,"close")}}setGrayscaleWeights(t,r,n,o=!0){De._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:r,blue:n,useIntegerApproximation:o})}setInversionMode(t){De._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=()=>DC(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(n=>n.createWorker()),!(!De._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let r=navigator.userAgentData;return r&&r.brands.some(({brand:n})=>/Chromium/i.test(n))&&/mac ?OS/i.test(r.platform)&&await r.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:n,platformVersion:o})=>/arm/i.test(n||"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 r=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-r)/2),y:Math.round((t.videoHeight-r)/2),width:r,height:r,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,r=t.videoWidth,n=t.videoHeight,o=t.offsetWidth,l=t.offsetHeight,u=t.offsetLeft,f=t.offsetTop,m=window.getComputedStyle(t),p=m.objectFit,y=r/n,S=o/l;switch(p){case"none":var v=r,_=n;break;case"fill":v=o,_=l;break;default:(p==="cover"?y>S:y<S)?(_=l,v=_*y):(v=o,_=v/y),p==="scale-down"&&(v=Math.min(v,r),_=Math.min(_,n))}var[b,x]=m.objectPosition.split(" ").map((N,$)=>{const z=parseFloat(N);return N.endsWith("%")?($?l-_:o-v)*z/100:z});m=this._scanRegion.width||r,S=this._scanRegion.height||n,p=this._scanRegion.x||0;var E=this._scanRegion.y||0;y=this.$overlay.style,y.width=`${m/r*v}px`,y.height=`${S/n*_}px`,y.top=`${f+x+E/n*_}px`,n=/scaleX\(-1\)/.test(t.style.transform),y.left=`${u+(n?o-b-v:b)+(n?r-p-m:p)/r*v}px`,y.transform=t.style.transform}})}static _convertPoints(t,r){if(!r)return t;let n=r.x||0,o=r.y||0,l=r.width&&r.downScaledWidth?r.width/r.downScaledWidth:1;r=r.height&&r.downScaledHeight?r.height/r.downScaledHeight:1;for(let u of t)u.x=u.x*l+n,u.y=u.y*r+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,r=1e3/this._maxScansPerSecond;t<r&&await new Promise(o=>setTimeout(o,r-t)),this._lastScanTimestamp=Date.now();try{var n=await De.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!De._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=De.createQrEngine()),n?(this._onDecode?this._onDecode(n):this._legacyOnDecode&&this._legacyOnDecode(n.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",n.cornerPoints.map(({x:o,y:l})=>`${o},${l}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(t){t!==De.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",r=[{width:{min:1024}},{width:{min:768}},{}],n=r.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...n,...r])try{let l=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),u=this._getFacingMode(l)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:l,facingMode:u}}catch{}throw"Camera not found."}async _restartVideoStream(){let t=this._paused;await this.pause(!0)&&!t&&this._active&&await this.start()}static _stopVideoStream(t){for(let r of t.getTracks())r.stop(),t.removeTrack(r)}_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,r,n,o=!1){n=n||document.createElement("canvas");let l=r&&r.x?r.x:0,u=r&&r.y?r.y:0,f=r&&r.width?r.width:t.videoWidth||t.width,m=r&&r.height?r.height:t.videoHeight||t.height;return o||(o=r&&r.downScaledWidth?r.downScaledWidth:f,r=r&&r.downScaledHeight?r.downScaledHeight:m,n.width!==o&&(n.width=o),n.height!==r&&(n.height=r)),r=n.getContext("2d",{alpha:!1}),r.imageSmoothingEnabled=!1,r.drawImage(t,l,u,f,m,0,0,n.width,n.height),[n,r]}static async _loadImage(t){if(t instanceof Image)return await De._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 r=new Image;r.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await De._awaitImageLoad(r),r}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(r.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((r,n)=>{let o=l=>{t.removeEventListener("load",o),t.removeEventListener("error",o),l instanceof ErrorEvent?n("Image load error"):r()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,r,n,o){return De._postWorkerMessageSync(await t,r,n,o)}static _postWorkerMessageSync(t,r,n,o){if(!(t instanceof Worker))return-1;let l=De._workerMessageId++;return t.postMessage({id:l,type:r,data:n},o),l}}De.DEFAULT_CANVAS_SIZE=400;De.NO_QR_CODE_FOUND="No QR code found";De._disableBarcodeDetector=!1;De._workerMessageId=0;function MC({onResult:e,onClose:t}){const r=M.useRef(null),n=M.useRef(null),o=M.useRef(!1),[l,u]=M.useState("");M.useEffect(()=>{let m=!1;const p=r.current,y=S=>{m||o.current||(o.current=!0,e(S))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){u(w("qr-unsupported"));return}let S=!1;try{S=await De.hasCamera()}catch{S=!1}if(!S){u(w("qr-no-camera"));return}if(m||!p)return;const v=new De(p,_=>{const b=mg(_);b&&y(b)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:_=>{const b=_.videoWidth||640,x=_.videoHeight||480,E=Math.max(1,Math.round(Math.min(b,x)*.92));return{x:Math.round((b-E)/2),y:Math.round((x-E)/2),width:E,height:E,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});n.current=v;try{await v.start()}catch(_){if(m)return;const b=_&&_.name||"";u(w(b==="NotAllowedError"||b==="SecurityError"?"qr-permission":b==="NotFoundError"||b==="OverconstrainedError"||b==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{m=!0;const S=n.current;if(S){try{S.stop()}catch{}try{S.destroy()}catch{}n.current=null}const v=p,_=v&&v.srcObject;if(_&&typeof _.getTracks=="function"){for(const b of _.getTracks())try{b.stop()}catch{}try{v.srcObject=null}catch{}}}},[]);const f=async m=>{const p=m.target.files&&m.target.files[0];if(m.target.value="",!!p)try{const y=await De.scanImage(p,{returnDetailedScanResult:!0}),S=mg(y);if(!S)throw new Error("empty");o.current||(o.current=!0,e(S))}catch{u(w("pairing-qr-invalid"))}};return h.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:t,children:h.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:m=>m.stopPropagation(),children:[h.jsx("div",{className:"nc-sheet-head",children:h.jsx("b",{children:w("scan-qr")})}),h.jsx("video",{ref:r,className:"nc-qr-video",playsInline:!0,muted:!0}),l&&h.jsx("div",{className:"nc-err",role:"alert",children:l}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[w("qr-upload"),h.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:f})]}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:t,children:w("cancel")})]})]})})}const vg=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:""});function Z_({token:e,initial:t="",autoStart:r=!1,deviceDefault:n="",readonly:o=!1,onSuccess:l,onBusyChange:u}){const[f,m]=M.useState(vg),[p,y]=M.useState(!1),[S,v]=M.useState(!1),[_,b]=M.useState("idle"),[x,E]=M.useState(null),[N,$]=M.useState(""),[z,j]=M.useState(!1),U=M.useRef(kC()),O=M.useRef(new Set),F=_==="busy";M.useEffect(()=>(u&&u(F),()=>{u&&u(!1)}),[F,u]);const Z=async T=>{const Y=String(T.pairingUrl||"").trim();if(U.current.start(Y)){b("busy"),E(null),$("");try{await ES(e,xC(T,{deviceDefault:n})),b("ok"),y(!1),m(vg()),O.current=new Set,j(!1),U.current.finish(),l&&await l()}catch(Q){const G=NC(Q);E(G),b("idle"),U.current.finish(),(G.stage==="validation"||G.stage==="conflict")&&y(!0)}}},R=(T,Y=!0)=>{const{classification:Q,form:G}=gg(f,T,O.current,z),k=G.pairingUrl;if(E(null),$(""),_==="ok"&&b("idle"),m(G),Q.kind==="invalid"){E({stage:"validation",code:"bad-link",message:w("pair-invalid-link"),hint:w("pair-invalid-hint"),retryable:!0});return}if(Q.kind==="partial"){y(!0),$(Q.missing.includes("ssh")?w("pair-missing-ssh"):w("pair-missing-name"));return}Q.kind==="complete"&&Y&&!o&&U.current.canAuto(k)&&Z(G)};M.useEffect(()=>{t&&R(t,r)},[]);const H=()=>{const T=String(f.pairingUrl||"").trim(),{classification:Y,form:Q}=gg(f,T,O.current,z);if(m(Q),$(""),E(null),Y.kind==="empty"){E({stage:"validation",message:w("pairing-required"),retryable:!0});return}if(Y.kind==="invalid"){E({stage:"validation",code:"bad-link",message:w("pair-invalid-link"),hint:w("pair-invalid-hint"),retryable:!0});return}if(!Q.ssh||!Q.name){y(!0),$(Q.ssh?w("pair-missing-name"):w("pair-missing-ssh"));return}if(Q.label&&!ah(Q.label)){E({stage:"validation",message:w("err-label"),retryable:!0});return}if(Q.localLabel&&!ah(Q.localLabel)){E({stage:"validation",message:w("err-label"),retryable:!0});return}U.current.reset(T),Z(Q)},A=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const T=await navigator.clipboard.readText();T&&T.trim()?R(T):$(w("pair-clipboard-empty"))}catch{$(w("pair-clipboard-denied"))}},P=(T,Y)=>{O.current.add(T),m(Q=>({...Q,[T]:Y}))},L=x&&x.stage&&(EC.includes(x.stage)||x.stage==="internal")?w(`pair-stage-${x.stage}`):w("pair-stage-generic");return h.jsxs("div",{className:"nc-set-form nc-pair-card",children:[h.jsx("div",{className:"nc-sheet-label",children:w("pair-card-title")}),h.jsx("div",{className:"nc-set-info",children:w("pair-card-help")}),h.jsx("input",{className:"nc-pair-input",placeholder:w("pair-paste-ph"),value:f.pairingUrl,disabled:o||F,onChange:T=>{m({...f,pairingUrl:T.target.value}),E(null),$("")},onPaste:T=>{const Y=T.clipboardData&&T.clipboardData.getData("text")||"";Y.trim()&&(T.preventDefault(),R(Y))},onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),H())}}),h.jsxs("div",{className:"nc-pair-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||F,onClick:A,children:w("pair-paste-btn")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||F,onClick:()=>v(!0),children:w("scan-qr")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||F,title:o?w("settings-readonly"):"",onClick:H,children:w("test-and-connect")})]}),h.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[F&&h.jsx("div",{className:"nc-pair-progress",children:w("pair-progress")}),_==="ok"&&h.jsx("div",{className:"nc-set-test ok",children:w("node-connected")}),N&&h.jsx("div",{className:"nc-set-hint nc-pair-notice",children:N}),x&&h.jsxs("div",{className:"nc-err",role:"alert",children:[h.jsx("b",{children:L})," — ",x.message,x.hint&&h.jsx("div",{className:"nc-pair-hint",children:x.hint}),x.retryable&&h.jsx("div",{children:h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||F,onClick:H,children:w("pair-retry")})})]})]}),h.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:F,onClick:()=>y(T=>!T),children:[p?"▾":"▸"," ",w("pair-advanced")]}),p&&h.jsxs("div",{className:"nc-pair-advanced",children:[h.jsxs("label",{className:"nc-field",children:[w("node-display-label"),h.jsx("input",{placeholder:"Home Relay",value:f.label,disabled:o||F,onChange:T=>{O.current.add("label"),m(Y=>({...Y,label:T.target.value,name:z?Y.name:Ls(T.target.value)}))}})]}),h.jsxs("label",{className:"nc-field",children:[w("node-name-label"),h.jsx("input",{placeholder:w("node-name-ph"),value:f.name,disabled:o||F,onChange:T=>{j(!0),O.current.add("name"),m(Y=>({...Y,name:T.target.value?Ls(T.target.value):""}))}})]}),h.jsx("small",{className:"nc-set-hint",children:w("node-slug-hint").replace("{slug}",f.name||"home-relay")}),h.jsxs("label",{className:"nc-field",children:[w("node-ssh-label"),h.jsx("input",{placeholder:"my-relay",value:f.ssh,disabled:o||F,onChange:T=>{O.current.add("ssh"),P("ssh",T.target.value)}})]}),h.jsxs("label",{className:"nc-field",children:[w("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:w("node-ssh-port-help"),value:f.sshPort,disabled:o||F,onChange:T=>P("sshPort",T.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),h.jsxs("label",{className:"nc-field",children:[w("device-name-label"),h.jsx("input",{placeholder:n||"NexusCrew",value:f.localLabel,disabled:o||F,onChange:T=>P("localLabel",T.target.value)}),h.jsx("small",{className:"nc-set-hint",children:w("device-name-hint")})]})]}),S&&h.jsx(MC,{onResult:T=>{v(!1),R(T)},onClose:()=>v(!1)})]})}function Th(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function LC(e){const t="=".repeat((4-e.length%4)%4),r=(e+t).replace(/-/g,"+").replace(/_/g,"/"),n=atob(r),o=new Uint8Array(n.length);for(let l=0;l<n.length;l+=1)o[l]=n.charCodeAt(l);return o}async function TC(){if(!Th())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function jC(e){if(!Th())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const r=await Ct("/api/push/vapid",e),{publicKey:n}=await r.json();if(!n)throw new Error("vapid non disponibile");const l=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:LC(n)}),u=await Ct("/api/push/subscribe",e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:l.toJSON()})});if(!u.ok){try{await l.unsubscribe()}catch{}const f=await u.json().catch(()=>({}));throw new Error(f.error||`HTTP ${u.status}`)}return!0}async function BC(e){if(!Th())return!1;const r=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!r)return!1;const n=r.endpoint;try{await r.unsubscribe()}catch{}try{await Ct("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:n})})}catch{}return!0}const ev="nexuscrew.cells",tv=1,AC=/^[A-Za-z0-9._-]{1,32}$/,iv=/^[a-z0-9._-]{1,32}$/,IC=new Set(["standard","unsafe"]),OC=4096,yg=256,zC=8192,FC=32,HC=new Set(["format","version","exportedAt","cells"]),$C=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]);function Sg(e,t){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))return null;const r=Object.entries(e);if(r.length>128)return null;const n={};for(const[o,l]of r){if(!iv.test(o)||!t(l))return null;n[o]=l}return n}function rv(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(l=>!$C.has(l))||!AC.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>OC||!iv.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>yg)||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>zC)return null;const r=Sg(e.models,l=>typeof l=="string"&&!!l&&l.length<=yg),n=Sg(e.permissionPolicies,l=>IC.has(l));if(r===null||n===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(r).length&&(o.models=r),Object.keys(n).length&&(o.permissionPolicies=n),o}function WC(e,t,r=new Date){const n=t instanceof Set?t:new Set(t||[]),o=[];for(const l of Array.isArray(e)?e:[]){if(!n.has(l.id))continue;const u=rv({id:l.id,cwd:l.cwd,engine:l.engine,boot:l.boot===!0,...l.model?{model:l.model}:{},...l.models?{models:l.models}:{},...l.permissionPolicies?{permissionPolicies:l.permissionPolicies}:{},systemPrompt:l.prompt||""});u&&o.push(u)}return{format:ev,version:tv,exportedAt:r.toISOString(),cells:o}}function UC(e){let t;try{t=JSON.parse(String(e||""))}catch{return{ok:!1,error:"invalid-json",cells:[]}}if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(o=>!HC.has(o))||t.format!==ev||t.version!==tv||!Array.isArray(t.cells)||t.cells.length>FC)return{ok:!1,error:"invalid-format",cells:[]};const r=new Set,n=[];for(const o of t.cells){const l=rv(o);if(!l)return{ok:!1,error:"invalid-cell",cells:[]};if(r.has(l.id))return{ok:!1,error:"duplicate-cell",cells:[]};r.add(l.id),n.push(l)}return{ok:!0,cells:n,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function qC(e,t,r){const n=new Set(r||[]);if(!n.has(t))return null;const o=m=>Object.fromEntries(Object.entries(m||{}).filter(([p])=>n.has(p))),l={id:e.id,cwd:e.cwd,engine:t,boot:e.boot===!0,prompt:e.systemPrompt||""};t===e.engine&&e.model?l.model=e.model:e.models&&e.models[t]&&(l.model=e.models[t]);const u=o(e.models),f=o(e.permissionPolicies);return Object.keys(u).length&&(l.models=u),Object.keys(f).length&&(l.permissionPolicies=f),l}const KC=()=>({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:[]}),wg=(e="")=>({id:"",cwd:"",engine:e,boot:!1,model:"",prompt:""}),sv=e=>e==="claude"?"unsafe":"standard",Ta=(e,t)=>e.find(r=>r.client===t.client&&r.provider===t.provider&&(r.credentialProfile||"")===(t.credentialProfile||"")),VC=(e,t)=>{var r;return((r=Ta(e,t))==null?void 0:r.label)||`${t.client} · ${t.provider}`};function YC(e){var t,r,n,o,l,u,f,m,p,y,S,v,_,b;return{kind:e.managed?"managed":"custom",id:e.id,label:e.label||"",command:e.command||"",argsText:(e.args||[]).join(`
89
- `),rc:!!e.rc,client:((t=e.managed)==null?void 0:t.client)||"claude",provider:((r=e.managed)==null?void 0:r.provider)||"native",credentialProfile:((n=e.managed)==null?void 0:n.credentialProfile)||"",managedModel:((o=e.managed)==null?void 0:o.model)||"",permissionPolicy:((l=e.managed)==null?void 0:l.permissionPolicy)||sv((u=e.managed)==null?void 0:u.client),displayName:((f=e.managed)==null?void 0:f.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||((v=e.managedInfo)==null?void 0:v.models)||[],promptMode:e.promptMode||"send-keys",promptFlag:e.promptFlag||"",modelFlag:((_=e.model)==null?void 0:_.flag)||"",modelValue:((b=e.model)==null?void 0:b.value)||"",envRows:(e.envKeys||[]).map(x=>({key:x,value:"",configured:!0,remove:!1}))}}function XC(e,t,r=[]){if(e.kind==="managed"){const o={client:e.client,provider:e.provider,model:e.managedModel||"",permissionPolicy:e.permissionPolicy||sv(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile);const l=Ta(r,e);return l!=null&&l.credentialEnv&&(o.envKey=e.envKey),e.provider==="custom"&&Object.assign(o,{displayName:e.displayName,protocol:e.protocol,baseUrl:e.baseUrl,envKey:e.envKey,providerId:e.providerId}),{...t?{id:e.id}:{},label:e.label||VC(r,e),rc:!!e.rc,managed:o}}const n={...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&&(n.model={flag:e.modelFlag,value:e.modelValue||""}),e.promptMode==="flag"&&(n.promptFlag=e.promptFlag),t&&(n.env=Object.fromEntries(e.envRows.filter(o=>!o.remove&&o.key).map(o=>[o.key,o.value]))),n}function Mn({children:e,onClose:t,label:r,error:n=""}){const o=M.useRef(null),l=M.useRef(null),u=M.useRef(t);return u.current=t,M.useEffect(()=>{const f=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(v=>v.offsetParent!==null),y=requestAnimationFrame(()=>{var v;return(v=p()[0]||m)==null?void 0:v.focus({preventScroll:!0})}),S=v=>{var E;if(v.key==="Escape"){v.preventDefault(),(E=u.current)==null||E.call(u);return}if(v.key!=="Tab")return;const _=p();if(!_.length){v.preventDefault(),m==null||m.focus();return}const b=_[0],x=_[_.length-1];v.shiftKey&&document.activeElement===b?(v.preventDefault(),x.focus()):!v.shiftKey&&document.activeElement===x&&(v.preventDefault(),b.focus())};return document.addEventListener("keydown",S),()=>{cancelAnimationFrame(y),document.removeEventListener("keydown",S),f&&f.isConnected&&typeof f.focus=="function"&&f.focus({preventScroll:!0})}},[]),M.useEffect(()=>{n&&requestAnimationFrame(()=>{var f;return(f=l.current)==null?void 0:f.scrollIntoView({block:"nearest"})})},[n]),h.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:f=>{f.target===f.currentTarget&&t()},children:h.jsxs("div",{ref:o,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":r||w("settings"),tabIndex:-1,children:[e,n&&h.jsx("div",{ref:l,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:n})]})})}function GC({token:e,readonly:t,targets:r=[],startNewCell:n=!1,initialLocation:o=""}){const[l,u]=M.useState({engines:[],cells:[],managedCatalog:[]}),[f,m]=M.useState({available:!1,capabilities:[]}),[p,y]=M.useState(null),[S,v]=M.useState(null),[_,b]=M.useState(!1),[x,E]=M.useState(""),[N,$]=M.useState(""),[z,j]=M.useState(o),[U,O]=M.useState(!1),[F,Z]=M.useState(null),[R,H]=M.useState(null),[A,P]=M.useState(!1),L=M.useRef(!1),T=z?z.split("/"):[],Y=M.useCallback(async()=>{try{const ee=await es(e,T);m(ee);try{const ge=await Og(e,T);O(!!ge.readonlyDefault)}catch{O(!1)}if(ee.provider==="builtin"&&(ee.capabilities||[]).includes("definitions")){const ge=await mh(e,T),Ee=new Map((ee.engines||[]).map(Be=>[Be.id,Be]));ge.engines=(ge.engines||[]).map(Be=>{var Ce;return{...Be,availableModels:((Ce=Ee.get(Be.id))==null?void 0:Ce.models)||[]}}),u(ge)}}catch(ee){E(String(ee.message||ee))}},[e,z]);M.useEffect(()=>{Y();const ee=setInterval(Y,5e3);return()=>clearInterval(ee)},[Y]);const Q=new Set((f.cells||[]).filter(ee=>ee.active).map(ee=>ee.cell)),G=f.provider==="builtin"&&(f.capabilities||[]).includes("edit"),k=(f.capabilities||[]).includes("restore");M.useEffect(()=>{!n||L.current||!G||!l.engines.length||(L.current=!0,v({mode:"new",form:wg(l.engines[0].id)}))},[n,G,l.engines]);const V=async ee=>{b(!0),E(""),$("");try{await ee(),await Y()}catch(ge){E(String(ge.message||ge))}b(!1)},re=()=>V(async()=>{const ee=p.mode==="new",ge=XC(p.form,ee,l.managedCatalog||[]);!ee&&p.form.kind==="custom"&&!p.form.modelFlag&&(ge.model=null),!ee&&p.form.kind==="custom"&&p.form.promptMode!=="flag"&&(ge.promptFlag=null);let Ee;if(ee)Ee=await _S(e,ge,T);else{const Ce=p.original,it=new Set(p.form.envRows.filter(Je=>!Je.remove).map(Je=>Je.key)),ut=(Ce.envKeys||[]).filter(Je=>!it.has(Je)),Pt=Object.fromEntries(p.form.envRows.filter(Je=>!Je.remove&&Je.key&&(!Je.configured||Je.value!=="")).map(Je=>[Je.key,Je.value]));Ee=await vS(e,Ce.id,ge,p.form.kind==="custom"?{set:Pt,remove:ut}:void 0,T)}y(null),$(w("fleet-saved"));const Be=(Ee==null?void 0:Ee.activeCells)||[];if(Be.length&&window.confirm(w("fleet-restart-confirm").replace("{cells}",Be.join(", "))))for(const Ce of Be)await da(e,Ce,T)}),I=()=>V(async()=>{const ee=S.mode==="new",ge=S.form,Ee={...ee?{id:ge.id}:{},cwd:ge.cwd,engine:ge.engine,boot:!!ge.boot};ee?(ge.model&&(Ee.model=ge.model),ge.prompt&&(Ee.prompt=ge.prompt)):(Ee.model=ge.model||null,Ee.prompt=ge.prompt||null);const Be=ee?await SS(e,Ee,T):await wS(e,S.original.id,Ee,T),Ce=ee?ge.id:S.original.id;v(null),$(w("fleet-saved")),!ee&&(Be!=null&&Be.active)&&window.confirm(w("fleet-restart-confirm").replace("{cells}",Ce))&&await da(e,Ce,T)}),K=t||U,ne=ee=>Z({...ee,route:Array.isArray(ee==null?void 0:ee.route)?ee.route:T}),B=async ee=>{if(!F)return;const ge=F.cell||F.id,Ee=Array.isArray(F.route)?F.route:T;ee.action==="up"?await ph(e,{cell:ge,boot:!!ee.boot,...ee.engine?{engine:ee.engine}:{},...ee.model!==void 0?{model:ee.model}:{},...ee.permissionPolicy?{permissionPolicy:ee.permissionPolicy}:{}},Ee):await Sa(e,{cell:ge,boot:!!ee.boot},Ee)},se=(ee,ge)=>{E(""),H({mode:"new",route:Array.isArray(ge)?ge:T,form:{tmuxSession:ee.name,id:"",engine:"",cwd:"",boot:!1},err:""})},ae=()=>V(async()=>{const ee=R.form;if(!ee.engine){H({...R,err:w("import-engine-required")});return}await bS(e,{tmuxSession:ee.tmuxSession,id:ee.id||void 0,engine:ee.engine,cwd:ee.cwd||void 0,boot:!!ee.boot},ee.route||T),H(null),$(w("fleet-saved"))}),me=ee=>V(async()=>{const ge=l.engines.map(ut=>ut.id),Ee=[];for(const ut of ee){const Pt=qC(ut.cell,ut.engine,ge);if(!Pt)throw new Error(`${ut.cell.id}: ${w("fleet-backup-engine-missing")}`);Ee.push(Pt)}const Be=ee.filter(ut=>ut.exists).map(ut=>ut.cell.id);if(Be.length&&!window.confirm(w("fleet-backup-confirm-overwrite").replace("{cells}",Be.join(", "))))return;const it=(await CS(e,Ee,T)).needsRestart||[];P(!1),$(`${w("fleet-backup-restored").replace("{n}",String(ee.length))}${it.length?` · ${w("fleet-backup-needs-restart").replace("{cells}",it.join(", "))}`:""}`)}),ue=h.jsxs("label",{className:"nc-field",children:[w("location"),h.jsxs("select",{value:z,onChange:ee=>{j(ee.target.value),y(null),v(null),E(""),$(""),O(!1),m({available:!1,capabilities:[]}),u({engines:[],cells:[],managedCatalog:[]})},children:[h.jsx("option",{value:"",children:w("local")}),r.map(ee=>h.jsxs("option",{value:ee.route.join("/"),disabled:ee.status&&ee.status!=="up",children:[ee.label,ee.status&&ee.status!=="up"?` · ${w("node-offline")}`:""]},ee.route.join("/")))]})]});return G?h.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[ue,h.jsx(bg,{token:e,targets:r,readonly:t,onPower:ne,onImport:se}),h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:w("fleet-engines")}),h.jsxs("button",{className:"nc-btn primary",disabled:K||_,onClick:()=>{E(""),y({mode:"new",form:KC()})},children:["+ ",w("add")]})]}),l.engines.map(ee=>{var ge,Ee;return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:ee.label}),h.jsx("small",{children:ee.managed?`${ee.id} · ${ee.managed.client} / ${ee.managed.provider} · ${(ge=ee.managedInfo)!=null&&ge.configured?w("fleet-ready"):((Ee=ee.managedInfo)==null?void 0:Ee.reason)||w("fleet-not-ready")}`:`${ee.id} · ${ee.command}`})]}),h.jsxs("span",{children:[h.jsx("button",{className:"nc-btn ghost",disabled:K||_,onClick:()=>{E(""),y({mode:"edit",original:ee,form:YC(ee)})},children:w("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:K||_,onClick:()=>V(async()=>{window.confirm(w("fleet-remove-engine").replace("{id}",ee.id))&&await yS(e,ee.id,T)}),children:"×"})]})]},ee.id)}),p&&h.jsx(Mn,{onClose:()=>y(null),label:w("fleet-new-engine"),error:x,children:h.jsx(JC,{state:p,setState:y,busy:_,onSave:re,catalog:l.managedCatalog||[]})}),h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:w("fleet-cells")}),h.jsxs("span",{className:"nc-fleet-head-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:K||_,onClick:()=>{E(""),P(!0)},children:w("fleet-backup")}),h.jsxs("button",{className:"nc-btn primary",disabled:K||_||!l.engines.length,onClick:()=>{var ee;E(""),v({mode:"new",form:wg((ee=l.engines[0])==null?void 0:ee.id)})},children:["+ ",w("add")]})]})]}),l.cells.map(ee=>{const ge=Q.has(ee.id),Ee=f.capabilities||[];return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:ee.id}),h.jsxs("small",{children:[ee.engine," · ",ee.cwd,ge?` · ${w("service-active")}`:` · ${w("cell-off")}`]})]}),h.jsxs("span",{children:[ge&&Ee.includes("down")&&h.jsx("button",{className:"nc-btn ghost",disabled:K||_,onClick:()=>V(()=>Sa(e,{cell:ee.id},T)),children:w("stop")}),!ge&&Ee.includes("up")&&h.jsx("button",{className:"nc-btn primary",disabled:K||_,onClick:()=>ne({cell:ee.id,id:ee.id,engine:ee.engine,model:ee.model,models:ee.models,permissionPolicies:ee.permissionPolicies,active:!1,boot:ee.boot}),children:w("start")}),ge&&Ee.includes("restart")&&h.jsx("button",{className:"nc-btn ghost",disabled:K||_,onClick:()=>V(()=>da(e,ee.id,T)),children:w("restart")}),h.jsx("button",{className:"nc-btn ghost",disabled:K||_,onClick:()=>{E(""),v({mode:"edit",original:ee,form:{...ee}})},children:w("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:K||_,onClick:()=>V(async()=>{window.confirm(w("fleet-remove-cell").replace("{id}",ee.id))&&await Tg(e,ee.id,!0,T)}),children:"×"})]})]},ee.id)}),S&&h.jsx(Mn,{onClose:()=>v(null),label:w("fleet-new-cell"),error:x,children:h.jsx(ZC,{token:e,route:T,targets:r,location:z,setLocation:j,state:S,setState:v,engines:l.engines,busy:_,onSave:I})}),N&&h.jsx("div",{className:"nc-set-note",children:N}),x&&h.jsx("div",{className:"nc-err",children:x}),A&&h.jsx(Mn,{onClose:()=>P(!1),label:w("fleet-backup"),error:x,children:h.jsx(QC,{cells:l.cells,engines:l.engines,busy:_,canRestore:k,onRestore:me,onClose:()=>P(!1)})}),R&&h.jsx(Mn,{onClose:()=>H(null),label:w("import-as-cell"),error:x,children:h.jsx(Cg,{token:e,route:R.route||T,state:R,setState:H,busy:_,onSave:ae})}),F&&h.jsx(wa,{cell:F,token:e,route:Array.isArray(F.route)?F.route:T,onConfirm:async ee=>{try{await B(ee)}finally{await Y()}},onClose:()=>Z(null)})]}):h.jsxs("div",{className:"nc-set-tab",children:[ue,h.jsx(bg,{token:e,targets:r,readonly:t,onPower:ne,onImport:se}),h.jsx("div",{className:"nc-set-info",children:w("fleet-editor-unavailable")}),x&&h.jsx("div",{className:"nc-err",children:x}),R&&h.jsx(Mn,{onClose:()=>H(null),label:w("import-as-cell"),error:x,children:h.jsx(Cg,{token:e,route:R.route||T,state:R,setState:H,busy:_,onSave:ae})}),F&&h.jsx(wa,{cell:F,token:e,route:Array.isArray(F.route)?F.route:T,onConfirm:async ee=>{try{await B(ee)}finally{await Y()}},onClose:()=>Z(null)})]})}function bg({token:e,targets:t=[],readonly:r=!1,onPower:n,onImport:o}){const[l,u]=M.useState([]),[f,m]=M.useState(0);M.useEffect(()=>{let E=!0;async function N(){const z=[{route:[],label:w("local")}].concat((t||[]).map(U=>({route:Array.isArray(U.route)?U.route:[],label:U.label||(U.route||[]).join(" › ")}))),j=await Promise.all(z.map(async U=>{const O={...U,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const F=await es(e,U.route);O.available=!!F.available,O.capabilities=F.capabilities||[],O.provider=F.provider||null,O.cells=(F.cells||[]).map(Z=>({...Z,route:U.route}));try{O.readonly=!!(await Og(e,U.route)).readonlyDefault}catch{}try{const Z=await Ig(e,U.route),R=new Set(O.cells.map(H=>H.tmuxSession).filter(Boolean));O.unmanaged=(Z.sessions||[]).filter(H=>H&&!R.has(H.name))}catch{}}catch(F){O.err=String(F&&F.message||F)}return O}));E&&u(j)}N();const $=setInterval(N,6e3);return()=>{E=!1,clearInterval($)}},[e,t,f]);const p=(E,N)=>Array.isArray(E.capabilities)&&E.capabilities.includes(N)&&!r&&!E.readonly,y=()=>m(E=>E+1),S=(E,N)=>{n&&n({...E,route:N})},v=(E,N)=>{n&&n({...E,route:N})},_=async(E,N)=>{try{await da(e,E.cell,N)}catch{}y()},b=async(E,N)=>{if(window.confirm(w("fleet-remove-cell").replace("{id}",E.cell))){try{await Tg(e,E.cell,!0,N)}catch{}y()}},x=async(E,N)=>{if(window.confirm(w("terminate-confirm").replace("{name}",E.name))){try{await gh(e,E.name,N)}catch{}y()}};return h.jsxs("div",{className:"nc-fleet-inventory",children:[h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:w("fleet-inventory")}),h.jsx("small",{children:w("fleet-inventory-help")})]}),l.map(E=>{const N=E.route.length?E.route.join("/"):"local";return h.jsxs("div",{className:"nc-fleet-pos",children:[h.jsxs("div",{className:"nc-fleet-pos-title",children:[h.jsx("span",{className:`dot ${E.available?"on":"warn"}`}),h.jsx("b",{children:E.label}),h.jsx("small",{children:E.available?`${E.cells.length} ${w("fleet-cells")} · ${E.unmanaged.length} ${w("fleet-tmux")}`:E.err||w("fleet-not-available")})]}),E.cells.map($=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[h.jsxs("span",{children:[h.jsx("b",{children:$.cell}),h.jsx("small",{children:`${$.engine||""}${$.key?`·${$.key}`:""}${$.active?"":` · ${w("cell-off")}`}`})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[$.active&&p(E,"down")&&h.jsx("button",{className:"nc-btn ghost",title:w("power-off"),onClick:()=>v($,E.route),children:w("stop")}),!$.active&&p(E,"up")&&h.jsx("button",{className:"nc-btn ghost",title:w("power-on"),onClick:()=>S($,E.route),children:w("start")}),p(E,"restart")&&$.active&&h.jsx("button",{className:"nc-btn ghost",title:w("restart"),onClick:()=>_($,E.route),children:w("restart")}),p(E,"remove")&&h.jsx("button",{className:"nc-btn danger",title:w("delete"),onClick:()=>b($,E.route),children:"×"})]})]},`${N}:${$.cell}`)),E.unmanaged.map($=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[h.jsxs("span",{children:[h.jsx("b",{children:$.name}),h.jsx("small",{children:w("fleet-tmux")})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[p(E,"import")&&o&&h.jsx("button",{className:"nc-btn ghost",title:w("import-as-cell"),onClick:()=>o($,E.route),children:w("import-as-cell")}),h.jsx("button",{className:"nc-btn danger",title:w("terminate"),onClick:()=>x($,E.route),children:"×"})]})]},`${N}:u:${$.name}`)),E.available&&E.cells.length===0&&E.unmanaged.length===0&&h.jsx("div",{className:"nc-empty",children:w("fleet-inventory-empty")})]},N)})]})}function QC({cells:e=[],engines:t=[],busy:r,canRestore:n=!1,onRestore:o,onClose:l}){const[u,f]=M.useState("export"),[m,p]=M.useState(()=>new Set(e.map(U=>U.id))),[y,S]=M.useState([]),[v,_]=M.useState(""),b=t.map(U=>U.id),x=new Set(e.map(U=>U.id)),E=U=>p(O=>{const F=new Set(O);return F.has(U)?F.delete(U):F.add(U),F}),N=()=>{const U=WC(e,m);if(!U.cells.length){_(w("fleet-backup-select-one"));return}const O=new Blob([`${JSON.stringify(U,null,2)}
91
- `],{type:"application/json"}),F=URL.createObjectURL(O),Z=document.createElement("a");Z.href=F,Z.download=`nexuscrew-cells-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(Z),Z.click(),Z.remove(),setTimeout(()=>URL.revokeObjectURL(F),0),_("")},$=async U=>{if(_(""),S([]),!!U){if(U.size>1024*1024){_(w("fleet-backup-too-large"));return}try{const O=UC(await U.text());if(!O.ok){_(w(`fleet-backup-${O.error}`));return}S(O.cells.map(F=>{const Z=b.includes(F.engine),R=x.has(F.id);return{cell:F,engine:Z?F.engine:"",selected:Z&&!R,exists:R}}))}catch(O){_(String(O.message||O))}}},z=(U,O)=>S(F=>F.map((Z,R)=>R===U?{...Z,...O}:Z)),j=y.filter(U=>U.selected&&U.engine);return h.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[h.jsx("b",{children:w("fleet-backup")}),h.jsx("small",{children:w("fleet-backup-help")}),h.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[h.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="export"?" on":""}`,onClick:()=>{f("export"),_("")},children:w("fleet-backup-export")}),h.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="import"?" on":""}`,disabled:!n,title:n?"":w("fleet-backup-restore-unavailable"),onClick:()=>{f("import"),_("")},children:w("fleet-backup-import")})]}),u==="export"?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>p(new Set(e.map(U=>U.id))),children:w("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>p(new Set),children:w("select-none")})]}),h.jsxs("div",{className:"nc-backup-list",children:[e.map(U=>h.jsxs("label",{className:"nc-check nc-backup-row",children:[h.jsx("input",{type:"checkbox",checked:m.has(U.id),onChange:()=>E(U.id)}),h.jsxs("span",{children:[h.jsx("b",{children:U.id}),h.jsxs("small",{children:[U.engine," · ",w("fleet-system-prompt")," ",(U.prompt||"").length," ",w("characters")]})]})]},U.id)),!e.length&&h.jsx("div",{className:"nc-empty",children:w("fleet-backup-empty")})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:w("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:!m.size,onClick:N,children:w("fleet-backup-download")})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"file",accept:"application/json,.json",disabled:r,onChange:U=>$(U.target.files&&U.target.files[0])}),h.jsx("small",{children:w("fleet-backup-import-help")}),!!y.length&&h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>S(U=>U.map(O=>({...O,selected:!!O.engine}))),children:w("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>S(U=>U.map(O=>({...O,selected:!1}))),children:w("select-none")})]}),h.jsx("div",{className:"nc-backup-list",children:y.map((U,O)=>h.jsxs("div",{className:"nc-backup-import-row",children:[h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:U.selected,disabled:!U.engine,onChange:F=>z(O,{selected:F.target.checked})}),h.jsxs("span",{children:[h.jsx("b",{children:U.cell.id}),h.jsxs("small",{children:[U.exists?w("fleet-backup-overwrite"):w("fleet-backup-new")," · ",w("fleet-system-prompt")," ",U.cell.systemPrompt.length," ",w("characters")]})]})]}),h.jsxs("select",{value:U.engine,onChange:F=>z(O,{engine:F.target.value,selected:!!F.target.value}),children:[h.jsx("option",{value:"",children:w("fleet-backup-engine-missing")}),t.map(F=>h.jsx("option",{value:F.id,children:F.label||F.id},F.id))]})]},U.cell.id))}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:w("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:r||!j.length,onClick:()=>o(j),children:w("fleet-backup-restore")})]})]}),v&&h.jsx("div",{className:"nc-err",children:v})]})}function JC({state:e,setState:t,busy:r,onSave:n,catalog:o}){var v;const l=e.form,u=_=>t({...e,form:{...l,..._}}),f=l.envRows||[],m=[...new Map(o.map(_=>[_.client,_.clientLabel||_.client])).entries()],p=o.filter(_=>_.client===l.client),y=Ta(o,l),S=_=>{_&&u({client:_.client,provider:_.provider,credentialProfile:_.credentialProfile||"",managedModel:_.model||"",protocol:_.protocol||"",permissionPolicy:_.permissionPolicyDefault||"standard",rc:!!_.rc,displayName:_.custom?w("fleet-custom-provider-default"):"",baseUrl:_.custom?"":_.endpoint||"",envKey:_.defaultEnvKey||"",providerId:"nexuscrew-custom",...e.mode==="new"?{id:_.id,label:""}:{}})};return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsx("b",{children:e.mode==="new"?w("fleet-new-engine"):`${w("edit")} ${l.id}`}),h.jsx("input",{value:l.id,disabled:e.mode!=="new",placeholder:"id",onChange:_=>u({id:_.target.value})}),h.jsx("input",{value:l.label,placeholder:w("label"),onChange:_=>u({label:_.target.value})}),h.jsxs("select",{value:l.kind,disabled:e.mode!=="new",onChange:_=>u({kind:_.target.value}),children:[h.jsx("option",{value:"managed",children:w("fleet-managed")}),h.jsx("option",{value:"custom",children:w("fleet-custom")})]}),l.kind==="managed"?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("select",{value:l.client,disabled:e.mode!=="new",onChange:_=>S(o.find(b=>b.client===_.target.value&&b.default)||o.find(b=>b.client===_.target.value)),children:m.map(([_,b])=>h.jsx("option",{value:_,children:b},_))}),h.jsx("select",{value:((v=Ta(o,l))==null?void 0:v.id)||"",disabled:e.mode!=="new",onChange:_=>S(o.find(b=>b.id===_.target.value)),children:p.map(_=>h.jsx("option",{value:_.id,children:_.label},_.id))})]}),h.jsx("input",{value:l.managedModel,list:"nc-managed-models",placeholder:w(y!=null&&y.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:_=>u({managedModel:_.target.value})}),h.jsx("datalist",{id:"nc-managed-models",children:[...(y==null?void 0:y.models)||[],...l.modelOptions||[]].filter((_,b,x)=>_&&x.indexOf(_)===b).map(_=>h.jsx("option",{value:_},_))}),y!=null&&y.supportsUnsafe?h.jsxs("select",{value:l.permissionPolicy,onChange:_=>u({permissionPolicy:_.target.value}),children:[h.jsx("option",{value:"standard",children:w("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:w("fleet-unsafe-permissions")})]}):h.jsx("small",{children:w("fleet-standard-permissions")}),(y==null?void 0:y.supportsUnsafe)&&l.permissionPolicy==="unsafe"&&h.jsx("small",{className:"nc-err",children:w("fleet-unsafe-warning")}),(y==null?void 0:y.credentialEnv)&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.envKey,placeholder:w("fleet-api-key-env"),onChange:_=>u({envKey:_.target.value})}),h.jsx("small",{children:w("fleet-custom-secret-help")})]}),l.provider==="custom"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.displayName,placeholder:w("fleet-provider-display"),onChange:_=>u({displayName:_.target.value})}),h.jsx("input",{value:l.baseUrl,placeholder:"https://api.example.com/v1",onChange:_=>u({baseUrl:_.target.value})}),((y==null?void 0:y.protocols)||[]).length>1&&h.jsx("select",{value:l.protocol,onChange:_=>u({protocol:_.target.value}),children:y.protocols.map(_=>h.jsx("option",{value:_,children:_},_))}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:l.envKey,placeholder:w("fleet-api-key-env"),onChange:_=>u({envKey:_.target.value})}),h.jsx("input",{value:l.providerId,placeholder:w("fleet-provider-id"),onChange:_=>u({providerId:_.target.value})})]}),h.jsxs("small",{children:[l.protocol," · ",w("fleet-custom-secret-help")]})]}),h.jsx("small",{children:w("fleet-managed-help")})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.command,placeholder:w("command-path"),onChange:_=>u({command:_.target.value})}),h.jsx("textarea",{value:l.argsText,placeholder:w("args-lines"),onChange:_=>u({argsText:_.target.value})}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:l.rc,onChange:_=>u({rc:_.target.checked})})," remote control"]}),h.jsxs("select",{value:l.promptMode,onChange:_=>u({promptMode:_.target.value}),children:[h.jsx("option",{value:"send-keys",children:"send-keys"}),h.jsx("option",{value:"flag",children:"flag"})]}),l.promptMode==="flag"&&h.jsx("input",{value:l.promptFlag,placeholder:"prompt flag",onChange:_=>u({promptFlag:_.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:l.modelFlag,placeholder:"model flag",onChange:_=>u({modelFlag:_.target.value})}),h.jsx("input",{value:l.modelValue,placeholder:"model default",onChange:_=>u({modelValue:_.target.value})})]}),h.jsx("small",{children:w("env-write-only")}),f.map((_,b)=>h.jsxs("div",{className:"nc-fleet-env",children:[h.jsx("input",{value:_.key,disabled:_.configured,placeholder:"ENV_KEY",onChange:x=>{const E=f.slice();E[b]={..._,key:x.target.value},u({envRows:E})}}),h.jsx("input",{type:"password",value:_.value,placeholder:_.configured?"•••••• (unchanged)":"value",onChange:x=>{const E=f.slice();E[b]={..._,value:x.target.value},u({envRows:E})}}),h.jsx("button",{className:"nc-btn danger",onClick:()=>u({envRows:f.filter((x,E)=>E!==b)}),children:"×"})]},`${_.key}-${b}`)),h.jsx("button",{className:"nc-btn ghost",onClick:()=>u({envRows:[...f,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>t(null),children:w("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:r||!l.id||l.kind==="custom"&&!l.command||l.kind==="managed"&&(y==null?void 0:y.requiresModel)&&!l.managedModel||l.kind==="managed"&&(y==null?void 0:y.credentialEnv)&&!l.envKey||l.kind==="managed"&&l.provider==="custom"&&(!l.displayName||!l.baseUrl||!l.envKey||!l.providerId),onClick:n,children:w("save")})]})]})}function ZC({token:e,route:t,targets:r=[],location:n,setLocation:o,state:l,setState:u,engines:f,busy:m,onSave:p}){const[y,S]=M.useState(null),[v,_]=M.useState(""),b=l.form,x=z=>u({...l,form:{...b,...z}}),E=f.find(z=>z.id===b.engine),N=z=>{var U,O,F;const j=f.find(Z=>Z.id===z);x({engine:z,model:((U=b.models)==null?void 0:U[z])||((O=j==null?void 0:j.managed)==null?void 0:O.model)||((F=j==null?void 0:j.model)==null?void 0:F.value)||""})},$=async z=>{try{const j=await jg(e,z,t);S(j),x({cwd:j.path}),_("")}catch(j){_(String(j.message||j))}};return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsx("b",{children:l.mode==="new"?w("fleet-new-cell"):`${w("edit")} ${b.id}`}),l.mode==="new"&&h.jsxs("label",{className:"nc-field",children:[w("location"),h.jsx("span",{className:"nc-req",children:" *"}),h.jsxs("select",{value:n,onChange:z=>{o(z.target.value),x({engine:""})},children:[h.jsx("option",{value:"",children:w("local")}),r.map(z=>h.jsxs("option",{value:z.route.join("/"),disabled:z.status&&z.status!=="up",children:[z.label,z.status&&z.status!=="up"?` · ${w("node-offline")}`:""]},z.route.join("/")))]})]}),h.jsx("input",{value:b.id,disabled:l.mode!=="new",placeholder:"id",onChange:z=>x({id:z.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:b.cwd,placeholder:w("cwd"),onChange:z=>x({cwd:z.target.value})}),h.jsx("button",{className:"nc-btn ghost",onClick:()=>y?S(null):$(b.cwd),children:w("browse")})]}),y&&h.jsxs("div",{className:"nc-fs",children:[h.jsx("div",{className:"nc-fs-path",children:y.path}),h.jsxs("div",{className:"nc-fs-list",children:[y.parent&&h.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>$(y.parent),children:["↑ ",w("fs-parent")]}),(y.dirs||[]).map(z=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>$(`${y.path.replace(/\/$/,"")}/${z}`),children:["📁 ",z]},z))]})]}),v&&h.jsx("div",{className:"nc-err",children:v}),h.jsx("select",{value:b.engine,onChange:z=>N(z.target.value),children:f.map(z=>h.jsx("option",{value:z.id,children:z.label},z.id))}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:!!b.boot,onChange:z=>x({boot:z.target.checked})})," boot"]}),h.jsx("input",{value:b.model||"",list:"nc-cell-models",placeholder:w("fleet-model-override"),onChange:z=>x({model:z.target.value})}),h.jsx("datalist",{id:"nc-cell-models",children:((E==null?void 0:E.availableModels)||[]).map(z=>h.jsx("option",{value:z},z))}),h.jsx("textarea",{value:b.prompt||"",placeholder:"prompt",onChange:z=>x({prompt:z.target.value})}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>u(null),children:w("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:m||!b.id||!b.cwd||!b.engine,onClick:p,children:w("save")})]})]})}function Cg({token:e,route:t=[],state:r,setState:n,busy:o,onSave:l}){const[u,f]=M.useState(null),[m,p]=M.useState([]),[y,S]=M.useState(""),v=Array.isArray(t)?t.join("/"):"";M.useEffect(()=>{let N=!0;return mh(e,v?v.split("/"):[]).then($=>{N&&(p($.engines||[]),S(""))}).catch($=>{N&&(p([]),S(String($.message||$)))}),()=>{N=!1}},[e,v]);const _=r.form,b=N=>n({...r,form:{..._,...N}}),x=async N=>{try{const $=await jg(e,N,t);f($),b({cwd:$.path})}catch{}},E=!_.id&&_.tmuxSession?_.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):_.id;return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsxs("b",{children:[w("import-as-cell")," · ",_.tmuxSession]}),h.jsx("small",{children:w("import-help")}),h.jsx("input",{value:_.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),h.jsx("input",{value:_.id,placeholder:w("name"),onChange:N=>b({id:N.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:_.cwd,placeholder:w("cwd"),onChange:N=>b({cwd:N.target.value})}),h.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>u?f(null):x(_.cwd),children:w("browse")})]}),u&&h.jsxs("div",{className:"nc-fs",children:[h.jsx("div",{className:"nc-fs-path",children:u.path}),h.jsxs("div",{className:"nc-fs-list",children:[u.parent&&h.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>x(u.parent),children:["↑ ",w("fs-parent")]}),(u.dirs||[]).map(N=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>x(`${u.path.replace(/\/$/,"")}/${N}`),children:["📁 ",N]},N))]})]}),h.jsxs("select",{value:_.engine,onChange:N=>b({engine:N.target.value}),children:[h.jsx("option",{value:"",children:w("import-engine-required")}),m.map(N=>h.jsx("option",{value:N.id,children:N.label},N.id))]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:!!_.boot,onChange:N=>b({boot:N.target.checked})})," boot"]}),(r.err||y)&&h.jsx("div",{className:"nc-err",children:r.err||y}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>n(null),children:w("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:o||!_.tmuxSession||!_.engine||!m.length,onClick:l,children:w(E?"import-as-cell":"save")})]})]})}function ex({text:e}){const[t,r]=M.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)}catch{}};return h.jsxs("div",{className:"nc-set-copyline",children:[h.jsx("code",{children:e}),h.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:n,children:[h.jsx(Oe,{name:"copy",size:14})," ",w(t?"copied":"copy")]})]})}function tx({value:e}){const[t,r]=M.useState("");return M.useEffect(()=>{let n=!0;return lC.toDataURL(e,{margin:1,width:220}).then(o=>{n&&r(o)}).catch(()=>{}),()=>{n=!1}},[e]),t?h.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function ix({token:e,nodes:t,settings:r,readonly:n,refresh:o}){const[l,u]=M.useState(null),[f,m]=M.useState(null),[p,y]=M.useState({}),[S,v]=M.useState(null),[_,b]=M.useState({ssh:"",sshPort:"",name:""}),[x,E]=M.useState(""),[N,$]=M.useState(!1),z=Date.now(),j=r&&r.deviceName||"",U=!!(r&&r.rendezvous&&r.rendezvous.ssh),O=async(R,H)=>{u(null),m(`${R}:${H}`);try{const A=await _h(e,R,H);H==="test"&&y(P=>({...P,[R]:A})),await o()}catch(A){u(`${R}: ${String(A.message||A)}`)}m(null)},F=async R=>{if(window.confirm(w("node-remove-confirm").replace("{name}",R))){u(null),m(`${R}:remove`);try{await PS(e,R),await o()}catch(H){u(`${R}: ${String(H.message||H)}`)}m(null)}},Z=async()=>{var P;u(null);const R=Ls(_.name||x||j||"NexusCrew"),H=((P=r==null?void 0:r.rendezvous)==null?void 0:P.ssh)||"",A=pC({name:R,ssh:_.ssh||H,sshPort:_.sshPort});if(!A.ok){u(w(A.error));return}m("invite");try{v(await NS(e,{...x||j?{label:x||j}:{},name:R,..._.ssh.trim()?{ssh:A.value.ssh}:{},...A.value.sshPort?{sshPort:A.value.sshPort}:{}}))}catch(L){u(String(L.message||L))}m(null)};return h.jsxs("div",{className:"nc-set-tab",children:[h.jsx(Z_,{token:e,deviceDefault:j,readonly:n,onSuccess:o}),(t||[]).length===0&&h.jsx("div",{className:"nc-empty",children:w("no-nodes")}),(t||[]).map(R=>{var P,L,T,Y;const H=gC(R.tunnel,z),A=p[R.name];return h.jsxs("div",{className:"nc-set-node",children:[h.jsxs("div",{className:"nc-set-node-head",children:[h.jsx("span",{className:`nc-dot ${H.up?"on":""}`}),h.jsx("b",{children:R.label||R.name}),h.jsxs("small",{children:[R.name," · ",R.ssh,R.sshPort?`:${R.sshPort}`:""," · :",R.localPort,"→:",R.remotePort]}),h.jsxs("span",{className:`nc-set-tunnel${H.up?" up":""}`,children:[w(H.label),H.since?` · ${H.since}`:""]}),h.jsxs("select",{value:R.visibility||"network",disabled:n||!!f,onChange:async Q=>{m(`${R.name}:visibility`);try{await Rp(e,R.name,Q.target.value),await o()}catch(G){u(String(G.message||G))}m(null)},children:[h.jsx("option",{value:"network",children:w("visibility-network")}),h.jsx("option",{value:"relay-only",children:w("visibility-relay")}),h.jsx("option",{value:"selected",children:w("visibility-selected")})]})]}),R.visibility==="selected"&&h.jsx("div",{className:"nc-set-row",children:(t||[]).filter(Q=>Q.name!==R.name&&Q.nodeId).map(Q=>{const G=(R.selected||[]).includes(Q.nodeId);return h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:G,disabled:n||!!f,onChange:async k=>{const V=k.target.checked?[...R.selected||[],Q.nodeId]:(R.selected||[]).filter(re=>re!==Q.nodeId);m(`${R.name}:visibility`);try{await Rp(e,R.name,"selected",V),await o()}catch(re){u(String(re.message||re))}m(null)}})," ",Q.name]},Q.nodeId)})}),h.jsxs("div",{className:"nc-set-node-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||!!f,onClick:async()=>{const Q=window.prompt(w("node-display-label"),R.label||R.name);if(Q!=null){if(!ah(Q)){u(w("err-label"));return}m(`${R.name}:label`);try{await RS(e,R.name,Q),await o()}catch(G){u(String(G.message||G))}m(null)}},children:w("edit")}),((P=R.health)==null?void 0:P.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>O(R.name,"test"),children:w("node-test")}),((L=R.health)==null?void 0:L.managed)!==!1&&(H.up?h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>O(R.name,"down"),children:w("tunnel-stop")}):h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>O(R.name,"up"),children:w("tunnel-start")})),((T=R.health)==null?void 0:T.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>O(R.name,"restart"),children:w("tunnel-restart")}),h.jsx("button",{type:"button",className:"nc-btn danger",disabled:n||!!f,title:w(n?"settings-readonly":"terminate"),onClick:()=>F(R.name),children:h.jsx(Oe,{name:"trash",size:14})})]}),((Y=R.health)==null?void 0:Y.detail)&&h.jsx("div",{className:`nc-set-test${R.health.status==="healthy"?" ok":R.health.status==="passive"?"":" ko"}`,children:R.health.detail}),A&&h.jsxs("div",{className:`nc-set-test${A.ok?" ok":" ko"}`,children:[A.result,A.detail?` — ${A.detail}`:""]})]},R.name)}),h.jsxs("div",{className:"nc-set-form",children:[h.jsx("div",{className:"nc-sheet-label",children:w("invite-node")}),h.jsx("small",{className:"nc-set-hint",children:w("invite-v2-hint")}),U&&!N?h.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[w("invite-endpoint-auto"),": ",h.jsx("b",{children:r.rendezvous.ssh}),r.rendezvous.publishedPort?` · Nexus :${r.rendezvous.publishedPort}`:""]}):h.jsxs("label",{className:"nc-field",children:[w("invite-endpoint-label"),h.jsx("input",{placeholder:"user@host",value:_.ssh,disabled:n,onChange:R=>b({..._,ssh:R.target.value})}),h.jsx("small",{className:"nc-set-hint",children:w("invite-endpoint-needed")})]}),N&&h.jsxs("div",{className:"nc-invite-advanced",children:[h.jsxs("label",{className:"nc-field",children:[w("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:"22",value:_.sshPort,disabled:n,onChange:R=>b({..._,sshPort:R.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),h.jsxs("label",{className:"nc-field",children:[w("device-name-label"),h.jsx("input",{placeholder:j||"NexusCrew",value:x,disabled:n,onChange:R=>E(R.target.value)}),h.jsx("small",{className:"nc-set-hint",children:w("device-name-hint")})]}),h.jsxs("label",{className:"nc-field",children:[w("node-name-label"),h.jsx("input",{placeholder:Ls(x||j||w("node-name-ph")),value:_.name,disabled:n,onChange:R=>b({..._,name:R.target.value?Ls(R.target.value):""})})]})]}),h.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[h.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||!!f||!U&&!_.ssh.trim(),onClick:Z,children:w("create-pairing-link")}),h.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>$(R=>!R),children:[N?"▾":"▸"," ",w("pair-advanced")]})]}),S&&h.jsxs(h.Fragment,{children:[h.jsx(tx,{value:S.pairingUrl}),h.jsx(ex,{text:S.pairingUrl}),h.jsx("div",{className:"nc-set-info",children:w("invite-next-steps")})]})]}),l&&h.jsx("div",{className:"nc-err",children:l})]})}function rx({token:e,readonly:t}){const[r,n]=M.useState("idle"),[o,l]=M.useState(!1),[u,f]=M.useState(null);M.useEffect(()=>{let p=!1;return TC().then(y=>{p||n(y)}),()=>{p=!0}},[]);const m=async()=>{f(null),l(!0);try{r==="subscribed"?(await BC(e),n("idle")):(await jC(e),n("subscribed"))}catch(p){const y=String(p.message||p);y==="push-denied"?(n("denied"),f(w("push-denied"))):y==="push-unsupported"?(n("unsupported"),f(w("push-unsupported"))):f(y)}l(!1)};return r==="unsupported"?h.jsx("div",{className:"nc-set-info",children:w("push-unsupported")}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||o||r==="denied",title:t?w("settings-readonly"):"",onClick:m,children:w(r==="subscribed"?"push-disable":"push-enable")}),h.jsx("span",{className:"nc-set-info",children:w(r==="subscribed"?"push-on":r==="denied"?"push-denied":"push-off")})]}),u&&h.jsx("div",{className:"nc-err",children:u})]})}function sx({token:e,settings:t,readonly:r,refresh:n}){const[o,l]=M.useState(null),[u,f]=M.useState(null),[m,p]=M.useState(!1),[y,S]=M.useState(!1),[v,_]=M.useState(null),[b,x]=M.useState(!0);M.useEffect(()=>{_(t&&t.update||null),x(!t||t.autoUpdate!==!1)},[t]);const E=async()=>{l(null),f(null),S(!0);try{const O=await kS(e);f(O.note||"ok"),p(!1)}catch(O){l(String(O.message||O))}S(!1)},N=async()=>{l(null),f(null),S(!0);try{const O=await DS(e);f(`${O.note||"ok"}${O.target?` (${O.target})`:""}`)}catch(O){l(String(O.message||O))}S(!1)},$=async O=>{l(null),f(null),S(!0);try{await zg(e,{autoUpdate:O}),x(O),n&&await n()}catch(F){l(String(F.message||F))}S(!1)},z=async()=>{l(null),f(null),S(!0);try{_(await MS(e))}catch(O){l(String(O.message||O))}S(!1)},j=async()=>{l(null),f(null),S(!0);try{const O=await LS(e);_(O),f(w("npm-update-restarting"))}catch(O){l(String(O.message||O))}S(!1)},U=t&&t.service;return h.jsxs("div",{className:"nc-set-tab",children:[t&&h.jsxs("div",{className:"nc-set-info",children:["v",t.version," · ",t.platform," · :",t.port,h.jsx("br",{}),U&&U.installed?w("service-installed"):w("service-missing"),U&&U.installed?` · ${U.active?w("service-active"):w("service-inactive")}`:"",U?` · boot ${U.boot?"on":"off"}`:""]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:r||y,title:r?w("settings-readonly"):"",onClick:()=>{l(null),f(null),p(!0)},children:w("token-rotate")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:r||y,title:r?w("settings-readonly"):"",onClick:N,children:w("service-regenerate")})]}),h.jsxs("div",{className:"nc-set-form nc-update-settings",children:[h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:b,disabled:r||y||v&&!v.supported,onChange:O=>$(O.target.checked)}),h.jsxs("span",{children:[h.jsx("b",{children:w("npm-auto-update")}),h.jsx("small",{children:w("npm-auto-update-help")})]})]}),v&&h.jsxs("div",{className:"nc-set-info",children:[w("npm-update-current")," v",v.current,v.latest?` · ${w("npm-update-latest")} v${v.latest}`:""," · ",w(`npm-update-${v.supported?v.phase:"unsupported"}`)]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:r||y||!v||!v.supported,onClick:z,children:w("npm-update-check")}),v&&v.available&&h.jsx("button",{type:"button",className:"nc-btn primary",disabled:r||y||v.phase==="installing",onClick:j,children:w("npm-update-install")})]}),v&&v.lastError&&h.jsx("div",{className:"nc-err",children:v.lastError})]}),h.jsx(rx,{token:e,readonly:r}),m&&h.jsxs("div",{className:"nc-set-confirm",children:[h.jsx("div",{children:w("token-rotate-explain")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:y,onClick:()=>p(!1),children:w("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:y,onClick:E,children:w("confirm")})]})]}),u&&h.jsx("div",{className:"nc-set-note",children:u}),o&&h.jsx("div",{className:"nc-err",children:o})]})}function nx({token:e,onClose:t,initialTab:r="nodes",initialLocation:n="",startNewCell:o=!1}){ai();const[l,u]=M.useState(r),[f,m]=M.useState(null),[p,y]=M.useState([]),[S,v]=M.useState(!1),[_,b]=M.useState(null),x=yh(e),E=M.useCallback(async()=>{try{const N=await Bg(e);m(N),b(null)}catch(N){b(String(N.message||N))}try{const N=await Ag(e);y(N.nodes||[])}catch(N){b(String(N.message||N))}},[e]);return M.useEffect(()=>{E();const N=setInterval(E,5e3);return()=>clearInterval(N)},[E]),M.useEffect(()=>{let N=!1;return Ct("/api/config",e).then($=>$.json()).then($=>{N||v(!!$.readonlyDefault)}).catch(()=>{}),()=>{N=!0}},[e]),h.jsx("div",{className:"nc-set-overlay",onClick:t,children:h.jsxs("div",{className:"nc-set-panel",onClick:N=>N.stopPropagation(),children:[h.jsxs("div",{className:"nc-set-head",children:[h.jsx(Oe,{name:"gear",size:18}),h.jsx("b",{children:w("settings")}),h.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:w("close"),children:h.jsx(Oe,{name:"x",size:18})})]}),S&&h.jsx("div",{className:"nc-set-readonly",children:w("settings-readonly")}),_&&h.jsx("div",{className:"nc-err",children:_}),h.jsx("div",{className:"nc-set-tabs",children:["nodes","fleet","system"].map(N=>h.jsx("button",{type:"button",className:`nc-set-tabbtn${l===N?" on":""}`,onClick:()=>u(N),children:w(`tab-${N}`)},N))}),h.jsxs("div",{className:"nc-set-body",children:[l==="nodes"&&h.jsx(ix,{token:e,nodes:p,settings:f,readonly:S,refresh:E}),l==="fleet"&&h.jsx(GC,{token:e,readonly:S,startNewCell:o,initialLocation:n,targets:x.map(N=>({route:N.route,label:N.label||N.name,status:N.status}))}),l==="system"&&h.jsx(sx,{token:e,settings:f,readonly:S,refresh:E})]})]})})}function ox({token:e,initialPair:t,onPairDone:r,onDone:n}){ai();const[o,l]=M.useState(t?"pair":"welcome"),[u,f]=M.useState(!1),[m,p]=M.useState(null),y=async()=>{f(!0),p(null);try{await zg(e,{wizardDone:!0}),r&&r(),n()}catch(S){p(String(S.message||S)),f(!1)}};return h.jsx("div",{className:"nc-wiz-overlay",children:h.jsxs("div",{className:"nc-wiz",children:[h.jsxs("div",{className:"nc-wiz-head",children:[h.jsx("b",{children:w("wizard-title")}),h.jsx("small",{children:w("hydra-simple")})]}),o==="welcome"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:w("local-ready")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:u,onClick:y,children:w("local-only")}),h.jsx("button",{className:"nc-btn primary",disabled:u,onClick:()=>l("pair"),children:w("add-node")})]})]}),o==="pair"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx(Z_,{token:e,initial:t||"",autoStart:!!t,onBusyChange:f,onSuccess:async()=>{r&&r(),l("done")}}),h.jsx("div",{className:"nc-sheet-actions",children:h.jsx("button",{className:"nc-btn ghost",disabled:u,onClick:()=>{r&&r(),l("welcome")},children:w("back")})})]}),o==="done"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:w("node-connected")}),h.jsx("div",{className:"nc-sheet-actions",children:h.jsx("button",{className:"nc-btn primary",disabled:u,onClick:y,children:w("finish")})})]}),m&&h.jsx("div",{className:"nc-err",children:m})]})})}function ax(e,t){if(typeof EventSource>"u"||!e)return()=>{};const r=new EventSource(`/api/events?token=${encodeURIComponent(e)}`);return r.onmessage=n=>{try{const o=JSON.parse(n.data);o&&typeof o=="object"&&typeof o.type=="string"&&t(o)}catch{}},()=>{try{r.close()}catch{}}}const lx=6e3,cx=12e3;function ux({n:e,onClose:t}){return h.jsxs("div",{className:`nc-ntf-toast${e.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[h.jsxs("div",{className:"nc-ntf-toast-txt",children:[h.jsx("b",{children:e.title}),e.body&&h.jsx("small",{children:e.body}),e.session&&h.jsx("span",{className:"nc-ntf-from",children:e.session})]}),h.jsx("button",{type:"button",className:"nc-ntf-x",onClick:t,title:w("close"),children:h.jsx(Oe,{name:"x",size:14})})]})}function hx({ask:e,token:t,onAnswered:r}){const[n,o]=M.useState(""),[l,u]=M.useState(!1),[f,m]=M.useState(null),p=async y=>{const S=String(y||"").trim();if(!(!S||l)){m(null),u(!0);try{await jS(t,e.id,S),r(e.id)}catch(v){m(String(v.message||v))}u(!1)}};return h.jsxs("div",{className:"nc-ask-card",children:[h.jsxs("div",{className:"nc-ask-head",children:[h.jsx("span",{className:"nc-ntf-from",children:e.session}),h.jsxs("code",{className:"nc-ask-id",children:["#",e.id]})]}),h.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&h.jsx("div",{className:"nc-ask-opts",children:e.options.map(y=>h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:l,onClick:()=>p(y),children:y},y))}),h.jsxs("div",{className:"nc-ask-reply",children:[h.jsx("textarea",{rows:2,placeholder:w("ask-reply-ph"),value:n,disabled:l,onChange:y=>o(y.target.value)}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:l||!n.trim(),onClick:()=>p(n),children:w("send")})]}),f&&h.jsx("div",{className:"nc-err",children:f})]})}function dx({token:e}){ai();const[t,r]=M.useState([]),[n,o]=M.useState([]),[l,u]=M.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),f=M.useRef(0),m=M.useCallback(S=>{r(v=>v.filter(_=>_.key!==S))},[]),p=M.useCallback(S=>{const v=`t${f.current+=1}`;r(_=>[..._.slice(-3),{...S,key:v}]),setTimeout(()=>m(v),S.urgency==="high"?cx:lx)},[m]);M.useEffect(()=>{if(!e)return;let S=!1;TS(e).then(_=>{S||o(_.asks||[])}).catch(()=>{});const v=ax(e,_=>{_.type==="notify"?p(_):_.type==="ask"&&_.ask&&_.ask.id?o(b=>b.some(x=>x.id===_.ask.id)?b:[...b,_.ask]):_.type==="ask-answered"&&_.id&&o(b=>b.filter(x=>x.id!==_.id))});return()=>{S=!0,v()}},[e,p]);const y=S=>o(v=>v.filter(_=>_.id!==S));return h.jsxs(h.Fragment,{children:[t.length>0&&h.jsx("div",{className:"nc-ntf-toasts",children:t.map(S=>h.jsx(ux,{n:S,onClose:()=>m(S.key)},S.key))}),n.length>0&&!l&&h.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>u(!0),title:w("asks-title"),children:["? ",h.jsx("span",{className:"nc-ask-count",children:n.length})]}),n.length>0&&l&&h.jsxs("div",{className:"nc-ask-panel",children:[h.jsxs("div",{className:"nc-ask-panel-head",children:[h.jsx("b",{children:w("asks-title")}),h.jsx("span",{className:"nc-ask-count",children:n.length}),h.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>u(!1),title:w("close"),children:h.jsx(Oe,{name:"x",size:16})})]}),h.jsx("div",{className:"nc-ask-panel-body",children:n.map(S=>h.jsx(hx,{ask:S,token:e,onAnswered:y},S.id))})]})]})}const vu=e=>Pi(Hi(e)).length===0;function fx(e,t,r,n){const[o,l]=M.useState([]),[u,f]=M.useState(!1),[m,p]=M.useState("idle"),[y,S]=M.useState(""),v=M.useRef([]),_=M.useRef(t),b=M.useRef(r),x=M.useRef(!1),E=M.useRef(!0);b.current=r,_.current=t,v.current=o;const N=M.useCallback((R,H=!0,A=_.current)=>{v.current=R,l(R);const P=R.find(L=>L.name===A);H&&P&&(E.current=!0,n(Hi(P.layout)),Ob(A,P.layout)),Ib(R.map(L=>L.name))},[n]),$=M.useCallback(async()=>{let R=await Dc(e);const H=R.decks.find(A=>A.name==="main");if(R.decks.length===1&&H&&H.revision===0&&vu(H.layout)){const A=Ab(),P=Hi(oh("main")||Da());if(!vu(P)){const L=await ra(e,"main",P,0);R.decks[0]=L}for(const L of A.filter(T=>T!=="main"))try{let T=await Pp(e,L);const Y=Hi(oh(L)||Da());vu(Y)||(T=await ra(e,L,Y,T.revision)),R.decks.push(T)}catch{}R=await Dc(e)}N(R.decks,!0),f(!0),S("")},[e,N]);M.useEffect(()=>{e&&$().catch(R=>S(String(R.message||R)))},[$,e]);const z=M.useCallback(async(R=_.current)=>{if(!u||!x.current)return!0;const H=v.current.find(A=>A.name===R);if(!H)return S(`deck inesistente: ${R}`),!1;p("saving");try{const A=await ra(e,R,Hi(b.current),H.revision);return N(v.current.map(P=>P.name===R?A:P),!1),x.current=!1,p("saved"),S(""),setTimeout(()=>p("idle"),1500),!0}catch(A){return p("error"),S(String(A.message||A)),A.status===409&&A.data&&A.data.current&&N(v.current.map(P=>P.name===R?A.data.current:P),!1),!1}},[u,e,N]);M.useEffect(()=>{if(!u)return;if(E.current){E.current=!1;return}x.current=!0,p("saving");const R=setTimeout(z,650);return()=>clearTimeout(R)},[r,u,z]),M.useEffect(()=>{if(!u)return;const R=setInterval(async()=>{try{const H=await Dc(e),A=v.current.find(T=>T.name===t),P=H.decks.find(T=>T.name===t),L=P&&(!A||P.revision>A.revision);N(H.decks,L&&!x.current)}catch{}},5e3);return()=>clearInterval(R)},[u,e,t,N]);const j=async R=>{const H=await Pp(e,R);return N([...v.current,H],!1),H},U=async(R,H)=>{if(!v.current.find(T=>T.name===R))throw new Error("deck inesistente");if(R===_.current&&x.current&&!await z(R))throw new Error(`salvataggio di "${R}" fallito: rinomina annullata`);const P=v.current.find(T=>T.name===R);if(!P)throw new Error("deck inesistente");const L=await BS(e,R,H,P.revision);return N(v.current.map(T=>T.name===R?L:T),!1),L},O=async R=>{const H=v.current.find(A=>A.name===R);if(!H)throw new Error("deck inesistente");R===_.current&&(x.current=!1),await AS(e,R,H.revision),N(v.current.filter(A=>A.name!==R),!1)},F=async(R,H)=>{const A=v.current.find(L=>L.name===R);if(!A)throw new Error("deck inesistente");const P=await ra(e,R,$_(Hi(A.layout),H),A.revision);return N(v.current.map(L=>L.name===R?P:L),!1),P},Z=async R=>{if(x.current&&!await z(_.current))throw new Error(`salvataggio di "${_.current}" fallito: cambio deck annullato`);const H=v.current.find(A=>A.name===R);if(!H)throw new Error(`deck inesistente: ${R}`);return x.current=!1,E.current=!0,Hi(H.layout)};return{decks:o.map(R=>R.name),records:o,ready:u,saveState:m,error:y,setError:S,saveNow:z,select:Z,add:j,rename:U,remove:O,addTileTo:F}}const px="/sw.js",lh="nc-sw-update";let ch=null,uh=!1,hh=null,nv=Object.freeze({needed:!1,kind:null,version:""}),ov=!1;function av(){typeof window<"u"&&window.dispatchEvent(new Event(lh))}function lv(){const e=hh||(uh?{kind:"reload",version:""}:null);nv=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function xg(){return nv}function mx(e){return typeof window>"u"?()=>{}:(window.addEventListener(lh,e),()=>window.removeEventListener(lh,e))}function jh(e){uh!==e&&(uh=e,lv(),av())}function gx(e,t,r){let n=null;e&&t&&e!==t?n={kind:"install",version:e}:t&&r&&t!==r&&(n={kind:"reload",version:t});const o=JSON.stringify(n)===JSON.stringify(hh);hh=n,lv(),o||av()}function _x(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&jh(!0)})}function vx(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{ov&&location.reload()}),navigator.serviceWorker.register(px).then(e=>{ch=e,e.waiting&&jh(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&_x(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function yx(){ov=!0,jh(!1);const e=ch&&ch.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function Sx({hash:e="",origin:t="",pathname:r="",search:n=""}={}){const o=String(e||"").replace(/^#/,""),l=`${r||""}${n||""}`;if(!o)return{token:"",pair:"",nextUrl:l};const u=new URLSearchParams(o),f=u.get("token")||"",m=u.get("pair")||"",p=m?`${t||""}${r||""}#pair=${m}`:"";return{token:f,pair:p,nextUrl:l}}const cv=9,uv=24,hv="nc_side_w",kg="nc_side_min",wx=240,Eg="(min-width:1024px) and (pointer:fine)";function bx(){const e=Number(localStorage.getItem(hv));return e>=180&&e<=480?e:wx}function Cx(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=cv&&e<=uv?e:13}function xx(){const e={token:"",pair:""};try{const{token:t,pair:r,nextUrl:n}=Sx({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(r){e.pair=r;try{sessionStorage.setItem("nc_pair",r)}catch{}}if(location.hash)try{history.replaceState(null,"",n)}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 kx(e){try{return Hi(oh(e))}catch{return Da()}}function Ng(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 Ex(){const[e,t]=M.useState(()=>window.matchMedia(Eg).matches);return M.useEffect(()=>{const r=window.matchMedia(Eg),n=o=>t(o.matches);return r.addEventListener("change",n),()=>r.removeEventListener("change",n)},[]),e}function Rg({session:e,node:t,token:r,readonly:n=!1,onBack:o}){ai();const[l,u]=M.useState(!1),[f,m]=M.useState(()=>window.matchMedia("(pointer: coarse)").matches),[p,y]=M.useState(null),[S,v]=M.useState(Cx),[_,b]=M.useState(""),x=R=>v(H=>{const A=Math.max(cv,Math.min(uv,H+R));return localStorage.setItem("nc_fontsize",String(A)),A}),E=M.useRef(()=>{}),N=M.useRef(()=>!1),$=M.useRef(()=>{}),z=M.useRef(!1),[j,U]=M.useState(!1),[O,F]=M.useState(!1),Z=()=>{z.current=!z.current,U(z.current)};return M.useEffect(()=>{let R=!0;const H=t?t.split("/"):[],A=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function P(){let T=null,Y=null;try{const k=await(await Ct(`${A}/sessions`,r)).json();Array.isArray(k.sessions)&&(T=k.sessions.find(V=>V.name===e))}catch{}try{const G=await es(r,H);G.available&&Array.isArray(G.cells)&&(Y=G.cells.find(k=>k.tmuxSession===e))}catch{}if(!R)return;let Q="";Y?Q=`${Y.engine}${Y.key?`·${Y.key}`:""}`:T&&(Q=T.attached?`attached · ${Ng(T.activity)}`:T.activity?Ng(T.activity):""),b(Q)}P();const L=setInterval(P,4e3);return()=>{R=!1,clearInterval(L)}},[e,t,r]),h.jsxs("div",{className:"nc-app",children:[h.jsxs("header",{className:"nc-bar nc-bar-single",children:[h.jsxs("button",{onClick:o,title:w("sessions"),children:[h.jsx(Oe,{name:"chevronLeft",size:18}),h.jsx("span",{className:"nc-bar-label",children:w("sessions")})]}),h.jsxs("span",{className:"nc-bar-center",children:[h.jsx("b",{children:t?`${t}:${e}`:e}),_&&h.jsx("small",{className:"nc-bar-sub",children:_})]}),h.jsxs("span",{className:"nc-bar-right",children:[h.jsx("button",{onClick:()=>x(-1),title:w("zoom-out"),children:h.jsx(Oe,{name:"zoomOut",size:18})}),h.jsx("button",{onClick:()=>x(1),title:w("zoom-in"),children:h.jsx(Oe,{name:"zoomIn",size:18})}),h.jsx("button",{onClick:()=>m(R=>!R),title:w("composer"),children:h.jsx(Oe,{name:"keyboard",size:20})}),h.jsx("button",{onClick:()=>u(R=>!R),title:w("files"),children:h.jsx(Oe,{name:"folder",size:20})})]})]}),h.jsx("div",{className:"nc-termwrap",children:h.jsx(I_,{session:e,node:t,token:r,readonly:n,takeSize:!0,sendRef:E,composerRef:N,actionRef:$,ctrlRef:z,setCtrlArmed:U,onFiles:y,fontSize:S,selectionMode:O,onSelectionModeChange:F})}),h.jsx(mb,{onKeyboard:()=>m(R=>!R),send:R=>E.current(R),action:R=>$.current(R),ctrlArmed:j,onCtrl:Z,selectionMode:O,onSelectionMode:F}),f&&h.jsx(z_,{submitText:R=>N.current(R),token:r,session:e,node:t}),l&&h.jsx(O_,{session:e,node:t,token:r,filesEvent:p,onClose:()=>u(!1)})]})}function Nx(){ai();const[e]=M.useState(xx),[t,r]=M.useState(e.token),[n,o]=M.useState(e.pair||""),l=M.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[u,f]=M.useState(!1),m=Ex(),[p,y]=M.useState(()=>Bb(typeof location<"u"?location.pathname:"/")),S=p===si,[v,_]=M.useState(null),b=X=>_(js(X)),[x,E]=M.useState([]),[N,$]=M.useState([]),[z,j]=M.useState(()=>kx(p)),U=fx(t,p,z,j),O=U.decks.length?U.decks:[si],[F,Z]=M.useState(null),[R,H]=M.useState(null),A=X=>H(js(X)),P=yh(t,m);M.useEffect(()=>{const X=new Map;for(const pe of P||[]){const Ne=(pe.route||[pe.name]).join("/"),He=new Set((pe.sessions||[]).map(rt=>rt.name));for(const rt of pe.cells||[])!rt.cell||!rt.tmuxSession||rt.cell===rt.tmuxSession||He.has(rt.cell)||X.set(`${Ne}:${rt.cell}`,`${Ne}:${rt.tmuxSession}`)}j(pe=>kb(pe,X))},[P]);const[L,T]=M.useState(null),[Y,Q]=M.useState(!1),[G,k]=M.useState(bx),[V,re]=M.useState(!S),[I,K]=M.useState(()=>S?localStorage.getItem(kg)==="1":!0),[ne,B]=M.useState(!1),[se,ae]=M.useState("nodes"),[me,ue]=M.useState(!1),[ee,ge]=M.useState(""),Ee=(X="nodes",pe=!1,Ne="")=>{ae(X),ue(pe),ge(Ne),B(!0)},[Be,Ce]=M.useState(!1),[it,ut]=M.useState(!1);M.useEffect(()=>{try{localStorage.setItem(hv,String(G))}catch{}},[G]),M.useEffect(()=>{try{localStorage.setItem(kg,I?"1":"")}catch{}},[I]),M.useEffect(()=>{if(!t)return;let X=!1;return Promise.all([Bg(t),Ct("/api/config",t).then(pe=>pe.json())]).then(([pe,Ne])=>{X||(ut(!!Ne.readonlyDefault),(pe.firstRun===!0&&!Ne.readonlyDefault||n)&&Ce(!0))}).catch(()=>{}),()=>{X=!0}},[t,n]);const Pt=M.useCallback(async()=>{try{const pe=await(await Ct("/api/sessions",t)).json();pe.error||E(pe.sessions||[])}catch{}try{const X=await es(t);$(X.available?X.cells||[]:[])}catch{$([])}},[t]);M.useEffect(()=>{if(!m)return;Pt();const X=setInterval(Pt,4e3);return()=>clearInterval(X)},[m,Pt]),M.useEffect(()=>{let X=!1;return Ct("/api/config",t).then(pe=>pe.json()).then(pe=>{X||gx(pe.version,pe.uiVersion,"0.8.9")}).catch(()=>{}),()=>{X=!0}},[t]);const Je=new Set([...x.map(X=>X.name),...P.flatMap(X=>X.sessions.map(pe=>pe.key))]),qi=Pi(z),vi=X=>j(pe=>{const Ne=$_(pe,X);return Ne===pe&&!Pi(pe).includes(typeof X=="string"?X:"")&&Pi(pe).length>=9&&U.setError(w("grid-full")),Ne}),Di=async(X,pe=[])=>{try{await gh(t,X,pe)}catch{return}const Ne=pe.length?`${pe.join("/")}:${X}`:X;j(He=>Ma(He,Ne)),Pt()},yi=async X=>{if(!L)return;const{cell:pe}=L,Ne=Array.isArray(L.route)?L.route:[];X.action==="up"?await ph(t,{cell:pe,boot:!!X.boot,...X.engine?{engine:X.engine}:{},...X.model!==void 0?{model:X.model}:{},...X.permissionPolicy?{permissionPolicy:X.permissionPolicy}:{}},Ne):await Sa(t,{cell:pe,boot:!!X.boot},Ne),Pt()},Xt=async X=>{if(!(!(X!=null&&X.direct)||Y)){Q(!0);try{await _h(t,X.name,X.tunnelStatus==="up"?"down":"up")}finally{Q(!1)}}},Mr=X=>{try{const pe=window.open(Yc(X,t),"_blank");return pe&&(pe.opener=null),!!pe}catch{return!1}},Ki=async X=>{if(!X||X===p)return;const pe=await U.select(X);y(X),j(pe),Z(null),H(null);try{history.replaceState(null,"",Yc(X,null))}catch{}},Lr=async X=>{await U.add(X),await Ki(X)},Tr=async(X,pe)=>{const Ne=await U.rename(X,pe);if(X===p){y(pe),j(Hi(Ne.layout)),Z(null),H(null);try{history.replaceState(null,"",Yc(pe,null))}catch{}}},Gt=async X=>{await U.remove(X),X===p&&await Ki(si)},Qt=async(X,pe)=>{!pe||pe===p||(await U.addTileTo(pe,X),j(Ne=>Ma(Ne,X)))};if(!t)return h.jsxs("div",{className:"nc-auth",children:[h.jsx("p",{children:w("auth-prompt")}),h.jsx("input",{onChange:X=>r(X.target.value.trim()),placeholder:"token"}),h.jsxs("label",{children:[h.jsx("input",{type:"checkbox",checked:u,onChange:X=>f(X.target.checked)})," ",w("remember-device")]}),h.jsx("button",{onClick:()=>{(u?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const Si=h.jsxs(h.Fragment,{children:[ne&&h.jsx(nx,{token:t,initialTab:se,initialLocation:ee,startNewCell:me,onClose:()=>{B(!1),ue(!1),ge("")}}),Be&&h.jsx(ox,{token:t,initialPair:n,onPairDone:l,onDone:()=>Ce(!1)}),h.jsx(dx,{token:t})]});if(!m)return v?h.jsxs(h.Fragment,{children:[h.jsx(Rg,{session:v.session,node:v.node,token:t,readonly:it,onBack:()=>_(null)}),Si]}):h.jsxs(h.Fragment,{children:[h.jsx(US,{onPick:b,token:t,onSettings:Ee}),Si]});const Ft=S||!V;return h.jsxs("div",{className:"nc-workspace",children:[Ft&&h.jsx(Sb,{sessions:x,cells:N,activeSessions:qi,nodeGroups:P,onPick:A,onAddTile:vi,onPower:T,onNodePower:Xt,onKill:Di,onNew:()=>Ee("fleet",!0),onSettings:Ee,width:G,collapsed:I,onResize:k,onToggleCollapse:()=>K(X=>!X)}),h.jsxs("div",{className:"nc-workspace-main",children:[h.jsx(zb,{decks:O,currentDeck:p,onCreate:Lr,onRename:Tr,onDelete:Gt,onOpenWindow:Mr,onNavigate:Ki,saveState:U.saveState,error:U.error,sidebarVisible:Ft,onToggleSidebar:S?null:()=>re(X=>!X)}),h.jsx(Lb,{layout:z,onLayoutChange:j,token:t,readonly:it,sessionsAlive:Je,focusSession:F,onFocus:Z,onOpenSingle:A,decks:O,currentDeck:p,onSendToDeck:Qt})]}),R&&h.jsx("div",{className:"nc-single-overlay",children:h.jsx(Rg,{session:R.session,node:R.node,token:t,readonly:it,onBack:()=>H(null)})}),L&&h.jsx(wa,{cell:L,token:t,route:Array.isArray(L.route)?L.route:[],onConfirm:yi,onClose:()=>T(null)}),Si]})}function Rx(){ai();const e=M.useSyncExternalStore(mx,xg,xg);if(!e.needed)return null;const t=e.kind==="install"?w("install-version-mismatch").replace("{v}",e.version):w("update-available").replace("{v}",e.version).replace(" "," ").trim();return h.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[h.jsx("span",{className:"nc-update-msg",children:t}),e.kind==="reload"&&h.jsx("button",{className:"nc-update-btn",onClick:yx,children:w("reload")})]})}vx();gS.createRoot(document.getElementById("root")).render(h.jsxs(cS.StrictMode,{children:[h.jsx(Nx,{}),h.jsx(Rx,{})]}));